@mrclrchtr/supi-code-intelligence 11.1.0 → 11.3.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 (199) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/README.md +41 -6
  3. package/node_modules/@mrclrchtr/supi-code-runtime/package.json +1 -1
  4. package/node_modules/@mrclrchtr/supi-code-runtime/src/capability/types.ts +3 -1
  5. package/node_modules/@mrclrchtr/supi-code-runtime/src/query-result.ts +9 -0
  6. package/node_modules/@mrclrchtr/supi-core/package.json +1 -1
  7. package/node_modules/@mrclrchtr/supi-core/src/child-web-tools.ts +110 -0
  8. package/node_modules/@mrclrchtr/supi-core/src/session.ts +11 -0
  9. package/node_modules/@mrclrchtr/supi-lsp/README.md +81 -7
  10. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-code-runtime/package.json +1 -1
  11. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-code-runtime/src/capability/types.ts +3 -1
  12. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-code-runtime/src/query-result.ts +9 -0
  13. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-core/package.json +1 -1
  14. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-core/src/child-web-tools.ts +110 -0
  15. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-core/src/session.ts +11 -0
  16. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/LICENSE +15 -0
  17. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/README.md +680 -0
  18. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/bin/semver.js +195 -0
  19. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/classes/comparator.js +143 -0
  20. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/classes/index.js +7 -0
  21. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/classes/range.js +577 -0
  22. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/classes/semver.js +350 -0
  23. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/functions/clean.js +8 -0
  24. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/functions/cmp.js +54 -0
  25. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/functions/coerce.js +62 -0
  26. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/functions/compare-build.js +9 -0
  27. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/functions/compare-loose.js +5 -0
  28. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/functions/compare.js +7 -0
  29. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/functions/diff.js +60 -0
  30. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/functions/eq.js +5 -0
  31. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/functions/gt.js +5 -0
  32. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/functions/gte.js +5 -0
  33. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/functions/inc.js +21 -0
  34. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/functions/lt.js +5 -0
  35. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/functions/lte.js +5 -0
  36. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/functions/major.js +5 -0
  37. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/functions/minor.js +5 -0
  38. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/functions/neq.js +5 -0
  39. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/functions/parse.js +18 -0
  40. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/functions/patch.js +5 -0
  41. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/functions/prerelease.js +8 -0
  42. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/functions/rcompare.js +5 -0
  43. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/functions/rsort.js +5 -0
  44. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/functions/satisfies.js +12 -0
  45. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/functions/sort.js +5 -0
  46. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/functions/truncate.js +48 -0
  47. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/functions/valid.js +8 -0
  48. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/index.js +93 -0
  49. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/internal/constants.js +37 -0
  50. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/internal/debug.js +11 -0
  51. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/internal/identifiers.js +29 -0
  52. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/internal/lrucache.js +42 -0
  53. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/internal/parse-options.js +17 -0
  54. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/internal/re.js +223 -0
  55. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/package.json +78 -0
  56. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/preload.js +4 -0
  57. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/range.bnf +17 -0
  58. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/ranges/gtr.js +6 -0
  59. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/ranges/intersects.js +9 -0
  60. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/ranges/ltr.js +6 -0
  61. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/ranges/max-satisfying.js +27 -0
  62. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/ranges/min-satisfying.js +26 -0
  63. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/ranges/min-version.js +63 -0
  64. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/ranges/outside.js +82 -0
  65. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/ranges/simplify.js +49 -0
  66. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/ranges/subset.js +249 -0
  67. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/ranges/to-comparators.js +10 -0
  68. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/ranges/valid.js +13 -0
  69. package/node_modules/@mrclrchtr/supi-lsp/package.json +5 -3
  70. package/node_modules/@mrclrchtr/supi-lsp/src/client/client-diagnostic-collection.ts +11 -4
  71. package/node_modules/@mrclrchtr/supi-lsp/src/client/client-diagnostics.ts +77 -6
  72. package/node_modules/@mrclrchtr/supi-lsp/src/client/client-input-admission.ts +149 -0
  73. package/node_modules/@mrclrchtr/supi-lsp/src/client/client-typescript-project.ts +40 -0
  74. package/node_modules/@mrclrchtr/supi-lsp/src/client/client.ts +174 -49
  75. package/node_modules/@mrclrchtr/supi-lsp/src/config/config.ts +53 -2
  76. package/node_modules/@mrclrchtr/supi-lsp/src/config/operation-support.ts +19 -4
  77. package/node_modules/@mrclrchtr/supi-lsp/src/config/server-config.ts +22 -0
  78. package/node_modules/@mrclrchtr/supi-lsp/src/config/typescript-launch.ts +276 -0
  79. package/node_modules/@mrclrchtr/supi-lsp/src/diagnostics/evidence.ts +2 -2
  80. package/node_modules/@mrclrchtr/supi-lsp/src/manager/manager-project-info.ts +22 -10
  81. package/node_modules/@mrclrchtr/supi-lsp/src/manager/manager-workspace-symbol.ts +157 -23
  82. package/node_modules/@mrclrchtr/supi-lsp/src/manager/manager.ts +306 -75
  83. package/node_modules/@mrclrchtr/supi-lsp/src/provider/refactor-planning.ts +4 -3
  84. package/node_modules/@mrclrchtr/supi-lsp/src/session/runtime-controller.ts +2 -2
  85. package/node_modules/@mrclrchtr/supi-lsp/src/session/runtime-registry.ts +19 -2
  86. package/node_modules/@mrclrchtr/supi-lsp/src/session/runtime-rename.ts +1 -0
  87. package/node_modules/@mrclrchtr/supi-lsp/src/session/scanner.ts +27 -15
  88. package/node_modules/@mrclrchtr/supi-lsp/src/session/workspace-lsp-runtime.ts +5 -1
  89. package/node_modules/@mrclrchtr/supi-tree-sitter/README.md +2 -2
  90. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/package.json +1 -1
  91. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/src/capability/types.ts +3 -1
  92. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/src/query-result.ts +9 -0
  93. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/package.json +1 -1
  94. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/src/child-web-tools.ts +110 -0
  95. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/src/session.ts +11 -0
  96. package/node_modules/@mrclrchtr/supi-tree-sitter/package.json +3 -3
  97. package/node_modules/@mrclrchtr/supi-tree-sitter/resources/grammars/tsx/tree-sitter-tsx.wasm +0 -0
  98. package/node_modules/@mrclrchtr/supi-tree-sitter/resources/grammars/tsx/tree-sitter-tsx.wasm.json +5 -1
  99. package/node_modules/@mrclrchtr/supi-tree-sitter/resources/grammars/typescript/tree-sitter-typescript.wasm +0 -0
  100. package/node_modules/@mrclrchtr/supi-tree-sitter/resources/grammars/typescript/tree-sitter-typescript.wasm.json +5 -1
  101. package/node_modules/@mrclrchtr/supi-tree-sitter/src/tool/call-sites.ts +40 -25
  102. package/node_modules/@mrclrchtr/supi-tree-sitter/src/tool/callees.ts +2 -0
  103. package/node_modules/@mrclrchtr/supi-tree-sitter/src/worker/call-context.ts +44 -0
  104. package/package.json +6 -5
  105. package/src/analysis/capability/capability-warnings.ts +18 -12
  106. package/src/analysis/health/check.ts +115 -0
  107. package/src/analysis/health/diagnostics.ts +3 -0
  108. package/src/analysis/health/file-scope.ts +2 -3
  109. package/src/analysis/health/semantic-state.ts +38 -0
  110. package/src/analysis/health/server-status.ts +14 -2
  111. package/src/analysis/health/signals.ts +2 -0
  112. package/src/analysis/health/status.ts +82 -0
  113. package/src/analysis/refactor/apply.ts +17 -8
  114. package/src/analysis/search/exclusions.ts +47 -0
  115. package/src/analysis/search/paths.ts +32 -9
  116. package/src/analysis/target/anchored-structural.ts +3 -8
  117. package/src/analysis/target/anchored.ts +4 -20
  118. package/src/analysis/target/identity.ts +1 -1
  119. package/src/analysis/target/latex-label-container.ts +6 -6
  120. package/src/analysis/target/latex-section-anchor.ts +6 -6
  121. package/src/analysis/target/resolution.ts +18 -0
  122. package/src/analysis/target/symbol.ts +39 -11
  123. package/src/analysis/target/types.ts +6 -1
  124. package/src/extension.ts +17 -11
  125. package/src/session/graph/collect.ts +1 -10
  126. package/src/session/graph-types.ts +2 -0
  127. package/src/session/graph-workflow.ts +1 -0
  128. package/src/session/health-types.ts +7 -0
  129. package/src/session/health-workflow.ts +8 -43
  130. package/src/session/inspect/collect.ts +8 -2
  131. package/src/session/inspect/file-point.ts +2 -3
  132. package/src/session/inspect-workflow.ts +1 -1
  133. package/src/session/orientation/collect.ts +184 -20
  134. package/src/session/orientation/context-facts.ts +27 -2
  135. package/src/session/orientation/context-sections.ts +49 -3
  136. package/src/session/orientation/facts.ts +132 -0
  137. package/src/session/orientation/gather.ts +98 -11
  138. package/src/session/orientation/workspace-context.ts +16 -6
  139. package/src/session/orientation-types.ts +8 -0
  140. package/src/session/orientation-workflow.ts +20 -6
  141. package/src/session/refactor-identity.ts +76 -0
  142. package/src/session/refactor-plans.ts +5 -2
  143. package/src/session/refactor-workflow.ts +15 -17
  144. package/src/session/target-store.ts +3 -18
  145. package/src/session/target-workflow.ts +33 -16
  146. package/src/substrate/lsp/recovery.ts +5 -5
  147. package/src/tool/code_find/guidance.ts +1 -1
  148. package/src/tool/code_find/render.ts +8 -4
  149. package/src/tool/code_find/result.ts +78 -6
  150. package/src/tool/code_find/spec.ts +4 -3
  151. package/src/tool/code_find/structured.ts +25 -9
  152. package/src/tool/code_graph/details.ts +1 -0
  153. package/src/tool/code_graph/display.ts +1 -1
  154. package/src/tool/code_graph/guidance.ts +1 -1
  155. package/src/tool/code_graph/markdown.ts +11 -6
  156. package/src/tool/code_graph/read-next.ts +38 -9
  157. package/src/tool/code_graph/reference-selection.ts +30 -0
  158. package/src/tool/code_graph/result.ts +25 -118
  159. package/src/tool/code_graph/section.ts +133 -0
  160. package/src/tool/code_graph/spec.ts +3 -3
  161. package/src/tool/code_graph/structured.ts +17 -6
  162. package/src/tool/code_health/display-paths.ts +92 -0
  163. package/src/tool/code_health/file-scope-markdown.ts +3 -2
  164. package/src/tool/code_health/markdown.ts +12 -2
  165. package/src/tool/code_health/result.ts +18 -3
  166. package/src/tool/code_health/spec.ts +5 -3
  167. package/src/tool/code_health/structured-schema.ts +250 -0
  168. package/src/tool/code_health/structured.ts +256 -0
  169. package/src/tool/code_inspect/result.ts +11 -5
  170. package/src/tool/code_inspect/spec.ts +7 -1
  171. package/src/tool/code_inspect/structured.ts +231 -0
  172. package/src/tool/code_orientation/execute.ts +1 -1
  173. package/src/tool/code_orientation/result.ts +31 -8
  174. package/src/tool/code_orientation/spec.ts +2 -0
  175. package/src/tool/code_orientation/structured-schema.ts +617 -0
  176. package/src/tool/code_orientation/structured-workspace.ts +194 -0
  177. package/src/tool/code_orientation/structured.ts +189 -0
  178. package/src/tool/code_orientation/workspace-format.ts +2 -5
  179. package/src/tool/code_orientation/workspace-observations.ts +81 -0
  180. package/src/tool/code_orientation/workspace-output.ts +5 -0
  181. package/src/tool/code_orientation/workspace-projects.ts +16 -31
  182. package/src/tool/code_orientation/workspace-sections.ts +46 -32
  183. package/src/tool/code_refactor_apply/execute.ts +1 -1
  184. package/src/tool/code_refactor_apply/result.ts +14 -6
  185. package/src/tool/code_refactor_apply/spec.ts +2 -0
  186. package/src/tool/code_refactor_apply/structured.ts +49 -0
  187. package/src/tool/code_refactor_plan/result.ts +18 -9
  188. package/src/tool/code_refactor_plan/spec.ts +2 -0
  189. package/src/tool/code_refactor_plan/structured.ts +127 -0
  190. package/src/tool/code_resolve/markdown.ts +6 -30
  191. package/src/tool/code_resolve/result.ts +24 -11
  192. package/src/tool/code_resolve/structured.ts +7 -9
  193. package/src/tool/result/refactor.ts +8 -5
  194. package/src/tool/result/structured.ts +8 -5
  195. package/src/tool/result/types.ts +18 -14
  196. package/src/tool/schemas.ts +12 -6
  197. package/src/ui/status-command.ts +147 -322
  198. package/src/ui/status-overlay.ts +584 -421
  199. package/src/ui/status-presentation.ts +108 -0
@@ -15,6 +15,7 @@ import {
15
15
  readNextEnclosingScope,
16
16
  readNextTarget,
17
17
  } from "../../analysis/read-next.ts";
18
+ import { isNonFileUri, toDisplayPath } from "../../analysis/search/paths.ts";
18
19
  import { diagnosticMessageString } from "../../substrate/lsp/utils.ts";
19
20
  import type {
20
21
  OrientationDeps,
@@ -26,7 +27,7 @@ import type {
26
27
  } from "../orientation-types.ts";
27
28
  import type { TargetStoreEntry } from "../target-store.ts";
28
29
  import { collectContextOrientationFacts } from "./context-facts.ts";
29
- import { gatherSubstrateContext } from "./gather.ts";
30
+ import { gatherSubstrateContext, type SubstrateContext } from "./gather.ts";
30
31
 
31
32
  interface TargetSectionCollection {
32
33
  readonly items: OrientationItem[];
@@ -36,6 +37,7 @@ interface TargetSectionCollection {
36
37
  readonly reason: string | null;
37
38
  readonly evidenceLists: readonly EvidenceListMetadata[];
38
39
  readonly errorRanges?: readonly SourceRange[];
40
+ readonly facts?: import("./facts.ts").OrientationFacts;
39
41
  }
40
42
 
41
43
  const DEFAULT_TARGET_SECTIONS: OrientationSection[] = ["defs", "docs", "diagnostics"];
@@ -141,11 +143,29 @@ async function buildRequestedSection(options: {
141
143
  switch (section) {
142
144
  case "defs": {
143
145
  const result = await buildEnrichedDefsSection(target, deps, treeContext, limit);
144
- return targetSectionResult(section, result, [
145
- result.hasSemanticEvidence
146
- ? { source: "semantic", capability: "LSP" }
147
- : { source: "structural", capability: "tree-sitter" },
148
- ]);
146
+ const contextFacts = targetContextFacts(treeContext, limit, deps.cwd);
147
+ const operations = treeContext?.operations;
148
+ const semanticObserved =
149
+ result.hasSemanticEvidence ||
150
+ (operations &&
151
+ [operations.hover, operations.definition].some(
152
+ ({ status }) => status === "complete" || status === "partial",
153
+ ));
154
+ const structuralObserved =
155
+ operations &&
156
+ [operations.nodeAt, operations.outline, operations.imports, operations.exports].some(
157
+ ({ status }) => status === "complete" || status === "partial",
158
+ );
159
+ return targetSectionResult(
160
+ section,
161
+ { ...result, facts: { ...contextFacts, ...result.facts } },
162
+ [
163
+ ...(semanticObserved ? [{ source: "semantic" as const, capability: "LSP" }] : []),
164
+ ...(structuralObserved
165
+ ? [{ source: "structural" as const, capability: "tree-sitter" }]
166
+ : []),
167
+ ],
168
+ );
149
169
  }
150
170
  case "docs":
151
171
  return targetSectionResult(section, await buildDocsSection(target, deps, limit), [
@@ -158,6 +178,83 @@ async function buildRequestedSection(options: {
158
178
  }
159
179
  }
160
180
 
181
+ /** Select independent source observations with public locations and unchanged evidence status. */
182
+ function targetContextFacts(
183
+ treeContext: Awaited<ReturnType<typeof maybeGatherTreeContext>>,
184
+ limit: number,
185
+ cwd: string,
186
+ ) {
187
+ return treeContext
188
+ ? {
189
+ node: treeContext.nodeInfo
190
+ ? {
191
+ type: treeContext.nodeInfo.type,
192
+ text: treeContext.nodeInfo.text,
193
+ startLine: treeContext.nodeInfo.startLine,
194
+ startCharacter: treeContext.nodeInfo.startCharacter,
195
+ endLine: treeContext.nodeInfo.endLine,
196
+ endCharacter: treeContext.nodeInfo.endCharacter,
197
+ ancestry: treeContext.nodeInfo.ancestry.map(
198
+ ({ type, startLine, startCharacter, endLine, endCharacter }) => ({
199
+ type,
200
+ startLine,
201
+ startCharacter,
202
+ endLine,
203
+ endCharacter,
204
+ }),
205
+ ),
206
+ }
207
+ : null,
208
+ nodeObservation: { ...treeContext.operations.nodeAt },
209
+ hoverObservation: { ...treeContext.operations.hover },
210
+ hover: treeContext.hover
211
+ ? {
212
+ contents: treeContext.hover.contents,
213
+ ...(treeContext.hover.range
214
+ ? {
215
+ range: publicRange(treeContext.hover.range),
216
+ }
217
+ : {}),
218
+ }
219
+ : null,
220
+ recovery: treeContext.recovery.map(({ operation, file, reason, errorRanges }) => ({
221
+ operation,
222
+ file: toDisplayPath(cwd, file),
223
+ reason,
224
+ errorRanges: errorRanges.map(publicRange),
225
+ })),
226
+ contextDefinitions: {
227
+ ...treeContext.operations.definition,
228
+ ...(treeContext.definition !== null
229
+ ? {
230
+ entries: treeContext.definition.slice(0, limit).map(({ uri, range }) => ({
231
+ ...(isNonFileUri(uri)
232
+ ? {
233
+ uri,
234
+ navigation: "unavailable" as const,
235
+ reason: "Provider URI is not a local filesystem source.",
236
+ }
237
+ : { file: toDisplayPath(cwd, uri) }),
238
+ range: publicRange(range),
239
+ })),
240
+ collectedCount: treeContext.definition.length,
241
+ omittedCount: Math.max(0, treeContext.definition.length - limit),
242
+ }
243
+ : {}),
244
+ },
245
+ sourceContext: {
246
+ outline: sourceSelection(treeContext.operations.outline, treeContext.outline, limit),
247
+ imports: sourceSelection(
248
+ treeContext.operations.imports,
249
+ treeContext.imports.map(({ moduleSpecifier }) => ({ moduleSpecifier })),
250
+ limit,
251
+ ),
252
+ exports: sourceSelection(treeContext.operations.exports, treeContext.exports, limit),
253
+ },
254
+ }
255
+ : {};
256
+ }
257
+
161
258
  /** Build enriched defs section: tree-sitter definitions + LSP definition targets. */
162
259
  async function buildEnrichedDefsSection(
163
260
  target: Readonly<TargetStoreEntry> | null | undefined,
@@ -166,9 +263,9 @@ async function buildEnrichedDefsSection(
166
263
  limit: number,
167
264
  ): Promise<TargetSectionCollection> {
168
265
  const items = buildDefinitionItems(target, deps.cwd, treeContext);
169
- const recovery = treeContext?.recovery ?? [];
266
+ const recovery = groupedRecovery(treeContext?.recovery ?? [], deps.cwd);
170
267
  const recoveryReason = recovery
171
- .map(({ operation, reason }) => `${operation}: ${reason}`)
268
+ .map(({ operations, reason }) => `${operations.join(", ")}: ${reason}`)
172
269
  .join("; ");
173
270
  const recoveryRanges = uniqueRecoveryRanges(recovery);
174
271
  const hasSemanticContext = Boolean(
@@ -252,6 +349,7 @@ function mergeDefinitionCollection(input: {
252
349
  reason:
253
350
  [input.recoveryReason || null, input.definitions.reason].filter(Boolean).join(" ") || null,
254
351
  evidenceLists: input.definitions.evidenceLists,
352
+ ...(input.definitions.facts ? { facts: input.definitions.facts } : {}),
255
353
  ...(input.recoveryRanges.length > 0 ? { errorRanges: [...input.recoveryRanges] } : {}),
256
354
  };
257
355
  }
@@ -263,7 +361,7 @@ async function collectDefinitionTargets(
263
361
  ): Promise<
264
362
  Pick<
265
363
  TargetSectionCollection,
266
- "items" | "hasSemanticEvidence" | "status" | "reason" | "evidenceLists"
364
+ "items" | "hasSemanticEvidence" | "status" | "reason" | "evidenceLists" | "facts"
267
365
  >
268
366
  > {
269
367
  if (!deps.provider?.definition) {
@@ -289,11 +387,10 @@ async function collectDefinitionTargets(
289
387
  evidenceLists: [],
290
388
  };
291
389
  }
292
- const locations = result.data.map((definition) => {
293
- const filePath = uriToFile(definition.uri);
294
- const relPath = path.relative(deps.cwd, filePath);
295
- return `\`${relPath}:${definition.range.start.line + 1}:${definition.range.start.character + 1}\``;
296
- });
390
+ const locations = result.data.map((definition) => ({
391
+ file: toDisplayPath(deps.cwd, uriToFile(definition.uri)),
392
+ range: publicRange(definition.range),
393
+ }));
297
394
  const evidence =
298
395
  result.kind === "partial"
299
396
  ? createPartialEvidenceList({
@@ -308,7 +405,11 @@ async function collectDefinitionTargets(
308
405
  maxResults: limit,
309
406
  });
310
407
  return {
311
- items: evidence.items.map((location) => ({ kind: "paragraph", text: location })),
408
+ items: evidence.items.map((location) => ({
409
+ kind: "paragraph",
410
+ text: `\`${location.file}:${location.range.start.line + 1}:${location.range.start.character + 1}\`${isNonFileUri(location.file) ? " (provider URI; filesystem navigation unavailable)" : ""}`,
411
+ })),
412
+ facts: { definitions: evidence.items },
312
413
  hasSemanticEvidence: true,
313
414
  status: result.kind === "partial" ? "partial" : "complete",
314
415
  reason: result.kind === "partial" ? result.reason : null,
@@ -384,6 +485,15 @@ async function buildDiagnosticsSection(
384
485
  : evidence.items.map((diagnostic) => formatDiagnosticItem(diagnostic)),
385
486
  hasStructuralEvidence: false,
386
487
  hasSemanticEvidence: true,
488
+ facts: {
489
+ diagnostics: evidence.items.map((diagnostic) => ({
490
+ range: publicRange(diagnostic.range),
491
+ severity: diagnostic.severity ?? null,
492
+ message: diagnosticMessageString(diagnostic),
493
+ source: diagnostic.source ?? null,
494
+ code: diagnostic.code ?? null,
495
+ })),
496
+ },
387
497
  status: result.kind === "partial" ? "partial" : "complete",
388
498
  reason: result.kind === "partial" ? result.reason : null,
389
499
  evidenceLists: [evidence.metadata],
@@ -409,6 +519,7 @@ function formatDiagnosticItem(diagnostic: Diagnostic): OrientationItem {
409
519
  function completedDocsSection(
410
520
  items: OrientationItem[],
411
521
  evidenceLists: readonly EvidenceListMetadata[],
522
+ documentation: readonly string[] = [],
412
523
  ): TargetSectionCollection {
413
524
  return {
414
525
  items,
@@ -417,6 +528,7 @@ function completedDocsSection(
417
528
  status: "complete",
418
529
  reason: null,
419
530
  evidenceLists,
531
+ facts: { documentation },
420
532
  };
421
533
  }
422
534
 
@@ -529,6 +641,7 @@ async function buildDocsSection(
529
641
  return completedDocsSection(
530
642
  [{ kind: "code", language: "ts", lines: evidence.items }],
531
643
  [evidence.metadata],
644
+ evidence.items,
532
645
  );
533
646
  } catch (error) {
534
647
  return unavailableTargetSection(
@@ -555,6 +668,27 @@ async function maybeGatherTreeContext(
555
668
  );
556
669
  }
557
670
 
671
+ function publicRange(range: SourceRange): SourceRange {
672
+ return {
673
+ start: { line: range.start.line, character: range.start.character },
674
+ end: { line: range.end.line, character: range.end.character },
675
+ };
676
+ }
677
+
678
+ /** These best-effort lists preserve availability separately from collected counts. */
679
+ function sourceSelection<T>(
680
+ status: { status: "complete" | "partial" | "unavailable"; reason: string | null },
681
+ entries: readonly T[],
682
+ limit: number,
683
+ ) {
684
+ return {
685
+ ...status,
686
+ entries: entries.slice(0, limit),
687
+ collectedCount: entries.length,
688
+ omittedCount: Math.max(0, entries.length - limit),
689
+ };
690
+ }
691
+
558
692
  function uniqueRecoveryRanges(
559
693
  recovery: readonly { errorRanges: readonly SourceRange[] }[],
560
694
  ): SourceRange[] {
@@ -565,6 +699,33 @@ function uniqueRecoveryRanges(
565
699
  return [...ranges.values()];
566
700
  }
567
701
 
702
+ /** Group only equivalent display warnings; native per-operation observations remain untouched. */
703
+ function groupedRecovery(recovery: SubstrateContext["recovery"], cwd: string) {
704
+ const groups = new Map<
705
+ string,
706
+ {
707
+ file: string;
708
+ reason: string;
709
+ errorRanges: readonly SourceRange[];
710
+ operations: string[];
711
+ }
712
+ >();
713
+ for (const item of recovery) {
714
+ const file = toDisplayPath(cwd, item.file);
715
+ const key = JSON.stringify([file, item.reason, item.errorRanges]);
716
+ const existing = groups.get(key);
717
+ if (existing) existing.operations.push(item.operation);
718
+ else
719
+ groups.set(key, {
720
+ file,
721
+ reason: item.reason,
722
+ errorRanges: item.errorRanges,
723
+ operations: [item.operation],
724
+ });
725
+ }
726
+ return [...groups.values()];
727
+ }
728
+
568
729
  function buildDefinitionItems(
569
730
  target: Readonly<TargetStoreEntry> | null | undefined,
570
731
  cwd: string,
@@ -590,14 +751,16 @@ function buildDefinitionItems(
590
751
  if (treeContext?.nodeInfo?.type) {
591
752
  items.push({ kind: "list-item", text: `Node: \`${treeContext.nodeInfo.type}\`` });
592
753
  }
593
- for (const recovery of treeContext?.recovery ?? []) {
754
+ for (const recovery of groupedRecovery(treeContext?.recovery ?? [], cwd)) {
594
755
  const locations = recovery.errorRanges.map(
595
756
  (range) => `L${range.start.line + 1}:${range.start.character + 1}`,
596
757
  );
597
758
  const suffix = locations.length > 0 ? ` Errors: ${locations.join(", ")}.` : "";
759
+ const reason = recovery.reason.trim();
760
+ const punctuation = /[.!?]$/.test(reason) ? "" : ".";
598
761
  items.push({
599
762
  kind: "paragraph",
600
- text: `Partial ${recovery.operation} evidence in \`${recovery.file}\`: ${recovery.reason}.${suffix}`,
763
+ text: `Partial ${recovery.operations.join(", ")} evidence in \`${recovery.file}\`: ${reason}${punctuation}${suffix}`,
601
764
  });
602
765
  }
603
766
  if (treeContext?.hover?.contents) {
@@ -684,7 +847,7 @@ function hoverBodyItems(lines: readonly string[]): OrientationItem[] {
684
847
  }
685
848
 
686
849
  function formatFocusTarget(target: Readonly<TargetStoreEntry>, cwd: string): string {
687
- const relPath = path.relative(cwd, target.file) || target.file;
850
+ const relPath = toDisplayPath(cwd, target.file);
688
851
  return `${relPath}:${target.displayLine}:${target.displayCharacter}`;
689
852
  }
690
853
 
@@ -694,7 +857,7 @@ function buildNextQueries(
694
857
  ): string[] {
695
858
  if (!target) return ["Use `code_orientation` for a neutral orientation summary."];
696
859
 
697
- const relPath = path.relative(cwd, target.file) || target.file;
860
+ const relPath = toDisplayPath(cwd, target.file);
698
861
  return [
699
862
  `\`code_graph\` with \`target: { anchor: { file: "${relPath}", line: ${target.displayLine}, character: ${target.displayCharacter} } }\` for relation follow-up`,
700
863
  ];
@@ -706,7 +869,7 @@ function buildReadNextGuidance(
706
869
  cwd: string,
707
870
  ): ReadNextItem[] {
708
871
  if (!target) return [];
709
- const relPath = path.relative(cwd, target.file) || target.file;
872
+ const relPath = toDisplayPath(cwd, target.file);
710
873
  const enclosing = findEnclosingOutlineItem(target, treeContext);
711
874
  if (enclosing) {
712
875
  return [readNextEnclosingScope(relPath, enclosing, target.displayLine)];
@@ -754,6 +917,7 @@ function targetSectionResult(
754
917
  provenance,
755
918
  evidenceLists: collection.evidenceLists,
756
919
  ...(collection.errorRanges ? { errorRanges: [...collection.errorRanges] } : {}),
920
+ ...(collection.facts ? { facts: collection.facts } : {}),
757
921
  items: collection.items,
758
922
  },
759
923
  hasStructuralEvidence: collection.hasStructuralEvidence,
@@ -110,8 +110,9 @@ async function collectFileFacts(
110
110
  appendList(builder, {
111
111
  key: "filesystem.file",
112
112
  title: "Filesystem facts",
113
- items: [`Size: ${byteSize} bytes`],
114
- render: (item) => item,
113
+ items: [byteSize],
114
+ render: (item) => `Size: ${item} bytes`,
115
+ facts: (items) => (items.length ? { fileSizeBytes: items[0] } : {}),
115
116
  confidence: "unavailable",
116
117
  provenance: [filesystemProvenance(input.cwd, focus)],
117
118
  });
@@ -225,6 +226,7 @@ function appendPackageContext(
225
226
  title: "Containing package",
226
227
  items: [module],
227
228
  render: packageLabel,
229
+ facts: (items) => (items[0] ? { package: packageFact(items[0]) } : {}),
228
230
  confidence: "unavailable",
229
231
  provenance: [{ source: "manifest", detail: module.manifestPath }],
230
232
  });
@@ -243,6 +245,7 @@ function appendPackageFacts(
243
245
  title,
244
246
  items: identity,
245
247
  render: (item) => item,
248
+ facts: () => ({ package: packageFact(module) }),
246
249
  confidence: "unavailable",
247
250
  provenance: [{ source: "manifest", detail: module.manifestPath }],
248
251
  });
@@ -253,6 +256,7 @@ function appendPackageFacts(
253
256
  title: "Manifest declarations",
254
257
  items: module.fields,
255
258
  render: (field) => `\`${field.field}\`: ${formatManifestValue(field.value)}`,
259
+ facts: (items) => ({ manifestFields: items.map(({ field, value }) => ({ field, value })) }),
256
260
  confidence: "unavailable",
257
261
  provenance: [{ source: "manifest", detail: module.manifestPath }],
258
262
  });
@@ -272,6 +276,9 @@ function appendDependencySection(
272
276
  title: `Manifest ${section.field}`,
273
277
  items: section.entries,
274
278
  render: (dependency) => `\`${dependency.name}\`: ${formatManifestValue(dependency.specifier)}`,
279
+ facts: (items) => ({
280
+ dependencies: items.map(({ field, name, specifier }) => ({ field, name, value: specifier })),
281
+ }),
275
282
  confidence: "unavailable",
276
283
  provenance: [{ source: "manifest", detail: `${module.manifestPath}#${section.field}` }],
277
284
  });
@@ -293,6 +300,15 @@ function appendRelationshipFacts(
293
300
  items: input.edges,
294
301
  render: (edge) =>
295
302
  `\`${edge.from}\` → \`${edge.to}\` — \`${edge.manifestPath}#${edge.field}\`: ${formatManifestValue(edge.specifier)}`,
303
+ facts: (items) => ({
304
+ relationships: items.map(({ from, to, field, manifestPath, specifier }) => ({
305
+ from,
306
+ to,
307
+ field,
308
+ manifestPath,
309
+ value: specifier,
310
+ })),
311
+ }),
296
312
  confidence: "unavailable",
297
313
  provenance: [{ source: "manifest", detail: "package dependency fields" }],
298
314
  status: input.status,
@@ -315,6 +331,15 @@ function topologyProvenance(
315
331
  : { source: "configuration", detail: "supported workspace metadata" };
316
332
  }
317
333
 
334
+ function packageFact(module: ModuleInfo) {
335
+ return {
336
+ name: module.name,
337
+ description: module.description,
338
+ manifestPath: module.manifestPath,
339
+ directory: module.relativePath,
340
+ };
341
+ }
342
+
318
343
  function packageLabel(module: ModuleInfo): string {
319
344
  const name = module.name ? `\`${module.name}\`` : "Unnamed package manifest";
320
345
  return `${name} — \`${module.relativePath}\` (\`${module.manifestPath}\`)`;
@@ -12,6 +12,7 @@ import type { WorkspaceLspRuntimeState } from "@mrclrchtr/supi-lsp/api";
12
12
  import type { EvidenceListMetadata, EvidencePartialReason } from "../../analysis/evidence.ts";
13
13
  import { createEvidenceList } from "../../analysis/evidence.ts";
14
14
  import type { CodeProvider } from "../../analysis/provider.ts";
15
+ import { toDisplayPath } from "../../analysis/search/paths.ts";
15
16
  import type {
16
17
  OrientationProvenance,
17
18
  OrientationResultData,
@@ -39,6 +40,7 @@ export interface ListSectionInput<T> {
39
40
  readonly unknownRemainder?: boolean;
40
41
  readonly partialReason?: EvidencePartialReason;
41
42
  readonly errorRanges?: readonly SourceRange[];
43
+ readonly facts?: (items: readonly T[]) => import("./facts.ts").OrientationFacts;
42
44
  }
43
45
 
44
46
  /** Start a context-Oriented document with one factual focus title. */
@@ -78,6 +80,7 @@ export function appendList<T>(
78
80
  provenance: input.provenance,
79
81
  evidenceLists: [{ ...metadata, key: input.key }],
80
82
  items: list.items.map((item) => ({ kind: "list-item", text: input.render(item) })),
83
+ ...(input.facts ? { facts: input.facts(list.items) } : {}),
81
84
  ...(input.errorRanges ? { errorRanges: [...input.errorRanges] } : {}),
82
85
  });
83
86
  }
@@ -175,6 +178,16 @@ export async function appendStructuralFileFacts(
175
178
  collect: () => provider.outline(file, requestControl),
176
179
  requestControl,
177
180
  render: (item) => `\`${item.name}\` (${item.kind}, L${item.startLine}–L${item.endLine})`,
181
+ facts: (items) => ({
182
+ outline: items.map(({ name, kind, startLine, startCharacter, endLine, endCharacter }) => ({
183
+ name,
184
+ kind,
185
+ startLine,
186
+ startCharacter,
187
+ endLine,
188
+ endCharacter,
189
+ })),
190
+ }),
178
191
  });
179
192
  await appendStructuralList(builder, {
180
193
  key: "structural.imports",
@@ -182,6 +195,17 @@ export async function appendStructuralFileFacts(
182
195
  collect: () => provider.imports(file, requestControl),
183
196
  requestControl,
184
197
  render: (item) => `\`${item.moduleSpecifier}\``,
198
+ facts: (items) => ({
199
+ imports: items.map(
200
+ ({ moduleSpecifier, startLine, startCharacter, endLine, endCharacter }) => ({
201
+ moduleSpecifier,
202
+ startLine,
203
+ startCharacter,
204
+ endLine,
205
+ endCharacter,
206
+ }),
207
+ ),
208
+ }),
185
209
  });
186
210
  await appendStructuralList(builder, {
187
211
  key: "structural.exports",
@@ -189,6 +213,19 @@ export async function appendStructuralFileFacts(
189
213
  collect: () => provider.exports(file, requestControl),
190
214
  requestControl,
191
215
  render: (item) => `\`${item.name}\` (${item.kind})`,
216
+ facts: (items) => ({
217
+ exports: items.map(
218
+ ({ name, kind, startLine, startCharacter, endLine, endCharacter, moduleSpecifier }) => ({
219
+ name,
220
+ kind,
221
+ startLine,
222
+ startCharacter,
223
+ endLine,
224
+ endCharacter,
225
+ ...(moduleSpecifier === undefined ? {} : { moduleSpecifier }),
226
+ }),
227
+ ),
228
+ }),
192
229
  });
193
230
  }
194
231
 
@@ -214,6 +251,7 @@ async function appendStructuralList<T>(
214
251
  title: string;
215
252
  collect: () => Promise<CodeResult<T[]>>;
216
253
  render: (item: T) => string;
254
+ facts: (items: readonly T[]) => import("./facts.ts").OrientationFacts;
217
255
  requestControl?: CodeRequestControl;
218
256
  },
219
257
  ): Promise<void> {
@@ -252,6 +290,7 @@ async function appendStructuralList<T>(
252
290
  title: input.title,
253
291
  items: result.data,
254
292
  render: input.render,
293
+ facts: input.facts,
255
294
  confidence: "structural",
256
295
  provenance: [{ source: "structural", capability: "tree-sitter" }],
257
296
  ...(result.kind === "partial"
@@ -296,6 +335,15 @@ export function appendPrioritySignals(
296
335
  return `Diagnostics: \`${displayPath(input.cwd, entry.file)}\` (${parts.join(", ")})`;
297
336
  },
298
337
  confidence: "semantic",
338
+ facts: (items) => ({
339
+ diagnosticSnapshot: items.map(({ file, total, errors, warnings }) => ({
340
+ file: displayPath(input.cwd, file),
341
+ total,
342
+ errors,
343
+ warnings,
344
+ })),
345
+ snapshotCurrent: snapshot.current,
346
+ }),
299
347
  provenance: [{ source: "semantic", capability: "LSP diagnostic snapshot" }],
300
348
  status: "partial",
301
349
  reason: snapshot.current
@@ -334,9 +382,7 @@ export function filesystemProvenance(cwd: string, target: string): OrientationPr
334
382
  }
335
383
 
336
384
  export function displayPath(cwd: string, target: string): string {
337
- const relative = path.relative(cwd, path.resolve(target)).replaceAll(path.sep, "/");
338
- if (relative.length === 0) return ".";
339
- return relative.startsWith("../") || relative === ".." ? target : relative;
385
+ return toDisplayPath(cwd, target);
340
386
  }
341
387
 
342
388
  export function formatManifestValue(value: unknown): string {
@@ -0,0 +1,132 @@
1
+ import type { SourceRange } from "@mrclrchtr/supi-code-runtime/api";
2
+
3
+ /** Named, selected observations retained independently of their text rendering. */
4
+ export interface OrientationFacts {
5
+ readonly fileSizeBytes?: number;
6
+ readonly package?: {
7
+ readonly name: string | null;
8
+ readonly description: string | null;
9
+ readonly manifestPath: string;
10
+ readonly directory: string;
11
+ };
12
+ readonly manifestFields?: readonly { readonly field: string; readonly value: unknown }[];
13
+ readonly dependencies?: readonly {
14
+ readonly field: string;
15
+ readonly name: string;
16
+ readonly value: unknown;
17
+ }[];
18
+ readonly relationships?: readonly {
19
+ readonly from: string;
20
+ readonly to: string;
21
+ readonly field: string;
22
+ readonly manifestPath: string;
23
+ readonly value: unknown;
24
+ }[];
25
+ readonly outline?: readonly {
26
+ readonly name: string;
27
+ readonly kind: string;
28
+ readonly startLine: number;
29
+ readonly startCharacter: number;
30
+ readonly endLine: number;
31
+ readonly endCharacter: number;
32
+ }[];
33
+ readonly imports?: readonly {
34
+ readonly moduleSpecifier: string;
35
+ readonly startLine: number;
36
+ readonly startCharacter: number;
37
+ readonly endLine: number;
38
+ readonly endCharacter: number;
39
+ }[];
40
+ readonly exports?: readonly {
41
+ readonly name: string;
42
+ readonly kind: string;
43
+ readonly startLine: number;
44
+ readonly startCharacter: number;
45
+ readonly endLine: number;
46
+ readonly endCharacter: number;
47
+ readonly moduleSpecifier?: string;
48
+ }[];
49
+ readonly diagnosticSnapshot?: readonly {
50
+ readonly file: string;
51
+ readonly total: number;
52
+ readonly errors: number;
53
+ readonly warnings: number;
54
+ }[];
55
+ readonly snapshotCurrent?: boolean;
56
+ readonly node?: {
57
+ readonly type: string;
58
+ readonly text: string;
59
+ readonly startLine: number;
60
+ readonly startCharacter: number;
61
+ readonly endLine: number;
62
+ readonly endCharacter: number;
63
+ readonly ancestry: readonly {
64
+ readonly type: string;
65
+ readonly startLine: number;
66
+ readonly startCharacter: number;
67
+ readonly endLine: number;
68
+ readonly endCharacter: number;
69
+ }[];
70
+ } | null;
71
+ /** Distinguish position-strict withholding, failure, and successful observations. */
72
+ readonly nodeObservation?: import("./gather.ts").ContextObservationStatus;
73
+ readonly hover?: { readonly contents: string; readonly range?: SourceRange } | null;
74
+ readonly hoverObservation?: import("./gather.ts").ContextObservationStatus;
75
+ readonly definitions?: readonly { readonly file: string; readonly range: SourceRange }[];
76
+ /** Independent context query; unavailable observations have no manufactured entries or counts. */
77
+ readonly contextDefinitions?: import("./gather.ts").ContextObservationStatus & {
78
+ readonly entries?: readonly (
79
+ | { readonly file: string; readonly range: SourceRange }
80
+ | {
81
+ readonly uri: string;
82
+ readonly range: SourceRange;
83
+ readonly navigation: "unavailable";
84
+ readonly reason: string;
85
+ }
86
+ )[];
87
+ readonly collectedCount?: number;
88
+ readonly omittedCount?: number;
89
+ };
90
+ readonly recovery?: readonly {
91
+ readonly operation: string;
92
+ readonly file: string;
93
+ readonly reason: string;
94
+ readonly errorRanges: readonly SourceRange[];
95
+ }[];
96
+ readonly sourceContext?: {
97
+ readonly outline: {
98
+ readonly status: "complete" | "partial" | "unavailable";
99
+ readonly reason: string | null;
100
+ readonly entries: readonly {
101
+ readonly name: string;
102
+ readonly kind: string;
103
+ readonly startLine: number;
104
+ readonly endLine: number;
105
+ }[];
106
+ readonly collectedCount: number;
107
+ readonly omittedCount: number;
108
+ };
109
+ readonly imports: {
110
+ readonly status: "complete" | "partial" | "unavailable";
111
+ readonly reason: string | null;
112
+ readonly entries: readonly { readonly moduleSpecifier: string }[];
113
+ readonly collectedCount: number;
114
+ readonly omittedCount: number;
115
+ };
116
+ readonly exports: {
117
+ readonly status: "complete" | "partial" | "unavailable";
118
+ readonly reason: string | null;
119
+ readonly entries: readonly { readonly name: string; readonly kind: string }[];
120
+ readonly collectedCount: number;
121
+ readonly omittedCount: number;
122
+ };
123
+ };
124
+ readonly documentation?: readonly string[];
125
+ readonly diagnostics?: readonly {
126
+ readonly range: SourceRange;
127
+ readonly severity: number | null;
128
+ readonly message: string;
129
+ readonly source: string | null;
130
+ readonly code: string | number | null;
131
+ }[];
132
+ }