@mrclrchtr/supi-code-intelligence 4.10.0 → 6.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 (269) hide show
  1. package/README.md +4 -3
  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 +2 -2
  10. package/node_modules/@mrclrchtr/supi-core/src/api.ts +1 -1
  11. package/node_modules/@mrclrchtr/supi-core/src/config/config.ts +31 -0
  12. package/node_modules/@mrclrchtr/supi-core/src/config.ts +2 -0
  13. package/node_modules/@mrclrchtr/supi-core/src/debug-registry.ts +19 -6
  14. package/node_modules/@mrclrchtr/supi-core/src/debug.ts +9 -0
  15. package/node_modules/@mrclrchtr/supi-core/src/index.ts +1 -1
  16. package/node_modules/@mrclrchtr/supi-core/src/settings/settings-registry.ts +3 -0
  17. package/node_modules/@mrclrchtr/supi-lsp/README.md +111 -5
  18. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-code-runtime/README.md +2 -0
  19. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-code-runtime/package.json +1 -1
  20. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-code-runtime/src/api.ts +9 -0
  21. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-code-runtime/src/capability/types.ts +53 -13
  22. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-code-runtime/src/request-control.ts +47 -0
  23. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-code-runtime/src/types.ts +13 -1
  24. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-core/README.md +2 -0
  25. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-core/package.json +2 -2
  26. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-core/src/api.ts +1 -1
  27. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-core/src/config/config.ts +31 -0
  28. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-core/src/config.ts +2 -0
  29. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-core/src/debug-registry.ts +19 -6
  30. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-core/src/debug.ts +9 -0
  31. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-core/src/index.ts +1 -1
  32. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-core/src/settings/settings-registry.ts +3 -0
  33. package/node_modules/@mrclrchtr/supi-lsp/package.json +7 -6
  34. package/node_modules/@mrclrchtr/supi-lsp/src/api.ts +22 -1
  35. package/node_modules/@mrclrchtr/supi-lsp/src/client/client-diagnostic-cache.ts +245 -0
  36. package/node_modules/@mrclrchtr/supi-lsp/src/client/client-diagnostic-capabilities.ts +78 -0
  37. package/node_modules/@mrclrchtr/supi-lsp/src/client/client-diagnostic-collection.ts +171 -0
  38. package/node_modules/@mrclrchtr/supi-lsp/src/client/client-diagnostic-evidence.ts +413 -0
  39. package/node_modules/@mrclrchtr/supi-lsp/src/client/client-diagnostic-host.ts +15 -0
  40. package/node_modules/@mrclrchtr/supi-lsp/src/client/client-diagnostic-publication.ts +214 -0
  41. package/node_modules/@mrclrchtr/supi-lsp/src/client/client-diagnostic-pull.ts +62 -0
  42. package/node_modules/@mrclrchtr/supi-lsp/src/client/client-diagnostic-refresh.ts +690 -0
  43. package/node_modules/@mrclrchtr/supi-lsp/src/client/client-diagnostic-request.ts +9 -0
  44. package/node_modules/@mrclrchtr/supi-lsp/src/client/client-diagnostic-timing.ts +97 -16
  45. package/node_modules/@mrclrchtr/supi-lsp/src/client/client-diagnostic-waiters.ts +206 -0
  46. package/node_modules/@mrclrchtr/supi-lsp/src/client/client-diagnostics.ts +448 -298
  47. package/node_modules/@mrclrchtr/supi-lsp/src/client/client-document-state.ts +70 -0
  48. package/node_modules/@mrclrchtr/supi-lsp/src/client/client-document-sync.ts +231 -0
  49. package/node_modules/@mrclrchtr/supi-lsp/src/client/client-file-state.ts +25 -0
  50. package/node_modules/@mrclrchtr/supi-lsp/src/client/client.ts +529 -119
  51. package/node_modules/@mrclrchtr/supi-lsp/src/client/transport.ts +161 -33
  52. package/node_modules/@mrclrchtr/supi-lsp/src/config/capabilities.ts +12 -3
  53. package/node_modules/@mrclrchtr/supi-lsp/src/config/config.ts +5 -5
  54. package/node_modules/@mrclrchtr/supi-lsp/src/config/defaults.json +1 -1
  55. package/node_modules/@mrclrchtr/supi-lsp/src/config/server-config.ts +3 -0
  56. package/node_modules/@mrclrchtr/supi-lsp/src/config/tsconfig-extends.ts +68 -0
  57. package/node_modules/@mrclrchtr/supi-lsp/src/config/tsconfig-path.ts +8 -0
  58. package/node_modules/@mrclrchtr/supi-lsp/src/config/tsconfig-scope.ts +176 -24
  59. package/node_modules/@mrclrchtr/supi-lsp/src/debug-telemetry.ts +45 -0
  60. package/node_modules/@mrclrchtr/supi-lsp/src/diagnostics/evidence.ts +42 -0
  61. package/node_modules/@mrclrchtr/supi-lsp/src/diagnostics/workspace-sentinels.ts +46 -10
  62. package/node_modules/@mrclrchtr/supi-lsp/src/manager/manager-client-state.ts +79 -9
  63. package/node_modules/@mrclrchtr/supi-lsp/src/manager/manager-diagnostics.ts +17 -7
  64. package/node_modules/@mrclrchtr/supi-lsp/src/manager/manager-workspace-recovery.ts +350 -26
  65. package/node_modules/@mrclrchtr/supi-lsp/src/manager/manager-workspace-symbol.ts +5 -2
  66. package/node_modules/@mrclrchtr/supi-lsp/src/manager/manager.ts +586 -96
  67. package/node_modules/@mrclrchtr/supi-lsp/src/provider/lsp-refactor-provider.ts +130 -0
  68. package/node_modules/@mrclrchtr/supi-lsp/src/provider/lsp-semantic-provider.ts +45 -329
  69. package/node_modules/@mrclrchtr/supi-lsp/src/provider/refactor-planning.ts +57 -120
  70. package/node_modules/@mrclrchtr/supi-lsp/src/provider/semantic-edit-normalizer.ts +320 -0
  71. package/node_modules/@mrclrchtr/supi-lsp/src/provider/semantic-symbol-mapper.ts +207 -0
  72. package/node_modules/@mrclrchtr/supi-lsp/src/session/readiness.ts +72 -2
  73. package/node_modules/@mrclrchtr/supi-lsp/src/session/runtime-controller.ts +151 -26
  74. package/node_modules/@mrclrchtr/supi-lsp/src/session/runtime-diagnostic-surface.ts +42 -0
  75. package/node_modules/@mrclrchtr/supi-lsp/src/session/runtime-diagnostics.ts +92 -0
  76. package/node_modules/@mrclrchtr/supi-lsp/src/session/runtime-registry.ts +165 -118
  77. package/node_modules/@mrclrchtr/supi-lsp/src/session/runtime-transition-debug.ts +49 -0
  78. package/node_modules/@mrclrchtr/supi-lsp/src/session/workspace-lsp-runtime.ts +102 -0
  79. package/node_modules/@mrclrchtr/supi-tree-sitter/README.md +17 -7
  80. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/README.md +2 -0
  81. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/package.json +1 -1
  82. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/src/api.ts +9 -0
  83. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/src/capability/types.ts +53 -13
  84. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/src/request-control.ts +47 -0
  85. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/src/types.ts +13 -1
  86. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/README.md +2 -0
  87. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/package.json +2 -2
  88. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/src/api.ts +1 -1
  89. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/src/config/config.ts +31 -0
  90. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/src/config.ts +2 -0
  91. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/src/debug-registry.ts +19 -6
  92. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/src/debug.ts +9 -0
  93. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/src/index.ts +1 -1
  94. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/src/settings/settings-registry.ts +3 -0
  95. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/jiti/LICENSE +21 -0
  96. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/jiti/README.md +258 -0
  97. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/jiti/dist/babel.cjs +257 -0
  98. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/jiti/dist/jiti.cjs +1 -0
  99. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/jiti/lib/jiti-cli.mjs +34 -0
  100. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/jiti/lib/jiti-hooks.mjs +124 -0
  101. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/jiti/lib/jiti-native.mjs +121 -0
  102. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/jiti/lib/jiti-register.d.mts +1 -0
  103. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/jiti/lib/jiti-register.mjs +4 -0
  104. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/jiti/lib/jiti-static.mjs +23 -0
  105. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/jiti/lib/jiti.cjs +30 -0
  106. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/jiti/lib/jiti.d.cts +8 -0
  107. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/jiti/lib/jiti.d.mts +8 -0
  108. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/jiti/lib/jiti.mjs +29 -0
  109. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/jiti/lib/types.d.ts +420 -0
  110. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/jiti/package.json +146 -0
  111. package/node_modules/@mrclrchtr/supi-tree-sitter/package.json +6 -3
  112. package/node_modules/@mrclrchtr/supi-tree-sitter/src/api.ts +0 -9
  113. package/node_modules/@mrclrchtr/supi-tree-sitter/src/index.ts +0 -8
  114. package/node_modules/@mrclrchtr/supi-tree-sitter/src/provider/tree-sitter-provider.ts +16 -12
  115. package/node_modules/@mrclrchtr/supi-tree-sitter/src/session/runtime-controller.ts +65 -87
  116. package/node_modules/@mrclrchtr/supi-tree-sitter/src/session/session.ts +47 -95
  117. package/node_modules/@mrclrchtr/supi-tree-sitter/src/session/structural-timing.ts +147 -0
  118. package/node_modules/@mrclrchtr/supi-tree-sitter/src/session/structural-worker-client-lifecycle.ts +39 -0
  119. package/node_modules/@mrclrchtr/supi-tree-sitter/src/session/structural-worker-client.ts +561 -0
  120. package/node_modules/@mrclrchtr/supi-tree-sitter/src/session/structural-worker-message-size.ts +24 -0
  121. package/node_modules/@mrclrchtr/supi-tree-sitter/src/session/structural-worker-protocol.ts +452 -0
  122. package/node_modules/@mrclrchtr/supi-tree-sitter/src/tool/call-sites.ts +4 -2
  123. package/node_modules/@mrclrchtr/supi-tree-sitter/src/tool/callees.ts +12 -4
  124. package/node_modules/@mrclrchtr/supi-tree-sitter/src/tool/exports.ts +4 -2
  125. package/node_modules/@mrclrchtr/supi-tree-sitter/src/tool/imports.ts +4 -2
  126. package/node_modules/@mrclrchtr/supi-tree-sitter/src/tool/node-at.ts +5 -3
  127. package/node_modules/@mrclrchtr/supi-tree-sitter/src/types.ts +33 -12
  128. package/node_modules/@mrclrchtr/supi-tree-sitter/src/worker/blocking-test-bootstrap.mjs +34 -0
  129. package/node_modules/@mrclrchtr/supi-tree-sitter/src/worker/bootstrap.mjs +8 -0
  130. package/node_modules/@mrclrchtr/supi-tree-sitter/src/worker/parsed-file-store-helpers.ts +23 -0
  131. package/node_modules/@mrclrchtr/supi-tree-sitter/src/worker/parsed-file-store.ts +400 -0
  132. package/node_modules/@mrclrchtr/supi-tree-sitter/src/worker/request-control.ts +48 -0
  133. package/node_modules/@mrclrchtr/supi-tree-sitter/src/worker/runtime-parser-helpers.ts +24 -0
  134. package/node_modules/@mrclrchtr/supi-tree-sitter/src/worker/runtime-query-helpers.ts +43 -0
  135. package/node_modules/@mrclrchtr/supi-tree-sitter/src/worker/runtime.ts +421 -0
  136. package/node_modules/@mrclrchtr/supi-tree-sitter/src/worker/service.ts +116 -0
  137. package/node_modules/@mrclrchtr/supi-tree-sitter/src/worker/worker-main.ts +201 -0
  138. package/package.json +5 -5
  139. package/src/analysis/health/diagnostics.ts +221 -77
  140. package/src/analysis/health/file-scope.ts +184 -0
  141. package/src/analysis/health/recovery.ts +14 -3
  142. package/src/analysis/provider.ts +58 -0
  143. package/src/analysis/readiness.ts +34 -9
  144. package/src/analysis/refactor/apply.ts +45 -1
  145. package/src/analysis/refactor/mutation-authority.ts +143 -0
  146. package/src/analysis/relations/callees.ts +9 -1
  147. package/src/analysis/relations/types.ts +5 -2
  148. package/src/analysis/search/ast-scan-timing.ts +9 -2
  149. package/src/analysis/search/ast-scan.ts +5 -2
  150. package/src/analysis/search/deadline.ts +2 -2
  151. package/src/analysis/search/pattern-analysis.ts +54 -33
  152. package/src/analysis/search/pattern.ts +18 -3
  153. package/src/analysis/target/anchored.ts +20 -11
  154. package/src/analysis/target/file.ts +18 -11
  155. package/src/analysis/target/identity.ts +19 -3
  156. package/src/analysis/target/symbol.ts +36 -15
  157. package/src/api.ts +4 -0
  158. package/src/config.ts +35 -1
  159. package/src/diagnostics/evidence.ts +51 -0
  160. package/src/extension.ts +57 -14
  161. package/src/overview/overview-data.ts +9 -2
  162. package/src/overview/overview.ts +49 -30
  163. package/src/overview/types.ts +2 -0
  164. package/src/session/capability-adapter.ts +12 -3
  165. package/src/session/find-types.ts +2 -2
  166. package/src/session/find-workflow.ts +20 -9
  167. package/src/session/graph/collect.ts +18 -2
  168. package/src/session/graph-workflow.ts +19 -12
  169. package/src/session/health-refresh.ts +175 -0
  170. package/src/session/health-types.ts +43 -15
  171. package/src/session/health-workflow.ts +69 -54
  172. package/src/session/input/workflows.ts +2 -2
  173. package/src/session/inspect/collect.ts +20 -3
  174. package/src/session/inspect-workflow.ts +12 -6
  175. package/src/session/orientation/collect.ts +12 -3
  176. package/src/session/orientation/context-facts.ts +3 -1
  177. package/src/session/orientation/context-sections.ts +20 -7
  178. package/src/session/orientation/gather.ts +17 -11
  179. package/src/session/orientation-types.ts +4 -1
  180. package/src/session/orientation-workflow.ts +23 -10
  181. package/src/session/refactor-plans.ts +2 -0
  182. package/src/session/refactor-workflow.ts +61 -15
  183. package/src/session/session.ts +29 -2
  184. package/src/session/target-workflow.ts +54 -23
  185. package/src/session/workflow-control.ts +7 -3
  186. package/src/substrate/lsp/lifecycle.ts +26 -46
  187. package/src/substrate/lsp/maintenance.ts +284 -28
  188. package/src/substrate/lsp/recovery.ts +11 -5
  189. package/src/substrate/lsp/state.ts +2 -2
  190. package/src/substrate/workspace-provider-host.ts +25 -3
  191. package/src/tool/{find → code_find}/execute.ts +2 -16
  192. package/src/tool/code_find/guidance.ts +8 -0
  193. package/src/tool/{find → code_find}/render.ts +21 -4
  194. package/src/tool/{result/find.ts → code_find/result.ts} +78 -9
  195. package/src/tool/code_find/spec.ts +37 -0
  196. package/src/tool/code_find/tui.ts +41 -0
  197. package/src/tool/code_graph/execute.ts +24 -0
  198. package/src/tool/code_graph/guidance.ts +6 -0
  199. package/src/tool/{graph → code_graph}/markdown.ts +1 -1
  200. package/src/tool/{result/graph.ts → code_graph/result.ts} +111 -3
  201. package/src/tool/code_graph/spec.ts +39 -0
  202. package/src/tool/code_graph/tui.ts +117 -0
  203. package/src/tool/{health → code_health}/execute.ts +2 -13
  204. package/src/tool/code_health/guidance.ts +8 -0
  205. package/src/tool/{health → code_health}/markdown.ts +119 -27
  206. package/src/tool/code_health/refresh-status.ts +105 -0
  207. package/src/tool/{result/health.ts → code_health/result.ts} +80 -3
  208. package/src/tool/code_health/spec.ts +41 -0
  209. package/src/tool/{health → code_health}/tui.ts +95 -98
  210. package/src/tool/{inspect → code_inspect}/execute.ts +2 -16
  211. package/src/tool/code_inspect/guidance.ts +6 -0
  212. package/src/tool/{inspect → code_inspect}/markdown.ts +1 -1
  213. package/src/tool/{result/inspect.ts → code_inspect/result.ts} +143 -2
  214. package/src/tool/code_inspect/spec.ts +25 -0
  215. package/src/tool/code_inspect/tui.ts +44 -0
  216. package/src/tool/code_orientation/execute.ts +25 -0
  217. package/src/tool/code_orientation/guidance.ts +9 -0
  218. package/src/tool/{orientation → code_orientation}/markdown.ts +1 -1
  219. package/src/tool/code_orientation/result.ts +248 -0
  220. package/src/tool/code_orientation/spec.ts +25 -0
  221. package/src/tool/{orientation → code_orientation}/tui.ts +51 -35
  222. package/src/tool/code_refactor_apply/execute.ts +17 -0
  223. package/src/tool/code_refactor_apply/guidance.ts +5 -0
  224. package/src/tool/{refactor-apply/execute.ts → code_refactor_apply/result.ts} +8 -11
  225. package/src/tool/code_refactor_apply/spec.ts +26 -0
  226. package/src/tool/code_refactor_apply/tui.ts +73 -0
  227. package/src/tool/code_refactor_plan/execute.ts +27 -0
  228. package/src/tool/code_refactor_plan/guidance.ts +8 -0
  229. package/src/tool/{refactor-plan/execute.ts → code_refactor_plan/result.ts} +13 -22
  230. package/src/tool/code_refactor_plan/spec.ts +25 -0
  231. package/src/tool/code_refactor_plan/tui.ts +54 -0
  232. package/src/tool/code_resolve/execute.ts +19 -0
  233. package/src/tool/code_resolve/guidance.ts +8 -0
  234. package/src/tool/{resolve → code_resolve}/markdown.ts +1 -1
  235. package/src/tool/{result/resolve.ts → code_resolve/result.ts} +79 -29
  236. package/src/tool/code_resolve/spec.ts +25 -0
  237. package/src/tool/code_resolve/tui.ts +60 -0
  238. package/src/tool/guidance.ts +71 -52
  239. package/src/tool/infra/truncate.ts +40 -0
  240. package/src/tool/infra/workflow-control.ts +8 -0
  241. package/src/tool/{refactor-plan/markdown.ts → refactor-markdown.ts} +4 -7
  242. package/src/tool/register.ts +105 -88
  243. package/src/tool/result/display.ts +107 -0
  244. package/src/tool/result/errors.ts +20 -17
  245. package/src/tool/result/refactor.ts +37 -8
  246. package/src/tool/result/types.ts +20 -0
  247. package/src/tool/schemas.ts +26 -157
  248. package/src/tool/specs.ts +40 -126
  249. package/src/types/execution.ts +18 -5
  250. package/src/types/index.ts +8 -1
  251. package/src/ui/status-command.ts +5 -3
  252. package/src/ui/status-overlay.ts +4 -0
  253. package/src/ui/tui/common.ts +108 -10
  254. package/src/ui/tui/display.ts +48 -0
  255. package/node_modules/@mrclrchtr/supi-tree-sitter/src/session/runtime.ts +0 -351
  256. package/src/tool/find/tui.ts +0 -39
  257. package/src/tool/graph/execute.ts +0 -62
  258. package/src/tool/graph/tui.ts +0 -104
  259. package/src/tool/inspect/tui.ts +0 -36
  260. package/src/tool/orientation/execute.ts +0 -62
  261. package/src/tool/refactor-apply/tui.ts +0 -55
  262. package/src/tool/refactor-plan/tui.ts +0 -41
  263. package/src/tool/resolve/execute.ts +0 -36
  264. package/src/tool/resolve/tui.ts +0 -42
  265. package/src/tool/result/orientation.ts +0 -132
  266. /package/src/tool/{find → code_find}/ast-kinds.ts +0 -0
  267. /package/src/tool/{find → code_find}/markdown.ts +0 -0
  268. /package/src/tool/{find → code_find}/modes.ts +0 -0
  269. /package/src/tool/{health → code_health}/semantic-state.ts +0 -0
@@ -1,25 +1,75 @@
1
+ import * as path from "node:path";
2
+ import {
3
+ type CodeRequestControl,
4
+ isCodeRequestInterruption,
5
+ throwIfCodeRequestInterrupted,
6
+ } from "@mrclrchtr/supi-code-runtime/api";
7
+ import type { RecoveryRestartReason } from "../client/client.ts";
8
+ import { getDiagnosticFileState } from "../client/client-file-state.ts";
1
9
  import type { Diagnostic, FileEvent } from "../config/types.ts";
10
+ import {
11
+ type DiagnosticEvidenceDocument,
12
+ type DiagnosticEvidenceSummary,
13
+ summarizeDiagnosticEvidence,
14
+ } from "../diagnostics/evidence.ts";
2
15
  import {
3
16
  assessStaleDiagnostics,
4
17
  type StaleDiagnosticAssessment,
5
18
  } from "../diagnostics/stale-diagnostics.ts";
19
+ import type { WorkspaceDiagnosticReport } from "../session/runtime-diagnostics.ts";
6
20
 
7
21
  export interface WorkspaceRecoveryResult {
8
22
  /** Active clients targeted by the best-effort refresh, not confirmed successful refreshes. */
9
23
  attemptedClients: number;
10
24
  restartedClients: number;
25
+ /** Server names of the active clients targeted by this pass, for telemetry identity. */
26
+ attemptedServers: string[];
27
+ /** Server names of the clients restarted during this pass, for telemetry identity. */
28
+ restartedServers: string[];
29
+ /** Stall signal of the first restarted route, when this pass restarted a client. */
30
+ restartReason?: RecoveryRestartReason;
31
+ /** Final document-level evidence from this pass, starting from the caller's initial evidence when one was supplied. */
32
+ diagnosticEvidence: DiagnosticEvidenceSummary;
33
+ /** Final diagnostic report captured after all refresh and recovery work. */
34
+ diagnosticReport: WorkspaceDiagnosticReport;
35
+ /** Failure from the first refresh, when no later pass replaced it. */
36
+ refreshFailureReason?: string;
37
+ /** Wall-clock duration of the whole recovery pass, for telemetry. */
38
+ elapsedMs: number;
11
39
  staleAssessment: StaleDiagnosticAssessment;
12
40
  }
13
41
 
42
+ /** One client route's diagnostic evidence capability for recovery targeting. */
43
+ export interface WorkspaceDiagnosticRoute {
44
+ key: string;
45
+ /** False for push-only clients, which cannot confirm freshness by pull. */
46
+ supportsPull: boolean;
47
+ /** Files tracked by the route whose evidence is unconfirmed. */
48
+ unconfirmedFiles: string[];
49
+ /** Protocol-stall signal observed on the route, or null when healthy. */
50
+ stallSignal: RecoveryRestartReason | null;
51
+ }
52
+
14
53
  export interface WorkspaceRecoveryHost {
15
54
  clearAllPullResultIds(): void;
16
55
  notifyWorkspaceFileChanges(changes: FileEvent[]): void;
17
- refreshOpenDiagnostics(options?: { maxWaitMs?: number; quietMs?: number }): Promise<void>;
56
+ refreshOpenDiagnostics(
57
+ options?: { maxWaitMs?: number; quietMs?: number } & CodeRequestControl,
58
+ ): Promise<DiagnosticEvidenceSummary>;
18
59
  getOutstandingDiagnostics(
19
60
  maxSeverity?: number,
20
61
  ): Array<{ file: string; diagnostics: Diagnostic[] }>;
21
- getStatus(): { servers: Array<{ status: "running" | "error" | "unavailable" }> };
22
- restartClientsForFiles(filePaths: string[]): Promise<string[]>;
62
+ getRunningClientCount(): number;
63
+ getRunningClientNames(): string[];
64
+ isDiagnosticFile(filePath: string): boolean;
65
+ getClientDiagnosticRoutes(): WorkspaceDiagnosticRoute[];
66
+ getDiagnosticEvidence(): DiagnosticEvidenceSummary;
67
+ getWorkspaceDiagnosticReport(maxSeverity?: number): WorkspaceDiagnosticReport;
68
+ getCwd(): string;
69
+ restartClientsForFiles(
70
+ filePaths: string[],
71
+ options?: { pushOnly?: boolean; control?: CodeRequestControl },
72
+ ): Promise<Array<{ key: string; serverName: string; files: string[]; restarted: boolean }>>;
23
73
  }
24
74
 
25
75
  /** Clear cached pull IDs and forward watched-file changes to active clients. */
@@ -29,10 +79,23 @@ export function softRecoverWorkspaceDiagnostics(
29
79
  ): number {
30
80
  host.clearAllPullResultIds();
31
81
  if (changes.length > 0) host.notifyWorkspaceFileChanges(changes);
32
- return countRunningClients(host);
82
+ return host.getRunningClientCount();
33
83
  }
34
84
 
35
- /** Run a recovery pass, refreshing diagnostics and escalating if stale state remains. */
85
+ /**
86
+ * Run a recovery pass, refreshing diagnostics and escalating if stale state remains.
87
+ *
88
+ * When the caller already ran a refresh this pass, it can hand its evidence in
89
+ * `initialEvidence`; the recovery pass then skips its own initial refresh and
90
+ * still runs stale assessment and restart escalation on the current state.
91
+ * Caller evidence is only reused when the pass applies no watched-file changes:
92
+ * evidence captured before a change would otherwise be reported as current
93
+ * after it.
94
+ *
95
+ * The pass observes request cancellation between its phases and propagates
96
+ * the interruption as a rejection instead of swallowing it. A pass that
97
+ * starts already cancelled rejects before any client or evidence work.
98
+ */
36
99
  export async function recoverWorkspaceDiagnostics(
37
100
  host: WorkspaceRecoveryHost,
38
101
  options: {
@@ -40,45 +103,306 @@ export async function recoverWorkspaceDiagnostics(
40
103
  restartIfStillStale?: boolean;
41
104
  maxWaitMs?: number;
42
105
  quietMs?: number;
106
+ /** Evidence from a refresh the caller already completed; skips this pass's own refresh when no watched-file changes apply. */
107
+ initialEvidence?: DiagnosticEvidenceSummary;
108
+ control?: CodeRequestControl;
43
109
  } = {},
44
110
  ): Promise<WorkspaceRecoveryResult> {
45
- const attemptedClients = softRecoverWorkspaceDiagnostics(host, options.changes ?? []);
111
+ // Reject immediately when the request was already cancelled: no client or
112
+ // evidence work may start for a pass the caller no longer awaits.
113
+ throwIfCodeRequestInterrupted(options.control);
114
+ const recoveryStartedAt = Date.now();
115
+ const initial = await collectInitialEvidence(host, options);
116
+ const attemptedClients = initial.attemptedClients;
117
+ const attemptedServers = host.getRunningClientNames();
118
+ let diagnosticEvidence = initial.diagnosticEvidence;
119
+ let refreshFailureReason = initial.refreshFailureReason;
120
+
121
+ let staleAssessment = assessStaleDiagnostics(host.getOutstandingDiagnostics(1));
122
+ let restartedClients = 0;
123
+ let restartServerNames: string[] = [];
124
+ let restartReason: RecoveryRestartReason | undefined;
125
+
126
+ if (options.restartIfStillStale) {
127
+ // Observe cancellation between pass phases: an abort that arrived during
128
+ // the first refresh stops the pass before any client restart.
129
+ throwIfCodeRequestInterrupted(options.control);
130
+ const restartTargets = collectRecoveryRestartTargets(host);
131
+ const restartFiles = restartTargets.flatMap((target) => target.files);
132
+ if (restartFiles.length > 0) {
133
+ const escalation = await runRestartEscalation(host, {
134
+ restartFiles,
135
+ restartTargets,
136
+ evidence: diagnosticEvidence,
137
+ ...options,
138
+ });
139
+ restartedClients = escalation.restartedClients;
140
+ restartServerNames = escalation.restartedServerNames;
141
+ restartReason = escalation.restartReason;
142
+ diagnosticEvidence = escalation.diagnosticEvidence;
143
+ if (escalation.refreshedAfterRestart) refreshFailureReason = undefined;
144
+ staleAssessment = assessStaleDiagnostics(host.getOutstandingDiagnostics(1));
145
+ }
146
+ }
147
+
148
+ // Observe cancellation before returning regardless of escalation: a
149
+ // refresh-only pass must not report a clean result after the caller
150
+ // cancelled the request.
151
+ throwIfCodeRequestInterrupted(options.control);
152
+ const diagnosticReport = host.getWorkspaceDiagnosticReport(2);
153
+
154
+ return recoveryResult();
46
155
 
156
+ function recoveryResult(): WorkspaceRecoveryResult {
157
+ return {
158
+ attemptedClients,
159
+ restartedClients,
160
+ attemptedServers,
161
+ restartedServers: restartServerNames,
162
+ ...(restartReason ? { restartReason } : {}),
163
+ diagnosticEvidence,
164
+ diagnosticReport,
165
+ ...(refreshFailureReason ? { refreshFailureReason } : {}),
166
+ elapsedMs: Date.now() - recoveryStartedAt,
167
+ staleAssessment,
168
+ };
169
+ }
170
+ }
171
+
172
+ /** One push-only route that a recovery pass may restart. */
173
+ interface RecoveryRestartTarget {
174
+ key: string;
175
+ reason: RecoveryRestartReason;
176
+ files: string[];
177
+ }
178
+
179
+ /** Establish the pass's starting evidence: caller-supplied reuse or a fresh refresh. */
180
+ async function collectInitialEvidence(
181
+ host: WorkspaceRecoveryHost,
182
+ options: {
183
+ changes?: FileEvent[];
184
+ initialEvidence?: DiagnosticEvidenceSummary;
185
+ maxWaitMs?: number;
186
+ quietMs?: number;
187
+ control?: CodeRequestControl;
188
+ },
189
+ ): Promise<{
190
+ attemptedClients: number;
191
+ diagnosticEvidence: DiagnosticEvidenceSummary;
192
+ refreshFailureReason?: string;
193
+ }> {
194
+ const changes = options.changes ?? [];
195
+ if (options.initialEvidence !== undefined && changes.length === 0) {
196
+ // Reuse skips the soft invalidation: the caller already refreshed this
197
+ // pass, and clearing cached pull result IDs without a refresh only forces
198
+ // a full pull on a later pass.
199
+ return {
200
+ attemptedClients: host.getRunningClientCount(),
201
+ diagnosticEvidence: options.initialEvidence,
202
+ };
203
+ }
204
+ const attemptedClients = softRecoverWorkspaceDiagnostics(host, changes);
47
205
  try {
48
- await host.refreshOpenDiagnostics({ maxWaitMs: options.maxWaitMs, quietMs: options.quietMs });
49
- } catch {
50
- // Recovery should be best-effort.
206
+ return {
207
+ attemptedClients,
208
+ diagnosticEvidence: await host.refreshOpenDiagnostics({
209
+ maxWaitMs: options.maxWaitMs,
210
+ quietMs: options.quietMs,
211
+ ...options.control,
212
+ }),
213
+ };
214
+ } catch (error) {
215
+ if (isCodeRequestInterruption(error, options.control)) throw error;
216
+ return {
217
+ attemptedClients,
218
+ diagnosticEvidence: host.getDiagnosticEvidence(),
219
+ refreshFailureReason: errorMessage(error),
220
+ };
51
221
  }
222
+ }
52
223
 
53
- let staleAssessment = assessStaleDiagnostics(host.getOutstandingDiagnostics(1));
224
+ /**
225
+ * Collect restart targets: push-only routes with a protocol-stall signal.
226
+ *
227
+ * Unconfirmed evidence alone never restarts a client: the reopen-resync
228
+ * fallback handles unconfirmed push-only documents without discarding
229
+ * server state (ADR 0020). Restarts require a readiness stall or repeated
230
+ * protocol failures, and stay limited to push-only routes.
231
+ */
232
+ function collectRecoveryRestartTargets(host: WorkspaceRecoveryHost): RecoveryRestartTarget[] {
233
+ const targets: RecoveryRestartTarget[] = [];
234
+ for (const route of host.getClientDiagnosticRoutes()) {
235
+ if (route.supportsPull) continue;
236
+ if (!route.stallSignal) continue;
237
+ if (route.unconfirmedFiles.length === 0) continue;
238
+ targets.push({
239
+ key: route.key,
240
+ reason: route.stallSignal,
241
+ files: route.unconfirmedFiles,
242
+ });
243
+ }
244
+ return targets;
245
+ }
246
+
247
+ /**
248
+ * Restart affected push-only clients and merge the replacement refresh evidence.
249
+ *
250
+ * Cancellation observed during the escalation is propagated as a rejection;
251
+ * only non-interruption failures degrade to unconfirmed evidence.
252
+ */
253
+ async function runRestartEscalation(
254
+ host: WorkspaceRecoveryHost,
255
+ options: {
256
+ restartFiles: readonly string[];
257
+ restartTargets: readonly RecoveryRestartTarget[];
258
+ evidence: DiagnosticEvidenceSummary;
259
+ maxWaitMs?: number;
260
+ quietMs?: number;
261
+ control?: CodeRequestControl;
262
+ },
263
+ ): Promise<{
264
+ restartedClients: number;
265
+ restartedServerNames: string[];
266
+ restartReason?: RecoveryRestartReason;
267
+ diagnosticEvidence: DiagnosticEvidenceSummary;
268
+ refreshedAfterRestart: boolean;
269
+ }> {
270
+ const { restartFiles, restartTargets, evidence } = options;
271
+ const reasonByKey = new Map(restartTargets.map((target) => [target.key, target.reason]));
272
+ let diagnosticEvidence = evidence;
54
273
  let restartedClients = 0;
274
+ let restartedServerNames: string[] = [];
275
+ let restartReason: RecoveryRestartReason | undefined;
276
+ let refreshedAfterRestart = false;
55
277
 
56
- if (options.restartIfStillStale && staleAssessment.suspected) {
57
- const restarted = await host.restartClientsForFiles(
58
- staleAssessment.matchedFiles.map((entry) => entry.file),
59
- );
278
+ try {
279
+ const restartResults = await host.restartClientsForFiles([...restartFiles], {
280
+ pushOnly: true,
281
+ control: options.control,
282
+ });
283
+ // Observe cancellation once the restart loop settles: a cancelled pass
284
+ // must not invalidate or refresh evidence for replacement processes.
285
+ throwIfCodeRequestInterrupted(options.control);
286
+ const restarted = restartResults.filter((result) => result.restarted);
60
287
  restartedClients = restarted.length;
288
+ restartedServerNames = restarted.map((result) => result.serverName);
289
+ restartReason = firstRestartReason(restarted, reasonByKey);
290
+ // Every attempted route had its client replaced or shut down; its owned
291
+ // files need fresh evidence. Routes the manager skipped (pull-capable or
292
+ // guard-blocked) produce no result and keep their refreshed evidence.
293
+ const attemptedFiles = restartResults
294
+ .flatMap((result) => result.files)
295
+ .filter((file) => host.isDiagnosticFile(file));
296
+ diagnosticEvidence = invalidateDiagnosticEvidence(evidence, attemptedFiles, host.getCwd());
61
297
 
62
- if (restartedClients > 0) {
298
+ if (restarted.length > 0) {
63
299
  try {
64
- await host.refreshOpenDiagnostics({
65
- maxWaitMs: options.maxWaitMs,
66
- quietMs: options.quietMs,
67
- });
68
- } catch {
69
- // Keep the previous assessment if the follow-up refresh fails.
300
+ diagnosticEvidence = mergeDiagnosticEvidence(
301
+ diagnosticEvidence,
302
+ await host.refreshOpenDiagnostics({
303
+ maxWaitMs: options.maxWaitMs,
304
+ quietMs: options.quietMs,
305
+ ...options.control,
306
+ }),
307
+ host.getCwd(),
308
+ );
309
+ // Observe cancellation after the replacement refresh: a cancelled
310
+ // pass discards the fresh result instead of reporting it as current.
311
+ throwIfCodeRequestInterrupted(options.control);
312
+ refreshedAfterRestart = true;
313
+ } catch (error) {
314
+ if (isCodeRequestInterruption(error, options.control)) throw error;
315
+ // Keep affected evidence unconfirmed when replacement refresh fails.
70
316
  }
71
- staleAssessment = assessStaleDiagnostics(host.getOutstandingDiagnostics(1));
72
317
  }
318
+ } catch (error) {
319
+ if (isCodeRequestInterruption(error, options.control)) throw error;
320
+ // Keep affected evidence unconfirmed when replacement fails.
73
321
  }
74
322
 
75
323
  return {
76
- attemptedClients,
77
324
  restartedClients,
78
- staleAssessment,
325
+ restartedServerNames,
326
+ ...(restartReason ? { restartReason } : {}),
327
+ diagnosticEvidence,
328
+ refreshedAfterRestart,
79
329
  };
80
330
  }
81
331
 
82
- function countRunningClients(host: WorkspaceRecoveryHost): number {
83
- return host.getStatus().servers.filter((server) => server.status === "running").length;
332
+ /** Return the stall signal of the first route that actually restarted. */
333
+ function firstRestartReason(
334
+ restarted: Array<{ key: string }>,
335
+ reasonByKey: ReadonlyMap<string, RecoveryRestartReason>,
336
+ ): RecoveryRestartReason | undefined {
337
+ for (const result of restarted) {
338
+ const reason = reasonByKey.get(result.key);
339
+ if (reason !== undefined) return reason;
340
+ }
341
+ return undefined;
342
+ }
343
+
344
+ function invalidateDiagnosticEvidence(
345
+ evidence: DiagnosticEvidenceSummary,
346
+ files: readonly string[],
347
+ cwd: string,
348
+ ): DiagnosticEvidenceSummary {
349
+ const affected = new Set(files.map((file) => path.resolve(cwd, file)));
350
+ const documents = evidence.documents.map((document) =>
351
+ affected.has(path.resolve(cwd, document.file))
352
+ ? {
353
+ ...document,
354
+ status: invalidatedFileStatus(path.resolve(cwd, document.file)),
355
+ }
356
+ : document,
357
+ );
358
+ const known = new Set(documents.map((document) => path.resolve(cwd, document.file)));
359
+ for (const file of files) {
360
+ const resolved = path.resolve(cwd, file);
361
+ if (!known.has(resolved)) {
362
+ documents.push({
363
+ file: path.relative(cwd, resolved),
364
+ status: invalidatedFileStatus(resolved),
365
+ });
366
+ known.add(resolved);
367
+ }
368
+ }
369
+ return summarizeDiagnosticEvidence(documents as DiagnosticEvidenceDocument[]);
370
+ }
371
+
372
+ function invalidatedFileStatus(filePath: string): "unconfirmed" | "failed" | "removed" {
373
+ switch (getDiagnosticFileState(filePath)) {
374
+ case "removed":
375
+ return "removed";
376
+ case "unreadable":
377
+ return "failed";
378
+ default:
379
+ return "unconfirmed";
380
+ }
381
+ }
382
+
383
+ function errorMessage(error: unknown): string {
384
+ return error instanceof Error && error.message ? error.message : "Diagnostic refresh failed.";
385
+ }
386
+
387
+ function mergeDiagnosticEvidence(
388
+ invalidated: DiagnosticEvidenceSummary,
389
+ refreshed: DiagnosticEvidenceSummary,
390
+ cwd: string,
391
+ ): DiagnosticEvidenceSummary {
392
+ const documents = new Map<string, DiagnosticEvidenceDocument>();
393
+ for (const document of invalidated.documents) {
394
+ const resolved = path.resolve(cwd, document.file);
395
+ documents.set(resolved, {
396
+ file: path.relative(cwd, resolved),
397
+ status: document.status,
398
+ });
399
+ }
400
+ for (const document of refreshed.documents) {
401
+ const resolved = path.resolve(cwd, document.file);
402
+ documents.set(resolved, {
403
+ file: path.relative(cwd, resolved),
404
+ status: document.status,
405
+ });
406
+ }
407
+ return summarizeDiagnosticEvidence(Array.from(documents.values()));
84
408
  }
@@ -2,6 +2,7 @@ import * as fs from "node:fs";
2
2
  import * as path from "node:path";
3
3
  import {
4
4
  type CodeQueryResult,
5
+ type CodeRequestControl,
5
6
  completedCodeQuery,
6
7
  partialCodeQuery,
7
8
  unavailableCodeQuery,
@@ -55,6 +56,7 @@ export interface WorkspaceSymbolCollection {
55
56
  export async function collectWorkspaceSymbols(
56
57
  clients: Iterable<LspClient>,
57
58
  query: string,
59
+ control?: CodeRequestControl,
58
60
  ): Promise<WorkspaceSymbolCollection> {
59
61
  const results: WorkspaceSymbolLike[] = [];
60
62
  const failures: string[] = [];
@@ -65,7 +67,7 @@ export async function collectWorkspaceSymbols(
65
67
  if (client.status !== "running") continue;
66
68
  if (!client.serverCapabilities?.workspaceSymbolProvider) continue;
67
69
  hasSupport = true;
68
- const result = await client.workspaceSymbol(query);
70
+ const result = await client.workspaceSymbol(query, control);
69
71
  if (result.kind === "unavailable") {
70
72
  failures.push(result.reason);
71
73
  continue;
@@ -99,8 +101,9 @@ export function workspaceSymbolCollectionResult(
99
101
  export async function managerWorkspaceSymbol(
100
102
  clients: Iterable<LspClient>,
101
103
  query: string,
104
+ control?: CodeRequestControl,
102
105
  ): Promise<CodeQueryResult<WorkspaceSymbolLike[]>> {
103
- return workspaceSymbolCollectionResult(await collectWorkspaceSymbols(clients, query));
106
+ return workspaceSymbolCollectionResult(await collectWorkspaceSymbols(clients, query, control));
104
107
  }
105
108
 
106
109
  export function findWorkspaceSymbolWarmTargets(