@mrclrchtr/supi-code-intelligence 4.9.0 → 5.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 +2 -1
- 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 +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 -3
- package/node_modules/@mrclrchtr/supi-core/src/debug-timing.ts +34 -21
- package/node_modules/@mrclrchtr/supi-core/src/settings/settings-registry.ts +3 -0
- package/node_modules/@mrclrchtr/supi-lsp/README.md +80 -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 +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 -3
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-core/src/debug-timing.ts +34 -21
- 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 +10 -0
- package/node_modules/@mrclrchtr/supi-lsp/src/client/client-diagnostic-cache.ts +206 -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 +114 -0
- package/node_modules/@mrclrchtr/supi-lsp/src/client/client-diagnostic-evidence.ts +372 -0
- package/node_modules/@mrclrchtr/supi-lsp/src/client/client-diagnostic-host.ts +14 -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 +491 -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 +215 -0
- 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 +370 -266
- package/node_modules/@mrclrchtr/supi-lsp/src/client/client-document-state.ts +52 -0
- package/node_modules/@mrclrchtr/supi-lsp/src/client/client-document-sync.ts +185 -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 +467 -115
- package/node_modules/@mrclrchtr/supi-lsp/src/client/transport.ts +238 -11
- package/node_modules/@mrclrchtr/supi-lsp/src/config/capabilities.ts +10 -1
- package/node_modules/@mrclrchtr/supi-lsp/src/config/defaults.json +1 -1
- package/node_modules/@mrclrchtr/supi-lsp/src/debug-telemetry.ts +45 -0
- package/node_modules/@mrclrchtr/supi-lsp/src/diagnostics/evidence.ts +38 -0
- 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 +13 -4
- package/node_modules/@mrclrchtr/supi-lsp/src/manager/manager-workspace-recovery.ts +300 -24
- package/node_modules/@mrclrchtr/supi-lsp/src/manager/manager-workspace-symbol.ts +5 -2
- package/node_modules/@mrclrchtr/supi-lsp/src/manager/manager.ts +464 -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 +40 -0
- package/node_modules/@mrclrchtr/supi-lsp/src/session/runtime-diagnostics.ts +50 -0
- package/node_modules/@mrclrchtr/supi-lsp/src/session/runtime-registry.ts +136 -120
- 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 +26 -6
- 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 +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 -3
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/src/debug-timing.ts +34 -21
- 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/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 +4 -4
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/web-tree-sitter/package.json +1 -1
- 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 +4 -4
- package/node_modules/@mrclrchtr/supi-tree-sitter/package.json +7 -3
- package/node_modules/@mrclrchtr/supi-tree-sitter/resources/grammars/kotlin/tree-sitter-kotlin.wasm.json +1 -1
- package/node_modules/@mrclrchtr/supi-tree-sitter/resources/grammars/sql/tree-sitter-sql.wasm.json +1 -1
- 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 +236 -24
- package/src/analysis/health/recovery.ts +6 -2
- package/src/analysis/provider.ts +58 -0
- package/src/analysis/readiness.ts +30 -9
- package/src/analysis/refactor/apply.ts +59 -20
- package/src/analysis/refactor/mutation-authority.ts +143 -0
- package/src/analysis/refactor/position.ts +47 -0
- package/src/analysis/refactor/safety.ts +18 -10
- 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 -4
- package/src/analysis/search/ast-scan.ts +1 -1
- package/src/analysis/search/deadline.ts +2 -2
- package/src/analysis/search/pattern-analysis.ts +46 -32
- package/src/analysis/search/pattern.ts +12 -2
- 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/diagnostics/evidence.ts +51 -0
- package/src/session/capability-adapter.ts +12 -3
- package/src/session/find-workflow.ts +17 -7
- package/src/session/graph/collect.ts +18 -2
- package/src/session/graph-workflow.ts +19 -12
- package/src/session/health-refresh.ts +148 -0
- package/src/session/health-types.ts +37 -15
- package/src/session/health-workflow.ts +37 -39
- package/src/session/inspect/collect.ts +20 -3
- package/src/session/inspect-workflow.ts +10 -5
- package/src/session/orientation/collect.ts +10 -1
- 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 +2 -1
- package/src/session/orientation-workflow.ts +15 -8
- package/src/session/refactor-plans.ts +2 -0
- package/src/session/refactor-workflow.ts +59 -14
- package/src/session/session.ts +4 -1
- 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 +199 -25
- package/src/substrate/lsp/state.ts +2 -2
- package/src/substrate/workspace-provider-host.ts +25 -3
- package/src/tool/find/execute.ts +7 -1
- package/src/tool/find/render.ts +20 -3
- package/src/tool/find/tui.ts +23 -21
- package/src/tool/graph/execute.ts +23 -3
- package/src/tool/graph/tui.ts +59 -46
- package/src/tool/health/execute.ts +7 -2
- package/src/tool/health/markdown.ts +56 -14
- package/src/tool/health/refresh-status.ts +105 -0
- package/src/tool/health/tui.ts +95 -98
- package/src/tool/infra/workflow-control.ts +8 -0
- package/src/tool/inspect/execute.ts +7 -1
- package/src/tool/inspect/tui.ts +26 -18
- package/src/tool/orientation/execute.ts +21 -3
- package/src/tool/orientation/tui.ts +51 -35
- package/src/tool/refactor-apply/execute.ts +3 -0
- package/src/tool/refactor-apply/tui.ts +43 -25
- package/src/tool/refactor-plan/execute.ts +4 -0
- package/src/tool/refactor-plan/tui.ts +33 -20
- package/src/tool/register.ts +127 -22
- package/src/tool/resolve/execute.ts +18 -1
- package/src/tool/resolve/tui.ts +42 -24
- package/src/tool/result/display.ts +107 -0
- package/src/tool/result/errors.ts +20 -17
- package/src/tool/result/find.ts +52 -8
- package/src/tool/result/graph.ts +44 -1
- package/src/tool/result/health.ts +53 -1
- package/src/tool/result/inspect.ts +113 -1
- package/src/tool/result/orientation.ts +66 -14
- package/src/tool/result/refactor.ts +36 -4
- package/src/tool/result/resolve.ts +44 -7
- package/src/tool/result/types.ts +20 -0
- 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 -247
|
@@ -4,8 +4,10 @@
|
|
|
4
4
|
* Turns one exact target selector into immutable resolved-target facts before
|
|
5
5
|
* graph, Orientation, resolve, or refactor analysis begins.
|
|
6
6
|
*/
|
|
7
|
-
|
|
7
|
+
// biome-ignore lint/style/noExcessiveLinesPerFile: target workflow keeps anchored, symbol, and file resolution together.
|
|
8
8
|
import { existsSync } from "node:fs";
|
|
9
|
+
import type { CodeRequestControl } from "@mrclrchtr/supi-code-runtime/api";
|
|
10
|
+
import { withSemanticRequestControl, withStructuralRequestControl } from "../analysis/provider.ts";
|
|
9
11
|
import { normalizePath, resolveScope } from "../analysis/search/paths.ts";
|
|
10
12
|
import { resolveAnchoredSymbolTarget } from "../analysis/target/anchored.ts";
|
|
11
13
|
import { resolveFileTargetGroup, validateFileTargetDiscovery } from "../analysis/target/file.ts";
|
|
@@ -87,6 +89,7 @@ export async function resolveTargetWorkflow(
|
|
|
87
89
|
input: TargetInput,
|
|
88
90
|
policy: TargetWorkflowPolicy,
|
|
89
91
|
deps: TargetWorkflowDeps,
|
|
92
|
+
control?: CodeRequestControl,
|
|
90
93
|
): Promise<TargetWorkflowOutcome> {
|
|
91
94
|
const parsed = parseTargetInput(input, ["handle", "anchor", "symbol", "file"]);
|
|
92
95
|
if (parsed.kind === "invalid-input") return parsed;
|
|
@@ -96,10 +99,10 @@ export async function resolveTargetWorkflow(
|
|
|
96
99
|
return resolveHandle(target.handle, policy, deps);
|
|
97
100
|
}
|
|
98
101
|
if ("anchor" in target) {
|
|
99
|
-
return resolveAnchoredWorkflow(target.anchor, policy, deps);
|
|
102
|
+
return resolveAnchoredWorkflow(target.anchor, policy, deps, control);
|
|
100
103
|
}
|
|
101
104
|
if ("symbol" in target) {
|
|
102
|
-
return resolveSymbolWorkflow(target.symbol, policy, deps);
|
|
105
|
+
return resolveSymbolWorkflow(target.symbol, policy, deps, control);
|
|
103
106
|
}
|
|
104
107
|
if (!policy.fileLevelAllowed) {
|
|
105
108
|
return {
|
|
@@ -107,7 +110,7 @@ export async function resolveTargetWorkflow(
|
|
|
107
110
|
message: "This workflow requires a handle, anchored point, or symbol target.",
|
|
108
111
|
};
|
|
109
112
|
}
|
|
110
|
-
return resolveFileOnlyWorkflow(target.file, policy.maxResults ?? 10, deps);
|
|
113
|
+
return resolveFileOnlyWorkflow(target.file, policy.maxResults ?? 10, deps, control);
|
|
111
114
|
}
|
|
112
115
|
|
|
113
116
|
function resolveHandle(
|
|
@@ -134,16 +137,18 @@ async function resolveAnchoredWorkflow(
|
|
|
134
137
|
anchor: { file: string; line: number; character: number },
|
|
135
138
|
policy: TargetWorkflowPolicy,
|
|
136
139
|
deps: TargetWorkflowDeps,
|
|
140
|
+
control?: CodeRequestControl,
|
|
137
141
|
): Promise<TargetWorkflowOutcome> {
|
|
138
142
|
const file = normalizePath(anchor.file, deps.cwd);
|
|
139
143
|
if (!existsSync(file)) {
|
|
140
144
|
return { kind: "invalid-input", message: `File not found: \`${anchor.file}\`` };
|
|
141
145
|
}
|
|
142
146
|
|
|
143
|
-
const readiness = await deps.capability.ensureSemanticReadiness(
|
|
144
|
-
|
|
145
|
-
file,
|
|
146
|
-
|
|
147
|
+
const readiness = await deps.capability.ensureSemanticReadiness(
|
|
148
|
+
deps.cwd,
|
|
149
|
+
{ kind: "file", file },
|
|
150
|
+
control,
|
|
151
|
+
);
|
|
147
152
|
if (readiness.kind === "timeout") {
|
|
148
153
|
return {
|
|
149
154
|
kind: "unavailable",
|
|
@@ -158,13 +163,19 @@ async function resolveAnchoredWorkflow(
|
|
|
158
163
|
file,
|
|
159
164
|
anchor.line,
|
|
160
165
|
anchor.character,
|
|
161
|
-
|
|
166
|
+
withSemanticRequestControl(
|
|
167
|
+
withStructuralRequestControl(deps.capability.getProvider(deps.cwd), control),
|
|
168
|
+
control,
|
|
169
|
+
),
|
|
170
|
+
control,
|
|
162
171
|
);
|
|
163
172
|
return toWorkflowOutcome(
|
|
164
173
|
await refineTargetOutcomeIdentity(
|
|
165
174
|
outcome,
|
|
166
175
|
deps.cwd,
|
|
167
|
-
deps.capability.getStructuralProvider(deps.cwd) ??
|
|
176
|
+
withStructuralRequestControl(deps.capability.getStructuralProvider(deps.cwd), control) ??
|
|
177
|
+
undefined,
|
|
178
|
+
control,
|
|
168
179
|
),
|
|
169
180
|
policy,
|
|
170
181
|
deps,
|
|
@@ -175,6 +186,7 @@ async function resolveSymbolWorkflow(
|
|
|
175
186
|
symbol: { query: string; scope?: string; symbolKind?: TargetSymbolKind },
|
|
176
187
|
policy: TargetWorkflowPolicy,
|
|
177
188
|
deps: TargetWorkflowDeps,
|
|
189
|
+
control?: CodeRequestControl,
|
|
178
190
|
): Promise<TargetWorkflowOutcome> {
|
|
179
191
|
if (!symbol.query.trim()) {
|
|
180
192
|
return { kind: "invalid-input", message: "Symbol query must not be empty." };
|
|
@@ -189,9 +201,11 @@ async function resolveSymbolWorkflow(
|
|
|
189
201
|
scope = resolved.path;
|
|
190
202
|
}
|
|
191
203
|
|
|
192
|
-
const readiness = await deps.capability.ensureSemanticReadiness(
|
|
193
|
-
|
|
194
|
-
|
|
204
|
+
const readiness = await deps.capability.ensureSemanticReadiness(
|
|
205
|
+
deps.cwd,
|
|
206
|
+
{ kind: "workspace" },
|
|
207
|
+
control,
|
|
208
|
+
);
|
|
195
209
|
if (readiness.kind === "timeout") {
|
|
196
210
|
return { kind: "unavailable", reason: "LSP readiness timed out. Retry shortly." };
|
|
197
211
|
}
|
|
@@ -199,7 +213,10 @@ async function resolveSymbolWorkflow(
|
|
|
199
213
|
return { kind: "unavailable", reason: readiness.reason };
|
|
200
214
|
}
|
|
201
215
|
|
|
202
|
-
const provider =
|
|
216
|
+
const provider = withSemanticRequestControl(
|
|
217
|
+
deps.capability.getSemanticProvider(deps.cwd),
|
|
218
|
+
control,
|
|
219
|
+
);
|
|
203
220
|
if (!provider) {
|
|
204
221
|
return {
|
|
205
222
|
kind: "unavailable",
|
|
@@ -211,12 +228,15 @@ async function resolveSymbolWorkflow(
|
|
|
211
228
|
path: scope,
|
|
212
229
|
kind: symbol.symbolKind,
|
|
213
230
|
maxResults: policy.maxResults,
|
|
231
|
+
control,
|
|
214
232
|
});
|
|
215
233
|
return toWorkflowOutcome(
|
|
216
234
|
await refineTargetOutcomeIdentity(
|
|
217
235
|
outcome,
|
|
218
236
|
deps.cwd,
|
|
219
|
-
deps.capability.getStructuralProvider(deps.cwd) ??
|
|
237
|
+
withStructuralRequestControl(deps.capability.getStructuralProvider(deps.cwd), control) ??
|
|
238
|
+
undefined,
|
|
239
|
+
control,
|
|
220
240
|
),
|
|
221
241
|
policy,
|
|
222
242
|
deps,
|
|
@@ -227,15 +247,17 @@ async function resolveFileOnlyWorkflow(
|
|
|
227
247
|
requestedFile: string,
|
|
228
248
|
maxResults: number,
|
|
229
249
|
deps: TargetWorkflowDeps,
|
|
250
|
+
control?: CodeRequestControl,
|
|
230
251
|
): Promise<TargetWorkflowOutcome> {
|
|
231
252
|
const validation = validateFileTargetDiscovery(requestedFile, deps.cwd);
|
|
232
253
|
if (validation.kind === "invalid-input") return validation;
|
|
233
254
|
const file = validation.file;
|
|
234
255
|
|
|
235
|
-
const readiness = await deps.capability.ensureSemanticReadiness(
|
|
236
|
-
|
|
237
|
-
file,
|
|
238
|
-
|
|
256
|
+
const readiness = await deps.capability.ensureSemanticReadiness(
|
|
257
|
+
deps.cwd,
|
|
258
|
+
{ kind: "file", file },
|
|
259
|
+
control,
|
|
260
|
+
);
|
|
239
261
|
if (readiness.kind === "timeout") {
|
|
240
262
|
return { kind: "unavailable", reason: "LSP readiness timed out. Retry shortly." };
|
|
241
263
|
}
|
|
@@ -243,10 +265,19 @@ async function resolveFileOnlyWorkflow(
|
|
|
243
265
|
return { kind: "unavailable", reason: readiness.reason };
|
|
244
266
|
}
|
|
245
267
|
|
|
246
|
-
const result = await resolveFileTargetGroup(
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
268
|
+
const result = await resolveFileTargetGroup(
|
|
269
|
+
file,
|
|
270
|
+
deps.cwd,
|
|
271
|
+
{
|
|
272
|
+
semantic:
|
|
273
|
+
withSemanticRequestControl(deps.capability.getSemanticProvider(deps.cwd), control) ??
|
|
274
|
+
undefined,
|
|
275
|
+
structural:
|
|
276
|
+
withStructuralRequestControl(deps.capability.getStructuralProvider(deps.cwd), control) ??
|
|
277
|
+
undefined,
|
|
278
|
+
},
|
|
279
|
+
control,
|
|
280
|
+
);
|
|
250
281
|
if (result.kind === "invalid-input") return result;
|
|
251
282
|
if (result.kind === "unavailable") {
|
|
252
283
|
return { kind: "unavailable", reason: result.message };
|
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
import {
|
|
2
|
+
type CodeRequestControl,
|
|
3
|
+
throwIfCodeRequestInterrupted,
|
|
4
|
+
} from "@mrclrchtr/supi-code-runtime/api";
|
|
5
|
+
|
|
1
6
|
/** Execution controls shared by Workspace code-intelligence session workflows. */
|
|
2
7
|
|
|
3
8
|
/** Stable progress event emitted by a session-owned workflow. */
|
|
@@ -16,8 +21,7 @@ export interface WorkflowProgressEvent {
|
|
|
16
21
|
}
|
|
17
22
|
|
|
18
23
|
/** Per-call cancellation and progress controls. */
|
|
19
|
-
export interface WorkflowControl {
|
|
20
|
-
readonly signal?: AbortSignal;
|
|
24
|
+
export interface WorkflowControl extends CodeRequestControl {
|
|
21
25
|
readonly progress?: (event: WorkflowProgressEvent) => void;
|
|
22
26
|
}
|
|
23
27
|
|
|
@@ -31,5 +35,5 @@ export function reportProgress(
|
|
|
31
35
|
|
|
32
36
|
/** Throw the platform-standard cancellation reason before starting a phase. */
|
|
33
37
|
export function throwIfAborted(control: WorkflowControl | undefined): void {
|
|
34
|
-
control
|
|
38
|
+
throwIfCodeRequestInterrupted(control);
|
|
35
39
|
}
|
|
@@ -4,66 +4,49 @@ import type { ExtensionAPI, ExtensionContext } from "@earendil-works/pi-coding-a
|
|
|
4
4
|
import { acquireWorkspaceProviderHost } from "../workspace-provider-host.ts";
|
|
5
5
|
import { LSP_STATE_CHANGE_EVENT, type LspAdapterState } from "./state.ts";
|
|
6
6
|
|
|
7
|
-
const STATE_CHANGE_EVENT = new Event(LSP_STATE_CHANGE_EVENT);
|
|
8
|
-
|
|
9
|
-
/** Poll interval (ms) for detecting server readiness transitions in the footer. */
|
|
10
|
-
const READINESS_POLL_MS = 2_000;
|
|
11
|
-
|
|
12
7
|
/** Acquire providers once per workspace and release them after the final Pi session ends. */
|
|
13
8
|
export function registerLspSessionLifecycle(
|
|
14
9
|
pi: ExtensionAPI,
|
|
15
10
|
state: LspAdapterState,
|
|
16
11
|
onStarted?: (ctx: ExtensionContext) => void | Promise<void>,
|
|
17
12
|
): void {
|
|
18
|
-
let
|
|
19
|
-
let
|
|
13
|
+
let disposeLifecycle: (() => void) | null = null;
|
|
14
|
+
let subscriptionGeneration = 0;
|
|
20
15
|
|
|
21
|
-
function
|
|
22
|
-
|
|
23
|
-
if (!servers) return "";
|
|
24
|
-
let ready = 0;
|
|
25
|
-
let starting = 0;
|
|
26
|
-
let error = 0;
|
|
27
|
-
let unavailable = 0;
|
|
28
|
-
let openFiles = 0;
|
|
29
|
-
for (const s of servers) {
|
|
30
|
-
openFiles += s.openFiles.length;
|
|
31
|
-
if (s.status === "running" && s.ready) ready++;
|
|
32
|
-
else if (s.status === "running") starting++;
|
|
33
|
-
else if (s.status === "error") error++;
|
|
34
|
-
else unavailable++;
|
|
35
|
-
}
|
|
36
|
-
return `${ready}:${starting}:${error}:${unavailable}:${openFiles}`;
|
|
16
|
+
function dispatchStateChange(): void {
|
|
17
|
+
state.stateChanges.dispatchEvent(new Event(LSP_STATE_CHANGE_EVENT));
|
|
37
18
|
}
|
|
38
19
|
|
|
39
|
-
function
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
if (state.controller?.kind !== "ready") return;
|
|
44
|
-
const current = fingerprint();
|
|
45
|
-
if (current === lastFingerprint) return;
|
|
46
|
-
lastFingerprint = current;
|
|
47
|
-
state.stateChanges.dispatchEvent(STATE_CHANGE_EVENT);
|
|
48
|
-
}, READINESS_POLL_MS);
|
|
49
|
-
readinessTimer.unref?.();
|
|
20
|
+
function stopLifecycleSubscription(): void {
|
|
21
|
+
subscriptionGeneration++;
|
|
22
|
+
disposeLifecycle?.();
|
|
23
|
+
disposeLifecycle = null;
|
|
50
24
|
}
|
|
51
25
|
|
|
52
|
-
function
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
26
|
+
function startLifecycleSubscription(): void {
|
|
27
|
+
stopLifecycleSubscription();
|
|
28
|
+
const controller = state.controller;
|
|
29
|
+
if (!controller) {
|
|
30
|
+
dispatchStateChange();
|
|
31
|
+
return;
|
|
56
32
|
}
|
|
57
|
-
|
|
33
|
+
const generation = subscriptionGeneration;
|
|
34
|
+
let receivedInitialTransition = false;
|
|
35
|
+
disposeLifecycle = controller.subscribeLifecycle(() => {
|
|
36
|
+
if (generation !== subscriptionGeneration) return;
|
|
37
|
+
receivedInitialTransition = true;
|
|
38
|
+
dispatchStateChange();
|
|
39
|
+
});
|
|
40
|
+
if (!receivedInitialTransition) dispatchStateChange();
|
|
58
41
|
}
|
|
59
42
|
|
|
60
43
|
pi.on("session_start", async (_event, ctx: ExtensionContext) => {
|
|
44
|
+
stopLifecycleSubscription();
|
|
61
45
|
await state.providerLease?.release();
|
|
62
46
|
state.providerLease = null;
|
|
63
47
|
state.controller = null;
|
|
64
48
|
state.lspActive = false;
|
|
65
49
|
state.sentinelSnapshot = new Map();
|
|
66
|
-
stopReadinessPolling();
|
|
67
50
|
|
|
68
51
|
const lease = await acquireWorkspaceProviderHost(ctx.cwd, {
|
|
69
52
|
projectTrusted: ctx.isProjectTrusted(),
|
|
@@ -73,19 +56,16 @@ export function registerLspSessionLifecycle(
|
|
|
73
56
|
state.lspActive = lease.lspController?.kind === "ready";
|
|
74
57
|
state.sentinelSnapshot = lease.sentinelSnapshot;
|
|
75
58
|
await onStarted?.(ctx);
|
|
76
|
-
|
|
77
|
-
// Dispatch initial server list so the footer shows starting servers immediately.
|
|
78
|
-
state.stateChanges.dispatchEvent(STATE_CHANGE_EVENT);
|
|
79
|
-
// Poll for readiness transitions (running → ready, errors, etc.).
|
|
80
|
-
startReadinessPolling();
|
|
59
|
+
startLifecycleSubscription();
|
|
81
60
|
});
|
|
82
61
|
|
|
83
62
|
pi.on("session_shutdown", async () => {
|
|
84
|
-
|
|
63
|
+
stopLifecycleSubscription();
|
|
85
64
|
await state.providerLease?.release();
|
|
86
65
|
state.providerLease = null;
|
|
87
66
|
state.controller = null;
|
|
88
67
|
state.lspActive = false;
|
|
89
68
|
state.sentinelSnapshot = new Map();
|
|
69
|
+
dispatchStateChange();
|
|
90
70
|
});
|
|
91
71
|
}
|
|
@@ -6,70 +6,244 @@
|
|
|
6
6
|
* semantic tool queries.
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
+
import { statSync } from "node:fs";
|
|
9
10
|
import * as nodePath from "node:path";
|
|
10
|
-
import
|
|
11
|
+
import {
|
|
12
|
+
type CodeRequestControl,
|
|
13
|
+
isCodeRequestInterruption,
|
|
14
|
+
throwIfCodeRequestInterrupted,
|
|
15
|
+
} from "@mrclrchtr/supi-code-runtime/api";
|
|
16
|
+
import type { DiagnosticEvidenceSummary } from "@mrclrchtr/supi-lsp/api";
|
|
11
17
|
import {
|
|
12
18
|
clearTsconfigCache,
|
|
13
19
|
isLikelyStaleDiagnostic,
|
|
20
|
+
raceRequestControl,
|
|
14
21
|
syncWorkspaceSentinelSnapshot,
|
|
22
|
+
type WorkspaceLspRuntime,
|
|
15
23
|
} from "@mrclrchtr/supi-lsp/api";
|
|
24
|
+
import { mergeDiagnosticEvidence } from "../../diagnostics/evidence.ts";
|
|
16
25
|
|
|
17
26
|
/**
|
|
18
|
-
* Run sentinel-sync, stale-module resync
|
|
19
|
-
*
|
|
20
|
-
*
|
|
27
|
+
* Run sentinel-sync, diagnostic refresh, and stale-module resync as a single
|
|
28
|
+
* maintenance pass. Call before explicit diagnostic queries (code_health with
|
|
29
|
+
* refresh:true) or semantic tool readiness checks.
|
|
21
30
|
*/
|
|
22
31
|
export async function refreshLspMaintenance(
|
|
23
32
|
runtime: WorkspaceLspRuntime,
|
|
24
33
|
cwd: string,
|
|
25
34
|
sentinelSnapshot: Map<string, number>,
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
35
|
+
control?: CodeRequestControl,
|
|
36
|
+
): Promise<WorkspaceLspMaintenanceResult> {
|
|
37
|
+
const { snapshot } = synchronizeSentinels(runtime, cwd, sentinelSnapshot);
|
|
38
|
+
let diagnosticEvidence = emptyEvidence();
|
|
39
|
+
let failureReason: string | undefined;
|
|
30
40
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
41
|
+
// Refresh before stale-module inspection. The refresh owns deleted-file
|
|
42
|
+
// classification; later snapshots must not erase its removed evidence.
|
|
43
|
+
try {
|
|
44
|
+
diagnosticEvidence = await runtime.refreshOpenDiagnostics(undefined, control);
|
|
45
|
+
} catch (error) {
|
|
46
|
+
if (isCodeRequestInterruption(error, control)) throw error;
|
|
47
|
+
failureReason = errorMessage(error);
|
|
48
|
+
diagnosticEvidence = readRuntimeEvidence(runtime);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
try {
|
|
52
|
+
const staleResult = await resyncStaleModuleFiles(runtime, cwd, control);
|
|
53
|
+
diagnosticEvidence = mergeDiagnosticEvidence(diagnosticEvidence, staleResult.evidence, cwd);
|
|
54
|
+
if (staleResult.completed) failureReason = undefined;
|
|
55
|
+
} catch (error) {
|
|
56
|
+
if (isCodeRequestInterruption(error, control)) throw error;
|
|
57
|
+
// Keep evidence from the first refresh when stale inspection fails.
|
|
34
58
|
}
|
|
35
59
|
|
|
36
|
-
|
|
37
|
-
|
|
60
|
+
return {
|
|
61
|
+
snapshot,
|
|
62
|
+
diagnosticEvidence,
|
|
63
|
+
...(failureReason ? { failureReason } : {}),
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/** Sentinel state and diagnostic evidence retained from one workspace pass. */
|
|
68
|
+
export interface WorkspaceLspMaintenanceResult {
|
|
69
|
+
/** The next sentinel snapshot for the session-owned maintenance state. */
|
|
70
|
+
snapshot: Map<string, number>;
|
|
71
|
+
/** Evidence from every diagnostic refresh performed by this pass. */
|
|
72
|
+
diagnosticEvidence: DiagnosticEvidenceSummary;
|
|
73
|
+
/** Failure from the first workspace refresh, when no fresh pass completed. */
|
|
74
|
+
failureReason?: string;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/** Sentinel state and stale-file facts from one file-scoped pass. */
|
|
78
|
+
export interface FileLspMaintenanceResult {
|
|
79
|
+
/** The next sentinel snapshot for the session-owned maintenance state. */
|
|
80
|
+
snapshot: Map<string, number>;
|
|
81
|
+
/** Number of stale files that matched the requested file. */
|
|
82
|
+
matchedStaleFileCount: number;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/** Refresh sentinel and stale-module state for one exact file without a workspace resync. */
|
|
86
|
+
export async function refreshFileLspMaintenance(options: {
|
|
87
|
+
runtime: WorkspaceLspRuntime;
|
|
88
|
+
cwd: string;
|
|
89
|
+
sentinelSnapshot: Map<string, number>;
|
|
90
|
+
filePath: string;
|
|
91
|
+
control?: CodeRequestControl;
|
|
92
|
+
}): Promise<FileLspMaintenanceResult> {
|
|
93
|
+
const { runtime, cwd, sentinelSnapshot, filePath, control } = options;
|
|
94
|
+
// A cancelled caller stops before any maintenance work starts.
|
|
95
|
+
throwIfCodeRequestInterrupted(control);
|
|
96
|
+
const { snapshot } = synchronizeSentinels(runtime, cwd, sentinelSnapshot);
|
|
97
|
+
const target = nodePath.resolve(filePath);
|
|
98
|
+
const stale = runtime
|
|
99
|
+
.getOutstandingDiagnostics(1)
|
|
100
|
+
.entries.some(
|
|
101
|
+
(entry) =>
|
|
102
|
+
nodePath.resolve(cwd, entry.file) === target &&
|
|
103
|
+
entry.diagnostics.some((diagnostic) => isLikelyStaleDiagnostic(diagnostic)),
|
|
104
|
+
);
|
|
38
105
|
|
|
39
|
-
// Two-pass prune/refresh for diagnostics
|
|
40
106
|
runtime.pruneMissingFiles();
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
107
|
+
if (stale) {
|
|
108
|
+
runtime.closeFile(target);
|
|
109
|
+
// Race the caller's cancellation so a client start during re-open does
|
|
110
|
+
// not outlive the caller; the underlying runtime keeps its own lifecycle.
|
|
111
|
+
await raceRequestControl(runtime.trackFile(target), control);
|
|
45
112
|
}
|
|
46
113
|
runtime.pruneMissingFiles();
|
|
114
|
+
throwIfCodeRequestInterrupted(control);
|
|
47
115
|
|
|
48
|
-
return snapshot;
|
|
116
|
+
return { snapshot, matchedStaleFileCount: stale ? 1 : 0 };
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
function synchronizeSentinels(
|
|
120
|
+
runtime: WorkspaceLspRuntime,
|
|
121
|
+
cwd: string,
|
|
122
|
+
sentinelSnapshot: Map<string, number>,
|
|
123
|
+
) {
|
|
124
|
+
const state = syncWorkspaceSentinelSnapshot(cwd, sentinelSnapshot);
|
|
125
|
+
if (state.changes.length > 0) {
|
|
126
|
+
clearTsconfigCache();
|
|
127
|
+
runtime.noteWorkspaceChanges(state.changes);
|
|
128
|
+
}
|
|
129
|
+
return state;
|
|
49
130
|
}
|
|
50
131
|
|
|
51
132
|
/** Re-open files with stale module-resolution errors. */
|
|
52
|
-
async function resyncStaleModuleFiles(
|
|
133
|
+
async function resyncStaleModuleFiles(
|
|
134
|
+
runtime: WorkspaceLspRuntime,
|
|
135
|
+
cwd: string,
|
|
136
|
+
control?: CodeRequestControl,
|
|
137
|
+
): Promise<{ evidence: DiagnosticEvidenceSummary; completed: boolean }> {
|
|
53
138
|
const outstanding = runtime.getOutstandingDiagnostics(1);
|
|
54
139
|
const staleFiles: string[] = [];
|
|
55
140
|
|
|
56
|
-
for (const entry of outstanding) {
|
|
141
|
+
for (const entry of outstanding.entries) {
|
|
57
142
|
if (entry.diagnostics.some((d) => isLikelyStaleDiagnostic(d))) {
|
|
58
143
|
staleFiles.push(entry.file);
|
|
59
144
|
}
|
|
60
145
|
}
|
|
61
146
|
|
|
62
|
-
if (staleFiles.length === 0) return;
|
|
147
|
+
if (staleFiles.length === 0) return { evidence: emptyEvidence(), completed: false };
|
|
63
148
|
|
|
149
|
+
const invalidated: Array<{
|
|
150
|
+
file: string;
|
|
151
|
+
status: "unconfirmed" | "failed" | "removed";
|
|
152
|
+
}> = staleFiles.map((file) => ({
|
|
153
|
+
file: nodePath.relative(cwd, nodePath.resolve(cwd, file)),
|
|
154
|
+
status: "unconfirmed",
|
|
155
|
+
}));
|
|
64
156
|
for (const file of staleFiles) {
|
|
65
157
|
const filePath = nodePath.resolve(cwd, file);
|
|
158
|
+
const relativeFile = nodePath.relative(cwd, filePath);
|
|
66
159
|
runtime.closeFile(filePath);
|
|
67
|
-
|
|
160
|
+
try {
|
|
161
|
+
if (!(await runtime.trackFile(filePath))) {
|
|
162
|
+
markUnavailable(invalidated, relativeFile, filePath);
|
|
163
|
+
}
|
|
164
|
+
} catch (error) {
|
|
165
|
+
if (isCodeRequestInterruption(error, control)) throw error;
|
|
166
|
+
markUnavailable(invalidated, relativeFile, filePath);
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
try {
|
|
171
|
+
return {
|
|
172
|
+
evidence: mergeDiagnosticEvidence(
|
|
173
|
+
{
|
|
174
|
+
requested: invalidated.length,
|
|
175
|
+
confirmed: 0,
|
|
176
|
+
unconfirmed: invalidated.length,
|
|
177
|
+
failed: 0,
|
|
178
|
+
removed: 0,
|
|
179
|
+
documents: invalidated,
|
|
180
|
+
},
|
|
181
|
+
await runtime.refreshOpenDiagnostics({ quietMs: 300, maxWaitMs: 2000 }, control),
|
|
182
|
+
cwd,
|
|
183
|
+
),
|
|
184
|
+
completed: true,
|
|
185
|
+
};
|
|
186
|
+
} catch (error) {
|
|
187
|
+
if (isCodeRequestInterruption(error, control)) throw error;
|
|
188
|
+
return {
|
|
189
|
+
evidence: {
|
|
190
|
+
requested: invalidated.length,
|
|
191
|
+
confirmed: 0,
|
|
192
|
+
unconfirmed: invalidated.filter((document) => document.status === "unconfirmed").length,
|
|
193
|
+
failed: invalidated.filter((document) => document.status === "failed").length,
|
|
194
|
+
removed: invalidated.filter((document) => document.status === "removed").length,
|
|
195
|
+
documents: invalidated,
|
|
196
|
+
},
|
|
197
|
+
completed: false,
|
|
198
|
+
};
|
|
68
199
|
}
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
function markUnavailable(
|
|
203
|
+
documents: Array<{ file: string; status: "unconfirmed" | "failed" | "removed" }>,
|
|
204
|
+
file: string,
|
|
205
|
+
filePath: string,
|
|
206
|
+
): void {
|
|
207
|
+
const entry = documents.find((document) => document.file === file);
|
|
208
|
+
if (entry) entry.status = diagnosticFailureStatus(filePath);
|
|
209
|
+
}
|
|
69
210
|
|
|
211
|
+
function diagnosticFailureStatus(filePath: string): "failed" | "removed" {
|
|
70
212
|
try {
|
|
71
|
-
|
|
213
|
+
statSync(filePath);
|
|
214
|
+
return "failed";
|
|
215
|
+
} catch (error) {
|
|
216
|
+
if (
|
|
217
|
+
typeof error === "object" &&
|
|
218
|
+
error !== null &&
|
|
219
|
+
"code" in error &&
|
|
220
|
+
(error.code === "ENOENT" || error.code === "ENOTDIR")
|
|
221
|
+
) {
|
|
222
|
+
return "removed";
|
|
223
|
+
}
|
|
224
|
+
return "failed";
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
function readRuntimeEvidence(runtime: WorkspaceLspRuntime): DiagnosticEvidenceSummary {
|
|
229
|
+
try {
|
|
230
|
+
return runtime.getWorkspaceDiagnosticSummary().evidence;
|
|
72
231
|
} catch {
|
|
73
|
-
|
|
232
|
+
return emptyEvidence();
|
|
74
233
|
}
|
|
75
234
|
}
|
|
235
|
+
|
|
236
|
+
function errorMessage(error: unknown): string {
|
|
237
|
+
return error instanceof Error && error.message ? error.message : "Diagnostic refresh failed.";
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
function emptyEvidence(): DiagnosticEvidenceSummary {
|
|
241
|
+
return {
|
|
242
|
+
requested: 0,
|
|
243
|
+
confirmed: 0,
|
|
244
|
+
unconfirmed: 0,
|
|
245
|
+
failed: 0,
|
|
246
|
+
removed: 0,
|
|
247
|
+
documents: [],
|
|
248
|
+
};
|
|
249
|
+
}
|
|
@@ -25,7 +25,7 @@ export interface LspAdapterState {
|
|
|
25
25
|
lspActive: boolean;
|
|
26
26
|
/** Snapshot of workspace sentinel files (package.json, tsconfig, lockfiles) for change detection. */
|
|
27
27
|
sentinelSnapshot: Map<string, number>;
|
|
28
|
-
/** Fired
|
|
28
|
+
/** Fired for runtime lifecycle changes that require a footer render. */
|
|
29
29
|
stateChanges: EventTarget;
|
|
30
30
|
}
|
|
31
31
|
|
|
@@ -40,5 +40,5 @@ export function createLspAdapterState(): LspAdapterState {
|
|
|
40
40
|
};
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
-
/** Event type dispatched on {@link LspAdapterState.stateChanges}
|
|
43
|
+
/** Event type dispatched on {@link LspAdapterState.stateChanges} for LSP lifecycle changes. */
|
|
44
44
|
export const LSP_STATE_CHANGE_EVENT = "server-status-changed" as const;
|
|
@@ -5,9 +5,11 @@ import { LspRuntimeController, scanWorkspaceSentinels } from "@mrclrchtr/supi-ls
|
|
|
5
5
|
import { TreeSitterRuntimeController } from "@mrclrchtr/supi-tree-sitter/api";
|
|
6
6
|
|
|
7
7
|
const HOSTS = Symbol.for("supi-code-intelligence/workspace-provider-hosts");
|
|
8
|
+
const CLOSING_HOSTS = Symbol.for("supi-code-intelligence/closing-workspace-provider-hosts");
|
|
8
9
|
const SHUTDOWN_GRACE_MS = 2_000;
|
|
9
10
|
|
|
10
11
|
type HostRegistry = Map<string, WorkspaceProviderHost>;
|
|
12
|
+
type ClosingHostRegistry = Map<string, Promise<void>>;
|
|
11
13
|
|
|
12
14
|
/** One acquired reference to a process-shared Workspace provider host. */
|
|
13
15
|
export interface WorkspaceProviderHostLease {
|
|
@@ -23,6 +25,12 @@ function registry(): HostRegistry {
|
|
|
23
25
|
return global[HOSTS];
|
|
24
26
|
}
|
|
25
27
|
|
|
28
|
+
function closingRegistry(): ClosingHostRegistry {
|
|
29
|
+
const global = globalThis as typeof globalThis & { [CLOSING_HOSTS]?: ClosingHostRegistry };
|
|
30
|
+
global[CLOSING_HOSTS] ??= new Map();
|
|
31
|
+
return global[CLOSING_HOSTS];
|
|
32
|
+
}
|
|
33
|
+
|
|
26
34
|
function canonicalWorkspace(cwd: string): string {
|
|
27
35
|
try {
|
|
28
36
|
return realpathSync(cwd);
|
|
@@ -76,8 +84,16 @@ class WorkspaceProviderHost {
|
|
|
76
84
|
released = true;
|
|
77
85
|
this.#leases--;
|
|
78
86
|
if (this.#leases === 0) {
|
|
79
|
-
|
|
80
|
-
|
|
87
|
+
await Promise.resolve();
|
|
88
|
+
if (this.#leases !== 0) return;
|
|
89
|
+
const shutdown = this.#shutdown();
|
|
90
|
+
closingRegistry().set(this.cwd, shutdown);
|
|
91
|
+
try {
|
|
92
|
+
await shutdown;
|
|
93
|
+
} finally {
|
|
94
|
+
if (closingRegistry().get(this.cwd) === shutdown) closingRegistry().delete(this.cwd);
|
|
95
|
+
registry().delete(this.cwd);
|
|
96
|
+
}
|
|
81
97
|
}
|
|
82
98
|
},
|
|
83
99
|
};
|
|
@@ -101,7 +117,7 @@ class WorkspaceProviderHost {
|
|
|
101
117
|
this.#closed = true;
|
|
102
118
|
await Promise.all([
|
|
103
119
|
...(this.#lsp ? [settleWithin(this.#lsp.shutdown())] : []),
|
|
104
|
-
...(this.#tree ? [
|
|
120
|
+
...(this.#tree ? [this.#tree.shutdown()] : []),
|
|
105
121
|
]);
|
|
106
122
|
this.#lsp = null;
|
|
107
123
|
this.#tree = null;
|
|
@@ -114,6 +130,11 @@ export async function acquireWorkspaceProviderHost(
|
|
|
114
130
|
options: { projectTrusted: boolean },
|
|
115
131
|
): Promise<WorkspaceProviderHostLease> {
|
|
116
132
|
const workspace = canonicalWorkspace(cwd);
|
|
133
|
+
for (;;) {
|
|
134
|
+
const closing = closingRegistry().get(workspace);
|
|
135
|
+
if (!closing) break;
|
|
136
|
+
await closing.catch(() => undefined);
|
|
137
|
+
}
|
|
117
138
|
const hosts = registry();
|
|
118
139
|
let host = hosts.get(workspace);
|
|
119
140
|
if (!host) {
|
|
@@ -126,4 +147,5 @@ export async function acquireWorkspaceProviderHost(
|
|
|
126
147
|
/** Clear process-shared hosts between isolated tests. */
|
|
127
148
|
export function resetWorkspaceProviderHostsForTests(): void {
|
|
128
149
|
registry().clear();
|
|
150
|
+
closingRegistry().clear();
|
|
129
151
|
}
|