@cybedefend/vibedefend 1.8.2 → 1.9.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 (328) hide show
  1. package/README.md +185 -17
  2. package/dist/auth/auth-store.js +16 -0
  3. package/dist/auth/auth-store.js.map +1 -1
  4. package/dist/clients/antigravity.js +30 -6
  5. package/dist/clients/antigravity.js.map +1 -1
  6. package/dist/clients/claude-code.js +209 -17
  7. package/dist/clients/claude-code.js.map +1 -1
  8. package/dist/clients/codex.js +171 -11
  9. package/dist/clients/codex.js.map +1 -1
  10. package/dist/clients/cursor.js +149 -9
  11. package/dist/clients/cursor.js.map +1 -1
  12. package/dist/clients/dependency-check-wiring.js +24 -0
  13. package/dist/clients/dependency-check-wiring.js.map +1 -0
  14. package/dist/clients/opencode-plugin.js +905 -0
  15. package/dist/clients/opencode-plugin.js.map +1 -0
  16. package/dist/clients/opencode.js +653 -0
  17. package/dist/clients/opencode.js.map +1 -0
  18. package/dist/clients/registry.js +2 -0
  19. package/dist/clients/registry.js.map +1 -1
  20. package/dist/clients/vscode.js +106 -12
  21. package/dist/clients/vscode.js.map +1 -1
  22. package/dist/clients/windsurf.js +9 -1
  23. package/dist/clients/windsurf.js.map +1 -1
  24. package/dist/commands/mcp/index.js +11 -0
  25. package/dist/commands/mcp/index.js.map +1 -1
  26. package/dist/config.js +4 -1
  27. package/dist/config.js.map +1 -1
  28. package/dist/diagnostics.js +22 -3
  29. package/dist/diagnostics.js.map +1 -1
  30. package/dist/doctor.js +26 -1
  31. package/dist/doctor.js.map +1 -1
  32. package/dist/guards-evaluator/command-analysis.js +347 -86
  33. package/dist/guards-evaluator/command-analysis.js.map +1 -1
  34. package/dist/guards-evaluator/command-view.js +116 -16
  35. package/dist/guards-evaluator/command-view.js.map +1 -1
  36. package/dist/guards-evaluator/evaluate.js +185 -41
  37. package/dist/guards-evaluator/evaluate.js.map +1 -1
  38. package/dist/guards-evaluator/file-reads.js +202 -0
  39. package/dist/guards-evaluator/file-reads.js.map +1 -0
  40. package/dist/guards-evaluator/index.js +1 -1
  41. package/dist/guards-evaluator/index.js.map +1 -1
  42. package/dist/guards-evaluator/inline-danger.js +299 -0
  43. package/dist/guards-evaluator/inline-danger.js.map +1 -0
  44. package/dist/guards-evaluator/normalize.js +1186 -55
  45. package/dist/guards-evaluator/normalize.js.map +1 -1
  46. package/dist/guards-evaluator/regex.js +91 -4
  47. package/dist/guards-evaluator/regex.js.map +1 -1
  48. package/dist/guards-evaluator/shell-files.js +587 -0
  49. package/dist/guards-evaluator/shell-files.js.map +1 -0
  50. package/dist/guards-evaluator/triage.js +32 -2
  51. package/dist/guards-evaluator/triage.js.map +1 -1
  52. package/dist/hook-runner.js +25601 -5423
  53. package/dist/hooks/install.js +8 -3
  54. package/dist/hooks/install.js.map +1 -1
  55. package/dist/hooks/runtime/antigravity-session.js +109 -50
  56. package/dist/hooks/runtime/antigravity-session.js.map +1 -1
  57. package/dist/hooks/runtime/apply-patch.js +92 -0
  58. package/dist/hooks/runtime/apply-patch.js.map +1 -0
  59. package/dist/hooks/runtime/caller-gate.js +27 -0
  60. package/dist/hooks/runtime/caller-gate.js.map +1 -0
  61. package/dist/hooks/runtime/code-mode.js +259 -0
  62. package/dist/hooks/runtime/code-mode.js.map +1 -0
  63. package/dist/hooks/runtime/dependency-check/api.js +179 -0
  64. package/dist/hooks/runtime/dependency-check/api.js.map +1 -0
  65. package/dist/hooks/runtime/dependency-check/capabilities.js +99 -0
  66. package/dist/hooks/runtime/dependency-check/capabilities.js.map +1 -0
  67. package/dist/hooks/runtime/dependency-check/checked-packages.js +48 -0
  68. package/dist/hooks/runtime/dependency-check/checked-packages.js.map +1 -0
  69. package/dist/hooks/runtime/dependency-check/commands/cwd.js +154 -0
  70. package/dist/hooks/runtime/dependency-check/commands/cwd.js.map +1 -0
  71. package/dist/hooks/runtime/dependency-check/commands/env.js +99 -0
  72. package/dist/hooks/runtime/dependency-check/commands/env.js.map +1 -0
  73. package/dist/hooks/runtime/dependency-check/commands/flags.js +164 -0
  74. package/dist/hooks/runtime/dependency-check/commands/flags.js.map +1 -0
  75. package/dist/hooks/runtime/dependency-check/commands/managers.js +418 -0
  76. package/dist/hooks/runtime/dependency-check/commands/managers.js.map +1 -0
  77. package/dist/hooks/runtime/dependency-check/commands/peel.js +111 -0
  78. package/dist/hooks/runtime/dependency-check/commands/peel.js.map +1 -0
  79. package/dist/hooks/runtime/dependency-check/commands/shell.js +217 -0
  80. package/dist/hooks/runtime/dependency-check/commands/shell.js.map +1 -0
  81. package/dist/hooks/runtime/dependency-check/commands/types.js +4 -0
  82. package/dist/hooks/runtime/dependency-check/commands/types.js.map +1 -0
  83. package/dist/hooks/runtime/dependency-check/commands.js +34 -0
  84. package/dist/hooks/runtime/dependency-check/commands.js.map +1 -0
  85. package/dist/hooks/runtime/dependency-check/deadlines.js +69 -0
  86. package/dist/hooks/runtime/dependency-check/deadlines.js.map +1 -0
  87. package/dist/hooks/runtime/dependency-check/dispatch.js +344 -0
  88. package/dist/hooks/runtime/dependency-check/dispatch.js.map +1 -0
  89. package/dist/hooks/runtime/dependency-check/entering.js +63 -0
  90. package/dist/hooks/runtime/dependency-check/entering.js.map +1 -0
  91. package/dist/hooks/runtime/dependency-check/exec-cache.js +36 -0
  92. package/dist/hooks/runtime/dependency-check/exec-cache.js.map +1 -0
  93. package/dist/hooks/runtime/dependency-check/git-blob.js +116 -0
  94. package/dist/hooks/runtime/dependency-check/git-blob.js.map +1 -0
  95. package/dist/hooks/runtime/dependency-check/hook.js +418 -0
  96. package/dist/hooks/runtime/dependency-check/hook.js.map +1 -0
  97. package/dist/hooks/runtime/dependency-check/local-store.js +74 -0
  98. package/dist/hooks/runtime/dependency-check/local-store.js.map +1 -0
  99. package/dist/hooks/runtime/dependency-check/lockfile-walk.js +89 -0
  100. package/dist/hooks/runtime/dependency-check/lockfile-walk.js.map +1 -0
  101. package/dist/hooks/runtime/dependency-check/lockfiles/bun.js +153 -0
  102. package/dist/hooks/runtime/dependency-check/lockfiles/bun.js.map +1 -0
  103. package/dist/hooks/runtime/dependency-check/lockfiles/by-name.js +46 -0
  104. package/dist/hooks/runtime/dependency-check/lockfiles/by-name.js.map +1 -0
  105. package/dist/hooks/runtime/dependency-check/lockfiles/cargo.js +91 -0
  106. package/dist/hooks/runtime/dependency-check/lockfiles/cargo.js.map +1 -0
  107. package/dist/hooks/runtime/dependency-check/lockfiles/composer.js +98 -0
  108. package/dist/hooks/runtime/dependency-check/lockfiles/composer.js.map +1 -0
  109. package/dist/hooks/runtime/dependency-check/lockfiles/gemfile.js +88 -0
  110. package/dist/hooks/runtime/dependency-check/lockfiles/gemfile.js.map +1 -0
  111. package/dist/hooks/runtime/dependency-check/lockfiles/go-mod.js +154 -0
  112. package/dist/hooks/runtime/dependency-check/lockfiles/go-mod.js.map +1 -0
  113. package/dist/hooks/runtime/dependency-check/lockfiles/gradle-lockfile.js +27 -0
  114. package/dist/hooks/runtime/dependency-check/lockfiles/gradle-lockfile.js.map +1 -0
  115. package/dist/hooks/runtime/dependency-check/lockfiles/graph.js +131 -0
  116. package/dist/hooks/runtime/dependency-check/lockfiles/graph.js.map +1 -0
  117. package/dist/hooks/runtime/dependency-check/lockfiles/npm.js +107 -0
  118. package/dist/hooks/runtime/dependency-check/lockfiles/npm.js.map +1 -0
  119. package/dist/hooks/runtime/dependency-check/lockfiles/nuget-packages-lock.js +60 -0
  120. package/dist/hooks/runtime/dependency-check/lockfiles/nuget-packages-lock.js.map +1 -0
  121. package/dist/hooks/runtime/dependency-check/lockfiles/pins.js +105 -0
  122. package/dist/hooks/runtime/dependency-check/lockfiles/pins.js.map +1 -0
  123. package/dist/hooks/runtime/dependency-check/lockfiles/pip-report.js +34 -0
  124. package/dist/hooks/runtime/dependency-check/lockfiles/pip-report.js.map +1 -0
  125. package/dist/hooks/runtime/dependency-check/lockfiles/pnpm.js +109 -0
  126. package/dist/hooks/runtime/dependency-check/lockfiles/pnpm.js.map +1 -0
  127. package/dist/hooks/runtime/dependency-check/lockfiles/poetry.js +105 -0
  128. package/dist/hooks/runtime/dependency-check/lockfiles/poetry.js.map +1 -0
  129. package/dist/hooks/runtime/dependency-check/lockfiles/uv.js +181 -0
  130. package/dist/hooks/runtime/dependency-check/lockfiles/uv.js.map +1 -0
  131. package/dist/hooks/runtime/dependency-check/lockfiles/yaml.js +319 -0
  132. package/dist/hooks/runtime/dependency-check/lockfiles/yaml.js.map +1 -0
  133. package/dist/hooks/runtime/dependency-check/lockfiles/yarn-berry.js +71 -0
  134. package/dist/hooks/runtime/dependency-check/lockfiles/yarn-berry.js.map +1 -0
  135. package/dist/hooks/runtime/dependency-check/lockfiles/yarn1.js +144 -0
  136. package/dist/hooks/runtime/dependency-check/lockfiles/yarn1.js.map +1 -0
  137. package/dist/hooks/runtime/dependency-check/manifests/apply.js +110 -0
  138. package/dist/hooks/runtime/dependency-check/manifests/apply.js.map +1 -0
  139. package/dist/hooks/runtime/dependency-check/manifests/diff.js +127 -0
  140. package/dist/hooks/runtime/dependency-check/manifests/diff.js.map +1 -0
  141. package/dist/hooks/runtime/dependency-check/manifests/edit.js +259 -0
  142. package/dist/hooks/runtime/dependency-check/manifests/edit.js.map +1 -0
  143. package/dist/hooks/runtime/dependency-check/manifests/json.js +109 -0
  144. package/dist/hooks/runtime/dependency-check/manifests/json.js.map +1 -0
  145. package/dist/hooks/runtime/dependency-check/manifests/kind.js +40 -0
  146. package/dist/hooks/runtime/dependency-check/manifests/kind.js.map +1 -0
  147. package/dist/hooks/runtime/dependency-check/manifests/patch.js +179 -0
  148. package/dist/hooks/runtime/dependency-check/manifests/patch.js.map +1 -0
  149. package/dist/hooks/runtime/dependency-check/manifests/text.js +665 -0
  150. package/dist/hooks/runtime/dependency-check/manifests/text.js.map +1 -0
  151. package/dist/hooks/runtime/dependency-check/manifests/toml.js +350 -0
  152. package/dist/hooks/runtime/dependency-check/manifests/toml.js.map +1 -0
  153. package/dist/hooks/runtime/dependency-check/manifests.js +14 -0
  154. package/dist/hooks/runtime/dependency-check/manifests.js.map +1 -0
  155. package/dist/hooks/runtime/dependency-check/messages.js +270 -0
  156. package/dist/hooks/runtime/dependency-check/messages.js.map +1 -0
  157. package/dist/hooks/runtime/dependency-check/net-baseline.js +157 -0
  158. package/dist/hooks/runtime/dependency-check/net-baseline.js.map +1 -0
  159. package/dist/hooks/runtime/dependency-check/net-state.js +70 -0
  160. package/dist/hooks/runtime/dependency-check/net-state.js.map +1 -0
  161. package/dist/hooks/runtime/dependency-check/pending-forces.js +54 -0
  162. package/dist/hooks/runtime/dependency-check/pending-forces.js.map +1 -0
  163. package/dist/hooks/runtime/dependency-check/post-tool-use.js +108 -0
  164. package/dist/hooks/runtime/dependency-check/post-tool-use.js.map +1 -0
  165. package/dist/hooks/runtime/dependency-check/ranges.js +369 -0
  166. package/dist/hooks/runtime/dependency-check/ranges.js.map +1 -0
  167. package/dist/hooks/runtime/dependency-check/requirement-files.js +144 -0
  168. package/dist/hooks/runtime/dependency-check/requirement-files.js.map +1 -0
  169. package/dist/hooks/runtime/dependency-check/resolvers/bun.js +38 -0
  170. package/dist/hooks/runtime/dependency-check/resolvers/bun.js.map +1 -0
  171. package/dist/hooks/runtime/dependency-check/resolvers/bundler.js +218 -0
  172. package/dist/hooks/runtime/dependency-check/resolvers/bundler.js.map +1 -0
  173. package/dist/hooks/runtime/dependency-check/resolvers/cargo.js +303 -0
  174. package/dist/hooks/runtime/dependency-check/resolvers/cargo.js.map +1 -0
  175. package/dist/hooks/runtime/dependency-check/resolvers/composer.js +250 -0
  176. package/dist/hooks/runtime/dependency-check/resolvers/composer.js.map +1 -0
  177. package/dist/hooks/runtime/dependency-check/resolvers/config-files.js +27 -0
  178. package/dist/hooks/runtime/dependency-check/resolvers/config-files.js.map +1 -0
  179. package/dist/hooks/runtime/dependency-check/resolvers/direct-only-registry.js +409 -0
  180. package/dist/hooks/runtime/dependency-check/resolvers/direct-only-registry.js.map +1 -0
  181. package/dist/hooks/runtime/dependency-check/resolvers/direct-only.js +290 -0
  182. package/dist/hooks/runtime/dependency-check/resolvers/direct-only.js.map +1 -0
  183. package/dist/hooks/runtime/dependency-check/resolvers/gem.js +89 -0
  184. package/dist/hooks/runtime/dependency-check/resolvers/gem.js.map +1 -0
  185. package/dist/hooks/runtime/dependency-check/resolvers/go.js +313 -0
  186. package/dist/hooks/runtime/dependency-check/resolvers/go.js.map +1 -0
  187. package/dist/hooks/runtime/dependency-check/resolvers/npm.js +81 -0
  188. package/dist/hooks/runtime/dependency-check/resolvers/npm.js.map +1 -0
  189. package/dist/hooks/runtime/dependency-check/resolvers/pip.js +229 -0
  190. package/dist/hooks/runtime/dependency-check/resolvers/pip.js.map +1 -0
  191. package/dist/hooks/runtime/dependency-check/resolvers/pipx.js +8 -0
  192. package/dist/hooks/runtime/dependency-check/resolvers/pipx.js.map +1 -0
  193. package/dist/hooks/runtime/dependency-check/resolvers/pnpm.js +68 -0
  194. package/dist/hooks/runtime/dependency-check/resolvers/pnpm.js.map +1 -0
  195. package/dist/hooks/runtime/dependency-check/resolvers/poetry.js +70 -0
  196. package/dist/hooks/runtime/dependency-check/resolvers/poetry.js.map +1 -0
  197. package/dist/hooks/runtime/dependency-check/resolvers/project.js +208 -0
  198. package/dist/hooks/runtime/dependency-check/resolvers/project.js.map +1 -0
  199. package/dist/hooks/runtime/dependency-check/resolvers/python-index.js +270 -0
  200. package/dist/hooks/runtime/dependency-check/resolvers/python-index.js.map +1 -0
  201. package/dist/hooks/runtime/dependency-check/resolvers/python.js +229 -0
  202. package/dist/hooks/runtime/dependency-check/resolvers/python.js.map +1 -0
  203. package/dist/hooks/runtime/dependency-check/resolvers/registry.js +221 -0
  204. package/dist/hooks/runtime/dependency-check/resolvers/registry.js.map +1 -0
  205. package/dist/hooks/runtime/dependency-check/resolvers/shared.js +440 -0
  206. package/dist/hooks/runtime/dependency-check/resolvers/shared.js.map +1 -0
  207. package/dist/hooks/runtime/dependency-check/resolvers/tree.js +131 -0
  208. package/dist/hooks/runtime/dependency-check/resolvers/tree.js.map +1 -0
  209. package/dist/hooks/runtime/dependency-check/resolvers/uv.js +433 -0
  210. package/dist/hooks/runtime/dependency-check/resolvers/uv.js.map +1 -0
  211. package/dist/hooks/runtime/dependency-check/resolvers/xml-lite.js +132 -0
  212. package/dist/hooks/runtime/dependency-check/resolvers/xml-lite.js.map +1 -0
  213. package/dist/hooks/runtime/dependency-check/resolvers/yarn-berry.js +106 -0
  214. package/dist/hooks/runtime/dependency-check/resolvers/yarn-berry.js.map +1 -0
  215. package/dist/hooks/runtime/dependency-check/sandbox.js +328 -0
  216. package/dist/hooks/runtime/dependency-check/sandbox.js.map +1 -0
  217. package/dist/hooks/runtime/dependency-check/specs.js +171 -0
  218. package/dist/hooks/runtime/dependency-check/specs.js.map +1 -0
  219. package/dist/hooks/runtime/dependency-check/static-view.js +90 -0
  220. package/dist/hooks/runtime/dependency-check/static-view.js.map +1 -0
  221. package/dist/hooks/runtime/dependency-check/stop-net.js +278 -0
  222. package/dist/hooks/runtime/dependency-check/stop-net.js.map +1 -0
  223. package/dist/hooks/runtime/dependency-check/stop-wiring.js +94 -0
  224. package/dist/hooks/runtime/dependency-check/stop-wiring.js.map +1 -0
  225. package/dist/hooks/runtime/dependency-check/tool-call.js +130 -0
  226. package/dist/hooks/runtime/dependency-check/tool-call.js.map +1 -0
  227. package/dist/hooks/runtime/dependency-check/types.js +96 -0
  228. package/dist/hooks/runtime/dependency-check/types.js.map +1 -0
  229. package/dist/hooks/runtime/emit.js +240 -52
  230. package/dist/hooks/runtime/emit.js.map +1 -1
  231. package/dist/hooks/runtime/exit-deadlock-guard.js +24 -8
  232. package/dist/hooks/runtime/exit-deadlock-guard.js.map +1 -1
  233. package/dist/hooks/runtime/fetch-rules.js +78 -29
  234. package/dist/hooks/runtime/fetch-rules.js.map +1 -1
  235. package/dist/hooks/runtime/grep-include.js +228 -0
  236. package/dist/hooks/runtime/grep-include.js.map +1 -0
  237. package/dist/hooks/runtime/pre-compact.js +1 -1
  238. package/dist/hooks/runtime/pre-compact.js.map +1 -1
  239. package/dist/hooks/runtime/pre-invocation.js +3 -3
  240. package/dist/hooks/runtime/pre-invocation.js.map +1 -1
  241. package/dist/hooks/runtime/repo-registry.js +72 -0
  242. package/dist/hooks/runtime/repo-registry.js.map +1 -0
  243. package/dist/hooks/runtime/repo-scope.js +75 -0
  244. package/dist/hooks/runtime/repo-scope.js.map +1 -0
  245. package/dist/hooks/runtime/resolve.js +11 -2
  246. package/dist/hooks/runtime/resolve.js.map +1 -1
  247. package/dist/hooks/runtime/runner-args.js +17 -2
  248. package/dist/hooks/runtime/runner-args.js.map +1 -1
  249. package/dist/hooks/runtime/script-resolve.js +21 -5
  250. package/dist/hooks/runtime/script-resolve.js.map +1 -1
  251. package/dist/hooks/runtime/session-activation.js +71 -18
  252. package/dist/hooks/runtime/session-activation.js.map +1 -1
  253. package/dist/hooks/runtime/session-review.js +184 -88
  254. package/dist/hooks/runtime/session-review.js.map +1 -1
  255. package/dist/hooks/runtime/session-start.js +68 -13
  256. package/dist/hooks/runtime/session-start.js.map +1 -1
  257. package/dist/hooks/runtime/session-writes.js +11 -5
  258. package/dist/hooks/runtime/session-writes.js.map +1 -1
  259. package/dist/hooks/runtime/shell-writes.js +7 -88
  260. package/dist/hooks/runtime/shell-writes.js.map +1 -1
  261. package/dist/hooks/runtime/sniff.js +227 -2
  262. package/dist/hooks/runtime/sniff.js.map +1 -1
  263. package/dist/hooks/runtime/target-resolve.js +32 -17
  264. package/dist/hooks/runtime/target-resolve.js.map +1 -1
  265. package/dist/hooks/runtime/unmapped-tools.js +77 -1
  266. package/dist/hooks/runtime/unmapped-tools.js.map +1 -1
  267. package/dist/hooks/runtime/user-prompt-submit.js +1 -1
  268. package/dist/hooks/runtime/user-prompt-submit.js.map +1 -1
  269. package/dist/hooks/runtime/work-dir.js +3 -0
  270. package/dist/hooks/runtime/work-dir.js.map +1 -1
  271. package/dist/hooks/shim.js +27 -20
  272. package/dist/hooks/shim.js.map +1 -1
  273. package/dist/index.js +46 -10
  274. package/dist/index.js.map +1 -1
  275. package/dist/install-scope.js +12 -0
  276. package/dist/install-scope.js.map +1 -0
  277. package/dist/install.js +188 -78
  278. package/dist/install.js.map +1 -1
  279. package/dist/link.js +55 -5
  280. package/dist/link.js.map +1 -1
  281. package/dist/mcp/config/hook.js +25 -0
  282. package/dist/mcp/config/hook.js.map +1 -1
  283. package/dist/org.js +3 -1
  284. package/dist/org.js.map +1 -1
  285. package/dist/prompts.js +97 -13
  286. package/dist/prompts.js.map +1 -1
  287. package/dist/refresh-hooks.js +67 -15
  288. package/dist/refresh-hooks.js.map +1 -1
  289. package/dist/repo/exclude-block.js +112 -0
  290. package/dist/repo/exclude-block.js.map +1 -0
  291. package/dist/repo/footer.js +93 -0
  292. package/dist/repo/footer.js.map +1 -0
  293. package/dist/repo/git-repo.js +77 -0
  294. package/dist/repo/git-repo.js.map +1 -0
  295. package/dist/repo/guarded-write.js +45 -0
  296. package/dist/repo/guarded-write.js.map +1 -0
  297. package/dist/repo/install-repo.js +508 -0
  298. package/dist/repo/install-repo.js.map +1 -0
  299. package/dist/repo/machine-wiring.js +122 -0
  300. package/dist/repo/machine-wiring.js.map +1 -0
  301. package/dist/repo/mcp-json.js +57 -0
  302. package/dist/repo/mcp-json.js.map +1 -0
  303. package/dist/repo/registry.js +53 -0
  304. package/dist/repo/registry.js.map +1 -0
  305. package/dist/repo/repo-mode-guard.js +83 -0
  306. package/dist/repo/repo-mode-guard.js.map +1 -0
  307. package/dist/repo/repo-setups.js +123 -0
  308. package/dist/repo/repo-setups.js.map +1 -0
  309. package/dist/repo/repo-status.js +283 -0
  310. package/dist/repo/repo-status.js.map +1 -0
  311. package/dist/repo/uninstall-repo.js +56 -0
  312. package/dist/repo/uninstall-repo.js.map +1 -0
  313. package/dist/repo/unsupported.js +14 -0
  314. package/dist/repo/unsupported.js.map +1 -0
  315. package/dist/scan-diff.js +526 -0
  316. package/dist/scan-diff.js.map +1 -0
  317. package/dist/shim.js +9 -7
  318. package/dist/status.js +53 -11
  319. package/dist/status.js.map +1 -1
  320. package/dist/uninstall.js +51 -3
  321. package/dist/uninstall.js.map +1 -1
  322. package/dist/update-check-gate.js +17 -0
  323. package/dist/update-check-gate.js.map +1 -0
  324. package/dist/update.js +6 -1
  325. package/dist/update.js.map +1 -1
  326. package/dist/zip.js +95 -0
  327. package/dist/zip.js.map +1 -0
  328. package/package.json +6 -3
@@ -0,0 +1,665 @@
1
+ /**
2
+ * Readers of the manifest formats that are not JSON or TOML: requirements
3
+ * files, go.mod, Gemfile and gemspec, mix.exs, pom.xml, Gradle, MSBuild and
4
+ * pubspec.yaml. Each takes the whole text and returns what it declares; none
5
+ * ever throws, and none evaluates anything (a Gemfile, a Gradle script and a
6
+ * mix.exs are code, read here only by pattern).
7
+ *
8
+ * `manifests.ts` owns the JSON and TOML readers (the only place that imports
9
+ * the TOML library) and the diff between two readings.
10
+ */
11
+ import { classify, classifyRange, pythonSpec, } from '../specs.js';
12
+ import { NAME_MAX, VERSION_MAX } from '../types.js';
13
+ export function emptyCollected() {
14
+ return { specs: [], notVerified: [] };
15
+ }
16
+ export function addNotVerified(c, name, reason, raw) {
17
+ c.notVerified.push({ name, reason, raw });
18
+ }
19
+ export function addParsed(c, p, name, raw, custom = false) {
20
+ if ('spec' in p)
21
+ c.specs.push(custom ? { ...p.spec, registry: 'custom' } : p.spec);
22
+ else if ('unparsed' in p)
23
+ addNotVerified(c, name, 'git_or_url', raw);
24
+ }
25
+ /** A value that is not a literal: a variable, a property, a substitution. */
26
+ export function nonLiteral(value) {
27
+ return /\$|`|[{}]/.test(value);
28
+ }
29
+ export function addSpec(c, ecosystem, name, range, custom = false) {
30
+ const r = range?.trim();
31
+ const spec = r ? { ecosystem, name, range: r } : { ecosystem, name };
32
+ if (custom)
33
+ spec.registry = 'custom';
34
+ c.specs.push(spec);
35
+ }
36
+ /** A name with a version part from a manifest, read for its ecosystem. */
37
+ export function addVersioned(c, ecosystem, name, range, custom = false) {
38
+ const r = range?.trim() ?? '';
39
+ const raw = `${name}@${r}`;
40
+ if (nonLiteral(name) || nonLiteral(r))
41
+ return addNotVerified(c, name, 'version_range', raw);
42
+ if (r !== '' && r !== '*') {
43
+ const k = classifyRange(r);
44
+ if (k)
45
+ return addParsed(c, k, name, raw, custom);
46
+ }
47
+ addSpec(c, ecosystem, name, r === '*' ? undefined : r, custom);
48
+ }
49
+ /** How two names of one ecosystem are the same package. */
50
+ export function nameKey(ecosystem, name) {
51
+ if (ecosystem === 'PyPI')
52
+ return name.toLowerCase().replace(/[-_.]+/g, '-');
53
+ return ecosystem === 'NuGet' || ecosystem === 'Packagist' ? name.toLowerCase() : name;
54
+ }
55
+ const lines = (text) => text.split(/\r?\n/);
56
+ // ---------------------------------------------------------------------------
57
+ // requirements*.txt
58
+ // ---------------------------------------------------------------------------
59
+ /** The package a URL or path names: `#egg=`, else the file or repository name. */
60
+ function urlName(raw) {
61
+ const egg = /[#&]egg=([A-Za-z0-9._-]+)/.exec(raw);
62
+ if (egg)
63
+ return egg[1];
64
+ const noQuery = raw.replace(/[#?].*$/, '').replace(/@[^/@]*$/, '');
65
+ const last = noQuery.split(/[/\\]/).filter(Boolean).pop() ?? raw;
66
+ if (/\.whl$/i.test(last))
67
+ return last.replace(/\.whl$/i, '').split('-')[0];
68
+ return last.replace(/\.(tar\.gz|tgz|zip|gem|git)$/i, '');
69
+ }
70
+ /**
71
+ * A regex source matching a long option of a requirements file the way pip
72
+ * reads it: optparse accepts any unambiguous prefix, so `--extra-ind` is
73
+ * `--extra-index-url`. `shortest` is the shortest prefix pip 26.2.1 accepted
74
+ * in a requirements file (measured: `--i`, `--ex`, `--f`, `--no-i`).
75
+ */
76
+ export function longOptionPrefixes(name, shortest) {
77
+ const prefixes = [];
78
+ for (let n = name.length; n >= shortest.length; n--)
79
+ prefixes.push(name.slice(0, n));
80
+ return `(?:${prefixes.join('|')})`;
81
+ }
82
+ const INDEX_OPTION_RE = new RegExp(`^(?:-i|${longOptionPrefixes('--index-url', '--i')}|${longOptionPrefixes('--extra-index-url', '--ex')})(?:\\s|=|$|[^-\\s])`);
83
+ export function readRequirements(text) {
84
+ const c = emptyCollected();
85
+ const logical = [];
86
+ let buf = '';
87
+ for (const raw of lines(text)) {
88
+ if (/\\\s*$/.test(raw)) {
89
+ buf += raw.replace(/\\\s*$/, ' ');
90
+ continue;
91
+ }
92
+ logical.push(buf + raw);
93
+ buf = '';
94
+ }
95
+ if (buf)
96
+ logical.push(buf);
97
+ const cleaned = logical.map((l) => l.replace(/(^|\s)#.*$/, '$1').trim());
98
+ // An index option anywhere in the file: its packages may come from that registry.
99
+ const custom = cleaned.some((l) => INDEX_OPTION_RE.test(l));
100
+ for (let line of cleaned) {
101
+ if (line === '')
102
+ continue;
103
+ if (line.startsWith('-')) {
104
+ // Options and includes are not specs; only an editable carries a source.
105
+ const ed = /^(?:-e|--editable)[\s=]+(\S+)/.exec(line);
106
+ if (!ed)
107
+ continue;
108
+ const k = classify(ed[1]);
109
+ if (k && 'unparsed' in k)
110
+ addNotVerified(c, urlName(ed[1]), 'git_or_url', ed[1]);
111
+ continue;
112
+ }
113
+ const option = line.search(/\s--?[A-Za-z]/); // --hash=…, per-requirement options
114
+ if (option >= 0)
115
+ line = line.slice(0, option).trim();
116
+ const p = pythonSpec(false)(line);
117
+ if (!('unparsed' in p)) {
118
+ addParsed(c, p, line, line, custom);
119
+ continue;
120
+ }
121
+ const named = /^[A-Za-z0-9](?:[A-Za-z0-9._-]*[A-Za-z0-9])?(?=\s*(?:\[[^\]]*\]\s*)?@)/.exec(line);
122
+ addNotVerified(c, named ? named[0] : urlName(line), 'git_or_url', line);
123
+ }
124
+ return c;
125
+ }
126
+ // ---------------------------------------------------------------------------
127
+ // go.mod
128
+ // ---------------------------------------------------------------------------
129
+ /**
130
+ * `lenient` reads a bare `path v1.2.3` line outside any block, which a patch
131
+ * hunk shows when the `require (` line is not in it. A hunk that shows a
132
+ * `replace (` or `exclude (` block keeps its lines out.
133
+ */
134
+ export function readGoMod(text, lenient = false) {
135
+ const c = emptyCollected();
136
+ let block = null;
137
+ for (const raw of lines(text)) {
138
+ const comment = raw.indexOf('//');
139
+ const line = (comment >= 0 ? raw.slice(0, comment) : raw).trim();
140
+ if (line === '')
141
+ continue;
142
+ const open = /^(require|replace|exclude|retract|tool|godebug|ignore)\s*\($/.exec(line);
143
+ if (open) {
144
+ block = open[1];
145
+ continue;
146
+ }
147
+ if (line.startsWith(')')) {
148
+ block = null;
149
+ continue;
150
+ }
151
+ const single = /^require\s+(\S+)\s+(\S+)$/.exec(line);
152
+ if (single) {
153
+ addSpec(c, 'Go', single[1], single[2]);
154
+ continue;
155
+ }
156
+ if (block === 'require' || (block === null && lenient)) {
157
+ const m = /^(\S+)\s+(v\d\S*)$/.exec(line);
158
+ if (m && !/^(go|module|toolchain|replace|exclude|retract)$/.test(m[1]))
159
+ addSpec(c, 'Go', m[1], m[2]);
160
+ }
161
+ }
162
+ return c;
163
+ }
164
+ // ---------------------------------------------------------------------------
165
+ // Gemfile, gemspec
166
+ // ---------------------------------------------------------------------------
167
+ const VERSION_LITERAL_RE = /^(?:~>|>=|<=|!=|=|<|>)?\s*\d[\w.+-]*$/; // on a trimmed literal
168
+ const INTERPOLATED_VERSION_RE = /^(?:(?:~>|>=|<=|!=|=|<|>)\s*)?(?:\d.*)?#\{/; // on a trimmed literal
169
+ /**
170
+ * The string literals of a line. A linear scan: a backslash escapes the next
171
+ * character, and an unterminated string ends at the end of the line.
172
+ */
173
+ export function stringLiterals(text) {
174
+ const out = [];
175
+ let i = 0;
176
+ while (i < text.length) {
177
+ const q = text[i];
178
+ if (q !== '"' && q !== "'") {
179
+ i++;
180
+ continue;
181
+ }
182
+ let j = i + 1;
183
+ let value = '';
184
+ let closed = false;
185
+ while (j < text.length) {
186
+ const ch = text[j];
187
+ if (ch === '\\' && j + 1 < text.length) {
188
+ value += ch + text[j + 1];
189
+ j += 2;
190
+ }
191
+ else if (ch === q) {
192
+ closed = true;
193
+ break;
194
+ }
195
+ else {
196
+ value += ch;
197
+ j++;
198
+ }
199
+ }
200
+ if (!closed)
201
+ break;
202
+ out.push(value);
203
+ i = j + 1;
204
+ }
205
+ return out;
206
+ }
207
+ /** The first string literal at the start of `text` (after spaces), if any. */
208
+ function leadingLiteral(text) {
209
+ const t = text.trimStart();
210
+ if (t[0] !== '"' && t[0] !== "'")
211
+ return undefined;
212
+ return stringLiterals(t)[0];
213
+ }
214
+ /** The arguments after a gem's name: versions, or a source that is not a registry. */
215
+ function addGem(c, name, argsText, inSourceBlock) {
216
+ const args = argsText.replace(/\s#(?!\{).*$/, '');
217
+ const literals = stringLiterals(args);
218
+ const raw = `${name} ${args.trim()}`;
219
+ if (nonLiteral(name) || literals.some((l) => INTERPOLATED_VERSION_RE.test(l.trim()))) {
220
+ return addNotVerified(c, name, 'version_range', raw);
221
+ }
222
+ if (/\b(?:git|github|gist|bitbucket)\s*:|:(?:git|github|gist|bitbucket)\s*=>/.test(args)) {
223
+ return addNotVerified(c, name, 'git_or_url', raw);
224
+ }
225
+ if (/\bpath\s*:|:path\s*=>/.test(args))
226
+ return;
227
+ const custom = inSourceBlock || /\bsource\s*:|:source\s*=>/.test(args);
228
+ const versions = literals.map((l) => l.trim()).filter((l) => VERSION_LITERAL_RE.test(l));
229
+ addSpec(c, 'RubyGems', name, versions.length ? versions.join(', ') : undefined, custom);
230
+ }
231
+ const RUBYGEMS_HOST_RE = /^https?:\/\/rubygems\.org\/?$/;
232
+ /** `source "https://g" do … end` on one line. */
233
+ const ONE_LINE_SOURCE_BLOCK_RE = /^\s*source\s+(['"])([^'"]*)\1\s+do\b(.*)\bend\b\s*$/;
234
+ const SOURCE_BLOCK_RE = /^\s*source\s+(['"])([^'"]*)\1\s+do\b/;
235
+ const TOP_SOURCE_RE = /^\s*source\s+(?::rubygems|(['"])([^'"]*)\1)\s*(?:#.*)?$/;
236
+ /** Lines that open a block closed by `end`. */
237
+ const BLOCK_OPENER_RE = /^\s*(?:def|class|module|if|unless|case|while|until|begin|for)\b(?!.*\bend\s*$)/;
238
+ const DO_BLOCK_RE = /\bdo(?:\s*\|[^|]*\|)?$/; // on a line without trailing whitespace
239
+ /**
240
+ * Gems of a Gemfile. A gem is on a custom registry when it names a `source:`,
241
+ * sits in a `source "…" do` block, or sits outside any block while the file's
242
+ * top-level `source` lines name no rubygems.org host.
243
+ */
244
+ export function readGemfile(text) {
245
+ const c = emptyCollected();
246
+ // One entry per open block: true / false for a `source "…" do` block (private / rubygems.org), null for any other.
247
+ const blocks = [];
248
+ const topSources = [];
249
+ const gems = [];
250
+ const own = () => {
251
+ for (let i = blocks.length - 1; i >= 0; i--)
252
+ if (blocks[i] !== null)
253
+ return blocks[i];
254
+ return null;
255
+ };
256
+ for (const line of lines(text)) {
257
+ if (/^\s*#/.test(line))
258
+ continue;
259
+ if (/^\s*end\b/.test(line)) {
260
+ blocks.pop();
261
+ continue;
262
+ }
263
+ const oneLine = ONE_LINE_SOURCE_BLOCK_RE.exec(line);
264
+ if (oneLine) {
265
+ for (const g of oneLine[3].matchAll(/\bgem\s*(?:\(\s*)?(['"])([^'"]+)\1([^;]*)/g)) {
266
+ gems.push({ name: g[2], args: g[3], own: !RUBYGEMS_HOST_RE.test(oneLine[2]) });
267
+ }
268
+ continue;
269
+ }
270
+ const gem = /^\s*gem\s*(?:\(\s*)?(['"])([^'"]+)\1(.*)$/.exec(line);
271
+ if (gem) {
272
+ gems.push({ name: gem[2], args: gem[3], own: own() });
273
+ continue;
274
+ }
275
+ const block = SOURCE_BLOCK_RE.exec(line);
276
+ if (block) {
277
+ blocks.push(!RUBYGEMS_HOST_RE.test(block[2]));
278
+ continue;
279
+ }
280
+ const top = TOP_SOURCE_RE.exec(line);
281
+ if (top && blocks.length === 0) {
282
+ topSources.push(top[2] === undefined ? 'rubygems' : top[2]);
283
+ continue;
284
+ }
285
+ if (DO_BLOCK_RE.test(line.trimEnd()) || BLOCK_OPENER_RE.test(line))
286
+ blocks.push(null);
287
+ }
288
+ // Only a source that is not rubygems.org makes the file's own gems private.
289
+ const privateTop = topSources.length > 0 && !topSources.some((u) => u === 'rubygems' || RUBYGEMS_HOST_RE.test(u));
290
+ for (const g of gems)
291
+ addGem(c, g.name, g.args, g.own ?? privateTop);
292
+ return c;
293
+ }
294
+ export function readGemspec(text) {
295
+ const c = emptyCollected();
296
+ for (const line of lines(text)) {
297
+ if (/^\s*#/.test(line))
298
+ continue;
299
+ const m = /\.add_(?:runtime_|development_)?dependency\s*(?:\(\s*)?(['"])([^'"]+)\1(.*)$/.exec(line);
300
+ if (m)
301
+ addGem(c, m[2], m[3], false);
302
+ }
303
+ return c;
304
+ }
305
+ // ---------------------------------------------------------------------------
306
+ // mix.exs
307
+ // ---------------------------------------------------------------------------
308
+ export function readMix(text) {
309
+ const c = emptyCollected();
310
+ const start = /\bdefp?\s+deps\b/.exec(text);
311
+ if (!start)
312
+ return c;
313
+ const rest = text.slice(start.index + start[0].length);
314
+ const end = /\n[ \t]*defp?\s+\w/.exec(rest);
315
+ const region = (end ? rest.slice(0, end.index) : rest).replace(/(^|\s)#(?!\{).*$/gm, '$1');
316
+ for (const m of region.matchAll(/\{\s*:([A-Za-z_]\w*)\s*(?:,((?:[^{}]|\{[^{}]*\})*))?\}/g)) {
317
+ const args = m[2] ?? '';
318
+ let name = m[1];
319
+ const hex = /\bhex:\s*:([A-Za-z_]\w*)/.exec(args);
320
+ if (hex)
321
+ name = hex[1];
322
+ const raw = `${name} ${args.trim()}`;
323
+ const version = leadingLiteral(args);
324
+ if (version !== undefined && /#\{/.test(version)) {
325
+ addNotVerified(c, name, 'version_range', raw);
326
+ }
327
+ else if (/\b(?:git|github)\s*:/.test(args)) {
328
+ addNotVerified(c, name, 'git_or_url', raw);
329
+ }
330
+ else if (/\b(?:path|in_umbrella)\s*:/.test(args)) {
331
+ continue;
332
+ }
333
+ else {
334
+ addSpec(c, 'Hex', name, version);
335
+ }
336
+ }
337
+ return c;
338
+ }
339
+ // ---------------------------------------------------------------------------
340
+ // pom.xml
341
+ // ---------------------------------------------------------------------------
342
+ /**
343
+ * Linear scans between two markers: each character is visited a bounded number
344
+ * of times, whatever the input. When a marker is never closed, no later one is
345
+ * either, so the scan stops there (the rest of the text is left as it is).
346
+ */
347
+ function blocksBetween(text, open, close) {
348
+ const out = [];
349
+ for (let i = text.indexOf(open); i >= 0;) {
350
+ const j = text.indexOf(close, i + open.length);
351
+ if (j < 0)
352
+ break;
353
+ out.push(text.slice(i + open.length, j));
354
+ i = text.indexOf(open, j + close.length);
355
+ }
356
+ return out;
357
+ }
358
+ /** `text` without the `open … close` blocks; an unclosed block is left in place. */
359
+ function removeBlocks(text, open, close) {
360
+ let out = '';
361
+ let at = 0;
362
+ for (let i = text.indexOf(open); i >= 0;) {
363
+ const j = text.indexOf(close, i + open.length);
364
+ if (j < 0)
365
+ break;
366
+ out += text.slice(at, i);
367
+ at = j + close.length;
368
+ i = text.indexOf(open, at);
369
+ }
370
+ return out + text.slice(at);
371
+ }
372
+ const stripXmlComments = (text) => removeBlocks(text, '<!--', '-->');
373
+ function xmlTag(body, tag) {
374
+ const m = new RegExp(`<${tag}>([^<]*)</${tag}>`).exec(body);
375
+ return m ? m[1].trim() : undefined;
376
+ }
377
+ /** `<name>value</name>` of every `<properties>` block of `text`. */
378
+ function pomProperties(text) {
379
+ const props = new Map();
380
+ for (const block of blocksBetween(text, '<properties>', '</properties>')) {
381
+ for (const t of block.matchAll(/<([\w.-]+)>([^<]*)<\/\1>/g))
382
+ props.set(t[1], t[2].trim());
383
+ }
384
+ return props;
385
+ }
386
+ /** What a property value may grow to: a version never exceeds this. */
387
+ const PROPERTY_VALUE_MAX = VERSION_MAX;
388
+ /** References expanded for one value, whatever they hold. */
389
+ const PROPERTY_EXPANSIONS_MAX = 200;
390
+ /**
391
+ * `${x}` replaced from the file's own properties. A key is never expanded
392
+ * inside its own expansion (a cycle stays `${x}`), the number of expansions is
393
+ * bounded, and a value that grows past the bound is given up as a whole. What
394
+ * stays `${…}` is undefined, cyclic, or not a property (`project.version`).
395
+ */
396
+ function substituteProperties(value, props, max = PROPERTY_VALUE_MAX) {
397
+ const budget = { left: PROPERTY_EXPANSIONS_MAX, overflow: false };
398
+ const expand = (v, active) => v.replace(/\$\{([^}]+)\}/g, (m, key) => {
399
+ const known = props.get(key);
400
+ if (known === undefined || active.has(key) || budget.left <= 0 || budget.overflow)
401
+ return m;
402
+ budget.left--;
403
+ active.add(key);
404
+ const out = expand(known, active);
405
+ active.delete(key);
406
+ if (out.length > max)
407
+ budget.overflow = true;
408
+ return out;
409
+ });
410
+ const result = expand(value, new Set());
411
+ return budget.overflow || result.length > max ? '${overflow}' : result;
412
+ }
413
+ function readPomDependencies(c, text, props) {
414
+ for (const block of blocksBetween(text, '<dependency>', '</dependency>')) {
415
+ const body = removeBlocks(block, '<exclusions>', '</exclusions>');
416
+ const group = xmlTag(body, 'groupId');
417
+ const artifact = xmlTag(body, 'artifactId');
418
+ const version = xmlTag(body, 'version');
419
+ if (!group || !artifact || !version)
420
+ continue; // managed by the parent or a BOM
421
+ const name = substituteProperties(`${group}:${artifact}`, props, NAME_MAX);
422
+ const resolved = substituteProperties(version, props);
423
+ if (nonLiteral(name) || nonLiteral(resolved))
424
+ addNotVerified(c, name, 'version_range', `${name}:${version}`);
425
+ else
426
+ addSpec(c, 'Maven', name, resolved);
427
+ }
428
+ }
429
+ /**
430
+ * Dependencies of the project and of its profiles. Properties come from the
431
+ * project level only (a profile's `<v>` does not hide the default); a profile's
432
+ * own dependencies resolve against its properties first, then the project's.
433
+ */
434
+ export function readPom(text) {
435
+ const c = emptyCollected();
436
+ const clean = stripXmlComments(text);
437
+ const profiles = blocksBetween(clean, '<profile>', '</profile>');
438
+ const projectText = removeBlocks(clean, '<profiles>', '</profiles>');
439
+ const projectProps = pomProperties(projectText);
440
+ readPomDependencies(c, projectText, projectProps);
441
+ for (const profile of profiles) {
442
+ readPomDependencies(c, profile, new Map([...projectProps, ...pomProperties(profile)]));
443
+ }
444
+ return c;
445
+ }
446
+ // ---------------------------------------------------------------------------
447
+ // Gradle
448
+ // ---------------------------------------------------------------------------
449
+ /** A configuration: `implementation`, `testImplementation`, `debugApi`, `kapt`, `classpath`… */
450
+ const GRADLE_CONFIG_RE = /^\s*((?:[a-z][A-Za-z]*?(?:Implementation|Api|CompileOnly|RuntimeOnly|AnnotationProcessor|Kapt|Ksp|Compile|Runtime|DevelopmentOnly|CoreLibraryDesugaring))|implementation|api|compileOnly|runtimeOnly|annotationProcessor|(?:kapt|ksp)(?:Test|AndroidTest)?|developmentOnly|coreLibraryDesugaring|classpath|compile|runtime)(?![A-Za-z0-9_])(.*)$/;
451
+ const GRADLE_STRING_RE = /^\s*(?:\(\s*)?(['"])((?:\\.|(?!\1)[^\\])*)\1/;
452
+ const GRADLE_MAP_RE = /group\s*[:=]\s*(['"])([^'"]+)\1\s*,\s*name\s*[:=]\s*(['"])([^'"]+)\3(?:\s*,\s*version\s*[:=]\s*(['"])([^'"]+)\5)?/;
453
+ const GRADLE_MAX_LINE = 4000;
454
+ export function readGradle(text) {
455
+ const c = emptyCollected();
456
+ for (const raw of lines(text)) {
457
+ if (raw.length > GRADLE_MAX_LINE)
458
+ continue;
459
+ const m = GRADLE_CONFIG_RE.exec(raw.replace(/\s\/\/.*$/, ''));
460
+ if (!m)
461
+ continue;
462
+ const rest = m[2];
463
+ const str = GRADLE_STRING_RE.exec(rest);
464
+ let group;
465
+ let artifact;
466
+ let version;
467
+ if (str) {
468
+ const parts = str[2].split(':');
469
+ if (parts.length < 2)
470
+ continue;
471
+ [group, artifact] = parts;
472
+ version = parts[2]?.replace(/@.*$/, '');
473
+ }
474
+ else {
475
+ const map = GRADLE_MAP_RE.exec(rest);
476
+ if (!map)
477
+ continue; // platform(), project(), files(), a catalogue reference
478
+ group = map[2];
479
+ artifact = map[4];
480
+ version = map[6];
481
+ }
482
+ const name = `${group}:${artifact}`;
483
+ if (version === undefined || version === '')
484
+ continue; // managed by a platform
485
+ if (nonLiteral(name) || nonLiteral(version))
486
+ addNotVerified(c, name, 'version_range', `${name}:${version}`);
487
+ else
488
+ addSpec(c, 'Maven', name, version);
489
+ }
490
+ return c;
491
+ }
492
+ // ---------------------------------------------------------------------------
493
+ // *.csproj, Directory.Packages.props
494
+ // ---------------------------------------------------------------------------
495
+ const isNameStart = (c) => (c >= 65 && c <= 90) || (c >= 97 && c <= 122) || c === 95;
496
+ const isNameChar = (c) => isNameStart(c) || (c >= 48 && c <= 57) || c === 46 || c === 45;
497
+ const isSpace = (c) => c === 32 || c === 9 || c === 10 || c === 13 || c === 12 || c === 11;
498
+ /**
499
+ * `name = "value"` / `name='value'` pairs of a start tag, in one pass: an
500
+ * identifier not followed by `=` is skipped whole (a regex retried it from
501
+ * each of its characters, quadratic on a long token), and an unclosed quote
502
+ * ends the scan.
503
+ */
504
+ export function xmlAttributes(text) {
505
+ const out = {};
506
+ const n = text.length;
507
+ let i = 0;
508
+ while (i < n) {
509
+ if (!isNameStart(text.charCodeAt(i))) {
510
+ i += 1;
511
+ continue;
512
+ }
513
+ let j = i + 1;
514
+ while (j < n && isNameChar(text.charCodeAt(j)))
515
+ j += 1;
516
+ let k = j;
517
+ while (k < n && isSpace(text.charCodeAt(k)))
518
+ k += 1;
519
+ if (text[k] !== '=') {
520
+ i = j;
521
+ continue;
522
+ }
523
+ k += 1;
524
+ while (k < n && isSpace(text.charCodeAt(k)))
525
+ k += 1;
526
+ const quote = text[k];
527
+ if (quote !== '"' && quote !== "'") {
528
+ i = k;
529
+ continue;
530
+ }
531
+ const end = text.indexOf(quote, k + 1);
532
+ if (end < 0)
533
+ break;
534
+ out[text.slice(i, j)] = text.slice(k + 1, end);
535
+ i = end + 1;
536
+ }
537
+ return out;
538
+ }
539
+ const DOTNET_ELEMENT_RE = /<(PackageReference|PackageVersion|GlobalPackageReference)\b/g;
540
+ /**
541
+ * Package elements, scanned with `indexOf` so that an unclosed element costs
542
+ * nothing more than the text it covers: the end of a start tag, and of an
543
+ * element, is looked for once, and a missing one ends the scan.
544
+ */
545
+ export function readDotnet(text) {
546
+ const c = emptyCollected();
547
+ const clean = stripXmlComments(text);
548
+ DOTNET_ELEMENT_RE.lastIndex = 0;
549
+ const unclosed = new Set();
550
+ for (let m = DOTNET_ELEMENT_RE.exec(clean); m;) {
551
+ const gt = clean.indexOf('>', DOTNET_ELEMENT_RE.lastIndex);
552
+ if (gt < 0)
553
+ break;
554
+ const selfClosing = clean[gt - 1] === '/';
555
+ const attrs = xmlAttributes(clean.slice(DOTNET_ELEMENT_RE.lastIndex, selfClosing ? gt - 1 : gt));
556
+ let resume = gt + 1;
557
+ let body;
558
+ if (!selfClosing && !unclosed.has(m[1])) {
559
+ const close = clean.indexOf(`</${m[1]}>`, gt + 1);
560
+ if (close >= 0) {
561
+ body = clean.slice(gt + 1, close);
562
+ resume = close + m[1].length + 3;
563
+ }
564
+ else
565
+ unclosed.add(m[1]); // no later element of this name has a closing tag either
566
+ }
567
+ const name = attrs.Include;
568
+ const version = attrs.Version ?? attrs.VersionOverride ?? (body ? xmlTag(body, 'Version') ?? xmlTag(body, 'VersionOverride') : undefined);
569
+ // `Update=` edits a reference declared elsewhere; no version: central package management.
570
+ if (name && version) {
571
+ if (/\$\(/.test(name) || /\$\(/.test(version))
572
+ addNotVerified(c, name, 'version_range', `${name}@${version}`);
573
+ else
574
+ addSpec(c, 'NuGet', name, version);
575
+ }
576
+ DOTNET_ELEMENT_RE.lastIndex = resume;
577
+ m = DOTNET_ELEMENT_RE.exec(clean);
578
+ }
579
+ return c;
580
+ }
581
+ // ---------------------------------------------------------------------------
582
+ // pubspec.yaml
583
+ // ---------------------------------------------------------------------------
584
+ const PUB_SECTIONS = new Set(['dependencies', 'dev_dependencies', 'dependency_overrides']);
585
+ const unquote = (v) => v.trim().replace(/^(['"])(.*)\1$/, '$2');
586
+ /**
587
+ * `dependencies:`, `dev_dependencies:` and `dependency_overrides:` blocks. An
588
+ * entry is a version string or a map: a `git` entry is not verified, a
589
+ * `hosted` one is a spec declared on a custom registry, `path` and `sdk`
590
+ * entries are the project's own.
591
+ */
592
+ export function readPubspec(text) {
593
+ const c = emptyCollected();
594
+ let inSection = false;
595
+ let entryIndent = -1;
596
+ let childIndent = -1;
597
+ let current = null;
598
+ const flush = () => {
599
+ if (!current)
600
+ return;
601
+ const { name, keys } = current;
602
+ current = null;
603
+ if ('git' in keys)
604
+ addNotVerified(c, name, 'git_or_url', JSON.stringify(keys));
605
+ else if ('path' in keys || 'sdk' in keys)
606
+ return;
607
+ else
608
+ addPubVersion(c, name, keys.version, 'hosted' in keys);
609
+ };
610
+ for (const raw of lines(text)) {
611
+ const line = raw.replace(/(^|\s)#.*$/, '$1');
612
+ if (line.trim() === '')
613
+ continue;
614
+ const indent = line.length - line.trimStart().length;
615
+ if (indent === 0) {
616
+ flush();
617
+ const head = /^([A-Za-z_]+)\s*:\s*$/.exec(line);
618
+ inSection = head !== null && PUB_SECTIONS.has(head[1]);
619
+ entryIndent = -1;
620
+ childIndent = -1;
621
+ continue;
622
+ }
623
+ if (!inSection)
624
+ continue;
625
+ if (entryIndent < 0)
626
+ entryIndent = indent;
627
+ const kv = /^\s*([A-Za-z_][\w]*)\s*:\s*(.*)$/.exec(line);
628
+ if (!kv)
629
+ continue;
630
+ if (indent === entryIndent) {
631
+ flush();
632
+ const value = kv[2].trim();
633
+ if (value === '') {
634
+ current = { name: kv[1], keys: {} };
635
+ childIndent = -1;
636
+ }
637
+ else if (value.startsWith('{')) {
638
+ const keys = {};
639
+ for (const k of value.matchAll(/\b(git|path|sdk|hosted|version)\s*:\s*(?:(['"])(.*?)\2|([^,}\s]+))/g)) {
640
+ keys[k[1]] = k[3] ?? k[4];
641
+ }
642
+ current = { name: kv[1], keys };
643
+ flush();
644
+ }
645
+ else {
646
+ addPubVersion(c, kv[1], unquote(value), false);
647
+ }
648
+ }
649
+ else if (current && indent > entryIndent) {
650
+ if (childIndent < 0)
651
+ childIndent = indent;
652
+ if (indent === childIndent)
653
+ current.keys[kv[1]] = unquote(kv[2]);
654
+ }
655
+ }
656
+ flush();
657
+ return c;
658
+ }
659
+ function addPubVersion(c, name, version, custom) {
660
+ const v = version?.trim();
661
+ if (v === undefined || v === '' || v === 'any')
662
+ return addSpec(c, 'Pub', name, undefined, custom);
663
+ addVersioned(c, 'Pub', name, v, custom);
664
+ }
665
+ //# sourceMappingURL=text.js.map