@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,21 +1,35 @@
1
+ import type { CodeRequestControl } from "@mrclrchtr/supi-code-runtime/api";
1
2
  import { startDebugTimer } from "@mrclrchtr/supi-core/debug";
3
+ import { boundCwd, truncateIdentity } from "../debug-telemetry.ts";
2
4
 
3
- type DiagnosticCollection = "fallback" | "none" | "pull" | "push";
5
+ type DiagnosticCollection = "cache" | "fallback" | "none" | "pull" | "push";
4
6
  type DiagnosticFreshness = "not-observed" | "observed";
5
- type DiagnosticOutcome = "completed" | "skipped" | "timed-out";
7
+ type DiagnosticOutcome = "completed" | "incomplete" | "skipped" | "timed-out";
6
8
  type DiagnosticPullOutcome = "completed" | "failed" | "not-supported" | "not-used" | "timed-out";
7
- type DiagnosticPushOutcome = "not-used" | "published" | "released" | "settled" | "timed-out";
8
- type DiagnosticSettleOutcome = "not-used" | "published" | "quiet" | "released" | "timed-out";
9
+ type DiagnosticPushOutcome =
10
+ | "not-used"
11
+ | "published"
12
+ | "tentative"
13
+ | "released"
14
+ | "settled"
15
+ | "timed-out";
16
+ type DiagnosticSettleOutcome =
17
+ | "not-used"
18
+ | "published"
19
+ | "tentative"
20
+ | "quiet"
21
+ | "released"
22
+ | "timed-out";
9
23
  type DiagnosticTimingOperation = "refresh-open" | "sync-file";
10
24
 
11
25
  /** Result of waiting for a quiet push-diagnostic window. */
12
26
  export interface DiagnosticSettleResult {
13
- readonly outcome: "quiet" | "timed-out";
27
+ readonly outcome: "quiet" | "released" | "timed-out";
14
28
  readonly freshness: DiagnosticFreshness;
15
29
  }
16
30
 
17
31
  /** Result of waiting for one file's push diagnostics. */
18
- export type DiagnosticPushWaitOutcome = "published" | "released" | "timed-out";
32
+ export type DiagnosticPushWaitOutcome = "published" | "tentative" | "released" | "timed-out";
19
33
 
20
34
  interface DiagnosticTimingData {
21
35
  readonly collection: DiagnosticCollection;
@@ -25,30 +39,47 @@ interface DiagnosticTimingData {
25
39
  readonly outcome: DiagnosticOutcome;
26
40
  readonly pull: DiagnosticPullOutcome;
27
41
  readonly push: DiagnosticPushOutcome;
42
+ readonly reopen: number;
28
43
  readonly settle: DiagnosticSettleOutcome;
29
44
  readonly timedOut: boolean;
30
45
  }
31
46
 
32
- /** Internal pull failure that retains only whether a timeout occurred. */
47
+ /** Internal pull failure that retains timeout state and failed document URIs. */
33
48
  export class DiagnosticPullError extends Error {
34
- constructor(readonly timedOut: boolean) {
49
+ constructor(
50
+ readonly timedOut: boolean,
51
+ readonly failedUris: readonly string[] = [],
52
+ ) {
35
53
  super("pull diagnostics incomplete");
36
54
  }
37
55
  }
38
56
 
57
+ /** Bounded identity for one diagnostic timing observation. */
58
+ export interface DiagnosticTimingIdentity {
59
+ /** Configured server name. */
60
+ readonly server?: string;
61
+ /** Absolute workspace root. */
62
+ readonly cwd?: string;
63
+ /** Workspace-relative file path; sync-file operations only. */
64
+ readonly file?: string;
65
+ }
66
+
39
67
  /**
40
- * Record one diagnostic operation without document identifiers or diagnostic text.
68
+ * Record one diagnostic operation without diagnostic text or document content.
41
69
  *
42
70
  * The observer owns result classification so diagnostic control flow does not
43
- * duplicate the event shape.
71
+ * duplicate the event shape. Identity is bounded and workspace-relative.
44
72
  */
45
73
  export class DiagnosticObserver {
46
74
  readonly #timer = startDebugTimer();
47
75
  #pull: "failed" | "not-supported" | "timed-out";
76
+ #reopened = 0;
48
77
 
49
78
  constructor(
50
79
  readonly operation: DiagnosticTimingOperation,
51
80
  readonly supportsPull: boolean,
81
+ readonly control?: CodeRequestControl,
82
+ readonly identity?: DiagnosticTimingIdentity,
52
83
  ) {
53
84
  this.#pull = supportsPull ? "failed" : "not-supported";
54
85
  }
@@ -66,6 +97,22 @@ export class DiagnosticObserver {
66
97
  outcome: "skipped",
67
98
  pull: "not-used",
68
99
  push: "not-used",
100
+ reopen: 0,
101
+ settle: "not-used",
102
+ timedOut: false,
103
+ });
104
+ }
105
+
106
+ cacheReused(documentCount: number): void {
107
+ this.#finish({
108
+ collection: "cache",
109
+ documentCount,
110
+ fallback: false,
111
+ freshness: "observed",
112
+ outcome: "completed",
113
+ pull: "not-used",
114
+ push: "not-used",
115
+ reopen: 0,
69
116
  settle: "not-used",
70
117
  timedOut: false,
71
118
  });
@@ -81,6 +128,7 @@ export class DiagnosticObserver {
81
128
  outcome: "completed",
82
129
  pull: "completed",
83
130
  push: "not-used",
131
+ reopen: 0,
84
132
  settle: "not-used",
85
133
  timedOut: false,
86
134
  },
@@ -98,17 +146,30 @@ export class DiagnosticObserver {
98
146
  this.#timer.mark("pull");
99
147
  }
100
148
 
149
+ /**
150
+ * Record that the reopen-resync fallback re-opened unconfirmed documents.
151
+ *
152
+ * The mark fires when the second settle window starts, so the measured
153
+ * phase is the preceding first settle window, not the reopen work.
154
+ */
155
+ reopened(count: number): void {
156
+ this.#reopened += count;
157
+ this.#timer.mark("first-settle");
158
+ }
159
+
101
160
  pushSettled(documentCount: number, settle: DiagnosticSettleResult): void {
102
161
  const timedOut = settle.outcome === "timed-out";
162
+ const completed = settle.outcome === "quiet" && settle.freshness === "observed";
103
163
  this.#finish(
104
164
  {
105
165
  collection: this.supportsPull ? "fallback" : "push",
106
166
  documentCount,
107
167
  fallback: this.supportsPull,
108
168
  freshness: settle.freshness,
109
- outcome: timedOut ? "timed-out" : "completed",
169
+ outcome: completed ? "completed" : timedOut ? "timed-out" : "incomplete",
110
170
  pull: this.#pull,
111
- push: timedOut ? "timed-out" : "settled",
171
+ push: timedOut ? "timed-out" : settle.outcome === "released" ? "released" : "settled",
172
+ reopen: this.#reopened,
112
173
  settle: settle.outcome,
113
174
  timedOut: timedOut || this.#pull === "timed-out",
114
175
  },
@@ -117,16 +178,21 @@ export class DiagnosticObserver {
117
178
  }
118
179
 
119
180
  pushWaitCompleted(documentCount: number, push: DiagnosticPushWaitOutcome): void {
120
- const timedOut = push === "timed-out";
181
+ const confirmed = push === "published";
182
+ // A tentative result used the full wait budget without a confirming
183
+ // republish. Keep its distinct push value and report the budget expiry.
184
+ const timedOut = push === "tentative" || push === "timed-out";
185
+ const observed = push === "published" || push === "tentative";
121
186
  this.#finish(
122
187
  {
123
188
  collection: this.supportsPull ? "fallback" : "push",
124
189
  documentCount,
125
190
  fallback: this.supportsPull,
126
- freshness: push === "published" ? "observed" : "not-observed",
127
- outcome: timedOut ? "timed-out" : "completed",
191
+ freshness: observed ? "observed" : "not-observed",
192
+ outcome: confirmed ? "completed" : timedOut ? "timed-out" : "incomplete",
128
193
  pull: this.#pull,
129
194
  push,
195
+ reopen: this.#reopened,
130
196
  settle: push,
131
197
  timedOut: timedOut || this.#pull === "timed-out",
132
198
  },
@@ -135,13 +201,28 @@ export class DiagnosticObserver {
135
201
  }
136
202
 
137
203
  #finish(data: DiagnosticTimingData, finalPhase?: "pull" | "push-settle" | "synchronize"): void {
204
+ const { reopen, ...observation } = data;
138
205
  this.#timer.finish(
139
206
  () => ({
207
+ operationId: this.control?.operationId,
140
208
  source: "lsp",
141
209
  level: "debug",
142
210
  category: "diagnostics.timing",
143
211
  message: `LSP diagnostic ${this.operation} ${data.outcome}`,
144
- data: { operation: this.operation, ...data },
212
+ cwd: boundCwd(this.identity?.cwd),
213
+ data: {
214
+ operation: this.operation,
215
+ ...observation,
216
+ // Reopen fallback usage is recorded only when it happened; the
217
+ // default event shape stays stable for consumers of #322 telemetry.
218
+ ...(reopen > 0 ? { reopen } : {}),
219
+ ...(this.identity?.server !== undefined
220
+ ? { server: truncateIdentity(this.identity.server) }
221
+ : {}),
222
+ ...(this.identity?.file !== undefined
223
+ ? { file: truncateIdentity(this.identity.file) }
224
+ : {}),
225
+ },
145
226
  }),
146
227
  finalPhase,
147
228
  );
@@ -0,0 +1,206 @@
1
+ import {
2
+ type CodeRequestControl,
3
+ CodeRequestDeadlineError,
4
+ throwIfCodeRequestInterrupted,
5
+ } from "@mrclrchtr/supi-code-runtime/api";
6
+ import type {
7
+ DiagnosticPushWaitOutcome,
8
+ DiagnosticSettleResult,
9
+ } from "./client-diagnostic-timing.ts";
10
+
11
+ type DiagnosticWaiter = (outcome: "published" | "released") => void;
12
+
13
+ /** One cancellable wait for diagnostic state change. */
14
+ export interface DiagnosticStateWait {
15
+ readonly promise: Promise<void>;
16
+ cancel(): void;
17
+ }
18
+
19
+ interface DiagnosticSettleOptions {
20
+ readonly syncStart: number;
21
+ readonly maxWaitMs: number;
22
+ readonly quietMs: number;
23
+ readonly settleEpoch: number;
24
+ readonly isComplete: () => boolean;
25
+ readonly latestReceived: () => number;
26
+ }
27
+
28
+ /** Own diagnostic waiters and their timers for one LSP client. */
29
+ export class DiagnosticWaitRegistry {
30
+ readonly #pushWaiters = new Map<string, DiagnosticWaiter[]>();
31
+ readonly #stateWaiters = new Set<() => void>();
32
+ readonly #settleWaiters = new Set<() => void>();
33
+ #settleEpoch = 0;
34
+
35
+ get settleEpoch(): number {
36
+ return this.#settleEpoch;
37
+ }
38
+
39
+ /** Wait for a diagnostic publication or a lifecycle release for one URI. */
40
+ waitForPush(
41
+ uri: string,
42
+ timeoutMs: number,
43
+ control?: CodeRequestControl,
44
+ ): Promise<DiagnosticPushWaitOutcome> {
45
+ const deadlineRemaining =
46
+ control?.deadline === undefined ? undefined : control.deadline - Date.now();
47
+ const bindMs =
48
+ deadlineRemaining === undefined ? timeoutMs : Math.min(timeoutMs, deadlineRemaining);
49
+ if (control?.signal?.aborted) {
50
+ return Promise.reject(control.signal.reason ?? new Error("Diagnostic push wait cancelled"));
51
+ }
52
+ if (bindMs <= 0) {
53
+ if (deadlineRemaining !== undefined && deadlineRemaining < timeoutMs) {
54
+ return Promise.reject(new CodeRequestDeadlineError());
55
+ }
56
+ return Promise.resolve("timed-out");
57
+ }
58
+
59
+ return new Promise<DiagnosticPushWaitOutcome>((resolve, reject) => {
60
+ const cleanup = () => {
61
+ clearTimeout(timer);
62
+ if (abortHandler) control?.signal?.removeEventListener("abort", abortHandler);
63
+ };
64
+ const waiter: DiagnosticWaiter = (outcome) => {
65
+ cleanup();
66
+ this.#removePushWaiter(uri, waiter);
67
+ resolve(outcome);
68
+ };
69
+ const timer = setTimeout(() => {
70
+ this.#removePushWaiter(uri, waiter);
71
+ cleanup();
72
+ if (deadlineRemaining !== undefined && deadlineRemaining < timeoutMs) {
73
+ reject(new CodeRequestDeadlineError());
74
+ } else {
75
+ resolve("timed-out");
76
+ }
77
+ }, bindMs);
78
+ let abortHandler: (() => void) | undefined;
79
+ abortHandler = () => {
80
+ cleanup();
81
+ this.#removePushWaiter(uri, waiter);
82
+ reject(control?.signal?.reason ?? new Error("Diagnostic push wait cancelled"));
83
+ };
84
+ if (control?.signal?.aborted) abortHandler();
85
+ else control?.signal?.addEventListener("abort", abortHandler, { once: true });
86
+ const waiters = this.#pushWaiters.get(uri) ?? [];
87
+ waiters.push(waiter);
88
+ this.#pushWaiters.set(uri, waiters);
89
+ });
90
+ }
91
+
92
+ /** Wait until any diagnostic or lifecycle state changes. */
93
+ waitForChange(): DiagnosticStateWait {
94
+ let finish = () => {};
95
+ const promise = new Promise<void>((resolve) => {
96
+ finish = () => {
97
+ this.#stateWaiters.delete(finish);
98
+ resolve();
99
+ };
100
+ this.#stateWaiters.add(finish);
101
+ });
102
+ return { promise, cancel: finish };
103
+ }
104
+
105
+ /** Release pending push waiters for one URI. */
106
+ releaseFile(uri: string, outcome: "published" | "released" = "released"): void {
107
+ const waiters = this.#pushWaiters.get(uri);
108
+ if (waiters) {
109
+ this.#pushWaiters.delete(uri);
110
+ for (const waiter of waiters) waiter(outcome);
111
+ }
112
+ this.#notifyStateWaiters();
113
+ }
114
+
115
+ /** Release all pending push waiters. */
116
+ releaseAll(): void {
117
+ for (const uri of Array.from(this.#pushWaiters.keys())) this.releaseFile(uri);
118
+ }
119
+
120
+ /** Cancel the active settle generation and release its timers. */
121
+ cancelSettle(): void {
122
+ this.#settleEpoch++;
123
+ this.notifySettle();
124
+ }
125
+
126
+ /** Notify settle operations that diagnostic state changed. */
127
+ notifySettle(): void {
128
+ for (const release of Array.from(this.#settleWaiters)) release();
129
+ this.#notifyStateWaiters();
130
+ }
131
+
132
+ /** Wait for fresh diagnostic state to become quiet or reach its deadline. */
133
+ async waitForSettle(
134
+ options: DiagnosticSettleOptions,
135
+ control?: CodeRequestControl,
136
+ ): Promise<DiagnosticSettleResult> {
137
+ const { syncStart, maxWaitMs, quietMs, settleEpoch, isComplete, latestReceived } = options;
138
+ const deadlineRemaining =
139
+ control?.deadline === undefined ? undefined : control.deadline - Date.now();
140
+ const deadline =
141
+ deadlineRemaining === undefined
142
+ ? syncStart + maxWaitMs
143
+ : Math.min(syncStart + maxWaitMs, control?.deadline ?? syncStart + maxWaitMs);
144
+ while (Date.now() < deadline) {
145
+ throwIfCodeRequestInterrupted(control);
146
+ if (this.#settleEpoch !== settleEpoch) {
147
+ return { outcome: "released", freshness: "not-observed" };
148
+ }
149
+ const observedAt = latestReceived();
150
+ const elapsed = Date.now() - observedAt;
151
+ const complete = isComplete();
152
+ if (observedAt > 0 && complete && elapsed >= quietMs) {
153
+ return { outcome: "quiet", freshness: "observed" };
154
+ }
155
+ const waitMs =
156
+ observedAt > 0 && complete
157
+ ? Math.min(quietMs - elapsed, deadline - Date.now())
158
+ : deadline - Date.now();
159
+ await this.#waitForStateChange(waitMs, control);
160
+ }
161
+ // A bound absolute deadline makes the settle outcome a deadline
162
+ // interruption instead of an ordinary relative timeout.
163
+ throwIfCodeRequestInterrupted(control);
164
+ return {
165
+ outcome: "timed-out",
166
+ freshness: latestReceived() > 0 ? "observed" : "not-observed",
167
+ };
168
+ }
169
+
170
+ /** Wait until diagnostic state changes or the timeout expires. */
171
+ #waitForStateChange(timeoutMs: number, control?: CodeRequestControl): Promise<void> {
172
+ if (timeoutMs <= 0) return Promise.resolve();
173
+ if (control?.signal?.aborted) {
174
+ return Promise.reject(control.signal.reason ?? new Error("Settle wait cancelled"));
175
+ }
176
+ return new Promise((resolve, reject) => {
177
+ let abortHandler: (() => void) | undefined;
178
+ const finish = () => {
179
+ clearTimeout(timer);
180
+ if (abortHandler) control?.signal?.removeEventListener("abort", abortHandler);
181
+ this.#settleWaiters.delete(finish);
182
+ resolve();
183
+ };
184
+ const timer = setTimeout(finish, timeoutMs);
185
+ abortHandler = () => {
186
+ clearTimeout(timer);
187
+ this.#settleWaiters.delete(finish);
188
+ reject(control?.signal?.reason ?? new Error("Settle wait cancelled"));
189
+ };
190
+ control?.signal?.addEventListener("abort", abortHandler, { once: true });
191
+ this.#settleWaiters.add(finish);
192
+ });
193
+ }
194
+
195
+ #notifyStateWaiters(): void {
196
+ for (const release of Array.from(this.#stateWaiters)) release();
197
+ }
198
+
199
+ #removePushWaiter(uri: string, waiter: DiagnosticWaiter): void {
200
+ const waiters = this.#pushWaiters.get(uri);
201
+ if (!waiters) return;
202
+ const next = waiters.filter((entry) => entry !== waiter);
203
+ if (next.length > 0) this.#pushWaiters.set(uri, next);
204
+ else this.#pushWaiters.delete(uri);
205
+ }
206
+ }