@mrclrchtr/supi-code-intelligence 1.16.0 → 2.0.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/README.md +373 -63
- package/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/package.json +6 -1
- package/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/src/abort-utils.ts +31 -0
- package/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/src/api.ts +8 -0
- package/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/src/config/config-settings.ts +10 -4
- package/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/src/config.ts +1 -0
- package/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/src/footer-registry.ts +1 -1
- package/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/src/index.ts +6 -0
- package/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/src/model-selection.ts +134 -0
- package/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/src/settings/settings-registry.ts +9 -2
- package/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/src/settings/settings-ui.ts +109 -4
- package/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/src/settings-ui.ts +5 -1
- package/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/src/spinner-frames.ts +11 -0
- package/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/src/status-spinner.ts +68 -0
- package/node_modules/@mrclrchtr/supi-code-runtime/package.json +3 -2
- package/node_modules/@mrclrchtr/supi-code-runtime/src/api.ts +7 -0
- package/node_modules/@mrclrchtr/supi-code-runtime/src/capability/types.ts +56 -2
- package/node_modules/@mrclrchtr/supi-code-runtime/src/evidence-badge.ts +40 -0
- package/node_modules/@mrclrchtr/supi-code-runtime/src/index.ts +5 -0
- package/node_modules/@mrclrchtr/supi-code-runtime/src/types.ts +76 -3
- package/node_modules/@mrclrchtr/supi-code-runtime/src/workspace/runtime.ts +37 -2
- package/node_modules/@mrclrchtr/supi-core/package.json +6 -1
- package/node_modules/@mrclrchtr/supi-core/src/abort-utils.ts +31 -0
- package/node_modules/@mrclrchtr/supi-core/src/api.ts +8 -0
- package/node_modules/@mrclrchtr/supi-core/src/config/config-settings.ts +10 -4
- package/node_modules/@mrclrchtr/supi-core/src/config.ts +1 -0
- package/node_modules/@mrclrchtr/supi-core/src/footer-registry.ts +1 -1
- package/node_modules/@mrclrchtr/supi-core/src/index.ts +6 -0
- package/node_modules/@mrclrchtr/supi-core/src/model-selection.ts +134 -0
- package/node_modules/@mrclrchtr/supi-core/src/settings/settings-registry.ts +9 -2
- package/node_modules/@mrclrchtr/supi-core/src/settings/settings-ui.ts +109 -4
- package/node_modules/@mrclrchtr/supi-core/src/settings-ui.ts +5 -1
- package/node_modules/@mrclrchtr/supi-core/src/spinner-frames.ts +11 -0
- package/node_modules/@mrclrchtr/supi-core/src/status-spinner.ts +68 -0
- package/node_modules/@mrclrchtr/supi-lsp/README.md +44 -56
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/package.json +6 -1
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/src/abort-utils.ts +31 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/src/api.ts +8 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/src/config/config-settings.ts +10 -4
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/src/config.ts +1 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/src/footer-registry.ts +1 -1
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/src/index.ts +6 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/src/model-selection.ts +134 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/src/settings/settings-registry.ts +9 -2
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/src/settings/settings-ui.ts +109 -4
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/src/settings-ui.ts +5 -1
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/src/spinner-frames.ts +11 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/src/status-spinner.ts +68 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-code-runtime/package.json +3 -2
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-code-runtime/src/api.ts +7 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-code-runtime/src/capability/types.ts +56 -2
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-code-runtime/src/evidence-badge.ts +40 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-code-runtime/src/index.ts +5 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-code-runtime/src/types.ts +76 -3
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-code-runtime/src/workspace/runtime.ts +37 -2
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-core/package.json +6 -1
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-core/src/abort-utils.ts +31 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-core/src/api.ts +8 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-core/src/config/config-settings.ts +10 -4
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-core/src/config.ts +1 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-core/src/footer-registry.ts +1 -1
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-core/src/index.ts +6 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-core/src/model-selection.ts +134 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-core/src/settings/settings-registry.ts +9 -2
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-core/src/settings/settings-ui.ts +109 -4
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-core/src/settings-ui.ts +5 -1
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-core/src/spinner-frames.ts +11 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-core/src/status-spinner.ts +68 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/vscode-languageserver-protocol/lib/common/protocol.diagnostic.d.ts +21 -2
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/vscode-languageserver-protocol/lib/common/protocol.diagnostic.js +1 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/vscode-languageserver-protocol/lib/common/protocol.inlineValue.d.ts +2 -1
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/vscode-languageserver-protocol/package.json +1 -1
- package/node_modules/@mrclrchtr/supi-lsp/package.json +4 -31
- package/node_modules/@mrclrchtr/supi-lsp/src/api.ts +27 -0
- package/node_modules/@mrclrchtr/supi-lsp/src/client/client-refresh.ts +5 -0
- package/node_modules/@mrclrchtr/supi-lsp/src/client/client.ts +246 -1
- package/node_modules/@mrclrchtr/supi-lsp/src/client/transport.ts +4 -0
- package/node_modules/@mrclrchtr/supi-lsp/src/config/capabilities.ts +3 -0
- package/node_modules/@mrclrchtr/supi-lsp/src/config/config.ts +4 -2
- package/node_modules/@mrclrchtr/supi-lsp/src/config/lsp-settings.ts +102 -0
- package/node_modules/@mrclrchtr/supi-lsp/src/config/server-actions.ts +59 -0
- package/node_modules/@mrclrchtr/supi-lsp/src/config/server-config.ts +4 -0
- package/node_modules/@mrclrchtr/supi-lsp/src/index.ts +11 -0
- package/node_modules/@mrclrchtr/supi-lsp/src/manager/capability-index.ts +1 -1
- package/node_modules/@mrclrchtr/supi-lsp/src/manager/manager-project-info.ts +2 -1
- package/node_modules/@mrclrchtr/supi-lsp/src/manager/manager.ts +115 -26
- package/node_modules/@mrclrchtr/supi-lsp/src/provider/lsp-semantic-provider.ts +177 -134
- package/node_modules/@mrclrchtr/supi-lsp/src/provider/refactor-planning.ts +214 -0
- package/node_modules/@mrclrchtr/supi-lsp/src/session/runtime-controller.ts +320 -0
- package/node_modules/@mrclrchtr/supi-lsp/src/session/runtime-registration.ts +26 -5
- package/node_modules/@mrclrchtr/supi-lsp/src/session/service-registry.ts +81 -4
- package/node_modules/@mrclrchtr/supi-lsp/src/summary.ts +2 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/README.md +18 -37
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/package.json +6 -1
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/src/abort-utils.ts +31 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/src/api.ts +8 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/src/config/config-settings.ts +10 -4
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/src/config.ts +1 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/src/footer-registry.ts +1 -1
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/src/index.ts +6 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/src/model-selection.ts +134 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/src/settings/settings-registry.ts +9 -2
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/src/settings/settings-ui.ts +109 -4
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/src/settings-ui.ts +5 -1
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/src/spinner-frames.ts +11 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/src/status-spinner.ts +68 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/package.json +3 -2
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/src/api.ts +7 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/src/capability/types.ts +56 -2
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/src/evidence-badge.ts +40 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/src/index.ts +5 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/src/types.ts +76 -3
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/src/workspace/runtime.ts +37 -2
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/package.json +6 -1
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/src/abort-utils.ts +31 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/src/api.ts +8 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/src/config/config-settings.ts +10 -4
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/src/config.ts +1 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/src/footer-registry.ts +1 -1
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/src/index.ts +6 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/src/model-selection.ts +134 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/src/settings/settings-registry.ts +9 -2
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/src/settings/settings-ui.ts +109 -4
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/src/settings-ui.ts +5 -1
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/src/spinner-frames.ts +11 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/src/status-spinner.ts +68 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/web-tree-sitter/LICENSE +21 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/web-tree-sitter/README.md +265 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/web-tree-sitter/debug/web-tree-sitter.cjs +4661 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/web-tree-sitter/debug/web-tree-sitter.cjs.map +7 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/web-tree-sitter/debug/web-tree-sitter.js +4605 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/web-tree-sitter/debug/web-tree-sitter.js.map +7 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/web-tree-sitter/debug/web-tree-sitter.wasm +0 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/web-tree-sitter/debug/web-tree-sitter.wasm.map +57 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/web-tree-sitter/package.json +100 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/web-tree-sitter/web-tree-sitter.cjs +4063 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/web-tree-sitter/web-tree-sitter.cjs.map +7 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/web-tree-sitter/web-tree-sitter.d.cts +1025 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/web-tree-sitter/web-tree-sitter.d.cts.map +58 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/web-tree-sitter/web-tree-sitter.d.ts +1025 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/web-tree-sitter/web-tree-sitter.d.ts.map +58 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/web-tree-sitter/web-tree-sitter.js +4007 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/web-tree-sitter/web-tree-sitter.js.map +7 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/web-tree-sitter/web-tree-sitter.wasm +0 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/web-tree-sitter/web-tree-sitter.wasm.map +55 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/package.json +6 -12
- package/node_modules/@mrclrchtr/supi-tree-sitter/src/api.ts +29 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/src/index.ts +28 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/src/language.ts +5 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/src/provider/tree-sitter-provider.ts +14 -2
- package/node_modules/@mrclrchtr/supi-tree-sitter/src/session/runtime-controller.ts +157 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/src/session/session.ts +8 -1
- package/node_modules/@mrclrchtr/supi-tree-sitter/src/tool/call-sites.ts +86 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/src/tool/callees.ts +35 -16
- package/node_modules/@mrclrchtr/supi-tree-sitter/src/tool/structure.ts +1 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/src/types.ts +10 -0
- package/package.json +14 -9
- package/src/{model.ts → analysis/architecture/discovery.ts} +15 -72
- package/src/analysis/architecture/model.ts +76 -0
- package/src/analysis/brief/directory.ts +324 -0
- package/src/analysis/brief/enrich.ts +157 -0
- package/src/analysis/brief/file.ts +84 -0
- package/src/analysis/brief/inventory.ts +177 -0
- package/src/analysis/brief/main.ts +176 -0
- package/src/analysis/brief/models.ts +75 -0
- package/src/{brief.ts → analysis/brief/public-brief.ts} +21 -26
- package/src/analysis/brief/summarize.ts +208 -0
- package/src/analysis/brief/types.ts +27 -0
- package/src/{use-case/generate-brief.ts → analysis/brief/use-case.ts} +67 -144
- package/src/analysis/coverage/coverage-warnings.ts +224 -0
- package/src/analysis/evidence.ts +91 -0
- package/src/{semantic-action-helpers.ts → analysis/helpers.ts} +4 -4
- package/src/analysis/provider.ts +186 -0
- package/src/analysis/read-next.ts +126 -0
- package/src/analysis/readiness.ts +73 -0
- package/src/{refactor → analysis/refactor}/safety.ts +1 -1
- package/src/{use-case/support/semantic-references.ts → analysis/references/semantic-refs.ts} +58 -26
- package/src/analysis/search/pattern.ts +345 -0
- package/src/analysis/search/ripgrep.ts +473 -0
- package/src/{git-context.ts → analysis/signals/git.ts} +20 -7
- package/src/{prioritization-signals.ts → analysis/signals/project.ts} +33 -19
- package/src/analysis/target/anchored.ts +349 -0
- package/src/analysis/target/bridge.ts +152 -0
- package/src/analysis/target/file-resolution.ts +125 -0
- package/src/{targeting/resolve-file.ts → analysis/target/file.ts} +40 -20
- package/src/{planner → analysis/target}/planner.ts +30 -20
- package/src/{targeting → analysis/target}/query.ts +17 -3
- package/src/analysis/target/resolve-common.ts +115 -0
- package/src/analysis/target/service.ts +229 -0
- package/src/analysis/target/symbol.ts +196 -0
- package/src/{targeting → analysis/target}/types.ts +17 -1
- package/src/analysis/tests/likely-tests.ts +174 -0
- package/src/analysis/tests/test-discovery.ts +540 -0
- package/src/analysis/tests/vitest.ts +87 -0
- package/src/api.ts +34 -41
- package/src/app/app.ts +125 -0
- package/src/app/manager.ts +65 -0
- package/src/extension.ts +132 -1
- package/src/index.ts +1 -57
- package/src/session/refactor-plans.ts +82 -0
- package/src/session/session.ts +300 -0
- package/src/session/target-store.ts +293 -0
- package/src/substrate/lsp/diagnostic-injection.ts +218 -0
- package/src/substrate/lsp/lifecycle.ts +66 -0
- package/src/substrate/lsp/overrides.ts +132 -0
- package/src/substrate/lsp/recovery.ts +55 -0
- package/src/substrate/lsp/settings.ts +286 -0
- package/src/substrate/lsp/state.ts +46 -0
- package/src/substrate/lsp/utils.ts +17 -0
- package/src/substrate/tree-sitter/lifecycle.ts +52 -0
- package/src/tool/find/execute.ts +118 -0
- package/src/{presentation/markdown/pattern.ts → tool/find/markdown.ts} +102 -53
- package/src/{use-case/generate-pattern.ts → tool/find/orchestrate.ts} +67 -33
- package/src/tool/find/semantic-search.ts +114 -0
- package/src/tool/find/tui.ts +39 -0
- package/src/tool/graph/callees.ts +87 -0
- package/src/tool/graph/calls-md.ts +54 -0
- package/src/tool/graph/collect-relation.ts +371 -0
- package/src/tool/graph/execute.ts +95 -0
- package/src/tool/graph/implementations-md.ts +79 -0
- package/src/tool/graph/implementations.ts +76 -0
- package/src/tool/graph/markdown-base.ts +243 -0
- package/src/tool/graph/orchestrate.ts +285 -0
- package/src/tool/graph/references-md.ts +34 -0
- package/src/tool/graph/references.ts +81 -0
- package/src/tool/graph/tui.ts +120 -0
- package/src/tool/graph/types.ts +97 -0
- package/src/tool/guidance.ts +96 -49
- package/src/tool/health/execute.ts +76 -0
- package/src/tool/health/markdown.ts +280 -0
- package/src/tool/health/orchestrate.ts +159 -0
- package/src/tool/health/sections/diagnostics.ts +182 -0
- package/src/tool/health/sections/recovery.ts +89 -0
- package/src/tool/health/sections/signals.ts +89 -0
- package/src/tool/health/tui.ts +137 -0
- package/src/tool/impact/analysis.ts +247 -0
- package/src/tool/impact/change-set-impact.ts +151 -0
- package/src/tool/impact/execute.ts +98 -0
- package/src/tool/impact/file-level-impact.ts +81 -0
- package/src/tool/impact/markdown.ts +283 -0
- package/src/tool/impact/orchestrate.ts +97 -0
- package/src/tool/impact/result.ts +21 -0
- package/src/tool/impact/single-impact.ts +89 -0
- package/src/tool/impact/tui.ts +39 -0
- package/src/tool/impact/types.ts +34 -0
- package/src/tool/infra/cross-field.ts +335 -0
- package/src/tool/infra/error-results.ts +199 -0
- package/src/tool/infra/pipeline.ts +311 -0
- package/src/tool/infra/progress.ts +21 -0
- package/src/tool/infra/readiness-message.ts +5 -0
- package/src/tool/infra/truncate.ts +49 -0
- package/src/tool/inspect/execute.ts +76 -0
- package/src/tool/inspect/markdown.ts +169 -0
- package/src/tool/inspect/orchestrate.ts +156 -0
- package/src/tool/inspect/tui.ts +36 -0
- package/src/tool/orientation/deps.ts +63 -0
- package/src/tool/orientation/execute.ts +50 -0
- package/src/tool/orientation/markdown.ts +35 -0
- package/src/tool/orientation/mode.ts +88 -0
- package/src/tool/orientation/orchestrate.ts +478 -0
- package/src/tool/orientation/precise-target.ts +257 -0
- package/src/tool/orientation/tui.ts +131 -0
- package/src/{refactor/apply-workspace-edit.ts → tool/refactor-apply/apply.ts} +39 -16
- package/src/tool/refactor-apply/execute.ts +20 -0
- package/src/tool/refactor-apply/markdown.ts +118 -0
- package/src/tool/refactor-apply/orchestrate.ts +89 -0
- package/src/tool/refactor-apply/tui.ts +51 -0
- package/src/tool/refactor-plan/execute.ts +73 -0
- package/src/tool/refactor-plan/markdown.ts +118 -0
- package/src/tool/refactor-plan/orchestrate.ts +363 -0
- package/src/tool/refactor-plan/tui.ts +42 -0
- package/src/tool/register.ts +123 -0
- package/src/tool/resolve/execute.ts +82 -0
- package/src/tool/resolve/markdown.ts +150 -0
- package/src/tool/resolve/orchestrate.ts +134 -0
- package/src/tool/resolve/tui.ts +40 -0
- package/src/tool/schemas.ts +337 -0
- package/src/tool/specs.ts +257 -0
- package/src/types/details.ts +188 -0
- package/src/types/execution.ts +60 -0
- package/src/types/index.ts +28 -0
- package/src/{intent/types.ts → types/tool-names.ts} +15 -14
- package/src/ui/footer.ts +52 -0
- package/src/ui/markdown/brief.ts +218 -0
- package/src/ui/markdown/gather.ts +177 -0
- package/src/{use-case/build-overview.ts → ui/markdown/overview-data.ts} +2 -2
- package/src/{presentation → ui}/markdown/overview.ts +2 -2
- package/src/ui/markdown/types.ts +80 -0
- package/{node_modules/@mrclrchtr/supi-lsp/src/ui/renderer.ts → src/ui/message-renderer.ts} +11 -10
- package/src/ui/status-command.ts +260 -0
- package/src/ui/status-overlay.ts +500 -0
- package/src/ui/tui/common.ts +220 -0
- package/src/ui/tui/index.ts +37 -0
- package/node_modules/@mrclrchtr/supi-lsp/src/extension.ts +0 -1
- package/node_modules/@mrclrchtr/supi-lsp/src/format.ts +0 -373
- package/node_modules/@mrclrchtr/supi-lsp/src/handlers/diagnostic-injection.ts +0 -182
- package/node_modules/@mrclrchtr/supi-lsp/src/handlers/session-lifecycle.ts +0 -149
- package/node_modules/@mrclrchtr/supi-lsp/src/handlers/status-command.ts +0 -38
- package/node_modules/@mrclrchtr/supi-lsp/src/handlers/workspace-recovery.ts +0 -92
- package/node_modules/@mrclrchtr/supi-lsp/src/lsp.ts +0 -37
- package/node_modules/@mrclrchtr/supi-lsp/src/session/lsp-state.ts +0 -93
- package/node_modules/@mrclrchtr/supi-lsp/src/session/settings-registration.ts +0 -296
- package/node_modules/@mrclrchtr/supi-lsp/src/session/tree-persist.ts +0 -75
- package/node_modules/@mrclrchtr/supi-lsp/src/tool/guidance.ts +0 -69
- package/node_modules/@mrclrchtr/supi-lsp/src/tool/names.ts +0 -27
- package/node_modules/@mrclrchtr/supi-lsp/src/tool/overrides.ts +0 -204
- package/node_modules/@mrclrchtr/supi-lsp/src/tool/register-tools.ts +0 -69
- package/node_modules/@mrclrchtr/supi-lsp/src/tool/service-actions.ts +0 -399
- package/node_modules/@mrclrchtr/supi-lsp/src/tool/tool-specs.ts +0 -248
- package/node_modules/@mrclrchtr/supi-lsp/src/ui/ui.ts +0 -360
- package/node_modules/@mrclrchtr/supi-lsp/src/workspace-change.ts +0 -40
- package/node_modules/@mrclrchtr/supi-tree-sitter/src/extension.ts +0 -1
- package/node_modules/@mrclrchtr/supi-tree-sitter/src/tool/formatting.ts +0 -104
- package/node_modules/@mrclrchtr/supi-tree-sitter/src/tool/guidance.ts +0 -35
- package/node_modules/@mrclrchtr/supi-tree-sitter/src/tool/handlers.ts +0 -196
- package/node_modules/@mrclrchtr/supi-tree-sitter/src/tool/register-tools.ts +0 -107
- package/node_modules/@mrclrchtr/supi-tree-sitter/src/tool/tool-specs.ts +0 -117
- package/node_modules/@mrclrchtr/supi-tree-sitter/src/tree-sitter.ts +0 -47
- package/src/brief-focused.ts +0 -563
- package/src/code-intelligence.ts +0 -70
- package/src/pattern-structured.ts +0 -194
- package/src/presentation/markdown/affected.ts +0 -170
- package/src/presentation/markdown/brief.ts +0 -174
- package/src/presentation/markdown/map.ts +0 -54
- package/src/presentation/markdown/refactor.ts +0 -27
- package/src/presentation/markdown/relations.ts +0 -121
- package/src/resolve-target.ts +0 -130
- package/src/search-helpers.ts +0 -303
- package/src/substrates/types.ts +0 -30
- package/src/target-resolution.ts +0 -122
- package/src/targeting/resolve-anchored.ts +0 -80
- package/src/targeting/resolve-symbol.ts +0 -110
- package/src/tool/execute-affected.ts +0 -71
- package/src/tool/execute-brief.ts +0 -59
- package/src/tool/execute-map.ts +0 -35
- package/src/tool/execute-pattern.ts +0 -29
- package/src/tool/execute-refactor.ts +0 -101
- package/src/tool/execute-relations.ts +0 -79
- package/src/tool/register-tools.ts +0 -32
- package/src/tool/tool-specs.ts +0 -190
- package/src/tool/validation.ts +0 -43
- package/src/types.ts +0 -169
- package/src/use-case/generate-affected.ts +0 -297
- package/src/use-case/generate-map.ts +0 -176
- package/src/use-case/generate-relations.ts +0 -438
- package/src/use-case/types.ts +0 -43
- package/src/workspace/request-context.ts +0 -139
- /package/src/{query-params.ts → tool/params.ts} +0 -0
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* TUI renderer for code_impact — renderCall + renderResult.
|
|
3
|
+
*/
|
|
4
|
+
import type { Theme } from "@earendil-works/pi-coding-agent";
|
|
5
|
+
import { Text } from "@earendil-works/pi-tui";
|
|
6
|
+
import { type ResultOptios, renderSimpleResult, type ToolResult } from "../../ui/tui/common.ts";
|
|
7
|
+
import type { CodeImpactToolParams } from "./execute.ts";
|
|
8
|
+
|
|
9
|
+
/** ── renderCall ────────────────────────────────────────────────── */
|
|
10
|
+
|
|
11
|
+
export function renderImpactCall(args: unknown, theme: Theme, _context: unknown): Text {
|
|
12
|
+
const params = (args ?? {}) as CodeImpactToolParams;
|
|
13
|
+
|
|
14
|
+
let content = theme.fg("toolTitle", "code_impact");
|
|
15
|
+
|
|
16
|
+
if (params.symbol) {
|
|
17
|
+
content += ` ${theme.fg("accent", params.symbol)}`;
|
|
18
|
+
} else if (params.file) {
|
|
19
|
+
const file = params.file.split("/").pop() ?? params.file;
|
|
20
|
+
content += ` ${theme.fg("accent", file)}`;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
if (params.change) {
|
|
24
|
+
content += theme.fg("dim", ` — "${params.change.slice(0, 40)}"`);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
return new Text(content, 0, 0);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/** ── renderResult ──────────────────────────────────────────────── */
|
|
31
|
+
|
|
32
|
+
export function renderImpactResult(
|
|
33
|
+
result: ToolResult,
|
|
34
|
+
options: ResultOptios,
|
|
35
|
+
theme: Theme,
|
|
36
|
+
_context: unknown,
|
|
37
|
+
): ReturnType<typeof renderSimpleResult> {
|
|
38
|
+
return renderSimpleResult(result, options, theme, "Analyzing impact…");
|
|
39
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { ConfidenceMode } from "@mrclrchtr/supi-code-runtime/api";
|
|
2
|
+
import type { TestSurfaceDetails } from "../../analysis/tests/test-discovery.ts";
|
|
3
|
+
|
|
4
|
+
export interface ImpactInput {
|
|
5
|
+
file?: string;
|
|
6
|
+
line?: number;
|
|
7
|
+
character?: number;
|
|
8
|
+
symbol?: string;
|
|
9
|
+
exportedOnly?: boolean;
|
|
10
|
+
maxResults?: number;
|
|
11
|
+
change?: string;
|
|
12
|
+
changeSetFiles?: string[];
|
|
13
|
+
includeTests?: boolean;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export interface ImpactDeps {
|
|
17
|
+
cwd: string;
|
|
18
|
+
provider: import("../../analysis/provider.ts").CodeProvider | null;
|
|
19
|
+
lspService: import("@mrclrchtr/supi-lsp/api").SessionLspServiceState;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export interface ImpactAnalysis {
|
|
23
|
+
confidence: ConfidenceMode;
|
|
24
|
+
affectedFiles: Set<string>;
|
|
25
|
+
affectedModules: Set<string>;
|
|
26
|
+
downstreamCount: number;
|
|
27
|
+
checkNext: string[];
|
|
28
|
+
likelyTests: string[];
|
|
29
|
+
likelyTestCommands: string[];
|
|
30
|
+
riskLevel: "low" | "medium" | "high";
|
|
31
|
+
externalRefs: number;
|
|
32
|
+
semanticRefFiles?: string[];
|
|
33
|
+
tests?: TestSurfaceDetails;
|
|
34
|
+
}
|
|
@@ -0,0 +1,335 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cross-field validation rules for tool parameters.
|
|
3
|
+
*
|
|
4
|
+
* pi validates structural types, required fields, and enum values against
|
|
5
|
+
* the TypeBox schemas in ./schemas.ts before calling tool executors. These
|
|
6
|
+
* composable rules cover constraints that TypeBox cannot express:
|
|
7
|
+
*
|
|
8
|
+
* - Cross-field requirements (e.g. "query OR file required")
|
|
9
|
+
* - Filesystem checks (e.g. "file exists and is not a directory")
|
|
10
|
+
* - Semantic consistency (e.g. "kind only valid with mode: ast")
|
|
11
|
+
*
|
|
12
|
+
* TypeBox already enforces, and rules here must NOT duplicate:
|
|
13
|
+
* - Required vs optional fields
|
|
14
|
+
* - Enum value membership (StringEnum)
|
|
15
|
+
* - Number ranges (minimum/maximum)
|
|
16
|
+
* - additionalProperties: false
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
import { existsSync, statSync } from "node:fs";
|
|
20
|
+
import { normalizePath } from "../../analysis/search/ripgrep.ts";
|
|
21
|
+
import { inspectParam } from "./pipeline.ts";
|
|
22
|
+
|
|
23
|
+
/** A cross-field validation rule. Returns an error message string or null if valid. */
|
|
24
|
+
export type CrossFieldRule<P> = (params: P, cwd: string) => string | null;
|
|
25
|
+
|
|
26
|
+
/** Compose multiple cross-field rules — stops at the first error. */
|
|
27
|
+
export function composeRules<P>(...rules: CrossFieldRule<P>[]): CrossFieldRule<P> {
|
|
28
|
+
return (params, cwd) => {
|
|
29
|
+
for (const rule of rules) {
|
|
30
|
+
const error = rule(params, cwd);
|
|
31
|
+
if (error) return error;
|
|
32
|
+
}
|
|
33
|
+
return null;
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
// ── Primitives ────────────────────────────────────────────────────────
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Require at least one of the named keys to be present and non-empty.
|
|
41
|
+
* A key is "present" when its value is not undefined, null, or empty-string.
|
|
42
|
+
*/
|
|
43
|
+
export function requireAtLeastOne<P>(...keys: (keyof P & string)[]): CrossFieldRule<P> {
|
|
44
|
+
return (params) => {
|
|
45
|
+
const present = keys.filter((k) => {
|
|
46
|
+
const v = inspectParam(params, k);
|
|
47
|
+
return v !== undefined && v !== null && (typeof v !== "string" || v.length > 0);
|
|
48
|
+
});
|
|
49
|
+
if (present.length === 0) {
|
|
50
|
+
const names = keys.map((k) => `\`${k}\``).join(" or ");
|
|
51
|
+
return `**Error:** At least one of ${names} is required.`;
|
|
52
|
+
}
|
|
53
|
+
return null;
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Require that the named keys appear together — all present or all absent.
|
|
59
|
+
* A key is "present" when its value is not undefined or null.
|
|
60
|
+
*/
|
|
61
|
+
export function requirePaired<P>(...keys: (keyof P & string)[]): CrossFieldRule<P> {
|
|
62
|
+
return (params) => {
|
|
63
|
+
const present = keys.map(
|
|
64
|
+
(k) => inspectParam(params, k) !== undefined && inspectParam(params, k) !== null,
|
|
65
|
+
);
|
|
66
|
+
const allPresent = present.every(Boolean);
|
|
67
|
+
const allAbsent = present.every((p) => !p);
|
|
68
|
+
if (!allPresent && !allAbsent) {
|
|
69
|
+
const names = keys.map((k) => `\`${k}\``).join(" and ");
|
|
70
|
+
return `**Error:** ${names} must be provided together.`;
|
|
71
|
+
}
|
|
72
|
+
return null;
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Require that when any of `dependentKeys` is present, `requiredKey` must
|
|
78
|
+
* also be present.
|
|
79
|
+
*/
|
|
80
|
+
export function requireWith<P>(
|
|
81
|
+
requiredKey: keyof P & string,
|
|
82
|
+
...dependentKeys: (keyof P & string)[]
|
|
83
|
+
): CrossFieldRule<P> {
|
|
84
|
+
return (params) => {
|
|
85
|
+
const needed = dependentKeys.some(
|
|
86
|
+
(k) => inspectParam(params, k) !== undefined && inspectParam(params, k) !== null,
|
|
87
|
+
);
|
|
88
|
+
if (
|
|
89
|
+
needed &&
|
|
90
|
+
(inspectParam(params, requiredKey) === undefined ||
|
|
91
|
+
inspectParam(params, requiredKey) === null)
|
|
92
|
+
) {
|
|
93
|
+
const depNames = dependentKeys.map((k) => `\`${k}\``).join(" or ");
|
|
94
|
+
return `**Error:** ${depNames} requires \`${requiredKey}\`.`;
|
|
95
|
+
}
|
|
96
|
+
return null;
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* Reject when any of `positionKeys` are present alongside `pathKey`.
|
|
102
|
+
* Positions (line/character) only anchor into files, not scope/path params.
|
|
103
|
+
*/
|
|
104
|
+
export function noPositionOnPath<P>(
|
|
105
|
+
pathKey: keyof P & string,
|
|
106
|
+
lineKey: keyof P & string,
|
|
107
|
+
charKey: keyof P & string,
|
|
108
|
+
): CrossFieldRule<P> {
|
|
109
|
+
return (params) => {
|
|
110
|
+
const hasPath = inspectParam(params, pathKey) !== undefined;
|
|
111
|
+
const hasPos =
|
|
112
|
+
inspectParam(params, lineKey) !== undefined || inspectParam(params, charKey) !== undefined;
|
|
113
|
+
if (hasPath && hasPos) {
|
|
114
|
+
return `**Error:** \`${lineKey}\` and \`${charKey}\` require \`file\`, not \`${pathKey}\`. Use \`${pathKey}\` to scope; use \`file\` to anchor a position.`;
|
|
115
|
+
}
|
|
116
|
+
return null;
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
// ── Filesystem primitives ─────────────────────────────────────────────
|
|
121
|
+
|
|
122
|
+
/** Ensure the value at `key` resolves to an existing file. */
|
|
123
|
+
export function fileMustExist<P>(key: keyof P & string): CrossFieldRule<P> {
|
|
124
|
+
return (params, cwd) => {
|
|
125
|
+
const file = inspectParam(params, key) as string | undefined;
|
|
126
|
+
if (!file) return null;
|
|
127
|
+
const resolved = normalizePath(file, cwd);
|
|
128
|
+
if (!existsSync(resolved)) {
|
|
129
|
+
return `**Error:** File not found: \`${file}\`.`;
|
|
130
|
+
}
|
|
131
|
+
return null;
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
/** Ensure the value at `key` resolves to a file, not a directory. */
|
|
136
|
+
export function fileNotDirectory<P>(key: keyof P & string): CrossFieldRule<P> {
|
|
137
|
+
return (params, cwd) => {
|
|
138
|
+
const file = inspectParam(params, key) as string | undefined;
|
|
139
|
+
if (!file) return null;
|
|
140
|
+
const resolved = normalizePath(file, cwd);
|
|
141
|
+
if (existsSync(resolved) && statSync(resolved).isDirectory()) {
|
|
142
|
+
return `**Error:** \`${key}\` points to a directory. Use \`scope\` for a directory; use \`file\` to anchor a position in a file.`;
|
|
143
|
+
}
|
|
144
|
+
return null;
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
// ── Tool-specific composed rules ──────────────────────────────────────
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* Standard cross-field rules for tools that accept anchored coordinates
|
|
152
|
+
* (file + line + character). Used by code_graph, code_impact, code_inspect,
|
|
153
|
+
* and any future tool that takes position params.
|
|
154
|
+
*
|
|
155
|
+
* TypeBox already enforces:
|
|
156
|
+
* - Types: file (String), line (Number >= 1), character (Number >= 1)
|
|
157
|
+
* - additionalProperties: false
|
|
158
|
+
*/
|
|
159
|
+
export function focusedToolRules<P>(
|
|
160
|
+
pathKey: keyof P & string = "scope" as keyof P & string,
|
|
161
|
+
): CrossFieldRule<P> {
|
|
162
|
+
return composeRules<P>(
|
|
163
|
+
noPositionOnPath(pathKey, "line" as keyof P & string, "character" as keyof P & string),
|
|
164
|
+
fileNotDirectory("file" as keyof P & string),
|
|
165
|
+
requireWith(
|
|
166
|
+
"file" as keyof P & string,
|
|
167
|
+
"line" as keyof P & string,
|
|
168
|
+
"character" as keyof P & string,
|
|
169
|
+
),
|
|
170
|
+
);
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
/**
|
|
174
|
+
* Cross-field rules for code_resolve.
|
|
175
|
+
*
|
|
176
|
+
* TypeBox already enforces:
|
|
177
|
+
* - kind must be a valid StringEnum value
|
|
178
|
+
* - line/character must be numbers >= 1
|
|
179
|
+
* - additionalProperties: false
|
|
180
|
+
*/
|
|
181
|
+
export const resolveCrossFieldRules: CrossFieldRule<{
|
|
182
|
+
query?: string;
|
|
183
|
+
file?: string;
|
|
184
|
+
line?: number;
|
|
185
|
+
character?: number;
|
|
186
|
+
}> = composeRules(
|
|
187
|
+
requireAtLeastOne("query", "file"),
|
|
188
|
+
requirePaired("line", "character"),
|
|
189
|
+
requireWith("file", "line", "character"),
|
|
190
|
+
);
|
|
191
|
+
|
|
192
|
+
/**
|
|
193
|
+
* Cross-field rules for code_orientation coordinate mode
|
|
194
|
+
* (focus + line + character).
|
|
195
|
+
*
|
|
196
|
+
* TypeBox already enforces:
|
|
197
|
+
* - line/character types and min >= 1
|
|
198
|
+
* - additionalProperties: false
|
|
199
|
+
*/
|
|
200
|
+
export function orientationCoordinateRules<
|
|
201
|
+
P extends {
|
|
202
|
+
focus?: string;
|
|
203
|
+
line?: number;
|
|
204
|
+
character?: number;
|
|
205
|
+
},
|
|
206
|
+
>(): CrossFieldRule<P> {
|
|
207
|
+
return composeRules<P>(
|
|
208
|
+
requirePaired(
|
|
209
|
+
"focus" as keyof P & string,
|
|
210
|
+
"line" as keyof P & string,
|
|
211
|
+
"character" as keyof P & string,
|
|
212
|
+
),
|
|
213
|
+
fileMustExist("focus" as keyof P & string),
|
|
214
|
+
fileNotDirectory("focus" as keyof P & string),
|
|
215
|
+
);
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
/**
|
|
219
|
+
* Cross-field rules for code_find mode+kind consistency.
|
|
220
|
+
*
|
|
221
|
+
* TypeBox already enforces:
|
|
222
|
+
* - mode must be a valid StringEnum value
|
|
223
|
+
* - kind must be a valid StringEnum value
|
|
224
|
+
* - query is required (not optional)
|
|
225
|
+
*/
|
|
226
|
+
const SUPPORTED_AST_KINDS = [
|
|
227
|
+
"definition",
|
|
228
|
+
"import",
|
|
229
|
+
"export",
|
|
230
|
+
"call",
|
|
231
|
+
"type",
|
|
232
|
+
"interface",
|
|
233
|
+
"class",
|
|
234
|
+
"method",
|
|
235
|
+
"enum",
|
|
236
|
+
"test",
|
|
237
|
+
] as const;
|
|
238
|
+
|
|
239
|
+
const SUPPORTED_AST_KINDS_TEXT = SUPPORTED_AST_KINDS.map((k) => `\`${k}\``).join(", ");
|
|
240
|
+
|
|
241
|
+
export function findModeKindRules<P extends { mode?: string; kind?: string }>(): CrossFieldRule<P> {
|
|
242
|
+
return (params) => {
|
|
243
|
+
const mode = params.mode ?? "text";
|
|
244
|
+
const kind = params.kind;
|
|
245
|
+
if ((mode === "text" || mode === "regex" || mode === "semantic") && kind) {
|
|
246
|
+
return `**Error:** code_find does not accept \`kind\` with \`mode: "${mode}"\`. Use \`mode: "ast"\` with \`kind\`.`;
|
|
247
|
+
}
|
|
248
|
+
if (mode === "ast" && !kind) {
|
|
249
|
+
return `**Error:** code_find with \`mode: "ast"\` requires \`kind\`. Supported AST kinds: ${SUPPORTED_AST_KINDS_TEXT}.`;
|
|
250
|
+
}
|
|
251
|
+
return null;
|
|
252
|
+
};
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
/**
|
|
256
|
+
* Cross-field rules for code_refactor_plan.
|
|
257
|
+
*
|
|
258
|
+
* TypeBox already enforces:
|
|
259
|
+
* - operation must be a valid StringEnum value
|
|
260
|
+
* - range shape (start/end with line/character)
|
|
261
|
+
* - additionalProperties: false
|
|
262
|
+
*/
|
|
263
|
+
// ── Refactor plan sub-rules (split for complexity) ────────────────────
|
|
264
|
+
|
|
265
|
+
function checkExtractRange<
|
|
266
|
+
P extends {
|
|
267
|
+
operation: string;
|
|
268
|
+
range?: {
|
|
269
|
+
start: { line: number; character: number };
|
|
270
|
+
end: { line: number; character: number };
|
|
271
|
+
};
|
|
272
|
+
},
|
|
273
|
+
>(params: P): string | null {
|
|
274
|
+
const isExtract =
|
|
275
|
+
params.operation === "extract_function" || params.operation === "extract_variable";
|
|
276
|
+
if (!isExtract) return null;
|
|
277
|
+
if (!params.range) {
|
|
278
|
+
return "**Error:** `range` is required for `extract_function` and `extract_variable`.";
|
|
279
|
+
}
|
|
280
|
+
const { start, end } = params.range;
|
|
281
|
+
if (end.line < start.line || (end.line === start.line && end.character <= start.character)) {
|
|
282
|
+
return "**Error:** `range.end` must be after `range.start`.";
|
|
283
|
+
}
|
|
284
|
+
return null;
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
function checkNewNameRequired<P extends { operation: string; newName?: string }>(
|
|
288
|
+
params: P,
|
|
289
|
+
): string | null {
|
|
290
|
+
const needsName =
|
|
291
|
+
params.operation === "rename_symbol" ||
|
|
292
|
+
params.operation === "extract_function" ||
|
|
293
|
+
params.operation === "extract_variable";
|
|
294
|
+
if (needsName && !params.newName) {
|
|
295
|
+
return `**Error:** \`newName\` is required for \`${params.operation}\`.`;
|
|
296
|
+
}
|
|
297
|
+
return null;
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
/**
|
|
301
|
+
* Cross-field rules for code_refactor_plan.
|
|
302
|
+
*
|
|
303
|
+
* TypeBox already enforces:
|
|
304
|
+
* - operation must be a valid StringEnum value
|
|
305
|
+
* - range shape (start/end with line/character)
|
|
306
|
+
* - additionalProperties: false
|
|
307
|
+
*/
|
|
308
|
+
export function refactorPlanCrossFieldRules<
|
|
309
|
+
P extends {
|
|
310
|
+
operation: string;
|
|
311
|
+
targetId?: string;
|
|
312
|
+
file?: string;
|
|
313
|
+
line?: number;
|
|
314
|
+
character?: number;
|
|
315
|
+
range?: {
|
|
316
|
+
start: { line: number; character: number };
|
|
317
|
+
end: { line: number; character: number };
|
|
318
|
+
};
|
|
319
|
+
newName?: string;
|
|
320
|
+
},
|
|
321
|
+
>(): CrossFieldRule<P> {
|
|
322
|
+
return composeRules<P>(
|
|
323
|
+
(params) => {
|
|
324
|
+
const hasTarget =
|
|
325
|
+
Boolean(params.targetId) ||
|
|
326
|
+
(Boolean(params.file) && params.line != null && params.character != null);
|
|
327
|
+
if (!hasTarget) {
|
|
328
|
+
return "**Error:** Refactor preview requires `targetId` (from `code_resolve`) or `file` + `line` + `character`.";
|
|
329
|
+
}
|
|
330
|
+
return null;
|
|
331
|
+
},
|
|
332
|
+
checkExtractRange as CrossFieldRule<P>,
|
|
333
|
+
checkNewNameRequired as CrossFieldRule<P>,
|
|
334
|
+
);
|
|
335
|
+
}
|
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Unified error-result factories for code-intelligence tool executors.
|
|
3
|
+
*
|
|
4
|
+
* Every factory returns a complete {@link CodeIntelResult} (content + typed
|
|
5
|
+
* details) so executors never need to inline the `{ content, details }`
|
|
6
|
+
* wrapper. The old `unavailableXxxDetails()` functions are kept as thin
|
|
7
|
+
* wrappers — prefer the combined `xxxErrorResult()` factories in new code.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import type {
|
|
11
|
+
CodeIntelResult,
|
|
12
|
+
ContextDetails,
|
|
13
|
+
HealthDetails,
|
|
14
|
+
ImpactDetails,
|
|
15
|
+
InspectDetails,
|
|
16
|
+
ResolveDetails,
|
|
17
|
+
SearchDetails,
|
|
18
|
+
} from "../../types/index.ts";
|
|
19
|
+
|
|
20
|
+
// ── Combined error-result factories (preferred) ──────────────────────
|
|
21
|
+
|
|
22
|
+
/** Full error result for search-family tools (code_find, code_graph, code_find, code_refactor_plan). */
|
|
23
|
+
export function searchErrorResult(
|
|
24
|
+
content: string,
|
|
25
|
+
opts?: { scope?: string | null; nextQueries?: string[] },
|
|
26
|
+
): CodeIntelResult {
|
|
27
|
+
return {
|
|
28
|
+
content,
|
|
29
|
+
details: {
|
|
30
|
+
type: "search" as const,
|
|
31
|
+
data: {
|
|
32
|
+
confidence: "unavailable" as const,
|
|
33
|
+
scope: opts?.scope ?? null,
|
|
34
|
+
candidateCount: 0,
|
|
35
|
+
omittedCount: 0,
|
|
36
|
+
nextQueries: opts?.nextQueries ?? [],
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/** Full error result for code_orientation (context-type details). */
|
|
43
|
+
export function contextErrorResult(
|
|
44
|
+
content: string,
|
|
45
|
+
opts?: { nextQueries?: string[] },
|
|
46
|
+
): CodeIntelResult {
|
|
47
|
+
return {
|
|
48
|
+
content,
|
|
49
|
+
details: {
|
|
50
|
+
type: "context" as const,
|
|
51
|
+
data: {
|
|
52
|
+
confidence: "unavailable" as const,
|
|
53
|
+
task: null,
|
|
54
|
+
focusTarget: null,
|
|
55
|
+
requestedSections: [],
|
|
56
|
+
renderedSections: [],
|
|
57
|
+
omittedCount: 0,
|
|
58
|
+
nextQueries: opts?.nextQueries ?? [],
|
|
59
|
+
},
|
|
60
|
+
},
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/** Full error result for code_resolve. */
|
|
65
|
+
export function resolveErrorResult(
|
|
66
|
+
content: string,
|
|
67
|
+
opts?: { nextQueries?: string[] },
|
|
68
|
+
): CodeIntelResult {
|
|
69
|
+
return {
|
|
70
|
+
content,
|
|
71
|
+
details: {
|
|
72
|
+
type: "resolve" as const,
|
|
73
|
+
data: {
|
|
74
|
+
confidence: "unavailable" as const,
|
|
75
|
+
targetCount: 0,
|
|
76
|
+
omittedCount: 0,
|
|
77
|
+
targets: [],
|
|
78
|
+
nextQueries: opts?.nextQueries ?? [],
|
|
79
|
+
},
|
|
80
|
+
},
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/** Full error result for code_inspect. */
|
|
85
|
+
export function inspectErrorResult(
|
|
86
|
+
content: string,
|
|
87
|
+
opts?: { focusTarget?: string; nextQueries?: string[] },
|
|
88
|
+
): CodeIntelResult {
|
|
89
|
+
return {
|
|
90
|
+
content,
|
|
91
|
+
details: {
|
|
92
|
+
type: "inspect" as const,
|
|
93
|
+
data: {
|
|
94
|
+
confidence: "unavailable" as const,
|
|
95
|
+
focusTarget: opts?.focusTarget ?? "",
|
|
96
|
+
unavailableSections: [],
|
|
97
|
+
nextQueries: opts?.nextQueries ?? [],
|
|
98
|
+
},
|
|
99
|
+
},
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/** Full error result for code_impact. */
|
|
104
|
+
export function impactErrorResult(
|
|
105
|
+
content: string,
|
|
106
|
+
opts?: { nextQueries?: string[] },
|
|
107
|
+
): CodeIntelResult {
|
|
108
|
+
const data: ImpactDetails = {
|
|
109
|
+
confidence: "unavailable",
|
|
110
|
+
directCount: 0,
|
|
111
|
+
downstreamCount: 0,
|
|
112
|
+
riskLevel: "low",
|
|
113
|
+
checkNext: [],
|
|
114
|
+
likelyTests: [],
|
|
115
|
+
likelyTestCommands: [],
|
|
116
|
+
omittedCount: 0,
|
|
117
|
+
nextQueries: opts?.nextQueries ?? [],
|
|
118
|
+
};
|
|
119
|
+
return { content, details: { type: "impact" as const, data } };
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/** Full error result for code_health. */
|
|
123
|
+
export function healthErrorResult(content: string, reason?: string): CodeIntelResult {
|
|
124
|
+
return {
|
|
125
|
+
content,
|
|
126
|
+
details: {
|
|
127
|
+
type: "health" as const,
|
|
128
|
+
data: {
|
|
129
|
+
lspAvailable: false,
|
|
130
|
+
lspStatus: reason ?? content,
|
|
131
|
+
recovered: false,
|
|
132
|
+
diagnosticFileCount: 0,
|
|
133
|
+
serverCount: 0,
|
|
134
|
+
},
|
|
135
|
+
},
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
// ── Details-only helpers (thin wrappers — prefer combined factories above) ─
|
|
140
|
+
|
|
141
|
+
export function unavailableSearchDetails(
|
|
142
|
+
scope: string | null,
|
|
143
|
+
nextQueries: string[],
|
|
144
|
+
): { type: "search"; data: SearchDetails } {
|
|
145
|
+
return searchErrorResult("", { scope, nextQueries }).details as {
|
|
146
|
+
type: "search";
|
|
147
|
+
data: SearchDetails;
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
export function unavailableContextDetails(nextQueries: string[]): {
|
|
152
|
+
type: "context";
|
|
153
|
+
data: ContextDetails;
|
|
154
|
+
} {
|
|
155
|
+
return contextErrorResult("", { nextQueries }).details as {
|
|
156
|
+
type: "context";
|
|
157
|
+
data: ContextDetails;
|
|
158
|
+
};
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
export function unavailableResolveDetails(nextQueries: string[]): {
|
|
162
|
+
type: "resolve";
|
|
163
|
+
data: ResolveDetails;
|
|
164
|
+
} {
|
|
165
|
+
return resolveErrorResult("", { nextQueries }).details as {
|
|
166
|
+
type: "resolve";
|
|
167
|
+
data: ResolveDetails;
|
|
168
|
+
};
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
export function unavailableInspectDetails(
|
|
172
|
+
focusTarget: string,
|
|
173
|
+
nextQueries: string[],
|
|
174
|
+
): { type: "inspect"; data: InspectDetails } {
|
|
175
|
+
return inspectErrorResult("", { focusTarget, nextQueries }).details as {
|
|
176
|
+
type: "inspect";
|
|
177
|
+
data: InspectDetails;
|
|
178
|
+
};
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
export function unavailableImpactDetails(nextQueries: string[]): {
|
|
182
|
+
type: "impact";
|
|
183
|
+
data: ImpactDetails;
|
|
184
|
+
} {
|
|
185
|
+
return impactErrorResult("", { nextQueries }).details as {
|
|
186
|
+
type: "impact";
|
|
187
|
+
data: ImpactDetails;
|
|
188
|
+
};
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
export function unavailableHealthDetails(reason: string): {
|
|
192
|
+
type: "health";
|
|
193
|
+
data: HealthDetails;
|
|
194
|
+
} {
|
|
195
|
+
return healthErrorResult("", reason).details as {
|
|
196
|
+
type: "health";
|
|
197
|
+
data: HealthDetails;
|
|
198
|
+
};
|
|
199
|
+
}
|