@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
@@ -2,6 +2,8 @@
2
2
 
3
3
  import {
4
4
  type CodePosition,
5
+ type CodeRequestControl,
6
+ isCodeRequestInterruption,
5
7
  mapCodeQueryResult,
6
8
  type OutlineData,
7
9
  type SemanticProvider,
@@ -27,6 +29,7 @@ export interface InspectCollectionInput {
27
29
  readonly line: number;
28
30
  readonly character: number;
29
31
  readonly lineCount: number;
32
+ readonly requestControl?: CodeRequestControl;
30
33
  readonly structural: StructuralProvider | null;
31
34
  readonly semantic: SemanticProvider | null;
32
35
  readonly semanticUnavailableReason: string;
@@ -50,7 +53,12 @@ async function collectNode(
50
53
  ): Promise<InspectObservation<InspectNode | null>> {
51
54
  if (!input.structural) return unavailableCodeQuery("No structural node provider is active.");
52
55
  try {
53
- const result = await input.structural.nodeAt(input.file, input.line, input.character);
56
+ const result = await input.structural.nodeAt(
57
+ input.file,
58
+ input.line,
59
+ input.character,
60
+ input.requestControl,
61
+ );
54
62
  if (result.kind !== "success") return unavailableCodeQuery(result.message);
55
63
  return {
56
64
  kind: "completed",
@@ -65,6 +73,7 @@ async function collectNode(
65
73
  },
66
74
  };
67
75
  } catch (error) {
76
+ if (isCodeRequestInterruption(error, input.requestControl)) throw error;
68
77
  return unavailableCodeQuery(failureReason("Structural node lookup", error));
69
78
  }
70
79
  }
@@ -74,7 +83,7 @@ async function collectEnclosingSymbol(
74
83
  ): Promise<InspectObservation<InspectEnclosingSymbol | null>> {
75
84
  if (!input.structural) return unavailableCodeQuery("No structural outline provider is active.");
76
85
  try {
77
- const result = await input.structural.outline(input.file);
86
+ const result = await input.structural.outline(input.file, input.requestControl);
78
87
  if (result.kind !== "success") return unavailableCodeQuery(result.message);
79
88
  return {
80
89
  kind: "completed",
@@ -84,6 +93,7 @@ async function collectEnclosingSymbol(
84
93
  }),
85
94
  };
86
95
  } catch (error) {
96
+ if (isCodeRequestInterruption(error, input.requestControl)) throw error;
87
97
  return unavailableCodeQuery(failureReason("Structural outline lookup", error));
88
98
  }
89
99
  }
@@ -98,6 +108,7 @@ async function collectHover(
98
108
  (hover) => hover?.contents ?? null,
99
109
  );
100
110
  } catch (error) {
111
+ if (isCodeRequestInterruption(error, input.requestControl)) throw error;
101
112
  return unavailableCodeQuery(failureReason("Hover lookup", error));
102
113
  }
103
114
  }
@@ -131,6 +142,7 @@ async function collectDefinition(
131
142
  ? { kind: "partial", data: definitions, reason: reasons.join(" ") }
132
143
  : { kind: "completed", data: definitions };
133
144
  } catch (error) {
145
+ if (isCodeRequestInterruption(error, input.requestControl)) throw error;
134
146
  return unavailableCodeQuery(failureReason("Definition lookup", error));
135
147
  }
136
148
  }
@@ -142,7 +154,11 @@ async function collectDiagnostics(
142
154
  return unavailableCodeQuery(lspUnavailableReason(input.lspState));
143
155
  }
144
156
  try {
145
- const result = await input.lspState.runtime.fileDiagnostics(input.file, 4);
157
+ const result = await input.lspState.runtime.fileDiagnostics(
158
+ input.file,
159
+ 4,
160
+ input.requestControl,
161
+ );
146
162
  if (result.kind === "unavailable") return result;
147
163
  const diagnostics = result.data
148
164
  .filter((diagnostic) => diagnosticOverlapsWindow(diagnostic.range, input))
@@ -159,6 +175,7 @@ async function collectDiagnostics(
159
175
  ? { kind: "partial", data: diagnostics, reason: result.reason }
160
176
  : { kind: "completed", data: diagnostics };
161
177
  } catch (error) {
178
+ if (isCodeRequestInterruption(error, input.requestControl)) throw error;
162
179
  return unavailableCodeQuery(failureReason("Diagnostic lookup", error));
163
180
  }
164
181
  }
@@ -1,6 +1,8 @@
1
1
  /** Session-owned point inspection workflow. */
2
2
 
3
3
  import type { WorkspaceLspRuntimeState } from "@mrclrchtr/supi-lsp/api";
4
+ import { withSemanticRequestControl } from "../analysis/provider.ts";
5
+ import { SEMANTIC_READINESS_TIMEOUT_REASON } from "../analysis/readiness.ts";
4
6
  import type { CapabilityAdapter, ReadinessOutcome } from "./capability-adapter.ts";
5
7
  import { parseInspectWorkflowInput } from "./input/workflows.ts";
6
8
  import { collectInspectSections } from "./inspect/collect.ts";
@@ -37,14 +39,17 @@ export async function runInspectWorkflow(
37
39
  phase: "providers",
38
40
  message: "Collecting point facts",
39
41
  });
40
- const readiness = await deps.capability.ensureSemanticReadiness(deps.cwd, {
41
- kind: "file",
42
- file: point.value.file,
43
- });
42
+ const readiness = await deps.capability.ensureSemanticReadiness(
43
+ deps.cwd,
44
+ { kind: "file", file: point.value.file },
45
+ control,
46
+ );
44
47
  throwIfAborted(control);
45
48
 
46
49
  const semanticReady = readiness.kind === "ready";
47
- const semantic = semanticReady ? deps.capability.getSemanticProvider(deps.cwd) : null;
50
+ const semantic = semanticReady
51
+ ? withSemanticRequestControl(deps.capability.getSemanticProvider(deps.cwd), control)
52
+ : null;
48
53
  const lspState = semanticReady
49
54
  ? deps.capability.getLspRuntimeState(deps.cwd)
50
55
  : unavailableLspState(readiness);
@@ -54,6 +59,7 @@ export async function runInspectWorkflow(
54
59
  line: point.value.line,
55
60
  character: point.value.character,
56
61
  lineCount: point.value.lineCount,
62
+ requestControl: control,
57
63
  structural: deps.capability.getStructuralProvider(deps.cwd),
58
64
  semantic,
59
65
  semanticUnavailableReason: semantic
@@ -150,7 +156,7 @@ function semanticReadinessReason(readiness: ReadinessOutcome): string {
150
156
  case "ready":
151
157
  return "No semantic provider is active for this file.";
152
158
  case "timeout":
153
- return "Semantic readiness timed out.";
159
+ return SEMANTIC_READINESS_TIMEOUT_REASON;
154
160
  case "unavailable":
155
161
  return readiness.reason;
156
162
  }
@@ -2,6 +2,7 @@
2
2
  import { existsSync, readFileSync } from "node:fs";
3
3
  import * as path from "node:path";
4
4
  import type { ConfidenceMode } from "@mrclrchtr/supi-code-runtime/api";
5
+ import { isCodeRequestInterruption } from "@mrclrchtr/supi-code-runtime/api";
5
6
  import { uriToFile } from "@mrclrchtr/supi-core/path";
6
7
  import type { Diagnostic } from "@mrclrchtr/supi-lsp/api";
7
8
  import {
@@ -69,6 +70,7 @@ async function executeOrientationContext(
69
70
  focus: input.focus,
70
71
  maxResults: input.maxResults ?? 10,
71
72
  lspRuntime: deps.lspRuntime,
73
+ requestControl: deps.requestControl,
72
74
  });
73
75
  }
74
76
 
@@ -181,7 +183,7 @@ async function buildEnrichedDefsSection(
181
183
  hasStructuralEvidence,
182
184
  hasSemanticEvidence: contextHasSemanticEvidence,
183
185
  status: contextHasSemanticEvidence ? "partial" : "unavailable",
184
- reason: "Definition targets require a live language server.",
186
+ reason: deps.semanticReadinessReason ?? "Definition targets require a live language server.",
185
187
  evidenceLists: [],
186
188
  };
187
189
  }
@@ -262,6 +264,7 @@ async function collectDefinitionTargets(
262
264
  evidenceLists: [evidence.metadata],
263
265
  };
264
266
  } catch (error) {
267
+ if (isCodeRequestInterruption(error, deps.requestControl)) throw error;
265
268
  return {
266
269
  items: [],
267
270
  hasSemanticEvidence: false,
@@ -289,13 +292,17 @@ async function buildDiagnosticsSection(
289
292
  },
290
293
  ],
291
294
  false,
292
- "Diagnostics require a live language server.",
295
+ deps.semanticReadinessReason ?? "Diagnostics require a live language server.",
293
296
  );
294
297
  }
295
298
 
296
299
  try {
297
300
  const targetFile = path.resolve(deps.cwd, target.file);
298
- const result = await deps.lspRuntime.runtime.fileDiagnostics(targetFile, 4);
301
+ const result = await deps.lspRuntime.runtime.fileDiagnostics(
302
+ targetFile,
303
+ 4,
304
+ deps.requestControl,
305
+ );
299
306
  if (result.kind === "unavailable") {
300
307
  return unavailableTargetSection(
301
308
  [{ kind: "paragraph", text: `Diagnostics unavailable for this target — ${result.reason}` }],
@@ -331,6 +338,7 @@ async function buildDiagnosticsSection(
331
338
  evidenceLists: [evidence.metadata],
332
339
  };
333
340
  } catch (error) {
341
+ if (isCodeRequestInterruption(error, deps.requestControl)) throw error;
334
342
  return unavailableTargetSection(
335
343
  [{ kind: "paragraph", text: "Diagnostics failed to load." }],
336
344
  false,
@@ -492,6 +500,7 @@ async function maybeGatherTreeContext(
492
500
  target.displayLine,
493
501
  target.displayCharacter,
494
502
  target.anchorKind !== "declaration",
503
+ deps.requestControl,
495
504
  );
496
505
  }
497
506
 
@@ -1,5 +1,6 @@
1
1
  import { statSync } from "node:fs";
2
2
  import * as path from "node:path";
3
+ import type { CodeRequestControl } from "@mrclrchtr/supi-code-runtime/api";
3
4
  import type { WorkspaceLspRuntimeState } from "@mrclrchtr/supi-lsp/api";
4
5
  import type {
5
6
  ArchitectureModel,
@@ -32,6 +33,7 @@ interface ContextFactsInput {
32
33
  readonly maxResults: number;
33
34
  readonly provider: CodeProvider | null;
34
35
  readonly lspRuntime: WorkspaceLspRuntimeState;
36
+ readonly requestControl?: CodeRequestControl;
35
37
  }
36
38
 
37
39
  /** Collect direct filesystem, parsed-manifest, and explicit-provider Orientation facts. */
@@ -115,7 +117,7 @@ async function collectFileFacts(
115
117
  });
116
118
  appendTopologyWarning(builder, input.model);
117
119
  appendPackageContext(builder, input.model, focus);
118
- await appendStructuralFileFacts(builder, input.provider, focus);
120
+ await appendStructuralFileFacts(builder, input.provider, focus, input.requestControl);
119
121
  appendPrioritySignals(builder, {
120
122
  scope: focus,
121
123
  isFile: true,
@@ -1,6 +1,11 @@
1
1
  import { readdirSync } from "node:fs";
2
2
  import * as path from "node:path";
3
- import type { CodeResult, ConfidenceMode } from "@mrclrchtr/supi-code-runtime/api";
3
+ import {
4
+ type CodeRequestControl,
5
+ type CodeResult,
6
+ type ConfidenceMode,
7
+ isCodeRequestInterruption,
8
+ } from "@mrclrchtr/supi-code-runtime/api";
4
9
  import { isWithinOrEqual } from "@mrclrchtr/supi-core/project";
5
10
  import type { WorkspaceLspRuntimeState } from "@mrclrchtr/supi-lsp/api";
6
11
  import type { EvidenceListMetadata, EvidencePartialReason } from "../../analysis/evidence.ts";
@@ -153,6 +158,7 @@ export async function appendStructuralFileFacts(
153
158
  builder: ContextOrientationBuilder,
154
159
  provider: CodeProvider | null,
155
160
  file: string,
161
+ requestControl?: CodeRequestControl,
156
162
  ): Promise<void> {
157
163
  if (!provider) {
158
164
  appendUnavailableStructuralSections(builder);
@@ -162,19 +168,22 @@ export async function appendStructuralFileFacts(
162
168
  await appendStructuralList(builder, {
163
169
  key: "structural.outline",
164
170
  title: "Provider outline",
165
- collect: () => provider.outline(file),
171
+ collect: () => provider.outline(file, requestControl),
172
+ requestControl,
166
173
  render: (item) => `\`${item.name}\` (${item.kind}, L${item.startLine}–L${item.endLine})`,
167
174
  });
168
175
  await appendStructuralList(builder, {
169
176
  key: "structural.imports",
170
177
  title: "Provider imports",
171
- collect: () => provider.imports(file),
178
+ collect: () => provider.imports(file, requestControl),
179
+ requestControl,
172
180
  render: (item) => `\`${item.moduleSpecifier}\``,
173
181
  });
174
182
  await appendStructuralList(builder, {
175
183
  key: "structural.exports",
176
184
  title: "Provider exports",
177
- collect: () => provider.exports(file),
185
+ collect: () => provider.exports(file, requestControl),
186
+ requestControl,
178
187
  render: (item) => `\`${item.name}\` (${item.kind})`,
179
188
  });
180
189
  }
@@ -201,12 +210,14 @@ async function appendStructuralList<T>(
201
210
  title: string;
202
211
  collect: () => Promise<CodeResult<T[]>>;
203
212
  render: (item: T) => string;
213
+ requestControl?: CodeRequestControl;
204
214
  },
205
215
  ): Promise<void> {
206
216
  let result: CodeResult<T[]>;
207
217
  try {
208
218
  result = await input.collect();
209
219
  } catch (error) {
220
+ if (isCodeRequestInterruption(error, input.requestControl)) throw error;
210
221
  appendUnavailable(builder, {
211
222
  key: input.key,
212
223
  title: input.title,
@@ -246,7 +257,8 @@ export function appendPrioritySignals(
246
257
  ): void {
247
258
  if (input.lspRuntime.kind !== "ready") return;
248
259
  const scopePath = path.resolve(input.scope);
249
- const entries = input.lspRuntime.runtime.getOutstandingDiagnosticSummary(2).filter((entry) => {
260
+ const snapshot = input.lspRuntime.runtime.getOutstandingDiagnosticSummary(2);
261
+ const entries = snapshot.entries.filter((entry) => {
250
262
  const file = path.resolve(input.cwd, entry.file);
251
263
  return input.isFile ? file === scopePath : isWithinOrEqual(scopePath, file);
252
264
  });
@@ -265,8 +277,9 @@ export function appendPrioritySignals(
265
277
  confidence: "semantic",
266
278
  provenance: [{ source: "semantic", capability: "LSP diagnostic snapshot" }],
267
279
  status: "partial",
268
- reason:
269
- "This is the current LSP snapshot, not a complete diagnostic scan; use code_health for diagnostic status.",
280
+ reason: snapshot.current
281
+ ? "This is the current LSP snapshot, not a complete diagnostic scan; use code_health for diagnostic status."
282
+ : "This LSP snapshot was invalidated by a document or workspace change; use code_health with refresh:true before relying on it.",
270
283
  });
271
284
  }
272
285
 
@@ -6,10 +6,12 @@
6
6
  * evidence collector in `collect.ts`.
7
7
  */
8
8
 
9
- import type {
10
- SemanticProvider,
11
- SourceRange,
12
- StructuralProvider,
9
+ import {
10
+ type CodeRequestControl,
11
+ isCodeRequestInterruption,
12
+ type SemanticProvider,
13
+ type SourceRange,
14
+ type StructuralProvider,
13
15
  } from "@mrclrchtr/supi-code-runtime/api";
14
16
 
15
17
  /** Structural provider subset plus optional semantic hover/definition used for gathering. */
@@ -64,6 +66,7 @@ export async function gatherSubstrateContext(
64
66
  line: number,
65
67
  character: number,
66
68
  positionStrict: boolean,
69
+ requestControl?: CodeRequestControl,
67
70
  ): Promise<SubstrateContext> {
68
71
  let nodeInfo: SubstrateContext["nodeInfo"] = null;
69
72
  let outline: SubstrateContext["outline"] = [];
@@ -76,7 +79,7 @@ export async function gatherSubstrateContext(
76
79
 
77
80
  try {
78
81
  if (positionStrict) {
79
- const nodeResult = await provider.nodeAt(relPath, line, character);
82
+ const nodeResult = await provider.nodeAt(relPath, line, character, requestControl);
80
83
  if (nodeResult.kind === "success") {
81
84
  nodeInfo = {
82
85
  type: nodeResult.data.type,
@@ -88,7 +91,7 @@ export async function gatherSubstrateContext(
88
91
  }
89
92
  }
90
93
 
91
- const outlineResult = await provider.outline(relPath);
94
+ const outlineResult = await provider.outline(relPath, requestControl);
92
95
  if (outlineResult.kind === "success") {
93
96
  outline = outlineResult.data.map((item) => ({
94
97
  name: item.name,
@@ -98,12 +101,12 @@ export async function gatherSubstrateContext(
98
101
  }));
99
102
  }
100
103
 
101
- const importsResult = await provider.imports(relPath);
104
+ const importsResult = await provider.imports(relPath, requestControl);
102
105
  if (importsResult.kind === "success") {
103
106
  imports = importsResult.data;
104
107
  }
105
108
 
106
- const exportsResult = await provider.exports(relPath);
109
+ const exportsResult = await provider.exports(relPath, requestControl);
107
110
  if (exportsResult.kind === "success") {
108
111
  exports = exportsResult.data.map((item) => ({
109
112
  name: item.name,
@@ -119,7 +122,8 @@ export async function gatherSubstrateContext(
119
122
  character: character - 1,
120
123
  });
121
124
  if (hoverResult.kind !== "unavailable" && hoverResult.data) hover = hoverResult.data;
122
- } catch {
125
+ } catch (error) {
126
+ if (isCodeRequestInterruption(error, requestControl)) throw error;
123
127
  // hover failed — continue without it
124
128
  }
125
129
  }
@@ -137,11 +141,13 @@ export async function gatherSubstrateContext(
137
141
  range: loc.range,
138
142
  }));
139
143
  }
140
- } catch {
144
+ } catch (error) {
145
+ if (isCodeRequestInterruption(error, requestControl)) throw error;
141
146
  // definition failed — continue without it
142
147
  }
143
148
  }
144
- } catch {
149
+ } catch (error) {
150
+ if (isCodeRequestInterruption(error, requestControl)) throw error;
145
151
  // Provider not available
146
152
  }
147
153
 
@@ -1,4 +1,4 @@
1
- import type { ConfidenceMode } from "@mrclrchtr/supi-code-runtime/api";
1
+ import type { CodeRequestControl, ConfidenceMode } from "@mrclrchtr/supi-code-runtime/api";
2
2
  import type { WorkspaceLspRuntimeState } from "@mrclrchtr/supi-lsp/api";
3
3
  import type { ArchitectureModel } from "../analysis/architecture/model.ts";
4
4
  import type { EvidenceListMetadata } from "../analysis/evidence.ts";
@@ -37,6 +37,9 @@ export interface OrientationDeps {
37
37
  readonly provider: CodeProvider | null;
38
38
  readonly cwd: string;
39
39
  readonly lspRuntime: WorkspaceLspRuntimeState;
40
+ /** Typed reason to surface when target semantic readiness timed out. */
41
+ readonly semanticReadinessReason?: string;
42
+ readonly requestControl?: CodeRequestControl;
40
43
  }
41
44
 
42
45
  /**
@@ -8,7 +8,8 @@ import {
8
8
  collectInstructionFiles,
9
9
  findInstructionFilesForDirectory,
10
10
  } from "../analysis/instruction-files.ts";
11
- import { createStructuralCodeProvider } from "../analysis/provider.ts";
11
+ import { createStructuralCodeProvider, withSemanticRequestControl } from "../analysis/provider.ts";
12
+ import { SEMANTIC_READINESS_TIMEOUT_REASON } from "../analysis/readiness.ts";
12
13
  import { normalizePath } from "../analysis/search/paths.ts";
13
14
  import { loadCodeIntelligenceConfig } from "../config.ts";
14
15
  import type { CapabilityAdapter } from "./capability-adapter.ts";
@@ -33,6 +34,8 @@ export interface OrientationWorkflowDeps extends TargetWorkflowDeps {
33
34
  readonly markInstructionDirsSurfaced: (directories: string[]) => void;
34
35
  /** Whether the project is trusted — controls instruction-file discovery. */
35
36
  readonly projectTrusted: boolean;
37
+ /** Global config home for hermetic config reads; undefined uses os.homedir(). */
38
+ readonly homeDir?: string;
36
39
  }
37
40
 
38
41
  /** Resolve the Orientation focus and collect immutable facts for presentation adapters. */
@@ -58,8 +61,9 @@ export async function runOrientationWorkflow(
58
61
  if (!request.focus) {
59
62
  const result = await executeOrientation(
60
63
  { maxResults },
61
- { model, provider, lspRuntime, cwd: deps.cwd },
64
+ { model, provider, lspRuntime, cwd: deps.cwd, requestControl: control },
62
65
  );
66
+ throwIfAborted(control);
63
67
  return { kind: "completed", data: result };
64
68
  }
65
69
 
@@ -74,8 +78,9 @@ export async function runOrientationWorkflow(
74
78
  focus: focus.path,
75
79
  maxResults,
76
80
  },
77
- { model, provider, lspRuntime, cwd: deps.cwd },
81
+ { model, provider, lspRuntime, cwd: deps.cwd, requestControl: control },
78
82
  );
83
+ throwIfAborted(control);
79
84
  const withInstructions = addInstructionFiles(result, focus.path, deps);
80
85
  return { kind: "completed", data: withInstructions };
81
86
  }
@@ -101,7 +106,9 @@ async function orientTarget(options: {
101
106
  maxResults,
102
107
  },
103
108
  deps,
109
+ control,
104
110
  );
111
+ throwIfAborted(control);
105
112
  if (target.kind === "target-group") {
106
113
  return {
107
114
  kind: "invalid-input",
@@ -133,19 +140,22 @@ async function orientTarget(options: {
133
140
  throwIfAborted(control);
134
141
 
135
142
  const entry = target.entry;
136
- const readiness = await deps.capability.ensureSemanticReadiness(deps.cwd, {
137
- kind: "file",
138
- file: entry.file,
139
- });
143
+ const readiness = await deps.capability.ensureSemanticReadiness(
144
+ deps.cwd,
145
+ { kind: "file", file: entry.file },
146
+ control,
147
+ );
140
148
  const semanticReady = readiness.kind === "ready";
141
149
  const provider = semanticReady
142
- ? deps.capability.getProvider(deps.cwd)
150
+ ? withSemanticRequestControl(deps.capability.getProvider(deps.cwd), control)
143
151
  : createStructuralCodeProvider(deps.capability.getStructuralProvider(deps.cwd));
152
+ const semanticReadinessReason =
153
+ readiness.kind === "timeout" ? SEMANTIC_READINESS_TIMEOUT_REASON : undefined;
144
154
  const lspRuntime = semanticReady
145
155
  ? deps.capability.getLspRuntimeState(deps.cwd)
146
156
  : {
147
157
  kind: "unavailable" as const,
148
- reason: readiness.kind === "timeout" ? "Semantic readiness timed out" : readiness.reason,
158
+ reason: readiness.kind === "timeout" ? SEMANTIC_READINESS_TIMEOUT_REASON : readiness.reason,
149
159
  };
150
160
  const result = await executeOrientation(
151
161
  { target: entry, maxResults },
@@ -153,9 +163,12 @@ async function orientTarget(options: {
153
163
  model,
154
164
  provider,
155
165
  lspRuntime,
166
+ semanticReadinessReason,
156
167
  cwd: deps.cwd,
168
+ requestControl: control,
157
169
  },
158
170
  );
171
+ throwIfAborted(control);
159
172
  return {
160
173
  kind: "completed",
161
174
  data: addTargetSummary(result, entry, target.notes, deps.cwd),
@@ -194,7 +207,7 @@ function addInstructionFiles(
194
207
  deps: OrientationWorkflowDeps,
195
208
  ): Awaited<ReturnType<typeof executeOrientation>> {
196
209
  if (!deps.projectTrusted || !isDirectory(focusPath)) return result;
197
- const config = loadCodeIntelligenceConfig(deps.cwd);
210
+ const config = loadCodeIntelligenceConfig(deps.cwd, deps.homeDir);
198
211
  const matches = findInstructionFilesForDirectory({
199
212
  directory: focusPath,
200
213
  cwd: deps.cwd,
@@ -19,6 +19,8 @@ export interface RefactorPlan {
19
19
  targetLine: number;
20
20
  targetCharacter: number;
21
21
  edits: WorkspaceEdit;
22
+ /** Canonical roots that the routed semantic provider authorized. */
23
+ authorizedMutationRoots: string[];
22
24
  fileFingerprints: Array<{ file: string; fingerprint: string }>;
23
25
  createdAt: number;
24
26
  }
@@ -7,7 +7,12 @@ import type {
7
7
  SourceRange,
8
8
  } from "@mrclrchtr/supi-code-runtime/api";
9
9
  import { toLspPosition } from "@mrclrchtr/supi-lsp/api";
10
+ import { SEMANTIC_READINESS_TIMEOUT_REASON } from "../analysis/readiness.ts";
10
11
  import { applyWorkspaceEdit } from "../analysis/refactor/apply.ts";
12
+ import {
13
+ establishMutationAuthority,
14
+ revalidateMutationAuthority,
15
+ } from "../analysis/refactor/mutation-authority.ts";
11
16
  import { validateEdit } from "../analysis/refactor/safety.ts";
12
17
  import { normalizePath } from "../analysis/search/paths.ts";
13
18
  import type { CapabilityAdapter } from "./capability-adapter.ts";
@@ -66,7 +71,9 @@ export async function runRefactorPlanWorkflow(
66
71
  nameAnchorRequired: parsed.operation === "rename_symbol",
67
72
  },
68
73
  deps,
74
+ control,
69
75
  );
76
+ throwIfAborted(control);
70
77
  if (target.kind === "target-group") {
71
78
  return {
72
79
  kind: "invalid-input",
@@ -81,24 +88,29 @@ export async function runRefactorPlanWorkflow(
81
88
  }
82
89
  if (target.kind !== "resolved") return target;
83
90
 
84
- const readiness = await deps.capability.ensureSemanticReadiness(deps.cwd, {
85
- kind: "file",
86
- file: target.entry.file,
87
- });
91
+ const readiness = await deps.capability.ensureSemanticReadiness(
92
+ deps.cwd,
93
+ { kind: "file", file: target.entry.file },
94
+ control,
95
+ );
88
96
  if (readiness.kind === "timeout") {
89
- return { kind: "unavailable", reason: "Semantic readiness timed out." };
97
+ return { kind: "unavailable", reason: SEMANTIC_READINESS_TIMEOUT_REASON };
90
98
  }
91
99
  if (readiness.kind === "unavailable") return readiness;
92
100
  throwIfAborted(control);
93
101
 
94
102
  const file = normalizePath(target.entry.file, deps.cwd);
95
- const result = await planWithProvider(deps.capability.getSemanticProvider(deps.cwd), {
96
- operation: parsed.operation,
97
- file,
98
- position: toLspPosition(target.entry.displayLine, target.entry.displayCharacter),
99
- range: parsed.range ? toLspRange(parsed.range) : undefined,
100
- newName: parsed.newName,
101
- });
103
+ const result = await planWithProvider(
104
+ deps.capability.getSemanticProvider(deps.cwd),
105
+ {
106
+ operation: parsed.operation,
107
+ file,
108
+ position: toLspPosition(target.entry.displayLine, target.entry.displayCharacter),
109
+ range: parsed.range ? toLspRange(parsed.range) : undefined,
110
+ newName: parsed.newName,
111
+ },
112
+ control,
113
+ );
102
114
  if (result.kind === "unavailable") return result;
103
115
  if (result.kind === "ambiguous") {
104
116
  return { kind: "ambiguous", candidates: result.candidates };
@@ -108,6 +120,11 @@ export async function runRefactorPlanWorkflow(
108
120
  if (!validation.safe) {
109
121
  return { kind: "invalid-input", message: `Refactor safety check failed: ${validation.reason}` };
110
122
  }
123
+ const authority = establishMutationAuthority(
124
+ result.edits.edits.map((edit) => edit.file),
125
+ result.authorizedMutationRoots,
126
+ );
127
+ if (authority.kind === "unavailable") return authority;
111
128
 
112
129
  const plan: RefactorPlan = {
113
130
  id: generatePlanId(
@@ -123,6 +140,7 @@ export async function runRefactorPlanWorkflow(
123
140
  targetLine: target.entry.displayLine,
124
141
  targetCharacter: target.entry.displayCharacter,
125
142
  edits: result.edits,
143
+ authorizedMutationRoots: authority.canonicalRoots,
126
144
  fileFingerprints: collectFileFingerprints(result.edits.edits),
127
145
  createdAt: Date.now(),
128
146
  };
@@ -147,6 +165,11 @@ export async function runRefactorApplyWorkflow(
147
165
  };
148
166
  }
149
167
 
168
+ const authority = revalidateMutationAuthority(
169
+ plan.edits.edits.map((edit) => edit.file),
170
+ plan.authorizedMutationRoots,
171
+ );
172
+ if (authority.kind === "unavailable") return authority;
150
173
  const freshness = isPlanFresh(plan);
151
174
  if (!freshness.fresh) return { kind: "invalid-input", message: freshness.reason };
152
175
  const validation = validateEdit(plan.edits);
@@ -161,12 +184,26 @@ export async function runRefactorApplyWorkflow(
161
184
  const expectedFingerprints = new Map(
162
185
  plan.fileFingerprints.map(({ file, fingerprint }) => [file, fingerprint]),
163
186
  );
164
- const result = await applyWorkspaceEdit(plan.edits, { expectedFingerprints });
187
+ const getOpenDocumentVersion = getDocumentVersionReader(deps);
188
+ const result = await applyWorkspaceEdit(plan.edits, {
189
+ authorizedMutationRoots: plan.authorizedMutationRoots,
190
+ expectedFingerprints,
191
+ getOpenDocumentVersion,
192
+ });
165
193
  if (result.kind === "error") return { kind: "unavailable", reason: result.reason };
166
194
  deps.removePlan(plan.id);
167
195
  return { kind: "completed", plan: immutablePlan(plan), result };
168
196
  }
169
197
 
198
+ function getDocumentVersionReader(
199
+ deps: RefactorWorkflowDeps,
200
+ ): ((file: string) => number | null) | undefined {
201
+ const state = deps.capability.getLspRuntimeState(deps.cwd);
202
+ if (state.kind !== "ready" && state.kind !== "inactive") return undefined;
203
+ if (typeof state.runtime.getOpenDocumentVersion !== "function") return undefined;
204
+ return (file) => state.runtime.getOpenDocumentVersion(file);
205
+ }
206
+
170
207
  function parseOperation(input: RefactorOperationInput):
171
208
  | {
172
209
  kind: "ok";
@@ -230,11 +267,12 @@ async function planWithProvider(
230
267
  range?: SourceRange;
231
268
  newName: string;
232
269
  },
270
+ control?: WorkflowControl,
233
271
  ): Promise<RefactorResult> {
234
272
  if (!provider) return { kind: "unavailable", reason: "No semantic provider is active." };
235
- if (provider.refactor) return provider.refactor(request);
273
+ if (provider.refactor) return provider.refactor(request, control);
236
274
  if (request.operation === "rename_symbol" && provider.rename) {
237
- return provider.rename(request.file, request.position, request.newName);
275
+ return provider.rename(request.file, request.position, request.newName, control);
238
276
  }
239
277
  return {
240
278
  kind: "unavailable",
@@ -255,7 +293,15 @@ function immutablePlan(plan: RefactorPlan): Readonly<RefactorPlan> {
255
293
  edits: Object.freeze({
256
294
  ...plan.edits,
257
295
  edits: Object.freeze(plan.edits.edits.map((edit) => Object.freeze({ ...edit }))),
296
+ documentPreconditions: plan.edits.documentPreconditions
297
+ ? Object.freeze(
298
+ plan.edits.documentPreconditions.map((precondition) =>
299
+ Object.freeze({ ...precondition }),
300
+ ),
301
+ )
302
+ : undefined,
258
303
  }),
304
+ authorizedMutationRoots: Object.freeze([...plan.authorizedMutationRoots]),
259
305
  fileFingerprints: Object.freeze(
260
306
  plan.fileFingerprints.map((fingerprint) => Object.freeze({ ...fingerprint })),
261
307
  ),