@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,22 +1,14 @@
1
- // Tree-sitter session runtime controller — pi-independent lifecycle for structural analysis.
2
- //
3
- // This controller owns runtime creation/disposal for one cwd:
4
- // - Creates and disposes the TreeSitterRuntime
5
- // - Creates TreeSitterService from the runtime
6
- // - Publishes SessionTreeSitterService state through the existing registry
7
- // - Exposes ready/unavailable lifecycle for umbrella adapter consumption
1
+ // Tree-sitter lifecycle controller — owns one Structural Worker for one cwd.
8
2
 
3
+ import { fileURLToPath } from "node:url";
9
4
  import type { WorkspaceRuntime } from "@mrclrchtr/supi-code-runtime/api";
10
- import type { SessionTreeSitterService, TreeSitterService } from "../types.ts";
11
- import { TreeSitterRuntime } from "./runtime.ts";
5
+ import type { SessionTreeSitterService, TreeSitterService, TreeSitterSession } from "../types.ts";
12
6
  import {
13
7
  registerTreeSitterCapabilities,
14
8
  unregisterTreeSitterCapabilities,
15
9
  } from "./runtime-registration.ts";
16
10
  import { clearSessionTreeSitterService, setSessionTreeSitterService } from "./service-registry.ts";
17
- import { createTreeSitterService } from "./session.ts";
18
-
19
- // ── Types ─────────────────────────────────────────────────────────────
11
+ import { createTreeSitterSession } from "./session.ts";
20
12
 
21
13
  /** Starting state before or after shutdown. */
22
14
  export type TsControllerState = TsControllerInitial | TsControllerReady | TsControllerUnavailable;
@@ -27,7 +19,7 @@ interface TsControllerInitial {
27
19
 
28
20
  interface TsControllerReady {
29
21
  kind: "ready";
30
- runtime: TreeSitterRuntime;
22
+ session: TreeSitterSession;
31
23
  service: TreeSitterService;
32
24
  }
33
25
 
@@ -39,119 +31,105 @@ interface TsControllerUnavailable {
39
31
  /** Result type from {@link TreeSitterRuntimeController.start}. */
40
32
  export type TsStartResult = { kind: "ready" } | { kind: "unavailable"; reason: string };
41
33
 
42
- // ── Controller ────────────────────────────────────────────────────────
43
-
44
- /**
45
- * Pi-independent Tree-sitter session lifecycle controller.
46
- *
47
- * Use this in the umbrella extension (supi-code-intelligence) instead of
48
- * reaching into substrate extension internals.
49
- *
50
- * @example
51
- * ```ts
52
- * const controller = new TreeSitterRuntimeController(cwd);
53
- * const result = await controller.start();
54
- * if (result.kind === "ready") {
55
- * // use controller.service, controller.runtime
56
- * }
57
- * // later
58
- * await controller.shutdown();
59
- * ```
60
- */
34
+ /** Pi-independent lifecycle for one shared workspace Structural Worker. */
61
35
  export class TreeSitterRuntimeController {
62
36
  readonly #cwd: string;
63
- #state: TsControllerState;
37
+ #state: TsControllerState = { kind: "initial" };
64
38
  #runtime: WorkspaceRuntime | null;
39
+ #pendingSession: TreeSitterSession | null = null;
40
+ #generation = 0;
41
+ #transition = Promise.resolve();
65
42
 
66
43
  constructor(cwd: string, runtime?: WorkspaceRuntime) {
67
44
  this.#cwd = cwd;
68
- this.#state = { kind: "initial" };
69
45
  this.#runtime = runtime ?? null;
70
46
  }
71
47
 
72
- /** The workspace cwd this controller was created for. */
73
48
  get cwd(): string {
74
49
  return this.#cwd;
75
50
  }
76
51
 
77
- /** Current controller state. */
78
52
  get kind(): TsControllerState["kind"] {
79
53
  return this.#state.kind;
80
54
  }
81
55
 
82
- /** The TreeSitterService (structural operations), available when state is "ready". */
83
56
  get service(): SessionTreeSitterService | null {
84
57
  return this.#state.kind === "ready" ? this.#state.service : null;
85
58
  }
86
59
 
87
- /** The TreeSitterRuntime, available when state is "ready". */
88
- get runtime(): TreeSitterRuntime | null {
89
- return this.#state.kind === "ready" ? this.#state.runtime : null;
90
- }
91
-
92
- /** Attach a WorkspaceRuntime for capability registration. */
93
60
  setRuntime(runtime: WorkspaceRuntime): void {
94
61
  this.#runtime = runtime;
95
62
  }
96
63
 
97
- /**
98
- * Start the Tree-sitter session.
99
- *
100
- * Creates the runtime, wires the service, and publishes state
101
- * into the shared registries. Validates that WASM initialization
102
- * succeeds, returning `unavailable` if it fails.
103
- */
104
- async start(): Promise<TsStartResult> {
105
- // Restart safety: dispose any existing runtime
106
- if (this.#state.kind === "ready") {
107
- this.#state.runtime.dispose();
108
- if (this.#runtime) unregisterTreeSitterCapabilities(this.#runtime, this.#cwd);
109
- clearSessionTreeSitterService(this.#cwd);
110
- }
64
+ /** Start and validate one Structural Worker before capability publication. */
65
+ start(): Promise<TsStartResult> {
66
+ const generation = ++this.#generation;
67
+ let result: TsStartResult = supersededStart();
68
+ const transition = this.#transition.then(async () => {
69
+ if (generation !== this.#generation) return;
70
+ result = await this.#startGeneration(generation);
71
+ });
72
+ this.#transition = transition.catch(() => undefined);
73
+ return transition.then(() => result);
74
+ }
111
75
 
76
+ /** Stop publication, terminate owned Workers, and await their exit. */
77
+ async shutdown(): Promise<void> {
78
+ const generation = ++this.#generation;
79
+ const sessions = this.#takeOwnedSessions();
80
+ await Promise.all([...sessions].map((session) => session.dispose()));
81
+ if (generation === this.#generation) this.#state = { kind: "initial" };
82
+ }
83
+
84
+ async #startGeneration(generation: number): Promise<TsStartResult> {
85
+ const previous = this.#takeOwnedSessions();
86
+ await Promise.all([...previous].map((session) => session.dispose()));
87
+ if (generation !== this.#generation) return supersededStart();
112
88
  this.#state = { kind: "unavailable", reason: "Initializing Tree-sitter" };
113
89
 
90
+ const session = createTreeSitterSession(this.#cwd);
91
+ this.#pendingSession = session;
114
92
  try {
115
- const treeSitterRuntime = new TreeSitterRuntime(this.#cwd);
116
-
117
- // Probe WASM initialization by loading the JavaScript grammar
118
- // (always vendored). This catches missing web-tree-sitter or
119
- // corrupted WASM early rather than deferring to first tool use.
120
- await treeSitterRuntime.ensureGrammarParser("javascript");
121
-
122
- const service = createTreeSitterService(treeSitterRuntime);
123
- setSessionTreeSitterService(this.#cwd, service);
124
-
125
- if (this.#runtime) {
126
- registerTreeSitterCapabilities(this.#runtime, this.#cwd, service);
93
+ const probe = await session.canParse(fileURLToPath(import.meta.url));
94
+ if (probe.kind !== "success") throw new Error(probe.message);
95
+ if (generation !== this.#generation || this.#pendingSession !== session) {
96
+ return supersededStart();
127
97
  }
128
-
129
- this.#state = { kind: "ready", runtime: treeSitterRuntime, service };
98
+ setSessionTreeSitterService(this.#cwd, session);
99
+ if (this.#runtime) registerTreeSitterCapabilities(this.#runtime, this.#cwd, session);
100
+ this.#pendingSession = null;
101
+ this.#state = { kind: "ready", session, service: session };
130
102
  return { kind: "ready" };
131
- } catch (error: unknown) {
103
+ } catch (error) {
104
+ if (generation !== this.#generation || this.#pendingSession !== session) {
105
+ return supersededStart();
106
+ }
107
+ await session.dispose();
108
+ this.#pendingSession = null;
132
109
  const reason = error instanceof Error ? error.message : String(error);
110
+ await this.#clearPublishedSession();
133
111
  this.#state = { kind: "unavailable", reason };
134
- clearSessionTreeSitterService(this.#cwd);
135
112
  return { kind: "unavailable", reason };
136
113
  }
137
114
  }
138
115
 
139
- /**
140
- * Shut down the Tree-sitter session.
141
- *
142
- * Disposes the runtime and clears all published state.
143
- */
144
- async shutdown(): Promise<void> {
145
- if (this.#runtime && this.#cwd) {
146
- unregisterTreeSitterCapabilities(this.#runtime, this.#cwd);
147
- }
116
+ async #clearPublishedSession(): Promise<void> {
117
+ const sessions = this.#takeOwnedSessions();
118
+ await Promise.all([...sessions].map((session) => session.dispose()));
119
+ }
148
120
 
121
+ #takeOwnedSessions(): Set<TreeSitterSession> {
122
+ if (this.#runtime) unregisterTreeSitterCapabilities(this.#runtime, this.#cwd);
149
123
  clearSessionTreeSitterService(this.#cwd);
150
-
151
- if (this.#state.kind === "ready") {
152
- this.#state.runtime.dispose();
153
- }
154
-
124
+ const sessions = new Set<TreeSitterSession>();
125
+ if (this.#pendingSession) sessions.add(this.#pendingSession);
126
+ if (this.#state.kind === "ready") sessions.add(this.#state.session);
127
+ this.#pendingSession = null;
155
128
  this.#state = { kind: "initial" };
129
+ return sessions;
156
130
  }
157
131
  }
132
+
133
+ function supersededStart(): TsStartResult {
134
+ return { kind: "unavailable", reason: "Startup superseded" };
135
+ }
@@ -1,15 +1,6 @@
1
- // Session factory — creates runtime-backed Tree-sitter services and owned sessions.
1
+ // Session factory — creates asynchronous Structural Worker proxies and owned sessions.
2
2
 
3
- import { detectGrammar } from "../language.ts";
4
- import { supportsGrammarOperation } from "../operation-support.ts";
5
- import {
6
- extractCallSites,
7
- extractExports,
8
- extractImports,
9
- extractOutline,
10
- lookupCalleesAt,
11
- lookupNodeAt,
12
- } from "../tool/structure.ts";
3
+ import type { CodeRequestControl } from "@mrclrchtr/supi-code-runtime/api";
13
4
  import type {
14
5
  CalleesAtResult,
15
6
  CallSiteMatch,
@@ -22,108 +13,69 @@ import type {
22
13
  TreeSitterService,
23
14
  TreeSitterSession,
24
15
  } from "../types.ts";
25
- import { TreeSitterRuntime } from "./runtime.ts";
16
+ import {
17
+ StructuralWorkerClient,
18
+ type StructuralWorkerFactory,
19
+ } from "./structural-worker-client.ts";
26
20
 
27
- /** Create a runtime-backed structural service without taking ownership of disposal. */
28
- export function createTreeSitterService(runtime: TreeSitterRuntime): TreeSitterService {
21
+ /** Create one asynchronous service backed by an owned Structural Worker client. */
22
+ export function createTreeSitterService(client: StructuralWorkerClient): TreeSitterService {
29
23
  return {
30
- async canParse(file: string) {
31
- const result = await runtime.parseFile(file);
32
- if (result.kind !== "success") return result;
33
- const { resolvedPath, grammarId, tree } = result.data;
34
- try {
35
- return {
36
- kind: "success",
37
- data: { file: resolvedPath, language: grammarId },
38
- };
39
- } finally {
40
- tree.delete();
41
- }
24
+ canParse(file, control) {
25
+ return execute(client, { operation: "canParse", file }, control);
42
26
  },
43
-
44
- async query(file: string, queryString: string): Promise<TreeSitterResult<QueryCapture[]>> {
45
- return runtime.queryFile(file, queryString);
27
+ query(file, query, control) {
28
+ return execute<QueryCapture[]>(client, { operation: "query", file, query }, control);
46
29
  },
47
-
48
- async outline(file: string): Promise<TreeSitterResult<OutlineItem[]>> {
49
- const grammarId = detectGrammar(file);
50
- if (grammarId && !supportsGrammarOperation(grammarId, "outline")) {
51
- return {
52
- kind: "unsupported-language",
53
- file,
54
- message: `outline is not supported for ${grammarId} files`,
55
- };
56
- }
57
- const parseResult = await runtime.parseFile(file);
58
- if (parseResult.kind !== "success") return parseResult;
59
- const { tree, source } = parseResult.data;
60
- try {
61
- const items = extractOutline(tree.rootNode, source);
62
- return { kind: "success", data: items };
63
- } finally {
64
- tree.delete();
65
- }
30
+ outline(file, control) {
31
+ return execute<OutlineItem[]>(client, { operation: "outline", file }, control);
66
32
  },
67
-
68
- async imports(file: string): Promise<TreeSitterResult<ImportRecord[]>> {
69
- const grammarId = detectGrammar(file);
70
- if (grammarId && !supportsGrammarOperation(grammarId, "imports")) {
71
- return {
72
- kind: "unsupported-language",
73
- file,
74
- message: `imports is not supported for ${grammarId} files`,
75
- };
76
- }
77
- return extractImports(runtime, file);
33
+ imports(file, control) {
34
+ return execute<ImportRecord[]>(client, { operation: "imports", file }, control);
78
35
  },
79
-
80
- async exports(file: string): Promise<TreeSitterResult<ExportRecord[]>> {
81
- const grammarId = detectGrammar(file);
82
- if (grammarId && !supportsGrammarOperation(grammarId, "exports")) {
83
- return {
84
- kind: "unsupported-language",
85
- file,
86
- message: `exports is not supported for ${grammarId} files`,
87
- };
88
- }
89
- return extractExports(runtime, file);
36
+ exports(file, control) {
37
+ return execute<ExportRecord[]>(client, { operation: "exports", file }, control);
90
38
  },
91
-
92
- async nodeAt(
93
- file: string,
94
- line: number,
95
- character: number,
96
- ): Promise<TreeSitterResult<NodeAtResult>> {
97
- return lookupNodeAt(runtime, file, line, character);
39
+ nodeAt(file, line, character, control) {
40
+ return execute<NodeAtResult>(client, { operation: "nodeAt", file, line, character }, control);
98
41
  },
99
-
100
- async calleesAt(
101
- file: string,
102
- line: number,
103
- character: number,
104
- depth?: "direct" | "deep",
105
- ): Promise<TreeSitterResult<CalleesAtResult>> {
106
- return lookupCalleesAt(runtime, file, line, character, depth);
42
+ calleesAt(file, line, character, depthOrOptions) {
43
+ const depth = typeof depthOrOptions === "string" ? depthOrOptions : depthOrOptions?.depth;
44
+ const control = typeof depthOrOptions === "string" ? undefined : depthOrOptions?.control;
45
+ return execute<CalleesAtResult>(
46
+ client,
47
+ { operation: "calleesAt", file, line, character, depth },
48
+ control,
49
+ );
107
50
  },
108
-
109
- async callSites(file: string): Promise<TreeSitterResult<CallSiteMatch[]>> {
110
- return extractCallSites(runtime, file);
51
+ callSites(file, control) {
52
+ return execute<CallSiteMatch[]>(client, { operation: "callSites", file }, control);
111
53
  },
112
54
  };
113
55
  }
114
56
 
115
57
  /**
116
- * Create a new Tree-sitter session bound to the given working directory.
117
- * The session owns parser/grammar reuse and must be disposed when done.
58
+ * Create one Tree-sitter session bound to a working directory.
59
+ * Await disposal to prove that its Structural Worker has terminated.
118
60
  */
119
- export function createTreeSitterSession(cwd: string): TreeSitterSession {
120
- const runtime = new TreeSitterRuntime(cwd);
121
- const service = createTreeSitterService(runtime);
122
-
61
+ export function createTreeSitterSession(
62
+ cwd: string,
63
+ options: { readonly workerFactory?: StructuralWorkerFactory } = {},
64
+ ): TreeSitterSession {
65
+ const client = new StructuralWorkerClient(cwd, options.workerFactory);
66
+ const service = createTreeSitterService(client);
123
67
  return {
124
68
  ...service,
125
69
  dispose() {
126
- runtime.dispose();
70
+ return client.dispose();
127
71
  },
128
72
  };
129
73
  }
74
+
75
+ function execute<T>(
76
+ client: StructuralWorkerClient,
77
+ input: Parameters<StructuralWorkerClient["execute"]>[0],
78
+ control?: CodeRequestControl,
79
+ ): Promise<TreeSitterResult<T>> {
80
+ return control ? client.execute<T>(input, control) : client.execute<T>(input);
81
+ }
@@ -0,0 +1,147 @@
1
+ import { performance } from "node:perf_hooks";
2
+ import { recordDebugEvent, startDebugTimer } from "@mrclrchtr/supi-core/debug";
3
+ import type { StructuralCacheObservation } from "../worker/parsed-file-store.ts";
4
+
5
+ /** Plain sanitized event sent from the Structural Worker to the parent. */
6
+ export interface StructuralTimingEvent {
7
+ readonly operationId?: string;
8
+ readonly source: "tree-sitter";
9
+ readonly level: "debug";
10
+ readonly category: "structural.parse.timing" | "structural.query.timing";
11
+ readonly message: string;
12
+ readonly data: Readonly<Record<string, unknown>> & {
13
+ readonly timing: {
14
+ readonly durationMs: number;
15
+ readonly phasesMs: Readonly<Record<string, number>>;
16
+ };
17
+ };
18
+ }
19
+
20
+ interface StructuralTimer {
21
+ mark(phase: string): void;
22
+ finish(
23
+ event: Omit<StructuralTimingEvent, "data"> & { data: Record<string, unknown> },
24
+ finalPhase: string,
25
+ ): void;
26
+ }
27
+
28
+ export type ParserState = "cold" | "initializing" | "reused";
29
+ export type ParseTimingPhase =
30
+ | "cache-lookup"
31
+ | "content-hash"
32
+ | "file-read"
33
+ | "parse"
34
+ | "parser-setup";
35
+ export type QueryTimingPhase = "query-cache" | "query-compilation" | "query-execution";
36
+
37
+ export type StructuralTimingObservation =
38
+ | {
39
+ readonly operation: "parse";
40
+ readonly grammar: string;
41
+ readonly parserState: ParserState;
42
+ readonly outcome:
43
+ | "cancelled"
44
+ | "completed"
45
+ | "file-access-error"
46
+ | "runtime-error"
47
+ | "timeout";
48
+ readonly cache?: StructuralCacheObservation;
49
+ readonly finalPhase: ParseTimingPhase;
50
+ }
51
+ | {
52
+ readonly operation: "query";
53
+ readonly grammar: string;
54
+ readonly outcome:
55
+ | "cancelled"
56
+ | "completed"
57
+ | "runtime-error"
58
+ | "timeout"
59
+ | "validation-error";
60
+ readonly captureCount: number;
61
+ readonly cache: StructuralCacheObservation;
62
+ readonly finalPhase: QueryTimingPhase;
63
+ };
64
+
65
+ /** Start one failure-isolated Tree-sitter timing observation. */
66
+ export function startStructuralTiming(
67
+ operationId?: string,
68
+ forward?: (event: StructuralTimingEvent) => void,
69
+ ): StructuralTimer {
70
+ if (forward) return createForwardedTimer(operationId, forward);
71
+ const timer = startDebugTimer();
72
+ return {
73
+ mark(phase) {
74
+ timer.mark(phase);
75
+ },
76
+ finish(event, finalPhase) {
77
+ timer.finish({ ...event, operationId }, finalPhase);
78
+ },
79
+ };
80
+ }
81
+
82
+ /** Finish one sanitized Tree-sitter timing observation. */
83
+ export function finishStructuralTiming(
84
+ timer: StructuralTimer,
85
+ observation: StructuralTimingObservation,
86
+ ): void {
87
+ const { finalPhase, ...data } = observation;
88
+ timer.finish(
89
+ {
90
+ source: "tree-sitter",
91
+ level: "debug",
92
+ category: `structural.${data.operation}.timing`,
93
+ message: `Tree-sitter ${data.operation} ${data.outcome}`,
94
+ data: { ...data },
95
+ },
96
+ finalPhase,
97
+ );
98
+ }
99
+
100
+ /** Publish one validated Worker timing event into the parent Debug Registry. */
101
+ export function publishStructuralTimingEvent(event: StructuralTimingEvent): void {
102
+ recordDebugEvent(event);
103
+ }
104
+
105
+ function createForwardedTimer(
106
+ operationId: string | undefined,
107
+ forward: (event: StructuralTimingEvent) => void,
108
+ ): StructuralTimer {
109
+ const startedAt = performance.now();
110
+ let previousAt = startedAt;
111
+ let finished = false;
112
+ const phases = new Map<string, number>();
113
+
114
+ const mark = (phase: string, current: number) => {
115
+ phases.set(phase, (phases.get(phase) ?? 0) + Math.max(0, current - previousAt));
116
+ previousAt = current;
117
+ };
118
+
119
+ return {
120
+ mark(phase) {
121
+ if (!finished) mark(phase, performance.now());
122
+ },
123
+ finish(event, finalPhase) {
124
+ if (finished) return;
125
+ finished = true;
126
+ const completedAt = performance.now();
127
+ mark(finalPhase, completedAt);
128
+ forward({
129
+ ...event,
130
+ ...(operationId ? { operationId } : {}),
131
+ data: {
132
+ ...event.data,
133
+ timing: {
134
+ durationMs: duration(completedAt - startedAt),
135
+ phasesMs: Object.fromEntries(
136
+ [...phases.entries()].map(([name, value]) => [name, duration(value)]),
137
+ ),
138
+ },
139
+ },
140
+ } as StructuralTimingEvent);
141
+ },
142
+ };
143
+ }
144
+
145
+ function duration(value: number): number {
146
+ return Math.round(Math.max(0, value) * 10) / 10;
147
+ }
@@ -0,0 +1,39 @@
1
+ interface OwnedWorkerLike {
2
+ terminate(): Promise<number>;
3
+ }
4
+
5
+ /** Serialize every Worker start, termination, and restart ownership transition. */
6
+ export class StructuralWorkerLifecycle {
7
+ #transition = Promise.resolve();
8
+ #generation = 0;
9
+
10
+ /** Run one transition after every older transition settles. */
11
+ run<T>(operation: () => Promise<T>): Promise<T> {
12
+ const generation = this.#generation;
13
+ const current = this.#transition.then(
14
+ () => this.#runIfCurrent(generation, operation),
15
+ () => this.#runIfCurrent(generation, operation),
16
+ );
17
+ this.#transition = current.then(
18
+ () => undefined,
19
+ () => undefined,
20
+ );
21
+ return current;
22
+ }
23
+
24
+ /** Terminate one Worker as part of the serialized transition fence. */
25
+ async terminate(worker: OwnedWorkerLike | null): Promise<void> {
26
+ this.#generation += 1;
27
+ if (worker) await worker.terminate().catch(() => 0);
28
+ }
29
+
30
+ /** Await every transition admitted before this call. */
31
+ settled(): Promise<void> {
32
+ return this.#transition;
33
+ }
34
+
35
+ async #runIfCurrent<T>(generation: number, operation: () => Promise<T>): Promise<T> {
36
+ if (generation !== this.#generation) throw new Error("Structural Worker lifecycle superseded");
37
+ return operation();
38
+ }
39
+ }