@mrclrchtr/supi-code-intelligence 1.16.1 → 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/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,478 @@
|
|
|
1
|
+
// biome-ignore-all lint/style/noExcessiveLinesPerFile: symbol-orientation section builders stay together to preserve one rendering contract
|
|
2
|
+
import { existsSync, readFileSync } from "node:fs";
|
|
3
|
+
import * as path from "node:path";
|
|
4
|
+
|
|
5
|
+
import type { ConfidenceMode } from "@mrclrchtr/supi-code-runtime/api";
|
|
6
|
+
import type { BriefInput } from "../../analysis/brief/types.ts";
|
|
7
|
+
import { executeBrief } from "../../analysis/brief/use-case.ts";
|
|
8
|
+
import {
|
|
9
|
+
type ReadNextItem,
|
|
10
|
+
readNextEnclosingScope,
|
|
11
|
+
readNextTarget,
|
|
12
|
+
} from "../../analysis/read-next.ts";
|
|
13
|
+
import type { ContextDetails } from "../../types/details.ts";
|
|
14
|
+
import { gatherTreeSitterContext } from "../../ui/markdown/gather.ts";
|
|
15
|
+
import type {
|
|
16
|
+
OrientationDeps,
|
|
17
|
+
OrientationInput,
|
|
18
|
+
OrientationSection,
|
|
19
|
+
OrientationTarget,
|
|
20
|
+
OrientationUseCaseResult,
|
|
21
|
+
} from "../../ui/markdown/types.ts";
|
|
22
|
+
import { type RenderedOrientationSection, renderOrientationResult } from "./markdown.ts";
|
|
23
|
+
|
|
24
|
+
const DEFAULT_TARGET_SECTIONS: OrientationSection[] = ["defs", "docs", "diagnostics"];
|
|
25
|
+
|
|
26
|
+
const SECTION_TITLES: Record<OrientationSection, string> = {
|
|
27
|
+
defs: "Definitions",
|
|
28
|
+
docs: "Docs",
|
|
29
|
+
diagnostics: "Diagnostics",
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Build a code_orientation result.
|
|
34
|
+
*
|
|
35
|
+
* - Without a precise target, returns a neutral project/module/directory/file orientation brief.
|
|
36
|
+
* - With a precise target, returns symbol-centered orientation facts: definitions, docs, and local diagnostics.
|
|
37
|
+
*/
|
|
38
|
+
export async function executeOrientation(
|
|
39
|
+
input: OrientationInput,
|
|
40
|
+
deps: OrientationDeps,
|
|
41
|
+
): Promise<OrientationUseCaseResult> {
|
|
42
|
+
if (!input.target) {
|
|
43
|
+
return executeOrientationContext(input, deps);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
return executeTargetOrientation(input, deps);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
async function executeOrientationContext(
|
|
50
|
+
input: OrientationInput,
|
|
51
|
+
deps: OrientationDeps,
|
|
52
|
+
): Promise<OrientationUseCaseResult> {
|
|
53
|
+
const briefInput = toBriefInput(input);
|
|
54
|
+
const result = await executeBrief(briefInput, {
|
|
55
|
+
model: deps.model,
|
|
56
|
+
provider: deps.provider,
|
|
57
|
+
cwd: deps.cwd,
|
|
58
|
+
showGitContext: input.showGitContext ?? true,
|
|
59
|
+
lspService: deps.lspService,
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
const details: ContextDetails = {
|
|
63
|
+
confidence: result.details.confidence,
|
|
64
|
+
task: null,
|
|
65
|
+
focusTarget: input.focus ?? null,
|
|
66
|
+
requestedSections: [],
|
|
67
|
+
renderedSections: ["orientation"],
|
|
68
|
+
omittedCount: result.details.omittedCount,
|
|
69
|
+
nextQueries: result.details.nextQueries,
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
return {
|
|
73
|
+
content: result.content,
|
|
74
|
+
details,
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
async function executeTargetOrientation(
|
|
79
|
+
input: OrientationInput,
|
|
80
|
+
deps: OrientationDeps,
|
|
81
|
+
): Promise<OrientationUseCaseResult> {
|
|
82
|
+
const requestedSections = DEFAULT_TARGET_SECTIONS;
|
|
83
|
+
const limit = input.maxResults ?? 10;
|
|
84
|
+
const focusTarget = input.target ? formatFocusTarget(input.target, deps.cwd) : null;
|
|
85
|
+
const sections: RenderedOrientationSection[] = [];
|
|
86
|
+
|
|
87
|
+
let hasStructural = false;
|
|
88
|
+
let hasSemantic = false;
|
|
89
|
+
const treeContext = await maybeGatherTreeContext(input.target, deps);
|
|
90
|
+
|
|
91
|
+
for (const section of requestedSections) {
|
|
92
|
+
const built = await buildRequestedSection({
|
|
93
|
+
section,
|
|
94
|
+
target: input.target,
|
|
95
|
+
deps,
|
|
96
|
+
limit,
|
|
97
|
+
treeContext,
|
|
98
|
+
});
|
|
99
|
+
sections.push(built.section);
|
|
100
|
+
hasStructural = hasStructural || built.hasStructuralEvidence;
|
|
101
|
+
hasSemantic = hasSemantic || built.hasSemanticEvidence;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
const confidence: ConfidenceMode = hasSemantic
|
|
105
|
+
? "semantic"
|
|
106
|
+
: hasStructural
|
|
107
|
+
? "structural"
|
|
108
|
+
: "unavailable";
|
|
109
|
+
|
|
110
|
+
const details: ContextDetails = {
|
|
111
|
+
confidence,
|
|
112
|
+
task: null,
|
|
113
|
+
focusTarget,
|
|
114
|
+
requestedSections,
|
|
115
|
+
renderedSections: sections.map((section) => section.key),
|
|
116
|
+
omittedCount: 0,
|
|
117
|
+
nextQueries: buildNextQueries(input.target, deps.cwd),
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
return {
|
|
121
|
+
content: renderOrientationResult({
|
|
122
|
+
focusTarget,
|
|
123
|
+
sections,
|
|
124
|
+
readNext: buildReadNextGuidance(input.target, treeContext, deps.cwd),
|
|
125
|
+
}),
|
|
126
|
+
details,
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
async function buildRequestedSection(options: {
|
|
131
|
+
section: OrientationSection;
|
|
132
|
+
target: OrientationTarget | null | undefined;
|
|
133
|
+
deps: OrientationDeps;
|
|
134
|
+
limit: number;
|
|
135
|
+
treeContext: Awaited<ReturnType<typeof maybeGatherTreeContext>>;
|
|
136
|
+
}): Promise<{
|
|
137
|
+
section: RenderedOrientationSection;
|
|
138
|
+
hasStructuralEvidence: boolean;
|
|
139
|
+
hasSemanticEvidence: boolean;
|
|
140
|
+
}> {
|
|
141
|
+
const { section, target, deps, limit, treeContext } = options;
|
|
142
|
+
|
|
143
|
+
switch (section) {
|
|
144
|
+
case "defs": {
|
|
145
|
+
const lines = await buildEnrichedDefsSection(target, deps, treeContext, limit);
|
|
146
|
+
return {
|
|
147
|
+
section: { key: section, title: SECTION_TITLES[section], lines },
|
|
148
|
+
hasStructuralEvidence: hasRenderableItems(lines),
|
|
149
|
+
hasSemanticEvidence: deps.lspService.kind === "ready",
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
case "docs": {
|
|
153
|
+
const result = await buildDocsSection(target, deps, limit);
|
|
154
|
+
return {
|
|
155
|
+
section: { key: section, title: SECTION_TITLES[section], lines: result.lines },
|
|
156
|
+
hasStructuralEvidence: result.hasStructuralEvidence,
|
|
157
|
+
hasSemanticEvidence: false,
|
|
158
|
+
};
|
|
159
|
+
}
|
|
160
|
+
case "diagnostics": {
|
|
161
|
+
const result = await buildDiagnosticsSection(target, deps, limit);
|
|
162
|
+
return {
|
|
163
|
+
section: { key: section, title: SECTION_TITLES[section], lines: result.lines },
|
|
164
|
+
hasStructuralEvidence: false,
|
|
165
|
+
hasSemanticEvidence: result.hasSemanticEvidence,
|
|
166
|
+
};
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
/** Build enriched defs section: tree-sitter definitions + LSP definition targets + code actions. */
|
|
172
|
+
async function buildEnrichedDefsSection(
|
|
173
|
+
target: OrientationTarget | null | undefined,
|
|
174
|
+
deps: OrientationDeps,
|
|
175
|
+
treeContext: Awaited<ReturnType<typeof maybeGatherTreeContext>>,
|
|
176
|
+
limit: number,
|
|
177
|
+
): Promise<string[]> {
|
|
178
|
+
const lines = buildDefinitionLines(target, deps.cwd, treeContext);
|
|
179
|
+
|
|
180
|
+
if (!target || deps.lspService.kind !== "ready") return lines;
|
|
181
|
+
|
|
182
|
+
const lspDefs = await appendDefinitionTargets(target, deps, limit);
|
|
183
|
+
if (lspDefs.length > 0) {
|
|
184
|
+
if (lines.length > 0) lines.push("");
|
|
185
|
+
lines.push(...lspDefs.slice(0, limit));
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
const actions = await appendCodeActions(target, deps, limit);
|
|
189
|
+
if (actions.length > 0) {
|
|
190
|
+
if (lines.length > 0) lines.push("");
|
|
191
|
+
lines.push(...actions.slice(0, limit));
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
return lines;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
async function appendDefinitionTargets(
|
|
198
|
+
target: OrientationTarget,
|
|
199
|
+
deps: OrientationDeps,
|
|
200
|
+
limit: number,
|
|
201
|
+
): Promise<string[]> {
|
|
202
|
+
if (!deps.provider?.definition) return [];
|
|
203
|
+
try {
|
|
204
|
+
const defs = await deps.provider.definition(target.file, {
|
|
205
|
+
line: target.line - 1,
|
|
206
|
+
character: target.character - 1,
|
|
207
|
+
});
|
|
208
|
+
if (!defs || !Array.isArray(defs) || defs.length === 0) return [];
|
|
209
|
+
const lines: string[] = ["**Definition:**"];
|
|
210
|
+
for (const def of defs.slice(0, limit)) {
|
|
211
|
+
const filePath = def.uri.startsWith("file://")
|
|
212
|
+
? decodeURIComponent(def.uri.slice(7))
|
|
213
|
+
: def.uri;
|
|
214
|
+
const relPath = path.relative(deps.cwd, filePath);
|
|
215
|
+
lines.push(`- \`${relPath}:${def.range.start.line + 1}:${def.range.start.character + 1}\``);
|
|
216
|
+
}
|
|
217
|
+
return lines;
|
|
218
|
+
} catch {
|
|
219
|
+
return [];
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
async function appendCodeActions(
|
|
224
|
+
target: OrientationTarget,
|
|
225
|
+
deps: OrientationDeps,
|
|
226
|
+
limit: number,
|
|
227
|
+
): Promise<string[]> {
|
|
228
|
+
if (deps.lspService.kind !== "ready" || !deps.lspService.service) return [];
|
|
229
|
+
try {
|
|
230
|
+
const actions = await deps.lspService.service.codeActions(target.file, {
|
|
231
|
+
line: target.line - 1,
|
|
232
|
+
character: target.character - 1,
|
|
233
|
+
});
|
|
234
|
+
if (!actions || actions.length === 0) return [];
|
|
235
|
+
const lines: string[] = ["**Code Actions:**"];
|
|
236
|
+
for (const action of actions.slice(0, limit)) {
|
|
237
|
+
const kindLabel = action.kind ? ` (${action.kind})` : "";
|
|
238
|
+
lines.push(`- ${action.title}${kindLabel}`);
|
|
239
|
+
}
|
|
240
|
+
return lines;
|
|
241
|
+
} catch {
|
|
242
|
+
return [];
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
async function buildDiagnosticsSection(
|
|
247
|
+
target: OrientationTarget | null | undefined,
|
|
248
|
+
deps: OrientationDeps,
|
|
249
|
+
limit: number,
|
|
250
|
+
): Promise<{ lines: string[]; hasSemanticEvidence: boolean }> {
|
|
251
|
+
if (!target) {
|
|
252
|
+
return {
|
|
253
|
+
lines: ["Diagnostics unavailable without a precise target."],
|
|
254
|
+
hasSemanticEvidence: false,
|
|
255
|
+
};
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
if (deps.lspService.kind !== "ready") {
|
|
259
|
+
return {
|
|
260
|
+
lines: [
|
|
261
|
+
"LSP not available — diagnostics require a live language server. Use `code_health` to check server status.",
|
|
262
|
+
],
|
|
263
|
+
hasSemanticEvidence: false,
|
|
264
|
+
};
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
try {
|
|
268
|
+
const targetFile = path.resolve(deps.cwd, target.file);
|
|
269
|
+
const diags = await deps.lspService.service.fileDiagnostics(targetFile, 4);
|
|
270
|
+
if (!diags || diags.length === 0) {
|
|
271
|
+
return { lines: ["No diagnostics found near this target."], hasSemanticEvidence: true };
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
const nearby = diags.filter((d) => Math.abs((d.range.start.line ?? 0) + 1 - target.line) <= 5);
|
|
275
|
+
if (nearby.length === 0) {
|
|
276
|
+
return { lines: ["No diagnostics found near this target."], hasSemanticEvidence: true };
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
const lines: string[] = [];
|
|
280
|
+
for (const d of nearby.slice(0, limit)) {
|
|
281
|
+
const severity = (d.severity ?? 1) === 1 ? "ERROR" : "WARN";
|
|
282
|
+
const line = (d.range.start.line ?? 0) + 1;
|
|
283
|
+
lines.push(`- **${severity}** (L${line}): ${d.message}`);
|
|
284
|
+
}
|
|
285
|
+
return { lines, hasSemanticEvidence: true };
|
|
286
|
+
} catch {
|
|
287
|
+
return { lines: ["Diagnostics failed to load."], hasSemanticEvidence: false };
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
// biome-ignore lint/complexity/noExcessiveCognitiveComplexity: JSDoc parsing naturally has state-machine complexity
|
|
292
|
+
async function buildDocsSection(
|
|
293
|
+
target: OrientationTarget | null | undefined,
|
|
294
|
+
deps: OrientationDeps,
|
|
295
|
+
limit: number,
|
|
296
|
+
): Promise<{ lines: string[]; hasStructuralEvidence: boolean }> {
|
|
297
|
+
if (!target) {
|
|
298
|
+
return { lines: ["Docs unavailable without a precise target."], hasStructuralEvidence: false };
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
const targetFile = path.resolve(deps.cwd, target.file);
|
|
302
|
+
if (!existsSync(targetFile)) {
|
|
303
|
+
return { lines: ["Docs unavailable — target file not found."], hasStructuralEvidence: false };
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
try {
|
|
307
|
+
const content = readFileSync(targetFile, "utf-8");
|
|
308
|
+
const lines = content.split("\n");
|
|
309
|
+
const startIdx = Math.max(0, target.line - 2);
|
|
310
|
+
let jsdocStart = -1;
|
|
311
|
+
let jsdocEnd = -1;
|
|
312
|
+
|
|
313
|
+
for (let i = startIdx; i >= 0; i--) {
|
|
314
|
+
const line = lines[i].trim();
|
|
315
|
+
|
|
316
|
+
if (line.startsWith("/**") && line.endsWith("*/")) {
|
|
317
|
+
jsdocStart = i;
|
|
318
|
+
jsdocEnd = i;
|
|
319
|
+
break;
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
if (line === "*/") {
|
|
323
|
+
jsdocEnd = i;
|
|
324
|
+
continue;
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
if (jsdocEnd !== -1) {
|
|
328
|
+
if (line.startsWith("/**")) {
|
|
329
|
+
jsdocStart = i;
|
|
330
|
+
break;
|
|
331
|
+
}
|
|
332
|
+
if (line.startsWith("*") || line.startsWith("@")) continue;
|
|
333
|
+
if (line !== "") {
|
|
334
|
+
jsdocStart = -1;
|
|
335
|
+
jsdocEnd = -1;
|
|
336
|
+
break;
|
|
337
|
+
}
|
|
338
|
+
continue;
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
if (line.startsWith("*") || line.startsWith("/**")) continue;
|
|
342
|
+
if (line !== "" && !line.startsWith("//")) break;
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
if (jsdocStart === -1 || jsdocEnd === -1) {
|
|
346
|
+
return {
|
|
347
|
+
lines: ["No JSDoc/TSDoc comment found for this symbol."],
|
|
348
|
+
hasStructuralEvidence: false,
|
|
349
|
+
};
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
const docLines = lines
|
|
353
|
+
.slice(jsdocStart, jsdocEnd + 1)
|
|
354
|
+
.map((line) =>
|
|
355
|
+
line
|
|
356
|
+
.replace(/^\s*\*\s?/, "")
|
|
357
|
+
.replace(/^\s*\/\*\*\s?/, "")
|
|
358
|
+
.replace(/\s*\*\/\s*$/, ""),
|
|
359
|
+
)
|
|
360
|
+
.filter((line) => line.trim() !== "")
|
|
361
|
+
.slice(0, limit);
|
|
362
|
+
|
|
363
|
+
if (docLines.length === 0) {
|
|
364
|
+
return {
|
|
365
|
+
lines: ["No JSDoc/TSDoc comment found for this symbol."],
|
|
366
|
+
hasStructuralEvidence: false,
|
|
367
|
+
};
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
return { lines: ["```ts", ...docLines, "```"], hasStructuralEvidence: true };
|
|
371
|
+
} catch {
|
|
372
|
+
return { lines: ["Docs extraction failed."], hasStructuralEvidence: false };
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
function toBriefInput(input: OrientationInput): BriefInput {
|
|
377
|
+
if (input.focus) return { kind: "path", path: input.focus, maxResults: input.maxResults };
|
|
378
|
+
return { kind: "project", maxResults: input.maxResults };
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
async function maybeGatherTreeContext(
|
|
382
|
+
target: OrientationTarget | null | undefined,
|
|
383
|
+
deps: OrientationDeps,
|
|
384
|
+
) {
|
|
385
|
+
if (!target) return null;
|
|
386
|
+
const relPath = path.relative(deps.cwd, target.file);
|
|
387
|
+
return gatherTreeSitterContext(deps.provider, relPath, target.line, target.character);
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
function buildDefinitionLines(
|
|
391
|
+
target: OrientationTarget | null | undefined,
|
|
392
|
+
cwd: string,
|
|
393
|
+
treeContext: Awaited<ReturnType<typeof maybeGatherTreeContext>>,
|
|
394
|
+
): string[] {
|
|
395
|
+
if (!target) return ["No precise target context found."];
|
|
396
|
+
|
|
397
|
+
const lines = [`- Focus: \`${formatFocusTarget(target, cwd)}\``];
|
|
398
|
+
if (target.name) {
|
|
399
|
+
lines.push(`- Symbol: \`${target.name}\`${target.kind ? ` (${target.kind})` : ""}`);
|
|
400
|
+
}
|
|
401
|
+
if (treeContext?.nodeInfo?.type) {
|
|
402
|
+
lines.push(`- Node: \`${treeContext.nodeInfo.type}\``);
|
|
403
|
+
}
|
|
404
|
+
if (treeContext?.hover?.contents) {
|
|
405
|
+
lines.push(...formatHoverLine(treeContext.hover.contents));
|
|
406
|
+
}
|
|
407
|
+
return lines;
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
function formatHoverLine(contents: string): string[] {
|
|
411
|
+
const trimmed = contents.trim();
|
|
412
|
+
const maxHoverChars = 600;
|
|
413
|
+
if (trimmed.length <= maxHoverChars) return [`- Hover: ${trimmed}`];
|
|
414
|
+
|
|
415
|
+
const hoverLines = trimmed.split("\n");
|
|
416
|
+
if (hoverLines.length === 1) {
|
|
417
|
+
return [
|
|
418
|
+
`- Hover: ${trimmed.slice(0, maxHoverChars)}...`,
|
|
419
|
+
" _(truncated, use `code_inspect` for full type)_",
|
|
420
|
+
];
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
let acc = "";
|
|
424
|
+
for (const line of hoverLines) {
|
|
425
|
+
if (acc.length + line.length + 1 > maxHoverChars && acc.length > 0) break;
|
|
426
|
+
acc += (acc ? "\n" : "") + line;
|
|
427
|
+
}
|
|
428
|
+
return [`- Hover: ${acc}`, " _(truncated, use `code_inspect` for full type)_"];
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
function formatFocusTarget(target: OrientationTarget, cwd: string): string {
|
|
432
|
+
const relPath = path.relative(cwd, target.file) || target.file;
|
|
433
|
+
return `${relPath}:${target.line}:${target.character}`;
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
function buildNextQueries(target: OrientationTarget | null | undefined, cwd: string): string[] {
|
|
437
|
+
if (!target) return ["Use `code_orientation` for a neutral orientation summary."];
|
|
438
|
+
|
|
439
|
+
const relPath = path.relative(cwd, target.file) || target.file;
|
|
440
|
+
return [
|
|
441
|
+
`\`code_graph\` with \`file: "${relPath}"\`, \`line: ${target.line}\`, and \`character: ${target.character}\` for relation follow-up`,
|
|
442
|
+
`\`code_impact\` with \`file: "${relPath}"\`, \`line: ${target.line}\`, and \`character: ${target.character}\` for blast-radius analysis`,
|
|
443
|
+
];
|
|
444
|
+
}
|
|
445
|
+
|
|
446
|
+
function buildReadNextGuidance(
|
|
447
|
+
target: OrientationTarget | null | undefined,
|
|
448
|
+
treeContext: Awaited<ReturnType<typeof maybeGatherTreeContext>>,
|
|
449
|
+
cwd: string,
|
|
450
|
+
): ReadNextItem[] {
|
|
451
|
+
if (!target) return [];
|
|
452
|
+
const relPath = path.relative(cwd, target.file) || target.file;
|
|
453
|
+
const enclosing = findEnclosingOutlineItem(target, treeContext);
|
|
454
|
+
if (enclosing) {
|
|
455
|
+
return [readNextEnclosingScope(relPath, enclosing, target.line)];
|
|
456
|
+
}
|
|
457
|
+
return [readNextTarget(relPath, target.line, "inspect the target implementation")];
|
|
458
|
+
}
|
|
459
|
+
|
|
460
|
+
function findEnclosingOutlineItem(
|
|
461
|
+
target: OrientationTarget,
|
|
462
|
+
treeContext: Awaited<ReturnType<typeof maybeGatherTreeContext>>,
|
|
463
|
+
): { name: string; kind: string; startLine: number; endLine: number } | null {
|
|
464
|
+
if (!treeContext || treeContext.outline.length === 0) return null;
|
|
465
|
+
const candidates = treeContext.outline.filter(
|
|
466
|
+
(item) => item.startLine <= target.line && item.endLine >= target.line,
|
|
467
|
+
);
|
|
468
|
+
if (candidates.length === 0) return null;
|
|
469
|
+
const matchingName = candidates.find((item) => target.name && item.name === target.name);
|
|
470
|
+
if (matchingName) return matchingName;
|
|
471
|
+
return candidates.sort(
|
|
472
|
+
(left, right) => left.endLine - left.startLine - (right.endLine - right.startLine),
|
|
473
|
+
)[0];
|
|
474
|
+
}
|
|
475
|
+
|
|
476
|
+
function hasRenderableItems(lines: string[]): boolean {
|
|
477
|
+
return lines.some((line) => line.trim().startsWith("- "));
|
|
478
|
+
}
|