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,152 @@
|
|
|
1
|
+
// Gitignore-aware recursive directory walker with nested ignore support
|
|
2
|
+
// Returns filtered file paths respecting project and per-directory ignore patterns
|
|
3
|
+
import { readdir, readFile, lstat, open } from "fs/promises";
|
|
4
|
+
import { constants } from "node:fs";
|
|
5
|
+
import { basename, dirname, join, relative, resolve } from "path";
|
|
6
|
+
import ignore from "ignore";
|
|
7
|
+
import { resolveProjectPath } from "./path-guard.js";
|
|
8
|
+
import { isAlwaysIgnoredDir } from "./ignore-dirs.js";
|
|
9
|
+
// These dot-directories contain authored workflows, tests and public web metadata, not runtime
|
|
10
|
+
// state. Keep other hidden entries excluded and honor ordinary ignore layers.
|
|
11
|
+
const SOURCE_DOT_DIRECTORIES = new Set([".github", ".maestro", ".well-known"]);
|
|
12
|
+
/** Recognize Graft's generated wiring cards, rather than excluding every
|
|
13
|
+
* authored package/directory named graft. Never follow a marker symlink. */
|
|
14
|
+
async function isGeneratedGraftDirectory(dir) {
|
|
15
|
+
if (basename(dir) !== "graft")
|
|
16
|
+
return false;
|
|
17
|
+
const marker = join(dir, "INDEX.md");
|
|
18
|
+
const stats = await lstat(marker).catch(() => null);
|
|
19
|
+
if (!stats?.isFile() || stats.isSymbolicLink())
|
|
20
|
+
return false;
|
|
21
|
+
let handle;
|
|
22
|
+
try {
|
|
23
|
+
handle = await open(marker, constants.O_RDONLY | constants.O_NOFOLLOW | constants.O_NONBLOCK);
|
|
24
|
+
if (!(await handle.stat()).isFile())
|
|
25
|
+
return false;
|
|
26
|
+
const prefix = Buffer.alloc(1024);
|
|
27
|
+
const { bytesRead } = await handle.read(prefix, 0, prefix.length, 0);
|
|
28
|
+
return /^# graft [—-] repo map\r?\n/.test(prefix.subarray(0, bytesRead).toString("utf8"));
|
|
29
|
+
}
|
|
30
|
+
catch {
|
|
31
|
+
return false;
|
|
32
|
+
}
|
|
33
|
+
finally {
|
|
34
|
+
await handle?.close();
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
// The comprehensive, framework-aware ignore set lives in ./ignore-dirs.ts so it can
|
|
38
|
+
// be reused and tested independently. The walker also honors `.gitignore` layers.
|
|
39
|
+
async function loadIgnoreFile(filePath) {
|
|
40
|
+
try {
|
|
41
|
+
return await readFile(filePath, "utf-8");
|
|
42
|
+
}
|
|
43
|
+
catch {
|
|
44
|
+
return null;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
async function buildLocalLayer(dir) {
|
|
48
|
+
const ig = ignore();
|
|
49
|
+
let hasRules = false;
|
|
50
|
+
const gitignoreContent = await loadIgnoreFile(join(dir, ".gitignore"));
|
|
51
|
+
if (gitignoreContent) {
|
|
52
|
+
ig.add(gitignoreContent);
|
|
53
|
+
hasRules = true;
|
|
54
|
+
}
|
|
55
|
+
const contextProIgnore = await loadIgnoreFile(join(dir, ".contextproignore"));
|
|
56
|
+
if (contextProIgnore) {
|
|
57
|
+
ig.add(contextProIgnore);
|
|
58
|
+
hasRules = true;
|
|
59
|
+
}
|
|
60
|
+
const legacyContextPlusIgnore = await loadIgnoreFile(join(dir, ".contextplusignore"));
|
|
61
|
+
if (legacyContextPlusIgnore) {
|
|
62
|
+
ig.add(legacyContextPlusIgnore);
|
|
63
|
+
hasRules = true;
|
|
64
|
+
}
|
|
65
|
+
return hasRules ? { ig, dir } : null;
|
|
66
|
+
}
|
|
67
|
+
function isIgnoredByLayers(fullPath, isDir, layers) {
|
|
68
|
+
for (const layer of layers) {
|
|
69
|
+
const relToLayer = relative(layer.dir, fullPath).replace(/\\/g, "/");
|
|
70
|
+
if (layer.ig.ignores(relToLayer))
|
|
71
|
+
return true;
|
|
72
|
+
if (isDir && layer.ig.ignores(relToLayer + "/"))
|
|
73
|
+
return true;
|
|
74
|
+
}
|
|
75
|
+
return false;
|
|
76
|
+
}
|
|
77
|
+
async function walkRecursive(dir, rootDir, parentLayers, depth, maxDepth, results, includeHidden) {
|
|
78
|
+
if (maxDepth > 0 && depth > maxDepth)
|
|
79
|
+
return;
|
|
80
|
+
const layers = [...parentLayers];
|
|
81
|
+
const localLayer = await buildLocalLayer(dir);
|
|
82
|
+
if (localLayer)
|
|
83
|
+
layers.push(localLayer);
|
|
84
|
+
const entries = await readdir(dir, { withFileTypes: true }).catch(() => []);
|
|
85
|
+
for (const entry of entries) {
|
|
86
|
+
// Discovery only admits recognized hidden source directories. Evidence can
|
|
87
|
+
// include hidden inputs, while still honoring ignore layers and cache policy.
|
|
88
|
+
if (isAlwaysIgnoredDir(entry.name)
|
|
89
|
+
|| (!includeHidden && entry.name.startsWith(".") && !(entry.isDirectory() && SOURCE_DOT_DIRECTORIES.has(entry.name))))
|
|
90
|
+
continue;
|
|
91
|
+
const fullPath = join(dir, entry.name);
|
|
92
|
+
const stats = await lstat(fullPath).catch(() => null);
|
|
93
|
+
if (!stats || stats.isSymbolicLink() || (!stats.isFile() && !stats.isDirectory()))
|
|
94
|
+
continue;
|
|
95
|
+
const isDir = entry.isDirectory();
|
|
96
|
+
if (isDir && await isGeneratedGraftDirectory(fullPath))
|
|
97
|
+
continue;
|
|
98
|
+
if (isIgnoredByLayers(fullPath, isDir, layers))
|
|
99
|
+
continue;
|
|
100
|
+
const relPath = relative(rootDir, fullPath).replace(/\\/g, "/");
|
|
101
|
+
results.push({ path: fullPath, relativePath: relPath, isDirectory: isDir, depth });
|
|
102
|
+
if (isDir)
|
|
103
|
+
await walkRecursive(fullPath, rootDir, layers, depth + 1, maxDepth, results, includeHidden);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
export async function walkDirectory(options) {
|
|
107
|
+
const rootDir = resolve(options.rootDir);
|
|
108
|
+
const startDir = options.targetPath ? resolveProjectPath(rootDir, options.targetPath, "targetPath") : rootDir;
|
|
109
|
+
const results = [];
|
|
110
|
+
const stats = await lstat(startDir).catch(() => null);
|
|
111
|
+
if (!stats)
|
|
112
|
+
return results;
|
|
113
|
+
// A scoped walk must apply the same cache policy to its ancestors, even when
|
|
114
|
+
// it starts at a cache file or a directory below graft/.
|
|
115
|
+
for (let dir = stats.isDirectory() ? startDir : dirname(startDir); dir !== rootDir;) {
|
|
116
|
+
if (await isGeneratedGraftDirectory(dir))
|
|
117
|
+
return results;
|
|
118
|
+
const parent = dirname(dir);
|
|
119
|
+
if (parent === dir)
|
|
120
|
+
break;
|
|
121
|
+
dir = parent;
|
|
122
|
+
}
|
|
123
|
+
if (stats.isFile()) {
|
|
124
|
+
const relPath = relative(rootDir, startDir).replace(/\\/g, "/");
|
|
125
|
+
results.push({ path: startDir, relativePath: relPath, isDirectory: false, depth: 0 });
|
|
126
|
+
return results;
|
|
127
|
+
}
|
|
128
|
+
// If a caller scopes the walk INTO an always-ignored directory (e.g.
|
|
129
|
+
// targetPath="vendor" or ".venv"), honor the ignore policy for the start dir
|
|
130
|
+
// itself — walkRecursive only filters children, so without this a scoped
|
|
131
|
+
// reindex/grep would still traverse the heavy folder. The project root is
|
|
132
|
+
// exempt (never refuse to scan the project just because its folder name
|
|
133
|
+
// collides with an ignored name).
|
|
134
|
+
if (startDir !== rootDir && isAlwaysIgnoredDir(basename(startDir))) {
|
|
135
|
+
return results;
|
|
136
|
+
}
|
|
137
|
+
await walkRecursive(startDir, rootDir, [], 0, options.depthLimit ?? 0, results, options.includeHidden ?? false);
|
|
138
|
+
return results;
|
|
139
|
+
}
|
|
140
|
+
export function groupByDirectory(entries) {
|
|
141
|
+
const groups = new Map();
|
|
142
|
+
for (const entry of entries) {
|
|
143
|
+
const dir = entry.relativePath.includes("/")
|
|
144
|
+
? entry.relativePath.substring(0, entry.relativePath.lastIndexOf("/"))
|
|
145
|
+
: ".";
|
|
146
|
+
const existing = groups.get(dir) ?? [];
|
|
147
|
+
existing.push(entry);
|
|
148
|
+
groups.set(dir, existing);
|
|
149
|
+
}
|
|
150
|
+
return groups;
|
|
151
|
+
}
|
|
152
|
+
//# sourceMappingURL=walker.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"walker.js","sourceRoot":"","sources":["../../src/core/walker.ts"],"names":[],"mappings":"AAAA,wEAAwE;AACxE,mFAAmF;AAEnF,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AAC7D,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AACpC,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAClE,OAAO,MAAuB,MAAM,QAAQ,CAAC;AAC7C,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AACrD,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAsBtD,+FAA+F;AAC/F,8EAA8E;AAC9E,MAAM,sBAAsB,GAAG,IAAI,GAAG,CAAC,CAAC,SAAS,EAAE,UAAU,EAAE,aAAa,CAAC,CAAC,CAAC;AAE/E;4EAC4E;AAC5E,KAAK,UAAU,yBAAyB,CAAC,GAAW;IAClD,IAAI,QAAQ,CAAC,GAAG,CAAC,KAAK,OAAO;QAAE,OAAO,KAAK,CAAC;IAC5C,MAAM,MAAM,GAAG,IAAI,CAAC,GAAG,EAAC,UAAU,CAAC,CAAC;IACpC,MAAM,KAAK,GAAG,MAAM,KAAK,CAAC,MAAM,CAAC,CAAC,KAAK,CAA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,KAAK,CAAC,YAAY,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC;YACtE,CAAC,CAAC,GAAG,CAAC;QACR,MAAM,QAAQ,GAAG,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC;QACvC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QACrB,MAAM,CAAC,GAAG,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAC;IAC5B,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export interface ResolvedWorkspace {
|
|
2
|
+
/** The working-tree root this request targets (a worktree or the main checkout). */
|
|
3
|
+
rootDir: string;
|
|
4
|
+
/** The main checkout that owns the shared git object store and base index. */
|
|
5
|
+
baseRoot: string;
|
|
6
|
+
/** Absolute path to the shared .git directory. */
|
|
7
|
+
gitCommonDir: string;
|
|
8
|
+
/** True when rootDir is a linked worktree rather than the main checkout. */
|
|
9
|
+
isWorktree: boolean;
|
|
10
|
+
/** When this workspace was first resolved (ISO 8601). */
|
|
11
|
+
resolvedAt: string;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Resolve the workspace a request belongs to. Lazy and cached: the first request
|
|
15
|
+
* for a given worktree pays git-detection cost; later requests reuse the entry.
|
|
16
|
+
*
|
|
17
|
+
* Precedence: explicit `requestRoot` (e.g. a tool's `root` argument or the MCP
|
|
18
|
+
* client's roots capability) → `defaultRoot` (the server's boot root). The result
|
|
19
|
+
* is validated through the same unsafe-root guard used at startup.
|
|
20
|
+
*/
|
|
21
|
+
export declare function resolveWorkspace(requestRoot: string | undefined, defaultRoot?: string, beforeInitialize?: (workspace: ResolvedWorkspace) => Promise<void>): Promise<ResolvedWorkspace>;
|
|
22
|
+
/** All workspaces resolved so far this process, de-duplicated by rootDir. */
|
|
23
|
+
export declare function listActiveWorkspaces(): ResolvedWorkspace[];
|
|
24
|
+
/** Drop a single workspace from the cache (e.g. on worktree teardown). */
|
|
25
|
+
export declare function forgetWorkspace(rootDir: string): void;
|
|
26
|
+
/** Clear the entire router cache. Intended for tests. */
|
|
27
|
+
export declare function resetWorkspaceRouter(): void;
|
|
28
|
+
//# sourceMappingURL=workspace-router.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workspace-router.d.ts","sourceRoot":"","sources":["../../src/core/workspace-router.ts"],"names":[],"mappings":"AAWA,MAAM,WAAW,iBAAiB;IAChC,oFAAoF;IACpF,OAAO,EAAE,MAAM,CAAC;IAChB,8EAA8E;IAC9E,QAAQ,EAAE,MAAM,CAAC;IACjB,kDAAkD;IAClD,YAAY,EAAE,MAAM,CAAC;IACrB,4EAA4E;IAC5E,UAAU,EAAE,OAAO,CAAC;IACpB,yDAAyD;IACzD,UAAU,EAAE,MAAM,CAAC;CACpB;AAYD;;;;;;;GAOG;AACH,wBAAsB,gBAAgB,CACpC,WAAW,EAAE,MAAM,GAAG,SAAS,EAC/B,WAAW,CAAC,EAAE,MAAM,EACpB,gBAAgB,CAAC,EAAE,CAAC,SAAS,EAAE,iBAAiB,KAAK,OAAO,CAAC,IAAI,CAAC,GACjE,OAAO,CAAC,iBAAiB,CAAC,CA8C5B;AAED,6EAA6E;AAC7E,wBAAgB,oBAAoB,IAAI,iBAAiB,EAAE,CAM1D;AAED,0EAA0E;AAC1E,wBAAgB,eAAe,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAMrD;AAED,yDAAyD;AACzD,wBAAgB,oBAAoB,IAAI,IAAI,CAE3C"}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
// Per-request workspace resolution for multi-worktree support.
|
|
2
|
+
// FEATURE: One MCP process serves many git worktrees — resolve the workspace a
|
|
3
|
+
// request belongs to (its own root + the shared base checkout) lazily and cache it,
|
|
4
|
+
// so parallel agents in different worktrees each hit the correct index.
|
|
5
|
+
import { resolve } from "path";
|
|
6
|
+
import { realpath } from "fs/promises";
|
|
7
|
+
import { detectWorktreeInfo } from "./project-config.js";
|
|
8
|
+
import { validateSelectedRoot } from "./root-guard.js";
|
|
9
|
+
import { seedWorktreeFromBase } from "./worktree-seed.js";
|
|
10
|
+
const workspaces = new Map();
|
|
11
|
+
function normalizeRequestRoot(requestRoot, defaultRoot) {
|
|
12
|
+
const candidate = requestRoot && requestRoot.trim().length > 0 ? requestRoot : defaultRoot;
|
|
13
|
+
if (!candidate || candidate.trim().length === 0) {
|
|
14
|
+
throw new Error("workspace-router: no request root and no default root provided");
|
|
15
|
+
}
|
|
16
|
+
return resolve(candidate);
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Resolve the workspace a request belongs to. Lazy and cached: the first request
|
|
20
|
+
* for a given worktree pays git-detection cost; later requests reuse the entry.
|
|
21
|
+
*
|
|
22
|
+
* Precedence: explicit `requestRoot` (e.g. a tool's `root` argument or the MCP
|
|
23
|
+
* client's roots capability) → `defaultRoot` (the server's boot root). The result
|
|
24
|
+
* is validated through the same unsafe-root guard used at startup.
|
|
25
|
+
*/
|
|
26
|
+
export async function resolveWorkspace(requestRoot, defaultRoot, beforeInitialize) {
|
|
27
|
+
const requested = normalizeRequestRoot(requestRoot, defaultRoot);
|
|
28
|
+
// Startup canonicalizes symlinks too. Keep one identity/cache entry for an
|
|
29
|
+
// alias and its real directory, including projects without Git metadata.
|
|
30
|
+
const normalized = await realpath(requested).catch(() => requested);
|
|
31
|
+
const cached = workspaces.get(normalized);
|
|
32
|
+
if (cached) {
|
|
33
|
+
// Routing must be checked for every request: worktrees may have appeared
|
|
34
|
+
// since this metadata was cached, or the prior caller passed an explicit root.
|
|
35
|
+
if (beforeInitialize)
|
|
36
|
+
await beforeInitialize(cached);
|
|
37
|
+
workspaces.set(requested, cached);
|
|
38
|
+
return cached;
|
|
39
|
+
}
|
|
40
|
+
// Guard before touching git or the filesystem for storage.
|
|
41
|
+
validateSelectedRoot({ rootDir: normalized, source: requestRoot ? "flag" : "cwd" });
|
|
42
|
+
const info = await detectWorktreeInfo(normalized);
|
|
43
|
+
const workspace = {
|
|
44
|
+
rootDir: info.worktreeRoot,
|
|
45
|
+
baseRoot: info.baseRoot,
|
|
46
|
+
gitCommonDir: info.gitCommonDir,
|
|
47
|
+
isWorktree: info.isWorktree,
|
|
48
|
+
resolvedAt: new Date().toISOString(),
|
|
49
|
+
};
|
|
50
|
+
// A rejected request must not create or copy an index into a guessed checkout.
|
|
51
|
+
if (beforeInitialize)
|
|
52
|
+
await beforeInitialize(workspace);
|
|
53
|
+
// Stage-2 churn optimization: a brand-new worktree clones the base checkout's
|
|
54
|
+
// already-built index so the follow-up incremental reindex only touches its
|
|
55
|
+
// diff. Best-effort — failure just means the worktree reindexes from scratch.
|
|
56
|
+
if (info.isWorktree) {
|
|
57
|
+
try {
|
|
58
|
+
await seedWorktreeFromBase(info.worktreeRoot, info.baseRoot);
|
|
59
|
+
}
|
|
60
|
+
catch (error) {
|
|
61
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
62
|
+
process.stderr.write(`[contextpro/workspace-router] base-index seed failed for ${info.worktreeRoot}: ${message}\n`);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
// Cache under the request path, canonical path and resolved worktree root,
|
|
66
|
+
// since git may realpath the toplevel to a different string than the request.
|
|
67
|
+
workspaces.set(requested, workspace);
|
|
68
|
+
workspaces.set(normalized, workspace);
|
|
69
|
+
workspaces.set(workspace.rootDir, workspace);
|
|
70
|
+
return workspace;
|
|
71
|
+
}
|
|
72
|
+
/** All workspaces resolved so far this process, de-duplicated by rootDir. */
|
|
73
|
+
export function listActiveWorkspaces() {
|
|
74
|
+
const byRoot = new Map();
|
|
75
|
+
for (const ws of workspaces.values()) {
|
|
76
|
+
byRoot.set(ws.rootDir, ws);
|
|
77
|
+
}
|
|
78
|
+
return [...byRoot.values()];
|
|
79
|
+
}
|
|
80
|
+
/** Drop a single workspace from the cache (e.g. on worktree teardown). */
|
|
81
|
+
export function forgetWorkspace(rootDir) {
|
|
82
|
+
const requested = resolve(rootDir);
|
|
83
|
+
const normalized = workspaces.get(requested)?.rootDir ?? requested;
|
|
84
|
+
for (const [key, ws] of workspaces) {
|
|
85
|
+
if (key === normalized || ws.rootDir === normalized)
|
|
86
|
+
workspaces.delete(key);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
/** Clear the entire router cache. Intended for tests. */
|
|
90
|
+
export function resetWorkspaceRouter() {
|
|
91
|
+
workspaces.clear();
|
|
92
|
+
}
|
|
93
|
+
//# sourceMappingURL=workspace-router.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workspace-router.js","sourceRoot":"","sources":["../../src/core/workspace-router.ts"],"names":[],"mappings":"AAAA,+DAA+D;AAC/D,+EAA+E;AAC/E,oFAAoF;AACpF,wEAAwE;AAExE,OAAO,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAC/B,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AACzD,OAAO,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AACvD,OAAO,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAe1D,MAAM,UAAU,GAAG,IAAI,GAAG,EAA6B,CAAC;AAExD,SAAS,oBAAoB,CAAC,WAA+B,EAAE,WAAoB;IACjF,MAAM,SAAS,GAAG,WAAW,IAAI,WAAW,CAAC,IAAI,EAAE,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,WAAW,CAAC;IAC3F,IAAI,CAAC,SAAS,IAAI,SAAS,CAAC,IAAI,EAAE,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAChD,MAAM,IAAI,KAAK,CAAC,gEAAgE,CAAC,CAAC;IACpF,CAAC;IACD,OAAO,OAAO,CAAC,SAAS,CAAC,CAAC;AAC5B,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,CAAC,KA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KAAK,UAAU;YAAE,UAAU,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;IAC9E,CAAC;AACH,CAAC;AAED,yDAAyD;AACzD,MAAM,UAAU,oBAAoB;IAClC,UAAU,CAAC,KAAK,EAAE,CAAC;AACrB,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export interface WorktreeGcResult {
|
|
2
|
+
removedWorkspaces: number;
|
|
3
|
+
removedDirs: string[];
|
|
4
|
+
}
|
|
5
|
+
/**
|
|
6
|
+
* Live worktree roots reported by git (`git worktree list --porcelain`), including
|
|
7
|
+
* the main checkout. Paths are realpath-resolved to match how the router keys them.
|
|
8
|
+
*/
|
|
9
|
+
export declare function listLiveWorktrees(baseRoot: string): Promise<string[]>;
|
|
10
|
+
/**
|
|
11
|
+
* Remove indexes for worktrees the router knows about but git no longer lists.
|
|
12
|
+
* The main checkout is never removed. Best-effort and idempotent: a worktree
|
|
13
|
+
* whose directory is already gone simply has its router entry dropped.
|
|
14
|
+
*/
|
|
15
|
+
export declare function garbageCollectDeadWorktrees(baseRoot: string): Promise<WorktreeGcResult>;
|
|
16
|
+
//# sourceMappingURL=worktree-gc.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"worktree-gc.d.ts","sourceRoot":"","sources":["../../src/core/worktree-gc.ts"],"names":[],"mappings":"AAgBA,MAAM,WAAW,gBAAgB;IAC/B,iBAAiB,EAAE,MAAM,CAAC;IAC1B,WAAW,EAAE,MAAM,EAAE,CAAC;CACvB;AAED;;;GAGG;AACH,wBAAsB,iBAAiB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CAgB3E;AAED;;;;GAIG;AACH,wBAAsB,2BAA2B,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,CAAC,CA0B7F"}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
// Garbage-collect indexes for worktrees that no longer exist.
|
|
2
|
+
// FEATURE: Stage-2 churn cleanup — Claude Code creates and destroys worktrees
|
|
3
|
+
// constantly. When a worktree is gone, drop it from the in-process router and
|
|
4
|
+
// remove its on-disk .contextpro/ overlay so stale indexes don't accumulate.
|
|
5
|
+
import { execFile } from "child_process";
|
|
6
|
+
import { rm } from "fs/promises";
|
|
7
|
+
import { join, resolve } from "path";
|
|
8
|
+
import { promisify } from "util";
|
|
9
|
+
import { CONTEXTPRO_DIR } from "./data-dir.js";
|
|
10
|
+
import { closeDB } from "./db.js";
|
|
11
|
+
import { forgetWorkspace, listActiveWorkspaces } from "./workspace-router.js";
|
|
12
|
+
import { forgetReconcileStatCache } from "./index-reconcile.js";
|
|
13
|
+
const execFileAsync = promisify(execFile);
|
|
14
|
+
/**
|
|
15
|
+
* Live worktree roots reported by git (`git worktree list --porcelain`), including
|
|
16
|
+
* the main checkout. Paths are realpath-resolved to match how the router keys them.
|
|
17
|
+
*/
|
|
18
|
+
export async function listLiveWorktrees(baseRoot) {
|
|
19
|
+
try {
|
|
20
|
+
const { stdout } = await execFileAsync("git", ["worktree", "list", "--porcelain"], {
|
|
21
|
+
cwd: baseRoot,
|
|
22
|
+
timeout: 8000,
|
|
23
|
+
});
|
|
24
|
+
const roots = [];
|
|
25
|
+
for (const line of stdout.split("\n")) {
|
|
26
|
+
if (line.startsWith("worktree ")) {
|
|
27
|
+
roots.push(resolve(line.slice("worktree ".length).trim()));
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
return roots;
|
|
31
|
+
}
|
|
32
|
+
catch {
|
|
33
|
+
return [resolve(baseRoot)];
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Remove indexes for worktrees the router knows about but git no longer lists.
|
|
38
|
+
* The main checkout is never removed. Best-effort and idempotent: a worktree
|
|
39
|
+
* whose directory is already gone simply has its router entry dropped.
|
|
40
|
+
*/
|
|
41
|
+
export async function garbageCollectDeadWorktrees(baseRoot) {
|
|
42
|
+
const base = resolve(baseRoot);
|
|
43
|
+
const live = new Set(await listLiveWorktrees(base));
|
|
44
|
+
const removedDirs = [];
|
|
45
|
+
let removedWorkspaces = 0;
|
|
46
|
+
for (const ws of listActiveWorkspaces()) {
|
|
47
|
+
if (!ws.isWorktree)
|
|
48
|
+
continue; // never GC the base checkout
|
|
49
|
+
if (ws.baseRoot !== base)
|
|
50
|
+
continue; // only this repo family
|
|
51
|
+
if (live.has(ws.rootDir))
|
|
52
|
+
continue; // still alive
|
|
53
|
+
// Dead worktree: close its DB handle, forget it, and reclaim its overlay dir.
|
|
54
|
+
closeDB(ws.rootDir);
|
|
55
|
+
forgetWorkspace(ws.rootDir);
|
|
56
|
+
forgetReconcileStatCache(ws.rootDir);
|
|
57
|
+
removedWorkspaces += 1;
|
|
58
|
+
const overlayDir = join(ws.rootDir, CONTEXTPRO_DIR);
|
|
59
|
+
try {
|
|
60
|
+
await rm(overlayDir, { recursive: true, force: true });
|
|
61
|
+
removedDirs.push(overlayDir);
|
|
62
|
+
}
|
|
63
|
+
catch {
|
|
64
|
+
// The worktree directory may already be gone; nothing to reclaim.
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
return { removedWorkspaces, removedDirs };
|
|
68
|
+
}
|
|
69
|
+
//# sourceMappingURL=worktree-gc.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"worktree-gc.js","sourceRoot":"","sources":["../../src/core/worktree-gc.ts"],"names":[],"mappings":"AAAA,8DAA8D;AAC9D,8EAA8E;AAC9E,8EAA8E;AAC9E,6EAA6E;AAE7E,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,EAAE,EAAE,MAAM,aAAa,CAAC;AACjC,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AACrC,OAAO,EAAE,SAAS,EAAE,MAAM,MAAM,CAAC;AACjC,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAC/C,OAAO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,EAAE,IAAI,oBAAoB,EAAE,EAAE,CAAC;QACxC,IAAI,CAAC,EAAE,CAAC,UAAU;YAAE,SAAS,CAAC,6BAA6B;QAC3D,IAAI,EAAE,CAAC,QAAQ,KAAK,IAAI;YAAE,SAAS,CAAC,wBAAwB;QAC5D,IAAI,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,OAAO,CAAC;YAAE,SAAS,CAAC,cAAc;QAElD,8EAA8E;QAC9E,OAAO,CAAC,EAAE,CAAC,OAAO,CAAC,CAAC;QACpB,eAAe,CAAC,EAAE,CAAC,OAAO,CAAC,CAAC;QAC5B,wBAAwB,CAAC,EAAE,CAAC,OAAO,CAAC,CAAC;QACrC,iBAAiB,IAAI,CAAC,CAAC;QACvB,MAAM,UAAU,GAAG,IAAI,CAAC,EAAE,CAAC,OAAO,EAAE,cAAc,CAAC,CAAC;QACpD,IAAI,CAAC;YACH,MAAM,EAAE,CAAC,UAAU,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;YACvD,WAAW,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;QAC/B,CAAC;QAAC,MAAM,CAAC;YACP,kEAAkE;QACpE,CAAC;IACH,CAAC;IAED,OAAO,EAAE,iBAAiB,EAAE,WAAW,EAAE,CAAC;AAC5C,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export interface WorktreeDiffSet {
|
|
2
|
+
/** Tracked files that differ from the base checkout's HEAD (modified). */
|
|
3
|
+
changed: string[];
|
|
4
|
+
/** Files present in the worktree but not in the base index (added/untracked). */
|
|
5
|
+
added: string[];
|
|
6
|
+
/** Files deleted in the worktree relative to base (to drop from the overlay). */
|
|
7
|
+
deleted: string[];
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Compute the set of files in `worktreeRoot` that diverge from `baseRoot`'s
|
|
11
|
+
* committed tree. Combines three git views:
|
|
12
|
+
* - committed-on-branch divergence: `git diff --name-status <base HEAD>...HEAD`
|
|
13
|
+
* - uncommitted working-tree changes: `git status --porcelain`
|
|
14
|
+
* - untracked files: surfaced by porcelain `??`
|
|
15
|
+
*
|
|
16
|
+
* Paths are returned worktree-relative (POSIX separators), matching how the
|
|
17
|
+
* indexer keys files.
|
|
18
|
+
*/
|
|
19
|
+
export declare function computeWorktreeDiffSet(worktreeRoot: string, baseRoot: string): Promise<WorktreeDiffSet>;
|
|
20
|
+
/** Worktree-relative paths to (re)index into the overlay: changed ∪ added. */
|
|
21
|
+
export declare function overlayFiles(set: WorktreeDiffSet): string[];
|
|
22
|
+
//# sourceMappingURL=worktree-overlay.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"worktree-overlay.d.ts","sourceRoot":"","sources":["../../src/core/worktree-overlay.ts"],"names":[],"mappings":"AAUA,MAAM,WAAW,eAAe;IAC9B,0EAA0E;IAC1E,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,iFAAiF;IACjF,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,iFAAiF;IACjF,OAAO,EAAE,MAAM,EAAE,CAAC;CACnB;AAeD;;;;;;;;;GASG;AACH,wBAAsB,sBAAsB,CAAC,YAAY,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,CAAC,CA4C7G;AAED,8EAA8E;AAC9E,wBAAgB,YAAY,CAAC,GAAG,EAAE,eAAe,GAAG,MAAM,EAAE,CAE3D"}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
// Worktree overlay diff computation for Stage-2 shared-base indexing.
|
|
2
|
+
// FEATURE: Constant worktree churn — instead of re-indexing every file in a new
|
|
3
|
+
// worktree (≈95% identical to the base checkout), index only the files that
|
|
4
|
+
// actually differ. This computes that diff set; the base index supplies the rest.
|
|
5
|
+
import { execFile } from "child_process";
|
|
6
|
+
import { promisify } from "util";
|
|
7
|
+
const execFileAsync = promisify(execFile);
|
|
8
|
+
async function git(cwd, args) {
|
|
9
|
+
try {
|
|
10
|
+
const { stdout } = await execFileAsync("git", args, { cwd, timeout: 8000, maxBuffer: 16 * 1024 * 1024 });
|
|
11
|
+
return stdout;
|
|
12
|
+
}
|
|
13
|
+
catch {
|
|
14
|
+
return "";
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
function nonEmptyLines(raw) {
|
|
18
|
+
return raw.split("\n").map((line) => line.trim()).filter((line) => line.length > 0);
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Compute the set of files in `worktreeRoot` that diverge from `baseRoot`'s
|
|
22
|
+
* committed tree. Combines three git views:
|
|
23
|
+
* - committed-on-branch divergence: `git diff --name-status <base HEAD>...HEAD`
|
|
24
|
+
* - uncommitted working-tree changes: `git status --porcelain`
|
|
25
|
+
* - untracked files: surfaced by porcelain `??`
|
|
26
|
+
*
|
|
27
|
+
* Paths are returned worktree-relative (POSIX separators), matching how the
|
|
28
|
+
* indexer keys files.
|
|
29
|
+
*/
|
|
30
|
+
export async function computeWorktreeDiffSet(worktreeRoot, baseRoot) {
|
|
31
|
+
const changed = new Set();
|
|
32
|
+
const added = new Set();
|
|
33
|
+
const deleted = new Set();
|
|
34
|
+
// Base HEAD to diff branch commits against. Empty when base has no commits.
|
|
35
|
+
const baseHead = (await git(baseRoot, ["rev-parse", "HEAD"])).trim();
|
|
36
|
+
if (baseHead.length > 0) {
|
|
37
|
+
// Three-dot: changes on the worktree branch since it forked from base HEAD.
|
|
38
|
+
const branchDiff = await git(worktreeRoot, ["diff", "--name-status", `${baseHead}...HEAD`]);
|
|
39
|
+
for (const line of nonEmptyLines(branchDiff)) {
|
|
40
|
+
const [status, ...rest] = line.split(/\s+/);
|
|
41
|
+
const path = rest[rest.length - 1];
|
|
42
|
+
if (!path)
|
|
43
|
+
continue;
|
|
44
|
+
if (status.startsWith("D"))
|
|
45
|
+
deleted.add(path);
|
|
46
|
+
else if (status.startsWith("A"))
|
|
47
|
+
added.add(path);
|
|
48
|
+
else
|
|
49
|
+
changed.add(path);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
// Uncommitted + untracked working-tree state.
|
|
53
|
+
const porcelain = await git(worktreeRoot, ["status", "--porcelain", "--untracked-files=all"]);
|
|
54
|
+
for (const line of porcelain.split("\n")) {
|
|
55
|
+
if (line.length < 4)
|
|
56
|
+
continue;
|
|
57
|
+
const code = line.slice(0, 2);
|
|
58
|
+
const path = line.slice(3).trim();
|
|
59
|
+
if (!path)
|
|
60
|
+
continue;
|
|
61
|
+
if (code === "??")
|
|
62
|
+
added.add(path);
|
|
63
|
+
else if (code.includes("D"))
|
|
64
|
+
deleted.add(path);
|
|
65
|
+
else
|
|
66
|
+
added.has(path) || changed.add(path);
|
|
67
|
+
}
|
|
68
|
+
// Deleted wins: a file deleted then re-added is "added", but a pure delete
|
|
69
|
+
// must not also appear as changed.
|
|
70
|
+
for (const path of deleted) {
|
|
71
|
+
changed.delete(path);
|
|
72
|
+
added.delete(path);
|
|
73
|
+
}
|
|
74
|
+
return {
|
|
75
|
+
changed: [...changed],
|
|
76
|
+
added: [...added],
|
|
77
|
+
deleted: [...deleted],
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
/** Worktree-relative paths to (re)index into the overlay: changed ∪ added. */
|
|
81
|
+
export function overlayFiles(set) {
|
|
82
|
+
return [...new Set([...set.changed, ...set.added])];
|
|
83
|
+
}
|
|
84
|
+
//# sourceMappingURL=worktree-overlay.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"worktree-overlay.js","sourceRoot":"","sources":["../../src/core/worktree-overlay.ts"],"names":[],"mappings":"AAAA,sEAAsE;AACtE,gFAAgF;AAChF,4EAA4E;AAC5E,kFAAkF;AAElF,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,SAAS,EAAE,MAAM,MAAM,CAAC;AAEjC,MAAM,aAAa,GAAG,SAAS,CAAC,QAAQ,CAAC,CAAC;AAW1C,KA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A2E;IAC3E,mCAAmC;IACnC,KAAK,MAAM,IAAI,IAAI,OAAO,EAAE,CAAC;QAC3B,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;QACrB,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IACrB,CAAC;IAED,OAAO;QACL,OAAO,EAAE,CAAC,GAAG,OAAO,CAAC;QACrB,KAAK,EAAE,CAAC,GAAG,KAAK,CAAC;QACjB,OAAO,EAAE,CAAC,GAAG,OAAO,CAAC;KACtB,CAAC;AACJ,CAAC;AAED,8EAA8E;AAC9E,MAAM,UAAU,YAAY,CAAC,GAAoB;IAC/C,OAAO,CAAC,GAAG,IAAI,GAAG,CAAC,CAAC,GAAG,GAAG,CAAC,OAAO,EAAE,GAAG,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;AACtD,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { ResolvedWorkspace } from "./workspace-router.js";
|
|
2
|
+
/**
|
|
3
|
+
* Inspect Git's small worktree registry, not the source tree. Do not cache its
|
|
4
|
+
* contents: another agent can add/remove a worktree while the MCP stays alive.
|
|
5
|
+
* Explicit-root requests never call this function.
|
|
6
|
+
*/
|
|
7
|
+
export declare function requireExplicitRootForSharedWorktrees(workspace: ResolvedWorkspace): Promise<void>;
|
|
8
|
+
//# sourceMappingURL=worktree-root-guard.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"worktree-root-guard.d.ts","sourceRoot":"","sources":["../../src/core/worktree-root-guard.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAU/D;;;;GAIG;AACH,wBAAsB,qCAAqC,CAAC,SAAS,EAAE,iBAAiB,GAAG,OAAO,CAAC,IAAI,CAAC,CAyDvG"}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
// Shared MCP connections cannot infer which subagent worktree made a request.
|
|
2
|
+
import { opendir, readFile, realpath, stat } from "node:fs/promises";
|
|
3
|
+
import { dirname, join, resolve } from "node:path";
|
|
4
|
+
const MAX_ADMIN_ENTRIES = 64;
|
|
5
|
+
const MAX_DISPLAY_ROOTS = 4;
|
|
6
|
+
const MAX_DISPLAY_PATH = 240;
|
|
7
|
+
function displayPath(path) {
|
|
8
|
+
return path.length <= MAX_DISPLAY_PATH ? path : `${path.slice(0, MAX_DISPLAY_PATH - 3)}...`;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Inspect Git's small worktree registry, not the source tree. Do not cache its
|
|
12
|
+
* contents: another agent can add/remove a worktree while the MCP stays alive.
|
|
13
|
+
* Explicit-root requests never call this function.
|
|
14
|
+
*/
|
|
15
|
+
export async function requireExplicitRootForSharedWorktrees(workspace) {
|
|
16
|
+
// Linked checkouts always require explicit routing. The main checkout cannot
|
|
17
|
+
// be located reliably from a separate Git store (or a bare repository), so
|
|
18
|
+
// the absence of another registered path does not prove this root is intended.
|
|
19
|
+
if (workspace.isWorktree) {
|
|
20
|
+
throw new Error(`Ambiguous worktree: this MCP connection would use ${displayPath(workspace.rootDir)}. `
|
|
21
|
+
+ "Linked worktrees require an explicit root, including checkouts attached to separate or bare Git stores. "
|
|
22
|
+
+ "Pass root as the absolute directory of the checkout you are editing on every tool call.");
|
|
23
|
+
}
|
|
24
|
+
const roots = new Set([workspace.rootDir]);
|
|
25
|
+
let registry;
|
|
26
|
+
try {
|
|
27
|
+
registry = await opendir(join(workspace.gitCommonDir, "worktrees"));
|
|
28
|
+
}
|
|
29
|
+
catch (error) {
|
|
30
|
+
if (["ENOENT", "ENOTDIR"].includes(error.code ?? ""))
|
|
31
|
+
return;
|
|
32
|
+
throw new Error(`Cannot verify worktree routing for ${displayPath(workspace.rootDir)}. Pass root as the absolute working directory for this request.`);
|
|
33
|
+
}
|
|
34
|
+
let inspected = 0;
|
|
35
|
+
let bounded = false;
|
|
36
|
+
try {
|
|
37
|
+
for await (const entry of registry) {
|
|
38
|
+
if (++inspected > MAX_ADMIN_ENTRIES) {
|
|
39
|
+
bounded = true;
|
|
40
|
+
break;
|
|
41
|
+
}
|
|
42
|
+
if (!entry.isDirectory())
|
|
43
|
+
continue;
|
|
44
|
+
const adminDir = join(workspace.gitCommonDir, "worktrees", entry.name);
|
|
45
|
+
try {
|
|
46
|
+
const gitFile = (await readFile(join(adminDir, "gitdir"), "utf8")).trim();
|
|
47
|
+
if (!gitFile)
|
|
48
|
+
continue;
|
|
49
|
+
const resolvedGitFile = resolve(adminDir, gitFile);
|
|
50
|
+
// Ignore prunable registry entries after a checkout was removed manually.
|
|
51
|
+
const checkoutGit = await stat(resolvedGitFile);
|
|
52
|
+
if (!checkoutGit.isFile())
|
|
53
|
+
continue;
|
|
54
|
+
const checkout = await realpath(dirname(resolvedGitFile));
|
|
55
|
+
roots.add(checkout);
|
|
56
|
+
if (roots.size >= MAX_DISPLAY_ROOTS) {
|
|
57
|
+
bounded = true;
|
|
58
|
+
break;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
catch (error) {
|
|
62
|
+
if (["ENOENT", "ENOTDIR"].includes(error.code ?? ""))
|
|
63
|
+
continue;
|
|
64
|
+
// Unreadable registry metadata cannot prove this connection unambiguous.
|
|
65
|
+
bounded = true;
|
|
66
|
+
break;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
catch {
|
|
71
|
+
bounded = true;
|
|
72
|
+
}
|
|
73
|
+
if (roots.size <= 1 && !bounded)
|
|
74
|
+
return;
|
|
75
|
+
const candidates = [...roots].slice(0, MAX_DISPLAY_ROOTS).map(displayPath).join(" | ");
|
|
76
|
+
throw new Error(`Ambiguous worktree: this MCP connection would use ${displayPath(workspace.rootDir)}, `
|
|
77
|
+
+ "but this repository has other or unverified linked worktrees. "
|
|
78
|
+
+ "Pass root as the absolute directory of the checkout you are editing on every tool call; "
|
|
79
|
+
+ "reindexing without root could refresh a different checkout. "
|
|
80
|
+
+ `Candidates: ${candidates}${bounded ? " | ..." : ""}`);
|
|
81
|
+
}
|
|
82
|
+
//# sourceMappingURL=worktree-root-guard.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"worktree-root-guard.js","sourceRoot":"","sources":["../../src/core/worktree-root-guard.ts"],"names":[],"mappings":"AAAA,8EAA8E;AAC9E,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AACrE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAGnD,MAAM,iBAAiB,GAAG,EAAE,CAAC;AAC7B,MAAM,iBAAiB,GAAG,CAAC,CAAC;AAC5B,MAAM,gBAAgB,GAAG,GAAG,CAAC;AAE7B,SAAS,WAAW,CAAC,IAAY;IAC/B,OAAO,IAAI,CAAC,MAAM,IAAI,gBAAgB,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,gBAAgB,GAAG,CAAC,CAAC,KAAK,CAAC;AAC9F,CAAC;AAED;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,qCAAqC,CAAC,SAA4B;IACtF,6EAA6E;IAC7E,2EAA2E;IAC3E,+EAA+E;IAC/E,IAAI,SAAS,CAAC,UAAU,EAAE,CAAC;QACzB,MAAM,IAAI,KAAK,CACb,qDAAqD,WAAW,CAAC,SAAS,CAAC,OAAO,CAAC,IAAI;cACrF,0GAA0G;cAC1G,yFAAyF,CAC5F,CAAC;IACJ,CAAC;IACD,MAAM,KAAK,GAAG,IAAI,GAAG,CAAC,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,CAAC;IAC3C,IAAI,QAAQ,CAAC;IACb,IAAI,CAAC;QACH,QAAQ,GAAG,MAAM,OAAO,CAAC,IAAI,CAAC,SAAS,CAAC,YAAY,EAAE,WAAW,CAAC,CAAC,CAAC;IACtE,CAAC;IAAC,OAA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EAAE,CAAC;oBAAC,OAAO,GAAG,IAAI,CAAC;oBAAC,MAAM;gBAAC,CAAC;YACjE,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,IAAI,CAAC,QAAQ,EAAE,SAAS,CAAC,CAAC,QAAQ,CAAE,KAA+B,CAAC,IAAI,IAAI,EAAE,CAAC;oBAAE,SAAS;gBAC1F,yEAAyE;gBACzE,OAAO,GAAG,IAAI,CAAC;gBACf,MAAM;YACR,CAAC;QACH,CAAC;IACH,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,GAAG,IAAI,CAAC;IACjB,CAAC;IAED,IAAI,KAAK,CAAC,IAAI,IAAI,CAAC,IAAI,CAAC,OAAO;QAAE,OAAO;IACxC,MAAM,UAAU,GAAG,CAAC,GAAG,KAAK,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,iBAAiB,CAAC,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IACvF,MAAM,IAAI,KAAK,CACb,qDAAqD,WAAW,CAAC,SAAS,CAAC,OAAO,CAAC,IAAI;UACrF,gEAAgE;UAChE,0FAA0F;UAC1F,8DAA8D;UAC9D,eAAe,UAAU,GAAG,OAAO,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,EAAE,CACxD,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export interface SeedResult {
|
|
2
|
+
seeded: boolean;
|
|
3
|
+
reason?: "same-root" | "no-base-index" | "worktree-index-exists";
|
|
4
|
+
bytesCopied?: number;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* SQLite's online backup includes committed WAL pages and yields a consistent
|
|
8
|
+
* snapshot even if the base is open in another process. Initialize the private
|
|
9
|
+
* snapshot before an exclusive hard-link publication: readers never see a
|
|
10
|
+
* partial database, and concurrent first requests cannot overwrite one another
|
|
11
|
+
* or a database initialized by getDB in the meantime.
|
|
12
|
+
*/
|
|
13
|
+
export declare function seedWorktreeFromBase(worktreeRoot: string, baseRoot: string): Promise<SeedResult>;
|
|
14
|
+
//# sourceMappingURL=worktree-seed.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"worktree-seed.d.ts","sourceRoot":"","sources":["../../src/core/worktree-seed.ts"],"names":[],"mappings":"AAOA,MAAM,WAAW,UAAU;IACzB,MAAM,EAAE,OAAO,CAAC;IAChB,MAAM,CAAC,EAAE,WAAW,GAAG,eAAe,GAAG,uBAAuB,CAAC;IACjE,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAgBD;;;;;;GAMG;AACH,wBAAsB,oBAAoB,CAAC,YAAY,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC,CAgEtG"}
|