@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
@@ -79,20 +79,49 @@ export function formatProjectServerCompiler(
79
79
  return `${selection.backend}: TypeScript ${selection.compilerVersion ?? "(unknown version)"} via ${selection.packageName}${selection.wrapperVersion ? ` (wrapper ${selection.wrapperVersion})` : ""}`;
80
80
  }
81
81
 
82
- /** Render operation support without hiding server limits or SuPi limits. */
82
+ /**
83
+ * Render operation support without hiding server limits or SuPi limits.
84
+ *
85
+ * A server that does not advertise an operation already rules it out, so its
86
+ * SuPi limitation is omitted. Operations with identical details share one
87
+ * entry, so a shared limitation reason appears once.
88
+ */
83
89
  export function formatProjectServerOperationSupport(
84
90
  support: ServerOperationSupportMap | undefined,
85
91
  ): string | null {
86
92
  if (!support) return null;
87
- const entries = Object.entries(support).flatMap(([operation, value]) => {
88
- const details: string[] = [];
89
- if (value.server === "not-advertised") details.push("server unsupported");
90
- if (value.server === "unknown") details.push("not negotiated");
91
- if (value.supi === "limited") {
92
- details.push(`SuPi limitation${value.reason ? `: ${value.reason}` : ""}`);
93
- }
94
- if (value.supi === "unsupported") details.push("SuPi unsupported");
95
- return details.length > 0 ? [`${operation}: ${details.join("; ")}`] : [];
96
- });
97
- return entries.length > 0 ? `operation support: ${entries.join(", ")}` : null;
93
+ const operationsByDetail = new Map<string, string[]>();
94
+ for (const [operation, value] of Object.entries(support)) {
95
+ const detail = formatOperationSupportDetail(value);
96
+ if (!detail) continue;
97
+ const operations = operationsByDetail.get(detail);
98
+ if (operations) operations.push(operation);
99
+ else operationsByDetail.set(detail, [operation]);
100
+ }
101
+ const entries = Array.from(
102
+ operationsByDetail,
103
+ ([detail, operations]) => `${operations.join(", ")}: ${detail}`,
104
+ );
105
+ // Details already use ";" and grouped operations use ",", so entries need a third separator.
106
+ return entries.length > 0 ? `operation support: ${entries.join(" | ")}` : null;
107
+ }
108
+
109
+ type OperationSupport = NonNullable<ServerOperationSupportMap[keyof ServerOperationSupportMap]>;
110
+
111
+ /** Describe one operation's limits, or return null when nothing limits it. */
112
+ function formatOperationSupportDetail(value: OperationSupport): string | null {
113
+ if (value.server === "not-advertised") return "server unsupported";
114
+ const details: string[] = [];
115
+ if (value.server === "unknown") details.push("not negotiated");
116
+ if (value.supi === "limited") {
117
+ details.push(`SuPi limitation${value.reason ? `: ${value.reason}` : ""}`);
118
+ }
119
+ if (value.supi === "unsupported") details.push("SuPi unsupported");
120
+ if (value.kinds?.length) details.push(`kinds ${value.kinds.join(", ")}`);
121
+ if (value.anyKind) {
122
+ details.push(
123
+ value.kinds?.length ? "may return unlisted kinds" : "no kinds listed; may return any kind",
124
+ );
125
+ }
126
+ return details.length > 0 ? details.join("; ") : null;
98
127
  }
@@ -2,7 +2,7 @@ import type { StructuralProvider as StructuralSubstrate } from "@mrclrchtr/supi-
2
2
  import type { AutomaticLspPathPolicy } from "@mrclrchtr/supi-lsp/api";
3
3
  import type { StructuralSearchOperation } from "@mrclrchtr/supi-tree-sitter/api";
4
4
  import type { CodeFindAstKind } from "../../tool/code_find/ast-kinds.ts";
5
- import type { EvidencePartialReason } from "../evidence.ts";
5
+ import type { CollectionPartialReason } from "../evidence.ts";
6
6
  import {
7
7
  type AstScanExclusion,
8
8
  type AstScanOperations,
@@ -46,7 +46,7 @@ export interface StructuredScanSummary {
46
46
 
47
47
  export interface StructuredPatternResult {
48
48
  readonly matches: readonly StructuredMatch[];
49
- readonly partialReason: EvidencePartialReason | null;
49
+ readonly partialReason: CollectionPartialReason | null;
50
50
  /** Per-file parse/analysis failures surfaced to the agent. */
51
51
  readonly failures: readonly StructuredFailure[];
52
52
  readonly scan: StructuredScanSummary;
@@ -190,7 +190,7 @@ export async function getStructuredPatternMatches(
190
190
 
191
191
  function primaryPartialReason(
192
192
  limitations: readonly StructuredScanLimitation[],
193
- ): EvidencePartialReason {
193
+ ): CollectionPartialReason {
194
194
  if (limitations.some((limitation) => limitation.reason === "timeout")) return "timeout";
195
195
  if (limitations.some((limitation) => limitation.reason === "safety-limit")) {
196
196
  return "safety-limit";
@@ -30,6 +30,9 @@ const DECLARATION_NODE_TYPES = new Set([
30
30
  "export_statement",
31
31
  ]);
32
32
 
33
+ /** Tree-sitter name tokens; Kotlin names its identifiers `simple_identifier`. */
34
+ const IDENTIFIER_NODE_TYPES = new Set(["identifier", "simple_identifier"]);
35
+
33
36
  /** Tree-sitter nodes that cannot identify a declaration name. */
34
37
  const NON_SYMBOL_NODE_TYPES = new Set([
35
38
  "comment",
@@ -94,7 +97,7 @@ export async function resolveFromStructural(
94
97
  ),
95
98
  };
96
99
  }
97
- if (node.type !== "identifier") {
100
+ if (!IDENTIFIER_NODE_TYPES.has(node.type)) {
98
101
  return {
99
102
  kind: "error",
100
103
  message: coordinateNotOnSymbolMessage(file, requested, node.type),
@@ -18,6 +18,7 @@ import {
18
18
  } from "@mrclrchtr/supi-code-runtime/api";
19
19
  import type { AnchorKind } from "../../session/target-store.ts";
20
20
  import type { AnchoredResolutionSource } from "../../types/index.ts";
21
+ import { createEvidenceList, type EvidenceListMetadata } from "../evidence.ts";
21
22
  import { resolveFromStructural } from "./anchored-structural.ts";
22
23
  import {
23
24
  canonicalFileDeclarationKind,
@@ -133,9 +134,7 @@ async function candidatesFromSymbols(
133
134
  ): Promise<{
134
135
  kind: "disambiguation";
135
136
  candidates: DisambiguationCandidateData[];
136
- totalCount: number;
137
- omittedCount: number;
138
- partialReason: null;
137
+ candidateEvidence: EvidenceListMetadata;
139
138
  }> {
140
139
  const candidates = await Promise.all(
141
140
  matched.map(async (s, idx) => {
@@ -162,9 +161,7 @@ async function candidatesFromSymbols(
162
161
  return {
163
162
  kind: "disambiguation",
164
163
  candidates,
165
- totalCount: candidates.length,
166
- omittedCount: 0,
167
- partialReason: null,
164
+ candidateEvidence: createEvidenceList({ key: "target.candidates", items: candidates }).metadata,
168
165
  };
169
166
  }
170
167
 
@@ -17,13 +17,10 @@ import {
17
17
  import { isWithinOrEqual } from "@mrclrchtr/supi-core/project";
18
18
  import type { TargetSymbolKind } from "../../session/target-input.ts";
19
19
  import type { AnchorKind } from "../../session/target-store.ts";
20
+ import { createEvidenceList, createPartialEvidenceList } from "../evidence.ts";
20
21
  import { describePartialQuery } from "../search/exclusions.ts";
21
22
  import { normalizePath } from "../search/paths.ts";
22
- import type {
23
- DisambiguationCandidateData,
24
- TargetCandidateCompleteness,
25
- TargetOutcome,
26
- } from "./types.ts";
23
+ import type { DisambiguationCandidateData, TargetOutcome } from "./types.ts";
27
24
 
28
25
  const MAX_CANDIDATES = 8; // default fallback when maxResults is not provided
29
26
  const NON_EXPORTED_KINDS = new Set(["Variable", "Field", "Property"]);
@@ -151,7 +148,7 @@ export async function resolveSymbolTarget(
151
148
  return buildCandidateOutcome({
152
149
  kind: "kind-mismatch",
153
150
  candidates: eligible,
154
- ...candidateCompleteness(result, eligible.length, cwd),
151
+ discovery: candidateDiscovery(result, cwd),
155
152
  semantic,
156
153
  cwd,
157
154
  maxResults: options.maxResults,
@@ -161,7 +158,7 @@ export async function resolveSymbolTarget(
161
158
  }
162
159
  return resolveCandidates({
163
160
  candidates: exactKind,
164
- ...candidateCompleteness(result, exactKind.length, cwd),
161
+ discovery: candidateDiscovery(result, cwd),
165
162
  exclusionNote: exclusionOnlyNote(result, cwd),
166
163
  semantic,
167
164
  cwd,
@@ -172,7 +169,7 @@ export async function resolveSymbolTarget(
172
169
 
173
170
  return resolveCandidates({
174
171
  candidates: eligible,
175
- ...candidateCompleteness(result, eligible.length, cwd),
172
+ discovery: candidateDiscovery(result, cwd),
176
173
  exclusionNote: exclusionOnlyNote(result, cwd),
177
174
  semantic,
178
175
  cwd,
@@ -190,28 +187,18 @@ function normalizeProviderKind(kind: string): string {
190
187
  }
191
188
 
192
189
  async function resolveCandidates(
193
- options: CandidateOutcomeBase &
194
- Omit<TargetCandidateCompleteness, "omittedCount"> & {
195
- /** Disclosure for a unique match beside policy-excluded rows. */
196
- exclusionNote?: string;
197
- },
190
+ options: CandidateOutcomeBase & {
191
+ discovery: CandidateDiscovery;
192
+ /** Disclosure for a unique match beside policy-excluded rows. */
193
+ exclusionNote?: string;
194
+ },
198
195
  ): Promise<TargetOutcome> {
199
- const {
200
- candidates,
201
- semantic,
202
- cwd,
203
- maxResults,
204
- control,
205
- totalCount,
206
- partialReason,
207
- partialMessage,
208
- exclusionNote,
209
- } = options;
196
+ const { candidates, semantic, cwd, maxResults, control, discovery, exclusionNote } = options;
210
197
  const ranged = candidates.filter(
211
198
  (candidate) =>
212
199
  candidate.declarationAnchor.line > 0 || candidate.declarationAnchor.character > 0,
213
200
  );
214
- if (ranged.length === 1 && totalCount !== null) {
201
+ if (ranged.length === 1 && discovery.partialMessage === null) {
215
202
  const resolved = resolvedTarget(await refineResolvedSymbolAnchor(ranged[0], semantic, control));
216
203
  // Exclusion-only evidence resolves, but the excluded rows stay disclosed.
217
204
  return exclusionNote ? { ...resolved, notes: [exclusionNote] } : resolved;
@@ -222,9 +209,7 @@ async function resolveCandidates(
222
209
  semantic,
223
210
  cwd,
224
211
  maxResults,
225
- totalCount,
226
- partialReason,
227
- partialMessage,
212
+ discovery,
228
213
  control,
229
214
  });
230
215
  }
@@ -258,21 +243,24 @@ interface CandidateOutcomeBase {
258
243
  control?: CodeRequestControl;
259
244
  }
260
245
 
261
- function candidateCompleteness(
246
+ /**
247
+ * Candidate collection status before the cap: exact when the provider was
248
+ * complete or removed only policy-excluded rows; otherwise provider-limited.
249
+ */
250
+ interface CandidateDiscovery {
251
+ readonly partialMessage: string | null;
252
+ }
253
+
254
+ function candidateDiscovery(
262
255
  result: Exclude<CodeQueryResult<CodeSymbol[]>, { kind: "unavailable" }>,
263
- totalCount: number,
264
256
  cwd: string,
265
- ): Omit<TargetCandidateCompleteness, "omittedCount"> {
257
+ ): CandidateDiscovery {
266
258
  // Policy exclusions alone remove only rows the workspace marked out of
267
259
  // automatic scope; the retained in-policy rows are complete. Failures and
268
260
  // coverage gaps keep the total unknown.
269
261
  return result.kind === "partial" && result.metadata?.exclusionOnly !== true
270
- ? {
271
- totalCount: null,
272
- partialReason: "provider-limited",
273
- partialMessage: describePartialQuery(result.reason, result.metadata, cwd),
274
- }
275
- : { totalCount, partialReason: null };
262
+ ? { partialMessage: describePartialQuery(result.reason, result.metadata, cwd) }
263
+ : { partialMessage: null };
276
264
  }
277
265
 
278
266
  /** Describe exclusion-only evidence so a resolved target still discloses dropped rows. */
@@ -284,9 +272,7 @@ function exclusionOnlyNote(
284
272
  return describePartialQuery(result.reason, result.metadata, cwd);
285
273
  }
286
274
 
287
- type CandidateOutcomeOptions = CandidateOutcomeBase &
288
- Omit<TargetCandidateCompleteness, "omittedCount"> &
289
- (
275
+ type CandidateOutcomeOptions = CandidateOutcomeBase & { discovery: CandidateDiscovery } & (
290
276
  | { kind: "disambiguation"; requestedKind?: never }
291
277
  | { kind: "kind-mismatch"; requestedKind: TargetSymbolKind }
292
278
  );
@@ -313,7 +299,7 @@ function emptySymbolOutcome(
313
299
  message: [
314
300
  `Symbol not found: \`${symbol}\`${scope ? ` in path \`${scope}\`` : ""}.`,
315
301
  "Workspace-symbol search covers only files in projects the language server has loaded; files outside them (e.g. excluded by tsconfig or in another toolchain's subtree) are not searched.",
316
- 'Next: `code_find` with `mode: "ast"` and `kind: "definition"` for a structural search, `code_resolve` with `target.file` if the file is known, or an anchor target (file/line/character) if the location is known.',
302
+ 'Next: `code_find` with `search.ast` and `kind: "definition"` for a structural search, `code_resolve` with `target.file` if the file is known, or an anchor target (file/line/character) if the location is known.',
317
303
  ].join(" "),
318
304
  };
319
305
  }
@@ -322,17 +308,25 @@ async function buildCandidateOutcome(
322
308
  options: CandidateOutcomeOptions,
323
309
  ): Promise<Extract<TargetOutcome, { kind: "disambiguation" | "kind-mismatch" }>> {
324
310
  const cap = options.maxResults ?? MAX_CANDIDATES;
311
+ const { partialMessage } = options.discovery;
312
+ const bounded =
313
+ partialMessage === null
314
+ ? createEvidenceList({ key: "target.candidates", items: options.candidates, maxResults: cap })
315
+ : createPartialEvidenceList({
316
+ key: "target.candidates",
317
+ items: options.candidates,
318
+ maxResults: cap,
319
+ partialReason: "provider-limited",
320
+ partialMessage,
321
+ });
325
322
  const refined = await Promise.all(
326
- options.candidates
327
- .slice(0, cap)
328
- .map((candidate) => refineResolvedSymbolAnchor(candidate, options.semantic, options.control)),
323
+ bounded.items.map((candidate) =>
324
+ refineResolvedSymbolAnchor(candidate, options.semantic, options.control),
325
+ ),
329
326
  );
330
327
  const common = {
331
328
  candidates: toDisambiguationCandidates(refined, options.cwd),
332
- totalCount: options.totalCount,
333
- omittedCount: Math.max(0, options.candidates.length - cap),
334
- partialReason: options.partialReason,
335
- partialMessage: options.partialMessage,
329
+ candidateEvidence: bounded.metadata,
336
330
  };
337
331
  return options.kind === "kind-mismatch"
338
332
  ? {
@@ -13,6 +13,7 @@ import type {
13
13
  } from "@mrclrchtr/supi-code-runtime/api";
14
14
  import type { TargetSymbolKind } from "../../session/target-input.ts";
15
15
  import type { AnchorKind, TargetProviderProvenance } from "../../session/target-store.ts";
16
+ import type { EvidenceListMetadata } from "../evidence.ts";
16
17
 
17
18
  export type { TargetProviderProvenance } from "../../session/target-store.ts";
18
19
 
@@ -167,16 +168,10 @@ export interface DisambiguationCandidateData {
167
168
  anchorKind: AnchorKind;
168
169
  }
169
170
 
170
- /** Completeness metadata for a bounded candidate collection. */
171
+ /** Completeness of a bounded candidate collection, keyed `target.candidates`. */
171
172
  export interface TargetCandidateCompleteness {
172
- /** Exact candidate total, or null when the provider returned partial data. */
173
- totalCount: number | null;
174
- /** Candidates returned by the provider but hidden by the target cap. */
175
- omittedCount: number;
176
- /** Why the provider cannot establish an exact candidate total. */
177
- partialReason: "provider-limited" | null;
178
- /** Provider explanation for incomplete discovery, when available. */
179
- partialMessage?: string;
173
+ /** Candidate Evidence list metadata; consumers re-key it, never rebuild it. */
174
+ candidateEvidence: EvidenceListMetadata;
180
175
  }
181
176
 
182
177
  /**
@@ -0,0 +1,207 @@
1
+ /**
2
+ * Minimal CMake language tokenizer for static `project()` observation.
3
+ *
4
+ * It follows the CMake language grammar for comments, bracket arguments,
5
+ * quoted arguments, unquoted arguments, and nested parentheses, and records
6
+ * command invocations with their block nesting. It never evaluates variables,
7
+ * conditions, functions, macros, or included files.
8
+ */
9
+
10
+ /** One command argument exactly as written. */
11
+ export interface CMakeArgument {
12
+ readonly form: "bracket" | "quoted" | "unquoted" | "paren";
13
+ /** Raw argument text without bracket or quote delimiters. */
14
+ readonly text: string;
15
+ }
16
+
17
+ /** One command invocation in source order. */
18
+ export interface CMakeCommand {
19
+ /** Lower-case command name; CMake command names are case-insensitive. */
20
+ readonly name: string;
21
+ /** One-based line of the command name. */
22
+ readonly line: number;
23
+ readonly args: readonly CMakeArgument[];
24
+ /** Number of enclosing control, function, macro, or block commands. */
25
+ readonly depth: number;
26
+ }
27
+
28
+ /** One syntax problem that stopped parsing. */
29
+ export interface CMakeParseIssue {
30
+ readonly line: number;
31
+ readonly reason: string;
32
+ }
33
+
34
+ /** Parsed commands, or the first syntax issue. */
35
+ export interface CMakeParseResult {
36
+ readonly commands: readonly CMakeCommand[];
37
+ readonly issue: CMakeParseIssue | null;
38
+ }
39
+
40
+ const OPENERS = new Set(["if", "foreach", "while", "function", "macro", "block"]);
41
+ const CLOSERS = new Set(["endif", "endforeach", "endwhile", "endfunction", "endmacro", "endblock"]);
42
+
43
+ class ParseError extends Error {
44
+ constructor(
45
+ readonly line: number,
46
+ message: string,
47
+ ) {
48
+ super(message);
49
+ }
50
+ }
51
+
52
+ /** Parse CMake source into command invocations. */
53
+ export function parseCMakeFile(text: string): CMakeParseResult {
54
+ const commands: CMakeCommand[] = [];
55
+ try {
56
+ new Scanner(text, commands).run();
57
+ return { commands, issue: null };
58
+ } catch (error) {
59
+ if (error instanceof ParseError)
60
+ return { commands: [], issue: { line: error.line, reason: error.message } };
61
+ throw error;
62
+ }
63
+ }
64
+
65
+ class Scanner {
66
+ private index = 0;
67
+ private line = 1;
68
+ private depth = 0;
69
+
70
+ constructor(
71
+ private readonly text: string,
72
+ private readonly commands: CMakeCommand[],
73
+ ) {}
74
+
75
+ run(): void {
76
+ while (this.index < this.text.length) {
77
+ const char = this.peek();
78
+ if (char === "\n" || char === " " || char === "\t" || char === "\r") this.advance();
79
+ else if (char === "#") this.skipComment();
80
+ else if (/[A-Za-z_]/.test(char)) this.readCommand();
81
+ else throw new ParseError(this.line, `Unexpected character ${JSON.stringify(char)}.`);
82
+ }
83
+ if (this.depth > 0)
84
+ throw new ParseError(this.line, "Unterminated control or definition block.");
85
+ }
86
+
87
+ private readCommand(): void {
88
+ const line = this.line;
89
+ const start = this.index;
90
+ while (/[A-Za-z0-9_]/.test(this.peek())) this.advance();
91
+ const name = this.text.slice(start, this.index).toLowerCase();
92
+ while (this.peek() === " " || this.peek() === "\t") this.advance();
93
+ if (this.peek() !== "(") throw new ParseError(line, `Command ${name} is missing "(".`);
94
+ this.advance();
95
+ const args = this.readArguments(line);
96
+ if (CLOSERS.has(name)) this.depth = Math.max(0, this.depth - 1);
97
+ this.commands.push({ name, line, args, depth: this.depth });
98
+ if (OPENERS.has(name)) this.depth += 1;
99
+ }
100
+
101
+ private readArguments(commandLine: number): CMakeArgument[] {
102
+ const args: CMakeArgument[] = [];
103
+ let nesting = 0;
104
+ for (;;) {
105
+ if (this.index >= this.text.length)
106
+ throw new ParseError(commandLine, "Unterminated command arguments.");
107
+ const char = this.peek();
108
+ if (char === ")" && nesting === 0) {
109
+ this.advance();
110
+ return args;
111
+ }
112
+ if (char === "(" || char === ")") {
113
+ this.advance();
114
+ nesting += char === "(" ? 1 : -1;
115
+ args.push({ form: "paren", text: char });
116
+ continue;
117
+ }
118
+ const argument = this.readArgument(char);
119
+ if (argument) args.push(argument);
120
+ }
121
+ }
122
+
123
+ /** Read one argument, or skip whitespace and comments and return null. */
124
+ private readArgument(char: string): CMakeArgument | null {
125
+ if (/\s/.test(char)) {
126
+ this.advance();
127
+ return null;
128
+ }
129
+ if (char === "#") {
130
+ this.skipComment();
131
+ return null;
132
+ }
133
+ if (char === "[" && this.bracketLevel() !== null)
134
+ return { form: "bracket", text: this.readBracket() };
135
+ if (char === '"') return { form: "quoted", text: this.readQuoted() };
136
+ return { form: "unquoted", text: this.readUnquoted() };
137
+ }
138
+
139
+ private skipComment(): void {
140
+ this.advance();
141
+ if (this.peek() === "[" && this.bracketLevel() !== null) {
142
+ this.readBracket();
143
+ return;
144
+ }
145
+ while (this.index < this.text.length && this.peek() !== "\n") this.advance();
146
+ }
147
+
148
+ /** Return the `=` count when a bracket opening starts at the cursor. */
149
+ private bracketLevel(): number | null {
150
+ const match = /^\[(=*)\[/.exec(this.text.slice(this.index, this.index + 256));
151
+ return match ? (match[1]?.length ?? 0) : null;
152
+ }
153
+
154
+ private readBracket(): string {
155
+ const line = this.line;
156
+ const level = this.bracketLevel() ?? 0;
157
+ this.advanceBy(level + 2);
158
+ const close = `]${"=".repeat(level)}]`;
159
+ const end = this.text.indexOf(close, this.index);
160
+ if (end < 0) throw new ParseError(line, "Unterminated bracket argument or comment.");
161
+ let content = this.text.slice(this.index, end);
162
+ this.advanceBy(end + close.length - this.index);
163
+ if (content.startsWith("\r\n")) content = content.slice(2);
164
+ else if (content.startsWith("\n")) content = content.slice(1);
165
+ return content;
166
+ }
167
+
168
+ private readQuoted(): string {
169
+ const line = this.line;
170
+ this.advance();
171
+ const start = this.index;
172
+ while (this.index < this.text.length) {
173
+ const char = this.peek();
174
+ if (char === "\\") this.advanceBy(2);
175
+ else if (char === '"') {
176
+ const content = this.text.slice(start, this.index);
177
+ this.advance();
178
+ return content;
179
+ } else this.advance();
180
+ }
181
+ throw new ParseError(line, "Unterminated quoted argument.");
182
+ }
183
+
184
+ private readUnquoted(): string {
185
+ const start = this.index;
186
+ while (this.index < this.text.length) {
187
+ const char = this.peek();
188
+ if (char === "\\") this.advanceBy(2);
189
+ else if (/[\s()#"]/.test(char)) break;
190
+ else this.advance();
191
+ }
192
+ return this.text.slice(start, this.index);
193
+ }
194
+
195
+ private peek(): string {
196
+ return this.text[this.index] ?? "";
197
+ }
198
+
199
+ private advance(): void {
200
+ if (this.text[this.index] === "\n") this.line += 1;
201
+ this.index += 1;
202
+ }
203
+
204
+ private advanceBy(count: number): void {
205
+ for (let step = 0; step < count && this.index < this.text.length; step += 1) this.advance();
206
+ }
207
+ }