@mrclrchtr/supi-code-intelligence 4.10.0 → 6.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 +4 -3
- package/node_modules/@mrclrchtr/supi-code-runtime/README.md +2 -0
- package/node_modules/@mrclrchtr/supi-code-runtime/package.json +1 -1
- package/node_modules/@mrclrchtr/supi-code-runtime/src/api.ts +9 -0
- package/node_modules/@mrclrchtr/supi-code-runtime/src/capability/types.ts +53 -13
- package/node_modules/@mrclrchtr/supi-code-runtime/src/request-control.ts +47 -0
- package/node_modules/@mrclrchtr/supi-code-runtime/src/types.ts +13 -1
- package/node_modules/@mrclrchtr/supi-core/README.md +2 -0
- package/node_modules/@mrclrchtr/supi-core/package.json +2 -2
- package/node_modules/@mrclrchtr/supi-core/src/api.ts +1 -1
- package/node_modules/@mrclrchtr/supi-core/src/config/config.ts +31 -0
- package/node_modules/@mrclrchtr/supi-core/src/config.ts +2 -0
- package/node_modules/@mrclrchtr/supi-core/src/debug-registry.ts +19 -6
- package/node_modules/@mrclrchtr/supi-core/src/debug.ts +9 -0
- package/node_modules/@mrclrchtr/supi-core/src/index.ts +1 -1
- package/node_modules/@mrclrchtr/supi-core/src/settings/settings-registry.ts +3 -0
- package/node_modules/@mrclrchtr/supi-lsp/README.md +111 -5
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-code-runtime/README.md +2 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-code-runtime/package.json +1 -1
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-code-runtime/src/api.ts +9 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-code-runtime/src/capability/types.ts +53 -13
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-code-runtime/src/request-control.ts +47 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-code-runtime/src/types.ts +13 -1
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-core/README.md +2 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-core/package.json +2 -2
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-core/src/api.ts +1 -1
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-core/src/config/config.ts +31 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-core/src/config.ts +2 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-core/src/debug-registry.ts +19 -6
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-core/src/debug.ts +9 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-core/src/index.ts +1 -1
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-core/src/settings/settings-registry.ts +3 -0
- package/node_modules/@mrclrchtr/supi-lsp/package.json +7 -6
- package/node_modules/@mrclrchtr/supi-lsp/src/api.ts +22 -1
- package/node_modules/@mrclrchtr/supi-lsp/src/client/client-diagnostic-cache.ts +245 -0
- package/node_modules/@mrclrchtr/supi-lsp/src/client/client-diagnostic-capabilities.ts +78 -0
- package/node_modules/@mrclrchtr/supi-lsp/src/client/client-diagnostic-collection.ts +171 -0
- package/node_modules/@mrclrchtr/supi-lsp/src/client/client-diagnostic-evidence.ts +413 -0
- package/node_modules/@mrclrchtr/supi-lsp/src/client/client-diagnostic-host.ts +15 -0
- package/node_modules/@mrclrchtr/supi-lsp/src/client/client-diagnostic-publication.ts +214 -0
- package/node_modules/@mrclrchtr/supi-lsp/src/client/client-diagnostic-pull.ts +62 -0
- package/node_modules/@mrclrchtr/supi-lsp/src/client/client-diagnostic-refresh.ts +690 -0
- package/node_modules/@mrclrchtr/supi-lsp/src/client/client-diagnostic-request.ts +9 -0
- package/node_modules/@mrclrchtr/supi-lsp/src/client/client-diagnostic-timing.ts +97 -16
- package/node_modules/@mrclrchtr/supi-lsp/src/client/client-diagnostic-waiters.ts +206 -0
- package/node_modules/@mrclrchtr/supi-lsp/src/client/client-diagnostics.ts +448 -298
- package/node_modules/@mrclrchtr/supi-lsp/src/client/client-document-state.ts +70 -0
- package/node_modules/@mrclrchtr/supi-lsp/src/client/client-document-sync.ts +231 -0
- package/node_modules/@mrclrchtr/supi-lsp/src/client/client-file-state.ts +25 -0
- package/node_modules/@mrclrchtr/supi-lsp/src/client/client.ts +529 -119
- package/node_modules/@mrclrchtr/supi-lsp/src/client/transport.ts +161 -33
- package/node_modules/@mrclrchtr/supi-lsp/src/config/capabilities.ts +12 -3
- package/node_modules/@mrclrchtr/supi-lsp/src/config/config.ts +5 -5
- package/node_modules/@mrclrchtr/supi-lsp/src/config/defaults.json +1 -1
- package/node_modules/@mrclrchtr/supi-lsp/src/config/server-config.ts +3 -0
- package/node_modules/@mrclrchtr/supi-lsp/src/config/tsconfig-extends.ts +68 -0
- package/node_modules/@mrclrchtr/supi-lsp/src/config/tsconfig-path.ts +8 -0
- package/node_modules/@mrclrchtr/supi-lsp/src/config/tsconfig-scope.ts +176 -24
- package/node_modules/@mrclrchtr/supi-lsp/src/debug-telemetry.ts +45 -0
- package/node_modules/@mrclrchtr/supi-lsp/src/diagnostics/evidence.ts +42 -0
- package/node_modules/@mrclrchtr/supi-lsp/src/diagnostics/workspace-sentinels.ts +46 -10
- package/node_modules/@mrclrchtr/supi-lsp/src/manager/manager-client-state.ts +79 -9
- package/node_modules/@mrclrchtr/supi-lsp/src/manager/manager-diagnostics.ts +17 -7
- package/node_modules/@mrclrchtr/supi-lsp/src/manager/manager-workspace-recovery.ts +350 -26
- package/node_modules/@mrclrchtr/supi-lsp/src/manager/manager-workspace-symbol.ts +5 -2
- package/node_modules/@mrclrchtr/supi-lsp/src/manager/manager.ts +586 -96
- package/node_modules/@mrclrchtr/supi-lsp/src/provider/lsp-refactor-provider.ts +130 -0
- package/node_modules/@mrclrchtr/supi-lsp/src/provider/lsp-semantic-provider.ts +45 -329
- package/node_modules/@mrclrchtr/supi-lsp/src/provider/refactor-planning.ts +57 -120
- package/node_modules/@mrclrchtr/supi-lsp/src/provider/semantic-edit-normalizer.ts +320 -0
- package/node_modules/@mrclrchtr/supi-lsp/src/provider/semantic-symbol-mapper.ts +207 -0
- package/node_modules/@mrclrchtr/supi-lsp/src/session/readiness.ts +72 -2
- package/node_modules/@mrclrchtr/supi-lsp/src/session/runtime-controller.ts +151 -26
- package/node_modules/@mrclrchtr/supi-lsp/src/session/runtime-diagnostic-surface.ts +42 -0
- package/node_modules/@mrclrchtr/supi-lsp/src/session/runtime-diagnostics.ts +92 -0
- package/node_modules/@mrclrchtr/supi-lsp/src/session/runtime-registry.ts +165 -118
- package/node_modules/@mrclrchtr/supi-lsp/src/session/runtime-transition-debug.ts +49 -0
- package/node_modules/@mrclrchtr/supi-lsp/src/session/workspace-lsp-runtime.ts +102 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/README.md +17 -7
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/README.md +2 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/package.json +1 -1
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/src/api.ts +9 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/src/capability/types.ts +53 -13
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/src/request-control.ts +47 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/src/types.ts +13 -1
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/README.md +2 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/package.json +2 -2
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/src/api.ts +1 -1
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/src/config/config.ts +31 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/src/config.ts +2 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/src/debug-registry.ts +19 -6
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/src/debug.ts +9 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/src/index.ts +1 -1
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/src/settings/settings-registry.ts +3 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/jiti/LICENSE +21 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/jiti/README.md +258 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/jiti/dist/babel.cjs +257 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/jiti/dist/jiti.cjs +1 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/jiti/lib/jiti-cli.mjs +34 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/jiti/lib/jiti-hooks.mjs +124 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/jiti/lib/jiti-native.mjs +121 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/jiti/lib/jiti-register.d.mts +1 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/jiti/lib/jiti-register.mjs +4 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/jiti/lib/jiti-static.mjs +23 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/jiti/lib/jiti.cjs +30 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/jiti/lib/jiti.d.cts +8 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/jiti/lib/jiti.d.mts +8 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/jiti/lib/jiti.mjs +29 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/jiti/lib/types.d.ts +420 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/jiti/package.json +146 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/package.json +6 -3
- package/node_modules/@mrclrchtr/supi-tree-sitter/src/api.ts +0 -9
- package/node_modules/@mrclrchtr/supi-tree-sitter/src/index.ts +0 -8
- package/node_modules/@mrclrchtr/supi-tree-sitter/src/provider/tree-sitter-provider.ts +16 -12
- package/node_modules/@mrclrchtr/supi-tree-sitter/src/session/runtime-controller.ts +65 -87
- package/node_modules/@mrclrchtr/supi-tree-sitter/src/session/session.ts +47 -95
- package/node_modules/@mrclrchtr/supi-tree-sitter/src/session/structural-timing.ts +147 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/src/session/structural-worker-client-lifecycle.ts +39 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/src/session/structural-worker-client.ts +561 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/src/session/structural-worker-message-size.ts +24 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/src/session/structural-worker-protocol.ts +452 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/src/tool/call-sites.ts +4 -2
- package/node_modules/@mrclrchtr/supi-tree-sitter/src/tool/callees.ts +12 -4
- package/node_modules/@mrclrchtr/supi-tree-sitter/src/tool/exports.ts +4 -2
- package/node_modules/@mrclrchtr/supi-tree-sitter/src/tool/imports.ts +4 -2
- package/node_modules/@mrclrchtr/supi-tree-sitter/src/tool/node-at.ts +5 -3
- package/node_modules/@mrclrchtr/supi-tree-sitter/src/types.ts +33 -12
- package/node_modules/@mrclrchtr/supi-tree-sitter/src/worker/blocking-test-bootstrap.mjs +34 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/src/worker/bootstrap.mjs +8 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/src/worker/parsed-file-store-helpers.ts +23 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/src/worker/parsed-file-store.ts +400 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/src/worker/request-control.ts +48 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/src/worker/runtime-parser-helpers.ts +24 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/src/worker/runtime-query-helpers.ts +43 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/src/worker/runtime.ts +421 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/src/worker/service.ts +116 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/src/worker/worker-main.ts +201 -0
- package/package.json +5 -5
- package/src/analysis/health/diagnostics.ts +221 -77
- package/src/analysis/health/file-scope.ts +184 -0
- package/src/analysis/health/recovery.ts +14 -3
- package/src/analysis/provider.ts +58 -0
- package/src/analysis/readiness.ts +34 -9
- package/src/analysis/refactor/apply.ts +45 -1
- package/src/analysis/refactor/mutation-authority.ts +143 -0
- package/src/analysis/relations/callees.ts +9 -1
- package/src/analysis/relations/types.ts +5 -2
- package/src/analysis/search/ast-scan-timing.ts +9 -2
- package/src/analysis/search/ast-scan.ts +5 -2
- package/src/analysis/search/deadline.ts +2 -2
- package/src/analysis/search/pattern-analysis.ts +54 -33
- package/src/analysis/search/pattern.ts +18 -3
- package/src/analysis/target/anchored.ts +20 -11
- package/src/analysis/target/file.ts +18 -11
- package/src/analysis/target/identity.ts +19 -3
- package/src/analysis/target/symbol.ts +36 -15
- package/src/api.ts +4 -0
- package/src/config.ts +35 -1
- package/src/diagnostics/evidence.ts +51 -0
- package/src/extension.ts +57 -14
- package/src/overview/overview-data.ts +9 -2
- package/src/overview/overview.ts +49 -30
- package/src/overview/types.ts +2 -0
- package/src/session/capability-adapter.ts +12 -3
- package/src/session/find-types.ts +2 -2
- package/src/session/find-workflow.ts +20 -9
- package/src/session/graph/collect.ts +18 -2
- package/src/session/graph-workflow.ts +19 -12
- package/src/session/health-refresh.ts +175 -0
- package/src/session/health-types.ts +43 -15
- package/src/session/health-workflow.ts +69 -54
- package/src/session/input/workflows.ts +2 -2
- package/src/session/inspect/collect.ts +20 -3
- package/src/session/inspect-workflow.ts +12 -6
- package/src/session/orientation/collect.ts +12 -3
- package/src/session/orientation/context-facts.ts +3 -1
- package/src/session/orientation/context-sections.ts +20 -7
- package/src/session/orientation/gather.ts +17 -11
- package/src/session/orientation-types.ts +4 -1
- package/src/session/orientation-workflow.ts +23 -10
- package/src/session/refactor-plans.ts +2 -0
- package/src/session/refactor-workflow.ts +61 -15
- package/src/session/session.ts +29 -2
- package/src/session/target-workflow.ts +54 -23
- package/src/session/workflow-control.ts +7 -3
- package/src/substrate/lsp/lifecycle.ts +26 -46
- package/src/substrate/lsp/maintenance.ts +284 -28
- package/src/substrate/lsp/recovery.ts +11 -5
- package/src/substrate/lsp/state.ts +2 -2
- package/src/substrate/workspace-provider-host.ts +25 -3
- package/src/tool/{find → code_find}/execute.ts +2 -16
- package/src/tool/code_find/guidance.ts +8 -0
- package/src/tool/{find → code_find}/render.ts +21 -4
- package/src/tool/{result/find.ts → code_find/result.ts} +78 -9
- package/src/tool/code_find/spec.ts +37 -0
- package/src/tool/code_find/tui.ts +41 -0
- package/src/tool/code_graph/execute.ts +24 -0
- package/src/tool/code_graph/guidance.ts +6 -0
- package/src/tool/{graph → code_graph}/markdown.ts +1 -1
- package/src/tool/{result/graph.ts → code_graph/result.ts} +111 -3
- package/src/tool/code_graph/spec.ts +39 -0
- package/src/tool/code_graph/tui.ts +117 -0
- package/src/tool/{health → code_health}/execute.ts +2 -13
- package/src/tool/code_health/guidance.ts +8 -0
- package/src/tool/{health → code_health}/markdown.ts +119 -27
- package/src/tool/code_health/refresh-status.ts +105 -0
- package/src/tool/{result/health.ts → code_health/result.ts} +80 -3
- package/src/tool/code_health/spec.ts +41 -0
- package/src/tool/{health → code_health}/tui.ts +95 -98
- package/src/tool/{inspect → code_inspect}/execute.ts +2 -16
- package/src/tool/code_inspect/guidance.ts +6 -0
- package/src/tool/{inspect → code_inspect}/markdown.ts +1 -1
- package/src/tool/{result/inspect.ts → code_inspect/result.ts} +143 -2
- package/src/tool/code_inspect/spec.ts +25 -0
- package/src/tool/code_inspect/tui.ts +44 -0
- package/src/tool/code_orientation/execute.ts +25 -0
- package/src/tool/code_orientation/guidance.ts +9 -0
- package/src/tool/{orientation → code_orientation}/markdown.ts +1 -1
- package/src/tool/code_orientation/result.ts +248 -0
- package/src/tool/code_orientation/spec.ts +25 -0
- package/src/tool/{orientation → code_orientation}/tui.ts +51 -35
- package/src/tool/code_refactor_apply/execute.ts +17 -0
- package/src/tool/code_refactor_apply/guidance.ts +5 -0
- package/src/tool/{refactor-apply/execute.ts → code_refactor_apply/result.ts} +8 -11
- package/src/tool/code_refactor_apply/spec.ts +26 -0
- package/src/tool/code_refactor_apply/tui.ts +73 -0
- package/src/tool/code_refactor_plan/execute.ts +27 -0
- package/src/tool/code_refactor_plan/guidance.ts +8 -0
- package/src/tool/{refactor-plan/execute.ts → code_refactor_plan/result.ts} +13 -22
- package/src/tool/code_refactor_plan/spec.ts +25 -0
- package/src/tool/code_refactor_plan/tui.ts +54 -0
- package/src/tool/code_resolve/execute.ts +19 -0
- package/src/tool/code_resolve/guidance.ts +8 -0
- package/src/tool/{resolve → code_resolve}/markdown.ts +1 -1
- package/src/tool/{result/resolve.ts → code_resolve/result.ts} +79 -29
- package/src/tool/code_resolve/spec.ts +25 -0
- package/src/tool/code_resolve/tui.ts +60 -0
- package/src/tool/guidance.ts +71 -52
- package/src/tool/infra/truncate.ts +40 -0
- package/src/tool/infra/workflow-control.ts +8 -0
- package/src/tool/{refactor-plan/markdown.ts → refactor-markdown.ts} +4 -7
- package/src/tool/register.ts +105 -88
- package/src/tool/result/display.ts +107 -0
- package/src/tool/result/errors.ts +20 -17
- package/src/tool/result/refactor.ts +37 -8
- package/src/tool/result/types.ts +20 -0
- package/src/tool/schemas.ts +26 -157
- package/src/tool/specs.ts +40 -126
- package/src/types/execution.ts +18 -5
- package/src/types/index.ts +8 -1
- package/src/ui/status-command.ts +5 -3
- package/src/ui/status-overlay.ts +4 -0
- package/src/ui/tui/common.ts +108 -10
- package/src/ui/tui/display.ts +48 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/src/session/runtime.ts +0 -351
- package/src/tool/find/tui.ts +0 -39
- package/src/tool/graph/execute.ts +0 -62
- package/src/tool/graph/tui.ts +0 -104
- package/src/tool/inspect/tui.ts +0 -36
- package/src/tool/orientation/execute.ts +0 -62
- package/src/tool/refactor-apply/tui.ts +0 -55
- package/src/tool/refactor-plan/tui.ts +0 -41
- package/src/tool/resolve/execute.ts +0 -36
- package/src/tool/resolve/tui.ts +0 -42
- package/src/tool/result/orientation.ts +0 -132
- /package/src/tool/{find → code_find}/ast-kinds.ts +0 -0
- /package/src/tool/{find → code_find}/markdown.ts +0 -0
- /package/src/tool/{find → code_find}/modes.ts +0 -0
- /package/src/tool/{health → code_health}/semantic-state.ts +0 -0
|
@@ -1,4 +1,6 @@
|
|
|
1
|
+
import type { CodeRequestControl } from "@mrclrchtr/supi-code-runtime/api";
|
|
1
2
|
import { startDebugTimer } from "@mrclrchtr/supi-core/debug";
|
|
3
|
+
import { truncateIdentity } from "@mrclrchtr/supi-lsp/debug-telemetry";
|
|
2
4
|
import type { StructuralSearchOperation } from "@mrclrchtr/supi-tree-sitter/api";
|
|
3
5
|
import type { StructuredFileAnalysis, StructuredPatternParams } from "./pattern-analysis.ts";
|
|
4
6
|
|
|
@@ -25,8 +27,11 @@ export interface AstScanTimer {
|
|
|
25
27
|
record(input: AstScanTimingInput): void;
|
|
26
28
|
}
|
|
27
29
|
|
|
28
|
-
/** Start one AST scan timer
|
|
29
|
-
export function startAstScanTimer(
|
|
30
|
+
/** Start one AST scan timer, recording the workspace root as event-level cwd. */
|
|
31
|
+
export function startAstScanTimer(
|
|
32
|
+
control: CodeRequestControl | undefined,
|
|
33
|
+
cwd: string,
|
|
34
|
+
): AstScanTimer {
|
|
30
35
|
const timer = startDebugTimer();
|
|
31
36
|
return {
|
|
32
37
|
enumerationCompleted() {
|
|
@@ -35,10 +40,12 @@ export function startAstScanTimer(): AstScanTimer {
|
|
|
35
40
|
record(input) {
|
|
36
41
|
timer.finish(
|
|
37
42
|
() => ({
|
|
43
|
+
operationId: control?.operationId,
|
|
38
44
|
source: "code-intelligence",
|
|
39
45
|
level: "debug",
|
|
40
46
|
category: "ast-scan.timing",
|
|
41
47
|
message: `AST ${input.context.params.kind} scan analyzed ${input.analysis.analyzedFileCount} files`,
|
|
48
|
+
cwd: truncateIdentity(cwd),
|
|
42
49
|
data: {
|
|
43
50
|
kind: input.context.params.kind,
|
|
44
51
|
operation: input.operation,
|
|
@@ -5,7 +5,7 @@ import {
|
|
|
5
5
|
getSupportedExtensions,
|
|
6
6
|
type StructuralSearchOperation,
|
|
7
7
|
} from "@mrclrchtr/supi-tree-sitter/api";
|
|
8
|
-
import { type DeadlineOutcome, settleByDeadline } from "./deadline.ts";
|
|
8
|
+
import { type DeadlineOutcome, type ScheduleDeadline, settleByDeadline } from "./deadline.ts";
|
|
9
9
|
import { relativeDisplayPath } from "./paths.ts";
|
|
10
10
|
|
|
11
11
|
/** Directory names excluded below an AST Scan root. */
|
|
@@ -83,6 +83,8 @@ export interface EnumerateAstFilesOptions {
|
|
|
83
83
|
readonly timeoutMs?: number;
|
|
84
84
|
readonly signal?: AbortSignal;
|
|
85
85
|
readonly now?: () => number;
|
|
86
|
+
/** Timer seam for deterministic deadline tests; defaults to wall-clock timers. */
|
|
87
|
+
readonly schedule?: ScheduleDeadline;
|
|
86
88
|
readonly operations?: AstScanOperations;
|
|
87
89
|
}
|
|
88
90
|
|
|
@@ -292,7 +294,7 @@ class AstFileEnumerator {
|
|
|
292
294
|
#checkControl(): boolean {
|
|
293
295
|
this.options.signal?.throwIfAborted();
|
|
294
296
|
if (this.#safetyLimited) return false;
|
|
295
|
-
if (this.#now()
|
|
297
|
+
if (this.#now() < this.options.deadline) return true;
|
|
296
298
|
this.#markTimeout();
|
|
297
299
|
return false;
|
|
298
300
|
}
|
|
@@ -302,6 +304,7 @@ class AstFileEnumerator {
|
|
|
302
304
|
deadline: this.options.deadline,
|
|
303
305
|
now: this.#now,
|
|
304
306
|
signal: this.options.signal,
|
|
307
|
+
schedule: this.options.schedule,
|
|
305
308
|
});
|
|
306
309
|
if (outcome.kind === "timeout") this.#markTimeout();
|
|
307
310
|
return outcome;
|
|
@@ -24,7 +24,7 @@ export async function settleByDeadline<T>(
|
|
|
24
24
|
): Promise<DeadlineOutcome<T>> {
|
|
25
25
|
control.signal?.throwIfAborted();
|
|
26
26
|
const remainingMs = control.deadline - control.now();
|
|
27
|
-
if (remainingMs
|
|
27
|
+
if (remainingMs <= 0) return { kind: "timeout" };
|
|
28
28
|
|
|
29
29
|
return new Promise<DeadlineOutcome<T>>((resolve, reject) => {
|
|
30
30
|
let settled = false;
|
|
@@ -70,7 +70,7 @@ export async function settleByDeadline<T>(
|
|
|
70
70
|
.then(
|
|
71
71
|
(value) => {
|
|
72
72
|
complete(
|
|
73
|
-
control.now()
|
|
73
|
+
control.now() >= control.deadline ? { kind: "timeout" } : { kind: "completed", value },
|
|
74
74
|
);
|
|
75
75
|
},
|
|
76
76
|
(error: unknown) => fail(error),
|
|
@@ -1,12 +1,15 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import {
|
|
2
|
+
type CodeRequestControl,
|
|
3
|
+
type CodeResult,
|
|
4
|
+
isCodeRequestDeadlineError,
|
|
5
|
+
isCodeRequestInterruption,
|
|
6
|
+
type OutlineData,
|
|
7
|
+
type StructuralProvider as StructuralSubstrate,
|
|
5
8
|
} from "@mrclrchtr/supi-code-runtime/api";
|
|
6
|
-
import type { CodeFindAstKind } from "../../tool/
|
|
9
|
+
import type { CodeFindAstKind } from "../../tool/code_find/ast-kinds.ts";
|
|
7
10
|
import type { AstScanLimitation } from "./ast-scan.ts";
|
|
8
11
|
import { callableExpressionForMatching } from "./call-name.ts";
|
|
9
|
-
import { settleByDeadline } from "./deadline.ts";
|
|
12
|
+
import { type DeadlineOutcome, type ScheduleDeadline, settleByDeadline } from "./deadline.ts";
|
|
10
13
|
import { relativeDisplayPath } from "./paths.ts";
|
|
11
14
|
|
|
12
15
|
export interface StructuredPatternParams {
|
|
@@ -52,6 +55,9 @@ interface AnalyzeStructuredFilesOptions {
|
|
|
52
55
|
readonly deadline: number;
|
|
53
56
|
readonly now: () => number;
|
|
54
57
|
readonly signal?: AbortSignal;
|
|
58
|
+
/** Timer seam for deterministic deadline tests; defaults to wall-clock timers. */
|
|
59
|
+
readonly schedule?: ScheduleDeadline;
|
|
60
|
+
readonly requestControl: CodeRequestControl;
|
|
55
61
|
readonly initialLimitations: readonly AstScanLimitation[];
|
|
56
62
|
}
|
|
57
63
|
|
|
@@ -67,34 +73,48 @@ export async function analyzeStructuredFiles(
|
|
|
67
73
|
|
|
68
74
|
for (const [index, absoluteFile] of options.files.entries()) {
|
|
69
75
|
options.signal?.throwIfAborted();
|
|
70
|
-
if (options.now()
|
|
76
|
+
if (options.now() >= options.deadline) {
|
|
71
77
|
addAnalysisTimeout(limitations, options.files.slice(index), options.displayBase);
|
|
72
78
|
break;
|
|
73
79
|
}
|
|
74
80
|
const relativeFile = relativeDisplayPath(options.displayBase, absoluteFile);
|
|
75
81
|
const fileMatches: StructuredMatch[] = [];
|
|
76
82
|
const fileFailures: StructuredFailure[] = [];
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
83
|
+
let outcome: DeadlineOutcome<void>;
|
|
84
|
+
try {
|
|
85
|
+
outcome = await settleByDeadline(
|
|
86
|
+
async () => {
|
|
87
|
+
try {
|
|
88
|
+
await collectMatchesForFile(
|
|
89
|
+
fileMatches,
|
|
90
|
+
fileFailures,
|
|
91
|
+
options.structural,
|
|
92
|
+
relativeFile,
|
|
93
|
+
options.params.kind,
|
|
94
|
+
matcher,
|
|
95
|
+
options.requestControl,
|
|
96
|
+
);
|
|
97
|
+
} catch (error) {
|
|
98
|
+
if (isCodeRequestInterruption(error, options.requestControl)) throw error;
|
|
99
|
+
fileFailures.push({
|
|
100
|
+
file: relativeFile,
|
|
101
|
+
kind: "runtime-error",
|
|
102
|
+
reason: errorMessage(error),
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
},
|
|
106
|
+
{
|
|
107
|
+
deadline: options.deadline,
|
|
108
|
+
now: options.now,
|
|
109
|
+
signal: options.signal,
|
|
110
|
+
schedule: options.schedule,
|
|
111
|
+
},
|
|
112
|
+
);
|
|
113
|
+
} catch (error) {
|
|
114
|
+
if (!isCodeRequestDeadlineError(error)) throw error;
|
|
115
|
+
addAnalysisTimeout(limitations, options.files.slice(index), options.displayBase);
|
|
116
|
+
break;
|
|
117
|
+
}
|
|
98
118
|
if (outcome.kind === "timeout") {
|
|
99
119
|
addAnalysisTimeout(limitations, options.files.slice(index), options.displayBase);
|
|
100
120
|
break;
|
|
@@ -137,13 +157,14 @@ async function collectMatchesForFile(
|
|
|
137
157
|
relFile: string,
|
|
138
158
|
kind: CodeFindAstKind,
|
|
139
159
|
matcher: (value: string) => boolean,
|
|
160
|
+
requestControl: CodeRequestControl,
|
|
140
161
|
): Promise<void> {
|
|
141
162
|
const recordFailure = (kind: StructuredFailureKind, reason: string) => {
|
|
142
163
|
failures.push({ file: relFile, kind, reason });
|
|
143
164
|
};
|
|
144
165
|
|
|
145
166
|
if (kind === "definition") {
|
|
146
|
-
const outline = await structural.outline(relFile);
|
|
167
|
+
const outline = await structural.outline(relFile, requestControl);
|
|
147
168
|
if (!handleStructuralResult(outline, recordFailure)) return;
|
|
148
169
|
for (const item of flattenOutlineItems(outline.data)) {
|
|
149
170
|
if (!matcher(item.name)) continue;
|
|
@@ -153,7 +174,7 @@ async function collectMatchesForFile(
|
|
|
153
174
|
}
|
|
154
175
|
|
|
155
176
|
if (kind === "export") {
|
|
156
|
-
const exportsResult = await structural.exports(relFile);
|
|
177
|
+
const exportsResult = await structural.exports(relFile, requestControl);
|
|
157
178
|
if (!handleStructuralResult(exportsResult, recordFailure)) return;
|
|
158
179
|
for (const item of exportsResult.data) {
|
|
159
180
|
if (!matcher(item.name)) continue;
|
|
@@ -163,7 +184,7 @@ async function collectMatchesForFile(
|
|
|
163
184
|
}
|
|
164
185
|
|
|
165
186
|
if (kind === "import") {
|
|
166
|
-
const importsResult = await structural.imports(relFile);
|
|
187
|
+
const importsResult = await structural.imports(relFile, requestControl);
|
|
167
188
|
if (!handleStructuralResult(importsResult, recordFailure)) return;
|
|
168
189
|
for (const item of importsResult.data) {
|
|
169
190
|
if (!matcher(item.moduleSpecifier)) continue;
|
|
@@ -178,7 +199,7 @@ async function collectMatchesForFile(
|
|
|
178
199
|
}
|
|
179
200
|
|
|
180
201
|
if (kind === "call") {
|
|
181
|
-
const callResult = await structural.callSites(relFile);
|
|
202
|
+
const callResult = await structural.callSites(relFile, requestControl);
|
|
182
203
|
if (!handleStructuralResult(callResult, recordFailure)) return;
|
|
183
204
|
for (const call of callResult.data) {
|
|
184
205
|
if (!matcher(callableExpressionForMatching(call.name))) continue;
|
|
@@ -187,7 +208,7 @@ async function collectMatchesForFile(
|
|
|
187
208
|
return;
|
|
188
209
|
}
|
|
189
210
|
|
|
190
|
-
const outline = await structural.outline(relFile);
|
|
211
|
+
const outline = await structural.outline(relFile, requestControl);
|
|
191
212
|
if (!handleStructuralResult(outline, recordFailure)) return;
|
|
192
213
|
for (const item of flattenOutlineItems(outline.data)) {
|
|
193
214
|
if (kind === "type" && !TYPE_KIND.test(item.kind.toLowerCase())) continue;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { StructuralProvider as StructuralSubstrate } from "@mrclrchtr/supi-code-runtime/api";
|
|
2
2
|
import type { StructuralSearchOperation } from "@mrclrchtr/supi-tree-sitter/api";
|
|
3
|
-
import type { CodeFindAstKind } from "../../tool/
|
|
3
|
+
import type { CodeFindAstKind } from "../../tool/code_find/ast-kinds.ts";
|
|
4
4
|
import type { EvidencePartialReason } from "../evidence.ts";
|
|
5
5
|
import {
|
|
6
6
|
type AstScanExclusion,
|
|
@@ -11,6 +11,7 @@ import {
|
|
|
11
11
|
enumerateAstFiles,
|
|
12
12
|
} from "./ast-scan.ts";
|
|
13
13
|
import { startAstScanTimer } from "./ast-scan-timing.ts";
|
|
14
|
+
import type { ScheduleDeadline } from "./deadline.ts";
|
|
14
15
|
import { relativeDisplayPath } from "./paths.ts";
|
|
15
16
|
import {
|
|
16
17
|
analyzeStructuredFiles,
|
|
@@ -56,11 +57,16 @@ export type StructuredPatternOutcome =
|
|
|
56
57
|
|
|
57
58
|
/** Internal controls for deterministic deadline, filesystem, and cancellation tests. */
|
|
58
59
|
export interface StructuredPatternControl {
|
|
60
|
+
readonly operationId?: string;
|
|
59
61
|
readonly signal?: AbortSignal;
|
|
60
62
|
readonly now?: () => number;
|
|
61
63
|
readonly operations?: AstScanOperations;
|
|
62
64
|
readonly maxFiles?: number;
|
|
63
65
|
readonly timeoutMs?: number;
|
|
66
|
+
/** Optional caller deadline; the earlier caller/policy deadline wins. */
|
|
67
|
+
readonly deadline?: number;
|
|
68
|
+
/** Timer seam for deterministic deadline tests; defaults to wall-clock timers. */
|
|
69
|
+
readonly schedule?: ScheduleDeadline;
|
|
64
70
|
}
|
|
65
71
|
|
|
66
72
|
export interface StructuredPatternSearchOptions {
|
|
@@ -80,11 +86,12 @@ export interface StructuredPatternSearchOptions {
|
|
|
80
86
|
export async function getStructuredPatternMatches(
|
|
81
87
|
options: StructuredPatternSearchOptions,
|
|
82
88
|
): Promise<StructuredPatternOutcome> {
|
|
83
|
-
const scanTimer = startAstScanTimer();
|
|
89
|
+
const scanTimer = startAstScanTimer(options.control, options.cwd);
|
|
84
90
|
const now = options.control?.now ?? Date.now;
|
|
85
91
|
const maxFiles = options.control?.maxFiles ?? DEFAULT_AST_SCAN_MAX_FILES;
|
|
86
92
|
const timeoutMs = options.control?.timeoutMs ?? DEFAULT_AST_SCAN_TIMEOUT_MS;
|
|
87
|
-
const
|
|
93
|
+
const policyDeadline = now() + timeoutMs;
|
|
94
|
+
const deadline = Math.min(options.control?.deadline ?? Number.POSITIVE_INFINITY, policyDeadline);
|
|
88
95
|
const roots = Array.isArray(options.roots) ? [...options.roots] : [options.roots];
|
|
89
96
|
const operation = structuralOperationForKind(options.params.kind);
|
|
90
97
|
options.control?.signal?.throwIfAborted();
|
|
@@ -98,6 +105,7 @@ export async function getStructuredPatternMatches(
|
|
|
98
105
|
timeoutMs,
|
|
99
106
|
signal: options.control?.signal,
|
|
100
107
|
now,
|
|
108
|
+
schedule: options.control?.schedule,
|
|
101
109
|
operations: options.control?.operations,
|
|
102
110
|
});
|
|
103
111
|
if (enumeration.kind === "invalid-root") {
|
|
@@ -127,6 +135,11 @@ export async function getStructuredPatternMatches(
|
|
|
127
135
|
}
|
|
128
136
|
|
|
129
137
|
scanTimer.enumerationCompleted();
|
|
138
|
+
const requestControl = {
|
|
139
|
+
operationId: options.control?.operationId,
|
|
140
|
+
signal: options.control?.signal,
|
|
141
|
+
deadline,
|
|
142
|
+
};
|
|
130
143
|
const analysis = await analyzeStructuredFiles({
|
|
131
144
|
files: enumeration.files,
|
|
132
145
|
displayBase: enumeration.displayBase,
|
|
@@ -135,6 +148,8 @@ export async function getStructuredPatternMatches(
|
|
|
135
148
|
deadline,
|
|
136
149
|
now,
|
|
137
150
|
signal: options.control?.signal,
|
|
151
|
+
schedule: options.control?.schedule,
|
|
152
|
+
requestControl,
|
|
138
153
|
initialLimitations: enumeration.limitations,
|
|
139
154
|
});
|
|
140
155
|
const capabilityMismatches = analysis.failures.filter(
|
|
@@ -9,12 +9,14 @@
|
|
|
9
9
|
|
|
10
10
|
import * as fs from "node:fs";
|
|
11
11
|
import * as path from "node:path";
|
|
12
|
-
import
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
12
|
+
import {
|
|
13
|
+
type CodeRequestControl,
|
|
14
|
+
type CodeResult,
|
|
15
|
+
type CodeSymbol,
|
|
16
|
+
isCodeRequestInterruption,
|
|
17
|
+
type NodeAtData,
|
|
18
|
+
type SemanticProvider,
|
|
19
|
+
type StructuralProvider,
|
|
18
20
|
} from "@mrclrchtr/supi-code-runtime/api";
|
|
19
21
|
import type { AnchorKind } from "../../session/target-store.ts";
|
|
20
22
|
import type { AnchoredResolutionMetadata, AnchoredResolutionSource } from "../../types/index.ts";
|
|
@@ -217,17 +219,20 @@ async function candidatesFromSymbols(
|
|
|
217
219
|
}
|
|
218
220
|
|
|
219
221
|
/** Layer 1: match the coordinate against LSP document symbols. Returns null to fall through. */
|
|
222
|
+
// biome-ignore lint/complexity/noExcessiveCognitiveComplexity: layered anchored resolution keeps layer-1 symbol matching and identity resolution together.
|
|
220
223
|
async function resolveFromSemantic(
|
|
221
224
|
file: string,
|
|
222
225
|
requested: Anchor,
|
|
223
226
|
provider: AnchoredResolverProvider,
|
|
227
|
+
control?: CodeRequestControl,
|
|
224
228
|
): Promise<TargetOutcome | null> {
|
|
225
229
|
if (!provider.documentSymbols) return null;
|
|
226
230
|
let symbols: CodeSymbol[] = [];
|
|
227
231
|
try {
|
|
228
232
|
const result = await provider.documentSymbols(file);
|
|
229
233
|
if (result.kind !== "unavailable") symbols = result.data;
|
|
230
|
-
} catch {
|
|
234
|
+
} catch (error) {
|
|
235
|
+
if (isCodeRequestInterruption(error, control)) throw error;
|
|
231
236
|
symbols = [];
|
|
232
237
|
}
|
|
233
238
|
if (symbols.length === 0) return null;
|
|
@@ -241,7 +246,7 @@ async function resolveFromSemantic(
|
|
|
241
246
|
}
|
|
242
247
|
|
|
243
248
|
const structural = provider.nodeAt ? { nodeAt: provider.nodeAt } : undefined;
|
|
244
|
-
const resolveIdentity = createCodeSymbolIdentityResolver(file, symbols, structural);
|
|
249
|
+
const resolveIdentity = createCodeSymbolIdentityResolver(file, symbols, structural, control);
|
|
245
250
|
if (exact.length === 1) {
|
|
246
251
|
return resolvedFromSymbol(file, exact[0], {
|
|
247
252
|
snapped: false,
|
|
@@ -268,12 +273,14 @@ async function resolveFromStructural(
|
|
|
268
273
|
file: string,
|
|
269
274
|
requested: Anchor,
|
|
270
275
|
provider: AnchoredResolverProvider,
|
|
276
|
+
control?: CodeRequestControl,
|
|
271
277
|
): Promise<TargetOutcome | null> {
|
|
272
278
|
if (!provider.nodeAt) return null;
|
|
273
279
|
let nodeResult: CodeResult<NodeAtData> | null = null;
|
|
274
280
|
try {
|
|
275
281
|
nodeResult = await provider.nodeAt(file, requested.line, requested.character);
|
|
276
|
-
} catch {
|
|
282
|
+
} catch (error) {
|
|
283
|
+
if (isCodeRequestInterruption(error, control)) throw error;
|
|
277
284
|
nodeResult = null;
|
|
278
285
|
}
|
|
279
286
|
if (nodeResult?.kind !== "success") return null;
|
|
@@ -351,11 +358,13 @@ async function resolveFromStructural(
|
|
|
351
358
|
* This does not perform heuristic global text search and does not silently
|
|
352
359
|
* treat declaration anchors as name anchors (ADR 0003).
|
|
353
360
|
*/
|
|
361
|
+
// biome-ignore lint/complexity/useMaxParams: anchored resolution is a stable public resolver boundary with fixed positional fields.
|
|
354
362
|
export async function resolveAnchoredSymbolTarget(
|
|
355
363
|
file: string,
|
|
356
364
|
line: number,
|
|
357
365
|
character: number,
|
|
358
366
|
provider: AnchoredResolverProvider | null,
|
|
367
|
+
control?: CodeRequestControl,
|
|
359
368
|
): Promise<TargetOutcome> {
|
|
360
369
|
if (!fs.existsSync(file)) {
|
|
361
370
|
return { kind: "error", message: `File not found: \`${file}\`` };
|
|
@@ -369,9 +378,9 @@ export async function resolveAnchoredSymbolTarget(
|
|
|
369
378
|
|
|
370
379
|
const requested: Anchor = { line, character };
|
|
371
380
|
if (provider) {
|
|
372
|
-
const semantic = await resolveFromSemantic(file, requested, provider);
|
|
381
|
+
const semantic = await resolveFromSemantic(file, requested, provider, control);
|
|
373
382
|
if (semantic) return semantic;
|
|
374
|
-
const structural = await resolveFromStructural(file, requested, provider);
|
|
383
|
+
const structural = await resolveFromStructural(file, requested, provider, control);
|
|
375
384
|
if (structural) return structural;
|
|
376
385
|
}
|
|
377
386
|
|
|
@@ -9,12 +9,14 @@
|
|
|
9
9
|
|
|
10
10
|
import * as fs from "node:fs";
|
|
11
11
|
import * as path from "node:path";
|
|
12
|
-
import
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
12
|
+
import {
|
|
13
|
+
type CodeRequestControl,
|
|
14
|
+
type DeclarationNesting,
|
|
15
|
+
type DocumentCodeSymbol,
|
|
16
|
+
isCodeRequestInterruption,
|
|
17
|
+
type OutlineData,
|
|
18
|
+
type SemanticProvider as SemanticSubstrate,
|
|
19
|
+
type StructuralProvider as StructuralSubstrate,
|
|
18
20
|
} from "@mrclrchtr/supi-code-runtime/api";
|
|
19
21
|
import type { AnchorKind } from "../../session/target-store.ts";
|
|
20
22
|
import { normalizePath } from "../search/paths.ts";
|
|
@@ -80,6 +82,7 @@ export async function resolveFileTargetGroup(
|
|
|
80
82
|
semantic?: SemanticSubstrate;
|
|
81
83
|
structural?: StructuralSubstrate;
|
|
82
84
|
} = {},
|
|
85
|
+
control?: CodeRequestControl,
|
|
83
86
|
): Promise<
|
|
84
87
|
| { kind: "resolved"; group: ResolvedTargetGroupData }
|
|
85
88
|
| { kind: "invalid-input"; message: string }
|
|
@@ -90,8 +93,8 @@ export async function resolveFileTargetGroup(
|
|
|
90
93
|
const resolvedFile = validation.file;
|
|
91
94
|
|
|
92
95
|
const [semantic, structural] = await Promise.all([
|
|
93
|
-
discoverSemantic(resolvedFile, deps.semantic, deps.structural),
|
|
94
|
-
discoverStructural(resolvedFile, deps.structural),
|
|
96
|
+
discoverSemantic(resolvedFile, deps.semantic, deps.structural, control),
|
|
97
|
+
discoverStructural(resolvedFile, deps.structural, control),
|
|
95
98
|
]);
|
|
96
99
|
if (!semantic.available && !structural.available) {
|
|
97
100
|
const displayFile = path.relative(cwd, resolvedFile) || file;
|
|
@@ -148,6 +151,7 @@ async function discoverSemantic(
|
|
|
148
151
|
file: string,
|
|
149
152
|
semantic: SemanticSubstrate | undefined,
|
|
150
153
|
structural: StructuralSubstrate | undefined,
|
|
154
|
+
control?: CodeRequestControl,
|
|
151
155
|
): Promise<DiscoveryResult> {
|
|
152
156
|
if (!semantic) return { available: false, targets: [] };
|
|
153
157
|
try {
|
|
@@ -158,12 +162,13 @@ async function discoverSemantic(
|
|
|
158
162
|
targets: await Promise.all(
|
|
159
163
|
result.data.map(async (symbol) => {
|
|
160
164
|
const target = targetFromSymbol(file, symbol);
|
|
161
|
-
const refined = await refineTypeAliasIdentity(target, structural);
|
|
165
|
+
const refined = await refineTypeAliasIdentity(target, structural, control);
|
|
162
166
|
return { ...refined, nesting: target.nesting };
|
|
163
167
|
}),
|
|
164
168
|
),
|
|
165
169
|
};
|
|
166
|
-
} catch {
|
|
170
|
+
} catch (error) {
|
|
171
|
+
if (isCodeRequestInterruption(error, control)) throw error;
|
|
167
172
|
return { available: false, targets: [] };
|
|
168
173
|
}
|
|
169
174
|
}
|
|
@@ -196,13 +201,15 @@ function normalizeNesting(value: unknown): DeclarationNesting {
|
|
|
196
201
|
async function discoverStructural(
|
|
197
202
|
file: string,
|
|
198
203
|
structural: StructuralSubstrate | undefined,
|
|
204
|
+
control?: CodeRequestControl,
|
|
199
205
|
): Promise<DiscoveryResult> {
|
|
200
206
|
if (!structural) return { available: false, targets: [] };
|
|
201
207
|
try {
|
|
202
208
|
const result = await structural.outline(file);
|
|
203
209
|
if (result.kind !== "success") return { available: false, targets: [] };
|
|
204
210
|
return { available: true, targets: flattenOutline(file, result.data) };
|
|
205
|
-
} catch {
|
|
211
|
+
} catch (error) {
|
|
212
|
+
if (isCodeRequestInterruption(error, control)) throw error;
|
|
206
213
|
return { available: false, targets: [] };
|
|
207
214
|
}
|
|
208
215
|
}
|
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
import { resolve } from "node:path";
|
|
2
|
-
import
|
|
2
|
+
import {
|
|
3
|
+
type CodeRequestControl,
|
|
4
|
+
type CodeSymbol,
|
|
5
|
+
isCodeRequestInterruption,
|
|
6
|
+
type StructuralProvider,
|
|
7
|
+
} from "@mrclrchtr/supi-code-runtime/api";
|
|
3
8
|
import type { ResolvedTargetData, TargetOutcome } from "./types.ts";
|
|
4
9
|
|
|
5
10
|
/**
|
|
@@ -45,6 +50,7 @@ export interface DeclarationOccurrenceIdentity extends DeclarationIdentityResult
|
|
|
45
50
|
export async function resolveDeclarationIdentityKind(
|
|
46
51
|
observation: DeclarationIdentityObservation,
|
|
47
52
|
structural: Pick<StructuralProvider, "nodeAt"> | undefined,
|
|
53
|
+
control?: CodeRequestControl,
|
|
48
54
|
): Promise<DeclarationIdentityResult> {
|
|
49
55
|
const identityKind = canonicalDeclarationKind(observation.providerKind);
|
|
50
56
|
if (
|
|
@@ -69,7 +75,8 @@ export async function resolveDeclarationIdentityKind(
|
|
|
69
75
|
return exactNameAnchor && isTypeAlias
|
|
70
76
|
? { identityKind: "type", structuralEvidence: true }
|
|
71
77
|
: { identityKind, structuralEvidence: false };
|
|
72
|
-
} catch {
|
|
78
|
+
} catch (error) {
|
|
79
|
+
if (isCodeRequestInterruption(error, control)) throw error;
|
|
73
80
|
return { identityKind, structuralEvidence: false };
|
|
74
81
|
}
|
|
75
82
|
}
|
|
@@ -82,6 +89,7 @@ export function createCodeSymbolIdentityResolver(
|
|
|
82
89
|
file: string,
|
|
83
90
|
allSymbols: readonly CodeSymbol[],
|
|
84
91
|
structural: Pick<StructuralProvider, "nodeAt"> | undefined,
|
|
92
|
+
control?: CodeRequestControl,
|
|
85
93
|
): (symbol: CodeSymbol) => Promise<DeclarationOccurrenceIdentity> {
|
|
86
94
|
const identities = new Map<CodeSymbol, Promise<DeclarationIdentityResult>>();
|
|
87
95
|
const occurrences = new Map<CodeSymbol, Promise<DeclarationOccurrenceIdentity>>();
|
|
@@ -97,6 +105,7 @@ export function createCodeSymbolIdentityResolver(
|
|
|
97
105
|
nameAnchor: symbol.nameAnchor ?? null,
|
|
98
106
|
},
|
|
99
107
|
structural,
|
|
108
|
+
control,
|
|
100
109
|
);
|
|
101
110
|
identities.set(symbol, identity);
|
|
102
111
|
return identity;
|
|
@@ -147,6 +156,7 @@ function compareCodeSymbolDeclarations(left: CodeSymbol, right: CodeSymbol): num
|
|
|
147
156
|
export async function refineTypeAliasIdentity(
|
|
148
157
|
target: ResolvedTargetData,
|
|
149
158
|
structural: Pick<StructuralProvider, "nodeAt"> | undefined,
|
|
159
|
+
control?: CodeRequestControl,
|
|
150
160
|
): Promise<ResolvedTargetData> {
|
|
151
161
|
if (target.identityKind !== undefined) return target;
|
|
152
162
|
const identity = await resolveDeclarationIdentityKind(
|
|
@@ -160,6 +170,7 @@ export async function refineTypeAliasIdentity(
|
|
|
160
170
|
: null,
|
|
161
171
|
},
|
|
162
172
|
structural,
|
|
173
|
+
control,
|
|
163
174
|
);
|
|
164
175
|
return {
|
|
165
176
|
...target,
|
|
@@ -173,9 +184,13 @@ export async function refineTargetOutcomeIdentity(
|
|
|
173
184
|
outcome: TargetOutcome,
|
|
174
185
|
cwd: string,
|
|
175
186
|
structural: Pick<StructuralProvider, "nodeAt"> | undefined,
|
|
187
|
+
control?: CodeRequestControl,
|
|
176
188
|
): Promise<TargetOutcome> {
|
|
177
189
|
if (outcome.kind === "resolved") {
|
|
178
|
-
return {
|
|
190
|
+
return {
|
|
191
|
+
kind: "resolved",
|
|
192
|
+
target: await refineTypeAliasIdentity(outcome.target, structural, control),
|
|
193
|
+
};
|
|
179
194
|
}
|
|
180
195
|
if (outcome.kind !== "disambiguation" && outcome.kind !== "kind-mismatch") return outcome;
|
|
181
196
|
|
|
@@ -195,6 +210,7 @@ export async function refineTargetOutcomeIdentity(
|
|
|
195
210
|
: null,
|
|
196
211
|
},
|
|
197
212
|
structural,
|
|
213
|
+
control,
|
|
198
214
|
);
|
|
199
215
|
return {
|
|
200
216
|
candidate: {
|