@mrclrchtr/supi-code-intelligence 9.1.2 → 11.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.
Files changed (189) hide show
  1. package/README.md +99 -27
  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/smol-toml/LICENSE +24 -0
  92. package/node_modules/smol-toml/README.md +605 -0
  93. package/node_modules/smol-toml/dist/date.d.ts +41 -0
  94. package/node_modules/smol-toml/dist/date.js +156 -0
  95. package/node_modules/smol-toml/dist/error.d.ts +37 -0
  96. package/node_modules/smol-toml/dist/error.js +67 -0
  97. package/node_modules/smol-toml/dist/extract.js +293 -0
  98. package/node_modules/smol-toml/dist/index.cjs +771 -0
  99. package/node_modules/smol-toml/dist/index.d.ts +44 -0
  100. package/node_modules/smol-toml/dist/index.js +34 -0
  101. package/node_modules/smol-toml/dist/parse.d.ts +73 -0
  102. package/node_modules/smol-toml/dist/parse.js +164 -0
  103. package/node_modules/smol-toml/dist/primitive.js +151 -0
  104. package/node_modules/smol-toml/dist/stringify.d.ts +32 -0
  105. package/node_modules/smol-toml/dist/stringify.js +219 -0
  106. package/node_modules/smol-toml/dist/struct.js +156 -0
  107. package/node_modules/smol-toml/dist/util.d.ts +43 -0
  108. package/node_modules/smol-toml/dist/util.js +57 -0
  109. package/node_modules/smol-toml/package.json +68 -0
  110. package/package.json +9 -5
  111. package/src/analysis/refactor/apply.ts +35 -14
  112. package/src/analysis/relations/callees.ts +9 -2
  113. package/src/analysis/relations/implementations.ts +7 -2
  114. package/src/analysis/search/pattern-analysis.ts +90 -12
  115. package/src/analysis/search/pattern.ts +1 -0
  116. package/src/analysis/target/anchored-structural.ts +1 -0
  117. package/src/analysis/target/discovery.ts +29 -0
  118. package/src/analysis/target/file.ts +19 -9
  119. package/src/analysis/target/types.ts +5 -0
  120. package/src/analysis/workspace/exclusions.ts +35 -0
  121. package/src/analysis/workspace/git.ts +130 -0
  122. package/src/analysis/workspace/go-parser.ts +330 -0
  123. package/src/analysis/workspace/go.ts +154 -0
  124. package/src/analysis/workspace/index.ts +28 -0
  125. package/src/analysis/workspace/inventory.ts +316 -0
  126. package/src/analysis/workspace/membership.ts +223 -0
  127. package/src/analysis/workspace/metadata-types.ts +56 -0
  128. package/src/analysis/workspace/metadata-utils.ts +60 -0
  129. package/src/analysis/workspace/metadata.ts +148 -0
  130. package/src/analysis/workspace/node.ts +214 -0
  131. package/src/analysis/workspace/observe.ts +161 -0
  132. package/src/analysis/workspace/paths.ts +65 -0
  133. package/src/analysis/workspace/python.ts +158 -0
  134. package/src/analysis/workspace/relationships.ts +87 -0
  135. package/src/analysis/workspace/rust.ts +238 -0
  136. package/src/analysis/workspace/safe-path.ts +20 -0
  137. package/src/analysis/workspace/types.ts +245 -0
  138. package/src/app/app.ts +1 -0
  139. package/src/config.ts +50 -11
  140. package/src/extension.ts +16 -49
  141. package/src/overview/budget.ts +23 -0
  142. package/src/overview/collect.ts +22 -0
  143. package/src/session/graph/collect.ts +2 -2
  144. package/src/session/graph-types.ts +6 -0
  145. package/src/session/inspect/collect.ts +35 -20
  146. package/src/session/inspect-types.ts +9 -2
  147. package/src/session/orientation/collect.ts +90 -18
  148. package/src/session/orientation/context-sections.ts +22 -1
  149. package/src/session/orientation/gather.ts +46 -6
  150. package/src/session/orientation/workspace-context.ts +166 -0
  151. package/src/session/orientation-types.ts +15 -2
  152. package/src/session/orientation-workflow.ts +14 -3
  153. package/src/session/refactor-plans.ts +17 -0
  154. package/src/session/refactor-workflow.ts +13 -6
  155. package/src/session/session.ts +2 -3
  156. package/src/session/target-store.ts +5 -0
  157. package/src/session/target-workflow.ts +3 -0
  158. package/src/substrate/workspace-provider-host.ts +22 -2
  159. package/src/tool/code_find/markdown.ts +17 -4
  160. package/src/tool/code_find/result.ts +17 -3
  161. package/src/tool/code_graph/details.ts +2 -0
  162. package/src/tool/code_graph/display.ts +1 -0
  163. package/src/tool/code_graph/format.ts +1 -0
  164. package/src/tool/code_graph/result.ts +32 -6
  165. package/src/tool/code_inspect/markdown.ts +15 -1
  166. package/src/tool/code_inspect/result.ts +11 -0
  167. package/src/tool/code_orientation/execute.ts +8 -1
  168. package/src/tool/code_orientation/markdown.ts +58 -8
  169. package/src/tool/code_orientation/result.ts +15 -4
  170. package/src/tool/code_orientation/workspace-format.ts +74 -0
  171. package/src/tool/code_orientation/workspace-instructions.ts +105 -0
  172. package/src/tool/code_orientation/workspace-output.ts +118 -0
  173. package/src/tool/code_orientation/workspace-projects.ts +177 -0
  174. package/src/tool/code_orientation/workspace-sections.ts +217 -0
  175. package/src/tool/code_resolve/markdown.ts +34 -14
  176. package/src/tool/code_resolve/result.ts +7 -3
  177. package/src/tool/register.ts +2 -0
  178. package/src/tool/result/types.ts +20 -2
  179. package/src/types/execution.ts +2 -0
  180. package/src/ui/tui/display.ts +2 -1
  181. package/src/overview/overview-data.ts +0 -154
  182. package/src/overview/overview.ts +0 -91
  183. package/src/overview/types.ts +0 -23
  184. /package/node_modules/{@mrclrchtr/supi-lsp/node_modules/ignore → ignore}/LICENSE-MIT +0 -0
  185. /package/node_modules/{@mrclrchtr/supi-lsp/node_modules/ignore → ignore}/README.md +0 -0
  186. /package/node_modules/{@mrclrchtr/supi-lsp/node_modules/ignore → ignore}/index.d.ts +0 -0
  187. /package/node_modules/{@mrclrchtr/supi-lsp/node_modules/ignore → ignore}/index.js +0 -0
  188. /package/node_modules/{@mrclrchtr/supi-lsp/node_modules/ignore → ignore}/legacy.js +0 -0
  189. /package/node_modules/{@mrclrchtr/supi-lsp/node_modules/ignore → ignore}/package.json +0 -0
@@ -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
  }
@@ -0,0 +1,166 @@
1
+ import { existsSync, lstatSync, statSync } from "node:fs";
2
+ import * as path from "node:path";
3
+ import { loadAutomaticExclusionPatterns } from "@mrclrchtr/supi-core/config";
4
+ import ignore from "ignore";
5
+ import { isGitIgnoredDirectory } from "../../analysis/workspace/git.ts";
6
+ import { observeWorkspace } from "../../analysis/workspace/observe.ts";
7
+ import { assertUnlinkedPath } from "../../analysis/workspace/safe-path.ts";
8
+ import type { WorkspaceObservation } from "../../analysis/workspace/types.ts";
9
+ import type { OrientationResultData, OrientationWorkflowInput } from "../orientation-types.ts";
10
+ import type { WorkflowControl } from "../workflow-control.ts";
11
+
12
+ /** Captured facts for workspace and directory presentation; no provider or live state. */
13
+ export interface WorkspaceOrientationFacts {
14
+ readonly observation: WorkspaceObservation;
15
+ readonly cwd: string;
16
+ /** Absolute explicit focus, or null for the session working directory. */
17
+ readonly focus: string | null;
18
+ readonly maxResults: number;
19
+ readonly overview?: boolean;
20
+ }
21
+
22
+ /** Select the new navigation path without changing file or symbol-focused workflows. */
23
+ export async function orientWorkspaceContext(
24
+ request: OrientationWorkflowInput,
25
+ options: { cwd: string; homeDir?: string; projectTrusted: boolean },
26
+ control?: WorkflowControl,
27
+ ): Promise<
28
+ | { kind: "completed"; data: OrientationResultData; directory: string | null }
29
+ | { kind: "invalid-input"; message: string }
30
+ | null
31
+ > {
32
+ const selected = directoryFocus(request, options.cwd);
33
+ if (!selected || selected.kind === "invalid-input") return selected;
34
+ let focus = selected.path;
35
+ const exclude = loadAutomaticExclusionPatterns(options.cwd, options);
36
+ if (focus) await assertFocusPath(options.cwd, focus);
37
+ let observation = await initialObservation(options.cwd, focus, exclude, control);
38
+ if (request.focus && "module" in request.focus) {
39
+ const selected = resolveModule(observation, request.focus.module);
40
+ if (selected.kind === "invalid-input") return selected;
41
+ focus = selected.path;
42
+ }
43
+ if (focus) observation = await focusObservation(observation, focus, exclude, control);
44
+ return {
45
+ kind: "completed",
46
+ directory: focus,
47
+ data: workspaceOrientationData({
48
+ observation,
49
+ cwd: options.cwd,
50
+ focus,
51
+ maxResults: request.maxResults ?? 10,
52
+ }),
53
+ };
54
+ }
55
+
56
+ async function initialObservation(
57
+ cwd: string,
58
+ focus: string | null,
59
+ exclude: readonly string[],
60
+ control?: WorkflowControl,
61
+ ): Promise<WorkspaceObservation> {
62
+ const root = focus && !within(cwd, focus) ? focus : cwd;
63
+ const separate = root !== cwd;
64
+ return observeWorkspace(root, {
65
+ exclude: separate ? [] : exclude,
66
+ control,
67
+ prioritizeDirectory: !separate && focus ? focus : undefined,
68
+ includeIgnored: separate && (await isGitIgnoredDirectory(root, control)),
69
+ });
70
+ }
71
+
72
+ async function focusObservation(
73
+ observation: WorkspaceObservation,
74
+ focus: string,
75
+ exclude: readonly string[],
76
+ control?: WorkflowControl,
77
+ ): Promise<WorkspaceObservation> {
78
+ const inside = within(observation.root, focus);
79
+ const relative = path.relative(observation.root, focus).replaceAll(path.sep, "/");
80
+ await assertFocusPath(observation.root, focus);
81
+ const excluded =
82
+ inside &&
83
+ relative !== "" &&
84
+ ignore()
85
+ .add([...exclude])
86
+ .ignores(`${relative}/`);
87
+ const ignored = await isGitIgnoredDirectory(focus, control);
88
+ if (!inside || excluded || (ignored && !observation.inclusion.includeIgnored))
89
+ return observeWorkspace(focus, { includeIgnored: excluded || ignored, control });
90
+ return observation;
91
+ }
92
+
93
+ /** Check new path components from the shared ancestor, including external focuses. */
94
+ async function assertFocusPath(cwd: string, focus: string): Promise<void> {
95
+ let common = path.resolve(cwd);
96
+ while (!within(common, focus)) {
97
+ const parent = path.dirname(common);
98
+ if (parent === common) {
99
+ common = path.parse(focus).root;
100
+ break;
101
+ }
102
+ common = parent;
103
+ }
104
+ await assertUnlinkedPath(common, path.relative(common, focus).replaceAll(path.sep, "/"), true);
105
+ }
106
+
107
+ function directoryFocus(
108
+ request: OrientationWorkflowInput,
109
+ cwd: string,
110
+ ): { kind: "directory"; path: string | null } | { kind: "invalid-input"; message: string } | null {
111
+ if (!request.focus || "module" in request.focus) return { kind: "directory", path: null };
112
+ if ("target" in request.focus) return null;
113
+ const focus = path.resolve(cwd, request.focus.path.replace(/^@/, ""));
114
+ if (!existsSync(focus) || !statSync(focus).isDirectory()) return null;
115
+ if (lstatSync(focus).isSymbolicLink())
116
+ return { kind: "invalid-input", message: "Symbolic-link directory focus is not followed." };
117
+ return { kind: "directory", path: focus };
118
+ }
119
+
120
+ function resolveModule(
121
+ observation: WorkspaceObservation,
122
+ name: string,
123
+ ): { kind: "resolved"; path: string } | { kind: "invalid-input"; message: string } {
124
+ const matches = observation.projects.filter(
125
+ (project) =>
126
+ project.name === name ||
127
+ (project.kind === "node-package" && project.name?.replace(/^@[^/]+\//, "") === name),
128
+ );
129
+ if (matches.length === 1)
130
+ return { kind: "resolved", path: path.resolve(observation.root, matches[0].directory) };
131
+ return {
132
+ kind: "invalid-input",
133
+ message:
134
+ matches.length === 0
135
+ ? `Module focus not found: ${name}.`
136
+ : `Module focus is ambiguous: ${matches.map((project) => `${project.name} (${project.manifestPath})`).join(", ")}.`,
137
+ };
138
+ }
139
+
140
+ /** Create the immutable workflow envelope; result assembly owns display selection. */
141
+ export function workspaceOrientationData(
142
+ workspace: WorkspaceOrientationFacts,
143
+ ): OrientationResultData {
144
+ return {
145
+ title: "Workspace Orientation",
146
+ notes: [],
147
+ sections: [],
148
+ confidence: "unavailable",
149
+ focusTarget: workspace.focus,
150
+ requestedSections: [],
151
+ renderedSections: [],
152
+ omittedCount: 0,
153
+ nextQueries: [],
154
+ readNext: [],
155
+ workspace,
156
+ };
157
+ }
158
+
159
+ /** Test containment without treating a common path prefix as ancestry. */
160
+ export function within(root: string, target: string): boolean {
161
+ const relative = path.relative(root, target);
162
+ return (
163
+ relative === "" ||
164
+ (!relative.startsWith(`..${path.sep}`) && relative !== ".." && !path.isAbsolute(relative))
165
+ );
166
+ }
@@ -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";
@@ -58,7 +62,12 @@ export type OrientationItem =
58
62
  readonly language: string | null;
59
63
  readonly lines: readonly string[];
60
64
  }
61
- | { readonly kind: "blank" };
65
+ | { readonly kind: "blank" }
66
+ | {
67
+ readonly kind: "table";
68
+ readonly headers: readonly string[];
69
+ readonly rows: readonly (readonly string[])[];
70
+ };
62
71
 
63
72
  /** Source that established one Orientation section. */
64
73
  export interface OrientationProvenance {
@@ -79,6 +88,8 @@ export interface OrientationSectionData {
79
88
  readonly title: string;
80
89
  readonly status: "complete" | "partial" | "unavailable";
81
90
  readonly reason: string | null;
91
+ /** Syntax recovery ranges for partial structural evidence, in 0-based coordinates. */
92
+ readonly errorRanges?: readonly SourceRange[];
82
93
  /** Semantic/structural confidence only; filesystem/config facts use unavailable. */
83
94
  readonly confidence: ConfidenceMode;
84
95
  readonly provenance: readonly OrientationProvenance[];
@@ -114,6 +125,8 @@ export interface OrientationResultData {
114
125
  readonly nextQueries: readonly string[];
115
126
  readonly readNext: readonly ReadNextItem[];
116
127
  readonly instructions?: InstructionFilesMetadata;
128
+ /** Captured generic workspace facts; absent for the unchanged file and symbol paths. */
129
+ readonly workspace?: import("./orientation/workspace-context.ts").WorkspaceOrientationFacts;
117
130
  readonly target?: Readonly<TargetStoreEntry>;
118
131
  }
119
132
 
@@ -15,6 +15,7 @@ import { loadCodeIntelligenceConfig } from "../config.ts";
15
15
  import type { CapabilityAdapter } from "./capability-adapter.ts";
16
16
  import { parseOrientationWorkflowInput } from "./input/workflows.ts";
17
17
  import { executeOrientation } from "./orientation/collect.ts";
18
+ import { orientWorkspaceContext } from "./orientation/workspace-context.ts";
18
19
  import type {
19
20
  OrientationFocusInput,
20
21
  OrientationItem,
@@ -31,7 +32,6 @@ export interface OrientationWorkflowDeps extends TargetWorkflowDeps {
31
32
  readonly capability: CapabilityAdapter;
32
33
  readonly nativeInstructionPaths: Set<string>;
33
34
  readonly surfacedInstructionDirs: Set<string>;
34
- readonly markInstructionDirsSurfaced: (directories: string[]) => void;
35
35
  /** Whether the project is trusted — controls instruction-file discovery. */
36
36
  readonly projectTrusted: boolean;
37
37
  /** Global config home for hermetic config reads; undefined uses os.homedir(). */
@@ -47,12 +47,24 @@ export async function runOrientationWorkflow(
47
47
  const parsed = parseOrientationWorkflowInput(input);
48
48
  if (parsed.kind === "invalid-input") return parsed;
49
49
  const request = parsed.value;
50
- throwIfAborted(control);
50
+ control?.signal?.throwIfAborted();
51
51
  reportProgress(control, {
52
52
  intent: "orientation",
53
53
  phase: "model",
54
54
  message: "Building workspace orientation model",
55
55
  });
56
+ const navigation = await orientWorkspaceContext(request, deps, control);
57
+ if (navigation) {
58
+ if (navigation.kind === "invalid-input") return navigation;
59
+ control?.signal?.throwIfAborted();
60
+ return {
61
+ kind: "completed",
62
+ data: navigation.directory
63
+ ? addInstructionFiles(navigation.data, navigation.directory, deps)
64
+ : navigation.data,
65
+ };
66
+ }
67
+ throwIfAborted(control);
56
68
  const model = await buildArchitectureModel(deps.cwd);
57
69
  const provider = deps.capability.getProvider(deps.cwd);
58
70
  const lspRuntime = deps.capability.getLspRuntimeState(deps.cwd);
@@ -228,7 +240,6 @@ function addInstructionFiles(
228
240
  });
229
241
  const collected = collectInstructionFiles(matches);
230
242
  if (!collected) return result;
231
- deps.markInstructionDirsSurfaced(collected.metadata.files.map((file) => file.directory));
232
243
  const items: OrientationItem[] = [];
233
244
  for (const file of collected.files) {
234
245
  items.push(
@@ -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);
@@ -216,8 +216,8 @@ export class WorkspaceCodeIntelligenceSession {
216
216
  }
217
217
 
218
218
  /** Restore overview state from the active session branch. */
219
- restoreOverviewInjection(): void {
220
- this.#hasInjectedOverview = true;
219
+ restoreOverviewInjection(injected = true): void {
220
+ this.#hasInjectedOverview = injected;
221
221
  }
222
222
 
223
223
  /**
@@ -343,7 +343,6 @@ export class WorkspaceCodeIntelligenceSession {
343
343
  ...this.targetWorkflowDeps(),
344
344
  nativeInstructionPaths: this.#nativeInstructionPaths,
345
345
  surfacedInstructionDirs: this.#surfacedInstructionDirs,
346
- markInstructionDirsSurfaced: (directories) => this.markInstructionDirsSurfaced(directories),
347
346
  projectTrusted: this.#projectTrusted,
348
347
  homeDir: this.#homeDir,
349
348
  },