@mrclrchtr/supi-code-intelligence 4.9.0 → 5.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 (215) hide show
  1. package/README.md +2 -1
  2. package/node_modules/@mrclrchtr/supi-code-runtime/README.md +2 -0
  3. package/node_modules/@mrclrchtr/supi-code-runtime/package.json +1 -1
  4. package/node_modules/@mrclrchtr/supi-code-runtime/src/api.ts +9 -0
  5. package/node_modules/@mrclrchtr/supi-code-runtime/src/capability/types.ts +53 -13
  6. package/node_modules/@mrclrchtr/supi-code-runtime/src/request-control.ts +47 -0
  7. package/node_modules/@mrclrchtr/supi-code-runtime/src/types.ts +13 -1
  8. package/node_modules/@mrclrchtr/supi-core/README.md +2 -0
  9. package/node_modules/@mrclrchtr/supi-core/package.json +1 -1
  10. package/node_modules/@mrclrchtr/supi-core/src/config/config.ts +31 -0
  11. package/node_modules/@mrclrchtr/supi-core/src/config.ts +2 -0
  12. package/node_modules/@mrclrchtr/supi-core/src/debug-registry.ts +19 -3
  13. package/node_modules/@mrclrchtr/supi-core/src/debug-timing.ts +34 -21
  14. package/node_modules/@mrclrchtr/supi-core/src/settings/settings-registry.ts +3 -0
  15. package/node_modules/@mrclrchtr/supi-lsp/README.md +80 -5
  16. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-code-runtime/README.md +2 -0
  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-code-runtime/src/api.ts +9 -0
  19. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-code-runtime/src/capability/types.ts +53 -13
  20. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-code-runtime/src/request-control.ts +47 -0
  21. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-code-runtime/src/types.ts +13 -1
  22. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-core/README.md +2 -0
  23. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-core/package.json +1 -1
  24. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-core/src/config/config.ts +31 -0
  25. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-core/src/config.ts +2 -0
  26. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-core/src/debug-registry.ts +19 -3
  27. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-core/src/debug-timing.ts +34 -21
  28. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-core/src/settings/settings-registry.ts +3 -0
  29. package/node_modules/@mrclrchtr/supi-lsp/package.json +7 -6
  30. package/node_modules/@mrclrchtr/supi-lsp/src/api.ts +10 -0
  31. package/node_modules/@mrclrchtr/supi-lsp/src/client/client-diagnostic-cache.ts +206 -0
  32. package/node_modules/@mrclrchtr/supi-lsp/src/client/client-diagnostic-capabilities.ts +78 -0
  33. package/node_modules/@mrclrchtr/supi-lsp/src/client/client-diagnostic-collection.ts +114 -0
  34. package/node_modules/@mrclrchtr/supi-lsp/src/client/client-diagnostic-evidence.ts +372 -0
  35. package/node_modules/@mrclrchtr/supi-lsp/src/client/client-diagnostic-host.ts +14 -0
  36. package/node_modules/@mrclrchtr/supi-lsp/src/client/client-diagnostic-pull.ts +62 -0
  37. package/node_modules/@mrclrchtr/supi-lsp/src/client/client-diagnostic-refresh.ts +491 -0
  38. package/node_modules/@mrclrchtr/supi-lsp/src/client/client-diagnostic-request.ts +9 -0
  39. package/node_modules/@mrclrchtr/supi-lsp/src/client/client-diagnostic-timing.ts +215 -0
  40. package/node_modules/@mrclrchtr/supi-lsp/src/client/client-diagnostic-waiters.ts +206 -0
  41. package/node_modules/@mrclrchtr/supi-lsp/src/client/client-diagnostics.ts +370 -266
  42. package/node_modules/@mrclrchtr/supi-lsp/src/client/client-document-state.ts +52 -0
  43. package/node_modules/@mrclrchtr/supi-lsp/src/client/client-document-sync.ts +185 -0
  44. package/node_modules/@mrclrchtr/supi-lsp/src/client/client-file-state.ts +25 -0
  45. package/node_modules/@mrclrchtr/supi-lsp/src/client/client.ts +467 -115
  46. package/node_modules/@mrclrchtr/supi-lsp/src/client/transport.ts +238 -11
  47. package/node_modules/@mrclrchtr/supi-lsp/src/config/capabilities.ts +10 -1
  48. package/node_modules/@mrclrchtr/supi-lsp/src/config/defaults.json +1 -1
  49. package/node_modules/@mrclrchtr/supi-lsp/src/debug-telemetry.ts +45 -0
  50. package/node_modules/@mrclrchtr/supi-lsp/src/diagnostics/evidence.ts +38 -0
  51. package/node_modules/@mrclrchtr/supi-lsp/src/manager/manager-client-state.ts +79 -9
  52. package/node_modules/@mrclrchtr/supi-lsp/src/manager/manager-diagnostics.ts +13 -4
  53. package/node_modules/@mrclrchtr/supi-lsp/src/manager/manager-workspace-recovery.ts +300 -24
  54. package/node_modules/@mrclrchtr/supi-lsp/src/manager/manager-workspace-symbol.ts +5 -2
  55. package/node_modules/@mrclrchtr/supi-lsp/src/manager/manager.ts +464 -96
  56. package/node_modules/@mrclrchtr/supi-lsp/src/provider/lsp-refactor-provider.ts +130 -0
  57. package/node_modules/@mrclrchtr/supi-lsp/src/provider/lsp-semantic-provider.ts +45 -329
  58. package/node_modules/@mrclrchtr/supi-lsp/src/provider/refactor-planning.ts +57 -120
  59. package/node_modules/@mrclrchtr/supi-lsp/src/provider/semantic-edit-normalizer.ts +320 -0
  60. package/node_modules/@mrclrchtr/supi-lsp/src/provider/semantic-symbol-mapper.ts +207 -0
  61. package/node_modules/@mrclrchtr/supi-lsp/src/session/readiness.ts +72 -2
  62. package/node_modules/@mrclrchtr/supi-lsp/src/session/runtime-controller.ts +151 -26
  63. package/node_modules/@mrclrchtr/supi-lsp/src/session/runtime-diagnostic-surface.ts +40 -0
  64. package/node_modules/@mrclrchtr/supi-lsp/src/session/runtime-diagnostics.ts +50 -0
  65. package/node_modules/@mrclrchtr/supi-lsp/src/session/runtime-registry.ts +136 -120
  66. package/node_modules/@mrclrchtr/supi-lsp/src/session/runtime-transition-debug.ts +49 -0
  67. package/node_modules/@mrclrchtr/supi-lsp/src/session/workspace-lsp-runtime.ts +102 -0
  68. package/node_modules/@mrclrchtr/supi-tree-sitter/README.md +26 -6
  69. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/README.md +2 -0
  70. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/package.json +1 -1
  71. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/src/api.ts +9 -0
  72. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/src/capability/types.ts +53 -13
  73. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/src/request-control.ts +47 -0
  74. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/src/types.ts +13 -1
  75. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/README.md +2 -0
  76. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/package.json +1 -1
  77. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/src/config/config.ts +31 -0
  78. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/src/config.ts +2 -0
  79. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/src/debug-registry.ts +19 -3
  80. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/src/debug-timing.ts +34 -21
  81. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/src/settings/settings-registry.ts +3 -0
  82. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/jiti/LICENSE +21 -0
  83. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/jiti/README.md +258 -0
  84. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/jiti/dist/babel.cjs +257 -0
  85. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/jiti/dist/jiti.cjs +1 -0
  86. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/jiti/lib/jiti-cli.mjs +34 -0
  87. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/jiti/lib/jiti-hooks.mjs +124 -0
  88. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/jiti/lib/jiti-native.mjs +121 -0
  89. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/jiti/lib/jiti-register.d.mts +1 -0
  90. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/jiti/lib/jiti-register.mjs +4 -0
  91. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/jiti/lib/jiti-static.mjs +23 -0
  92. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/jiti/lib/jiti.cjs +30 -0
  93. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/jiti/lib/jiti.d.cts +8 -0
  94. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/jiti/lib/jiti.d.mts +8 -0
  95. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/jiti/lib/jiti.mjs +29 -0
  96. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/jiti/lib/types.d.ts +420 -0
  97. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/jiti/package.json +146 -0
  98. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/web-tree-sitter/debug/web-tree-sitter.wasm +0 -0
  99. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/web-tree-sitter/debug/web-tree-sitter.wasm.map +4 -4
  100. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/web-tree-sitter/package.json +1 -1
  101. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/web-tree-sitter/web-tree-sitter.wasm +0 -0
  102. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/web-tree-sitter/web-tree-sitter.wasm.map +4 -4
  103. package/node_modules/@mrclrchtr/supi-tree-sitter/package.json +7 -3
  104. package/node_modules/@mrclrchtr/supi-tree-sitter/resources/grammars/kotlin/tree-sitter-kotlin.wasm.json +1 -1
  105. package/node_modules/@mrclrchtr/supi-tree-sitter/resources/grammars/sql/tree-sitter-sql.wasm.json +1 -1
  106. package/node_modules/@mrclrchtr/supi-tree-sitter/src/api.ts +0 -9
  107. package/node_modules/@mrclrchtr/supi-tree-sitter/src/index.ts +0 -8
  108. package/node_modules/@mrclrchtr/supi-tree-sitter/src/provider/tree-sitter-provider.ts +16 -12
  109. package/node_modules/@mrclrchtr/supi-tree-sitter/src/session/runtime-controller.ts +65 -87
  110. package/node_modules/@mrclrchtr/supi-tree-sitter/src/session/session.ts +47 -95
  111. package/node_modules/@mrclrchtr/supi-tree-sitter/src/session/structural-timing.ts +147 -0
  112. package/node_modules/@mrclrchtr/supi-tree-sitter/src/session/structural-worker-client-lifecycle.ts +39 -0
  113. package/node_modules/@mrclrchtr/supi-tree-sitter/src/session/structural-worker-client.ts +561 -0
  114. package/node_modules/@mrclrchtr/supi-tree-sitter/src/session/structural-worker-message-size.ts +24 -0
  115. package/node_modules/@mrclrchtr/supi-tree-sitter/src/session/structural-worker-protocol.ts +452 -0
  116. package/node_modules/@mrclrchtr/supi-tree-sitter/src/tool/call-sites.ts +4 -2
  117. package/node_modules/@mrclrchtr/supi-tree-sitter/src/tool/callees.ts +12 -4
  118. package/node_modules/@mrclrchtr/supi-tree-sitter/src/tool/exports.ts +4 -2
  119. package/node_modules/@mrclrchtr/supi-tree-sitter/src/tool/imports.ts +4 -2
  120. package/node_modules/@mrclrchtr/supi-tree-sitter/src/tool/node-at.ts +5 -3
  121. package/node_modules/@mrclrchtr/supi-tree-sitter/src/types.ts +33 -12
  122. package/node_modules/@mrclrchtr/supi-tree-sitter/src/worker/blocking-test-bootstrap.mjs +34 -0
  123. package/node_modules/@mrclrchtr/supi-tree-sitter/src/worker/bootstrap.mjs +8 -0
  124. package/node_modules/@mrclrchtr/supi-tree-sitter/src/worker/parsed-file-store-helpers.ts +23 -0
  125. package/node_modules/@mrclrchtr/supi-tree-sitter/src/worker/parsed-file-store.ts +400 -0
  126. package/node_modules/@mrclrchtr/supi-tree-sitter/src/worker/request-control.ts +48 -0
  127. package/node_modules/@mrclrchtr/supi-tree-sitter/src/worker/runtime-parser-helpers.ts +24 -0
  128. package/node_modules/@mrclrchtr/supi-tree-sitter/src/worker/runtime-query-helpers.ts +43 -0
  129. package/node_modules/@mrclrchtr/supi-tree-sitter/src/worker/runtime.ts +421 -0
  130. package/node_modules/@mrclrchtr/supi-tree-sitter/src/worker/service.ts +116 -0
  131. package/node_modules/@mrclrchtr/supi-tree-sitter/src/worker/worker-main.ts +201 -0
  132. package/package.json +5 -5
  133. package/src/analysis/health/diagnostics.ts +236 -24
  134. package/src/analysis/health/recovery.ts +6 -2
  135. package/src/analysis/provider.ts +58 -0
  136. package/src/analysis/readiness.ts +30 -9
  137. package/src/analysis/refactor/apply.ts +59 -20
  138. package/src/analysis/refactor/mutation-authority.ts +143 -0
  139. package/src/analysis/refactor/position.ts +47 -0
  140. package/src/analysis/refactor/safety.ts +18 -10
  141. package/src/analysis/relations/callees.ts +9 -1
  142. package/src/analysis/relations/types.ts +5 -2
  143. package/src/analysis/search/ast-scan-timing.ts +9 -4
  144. package/src/analysis/search/ast-scan.ts +1 -1
  145. package/src/analysis/search/deadline.ts +2 -2
  146. package/src/analysis/search/pattern-analysis.ts +46 -32
  147. package/src/analysis/search/pattern.ts +12 -2
  148. package/src/analysis/target/anchored.ts +20 -11
  149. package/src/analysis/target/file.ts +18 -11
  150. package/src/analysis/target/identity.ts +19 -3
  151. package/src/analysis/target/symbol.ts +36 -15
  152. package/src/api.ts +4 -0
  153. package/src/diagnostics/evidence.ts +51 -0
  154. package/src/session/capability-adapter.ts +12 -3
  155. package/src/session/find-workflow.ts +17 -7
  156. package/src/session/graph/collect.ts +18 -2
  157. package/src/session/graph-workflow.ts +19 -12
  158. package/src/session/health-refresh.ts +148 -0
  159. package/src/session/health-types.ts +37 -15
  160. package/src/session/health-workflow.ts +37 -39
  161. package/src/session/inspect/collect.ts +20 -3
  162. package/src/session/inspect-workflow.ts +10 -5
  163. package/src/session/orientation/collect.ts +10 -1
  164. package/src/session/orientation/context-facts.ts +3 -1
  165. package/src/session/orientation/context-sections.ts +20 -7
  166. package/src/session/orientation/gather.ts +17 -11
  167. package/src/session/orientation-types.ts +2 -1
  168. package/src/session/orientation-workflow.ts +15 -8
  169. package/src/session/refactor-plans.ts +2 -0
  170. package/src/session/refactor-workflow.ts +59 -14
  171. package/src/session/session.ts +4 -1
  172. package/src/session/target-workflow.ts +54 -23
  173. package/src/session/workflow-control.ts +7 -3
  174. package/src/substrate/lsp/lifecycle.ts +26 -46
  175. package/src/substrate/lsp/maintenance.ts +199 -25
  176. package/src/substrate/lsp/state.ts +2 -2
  177. package/src/substrate/workspace-provider-host.ts +25 -3
  178. package/src/tool/find/execute.ts +7 -1
  179. package/src/tool/find/render.ts +20 -3
  180. package/src/tool/find/tui.ts +23 -21
  181. package/src/tool/graph/execute.ts +23 -3
  182. package/src/tool/graph/tui.ts +59 -46
  183. package/src/tool/health/execute.ts +7 -2
  184. package/src/tool/health/markdown.ts +56 -14
  185. package/src/tool/health/refresh-status.ts +105 -0
  186. package/src/tool/health/tui.ts +95 -98
  187. package/src/tool/infra/workflow-control.ts +8 -0
  188. package/src/tool/inspect/execute.ts +7 -1
  189. package/src/tool/inspect/tui.ts +26 -18
  190. package/src/tool/orientation/execute.ts +21 -3
  191. package/src/tool/orientation/tui.ts +51 -35
  192. package/src/tool/refactor-apply/execute.ts +3 -0
  193. package/src/tool/refactor-apply/tui.ts +43 -25
  194. package/src/tool/refactor-plan/execute.ts +4 -0
  195. package/src/tool/refactor-plan/tui.ts +33 -20
  196. package/src/tool/register.ts +127 -22
  197. package/src/tool/resolve/execute.ts +18 -1
  198. package/src/tool/resolve/tui.ts +42 -24
  199. package/src/tool/result/display.ts +107 -0
  200. package/src/tool/result/errors.ts +20 -17
  201. package/src/tool/result/find.ts +52 -8
  202. package/src/tool/result/graph.ts +44 -1
  203. package/src/tool/result/health.ts +53 -1
  204. package/src/tool/result/inspect.ts +113 -1
  205. package/src/tool/result/orientation.ts +66 -14
  206. package/src/tool/result/refactor.ts +36 -4
  207. package/src/tool/result/resolve.ts +44 -7
  208. package/src/tool/result/types.ts +20 -0
  209. package/src/types/execution.ts +18 -5
  210. package/src/types/index.ts +8 -1
  211. package/src/ui/status-command.ts +5 -3
  212. package/src/ui/status-overlay.ts +4 -0
  213. package/src/ui/tui/common.ts +108 -10
  214. package/src/ui/tui/display.ts +48 -0
  215. package/node_modules/@mrclrchtr/supi-tree-sitter/src/session/runtime.ts +0 -247
@@ -1,20 +1,14 @@
1
- /**
2
- * Tool-result error assembly factories for code-intelligence tool executors.
3
- *
4
- * Every factory returns a complete {@link CodeIntelResult} (content + typed
5
- * details) so executors never need to inline the `{ content, details }`
6
- * wrapper. Returned tool errors are result assembly concerns; whole-tool
7
- * capability failures may still throw so PI marks the tool call as failed.
8
- */
1
+ import type { CodeIntelResult, ToolDisplaySection } from "../../types/index.ts";
9
2
 
10
- import type { CodeIntelResult } from "../../types/index.ts";
11
-
12
- // ── Error-result factories ──────────────────────────────────────────
13
-
14
- /** Full error result for search-family tools (code_find, code_graph, code_refactor_plan). */
3
+ /** Full error result for search-family tools. */
15
4
  export function searchErrorResult(
16
5
  content: string,
17
- opts?: { scope?: string | null; nextQueries?: string[] },
6
+ opts?: {
7
+ scope?: string | null;
8
+ nextQueries?: string[];
9
+ message?: string;
10
+ displaySections?: readonly ToolDisplaySection[];
11
+ },
18
12
  ): CodeIntelResult {
19
13
  return {
20
14
  content,
@@ -27,14 +21,17 @@ export function searchErrorResult(
27
21
  omittedCount: 0,
28
22
  nextQueries: opts?.nextQueries ?? [],
29
23
  },
24
+ status: "invalid-input",
25
+ ...(opts?.message ? { message: opts.message } : {}),
26
+ ...(opts?.displaySections ? { displaySections: opts.displaySections } : {}),
30
27
  },
31
28
  };
32
29
  }
33
30
 
34
- /** Full error result for code_orientation (context-type details). */
31
+ /** Full error result for code_orientation. */
35
32
  export function contextErrorResult(
36
33
  content: string,
37
- opts?: { nextQueries?: string[] },
34
+ opts?: { nextQueries?: string[]; message?: string },
38
35
  ): CodeIntelResult {
39
36
  return {
40
37
  content,
@@ -49,6 +46,8 @@ export function contextErrorResult(
49
46
  omittedCount: 0,
50
47
  nextQueries: opts?.nextQueries ?? [],
51
48
  },
49
+ status: "invalid-input",
50
+ ...(opts?.message ? { message: opts.message } : {}),
52
51
  },
53
52
  };
54
53
  }
@@ -56,7 +55,7 @@ export function contextErrorResult(
56
55
  /** Full error result for code_inspect. */
57
56
  export function inspectErrorResult(
58
57
  content: string,
59
- opts?: { focusTarget?: string; nextQueries?: string[] },
58
+ opts?: { focusTarget?: string; nextQueries?: string[]; message?: string },
60
59
  ): CodeIntelResult {
61
60
  return {
62
61
  content,
@@ -69,6 +68,8 @@ export function inspectErrorResult(
69
68
  sections: [],
70
69
  nextQueries: opts?.nextQueries ?? [],
71
70
  },
71
+ status: "invalid-input",
72
+ ...(opts?.message ? { message: opts.message } : {}),
72
73
  },
73
74
  };
74
75
  }
@@ -100,6 +101,8 @@ export function healthErrorResult(content: string, reason?: string): CodeIntelRe
100
101
  diagnosticFileCount: 0,
101
102
  serverCount: 0,
102
103
  },
104
+ status: "invalid-input",
105
+ message: reason ?? content,
103
106
  },
104
107
  };
105
108
  }
@@ -11,13 +11,15 @@ import {
11
11
  type ResultProvenance,
12
12
  type ToolResultAssembly,
13
13
  } from "./assembly.ts";
14
- import type { SearchDetails } from "./types.ts";
14
+ import { createToolDisplaySection } from "./display.ts";
15
+ import type { SearchDetails, ToolDisplaySection } from "./types.ts";
15
16
 
16
17
  /** Presentation-neutral assembled find result. */
17
18
  export interface FindResultAssembly {
18
19
  outcome: Extract<FindWorkflowOutcome, { kind: "completed" }>;
19
20
  assembled: ToolResultAssembly<Extract<FindWorkflowOutcome, { kind: "completed" }>["data"]>;
20
21
  details: SearchDetails;
22
+ displaySections: readonly ToolDisplaySection[];
21
23
  }
22
24
 
23
25
  /** Assemble one completed code-aware search outcome before presentation. */
@@ -26,13 +28,7 @@ export function assembleFindWorkflowResult(
26
28
  ): FindResultAssembly {
27
29
  const evidence = createFindEvidence(outcome);
28
30
  const confidence: ConfidenceMode = outcome.data.kind === "semantic" ? "semantic" : "structural";
29
- const nextQueries =
30
- outcome.data.kind === "ast" && outcome.data.astKind === "call"
31
- ? [
32
- "Use code_graph references on a resolved target for symbol-identity relationships",
33
- "Use PI grep for literal or regex source matches when it is active",
34
- ]
35
- : ["Change mode only when you need a different code-aware evidence substrate"];
31
+ const nextQueries = findNextQueries(outcome);
36
32
  const provenance = findProvenance(outcome.data.kind);
37
33
  const assembled = assembleToolResult({
38
34
  data: outcome.data,
@@ -53,9 +49,22 @@ export function assembleFindWorkflowResult(
53
49
  provenance,
54
50
  });
55
51
 
52
+ const displaySections = [
53
+ createToolDisplaySection({
54
+ key: `find.${outcome.data.kind}`,
55
+ title: outcome.data.kind === "semantic" ? "Symbols" : "Matches",
56
+ items: findItems(outcome.data),
57
+ totalCount: evidence.metadata.totalCount,
58
+ omittedCount: evidence.metadata.omittedCount,
59
+ partialReason: evidence.metadata.partialReason,
60
+ format: (item) => formatFindDisplayItem(outcome.data.kind, item),
61
+ }),
62
+ ];
63
+
56
64
  return {
57
65
  outcome,
58
66
  assembled,
67
+ displaySections,
59
68
  details: {
60
69
  confidence,
61
70
  scope: outcome.scopeLabel === "." ? null : outcome.scopeLabel,
@@ -68,6 +77,22 @@ export function assembleFindWorkflowResult(
68
77
  };
69
78
  }
70
79
 
80
+ function findNextQueries(outcome: Extract<FindWorkflowOutcome, { kind: "completed" }>): string[] {
81
+ if (outcome.data.kind === "semantic" && outcome.data.symbols.length === 0) {
82
+ return [
83
+ "If you know the file, use code_resolve with a file selector to enumerate document declarations",
84
+ "Change mode only when you need a different code-aware evidence substrate",
85
+ ];
86
+ }
87
+ if (outcome.data.kind === "ast" && outcome.data.astKind === "call") {
88
+ return [
89
+ "Use code_graph references on a resolved target for symbol-identity relationships",
90
+ "Use PI grep for literal or regex source matches when it is active",
91
+ ];
92
+ }
93
+ return ["Change mode only when you need a different code-aware evidence substrate"];
94
+ }
95
+
71
96
  function createFindEvidence(outcome: Extract<FindWorkflowOutcome, { kind: "completed" }>): {
72
97
  total: number;
73
98
  metadata: EvidenceListMetadata;
@@ -106,6 +131,25 @@ function findItems(
106
131
  return data.kind === "semantic" ? data.symbols : data.result.matches;
107
132
  }
108
133
 
134
+ function formatFindDisplayItem(kind: "semantic" | "ast", item: unknown): string {
135
+ if (kind === "ast") {
136
+ const match = item as { name: string; kind: string; file: string; line: number };
137
+ return `${match.name} (${match.kind}) — ${match.file}:L${match.line}`;
138
+ }
139
+
140
+ const symbol = item as {
141
+ name: string;
142
+ kind: string;
143
+ file: string;
144
+ container?: string | null;
145
+ nameAnchor?: { line: number };
146
+ declarationAnchor: { line: number };
147
+ };
148
+ const container = symbol.container ? ` in ${symbol.container}` : "";
149
+ const anchor = symbol.nameAnchor ?? symbol.declarationAnchor;
150
+ return `${symbol.name} [${symbol.kind}]${container} — ${symbol.file}:L${anchor.line}`;
151
+ }
152
+
109
153
  function findProvenance(
110
154
  kind: Extract<FindWorkflowOutcome, { kind: "completed" }>["data"]["kind"],
111
155
  ): ResultProvenance[] {
@@ -6,6 +6,7 @@ import type {
6
6
  ImplementationEntry,
7
7
  ReferenceEntry,
8
8
  } from "../../analysis/relations/types.ts";
9
+ import { toDisplayPath } from "../../analysis/search/paths.ts";
9
10
  import type { GraphSection } from "../../session/graph-types.ts";
10
11
  import {
11
12
  assembledNextQueries,
@@ -13,7 +14,8 @@ import {
13
14
  type ResultProvenance,
14
15
  type ToolResultAssembly,
15
16
  } from "./assembly.ts";
16
- import type { SearchDetails } from "./types.ts";
17
+ import { createToolDisplaySection } from "./display.ts";
18
+ import type { SearchDetails, ToolDisplaySection } from "./types.ts";
17
19
 
18
20
  export type { GraphRelationKind, GraphSection } from "../../session/graph-types.ts";
19
21
 
@@ -39,6 +41,7 @@ export interface GraphResultAssembly {
39
41
  cwd: string;
40
42
  assembled: ToolResultAssembly<{ readonly sections: readonly AssembledGraphSection[] }>;
41
43
  details: SearchDetails;
44
+ displaySections: readonly ToolDisplaySection[];
42
45
  }
43
46
 
44
47
  /** Assemble graph evidence once before either presentation adapter consumes it. */
@@ -77,12 +80,15 @@ export function assembleGraphResult(input: {
77
80
  provenance,
78
81
  });
79
82
 
83
+ const displaySections = sections.map((section) => graphDisplaySection(section, input.cwd));
84
+
80
85
  return {
81
86
  displayName: input.displayName,
82
87
  sections,
83
88
  resolvedDisplayFile: input.resolvedDisplayFile,
84
89
  cwd: input.cwd,
85
90
  assembled,
91
+ displaySections,
86
92
  details: {
87
93
  confidence,
88
94
  scope: null,
@@ -94,6 +100,43 @@ export function assembleGraphResult(input: {
94
100
  };
95
101
  }
96
102
 
103
+ function graphDisplaySection(section: AssembledGraphSection, cwd: string): ToolDisplaySection {
104
+ if (section.kind === "unavailable") {
105
+ return createToolDisplaySection({
106
+ key: `graph.${section.rel}`,
107
+ title: section.rel,
108
+ items: [section.message],
109
+ format: (message) => `Unavailable — ${message}`,
110
+ totalCount: 1,
111
+ });
112
+ }
113
+
114
+ return createToolDisplaySection({
115
+ key: `graph.${section.rel}`,
116
+ title: section.rel,
117
+ items: section.evidence.items as readonly unknown[],
118
+ totalCount: section.evidence.metadata.totalCount,
119
+ omittedCount: section.evidence.metadata.omittedCount,
120
+ partialReason: section.evidence.metadata.partialReason,
121
+ format: (item) => formatGraphDisplayItem(section.rel, item, cwd),
122
+ });
123
+ }
124
+
125
+ function formatGraphDisplayItem(
126
+ relation: "references" | "callees" | "implements",
127
+ item: unknown,
128
+ cwd: string,
129
+ ): string {
130
+ if (relation === "callees") {
131
+ const call = item as { name: string; file: string; line: number };
132
+ return `${call.name} — ${toDisplayPath(cwd, call.file)}:L${call.line}`;
133
+ }
134
+
135
+ const location = item as { name: string | null; file: string; line: number; character: number };
136
+ const name = location.name ? `${location.name} — ` : "";
137
+ return `${name}${toDisplayPath(cwd, location.file)}:L${location.line}:${location.character}`;
138
+ }
139
+
97
140
  function assembleGraphSection(section: GraphSection, maxResults: number): AssembledGraphSection {
98
141
  if (section.kind === "unavailable") return section;
99
142
  switch (section.rel) {
@@ -6,7 +6,8 @@ import {
6
6
  type ResultSection,
7
7
  type ToolResultAssembly,
8
8
  } from "./assembly.ts";
9
- import type { HealthDetails, HealthSectionDetails } from "./types.ts";
9
+ import { createToolDisplaySection, truncateDisplayText } from "./display.ts";
10
+ import type { HealthDetails, HealthSectionDetails, ToolDisplaySection } from "./types.ts";
10
11
 
11
12
  export type {
12
13
  HealthData,
@@ -26,6 +27,7 @@ export interface HealthResultAssembly {
26
27
  data: HealthData;
27
28
  assembled: ToolResultAssembly<HealthData>;
28
29
  details: HealthDetails;
30
+ displaySections: readonly ToolDisplaySection[];
29
31
  }
30
32
 
31
33
  const SECTION_TITLES: Record<HealthSection, string> = {
@@ -53,9 +55,12 @@ export function assembleHealthResult(data: HealthData): HealthResultAssembly {
53
55
  provenance,
54
56
  });
55
57
 
58
+ const displaySections = buildHealthDisplaySections(data);
59
+
56
60
  return {
57
61
  data,
58
62
  assembled,
63
+ displaySections,
59
64
  details: {
60
65
  includedSections: [...data.includedSections],
61
66
  sections: sectionDetails,
@@ -78,6 +83,53 @@ export function assembleHealthResult(data: HealthData): HealthResultAssembly {
78
83
  };
79
84
  }
80
85
 
86
+ function buildHealthDisplaySections(data: HealthData): ToolDisplaySection[] {
87
+ const sections: ToolDisplaySection[] = [];
88
+
89
+ if (data.includedSections.includes("diagnostics") && data.diagnostics.entries.length > 0) {
90
+ sections.push(
91
+ createToolDisplaySection({
92
+ key: "health.diagnostics",
93
+ title: "Diagnostics",
94
+ items: data.diagnostics.entries,
95
+ totalCount: data.diagnostics.kind === "completed" ? data.diagnostics.entries.length : null,
96
+ omittedCount: data.diagnostics.kind === "completed" ? 0 : null,
97
+ partialReason: diagnosticPartialReason(data),
98
+ format: formatDiagnosticEntry,
99
+ }),
100
+ );
101
+ }
102
+
103
+ if (data.includedSections.includes("servers") && data.servers.length > 0) {
104
+ sections.push(
105
+ createToolDisplaySection({
106
+ key: "health.servers",
107
+ title: "Servers",
108
+ items: data.servers,
109
+ totalCount: data.servers.length,
110
+ format: (server) => `${server.name} (${server.fileTypes.join(", ")}) — ${server.status}`,
111
+ }),
112
+ );
113
+ }
114
+
115
+ return sections;
116
+ }
117
+
118
+ function diagnosticPartialReason(data: HealthData): string | null {
119
+ return data.diagnostics.kind === "partial" || data.diagnostics.kind === "unavailable"
120
+ ? data.diagnostics.reason
121
+ : null;
122
+ }
123
+
124
+ function formatDiagnosticEntry(entry: HealthData["diagnostics"]["entries"][number]): string {
125
+ const summary = `${entry.file} — ${entry.errors} error${entry.errors === 1 ? "" : "s"}, ${entry.warnings} warning${entry.warnings === 1 ? "" : "s"}`;
126
+ const messages = entry.messages?.map(
127
+ (message) =>
128
+ ` ${message.severity} L${message.line}${message.source ? ` [${message.source}]` : ""}: ${truncateDisplayText(message.message, 200)}`,
129
+ );
130
+ return messages && messages.length > 0 ? [summary, ...messages].join("\n") : summary;
131
+ }
132
+
81
133
  interface HealthSectionFacts {
82
134
  status: "complete" | "partial" | "unavailable";
83
135
  available: boolean;
@@ -17,7 +17,8 @@ import {
17
17
  type ResultSection,
18
18
  type ToolResultAssembly,
19
19
  } from "./assembly.ts";
20
- import type { InspectDetails, InspectSectionDetails } from "./types.ts";
20
+ import { createToolDisplaySection, truncateDisplayText } from "./display.ts";
21
+ import type { InspectDetails, InspectSectionDetails, ToolDisplaySection } from "./types.ts";
21
22
 
22
23
  export type { InspectResultData } from "../../session/inspect-types.ts";
23
24
 
@@ -30,6 +31,7 @@ export interface InspectResultAssembly {
30
31
  diagnosticEvidence: EvidenceList<InspectDiagnostic> | null;
31
32
  assembled: ToolResultAssembly<InspectResultData>;
32
33
  details: InspectDetails;
34
+ displaySections: readonly ToolDisplaySection[];
33
35
  }
34
36
 
35
37
  /** Assemble code_inspect evidence/details before presentation adapters render it. */
@@ -62,6 +64,14 @@ export function assembleInspectResult(
62
64
  provenance,
63
65
  });
64
66
 
67
+ const displaySections = buildInspectDisplaySections({
68
+ data,
69
+ displayedDefinitions: definitionEvidence?.items ?? [],
70
+ displayedDiagnostics: diagnosticEvidence?.items ?? [],
71
+ definitionEvidence,
72
+ diagnosticEvidence,
73
+ });
74
+
65
75
  return {
66
76
  data,
67
77
  displayedDefinitions: definitionEvidence?.items ?? [],
@@ -69,6 +79,7 @@ export function assembleInspectResult(
69
79
  definitionEvidence,
70
80
  diagnosticEvidence,
71
81
  assembled,
82
+ displaySections,
72
83
  details: {
73
84
  confidence: data.confidence,
74
85
  focusTarget: `${data.relPath}:${data.line}:${data.character}`,
@@ -80,6 +91,107 @@ export function assembleInspectResult(
80
91
  };
81
92
  }
82
93
 
94
+ function buildInspectDisplaySections(input: {
95
+ data: InspectResultData;
96
+ displayedDefinitions: readonly InspectDefinition[];
97
+ displayedDiagnostics: readonly InspectDiagnostic[];
98
+ definitionEvidence: EvidenceList<InspectDefinition> | null;
99
+ diagnosticEvidence: EvidenceList<InspectDiagnostic> | null;
100
+ }): ToolDisplaySection[] {
101
+ const sections: ToolDisplaySection[] = [];
102
+ const { data } = input;
103
+
104
+ if (data.sections.node.kind !== "unavailable" && data.sections.node.data) {
105
+ const node = data.sections.node.data;
106
+ sections.push(
107
+ createToolDisplaySection({
108
+ key: "inspect.node",
109
+ title: "Syntax node",
110
+ items: [node],
111
+ format: (item) =>
112
+ `${item.type} at ${data.relPath}:${item.startLine}:${item.startCharacter}–${item.endLine}:${item.endCharacter}${item.text ? ` — ${truncateDisplayText(item.text, 160)}` : ""}`,
113
+ partialReason: observationReason(data.sections.node),
114
+ }),
115
+ );
116
+ }
117
+
118
+ if (data.sections.enclosingSymbol.kind !== "unavailable" && data.sections.enclosingSymbol.data) {
119
+ const symbol = data.sections.enclosingSymbol.data;
120
+ sections.push(
121
+ createToolDisplaySection({
122
+ key: "inspect.enclosingSymbol",
123
+ title: "Enclosing symbol",
124
+ items: [symbol],
125
+ format: (item) =>
126
+ `${item.name} (${item.kind}) L${item.startLine}:${item.startCharacter}–L${item.endLine}:${item.endCharacter}`,
127
+ partialReason: observationReason(data.sections.enclosingSymbol),
128
+ }),
129
+ );
130
+ }
131
+
132
+ if (data.sections.hover.kind !== "unavailable" && data.sections.hover.data) {
133
+ sections.push(
134
+ createToolDisplaySection({
135
+ key: "inspect.hover",
136
+ title: "Hover",
137
+ items: [data.sections.hover.data],
138
+ format: (hover) => truncateDisplayText(hover, 240),
139
+ partialReason: observationReason(data.sections.hover),
140
+ }),
141
+ );
142
+ }
143
+
144
+ if (input.displayedDefinitions.length > 0) {
145
+ sections.push(
146
+ createToolDisplaySection({
147
+ key: "inspect.definitions",
148
+ title: "Definitions",
149
+ items: input.displayedDefinitions,
150
+ totalCount: input.definitionEvidence?.metadata.totalCount,
151
+ omittedCount: input.definitionEvidence?.metadata.omittedCount,
152
+ partialReason: input.definitionEvidence?.metadata.partialReason,
153
+ format: (definition) => `${definition.file}:${definition.line}:${definition.character}`,
154
+ }),
155
+ );
156
+ }
157
+
158
+ if (input.displayedDiagnostics.length > 0) {
159
+ sections.push(
160
+ createToolDisplaySection({
161
+ key: "inspect.diagnostics",
162
+ title: "Diagnostics",
163
+ items: input.displayedDiagnostics,
164
+ totalCount: input.diagnosticEvidence?.metadata.totalCount,
165
+ omittedCount: input.diagnosticEvidence?.metadata.omittedCount,
166
+ partialReason: input.diagnosticEvidence?.metadata.partialReason,
167
+ format: (diagnostic) =>
168
+ `L${diagnostic.line}:${diagnostic.character} ${formatDiagnosticSeverity(diagnostic.severity)}: ${truncateDisplayText(diagnostic.message, 200)}`,
169
+ }),
170
+ );
171
+ }
172
+
173
+ return sections;
174
+ }
175
+
176
+ function observationReason<T>(observation: InspectObservation<T>): string | null {
177
+ return observation.kind === "partial" ? observation.reason : null;
178
+ }
179
+
180
+ function formatDiagnosticSeverity(severity: number): string {
181
+ switch (severity) {
182
+ case 1:
183
+ return "Error";
184
+ case 2:
185
+ return "Warning";
186
+ case 3:
187
+ return "Info";
188
+ case 4:
189
+ return "Hint";
190
+ default:
191
+ return "Diagnostic";
192
+ }
193
+ }
194
+
83
195
  function listEvidence<T>(
84
196
  key: string,
85
197
  observation: InspectObservation<readonly T[]>,
@@ -3,6 +3,7 @@ import type { EvidenceListMetadata } from "../../analysis/evidence.ts";
3
3
  import type { ReadNextItem } from "../../analysis/read-next.ts";
4
4
  import type {
5
5
  OrientationCandidate,
6
+ OrientationItem,
6
7
  OrientationResultData,
7
8
  OrientationSectionData,
8
9
  } from "../../session/orientation-types.ts";
@@ -14,7 +15,8 @@ import {
14
15
  type ResultSection,
15
16
  type ToolResultAssembly,
16
17
  } from "./assembly.ts";
17
- import type { ContextDetails, OrientationSectionDetails } from "./types.ts";
18
+ import { createToolDisplaySection } from "./display.ts";
19
+ import type { ContextDetails, OrientationSectionDetails, ToolDisplaySection } from "./types.ts";
18
20
 
19
21
  export interface OrientationDetailsInput {
20
22
  readonly confidence: ConfidenceMode;
@@ -35,6 +37,25 @@ export interface OrientationDetailsInput {
35
37
  export interface OrientationResultAssembly {
36
38
  readonly assembled: ToolResultAssembly<OrientationResultData>;
37
39
  readonly details: ContextDetails;
40
+ readonly displaySections: readonly ToolDisplaySection[];
41
+ }
42
+
43
+ /** Build structured candidate rows for an unresolved Orientation target. */
44
+ export function orientationCandidateDisplaySections(
45
+ candidates: readonly OrientationCandidate[],
46
+ omittedCount = 0,
47
+ ): readonly ToolDisplaySection[] {
48
+ return [
49
+ createToolDisplaySection({
50
+ key: "orientation.candidates",
51
+ title: "Candidates",
52
+ items: candidates,
53
+ totalCount: candidates.length + omittedCount,
54
+ omittedCount,
55
+ format: (candidate) =>
56
+ `${candidate.rank}. ${candidate.name} (${candidate.kind ?? "unknown"}) — ${candidate.file}:${candidate.line}:${candidate.character} [${candidate.targetId}]`,
57
+ }),
58
+ ];
38
59
  }
39
60
 
40
61
  /** Assemble Orientation facts and shared result policy before rendering. */
@@ -50,21 +71,24 @@ export function assembleOrientationResult(data: OrientationResultData): Orientat
50
71
  confidence: data.confidence,
51
72
  provenance: uniqueProvenance(data.sections),
52
73
  });
74
+ const details = assembleOrientationDetails({
75
+ confidence: assembled.confidence,
76
+ focusTarget: assembled.data.focusTarget,
77
+ requestedSections: assembled.data.requestedSections,
78
+ renderedSections: assembled.data.renderedSections,
79
+ omittedCount: assembled.totals.omittedCount,
80
+ evidenceLists: assembled.evidenceLists,
81
+ sections: assembled.data.sections,
82
+ nextQueries: assembledNextQueries(assembled),
83
+ readNext: assembledReadNext(assembled),
84
+ target: assembled.data.target,
85
+ instructions: assembled.data.instructions,
86
+ });
87
+
53
88
  return {
54
89
  assembled,
55
- details: assembleOrientationDetails({
56
- confidence: assembled.confidence,
57
- focusTarget: assembled.data.focusTarget,
58
- requestedSections: assembled.data.requestedSections,
59
- renderedSections: assembled.data.renderedSections,
60
- omittedCount: assembled.totals.omittedCount,
61
- evidenceLists: assembled.evidenceLists,
62
- sections: assembled.data.sections,
63
- nextQueries: assembledNextQueries(assembled),
64
- readNext: assembledReadNext(assembled),
65
- target: assembled.data.target,
66
- instructions: assembled.data.instructions,
67
- }),
90
+ details,
91
+ displaySections: assembled.data.sections.map(orientationDisplaySection),
68
92
  };
69
93
  }
70
94
 
@@ -96,6 +120,34 @@ export function assembleOrientationDetails(input: OrientationDetailsInput): Cont
96
120
  };
97
121
  }
98
122
 
123
+ function orientationDisplaySection(section: OrientationSectionData): ToolDisplaySection {
124
+ const items = section.items.filter((item) => item.kind !== "blank");
125
+ return createToolDisplaySection({
126
+ key: `orientation.${section.key}`,
127
+ title: section.title,
128
+ items,
129
+ totalCount: items.length,
130
+ omittedCount: 0,
131
+ partialReason:
132
+ section.reason ??
133
+ section.evidenceLists.find((evidence) => evidence.partialReason)?.partialReason,
134
+ format: formatOrientationItem,
135
+ });
136
+ }
137
+
138
+ function formatOrientationItem(item: OrientationItem): string {
139
+ switch (item.kind) {
140
+ case "paragraph":
141
+ case "list-item":
142
+ case "subheading":
143
+ return item.text;
144
+ case "code":
145
+ return item.lines.join(" ");
146
+ case "blank":
147
+ return "";
148
+ }
149
+ }
150
+
99
151
  function toResultSection(section: OrientationSectionData): ResultSection {
100
152
  return {
101
153
  key: section.key,