@mrclrchtr/supi-code-intelligence 10.0.0 → 11.0.1

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.
Files changed (138) hide show
  1. package/README.md +77 -21
  2. package/node_modules/@mrclrchtr/supi-code-runtime/node_modules/picomatch/LICENSE +21 -0
  3. package/node_modules/@mrclrchtr/supi-code-runtime/node_modules/picomatch/README.md +743 -0
  4. package/node_modules/@mrclrchtr/supi-code-runtime/node_modules/picomatch/index.js +17 -0
  5. package/node_modules/@mrclrchtr/supi-code-runtime/node_modules/picomatch/lib/constants.js +184 -0
  6. package/node_modules/@mrclrchtr/supi-code-runtime/node_modules/picomatch/lib/parse.js +1425 -0
  7. package/node_modules/@mrclrchtr/supi-code-runtime/node_modules/picomatch/lib/picomatch.js +361 -0
  8. package/node_modules/@mrclrchtr/supi-code-runtime/node_modules/picomatch/lib/scan.js +403 -0
  9. package/node_modules/@mrclrchtr/supi-code-runtime/node_modules/picomatch/lib/utils.js +72 -0
  10. package/node_modules/@mrclrchtr/supi-code-runtime/node_modules/picomatch/package.json +83 -0
  11. package/node_modules/@mrclrchtr/supi-code-runtime/node_modules/picomatch/posix.js +3 -0
  12. package/node_modules/@mrclrchtr/supi-code-runtime/package.json +4 -1
  13. package/node_modules/@mrclrchtr/supi-code-runtime/src/api.ts +11 -0
  14. package/node_modules/@mrclrchtr/supi-code-runtime/src/file-associations.ts +190 -0
  15. package/node_modules/@mrclrchtr/supi-code-runtime/src/types.ts +22 -0
  16. package/node_modules/@mrclrchtr/supi-core/package.json +1 -1
  17. package/node_modules/@mrclrchtr/supi-lsp/README.md +88 -2
  18. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-code-runtime/node_modules/picomatch/LICENSE +21 -0
  19. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-code-runtime/node_modules/picomatch/README.md +743 -0
  20. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-code-runtime/node_modules/picomatch/index.js +17 -0
  21. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-code-runtime/node_modules/picomatch/lib/constants.js +184 -0
  22. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-code-runtime/node_modules/picomatch/lib/parse.js +1425 -0
  23. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-code-runtime/node_modules/picomatch/lib/picomatch.js +361 -0
  24. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-code-runtime/node_modules/picomatch/lib/scan.js +403 -0
  25. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-code-runtime/node_modules/picomatch/lib/utils.js +72 -0
  26. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-code-runtime/node_modules/picomatch/package.json +83 -0
  27. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-code-runtime/node_modules/picomatch/posix.js +3 -0
  28. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-code-runtime/package.json +4 -1
  29. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-code-runtime/src/api.ts +11 -0
  30. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-code-runtime/src/file-associations.ts +190 -0
  31. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-code-runtime/src/types.ts +22 -0
  32. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-core/package.json +1 -1
  33. package/node_modules/@mrclrchtr/supi-lsp/package.json +3 -3
  34. package/node_modules/@mrclrchtr/supi-lsp/src/api.ts +1 -0
  35. package/node_modules/@mrclrchtr/supi-lsp/src/client/client-diagnostic-host.ts +3 -0
  36. package/node_modules/@mrclrchtr/supi-lsp/src/client/client-diagnostics.ts +6 -4
  37. package/node_modules/@mrclrchtr/supi-lsp/src/client/client-request-enrollment.ts +66 -22
  38. package/node_modules/@mrclrchtr/supi-lsp/src/client/client-semantic-input-barrier.ts +37 -5
  39. package/node_modules/@mrclrchtr/supi-lsp/src/client/client.ts +136 -43
  40. package/node_modules/@mrclrchtr/supi-lsp/src/manager/manager.ts +261 -22
  41. package/node_modules/@mrclrchtr/supi-lsp/src/provider/refactor-planning.ts +13 -0
  42. package/node_modules/@mrclrchtr/supi-lsp/src/provider/semantic-edit-discovery.ts +151 -0
  43. package/node_modules/@mrclrchtr/supi-lsp/src/provider/semantic-edit-normalizer.ts +97 -129
  44. package/node_modules/@mrclrchtr/supi-lsp/src/provider/semantic-edit-protocol.ts +132 -0
  45. package/node_modules/@mrclrchtr/supi-lsp/src/session/runtime-controller.ts +8 -1
  46. package/node_modules/@mrclrchtr/supi-lsp/src/session/runtime-registry.ts +7 -20
  47. package/node_modules/@mrclrchtr/supi-lsp/src/session/runtime-rename.ts +172 -0
  48. package/node_modules/@mrclrchtr/supi-lsp/src/session/workspace-lsp-runtime.ts +14 -0
  49. package/node_modules/@mrclrchtr/supi-lsp/src/utils.ts +12 -11
  50. package/node_modules/@mrclrchtr/supi-tree-sitter/README.md +63 -17
  51. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/node_modules/picomatch/LICENSE +21 -0
  52. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/node_modules/picomatch/README.md +743 -0
  53. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/node_modules/picomatch/index.js +17 -0
  54. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/node_modules/picomatch/lib/constants.js +184 -0
  55. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/node_modules/picomatch/lib/parse.js +1425 -0
  56. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/node_modules/picomatch/lib/picomatch.js +361 -0
  57. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/node_modules/picomatch/lib/scan.js +403 -0
  58. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/node_modules/picomatch/lib/utils.js +72 -0
  59. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/node_modules/picomatch/package.json +83 -0
  60. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/node_modules/picomatch/posix.js +3 -0
  61. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/package.json +4 -1
  62. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/src/api.ts +11 -0
  63. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/src/file-associations.ts +190 -0
  64. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/src/types.ts +22 -0
  65. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/package.json +1 -1
  66. package/node_modules/@mrclrchtr/supi-tree-sitter/package.json +3 -3
  67. package/node_modules/@mrclrchtr/supi-tree-sitter/src/language.ts +16 -10
  68. package/node_modules/@mrclrchtr/supi-tree-sitter/src/operation-support.ts +13 -6
  69. package/node_modules/@mrclrchtr/supi-tree-sitter/src/provider/tree-sitter-provider.ts +19 -1
  70. package/node_modules/@mrclrchtr/supi-tree-sitter/src/session/runtime-controller.ts +18 -4
  71. package/node_modules/@mrclrchtr/supi-tree-sitter/src/session/session.ts +10 -3
  72. package/node_modules/@mrclrchtr/supi-tree-sitter/src/session/structural-worker-client.ts +17 -2
  73. package/node_modules/@mrclrchtr/supi-tree-sitter/src/session/structural-worker-process.ts +22 -5
  74. package/node_modules/@mrclrchtr/supi-tree-sitter/src/session/structural-worker-protocol.ts +36 -1
  75. package/node_modules/@mrclrchtr/supi-tree-sitter/src/syntax-errors.ts +73 -0
  76. package/node_modules/@mrclrchtr/supi-tree-sitter/src/syntax-node.ts +4 -0
  77. package/node_modules/@mrclrchtr/supi-tree-sitter/src/tool/call-sites.ts +15 -9
  78. package/node_modules/@mrclrchtr/supi-tree-sitter/src/tool/callees.ts +24 -15
  79. package/node_modules/@mrclrchtr/supi-tree-sitter/src/tool/exports.ts +8 -1
  80. package/node_modules/@mrclrchtr/supi-tree-sitter/src/tool/imports.ts +233 -7
  81. package/node_modules/@mrclrchtr/supi-tree-sitter/src/tool/node-at.ts +7 -3
  82. package/node_modules/@mrclrchtr/supi-tree-sitter/src/tool/outline-expansion.ts +78 -0
  83. package/node_modules/@mrclrchtr/supi-tree-sitter/src/tool/outline-jvm.ts +25 -4
  84. package/node_modules/@mrclrchtr/supi-tree-sitter/src/tool/outline-nested.ts +390 -0
  85. package/node_modules/@mrclrchtr/supi-tree-sitter/src/tool/outline.ts +49 -28
  86. package/node_modules/@mrclrchtr/supi-tree-sitter/src/types.ts +16 -0
  87. package/node_modules/@mrclrchtr/supi-tree-sitter/src/worker/process-host.mjs +61 -24
  88. package/node_modules/@mrclrchtr/supi-tree-sitter/src/worker/runtime.ts +44 -10
  89. package/node_modules/@mrclrchtr/supi-tree-sitter/src/worker/service.ts +13 -9
  90. package/node_modules/@mrclrchtr/supi-tree-sitter/src/worker/worker-main.ts +15 -2
  91. package/node_modules/ignore/README.md +61 -6
  92. package/node_modules/ignore/index.d.ts +55 -20
  93. package/node_modules/ignore/index.js +93 -67
  94. package/node_modules/ignore/legacy.js +109 -85
  95. package/node_modules/ignore/package.json +1 -1
  96. package/package.json +5 -5
  97. package/src/analysis/refactor/apply.ts +35 -14
  98. package/src/analysis/relations/callees.ts +9 -2
  99. package/src/analysis/relations/implementations.ts +7 -2
  100. package/src/analysis/search/pattern-analysis.ts +90 -12
  101. package/src/analysis/search/pattern.ts +1 -0
  102. package/src/analysis/target/anchored-structural.ts +1 -0
  103. package/src/analysis/target/discovery.ts +29 -0
  104. package/src/analysis/target/file.ts +19 -9
  105. package/src/analysis/target/types.ts +5 -0
  106. package/src/config.ts +46 -7
  107. package/src/session/graph/collect.ts +2 -2
  108. package/src/session/graph-types.ts +6 -0
  109. package/src/session/inspect/collect.ts +35 -20
  110. package/src/session/inspect-types.ts +9 -2
  111. package/src/session/orientation/collect.ts +90 -18
  112. package/src/session/orientation/context-sections.ts +22 -1
  113. package/src/session/orientation/gather.ts +46 -6
  114. package/src/session/orientation-types.ts +7 -1
  115. package/src/session/refactor-plans.ts +17 -0
  116. package/src/session/refactor-workflow.ts +13 -6
  117. package/src/session/target-store.ts +5 -0
  118. package/src/session/target-workflow.ts +3 -0
  119. package/src/substrate/workspace-provider-host.ts +22 -2
  120. package/src/tool/code_find/markdown.ts +17 -4
  121. package/src/tool/code_find/result.ts +17 -3
  122. package/src/tool/code_graph/details.ts +2 -0
  123. package/src/tool/code_graph/display.ts +1 -0
  124. package/src/tool/code_graph/format.ts +1 -0
  125. package/src/tool/code_graph/result.ts +32 -6
  126. package/src/tool/code_inspect/markdown.ts +15 -1
  127. package/src/tool/code_inspect/result.ts +11 -0
  128. package/src/tool/code_orientation/result.ts +4 -2
  129. package/src/tool/code_resolve/markdown.ts +34 -14
  130. package/src/tool/code_resolve/result.ts +7 -3
  131. package/src/tool/result/types.ts +20 -2
  132. package/src/ui/tui/display.ts +2 -1
  133. package/node_modules/@mrclrchtr/supi-lsp/node_modules/ignore/LICENSE-MIT +0 -21
  134. package/node_modules/@mrclrchtr/supi-lsp/node_modules/ignore/README.md +0 -501
  135. package/node_modules/@mrclrchtr/supi-lsp/node_modules/ignore/index.d.ts +0 -81
  136. package/node_modules/@mrclrchtr/supi-lsp/node_modules/ignore/index.js +0 -1566
  137. package/node_modules/@mrclrchtr/supi-lsp/node_modules/ignore/legacy.js +0 -1346
  138. package/node_modules/@mrclrchtr/supi-lsp/node_modules/ignore/package.json +0 -93
@@ -59,19 +59,26 @@ async function collectNode(
59
59
  input.character,
60
60
  input.requestControl,
61
61
  );
62
- if (result.kind !== "success") return unavailableCodeQuery(result.message);
63
- return {
64
- kind: "completed",
65
- data: {
66
- type: result.data.type,
67
- text: result.data.text,
68
- startLine: result.data.startLine,
69
- startCharacter: result.data.startCharacter,
70
- endLine: result.data.endLine,
71
- endCharacter: result.data.endCharacter,
72
- ancestry: result.data.ancestry ?? [],
73
- },
62
+ if (result.kind !== "success" && result.kind !== "partial") {
63
+ return unavailableCodeQuery(result.message);
64
+ }
65
+ const data: InspectNode = {
66
+ type: result.data.type,
67
+ text: result.data.text,
68
+ startLine: result.data.startLine,
69
+ startCharacter: result.data.startCharacter,
70
+ endLine: result.data.endLine,
71
+ endCharacter: result.data.endCharacter,
72
+ ancestry: result.data.ancestry ?? [],
74
73
  };
74
+ return result.kind === "partial"
75
+ ? {
76
+ kind: "partial",
77
+ data,
78
+ reason: result.reason,
79
+ recovery: { file: result.file, errorRanges: result.errorRanges },
80
+ }
81
+ : { kind: "completed", data };
75
82
  } catch (error) {
76
83
  if (isCodeRequestInterruption(error, input.requestControl)) throw error;
77
84
  return unavailableCodeQuery(failureReason("Structural node lookup", error));
@@ -84,14 +91,21 @@ async function collectEnclosingSymbol(
84
91
  if (!input.structural) return unavailableCodeQuery("No structural outline provider is active.");
85
92
  try {
86
93
  const result = await input.structural.outline(input.file, input.requestControl);
87
- if (result.kind !== "success") return unavailableCodeQuery(result.message);
88
- return {
89
- kind: "completed",
90
- data: narrowestEnclosingSymbol(result.data, {
91
- line: input.line,
92
- character: input.character,
93
- }),
94
- };
94
+ if (result.kind !== "success" && result.kind !== "partial") {
95
+ return unavailableCodeQuery(result.message);
96
+ }
97
+ const symbol = narrowestEnclosingSymbol(result.data, {
98
+ line: input.line,
99
+ character: input.character,
100
+ });
101
+ return result.kind === "partial"
102
+ ? {
103
+ kind: "partial",
104
+ data: symbol,
105
+ reason: result.reason,
106
+ recovery: { file: result.file, errorRanges: result.errorRanges },
107
+ }
108
+ : { kind: "completed", data: symbol };
95
109
  } catch (error) {
96
110
  if (isCodeRequestInterruption(error, input.requestControl)) throw error;
97
111
  return unavailableCodeQuery(failureReason("Structural outline lookup", error));
@@ -209,6 +223,7 @@ function flattenOutline(
209
223
  const candidate: OutlineCandidate = {
210
224
  name: item.name,
211
225
  kind: item.kind,
226
+ ...(item.nativeKind ? { nativeKind: item.nativeKind } : {}),
212
227
  startLine: item.startLine,
213
228
  startCharacter: item.startCharacter,
214
229
  endLine: item.endLine,
@@ -1,4 +1,8 @@
1
- import type { CodeQueryResult, ConfidenceMode } from "@mrclrchtr/supi-code-runtime/api";
1
+ import type {
2
+ CodeQueryResult,
3
+ ConfidenceMode,
4
+ SourceRange,
5
+ } from "@mrclrchtr/supi-code-runtime/api";
2
6
  import type { SourcePointInput } from "./target-input.ts";
3
7
 
4
8
  /** Canonical code_inspect workflow input. */
@@ -7,7 +11,9 @@ export interface InspectWorkflowInput {
7
11
  readonly maxResults?: number;
8
12
  }
9
13
 
10
- export type InspectObservation<T> = CodeQueryResult<T>;
14
+ export type InspectObservation<T> = CodeQueryResult<T> & {
15
+ readonly recovery?: { readonly file: string; readonly errorRanges: readonly SourceRange[] };
16
+ };
11
17
 
12
18
  export interface InspectNode {
13
19
  readonly type: string;
@@ -28,6 +34,7 @@ export interface InspectNode {
28
34
  export interface InspectEnclosingSymbol {
29
35
  readonly name: string;
30
36
  readonly kind: string;
37
+ readonly nativeKind?: string;
31
38
  readonly startLine: number;
32
39
  readonly startCharacter: number;
33
40
  readonly endLine: number;
@@ -1,7 +1,7 @@
1
1
  // biome-ignore-all lint/style/noExcessiveLinesPerFile: symbol-orientation section builders stay together to preserve one rendering contract
2
2
  import { existsSync, readFileSync } from "node:fs";
3
3
  import * as path from "node:path";
4
- import type { ConfidenceMode } from "@mrclrchtr/supi-code-runtime/api";
4
+ import type { ConfidenceMode, SourceRange } from "@mrclrchtr/supi-code-runtime/api";
5
5
  import { isCodeRequestInterruption } from "@mrclrchtr/supi-code-runtime/api";
6
6
  import { uriToFile } from "@mrclrchtr/supi-core/path";
7
7
  import type { Diagnostic } from "@mrclrchtr/supi-lsp/api";
@@ -35,6 +35,7 @@ interface TargetSectionCollection {
35
35
  readonly status: "complete" | "partial" | "unavailable";
36
36
  readonly reason: string | null;
37
37
  readonly evidenceLists: readonly EvidenceListMetadata[];
38
+ readonly errorRanges?: readonly SourceRange[];
38
39
  }
39
40
 
40
41
  const DEFAULT_TARGET_SECTIONS: OrientationSection[] = ["defs", "docs", "diagnostics"];
@@ -165,7 +166,12 @@ async function buildEnrichedDefsSection(
165
166
  limit: number,
166
167
  ): Promise<TargetSectionCollection> {
167
168
  const items = buildDefinitionItems(target, deps.cwd, treeContext);
168
- const contextHasSemanticEvidence = Boolean(
169
+ const recovery = treeContext?.recovery ?? [];
170
+ const recoveryReason = recovery
171
+ .map(({ operation, reason }) => `${operation}: ${reason}`)
172
+ .join("; ");
173
+ const recoveryRanges = uniqueRecoveryRanges(recovery);
174
+ const hasSemanticContext = Boolean(
169
175
  treeContext?.hover || (treeContext?.definition?.length ?? 0) > 0,
170
176
  );
171
177
  const hasStructuralEvidence = hasRenderableItems(items);
@@ -178,30 +184,75 @@ async function buildEnrichedDefsSection(
178
184
  );
179
185
  }
180
186
  if (deps.lspRuntime.kind !== "ready") {
181
- return {
187
+ return unavailableDefinitionCollection({
182
188
  items,
183
189
  hasStructuralEvidence,
184
- hasSemanticEvidence: contextHasSemanticEvidence,
185
- status: contextHasSemanticEvidence ? "partial" : "unavailable",
186
- reason: deps.semanticReadinessReason ?? "Definition targets require a live language server.",
187
- evidenceLists: [],
188
- };
190
+ hasSemanticContext,
191
+ recoveryReason,
192
+ recoveryRanges,
193
+ readinessReason: deps.semanticReadinessReason ?? null,
194
+ });
189
195
  }
190
-
191
196
  const definitions = await collectDefinitionTargets(target, deps, limit);
192
- if (definitions.items.length > 0) {
193
- if (items.length > 0) items.push({ kind: "blank" });
194
- items.push({ kind: "paragraph", text: "**Definition:**" }, ...definitions.items);
195
- }
196
- const hasSemanticEvidence = contextHasSemanticEvidence || definitions.hasSemanticEvidence;
197
- return {
197
+ return mergeDefinitionCollection({
198
198
  items,
199
+ definitions,
199
200
  hasStructuralEvidence,
201
+ hasSemanticContext,
202
+ recoveryReason,
203
+ recoveryRanges,
204
+ });
205
+ }
206
+
207
+ function unavailableDefinitionCollection(input: {
208
+ items: OrientationItem[];
209
+ hasStructuralEvidence: boolean;
210
+ hasSemanticContext: boolean;
211
+ recoveryReason: string;
212
+ recoveryRanges: readonly SourceRange[];
213
+ readinessReason: string | null;
214
+ }): TargetSectionCollection {
215
+ return {
216
+ items: input.items,
217
+ hasStructuralEvidence: input.hasStructuralEvidence,
218
+ hasSemanticEvidence: input.hasSemanticContext,
219
+ status: input.recoveryReason || input.hasSemanticContext ? "partial" : "unavailable",
220
+ reason: [
221
+ input.recoveryReason || null,
222
+ input.readinessReason ?? "Definition targets require a live language server.",
223
+ ]
224
+ .filter(Boolean)
225
+ .join(" "),
226
+ evidenceLists: [],
227
+ ...(input.recoveryRanges.length > 0 ? { errorRanges: [...input.recoveryRanges] } : {}),
228
+ };
229
+ }
230
+
231
+ function mergeDefinitionCollection(input: {
232
+ items: OrientationItem[];
233
+ definitions: Awaited<ReturnType<typeof collectDefinitionTargets>>;
234
+ hasStructuralEvidence: boolean;
235
+ hasSemanticContext: boolean;
236
+ recoveryReason: string;
237
+ recoveryRanges: readonly SourceRange[];
238
+ }): TargetSectionCollection {
239
+ if (input.definitions.items.length > 0) {
240
+ if (input.items.length > 0) input.items.push({ kind: "blank" });
241
+ input.items.push({ kind: "paragraph", text: "**Definition:**" }, ...input.definitions.items);
242
+ }
243
+ const hasSemanticEvidence = input.hasSemanticContext || input.definitions.hasSemanticEvidence;
244
+ return {
245
+ items: input.items,
246
+ hasStructuralEvidence: input.hasStructuralEvidence,
200
247
  hasSemanticEvidence,
201
248
  status:
202
- definitions.status === "unavailable" && hasSemanticEvidence ? "partial" : definitions.status,
203
- reason: definitions.reason,
204
- evidenceLists: definitions.evidenceLists,
249
+ input.recoveryReason || (input.definitions.status === "unavailable" && hasSemanticEvidence)
250
+ ? "partial"
251
+ : input.definitions.status,
252
+ reason:
253
+ [input.recoveryReason || null, input.definitions.reason].filter(Boolean).join(" ") || null,
254
+ evidenceLists: input.definitions.evidenceLists,
255
+ ...(input.recoveryRanges.length > 0 ? { errorRanges: [...input.recoveryRanges] } : {}),
205
256
  };
206
257
  }
207
258
 
@@ -504,6 +555,16 @@ async function maybeGatherTreeContext(
504
555
  );
505
556
  }
506
557
 
558
+ function uniqueRecoveryRanges(
559
+ recovery: readonly { errorRanges: readonly SourceRange[] }[],
560
+ ): SourceRange[] {
561
+ const ranges = new Map<string, SourceRange>();
562
+ for (const item of recovery) {
563
+ for (const range of item.errorRanges) ranges.set(JSON.stringify(range), range);
564
+ }
565
+ return [...ranges.values()];
566
+ }
567
+
507
568
  function buildDefinitionItems(
508
569
  target: Readonly<TargetStoreEntry> | null | undefined,
509
570
  cwd: string,
@@ -529,6 +590,16 @@ function buildDefinitionItems(
529
590
  if (treeContext?.nodeInfo?.type) {
530
591
  items.push({ kind: "list-item", text: `Node: \`${treeContext.nodeInfo.type}\`` });
531
592
  }
593
+ for (const recovery of treeContext?.recovery ?? []) {
594
+ const locations = recovery.errorRanges.map(
595
+ (range) => `L${range.start.line + 1}:${range.start.character + 1}`,
596
+ );
597
+ const suffix = locations.length > 0 ? ` Errors: ${locations.join(", ")}.` : "";
598
+ items.push({
599
+ kind: "paragraph",
600
+ text: `Partial ${recovery.operation} evidence in \`${recovery.file}\`: ${recovery.reason}.${suffix}`,
601
+ });
602
+ }
532
603
  if (treeContext?.hover?.contents) {
533
604
  items.push(...hoverItems(treeContext.hover.contents));
534
605
  }
@@ -682,6 +753,7 @@ function targetSectionResult(
682
753
  confidence,
683
754
  provenance,
684
755
  evidenceLists: collection.evidenceLists,
756
+ ...(collection.errorRanges ? { errorRanges: [...collection.errorRanges] } : {}),
685
757
  items: collection.items,
686
758
  },
687
759
  hasStructuralEvidence: collection.hasStructuralEvidence,
@@ -5,6 +5,7 @@ import {
5
5
  type CodeResult,
6
6
  type ConfidenceMode,
7
7
  isCodeRequestInterruption,
8
+ type SourceRange,
8
9
  } from "@mrclrchtr/supi-code-runtime/api";
9
10
  import { isWithinOrEqual } from "@mrclrchtr/supi-core/project";
10
11
  import type { WorkspaceLspRuntimeState } from "@mrclrchtr/supi-lsp/api";
@@ -37,6 +38,7 @@ export interface ListSectionInput<T> {
37
38
  readonly reason?: string | null;
38
39
  readonly unknownRemainder?: boolean;
39
40
  readonly partialReason?: EvidencePartialReason;
41
+ readonly errorRanges?: readonly SourceRange[];
40
42
  }
41
43
 
42
44
  /** Start a context-Oriented document with one factual focus title. */
@@ -64,6 +66,7 @@ export function appendList<T>(
64
66
  ...list.metadata,
65
67
  totalCount: null,
66
68
  partialReason: input.partialReason ?? "filesystem-error",
69
+ ...(input.reason ? { partialMessage: input.reason } : {}),
67
70
  }
68
71
  : list.metadata;
69
72
  builder.sections.push({
@@ -75,6 +78,7 @@ export function appendList<T>(
75
78
  provenance: input.provenance,
76
79
  evidenceLists: [{ ...metadata, key: input.key }],
77
80
  items: list.items.map((item) => ({ kind: "list-item", text: input.render(item) })),
81
+ ...(input.errorRanges ? { errorRanges: [...input.errorRanges] } : {}),
78
82
  });
79
83
  }
80
84
 
@@ -226,7 +230,7 @@ async function appendStructuralList<T>(
226
230
  });
227
231
  return;
228
232
  }
229
- if (result.kind !== "success") {
233
+ if (result.kind !== "success" && result.kind !== "partial") {
230
234
  appendUnavailable(builder, {
231
235
  key: input.key,
232
236
  title: input.title,
@@ -235,6 +239,14 @@ async function appendStructuralList<T>(
235
239
  });
236
240
  return;
237
241
  }
242
+ const recoveryLocations =
243
+ result.kind === "partial"
244
+ ? result.errorRanges.map((range) => `L${range.start.line + 1}:${range.start.character + 1}`)
245
+ : [];
246
+ const recoveryReason =
247
+ result.kind === "partial"
248
+ ? `${result.reason}${recoveryLocations.length ? ` Error locations: ${recoveryLocations.join(", ")}.` : ""}`
249
+ : null;
238
250
  appendList(builder, {
239
251
  key: input.key,
240
252
  title: input.title,
@@ -242,6 +254,15 @@ async function appendStructuralList<T>(
242
254
  render: input.render,
243
255
  confidence: "structural",
244
256
  provenance: [{ source: "structural", capability: "tree-sitter" }],
257
+ ...(result.kind === "partial"
258
+ ? {
259
+ status: "partial" as const,
260
+ reason: recoveryReason,
261
+ unknownRemainder: true,
262
+ partialReason: "provider-limited" as const,
263
+ errorRanges: result.errorRanges,
264
+ }
265
+ : {}),
245
266
  });
246
267
  }
247
268
 
@@ -46,6 +46,13 @@ export interface SubstrateContext {
46
46
  hover: { contents: string; range?: SourceRange } | null;
47
47
  /** Best-effort LSP definition targets at the anchored position. `null` when unavailable. */
48
48
  definition: Array<{ uri: string; range: SourceRange }> | null;
49
+ /** Structural recovery from independently queried source operations. */
50
+ recovery: Array<{
51
+ operation: "nodeAt" | "outline" | "imports" | "exports";
52
+ file: string;
53
+ reason: string;
54
+ errorRanges: readonly SourceRange[];
55
+ }>;
49
56
  }
50
57
 
51
58
  /**
@@ -74,13 +81,22 @@ export async function gatherSubstrateContext(
74
81
  let exports: SubstrateContext["exports"] = [];
75
82
  let hover: SubstrateContext["hover"] = null;
76
83
  let definition: SubstrateContext["definition"] = null;
84
+ const recovery: SubstrateContext["recovery"] = [];
77
85
 
78
- if (!provider) return { nodeInfo, outline, imports, exports, hover, definition: null };
86
+ if (!provider) return { nodeInfo, outline, imports, exports, hover, definition: null, recovery };
79
87
 
80
88
  try {
81
89
  if (positionStrict) {
82
90
  const nodeResult = await provider.nodeAt(relPath, line, character, requestControl);
83
- if (nodeResult.kind === "success") {
91
+ if (nodeResult.kind === "partial") {
92
+ recovery.push({
93
+ operation: "nodeAt",
94
+ file: nodeResult.file,
95
+ reason: nodeResult.reason,
96
+ errorRanges: nodeResult.errorRanges,
97
+ });
98
+ }
99
+ if (nodeResult.kind === "success" || nodeResult.kind === "partial") {
84
100
  nodeInfo = {
85
101
  type: nodeResult.data.type,
86
102
  text: nodeResult.data.text,
@@ -92,7 +108,15 @@ export async function gatherSubstrateContext(
92
108
  }
93
109
 
94
110
  const outlineResult = await provider.outline(relPath, requestControl);
95
- if (outlineResult.kind === "success") {
111
+ if (outlineResult.kind === "partial") {
112
+ recovery.push({
113
+ operation: "outline",
114
+ file: outlineResult.file,
115
+ reason: outlineResult.reason,
116
+ errorRanges: outlineResult.errorRanges,
117
+ });
118
+ }
119
+ if (outlineResult.kind === "success" || outlineResult.kind === "partial") {
96
120
  outline = outlineResult.data.map((item) => ({
97
121
  name: item.name,
98
122
  kind: item.kind,
@@ -102,12 +126,28 @@ export async function gatherSubstrateContext(
102
126
  }
103
127
 
104
128
  const importsResult = await provider.imports(relPath, requestControl);
105
- if (importsResult.kind === "success") {
129
+ if (importsResult.kind === "partial") {
130
+ recovery.push({
131
+ operation: "imports",
132
+ file: importsResult.file,
133
+ reason: importsResult.reason,
134
+ errorRanges: importsResult.errorRanges,
135
+ });
136
+ }
137
+ if (importsResult.kind === "success" || importsResult.kind === "partial") {
106
138
  imports = importsResult.data;
107
139
  }
108
140
 
109
141
  const exportsResult = await provider.exports(relPath, requestControl);
110
- if (exportsResult.kind === "success") {
142
+ if (exportsResult.kind === "partial") {
143
+ recovery.push({
144
+ operation: "exports",
145
+ file: exportsResult.file,
146
+ reason: exportsResult.reason,
147
+ errorRanges: exportsResult.errorRanges,
148
+ });
149
+ }
150
+ if (exportsResult.kind === "success" || exportsResult.kind === "partial") {
111
151
  exports = exportsResult.data.map((item) => ({
112
152
  name: item.name,
113
153
  kind: item.kind,
@@ -151,5 +191,5 @@ export async function gatherSubstrateContext(
151
191
  // Provider not available
152
192
  }
153
193
 
154
- return { nodeInfo, outline, imports, exports, hover, definition };
194
+ return { nodeInfo, outline, imports, exports, hover, definition, recovery };
155
195
  }
@@ -1,4 +1,8 @@
1
- import type { CodeRequestControl, ConfidenceMode } from "@mrclrchtr/supi-code-runtime/api";
1
+ import type {
2
+ CodeRequestControl,
3
+ ConfidenceMode,
4
+ SourceRange,
5
+ } from "@mrclrchtr/supi-code-runtime/api";
2
6
  import type { WorkspaceLspRuntimeState } from "@mrclrchtr/supi-lsp/api";
3
7
  import type { ArchitectureModel } from "../analysis/architecture/model.ts";
4
8
  import type { EvidenceListMetadata } from "../analysis/evidence.ts";
@@ -84,6 +88,8 @@ export interface OrientationSectionData {
84
88
  readonly title: string;
85
89
  readonly status: "complete" | "partial" | "unavailable";
86
90
  readonly reason: string | null;
91
+ /** Syntax recovery ranges for partial structural evidence, in 0-based coordinates. */
92
+ readonly errorRanges?: readonly SourceRange[];
87
93
  /** Semantic/structural confidence only; filesystem/config facts use unavailable. */
88
94
  readonly confidence: ConfidenceMode;
89
95
  readonly provenance: readonly OrientationProvenance[];
@@ -37,6 +37,23 @@ export function computeFileFingerprint(file: string): string {
37
37
  }
38
38
  }
39
39
 
40
+ /** Check that request-scoped content evidence still matches the plan inputs. */
41
+ export function validateSynchronizedContentFingerprints(
42
+ preconditions: WorkspaceEdit["documentPreconditions"],
43
+ fileFingerprints: readonly { file: string; fingerprint: string }[],
44
+ ): string | null {
45
+ const fingerprints = new Map(
46
+ fileFingerprints.map(({ file, fingerprint }) => [file, fingerprint]),
47
+ );
48
+ for (const precondition of preconditions ?? []) {
49
+ if (precondition.kind !== "open-document-content") continue;
50
+ if (fingerprints.get(precondition.file) !== precondition.fingerprint) {
51
+ return `File ${precondition.file} changed after the semantic input snapshot. Request a new rename plan.`;
52
+ }
53
+ }
54
+ return null;
55
+ }
56
+
40
57
  /** Generate a stable plan id from operation details. */
41
58
  // biome-ignore lint/complexity/useMaxParams: plan id construction needs all positional args
42
59
  export function generatePlanId(
@@ -29,6 +29,7 @@ import {
29
29
  generatePlanId,
30
30
  isPlanFresh,
31
31
  type RefactorPlan,
32
+ validateSynchronizedContentFingerprints,
32
33
  } from "./refactor-plans.ts";
33
34
  import {
34
35
  PUBLIC_REFACTOR_OPERATION_NAMES,
@@ -189,6 +190,17 @@ async function planResolvedRefactor(
189
190
  result.authorizedMutationRoots,
190
191
  );
191
192
  if (authority.kind === "unavailable") return authority;
193
+ const fileFingerprints = collectFileFingerprints(
194
+ result.edits.edits,
195
+ sectionRename.sourceFingerprint
196
+ ? { file, fingerprint: sectionRename.sourceFingerprint }
197
+ : undefined,
198
+ );
199
+ const snapshotError = validateSynchronizedContentFingerprints(
200
+ result.edits.documentPreconditions,
201
+ fileFingerprints,
202
+ );
203
+ if (snapshotError) return { kind: "unavailable", reason: snapshotError };
192
204
 
193
205
  const plan: RefactorPlan = {
194
206
  id: generatePlanId(
@@ -206,12 +218,7 @@ async function planResolvedRefactor(
206
218
  edits: result.edits,
207
219
  evidenceSource: sectionRename.evidenceSource,
208
220
  authorizedMutationRoots: authority.canonicalRoots,
209
- fileFingerprints: collectFileFingerprints(
210
- result.edits.edits,
211
- sectionRename.sourceFingerprint
212
- ? { file, fingerprint: sectionRename.sourceFingerprint }
213
- : undefined,
214
- ),
221
+ fileFingerprints,
215
222
  createdAt: Date.now(),
216
223
  };
217
224
  deps.storePlan(plan);
@@ -50,6 +50,8 @@ export interface TargetStoreEntry {
50
50
  displayCharacter: number;
51
51
  name: string | null;
52
52
  kind: string | null;
53
+ /** Structural source-language declaration kind; it does not change identity. */
54
+ nativeKind?: string;
53
55
  confidence: ConfidenceMode;
54
56
  /** Monotonic provider families that established this target. */
55
57
  provenance: readonly TargetProviderProvenance[];
@@ -82,6 +84,8 @@ export interface TargetRegistrationInput {
82
84
  displayCharacter: number;
83
85
  name: string | null;
84
86
  kind: string | null;
87
+ /** Structural source-language declaration kind; it does not change identity. */
88
+ nativeKind?: string;
85
89
  /** Provider-independent declaration kind used only for stable identity. */
86
90
  identityKind?: string;
87
91
  confidence: ConfidenceMode;
@@ -251,6 +255,7 @@ export function registerWorkflowTarget(
251
255
  displayCharacter: input.displayCharacter,
252
256
  name: input.name,
253
257
  kind: input.kind,
258
+ ...(input.nativeKind ? { nativeKind: input.nativeKind } : {}),
254
259
  confidence: input.confidence,
255
260
  provenance: normalizeProvenance(input.provenance),
256
261
  anchorKind: input.anchorKind,
@@ -59,6 +59,7 @@ export type TargetWorkflowOutcome =
59
59
  totalCount: number;
60
60
  omittedCount: number;
61
61
  unknownNestingCount: number;
62
+ partial?: ResolvedTargetGroupData["partial"];
62
63
  }
63
64
  | ({
64
65
  kind: "disambiguation";
@@ -353,6 +354,7 @@ function registerTargetGroup(
353
354
  totalCount,
354
355
  omittedCount: totalCount - targets.length,
355
356
  unknownNestingCount: group.unknownNestingCount,
357
+ ...(group.partial ? { partial: group.partial } : {}),
356
358
  });
357
359
  }
358
360
 
@@ -386,6 +388,7 @@ function registerFromTargetData(
386
388
  displayCharacter: target.displayCharacter,
387
389
  name: target.name,
388
390
  kind: target.kind,
391
+ nativeKind: target.nativeKind,
389
392
  identityKind: target.identityKind ?? canonicalDeclarationKind(target.kind),
390
393
  confidence: target.confidence,
391
394
  provenance: target.provenance,
@@ -1,6 +1,7 @@
1
1
  import { realpathSync } from "node:fs";
2
2
  import { homedir } from "node:os";
3
3
  import { resolve } from "node:path";
4
+ import type { CFamilyFileAssociationResolver } from "@mrclrchtr/supi-code-runtime/api";
4
5
  import { getDefaultWorkspaceRuntime } from "@mrclrchtr/supi-code-runtime/api";
5
6
  import {
6
7
  type AutomaticLspPathPolicy,
@@ -8,6 +9,7 @@ import {
8
9
  LspRuntimeController,
9
10
  } from "@mrclrchtr/supi-lsp/api";
10
11
  import { TreeSitterRuntimeController } from "@mrclrchtr/supi-tree-sitter/api";
12
+ import { loadProjectFileAssociations } from "../config.ts";
11
13
 
12
14
  const HOSTS = Symbol.for("supi-code-intelligence/workspace-provider-hosts");
13
15
  const CLOSING_HOSTS = Symbol.for("supi-code-intelligence/closing-workspace-provider-hosts");
@@ -22,6 +24,8 @@ export interface WorkspaceProviderHostLease {
22
24
  lspController: LspRuntimeController | null;
23
25
  /** Immutable automatic exclusion policy captured for this lease. */
24
26
  automaticPathPolicy: AutomaticLspPathPolicy;
27
+ /** Shared immutable C-family language snapshot captured by the host. */
28
+ fileAssociations: CFamilyFileAssociationResolver;
25
29
  sentinelSnapshot: Map<string, number>;
26
30
  release(): Promise<void>;
27
31
  }
@@ -66,6 +70,8 @@ class WorkspaceProviderHost {
66
70
  #settledStart = Promise.resolve();
67
71
  #closed = false;
68
72
  #automaticPathPolicies = new Map<boolean, AutomaticLspPathPolicy>();
73
+ #fileAssociations: CFamilyFileAssociationResolver | null = null;
74
+ #projectTrusted: boolean | null = null;
69
75
  /** One configuration home owns all providers and policies until shutdown. */
70
76
  #homeDir: string | null = null;
71
77
 
@@ -81,6 +87,13 @@ class WorkspaceProviderHost {
81
87
  `Workspace ${this.cwd} already uses configuration home ${this.#homeDir}. Cannot use ${normalizedHome} until all existing provider leases are released.`,
82
88
  );
83
89
  }
90
+ if (this.#projectTrusted !== null && this.#projectTrusted !== projectTrusted) {
91
+ throw new Error(
92
+ `Workspace ${this.cwd} already uses projectTrusted=${this.#projectTrusted}. Cannot use projectTrusted=${projectTrusted} until all existing provider leases are released.`,
93
+ );
94
+ }
95
+ const fileAssociations =
96
+ this.#fileAssociations ?? loadProjectFileAssociations(this.cwd, projectTrusted);
84
97
  const automaticPathPolicy =
85
98
  this.#automaticPathPolicies.get(projectTrusted) ??
86
99
  createDefaultAutomaticLspPathPolicy(this.cwd, {
@@ -88,11 +101,15 @@ class WorkspaceProviderHost {
88
101
  homeDir: normalizedHome,
89
102
  });
90
103
  this.#homeDir = normalizedHome;
104
+ this.#projectTrusted = projectTrusted;
105
+ this.#fileAssociations = fileAssociations;
91
106
  this.#automaticPathPolicies.set(projectTrusted, automaticPathPolicy);
92
107
  // Count this pending acquirer before awaiting startup so the final active lease cannot shut it down.
93
108
  this.#leases++;
94
109
  this.#settledStart = this.#settledStart
95
- .then(() => this.#startMissing(projectTrusted, automaticPathPolicy, normalizedHome))
110
+ .then(() =>
111
+ this.#startMissing(projectTrusted, automaticPathPolicy, fileAssociations, normalizedHome),
112
+ )
96
113
  .catch(() => undefined);
97
114
  await this.#settledStart;
98
115
  let released = false;
@@ -100,6 +117,7 @@ class WorkspaceProviderHost {
100
117
  cwd: this.cwd,
101
118
  lspController: projectTrusted ? this.#lsp : null,
102
119
  automaticPathPolicy,
120
+ fileAssociations,
103
121
  sentinelSnapshot:
104
122
  projectTrusted && this.#lsp?.kind === "ready"
105
123
  ? (this.#lsp.workspaceRuntime?.scanWorkspaceSentinels() ?? new Map())
@@ -127,12 +145,13 @@ class WorkspaceProviderHost {
127
145
  async #startMissing(
128
146
  projectTrusted: boolean,
129
147
  automaticPathPolicy: AutomaticLspPathPolicy,
148
+ fileAssociations: CFamilyFileAssociationResolver,
130
149
  homeDir?: string,
131
150
  ): Promise<void> {
132
151
  const runtime = getDefaultWorkspaceRuntime();
133
152
  if (!this.#treeStarted) {
134
153
  this.#treeStarted = true;
135
- this.#tree = new TreeSitterRuntimeController(this.cwd, runtime);
154
+ this.#tree = new TreeSitterRuntimeController(this.cwd, runtime, fileAssociations);
136
155
  await this.#tree.start().catch(() => undefined);
137
156
  }
138
157
  if (!projectTrusted || this.#lspStarted) return;
@@ -141,6 +160,7 @@ class WorkspaceProviderHost {
141
160
  automaticPathPolicy,
142
161
  projectTrusted,
143
162
  homeDir,
163
+ fileAssociations,
144
164
  });
145
165
  await this.#lsp.start().catch(() => undefined);
146
166
  }