@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
@@ -3,16 +3,22 @@
3
3
  // and notification/request dispatching through vscode-jsonrpc's MessageConnection.
4
4
 
5
5
  import type { Readable, Writable } from "node:stream";
6
+ import {
7
+ type CodeRequestControl,
8
+ CodeRequestDeadlineError,
9
+ } from "@mrclrchtr/supi-code-runtime/api";
6
10
  import { startDebugTimer } from "@mrclrchtr/supi-core/debug";
7
11
  import {
8
12
  CancellationTokenSource,
9
13
  createMessageConnection,
14
+ ErrorCodes,
10
15
  type MessageConnection,
11
16
  NullLogger,
12
17
  ResponseError,
13
18
  StreamMessageReader,
14
19
  StreamMessageWriter,
15
20
  } from "vscode-jsonrpc/node";
21
+ import { boundCwd, LSP_REQUEST_TIMEOUT_ERROR_CODE, truncateIdentity } from "../debug-telemetry.ts";
16
22
 
17
23
  const DEFAULT_TIMEOUT_MS = 30_000;
18
24
 
@@ -37,13 +43,19 @@ export class JsonRpcClient {
37
43
  private requestHandler: RequestHandler | null = null;
38
44
  private closed = false;
39
45
  private readonly timeoutMs: number;
46
+ private readonly server: string | undefined;
47
+ private readonly cwd: string | undefined;
48
+ /** Failures that signal a stalled protocol: repeated errors and local timeouts. */
49
+ private protocolFailureCount = 0;
40
50
 
41
51
  constructor(
42
52
  private readonly input: Readable,
43
53
  private readonly output: Writable,
44
- options?: { timeoutMs?: number },
54
+ options?: { timeoutMs?: number; server?: string; cwd?: string },
45
55
  ) {
46
56
  this.timeoutMs = options?.timeoutMs ?? DEFAULT_TIMEOUT_MS;
57
+ this.server = options?.server;
58
+ this.cwd = options?.cwd;
47
59
 
48
60
  const reader = new StreamMessageReader(this.input);
49
61
  const writer = new StreamMessageWriter(this.output);
@@ -55,6 +67,13 @@ export class JsonRpcClient {
55
67
  this.notificationHandler?.(method, params);
56
68
  });
57
69
 
70
+ // vscode-jsonrpc registers an internal $/progress handler that never
71
+ // reaches the catch-all handler. Route it explicitly so LSP progress
72
+ // notifications reach the client's readiness state machine.
73
+ this.connection.onNotification("$/progress", (params) => {
74
+ this.notificationHandler?.("$/progress", params);
75
+ });
76
+
58
77
  // Register catch-all request handler for server-initiated requests
59
78
  this.connection.onRequest(async (method, params, _token) => {
60
79
  if (!this.requestHandler) {
@@ -85,26 +104,53 @@ export class JsonRpcClient {
85
104
  sendRequest(
86
105
  method: string,
87
106
  params?: unknown,
88
- options?: { timeoutMs?: number },
107
+ options?: { timeoutMs?: number } & CodeRequestControl,
89
108
  ): Promise<unknown> {
90
109
  const timeoutMs = options?.timeoutMs ?? this.timeoutMs;
110
+ const signal = options?.signal;
111
+ const deadlineMs = options?.deadline === undefined ? undefined : options.deadline - Date.now();
91
112
  const methodClass = classifyRequestMethod(method);
113
+ const boundedMethod = truncateIdentity(method);
92
114
  const timer = startDebugTimer();
115
+ // An expired absolute deadline must not even send the request: the caller
116
+ // no longer awaits a result, so no protocol traffic may start.
117
+ if (deadlineMs !== undefined && deadlineMs <= 0) {
118
+ recordRequestTiming(
119
+ timer,
120
+ options?.operationId,
121
+ {
122
+ method: boundedMethod,
123
+ methodClass,
124
+ outcome: "timed-out",
125
+ errorCode: LSP_REQUEST_TIMEOUT_ERROR_CODE,
126
+ },
127
+ { server: this.server, cwd: this.cwd },
128
+ );
129
+ return Promise.reject(new CodeRequestDeadlineError());
130
+ }
93
131
  if (this.closed || !this.connection) {
94
- recordRequestTiming(timer, {
95
- methodClass,
96
- outcome: "cancelled",
97
- timeoutMs,
98
- timedOut: false,
99
- cancelled: true,
100
- });
132
+ recordRequestTiming(
133
+ timer,
134
+ options?.operationId,
135
+ {
136
+ method: boundedMethod,
137
+ methodClass,
138
+ outcome: "cancelled",
139
+ },
140
+ { server: this.server, cwd: this.cwd },
141
+ );
101
142
  return Promise.reject(new Error("JSON-RPC client is closed"));
102
143
  }
103
-
104
144
  const tokenSource = new CancellationTokenSource();
105
145
  let timeout: ReturnType<typeof setTimeout> | undefined;
106
146
  let timedOut = false;
107
- const timeoutError = new Error(`Request ${method} timed out after ${timeoutMs}ms`);
147
+ let aborted = false;
148
+ const timerDelayMs = deadlineMs === undefined ? timeoutMs : Math.min(timeoutMs, deadlineMs);
149
+ const timeoutError = Object.assign(
150
+ new Error(`Request ${method} timed out after ${timerDelayMs}ms`),
151
+ { code: LSP_REQUEST_TIMEOUT_ERROR_CODE },
152
+ );
153
+ const abortError = new Error(`Request ${method} was cancelled`);
108
154
 
109
155
  const request = this.connection.sendRequest(method, params, tokenSource.token);
110
156
  // Catch the raw request promise to prevent unhandled rejections when
@@ -115,46 +161,79 @@ export class JsonRpcClient {
115
161
  // the JSON-RPC token and rejects the caller. Using one timer avoids
116
162
  // a leak where the rejecting timer in a second Promise stays alive
117
163
  // after a successful response.
164
+ let abortHandler: (() => void) | undefined;
165
+ const abort = new Promise<never>((_resolve, reject) => {
166
+ abortHandler = () => {
167
+ aborted = true;
168
+ tokenSource.cancel();
169
+ // Reject with the caller's abort reason when one exists, matching the
170
+ // canonical throwIfCodeRequestInterrupted() behavior.
171
+ reject(signal?.reason ?? abortError);
172
+ };
173
+ if (signal?.aborted) abortHandler();
174
+ else signal?.addEventListener("abort", abortHandler, { once: true });
175
+ });
118
176
  const promise = Promise.race([
119
177
  request,
120
178
  new Promise<never>((_resolve, reject) => {
121
179
  timeout = setTimeout(() => {
122
180
  timedOut = true;
123
181
  tokenSource.cancel();
124
- reject(timeoutError);
125
- }, timeoutMs);
182
+ // A deadline that binds earlier than the timeout is a deadline
183
+ // outcome, distinct from an ordinary per-request timeout.
184
+ reject(
185
+ deadlineMs !== undefined && deadlineMs < timeoutMs
186
+ ? new CodeRequestDeadlineError()
187
+ : timeoutError,
188
+ );
189
+ }, timerDelayMs);
126
190
  }),
191
+ abort,
127
192
  ])
128
193
  .then(
129
194
  (result) => {
130
- recordRequestTiming(timer, {
131
- methodClass,
132
- outcome: "completed",
133
- timeoutMs,
134
- timedOut: false,
135
- cancelled: false,
136
- });
195
+ recordRequestTiming(
196
+ timer,
197
+ options?.operationId,
198
+ {
199
+ method: boundedMethod,
200
+ methodClass,
201
+ outcome: "completed",
202
+ },
203
+ { server: this.server, cwd: this.cwd },
204
+ );
137
205
  return result;
138
206
  },
139
207
  (error: unknown) => {
140
- const cancelled = timedOut || this.closed || isCancellationError(error);
208
+ const cancelled = timedOut || aborted || this.closed || isCancellationError(error);
141
209
  const outcome: RequestOutcome = timedOut
142
210
  ? "timed-out"
143
211
  : cancelled
144
212
  ? "cancelled"
145
213
  : "failed";
146
- recordRequestTiming(timer, {
147
- methodClass,
148
- outcome,
149
- timeoutMs,
150
- timedOut,
151
- cancelled,
152
- });
214
+ const errorCode = requestErrorCode(outcome, error);
215
+ this.countProtocolStallFailure(outcome, errorCode, error);
216
+ recordRequestTiming(
217
+ timer,
218
+ options?.operationId,
219
+ {
220
+ method: boundedMethod,
221
+ methodClass,
222
+ outcome,
223
+ // Failed requests record the server-reported JSON-RPC error code
224
+ // when the error carries one; timed-out requests record the
225
+ // defined timeout code (also for deadline expiries, whose error
226
+ // carries none); cancellations carry no error code.
227
+ errorCode,
228
+ },
229
+ { server: this.server, cwd: this.cwd },
230
+ );
153
231
  throw error;
154
232
  },
155
233
  )
156
234
  .finally(() => {
157
235
  if (timeout !== undefined) clearTimeout(timeout);
236
+ if (abortHandler) signal?.removeEventListener("abort", abortHandler);
158
237
  });
159
238
 
160
239
  // Prevent unhandled rejection when dispose() cancels requests
@@ -184,6 +263,30 @@ export class JsonRpcClient {
184
263
  this.connection = null;
185
264
  }
186
265
  }
266
+
267
+ /**
268
+ * Count one protocol-stall failure: a local timeout (not a caller-imposed
269
+ * deadline expiry) or a repeated server-reported protocol error. A deadline
270
+ * expiry is not a stall: the request may be perfectly healthy (ADR 0020).
271
+ */
272
+ private countProtocolStallFailure(
273
+ outcome: RequestOutcome,
274
+ errorCode: number | undefined,
275
+ error: unknown,
276
+ ): void {
277
+ if (
278
+ (outcome === "timed-out" && !(error instanceof CodeRequestDeadlineError)) ||
279
+ errorCode === ErrorCodes.ServerNotInitialized ||
280
+ errorCode === ErrorCodes.InvalidRequest
281
+ ) {
282
+ this.protocolFailureCount++;
283
+ }
284
+ }
285
+
286
+ /** Number of protocol-stall failures observed on this connection. */
287
+ getProtocolFailureCount(): number {
288
+ return this.protocolFailureCount;
289
+ }
187
290
  }
188
291
 
189
292
  const SEMANTIC_REQUESTS = new Set([
@@ -218,25 +321,50 @@ function isCancellationError(error: unknown): boolean {
218
321
  );
219
322
  }
220
323
 
324
+ /** One bounded request-timing observation with exact method identity. */
221
325
  interface RequestTimingObservation {
326
+ readonly method: string;
222
327
  readonly methodClass: RequestMethodClass;
223
328
  readonly outcome: RequestOutcome;
224
- readonly timeoutMs: number;
225
- readonly timedOut: boolean;
226
- readonly cancelled: boolean;
329
+ /** JSON-RPC error code reported by the server for a failed request. */
330
+ readonly errorCode?: number;
331
+ }
332
+
333
+ /** Return the JSON-RPC error code for one request outcome. */
334
+ function requestErrorCode(outcome: RequestOutcome, error: unknown): number | undefined {
335
+ if (outcome === "failed") return jsonRpcErrorCode(error);
336
+ if (outcome === "timed-out") return jsonRpcErrorCode(error) ?? LSP_REQUEST_TIMEOUT_ERROR_CODE;
337
+ return undefined;
338
+ }
339
+
340
+ /** Return the numeric JSON-RPC error code carried by an error, if any. */
341
+ function jsonRpcErrorCode(error: unknown): number | undefined {
342
+ if (typeof error !== "object" || error === null) return undefined;
343
+ const code = (error as { code?: unknown }).code;
344
+ return typeof code === "number" && Number.isInteger(code) ? code : undefined;
227
345
  }
228
346
 
229
347
  function recordRequestTiming(
230
348
  timer: ReturnType<typeof startDebugTimer>,
349
+ operationId: string | undefined,
231
350
  observation: RequestTimingObservation,
351
+ identity: { server?: string; cwd?: string },
232
352
  ): void {
233
353
  timer.finish(
234
354
  () => ({
355
+ operationId,
235
356
  source: "lsp",
236
357
  level: "debug",
237
358
  category: "request.timing",
238
- message: `LSP ${observation.methodClass} request ${observation.outcome}`,
239
- data: { ...observation },
359
+ message: `LSP ${observation.methodClass} request ${observation.outcome} for ${observation.method}`,
360
+ cwd: boundCwd(identity.cwd),
361
+ data: {
362
+ method: observation.method,
363
+ methodClass: observation.methodClass,
364
+ outcome: observation.outcome,
365
+ ...(identity.server !== undefined ? { server: truncateIdentity(identity.server) } : {}),
366
+ ...(observation.errorCode !== undefined ? { errorCode: observation.errorCode } : {}),
367
+ },
240
368
  }),
241
369
  "request",
242
370
  );
@@ -3,6 +3,9 @@
3
3
  import type { ClientCapabilities } from "./types.ts";
4
4
 
5
5
  export const CLIENT_CAPABILITIES: ClientCapabilities = {
6
+ general: {
7
+ positionEncodings: ["utf-16"],
8
+ },
6
9
  textDocument: {
7
10
  synchronization: {
8
11
  didSave: true,
@@ -49,7 +52,10 @@ export const CLIENT_CAPABILITIES: ClientCapabilities = {
49
52
  versionSupport: true,
50
53
  },
51
54
  diagnostic: {
52
- dynamicRegistration: false,
55
+ // Dynamic registration lets servers such as pyright-langserver register
56
+ // `textDocument/diagnostic` support after initialization. Probes show
57
+ // only Pyright acts on this global flag among the built-in servers.
58
+ dynamicRegistration: true,
53
59
  relatedDocumentSupport: true,
54
60
  },
55
61
  },
@@ -57,9 +63,12 @@ export const CLIENT_CAPABILITIES: ClientCapabilities = {
57
63
  workDoneProgress: true,
58
64
  },
59
65
  workspace: {
60
- workspaceFolders: false,
66
+ workspaceFolders: true,
67
+ workspaceEdit: {
68
+ documentChanges: true,
69
+ },
61
70
  diagnostics: {
62
- refreshSupport: false,
71
+ refreshSupport: true,
63
72
  },
64
73
  },
65
74
  };
@@ -125,15 +125,15 @@ function mergeSingleServer(
125
125
  override: Partial<ServerConfig>,
126
126
  ): ServerConfig | null {
127
127
  if (!base) {
128
- // New custom language must have all required fields
128
+ // A custom server needs a command and at least one file extension.
129
129
  if (
130
- override.command &&
130
+ typeof override.command === "string" &&
131
+ override.command.length > 0 &&
131
132
  Array.isArray(override.fileTypes) &&
132
133
  override.fileTypes.length > 0 &&
133
- Array.isArray(override.rootMarkers) &&
134
- override.rootMarkers.length > 0
134
+ (override.rootMarkers === undefined || Array.isArray(override.rootMarkers))
135
135
  ) {
136
- return override as ServerConfig;
136
+ return { ...override, rootMarkers: override.rootMarkers ?? [] } as ServerConfig;
137
137
  }
138
138
  return null;
139
139
  }
@@ -50,7 +50,7 @@
50
50
  },
51
51
  "kotlin": {
52
52
  "command": "kotlin-lsp",
53
- "args": [],
53
+ "args": ["--stdio"],
54
54
  "fileTypes": ["kt", "kts"],
55
55
  "rootMarkers": ["build.gradle.kts", "pom.xml"]
56
56
  },
@@ -5,8 +5,11 @@ export interface ServerConfig {
5
5
  command: string;
6
6
  args?: string[];
7
7
  fileTypes: string[];
8
+ /** Files that identify the project root. An empty list uses the session root. */
8
9
  rootMarkers: string[];
9
10
  enabled?: boolean;
11
+ /** Environment values added when the server process starts. */
12
+ env?: Record<string, string>;
10
13
  initializationOptions?: unknown;
11
14
  /** Maximum time to wait for a single $/progress cycle, in ms. Default: 10_000. */
12
15
  readinessTimeoutMs?: number;
@@ -0,0 +1,68 @@
1
+ import * as path from "node:path";
2
+ import ts from "typescript";
3
+ import { normalizeTsconfigPath as normalizePath } from "./tsconfig-path.ts";
4
+
5
+ /**
6
+ * Collect recognized local project configs declared by `extends`, including
7
+ * transitive dependencies and paths that do not exist yet.
8
+ */
9
+ export function collectExtendedProjectConfigs(configPath: string): Set<string> {
10
+ const dependencies = new Set<string>();
11
+ const visited = new Set<string>();
12
+
13
+ const visit = (currentConfigPath: string): void => {
14
+ const normalizedConfigPath = normalizePath(currentConfigPath);
15
+ if (visited.has(normalizedConfigPath)) return;
16
+ visited.add(normalizedConfigPath);
17
+
18
+ const config = ts.readConfigFile(currentConfigPath, ts.sys.readFile).config;
19
+ if (!config || typeof config !== "object") return;
20
+
21
+ const extendsValues =
22
+ typeof config.extends === "string"
23
+ ? [config.extends]
24
+ : Array.isArray(config.extends)
25
+ ? config.extends.filter((value: unknown): value is string => typeof value === "string")
26
+ : [];
27
+
28
+ for (const extendsValue of extendsValues) {
29
+ const extendedConfigPath = resolveLocalExtendedConfigPath(currentConfigPath, extendsValue);
30
+ if (!extendedConfigPath) continue;
31
+
32
+ const normalizedExtendedConfigPath = normalizePath(extendedConfigPath);
33
+ dependencies.add(normalizedExtendedConfigPath);
34
+ visit(extendedConfigPath);
35
+ }
36
+ };
37
+
38
+ visit(configPath);
39
+ return dependencies;
40
+ }
41
+
42
+ /**
43
+ * Resolve a local project-config extends entry.
44
+ *
45
+ * Package names are not local paths and are deliberately ignored. TypeScript
46
+ * uses the `.json` suffix for extensionless local config references. Only
47
+ * recognized project-config names are tracked; arbitrary local JSON files may
48
+ * still be parsed by TypeScript but are outside this invalidation contract.
49
+ */
50
+ function resolveLocalExtendedConfigPath(configPath: string, extendsValue: string): string | null {
51
+ if (!path.isAbsolute(extendsValue) && !/^\.{1,2}(?:[\\/]|$)/.test(extendsValue)) {
52
+ return null;
53
+ }
54
+
55
+ const resolved = path.resolve(path.dirname(configPath), extendsValue);
56
+ const candidate =
57
+ path.extname(resolved).toLowerCase() === ".json" ? resolved : `${resolved}.json`;
58
+ return isProjectConfigFileName(path.basename(candidate)) ? candidate : null;
59
+ }
60
+
61
+ /** Whether a file name is a tsconfig.json, jsconfig.json, or tsconfig.*.json name. */
62
+ export function isProjectConfigFileName(name: string): boolean {
63
+ return (
64
+ name === "tsconfig.json" ||
65
+ name === "jsconfig.json" ||
66
+ (name.startsWith("tsconfig.") && name.endsWith(".json"))
67
+ );
68
+ }
@@ -0,0 +1,8 @@
1
+ import * as path from "node:path";
2
+ import ts from "typescript";
3
+
4
+ /** Normalize a path for tsconfig cache keys and comparisons. */
5
+ export function normalizeTsconfigPath(target: string): string {
6
+ const resolved = path.resolve(target).replaceAll("\\", "/");
7
+ return ts.sys.useCaseSensitiveFileNames ? resolved : resolved.toLowerCase();
8
+ }