contextpro-mcp 0.0.0-stage → 1.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +425 -0
- package/INSTALL.md +218 -0
- package/INSTRUCTIONS.md +33 -0
- package/LICENSE +21 -0
- package/NOTICE +12 -0
- package/README.md +89 -2
- package/SECURITY.md +29 -0
- package/agent-guide.md +354 -0
- package/agent-instructions.md +1 -0
- package/build/core/agent-setup.d.ts +5 -0
- package/build/core/agent-setup.d.ts.map +1 -0
- package/build/core/agent-setup.js +95 -0
- package/build/core/agent-setup.js.map +1 -0
- package/build/core/artifacts.d.ts +64 -0
- package/build/core/artifacts.d.ts.map +1 -0
- package/build/core/artifacts.js +370 -0
- package/build/core/artifacts.js.map +1 -0
- package/build/core/bounded-source.d.ts +15 -0
- package/build/core/bounded-source.d.ts.map +1 -0
- package/build/core/bounded-source.js +78 -0
- package/build/core/bounded-source.js.map +1 -0
- package/build/core/changed-since.d.ts +20 -0
- package/build/core/changed-since.d.ts.map +1 -0
- package/build/core/changed-since.js +43 -0
- package/build/core/changed-since.js.map +1 -0
- package/build/core/chat-model.d.ts +8 -0
- package/build/core/chat-model.d.ts.map +1 -0
- package/build/core/chat-model.js +135 -0
- package/build/core/chat-model.js.map +1 -0
- package/build/core/clustering.d.ts +6 -0
- package/build/core/clustering.d.ts.map +1 -0
- package/build/core/clustering.js +201 -0
- package/build/core/clustering.js.map +1 -0
- package/build/core/context-metadata.d.ts +50 -0
- package/build/core/context-metadata.d.ts.map +1 -0
- package/build/core/context-metadata.js +118 -0
- package/build/core/context-metadata.js.map +1 -0
- package/build/core/data-dir.d.ts +5 -0
- package/build/core/data-dir.d.ts.map +1 -0
- package/build/core/data-dir.js +61 -0
- package/build/core/data-dir.js.map +1 -0
- package/build/core/db-native.d.ts +28 -0
- package/build/core/db-native.d.ts.map +1 -0
- package/build/core/db-native.js +120 -0
- package/build/core/db-native.js.map +1 -0
- package/build/core/db.d.ts +294 -0
- package/build/core/db.d.ts.map +1 -0
- package/build/core/db.js +1047 -0
- package/build/core/db.js.map +1 -0
- package/build/core/doctor.d.ts +13 -0
- package/build/core/doctor.d.ts.map +1 -0
- package/build/core/doctor.js +55 -0
- package/build/core/doctor.js.map +1 -0
- package/build/core/efficiency.d.ts +16 -0
- package/build/core/efficiency.d.ts.map +1 -0
- package/build/core/efficiency.js +170 -0
- package/build/core/efficiency.js.map +1 -0
- package/build/core/embedding-tracker.d.ts +25 -0
- package/build/core/embedding-tracker.d.ts.map +1 -0
- package/build/core/embedding-tracker.js +228 -0
- package/build/core/embedding-tracker.js.map +1 -0
- package/build/core/embeddings.d.ts +90 -0
- package/build/core/embeddings.d.ts.map +1 -0
- package/build/core/embeddings.js +693 -0
- package/build/core/embeddings.js.map +1 -0
- package/build/core/evidence-state.d.ts +42 -0
- package/build/core/evidence-state.d.ts.map +1 -0
- package/build/core/evidence-state.js +153 -0
- package/build/core/evidence-state.js.map +1 -0
- package/build/core/extractor-stamp.d.ts +10 -0
- package/build/core/extractor-stamp.d.ts.map +1 -0
- package/build/core/extractor-stamp.js +51 -0
- package/build/core/extractor-stamp.js.map +1 -0
- package/build/core/feature-brief-cache.d.ts +37 -0
- package/build/core/feature-brief-cache.d.ts.map +1 -0
- package/build/core/feature-brief-cache.js +100 -0
- package/build/core/feature-brief-cache.js.map +1 -0
- package/build/core/file-fingerprint.d.ts +15 -0
- package/build/core/file-fingerprint.d.ts.map +1 -0
- package/build/core/file-fingerprint.js +24 -0
- package/build/core/file-fingerprint.js.map +1 -0
- package/build/core/graph-analytics.d.ts +46 -0
- package/build/core/graph-analytics.d.ts.map +1 -0
- package/build/core/graph-analytics.js +371 -0
- package/build/core/graph-analytics.js.map +1 -0
- package/build/core/hub.d.ts +23 -0
- package/build/core/hub.d.ts.map +1 -0
- package/build/core/hub.js +123 -0
- package/build/core/hub.js.map +1 -0
- package/build/core/ignore-dirs.d.ts +7 -0
- package/build/core/ignore-dirs.d.ts.map +1 -0
- package/build/core/ignore-dirs.js +84 -0
- package/build/core/ignore-dirs.js.map +1 -0
- package/build/core/index-freshness.d.ts +15 -0
- package/build/core/index-freshness.d.ts.map +1 -0
- package/build/core/index-freshness.js +96 -0
- package/build/core/index-freshness.js.map +1 -0
- package/build/core/index-reconcile.d.ts +28 -0
- package/build/core/index-reconcile.d.ts.map +1 -0
- package/build/core/index-reconcile.js +129 -0
- package/build/core/index-reconcile.js.map +1 -0
- package/build/core/local-daemon.d.ts +5 -0
- package/build/core/local-daemon.d.ts.map +1 -0
- package/build/core/local-daemon.js +282 -0
- package/build/core/local-daemon.js.map +1 -0
- package/build/core/memory-graph.d.ts +68 -0
- package/build/core/memory-graph.d.ts.map +1 -0
- package/build/core/memory-graph.js +152 -0
- package/build/core/memory-graph.js.map +1 -0
- package/build/core/native-repair.d.ts +12 -0
- package/build/core/native-repair.d.ts.map +1 -0
- package/build/core/native-repair.js +167 -0
- package/build/core/native-repair.js.map +1 -0
- package/build/core/native-runtime.d.ts +12 -0
- package/build/core/native-runtime.d.ts.map +1 -0
- package/build/core/native-runtime.js +38 -0
- package/build/core/native-runtime.js.map +1 -0
- package/build/core/pagerank.d.ts +29 -0
- package/build/core/pagerank.d.ts.map +1 -0
- package/build/core/pagerank.js +90 -0
- package/build/core/pagerank.js.map +1 -0
- package/build/core/parser-process.d.ts +21 -0
- package/build/core/parser-process.d.ts.map +1 -0
- package/build/core/parser-process.js +103 -0
- package/build/core/parser-process.js.map +1 -0
- package/build/core/parser-worker.d.ts +2 -0
- package/build/core/parser-worker.d.ts.map +1 -0
- package/build/core/parser-worker.js +17 -0
- package/build/core/parser-worker.js.map +1 -0
- package/build/core/parser.d.ts +66 -0
- package/build/core/parser.d.ts.map +1 -0
- package/build/core/parser.js +750 -0
- package/build/core/parser.js.map +1 -0
- package/build/core/path-guard.d.ts +6 -0
- package/build/core/path-guard.d.ts.map +1 -0
- package/build/core/path-guard.js +55 -0
- package/build/core/path-guard.js.map +1 -0
- package/build/core/process-lifecycle.d.ts +30 -0
- package/build/core/process-lifecycle.d.ts.map +1 -0
- package/build/core/process-lifecycle.js +129 -0
- package/build/core/process-lifecycle.js.map +1 -0
- package/build/core/project-config.d.ts +83 -0
- package/build/core/project-config.d.ts.map +1 -0
- package/build/core/project-config.js +302 -0
- package/build/core/project-config.js.map +1 -0
- package/build/core/project-graph.d.ts +69 -0
- package/build/core/project-graph.d.ts.map +1 -0
- package/build/core/project-graph.js +874 -0
- package/build/core/project-graph.js.map +1 -0
- package/build/core/provider-config.d.ts +15 -0
- package/build/core/provider-config.d.ts.map +1 -0
- package/build/core/provider-config.js +67 -0
- package/build/core/provider-config.js.map +1 -0
- package/build/core/provider-usage.d.ts +21 -0
- package/build/core/provider-usage.d.ts.map +1 -0
- package/build/core/provider-usage.js +52 -0
- package/build/core/provider-usage.js.map +1 -0
- package/build/core/python-language-server.d.ts +23 -0
- package/build/core/python-language-server.d.ts.map +1 -0
- package/build/core/python-language-server.js +217 -0
- package/build/core/python-language-server.js.map +1 -0
- package/build/core/python-runtime-identity.d.ts +3 -0
- package/build/core/python-runtime-identity.d.ts.map +1 -0
- package/build/core/python-runtime-identity.js +53 -0
- package/build/core/python-runtime-identity.js.map +1 -0
- package/build/core/reconcile-scheduler.d.ts +20 -0
- package/build/core/reconcile-scheduler.d.ts.map +1 -0
- package/build/core/reconcile-scheduler.js +58 -0
- package/build/core/reconcile-scheduler.js.map +1 -0
- package/build/core/request-context.d.ts +7 -0
- package/build/core/request-context.d.ts.map +1 -0
- package/build/core/request-context.js +17 -0
- package/build/core/request-context.js.map +1 -0
- package/build/core/request-root.d.ts +19 -0
- package/build/core/request-root.d.ts.map +1 -0
- package/build/core/request-root.js +26 -0
- package/build/core/request-root.js.map +1 -0
- package/build/core/root-guard.d.ts +9 -0
- package/build/core/root-guard.d.ts.map +1 -0
- package/build/core/root-guard.js +64 -0
- package/build/core/root-guard.js.map +1 -0
- package/build/core/roots-detect.d.ts +17 -0
- package/build/core/roots-detect.d.ts.map +1 -0
- package/build/core/roots-detect.js +63 -0
- package/build/core/roots-detect.js.map +1 -0
- package/build/core/runtime-session.d.ts +5 -0
- package/build/core/runtime-session.d.ts.map +1 -0
- package/build/core/runtime-session.js +10 -0
- package/build/core/runtime-session.js.map +1 -0
- package/build/core/scip-index.d.ts +71 -0
- package/build/core/scip-index.d.ts.map +1 -0
- package/build/core/scip-index.js +343 -0
- package/build/core/scip-index.js.map +1 -0
- package/build/core/semantic-diff.d.ts +32 -0
- package/build/core/semantic-diff.d.ts.map +1 -0
- package/build/core/semantic-diff.js +259 -0
- package/build/core/semantic-diff.js.map +1 -0
- package/build/core/source-context.d.ts +3 -0
- package/build/core/source-context.d.ts.map +1 -0
- package/build/core/source-context.js +86 -0
- package/build/core/source-context.js.map +1 -0
- package/build/core/source-mask.d.ts +8 -0
- package/build/core/source-mask.d.ts.map +1 -0
- package/build/core/source-mask.js +156 -0
- package/build/core/source-mask.js.map +1 -0
- package/build/core/source-mutation.d.ts +16 -0
- package/build/core/source-mutation.d.ts.map +1 -0
- package/build/core/source-mutation.js +193 -0
- package/build/core/source-mutation.js.map +1 -0
- package/build/core/sql-schema.d.ts +59 -0
- package/build/core/sql-schema.d.ts.map +1 -0
- package/build/core/sql-schema.js +218 -0
- package/build/core/sql-schema.js.map +1 -0
- package/build/core/startup-health.d.ts +40 -0
- package/build/core/startup-health.d.ts.map +1 -0
- package/build/core/startup-health.js +132 -0
- package/build/core/startup-health.js.map +1 -0
- package/build/core/team-ledger.d.ts +60 -0
- package/build/core/team-ledger.d.ts.map +1 -0
- package/build/core/team-ledger.js +171 -0
- package/build/core/team-ledger.js.map +1 -0
- package/build/core/test-impact.d.ts +23 -0
- package/build/core/test-impact.d.ts.map +1 -0
- package/build/core/test-impact.js +131 -0
- package/build/core/test-impact.js.map +1 -0
- package/build/core/tool-metrics.d.ts +29 -0
- package/build/core/tool-metrics.d.ts.map +1 -0
- package/build/core/tool-metrics.js +74 -0
- package/build/core/tool-metrics.js.map +1 -0
- package/build/core/tool-profile.d.ts +12 -0
- package/build/core/tool-profile.d.ts.map +1 -0
- package/build/core/tool-profile.js +102 -0
- package/build/core/tool-profile.js.map +1 -0
- package/build/core/tool-trace.d.ts +8 -0
- package/build/core/tool-trace.d.ts.map +1 -0
- package/build/core/tool-trace.js +70 -0
- package/build/core/tool-trace.js.map +1 -0
- package/build/core/tree-sitter-runtime.d.ts +20 -0
- package/build/core/tree-sitter-runtime.d.ts.map +1 -0
- package/build/core/tree-sitter-runtime.js +324 -0
- package/build/core/tree-sitter-runtime.js.map +1 -0
- package/build/core/tree-sitter.d.ts +6 -0
- package/build/core/tree-sitter.d.ts.map +1 -0
- package/build/core/tree-sitter.js +24 -0
- package/build/core/tree-sitter.js.map +1 -0
- package/build/core/typescript-reference-process.d.ts +30 -0
- package/build/core/typescript-reference-process.d.ts.map +1 -0
- package/build/core/typescript-reference-process.js +124 -0
- package/build/core/typescript-reference-process.js.map +1 -0
- package/build/core/typescript-reference-worker.d.ts +2 -0
- package/build/core/typescript-reference-worker.d.ts.map +1 -0
- package/build/core/typescript-reference-worker.js +14 -0
- package/build/core/typescript-reference-worker.js.map +1 -0
- package/build/core/typescript-references.d.ts +71 -0
- package/build/core/typescript-references.d.ts.map +1 -0
- package/build/core/typescript-references.js +392 -0
- package/build/core/typescript-references.js.map +1 -0
- package/build/core/typescript-skeleton.d.ts +5 -0
- package/build/core/typescript-skeleton.d.ts.map +1 -0
- package/build/core/typescript-skeleton.js +49 -0
- package/build/core/typescript-skeleton.js.map +1 -0
- package/build/core/walker.d.ts +16 -0
- package/build/core/walker.d.ts.map +1 -0
- package/build/core/walker.js +152 -0
- package/build/core/walker.js.map +1 -0
- package/build/core/workspace-router.d.ts +28 -0
- package/build/core/workspace-router.d.ts.map +1 -0
- package/build/core/workspace-router.js +93 -0
- package/build/core/workspace-router.js.map +1 -0
- package/build/core/worktree-gc.d.ts +16 -0
- package/build/core/worktree-gc.d.ts.map +1 -0
- package/build/core/worktree-gc.js +69 -0
- package/build/core/worktree-gc.js.map +1 -0
- package/build/core/worktree-overlay.d.ts +22 -0
- package/build/core/worktree-overlay.d.ts.map +1 -0
- package/build/core/worktree-overlay.js +84 -0
- package/build/core/worktree-overlay.js.map +1 -0
- package/build/core/worktree-root-guard.d.ts +8 -0
- package/build/core/worktree-root-guard.d.ts.map +1 -0
- package/build/core/worktree-root-guard.js +82 -0
- package/build/core/worktree-root-guard.js.map +1 -0
- package/build/core/worktree-seed.d.ts +14 -0
- package/build/core/worktree-seed.d.ts.map +1 -0
- package/build/core/worktree-seed.js +98 -0
- package/build/core/worktree-seed.js.map +1 -0
- package/build/git/shadow.d.ts +40 -0
- package/build/git/shadow.d.ts.map +1 -0
- package/build/git/shadow.js +298 -0
- package/build/git/shadow.js.map +1 -0
- package/build/index.d.ts +3 -0
- package/build/index.d.ts.map +1 -0
- package/build/index.js +634 -0
- package/build/index.js.map +1 -0
- package/build/tools/agentic-context.d.ts +86 -0
- package/build/tools/agentic-context.d.ts.map +1 -0
- package/build/tools/agentic-context.js +1546 -0
- package/build/tools/agentic-context.js.map +1 -0
- package/build/tools/blast-radius.d.ts +24 -0
- package/build/tools/blast-radius.d.ts.map +1 -0
- package/build/tools/blast-radius.js +231 -0
- package/build/tools/blast-radius.js.map +1 -0
- package/build/tools/changed-since.d.ts +7 -0
- package/build/tools/changed-since.d.ts.map +1 -0
- package/build/tools/changed-since.js +68 -0
- package/build/tools/changed-since.js.map +1 -0
- package/build/tools/compiler-actions.d.ts +26 -0
- package/build/tools/compiler-actions.d.ts.map +1 -0
- package/build/tools/compiler-actions.js +121 -0
- package/build/tools/compiler-actions.js.map +1 -0
- package/build/tools/context-tree.d.ts +9 -0
- package/build/tools/context-tree.d.ts.map +1 -0
- package/build/tools/context-tree.js +131 -0
- package/build/tools/context-tree.js.map +1 -0
- package/build/tools/context.d.ts +37 -0
- package/build/tools/context.d.ts.map +1 -0
- package/build/tools/context.js +800 -0
- package/build/tools/context.js.map +1 -0
- package/build/tools/diff.d.ts +9 -0
- package/build/tools/diff.d.ts.map +1 -0
- package/build/tools/diff.js +176 -0
- package/build/tools/diff.js.map +1 -0
- package/build/tools/directory-prior.d.ts +16 -0
- package/build/tools/directory-prior.d.ts.map +1 -0
- package/build/tools/directory-prior.js +121 -0
- package/build/tools/directory-prior.js.map +1 -0
- package/build/tools/discovery-documents.d.ts +11 -0
- package/build/tools/discovery-documents.d.ts.map +1 -0
- package/build/tools/discovery-documents.js +71 -0
- package/build/tools/discovery-documents.js.map +1 -0
- package/build/tools/discovery-hints.d.ts +25 -0
- package/build/tools/discovery-hints.d.ts.map +1 -0
- package/build/tools/discovery-hints.js +329 -0
- package/build/tools/discovery-hints.js.map +1 -0
- package/build/tools/efficiency-report.d.ts +13 -0
- package/build/tools/efficiency-report.d.ts.map +1 -0
- package/build/tools/efficiency-report.js +78 -0
- package/build/tools/efficiency-report.js.map +1 -0
- package/build/tools/evidence-retrieval.d.ts +33 -0
- package/build/tools/evidence-retrieval.d.ts.map +1 -0
- package/build/tools/evidence-retrieval.js +200 -0
- package/build/tools/evidence-retrieval.js.map +1 -0
- package/build/tools/exact-references.d.ts +10 -0
- package/build/tools/exact-references.d.ts.map +1 -0
- package/build/tools/exact-references.js +351 -0
- package/build/tools/exact-references.js.map +1 -0
- package/build/tools/explain.d.ts +14 -0
- package/build/tools/explain.d.ts.map +1 -0
- package/build/tools/explain.js +370 -0
- package/build/tools/explain.js.map +1 -0
- package/build/tools/feature-brief.d.ts +7 -0
- package/build/tools/feature-brief.d.ts.map +1 -0
- package/build/tools/feature-brief.js +89 -0
- package/build/tools/feature-brief.js.map +1 -0
- package/build/tools/feature-hub.d.ts +15 -0
- package/build/tools/feature-hub.d.ts.map +1 -0
- package/build/tools/feature-hub.js +404 -0
- package/build/tools/feature-hub.js.map +1 -0
- package/build/tools/file-skeleton.d.ts +7 -0
- package/build/tools/file-skeleton.d.ts.map +1 -0
- package/build/tools/file-skeleton.js +190 -0
- package/build/tools/file-skeleton.js.map +1 -0
- package/build/tools/grep.d.ts +25 -0
- package/build/tools/grep.d.ts.map +1 -0
- package/build/tools/grep.js +341 -0
- package/build/tools/grep.js.map +1 -0
- package/build/tools/impact-delta.d.ts +7 -0
- package/build/tools/impact-delta.d.ts.map +1 -0
- package/build/tools/impact-delta.js +102 -0
- package/build/tools/impact-delta.js.map +1 -0
- package/build/tools/memory-tools.d.ts +69 -0
- package/build/tools/memory-tools.d.ts.map +1 -0
- package/build/tools/memory-tools.js +366 -0
- package/build/tools/memory-tools.js.map +1 -0
- package/build/tools/planning-helpers.d.ts +26 -0
- package/build/tools/planning-helpers.d.ts.map +1 -0
- package/build/tools/planning-helpers.js +269 -0
- package/build/tools/planning-helpers.js.map +1 -0
- package/build/tools/project-graph.d.ts +19 -0
- package/build/tools/project-graph.d.ts.map +1 -0
- package/build/tools/project-graph.js +259 -0
- package/build/tools/project-graph.js.map +1 -0
- package/build/tools/propose-commit.d.ts +9 -0
- package/build/tools/propose-commit.d.ts.map +1 -0
- package/build/tools/propose-commit.js +156 -0
- package/build/tools/propose-commit.js.map +1 -0
- package/build/tools/register-tools.d.ts +18 -0
- package/build/tools/register-tools.d.ts.map +1 -0
- package/build/tools/register-tools.js +1131 -0
- package/build/tools/register-tools.js.map +1 -0
- package/build/tools/reindex.d.ts +76 -0
- package/build/tools/reindex.d.ts.map +1 -0
- package/build/tools/reindex.js +871 -0
- package/build/tools/reindex.js.map +1 -0
- package/build/tools/related.d.ts +6 -0
- package/build/tools/related.d.ts.map +1 -0
- package/build/tools/related.js +143 -0
- package/build/tools/related.js.map +1 -0
- package/build/tools/repo-map.d.ts +59 -0
- package/build/tools/repo-map.d.ts.map +1 -0
- package/build/tools/repo-map.js +270 -0
- package/build/tools/repo-map.js.map +1 -0
- package/build/tools/resolve-symbol.d.ts +41 -0
- package/build/tools/resolve-symbol.d.ts.map +1 -0
- package/build/tools/resolve-symbol.js +250 -0
- package/build/tools/resolve-symbol.js.map +1 -0
- package/build/tools/retrieval-helpers.d.ts +35 -0
- package/build/tools/retrieval-helpers.d.ts.map +1 -0
- package/build/tools/retrieval-helpers.js +302 -0
- package/build/tools/retrieval-helpers.js.map +1 -0
- package/build/tools/scip-index.d.ts +12 -0
- package/build/tools/scip-index.d.ts.map +1 -0
- package/build/tools/scip-index.js +66 -0
- package/build/tools/scip-index.js.map +1 -0
- package/build/tools/scoped-discovery.d.ts +7 -0
- package/build/tools/scoped-discovery.d.ts.map +1 -0
- package/build/tools/scoped-discovery.js +89 -0
- package/build/tools/scoped-discovery.js.map +1 -0
- package/build/tools/search.d.ts +62 -0
- package/build/tools/search.d.ts.map +1 -0
- package/build/tools/search.js +419 -0
- package/build/tools/search.js.map +1 -0
- package/build/tools/semantic-diff.d.ts +7 -0
- package/build/tools/semantic-diff.d.ts.map +1 -0
- package/build/tools/semantic-diff.js +45 -0
- package/build/tools/semantic-diff.js.map +1 -0
- package/build/tools/semantic-identifiers.d.ts +51 -0
- package/build/tools/semantic-identifiers.d.ts.map +1 -0
- package/build/tools/semantic-identifiers.js +522 -0
- package/build/tools/semantic-identifiers.js.map +1 -0
- package/build/tools/semantic-navigate.d.ts +18 -0
- package/build/tools/semantic-navigate.d.ts.map +1 -0
- package/build/tools/semantic-navigate.js +413 -0
- package/build/tools/semantic-navigate.js.map +1 -0
- package/build/tools/semantic-search.d.ts +30 -0
- package/build/tools/semantic-search.d.ts.map +1 -0
- package/build/tools/semantic-search.js +466 -0
- package/build/tools/semantic-search.js.map +1 -0
- package/build/tools/sql-schema.d.ts +23 -0
- package/build/tools/sql-schema.d.ts.map +1 -0
- package/build/tools/sql-schema.js +155 -0
- package/build/tools/sql-schema.js.map +1 -0
- package/build/tools/static-analysis.d.ts +7 -0
- package/build/tools/static-analysis.d.ts.map +1 -0
- package/build/tools/static-analysis.js +331 -0
- package/build/tools/static-analysis.js.map +1 -0
- package/build/tools/status.d.ts +74 -0
- package/build/tools/status.d.ts.map +1 -0
- package/build/tools/status.js +227 -0
- package/build/tools/status.js.map +1 -0
- package/build/tools/symbolic-edit.d.ts +57 -0
- package/build/tools/symbolic-edit.d.ts.map +1 -0
- package/build/tools/symbolic-edit.js +500 -0
- package/build/tools/symbolic-edit.js.map +1 -0
- package/build/tools/test-impact.d.ts +7 -0
- package/build/tools/test-impact.d.ts.map +1 -0
- package/build/tools/test-impact.js +34 -0
- package/build/tools/test-impact.js.map +1 -0
- package/build/tools/test-map.d.ts +8 -0
- package/build/tools/test-map.d.ts.map +1 -0
- package/build/tools/test-map.js +75 -0
- package/build/tools/test-map.js.map +1 -0
- package/docs/README.md +35 -0
- package/docs/architecture.md +35 -0
- package/docs/configuration.md +207 -0
- package/docs/maintenance.md +77 -0
- package/package.json +80 -4
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
// Shared, bounded candidate assembly. Relations here are indexed heuristics,
|
|
2
|
+
// never compiler-resolved references. Source selection happens in context.ts.
|
|
3
|
+
import { getDB } from "../core/db.js";
|
|
4
|
+
import { basename, dirname } from "node:path";
|
|
5
|
+
import { searchTerms, withQueryEmbeddingCache } from "../core/embeddings.js";
|
|
6
|
+
import { unifiedSearchData, extractIdentifierHints } from "./search.js";
|
|
7
|
+
import { discoveryPathWeight, facetPathWeight, mentionedFiles, queryLiterals } from "./discovery-hints.js";
|
|
8
|
+
import { findTestsForFiles, isTestEvidence, isTestFile } from "./retrieval-helpers.js";
|
|
9
|
+
import { maybeChatRerankPlanningFiles } from "./planning-helpers.js";
|
|
10
|
+
export const connectedRetrievalEnabled = () => process.env.CONTEXTPRO_CONNECTED_CONTEXT === "true";
|
|
11
|
+
export async function retrieveEvidence(options) {
|
|
12
|
+
return withQueryEmbeddingCache(async () => {
|
|
13
|
+
const { rootDir, query } = options;
|
|
14
|
+
const search = await unifiedSearchData({ rootDir, query, mode: "hybrid", topK: 24,
|
|
15
|
+
preset: options.preset ?? "balanced", fusion: "rrf", inlineCode: "off", expandCallers: false, persistArtifact: false });
|
|
16
|
+
const db = await getDB(rootDir), files = db.getAllFiles();
|
|
17
|
+
const byId = new Map(files.map(file => [file.id, file.path]));
|
|
18
|
+
const pool = new Map();
|
|
19
|
+
const facetOwners = new Set();
|
|
20
|
+
const topicOwners = new Set();
|
|
21
|
+
let weakSemanticMatches = 0;
|
|
22
|
+
const add = (path, rank, lane, role = "implementation", anchor, symbols = []) => {
|
|
23
|
+
if (isTestEvidence(path))
|
|
24
|
+
role = "test";
|
|
25
|
+
const prior = discoveryPathWeight(query, path, lane === "named definition");
|
|
26
|
+
// Graph links are evidence in their own right, including tests that do not
|
|
27
|
+
// repeat the query words. Lexical decoys still receive the normal penalty.
|
|
28
|
+
const weight = lane.startsWith("graph:") || lane === "test association" ? 1 : prior;
|
|
29
|
+
const item = pool.get(path) ?? { path, score: 0, reason: "", symbols: [], roles: [], anchors: [] };
|
|
30
|
+
// RRF contributes once per file per lane. Ten identifiers in one test
|
|
31
|
+
// file are not ten independent retrieval signals for that file.
|
|
32
|
+
if (!item.reason.split("; ").includes(lane))
|
|
33
|
+
item.score += weight / (60 + rank + 1);
|
|
34
|
+
item.reason = [...new Set([...item.reason.split("; ").filter(Boolean), lane])].join("; ");
|
|
35
|
+
if (!item.roles.includes(role))
|
|
36
|
+
item.roles.push(role);
|
|
37
|
+
if (anchor && !item.anchors.includes(anchor))
|
|
38
|
+
item.anchors.push(anchor);
|
|
39
|
+
item.symbols = [...new Set([...item.symbols, ...symbols])];
|
|
40
|
+
pool.set(path, item);
|
|
41
|
+
};
|
|
42
|
+
// Rank fusion must not turn weak, zero-overlap neighbors into graph seeds.
|
|
43
|
+
// Match the existing search caller-expansion floor (40/100 cosine score).
|
|
44
|
+
// This is a conservative retrieval heuristic, not a calibrated probability.
|
|
45
|
+
const supported = (item) => {
|
|
46
|
+
const accepted = item.keywordScore > 0 || item.semanticScore > 40;
|
|
47
|
+
if (!accepted && item.semanticScore > 0)
|
|
48
|
+
weakSemanticMatches++;
|
|
49
|
+
return accepted;
|
|
50
|
+
};
|
|
51
|
+
(search.files?.results ?? []).forEach((file, rank) => {
|
|
52
|
+
if (!supported(file))
|
|
53
|
+
return;
|
|
54
|
+
add(file.path, rank, "file retrieval", "implementation", undefined, file.matchedSymbols);
|
|
55
|
+
pool.get(file.path).semanticScore = file.semanticScore;
|
|
56
|
+
});
|
|
57
|
+
(search.identifiers?.results ?? []).forEach((symbol, rank) => {
|
|
58
|
+
if (!supported(symbol))
|
|
59
|
+
return;
|
|
60
|
+
add(symbol.path, rank, "symbol retrieval", "implementation", undefined, [symbol.name]);
|
|
61
|
+
const item = pool.get(symbol.path);
|
|
62
|
+
item.semanticScore = Math.max(item.semanticScore ?? 0, symbol.semanticScore);
|
|
63
|
+
});
|
|
64
|
+
const terms = new Set(searchTerms(query));
|
|
65
|
+
if (options.preset !== "semantic_only") {
|
|
66
|
+
db.searchFileText(query, 32).forEach((file, rank) => add(file.path, rank, "source text"));
|
|
67
|
+
for (const literal of queryLiterals(query).slice(0, 8))
|
|
68
|
+
db.searchFileText(literal, 8, true).forEach((file, rank) => add(file.path, rank, "literal"));
|
|
69
|
+
// A broad OR query can fill every slot with one popular topic. Give each
|
|
70
|
+
// concrete query term its own small lane before truncating the union.
|
|
71
|
+
const generic = new Set(["find", "where", "implementation", "function", "code", "file", "files", "explain", "logic", "checks", "check", "system", "does", "which", "existing", "relevant", "include", "only", "all", "any", "remaining", "identify", "paths", "path", "across", "locate", "source"]);
|
|
72
|
+
for (const term of [...terms].filter(term => term.length >= 3 && !generic.has(term)).slice(0, 24)) {
|
|
73
|
+
const hits = db.searchFileText(term, 64).sort((a, b) => facetPathWeight(query, term, b.path) - facetPathWeight(query, term, a.path) || a.score - b.score || a.path.localeCompare(b.path));
|
|
74
|
+
hits.slice(0, 2).forEach((hit, rank) => add(hit.path, rank, `facet:${term}`));
|
|
75
|
+
if (hits[0])
|
|
76
|
+
facetOwners.add(hits[0].path);
|
|
77
|
+
}
|
|
78
|
+
mentionedFiles(rootDir, query, files).slice(0, 8).forEach((file, rank) => add(file, rank, "explicit path"));
|
|
79
|
+
files.map(file => ({ path: file.path, hits: searchTerms(file.path).filter(term => terms.has(term)).length }))
|
|
80
|
+
.filter(file => file.hits > 0).sort((a, b) => b.hits - a.hits || a.path.localeCompare(b.path)).slice(0, 16)
|
|
81
|
+
.forEach((file, rank) => add(file.path, rank, "path terms"));
|
|
82
|
+
// A basename carrying several concrete query topics is stronger than a
|
|
83
|
+
// ubiquitous directory token (tests, web, native). Keep those modules in
|
|
84
|
+
// the union even when unrelated single-term facets have many matches.
|
|
85
|
+
const topics = new Set([...terms].filter(term => !generic.has(term) && !["tests", "test", "web", "native", "server", "api"].includes(term)));
|
|
86
|
+
files.map(file => ({ path: file.path, hits: new Set(searchTerms(basename(file.path)).filter(term => topics.has(term))).size }))
|
|
87
|
+
.filter(file => file.hits >= 2).sort((a, b) => b.hits - a.hits || (pool.get(b.path)?.score ?? 0) - (pool.get(a.path)?.score ?? 0) || a.path.localeCompare(b.path)).slice(0, 8)
|
|
88
|
+
.forEach((file, rank) => { add(file.path, rank, "path topics"); topicOwners.add(file.path); });
|
|
89
|
+
for (const hint of extractIdentifierHints(query).slice(0, 16)) {
|
|
90
|
+
const matches = db.searchSymbolsByName(hint).filter(symbol => symbol.name === hint);
|
|
91
|
+
const hasImplementation = matches.some(symbol => {
|
|
92
|
+
const path = byId.get(symbol.file_id);
|
|
93
|
+
return path && !isTestEvidence(path) && discoveryPathWeight(query, path, true) >= 1;
|
|
94
|
+
});
|
|
95
|
+
for (const symbol of matches.filter(symbol => {
|
|
96
|
+
const path = byId.get(symbol.file_id);
|
|
97
|
+
return path && (!hasImplementation || !isTestEvidence(path) || discoveryPathWeight(query, path) >= 1);
|
|
98
|
+
}).slice(0, 8)) {
|
|
99
|
+
const path = byId.get(symbol.file_id);
|
|
100
|
+
if (path && discoveryPathWeight(query, path, true) >= 1)
|
|
101
|
+
add(path, 0, "named definition", "implementation", symbol.line_start, [hint]);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
const ranked = () => [...pool.values()].sort((a, b) => Number(b.reason.includes("named definition")) - Number(a.reason.includes("named definition")) || b.score - a.score || a.path.localeCompare(b.path));
|
|
106
|
+
// Four seeds leave space for connected evidence instead of saturating all
|
|
107
|
+
// slots with repetitive hits before graph expansion starts.
|
|
108
|
+
const seedPool = ranked().filter(item => !isTestFile(item.path));
|
|
109
|
+
const seeds = [], coveredFacets = new Set();
|
|
110
|
+
while (seeds.length < 4 && seedPool.length) {
|
|
111
|
+
const facets = (item) => item.reason.split("; ").filter(reason => reason.startsWith("facet:"));
|
|
112
|
+
seedPool.sort((a, b) => (facets(b).filter(term => !coveredFacets.has(term)).length - facets(a).filter(term => !coveredFacets.has(term)).length) || b.score - a.score || a.path.localeCompare(b.path));
|
|
113
|
+
const seed = seedPool.shift();
|
|
114
|
+
seeds.push(seed);
|
|
115
|
+
facets(seed).forEach(term => coveredFacets.add(term));
|
|
116
|
+
}
|
|
117
|
+
const graphLimit = Math.min(16, Math.max(0, options.graphMaxFiles ?? 8));
|
|
118
|
+
const linked = new Set(), visited = new Set(seeds.map(item => item.path));
|
|
119
|
+
// Broad multi-topic questions need a hop from each represented facet, not
|
|
120
|
+
// just the first four globally popular files. Visit edges round-robin so a
|
|
121
|
+
// large import hub cannot spend the entire expansion budget on its own.
|
|
122
|
+
let frontier = [...new Map([...seeds, ...ranked().filter(item => facetOwners.has(item.path) && !isTestFile(item.path))].map(item => [item.path, item])).values()].slice(0, 16);
|
|
123
|
+
for (const item of frontier)
|
|
124
|
+
visited.add(item.path);
|
|
125
|
+
for (let depth = 0; depth < (options.graphHops ?? 1) && frontier.length && linked.size < graphLimit; depth++) {
|
|
126
|
+
const next = [];
|
|
127
|
+
const queues = frontier.map(seed => {
|
|
128
|
+
const file = db.getFile(seed.path);
|
|
129
|
+
if (!file)
|
|
130
|
+
return [];
|
|
131
|
+
const edges = [
|
|
132
|
+
...db.getImportsFrom(file.id).map(edge => ({ path: edge.target_file_id ? byId.get(edge.target_file_id) : undefined, role: "dependency", reason: `graph: imported by ${seed.path}` })),
|
|
133
|
+
...db.getImportersOf(file.id).map(edge => ({ path: byId.get(edge.source_file_id), role: "caller", reason: `graph: imports ${seed.path}` })),
|
|
134
|
+
];
|
|
135
|
+
// Name-only call links may be ambiguous. Retrieve their source files,
|
|
136
|
+
// but do not infer binding identity from them.
|
|
137
|
+
for (const symbol of seed.symbols.slice(0, 4))
|
|
138
|
+
for (const call of db.getCallersOf(symbol).slice(0, 12)) {
|
|
139
|
+
edges.push({ path: byId.get(call.file_id), role: "caller", reason: `graph: textual caller of ${symbol} (ambiguous binding)` });
|
|
140
|
+
}
|
|
141
|
+
edges.sort((a, b) => {
|
|
142
|
+
const score = (edge) => edge.path ?
|
|
143
|
+
(edge.role === "dependency" ? 1 : 0) + (dirname(edge.path) === dirname(seed.path) ? 2 : 0)
|
|
144
|
+
+ Math.min(4, searchTerms(edge.path).filter(term => terms.has(term)).length) * .2 : -1;
|
|
145
|
+
return score(b) - score(a) || (a.path ?? "").localeCompare(b.path ?? "");
|
|
146
|
+
});
|
|
147
|
+
return edges.filter(edge => edge.path && edge.path !== seed.path);
|
|
148
|
+
});
|
|
149
|
+
while (queues.some(queue => queue.length) && linked.size < graphLimit)
|
|
150
|
+
for (const queue of queues) {
|
|
151
|
+
while (queue.length) {
|
|
152
|
+
const edge = queue.shift();
|
|
153
|
+
if (!edge.path)
|
|
154
|
+
continue;
|
|
155
|
+
const role = isTestFile(edge.path) ? "test" : edge.role;
|
|
156
|
+
if (visited.has(edge.path)) {
|
|
157
|
+
// Existing seeds/previous-hop paths may gain a role, but consume no
|
|
158
|
+
// expansion slot and must not be queued or score-boosted again.
|
|
159
|
+
const existing = pool.get(edge.path);
|
|
160
|
+
if (existing) {
|
|
161
|
+
if (!existing.roles.includes(role))
|
|
162
|
+
existing.roles.push(role);
|
|
163
|
+
existing.reason = [...new Set([...existing.reason.split("; "), edge.reason, "indexed heuristic"])].join("; ");
|
|
164
|
+
}
|
|
165
|
+
continue;
|
|
166
|
+
}
|
|
167
|
+
if (!linked.has(edge.path) && linked.size >= graphLimit)
|
|
168
|
+
break;
|
|
169
|
+
add(edge.path, depth, edge.reason + "; indexed heuristic", role);
|
|
170
|
+
linked.add(edge.path);
|
|
171
|
+
visited.add(edge.path);
|
|
172
|
+
next.push(pool.get(edge.path));
|
|
173
|
+
break;
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
frontier = next;
|
|
177
|
+
}
|
|
178
|
+
const tests = options.includeTests === false ? [] : (await findTestsForFiles(rootDir, seeds.map(seed => seed.path))).slice(0, 4);
|
|
179
|
+
tests.forEach((test, rank) => add(test.path, rank, "test association", "test"));
|
|
180
|
+
const order = ranked();
|
|
181
|
+
// Reserve at most 4 seeds + 16 graph files + 4 associated tests first.
|
|
182
|
+
// Facet/topic owners share the remaining slots; an oversized owner union
|
|
183
|
+
// must not silently evict the connected evidence we already budgeted for.
|
|
184
|
+
const selected = new Set([...seeds.map(seed => seed.path), ...linked, ...tests.map(test => test.path)]);
|
|
185
|
+
const owners = order.filter(item => facetOwners.has(item.path) || topicOwners.has(item.path));
|
|
186
|
+
for (const item of [...owners, ...order]) {
|
|
187
|
+
if (selected.size >= 32)
|
|
188
|
+
break;
|
|
189
|
+
selected.add(item.path);
|
|
190
|
+
}
|
|
191
|
+
let candidates = order.filter(item => selected.has(item.path));
|
|
192
|
+
const reordered = await maybeChatRerankPlanningFiles(rootDir, query, candidates);
|
|
193
|
+
const map = new Map(candidates.map(item => [item.path, item]));
|
|
194
|
+
candidates = reordered.map(item => ({ ...map.get(item.path), score: item.score, reason: item.reason }));
|
|
195
|
+
return { search, candidates, tests, limited: pool.size > 32,
|
|
196
|
+
relevanceNotice: weakSemanticMatches ? "Weak semantic-only neighbors omitted before graph expansion; no lexical match or sufficient absolute similarity. Use exact targets if scope is known." : undefined,
|
|
197
|
+
relationNotice: candidates.some(item => item.reason.includes("graph:")) ? "Connected paths use indexed import/test and name-only call heuristics; verify bindings with exact_references." : undefined };
|
|
198
|
+
});
|
|
199
|
+
}
|
|
200
|
+
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AAC,uJAAuJ,CAAC,CAAC,CAAC,SAAS;YAC1M,cAAc,EAAE,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,+GAA+G,CAAC,CAAC,CAAC,SAAS,EAAE,CAAC;IAC5M,CAAC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export interface ExactReferencesOptions {
|
|
2
|
+
rootDir: string;
|
|
3
|
+
symbolName: string;
|
|
4
|
+
file?: string;
|
|
5
|
+
line?: number;
|
|
6
|
+
limit?: number;
|
|
7
|
+
format?: "text" | "json";
|
|
8
|
+
}
|
|
9
|
+
export declare function exactReferencesTool(options: ExactReferencesOptions): Promise<string>;
|
|
10
|
+
//# sourceMappingURL=exact-references.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"exact-references.d.ts","sourceRoot":"","sources":["../../src/tools/exact-references.ts"],"names":[],"mappings":"AAWA,MAAM,WAAW,sBAAsB;IACrC,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;CAC1B;AA4TD,wBAAsB,mBAAmB,CAAC,OAAO,EAAE,sBAAsB,GAAG,OAAO,CAAC,MAAM,CAAC,CAqD1F"}
|
|
@@ -0,0 +1,351 @@
|
|
|
1
|
+
// TypeScript language-service backed exact reference lookup
|
|
2
|
+
// FEATURE: Exact references — local TS/JS adapter with LSP-grade symbol references
|
|
3
|
+
import { readFile } from "fs/promises";
|
|
4
|
+
import { extname } from "path";
|
|
5
|
+
import ts from "typescript";
|
|
6
|
+
import { getDB } from "../core/db.js";
|
|
7
|
+
import { resolveProjectPath, toProjectRelativePath } from "../core/path-guard.js";
|
|
8
|
+
import { findScipReferences } from "../core/scip-index.js";
|
|
9
|
+
import { pythonLanguageServerConfigured, pythonOperation } from "../core/python-language-server.js";
|
|
10
|
+
function isTypeScriptLike(path) {
|
|
11
|
+
return [".ts", ".tsx", ".js", ".jsx", ".mjs", ".cjs"].includes(extname(path).toLowerCase());
|
|
12
|
+
}
|
|
13
|
+
function isPython(path) {
|
|
14
|
+
return extname(path).toLowerCase() === ".py";
|
|
15
|
+
}
|
|
16
|
+
const EXACT_REF_STRUCTURAL_KINDS = new Set(["function", "method", "class", "interface", "enum", "type", "struct", "trait", "export"]);
|
|
17
|
+
function looksLikeTestPath(path) {
|
|
18
|
+
return /(^|\/)(test|tests|__tests__|spec)(\/|$)|\.(test|spec)\./.test(path);
|
|
19
|
+
}
|
|
20
|
+
async function resolveTarget(options) {
|
|
21
|
+
if (options.file && options.line !== undefined) {
|
|
22
|
+
return {
|
|
23
|
+
file: toProjectRelativePath(options.rootDir, options.file, "file"),
|
|
24
|
+
line: options.line,
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
const relativeFile = options.file ? toProjectRelativePath(options.rootDir, options.file, "file") : null;
|
|
28
|
+
if (relativeFile && isTypeScriptLike(relativeFile)) {
|
|
29
|
+
// The structural index intentionally omits some declarations (notably
|
|
30
|
+
// interface properties). Infer from current syntax, including the name's
|
|
31
|
+
// actual line rather than a stale index or the declaration's first line.
|
|
32
|
+
const source = await readFile(resolveProjectPath(options.rootDir, relativeFile, "reference target"), "utf8");
|
|
33
|
+
const syntax = ts.createSourceFile(relativeFile, source, ts.ScriptTarget.Latest, true);
|
|
34
|
+
const candidates = [];
|
|
35
|
+
const visit = (node) => {
|
|
36
|
+
if (ts.isFunctionDeclaration(node) || ts.isFunctionExpression(node) || ts.isClassDeclaration(node)
|
|
37
|
+
|| ts.isClassExpression(node) || ts.isInterfaceDeclaration(node) || ts.isTypeAliasDeclaration(node)
|
|
38
|
+
|| ts.isEnumDeclaration(node) || ts.isModuleDeclaration(node) || ts.isVariableDeclaration(node)
|
|
39
|
+
|| ts.isBindingElement(node) || ts.isParameter(node) || ts.isMethodDeclaration(node)
|
|
40
|
+
|| ts.isMethodSignature(node) || ts.isPropertyDeclaration(node) || ts.isPropertySignature(node)
|
|
41
|
+
|| ts.isPropertyAssignment(node) || ts.isShorthandPropertyAssignment(node)
|
|
42
|
+
|| ts.isGetAccessorDeclaration(node) || ts.isSetAccessorDeclaration(node) || ts.isEnumMember(node)) {
|
|
43
|
+
const name = node.name;
|
|
44
|
+
if (name && (ts.isIdentifier(name) || ts.isStringLiteral(name)) && name.text === options.symbolName) {
|
|
45
|
+
candidates.push({ file: relativeFile, line: syntax.getLineAndCharacterOfPosition(name.getStart(syntax)).line + 1,
|
|
46
|
+
kind: ts.SyntaxKind[node.kind] });
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
ts.forEachChild(node, visit);
|
|
50
|
+
};
|
|
51
|
+
visit(syntax);
|
|
52
|
+
const selected = candidates[0];
|
|
53
|
+
return selected ? { file: relativeFile, line: selected.line,
|
|
54
|
+
...(candidates.length > 1 ? { ambiguousCandidates: candidates.slice(0, 5) } : {}) } : null;
|
|
55
|
+
}
|
|
56
|
+
const db = await getDB(options.rootDir);
|
|
57
|
+
const exact = db.searchSymbolsByName(options.symbolName)
|
|
58
|
+
.filter((symbol) => symbol.name === options.symbolName);
|
|
59
|
+
if (relativeFile) {
|
|
60
|
+
const dbFile = db.getFile(relativeFile);
|
|
61
|
+
if (dbFile) {
|
|
62
|
+
const inFile = exact
|
|
63
|
+
.filter((symbol) => symbol.file_id === dbFile.id)
|
|
64
|
+
.sort((a, b) => a.line_start - b.line_start);
|
|
65
|
+
if (inFile.length > 0) {
|
|
66
|
+
return { file: relativeFile, line: inFile[0].line_start,
|
|
67
|
+
...(inFile.length > 1 ? { ambiguousCandidates: inFile.slice(0, 5).map(symbol => ({ file: relativeFile, line: symbol.line_start, kind: symbol.kind })) } : {}) };
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
return null;
|
|
71
|
+
}
|
|
72
|
+
const files = db.getAllFiles();
|
|
73
|
+
const fileById = new Map(files.map((file) => [file.id, file]));
|
|
74
|
+
// Prefer a real structural definition (function/class/...) over a same-named local
|
|
75
|
+
// variable, and a non-test file over a test file, before falling back to line order —
|
|
76
|
+
// this is a best-guess ranking, not a resolution: multiple distinct sites still surface
|
|
77
|
+
// as an ambiguity warning below rather than being silently picked between.
|
|
78
|
+
const ranked = exact
|
|
79
|
+
.map((symbol) => ({ symbol, file: fileById.get(symbol.file_id) }))
|
|
80
|
+
.filter((entry) => Boolean(entry.file))
|
|
81
|
+
.sort((a, b) => {
|
|
82
|
+
const structural = Number(EXACT_REF_STRUCTURAL_KINDS.has(b.symbol.kind)) - Number(EXACT_REF_STRUCTURAL_KINDS.has(a.symbol.kind));
|
|
83
|
+
if (structural !== 0)
|
|
84
|
+
return structural;
|
|
85
|
+
const nonTest = Number(looksLikeTestPath(a.file.path)) - Number(looksLikeTestPath(b.file.path));
|
|
86
|
+
if (nonTest !== 0)
|
|
87
|
+
return nonTest;
|
|
88
|
+
return a.symbol.line_start - b.symbol.line_start;
|
|
89
|
+
});
|
|
90
|
+
const selected = ranked[0];
|
|
91
|
+
if (!selected)
|
|
92
|
+
return null;
|
|
93
|
+
const distinctSites = new Set(ranked.map((entry) => `${entry.file.path}:${entry.symbol.line_start}`));
|
|
94
|
+
const ambiguousCandidates = distinctSites.size > 1
|
|
95
|
+
? ranked.slice(0, 5).map((entry) => ({ file: entry.file.path, line: entry.symbol.line_start, kind: entry.symbol.kind }))
|
|
96
|
+
: undefined;
|
|
97
|
+
return { file: selected.file.path, line: selected.symbol.line_start, ambiguousCandidates };
|
|
98
|
+
}
|
|
99
|
+
function formatReferencePayload(input) {
|
|
100
|
+
const ambiguousCandidates = input.target?.ambiguousCandidates ?? [];
|
|
101
|
+
const total = input.total ?? input.references.length;
|
|
102
|
+
const truncated = total > input.references.length;
|
|
103
|
+
const warnings = [...(input.warnings ?? []), ...(truncated ? ["Only the first results are shown; raise limit up to 500, or verify the remaining matches with native tools."] : [])];
|
|
104
|
+
const callFilesTruncated = input.callFileCount !== undefined && input.callFileCount > (input.callsByFile?.length ?? 0);
|
|
105
|
+
if (callFilesTruncated)
|
|
106
|
+
warnings.push(`Call-file summary shows ${input.callsByFile?.length ?? 0} of ${input.callFileCount} files; aggregate call count includes all checked files.`);
|
|
107
|
+
const scope = input.scope ?? { kind: "indexed_candidates", completeness: "not_guaranteed" };
|
|
108
|
+
if (input.format === "json") {
|
|
109
|
+
return JSON.stringify({
|
|
110
|
+
symbol: input.symbolName,
|
|
111
|
+
target: input.target,
|
|
112
|
+
ambiguous: ambiguousCandidates.length > 0,
|
|
113
|
+
ambiguousCandidates,
|
|
114
|
+
confidence: input.confidence,
|
|
115
|
+
scipSymbols: input.scipSymbols,
|
|
116
|
+
references: input.references,
|
|
117
|
+
total, returned: input.references.length, truncated, counts: input.counts, scope, warnings,
|
|
118
|
+
...(input.callsByFile ? { callsByFile: input.callsByFile, callFileCount: input.callFileCount, callFilesTruncated } : {}),
|
|
119
|
+
}, null, 2);
|
|
120
|
+
}
|
|
121
|
+
const ambiguityLines = ambiguousCandidates.length > 0
|
|
122
|
+
? [
|
|
123
|
+
`⚠ AMBIGUOUS: "${input.symbolName}" matched multiple declaration sites; showing up to five candidates. The inferred target is a best guess; with a supplied file, its first declaration is selected:`,
|
|
124
|
+
...ambiguousCandidates.map((c) => ` ${c.file}:L${c.line} [${c.kind}]`),
|
|
125
|
+
` Pass file/line explicitly to disambiguate if this looks wrong.`,
|
|
126
|
+
"",
|
|
127
|
+
]
|
|
128
|
+
: [];
|
|
129
|
+
if (input.references.length === 0) {
|
|
130
|
+
// Files the compiler could not check make an empty result unproven, not "no references".
|
|
131
|
+
const unchecked = warnings.some(w => w.includes("could not be checked"));
|
|
132
|
+
return [...ambiguityLines, ...warnings.map(w => `Warning: ${w}`), `${unchecked ? "Unverified: " : ""}No exact references found for "${input.symbolName}"${input.target ? ` from ${input.target.file}:${input.target.line}` : ""}.${unchecked ? " Some files were not checked; install the project's dependencies (for example npm install) and retry." : ""}`].join("\n");
|
|
133
|
+
}
|
|
134
|
+
const lines = [
|
|
135
|
+
`Exact references for "${input.symbolName}": ${input.references.length} returned of ${total} matched occurrences${truncated ? " (TRUNCATED)" : ""}`,
|
|
136
|
+
...(input.target ? [`Target: ${input.target.file}:${input.target.line}`] : []),
|
|
137
|
+
`Evidence: ${input.confidence}; scope is limited to indexed files, not all possible runtime references.`,
|
|
138
|
+
...(input.counts ? [`Occurrences: ${Object.entries(input.counts).map(([kind, count]) => `${kind}=${count}`).join(", ")}`] : []),
|
|
139
|
+
...(input.callsByFile?.length ? [`Calls by file (before result limit): ${input.callsByFile.map(entry => `${entry.file}=${entry.calls}`).join(", ")}`] : []),
|
|
140
|
+
...warnings.map(w => `Warning: ${w}`),
|
|
141
|
+
"",
|
|
142
|
+
...ambiguityLines,
|
|
143
|
+
];
|
|
144
|
+
const shownSnippets = new Set();
|
|
145
|
+
let repeatedSnippets = 0;
|
|
146
|
+
for (const ref of input.references) {
|
|
147
|
+
lines.push(`${ref.file}:${ref.line}:${ref.column}${ref.kind ? ` [${ref.kind}]` : ref.isDefinition ? " [definition]" : ""}`);
|
|
148
|
+
if (ref.context) {
|
|
149
|
+
const key = JSON.stringify([ref.file, ref.context]);
|
|
150
|
+
if (shownSnippets.has(key))
|
|
151
|
+
repeatedSnippets++;
|
|
152
|
+
else {
|
|
153
|
+
shownSnippets.add(key);
|
|
154
|
+
lines.push(` ${ref.context}`);
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
if (repeatedSnippets)
|
|
159
|
+
lines.push(`Identical snippets shown once per file (${repeatedSnippets} repeats); all returned locations retained.`);
|
|
160
|
+
return lines.join("\n");
|
|
161
|
+
}
|
|
162
|
+
async function formatScipFallback(options, target, warnings = []) {
|
|
163
|
+
const scip = await findScipReferences({
|
|
164
|
+
rootDir: options.rootDir,
|
|
165
|
+
symbolName: options.symbolName,
|
|
166
|
+
file: target?.file ?? options.file,
|
|
167
|
+
line: target?.line ?? options.line,
|
|
168
|
+
limit: options.limit,
|
|
169
|
+
});
|
|
170
|
+
if (!scip)
|
|
171
|
+
return null;
|
|
172
|
+
return formatReferencePayload({
|
|
173
|
+
symbolName: options.symbolName,
|
|
174
|
+
target,
|
|
175
|
+
confidence: "SCIP_RESOLVED",
|
|
176
|
+
references: scip.references.map((ref) => ({
|
|
177
|
+
file: ref.file,
|
|
178
|
+
line: ref.line,
|
|
179
|
+
column: ref.column,
|
|
180
|
+
context: ref.context,
|
|
181
|
+
isDefinition: ref.isDefinition,
|
|
182
|
+
confidence: "SCIP_RESOLVED",
|
|
183
|
+
})),
|
|
184
|
+
format: options.format,
|
|
185
|
+
scipSymbols: scip.symbols,
|
|
186
|
+
total: scip.total,
|
|
187
|
+
warnings: [...warnings, "Imported SCIP evidence has not been checked against the current source revision; reimport after source changes."],
|
|
188
|
+
scope: { kind: "imported_scip", completeness: "not_guaranteed", freshness: "unverified" },
|
|
189
|
+
});
|
|
190
|
+
}
|
|
191
|
+
function symbolPattern(symbolName) {
|
|
192
|
+
return new RegExp(`\\b${symbolName.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}\\b`, "g");
|
|
193
|
+
}
|
|
194
|
+
function escapeRegex(value) {
|
|
195
|
+
return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
196
|
+
}
|
|
197
|
+
async function pythonIndexReferences(options, target) {
|
|
198
|
+
const db = await getDB(options.rootDir);
|
|
199
|
+
const targetFile = db.getFile(target.file);
|
|
200
|
+
if (!targetFile)
|
|
201
|
+
return null;
|
|
202
|
+
const indexedFiles = db.getAllFiles();
|
|
203
|
+
const fileById = new Map(indexedFiles.map((file) => [file.id, file]));
|
|
204
|
+
const candidates = new Set([targetFile.id]);
|
|
205
|
+
const queue = [{ fileId: targetFile.id, depth: 0 }];
|
|
206
|
+
while (queue.length > 0) {
|
|
207
|
+
const current = queue.shift();
|
|
208
|
+
if (current.depth >= 6)
|
|
209
|
+
continue;
|
|
210
|
+
for (const importer of db.getImportersOf(current.fileId)) {
|
|
211
|
+
const source = fileById.get(importer.source_file_id);
|
|
212
|
+
if (!source || !isPython(source.path) || candidates.has(source.id))
|
|
213
|
+
continue;
|
|
214
|
+
candidates.add(source.id);
|
|
215
|
+
queue.push({ fileId: source.id, depth: current.depth + 1 });
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
const graphCandidateCount = candidates.size;
|
|
219
|
+
for (const call of db.getCallersOf(options.symbolName)) {
|
|
220
|
+
const source = fileById.get(call.file_id);
|
|
221
|
+
if (!source || !isPython(source.path))
|
|
222
|
+
continue;
|
|
223
|
+
if (graphCandidateCount > 1 && !candidates.has(source.id))
|
|
224
|
+
continue;
|
|
225
|
+
candidates.add(source.id);
|
|
226
|
+
}
|
|
227
|
+
const definitionLines = new Set(db.getSymbolsByFile(targetFile.id)
|
|
228
|
+
.filter((symbol) => symbol.name === options.symbolName)
|
|
229
|
+
.map((symbol) => symbol.line_start));
|
|
230
|
+
const references = [];
|
|
231
|
+
const pattern = symbolPattern(options.symbolName);
|
|
232
|
+
const escapedSymbol = escapeRegex(options.symbolName);
|
|
233
|
+
for (const fileId of candidates) {
|
|
234
|
+
const file = fileById.get(fileId);
|
|
235
|
+
if (!file)
|
|
236
|
+
continue;
|
|
237
|
+
let content = "";
|
|
238
|
+
try {
|
|
239
|
+
content = await readFile(resolveProjectPath(options.rootDir, file.path, "python reference file"), "utf-8");
|
|
240
|
+
}
|
|
241
|
+
catch {
|
|
242
|
+
continue;
|
|
243
|
+
}
|
|
244
|
+
const lines = content.split("\n");
|
|
245
|
+
for (let lineIndex = 0; lineIndex < lines.length; lineIndex++) {
|
|
246
|
+
const line = lines[lineIndex];
|
|
247
|
+
pattern.lastIndex = 0;
|
|
248
|
+
let match;
|
|
249
|
+
while ((match = pattern.exec(line)) !== null) {
|
|
250
|
+
const lineNumber = lineIndex + 1;
|
|
251
|
+
const trimmed = line.trim();
|
|
252
|
+
const isDefinition = file.path === target.file && (definitionLines.has(lineNumber)
|
|
253
|
+
|| new RegExp(`^def\\s+${escapedSymbol}\\b`).test(trimmed)
|
|
254
|
+
|| new RegExp(`^class\\s+${escapedSymbol}\\b`).test(trimmed));
|
|
255
|
+
const looksRelevant = isDefinition
|
|
256
|
+
|| /^from\s+[\w.]+\s+import\b/.test(trimmed)
|
|
257
|
+
|| /^import\s+[\w.]+/.test(trimmed)
|
|
258
|
+
|| /\w+\s*\(/.test(trimmed)
|
|
259
|
+
|| trimmed.includes(options.symbolName);
|
|
260
|
+
if (!looksRelevant)
|
|
261
|
+
continue;
|
|
262
|
+
references.push({
|
|
263
|
+
file: file.path,
|
|
264
|
+
line: lineNumber,
|
|
265
|
+
column: match.index + 1,
|
|
266
|
+
context: trimmed.slice(0, 160),
|
|
267
|
+
isDefinition,
|
|
268
|
+
confidence: "PYTHON_INDEX_RESOLVED",
|
|
269
|
+
});
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
const unique = new Map();
|
|
274
|
+
for (const ref of references)
|
|
275
|
+
unique.set(`${ref.file}:${ref.line}:${ref.column}:${ref.isDefinition}`, ref);
|
|
276
|
+
const total = unique.size;
|
|
277
|
+
const limited = [...unique.values()]
|
|
278
|
+
.sort((a, b) => Number(b.isDefinition) - Number(a.isDefinition) || a.file.localeCompare(b.file) || a.line - b.line || a.column - b.column)
|
|
279
|
+
.slice(0, Math.max(1, Math.min(options.limit ?? 100, 500)));
|
|
280
|
+
if (limited.length === 0)
|
|
281
|
+
return null;
|
|
282
|
+
return formatReferencePayload({
|
|
283
|
+
symbolName: options.symbolName,
|
|
284
|
+
target,
|
|
285
|
+
confidence: "PYTHON_INDEX_RESOLVED",
|
|
286
|
+
total,
|
|
287
|
+
warnings: ["Python import/call candidates are heuristic; this is not binding-resolved or exhaustive."],
|
|
288
|
+
references: limited,
|
|
289
|
+
format: options.format,
|
|
290
|
+
});
|
|
291
|
+
}
|
|
292
|
+
export async function exactReferencesTool(options) {
|
|
293
|
+
const target = await resolveTarget(options);
|
|
294
|
+
if (!target) {
|
|
295
|
+
const scipResult = await formatScipFallback(options);
|
|
296
|
+
if (scipResult)
|
|
297
|
+
return scipResult;
|
|
298
|
+
if (options.file)
|
|
299
|
+
return `No declaration found for symbol "${options.symbolName}" in ${options.file}. Provide the line of a known occurrence explicitly, or choose its definition file.`;
|
|
300
|
+
return `No indexed definition found for symbol "${options.symbolName}". Run reindex, import a SCIP JSON index, or provide file and line.`;
|
|
301
|
+
}
|
|
302
|
+
if (!isTypeScriptLike(target.file)) {
|
|
303
|
+
if (isPython(target.file) && pythonLanguageServerConfigured()) {
|
|
304
|
+
const source = await readFile(resolveProjectPath(options.rootDir, target.file), "utf8");
|
|
305
|
+
const line = source.split("\n")[target.line - 1] ?? "";
|
|
306
|
+
const escaped = options.symbolName.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
307
|
+
const matches = [...line.matchAll(new RegExp(`(?<![\\p{ID_Continue}])${escaped}(?![\\p{ID_Continue}])`, "gu"))];
|
|
308
|
+
if (matches.length !== 1)
|
|
309
|
+
throw new Error("Python reference target is absent or ambiguous on the supplied line.");
|
|
310
|
+
const db = await getDB(options.rootDir);
|
|
311
|
+
const found = await pythonOperation({ rootDir: options.rootDir, files: db.getAllFiles().filter(file => isPython(file.path)).map(file => file.path),
|
|
312
|
+
operation: "references", file: target.file, line: target.line, column: matches[0].index + 1 });
|
|
313
|
+
const references = (found.references ?? []).map(ref => ({ ...ref, confidence: "LSP_RESOLVED" }));
|
|
314
|
+
return formatReferencePayload({ symbolName: options.symbolName, target, confidence: "LSP_RESOLVED", references: references.slice(0, Math.max(1, Math.min(options.limit ?? 100, 500))), total: references.length,
|
|
315
|
+
warnings: found.warnings, scope: { kind: "python_pyright", completeness: "language_server_workspace" }, format: options.format });
|
|
316
|
+
}
|
|
317
|
+
const scipResult = await formatScipFallback(options, target);
|
|
318
|
+
if (scipResult)
|
|
319
|
+
return scipResult;
|
|
320
|
+
if (isPython(target.file)) {
|
|
321
|
+
const pythonResult = await pythonIndexReferences(options, target);
|
|
322
|
+
if (pythonResult)
|
|
323
|
+
return pythonResult;
|
|
324
|
+
}
|
|
325
|
+
return `Exact references require TypeScript/JavaScript language-service support, Python import/call index evidence, or an imported SCIP JSON index. Target file: ${target.file}`;
|
|
326
|
+
}
|
|
327
|
+
const { queryTypeScriptReferences } = await import("../core/typescript-reference-process.js");
|
|
328
|
+
const db = await getDB(options.rootDir);
|
|
329
|
+
const found = await queryTypeScriptReferences({
|
|
330
|
+
rootDir: options.rootDir,
|
|
331
|
+
files: db.getAllFiles().filter(file => isTypeScriptLike(file.path)).map(file => resolveProjectPath(options.rootDir, file.path, "indexed file")),
|
|
332
|
+
file: resolveProjectPath(options.rootDir, target.file, "reference target"),
|
|
333
|
+
line: target.line, symbol: options.symbolName,
|
|
334
|
+
limit: Math.max(1, Math.min(options.limit ?? 100, 500)),
|
|
335
|
+
});
|
|
336
|
+
if (found.total === 0) {
|
|
337
|
+
const scipResult = await formatScipFallback(options, target, [
|
|
338
|
+
...found.warnings, "TypeScript returned no references; using imported SCIP evidence as a fallback.",
|
|
339
|
+
]);
|
|
340
|
+
if (scipResult)
|
|
341
|
+
return scipResult;
|
|
342
|
+
}
|
|
343
|
+
const references = found.references.map(ref => ({ ...ref, confidence: "LSP_RESOLVED" }));
|
|
344
|
+
return formatReferencePayload({
|
|
345
|
+
symbolName: options.symbolName, target, confidence: "LSP_RESOLVED",
|
|
346
|
+
references,
|
|
347
|
+
total: found.total, counts: found.counts, callsByFile: found.callsByFile, callFileCount: found.callFileCount,
|
|
348
|
+
warnings: found.warnings, scope: found.scope, format: options.format,
|
|
349
|
+
});
|
|
350
|
+
}
|
|
351
|
+
//# sourceMappingURL=exact-references.js.map
|