@mrclrchtr/supi-code-intelligence 11.1.0 → 11.2.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 +29 -4
- package/node_modules/@mrclrchtr/supi-code-runtime/package.json +1 -1
- package/node_modules/@mrclrchtr/supi-core/package.json +1 -1
- package/node_modules/@mrclrchtr/supi-lsp/README.md +42 -5
- 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-core/package.json +1 -1
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/LICENSE +15 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/README.md +680 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/bin/semver.js +195 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/classes/comparator.js +143 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/classes/index.js +7 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/classes/range.js +577 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/classes/semver.js +350 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/functions/clean.js +8 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/functions/cmp.js +54 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/functions/coerce.js +62 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/functions/compare-build.js +9 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/functions/compare-loose.js +5 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/functions/compare.js +7 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/functions/diff.js +60 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/functions/eq.js +5 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/functions/gt.js +5 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/functions/gte.js +5 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/functions/inc.js +21 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/functions/lt.js +5 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/functions/lte.js +5 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/functions/major.js +5 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/functions/minor.js +5 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/functions/neq.js +5 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/functions/parse.js +18 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/functions/patch.js +5 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/functions/prerelease.js +8 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/functions/rcompare.js +5 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/functions/rsort.js +5 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/functions/satisfies.js +12 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/functions/sort.js +5 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/functions/truncate.js +48 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/functions/valid.js +8 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/index.js +93 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/internal/constants.js +37 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/internal/debug.js +11 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/internal/identifiers.js +29 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/internal/lrucache.js +42 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/internal/parse-options.js +17 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/internal/re.js +223 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/package.json +78 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/preload.js +4 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/range.bnf +17 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/ranges/gtr.js +6 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/ranges/intersects.js +9 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/ranges/ltr.js +6 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/ranges/max-satisfying.js +27 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/ranges/min-satisfying.js +26 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/ranges/min-version.js +63 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/ranges/outside.js +82 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/ranges/simplify.js +49 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/ranges/subset.js +249 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/ranges/to-comparators.js +10 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/ranges/valid.js +13 -0
- package/node_modules/@mrclrchtr/supi-lsp/package.json +5 -3
- package/node_modules/@mrclrchtr/supi-lsp/src/client/client.ts +23 -5
- package/node_modules/@mrclrchtr/supi-lsp/src/config/config.ts +53 -2
- package/node_modules/@mrclrchtr/supi-lsp/src/config/operation-support.ts +19 -4
- package/node_modules/@mrclrchtr/supi-lsp/src/config/server-config.ts +22 -0
- package/node_modules/@mrclrchtr/supi-lsp/src/config/typescript-launch.ts +276 -0
- package/node_modules/@mrclrchtr/supi-lsp/src/manager/manager-project-info.ts +22 -10
- package/node_modules/@mrclrchtr/supi-lsp/src/manager/manager.ts +52 -19
- package/node_modules/@mrclrchtr/supi-lsp/src/provider/refactor-planning.ts +4 -3
- package/node_modules/@mrclrchtr/supi-lsp/src/session/runtime-controller.ts +2 -2
- package/node_modules/@mrclrchtr/supi-lsp/src/session/scanner.ts +27 -15
- 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-core/package.json +1 -1
- package/node_modules/@mrclrchtr/supi-tree-sitter/package.json +3 -3
- package/package.json +5 -5
- package/src/analysis/capability/capability-warnings.ts +18 -12
- package/src/analysis/health/check.ts +115 -0
- package/src/analysis/health/diagnostics.ts +3 -0
- package/src/analysis/health/file-scope.ts +2 -3
- package/src/analysis/health/semantic-state.ts +38 -0
- package/src/analysis/health/server-status.ts +8 -0
- package/src/analysis/health/signals.ts +2 -0
- package/src/analysis/health/status.ts +82 -0
- package/src/analysis/refactor/apply.ts +17 -8
- package/src/session/health-types.ts +7 -0
- package/src/session/health-workflow.ts +8 -43
- package/src/session/orientation/collect.ts +138 -12
- package/src/session/orientation/context-facts.ts +27 -2
- package/src/session/orientation/context-sections.ts +47 -0
- package/src/session/orientation/facts.ts +124 -0
- package/src/session/orientation/gather.ts +98 -11
- package/src/session/orientation/workspace-context.ts +16 -6
- package/src/session/orientation-types.ts +5 -0
- package/src/session/orientation-workflow.ts +3 -2
- package/src/session/refactor-plans.ts +5 -2
- package/src/session/refactor-workflow.ts +4 -3
- package/src/tool/code_find/guidance.ts +1 -1
- package/src/tool/code_health/markdown.ts +12 -2
- package/src/tool/code_health/result.ts +15 -2
- package/src/tool/code_health/spec.ts +2 -0
- package/src/tool/code_health/structured-schema.ts +250 -0
- package/src/tool/code_health/structured.ts +256 -0
- package/src/tool/code_inspect/result.ts +11 -5
- package/src/tool/code_inspect/spec.ts +2 -0
- package/src/tool/code_inspect/structured.ts +232 -0
- package/src/tool/code_orientation/result.ts +10 -4
- package/src/tool/code_orientation/spec.ts +2 -0
- package/src/tool/code_orientation/structured-schema.ts +607 -0
- package/src/tool/code_orientation/structured-workspace.ts +193 -0
- package/src/tool/code_orientation/structured.ts +195 -0
- package/src/tool/code_orientation/workspace-observations.ts +81 -0
- package/src/tool/code_orientation/workspace-output.ts +5 -0
- package/src/tool/code_orientation/workspace-projects.ts +16 -31
- package/src/tool/code_orientation/workspace-sections.ts +43 -30
- package/src/tool/code_refactor_apply/execute.ts +1 -1
- package/src/tool/code_refactor_apply/result.ts +13 -5
- package/src/tool/code_refactor_apply/spec.ts +2 -0
- package/src/tool/code_refactor_apply/structured.ts +49 -0
- package/src/tool/code_refactor_plan/result.ts +16 -8
- package/src/tool/code_refactor_plan/spec.ts +2 -0
- package/src/tool/code_refactor_plan/structured.ts +128 -0
- package/src/tool/schemas.ts +7 -1
- package/src/ui/status-command.ts +110 -321
- package/src/ui/status-overlay.ts +564 -420
|
@@ -22,15 +22,26 @@ export type ContextGatherProvider = Pick<
|
|
|
22
22
|
Partial<Pick<SemanticProvider, "hover" | "definition">>;
|
|
23
23
|
|
|
24
24
|
/**
|
|
25
|
-
* Best-effort substrate evidence at one target position.
|
|
26
|
-
*
|
|
25
|
+
* Best-effort substrate evidence at one target position. Consult each operation's
|
|
26
|
+
* status to distinguish a completed empty value from unavailable or withheld evidence.
|
|
27
27
|
*/
|
|
28
|
+
/** Availability of one independently attempted context observation. */
|
|
29
|
+
type CollectedStatus =
|
|
30
|
+
| { readonly status: "complete"; readonly reason: null }
|
|
31
|
+
| { readonly status: "partial" | "unavailable"; readonly reason: string };
|
|
32
|
+
|
|
33
|
+
export type ContextObservationStatus =
|
|
34
|
+
| CollectedStatus
|
|
35
|
+
| { readonly status: "withheld"; readonly reason: string };
|
|
36
|
+
|
|
28
37
|
export interface SubstrateContext {
|
|
29
38
|
nodeInfo: {
|
|
30
39
|
type: string;
|
|
31
40
|
text: string;
|
|
32
41
|
startLine: number;
|
|
33
42
|
startCharacter: number;
|
|
43
|
+
endLine: number;
|
|
44
|
+
endCharacter: number;
|
|
34
45
|
ancestry: Array<{
|
|
35
46
|
type: string;
|
|
36
47
|
startLine: number;
|
|
@@ -42,10 +53,19 @@ export interface SubstrateContext {
|
|
|
42
53
|
outline: Array<{ name: string; kind: string; startLine: number; endLine: number }>;
|
|
43
54
|
imports: Array<{ moduleSpecifier: string }>;
|
|
44
55
|
exports: Array<{ name: string; kind: string }>;
|
|
45
|
-
/** Best-effort LSP hover
|
|
56
|
+
/** Best-effort LSP hover data; consult operations.hover for empty versus unavailable. */
|
|
46
57
|
hover: { contents: string; range?: SourceRange } | null;
|
|
47
|
-
/** Best-effort LSP definition
|
|
58
|
+
/** Best-effort LSP definition data; empty arrays are successful observations. */
|
|
48
59
|
definition: Array<{ uri: string; range: SourceRange }> | null;
|
|
60
|
+
/** Availability of each independent observation, including withheld position-strict queries. */
|
|
61
|
+
operations: {
|
|
62
|
+
nodeAt: ContextObservationStatus;
|
|
63
|
+
hover: ContextObservationStatus;
|
|
64
|
+
definition: ContextObservationStatus;
|
|
65
|
+
outline: CollectedStatus;
|
|
66
|
+
imports: CollectedStatus;
|
|
67
|
+
exports: CollectedStatus;
|
|
68
|
+
};
|
|
49
69
|
/** Structural recovery from independently queried source operations. */
|
|
50
70
|
recovery: Array<{
|
|
51
71
|
operation: "nodeAt" | "outline" | "imports" | "exports";
|
|
@@ -63,9 +83,10 @@ export interface SubstrateContext {
|
|
|
63
83
|
* (tree-sitter `nodeAt`, hover-at) run only when `positionStrict` is true —
|
|
64
84
|
* callers holding a declaration-anchor target must pass false (ADR 0003).
|
|
65
85
|
* File-level evidence (outline, imports, exports) and position-tolerant
|
|
66
|
-
* definition lookups run regardless. Failures
|
|
86
|
+
* definition lookups run regardless. Failures retain unavailable status and reason.
|
|
67
87
|
*/
|
|
68
88
|
// biome-ignore lint/complexity/noExcessiveCognitiveComplexity: best-effort substrate gathering with independent try/catch blocks kept together for readability
|
|
89
|
+
// biome-ignore lint/complexity/noExcessiveLinesPerFunction: keep the existing shared best-effort failure boundary and query order intact
|
|
69
90
|
// biome-ignore lint/complexity/useMaxParams: one internal gather call site carries the full position context
|
|
70
91
|
export async function gatherSubstrateContext(
|
|
71
92
|
provider: ContextGatherProvider | null,
|
|
@@ -82,12 +103,34 @@ export async function gatherSubstrateContext(
|
|
|
82
103
|
let hover: SubstrateContext["hover"] = null;
|
|
83
104
|
let definition: SubstrateContext["definition"] = null;
|
|
84
105
|
const recovery: SubstrateContext["recovery"] = [];
|
|
106
|
+
const withheld = {
|
|
107
|
+
status: "withheld" as const,
|
|
108
|
+
reason:
|
|
109
|
+
"Position-strict evidence requires a name anchor; this target has a declaration anchor.",
|
|
110
|
+
};
|
|
111
|
+
const operations: SubstrateContext["operations"] = {
|
|
112
|
+
nodeAt: positionStrict ? { status: "unavailable", reason: "Not collected." } : withheld,
|
|
113
|
+
hover: positionStrict ? { status: "unavailable", reason: "Not collected." } : withheld,
|
|
114
|
+
definition: { status: "unavailable", reason: "Not collected." },
|
|
115
|
+
outline: { status: "unavailable", reason: "Not collected." },
|
|
116
|
+
imports: { status: "unavailable", reason: "Not collected." },
|
|
117
|
+
exports: { status: "unavailable", reason: "Not collected." },
|
|
118
|
+
};
|
|
119
|
+
let currentOperation: keyof SubstrateContext["operations"] | null = null;
|
|
85
120
|
|
|
86
|
-
if (!provider)
|
|
121
|
+
if (!provider) {
|
|
122
|
+
for (const key of Object.keys(operations) as Array<keyof SubstrateContext["operations"]>) {
|
|
123
|
+
if (operations[key].status !== "withheld")
|
|
124
|
+
operations[key] = { status: "unavailable", reason: "Provider unavailable." };
|
|
125
|
+
}
|
|
126
|
+
return { nodeInfo, outline, imports, exports, hover, definition: null, recovery, operations };
|
|
127
|
+
}
|
|
87
128
|
|
|
88
129
|
try {
|
|
89
130
|
if (positionStrict) {
|
|
131
|
+
currentOperation = "nodeAt";
|
|
90
132
|
const nodeResult = await provider.nodeAt(relPath, line, character, requestControl);
|
|
133
|
+
operations.nodeAt = structuralStatus(nodeResult);
|
|
91
134
|
if (nodeResult.kind === "partial") {
|
|
92
135
|
recovery.push({
|
|
93
136
|
operation: "nodeAt",
|
|
@@ -102,12 +145,17 @@ export async function gatherSubstrateContext(
|
|
|
102
145
|
text: nodeResult.data.text,
|
|
103
146
|
startLine: nodeResult.data.startLine,
|
|
104
147
|
startCharacter: nodeResult.data.startCharacter,
|
|
148
|
+
endLine: nodeResult.data.endLine,
|
|
149
|
+
endCharacter: nodeResult.data.endCharacter,
|
|
105
150
|
ancestry: nodeResult.data.ancestry ?? [],
|
|
106
151
|
};
|
|
107
152
|
}
|
|
153
|
+
currentOperation = null;
|
|
108
154
|
}
|
|
109
155
|
|
|
156
|
+
currentOperation = "outline";
|
|
110
157
|
const outlineResult = await provider.outline(relPath, requestControl);
|
|
158
|
+
operations.outline = structuralStatus(outlineResult);
|
|
111
159
|
if (outlineResult.kind === "partial") {
|
|
112
160
|
recovery.push({
|
|
113
161
|
operation: "outline",
|
|
@@ -125,7 +173,9 @@ export async function gatherSubstrateContext(
|
|
|
125
173
|
}));
|
|
126
174
|
}
|
|
127
175
|
|
|
176
|
+
currentOperation = "imports";
|
|
128
177
|
const importsResult = await provider.imports(relPath, requestControl);
|
|
178
|
+
operations.imports = structuralStatus(importsResult);
|
|
129
179
|
if (importsResult.kind === "partial") {
|
|
130
180
|
recovery.push({
|
|
131
181
|
operation: "imports",
|
|
@@ -138,7 +188,9 @@ export async function gatherSubstrateContext(
|
|
|
138
188
|
imports = importsResult.data;
|
|
139
189
|
}
|
|
140
190
|
|
|
191
|
+
currentOperation = "exports";
|
|
141
192
|
const exportsResult = await provider.exports(relPath, requestControl);
|
|
193
|
+
operations.exports = structuralStatus(exportsResult);
|
|
142
194
|
if (exportsResult.kind === "partial") {
|
|
143
195
|
recovery.push({
|
|
144
196
|
operation: "exports",
|
|
@@ -153,6 +205,7 @@ export async function gatherSubstrateContext(
|
|
|
153
205
|
kind: item.kind,
|
|
154
206
|
}));
|
|
155
207
|
}
|
|
208
|
+
currentOperation = null;
|
|
156
209
|
|
|
157
210
|
// Best-effort hover — LSP expects 0-based coordinates; hover-at is position-strict.
|
|
158
211
|
if (positionStrict && provider.hover) {
|
|
@@ -161,11 +214,14 @@ export async function gatherSubstrateContext(
|
|
|
161
214
|
line: line - 1,
|
|
162
215
|
character: character - 1,
|
|
163
216
|
});
|
|
217
|
+
operations.hover = semanticStatus(hoverResult);
|
|
164
218
|
if (hoverResult.kind !== "unavailable" && hoverResult.data) hover = hoverResult.data;
|
|
165
219
|
} catch (error) {
|
|
166
220
|
if (isCodeRequestInterruption(error, requestControl)) throw error;
|
|
167
|
-
|
|
221
|
+
operations.hover = { status: "unavailable", reason: String(error) };
|
|
168
222
|
}
|
|
223
|
+
} else if (positionStrict) {
|
|
224
|
+
operations.hover = { status: "unavailable", reason: "Hover provider unavailable." };
|
|
169
225
|
}
|
|
170
226
|
|
|
171
227
|
// Best-effort definition — LSP expects 0-based coordinates; definitions are position-tolerant.
|
|
@@ -175,7 +231,8 @@ export async function gatherSubstrateContext(
|
|
|
175
231
|
line: line - 1,
|
|
176
232
|
character: character - 1,
|
|
177
233
|
});
|
|
178
|
-
|
|
234
|
+
operations.definition = semanticStatus(defResult);
|
|
235
|
+
if (defResult.kind !== "unavailable") {
|
|
179
236
|
definition = defResult.data.map((loc) => ({
|
|
180
237
|
uri: loc.uri,
|
|
181
238
|
range: loc.range,
|
|
@@ -183,13 +240,43 @@ export async function gatherSubstrateContext(
|
|
|
183
240
|
}
|
|
184
241
|
} catch (error) {
|
|
185
242
|
if (isCodeRequestInterruption(error, requestControl)) throw error;
|
|
186
|
-
|
|
243
|
+
operations.definition = { status: "unavailable", reason: String(error) };
|
|
187
244
|
}
|
|
245
|
+
} else {
|
|
246
|
+
operations.definition = { status: "unavailable", reason: "Definition provider unavailable." };
|
|
188
247
|
}
|
|
189
248
|
} catch (error) {
|
|
190
249
|
if (isCodeRequestInterruption(error, requestControl)) throw error;
|
|
191
|
-
|
|
250
|
+
if (currentOperation) {
|
|
251
|
+
operations[currentOperation] = { status: "unavailable", reason: String(error) };
|
|
252
|
+
for (const key of ["hover", "definition"] as const) {
|
|
253
|
+
if (operations[key].reason === "Not collected.") {
|
|
254
|
+
operations[key] = {
|
|
255
|
+
status: "unavailable",
|
|
256
|
+
reason: `Not collected after ${currentOperation} failed.`,
|
|
257
|
+
};
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
}
|
|
192
261
|
}
|
|
193
262
|
|
|
194
|
-
return { nodeInfo, outline, imports, exports, hover, definition, recovery };
|
|
263
|
+
return { nodeInfo, outline, imports, exports, hover, definition, recovery, operations };
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
function semanticStatus(result: { kind: string; reason?: string }): CollectedStatus {
|
|
267
|
+
if (result.kind === "completed") return { status: "complete", reason: null };
|
|
268
|
+
if (result.kind === "partial")
|
|
269
|
+
return { status: "partial", reason: result.reason ?? "Partial evidence." };
|
|
270
|
+
return { status: "unavailable", reason: result.reason ?? "Semantic provider unavailable." };
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
function structuralStatus(result: {
|
|
274
|
+
kind: string;
|
|
275
|
+
reason?: string;
|
|
276
|
+
message?: string;
|
|
277
|
+
}): SubstrateContext["operations"]["outline"] {
|
|
278
|
+
if (result.kind === "success") return { status: "complete", reason: null };
|
|
279
|
+
if (result.kind === "partial")
|
|
280
|
+
return { status: "partial", reason: result.reason ?? "Partial evidence." };
|
|
281
|
+
return { status: "unavailable", reason: result.message ?? "Structural provider unavailable." };
|
|
195
282
|
}
|
|
@@ -58,12 +58,15 @@ export async function orientWorkspaceContext(
|
|
|
58
58
|
return {
|
|
59
59
|
kind: "completed",
|
|
60
60
|
directory: focus,
|
|
61
|
-
data:
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
61
|
+
data: {
|
|
62
|
+
...workspaceOrientationData({
|
|
63
|
+
observation,
|
|
64
|
+
cwd: options.cwd,
|
|
65
|
+
focus,
|
|
66
|
+
maxResults: request.maxResults ?? 10,
|
|
67
|
+
}),
|
|
68
|
+
focusKind: workspaceFocusKind(request),
|
|
69
|
+
},
|
|
67
70
|
};
|
|
68
71
|
} catch (error) {
|
|
69
72
|
if (!(error instanceof WorkspaceSymlinkError)) throw error;
|
|
@@ -75,6 +78,13 @@ export async function orientWorkspaceContext(
|
|
|
75
78
|
}
|
|
76
79
|
}
|
|
77
80
|
|
|
81
|
+
function workspaceFocusKind(
|
|
82
|
+
request: OrientationWorkflowInput,
|
|
83
|
+
): "workspace" | "module" | "directory" {
|
|
84
|
+
if (!request.focus) return "workspace";
|
|
85
|
+
return "module" in request.focus ? "module" : "directory";
|
|
86
|
+
}
|
|
87
|
+
|
|
78
88
|
async function initialObservation(
|
|
79
89
|
cwd: string,
|
|
80
90
|
focus: string | null,
|
|
@@ -96,6 +96,8 @@ export interface OrientationSectionData {
|
|
|
96
96
|
readonly evidenceLists: readonly EvidenceListMetadata[];
|
|
97
97
|
/** Evidence list counted by table rows, including when only empty-result framing remains. */
|
|
98
98
|
readonly tableEvidenceKey?: string;
|
|
99
|
+
/** Named collected facts, independent of presentation atoms. */
|
|
100
|
+
readonly facts?: import("./orientation/facts.ts").OrientationFacts;
|
|
99
101
|
/** Content atoms for this section; the adapter frames them under the title + note. */
|
|
100
102
|
readonly items: readonly OrientationItem[];
|
|
101
103
|
}
|
|
@@ -121,12 +123,15 @@ export interface OrientationResultData {
|
|
|
121
123
|
readonly sections: readonly OrientationSectionData[];
|
|
122
124
|
readonly confidence: ConfidenceMode;
|
|
123
125
|
readonly focusTarget: string | null;
|
|
126
|
+
readonly focusKind?: "workspace" | "directory" | "module" | "file" | "symbol";
|
|
124
127
|
readonly requestedSections: readonly string[];
|
|
125
128
|
readonly renderedSections: readonly string[];
|
|
126
129
|
readonly omittedCount: number;
|
|
127
130
|
readonly nextQueries: readonly string[];
|
|
128
131
|
readonly readNext: readonly ReadNextItem[];
|
|
129
132
|
readonly instructions?: InstructionFilesMetadata;
|
|
133
|
+
/** Collected instruction snippets; separate from mutable session deduplication state. */
|
|
134
|
+
readonly instructionFiles?: readonly import("../analysis/instruction-files.ts").RenderedInstructionFile[];
|
|
130
135
|
/** Captured generic workspace facts; absent for the unchanged file and symbol paths. */
|
|
131
136
|
readonly workspace?: import("./orientation/workspace-context.ts").WorkspaceOrientationFacts;
|
|
132
137
|
readonly target?: Readonly<TargetStoreEntry>;
|
|
@@ -95,7 +95,7 @@ export async function runOrientationWorkflow(
|
|
|
95
95
|
{ model, provider, lspRuntime, cwd: deps.cwd, requestControl: control },
|
|
96
96
|
);
|
|
97
97
|
throwIfAborted(control);
|
|
98
|
-
const withInstructions = addInstructionFiles(result, focus.path, deps);
|
|
98
|
+
const withInstructions = addInstructionFiles({ ...result, focusKind: "file" }, focus.path, deps);
|
|
99
99
|
return { kind: "completed", data: withInstructions };
|
|
100
100
|
}
|
|
101
101
|
|
|
@@ -195,7 +195,7 @@ async function orientTarget(options: {
|
|
|
195
195
|
throwIfAborted(control);
|
|
196
196
|
return {
|
|
197
197
|
kind: "completed",
|
|
198
|
-
data: addTargetSummary(result, entry, target.notes, deps.cwd),
|
|
198
|
+
data: addTargetSummary({ ...result, focusKind: "symbol" }, entry, target.notes, deps.cwd),
|
|
199
199
|
};
|
|
200
200
|
}
|
|
201
201
|
|
|
@@ -279,6 +279,7 @@ function addInstructionFiles(
|
|
|
279
279
|
sections: [section, ...result.sections],
|
|
280
280
|
renderedSections: ["instructions", ...result.renderedSections],
|
|
281
281
|
instructions: collected.metadata,
|
|
282
|
+
instructionFiles: collected.files,
|
|
282
283
|
};
|
|
283
284
|
}
|
|
284
285
|
|
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
import { createHash } from "node:crypto";
|
|
10
10
|
import { readFileSync } from "node:fs";
|
|
11
11
|
import type { RefactorOperation, WorkspaceEdit } from "@mrclrchtr/supi-code-runtime/api";
|
|
12
|
+
import { toDisplayPath } from "../analysis/search/paths.ts";
|
|
12
13
|
|
|
13
14
|
export interface RefactorPlan {
|
|
14
15
|
id: string;
|
|
@@ -41,6 +42,7 @@ export function computeFileFingerprint(file: string): string {
|
|
|
41
42
|
export function validateSynchronizedContentFingerprints(
|
|
42
43
|
preconditions: WorkspaceEdit["documentPreconditions"],
|
|
43
44
|
fileFingerprints: readonly { file: string; fingerprint: string }[],
|
|
45
|
+
cwd: string,
|
|
44
46
|
): string | null {
|
|
45
47
|
const fingerprints = new Map(
|
|
46
48
|
fileFingerprints.map(({ file, fingerprint }) => [file, fingerprint]),
|
|
@@ -48,7 +50,7 @@ export function validateSynchronizedContentFingerprints(
|
|
|
48
50
|
for (const precondition of preconditions ?? []) {
|
|
49
51
|
if (precondition.kind !== "open-document-content") continue;
|
|
50
52
|
if (fingerprints.get(precondition.file) !== precondition.fingerprint) {
|
|
51
|
-
return `File ${precondition.file} changed after the semantic input snapshot. Request a new rename plan.`;
|
|
53
|
+
return `File ${toDisplayPath(cwd, precondition.file)} changed after the semantic input snapshot. Request a new rename plan.`;
|
|
52
54
|
}
|
|
53
55
|
}
|
|
54
56
|
return null;
|
|
@@ -89,13 +91,14 @@ export function removePlan(store: Map<string, RefactorPlan>, id: string): void {
|
|
|
89
91
|
/** Check if a plan is still fresh (all file fingerprints match). */
|
|
90
92
|
export function isPlanFresh(
|
|
91
93
|
plan: RefactorPlan,
|
|
94
|
+
cwd: string,
|
|
92
95
|
): { fresh: true } | { fresh: false; reason: string } {
|
|
93
96
|
for (const fp of plan.fileFingerprints) {
|
|
94
97
|
const current = computeFileFingerprint(fp.file);
|
|
95
98
|
if (current !== fp.fingerprint) {
|
|
96
99
|
return {
|
|
97
100
|
fresh: false,
|
|
98
|
-
reason: `File ${fp.file} has changed since the plan was generated. Regenerate with code_refactor_plan.`,
|
|
101
|
+
reason: `File ${toDisplayPath(cwd, fp.file)} has changed since the plan was generated. Regenerate with code_refactor_plan.`,
|
|
99
102
|
};
|
|
100
103
|
}
|
|
101
104
|
}
|
|
@@ -130,7 +130,7 @@ export async function runRefactorApplyWorkflow(
|
|
|
130
130
|
plan.authorizedMutationRoots,
|
|
131
131
|
);
|
|
132
132
|
if (authority.kind === "unavailable") return authority;
|
|
133
|
-
const freshness = isPlanFresh(plan);
|
|
133
|
+
const freshness = isPlanFresh(plan, deps.cwd);
|
|
134
134
|
if (!freshness.fresh) return { kind: "invalid-input", message: freshness.reason };
|
|
135
135
|
const validation = validateEdit(plan.edits);
|
|
136
136
|
if (!validation.safe) return { kind: "invalid-input", message: validation.reason };
|
|
@@ -144,11 +144,11 @@ export async function runRefactorApplyWorkflow(
|
|
|
144
144
|
const expectedFingerprints = new Map(
|
|
145
145
|
plan.fileFingerprints.map(({ file, fingerprint }) => [file, fingerprint]),
|
|
146
146
|
);
|
|
147
|
-
const getOpenDocumentVersion = getDocumentVersionReader(deps);
|
|
148
147
|
const result = await applyWorkspaceEdit(plan.edits, {
|
|
148
|
+
cwd: deps.cwd,
|
|
149
149
|
authorizedMutationRoots: plan.authorizedMutationRoots,
|
|
150
150
|
expectedFingerprints,
|
|
151
|
-
getOpenDocumentVersion,
|
|
151
|
+
getOpenDocumentVersion: getDocumentVersionReader(deps),
|
|
152
152
|
});
|
|
153
153
|
if (result.kind === "error") return { kind: "unavailable", reason: result.reason };
|
|
154
154
|
deps.removePlan(plan.id);
|
|
@@ -199,6 +199,7 @@ async function planResolvedRefactor(
|
|
|
199
199
|
const snapshotError = validateSynchronizedContentFingerprints(
|
|
200
200
|
result.edits.documentPreconditions,
|
|
201
201
|
fileFingerprints,
|
|
202
|
+
deps.cwd,
|
|
202
203
|
);
|
|
203
204
|
if (snapshotError) return { kind: "unavailable", reason: snapshotError };
|
|
204
205
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export const toolDescription =
|
|
2
|
-
"Search workspace symbols in semantic mode, or declaration, import, export, and call names in AST mode. Use
|
|
2
|
+
"Search workspace symbols in semantic mode, or declaration, import, export, and call names in AST mode. Use grep for literal or regular-expression file-content search. The selected mode does not switch to another search method.";
|
|
3
3
|
|
|
4
4
|
export const promptSnippet = "search code structure or workspace symbols";
|
|
5
5
|
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/** Markdown renderer for code_health results. */
|
|
2
2
|
import type { CapabilityWarningReport } from "../../analysis/capability/capability-warnings.ts";
|
|
3
3
|
import {
|
|
4
|
+
formatProjectServerCompiler,
|
|
4
5
|
formatProjectServerOperationSupport,
|
|
5
6
|
formatProjectServerRoot,
|
|
6
7
|
formatProjectServerRouteSummary,
|
|
@@ -372,13 +373,22 @@ function renderServersSection(
|
|
|
372
373
|
lines.push(
|
|
373
374
|
`- ${statusIcon} **${server.name}** @ \`${formatProjectServerRoot(cwd, server.root)}\` (${server.fileTypes.join(", ")}) — ${server.status}${reason}`,
|
|
374
375
|
);
|
|
375
|
-
|
|
376
|
-
if (operationSupport) lines.push(` - ${operationSupport}`);
|
|
376
|
+
renderServerDetails(lines, server);
|
|
377
377
|
}
|
|
378
378
|
}
|
|
379
379
|
lines.push("");
|
|
380
380
|
}
|
|
381
381
|
|
|
382
|
+
function renderServerDetails(lines: string[], server: HealthData["servers"][number]): void {
|
|
383
|
+
for (const detail of [
|
|
384
|
+
formatProjectServerCompiler(server.typescript),
|
|
385
|
+
server.failureMessage,
|
|
386
|
+
formatProjectServerOperationSupport(server.operationSupport),
|
|
387
|
+
]) {
|
|
388
|
+
if (detail) lines.push(` - ${detail}`);
|
|
389
|
+
}
|
|
390
|
+
}
|
|
391
|
+
|
|
382
392
|
function displaySemanticStatus(data: HealthData): string {
|
|
383
393
|
return formatSemanticHealthState(data.semanticState);
|
|
384
394
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { ConfidenceMode } from "@mrclrchtr/supi-code-runtime/api";
|
|
2
2
|
import {
|
|
3
3
|
countProjectServerRouteStatuses,
|
|
4
|
+
formatProjectServerCompiler,
|
|
4
5
|
formatProjectServerOperationSupport,
|
|
5
6
|
formatProjectServerRoot,
|
|
6
7
|
formatProjectServerStatusReason,
|
|
@@ -117,7 +118,14 @@ function buildHealthDisplaySections(data: HealthData, cwd?: string): ToolDisplay
|
|
|
117
118
|
totalCount: data.servers.length,
|
|
118
119
|
format: (server) => {
|
|
119
120
|
const root = cwd ? formatProjectServerRoot(cwd, server.root) : server.root;
|
|
120
|
-
const
|
|
121
|
+
const compiler = formatProjectServerCompiler(server.typescript);
|
|
122
|
+
const support = [
|
|
123
|
+
compiler,
|
|
124
|
+
server.failureMessage,
|
|
125
|
+
formatProjectServerOperationSupport(server.operationSupport),
|
|
126
|
+
]
|
|
127
|
+
.filter(Boolean)
|
|
128
|
+
.join(" — ");
|
|
121
129
|
return `${server.name} @ ${root} (${server.fileTypes.join(", ")}) — ${server.status}${server.statusReason ? ` — ${formatProjectServerStatusReason(server.statusReason)}` : ""}${support ? ` — ${support}` : ""}`;
|
|
122
130
|
},
|
|
123
131
|
}),
|
|
@@ -257,6 +265,7 @@ function uniqueProvenance(provenance: readonly ResultProvenance[]): ResultProven
|
|
|
257
265
|
import type { CodeIntelResult, CodeIntelToolExecCtx } from "../../types/index.ts";
|
|
258
266
|
import { healthErrorResult } from "../result/errors.ts";
|
|
259
267
|
import { renderHealthResult } from "./markdown.ts";
|
|
268
|
+
import { structuredHealthResult } from "./structured.ts";
|
|
260
269
|
|
|
261
270
|
type HealthOutcome = Awaited<ReturnType<CodeIntelToolExecCtx["session"]["health"]>>;
|
|
262
271
|
|
|
@@ -264,12 +273,16 @@ type HealthOutcome = Awaited<ReturnType<CodeIntelToolExecCtx["session"]["health"
|
|
|
264
273
|
export function finishHealthResult(outcome: HealthOutcome, cwd: string): CodeIntelResult {
|
|
265
274
|
if (outcome.kind === "unavailable") throw new Error(outcome.reason);
|
|
266
275
|
if (outcome.kind === "invalid-input") {
|
|
267
|
-
return
|
|
276
|
+
return {
|
|
277
|
+
...healthErrorResult(`**Error:** ${outcome.message}`, outcome.message),
|
|
278
|
+
structuredContent: { kind: "invalid-input", message: outcome.message },
|
|
279
|
+
};
|
|
268
280
|
}
|
|
269
281
|
|
|
270
282
|
const assembly = assembleHealthResult(outcome.data, cwd);
|
|
271
283
|
return {
|
|
272
284
|
content: renderHealthResult(assembly, cwd),
|
|
285
|
+
structuredContent: structuredHealthResult(outcome.data),
|
|
273
286
|
details: {
|
|
274
287
|
type: "health",
|
|
275
288
|
data: assembly.details,
|
|
@@ -3,6 +3,7 @@ import { Type } from "typebox";
|
|
|
3
3
|
import type { CodeIntelToolExecCtx } from "../../types/index.ts";
|
|
4
4
|
import { ScopeParam } from "../schemas.ts";
|
|
5
5
|
import { executeHealthTool } from "./execute.ts";
|
|
6
|
+
import { HealthOutputSchema } from "./structured-schema.ts";
|
|
6
7
|
import { renderHealthCall, renderHealthResult } from "./tui.ts";
|
|
7
8
|
|
|
8
9
|
export const CODE_HEALTH_TOOL_NAME = "code_health";
|
|
@@ -35,6 +36,7 @@ export const codeHealthSpec = {
|
|
|
35
36
|
},
|
|
36
37
|
{ additionalProperties: false },
|
|
37
38
|
),
|
|
39
|
+
outputSchema: HealthOutputSchema,
|
|
38
40
|
run: (params: unknown, ctx: CodeIntelToolExecCtx) =>
|
|
39
41
|
executeHealthTool(params as Parameters<typeof executeHealthTool>[0], ctx),
|
|
40
42
|
renderCall: renderHealthCall,
|