@mrclrchtr/supi-code-intelligence 11.0.1 → 11.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (200) hide show
  1. package/README.md +68 -6
  2. package/gradle-helper/README.md +48 -0
  3. package/gradle-helper/build.sh +73 -0
  4. package/gradle-helper/lib/gradle-tooling-api-9.4.0.jar +0 -0
  5. package/gradle-helper/lib/slf4j-api-2.0.17.jar +0 -0
  6. package/gradle-helper/lib/slf4j-simple-2.0.17.jar +0 -0
  7. package/gradle-helper/lib/supi-gradle-observation.jar +0 -0
  8. package/gradle-helper/licenses/DEPENDENCIES.md +11 -0
  9. package/gradle-helper/licenses/LICENSE-gradle-tooling-api.txt +422 -0
  10. package/gradle-helper/licenses/LICENSE-slf4j.txt +21 -0
  11. package/gradle-helper/licenses/NOTICE-gradle.txt +21 -0
  12. package/gradle-helper/src/GradleObservation.java +597 -0
  13. package/node_modules/@mrclrchtr/supi-code-runtime/package.json +1 -1
  14. package/node_modules/@mrclrchtr/supi-core/package.json +1 -1
  15. package/node_modules/@mrclrchtr/supi-core/src/debug-registry.ts +41 -1
  16. package/node_modules/@mrclrchtr/supi-lsp/README.md +43 -6
  17. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-code-runtime/package.json +1 -1
  18. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-core/package.json +1 -1
  19. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-core/src/debug-registry.ts +41 -1
  20. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/LICENSE +15 -0
  21. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/README.md +680 -0
  22. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/bin/semver.js +195 -0
  23. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/classes/comparator.js +143 -0
  24. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/classes/index.js +7 -0
  25. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/classes/range.js +577 -0
  26. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/classes/semver.js +350 -0
  27. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/functions/clean.js +8 -0
  28. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/functions/cmp.js +54 -0
  29. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/functions/coerce.js +62 -0
  30. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/functions/compare-build.js +9 -0
  31. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/functions/compare-loose.js +5 -0
  32. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/functions/compare.js +7 -0
  33. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/functions/diff.js +60 -0
  34. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/functions/eq.js +5 -0
  35. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/functions/gt.js +5 -0
  36. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/functions/gte.js +5 -0
  37. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/functions/inc.js +21 -0
  38. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/functions/lt.js +5 -0
  39. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/functions/lte.js +5 -0
  40. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/functions/major.js +5 -0
  41. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/functions/minor.js +5 -0
  42. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/functions/neq.js +5 -0
  43. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/functions/parse.js +18 -0
  44. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/functions/patch.js +5 -0
  45. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/functions/prerelease.js +8 -0
  46. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/functions/rcompare.js +5 -0
  47. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/functions/rsort.js +5 -0
  48. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/functions/satisfies.js +12 -0
  49. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/functions/sort.js +5 -0
  50. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/functions/truncate.js +48 -0
  51. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/functions/valid.js +8 -0
  52. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/index.js +93 -0
  53. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/internal/constants.js +37 -0
  54. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/internal/debug.js +11 -0
  55. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/internal/identifiers.js +29 -0
  56. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/internal/lrucache.js +42 -0
  57. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/internal/parse-options.js +17 -0
  58. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/internal/re.js +223 -0
  59. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/package.json +78 -0
  60. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/preload.js +4 -0
  61. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/range.bnf +17 -0
  62. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/ranges/gtr.js +6 -0
  63. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/ranges/intersects.js +9 -0
  64. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/ranges/ltr.js +6 -0
  65. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/ranges/max-satisfying.js +27 -0
  66. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/ranges/min-satisfying.js +26 -0
  67. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/ranges/min-version.js +63 -0
  68. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/ranges/outside.js +82 -0
  69. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/ranges/simplify.js +49 -0
  70. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/ranges/subset.js +249 -0
  71. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/ranges/to-comparators.js +10 -0
  72. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/ranges/valid.js +13 -0
  73. package/node_modules/@mrclrchtr/supi-lsp/node_modules/vscode-jsonrpc/README.md +5 -0
  74. package/node_modules/@mrclrchtr/supi-lsp/node_modules/vscode-jsonrpc/lib/browser/ril.js +8 -0
  75. package/node_modules/@mrclrchtr/supi-lsp/node_modules/vscode-jsonrpc/lib/common/connection.js +7 -2
  76. package/node_modules/@mrclrchtr/supi-lsp/node_modules/vscode-jsonrpc/lib/common/ral.d.ts +8 -0
  77. package/node_modules/@mrclrchtr/supi-lsp/node_modules/vscode-jsonrpc/lib/node/main.d.ts +14 -0
  78. package/node_modules/@mrclrchtr/supi-lsp/node_modules/vscode-jsonrpc/lib/node/main.js +6 -4
  79. package/node_modules/@mrclrchtr/supi-lsp/node_modules/vscode-jsonrpc/lib/node/ril.js +5 -1
  80. package/node_modules/@mrclrchtr/supi-lsp/node_modules/vscode-jsonrpc/package.json +4 -2
  81. package/node_modules/@mrclrchtr/supi-lsp/node_modules/vscode-languageserver-protocol/package.json +4 -3
  82. package/node_modules/@mrclrchtr/supi-lsp/node_modules/vscode-languageserver-types/lib/esm/main.js +2 -2
  83. package/node_modules/@mrclrchtr/supi-lsp/node_modules/vscode-languageserver-types/lib/umd/main.js +2 -2
  84. package/node_modules/@mrclrchtr/supi-lsp/node_modules/vscode-languageserver-types/package.json +2 -1
  85. package/node_modules/@mrclrchtr/supi-lsp/package.json +8 -6
  86. package/node_modules/@mrclrchtr/supi-lsp/src/client/client.ts +44 -5
  87. package/node_modules/@mrclrchtr/supi-lsp/src/config/config.ts +53 -2
  88. package/node_modules/@mrclrchtr/supi-lsp/src/config/operation-support.ts +19 -4
  89. package/node_modules/@mrclrchtr/supi-lsp/src/config/server-config.ts +22 -0
  90. package/node_modules/@mrclrchtr/supi-lsp/src/config/typescript-launch.ts +276 -0
  91. package/node_modules/@mrclrchtr/supi-lsp/src/manager/manager-project-info.ts +22 -10
  92. package/node_modules/@mrclrchtr/supi-lsp/src/manager/manager.ts +53 -20
  93. package/node_modules/@mrclrchtr/supi-lsp/src/provider/refactor-planning.ts +4 -3
  94. package/node_modules/@mrclrchtr/supi-lsp/src/session/runtime-controller.ts +2 -2
  95. package/node_modules/@mrclrchtr/supi-lsp/src/session/scanner.ts +27 -15
  96. package/node_modules/@mrclrchtr/supi-tree-sitter/README.md +1 -0
  97. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/package.json +1 -1
  98. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/package.json +1 -1
  99. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/src/debug-registry.ts +41 -1
  100. package/node_modules/@mrclrchtr/supi-tree-sitter/package.json +5 -3
  101. package/node_modules/@mrclrchtr/supi-tree-sitter/resources/grammars/tsx/LICENSE +21 -0
  102. package/node_modules/@mrclrchtr/supi-tree-sitter/resources/grammars/tsx/tree-sitter-tsx.wasm +0 -0
  103. package/node_modules/@mrclrchtr/supi-tree-sitter/resources/grammars/tsx/tree-sitter-tsx.wasm.json +19 -2
  104. package/node_modules/@mrclrchtr/supi-tree-sitter/resources/grammars/typescript/LICENSE +21 -0
  105. package/node_modules/@mrclrchtr/supi-tree-sitter/resources/grammars/typescript/tree-sitter-typescript.wasm +0 -0
  106. package/node_modules/@mrclrchtr/supi-tree-sitter/resources/grammars/typescript/tree-sitter-typescript.wasm.json +19 -2
  107. package/node_modules/ignore/README.md +36 -10
  108. package/node_modules/ignore/index.d.ts +3 -2
  109. package/node_modules/ignore/index.js +57 -53
  110. package/node_modules/ignore/legacy.js +50 -46
  111. package/node_modules/ignore/package.json +1 -1
  112. package/package.json +11 -6
  113. package/src/analysis/capability/capability-warnings.ts +18 -12
  114. package/src/analysis/gradle/query.ts +273 -0
  115. package/src/analysis/gradle/runtime.ts +173 -0
  116. package/src/analysis/gradle/types.ts +65 -0
  117. package/src/analysis/health/check.ts +115 -0
  118. package/src/analysis/health/diagnostics.ts +3 -0
  119. package/src/analysis/health/file-scope.ts +2 -3
  120. package/src/analysis/health/semantic-state.ts +38 -0
  121. package/src/analysis/health/server-status.ts +8 -0
  122. package/src/analysis/health/signals.ts +2 -0
  123. package/src/analysis/health/status.ts +82 -0
  124. package/src/analysis/read-next.ts +1 -4
  125. package/src/analysis/refactor/apply.ts +19 -10
  126. package/src/analysis/refactor/mutation-authority.ts +4 -1
  127. package/src/analysis/search/ast-scan.ts +143 -18
  128. package/src/analysis/workspace/safe-path.ts +14 -2
  129. package/src/analysis/workspace/types.ts +2 -0
  130. package/src/extension.ts +10 -1
  131. package/src/gradle/consent.ts +279 -0
  132. package/src/headless.ts +3 -0
  133. package/src/overview/collect.ts +11 -3
  134. package/src/session/health-types.ts +7 -0
  135. package/src/session/health-workflow.ts +8 -43
  136. package/src/session/orientation/collect.ts +138 -12
  137. package/src/session/orientation/context-facts.ts +27 -2
  138. package/src/session/orientation/context-sections.ts +47 -0
  139. package/src/session/orientation/facts.ts +124 -0
  140. package/src/session/orientation/gather.ts +98 -11
  141. package/src/session/orientation/workspace-context.ts +59 -28
  142. package/src/session/orientation-types.ts +16 -1
  143. package/src/session/orientation-workflow.ts +5 -2
  144. package/src/session/refactor-plans.ts +5 -2
  145. package/src/session/refactor-workflow.ts +4 -3
  146. package/src/session/session.ts +8 -0
  147. package/src/tool/code_find/execute.ts +1 -1
  148. package/src/tool/code_find/guidance.ts +1 -1
  149. package/src/tool/code_find/markdown.ts +24 -17
  150. package/src/tool/code_find/result.ts +18 -5
  151. package/src/tool/code_find/spec.ts +2 -0
  152. package/src/tool/code_find/structured.ts +161 -0
  153. package/src/tool/code_graph/result.ts +32 -15
  154. package/src/tool/code_graph/spec.ts +2 -0
  155. package/src/tool/code_graph/structured.ts +142 -0
  156. package/src/tool/code_health/markdown.ts +17 -17
  157. package/src/tool/code_health/result.ts +15 -2
  158. package/src/tool/code_health/spec.ts +2 -0
  159. package/src/tool/code_health/structured-schema.ts +250 -0
  160. package/src/tool/code_health/structured.ts +256 -0
  161. package/src/tool/code_inspect/markdown.ts +19 -11
  162. package/src/tool/code_inspect/result.ts +12 -5
  163. package/src/tool/code_inspect/spec.ts +2 -0
  164. package/src/tool/code_inspect/structured.ts +232 -0
  165. package/src/tool/code_orientation/directory-navigation.ts +66 -0
  166. package/src/tool/code_orientation/gradle-sections.ts +68 -0
  167. package/src/tool/code_orientation/markdown.ts +19 -8
  168. package/src/tool/code_orientation/result.ts +95 -11
  169. package/src/tool/code_orientation/spec.ts +2 -0
  170. package/src/tool/code_orientation/structured-schema.ts +607 -0
  171. package/src/tool/code_orientation/structured-workspace.ts +193 -0
  172. package/src/tool/code_orientation/structured.ts +195 -0
  173. package/src/tool/code_orientation/workspace-format.ts +2 -1
  174. package/src/tool/code_orientation/workspace-observations.ts +81 -0
  175. package/src/tool/code_orientation/workspace-output.ts +45 -13
  176. package/src/tool/code_orientation/workspace-projects.ts +180 -75
  177. package/src/tool/code_orientation/workspace-sections.ts +46 -31
  178. package/src/tool/code_refactor_apply/execute.ts +1 -1
  179. package/src/tool/code_refactor_apply/result.ts +13 -5
  180. package/src/tool/code_refactor_apply/spec.ts +2 -0
  181. package/src/tool/code_refactor_apply/structured.ts +49 -0
  182. package/src/tool/code_refactor_plan/result.ts +16 -8
  183. package/src/tool/code_refactor_plan/spec.ts +2 -0
  184. package/src/tool/code_refactor_plan/structured.ts +128 -0
  185. package/src/tool/code_resolve/markdown.ts +4 -10
  186. package/src/tool/code_resolve/result.ts +2 -0
  187. package/src/tool/code_resolve/spec.ts +2 -0
  188. package/src/tool/code_resolve/structured.ts +103 -0
  189. package/src/tool/infra/truncate.ts +12 -4
  190. package/src/tool/register.ts +10 -6
  191. package/src/tool/result/display.ts +17 -0
  192. package/src/tool/result/model-budget.ts +195 -0
  193. package/src/tool/result/structured.ts +62 -0
  194. package/src/tool/result/types.ts +10 -2
  195. package/src/tool/schemas.ts +7 -1
  196. package/src/tool/specs.ts +2 -0
  197. package/src/types/execution.ts +5 -1
  198. package/src/ui/status-command.ts +110 -321
  199. package/src/ui/status-overlay.ts +564 -420
  200. package/src/ui/tui/display.ts +10 -4
@@ -5,17 +5,25 @@ import { workspaceOrientationData } from "../session/orientation/workspace-conte
5
5
  import { prepareWorkspaceOutput } from "../tool/code_orientation/workspace-output.ts";
6
6
 
7
7
  /** Capture a first-turn map without requiring any project metadata or provider. */
8
- export async function collectOverview(cwd: string, projectTrusted: boolean, homeDir?: string) {
8
+ export async function collectOverview(
9
+ cwd: string,
10
+ projectTrusted: boolean,
11
+ homeDir?: string,
12
+ gradleObserver?: import("../analysis/gradle/types.ts").GradleObserver,
13
+ ) {
9
14
  try {
10
15
  if (!statSync(cwd).isDirectory()) return null;
11
16
  } catch {
12
17
  return null;
13
18
  }
14
19
  const exclude = loadAutomaticExclusionPatterns(cwd, { projectTrusted, homeDir });
15
- const observation = await observeWorkspace(cwd, {
20
+ const control = { deadline: Date.now() + 10_000 };
21
+ let observation = await observeWorkspace(cwd, {
16
22
  exclude,
17
- control: { deadline: Date.now() + 10_000 },
23
+ control,
18
24
  });
25
+ const gradle = await gradleObserver?.observe(cwd, control);
26
+ if (gradle) observation = { ...observation, gradle };
19
27
  return prepareWorkspaceOutput(
20
28
  workspaceOrientationData({ observation, cwd, focus: null, maxResults: 10, overview: true }),
21
29
  );
@@ -10,6 +10,9 @@ import type {
10
10
  import type { CapabilityWarningReport } from "../analysis/capability/capability-warnings.ts";
11
11
  import type { SourceTrackingReport } from "../substrate/lsp/source-tracking.ts";
12
12
 
13
+ /** Maximum detailed error and warning messages retained for each diagnostic file. */
14
+ export const HEALTH_DIAGNOSTIC_MESSAGE_LIMIT = 3;
15
+
13
16
  export type HealthSection = "diagnostics" | "servers";
14
17
 
15
18
  /** Final semantic-diagnostics readiness after routing and requested recovery. */
@@ -33,6 +36,10 @@ export interface HealthServerInfo {
33
36
  readonly fileTypes: readonly string[];
34
37
  readonly status: ProjectServerInfo["status"];
35
38
  readonly statusReason?: ProjectServerStatusReason;
39
+ /** Compiler selection used by this route generation, if automatically resolved. */
40
+ readonly typescript?: ProjectServerInfo["typescript"];
41
+ /** Actionable launch failure, distinct from process recovery status. */
42
+ readonly failureMessage?: string;
36
43
  readonly ready: boolean;
37
44
  /** Negotiated operation support and SuPi planning limitations. */
38
45
  readonly operationSupport?: ServerOperationSupportMap;
@@ -20,6 +20,7 @@ import {
20
20
  isScopedFile,
21
21
  } from "../analysis/health/diagnostics.ts";
22
22
  import { describeStructuralState } from "../analysis/health/recovery.ts";
23
+ import { deriveWorkspaceSemanticHealthState } from "../analysis/health/semantic-state.ts";
23
24
  import { collectServers } from "../analysis/health/signals.ts";
24
25
  import { SEMANTIC_READINESS_TIMEOUT_REASON } from "../analysis/readiness.ts";
25
26
  import { resolveScope } from "../analysis/search/paths.ts";
@@ -175,55 +176,19 @@ async function establishSemanticHealthState(
175
176
  options.control,
176
177
  )
177
178
  : null);
178
- if (!readiness) return deriveNonReadySemanticState(options.lspState, options.capabilityState);
179
+ if (!readiness)
180
+ return deriveWorkspaceSemanticHealthState(options.lspState, options.capabilityState, []);
179
181
  if (readiness.kind === "ready") return { kind: "ready" };
180
182
  if (readiness.kind === "timeout") {
181
183
  return { kind: "pending", reason: SEMANTIC_READINESS_TIMEOUT_REASON };
182
184
  }
183
185
  return { kind: "unavailable", reason: readiness.reason };
184
186
  }
185
- if (
186
- options.runtime
187
- ?.getProjectServers()
188
- .some((server) => server.status === "running" && server.ready === true)
189
- ) {
190
- return { kind: "ready" };
191
- }
192
- return deriveNonReadySemanticState(options.lspState, options.capabilityState);
193
- }
194
-
195
- function deriveNonReadySemanticState(
196
- lspState: WorkspaceLspRuntimeState,
197
- capabilityState: CapabilityState,
198
- ): Exclude<SemanticHealthState, { kind: "ready" }> {
199
- switch (lspState.kind) {
200
- case "pending":
201
- return { kind: "pending", reason: "LSP is starting" };
202
- case "inactive":
203
- return { kind: "inactive", reason: "Inactive on the current session branch" };
204
- case "disabled":
205
- return { kind: "disabled", reason: "Disabled by configuration" };
206
- case "unavailable":
207
- return { kind: "unavailable", reason: lspState.reason };
208
- case "ready":
209
- return deriveReadyOwnerWithoutServerState(capabilityState);
210
- }
211
- }
212
-
213
- function deriveReadyOwnerWithoutServerState(
214
- capabilityState: CapabilityState,
215
- ): Exclude<SemanticHealthState, { kind: "ready" }> {
216
- switch (capabilityState.kind) {
217
- case "inactive":
218
- return { kind: "inactive", reason: "Inactive on the current session branch" };
219
- case "disabled":
220
- return { kind: "disabled", reason: "Disabled by configuration" };
221
- case "unavailable":
222
- return { kind: "unavailable", reason: capabilityState.reason };
223
- case "pending":
224
- case "ready":
225
- return { kind: "pending", reason: "No active, ready project servers" };
226
- }
187
+ return deriveWorkspaceSemanticHealthState(
188
+ options.lspState,
189
+ options.capabilityState,
190
+ options.runtime?.getProjectServers() ?? [],
191
+ );
227
192
  }
228
193
 
229
194
  function collectCapabilityWarnings(
@@ -36,6 +36,7 @@ interface TargetSectionCollection {
36
36
  readonly reason: string | null;
37
37
  readonly evidenceLists: readonly EvidenceListMetadata[];
38
38
  readonly errorRanges?: readonly SourceRange[];
39
+ readonly facts?: import("./facts.ts").OrientationFacts;
39
40
  }
40
41
 
41
42
  const DEFAULT_TARGET_SECTIONS: OrientationSection[] = ["defs", "docs", "diagnostics"];
@@ -141,11 +142,29 @@ async function buildRequestedSection(options: {
141
142
  switch (section) {
142
143
  case "defs": {
143
144
  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
- ]);
145
+ const contextFacts = targetContextFacts(treeContext, limit);
146
+ const operations = treeContext?.operations;
147
+ const semanticObserved =
148
+ result.hasSemanticEvidence ||
149
+ (operations &&
150
+ [operations.hover, operations.definition].some(
151
+ ({ status }) => status === "complete" || status === "partial",
152
+ ));
153
+ const structuralObserved =
154
+ operations &&
155
+ [operations.nodeAt, operations.outline, operations.imports, operations.exports].some(
156
+ ({ status }) => status === "complete" || status === "partial",
157
+ );
158
+ return targetSectionResult(
159
+ section,
160
+ { ...result, facts: { ...contextFacts, ...result.facts } },
161
+ [
162
+ ...(semanticObserved ? [{ source: "semantic" as const, capability: "LSP" }] : []),
163
+ ...(structuralObserved
164
+ ? [{ source: "structural" as const, capability: "tree-sitter" }]
165
+ : []),
166
+ ],
167
+ );
149
168
  }
150
169
  case "docs":
151
170
  return targetSectionResult(section, await buildDocsSection(target, deps, limit), [
@@ -158,6 +177,75 @@ async function buildRequestedSection(options: {
158
177
  }
159
178
  }
160
179
 
180
+ /** Select the independently gathered source observations without rendering them. */
181
+ function targetContextFacts(
182
+ treeContext: Awaited<ReturnType<typeof maybeGatherTreeContext>>,
183
+ limit: number,
184
+ ) {
185
+ return treeContext
186
+ ? {
187
+ node: treeContext.nodeInfo
188
+ ? {
189
+ type: treeContext.nodeInfo.type,
190
+ text: treeContext.nodeInfo.text,
191
+ startLine: treeContext.nodeInfo.startLine,
192
+ startCharacter: treeContext.nodeInfo.startCharacter,
193
+ endLine: treeContext.nodeInfo.endLine,
194
+ endCharacter: treeContext.nodeInfo.endCharacter,
195
+ ancestry: treeContext.nodeInfo.ancestry.map(
196
+ ({ type, startLine, startCharacter, endLine, endCharacter }) => ({
197
+ type,
198
+ startLine,
199
+ startCharacter,
200
+ endLine,
201
+ endCharacter,
202
+ }),
203
+ ),
204
+ }
205
+ : null,
206
+ nodeObservation: { ...treeContext.operations.nodeAt },
207
+ hoverObservation: { ...treeContext.operations.hover },
208
+ hover: treeContext.hover
209
+ ? {
210
+ contents: treeContext.hover.contents,
211
+ ...(treeContext.hover.range
212
+ ? {
213
+ range: publicRange(treeContext.hover.range),
214
+ }
215
+ : {}),
216
+ }
217
+ : null,
218
+ recovery: treeContext.recovery.map(({ operation, file, reason, errorRanges }) => ({
219
+ operation,
220
+ file,
221
+ reason,
222
+ errorRanges: errorRanges.map(publicRange),
223
+ })),
224
+ contextDefinitions: {
225
+ ...treeContext.operations.definition,
226
+ ...(treeContext.definition !== null
227
+ ? {
228
+ entries: treeContext.definition
229
+ .slice(0, limit)
230
+ .map(({ uri, range }) => ({ uri, range: publicRange(range) })),
231
+ collectedCount: treeContext.definition.length,
232
+ omittedCount: Math.max(0, treeContext.definition.length - limit),
233
+ }
234
+ : {}),
235
+ },
236
+ sourceContext: {
237
+ outline: sourceSelection(treeContext.operations.outline, treeContext.outline, limit),
238
+ imports: sourceSelection(
239
+ treeContext.operations.imports,
240
+ treeContext.imports.map(({ moduleSpecifier }) => ({ moduleSpecifier })),
241
+ limit,
242
+ ),
243
+ exports: sourceSelection(treeContext.operations.exports, treeContext.exports, limit),
244
+ },
245
+ }
246
+ : {};
247
+ }
248
+
161
249
  /** Build enriched defs section: tree-sitter definitions + LSP definition targets. */
162
250
  async function buildEnrichedDefsSection(
163
251
  target: Readonly<TargetStoreEntry> | null | undefined,
@@ -252,6 +340,7 @@ function mergeDefinitionCollection(input: {
252
340
  reason:
253
341
  [input.recoveryReason || null, input.definitions.reason].filter(Boolean).join(" ") || null,
254
342
  evidenceLists: input.definitions.evidenceLists,
343
+ ...(input.definitions.facts ? { facts: input.definitions.facts } : {}),
255
344
  ...(input.recoveryRanges.length > 0 ? { errorRanges: [...input.recoveryRanges] } : {}),
256
345
  };
257
346
  }
@@ -263,7 +352,7 @@ async function collectDefinitionTargets(
263
352
  ): Promise<
264
353
  Pick<
265
354
  TargetSectionCollection,
266
- "items" | "hasSemanticEvidence" | "status" | "reason" | "evidenceLists"
355
+ "items" | "hasSemanticEvidence" | "status" | "reason" | "evidenceLists" | "facts"
267
356
  >
268
357
  > {
269
358
  if (!deps.provider?.definition) {
@@ -289,11 +378,10 @@ async function collectDefinitionTargets(
289
378
  evidenceLists: [],
290
379
  };
291
380
  }
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
- });
381
+ const locations = result.data.map((definition) => ({
382
+ file: path.relative(deps.cwd, uriToFile(definition.uri)),
383
+ range: publicRange(definition.range),
384
+ }));
297
385
  const evidence =
298
386
  result.kind === "partial"
299
387
  ? createPartialEvidenceList({
@@ -308,7 +396,11 @@ async function collectDefinitionTargets(
308
396
  maxResults: limit,
309
397
  });
310
398
  return {
311
- items: evidence.items.map((location) => ({ kind: "paragraph", text: location })),
399
+ items: evidence.items.map((location) => ({
400
+ kind: "paragraph",
401
+ text: `\`${location.file}:${location.range.start.line + 1}:${location.range.start.character + 1}\``,
402
+ })),
403
+ facts: { definitions: evidence.items },
312
404
  hasSemanticEvidence: true,
313
405
  status: result.kind === "partial" ? "partial" : "complete",
314
406
  reason: result.kind === "partial" ? result.reason : null,
@@ -384,6 +476,15 @@ async function buildDiagnosticsSection(
384
476
  : evidence.items.map((diagnostic) => formatDiagnosticItem(diagnostic)),
385
477
  hasStructuralEvidence: false,
386
478
  hasSemanticEvidence: true,
479
+ facts: {
480
+ diagnostics: evidence.items.map((diagnostic) => ({
481
+ range: publicRange(diagnostic.range),
482
+ severity: diagnostic.severity ?? null,
483
+ message: diagnosticMessageString(diagnostic),
484
+ source: diagnostic.source ?? null,
485
+ code: diagnostic.code ?? null,
486
+ })),
487
+ },
387
488
  status: result.kind === "partial" ? "partial" : "complete",
388
489
  reason: result.kind === "partial" ? result.reason : null,
389
490
  evidenceLists: [evidence.metadata],
@@ -409,6 +510,7 @@ function formatDiagnosticItem(diagnostic: Diagnostic): OrientationItem {
409
510
  function completedDocsSection(
410
511
  items: OrientationItem[],
411
512
  evidenceLists: readonly EvidenceListMetadata[],
513
+ documentation: readonly string[] = [],
412
514
  ): TargetSectionCollection {
413
515
  return {
414
516
  items,
@@ -417,6 +519,7 @@ function completedDocsSection(
417
519
  status: "complete",
418
520
  reason: null,
419
521
  evidenceLists,
522
+ facts: { documentation },
420
523
  };
421
524
  }
422
525
 
@@ -529,6 +632,7 @@ async function buildDocsSection(
529
632
  return completedDocsSection(
530
633
  [{ kind: "code", language: "ts", lines: evidence.items }],
531
634
  [evidence.metadata],
635
+ evidence.items,
532
636
  );
533
637
  } catch (error) {
534
638
  return unavailableTargetSection(
@@ -555,6 +659,27 @@ async function maybeGatherTreeContext(
555
659
  );
556
660
  }
557
661
 
662
+ function publicRange(range: SourceRange): SourceRange {
663
+ return {
664
+ start: { line: range.start.line, character: range.start.character },
665
+ end: { line: range.end.line, character: range.end.character },
666
+ };
667
+ }
668
+
669
+ /** These best-effort lists preserve availability separately from collected counts. */
670
+ function sourceSelection<T>(
671
+ status: { status: "complete" | "partial" | "unavailable"; reason: string | null },
672
+ entries: readonly T[],
673
+ limit: number,
674
+ ) {
675
+ return {
676
+ ...status,
677
+ entries: entries.slice(0, limit),
678
+ collectedCount: entries.length,
679
+ omittedCount: Math.max(0, entries.length - limit),
680
+ };
681
+ }
682
+
558
683
  function uniqueRecoveryRanges(
559
684
  recovery: readonly { errorRanges: readonly SourceRange[] }[],
560
685
  ): SourceRange[] {
@@ -754,6 +879,7 @@ function targetSectionResult(
754
879
  provenance,
755
880
  evidenceLists: collection.evidenceLists,
756
881
  ...(collection.errorRanges ? { errorRanges: [...collection.errorRanges] } : {}),
882
+ ...(collection.facts ? { facts: collection.facts } : {}),
757
883
  items: collection.items,
758
884
  },
759
885
  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}\`)`;
@@ -39,6 +39,7 @@ export interface ListSectionInput<T> {
39
39
  readonly unknownRemainder?: boolean;
40
40
  readonly partialReason?: EvidencePartialReason;
41
41
  readonly errorRanges?: readonly SourceRange[];
42
+ readonly facts?: (items: readonly T[]) => import("./facts.ts").OrientationFacts;
42
43
  }
43
44
 
44
45
  /** Start a context-Oriented document with one factual focus title. */
@@ -78,6 +79,7 @@ export function appendList<T>(
78
79
  provenance: input.provenance,
79
80
  evidenceLists: [{ ...metadata, key: input.key }],
80
81
  items: list.items.map((item) => ({ kind: "list-item", text: input.render(item) })),
82
+ ...(input.facts ? { facts: input.facts(list.items) } : {}),
81
83
  ...(input.errorRanges ? { errorRanges: [...input.errorRanges] } : {}),
82
84
  });
83
85
  }
@@ -175,6 +177,16 @@ export async function appendStructuralFileFacts(
175
177
  collect: () => provider.outline(file, requestControl),
176
178
  requestControl,
177
179
  render: (item) => `\`${item.name}\` (${item.kind}, L${item.startLine}–L${item.endLine})`,
180
+ facts: (items) => ({
181
+ outline: items.map(({ name, kind, startLine, startCharacter, endLine, endCharacter }) => ({
182
+ name,
183
+ kind,
184
+ startLine,
185
+ startCharacter,
186
+ endLine,
187
+ endCharacter,
188
+ })),
189
+ }),
178
190
  });
179
191
  await appendStructuralList(builder, {
180
192
  key: "structural.imports",
@@ -182,6 +194,17 @@ export async function appendStructuralFileFacts(
182
194
  collect: () => provider.imports(file, requestControl),
183
195
  requestControl,
184
196
  render: (item) => `\`${item.moduleSpecifier}\``,
197
+ facts: (items) => ({
198
+ imports: items.map(
199
+ ({ moduleSpecifier, startLine, startCharacter, endLine, endCharacter }) => ({
200
+ moduleSpecifier,
201
+ startLine,
202
+ startCharacter,
203
+ endLine,
204
+ endCharacter,
205
+ }),
206
+ ),
207
+ }),
185
208
  });
186
209
  await appendStructuralList(builder, {
187
210
  key: "structural.exports",
@@ -189,6 +212,19 @@ export async function appendStructuralFileFacts(
189
212
  collect: () => provider.exports(file, requestControl),
190
213
  requestControl,
191
214
  render: (item) => `\`${item.name}\` (${item.kind})`,
215
+ facts: (items) => ({
216
+ exports: items.map(
217
+ ({ name, kind, startLine, startCharacter, endLine, endCharacter, moduleSpecifier }) => ({
218
+ name,
219
+ kind,
220
+ startLine,
221
+ startCharacter,
222
+ endLine,
223
+ endCharacter,
224
+ ...(moduleSpecifier === undefined ? {} : { moduleSpecifier }),
225
+ }),
226
+ ),
227
+ }),
192
228
  });
193
229
  }
194
230
 
@@ -214,6 +250,7 @@ async function appendStructuralList<T>(
214
250
  title: string;
215
251
  collect: () => Promise<CodeResult<T[]>>;
216
252
  render: (item: T) => string;
253
+ facts: (items: readonly T[]) => import("./facts.ts").OrientationFacts;
217
254
  requestControl?: CodeRequestControl;
218
255
  },
219
256
  ): Promise<void> {
@@ -252,6 +289,7 @@ async function appendStructuralList<T>(
252
289
  title: input.title,
253
290
  items: result.data,
254
291
  render: input.render,
292
+ facts: input.facts,
255
293
  confidence: "structural",
256
294
  provenance: [{ source: "structural", capability: "tree-sitter" }],
257
295
  ...(result.kind === "partial"
@@ -296,6 +334,15 @@ export function appendPrioritySignals(
296
334
  return `Diagnostics: \`${displayPath(input.cwd, entry.file)}\` (${parts.join(", ")})`;
297
335
  },
298
336
  confidence: "semantic",
337
+ facts: (items) => ({
338
+ diagnosticSnapshot: items.map(({ file, total, errors, warnings }) => ({
339
+ file: displayPath(input.cwd, file),
340
+ total,
341
+ errors,
342
+ warnings,
343
+ })),
344
+ snapshotCurrent: snapshot.current,
345
+ }),
299
346
  provenance: [{ source: "semantic", capability: "LSP diagnostic snapshot" }],
300
347
  status: "partial",
301
348
  reason: snapshot.current
@@ -0,0 +1,124 @@
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 { readonly uri: string; readonly range: SourceRange }[];
79
+ readonly collectedCount?: number;
80
+ readonly omittedCount?: number;
81
+ };
82
+ readonly recovery?: readonly {
83
+ readonly operation: string;
84
+ readonly file: string;
85
+ readonly reason: string;
86
+ readonly errorRanges: readonly SourceRange[];
87
+ }[];
88
+ readonly sourceContext?: {
89
+ readonly outline: {
90
+ readonly status: "complete" | "partial" | "unavailable";
91
+ readonly reason: string | null;
92
+ readonly entries: readonly {
93
+ readonly name: string;
94
+ readonly kind: string;
95
+ readonly startLine: number;
96
+ readonly endLine: number;
97
+ }[];
98
+ readonly collectedCount: number;
99
+ readonly omittedCount: number;
100
+ };
101
+ readonly imports: {
102
+ readonly status: "complete" | "partial" | "unavailable";
103
+ readonly reason: string | null;
104
+ readonly entries: readonly { readonly moduleSpecifier: string }[];
105
+ readonly collectedCount: number;
106
+ readonly omittedCount: number;
107
+ };
108
+ readonly exports: {
109
+ readonly status: "complete" | "partial" | "unavailable";
110
+ readonly reason: string | null;
111
+ readonly entries: readonly { readonly name: string; readonly kind: string }[];
112
+ readonly collectedCount: number;
113
+ readonly omittedCount: number;
114
+ };
115
+ };
116
+ readonly documentation?: readonly string[];
117
+ readonly diagnostics?: readonly {
118
+ readonly range: SourceRange;
119
+ readonly severity: number | null;
120
+ readonly message: string;
121
+ readonly source: string | null;
122
+ readonly code: string | number | null;
123
+ }[];
124
+ }