@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
@@ -9,6 +9,7 @@ import {
9
9
  createEvidenceList,
10
10
  createPartialEvidenceList,
11
11
  type EvidenceListMetadata,
12
+ toEvidenceListFacts,
12
13
  } from "../../analysis/evidence.ts";
13
14
  import {
14
15
  type ReadNextItem,
@@ -237,19 +238,34 @@ function targetContextFacts(
237
238
  : { file: toDisplayPath(cwd, uri) }),
238
239
  range: publicRange(range),
239
240
  })),
240
- collectedCount: treeContext.definition.length,
241
- omittedCount: Math.max(0, treeContext.definition.length - limit),
241
+ evidence: sourceEvidence(
242
+ "context.definitions",
243
+ treeContext.operations.definition,
244
+ treeContext.definition,
245
+ limit,
246
+ ),
242
247
  }
243
248
  : {}),
244
249
  },
245
250
  sourceContext: {
246
- outline: sourceSelection(treeContext.operations.outline, treeContext.outline, limit),
251
+ outline: sourceSelection(
252
+ "context.outline",
253
+ treeContext.operations.outline,
254
+ treeContext.outline,
255
+ limit,
256
+ ),
247
257
  imports: sourceSelection(
258
+ "context.imports",
248
259
  treeContext.operations.imports,
249
260
  treeContext.imports.map(({ moduleSpecifier }) => ({ moduleSpecifier })),
250
261
  limit,
251
262
  ),
252
- exports: sourceSelection(treeContext.operations.exports, treeContext.exports, limit),
263
+ exports: sourceSelection(
264
+ "context.exports",
265
+ treeContext.operations.exports,
266
+ treeContext.exports,
267
+ limit,
268
+ ),
253
269
  },
254
270
  }
255
271
  : {};
@@ -675,8 +691,9 @@ function publicRange(range: SourceRange): SourceRange {
675
691
  };
676
692
  }
677
693
 
678
- /** These best-effort lists preserve availability separately from collected counts. */
694
+ /** These best-effort lists preserve availability separately from their Evidence list. */
679
695
  function sourceSelection<T>(
696
+ key: string,
680
697
  status: { status: "complete" | "partial" | "unavailable"; reason: string | null },
681
698
  entries: readonly T[],
682
699
  limit: number,
@@ -684,11 +701,29 @@ function sourceSelection<T>(
684
701
  return {
685
702
  ...status,
686
703
  entries: entries.slice(0, limit),
687
- collectedCount: entries.length,
688
- omittedCount: Math.max(0, entries.length - limit),
704
+ evidence: sourceEvidence(key, status, entries, limit),
689
705
  };
690
706
  }
691
707
 
708
+ /** A partial observation counts its collected atoms; more may exist. */
709
+ function sourceEvidence<T>(
710
+ key: string,
711
+ status: { status: string; reason: string | null },
712
+ entries: readonly T[],
713
+ limit: number,
714
+ ) {
715
+ const params = { key, items: entries, maxResults: limit };
716
+ return toEvidenceListFacts(
717
+ status.status === "complete"
718
+ ? createEvidenceList(params).metadata
719
+ : createPartialEvidenceList({
720
+ ...params,
721
+ partialReason: "provider-limited",
722
+ ...(status.reason ? { partialMessage: status.reason } : {}),
723
+ }).metadata,
724
+ );
725
+ }
726
+
692
727
  function uniqueRecoveryRanges(
693
728
  recovery: readonly { errorRanges: readonly SourceRange[] }[],
694
729
  ): SourceRange[] {
@@ -9,7 +9,7 @@ import type {
9
9
  ModuleInfo,
10
10
  } from "../../analysis/architecture/model.ts";
11
11
  import { findModuleForPath } from "../../analysis/architecture/model.ts";
12
- import type { EvidencePartialReason } from "../../analysis/evidence.ts";
12
+ import type { CollectionPartialReason } from "../../analysis/evidence.ts";
13
13
  import type { CodeProvider } from "../../analysis/provider.ts";
14
14
  import type { OrientationProvenance, OrientationResultData } from "../orientation-types.ts";
15
15
  import {
@@ -290,7 +290,7 @@ function appendRelationshipFacts(
290
290
  edges: readonly DependencyEdge[];
291
291
  status: "complete" | "partial" | "unavailable";
292
292
  reason: string | null;
293
- partialReason: EvidencePartialReason | undefined;
293
+ partialReason: CollectionPartialReason | undefined;
294
294
  },
295
295
  ): void {
296
296
  if (input.status === "unavailable") return;
@@ -318,7 +318,7 @@ function appendRelationshipFacts(
318
318
  });
319
319
  }
320
320
 
321
- function topologyPartialReason(model: ArchitectureModel): EvidencePartialReason | undefined {
321
+ function topologyPartialReason(model: ArchitectureModel): CollectionPartialReason | undefined {
322
322
  if (model.topology.status !== "partial") return undefined;
323
323
  return model.topology.failedPackageManifestCount > 0 ? "filesystem-error" : "configuration-error";
324
324
  }
@@ -9,8 +9,11 @@ import {
9
9
  } from "@mrclrchtr/supi-code-runtime/api";
10
10
  import { isWithinOrEqual } from "@mrclrchtr/supi-core/project";
11
11
  import type { WorkspaceLspRuntimeState } from "@mrclrchtr/supi-lsp/api";
12
- import type { EvidenceListMetadata, EvidencePartialReason } from "../../analysis/evidence.ts";
13
- import { createEvidenceList } from "../../analysis/evidence.ts";
12
+ import {
13
+ type CollectionPartialReason,
14
+ createEvidenceList,
15
+ createPartialEvidenceList,
16
+ } from "../../analysis/evidence.ts";
14
17
  import type { CodeProvider } from "../../analysis/provider.ts";
15
18
  import { toDisplayPath } from "../../analysis/search/paths.ts";
16
19
  import type {
@@ -38,7 +41,7 @@ export interface ListSectionInput<T> {
38
41
  readonly status?: "complete" | "partial";
39
42
  readonly reason?: string | null;
40
43
  readonly unknownRemainder?: boolean;
41
- readonly partialReason?: EvidencePartialReason;
44
+ readonly partialReason?: CollectionPartialReason;
42
45
  readonly errorRanges?: readonly SourceRange[];
43
46
  readonly facts?: (items: readonly T[]) => import("./facts.ts").OrientationFacts;
44
47
  }
@@ -58,19 +61,14 @@ export function appendList<T>(
58
61
  builder: ContextOrientationBuilder,
59
62
  input: ListSectionInput<T>,
60
63
  ): void {
61
- const list = createEvidenceList({
62
- key: input.key,
63
- items: [...input.items],
64
- maxResults: builder.maxResults,
65
- });
66
- const metadata: EvidenceListMetadata = input.unknownRemainder
67
- ? {
68
- ...list.metadata,
69
- totalCount: null,
64
+ const params = { key: input.key, items: [...input.items], maxResults: builder.maxResults };
65
+ const list = input.unknownRemainder
66
+ ? createPartialEvidenceList({
67
+ ...params,
70
68
  partialReason: input.partialReason ?? "filesystem-error",
71
69
  ...(input.reason ? { partialMessage: input.reason } : {}),
72
- }
73
- : list.metadata;
70
+ })
71
+ : createEvidenceList(params);
74
72
  builder.sections.push({
75
73
  key: input.key,
76
74
  title: input.title,
@@ -78,7 +76,7 @@ export function appendList<T>(
78
76
  reason: input.reason ?? null,
79
77
  confidence: input.confidence,
80
78
  provenance: input.provenance,
81
- evidenceLists: [{ ...metadata, key: input.key }],
79
+ evidenceLists: [list.metadata],
82
80
  items: list.items.map((item) => ({ kind: "list-item", text: input.render(item) })),
83
81
  ...(input.facts ? { facts: input.facts(list.items) } : {}),
84
82
  ...(input.errorRanges ? { errorRanges: [...input.errorRanges] } : {}),
@@ -1,4 +1,5 @@
1
1
  import type { SourceRange } from "@mrclrchtr/supi-code-runtime/api";
2
+ import type { EvidenceListFacts } from "../../analysis/evidence.ts";
2
3
 
3
4
  /** Named, selected observations retained independently of their text rendering. */
4
5
  export interface OrientationFacts {
@@ -84,8 +85,7 @@ export interface OrientationFacts {
84
85
  readonly reason: string;
85
86
  }
86
87
  )[];
87
- readonly collectedCount?: number;
88
- readonly omittedCount?: number;
88
+ readonly evidence?: EvidenceListFacts;
89
89
  };
90
90
  readonly recovery?: readonly {
91
91
  readonly operation: string;
@@ -103,22 +103,19 @@ export interface OrientationFacts {
103
103
  readonly startLine: number;
104
104
  readonly endLine: number;
105
105
  }[];
106
- readonly collectedCount: number;
107
- readonly omittedCount: number;
106
+ readonly evidence: EvidenceListFacts;
108
107
  };
109
108
  readonly imports: {
110
109
  readonly status: "complete" | "partial" | "unavailable";
111
110
  readonly reason: string | null;
112
111
  readonly entries: readonly { readonly moduleSpecifier: string }[];
113
- readonly collectedCount: number;
114
- readonly omittedCount: number;
112
+ readonly evidence: EvidenceListFacts;
115
113
  };
116
114
  readonly exports: {
117
115
  readonly status: "complete" | "partial" | "unavailable";
118
116
  readonly reason: string | null;
119
117
  readonly entries: readonly { readonly name: string; readonly kind: string }[];
120
- readonly collectedCount: number;
121
- readonly omittedCount: number;
118
+ readonly evidence: EvidenceListFacts;
122
119
  };
123
120
  };
124
121
  readonly documentation?: readonly string[];
@@ -3,6 +3,7 @@
3
3
  import { existsSync, statSync } from "node:fs";
4
4
  import { buildArchitectureModel } from "../analysis/architecture/discovery.ts";
5
5
  import type { ArchitectureModel } from "../analysis/architecture/model.ts";
6
+ import { createEvidenceList } from "../analysis/evidence.ts";
6
7
  import {
7
8
  collectInstructionFiles,
8
9
  findInstructionFilesForDirectory,
@@ -148,19 +149,9 @@ async function orientTarget(options: {
148
149
  kind: "kind-mismatch",
149
150
  requestedKind: target.requestedKind,
150
151
  candidates,
151
- totalCount: target.totalCount,
152
- omittedCount: target.omittedCount,
153
- partialReason: target.partialReason,
154
- partialMessage: target.partialMessage,
152
+ candidateEvidence: target.candidateEvidence,
155
153
  }
156
- : {
157
- kind: "disambiguation",
158
- candidates,
159
- totalCount: target.totalCount,
160
- omittedCount: target.omittedCount,
161
- partialReason: target.partialReason,
162
- partialMessage: target.partialMessage,
163
- };
154
+ : { kind: "disambiguation", candidates, candidateEvidence: target.candidateEvidence };
164
155
  }
165
156
  if (target.kind !== "resolved") return target;
166
157
  throwIfAborted(control);
@@ -280,13 +271,7 @@ function addInstructionFiles(
280
271
  confidence: "unavailable",
281
272
  provenance: [{ source: "filesystem", detail: "configured instruction files" }],
282
273
  evidenceLists: [
283
- {
284
- key: "instructions.files",
285
- totalCount: collected.files.length,
286
- shownCount: collected.files.length,
287
- omittedCount: 0,
288
- partialReason: null,
289
- },
274
+ createEvidenceList({ key: "instructions.files", items: collected.files }).metadata,
290
275
  ],
291
276
  items,
292
277
  };
@@ -0,0 +1,122 @@
1
+ /** Code- and source-action refactor planning for one named file. */
2
+
3
+ import { existsSync, readFileSync, statSync } from "node:fs";
4
+ import type { RefactorRequest, SourceRange } from "@mrclrchtr/supi-code-runtime/api";
5
+ import { toLspPosition } from "@mrclrchtr/supi-lsp/api";
6
+ import { normalizePath } from "../analysis/search/paths.ts";
7
+ import {
8
+ ensureFileReadiness,
9
+ finishProviderPlan,
10
+ planWithProvider,
11
+ type RefactorWorkflowDeps,
12
+ } from "./refactor-plan-pipeline.ts";
13
+ import type {
14
+ PublicSourceRange,
15
+ RefactorOperationInput,
16
+ RefactorPlanWorkflowOutcome,
17
+ } from "./refactor-types.ts";
18
+ import { reportProgress, throwIfAborted, type WorkflowControl } from "./workflow-control.ts";
19
+
20
+ /**
21
+ * Plan one code or source action. These operations name a file directly and
22
+ * never resolve a symbol target; source actions cover the whole document.
23
+ */
24
+ export async function planFileAction(
25
+ operation: Exclude<RefactorOperationInput, { rename_symbol: unknown }>,
26
+ deps: RefactorWorkflowDeps,
27
+ control?: WorkflowControl,
28
+ ): Promise<RefactorPlanWorkflowOutcome> {
29
+ const { name, selection, range } =
30
+ "code_action" in operation
31
+ ? {
32
+ name: "code_action" as const,
33
+ selection: operation.code_action,
34
+ range: operation.code_action.range,
35
+ }
36
+ : { name: "source_action" as const, selection: operation.source_action, range: undefined };
37
+ const file = normalizePath(selection.file, deps.cwd);
38
+ const fileError = validateActionFile(file, selection.file, `operation.${name}.file`);
39
+ if (fileError) return { kind: "invalid-input", message: fileError };
40
+ const rangeError = range
41
+ ? validateRangeWithinFile(file, selection.file, range, `operation.${name}.range`)
42
+ : null;
43
+ if (rangeError) return { kind: "invalid-input", message: rangeError };
44
+
45
+ const readiness = await ensureFileReadiness(file, deps, control);
46
+ if (readiness) return readiness;
47
+ reportProgress(control, {
48
+ intent: "refactor-plan",
49
+ phase: "provider",
50
+ message: `Requesting ${selection.kind} code actions`,
51
+ });
52
+ const action = {
53
+ file,
54
+ kind: selection.kind,
55
+ ...(selection.title === undefined ? {} : { title: selection.title }),
56
+ };
57
+ const request: RefactorRequest = range
58
+ ? { operation: "code_action", ...action, range: toLspRange(range) }
59
+ : { operation: "source_action", ...action };
60
+ const result = await planWithProvider(
61
+ deps.capability.getSemanticProvider(deps.cwd),
62
+ request,
63
+ control,
64
+ );
65
+ throwIfAborted(control);
66
+ return finishProviderPlan(result, deps, {
67
+ operation: name,
68
+ file,
69
+ discriminator: `${selection.kind}:${selection.title ?? ""}:${JSON.stringify(range ?? null)}`,
70
+ fields: range ? { range } : {},
71
+ evidenceSource: "semantic",
72
+ });
73
+ }
74
+
75
+ /**
76
+ * Check that an action file exists and is a file. The routed language server
77
+ * enforces its own project root before any request.
78
+ */
79
+ function validateActionFile(file: string, input: string, label: string): string | null {
80
+ if (!existsSync(file)) return `File not found: \`${input}\``;
81
+ if (statSync(file).isDirectory()) {
82
+ return `${label} must be a file, not a directory: \`${input}\`.`;
83
+ }
84
+ return null;
85
+ }
86
+
87
+ /**
88
+ * Check that both range ends lie inside the file's current disk text, so an
89
+ * out-of-range position fails as input instead of as a server error. Positions
90
+ * are one-based UTF-16; a line's maximum character is one past its last character.
91
+ */
92
+ function validateRangeWithinFile(
93
+ file: string,
94
+ input: string,
95
+ range: PublicSourceRange,
96
+ label: string,
97
+ ): string | null {
98
+ let lines: string[];
99
+ try {
100
+ lines = readFileSync(file, "utf-8").split(/\r\n|\r|\n/);
101
+ } catch {
102
+ return `Cannot read file: \`${input}\``;
103
+ }
104
+ for (const end of ["start", "end"] as const) {
105
+ const { line, character } = range[end];
106
+ if (line > lines.length) {
107
+ return `${label}.${end} line ${line} is beyond the end of \`${input}\` (${lines.length} lines).`;
108
+ }
109
+ const maximum = (lines[line - 1] ?? "").length + 1;
110
+ if (character > maximum) {
111
+ return `${label}.${end} character ${character} is beyond line ${line} of \`${input}\` (maximum ${maximum}, 1-based UTF-16).`;
112
+ }
113
+ }
114
+ return null;
115
+ }
116
+
117
+ function toLspRange(range: PublicSourceRange): SourceRange {
118
+ return {
119
+ start: toLspPosition(range.start.line, range.start.character),
120
+ end: toLspPosition(range.end.line, range.end.character),
121
+ };
122
+ }
@@ -0,0 +1,152 @@
1
+ /** Shared refactor-plan pipeline: provider calls, readiness, validation, and plan storage. */
2
+
3
+ import type {
4
+ RefactorOperation,
5
+ RefactorRequest,
6
+ RefactorResult,
7
+ SemanticProvider,
8
+ } from "@mrclrchtr/supi-code-runtime/api";
9
+ import { SEMANTIC_READINESS_TIMEOUT_REASON } from "../analysis/readiness.ts";
10
+ import { establishMutationAuthority } from "../analysis/refactor/mutation-authority.ts";
11
+ import { validateEdit } from "../analysis/refactor/safety.ts";
12
+ import type { CapabilityAdapter } from "./capability-adapter.ts";
13
+ import { collectFileFingerprints, dropIdentityEdits } from "./refactor-identity.ts";
14
+ import {
15
+ generatePlanId,
16
+ type RefactorPlan,
17
+ validateSynchronizedContentFingerprints,
18
+ } from "./refactor-plans.ts";
19
+ import type { RefactorPlanWorkflowOutcome } from "./refactor-types.ts";
20
+ import type { TargetWorkflowDeps } from "./target-workflow.ts";
21
+ import { throwIfAborted, type WorkflowControl } from "./workflow-control.ts";
22
+
23
+ /** Session collaborators for refactor planning and apply workflows. */
24
+ export interface RefactorWorkflowDeps extends TargetWorkflowDeps {
25
+ readonly capability: CapabilityAdapter;
26
+ readonly storePlan: (plan: RefactorPlan) => string;
27
+ readonly getPlan: (id: string) => RefactorPlan | undefined;
28
+ readonly removePlan: (id: string) => void;
29
+ }
30
+
31
+ /** Wait for semantic readiness for one file; returns an outcome only when planning must stop. */
32
+ export async function ensureFileReadiness(
33
+ file: string,
34
+ deps: RefactorWorkflowDeps,
35
+ control?: WorkflowControl,
36
+ ): Promise<RefactorPlanWorkflowOutcome | null> {
37
+ const readiness = await deps.capability.ensureSemanticReadiness(
38
+ deps.cwd,
39
+ { kind: "file", file },
40
+ control,
41
+ );
42
+ throwIfAborted(control);
43
+ if (readiness.kind === "timeout") {
44
+ return { kind: "unavailable", reason: SEMANTIC_READINESS_TIMEOUT_REASON };
45
+ }
46
+ if (readiness.kind === "unavailable") return readiness;
47
+ return null;
48
+ }
49
+
50
+ /** Validate a provider result and store it as a fingerprinted plan. */
51
+ export async function finishProviderPlan(
52
+ result: RefactorResult,
53
+ deps: RefactorWorkflowDeps,
54
+ plan: {
55
+ readonly operation: RefactorOperation;
56
+ readonly file: string;
57
+ readonly discriminator: string;
58
+ readonly fields: Pick<RefactorPlan, "newName" | "target" | "range">;
59
+ readonly evidenceSource: "semantic" | "structural";
60
+ readonly sourceFingerprint?: string;
61
+ },
62
+ ): Promise<RefactorPlanWorkflowOutcome> {
63
+ if (result.kind === "unavailable") return { kind: "unavailable", reason: result.reason };
64
+ if (result.kind === "ambiguous") {
65
+ return { kind: "ambiguous", candidates: result.candidates };
66
+ }
67
+
68
+ const validation = validateEdit(result.edits);
69
+ if (!validation.safe) {
70
+ return { kind: "invalid-input", message: `Refactor safety check failed: ${validation.reason}` };
71
+ }
72
+ const authority = establishMutationAuthority(
73
+ result.edits.edits.map((edit) => edit.file),
74
+ result.authorizedMutationRoots,
75
+ );
76
+ if (authority.kind === "unavailable") return authority;
77
+ const fileFingerprints = collectFileFingerprints(
78
+ result.edits.edits,
79
+ plan.sourceFingerprint ? { file: plan.file, fingerprint: plan.sourceFingerprint } : undefined,
80
+ );
81
+ const snapshotError = validateSynchronizedContentFingerprints(
82
+ result.edits.documentPreconditions,
83
+ fileFingerprints,
84
+ deps.cwd,
85
+ );
86
+ if (snapshotError) return { kind: "unavailable", reason: snapshotError };
87
+ const changed = dropIdentityEdits(result.edits, fileFingerprints);
88
+ if (changed.kind === "unavailable") return changed;
89
+ if (changed.edits.edits.length === 0) {
90
+ return {
91
+ kind: "invalid-input",
92
+ message: `The ${plan.operation} refactor produces no changes; every planned edit matches the current text.`,
93
+ };
94
+ }
95
+
96
+ const stored: RefactorPlan = {
97
+ id: generatePlanId(plan.operation, plan.file, plan.discriminator),
98
+ operation: plan.operation,
99
+ file: plan.file,
100
+ ...plan.fields,
101
+ ...(result.action ? { action: { ...result.action } } : {}),
102
+ edits: changed.edits,
103
+ evidenceSource: plan.evidenceSource,
104
+ authorizedMutationRoots: authority.canonicalRoots,
105
+ fileFingerprints: changed.fileFingerprints,
106
+ createdAt: Date.now(),
107
+ };
108
+ deps.storePlan(stored);
109
+ return { kind: "completed", plan: immutablePlan(stored) };
110
+ }
111
+
112
+ /** Ask the active semantic provider for one refactor result. */
113
+ export async function planWithProvider(
114
+ provider: SemanticProvider | null,
115
+ request: RefactorRequest,
116
+ control?: WorkflowControl,
117
+ ): Promise<RefactorResult> {
118
+ if (!provider) return { kind: "unavailable", reason: "No semantic provider is active." };
119
+ if (provider.refactor) return provider.refactor(request, control);
120
+ if (request.operation === "rename_symbol" && provider.rename) {
121
+ return provider.rename(request.file, request.position, request.newName, control);
122
+ }
123
+ return {
124
+ kind: "unavailable",
125
+ reason: `The semantic provider cannot plan ${request.operation}.`,
126
+ };
127
+ }
128
+
129
+ /** Freeze a stored plan before it leaves the session. */
130
+ export function immutablePlan(plan: RefactorPlan): Readonly<RefactorPlan> {
131
+ return Object.freeze({
132
+ ...plan,
133
+ ...(plan.target ? { target: Object.freeze({ ...plan.target }) } : {}),
134
+ ...(plan.range ? { range: Object.freeze({ ...plan.range }) } : {}),
135
+ ...(plan.action ? { action: Object.freeze({ ...plan.action }) } : {}),
136
+ edits: Object.freeze({
137
+ ...plan.edits,
138
+ edits: Object.freeze(plan.edits.edits.map((edit) => Object.freeze({ ...edit }))),
139
+ documentPreconditions: plan.edits.documentPreconditions
140
+ ? Object.freeze(
141
+ plan.edits.documentPreconditions.map((precondition) =>
142
+ Object.freeze({ ...precondition }),
143
+ ),
144
+ )
145
+ : undefined,
146
+ }),
147
+ authorizedMutationRoots: Object.freeze([...plan.authorizedMutationRoots]),
148
+ fileFingerprints: Object.freeze(
149
+ plan.fileFingerprints.map((fingerprint) => Object.freeze({ ...fingerprint })),
150
+ ),
151
+ }) as Readonly<RefactorPlan>;
152
+ }
@@ -8,17 +8,27 @@
8
8
 
9
9
  import { createHash } from "node:crypto";
10
10
  import { readFileSync } from "node:fs";
11
- import type { RefactorOperation, WorkspaceEdit } from "@mrclrchtr/supi-code-runtime/api";
11
+ import type {
12
+ RefactorActionIdentity,
13
+ RefactorOperation,
14
+ WorkspaceEdit,
15
+ } from "@mrclrchtr/supi-code-runtime/api";
12
16
  import { toDisplayPath } from "../analysis/search/paths.ts";
17
+ import type { PublicSourceRange } from "./refactor-types.ts";
13
18
 
14
19
  export interface RefactorPlan {
15
20
  id: string;
16
21
  operation: RefactorOperation;
22
+ /** Absolute file the operation was requested for. */
23
+ file: string;
24
+ /** `rename_symbol`: the requested name. */
17
25
  newName?: string;
18
- destination?: string;
19
- targetFile: string;
20
- targetLine: number;
21
- targetCharacter: number;
26
+ /** `rename_symbol`: one-based target position in `file`. */
27
+ target?: { line: number; character: number };
28
+ /** `code_action`: the one-based requested range in `file`. */
29
+ range?: PublicSourceRange;
30
+ /** `code_action` / `source_action`: the selected server action. */
31
+ action?: RefactorActionIdentity;
22
32
  edits: WorkspaceEdit;
23
33
  /** Evidence source used to compose this plan. */
24
34
  evidenceSource?: "semantic" | "structural";
@@ -56,17 +66,10 @@ export function validateSynchronizedContentFingerprints(
56
66
  return null;
57
67
  }
58
68
 
59
- /** Generate a stable plan id from operation details. */
60
- // biome-ignore lint/complexity/useMaxParams: plan id construction needs all positional args
61
- export function generatePlanId(
62
- operation: string,
63
- file: string,
64
- line: number,
65
- character: number,
66
- discriminator: string = "",
67
- ): string {
69
+ /** Generate a plan id from operation details and a time discriminator. */
70
+ export function generatePlanId(operation: string, file: string, discriminator: string): string {
68
71
  const hash = createHash("sha256")
69
- .update(`${operation}:${file}:${line}:${character}:${discriminator}:${Date.now()}`)
72
+ .update(`${operation}:${file}:${discriminator}:${Date.now()}`)
70
73
  .digest("hex")
71
74
  .slice(0, 12);
72
75
  return `plan-${hash}`;
@@ -6,38 +6,50 @@ import type { RefactorTargetInput, SourcePointInput } from "./target-input.ts";
6
6
  /** Public refactor operations exposed by code_refactor_plan. */
7
7
  export const PUBLIC_REFACTOR_OPERATION_NAMES = [
8
8
  "rename_symbol",
9
- "extract_function",
10
- "extract_variable",
11
- "update_imports",
12
- "delete_dead_code",
9
+ "code_action",
10
+ "source_action",
13
11
  ] as const;
14
12
 
15
13
  export type PublicRefactorOperationName = (typeof PUBLIC_REFACTOR_OPERATION_NAMES)[number];
16
14
 
15
+ /** One-based public source range; the end is exclusive. */
17
16
  export interface PublicSourceRange {
18
17
  readonly start: Omit<SourcePointInput, "file">;
19
18
  readonly end: Omit<SourcePointInput, "file">;
20
19
  }
21
20
 
21
+ /**
22
+ * One refactor operation with its own scope. Only `rename_symbol` needs a
23
+ * symbol target; code and source actions name a file directly.
24
+ */
22
25
  export type RefactorOperationInput =
23
- | { readonly rename_symbol: { readonly newName: string } }
24
26
  | {
25
- readonly extract_function: {
27
+ readonly rename_symbol: {
28
+ readonly target: RefactorTargetInput;
26
29
  readonly newName: string;
27
- readonly range: PublicSourceRange;
28
30
  };
29
31
  }
30
32
  | {
31
- readonly extract_variable: {
32
- readonly newName: string;
33
+ readonly code_action: {
34
+ readonly file: string;
33
35
  readonly range: PublicSourceRange;
36
+ /** CodeActionKind prefix under `refactor`. */
37
+ readonly kind: string;
38
+ /** Exact action title that selects one matching action. */
39
+ readonly title?: string;
34
40
  };
35
41
  }
36
- | { readonly update_imports: Record<string, never> }
37
- | { readonly delete_dead_code: Record<string, never> };
42
+ | {
43
+ readonly source_action: {
44
+ readonly file: string;
45
+ /** CodeActionKind prefix under `source`. */
46
+ readonly kind: string;
47
+ /** Exact action title that selects one matching action. */
48
+ readonly title?: string;
49
+ };
50
+ };
38
51
 
39
52
  export interface RefactorPlanWorkflowInput {
40
- readonly target: RefactorTargetInput;
41
53
  readonly operation: RefactorOperationInput;
42
54
  }
43
55