@flyingrobots/graft 0.6.0 → 0.7.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/ADVANCED_GUIDE.md +52 -0
- package/CHANGELOG.md +142 -0
- package/GUIDE.md +53 -0
- package/README.md +1 -1
- package/dist/adapters/json-text-decoder.d.ts +3 -0
- package/dist/adapters/json-text-decoder.d.ts.map +1 -0
- package/dist/adapters/json-text-decoder.js +12 -0
- package/dist/adapters/json-text-decoder.js.map +1 -0
- package/dist/adapters/node-paths.d.ts +3 -0
- package/dist/adapters/node-paths.d.ts.map +1 -0
- package/dist/adapters/node-paths.js +29 -0
- package/dist/adapters/node-paths.js.map +1 -0
- package/dist/adapters/repo-paths.d.ts.map +1 -1
- package/dist/adapters/repo-paths.js +40 -5
- package/dist/adapters/repo-paths.js.map +1 -1
- package/dist/api/tool-bridge.d.ts +1 -1
- package/dist/api/tool-bridge.d.ts.map +1 -1
- package/dist/api/tool-bridge.js +1 -1
- package/dist/api/tool-bridge.js.map +1 -1
- package/dist/cli/cli-error.d.ts.map +1 -1
- package/dist/cli/cli-error.js +47 -10
- package/dist/cli/cli-error.js.map +1 -1
- package/dist/cli/command-parser.d.ts +12 -3
- package/dist/cli/command-parser.d.ts.map +1 -1
- package/dist/cli/command-parser.js +161 -2
- package/dist/cli/command-parser.js.map +1 -1
- package/dist/cli/daemon-status-model.d.ts +87 -0
- package/dist/cli/daemon-status-model.d.ts.map +1 -0
- package/dist/cli/daemon-status-model.js +142 -0
- package/dist/cli/daemon-status-model.js.map +1 -0
- package/dist/cli/daemon-status-render.d.ts +3 -0
- package/dist/cli/daemon-status-render.d.ts.map +1 -0
- package/dist/cli/daemon-status-render.js +100 -0
- package/dist/cli/daemon-status-render.js.map +1 -0
- package/dist/cli/daemon-status.d.ts +7 -0
- package/dist/cli/daemon-status.d.ts.map +1 -0
- package/dist/cli/daemon-status.js +79 -0
- package/dist/cli/daemon-status.js.map +1 -0
- package/dist/cli/git-graft-enhance-model.d.ts +67 -0
- package/dist/cli/git-graft-enhance-model.d.ts.map +1 -0
- package/dist/cli/git-graft-enhance-model.js +55 -0
- package/dist/cli/git-graft-enhance-model.js.map +1 -0
- package/dist/cli/git-graft-enhance-render.d.ts +3 -0
- package/dist/cli/git-graft-enhance-render.d.ts.map +1 -0
- package/dist/cli/git-graft-enhance-render.js +29 -0
- package/dist/cli/git-graft-enhance-render.js.map +1 -0
- package/dist/cli/git-graft-enhance.d.ts +14 -0
- package/dist/cli/git-graft-enhance.d.ts.map +1 -0
- package/dist/cli/git-graft-enhance.js +29 -0
- package/dist/cli/git-graft-enhance.js.map +1 -0
- package/dist/cli/index-cmd.d.ts.map +1 -1
- package/dist/cli/index-cmd.js +18 -21
- package/dist/cli/index-cmd.js.map +1 -1
- package/dist/cli/index-model.d.ts +5 -9
- package/dist/cli/index-model.d.ts.map +1 -1
- package/dist/cli/index-model.js +20 -18
- package/dist/cli/index-model.js.map +1 -1
- package/dist/cli/init-client-config.d.ts +12 -7
- package/dist/cli/init-client-config.d.ts.map +1 -1
- package/dist/cli/init-client-config.js +105 -43
- package/dist/cli/init-client-config.js.map +1 -1
- package/dist/cli/init-model.d.ts +9 -2
- package/dist/cli/init-model.d.ts.map +1 -1
- package/dist/cli/init-model.js +52 -4
- package/dist/cli/init-model.js.map +1 -1
- package/dist/cli/init-render.d.ts.map +1 -1
- package/dist/cli/init-render.js +2 -2
- package/dist/cli/init-render.js.map +1 -1
- package/dist/cli/init.d.ts.map +1 -1
- package/dist/cli/init.js +11 -9
- package/dist/cli/init.js.map +1 -1
- package/dist/cli/json-document.d.ts +5 -0
- package/dist/cli/json-document.d.ts.map +1 -1
- package/dist/cli/json-document.js +9 -0
- package/dist/cli/json-document.js.map +1 -1
- package/dist/cli/main.d.ts +7 -0
- package/dist/cli/main.d.ts.map +1 -1
- package/dist/cli/main.js +49 -7
- package/dist/cli/main.js.map +1 -1
- package/dist/cli/migrate-local-history.d.ts.map +1 -1
- package/dist/cli/migrate-local-history.js +3 -2
- package/dist/cli/migrate-local-history.js.map +1 -1
- package/dist/cli/peer-command.d.ts +1 -1
- package/dist/cli/peer-command.d.ts.map +1 -1
- package/dist/cli/peer-command.js +1 -1
- package/dist/cli/peer-command.js.map +1 -1
- package/dist/contracts/capabilities.d.ts +5 -5
- package/dist/contracts/capabilities.d.ts.map +1 -1
- package/dist/contracts/capabilities.js +89 -0
- package/dist/contracts/capabilities.js.map +1 -1
- package/dist/contracts/causal-ontology.d.ts +17 -17
- package/dist/contracts/json-object.d.ts +0 -1
- package/dist/contracts/json-object.d.ts.map +1 -1
- package/dist/contracts/json-object.js +0 -10
- package/dist/contracts/json-object.js.map +1 -1
- package/dist/contracts/output-schema-cli.d.ts +277 -25
- package/dist/contracts/output-schema-cli.d.ts.map +1 -1
- package/dist/contracts/output-schema-cli.js +35 -3
- package/dist/contracts/output-schema-cli.js.map +1 -1
- package/dist/contracts/output-schema-fragments.d.ts +212 -87
- package/dist/contracts/output-schema-fragments.d.ts.map +1 -1
- package/dist/contracts/output-schema-fragments.js +49 -2
- package/dist/contracts/output-schema-fragments.js.map +1 -1
- package/dist/contracts/output-schema-mcp.d.ts +372 -47
- package/dist/contracts/output-schema-mcp.d.ts.map +1 -1
- package/dist/contracts/output-schema-mcp.js +217 -1
- package/dist/contracts/output-schema-mcp.js.map +1 -1
- package/dist/contracts/output-schema-meta.d.ts +2 -2
- package/dist/contracts/output-schema-meta.d.ts.map +1 -1
- package/dist/contracts/output-schemas.d.ts +7 -7
- package/dist/contracts/output-schemas.d.ts.map +1 -1
- package/dist/contracts/output-schemas.js +294 -6
- package/dist/contracts/output-schemas.js.map +1 -1
- package/dist/git/diff.d.ts +11 -0
- package/dist/git/diff.d.ts.map +1 -1
- package/dist/git/diff.js +50 -6
- package/dist/git/diff.js.map +1 -1
- package/dist/mcp/burden.d.ts.map +1 -1
- package/dist/mcp/burden.js +9 -0
- package/dist/mcp/burden.js.map +1 -1
- package/dist/mcp/context.d.ts +3 -2
- package/dist/mcp/context.d.ts.map +1 -1
- package/dist/mcp/context.js +2 -37
- package/dist/mcp/context.js.map +1 -1
- package/dist/mcp/daemon-server.d.ts +2 -0
- package/dist/mcp/daemon-server.d.ts.map +1 -1
- package/dist/mcp/daemon-server.js +6 -1
- package/dist/mcp/daemon-server.js.map +1 -1
- package/dist/mcp/daemon-session-host.d.ts +1 -0
- package/dist/mcp/daemon-session-host.d.ts.map +1 -1
- package/dist/mcp/daemon-session-host.js +3 -0
- package/dist/mcp/daemon-session-host.js.map +1 -1
- package/dist/mcp/daemon-stdio-bridge.d.ts +1 -0
- package/dist/mcp/daemon-stdio-bridge.d.ts.map +1 -1
- package/dist/mcp/daemon-stdio-bridge.js +1 -0
- package/dist/mcp/daemon-stdio-bridge.js.map +1 -1
- package/dist/mcp/monitor-tick-job.d.ts +1 -0
- package/dist/mcp/monitor-tick-job.d.ts.map +1 -1
- package/dist/mcp/monitor-tick-job.js +84 -29
- package/dist/mcp/monitor-tick-job.js.map +1 -1
- package/dist/mcp/monitor-types.d.ts +1 -1
- package/dist/mcp/monitor-types.d.ts.map +1 -1
- package/dist/mcp/persisted-local-history-graph.d.ts +2 -2
- package/dist/mcp/persisted-local-history-graph.d.ts.map +1 -1
- package/dist/mcp/persisted-local-history-graph.js +3 -2
- package/dist/mcp/persisted-local-history-graph.js.map +1 -1
- package/dist/mcp/persisted-local-history.d.ts +5 -5
- package/dist/mcp/persisted-local-history.js +2 -2
- package/dist/mcp/persisted-local-history.js.map +1 -1
- package/dist/mcp/persistent-monitor-runtime.d.ts +1 -0
- package/dist/mcp/persistent-monitor-runtime.d.ts.map +1 -1
- package/dist/mcp/persistent-monitor-runtime.js +35 -0
- package/dist/mcp/persistent-monitor-runtime.js.map +1 -1
- package/dist/mcp/repo-tool-worker-context.d.ts.map +1 -1
- package/dist/mcp/repo-tool-worker-context.js +5 -2
- package/dist/mcp/repo-tool-worker-context.js.map +1 -1
- package/dist/mcp/server-context.d.ts.map +1 -1
- package/dist/mcp/server-context.js +13 -0
- package/dist/mcp/server-context.js.map +1 -1
- package/dist/mcp/server-tool-access.d.ts +1 -1
- package/dist/mcp/server-tool-access.d.ts.map +1 -1
- package/dist/mcp/server-tool-access.js +3 -1
- package/dist/mcp/server-tool-access.js.map +1 -1
- package/dist/mcp/server.d.ts +3 -0
- package/dist/mcp/server.d.ts.map +1 -1
- package/dist/mcp/server.js +5 -3
- package/dist/mcp/server.js.map +1 -1
- package/dist/mcp/tool-registry.d.ts.map +1 -1
- package/dist/mcp/tool-registry.js +18 -0
- package/dist/mcp/tool-registry.js.map +1 -1
- package/dist/mcp/tools/code-find.d.ts.map +1 -1
- package/dist/mcp/tools/code-find.js +20 -0
- package/dist/mcp/tools/code-find.js.map +1 -1
- package/dist/mcp/tools/code-show.d.ts.map +1 -1
- package/dist/mcp/tools/code-show.js +24 -0
- package/dist/mcp/tools/code-show.js.map +1 -1
- package/dist/mcp/tools/diagnostic-models.d.ts +2 -0
- package/dist/mcp/tools/diagnostic-models.d.ts.map +1 -1
- package/dist/mcp/tools/doctor.d.ts.map +1 -1
- package/dist/mcp/tools/doctor.js +18 -1
- package/dist/mcp/tools/doctor.js.map +1 -1
- package/dist/mcp/tools/export-surface-diff.d.ts +3 -0
- package/dist/mcp/tools/export-surface-diff.d.ts.map +1 -0
- package/dist/mcp/tools/export-surface-diff.js +24 -0
- package/dist/mcp/tools/export-surface-diff.js.map +1 -0
- package/dist/mcp/tools/file-outline.js +1 -1
- package/dist/mcp/tools/file-outline.js.map +1 -1
- package/dist/mcp/tools/graft-edit.d.ts +3 -0
- package/dist/mcp/tools/graft-edit.d.ts.map +1 -0
- package/dist/mcp/tools/graft-edit.js +192 -0
- package/dist/mcp/tools/graft-edit.js.map +1 -0
- package/dist/mcp/tools/knowledge-map.d.ts +3 -0
- package/dist/mcp/tools/knowledge-map.d.ts.map +1 -0
- package/dist/mcp/tools/knowledge-map.js +31 -0
- package/dist/mcp/tools/knowledge-map.js.map +1 -0
- package/dist/mcp/tools/monitor-nudge.d.ts +3 -0
- package/dist/mcp/tools/monitor-nudge.d.ts.map +1 -0
- package/dist/mcp/tools/monitor-nudge.js +17 -0
- package/dist/mcp/tools/monitor-nudge.js.map +1 -0
- package/dist/mcp/tools/precision-warp.d.ts +3 -3
- package/dist/mcp/tools/precision-warp.d.ts.map +1 -1
- package/dist/mcp/tools/precision-warp.js +24 -15
- package/dist/mcp/tools/precision-warp.js.map +1 -1
- package/dist/mcp/tools/refactor-difficulty.d.ts +3 -0
- package/dist/mcp/tools/refactor-difficulty.d.ts.map +1 -0
- package/dist/mcp/tools/refactor-difficulty.js +36 -0
- package/dist/mcp/tools/refactor-difficulty.js.map +1 -0
- package/dist/mcp/tools/safe-read.js +2 -2
- package/dist/mcp/tools/safe-read.js.map +1 -1
- package/dist/mcp/tools/structural-blame.d.ts +3 -0
- package/dist/mcp/tools/structural-blame.d.ts.map +1 -0
- package/dist/mcp/tools/structural-blame.js +44 -0
- package/dist/mcp/tools/structural-blame.js.map +1 -0
- package/dist/mcp/tools/structural-churn.d.ts +3 -0
- package/dist/mcp/tools/structural-churn.d.ts.map +1 -0
- package/dist/mcp/tools/structural-churn.js +28 -0
- package/dist/mcp/tools/structural-churn.js.map +1 -0
- package/dist/mcp/tools/structural-log.d.ts +3 -0
- package/dist/mcp/tools/structural-log.d.ts.map +1 -0
- package/dist/mcp/tools/structural-log.js +38 -0
- package/dist/mcp/tools/structural-log.js.map +1 -0
- package/dist/mcp/tools/structural-review.d.ts +3 -0
- package/dist/mcp/tools/structural-review.d.ts.map +1 -0
- package/dist/mcp/tools/structural-review.js +55 -0
- package/dist/mcp/tools/structural-review.js.map +1 -0
- package/dist/mcp/warp-pool.d.ts +4 -4
- package/dist/mcp/warp-pool.d.ts.map +1 -1
- package/dist/mcp/warp-pool.js.map +1 -1
- package/dist/mcp/workspace-router-model.d.ts +2 -2
- package/dist/mcp/workspace-router-model.d.ts.map +1 -1
- package/dist/mcp/workspace-router-runtime.d.ts +3 -3
- package/dist/mcp/workspace-router-runtime.d.ts.map +1 -1
- package/dist/mcp/workspace-router-runtime.js +4 -1
- package/dist/mcp/workspace-router-runtime.js.map +1 -1
- package/dist/mcp/workspace-router.d.ts +3 -2
- package/dist/mcp/workspace-router.d.ts.map +1 -1
- package/dist/mcp/workspace-router.js +6 -0
- package/dist/mcp/workspace-router.js.map +1 -1
- package/dist/operations/adaptive-projection.d.ts +22 -0
- package/dist/operations/adaptive-projection.d.ts.map +1 -0
- package/dist/operations/adaptive-projection.js +36 -0
- package/dist/operations/adaptive-projection.js.map +1 -0
- package/dist/operations/agent-handoff.d.ts +25 -0
- package/dist/operations/agent-handoff.d.ts.map +1 -0
- package/dist/operations/agent-handoff.js +36 -0
- package/dist/operations/agent-handoff.js.map +1 -0
- package/dist/operations/capture-range.d.ts +33 -0
- package/dist/operations/capture-range.d.ts.map +1 -0
- package/dist/operations/capture-range.js +45 -0
- package/dist/operations/capture-range.js.map +1 -0
- package/dist/operations/conversation-primer.d.ts +27 -0
- package/dist/operations/conversation-primer.d.ts.map +1 -0
- package/dist/operations/conversation-primer.js +52 -0
- package/dist/operations/conversation-primer.js.map +1 -0
- package/dist/operations/cross-session-resume.d.ts +28 -0
- package/dist/operations/cross-session-resume.d.ts.map +1 -0
- package/dist/operations/cross-session-resume.js +79 -0
- package/dist/operations/cross-session-resume.js.map +1 -0
- package/dist/operations/deterministic-replay.d.ts +39 -0
- package/dist/operations/deterministic-replay.d.ts.map +1 -0
- package/dist/operations/deterministic-replay.js +90 -0
- package/dist/operations/deterministic-replay.js.map +1 -0
- package/dist/operations/export-surface-diff.d.ts +36 -0
- package/dist/operations/export-surface-diff.d.ts.map +1 -0
- package/dist/operations/export-surface-diff.js +298 -0
- package/dist/operations/export-surface-diff.js.map +1 -0
- package/dist/operations/footprint-parallelism.d.ts +25 -0
- package/dist/operations/footprint-parallelism.d.ts.map +1 -0
- package/dist/operations/footprint-parallelism.js +79 -0
- package/dist/operations/footprint-parallelism.js.map +1 -0
- package/dist/operations/graft-diff.d.ts.map +1 -1
- package/dist/operations/graft-diff.js +14 -7
- package/dist/operations/graft-diff.js.map +1 -1
- package/dist/operations/horizon-of-readability.d.ts +23 -0
- package/dist/operations/horizon-of-readability.d.ts.map +1 -0
- package/dist/operations/horizon-of-readability.js +39 -0
- package/dist/operations/horizon-of-readability.js.map +1 -0
- package/dist/operations/import-reference-impact.d.ts +13 -0
- package/dist/operations/import-reference-impact.d.ts.map +1 -0
- package/dist/operations/import-reference-impact.js +101 -0
- package/dist/operations/import-reference-impact.js.map +1 -0
- package/dist/operations/knowledge-map.d.ts +30 -0
- package/dist/operations/knowledge-map.d.ts.map +1 -0
- package/dist/operations/knowledge-map.js +64 -0
- package/dist/operations/knowledge-map.js.map +1 -0
- package/dist/operations/observation-cache.d.ts +8 -2
- package/dist/operations/observation-cache.d.ts.map +1 -1
- package/dist/operations/observation-cache.js +17 -5
- package/dist/operations/observation-cache.js.map +1 -1
- package/dist/operations/projection-safety.d.ts +31 -0
- package/dist/operations/projection-safety.d.ts.map +1 -0
- package/dist/operations/projection-safety.js +77 -0
- package/dist/operations/projection-safety.js.map +1 -0
- package/dist/operations/repo-workspace.js +3 -3
- package/dist/operations/repo-workspace.js.map +1 -1
- package/dist/operations/semantic-drift.d.ts +27 -0
- package/dist/operations/semantic-drift.d.ts.map +1 -0
- package/dist/operations/semantic-drift.js +46 -0
- package/dist/operations/semantic-drift.js.map +1 -0
- package/dist/operations/session-filtration.d.ts +36 -0
- package/dist/operations/session-filtration.d.ts.map +1 -0
- package/dist/operations/session-filtration.js +48 -0
- package/dist/operations/session-filtration.js.map +1 -0
- package/dist/operations/session-replay.d.ts +17 -0
- package/dist/operations/session-replay.d.ts.map +1 -0
- package/dist/operations/session-replay.js +59 -0
- package/dist/operations/session-replay.js.map +1 -0
- package/dist/operations/sludge-detector.d.ts +45 -0
- package/dist/operations/sludge-detector.d.ts.map +1 -0
- package/dist/operations/sludge-detector.js +278 -0
- package/dist/operations/sludge-detector.js.map +1 -0
- package/dist/operations/structural-blame.d.ts +67 -0
- package/dist/operations/structural-blame.d.ts.map +1 -0
- package/dist/operations/structural-blame.js +111 -0
- package/dist/operations/structural-blame.js.map +1 -0
- package/dist/operations/structural-review.d.ts +47 -0
- package/dist/operations/structural-review.d.ts.map +1 -0
- package/dist/operations/structural-review.js +225 -0
- package/dist/operations/structural-review.js.map +1 -0
- package/dist/operations/teaching-hints.d.ts +18 -0
- package/dist/operations/teaching-hints.d.ts.map +1 -0
- package/dist/operations/teaching-hints.js +35 -0
- package/dist/operations/teaching-hints.js.map +1 -0
- package/dist/parser/diff.d.ts +2 -0
- package/dist/parser/diff.d.ts.map +1 -1
- package/dist/parser/diff.js +7 -0
- package/dist/parser/diff.js.map +1 -1
- package/dist/ports/paths.d.ts +17 -0
- package/dist/ports/paths.d.ts.map +1 -0
- package/dist/ports/{warp.js → paths.js} +2 -2
- package/dist/ports/paths.js.map +1 -0
- package/dist/warp/ast-emitter.d.ts +28 -0
- package/dist/warp/ast-emitter.d.ts.map +1 -0
- package/dist/warp/ast-emitter.js +90 -0
- package/dist/warp/ast-emitter.js.map +1 -0
- package/dist/warp/ast-import-resolver.d.ts +13 -0
- package/dist/warp/ast-import-resolver.d.ts.map +1 -0
- package/dist/warp/ast-import-resolver.js +259 -0
- package/dist/warp/ast-import-resolver.js.map +1 -0
- package/dist/warp/commit-meta.d.ts +8 -0
- package/dist/warp/commit-meta.d.ts.map +1 -0
- package/dist/warp/commit-meta.js +13 -0
- package/dist/warp/commit-meta.js.map +1 -0
- package/dist/warp/context.d.ts +10 -0
- package/dist/warp/context.d.ts.map +1 -0
- package/dist/warp/context.js +26 -0
- package/dist/warp/context.js.map +1 -0
- package/dist/warp/dead-symbols.d.ts +40 -0
- package/dist/warp/dead-symbols.d.ts.map +1 -0
- package/dist/warp/dead-symbols.js +127 -0
- package/dist/warp/dead-symbols.js.map +1 -0
- package/dist/warp/drift-sentinel.d.ts +30 -0
- package/dist/warp/drift-sentinel.d.ts.map +1 -0
- package/dist/warp/drift-sentinel.js +65 -0
- package/dist/warp/drift-sentinel.js.map +1 -0
- package/dist/warp/index-head.d.ts +32 -0
- package/dist/warp/index-head.d.ts.map +1 -0
- package/dist/warp/index-head.js +245 -0
- package/dist/warp/index-head.js.map +1 -0
- package/dist/warp/observers.d.ts +6 -6
- package/dist/warp/observers.d.ts.map +1 -1
- package/dist/warp/observers.js +5 -4
- package/dist/warp/observers.js.map +1 -1
- package/dist/warp/open.d.ts +5 -4
- package/dist/warp/open.d.ts.map +1 -1
- package/dist/warp/open.js +24 -49
- package/dist/warp/open.js.map +1 -1
- package/dist/warp/outline-diff-trailer.d.ts +26 -0
- package/dist/warp/outline-diff-trailer.d.ts.map +1 -0
- package/dist/warp/outline-diff-trailer.js +68 -0
- package/dist/warp/outline-diff-trailer.js.map +1 -0
- package/dist/warp/refactor-difficulty.d.ts +38 -0
- package/dist/warp/refactor-difficulty.d.ts.map +1 -0
- package/dist/warp/refactor-difficulty.js +169 -0
- package/dist/warp/refactor-difficulty.js.map +1 -0
- package/dist/warp/references.d.ts +22 -0
- package/dist/warp/references.d.ts.map +1 -0
- package/dist/warp/references.js +57 -0
- package/dist/warp/references.js.map +1 -0
- package/dist/warp/stale-docs.d.ts +56 -0
- package/dist/warp/stale-docs.d.ts.map +1 -0
- package/dist/warp/stale-docs.js +149 -0
- package/dist/warp/stale-docs.js.map +1 -0
- package/dist/warp/structural-drift-detection.d.ts +49 -0
- package/dist/warp/structural-drift-detection.d.ts.map +1 -0
- package/dist/warp/structural-drift-detection.js +51 -0
- package/dist/warp/structural-drift-detection.js.map +1 -0
- package/dist/warp/structural-queries.d.ts +49 -0
- package/dist/warp/structural-queries.d.ts.map +1 -0
- package/dist/warp/structural-queries.js +175 -0
- package/dist/warp/structural-queries.js.map +1 -0
- package/dist/warp/symbol-timeline.d.ts +34 -0
- package/dist/warp/symbol-timeline.d.ts.map +1 -0
- package/dist/warp/symbol-timeline.js +127 -0
- package/dist/warp/symbol-timeline.js.map +1 -0
- package/dist/warp/traverse-hydrate.d.ts +23 -0
- package/dist/warp/traverse-hydrate.d.ts.map +1 -0
- package/dist/warp/traverse-hydrate.js +39 -0
- package/dist/warp/traverse-hydrate.js.map +1 -0
- package/dist/warp/warp-reference-count.d.ts +19 -0
- package/dist/warp/warp-reference-count.d.ts.map +1 -0
- package/dist/warp/warp-reference-count.js +32 -0
- package/dist/warp/warp-reference-count.js.map +1 -0
- package/dist/warp/warp-structural-blame.d.ts +20 -0
- package/dist/warp/warp-structural-blame.d.ts.map +1 -0
- package/dist/warp/warp-structural-blame.js +43 -0
- package/dist/warp/warp-structural-blame.js.map +1 -0
- package/dist/warp/warp-structural-churn.d.ts +30 -0
- package/dist/warp/warp-structural-churn.d.ts.map +1 -0
- package/dist/warp/warp-structural-churn.js +213 -0
- package/dist/warp/warp-structural-churn.js.map +1 -0
- package/dist/warp/warp-structural-log.d.ts +35 -0
- package/dist/warp/warp-structural-log.d.ts.map +1 -0
- package/dist/warp/warp-structural-log.js +104 -0
- package/dist/warp/warp-structural-log.js.map +1 -0
- package/docs/CLI.md +68 -4
- package/docs/MCP.md +23 -0
- package/docs/SETUP.md +779 -0
- package/package.json +10 -7
- package/src/adapters/json-text-decoder.ts +11 -0
- package/src/adapters/node-paths.ts +35 -0
- package/src/adapters/repo-paths.ts +45 -4
- package/src/api/tool-bridge.ts +2 -1
- package/src/cli/cli-error.ts +49 -10
- package/src/cli/command-parser.ts +185 -3
- package/src/cli/daemon-status-model.ts +238 -0
- package/src/cli/daemon-status-render.ts +102 -0
- package/src/cli/daemon-status.ts +100 -0
- package/src/cli/git-graft-enhance-model.ts +131 -0
- package/src/cli/git-graft-enhance-render.ts +33 -0
- package/src/cli/git-graft-enhance.ts +54 -0
- package/src/cli/index-cmd.ts +18 -22
- package/src/cli/index-model.ts +21 -22
- package/src/cli/init-client-config.ts +167 -38
- package/src/cli/init-model.ts +57 -2
- package/src/cli/init-render.ts +2 -2
- package/src/cli/init.ts +11 -9
- package/src/cli/json-document.ts +11 -0
- package/src/cli/main.ts +53 -6
- package/src/cli/migrate-local-history.ts +3 -2
- package/src/cli/peer-command.ts +2 -1
- package/src/contracts/capabilities.ts +90 -0
- package/src/contracts/json-object.ts +1 -11
- package/src/contracts/output-schema-cli.ts +36 -3
- package/src/contracts/output-schema-fragments.ts +52 -2
- package/src/contracts/output-schema-mcp.ts +219 -0
- package/src/contracts/output-schemas.ts +300 -6
- package/src/git/diff.ts +61 -0
- package/src/mcp/burden.ts +9 -0
- package/src/mcp/context.ts +5 -42
- package/src/mcp/daemon-server.ts +8 -1
- package/src/mcp/daemon-session-host.ts +4 -0
- package/src/mcp/daemon-stdio-bridge.ts +2 -0
- package/src/mcp/monitor-tick-job.ts +90 -39
- package/src/mcp/monitor-types.ts +1 -1
- package/src/mcp/persisted-local-history-graph.ts +5 -4
- package/src/mcp/persisted-local-history.ts +2 -2
- package/src/mcp/persistent-monitor-runtime.ts +37 -0
- package/src/mcp/repo-tool-worker-context.ts +5 -2
- package/src/mcp/server-context.ts +15 -2
- package/src/mcp/server-tool-access.ts +4 -1
- package/src/mcp/server.ts +8 -3
- package/src/mcp/tool-registry.ts +18 -0
- package/src/mcp/tools/code-find.ts +23 -0
- package/src/mcp/tools/code-show.ts +27 -0
- package/src/mcp/tools/diagnostic-models.ts +2 -0
- package/src/mcp/tools/doctor.ts +18 -1
- package/src/mcp/tools/export-surface-diff.ts +26 -0
- package/src/mcp/tools/file-outline.ts +1 -1
- package/src/mcp/tools/graft-edit.ts +276 -0
- package/src/mcp/tools/knowledge-map.ts +34 -0
- package/src/mcp/tools/monitor-nudge.ts +19 -0
- package/src/mcp/tools/precision-warp.ts +27 -16
- package/src/mcp/tools/refactor-difficulty.ts +42 -0
- package/src/mcp/tools/safe-read.ts +2 -2
- package/src/mcp/tools/structural-blame.ts +55 -0
- package/src/mcp/tools/structural-churn.ts +28 -0
- package/src/mcp/tools/structural-log.ts +41 -0
- package/src/mcp/tools/structural-review.ts +63 -0
- package/src/mcp/warp-pool.ts +6 -6
- package/src/mcp/workspace-router-model.ts +2 -2
- package/src/mcp/workspace-router-runtime.ts +11 -8
- package/src/mcp/workspace-router.ts +9 -2
- package/src/operations/adaptive-projection.ts +54 -0
- package/src/operations/agent-handoff.ts +59 -0
- package/src/operations/capture-range.ts +64 -0
- package/src/operations/conversation-primer.ts +82 -0
- package/src/operations/cross-session-resume.ts +104 -0
- package/src/operations/deterministic-replay.ts +143 -0
- package/src/operations/export-surface-diff.ts +355 -0
- package/src/operations/footprint-parallelism.ts +98 -0
- package/src/operations/graft-diff.ts +14 -7
- package/src/operations/horizon-of-readability.ts +60 -0
- package/src/operations/import-reference-impact.ts +143 -0
- package/src/operations/knowledge-map.ts +96 -0
- package/src/operations/observation-cache.ts +20 -4
- package/src/operations/projection-safety.ts +111 -0
- package/src/operations/repo-workspace.ts +3 -3
- package/src/operations/semantic-drift.ts +70 -0
- package/src/operations/session-filtration.ts +76 -0
- package/src/operations/session-replay.ts +73 -0
- package/src/operations/sludge-detector.ts +356 -0
- package/src/operations/structural-blame.ts +197 -0
- package/src/operations/structural-review.ts +317 -0
- package/src/operations/teaching-hints.ts +52 -0
- package/src/parser/diff.ts +7 -0
- package/src/ports/paths.ts +22 -0
- package/src/warp/ast-emitter.ts +133 -0
- package/src/warp/ast-import-resolver.ts +333 -0
- package/src/warp/commit-meta.ts +19 -0
- package/src/warp/context.ts +48 -0
- package/src/warp/dead-symbols.ts +174 -0
- package/src/warp/drift-sentinel.ts +101 -0
- package/src/warp/index-head.ts +348 -0
- package/src/warp/observers.ts +8 -7
- package/src/warp/open.ts +40 -66
- package/src/warp/outline-diff-trailer.ts +100 -0
- package/src/warp/plumbing.d.ts +11 -2
- package/src/warp/refactor-difficulty.ts +257 -0
- package/src/warp/references.ts +77 -0
- package/src/warp/stale-docs.ts +210 -0
- package/src/warp/structural-drift-detection.ts +97 -0
- package/src/warp/structural-queries.ts +258 -0
- package/src/warp/symbol-timeline.ts +209 -0
- package/src/warp/traverse-hydrate.ts +61 -0
- package/src/warp/warp-reference-count.ts +47 -0
- package/src/warp/warp-structural-blame.ts +65 -0
- package/src/warp/warp-structural-churn.ts +309 -0
- package/src/warp/warp-structural-log.ts +149 -0
- package/dist/ports/warp.d.ts +0 -45
- package/dist/ports/warp.d.ts.map +0 -1
- package/dist/ports/warp.js.map +0 -1
- package/dist/warp/identity-resolver.d.ts +0 -14
- package/dist/warp/identity-resolver.d.ts.map +0 -1
- package/dist/warp/identity-resolver.js +0 -31
- package/dist/warp/identity-resolver.js.map +0 -1
- package/dist/warp/indexer-git.d.ts +0 -22
- package/dist/warp/indexer-git.d.ts.map +0 -1
- package/dist/warp/indexer-git.js +0 -148
- package/dist/warp/indexer-git.js.map +0 -1
- package/dist/warp/indexer-graph.d.ts +0 -17
- package/dist/warp/indexer-graph.d.ts.map +0 -1
- package/dist/warp/indexer-graph.js +0 -179
- package/dist/warp/indexer-graph.js.map +0 -1
- package/dist/warp/indexer-model.d.ts +0 -51
- package/dist/warp/indexer-model.d.ts.map +0 -1
- package/dist/warp/indexer-model.js +0 -21
- package/dist/warp/indexer-model.js.map +0 -1
- package/dist/warp/indexer.d.ts +0 -9
- package/dist/warp/indexer.d.ts.map +0 -1
- package/dist/warp/indexer.js +0 -112
- package/dist/warp/indexer.js.map +0 -1
- package/dist/warp/symbol-identity.d.ts +0 -11
- package/dist/warp/symbol-identity.d.ts.map +0 -1
- package/dist/warp/symbol-identity.js +0 -67
- package/dist/warp/symbol-identity.js.map +0 -1
- package/src/ports/warp.ts +0 -55
- package/src/warp/identity-resolver.ts +0 -35
- package/src/warp/indexer-git.ts +0 -182
- package/src/warp/indexer-graph.ts +0 -276
- package/src/warp/indexer-model.ts +0 -69
- package/src/warp/indexer.ts +0 -186
- package/src/warp/symbol-identity.ts +0 -100
|
@@ -0,0 +1,333 @@
|
|
|
1
|
+
// ---------------------------------------------------------------------------
|
|
2
|
+
// AST Import Resolver — adds cross-file reference edges to the WARP graph
|
|
3
|
+
// ---------------------------------------------------------------------------
|
|
4
|
+
|
|
5
|
+
import { createHash } from "node:crypto";
|
|
6
|
+
import type { PatchBuilderV2 } from "@git-stunts/git-warp";
|
|
7
|
+
import type { PathOps } from "../ports/paths.js";
|
|
8
|
+
|
|
9
|
+
type TSNode = import("web-tree-sitter").SyntaxNode;
|
|
10
|
+
|
|
11
|
+
function hashId(input: string): string {
|
|
12
|
+
return createHash("sha1").update(input).digest("hex").slice(0, 12);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
function astNodeId(filePath: string, node: TSNode): string {
|
|
16
|
+
const hash = hashId(`${filePath}:${node.type}:${String(node.startIndex)}:${String(node.endIndex)}`);
|
|
17
|
+
return `ast:${filePath}:${hash}`;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
function resolveModulePath(
|
|
21
|
+
importSource: string,
|
|
22
|
+
importingFilePath: string,
|
|
23
|
+
pathOps: PathOps,
|
|
24
|
+
knownFiles: ReadonlySet<string>,
|
|
25
|
+
): string | null {
|
|
26
|
+
// Skip non-relative imports (bare specifiers like "@pkg/foo" or "node:path")
|
|
27
|
+
if (!importSource.startsWith(".") && !importSource.startsWith("/")) {
|
|
28
|
+
return null;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// Resolve relative to the importing file's directory
|
|
32
|
+
const dir = importingFilePath.includes("/")
|
|
33
|
+
? importingFilePath.slice(0, importingFilePath.lastIndexOf("/"))
|
|
34
|
+
: "";
|
|
35
|
+
const raw = dir.length > 0
|
|
36
|
+
? pathOps.join(dir, importSource)
|
|
37
|
+
: pathOps.normalize(importSource);
|
|
38
|
+
|
|
39
|
+
const sourceExtensionCandidates = compiledSpecifierSourceCandidates(raw);
|
|
40
|
+
|
|
41
|
+
// Try exact match, then with extensions
|
|
42
|
+
const candidates = [
|
|
43
|
+
raw,
|
|
44
|
+
...sourceExtensionCandidates,
|
|
45
|
+
`${raw}.ts`,
|
|
46
|
+
`${raw}.tsx`,
|
|
47
|
+
`${raw}.js`,
|
|
48
|
+
`${raw}.jsx`,
|
|
49
|
+
`${raw}/index.ts`,
|
|
50
|
+
`${raw}/index.tsx`,
|
|
51
|
+
`${raw}/index.js`,
|
|
52
|
+
];
|
|
53
|
+
|
|
54
|
+
for (const candidate of candidates) {
|
|
55
|
+
if (knownFiles.has(candidate)) {
|
|
56
|
+
return candidate;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
return null;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
function compiledSpecifierSourceCandidates(resolvedImportSource: string): readonly string[] {
|
|
64
|
+
const compiledToSourceExtensions: readonly [string, readonly string[]][] = [
|
|
65
|
+
[".js", [".ts", ".tsx"]],
|
|
66
|
+
[".jsx", [".tsx", ".ts"]],
|
|
67
|
+
[".mjs", [".mts", ".ts"]],
|
|
68
|
+
[".cjs", [".cts", ".ts"]],
|
|
69
|
+
];
|
|
70
|
+
|
|
71
|
+
for (const [compiledExtension, sourceExtensions] of compiledToSourceExtensions) {
|
|
72
|
+
if (!resolvedImportSource.endsWith(compiledExtension)) continue;
|
|
73
|
+
|
|
74
|
+
const base = resolvedImportSource.slice(0, -compiledExtension.length);
|
|
75
|
+
return sourceExtensions.map((sourceExtension) => `${base}${sourceExtension}`);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
return [];
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
function symNodeId(filePath: string, symbolName: string): string {
|
|
82
|
+
return `sym:${filePath}:${symbolName}`;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
interface ImportInfo {
|
|
86
|
+
readonly specifierNodeId: string;
|
|
87
|
+
readonly node: TSNode;
|
|
88
|
+
readonly importedName: string;
|
|
89
|
+
readonly localName: string;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
function emitAstAnchor(patch: PatchBuilderV2, filePath: string, node: TSNode): string {
|
|
93
|
+
const nodeId = astNodeId(filePath, node);
|
|
94
|
+
patch.addNode(nodeId);
|
|
95
|
+
patch.setProperty(nodeId, "type", node.type);
|
|
96
|
+
patch.setProperty(nodeId, "named", node.isNamed());
|
|
97
|
+
patch.setProperty(nodeId, "startRow", node.startPosition.row);
|
|
98
|
+
patch.setProperty(nodeId, "startCol", node.startPosition.column);
|
|
99
|
+
patch.setProperty(nodeId, "endRow", node.endPosition.row);
|
|
100
|
+
patch.setProperty(nodeId, "endCol", node.endPosition.column);
|
|
101
|
+
patch.setProperty(nodeId, "filePath", filePath);
|
|
102
|
+
return nodeId;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
function extractImportSpecifiers(
|
|
106
|
+
importNode: TSNode,
|
|
107
|
+
filePath: string,
|
|
108
|
+
): ImportInfo[] {
|
|
109
|
+
const results: ImportInfo[] = [];
|
|
110
|
+
const importClause = importNode.namedChildren.find((c) => c.type === "import_clause");
|
|
111
|
+
if (importClause === undefined) return results;
|
|
112
|
+
|
|
113
|
+
for (const child of importClause.namedChildren) {
|
|
114
|
+
switch (child.type) {
|
|
115
|
+
case "named_imports": {
|
|
116
|
+
// import { foo, bar as baz } from "..."
|
|
117
|
+
for (const spec of child.namedChildren) {
|
|
118
|
+
if (spec.type === "import_specifier") {
|
|
119
|
+
const nameNode = spec.childForFieldName("name");
|
|
120
|
+
const aliasNode = spec.childForFieldName("alias");
|
|
121
|
+
if (nameNode !== null) {
|
|
122
|
+
results.push({
|
|
123
|
+
specifierNodeId: astNodeId(filePath, spec),
|
|
124
|
+
node: spec,
|
|
125
|
+
importedName: nameNode.text,
|
|
126
|
+
localName: aliasNode !== null ? aliasNode.text : nameNode.text,
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
break;
|
|
132
|
+
}
|
|
133
|
+
case "identifier": {
|
|
134
|
+
// import foo from "..." (default import)
|
|
135
|
+
results.push({
|
|
136
|
+
specifierNodeId: astNodeId(filePath, child),
|
|
137
|
+
node: child,
|
|
138
|
+
importedName: "default",
|
|
139
|
+
localName: child.text,
|
|
140
|
+
});
|
|
141
|
+
break;
|
|
142
|
+
}
|
|
143
|
+
case "namespace_import": {
|
|
144
|
+
// import * as ns from "..."
|
|
145
|
+
const aliasNode = child.namedChildren.find((c) => c.type === "identifier");
|
|
146
|
+
if (aliasNode !== undefined) {
|
|
147
|
+
results.push({
|
|
148
|
+
specifierNodeId: astNodeId(filePath, child),
|
|
149
|
+
node: child,
|
|
150
|
+
importedName: "*",
|
|
151
|
+
localName: aliasNode.text,
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
break;
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
return results;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
function extractExportSpecifiers(
|
|
163
|
+
exportNode: TSNode,
|
|
164
|
+
filePath: string,
|
|
165
|
+
): ImportInfo[] {
|
|
166
|
+
const results: ImportInfo[] = [];
|
|
167
|
+
const exportClause = exportNode.namedChildren.find((c) => c.type === "export_clause");
|
|
168
|
+
if (exportClause === undefined) return results;
|
|
169
|
+
|
|
170
|
+
for (const spec of exportClause.namedChildren) {
|
|
171
|
+
if (spec.type === "export_specifier") {
|
|
172
|
+
const nameNode = spec.childForFieldName("name");
|
|
173
|
+
const aliasNode = spec.childForFieldName("alias");
|
|
174
|
+
if (nameNode !== null) {
|
|
175
|
+
results.push({
|
|
176
|
+
specifierNodeId: astNodeId(filePath, spec),
|
|
177
|
+
node: spec,
|
|
178
|
+
importedName: nameNode.text,
|
|
179
|
+
localName: aliasNode !== null ? aliasNode.text : nameNode.text,
|
|
180
|
+
});
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
return results;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
function getModuleSource(node: TSNode): string | null {
|
|
189
|
+
const stringNode = node.namedChildren.find((c) => c.type === "string");
|
|
190
|
+
if (stringNode === undefined) return null;
|
|
191
|
+
const fragment = stringNode.namedChildren.find((c) => c.type === "string_fragment");
|
|
192
|
+
return fragment !== undefined ? fragment.text : null;
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
/**
|
|
196
|
+
* Resolve import/export statements and emit cross-file reference edges.
|
|
197
|
+
*
|
|
198
|
+
* Call this inside a patch callback after emitAstNodes has run for a file.
|
|
199
|
+
* Handles: named imports, aliased imports, default imports, namespace imports,
|
|
200
|
+
* re-exports, and dynamic imports.
|
|
201
|
+
*/
|
|
202
|
+
export function resolveImportEdges(
|
|
203
|
+
patch: PatchBuilderV2,
|
|
204
|
+
filePath: string,
|
|
205
|
+
root: TSNode,
|
|
206
|
+
pathOps: PathOps,
|
|
207
|
+
knownFiles: ReadonlySet<string>,
|
|
208
|
+
): void {
|
|
209
|
+
for (const child of root.namedChildren) {
|
|
210
|
+
if (child.type === "import_statement") {
|
|
211
|
+
handleImportStatement(patch, filePath, child, pathOps, knownFiles);
|
|
212
|
+
} else if (child.type === "export_statement") {
|
|
213
|
+
handleExportStatement(patch, filePath, child, pathOps, knownFiles);
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
// Dynamic imports: find call_expression nodes with `import` function
|
|
218
|
+
walkForDynamicImports(patch, filePath, root, pathOps, knownFiles);
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
function handleImportStatement(
|
|
222
|
+
patch: PatchBuilderV2,
|
|
223
|
+
filePath: string,
|
|
224
|
+
node: TSNode,
|
|
225
|
+
pathOps: PathOps,
|
|
226
|
+
knownFiles: ReadonlySet<string>,
|
|
227
|
+
): void {
|
|
228
|
+
const source = getModuleSource(node);
|
|
229
|
+
if (source === null) return;
|
|
230
|
+
|
|
231
|
+
const resolvedPath = resolveModulePath(source, filePath, pathOps, knownFiles);
|
|
232
|
+
|
|
233
|
+
// Emit resolves_to edge from the string node to the target file
|
|
234
|
+
const stringNode = node.namedChildren.find((c) => c.type === "string");
|
|
235
|
+
if (stringNode !== undefined && resolvedPath !== null) {
|
|
236
|
+
const stringId = emitAstAnchor(patch, filePath, stringNode);
|
|
237
|
+
patch.addEdge(stringId, `file:${resolvedPath}`, "resolves_to");
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
// Emit reference edges from specifiers to sym: nodes
|
|
241
|
+
const specifiers = extractImportSpecifiers(node, filePath);
|
|
242
|
+
for (const spec of specifiers) {
|
|
243
|
+
emitAstAnchor(patch, filePath, spec.node);
|
|
244
|
+
patch.setProperty(spec.specifierNodeId, "importedName", spec.importedName);
|
|
245
|
+
patch.setProperty(spec.specifierNodeId, "localName", spec.localName);
|
|
246
|
+
patch.setProperty(spec.specifierNodeId, "filePath", filePath);
|
|
247
|
+
|
|
248
|
+
if (resolvedPath !== null) {
|
|
249
|
+
if (spec.importedName === "*") {
|
|
250
|
+
// Namespace import references the whole file
|
|
251
|
+
patch.addEdge(spec.specifierNodeId, `file:${resolvedPath}`, "references");
|
|
252
|
+
} else {
|
|
253
|
+
// Named/default import references a specific symbol
|
|
254
|
+
patch.addEdge(spec.specifierNodeId, symNodeId(resolvedPath, spec.importedName), "references");
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
function handleExportStatement(
|
|
261
|
+
patch: PatchBuilderV2,
|
|
262
|
+
filePath: string,
|
|
263
|
+
node: TSNode,
|
|
264
|
+
pathOps: PathOps,
|
|
265
|
+
knownFiles: ReadonlySet<string>,
|
|
266
|
+
): void {
|
|
267
|
+
// Only handle re-exports (export { ... } from "...")
|
|
268
|
+
const source = getModuleSource(node);
|
|
269
|
+
if (source === null) return;
|
|
270
|
+
|
|
271
|
+
const resolvedPath = resolveModulePath(source, filePath, pathOps, knownFiles);
|
|
272
|
+
|
|
273
|
+
const stringNode = node.namedChildren.find((c) => c.type === "string");
|
|
274
|
+
if (stringNode !== undefined && resolvedPath !== null) {
|
|
275
|
+
const stringId = emitAstAnchor(patch, filePath, stringNode);
|
|
276
|
+
patch.addEdge(stringId, `file:${resolvedPath}`, "resolves_to");
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
// Check for wildcard re-export: export * from "..."
|
|
280
|
+
const hasWildcard = node.children.some((c) => c.type === "*" || c.type === "namespace_export");
|
|
281
|
+
if (hasWildcard && resolvedPath !== null) {
|
|
282
|
+
const nodeId = emitAstAnchor(patch, filePath, node);
|
|
283
|
+
patch.addEdge(nodeId, `file:${resolvedPath}`, "reexports");
|
|
284
|
+
return;
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
// Named re-exports: export { foo, bar as baz } from "..."
|
|
288
|
+
const specifiers = extractExportSpecifiers(node, filePath);
|
|
289
|
+
for (const spec of specifiers) {
|
|
290
|
+
emitAstAnchor(patch, filePath, spec.node);
|
|
291
|
+
patch.setProperty(spec.specifierNodeId, "importedName", spec.importedName);
|
|
292
|
+
patch.setProperty(spec.specifierNodeId, "localName", spec.localName);
|
|
293
|
+
patch.setProperty(spec.specifierNodeId, "filePath", filePath);
|
|
294
|
+
|
|
295
|
+
if (resolvedPath !== null) {
|
|
296
|
+
patch.addEdge(spec.specifierNodeId, symNodeId(resolvedPath, spec.importedName), "references");
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
function walkForDynamicImports(
|
|
302
|
+
patch: PatchBuilderV2,
|
|
303
|
+
filePath: string,
|
|
304
|
+
node: TSNode,
|
|
305
|
+
pathOps: PathOps,
|
|
306
|
+
knownFiles: ReadonlySet<string>,
|
|
307
|
+
): void {
|
|
308
|
+
if (node.type === "call_expression") {
|
|
309
|
+
const funcNode = node.namedChildren[0];
|
|
310
|
+
if (funcNode?.type === "import") {
|
|
311
|
+
// Dynamic import: import("./foo")
|
|
312
|
+
const args = node.namedChildren.find((c) => c.type === "arguments");
|
|
313
|
+
if (args !== undefined) {
|
|
314
|
+
const stringArg = args.namedChildren.find((c) => c.type === "string");
|
|
315
|
+
if (stringArg !== undefined) {
|
|
316
|
+
const fragment = stringArg.namedChildren.find((c) => c.type === "string_fragment");
|
|
317
|
+
if (fragment !== undefined) {
|
|
318
|
+
const resolved = resolveModulePath(fragment.text, filePath, pathOps, knownFiles);
|
|
319
|
+
if (resolved !== null) {
|
|
320
|
+
const stringId = emitAstAnchor(patch, filePath, stringArg);
|
|
321
|
+
patch.addEdge(stringId, `file:${resolved}`, "resolves_to");
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
// Recurse
|
|
330
|
+
for (const child of node.namedChildren) {
|
|
331
|
+
walkForDynamicImports(patch, filePath, child, pathOps, knownFiles);
|
|
332
|
+
}
|
|
333
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { GitClient } from "../ports/git.js";
|
|
2
|
+
|
|
3
|
+
async function git(gitClient: GitClient, cwd: string, args: readonly string[]): Promise<string> {
|
|
4
|
+
const result = await gitClient.run({ cwd, args });
|
|
5
|
+
if (result.error !== undefined || result.status !== 0) {
|
|
6
|
+
throw result.error ?? new Error(result.stderr.trim() || `git exited with status ${String(result.status)}`);
|
|
7
|
+
}
|
|
8
|
+
return result.stdout;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export async function getCommitMeta(
|
|
12
|
+
gitClient: GitClient,
|
|
13
|
+
sha: string,
|
|
14
|
+
cwd: string,
|
|
15
|
+
): Promise<{ message: string; author: string; email: string; timestamp: string }> {
|
|
16
|
+
const output = await git(gitClient, cwd, ["log", "-1", "--format=%s%n%aN%n%aE%n%aI", sha]);
|
|
17
|
+
const lines = output.trim().split("\n");
|
|
18
|
+
return { message: lines[0] ?? "", author: lines[1] ?? "", email: lines[2] ?? "", timestamp: lines[3] ?? "" };
|
|
19
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
// ---------------------------------------------------------------------------
|
|
2
|
+
// WarpContext — session-scoped DI bag for all graph access.
|
|
3
|
+
//
|
|
4
|
+
// Every graph interaction (reads AND writes) routes through this context.
|
|
5
|
+
// A strand scopes the agent's entire worldview — strand-local writes are
|
|
6
|
+
// invisible from live reads, so routing must be uniform.
|
|
7
|
+
// ---------------------------------------------------------------------------
|
|
8
|
+
|
|
9
|
+
import type WarpApp from "@git-stunts/git-warp";
|
|
10
|
+
import type { Lens, Observer, ObserverOptions, PatchBuilderV2 } from "@git-stunts/git-warp";
|
|
11
|
+
|
|
12
|
+
export interface WarpContext {
|
|
13
|
+
readonly app: WarpApp;
|
|
14
|
+
readonly strandId: string | null;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
function assertNoStrand(ctx: WarpContext): void {
|
|
18
|
+
if (ctx.strandId !== null) {
|
|
19
|
+
throw new Error(
|
|
20
|
+
`Strand isolation not yet supported (strandId: ${ctx.strandId}). ` +
|
|
21
|
+
`git-warp strand merging is not ready.`,
|
|
22
|
+
);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export async function patchGraph(
|
|
27
|
+
ctx: WarpContext,
|
|
28
|
+
build: (patch: PatchBuilderV2) => void | Promise<void>,
|
|
29
|
+
): Promise<string> {
|
|
30
|
+
assertNoStrand(ctx);
|
|
31
|
+
return ctx.app.patch(build);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export async function observeGraph(
|
|
35
|
+
ctx: WarpContext,
|
|
36
|
+
lens: Lens,
|
|
37
|
+
options?: ObserverOptions,
|
|
38
|
+
): Promise<Observer> {
|
|
39
|
+
assertNoStrand(ctx);
|
|
40
|
+
return ctx.app.observer(lens, options);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export async function materializeGraph(
|
|
44
|
+
ctx: WarpContext,
|
|
45
|
+
): Promise<void> {
|
|
46
|
+
assertNoStrand(ctx);
|
|
47
|
+
await ctx.app.core().materialize();
|
|
48
|
+
}
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Dead Symbol Detection — find symbols removed and never re-added.
|
|
3
|
+
*
|
|
4
|
+
* A symbol is "dead" when it existed at one tick but is absent at a
|
|
5
|
+
* later tick and never reappears. This identifies cleanup candidates,
|
|
6
|
+
* tracks deprecations, and measures API surface shrinkage.
|
|
7
|
+
*
|
|
8
|
+
* Uses the WARP graph's temporal observer to compare symbol snapshots
|
|
9
|
+
* across ticks. Walks commits in tick order, detects removals by
|
|
10
|
+
* diff, then filters out any symbol that reappears later.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
import type { Lens } from "@git-stunts/git-warp";
|
|
14
|
+
import { observeGraph, type WarpContext } from "./context.js";
|
|
15
|
+
|
|
16
|
+
// ---------------------------------------------------------------------------
|
|
17
|
+
// Types
|
|
18
|
+
// ---------------------------------------------------------------------------
|
|
19
|
+
|
|
20
|
+
/** A symbol that was removed and never re-added. */
|
|
21
|
+
export interface DeadSymbol {
|
|
22
|
+
/** The symbol name (e.g. "myFunction"). */
|
|
23
|
+
readonly name: string;
|
|
24
|
+
/** The kind of symbol (e.g. "function", "class"). */
|
|
25
|
+
readonly kind: string;
|
|
26
|
+
/** The file path the symbol belonged to. */
|
|
27
|
+
readonly filePath: string;
|
|
28
|
+
/** Whether the symbol was exported. */
|
|
29
|
+
readonly exported: boolean;
|
|
30
|
+
/** The commit SHA that removed the symbol. */
|
|
31
|
+
readonly removedInCommit: string;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/** Options for the dead-symbol query. */
|
|
35
|
+
export interface DeadSymbolOptions {
|
|
36
|
+
/** Limit the search to the last N commits (by tick order). */
|
|
37
|
+
readonly maxCommits?: number | undefined;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
// ---------------------------------------------------------------------------
|
|
41
|
+
// Internal helpers
|
|
42
|
+
// ---------------------------------------------------------------------------
|
|
43
|
+
|
|
44
|
+
/** Extract the file path from a sym node id like "sym:path/to/file.ts:symbolName". */
|
|
45
|
+
function filePathFromSymId(symId: string): string {
|
|
46
|
+
const withoutPrefix = symId.slice("sym:".length);
|
|
47
|
+
const lastColon = withoutPrefix.lastIndexOf(":");
|
|
48
|
+
if (lastColon === -1) {
|
|
49
|
+
return withoutPrefix;
|
|
50
|
+
}
|
|
51
|
+
return withoutPrefix.slice(0, lastColon);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
const SYM_LENS: Lens = {
|
|
55
|
+
match: "sym:*",
|
|
56
|
+
expose: ["name", "kind", "signature", "exported"],
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
// ---------------------------------------------------------------------------
|
|
60
|
+
// Public API
|
|
61
|
+
// ---------------------------------------------------------------------------
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Find symbols that were removed and never re-added.
|
|
65
|
+
*
|
|
66
|
+
* For each commit in tick order, compares the sym-node set at the previous
|
|
67
|
+
* indexed commit tick vs this commit's tick to find removals (present before,
|
|
68
|
+
* absent after). A single Git commit can span multiple WARP Lamport ticks
|
|
69
|
+
* because lazy indexing writes one bounded patch per file.
|
|
70
|
+
*/
|
|
71
|
+
export async function findDeadSymbols(
|
|
72
|
+
ctx: WarpContext,
|
|
73
|
+
options?: DeadSymbolOptions,
|
|
74
|
+
): Promise<DeadSymbol[]> {
|
|
75
|
+
// Discover all commit nodes and read their ticks.
|
|
76
|
+
const commitLens: Lens = {
|
|
77
|
+
match: "commit:*",
|
|
78
|
+
expose: ["sha", "tick"],
|
|
79
|
+
};
|
|
80
|
+
const commitObs = await observeGraph(ctx, commitLens);
|
|
81
|
+
const commitNodeIds = await commitObs.getNodes();
|
|
82
|
+
|
|
83
|
+
const commits: { id: string; sha: string; tick: number }[] = [];
|
|
84
|
+
for (const id of commitNodeIds) {
|
|
85
|
+
const props = await commitObs.getNodeProps(id);
|
|
86
|
+
const tick = typeof props?.["tick"] === "number" ? props["tick"] : null;
|
|
87
|
+
if (tick === null) continue;
|
|
88
|
+
const sha = typeof props?.["sha"] === "string"
|
|
89
|
+
? props["sha"]
|
|
90
|
+
: id.slice("commit:".length);
|
|
91
|
+
commits.push({ id, sha, tick });
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
// Sort by tick ascending.
|
|
95
|
+
commits.sort((a, b) => a.tick - b.tick);
|
|
96
|
+
|
|
97
|
+
if (commits.length === 0) return [];
|
|
98
|
+
|
|
99
|
+
// Apply maxCommits limit — scope to the last N commits.
|
|
100
|
+
const limit = options?.maxCommits;
|
|
101
|
+
const scopedCommits = limit !== undefined && limit > 0
|
|
102
|
+
? commits.slice(-limit)
|
|
103
|
+
: commits;
|
|
104
|
+
|
|
105
|
+
// For each scoped commit, detect removals by diffing sym nodes at the
|
|
106
|
+
// previous indexed commit boundary vs this commit's boundary. Per-file lazy
|
|
107
|
+
// index patches inside the same Git commit are deliberately treated as one
|
|
108
|
+
// commit window.
|
|
109
|
+
// Track removed symbols with the pre-removal boundary needed to recover props.
|
|
110
|
+
// If a symbol reappears at a later tick, remove it from the map.
|
|
111
|
+
const removals = new Map<string, { sha: string; tick: number; beforeTick: number }>();
|
|
112
|
+
|
|
113
|
+
for (const commit of scopedCommits) {
|
|
114
|
+
const commitIndex = commits.indexOf(commit);
|
|
115
|
+
const previousCommit = commitIndex > 0 ? commits[commitIndex - 1] : undefined;
|
|
116
|
+
const beforeTick = commitIndex > 0
|
|
117
|
+
? previousCommit?.tick ?? 0
|
|
118
|
+
: 0;
|
|
119
|
+
|
|
120
|
+
const [beforeObs, afterObs] = await Promise.all([
|
|
121
|
+
observeGraph(ctx, SYM_LENS, { source: { kind: "live", ceiling: beforeTick } }),
|
|
122
|
+
observeGraph(ctx, SYM_LENS, { source: { kind: "live", ceiling: commit.tick } }),
|
|
123
|
+
]);
|
|
124
|
+
|
|
125
|
+
const [beforeNodes, afterNodes] = await Promise.all([
|
|
126
|
+
beforeObs.getNodes(),
|
|
127
|
+
afterObs.getNodes(),
|
|
128
|
+
]);
|
|
129
|
+
|
|
130
|
+
const afterSet = new Set(afterNodes);
|
|
131
|
+
const beforeSet = new Set(beforeNodes);
|
|
132
|
+
|
|
133
|
+
// Symbols present before but absent after = removed in this commit.
|
|
134
|
+
for (const symId of beforeNodes) {
|
|
135
|
+
if (!afterSet.has(symId)) {
|
|
136
|
+
removals.set(symId, { sha: commit.sha, tick: commit.tick, beforeTick });
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
// Symbols absent before but present after = re-added in this commit.
|
|
141
|
+
for (const symId of afterNodes) {
|
|
142
|
+
if (!beforeSet.has(symId) && removals.has(symId)) {
|
|
143
|
+
removals.delete(symId);
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
if (removals.size === 0) return [];
|
|
149
|
+
|
|
150
|
+
// Read props for dead symbols from a ceiling just before removal.
|
|
151
|
+
const dead: DeadSymbol[] = [];
|
|
152
|
+
|
|
153
|
+
for (const [symId, removal] of removals) {
|
|
154
|
+
const beforeObs = await observeGraph(ctx, SYM_LENS, {
|
|
155
|
+
source: { kind: "live", ceiling: removal.beforeTick },
|
|
156
|
+
});
|
|
157
|
+
|
|
158
|
+
const props = await beforeObs.getNodeProps(symId);
|
|
159
|
+
const name = typeof props?.["name"] === "string" ? props["name"] : symId;
|
|
160
|
+
const kind = typeof props?.["kind"] === "string" ? props["kind"] : "unknown";
|
|
161
|
+
const exported = typeof props?.["exported"] === "boolean" ? props["exported"] : false;
|
|
162
|
+
const filePath = filePathFromSymId(symId);
|
|
163
|
+
|
|
164
|
+
dead.push({
|
|
165
|
+
name,
|
|
166
|
+
kind,
|
|
167
|
+
filePath,
|
|
168
|
+
exported,
|
|
169
|
+
removedInCommit: removal.sha,
|
|
170
|
+
});
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
return dead;
|
|
174
|
+
}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
// ---------------------------------------------------------------------------
|
|
2
|
+
// Drift Sentinel — scan all markdown files for stale symbol references
|
|
3
|
+
// ---------------------------------------------------------------------------
|
|
4
|
+
|
|
5
|
+
import type { WarpContext } from "./context.js";
|
|
6
|
+
import { checkStaleDocs, type StaleDocReport } from "./stale-docs.js";
|
|
7
|
+
import type { GitClient } from "../ports/git.js";
|
|
8
|
+
import picomatch from "picomatch";
|
|
9
|
+
|
|
10
|
+
/** Options for the drift sentinel scan. */
|
|
11
|
+
export interface DriftSentinelOptions {
|
|
12
|
+
readonly cwd: string;
|
|
13
|
+
readonly git: GitClient;
|
|
14
|
+
/** Glob pattern for markdown files to check. Defaults to all tracked .md files. */
|
|
15
|
+
readonly pattern?: string;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/** Full drift report across all scanned doc files. */
|
|
19
|
+
export interface DriftSentinelReport {
|
|
20
|
+
/** True if no stale or unknown symbols were found in any doc. */
|
|
21
|
+
readonly passed: boolean;
|
|
22
|
+
/** Per-file results. */
|
|
23
|
+
readonly results: readonly StaleDocReport[];
|
|
24
|
+
/** Total stale symbol count across all files. */
|
|
25
|
+
readonly totalStale: number;
|
|
26
|
+
/** Total unknown symbol count across all files. */
|
|
27
|
+
readonly totalUnknown: number;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Scan all markdown files in the repo for stale symbol references.
|
|
32
|
+
*
|
|
33
|
+
* For each tracked `.md` file, runs `checkStaleDocs` against the WARP
|
|
34
|
+
* graph. Returns a structured report with pass/fail verdict suitable
|
|
35
|
+
* for pre-commit hook exit codes.
|
|
36
|
+
*/
|
|
37
|
+
export async function runDriftSentinel(
|
|
38
|
+
ctx: WarpContext,
|
|
39
|
+
options: DriftSentinelOptions,
|
|
40
|
+
): Promise<DriftSentinelReport> {
|
|
41
|
+
const { cwd, git } = options;
|
|
42
|
+
|
|
43
|
+
// List all tracked markdown files
|
|
44
|
+
const lsResult = await git.run({
|
|
45
|
+
cwd,
|
|
46
|
+
args: ["ls-files", "--cached", "*.md", "**/*.md"],
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
if (lsResult.error !== undefined || lsResult.status !== 0) {
|
|
50
|
+
return { passed: true, results: [], totalStale: 0, totalUnknown: 0 };
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
const pattern = options.pattern?.trim();
|
|
54
|
+
const matchesPattern = pattern !== undefined && pattern.length > 0
|
|
55
|
+
? picomatch(pattern)
|
|
56
|
+
: null;
|
|
57
|
+
|
|
58
|
+
const mdFiles = lsResult.stdout
|
|
59
|
+
.split("\n")
|
|
60
|
+
.map((f) => f.trim())
|
|
61
|
+
.filter((f) => f.length > 0 && f.endsWith(".md"))
|
|
62
|
+
.filter((f) => matchesPattern === null || matchesPattern(f));
|
|
63
|
+
|
|
64
|
+
if (mdFiles.length === 0) {
|
|
65
|
+
return { passed: true, results: [], totalStale: 0, totalUnknown: 0 };
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
// For each markdown file, get its last-modified commit SHA and content
|
|
69
|
+
const results: StaleDocReport[] = [];
|
|
70
|
+
|
|
71
|
+
for (const mdFile of mdFiles) {
|
|
72
|
+
// Get the commit SHA that last modified this file
|
|
73
|
+
const logResult = await git.run({
|
|
74
|
+
cwd,
|
|
75
|
+
args: ["log", "-1", "--format=%H", "--", mdFile],
|
|
76
|
+
});
|
|
77
|
+
const docCommitSha = logResult.stdout.trim();
|
|
78
|
+
if (docCommitSha.length === 0) continue;
|
|
79
|
+
|
|
80
|
+
// Read file content
|
|
81
|
+
const showResult = await git.run({
|
|
82
|
+
cwd,
|
|
83
|
+
args: ["show", `HEAD:${mdFile}`],
|
|
84
|
+
});
|
|
85
|
+
const docContent = showResult.stdout;
|
|
86
|
+
if (docContent.length === 0) continue;
|
|
87
|
+
|
|
88
|
+
const report = await checkStaleDocs(ctx, mdFile, docCommitSha, docContent);
|
|
89
|
+
|
|
90
|
+
// Only include files that have symbol references
|
|
91
|
+
if (report.staleSymbols.length > 0 || report.unknownSymbols.length > 0) {
|
|
92
|
+
results.push(report);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
const totalStale = results.reduce((sum, r) => sum + r.staleSymbols.length, 0);
|
|
97
|
+
const totalUnknown = results.reduce((sum, r) => sum + r.unknownSymbols.length, 0);
|
|
98
|
+
const passed = totalStale === 0 && totalUnknown === 0;
|
|
99
|
+
|
|
100
|
+
return { passed, results, totalStale, totalUnknown };
|
|
101
|
+
}
|