-
Notifications
You must be signed in to change notification settings - Fork 37
Import Graph Debugging
When explain_file shows no callers or imports, the import graph may not be populated correctly.
Use the built-in diagnostics tool:
# Summary of import graph
node sigmap-diagnostics.js --summary
# Analyze specific file
node sigmap-diagnostics.js --file src/models/account.py
# Search for files matching pattern
node sigmap-diagnostics.js --grep scheduler
# Verbose output
node sigmap-diagnostics.js --file src/models/account.py --verboseExpected output:
- Shows files that import the target file
- Shows what the file imports
- Summary stats on detected edges
Symptom: Files with from models.account import Account show no imports
Fix: Ensure v6.10.10+ (latest version with R language support)
npm install -g sigmap@latestVerify:
sigmap --version
# Should be 6.10.10 or laterSymptom: Python package structure not recognized
Check:
find src -name "__init__.py" | wc -lFix: Add __init__.py to all package directories:
src/models/__init__.py
src/services/__init__.pySymptom: from ...utils import helper not resolved
Debug:
sigmap-diagnostics.js --file src/deep/nested/module.py --verboseFix: Ensure srcDirs includes the root:
{
"srcDirs": ["src"]
}Symptom: Import graph includes npm/pip packages
Filter: Check .contextignore excludes node_modules/, site-packages/
mkdir test-import
cd test-import
mkdir src/models src/services
cat > src/models/account.py << 'EOF'
class Account:
def __init__(self, name):
self.name = name
EOF
cat > src/services/scheduler.py << 'EOF'
from models.account import Account
def process_accounts():
return Account('test')
EOF
cat > src/models/__init__.py << 'EOF'
EOF
cat > src/services/__init__.py << 'EOF'
EOF
cat > package.json << 'EOF'
{"name": "test"}
EOF
# Generate and test
node gen-context.js
node sigmap-diagnostics.js --file src/models/account.py
# Should show: scheduler.py imports account.pyAfter diagnostics show imports are detected:
node -e "
const { explainFile } = require('./src/mcp/handlers.js');
const result = explainFile({ path: 'src/models/account.py' }, process.cwd());
console.log(result);
" | grep -A 10 "## Callers"
# Should show files that import account.pyLarge import graphs (5000+ edges) can be slow:
# Benchmark import analysis
time node sigmap-diagnostics.js --summaryIf >5 seconds, consider:
- Excluding generated code
- Using per-module strategy
- Limiting srcDirs
The following patterns are now detected:
✅ from models.account import Account
✅ from services.scheduler import process_accounts
✅ from services.auth.oauth import get_token
✅ Relative imports: from . import sibling
✅ Relative imports: from .. import parent
❌ Star imports: from models import * (security)
❌ Dynamic imports: __import__('models.account')
-
Run full diagnostics:
sigmap-diagnostics.js --file <problem-file> --verbose
-
Check Testing Guide
-
Open issue with:
- Output of
node sigmap-diagnostics.js --summary - File structure (sample tree)
- Actual imports in files
- Output of