contextpro-mcp 0.0.0-stage → 1.4.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 +416 -0
- package/INSTALL.md +128 -0
- package/INSTRUCTIONS.md +33 -0
- package/LICENSE +21 -0
- package/NOTICE +12 -0
- package/README.md +164 -2
- package/SECURITY.md +27 -0
- package/agent-guide.md +323 -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 +94 -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 +53 -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 +8 -0
- package/build/core/root-guard.d.ts.map +1 -0
- package/build/core/root-guard.js +53 -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 +599 -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 +349 -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 +26 -0
- package/docs/architecture.md +35 -0
- package/docs/configuration.md +178 -0
- package/docs/maintenance.md +77 -0
- package/package.json +80 -4
|
@@ -0,0 +1,750 @@
|
|
|
1
|
+
// Multi-language symbol extraction with tree-sitter AST + regex fallback
|
|
2
|
+
// Supports 36 languages via WASM grammars, regex fallback for unsupported
|
|
3
|
+
import { readFile } from "fs/promises";
|
|
4
|
+
import ts from "typescript";
|
|
5
|
+
import { extname } from "path";
|
|
6
|
+
import { parseWithTreeSitter, getSupportedExtensions } from "./tree-sitter.js";
|
|
7
|
+
import { maskSourceText } from "./source-mask.js";
|
|
8
|
+
export var SymbolKind;
|
|
9
|
+
(function (SymbolKind) {
|
|
10
|
+
SymbolKind["Function"] = "function";
|
|
11
|
+
SymbolKind["Class"] = "class";
|
|
12
|
+
SymbolKind["Method"] = "method";
|
|
13
|
+
SymbolKind["Enum"] = "enum";
|
|
14
|
+
SymbolKind["Interface"] = "interface";
|
|
15
|
+
SymbolKind["Struct"] = "struct";
|
|
16
|
+
SymbolKind["Type"] = "type";
|
|
17
|
+
SymbolKind["Trait"] = "trait";
|
|
18
|
+
SymbolKind["Const"] = "const";
|
|
19
|
+
SymbolKind["Variable"] = "variable";
|
|
20
|
+
SymbolKind["Export"] = "export";
|
|
21
|
+
})(SymbolKind || (SymbolKind = {}));
|
|
22
|
+
const LANG_MAP = {
|
|
23
|
+
".ts": "typescript",
|
|
24
|
+
".tsx": "typescript",
|
|
25
|
+
".js": "javascript",
|
|
26
|
+
".jsx": "javascript",
|
|
27
|
+
".mjs": "javascript",
|
|
28
|
+
".py": "python",
|
|
29
|
+
".rs": "rust",
|
|
30
|
+
".go": "go",
|
|
31
|
+
".java": "java",
|
|
32
|
+
".cs": "csharp",
|
|
33
|
+
".c": "c",
|
|
34
|
+
".cpp": "cpp",
|
|
35
|
+
".h": "c",
|
|
36
|
+
".hpp": "cpp",
|
|
37
|
+
".rb": "ruby",
|
|
38
|
+
".swift": "swift",
|
|
39
|
+
".kt": "kotlin",
|
|
40
|
+
".lua": "lua",
|
|
41
|
+
".zig": "zig",
|
|
42
|
+
// SQL participates in bounded source/FTS retrieval. No generic brace-based
|
|
43
|
+
// symbol extraction: SQL bodies and dollar quoting require a real grammar.
|
|
44
|
+
".sql": "sql",
|
|
45
|
+
};
|
|
46
|
+
const TS_PATTERNS = [
|
|
47
|
+
/^(?:export\s+)?(?:async\s+)?function\s+(\w+)\s*(<[^>]*>)?\s*\(([^)]*)\)(?:\s*:\s*([^\n{]+))?/,
|
|
48
|
+
/^(?:export\s+)?(?:abstract\s+)?class\s+(\w+)(?:\s+extends\s+\w+)?(?:\s+implements\s+[\w,\s]+)?/,
|
|
49
|
+
/^(?:export\s+)?(?:const\s+)?enum\s+(\w+)/,
|
|
50
|
+
/^(?:export\s+)?interface\s+(\w+)(?:\s+extends\s+[\w,\s<>]+)?/,
|
|
51
|
+
/^(?:export\s+)?type\s+(\w+)\s*(?:<[^>]*>)?\s*=/,
|
|
52
|
+
/^(?:export\s+)?const\s+(\w+)\s*(?::\s*[^=]+)?\s*=/,
|
|
53
|
+
];
|
|
54
|
+
const PY_PATTERNS = [
|
|
55
|
+
/^(?:async\s+)?def\s+(\w+)\s*\(([^)]*)\)(?:\s*->\s*(\S+))?/,
|
|
56
|
+
/^class\s+(\w+)(?:\(([^)]*)\))?/,
|
|
57
|
+
];
|
|
58
|
+
const RS_PATTERNS = [
|
|
59
|
+
/^(?:pub(?:\(crate\))?\s+)?(?:async\s+)?fn\s+(\w+)(?:<[^>]*>)?\s*\(([^)]*)\)(?:\s*->\s*([^\n{]+))?/,
|
|
60
|
+
/^(?:pub(?:\(crate\))?\s+)?struct\s+(\w+)(?:<[^>]*>)?/,
|
|
61
|
+
/^(?:pub(?:\(crate\))?\s+)?enum\s+(\w+)(?:<[^>]*>)?/,
|
|
62
|
+
/^(?:pub(?:\(crate\))?\s+)?trait\s+(\w+)(?:<[^>]*>)?/,
|
|
63
|
+
/^impl(?:<[^>]*>)?\s+(\w+)/,
|
|
64
|
+
];
|
|
65
|
+
const GO_PATTERNS = [
|
|
66
|
+
/^func\s+(?:\(\w+\s+\*?\w+\)\s+)?(\w+)\s*\(([^)]*)\)(?:\s*(?:\(([^)]*)\)|(\w+)))?/,
|
|
67
|
+
/^type\s+(\w+)\s+struct/,
|
|
68
|
+
/^type\s+(\w+)\s+interface/,
|
|
69
|
+
];
|
|
70
|
+
const JAVA_PATTERNS = [
|
|
71
|
+
/^(?:public|private|protected)?\s*(?:static\s+)?(?:abstract\s+)?(?:final\s+)?(?:\w+(?:<[^>]*>)?)\s+(\w+)\s*\(/,
|
|
72
|
+
/^(?:public|private|protected)?\s*(?:abstract\s+)?(?:final\s+)?class\s+(\w+)/,
|
|
73
|
+
/^(?:public|private|protected)?\s*(?:abstract\s+)?interface\s+(\w+)/,
|
|
74
|
+
/^(?:public|private|protected)?\s*enum\s+(\w+)/,
|
|
75
|
+
];
|
|
76
|
+
function detectLanguage(filePath) {
|
|
77
|
+
return LANG_MAP[extname(filePath).toLowerCase()] ?? null;
|
|
78
|
+
}
|
|
79
|
+
function extractHeader(lines) {
|
|
80
|
+
const headerLines = [];
|
|
81
|
+
let block = false;
|
|
82
|
+
for (const line of lines.slice(0, 10)) {
|
|
83
|
+
const trimmed = line.trim();
|
|
84
|
+
if (!trimmed)
|
|
85
|
+
continue;
|
|
86
|
+
if (trimmed.startsWith("#!"))
|
|
87
|
+
continue;
|
|
88
|
+
if (!block && !/^(?:\/\/|#|--|\/\*)/.test(trimmed))
|
|
89
|
+
break;
|
|
90
|
+
const closes = trimmed.includes("*/");
|
|
91
|
+
if (trimmed.startsWith("/*"))
|
|
92
|
+
block = true;
|
|
93
|
+
const stripped = trimmed.replace(/\*\/.*$/, "").replace(/^(?:\/\/|#|--|\/\*+|\*)\s?/, "").trim();
|
|
94
|
+
if (stripped)
|
|
95
|
+
headerLines.push(stripped);
|
|
96
|
+
if (closes)
|
|
97
|
+
block = false;
|
|
98
|
+
if (headerLines.length >= 2)
|
|
99
|
+
break;
|
|
100
|
+
}
|
|
101
|
+
return headerLines.join(" | ");
|
|
102
|
+
}
|
|
103
|
+
function matchPatterns(line, patterns, kindMap) {
|
|
104
|
+
for (let i = 0; i < patterns.length; i++) {
|
|
105
|
+
const match = line.match(patterns[i]);
|
|
106
|
+
if (match?.[1]) {
|
|
107
|
+
return {
|
|
108
|
+
name: match[1],
|
|
109
|
+
kind: kindMap[i] ?? SymbolKind.Function,
|
|
110
|
+
line: 0,
|
|
111
|
+
endLine: 0,
|
|
112
|
+
signature: line.trim().replace(/\s*\{?\s*$/, ""),
|
|
113
|
+
children: [],
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
return null;
|
|
118
|
+
}
|
|
119
|
+
function findBraceBlockEnd(lines, startIndex) {
|
|
120
|
+
let depth = 0;
|
|
121
|
+
let seenOpening = false;
|
|
122
|
+
for (let i = startIndex; i < lines.length; i++) {
|
|
123
|
+
const line = lines[i];
|
|
124
|
+
for (const ch of line) {
|
|
125
|
+
if (ch === "{") {
|
|
126
|
+
depth++;
|
|
127
|
+
seenOpening = true;
|
|
128
|
+
}
|
|
129
|
+
else if (ch === "}" && seenOpening) {
|
|
130
|
+
depth--;
|
|
131
|
+
if (depth <= 0)
|
|
132
|
+
return i + 1;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
return startIndex + 1;
|
|
137
|
+
}
|
|
138
|
+
function findIndentBlockEnd(lines, startIndex, baseIndent) {
|
|
139
|
+
for (let i = startIndex + 1; i < lines.length; i++) {
|
|
140
|
+
const raw = lines[i];
|
|
141
|
+
const trimmed = raw.trim();
|
|
142
|
+
if (!trimmed)
|
|
143
|
+
continue;
|
|
144
|
+
const indent = raw.length - raw.trimStart().length;
|
|
145
|
+
if (indent <= baseIndent)
|
|
146
|
+
return i;
|
|
147
|
+
}
|
|
148
|
+
return lines.length;
|
|
149
|
+
}
|
|
150
|
+
function parseTypeScript(lines) {
|
|
151
|
+
const symbols = [];
|
|
152
|
+
const kindMap = [SymbolKind.Function, SymbolKind.Class, SymbolKind.Enum, SymbolKind.Interface, SymbolKind.Type, SymbolKind.Const];
|
|
153
|
+
let currentClass = null;
|
|
154
|
+
for (let i = 0; i < lines.length; i++) {
|
|
155
|
+
const trimmed = lines[i].trimStart();
|
|
156
|
+
const indent = lines[i].length - trimmed.length;
|
|
157
|
+
if (indent === 0 || trimmed.startsWith("export ")) {
|
|
158
|
+
const sym = matchPatterns(trimmed, TS_PATTERNS, kindMap);
|
|
159
|
+
if (sym) {
|
|
160
|
+
sym.line = i + 1;
|
|
161
|
+
if ([SymbolKind.Function, SymbolKind.Class, SymbolKind.Interface, SymbolKind.Enum].includes(sym.kind)) {
|
|
162
|
+
sym.endLine = findBraceBlockEnd(lines, i);
|
|
163
|
+
}
|
|
164
|
+
else {
|
|
165
|
+
sym.endLine = i + 1;
|
|
166
|
+
}
|
|
167
|
+
if (sym.kind === SymbolKind.Class)
|
|
168
|
+
currentClass = sym;
|
|
169
|
+
else
|
|
170
|
+
currentClass = null;
|
|
171
|
+
symbols.push(sym);
|
|
172
|
+
continue;
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
if (currentClass && indent >= 2) {
|
|
176
|
+
const methodMatch = trimmed.match(/^(?:public|private|protected|static|async|readonly|\s)*\s*(?:get|set\s+)?(\w+)\s*(?:<[^>]*>)?\s*\(([^)]*)\)(?:\s*:\s*([^\n{]+))?/);
|
|
177
|
+
if (methodMatch?.[1] && !["if", "for", "while", "switch", "return", "throw", "new", "delete"].includes(methodMatch[1])) {
|
|
178
|
+
currentClass.children.push({
|
|
179
|
+
name: methodMatch[1],
|
|
180
|
+
kind: SymbolKind.Method,
|
|
181
|
+
line: i + 1,
|
|
182
|
+
endLine: findBraceBlockEnd(lines, i),
|
|
183
|
+
signature: trimmed.replace(/\s*\{?\s*$/, ""),
|
|
184
|
+
children: [],
|
|
185
|
+
});
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
return symbols;
|
|
190
|
+
}
|
|
191
|
+
function parsePython(lines) {
|
|
192
|
+
const symbols = [];
|
|
193
|
+
const kindMap = [SymbolKind.Function, SymbolKind.Class];
|
|
194
|
+
let currentClass = null;
|
|
195
|
+
for (let i = 0; i < lines.length; i++) {
|
|
196
|
+
const trimmed = lines[i].trimStart();
|
|
197
|
+
const indent = lines[i].length - trimmed.length;
|
|
198
|
+
if (indent === 0) {
|
|
199
|
+
const sym = matchPatterns(trimmed, PY_PATTERNS, kindMap);
|
|
200
|
+
if (sym) {
|
|
201
|
+
sym.line = i + 1;
|
|
202
|
+
sym.endLine = findIndentBlockEnd(lines, i, indent);
|
|
203
|
+
if (sym.kind === SymbolKind.Class)
|
|
204
|
+
currentClass = sym;
|
|
205
|
+
else
|
|
206
|
+
currentClass = null;
|
|
207
|
+
symbols.push(sym);
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
else if (currentClass && indent >= 4 && trimmed.startsWith("def ")) {
|
|
211
|
+
const methodMatch = trimmed.match(/^(?:async\s+)?def\s+(\w+)\s*\(([^)]*)\)(?:\s*->\s*(\S+))?/);
|
|
212
|
+
if (methodMatch?.[1]) {
|
|
213
|
+
currentClass.children.push({
|
|
214
|
+
name: methodMatch[1],
|
|
215
|
+
kind: SymbolKind.Method,
|
|
216
|
+
line: i + 1,
|
|
217
|
+
endLine: findIndentBlockEnd(lines, i, indent),
|
|
218
|
+
signature: trimmed.replace(/\s*:\s*$/, ""),
|
|
219
|
+
children: [],
|
|
220
|
+
});
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
return symbols;
|
|
225
|
+
}
|
|
226
|
+
function parseRust(lines) {
|
|
227
|
+
const symbols = [];
|
|
228
|
+
const kindMap = [SymbolKind.Function, SymbolKind.Struct, SymbolKind.Enum, SymbolKind.Trait, SymbolKind.Class];
|
|
229
|
+
for (let i = 0; i < lines.length; i++) {
|
|
230
|
+
const trimmed = lines[i].trimStart();
|
|
231
|
+
const sym = matchPatterns(trimmed, RS_PATTERNS, kindMap);
|
|
232
|
+
if (sym) {
|
|
233
|
+
sym.line = i + 1;
|
|
234
|
+
sym.endLine = findBraceBlockEnd(lines, i);
|
|
235
|
+
symbols.push(sym);
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
return symbols;
|
|
239
|
+
}
|
|
240
|
+
function parseGo(lines) {
|
|
241
|
+
const symbols = [];
|
|
242
|
+
const kindMap = [SymbolKind.Function, SymbolKind.Struct, SymbolKind.Interface];
|
|
243
|
+
for (let i = 0; i < lines.length; i++) {
|
|
244
|
+
const trimmed = lines[i].trimStart();
|
|
245
|
+
const sym = matchPatterns(trimmed, GO_PATTERNS, kindMap);
|
|
246
|
+
if (sym) {
|
|
247
|
+
sym.line = i + 1;
|
|
248
|
+
sym.endLine = findBraceBlockEnd(lines, i);
|
|
249
|
+
symbols.push(sym);
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
return symbols;
|
|
253
|
+
}
|
|
254
|
+
function parseJava(lines) {
|
|
255
|
+
const symbols = [];
|
|
256
|
+
const kindMap = [SymbolKind.Method, SymbolKind.Class, SymbolKind.Interface, SymbolKind.Enum];
|
|
257
|
+
let currentClass = null;
|
|
258
|
+
for (let i = 0; i < lines.length; i++) {
|
|
259
|
+
const trimmed = lines[i].trimStart();
|
|
260
|
+
const indent = lines[i].length - trimmed.length;
|
|
261
|
+
if (indent <= 0) {
|
|
262
|
+
const sym = matchPatterns(trimmed, JAVA_PATTERNS, kindMap);
|
|
263
|
+
if (sym && (sym.kind === SymbolKind.Class || sym.kind === SymbolKind.Interface || sym.kind === SymbolKind.Enum)) {
|
|
264
|
+
sym.line = i + 1;
|
|
265
|
+
sym.endLine = findBraceBlockEnd(lines, i);
|
|
266
|
+
currentClass = sym;
|
|
267
|
+
symbols.push(sym);
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
else if (currentClass && indent >= 2) {
|
|
271
|
+
const sym = matchPatterns(trimmed, JAVA_PATTERNS, kindMap);
|
|
272
|
+
if (sym && sym.kind === SymbolKind.Method) {
|
|
273
|
+
sym.line = i + 1;
|
|
274
|
+
sym.endLine = findBraceBlockEnd(lines, i);
|
|
275
|
+
currentClass.children.push(sym);
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
return symbols;
|
|
280
|
+
}
|
|
281
|
+
function parseGeneric(lines) {
|
|
282
|
+
const symbols = [];
|
|
283
|
+
const genericPatterns = [
|
|
284
|
+
/^(?:pub\s+)?(?:export\s+)?(?:async\s+)?(?:fn|func|function|def)\s+(\w+)/,
|
|
285
|
+
/^(?:pub\s+)?(?:export\s+)?(?:class|struct)\s+(\w+)/,
|
|
286
|
+
/^(?:pub\s+)?(?:export\s+)?(?:enum|interface|type|trait)\s+(\w+)/,
|
|
287
|
+
];
|
|
288
|
+
const kindMap = [SymbolKind.Function, SymbolKind.Class, SymbolKind.Enum];
|
|
289
|
+
for (let i = 0; i < lines.length; i++) {
|
|
290
|
+
const sym = matchPatterns(lines[i].trimStart(), genericPatterns, kindMap);
|
|
291
|
+
if (sym) {
|
|
292
|
+
sym.line = i + 1;
|
|
293
|
+
sym.endLine = findBraceBlockEnd(lines, i);
|
|
294
|
+
symbols.push(sym);
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
return symbols;
|
|
298
|
+
}
|
|
299
|
+
function lineNumberAt(content, index) {
|
|
300
|
+
return content.slice(0, index).split("\n").length;
|
|
301
|
+
}
|
|
302
|
+
function findStatementEnd(lines, startLine) {
|
|
303
|
+
for (let i = startLine - 1; i < lines.length; i++) {
|
|
304
|
+
const trimmed = lines[i].trim();
|
|
305
|
+
if (trimmed.endsWith(");") || trimmed === ");" || trimmed.endsWith(";")) {
|
|
306
|
+
return i + 1;
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
return startLine;
|
|
310
|
+
}
|
|
311
|
+
function addReactWrapperSymbols(content, lines, symbols) {
|
|
312
|
+
const existing = new Set(symbols.map((symbol) => symbol.name));
|
|
313
|
+
const additions = [];
|
|
314
|
+
const patterns = [
|
|
315
|
+
/(?:export\s+)?(?:const|let|var)\s+([A-Z][A-Za-z0-9_]*)\s*=\s*(?:React\.)?(?:memo|forwardRef)\s*\(/g,
|
|
316
|
+
/export\s+default\s+(?:React\.)?(?:memo|forwardRef)\s*\(\s*function\s+([A-Z][A-Za-z0-9_]*)\s*\(/g,
|
|
317
|
+
];
|
|
318
|
+
for (const pattern of patterns) {
|
|
319
|
+
let match;
|
|
320
|
+
while ((match = pattern.exec(content)) !== null) {
|
|
321
|
+
const name = match[1];
|
|
322
|
+
if (!name || existing.has(name))
|
|
323
|
+
continue;
|
|
324
|
+
const line = lineNumberAt(content, match.index);
|
|
325
|
+
const signature = lines[line - 1]?.trim().slice(0, 180) ?? name;
|
|
326
|
+
additions.push({
|
|
327
|
+
name,
|
|
328
|
+
kind: SymbolKind.Function,
|
|
329
|
+
line,
|
|
330
|
+
endLine: findStatementEnd(lines, line),
|
|
331
|
+
signature,
|
|
332
|
+
children: [],
|
|
333
|
+
});
|
|
334
|
+
existing.add(name);
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
return additions.length > 0
|
|
338
|
+
? [...symbols, ...additions].sort((left, right) => left.line - right.line || left.name.localeCompare(right.name))
|
|
339
|
+
: symbols;
|
|
340
|
+
}
|
|
341
|
+
function isConfigFile(filePath) {
|
|
342
|
+
const lower = filePath.toLowerCase();
|
|
343
|
+
return /\.(config|conf|settings)\.(ts|tsx|js|jsx|mjs|cjs)$/.test(lower)
|
|
344
|
+
|| /(^|\/)(rsbuild|webpack|vite|rollup|next|nuxt|astro|svelte|tailwind|postcss|babel|eslint|jest|vitest|playwright|cypress)\.config\.[jt]sx?$/.test(lower);
|
|
345
|
+
}
|
|
346
|
+
const CONFIG_KEY_PATTERNS = [
|
|
347
|
+
/^\s*([a-zA-Z_$][a-zA-Z0-9_$]*)\s*:\s*[{[]/,
|
|
348
|
+
/^\s*([a-zA-Z_$][a-zA-Z0-9_$]*)\s*:\s*(?:true|false)\s*(?:[,}]|$)/,
|
|
349
|
+
/^\s*"([a-zA-Z_$][a-zA-Z0-9_$ -]*)"\s*:\s*[{[]/,
|
|
350
|
+
];
|
|
351
|
+
const CONFIG_MAX_DEPTH = 6;
|
|
352
|
+
function extractConfigKeys(lines) {
|
|
353
|
+
const keys = [];
|
|
354
|
+
const seenNames = new Set();
|
|
355
|
+
let depth = 0;
|
|
356
|
+
let inExportDefault = false;
|
|
357
|
+
let braceDepthAtExport = -1;
|
|
358
|
+
let inBlockComment = false;
|
|
359
|
+
let inString = null;
|
|
360
|
+
for (let i = 0; i < lines.length; i++) {
|
|
361
|
+
const line = lines[i];
|
|
362
|
+
// Lightweight string/comment state machine so we don't extract from comments or string contents.
|
|
363
|
+
// Tracks per-character; we don't need a perfect tokenizer, just good-enough for typical configs.
|
|
364
|
+
let lineHasCode = "";
|
|
365
|
+
for (let c = 0; c < line.length; c++) {
|
|
366
|
+
const ch = line[c];
|
|
367
|
+
const next = line[c + 1];
|
|
368
|
+
if (inBlockComment) {
|
|
369
|
+
if (ch === "*" && next === "/") {
|
|
370
|
+
inBlockComment = false;
|
|
371
|
+
c++;
|
|
372
|
+
}
|
|
373
|
+
continue;
|
|
374
|
+
}
|
|
375
|
+
if (inString) {
|
|
376
|
+
lineHasCode += ch;
|
|
377
|
+
if (ch === "\\") {
|
|
378
|
+
lineHasCode += next ?? "";
|
|
379
|
+
c++;
|
|
380
|
+
continue;
|
|
381
|
+
}
|
|
382
|
+
if (ch === inString)
|
|
383
|
+
inString = null;
|
|
384
|
+
continue;
|
|
385
|
+
}
|
|
386
|
+
if (ch === "/" && next === "/")
|
|
387
|
+
break; // line comment
|
|
388
|
+
if (ch === "/" && next === "*") {
|
|
389
|
+
inBlockComment = true;
|
|
390
|
+
c++;
|
|
391
|
+
continue;
|
|
392
|
+
}
|
|
393
|
+
if (ch === '"' || ch === "'" || ch === "`") {
|
|
394
|
+
inString = ch;
|
|
395
|
+
lineHasCode += ch;
|
|
396
|
+
continue;
|
|
397
|
+
}
|
|
398
|
+
lineHasCode += ch;
|
|
399
|
+
}
|
|
400
|
+
// Detect entry into an export default object literal — this is what we consider the "config root".
|
|
401
|
+
if (!inExportDefault && /^(?:\s*export\s+default\s+|\s*module\.exports\s*=\s*|\s*export\s+const\s+\w+\s*[:=])/m.test(lineHasCode) && lineHasCode.includes("{")) {
|
|
402
|
+
inExportDefault = true;
|
|
403
|
+
braceDepthAtExport = depth;
|
|
404
|
+
}
|
|
405
|
+
// Track depth only on the in-code portion of the line so braces in strings/comments don't count.
|
|
406
|
+
const opens = (lineHasCode.match(/[{[(]/g) ?? []).length;
|
|
407
|
+
const closes = (lineHasCode.match(/[}\])]/g) ?? []).length;
|
|
408
|
+
const startingDepth = depth;
|
|
409
|
+
depth += opens - closes;
|
|
410
|
+
if (depth < 0)
|
|
411
|
+
depth = 0;
|
|
412
|
+
if (inExportDefault && depth <= braceDepthAtExport) {
|
|
413
|
+
// Closed the top-level object — leave the config root.
|
|
414
|
+
inExportDefault = false;
|
|
415
|
+
braceDepthAtExport = -1;
|
|
416
|
+
}
|
|
417
|
+
// Skip if we're not inside the config root, or too deep.
|
|
418
|
+
if (!inExportDefault)
|
|
419
|
+
continue;
|
|
420
|
+
const relativeDepth = startingDepth - braceDepthAtExport;
|
|
421
|
+
if (relativeDepth > CONFIG_MAX_DEPTH)
|
|
422
|
+
continue;
|
|
423
|
+
for (const pattern of CONFIG_KEY_PATTERNS) {
|
|
424
|
+
const match = lineHasCode.match(pattern);
|
|
425
|
+
if (match?.[1]) {
|
|
426
|
+
const name = match[1].trim();
|
|
427
|
+
if (name.length < 2 || name.length > 40)
|
|
428
|
+
continue;
|
|
429
|
+
if (CONFIG_KEY_RESERVED.has(name))
|
|
430
|
+
continue;
|
|
431
|
+
if (seenNames.has(name))
|
|
432
|
+
continue;
|
|
433
|
+
seenNames.add(name);
|
|
434
|
+
keys.push({
|
|
435
|
+
name,
|
|
436
|
+
kind: SymbolKind.Const,
|
|
437
|
+
line: i + 1,
|
|
438
|
+
endLine: i + 1,
|
|
439
|
+
signature: line.trim().slice(0, 180),
|
|
440
|
+
children: [],
|
|
441
|
+
});
|
|
442
|
+
break;
|
|
443
|
+
}
|
|
444
|
+
}
|
|
445
|
+
}
|
|
446
|
+
return keys;
|
|
447
|
+
}
|
|
448
|
+
const CONFIG_KEY_RESERVED = new Set([
|
|
449
|
+
"default", "if", "for", "while", "return", "function", "class", "type", "const", "let",
|
|
450
|
+
"var", "import", "export", "from", "as", "true", "false", "null", "undefined",
|
|
451
|
+
"case", "switch", "throw", "new", "delete", "typeof", "instanceof", "in", "of",
|
|
452
|
+
]);
|
|
453
|
+
export async function analyzeFile(filePath) {
|
|
454
|
+
const raw = await readFile(filePath, "utf-8");
|
|
455
|
+
return analyzeContent(filePath, raw);
|
|
456
|
+
}
|
|
457
|
+
function recoverTypeScriptFunctions(filePath, content, symbols) {
|
|
458
|
+
const source = ts.createSourceFile(filePath, content, ts.ScriptTarget.Latest, true);
|
|
459
|
+
for (const statement of source.statements) {
|
|
460
|
+
if (!ts.isFunctionDeclaration(statement) || !statement.name || !statement.body)
|
|
461
|
+
continue;
|
|
462
|
+
const name = statement.name.text;
|
|
463
|
+
const startIndex = statement.getStart(source), endIndex = statement.end;
|
|
464
|
+
const line = source.getLineAndCharacterOfPosition(startIndex).line + 1;
|
|
465
|
+
const nameIndex = statement.name.getStart(source);
|
|
466
|
+
const nameLine = source.getLineAndCharacterOfPosition(nameIndex).line + 1;
|
|
467
|
+
if (symbols.some(symbol => symbol.name === name && (symbol.startIndex !== undefined
|
|
468
|
+
? symbol.startIndex >= startIndex && symbol.startIndex <= nameIndex
|
|
469
|
+
: symbol.line >= line && symbol.line <= nameLine)))
|
|
470
|
+
continue;
|
|
471
|
+
// Older tree-sitter grammars can omit complete functions with inline import return types.
|
|
472
|
+
const children = symbols.filter(symbol => symbol.startIndex !== undefined && symbol.endIndex !== undefined
|
|
473
|
+
&& symbol.startIndex >= startIndex && symbol.endIndex <= endIndex);
|
|
474
|
+
symbols = symbols.filter(symbol => !children.includes(symbol));
|
|
475
|
+
symbols.push({
|
|
476
|
+
name, kind: SymbolKind.Function, line,
|
|
477
|
+
endLine: source.getLineAndCharacterOfPosition(endIndex).line + 1,
|
|
478
|
+
startIndex, endIndex,
|
|
479
|
+
signature: statement.getText(source).split("\n")[0].trim().slice(0, 150),
|
|
480
|
+
children,
|
|
481
|
+
});
|
|
482
|
+
}
|
|
483
|
+
return symbols.sort((left, right) => left.line - right.line);
|
|
484
|
+
}
|
|
485
|
+
/**
|
|
486
|
+
* Analyze already-loaded source text under a logical path. Same logic as
|
|
487
|
+
* analyzeFile but without touching disk — lets callers parse content that isn't a
|
|
488
|
+
* working-tree file (e.g. an old git blob for semantic_diff).
|
|
489
|
+
*/
|
|
490
|
+
export async function analyzeContent(filePath, raw) {
|
|
491
|
+
const content = (raw.startsWith("") ? raw.slice(1) : raw).replace(/\r\n/g, "\n");
|
|
492
|
+
const lines = content.split("\n");
|
|
493
|
+
const ext = extname(filePath).toLowerCase();
|
|
494
|
+
let symbols = null;
|
|
495
|
+
try {
|
|
496
|
+
symbols = await parseWithTreeSitter(content, ext);
|
|
497
|
+
}
|
|
498
|
+
catch {
|
|
499
|
+
symbols = null;
|
|
500
|
+
}
|
|
501
|
+
if (!symbols) {
|
|
502
|
+
const lang = detectLanguage(filePath);
|
|
503
|
+
const parsers = {
|
|
504
|
+
typescript: parseTypeScript,
|
|
505
|
+
javascript: parseTypeScript,
|
|
506
|
+
python: parsePython,
|
|
507
|
+
rust: parseRust,
|
|
508
|
+
go: parseGo,
|
|
509
|
+
java: parseJava,
|
|
510
|
+
csharp: parseJava,
|
|
511
|
+
kotlin: parseJava,
|
|
512
|
+
sql: () => [],
|
|
513
|
+
};
|
|
514
|
+
symbols = (parsers[lang ?? ""] ?? parseGeneric)(lines);
|
|
515
|
+
}
|
|
516
|
+
if (ext === ".ts" || ext === ".tsx") {
|
|
517
|
+
symbols = recoverTypeScriptFunctions(filePath, content, symbols);
|
|
518
|
+
}
|
|
519
|
+
if ([".ts", ".tsx", ".js", ".jsx", ".mjs"].includes(ext)) {
|
|
520
|
+
symbols = addReactWrapperSymbols(content, lines, symbols);
|
|
521
|
+
}
|
|
522
|
+
if (isConfigFile(filePath)) {
|
|
523
|
+
const existingNames = new Set(symbols.map((sym) => `${sym.name}@${sym.line}`));
|
|
524
|
+
const configKeys = extractConfigKeys(lines).filter((key) => !existingNames.has(`${key.name}@${key.line}`));
|
|
525
|
+
if (configKeys.length > 0) {
|
|
526
|
+
symbols = [...symbols, ...configKeys].sort((left, right) => left.line - right.line || left.name.localeCompare(right.name));
|
|
527
|
+
}
|
|
528
|
+
}
|
|
529
|
+
// Tree-sitter consumed normalized text; translate offsets back to the caller's original
|
|
530
|
+
// source so BOM, CRLF, and Unicode prefixes survive exact source mutations.
|
|
531
|
+
if (content !== raw) {
|
|
532
|
+
const offsets = [];
|
|
533
|
+
for (let i = raw.startsWith("") ? 1 : 0; i < raw.length; i++) {
|
|
534
|
+
if (raw[i] === "\r" && raw[i + 1] === "\n")
|
|
535
|
+
continue;
|
|
536
|
+
offsets.push(i);
|
|
537
|
+
}
|
|
538
|
+
offsets.push(raw.length);
|
|
539
|
+
const translate = (items) => {
|
|
540
|
+
for (const item of items) {
|
|
541
|
+
if (item.startIndex !== undefined)
|
|
542
|
+
item.startIndex = offsets[item.startIndex];
|
|
543
|
+
if (item.endIndex !== undefined)
|
|
544
|
+
item.endIndex = offsets[item.endIndex];
|
|
545
|
+
translate(item.children);
|
|
546
|
+
}
|
|
547
|
+
};
|
|
548
|
+
translate(symbols);
|
|
549
|
+
}
|
|
550
|
+
return {
|
|
551
|
+
path: filePath,
|
|
552
|
+
header: extractHeader(lines),
|
|
553
|
+
symbols,
|
|
554
|
+
lineCount: lines.length,
|
|
555
|
+
};
|
|
556
|
+
}
|
|
557
|
+
export function formatSymbol(sym, indent = 0) {
|
|
558
|
+
const prefix = " ".repeat(indent);
|
|
559
|
+
const kindLabel = sym.kind === SymbolKind.Method ? "method" : sym.kind;
|
|
560
|
+
const lineLabel = sym.endLine > sym.line ? `L${sym.line}-L${sym.endLine}` : `L${sym.line}`;
|
|
561
|
+
let result = `${prefix}${kindLabel}: ${sym.name} (${lineLabel})`;
|
|
562
|
+
if (sym.kind === SymbolKind.Function || sym.kind === SymbolKind.Method) {
|
|
563
|
+
result = `${prefix}${kindLabel}: ${sym.signature} (${lineLabel})`;
|
|
564
|
+
}
|
|
565
|
+
for (const child of sym.children) {
|
|
566
|
+
result += "\n" + formatSymbol(child, indent + 1);
|
|
567
|
+
}
|
|
568
|
+
return result;
|
|
569
|
+
}
|
|
570
|
+
export function isSupportedFile(filePath) {
|
|
571
|
+
const ext = extname(filePath).toLowerCase();
|
|
572
|
+
if (detectLanguage(filePath) !== null)
|
|
573
|
+
return true;
|
|
574
|
+
return getSupportedExtensions().includes(ext);
|
|
575
|
+
}
|
|
576
|
+
const IMPORT_PATTERNS = {
|
|
577
|
+
typescript: [
|
|
578
|
+
/^import\s+(?:type\s+)?(?:\{([^}]+)\}|(\w+)(?:\s*,\s*\{([^}]+)\})?)\s+from\s+["']([^"']+)["']/,
|
|
579
|
+
/^import\s+["']([^"']+)["']/,
|
|
580
|
+
/^export\s+(?:type\s+)?\{([^}]+)\}\s+from\s+["']([^"']+)["']/,
|
|
581
|
+
/import\(["']([^"']+)["']\)/,
|
|
582
|
+
],
|
|
583
|
+
javascript: [
|
|
584
|
+
/^import\s+(?:\{([^}]+)\}|(\w+)(?:\s*,\s*\{([^}]+)\})?)\s+from\s+["']([^"']+)["']/,
|
|
585
|
+
/^import\s+["']([^"']+)["']/,
|
|
586
|
+
/^export\s+\{([^}]+)\}\s+from\s+["']([^"']+)["']/,
|
|
587
|
+
/require\(["']([^"']+)["']\)/,
|
|
588
|
+
/import\(["']([^"']+)["']\)/,
|
|
589
|
+
],
|
|
590
|
+
python: [
|
|
591
|
+
/^from\s+([\w.]+)\s+import\s+(.+)/,
|
|
592
|
+
/^import\s+([\w.]+)/,
|
|
593
|
+
],
|
|
594
|
+
go: [
|
|
595
|
+
/^\s*"([^"]+)"/,
|
|
596
|
+
/^\s*(\w+)\s+"([^"]+)"/,
|
|
597
|
+
],
|
|
598
|
+
rust: [
|
|
599
|
+
/^use\s+([\w:]+(?:::\{[^}]+\})?)/,
|
|
600
|
+
/^use\s+([\w:]+)\s+as\s+\w+/,
|
|
601
|
+
],
|
|
602
|
+
};
|
|
603
|
+
export function extractImports(content, filePath) {
|
|
604
|
+
// Parse TS/JS declarations as units: imports may span lines and contain
|
|
605
|
+
// aliases, type-only specifiers, or namespace bindings. Comments are not imports.
|
|
606
|
+
if (/\.[cm]?[jt]sx?$/i.test(filePath)) {
|
|
607
|
+
const source = ts.createSourceFile(filePath, content, ts.ScriptTarget.Latest, true);
|
|
608
|
+
const imports = [];
|
|
609
|
+
const add = (node, module, specifiers, type) => {
|
|
610
|
+
if (module && ts.isStringLiteral(module))
|
|
611
|
+
imports.push({ source: module.text, specifiers, type,
|
|
612
|
+
line: source.getLineAndCharacterOfPosition(node.getStart(source)).line + 1 });
|
|
613
|
+
};
|
|
614
|
+
const visit = (node) => {
|
|
615
|
+
if (ts.isImportDeclaration(node)) {
|
|
616
|
+
const clause = node.importClause, bindings = clause?.namedBindings;
|
|
617
|
+
const specs = clause?.name ? [clause.name.text] : [];
|
|
618
|
+
if (bindings && ts.isNamedImports(bindings))
|
|
619
|
+
specs.push(...bindings.elements.map(item => (item.propertyName ?? item.name).text));
|
|
620
|
+
else if (bindings)
|
|
621
|
+
specs.push(bindings.name.text);
|
|
622
|
+
add(node, node.moduleSpecifier, specs, "static");
|
|
623
|
+
}
|
|
624
|
+
else if (ts.isExportDeclaration(node)) {
|
|
625
|
+
const clause = node.exportClause;
|
|
626
|
+
const specs = clause && ts.isNamedExports(clause) ? clause.elements.map(item => (item.propertyName ?? item.name).text) : clause ? [clause.name.text] : [];
|
|
627
|
+
add(node, node.moduleSpecifier, specs, "re-export");
|
|
628
|
+
}
|
|
629
|
+
else if (ts.isImportEqualsDeclaration(node) && ts.isExternalModuleReference(node.moduleReference)) {
|
|
630
|
+
add(node, node.moduleReference.expression, [node.name.text], "static");
|
|
631
|
+
}
|
|
632
|
+
else if (ts.isCallExpression(node) && (node.expression.kind === ts.SyntaxKind.ImportKeyword || ts.isIdentifier(node.expression) && node.expression.text === "require")) {
|
|
633
|
+
add(node, node.arguments[0], [], "dynamic");
|
|
634
|
+
}
|
|
635
|
+
ts.forEachChild(node, visit);
|
|
636
|
+
};
|
|
637
|
+
visit(source);
|
|
638
|
+
return imports;
|
|
639
|
+
}
|
|
640
|
+
const ext = extname(filePath).toLowerCase();
|
|
641
|
+
const lang = LANG_MAP[ext];
|
|
642
|
+
if (!lang)
|
|
643
|
+
return [];
|
|
644
|
+
const langKey = (lang === "tsx" || lang === "typescript") ? "typescript"
|
|
645
|
+
: (lang === "jsx" || lang === "javascript") ? "javascript"
|
|
646
|
+
: lang;
|
|
647
|
+
const patterns = IMPORT_PATTERNS[langKey];
|
|
648
|
+
if (!patterns)
|
|
649
|
+
return [];
|
|
650
|
+
const imports = [];
|
|
651
|
+
const lines = content.split("\n");
|
|
652
|
+
for (let i = 0; i < lines.length; i++) {
|
|
653
|
+
const line = lines[i].trim();
|
|
654
|
+
if (langKey === "python") {
|
|
655
|
+
const fromMatch = line.match(/^from\s+([\w.]+)\s+import\s+(.+)/);
|
|
656
|
+
if (fromMatch) {
|
|
657
|
+
const specParts = fromMatch[2].split(",").map(s => s.trim().split(/\s+as\s+/)[0].trim()).filter(Boolean);
|
|
658
|
+
imports.push({ source: fromMatch[1], specifiers: specParts, type: "static", line: i + 1 });
|
|
659
|
+
continue;
|
|
660
|
+
}
|
|
661
|
+
const importMatch = line.match(/^import\s+([\w.]+)/);
|
|
662
|
+
if (importMatch) {
|
|
663
|
+
imports.push({ source: importMatch[1], specifiers: [], type: "static", line: i + 1 });
|
|
664
|
+
continue;
|
|
665
|
+
}
|
|
666
|
+
}
|
|
667
|
+
if (langKey === "go") {
|
|
668
|
+
const goMatch = line.match(/^\s*"([^"]+)"/);
|
|
669
|
+
if (goMatch) {
|
|
670
|
+
imports.push({ source: goMatch[1], specifiers: [], type: "static", line: i + 1 });
|
|
671
|
+
continue;
|
|
672
|
+
}
|
|
673
|
+
}
|
|
674
|
+
if (langKey === "rust") {
|
|
675
|
+
const useMatch = line.match(/^use\s+([\w:]+(?:::\{[^}]+\})?)/);
|
|
676
|
+
if (useMatch) {
|
|
677
|
+
imports.push({ source: useMatch[1], specifiers: [], type: "static", line: i + 1 });
|
|
678
|
+
continue;
|
|
679
|
+
}
|
|
680
|
+
}
|
|
681
|
+
}
|
|
682
|
+
return imports;
|
|
683
|
+
}
|
|
684
|
+
const CALL_SITE_KEYWORDS = new Set([
|
|
685
|
+
"if", "for", "while", "switch", "return", "throw", "catch", "new", "delete", "typeof",
|
|
686
|
+
"void", "yield", "await", "async", "function", "class", "do", "in", "of", "instanceof",
|
|
687
|
+
"import", "export", "default", "from", "as", "case", "break", "continue", "let", "const",
|
|
688
|
+
"var", "static", "public", "private", "protected", "true", "false", "null", "undefined",
|
|
689
|
+
"this", "super", "with", "try", "finally", "else", "interface", "type", "enum", "extends",
|
|
690
|
+
"implements", "abstract", "readonly", "declare", "namespace", "module", "package",
|
|
691
|
+
]);
|
|
692
|
+
const STDLIB_GLOBALS = new Set([
|
|
693
|
+
"Math", "JSON", "Object", "Array", "String", "Number", "Boolean", "Date", "RegExp",
|
|
694
|
+
"Map", "Set", "WeakMap", "WeakSet", "Promise", "Symbol", "BigInt", "Error", "TypeError",
|
|
695
|
+
"Reflect", "Proxy", "globalThis", "console", "process",
|
|
696
|
+
]);
|
|
697
|
+
export function extractCallSites(content, filePath) {
|
|
698
|
+
// SQL is indexed for literal source discovery, not cross-language call edges.
|
|
699
|
+
// Its comments, dollar-quoted bodies and database functions need a SQL-aware
|
|
700
|
+
// binding model before they can be exposed as application callers.
|
|
701
|
+
if (filePath && /\.sql$/i.test(filePath))
|
|
702
|
+
return [];
|
|
703
|
+
const lines = content.split("\n");
|
|
704
|
+
const codeLines = maskSourceText(content, filePath).split("\n");
|
|
705
|
+
const sites = [];
|
|
706
|
+
const callPattern = /(?<![A-Za-z0-9_$.])([a-zA-Z_$][a-zA-Z0-9_$]*)\s*\(/g;
|
|
707
|
+
const definitionPattern = /(?:function|class|interface|enum|type|const|let|var|def|fn|func|pub)\s+[a-zA-Z_$]/;
|
|
708
|
+
for (let i = 0; i < lines.length; i++) {
|
|
709
|
+
const line = lines[i];
|
|
710
|
+
const codeLine = codeLines[i] ?? "";
|
|
711
|
+
if (definitionPattern.test(codeLine))
|
|
712
|
+
continue;
|
|
713
|
+
callPattern.lastIndex = 0;
|
|
714
|
+
let match;
|
|
715
|
+
const seen = new Set();
|
|
716
|
+
while ((match = callPattern.exec(codeLine)) !== null) {
|
|
717
|
+
const callee = match[1];
|
|
718
|
+
if (seen.has(callee))
|
|
719
|
+
continue;
|
|
720
|
+
if (CALL_SITE_KEYWORDS.has(callee))
|
|
721
|
+
continue;
|
|
722
|
+
if (STDLIB_GLOBALS.has(callee))
|
|
723
|
+
continue;
|
|
724
|
+
if (callee.length < 2)
|
|
725
|
+
continue;
|
|
726
|
+
seen.add(callee);
|
|
727
|
+
sites.push({ callee, line: i + 1, context: line.trim().substring(0, 120) });
|
|
728
|
+
}
|
|
729
|
+
}
|
|
730
|
+
return sites;
|
|
731
|
+
}
|
|
732
|
+
export function flattenSymbols(symbols, parentName, parentIndex, out = []) {
|
|
733
|
+
for (const sym of symbols) {
|
|
734
|
+
const selfIndex = out.length;
|
|
735
|
+
out.push({
|
|
736
|
+
name: sym.name,
|
|
737
|
+
kind: sym.kind,
|
|
738
|
+
line: sym.line,
|
|
739
|
+
endLine: sym.endLine,
|
|
740
|
+
signature: sym.signature,
|
|
741
|
+
parentName,
|
|
742
|
+
parentIndex,
|
|
743
|
+
});
|
|
744
|
+
if (sym.children.length > 0) {
|
|
745
|
+
flattenSymbols(sym.children, sym.name, selfIndex, out);
|
|
746
|
+
}
|
|
747
|
+
}
|
|
748
|
+
return out;
|
|
749
|
+
}
|
|
750
|
+
//# sourceMappingURL=parser.js.map
|