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,118 @@
|
|
|
1
|
+
// Shared repo, freshness, and trust metadata for agent-facing JSON responses
|
|
2
|
+
// FEATURE: Trust envelope — explicit index state, evidence, and confidence
|
|
3
|
+
import { getDB, hashContent } from "./db.js";
|
|
4
|
+
import { stat } from "node:fs/promises";
|
|
5
|
+
import { matchesFileFingerprint, readSourceSnapshot } from "./file-fingerprint.js";
|
|
6
|
+
import { walkDirectory } from "./walker.js";
|
|
7
|
+
import { isSupportedFile } from "./parser.js";
|
|
8
|
+
function parseNumber(value) {
|
|
9
|
+
if (!value)
|
|
10
|
+
return null;
|
|
11
|
+
const parsed = Number(value);
|
|
12
|
+
return Number.isFinite(parsed) ? parsed : null;
|
|
13
|
+
}
|
|
14
|
+
function toIso(timestamp) {
|
|
15
|
+
return timestamp ? new Date(timestamp).toISOString() : null;
|
|
16
|
+
}
|
|
17
|
+
function clamp(value, min, max) {
|
|
18
|
+
return Math.max(min, Math.min(max, value));
|
|
19
|
+
}
|
|
20
|
+
export async function getIndexState(rootDir) {
|
|
21
|
+
const db = await getDB(rootDir);
|
|
22
|
+
const latestIndexedAt = db.getLatestIndexedAt();
|
|
23
|
+
const indexedSourceFiles = db.getAllFiles().filter((file) => isSupportedFile(file.path));
|
|
24
|
+
const indexedFiles = indexedSourceFiles.length;
|
|
25
|
+
const indexedPaths = new Set(indexedSourceFiles.map((file) => file.path));
|
|
26
|
+
const entries = await walkDirectory({ rootDir, depthLimit: 0 });
|
|
27
|
+
const sourceEntries = entries.filter((entry) => !entry.isDirectory && isSupportedFile(entry.path));
|
|
28
|
+
const sourcePaths = new Set(sourceEntries.map((entry) => entry.relativePath));
|
|
29
|
+
const missingIndexedFiles = sourceEntries.filter((entry) => !indexedPaths.has(entry.relativePath)).length;
|
|
30
|
+
const removedIndexedFiles = db.getRemovedFiles(sourcePaths).length;
|
|
31
|
+
const indexedByPath = new Map(indexedSourceFiles.map(file => [file.path, file]));
|
|
32
|
+
let changedIndexedFiles = 0;
|
|
33
|
+
for (const entry of sourceEntries) {
|
|
34
|
+
const indexed = indexedByPath.get(entry.relativePath);
|
|
35
|
+
if (!indexed)
|
|
36
|
+
continue;
|
|
37
|
+
try {
|
|
38
|
+
if (matchesFileFingerprint(indexed, await stat(entry.path)))
|
|
39
|
+
continue;
|
|
40
|
+
if (hashContent((await readSourceSnapshot(entry.path)).content) !== indexed.content_hash)
|
|
41
|
+
changedIndexedFiles++;
|
|
42
|
+
}
|
|
43
|
+
catch {
|
|
44
|
+
changedIndexedFiles++;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
const generation = db.getIndexGeneration();
|
|
48
|
+
const activeStatus = db.getMeta("index_status");
|
|
49
|
+
const state = activeStatus === "indexing"
|
|
50
|
+
? "indexing"
|
|
51
|
+
: indexedFiles === 0
|
|
52
|
+
? "empty"
|
|
53
|
+
: db.getMeta("index_repair_required") === "1" || generation === 0 || changedIndexedFiles > 0 || missingIndexedFiles > 0 || removedIndexedFiles > 0 || sourceEntries.length !== indexedFiles
|
|
54
|
+
? "stale"
|
|
55
|
+
: "fresh";
|
|
56
|
+
return {
|
|
57
|
+
generation,
|
|
58
|
+
indexedFiles,
|
|
59
|
+
sourceFiles: sourceEntries.length,
|
|
60
|
+
missingIndexedFiles,
|
|
61
|
+
removedIndexedFiles,
|
|
62
|
+
changedIndexedFiles,
|
|
63
|
+
lastIndexedAt: toIso(latestIndexedAt),
|
|
64
|
+
lastReindexAt: toIso(parseNumber(db.getMeta("last_reindex_at"))),
|
|
65
|
+
lastReindexDurationMs: parseNumber(db.getMeta("last_reindex_duration_ms")),
|
|
66
|
+
autoHubCount: parseNumber(db.getMeta("last_auto_hub_count")),
|
|
67
|
+
indexStartedAt: toIso(parseNumber(db.getMeta("index_started_at"))),
|
|
68
|
+
state,
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
export function buildFreshnessMetadata(indexState, input) {
|
|
72
|
+
const indexStateLabel = indexState.state === "empty"
|
|
73
|
+
? "empty"
|
|
74
|
+
: indexState.state === "indexing"
|
|
75
|
+
? "indexing"
|
|
76
|
+
: input.complete === false || (input.remainingStaleCount ?? 0) > 0 || indexState.state === "stale"
|
|
77
|
+
? "stale"
|
|
78
|
+
: input.staleCount > 0
|
|
79
|
+
? input.refreshed ? "refreshed" : "stale"
|
|
80
|
+
: "fresh";
|
|
81
|
+
return {
|
|
82
|
+
staleCount: input.staleCount,
|
|
83
|
+
refreshed: input.refreshed,
|
|
84
|
+
warning: input.warning,
|
|
85
|
+
indexGeneration: indexState.generation,
|
|
86
|
+
indexedFiles: indexState.indexedFiles,
|
|
87
|
+
lastIndexedAt: indexState.lastIndexedAt,
|
|
88
|
+
lastReindexAt: indexState.lastReindexAt,
|
|
89
|
+
lastReindexDurationMs: indexState.lastReindexDurationMs,
|
|
90
|
+
autoHubCount: indexState.autoHubCount,
|
|
91
|
+
indexState: indexStateLabel,
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
export function buildTrustMetadata(input) {
|
|
95
|
+
const evidence = [...new Set((input.evidence ?? []).filter(Boolean))];
|
|
96
|
+
const ambiguities = [...new Set((input.ambiguities ?? []).filter(Boolean))];
|
|
97
|
+
let confidence = input.baseConfidence ?? 0.72;
|
|
98
|
+
confidence += Math.min(evidence.length, 4) * 0.04;
|
|
99
|
+
confidence -= Math.min(ambiguities.length, 3) * 0.08;
|
|
100
|
+
if (input.freshness.indexState === "empty")
|
|
101
|
+
confidence -= 0.25;
|
|
102
|
+
if (input.freshness.indexState === "indexing")
|
|
103
|
+
confidence -= 0.14;
|
|
104
|
+
if (input.freshness.indexState === "stale")
|
|
105
|
+
confidence -= 0.18;
|
|
106
|
+
if (input.freshness.indexState === "refreshed")
|
|
107
|
+
confidence -= 0.08;
|
|
108
|
+
if (input.freshness.warning)
|
|
109
|
+
confidence -= 0.03;
|
|
110
|
+
return {
|
|
111
|
+
confidence: clamp(Number(confidence.toFixed(2)), 0.1, 0.99),
|
|
112
|
+
evidence,
|
|
113
|
+
ambiguities,
|
|
114
|
+
freshness: input.freshness,
|
|
115
|
+
artifact: input.artifact ?? null,
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
//# sourceMappingURL=context-metadata.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context-metadata.js","sourceRoot":"","sources":["../../src/core/context-metadata.ts"],"names":[],"mappings":"AAAA,6EAA6E;AAC7E,2EAA2E;AAE3E,OAAO,EAAE,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAC7C,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AACxC,OAAO,EAAE,sBAAsB,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAEnF,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAsC9C,SAAS,WAAW,CAAC,KAAoB;IACvC,IAAI,CAAC,KAAK;QAAE,OAAO,IAAI,CAAC;IACxB,MAAM,MAAM,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;IAC7B,OAAO,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC;AACjD,CAAC;AAED,SAAS,KAAK,CAAC,SAAwB;IAC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IAAI,CAAC;IAC/D,IAAI,KAAK,CAAC,SAAS,CAAC,UAAU,KAAK,WAAW;QAAE,UAAU,IAAI,IAAI,CAAC;IACnE,IAAI,KAAK,CAAC,SAAS,CAAC,OAAO;QAAE,UAAU,IAAI,IAAI,CAAC;IAChD,OAAO;QACL,UAAU,EAAE,KAAK,CAAC,MAAM,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,EAAE,GAAG,EAAE,IAAI,CAAC;QAC3D,QAAQ;QACR,WAAW;QACX,SAAS,EAAE,KAAK,CAAC,SAAS;QAC1B,QAAQ,EAAE,KAAK,CAAC,QAAQ,IAAI,IAAI;KACjC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export declare const CONTEXTPRO_DIR = ".contextpro";
|
|
2
|
+
export declare const LEGACY_CONTEXT_DIRS: readonly [".contextplus", ".mcp_data"];
|
|
3
|
+
export declare function migrateLegacyProjectData(rootDir: string): Promise<string | null>;
|
|
4
|
+
export declare function ensureContextProDir(rootDir: string): Promise<string | null>;
|
|
5
|
+
//# sourceMappingURL=data-dir.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"data-dir.d.ts","sourceRoot":"","sources":["../../src/core/data-dir.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,cAAc,gBAAgB,CAAC;AAC5C,eAAO,MAAM,mBAAmB,wCAAyC,CAAC;AAc1E,wBAAsB,wBAAwB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAwBtF;AAED,wBAAsB,mBAAmB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAKjF"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
// Canonical ContextPro project storage and one-way migration from legacy names.
|
|
2
|
+
import { cp, mkdir, rename, rm, stat } from "fs/promises";
|
|
3
|
+
import { join } from "path";
|
|
4
|
+
import { resolveProjectPath } from "./path-guard.js";
|
|
5
|
+
export const CONTEXTPRO_DIR = ".contextpro";
|
|
6
|
+
export const LEGACY_CONTEXT_DIRS = [".contextplus", ".mcp_data"];
|
|
7
|
+
async function pathExists(path) {
|
|
8
|
+
try {
|
|
9
|
+
await stat(path);
|
|
10
|
+
return true;
|
|
11
|
+
}
|
|
12
|
+
catch (error) {
|
|
13
|
+
if (error.code === "ENOENT")
|
|
14
|
+
return false;
|
|
15
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
16
|
+
process.stderr.write(`[contextpro/data-dir] stat failed for ${path}: ${message}\n`);
|
|
17
|
+
return false;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
export async function migrateLegacyProjectData(rootDir) {
|
|
21
|
+
const destination = resolveProjectPath(rootDir, CONTEXTPRO_DIR);
|
|
22
|
+
if (await pathExists(destination))
|
|
23
|
+
return null;
|
|
24
|
+
for (const legacyName of LEGACY_CONTEXT_DIRS) {
|
|
25
|
+
const source = resolveProjectPath(rootDir, legacyName);
|
|
26
|
+
if (!(await pathExists(source)))
|
|
27
|
+
continue;
|
|
28
|
+
try {
|
|
29
|
+
await rename(source, destination);
|
|
30
|
+
}
|
|
31
|
+
catch (renameError) {
|
|
32
|
+
const renameMessage = renameError instanceof Error ? renameError.message : String(renameError);
|
|
33
|
+
process.stderr.write(`[contextpro/data-dir] rename ${legacyName} → ${CONTEXTPRO_DIR} failed (${renameMessage}); falling back to recursive copy\n`);
|
|
34
|
+
try {
|
|
35
|
+
await cp(source, destination, { recursive: true, force: true });
|
|
36
|
+
await rm(source, { recursive: true, force: true });
|
|
37
|
+
}
|
|
38
|
+
catch (copyError) {
|
|
39
|
+
const copyMessage = copyError instanceof Error ? copyError.message : String(copyError);
|
|
40
|
+
throw new Error(`Failed to migrate legacy directory ${legacyName} to ${CONTEXTPRO_DIR}: ${copyMessage}`);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
return legacyName;
|
|
44
|
+
}
|
|
45
|
+
return null;
|
|
46
|
+
}
|
|
47
|
+
export async function ensureContextProDir(rootDir) {
|
|
48
|
+
const migratedFrom = await migrateLegacyProjectData(rootDir);
|
|
49
|
+
await mkdir(resolveProjectPath(rootDir, join(CONTEXTPRO_DIR, "backups")), { recursive: true });
|
|
50
|
+
await mkdir(resolveProjectPath(rootDir, join(CONTEXTPRO_DIR, "hubs")), { recursive: true });
|
|
51
|
+
return migratedFrom;
|
|
52
|
+
}
|
|
53
|
+
//# sourceMappingURL=data-dir.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"data-dir.js","sourceRoot":"","sources":["../../src/core/data-dir.ts"],"names":[],"mappings":"AAAA,gFAAgF;AAEhF,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AAC1D,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAC5B,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAErD,MAAM,CAAC,MAAM,cAAc,GAAG,aAAa,CAAC;AAC5C,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,cAAc,EAAE,WAAW,CAAU,CAAC;AAE1E,KAAK,UAAU,UAAU,CAAC,IAAY;IACpC,IAAI,CAAC;QACH,MAAM,IAAI,CAAC,IAAI,CAAC,CAAC;QACjB,OAAO,IAAI,CAAC;IACd,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,IAAK,KAA+B,CAAC,IAAI,KAAK,QAAQ;YAAE,OAAO,KAAK,CAAC;QACrE,MAAM,OAAO,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QACvE,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,yCAAyC,IAAI,KAAK,OAAO,IAAI,CAAC,CAAC;QACpF,OAAO,KAAK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,CAAC,CAAC;YAC3G,CAAC;QACH,CAAC;QACD,OAAO,UAAU,CAAC;IACpB,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,mBAAmB,CAAC,OAAe;IACvD,MAAM,YAAY,GAAG,MAAM,wBAAwB,CAAC,OAAO,CAAC,CAAC;IAC7D,MAAM,KAAK,CAAC,kBAAkB,CAAC,OAAO,EAAE,IAAI,CAAC,cAAc,EAAE,SAAS,CAAC,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IAC/F,MAAM,KAAK,CAAC,kBAAkB,CAAC,OAAO,EAAE,IAAI,CAAC,cAAc,EAAE,MAAM,CAAC,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IAC5F,OAAO,YAAY,CAAC;AACtB,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
type DatabaseType = import("better-sqlite3").Database;
|
|
2
|
+
export type BetterSqlite3Constructor = new (path: string, options?: unknown) => DatabaseType;
|
|
3
|
+
export type SqliteVecModule = {
|
|
4
|
+
load: (db: DatabaseType) => void;
|
|
5
|
+
};
|
|
6
|
+
export interface NativeStorageDiagnostic {
|
|
7
|
+
code: string;
|
|
8
|
+
message: string;
|
|
9
|
+
remediation: string[];
|
|
10
|
+
}
|
|
11
|
+
export interface NativeStorageProbe {
|
|
12
|
+
ok: boolean;
|
|
13
|
+
runtime: {
|
|
14
|
+
nodeVersion: string;
|
|
15
|
+
nodeAbi: string;
|
|
16
|
+
execPath: string;
|
|
17
|
+
};
|
|
18
|
+
diagnostic?: NativeStorageDiagnostic;
|
|
19
|
+
}
|
|
20
|
+
export declare function describeNativeStorageError(error: unknown): NativeStorageDiagnostic;
|
|
21
|
+
export declare function loadNativeStorageBindings(): {
|
|
22
|
+
Database: BetterSqlite3Constructor;
|
|
23
|
+
sqliteVec: SqliteVecModule;
|
|
24
|
+
};
|
|
25
|
+
export declare function ensureNativeStorage(): Promise<void>;
|
|
26
|
+
export declare function probeNativeStorage(): NativeStorageProbe;
|
|
27
|
+
export {};
|
|
28
|
+
//# sourceMappingURL=db-native.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"db-native.d.ts","sourceRoot":"","sources":["../../src/core/db-native.ts"],"names":[],"mappings":"AAWA,KAAK,YAAY,GAAG,OAAO,gBAAgB,EAAE,QAAQ,CAAC;AACtD,MAAM,MAAM,wBAAwB,GAAG,KAAK,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,OAAO,KAAK,YAAY,CAAC;AAC7F,MAAM,MAAM,eAAe,GAAG;IAAE,IAAI,EAAE,CAAC,EAAE,EAAE,YAAY,KAAK,IAAI,CAAA;CAAE,CAAC;AAEnE,MAAM,WAAW,uBAAuB;IACtC,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,MAAM,EAAE,CAAC;CACvB;AAED,MAAM,WAAW,kBAAkB;IACjC,EAAE,EAAE,OAAO,CAAC;IACZ,OAAO,EAAE;QACP,WAAW,EAAE,MAAM,CAAC;QACpB,OAAO,EAAE,MAAM,CAAC;QAChB,QAAQ,EAAE,MAAM,CAAC;KAClB,CAAC;IACF,UAAU,CAAC,EAAE,uBAAuB,CAAC;CACtC;AAqBD,wBAAgB,0BAA0B,CAAC,KAAK,EAAE,OAAO,GAAG,uBAAuB,CAelF;AAED,wBAAgB,yBAAyB,IAAI;IAAE,QAAQ,EAAE,wBAAwB,CAAC;IAAC,SAAS,EAAE,eAAe,CAAA;CAAE,CAmC9G;AAED,wBAAsB,mBAAmB,IAAI,OAAO,CAAC,IAAI,CAAC,CAMzD;AAED,wBAAgB,kBAAkB,IAAI,kBAAkB,CAiBvD"}
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
// Native SQLite module loader — probes and loads better-sqlite3 and sqlite-vec
|
|
2
|
+
// FEATURE: Isolated bootstrap so DB class stays free of ABI error-handling noise
|
|
3
|
+
import { createRequire } from "module";
|
|
4
|
+
import { existsSync } from "fs";
|
|
5
|
+
import { join } from "path";
|
|
6
|
+
import { getNativeRuntime } from "./native-runtime.js";
|
|
7
|
+
import { attemptNativeAutoRepair, getContextPlusPackageRoot } from "./native-repair.js";
|
|
8
|
+
const requireFromHere = createRequire(import.meta.url);
|
|
9
|
+
let cachedBindings = null;
|
|
10
|
+
function normalizeBetterSqliteModule(candidate) {
|
|
11
|
+
if (typeof candidate === "function")
|
|
12
|
+
return candidate;
|
|
13
|
+
if (candidate && typeof candidate.default === "function") {
|
|
14
|
+
return candidate.default;
|
|
15
|
+
}
|
|
16
|
+
throw new Error("better-sqlite3 did not expose a database constructor.");
|
|
17
|
+
}
|
|
18
|
+
function normalizeSqliteVecModule(candidate) {
|
|
19
|
+
const maybeModule = candidate && typeof candidate.load === "function"
|
|
20
|
+
? candidate
|
|
21
|
+
: candidate?.default;
|
|
22
|
+
if (maybeModule && typeof maybeModule.load === "function")
|
|
23
|
+
return maybeModule;
|
|
24
|
+
throw new Error("sqlite-vec did not expose a load(db) function.");
|
|
25
|
+
}
|
|
26
|
+
export function describeNativeStorageError(error) {
|
|
27
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
28
|
+
const remediation = [
|
|
29
|
+
`Run ContextPro doctor --fix with the failing host's Node runtime (${process.execPath}).`,
|
|
30
|
+
`Repair installs ABI-specific dependencies in the user cache without rebuilding shared node_modules.`,
|
|
31
|
+
`Restart the MCP host after fixing native dependencies so it respawns the server cleanly.`,
|
|
32
|
+
];
|
|
33
|
+
if (message.includes("Cannot find module") || message.includes("Could not locate the bindings file")) {
|
|
34
|
+
return { code: "native_module_missing", message, remediation };
|
|
35
|
+
}
|
|
36
|
+
if (message.includes("NODE_MODULE_VERSION") || message.includes("compiled against a different Node.js version")) {
|
|
37
|
+
return { code: "native_module_abi_mismatch", message, remediation };
|
|
38
|
+
}
|
|
39
|
+
return { code: "native_module_error", message, remediation };
|
|
40
|
+
}
|
|
41
|
+
export function loadNativeStorageBindings() {
|
|
42
|
+
if (cachedBindings)
|
|
43
|
+
return cachedBindings;
|
|
44
|
+
const candidates = [];
|
|
45
|
+
try {
|
|
46
|
+
const { directory } = getNativeRuntime(getContextPlusPackageRoot());
|
|
47
|
+
if (existsSync(join(directory, "package.json")))
|
|
48
|
+
candidates.push(() => ({
|
|
49
|
+
Database: normalizeBetterSqliteModule(requireFromHere(join(directory, "node_modules/better-sqlite3"))),
|
|
50
|
+
sqliteVec: normalizeSqliteVecModule(requireFromHere(join(directory, "node_modules/sqlite-vec"))),
|
|
51
|
+
}));
|
|
52
|
+
}
|
|
53
|
+
catch { /* A working bundled installation does not need a repair descriptor. */ }
|
|
54
|
+
candidates.push(() => ({
|
|
55
|
+
Database: normalizeBetterSqliteModule(requireFromHere("better-sqlite3")),
|
|
56
|
+
sqliteVec: normalizeSqliteVecModule(requireFromHere("sqlite-vec")),
|
|
57
|
+
}));
|
|
58
|
+
let lastError;
|
|
59
|
+
for (const load of candidates) {
|
|
60
|
+
try {
|
|
61
|
+
const bindings = load();
|
|
62
|
+
// better-sqlite3 loads its addon lazily. Do not cache a constructor until
|
|
63
|
+
// opening SQLite and loading its vector extension actually succeed.
|
|
64
|
+
const db = new bindings.Database(":memory:");
|
|
65
|
+
try {
|
|
66
|
+
bindings.sqliteVec.load(db);
|
|
67
|
+
db.prepare("SELECT vec_version()").get();
|
|
68
|
+
}
|
|
69
|
+
finally {
|
|
70
|
+
db.close();
|
|
71
|
+
}
|
|
72
|
+
cachedBindings = bindings;
|
|
73
|
+
return bindings;
|
|
74
|
+
}
|
|
75
|
+
catch (error) {
|
|
76
|
+
lastError = error;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
const diagnostic = describeNativeStorageError(lastError);
|
|
80
|
+
throw new Error(`ContextPro storage engine is unavailable [${diagnostic.code}]. ` +
|
|
81
|
+
`Runtime: ${process.execPath} (${process.version}, ABI ${process.versions.modules}). ` +
|
|
82
|
+
`Automatic repair uses an isolated per-ABI cache; CONTEXTPRO_NATIVE_AUTO_REPAIR=false disables it. ` +
|
|
83
|
+
`doctor --fix retries explicitly.\n${diagnostic.remediation.map((step) => ` - ${step}`).join("\n")}\n` +
|
|
84
|
+
`Underlying error: ${diagnostic.message}`);
|
|
85
|
+
}
|
|
86
|
+
export async function ensureNativeStorage() {
|
|
87
|
+
try {
|
|
88
|
+
loadNativeStorageBindings();
|
|
89
|
+
}
|
|
90
|
+
catch (error) {
|
|
91
|
+
if (!await attemptNativeAutoRepair(describeNativeStorageError(error).code))
|
|
92
|
+
throw error;
|
|
93
|
+
loadNativeStorageBindings();
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
export function probeNativeStorage() {
|
|
97
|
+
try {
|
|
98
|
+
const { Database, sqliteVec } = loadNativeStorageBindings();
|
|
99
|
+
const db = new Database(":memory:");
|
|
100
|
+
try {
|
|
101
|
+
sqliteVec.load(db);
|
|
102
|
+
db.prepare("SELECT 1").get();
|
|
103
|
+
}
|
|
104
|
+
finally {
|
|
105
|
+
db.close();
|
|
106
|
+
}
|
|
107
|
+
return {
|
|
108
|
+
ok: true,
|
|
109
|
+
runtime: { nodeVersion: process.version, nodeAbi: process.versions.modules ?? "unknown", execPath: process.execPath },
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
catch (error) {
|
|
113
|
+
return {
|
|
114
|
+
ok: false,
|
|
115
|
+
runtime: { nodeVersion: process.version, nodeAbi: process.versions.modules ?? "unknown", execPath: process.execPath },
|
|
116
|
+
diagnostic: describeNativeStorageError(error),
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
//# sourceMappingURL=db-native.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"db-native.js","sourceRoot":"","sources":["../../src/core/db-native.ts"],"names":[],"mappings":"AAAA,+EAA+E;AAC/E,iFAAiF;AAEjF,OAAO,EAAE,aAAa,EAAE,MAAM,QAAQ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uBAAuB,CAAC,0BAA0B,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC;YAAE,MAAM,KAAK,CAAC;QACxF,yBAAyB,EAAE,CAAC;IAC9B,CAAC;AACH,CAAC;AAED,MAAM,UAAU,kBAAkB;IAChC,IAAI,CAAC;QACH,MAAM,EAAE,QAAQ,EAAE,SAAS,EAAE,GAAG,yBAAyB,EAAE,CAAC;QAC5D,MAAM,EAAE,GAAG,IAAI,QAAQ,CAAC,UAAU,CAAC,CAAC;QACpC,IAAI,CAAC;YAAC,SAAS,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;YAAC,EAAE,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC,GAAG,EAAE,CAAC;QAAC,CAAC;gBACjD,CAAC;YAAC,EAAE,CAAC,KAAK,EAAE,CAAC;QAAC,CAAC;QACvB,OAAO;YACL,EAAE,EAAE,IAAI;YACR,OAAO,EAAE,EAAE,WAAW,EAAE,OAAO,CAAC,OAAO,EAAE,OAAO,EAAE,OAAO,CAAC,QAAQ,CAAC,OAAO,IAAI,SAAS,EAAE,QAAQ,EAAE,OAAO,CAAC,QAAQ,EAAE;SACtH,CAAC;IACJ,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO;YACL,EAAE,EAAE,KAAK;YACT,OAAO,EAAE,EAAE,WAAW,EAAE,OAAO,CAAC,OAAO,EAAE,OAAO,EAAE,OAAO,CAAC,QAAQ,CAAC,OAAO,IAAI,SAAS,EAAE,QAAQ,EAAE,OAAO,CAAC,QAAQ,EAAE;YACrH,UAAU,EAAE,0BAA0B,CAAC,KAAK,CAAC;SAC9C,CAAC;IACJ,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,294 @@
|
|
|
1
|
+
export interface FileRow {
|
|
2
|
+
id: number;
|
|
3
|
+
path: string;
|
|
4
|
+
content_hash: string;
|
|
5
|
+
header: string | null;
|
|
6
|
+
language: string | null;
|
|
7
|
+
symbol_count: number;
|
|
8
|
+
last_indexed_at: number;
|
|
9
|
+
file_size: number;
|
|
10
|
+
file_mtime_ms: number;
|
|
11
|
+
file_ctime_ms: number;
|
|
12
|
+
}
|
|
13
|
+
export interface ToolCallEfficiency {
|
|
14
|
+
inputTokens?: number;
|
|
15
|
+
outputTokens?: number;
|
|
16
|
+
sourceTokens?: number;
|
|
17
|
+
savedTokens?: number;
|
|
18
|
+
representedFiles?: number;
|
|
19
|
+
}
|
|
20
|
+
export interface ToolCallHistoryRow {
|
|
21
|
+
tool: string;
|
|
22
|
+
status: string;
|
|
23
|
+
durationMs: number;
|
|
24
|
+
calledAt: number;
|
|
25
|
+
inputTokens: number;
|
|
26
|
+
outputTokens: number;
|
|
27
|
+
sourceTokens: number;
|
|
28
|
+
savedTokens: number;
|
|
29
|
+
representedFiles: number;
|
|
30
|
+
}
|
|
31
|
+
export interface ToolEfficiencyAggregate {
|
|
32
|
+
tool: string;
|
|
33
|
+
calls: number;
|
|
34
|
+
errors: number;
|
|
35
|
+
avgMs: number;
|
|
36
|
+
maxMs: number;
|
|
37
|
+
lastAt: number;
|
|
38
|
+
inputTokens: number;
|
|
39
|
+
outputTokens: number;
|
|
40
|
+
sourceTokens: number;
|
|
41
|
+
savedTokens: number;
|
|
42
|
+
representedFiles: number;
|
|
43
|
+
}
|
|
44
|
+
export interface SymbolRow {
|
|
45
|
+
id: number;
|
|
46
|
+
file_id: number;
|
|
47
|
+
name: string;
|
|
48
|
+
kind: string;
|
|
49
|
+
line_start: number;
|
|
50
|
+
line_end: number | null;
|
|
51
|
+
signature: string | null;
|
|
52
|
+
parent_symbol_id: number | null;
|
|
53
|
+
}
|
|
54
|
+
export interface ParsedSymbol {
|
|
55
|
+
name: string;
|
|
56
|
+
kind: string;
|
|
57
|
+
lineStart: number;
|
|
58
|
+
lineEnd?: number;
|
|
59
|
+
signature?: string;
|
|
60
|
+
parentSymbolId?: number;
|
|
61
|
+
/** Index into the same `symbols` array passed to upsertSymbols, resolved to a real row id at insert time. */
|
|
62
|
+
parentIndex?: number;
|
|
63
|
+
}
|
|
64
|
+
export interface EmbeddingMatch {
|
|
65
|
+
rowid: number;
|
|
66
|
+
sourceType: string;
|
|
67
|
+
sourceId: string;
|
|
68
|
+
contentHash: string;
|
|
69
|
+
distance: number;
|
|
70
|
+
}
|
|
71
|
+
export interface MemoryNodeInput {
|
|
72
|
+
id?: string;
|
|
73
|
+
type: "concept" | "file" | "symbol" | "note";
|
|
74
|
+
label: string;
|
|
75
|
+
content: string;
|
|
76
|
+
metadata?: Record<string, string>;
|
|
77
|
+
}
|
|
78
|
+
export interface MemoryNodeRow {
|
|
79
|
+
id: string;
|
|
80
|
+
type: string;
|
|
81
|
+
label: string;
|
|
82
|
+
content: string;
|
|
83
|
+
created_at: number;
|
|
84
|
+
last_accessed: number;
|
|
85
|
+
access_count: number;
|
|
86
|
+
metadata: string;
|
|
87
|
+
}
|
|
88
|
+
export interface MemoryEdgeInput {
|
|
89
|
+
id?: string;
|
|
90
|
+
source: string;
|
|
91
|
+
target: string;
|
|
92
|
+
relation: string;
|
|
93
|
+
weight?: number;
|
|
94
|
+
metadata?: Record<string, string>;
|
|
95
|
+
}
|
|
96
|
+
export interface MemoryEdgeRow {
|
|
97
|
+
id: string;
|
|
98
|
+
source: string;
|
|
99
|
+
target: string;
|
|
100
|
+
relation: string;
|
|
101
|
+
weight: number;
|
|
102
|
+
created_at: number;
|
|
103
|
+
metadata: string;
|
|
104
|
+
}
|
|
105
|
+
export interface MemorySearchResult {
|
|
106
|
+
node: MemoryNodeRow;
|
|
107
|
+
distance: number;
|
|
108
|
+
}
|
|
109
|
+
export interface TraversalResult {
|
|
110
|
+
node: MemoryNodeRow;
|
|
111
|
+
depth: number;
|
|
112
|
+
pathRelations: string[];
|
|
113
|
+
relevanceScore: number;
|
|
114
|
+
}
|
|
115
|
+
export interface ImportRow {
|
|
116
|
+
id: number;
|
|
117
|
+
source_file_id: number;
|
|
118
|
+
target_path: string;
|
|
119
|
+
target_file_id: number | null;
|
|
120
|
+
import_type: string;
|
|
121
|
+
symbols_imported: string | null;
|
|
122
|
+
}
|
|
123
|
+
export interface CallSiteRow {
|
|
124
|
+
id: number;
|
|
125
|
+
file_id: number;
|
|
126
|
+
callee: string;
|
|
127
|
+
line: number;
|
|
128
|
+
context: string;
|
|
129
|
+
}
|
|
130
|
+
export interface FileTextSearchMatch {
|
|
131
|
+
path: string;
|
|
132
|
+
score: number;
|
|
133
|
+
}
|
|
134
|
+
export type { NativeStorageDiagnostic, NativeStorageProbe } from "./db-native.js";
|
|
135
|
+
export { describeNativeStorageError, probeNativeStorage } from "./db-native.js";
|
|
136
|
+
export declare function hashContent(content: string): string;
|
|
137
|
+
export declare function bufferToVec(buf: Buffer): number[];
|
|
138
|
+
export declare class ContextPlusDB {
|
|
139
|
+
private db;
|
|
140
|
+
private get vecDimension();
|
|
141
|
+
private rootDir;
|
|
142
|
+
constructor(rootDir: string);
|
|
143
|
+
private initMeta;
|
|
144
|
+
private runMigrations;
|
|
145
|
+
private ensureVecTables;
|
|
146
|
+
private createVecTablesIfNeeded;
|
|
147
|
+
private ensureVecDimension;
|
|
148
|
+
recordEmbeddingProvider(provider: string, model: string): void;
|
|
149
|
+
private recordEmbeddingProviderInTransaction;
|
|
150
|
+
isEmbeddingsStale(): {
|
|
151
|
+
stale: boolean;
|
|
152
|
+
reason: string | null;
|
|
153
|
+
};
|
|
154
|
+
clearEmbeddingsStaleFlag(): void;
|
|
155
|
+
private hasVectorTables;
|
|
156
|
+
private tableExists;
|
|
157
|
+
private columnExists;
|
|
158
|
+
private hasUsableEmbedding;
|
|
159
|
+
upsertFile(path: string, hash: string, header: string | null, language: string | null, fileSize?: number, fileMtimeMs?: number, fileCtimeMs?: number): number;
|
|
160
|
+
updateFileFingerprint(path: string, fileSize: number, fileMtimeMs: number, fileCtimeMs?: number, expectedHash?: string): void;
|
|
161
|
+
getFile(path: string): FileRow | null;
|
|
162
|
+
getFileById(id: number): FileRow | null;
|
|
163
|
+
getAllFiles(): FileRow[];
|
|
164
|
+
getStaleFiles(currentHashes: Map<string, string>): string[];
|
|
165
|
+
getRemovedFiles(currentPaths: Set<string>): string[];
|
|
166
|
+
deleteFile(path: string): void;
|
|
167
|
+
upsertSymbols(fileId: number, symbols: ParsedSymbol[]): void;
|
|
168
|
+
getSymbolsByFile(fileId: number): SymbolRow[];
|
|
169
|
+
searchSymbolsByName(query: string): SymbolRow[];
|
|
170
|
+
upsertEmbedding(sourceType: string, sourceId: number | string, vector: number[] | Float32Array, hash: string): void;
|
|
171
|
+
upsertEmbeddingsBatch(sourceType: string, entries: Array<{
|
|
172
|
+
sourceId: string;
|
|
173
|
+
vector: number[] | Float32Array;
|
|
174
|
+
hash: string;
|
|
175
|
+
}>): void;
|
|
176
|
+
private bumpEmbeddingRevision;
|
|
177
|
+
getEmbeddingsByType(sourceType: string): Array<{
|
|
178
|
+
sourceId: string;
|
|
179
|
+
contentHash: string;
|
|
180
|
+
vector: Buffer;
|
|
181
|
+
}>;
|
|
182
|
+
getEmbeddingStats(): {
|
|
183
|
+
vectorTablesReady: boolean;
|
|
184
|
+
dimension: number | null;
|
|
185
|
+
total: number;
|
|
186
|
+
fileSearch: number;
|
|
187
|
+
identifiers: number;
|
|
188
|
+
memory: number;
|
|
189
|
+
};
|
|
190
|
+
deleteEmbeddingsByPrefix(sourceType: string, prefix: string): void;
|
|
191
|
+
searchEmbeddings(queryVector: number[] | Float32Array, topK: number, sourceType?: string): EmbeddingMatch[];
|
|
192
|
+
getEmbeddingBySource(sourceType: string, sourceId: number): {
|
|
193
|
+
vector: Buffer;
|
|
194
|
+
hash: string;
|
|
195
|
+
} | null;
|
|
196
|
+
getEmbeddingHash(sourceType: string, sourceId: number): string | null;
|
|
197
|
+
getMemoryRevision(): number;
|
|
198
|
+
private bumpMemoryRevision;
|
|
199
|
+
upsertMemoryNode(input: MemoryNodeInput, embedding?: number[], model?: {
|
|
200
|
+
provider: string;
|
|
201
|
+
model: string;
|
|
202
|
+
}): string;
|
|
203
|
+
private upsertMemoryNodeInTransaction;
|
|
204
|
+
peekMemoryNode(id: string): MemoryNodeRow | null;
|
|
205
|
+
findMemoryNodeByLabel(type: string, label: string): MemoryNodeRow | null;
|
|
206
|
+
getMemoryNode(id: string): MemoryNodeRow | null;
|
|
207
|
+
listMemoryNodes(): MemoryNodeRow[];
|
|
208
|
+
listMemoryNodesWithoutEmbeddings(): MemoryNodeRow[];
|
|
209
|
+
setMemoryEmbedding(node: Pick<MemoryNodeRow, "id" | "label" | "content">, embedding: number[]): boolean;
|
|
210
|
+
deleteMemoryNode(id: string): void;
|
|
211
|
+
upsertMemoryEdge(input: MemoryEdgeInput): string;
|
|
212
|
+
deleteMemoryEdge(id: string): void;
|
|
213
|
+
getMemoryEdgesForNode(id: string): MemoryEdgeRow[];
|
|
214
|
+
searchMemoryNodes(queryVector: number[], topK?: number): MemorySearchResult[];
|
|
215
|
+
getNeighbors(nodeId: string, maxDepth?: number, edgeFilter?: string[]): TraversalResult[];
|
|
216
|
+
pruneStaleEdges(threshold?: number): {
|
|
217
|
+
edgesRemoved: number;
|
|
218
|
+
nodesRemoved: number;
|
|
219
|
+
};
|
|
220
|
+
ensureGraphFresh(): void;
|
|
221
|
+
upsertImport(sourceFileId: number, targetPath: string, targetFileId: number | null, importType?: string, symbolsImported?: string[]): void;
|
|
222
|
+
deleteImportsForFile(fileId: number): void;
|
|
223
|
+
getImportsFrom(fileId: number): ImportRow[];
|
|
224
|
+
getImportersOf(fileId: number): ImportRow[];
|
|
225
|
+
getAllImports(): ImportRow[];
|
|
226
|
+
updateImportTarget(importId: number, targetFileId: number | null): void;
|
|
227
|
+
upsertCallSites(fileId: number, sites: Array<{
|
|
228
|
+
callee: string;
|
|
229
|
+
line: number;
|
|
230
|
+
context: string;
|
|
231
|
+
}>): void;
|
|
232
|
+
getCallSitesByFile(fileId: number): CallSiteRow[];
|
|
233
|
+
getCallersOf(callee: string): CallSiteRow[];
|
|
234
|
+
upsertFileSearchDocument(input: {
|
|
235
|
+
path: string;
|
|
236
|
+
header?: string | null;
|
|
237
|
+
language?: string | null;
|
|
238
|
+
symbols?: Array<{
|
|
239
|
+
name: string;
|
|
240
|
+
kind?: string;
|
|
241
|
+
signature?: string | null;
|
|
242
|
+
}>;
|
|
243
|
+
content?: string;
|
|
244
|
+
}): void;
|
|
245
|
+
deleteFileSearchDocument(path: string): void;
|
|
246
|
+
searchFileText(query: string, topK?: number, phraseOnly?: boolean, requireAllTerms?: boolean): FileTextSearchMatch[];
|
|
247
|
+
getGraphStats(): {
|
|
248
|
+
totalNodes: number;
|
|
249
|
+
totalEdges: number;
|
|
250
|
+
};
|
|
251
|
+
/** Append one tool-call event. Best-effort telemetry — callers must not let a
|
|
252
|
+
* failure here break the tool itself. Prunes opportunistically to a bounded size. */
|
|
253
|
+
recordToolCall(tool: string, status: "ok" | "error", durationMs: number, calledAt: number, efficiency?: ToolCallEfficiency, sessionId?: string): void;
|
|
254
|
+
/** Most-recent tool calls, newest first. */
|
|
255
|
+
getToolCallHistory(limit?: number): ToolCallHistoryRow[];
|
|
256
|
+
/** Recent calls with a positive savings estimate, optionally bounded by time. */
|
|
257
|
+
getToolSavingsHistory(limit?: number, sinceMs?: number, sessionId?: string): ToolCallHistoryRow[];
|
|
258
|
+
/** Per-tool aggregates over the whole history (or since a timestamp). */
|
|
259
|
+
getToolCallAggregates(sinceMs?: number, sessionId?: string): ToolEfficiencyAggregate[];
|
|
260
|
+
getEfficiencyTotals(sinceMs?: number, sessionId?: string): Omit<ToolEfficiencyAggregate, "tool" | "avgMs" | "maxMs"> & {
|
|
261
|
+
avgMs: number;
|
|
262
|
+
maxMs: number;
|
|
263
|
+
};
|
|
264
|
+
getToolCallTotal(): number;
|
|
265
|
+
/** Keep the table bounded: delete all but the newest `keep` rows. */
|
|
266
|
+
pruneToolCalls(keep?: number): number;
|
|
267
|
+
getLatestIndexedAt(): number | null;
|
|
268
|
+
getIndexGeneration(): number;
|
|
269
|
+
bumpIndexGeneration(): number;
|
|
270
|
+
getMeta(key: string): string | null;
|
|
271
|
+
setMeta(key: string, value: string): void;
|
|
272
|
+
/**
|
|
273
|
+
* Atomic compare-and-set on the meta table. Returns true if the previous value matched
|
|
274
|
+
* `expected` and `next` was written; false otherwise. Both reads and writes happen inside
|
|
275
|
+
* an IMMEDIATE transaction so concurrent callers cannot race past the guard.
|
|
276
|
+
*/
|
|
277
|
+
compareAndSetMeta(key: string, expected: string | null, next: string | null, extra?: Array<[string, string]>): boolean;
|
|
278
|
+
setMetaBatch(entries: Array<[string, string]>): void;
|
|
279
|
+
close(): void;
|
|
280
|
+
vacuum(): void;
|
|
281
|
+
/** Commit a synchronous group of related index writes, or roll them all back. */
|
|
282
|
+
transaction<T>(operation: () => T): T;
|
|
283
|
+
/**
|
|
284
|
+
* Flush the WAL into the main index.db so an on-disk copy of the file is fully
|
|
285
|
+
* current. Used before seeding a worktree from this base index. TRUNCATE resets
|
|
286
|
+
* the WAL after checkpointing. Best-effort: a busy checkpoint is non-fatal.
|
|
287
|
+
*/
|
|
288
|
+
checkpoint(): void;
|
|
289
|
+
}
|
|
290
|
+
/** Checkpoint the base DB (if open) so a file copy captures all committed rows. */
|
|
291
|
+
export declare function checkpointDB(rootDir: string): void;
|
|
292
|
+
export declare function getDB(rootDir: string): Promise<ContextPlusDB>;
|
|
293
|
+
export declare function closeDB(rootDir?: string): void;
|
|
294
|
+
//# sourceMappingURL=db.d.ts.map
|