@mrclrchtr/supi-code-intelligence 11.4.0 → 13.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 (330) hide show
  1. package/CHANGELOG.md +39 -0
  2. package/README.md +17 -9
  3. package/node_modules/@mrclrchtr/supi-code-runtime/package.json +1 -1
  4. package/node_modules/@mrclrchtr/supi-code-runtime/src/api.ts +1 -0
  5. package/node_modules/@mrclrchtr/supi-code-runtime/src/types.ts +51 -23
  6. package/node_modules/@mrclrchtr/supi-core/package.json +3 -1
  7. package/node_modules/@mrclrchtr/supi-core/src/api.ts +4 -0
  8. package/node_modules/@mrclrchtr/supi-core/src/context/context-tag.ts +1 -1
  9. package/node_modules/@mrclrchtr/supi-core/src/debug-registry.ts +22 -3
  10. package/node_modules/@mrclrchtr/supi-core/src/retired-packages.ts +152 -0
  11. package/node_modules/@mrclrchtr/supi-core/src/session.ts +1 -0
  12. package/node_modules/@mrclrchtr/supi-core/src/shell-hints.ts +46 -0
  13. package/node_modules/@mrclrchtr/supi-core/src/spill.ts +93 -0
  14. package/node_modules/@mrclrchtr/supi-lsp/README.md +21 -16
  15. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-code-runtime/package.json +1 -1
  16. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-code-runtime/src/api.ts +1 -0
  17. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-code-runtime/src/types.ts +51 -23
  18. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-core/package.json +3 -1
  19. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-core/src/api.ts +4 -0
  20. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-core/src/context/context-tag.ts +1 -1
  21. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-core/src/debug-registry.ts +22 -3
  22. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-core/src/retired-packages.ts +152 -0
  23. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-core/src/session.ts +1 -0
  24. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-core/src/shell-hints.ts +46 -0
  25. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-core/src/spill.ts +93 -0
  26. package/node_modules/@mrclrchtr/supi-lsp/package.json +8 -8
  27. package/node_modules/@mrclrchtr/supi-lsp/src/api.ts +3 -2
  28. package/node_modules/@mrclrchtr/supi-lsp/src/client/client-diagnostic-cache.ts +102 -47
  29. package/node_modules/@mrclrchtr/supi-lsp/src/client/client-diagnostic-capabilities.ts +13 -3
  30. package/node_modules/@mrclrchtr/supi-lsp/src/client/client-diagnostic-host.ts +8 -0
  31. package/node_modules/@mrclrchtr/supi-lsp/src/client/client-diagnostic-refresh.ts +15 -1
  32. package/node_modules/@mrclrchtr/supi-lsp/src/client/client-diagnostic-request.ts +1 -1
  33. package/node_modules/@mrclrchtr/supi-lsp/src/client/client-diagnostics.ts +71 -13
  34. package/node_modules/@mrclrchtr/supi-lsp/src/client/client-disk-stamp.ts +60 -0
  35. package/node_modules/@mrclrchtr/supi-lsp/src/client/client-document-state.ts +3 -0
  36. package/node_modules/@mrclrchtr/supi-lsp/src/client/client-document-sync.ts +28 -6
  37. package/node_modules/@mrclrchtr/supi-lsp/src/client/client-edit-capture.ts +258 -0
  38. package/node_modules/@mrclrchtr/supi-lsp/src/client/client-file-state.ts +17 -3
  39. package/node_modules/@mrclrchtr/supi-lsp/src/client/client-semantic-input-barrier.ts +53 -4
  40. package/node_modules/@mrclrchtr/supi-lsp/src/client/client.ts +75 -14
  41. package/node_modules/@mrclrchtr/supi-lsp/src/config/capabilities.ts +8 -0
  42. package/node_modules/@mrclrchtr/supi-lsp/src/config/operation-support.ts +48 -79
  43. package/node_modules/@mrclrchtr/supi-lsp/src/config/tsconfig-extends.ts +2 -1
  44. package/node_modules/@mrclrchtr/supi-lsp/src/config/tsconfig-path.ts +2 -2
  45. package/node_modules/@mrclrchtr/supi-lsp/src/config/tsconfig-scope.ts +14 -5
  46. package/node_modules/@mrclrchtr/supi-lsp/src/config/typescript-module.ts +17 -0
  47. package/node_modules/@mrclrchtr/supi-lsp/src/diagnostics/evidence.ts +42 -0
  48. package/node_modules/@mrclrchtr/supi-lsp/src/manager/manager-client-state.ts +2 -17
  49. package/node_modules/@mrclrchtr/supi-lsp/src/manager/manager-removal-ledger.ts +52 -0
  50. package/node_modules/@mrclrchtr/supi-lsp/src/manager/manager.ts +43 -21
  51. package/node_modules/@mrclrchtr/supi-lsp/src/manager/typescript-file-local.ts +6 -1
  52. package/node_modules/@mrclrchtr/supi-lsp/src/provider/lsp-refactor-provider.ts +21 -35
  53. package/node_modules/@mrclrchtr/supi-lsp/src/provider/lsp-semantic-provider.ts +6 -1
  54. package/node_modules/@mrclrchtr/supi-lsp/src/provider/refactor-command-capture.ts +139 -0
  55. package/node_modules/@mrclrchtr/supi-lsp/src/provider/refactor-planning.ts +202 -47
  56. package/node_modules/@mrclrchtr/supi-lsp/src/provider/semantic-symbol-mapper.ts +13 -3
  57. package/node_modules/@mrclrchtr/supi-lsp/src/session/route-boundary.ts +26 -0
  58. package/node_modules/@mrclrchtr/supi-lsp/src/session/runtime-diagnostic-surface.ts +11 -0
  59. package/node_modules/@mrclrchtr/supi-lsp/src/session/runtime-diagnostics.ts +1 -0
  60. package/node_modules/@mrclrchtr/supi-lsp/src/session/runtime-registry.ts +74 -14
  61. package/node_modules/@mrclrchtr/supi-lsp/src/session/runtime-rename.ts +3 -0
  62. package/node_modules/@mrclrchtr/supi-lsp/src/session/runtime-transition-debug.ts +11 -1
  63. package/node_modules/@mrclrchtr/supi-lsp/src/session/workspace-lsp-runtime.ts +24 -1
  64. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/package.json +1 -1
  65. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/src/api.ts +1 -0
  66. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/src/types.ts +51 -23
  67. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/package.json +3 -1
  68. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/src/api.ts +4 -0
  69. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/src/context/context-tag.ts +1 -1
  70. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/src/debug-registry.ts +22 -3
  71. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/src/retired-packages.ts +152 -0
  72. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/src/session.ts +1 -0
  73. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/src/shell-hints.ts +46 -0
  74. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/src/spill.ts +93 -0
  75. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/web-tree-sitter/debug/web-tree-sitter.cjs +50 -75
  76. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/web-tree-sitter/debug/web-tree-sitter.cjs.map +2 -2
  77. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/web-tree-sitter/debug/web-tree-sitter.js +50 -75
  78. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/web-tree-sitter/debug/web-tree-sitter.js.map +2 -2
  79. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/web-tree-sitter/debug/web-tree-sitter.wasm +0 -0
  80. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/web-tree-sitter/debug/web-tree-sitter.wasm.map +6 -6
  81. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/web-tree-sitter/package.json +1 -1
  82. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/web-tree-sitter/web-tree-sitter.cjs +50 -75
  83. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/web-tree-sitter/web-tree-sitter.cjs.map +2 -2
  84. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/web-tree-sitter/web-tree-sitter.d.cts +7 -7
  85. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/web-tree-sitter/web-tree-sitter.d.cts.map +1 -1
  86. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/web-tree-sitter/web-tree-sitter.d.ts +7 -7
  87. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/web-tree-sitter/web-tree-sitter.d.ts.map +1 -1
  88. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/web-tree-sitter/web-tree-sitter.js +50 -75
  89. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/web-tree-sitter/web-tree-sitter.js.map +2 -2
  90. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/web-tree-sitter/web-tree-sitter.wasm +0 -0
  91. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/web-tree-sitter/web-tree-sitter.wasm.map +5 -5
  92. package/node_modules/@mrclrchtr/supi-tree-sitter/package.json +5 -5
  93. package/node_modules/@mrclrchtr/supi-tree-sitter/resources/grammars/kotlin/tree-sitter-kotlin.wasm.json +1 -1
  94. package/node_modules/@mrclrchtr/supi-tree-sitter/resources/grammars/latex/tree-sitter-latex.wasm.json +1 -1
  95. package/node_modules/@mrclrchtr/supi-tree-sitter/resources/grammars/sql/tree-sitter-sql.wasm.json +1 -1
  96. package/node_modules/@mrclrchtr/supi-tree-sitter/resources/grammars/tsx/tree-sitter-tsx.wasm.json +1 -1
  97. package/node_modules/@mrclrchtr/supi-tree-sitter/resources/grammars/typescript/tree-sitter-typescript.wasm.json +1 -1
  98. package/node_modules/@mrclrchtr/supi-tree-sitter/src/coordinates.ts +16 -2
  99. package/node_modules/@mrclrchtr/supi-tree-sitter/src/session/structural-worker-client.ts +4 -3
  100. package/node_modules/@mrclrchtr/supi-tree-sitter/src/syntax-errors.ts +2 -0
  101. package/node_modules/@mrclrchtr/supi-tree-sitter/src/tool/call-range.ts +94 -0
  102. package/node_modules/@mrclrchtr/supi-tree-sitter/src/tool/call-sites.ts +26 -6
  103. package/node_modules/@mrclrchtr/supi-tree-sitter/src/tool/callees.ts +6 -3
  104. package/node_modules/@mrclrchtr/supi-tree-sitter/src/tool/exports.ts +13 -4
  105. package/node_modules/@mrclrchtr/supi-tree-sitter/src/worker/runtime.ts +1 -9
  106. package/node_modules/fast-xml-parser/CHANGELOG.md +886 -0
  107. package/node_modules/fast-xml-parser/LICENSE +21 -0
  108. package/node_modules/fast-xml-parser/README.md +204 -0
  109. package/node_modules/fast-xml-parser/lib/fxbuilder.min.js +2 -0
  110. package/node_modules/fast-xml-parser/lib/fxbuilder.min.js.map +1 -0
  111. package/node_modules/fast-xml-parser/lib/fxp.cjs +1 -0
  112. package/node_modules/fast-xml-parser/lib/fxp.d.cts +774 -0
  113. package/node_modules/fast-xml-parser/lib/fxp.min.js +2 -0
  114. package/node_modules/fast-xml-parser/lib/fxp.min.js.map +1 -0
  115. package/node_modules/fast-xml-parser/lib/fxparser.min.js +2 -0
  116. package/node_modules/fast-xml-parser/lib/fxparser.min.js.map +1 -0
  117. package/node_modules/fast-xml-parser/lib/fxvalidator.min.js +2 -0
  118. package/node_modules/fast-xml-parser/lib/fxvalidator.min.js.map +1 -0
  119. package/node_modules/fast-xml-parser/node_modules/@nodable/entities/README.md +92 -0
  120. package/node_modules/fast-xml-parser/node_modules/@nodable/entities/package.json +57 -0
  121. package/node_modules/fast-xml-parser/node_modules/@nodable/entities/src/EntityDecoder.js +644 -0
  122. package/node_modules/fast-xml-parser/node_modules/@nodable/entities/src/EntityEncoder.js +239 -0
  123. package/node_modules/fast-xml-parser/node_modules/@nodable/entities/src/all-entities.js +53 -0
  124. package/node_modules/fast-xml-parser/node_modules/@nodable/entities/src/entities.js +1139 -0
  125. package/node_modules/fast-xml-parser/node_modules/@nodable/entities/src/entityTries.js +60 -0
  126. package/node_modules/fast-xml-parser/node_modules/@nodable/entities/src/index.d.ts +358 -0
  127. package/node_modules/fast-xml-parser/node_modules/@nodable/entities/src/index.js +29 -0
  128. package/node_modules/fast-xml-parser/node_modules/fast-xml-builder/CHANGELOG.md +52 -0
  129. package/node_modules/fast-xml-parser/node_modules/fast-xml-builder/LICENSE +21 -0
  130. package/node_modules/fast-xml-parser/node_modules/fast-xml-builder/README.md +77 -0
  131. package/node_modules/fast-xml-parser/node_modules/fast-xml-builder/lib/fxb.cjs +1 -0
  132. package/node_modules/fast-xml-parser/node_modules/fast-xml-builder/lib/fxb.d.cts +270 -0
  133. package/node_modules/fast-xml-parser/node_modules/fast-xml-builder/lib/fxb.min.js +2 -0
  134. package/node_modules/fast-xml-parser/node_modules/fast-xml-builder/lib/fxb.min.js.map +1 -0
  135. package/node_modules/fast-xml-parser/node_modules/fast-xml-builder/package.json +77 -0
  136. package/node_modules/fast-xml-parser/node_modules/fast-xml-builder/src/fxb.d.ts +270 -0
  137. package/node_modules/fast-xml-parser/node_modules/fast-xml-builder/src/fxb.js +609 -0
  138. package/node_modules/fast-xml-parser/node_modules/fast-xml-builder/src/ignoreAttributes.js +18 -0
  139. package/node_modules/fast-xml-parser/node_modules/fast-xml-builder/src/orderedJs2Xml.js +360 -0
  140. package/node_modules/fast-xml-parser/node_modules/fast-xml-builder/src/prettifyJs2Xml.js +0 -0
  141. package/node_modules/fast-xml-parser/node_modules/fast-xml-builder/src/util.js +23 -0
  142. package/node_modules/fast-xml-parser/node_modules/is-unsafe/LICENSE +21 -0
  143. package/node_modules/fast-xml-parser/node_modules/is-unsafe/README.md +632 -0
  144. package/node_modules/fast-xml-parser/node_modules/is-unsafe/package.json +56 -0
  145. package/node_modules/fast-xml-parser/node_modules/is-unsafe/src/contexts/html.js +102 -0
  146. package/node_modules/fast-xml-parser/node_modules/is-unsafe/src/contexts/log.js +98 -0
  147. package/node_modules/fast-xml-parser/node_modules/is-unsafe/src/contexts/nosql.js +114 -0
  148. package/node_modules/fast-xml-parser/node_modules/is-unsafe/src/contexts/redos.js +60 -0
  149. package/node_modules/fast-xml-parser/node_modules/is-unsafe/src/contexts/shell.js +105 -0
  150. package/node_modules/fast-xml-parser/node_modules/is-unsafe/src/contexts/sql-strict.js +47 -0
  151. package/node_modules/fast-xml-parser/node_modules/is-unsafe/src/contexts/sql.js +95 -0
  152. package/node_modules/fast-xml-parser/node_modules/is-unsafe/src/contexts/svg.js +81 -0
  153. package/node_modules/fast-xml-parser/node_modules/is-unsafe/src/contexts/xml.js +79 -0
  154. package/node_modules/fast-xml-parser/node_modules/is-unsafe/src/index.cjs +27 -0
  155. package/node_modules/fast-xml-parser/node_modules/is-unsafe/src/index.d.ts +103 -0
  156. package/node_modules/fast-xml-parser/node_modules/is-unsafe/src/index.js +292 -0
  157. package/node_modules/fast-xml-parser/node_modules/is-unsafe/src/util/decode-entities.js +48 -0
  158. package/node_modules/fast-xml-parser/node_modules/path-expression-matcher/LICENSE +21 -0
  159. package/node_modules/fast-xml-parser/node_modules/path-expression-matcher/README.md +947 -0
  160. package/node_modules/fast-xml-parser/node_modules/path-expression-matcher/lib/pem.cjs +1 -0
  161. package/node_modules/fast-xml-parser/node_modules/path-expression-matcher/lib/pem.d.cts +725 -0
  162. package/node_modules/fast-xml-parser/node_modules/path-expression-matcher/lib/pem.min.js +2 -0
  163. package/node_modules/fast-xml-parser/node_modules/path-expression-matcher/lib/pem.min.js.map +1 -0
  164. package/node_modules/fast-xml-parser/node_modules/path-expression-matcher/package.json +79 -0
  165. package/node_modules/fast-xml-parser/node_modules/path-expression-matcher/src/Expression.js +232 -0
  166. package/node_modules/fast-xml-parser/node_modules/path-expression-matcher/src/ExpressionSet.js +225 -0
  167. package/node_modules/fast-xml-parser/node_modules/path-expression-matcher/src/Matcher.js +663 -0
  168. package/node_modules/fast-xml-parser/node_modules/path-expression-matcher/src/index.d.ts +589 -0
  169. package/node_modules/fast-xml-parser/node_modules/path-expression-matcher/src/index.js +30 -0
  170. package/node_modules/fast-xml-parser/node_modules/strnum/CHANGELOG.md +63 -0
  171. package/node_modules/fast-xml-parser/node_modules/strnum/LICENSE +21 -0
  172. package/node_modules/fast-xml-parser/node_modules/strnum/README.md +113 -0
  173. package/node_modules/fast-xml-parser/node_modules/strnum/node_modules/anynum/LICENSE +21 -0
  174. package/node_modules/fast-xml-parser/node_modules/strnum/node_modules/anynum/README.md +142 -0
  175. package/node_modules/fast-xml-parser/node_modules/strnum/node_modules/anynum/anynum.js +135 -0
  176. package/node_modules/fast-xml-parser/node_modules/strnum/node_modules/anynum/digitTable.js +116 -0
  177. package/node_modules/fast-xml-parser/node_modules/strnum/node_modules/anynum/package.json +42 -0
  178. package/node_modules/fast-xml-parser/node_modules/strnum/package.json +36 -0
  179. package/node_modules/fast-xml-parser/node_modules/strnum/strnum.js +176 -0
  180. package/node_modules/fast-xml-parser/node_modules/xml-naming/LICENSE +21 -0
  181. package/node_modules/fast-xml-parser/node_modules/xml-naming/README.md +287 -0
  182. package/node_modules/fast-xml-parser/node_modules/xml-naming/package.json +56 -0
  183. package/node_modules/fast-xml-parser/node_modules/xml-naming/src/index.d.ts +108 -0
  184. package/node_modules/fast-xml-parser/node_modules/xml-naming/src/index.js +382 -0
  185. package/node_modules/fast-xml-parser/package.json +93 -0
  186. package/node_modules/fast-xml-parser/src/cli/cli.js +97 -0
  187. package/node_modules/fast-xml-parser/src/cli/man.js +17 -0
  188. package/node_modules/fast-xml-parser/src/cli/read.js +43 -0
  189. package/node_modules/fast-xml-parser/src/fxp.d.ts +754 -0
  190. package/node_modules/fast-xml-parser/src/fxp.js +14 -0
  191. package/node_modules/fast-xml-parser/src/ignoreAttributes.js +18 -0
  192. package/node_modules/fast-xml-parser/src/util.js +61 -0
  193. package/node_modules/fast-xml-parser/src/v6/CharsSymbol.js +16 -0
  194. package/node_modules/fast-xml-parser/src/v6/EntitiesParser.js +106 -0
  195. package/node_modules/fast-xml-parser/src/v6/OptionsBuilder.js +61 -0
  196. package/node_modules/fast-xml-parser/src/v6/OutputBuilders/BaseOutputBuilder.js +69 -0
  197. package/node_modules/fast-xml-parser/src/v6/OutputBuilders/JsArrBuilder.js +103 -0
  198. package/node_modules/fast-xml-parser/src/v6/OutputBuilders/JsMinArrBuilder.js +100 -0
  199. package/node_modules/fast-xml-parser/src/v6/OutputBuilders/JsObjBuilder.js +154 -0
  200. package/node_modules/fast-xml-parser/src/v6/OutputBuilders/ParserOptionsBuilder.js +94 -0
  201. package/node_modules/fast-xml-parser/src/v6/Report.js +0 -0
  202. package/node_modules/fast-xml-parser/src/v6/TagPath.js +81 -0
  203. package/node_modules/fast-xml-parser/src/v6/TagPathMatcher.js +13 -0
  204. package/node_modules/fast-xml-parser/src/v6/XMLParser.js +83 -0
  205. package/node_modules/fast-xml-parser/src/v6/Xml2JsParser.js +235 -0
  206. package/node_modules/fast-xml-parser/src/v6/XmlPartReader.js +210 -0
  207. package/node_modules/fast-xml-parser/src/v6/XmlSpecialTagsReader.js +111 -0
  208. package/node_modules/fast-xml-parser/src/v6/inputSource/BufferSource.js +116 -0
  209. package/node_modules/fast-xml-parser/src/v6/inputSource/StringSource.js +121 -0
  210. package/node_modules/fast-xml-parser/src/v6/valueParsers/EntitiesParser.js +105 -0
  211. package/node_modules/fast-xml-parser/src/v6/valueParsers/booleanParser.js +22 -0
  212. package/node_modules/fast-xml-parser/src/v6/valueParsers/booleanParserExt.js +19 -0
  213. package/node_modules/fast-xml-parser/src/v6/valueParsers/currency.js +38 -0
  214. package/node_modules/fast-xml-parser/src/v6/valueParsers/join.js +13 -0
  215. package/node_modules/fast-xml-parser/src/v6/valueParsers/number.js +14 -0
  216. package/node_modules/fast-xml-parser/src/v6/valueParsers/trim.js +6 -0
  217. package/node_modules/fast-xml-parser/src/validator.js +518 -0
  218. package/node_modules/fast-xml-parser/src/xmlbuilder/json2xml.js +6 -0
  219. package/node_modules/fast-xml-parser/src/xmlparser/DocTypeReader.js +426 -0
  220. package/node_modules/fast-xml-parser/src/xmlparser/OptionsBuilder.js +164 -0
  221. package/node_modules/fast-xml-parser/src/xmlparser/OrderedObjParser.js +907 -0
  222. package/node_modules/fast-xml-parser/src/xmlparser/XMLParser.js +77 -0
  223. package/node_modules/fast-xml-parser/src/xmlparser/node2json.js +177 -0
  224. package/node_modules/fast-xml-parser/src/xmlparser/xmlNode.js +54 -0
  225. package/package.json +10 -8
  226. package/src/analysis/evidence.ts +331 -73
  227. package/src/analysis/health/diagnostics.ts +66 -18
  228. package/src/analysis/health/evidence-reason.ts +44 -0
  229. package/src/analysis/health/server-status.ts +41 -12
  230. package/src/analysis/search/pattern.ts +3 -3
  231. package/src/analysis/target/anchored-structural.ts +4 -1
  232. package/src/analysis/target/anchored.ts +3 -6
  233. package/src/analysis/target/symbol.ts +42 -48
  234. package/src/analysis/target/types.ts +4 -9
  235. package/src/analysis/workspace/cmake-parser.ts +207 -0
  236. package/src/analysis/workspace/cmake.ts +141 -0
  237. package/src/analysis/workspace/maven.ts +310 -0
  238. package/src/analysis/workspace/membership.ts +100 -26
  239. package/src/analysis/workspace/metadata.ts +6 -1
  240. package/src/analysis/workspace/observe.ts +6 -0
  241. package/src/analysis/workspace/types.ts +11 -3
  242. package/src/diagnostics/coverage.ts +49 -0
  243. package/src/diagnostics/evidence.ts +10 -2
  244. package/src/session/find-types.ts +8 -4
  245. package/src/session/find-workflow.ts +11 -16
  246. package/src/session/health-workflow.ts +6 -0
  247. package/src/session/input/common.ts +1 -1
  248. package/src/session/input/health-refactor.ts +48 -34
  249. package/src/session/input/workflows.ts +45 -46
  250. package/src/session/inspect/file-point.ts +2 -2
  251. package/src/session/inspect-types.ts +1 -1
  252. package/src/session/inspect-workflow.ts +3 -3
  253. package/src/session/orientation/collect.ts +42 -7
  254. package/src/session/orientation/context-facts.ts +3 -3
  255. package/src/session/orientation/context-sections.ts +13 -15
  256. package/src/session/orientation/facts.ts +5 -8
  257. package/src/session/orientation-workflow.ts +4 -19
  258. package/src/session/refactor-file-actions.ts +122 -0
  259. package/src/session/refactor-plan-pipeline.ts +152 -0
  260. package/src/session/refactor-plans.ts +18 -15
  261. package/src/session/refactor-types.ts +24 -12
  262. package/src/session/refactor-workflow.ts +68 -243
  263. package/src/session/target-workflow.ts +25 -18
  264. package/src/tool/code_find/execute.ts +6 -7
  265. package/src/tool/code_find/result.ts +5 -7
  266. package/src/tool/code_find/spec.ts +9 -16
  267. package/src/tool/code_find/tui.ts +12 -6
  268. package/src/tool/code_graph/display.ts +5 -6
  269. package/src/tool/code_graph/format.ts +8 -24
  270. package/src/tool/code_graph/result.ts +16 -75
  271. package/src/tool/code_graph/section.ts +21 -33
  272. package/src/tool/code_graph/spec.ts +6 -0
  273. package/src/tool/code_graph/tui.ts +10 -5
  274. package/src/tool/code_health/diagnostic-tui.ts +49 -0
  275. package/src/tool/code_health/guidance.ts +27 -0
  276. package/src/tool/code_health/markdown.ts +60 -8
  277. package/src/tool/code_health/result.ts +20 -9
  278. package/src/tool/code_health/spec.ts +6 -0
  279. package/src/tool/code_health/structured-schema.ts +18 -4
  280. package/src/tool/code_health/structured.ts +22 -18
  281. package/src/tool/code_health/tui.ts +33 -40
  282. package/src/tool/code_inspect/execute.ts +1 -1
  283. package/src/tool/code_inspect/markdown.ts +33 -6
  284. package/src/tool/code_inspect/result.ts +24 -19
  285. package/src/tool/code_inspect/spec.ts +14 -6
  286. package/src/tool/code_inspect/structured.ts +4 -21
  287. package/src/tool/code_inspect/tui.ts +2 -2
  288. package/src/tool/code_orientation/result.ts +53 -100
  289. package/src/tool/code_orientation/spec.ts +8 -0
  290. package/src/tool/code_orientation/structured-schema.ts +16 -12
  291. package/src/tool/code_orientation/structured-workspace.ts +13 -7
  292. package/src/tool/code_orientation/structured.ts +31 -39
  293. package/src/tool/code_orientation/workspace-format.ts +4 -10
  294. package/src/tool/code_orientation/workspace-instructions.ts +4 -5
  295. package/src/tool/code_orientation/workspace-observations.ts +2 -2
  296. package/src/tool/code_orientation/workspace-output.ts +16 -7
  297. package/src/tool/code_orientation/workspace-projects.ts +7 -10
  298. package/src/tool/code_orientation/workspace-sections.ts +13 -19
  299. package/src/tool/code_refactor_apply/result.ts +2 -1
  300. package/src/tool/code_refactor_apply/spec.ts +7 -0
  301. package/src/tool/code_refactor_plan/execute.ts +0 -2
  302. package/src/tool/code_refactor_plan/result.ts +23 -13
  303. package/src/tool/code_refactor_plan/spec.ts +8 -2
  304. package/src/tool/code_refactor_plan/structured.ts +59 -12
  305. package/src/tool/code_refactor_plan/tui.ts +14 -17
  306. package/src/tool/code_resolve/markdown.ts +5 -47
  307. package/src/tool/code_resolve/result.ts +43 -72
  308. package/src/tool/code_resolve/spec.ts +6 -0
  309. package/src/tool/infra/truncate.ts +2 -16
  310. package/src/tool/namespace.ts +14 -0
  311. package/src/tool/refactor-markdown.ts +55 -15
  312. package/src/tool/register.ts +3 -0
  313. package/src/tool/result/candidate-selection.ts +141 -0
  314. package/src/tool/result/display.ts +41 -45
  315. package/src/tool/result/errors.ts +1 -0
  316. package/src/tool/result/model-budget.ts +26 -1
  317. package/src/tool/result/refactor-preview.ts +118 -0
  318. package/src/tool/result/refactor-unavailable.ts +16 -0
  319. package/src/tool/result/refactor.ts +19 -10
  320. package/src/tool/result/structured.ts +2 -1
  321. package/src/tool/result/types.ts +9 -8
  322. package/src/tool/schemas.ts +76 -38
  323. package/src/tool/specs.ts +3 -0
  324. package/src/ui/footer.ts +2 -4
  325. package/src/ui/status-overlay.ts +1 -1
  326. package/src/ui/status-presentation.ts +4 -7
  327. package/src/ui/tui/candidate-selection.ts +40 -95
  328. package/src/ui/tui/common.ts +16 -70
  329. package/src/ui/tui/display.ts +6 -24
  330. package/src/tool/result/candidate-row.ts +0 -49
@@ -6,9 +6,10 @@
6
6
  // to suppress LSP errors on files that TypeScript itself would not include.
7
7
 
8
8
  import * as path from "node:path";
9
- import ts from "typescript";
9
+ import type ts from "typescript";
10
10
  import { collectExtendedProjectConfigs } from "./tsconfig-extends.ts";
11
11
  import { normalizeTsconfigPath as normalizePath } from "./tsconfig-path.ts";
12
+ import { getTypeScript } from "./typescript-module.ts";
12
13
 
13
14
  export { isProjectConfigFileName } from "./tsconfig-extends.ts";
14
15
 
@@ -74,7 +75,7 @@ export function isTsconfigApplicableFile(filePath: string): boolean {
74
75
  const nearestConfigCache = new Map<string, string | null>();
75
76
  const parsedConfigCache = new Map<string, ParsedProjectConfigCacheEntry>();
76
77
 
77
- const tsInternal = ts as typeof ts & {
78
+ type TypeScriptInternal = typeof ts & {
78
79
  getFileMatcherPatterns?: (
79
80
  configDir: string,
80
81
  excludes: readonly string[] | undefined,
@@ -91,6 +92,10 @@ const tsInternal = ts as typeof ts & {
91
92
  ) => ReadonlyArray<ReadonlyArray<string>>;
92
93
  };
93
94
 
95
+ function getTypeScriptInternal(): TypeScriptInternal {
96
+ return getTypeScript() as TypeScriptInternal;
97
+ }
98
+
94
99
  /**
95
100
  * Check whether a file is excluded by its nearest tsconfig.json or jsconfig.json.
96
101
  *
@@ -122,7 +127,7 @@ export function isFileExcludedByTsconfig(filePath: string, cwd: string): boolean
122
127
  * project config without re-deriving the scope logic.
123
128
  */
124
129
  export function getFileScopeDecision(filePath: string, cwd: string): FileScopeDecision {
125
- const caseSensitiveFileNames = ts.sys.useCaseSensitiveFileNames;
130
+ const caseSensitiveFileNames = getTypeScript().sys.useCaseSensitiveFileNames;
126
131
  const absolutePath = path.resolve(cwd, filePath);
127
132
  if (isOutOfTree(cwd, absolutePath)) {
128
133
  return {
@@ -212,6 +217,7 @@ function findNearestProjectConfig(startDir: string, rootDir: string): string | n
212
217
  }
213
218
 
214
219
  function getLocalProjectConfig(directory: string): string | null {
220
+ const ts = getTypeScript();
215
221
  const tsconfigPath = path.join(directory, "tsconfig.json");
216
222
  if (ts.sys.fileExists(tsconfigPath)) return tsconfigPath;
217
223
 
@@ -230,6 +236,7 @@ function parseProjectConfig(configPath: string): ParsedProjectConfig | null {
230
236
  parsed: null,
231
237
  dependencies: collectExtendedProjectConfigs(configPath),
232
238
  };
239
+ const ts = getTypeScript();
233
240
  const parsed = ts.getParsedCommandLineOfConfigFile(configPath, {}, createParseConfigHost());
234
241
  if (!parsed) {
235
242
  parsedConfigCache.set(normalizedConfigPath, cacheEntry);
@@ -343,6 +350,7 @@ function decideFileScope(
343
350
  }
344
351
 
345
352
  function getSupportedExtensions(options: ts.CompilerOptions): string[] {
353
+ const tsInternal = getTypeScriptInternal();
346
354
  return tsInternal.getSupportedExtensions
347
355
  ? [...tsInternal.getSupportedExtensions(options, undefined).flat()]
348
356
  : [".ts", ".tsx", ".d.ts", ".cts", ".d.cts", ".mts", ".d.mts"];
@@ -353,12 +361,13 @@ function getFileMatcherPatterns(
353
361
  excludeSpecs: readonly string[] | undefined,
354
362
  includeSpecs: readonly string[] | undefined,
355
363
  ): { includeFilePattern?: string; excludePattern?: string } {
364
+ const tsInternal = getTypeScriptInternal();
356
365
  return tsInternal.getFileMatcherPatterns
357
366
  ? tsInternal.getFileMatcherPatterns(
358
367
  configDir,
359
368
  excludeSpecs,
360
369
  includeSpecs,
361
- ts.sys.useCaseSensitiveFileNames,
370
+ tsInternal.sys.useCaseSensitiveFileNames,
362
371
  path.parse(configDir).root,
363
372
  )
364
373
  : {};
@@ -366,7 +375,7 @@ function getFileMatcherPatterns(
366
375
 
367
376
  function createParseConfigHost(): ts.ParseConfigFileHost {
368
377
  return {
369
- ...ts.sys,
378
+ ...getTypeScript().sys,
370
379
  onUnRecoverableConfigFileDiagnostic: () => {
371
380
  // Treat invalid configs as unsupported rather than surfacing a secondary
372
381
  // filter failure to the agent.
@@ -0,0 +1,17 @@
1
+ import { createRequire } from "node:module";
2
+ import type ts from "typescript";
3
+
4
+ const require = createRequire(import.meta.url);
5
+ let cached: typeof ts | undefined;
6
+
7
+ /**
8
+ * Load the bundled TypeScript compiler API on first use.
9
+ *
10
+ * Evaluating `typescript` costs roughly 100 ms, and most sessions and tests that import this
11
+ * package never ask a tsconfig question. Callers stay synchronous, so this uses `require`
12
+ * rather than a dynamic `import()`.
13
+ */
14
+ export function getTypeScript(): typeof ts {
15
+ cached ??= require("typescript") as typeof ts;
16
+ return cached;
17
+ }
@@ -5,10 +5,20 @@ export const TENTATIVE_PUSH_UNAVAILABLE_REASON =
5
5
  /** A final evidence state for one tracked document. */
6
6
  export type DiagnosticEvidenceStatus = "confirmed" | "unconfirmed" | "failed" | "removed";
7
7
 
8
+ /**
9
+ * Why a document is not confirmed, when a specific cause is known.
10
+ *
11
+ * `disk-changed`: the file's disk metadata changed after its content was last
12
+ * read and diagnosed, for example through an edit outside Pi.
13
+ */
14
+ export type DiagnosticEvidenceReason = "disk-changed";
15
+
8
16
  /** Freshness evidence for one tracked document. */
9
17
  export interface DiagnosticEvidenceDocument {
10
18
  readonly file: string;
11
19
  readonly status: DiagnosticEvidenceStatus;
20
+ /** Known cause for a non-confirmed status. */
21
+ readonly reason?: DiagnosticEvidenceReason;
12
22
  }
13
23
 
14
24
  /** Exact document coverage from a diagnostic snapshot or refresh attempt. */
@@ -35,3 +45,35 @@ export function summarizeDiagnosticEvidence(
35
45
  for (const document of documents) counts[document.status]++;
36
46
  return { ...counts, documents: [...documents] };
37
47
  }
48
+
49
+ function evidenceStatusRank(status: DiagnosticEvidenceStatus): number {
50
+ switch (status) {
51
+ case "confirmed":
52
+ return 1;
53
+ case "unconfirmed":
54
+ return 2;
55
+ case "failed":
56
+ return 3;
57
+ case "removed":
58
+ return 4;
59
+ }
60
+ }
61
+
62
+ /**
63
+ * Choose the more conservative of two documents for the same file.
64
+ *
65
+ * The higher status rank wins. For equal rank, a known `reason` is kept so a
66
+ * reason-less duplicate from another route cannot drop it.
67
+ */
68
+ export function preferEvidenceDocument(
69
+ existing: DiagnosticEvidenceDocument | undefined,
70
+ next: DiagnosticEvidenceDocument,
71
+ ): DiagnosticEvidenceDocument {
72
+ if (!existing) return next;
73
+ const nextRank = evidenceStatusRank(next.status);
74
+ const existingRank = evidenceStatusRank(existing.status);
75
+ if (nextRank > existingRank) return next;
76
+ if (nextRank < existingRank) return existing;
77
+ if (existing.reason === undefined && next.reason !== undefined) return next;
78
+ return existing;
79
+ }
@@ -9,6 +9,7 @@ import { getDiagnosticFileState } from "../client/client-file-state.ts";
9
9
  import {
10
10
  type DiagnosticEvidenceDocument,
11
11
  type DiagnosticEvidenceSummary,
12
+ preferEvidenceDocument,
12
13
  summarizeDiagnosticEvidence,
13
14
  } from "../diagnostics/evidence.ts";
14
15
 
@@ -82,23 +83,7 @@ function deduplicateEvidenceDocuments(
82
83
  ): DiagnosticEvidenceDocument[] {
83
84
  const byFile = new Map<string, DiagnosticEvidenceDocument>();
84
85
  for (const document of documents) {
85
- const existing = byFile.get(document.file);
86
- if (!existing || evidenceStatusRank(document.status) > evidenceStatusRank(existing.status)) {
87
- byFile.set(document.file, document);
88
- }
86
+ byFile.set(document.file, preferEvidenceDocument(byFile.get(document.file), document));
89
87
  }
90
88
  return Array.from(byFile.values()).sort((a, b) => a.file.localeCompare(b.file));
91
89
  }
92
-
93
- function evidenceStatusRank(status: DiagnosticEvidenceDocument["status"]): number {
94
- switch (status) {
95
- case "confirmed":
96
- return 1;
97
- case "unconfirmed":
98
- return 2;
99
- case "failed":
100
- return 3;
101
- case "removed":
102
- return 4;
103
- }
104
- }
@@ -0,0 +1,52 @@
1
+ import * as path from "node:path";
2
+ import { isWithinOrEqual } from "@mrclrchtr/supi-core/project";
3
+ import { getDiagnosticFileState } from "../client/client-file-state.ts";
4
+
5
+ /**
6
+ * Session-owned record of tracked files that disappeared from disk.
7
+ *
8
+ * Every path that clears tracked state for a missing file records the file here,
9
+ * including passive snapshot reads and background server-requested refreshes.
10
+ * The record survives until a caller acknowledges that a report showed the
11
+ * removal, so the removal does not depend on when the next refresh runs.
12
+ *
13
+ * Example: `rm src/a.ts`, then the TypeScript server sends
14
+ * `workspace/diagnostic/refresh`. The background refresh clears `src/a.ts`.
15
+ * A later `code_health({ refresh: true })` still reports it as removed.
16
+ *
17
+ * Entries come only from previously tracked files, so the record is bounded by
18
+ * the tracked-file state it replaces.
19
+ */
20
+ export class RemovedTrackedFileLedger {
21
+ readonly #files = new Set<string>();
22
+
23
+ /** Record one removed tracked file. */
24
+ record(filePath: string): void {
25
+ this.#files.add(path.resolve(filePath));
26
+ }
27
+
28
+ /**
29
+ * Return retained removals within `scope`, sorted, without consuming them.
30
+ *
31
+ * Files that exist again are dropped: a recreated file is no longer removed.
32
+ */
33
+ peek(scope: string | null = null): string[] {
34
+ for (const file of this.#files) {
35
+ if (getDiagnosticFileState(file) !== "removed") this.#files.delete(file);
36
+ }
37
+ const root = scope === null ? null : path.resolve(scope);
38
+ return Array.from(this.#files)
39
+ .filter((file) => root === null || isWithinOrEqual(root, file))
40
+ .sort((left, right) => left.localeCompare(right));
41
+ }
42
+
43
+ /** Forget removals that a delivered diagnostic report has shown. */
44
+ acknowledge(files: readonly string[]): void {
45
+ for (const file of files) this.#files.delete(path.resolve(file));
46
+ }
47
+
48
+ /** Forget every retained removal. */
49
+ clear(): void {
50
+ this.#files.clear();
51
+ }
52
+ }
@@ -11,7 +11,6 @@ import {
11
11
  unavailableCodeQuery,
12
12
  } from "@mrclrchtr/supi-code-runtime/api";
13
13
  import * as projectRoots from "@mrclrchtr/supi-core/project";
14
- import * as ts from "typescript";
15
14
  import {
16
15
  LspClient,
17
16
  type LspClientLifecycleTransitionKind,
@@ -50,6 +49,7 @@ import type {
50
49
  } from "../config/types.ts";
51
50
  import { FileChangeType } from "../config/types.ts";
52
51
  import { inspectTypeScriptLaunch } from "../config/typescript-launch.ts";
52
+ import { getTypeScript } from "../config/typescript-module.ts";
53
53
  import { boundCwd } from "../debug-telemetry.ts";
54
54
  import {
55
55
  accumulateOutstandingDiagnostics,
@@ -60,6 +60,7 @@ import {
60
60
  import {
61
61
  type DiagnosticEvidenceDocument,
62
62
  type DiagnosticEvidenceSummary,
63
+ preferEvidenceDocument,
63
64
  summarizeDiagnosticEvidence,
64
65
  } from "../diagnostics/evidence.ts";
65
66
  import {
@@ -120,6 +121,7 @@ import {
120
121
  type StartupRetryRouteResult,
121
122
  } from "./manager-process-crash-report.ts";
122
123
  import { buildProjectServerInfo } from "./manager-project-info.ts";
124
+ import { RemovedTrackedFileLedger } from "./manager-removal-ledger.ts";
123
125
  import type {
124
126
  ActiveCoverageSummaryEntry,
125
127
  CoverageSummaryEntry,
@@ -400,6 +402,8 @@ export class LspManager {
400
402
  private retiredRoutes = new Set<string>();
401
403
  /** Runtime-owned cleanup for clients removed by route retirement. */
402
404
  private retiredClientShutdowns = new Set<Promise<void>>();
405
+ /** Tracked files removed from disk until a diagnostic report shows them. */
406
+ private readonly removedTrackedFiles = new RemovedTrackedFileLedger();
403
407
  /** Shared diagnostic-recovery restart for each replaceable client route. */
404
408
  private pendingRestarts = new Map<string, Promise<{ files: string[]; restarted: boolean }>>();
405
409
  /** Monotonic ownership generation for each replaceable client route. */
@@ -582,6 +586,14 @@ export class LspManager {
582
586
  );
583
587
  }
584
588
 
589
+ /** Return the open document text last synchronized to the server, without starting one. */
590
+ getOpenDocumentContent(filePath: string): string | null {
591
+ const resolvedPath = resolveSessionPath(this.cwd, filePath);
592
+ return (
593
+ this.getExistingClientForFile(resolvedPath)?.getOpenDocumentContent(resolvedPath) ?? null
594
+ );
595
+ }
596
+
585
597
  /**
586
598
  * Coverage gap for a project-wide TypeScript request answered by `client`.
587
599
  *
@@ -732,6 +744,7 @@ export class LspManager {
732
744
  },
733
745
  this.cwd,
734
746
  this.fileAssociations,
747
+ (filePath) => this.removedTrackedFiles.record(filePath),
735
748
  );
736
749
  return client;
737
750
  }
@@ -1107,7 +1120,9 @@ export class LspManager {
1107
1120
  if (client.status !== "running" || !client.ready) return;
1108
1121
  const key = clientKey(client.name, client.root);
1109
1122
  const recovery = this.processCrashRecoveries.get(key);
1110
- if (recovery) {
1123
+ // An in-flight recovery owns its record until it settles; removing it here
1124
+ // would make that recovery report cancellation for a live replacement.
1125
+ if (recovery && !recovery.pending) {
1111
1126
  recovery.attemptConsumed = false;
1112
1127
  recovery.statusReason = undefined;
1113
1128
  recovery.failureMessage = undefined;
@@ -1524,7 +1539,7 @@ export class LspManager {
1524
1539
  try {
1525
1540
  recordDebugEvent({
1526
1541
  source: "lsp",
1527
- level: outcome === "failure" || outcome === "exhausted" ? "warning" : "debug",
1542
+ level: outcome === "failure" || outcome === "exhausted" ? "warning" : "info",
1528
1543
  category: "runtime.recovery",
1529
1544
  message: `LSP process-crash recovery ${outcome}`,
1530
1545
  cwd: boundCwd(this.cwd),
@@ -2306,6 +2321,24 @@ export class LspManager {
2306
2321
  closeFile(filePath: string): void {
2307
2322
  closeFileAcrossClients(this.clients.values(), resolveSessionPath(this.cwd, filePath));
2308
2323
  }
2324
+ /**
2325
+ * Return tracked files removed from disk since a report last showed them.
2326
+ *
2327
+ * The read does not consume the removals; call
2328
+ * {@link acknowledgeRemovedTrackedFiles} after a report delivered them.
2329
+ */
2330
+ peekRemovedTrackedFiles(scope: string | null = null): string[] {
2331
+ this.pruneMissingFiles();
2332
+ return this.removedTrackedFiles.peek(
2333
+ scope === null ? null : resolveSessionPath(this.cwd, scope),
2334
+ );
2335
+ }
2336
+
2337
+ /** Forget removals that a delivered diagnostic report has shown. */
2338
+ acknowledgeRemovedTrackedFiles(files: readonly string[]): void {
2339
+ this.removedTrackedFiles.acknowledge(files.map((file) => resolveSessionPath(this.cwd, file)));
2340
+ }
2341
+
2309
2342
  /** Remove any missing files from open-document and diagnostic state. */
2310
2343
  pruneMissingFiles(): string[] {
2311
2344
  const removed = pruneMissingFilesFromClients(this.clients.values());
@@ -2625,6 +2658,7 @@ export class LspManager {
2625
2658
  const shutdowns = clients.map((client) => client.shutdown().catch(() => {}));
2626
2659
  await Promise.all([...shutdowns, ...this.retiredClientShutdowns]);
2627
2660
  this.retiredClientShutdowns.clear();
2661
+ this.removedTrackedFiles.clear();
2628
2662
  // Dispose every client so pending or active progress tokens and
2629
2663
  // readiness promises cannot outlive the manager.
2630
2664
  for (const client of clients) client.dispose();
@@ -2765,6 +2799,7 @@ export class LspManager {
2765
2799
  snapshot.documents.map((document) => ({
2766
2800
  file: relativeFilePathFromUri(document.uri, this.cwd),
2767
2801
  status: document.status,
2802
+ ...(document.reason ? { reason: document.reason } : {}),
2768
2803
  })),
2769
2804
  ),
2770
2805
  );
@@ -2819,6 +2854,7 @@ export class LspManager {
2819
2854
  evidenceDocuments.push({
2820
2855
  file: relativeFilePathFromUri(document.uri, this.cwd),
2821
2856
  status: document.status,
2857
+ ...(document.reason ? { reason: document.reason } : {}),
2822
2858
  });
2823
2859
  }
2824
2860
  for (const entry of snapshot.entries) {
@@ -2896,6 +2932,7 @@ export class LspManager {
2896
2932
  snapshot.documents.map((document) => ({
2897
2933
  file: relativeFilePathFromUri(document.uri, this.cwd),
2898
2934
  status: document.status,
2935
+ ...(document.reason ? { reason: document.reason } : {}),
2899
2936
  })),
2900
2937
  );
2901
2938
  const evidence = this.toWorkspaceDiagnosticEvidence(evidenceDocuments);
@@ -2940,7 +2977,7 @@ export class LspManager {
2940
2977
  }
2941
2978
 
2942
2979
  return {
2943
- caseSensitiveFileNames: ts.sys.useCaseSensitiveFileNames,
2980
+ caseSensitiveFileNames: getTypeScript().sys.useCaseSensitiveFileNames,
2944
2981
  counts: accumulator.counts,
2945
2982
  basisCounts: accumulator.basisCounts,
2946
2983
  entries: accumulator.entries,
@@ -2954,10 +2991,7 @@ export class LspManager {
2954
2991
  for (const document of documents) {
2955
2992
  const file = path.relative(this.cwd, path.resolve(this.cwd, document.file));
2956
2993
  if (!this.isAutomaticScopePath(file)) continue;
2957
- const existing = byFile.get(file);
2958
- if (!existing || evidenceStatusRank(document.status) > evidenceStatusRank(existing.status)) {
2959
- byFile.set(file, { file, status: document.status });
2960
- }
2994
+ byFile.set(file, preferEvidenceDocument(byFile.get(file), { ...document, file }));
2961
2995
  }
2962
2996
  return summarizeDiagnosticEvidence(
2963
2997
  Array.from(byFile.values()).sort((a, b) => a.file.localeCompare(b.file)),
@@ -3518,6 +3552,7 @@ function collectClientDiagnosticEvidenceDocuments(
3518
3552
  snapshot.documents.map((document) => ({
3519
3553
  file: relativeFilePathFromUri(document.uri, cwd),
3520
3554
  status: document.status,
3555
+ ...(document.reason ? { reason: document.reason } : {}),
3521
3556
  })),
3522
3557
  );
3523
3558
  }
@@ -3547,16 +3582,3 @@ function collectOutstandingDiagnosticSummaryEntries(
3547
3582
  a.file.localeCompare(b.file),
3548
3583
  );
3549
3584
  }
3550
-
3551
- function evidenceStatusRank(status: DiagnosticEvidenceDocument["status"]): number {
3552
- switch (status) {
3553
- case "confirmed":
3554
- return 1;
3555
- case "unconfirmed":
3556
- return 2;
3557
- case "failed":
3558
- return 3;
3559
- case "removed":
3560
- return 4;
3561
- }
3562
- }
@@ -1,5 +1,6 @@
1
1
  import * as fs from "node:fs";
2
- import ts from "typescript";
2
+ import type ts from "typescript";
3
+ import { getTypeScript } from "../config/typescript-module.ts";
3
4
 
4
5
  /**
5
6
  * Whether the identifier at `position` names a top-level declaration that only
@@ -22,6 +23,7 @@ export function isFileLocalTopLevelDeclaration(
22
23
  } catch {
23
24
  return false;
24
25
  }
26
+ const ts = getTypeScript();
25
27
  const sourceFile = ts.createSourceFile(filePath, text, ts.ScriptTarget.Latest, true);
26
28
  if (!ts.isExternalModule(sourceFile)) return false;
27
29
  let offset: number;
@@ -44,6 +46,7 @@ function topLevelDeclarationNameAt(
44
46
  offset: number,
45
47
  sourceFile: ts.SourceFile,
46
48
  ): string | null {
49
+ const ts = getTypeScript();
47
50
  const names: ts.Identifier[] = [];
48
51
  if (
49
52
  ts.isFunctionDeclaration(statement) ||
@@ -63,6 +66,7 @@ function topLevelDeclarationNameAt(
63
66
  }
64
67
 
65
68
  function hasExportModifier(statement: ts.Statement): boolean {
69
+ const ts = getTypeScript();
66
70
  return (
67
71
  ts.canHaveModifiers(statement) &&
68
72
  (ts.getModifiers(statement) ?? []).some(
@@ -75,6 +79,7 @@ function hasExportModifier(statement: ts.Statement): boolean {
75
79
 
76
80
  /** `export { name }`, `export default name`, or `export = name` in this file. */
77
81
  function exportedByName(sourceFile: ts.SourceFile, name: string): boolean {
82
+ const ts = getTypeScript();
78
83
  return sourceFile.statements.some((statement) => {
79
84
  if (ts.isExportAssignment(statement)) {
80
85
  return ts.isIdentifier(statement.expression) && statement.expression.text === name;
@@ -7,10 +7,10 @@ import type {
7
7
  import type { WorkspaceLspRuntime } from "../session/runtime-registry.ts";
8
8
  import {
9
9
  collectCodeActionResults,
10
- isDeleteDeadCodeCodeAction,
11
- isUpdateImportsCodeAction,
12
- runFilteredCodeActionRefactor,
10
+ runCodeActionRefactor,
13
11
  runRenameRefactor,
12
+ runSourceActionRefactor,
13
+ wholeDocumentRange,
14
14
  } from "./refactor-planning.ts";
15
15
 
16
16
  /** Build optional refactor methods for the semantic provider adapter. */
@@ -45,12 +45,6 @@ async function planRefactor(
45
45
  ): Promise<RefactorResult> {
46
46
  switch (request.operation) {
47
47
  case "rename_symbol":
48
- if (!request.newName) {
49
- return {
50
- kind: "unavailable",
51
- reason: 'Refactor operation "rename_symbol" requires `newName`.',
52
- };
53
- }
54
48
  return runRenameRefactor({
55
49
  lsp,
56
50
  file: request.file,
@@ -58,39 +52,31 @@ async function planRefactor(
58
52
  newName: request.newName,
59
53
  control,
60
54
  });
61
- case "extract_function":
62
- case "extract_variable":
63
- return {
64
- kind: "unavailable",
65
- reason: `Refactor operation "${request.operation}" is unavailable: standard LSP code actions do not provide a safe exact extraction-name contract.`,
66
- };
67
- case "update_imports":
68
- return runFilteredCodeActionRefactor({
55
+ case "code_action":
56
+ return runCodeActionRefactor({
69
57
  lsp,
70
58
  file: request.file,
71
- position: request.position,
72
- operation: "update_imports",
73
- matches: isUpdateImportsCodeAction,
59
+ range: request.range,
60
+ kind: request.kind,
61
+ title: request.title,
62
+ label: "Code action",
74
63
  control,
75
64
  });
76
- case "delete_dead_code":
77
- return runFilteredCodeActionRefactor({
65
+ case "source_action": {
66
+ // LSP source actions apply to the entire file, so request the whole document.
67
+ const range = wholeDocumentRange(request.file);
68
+ if (!range) {
69
+ return { kind: "unavailable", reason: `File ${request.file} could not be read.` };
70
+ }
71
+ return runSourceActionRefactor({
78
72
  lsp,
79
73
  file: request.file,
80
- position: request.position,
81
- operation: "delete_dead_code",
82
- matches: isDeleteDeadCodeCodeAction,
74
+ range,
75
+ kind: request.kind,
76
+ title: request.title,
77
+ label: "Source action",
83
78
  control,
84
79
  });
85
- case "rename_file":
86
- case "move_file":
87
- return {
88
- kind: "unavailable",
89
- reason: `Refactor operation "${request.operation}" is not supported yet. File/resource operations are deferred.`,
90
- };
80
+ }
91
81
  }
92
- return {
93
- kind: "unavailable",
94
- reason: `Refactor operation "${request.operation}" is not supported by the active semantic provider.`,
95
- };
96
82
  }
@@ -83,7 +83,12 @@ export function createLspSemanticProvider(lsp: WorkspaceLspRuntime): SemanticPro
83
83
  ? await lsp.documentSymbols(filePath, control)
84
84
  : await lsp.documentSymbols(filePath);
85
85
  if (result.kind === "unavailable") return unavailableCodeQuery(result.reason);
86
- const symbols = await mapDocumentSymbols(result.data, filePath);
86
+ // Anchor names against the text the server analyzed, not possibly newer disk content.
87
+ const symbols = await mapDocumentSymbols(
88
+ result.data,
89
+ filePath,
90
+ lsp.getOpenDocumentContent(filePath),
91
+ );
87
92
  return result.kind === "partial"
88
93
  ? partialCodeQuery(symbols, result.reason)
89
94
  : completedCodeQuery(symbols);