@cybedefend/vibedefend 1.8.3 → 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 (320) hide show
  1. package/README.md +135 -16
  2. package/dist/clients/antigravity.js +30 -6
  3. package/dist/clients/antigravity.js.map +1 -1
  4. package/dist/clients/claude-code.js +209 -17
  5. package/dist/clients/claude-code.js.map +1 -1
  6. package/dist/clients/codex.js +171 -11
  7. package/dist/clients/codex.js.map +1 -1
  8. package/dist/clients/cursor.js +149 -9
  9. package/dist/clients/cursor.js.map +1 -1
  10. package/dist/clients/dependency-check-wiring.js +24 -0
  11. package/dist/clients/dependency-check-wiring.js.map +1 -0
  12. package/dist/clients/opencode-plugin.js +905 -0
  13. package/dist/clients/opencode-plugin.js.map +1 -0
  14. package/dist/clients/opencode.js +653 -0
  15. package/dist/clients/opencode.js.map +1 -0
  16. package/dist/clients/registry.js +2 -0
  17. package/dist/clients/registry.js.map +1 -1
  18. package/dist/clients/vscode.js +106 -12
  19. package/dist/clients/vscode.js.map +1 -1
  20. package/dist/clients/windsurf.js +9 -1
  21. package/dist/clients/windsurf.js.map +1 -1
  22. package/dist/commands/mcp/index.js +11 -0
  23. package/dist/commands/mcp/index.js.map +1 -1
  24. package/dist/config.js +3 -0
  25. package/dist/config.js.map +1 -1
  26. package/dist/diagnostics.js +22 -3
  27. package/dist/diagnostics.js.map +1 -1
  28. package/dist/doctor.js +26 -1
  29. package/dist/doctor.js.map +1 -1
  30. package/dist/guards-evaluator/command-analysis.js +347 -86
  31. package/dist/guards-evaluator/command-analysis.js.map +1 -1
  32. package/dist/guards-evaluator/command-view.js +116 -16
  33. package/dist/guards-evaluator/command-view.js.map +1 -1
  34. package/dist/guards-evaluator/evaluate.js +185 -41
  35. package/dist/guards-evaluator/evaluate.js.map +1 -1
  36. package/dist/guards-evaluator/file-reads.js +202 -0
  37. package/dist/guards-evaluator/file-reads.js.map +1 -0
  38. package/dist/guards-evaluator/index.js +1 -1
  39. package/dist/guards-evaluator/index.js.map +1 -1
  40. package/dist/guards-evaluator/inline-danger.js +299 -0
  41. package/dist/guards-evaluator/inline-danger.js.map +1 -0
  42. package/dist/guards-evaluator/normalize.js +1186 -55
  43. package/dist/guards-evaluator/normalize.js.map +1 -1
  44. package/dist/guards-evaluator/regex.js +91 -4
  45. package/dist/guards-evaluator/regex.js.map +1 -1
  46. package/dist/guards-evaluator/shell-files.js +587 -0
  47. package/dist/guards-evaluator/shell-files.js.map +1 -0
  48. package/dist/guards-evaluator/triage.js +32 -2
  49. package/dist/guards-evaluator/triage.js.map +1 -1
  50. package/dist/hook-runner.js +25598 -5432
  51. package/dist/hooks/install.js +8 -3
  52. package/dist/hooks/install.js.map +1 -1
  53. package/dist/hooks/runtime/antigravity-session.js +109 -50
  54. package/dist/hooks/runtime/antigravity-session.js.map +1 -1
  55. package/dist/hooks/runtime/apply-patch.js +92 -0
  56. package/dist/hooks/runtime/apply-patch.js.map +1 -0
  57. package/dist/hooks/runtime/caller-gate.js +27 -0
  58. package/dist/hooks/runtime/caller-gate.js.map +1 -0
  59. package/dist/hooks/runtime/code-mode.js +259 -0
  60. package/dist/hooks/runtime/code-mode.js.map +1 -0
  61. package/dist/hooks/runtime/dependency-check/api.js +179 -0
  62. package/dist/hooks/runtime/dependency-check/api.js.map +1 -0
  63. package/dist/hooks/runtime/dependency-check/capabilities.js +99 -0
  64. package/dist/hooks/runtime/dependency-check/capabilities.js.map +1 -0
  65. package/dist/hooks/runtime/dependency-check/checked-packages.js +48 -0
  66. package/dist/hooks/runtime/dependency-check/checked-packages.js.map +1 -0
  67. package/dist/hooks/runtime/dependency-check/commands/cwd.js +154 -0
  68. package/dist/hooks/runtime/dependency-check/commands/cwd.js.map +1 -0
  69. package/dist/hooks/runtime/dependency-check/commands/env.js +99 -0
  70. package/dist/hooks/runtime/dependency-check/commands/env.js.map +1 -0
  71. package/dist/hooks/runtime/dependency-check/commands/flags.js +164 -0
  72. package/dist/hooks/runtime/dependency-check/commands/flags.js.map +1 -0
  73. package/dist/hooks/runtime/dependency-check/commands/managers.js +418 -0
  74. package/dist/hooks/runtime/dependency-check/commands/managers.js.map +1 -0
  75. package/dist/hooks/runtime/dependency-check/commands/peel.js +111 -0
  76. package/dist/hooks/runtime/dependency-check/commands/peel.js.map +1 -0
  77. package/dist/hooks/runtime/dependency-check/commands/shell.js +217 -0
  78. package/dist/hooks/runtime/dependency-check/commands/shell.js.map +1 -0
  79. package/dist/hooks/runtime/dependency-check/commands/types.js +4 -0
  80. package/dist/hooks/runtime/dependency-check/commands/types.js.map +1 -0
  81. package/dist/hooks/runtime/dependency-check/commands.js +34 -0
  82. package/dist/hooks/runtime/dependency-check/commands.js.map +1 -0
  83. package/dist/hooks/runtime/dependency-check/deadlines.js +69 -0
  84. package/dist/hooks/runtime/dependency-check/deadlines.js.map +1 -0
  85. package/dist/hooks/runtime/dependency-check/dispatch.js +344 -0
  86. package/dist/hooks/runtime/dependency-check/dispatch.js.map +1 -0
  87. package/dist/hooks/runtime/dependency-check/entering.js +63 -0
  88. package/dist/hooks/runtime/dependency-check/entering.js.map +1 -0
  89. package/dist/hooks/runtime/dependency-check/exec-cache.js +36 -0
  90. package/dist/hooks/runtime/dependency-check/exec-cache.js.map +1 -0
  91. package/dist/hooks/runtime/dependency-check/git-blob.js +116 -0
  92. package/dist/hooks/runtime/dependency-check/git-blob.js.map +1 -0
  93. package/dist/hooks/runtime/dependency-check/hook.js +418 -0
  94. package/dist/hooks/runtime/dependency-check/hook.js.map +1 -0
  95. package/dist/hooks/runtime/dependency-check/local-store.js +74 -0
  96. package/dist/hooks/runtime/dependency-check/local-store.js.map +1 -0
  97. package/dist/hooks/runtime/dependency-check/lockfile-walk.js +89 -0
  98. package/dist/hooks/runtime/dependency-check/lockfile-walk.js.map +1 -0
  99. package/dist/hooks/runtime/dependency-check/lockfiles/bun.js +153 -0
  100. package/dist/hooks/runtime/dependency-check/lockfiles/bun.js.map +1 -0
  101. package/dist/hooks/runtime/dependency-check/lockfiles/by-name.js +46 -0
  102. package/dist/hooks/runtime/dependency-check/lockfiles/by-name.js.map +1 -0
  103. package/dist/hooks/runtime/dependency-check/lockfiles/cargo.js +91 -0
  104. package/dist/hooks/runtime/dependency-check/lockfiles/cargo.js.map +1 -0
  105. package/dist/hooks/runtime/dependency-check/lockfiles/composer.js +98 -0
  106. package/dist/hooks/runtime/dependency-check/lockfiles/composer.js.map +1 -0
  107. package/dist/hooks/runtime/dependency-check/lockfiles/gemfile.js +88 -0
  108. package/dist/hooks/runtime/dependency-check/lockfiles/gemfile.js.map +1 -0
  109. package/dist/hooks/runtime/dependency-check/lockfiles/go-mod.js +154 -0
  110. package/dist/hooks/runtime/dependency-check/lockfiles/go-mod.js.map +1 -0
  111. package/dist/hooks/runtime/dependency-check/lockfiles/gradle-lockfile.js +27 -0
  112. package/dist/hooks/runtime/dependency-check/lockfiles/gradle-lockfile.js.map +1 -0
  113. package/dist/hooks/runtime/dependency-check/lockfiles/graph.js +131 -0
  114. package/dist/hooks/runtime/dependency-check/lockfiles/graph.js.map +1 -0
  115. package/dist/hooks/runtime/dependency-check/lockfiles/npm.js +107 -0
  116. package/dist/hooks/runtime/dependency-check/lockfiles/npm.js.map +1 -0
  117. package/dist/hooks/runtime/dependency-check/lockfiles/nuget-packages-lock.js +60 -0
  118. package/dist/hooks/runtime/dependency-check/lockfiles/nuget-packages-lock.js.map +1 -0
  119. package/dist/hooks/runtime/dependency-check/lockfiles/pins.js +105 -0
  120. package/dist/hooks/runtime/dependency-check/lockfiles/pins.js.map +1 -0
  121. package/dist/hooks/runtime/dependency-check/lockfiles/pip-report.js +34 -0
  122. package/dist/hooks/runtime/dependency-check/lockfiles/pip-report.js.map +1 -0
  123. package/dist/hooks/runtime/dependency-check/lockfiles/pnpm.js +109 -0
  124. package/dist/hooks/runtime/dependency-check/lockfiles/pnpm.js.map +1 -0
  125. package/dist/hooks/runtime/dependency-check/lockfiles/poetry.js +105 -0
  126. package/dist/hooks/runtime/dependency-check/lockfiles/poetry.js.map +1 -0
  127. package/dist/hooks/runtime/dependency-check/lockfiles/uv.js +181 -0
  128. package/dist/hooks/runtime/dependency-check/lockfiles/uv.js.map +1 -0
  129. package/dist/hooks/runtime/dependency-check/lockfiles/yaml.js +319 -0
  130. package/dist/hooks/runtime/dependency-check/lockfiles/yaml.js.map +1 -0
  131. package/dist/hooks/runtime/dependency-check/lockfiles/yarn-berry.js +71 -0
  132. package/dist/hooks/runtime/dependency-check/lockfiles/yarn-berry.js.map +1 -0
  133. package/dist/hooks/runtime/dependency-check/lockfiles/yarn1.js +144 -0
  134. package/dist/hooks/runtime/dependency-check/lockfiles/yarn1.js.map +1 -0
  135. package/dist/hooks/runtime/dependency-check/manifests/apply.js +110 -0
  136. package/dist/hooks/runtime/dependency-check/manifests/apply.js.map +1 -0
  137. package/dist/hooks/runtime/dependency-check/manifests/diff.js +127 -0
  138. package/dist/hooks/runtime/dependency-check/manifests/diff.js.map +1 -0
  139. package/dist/hooks/runtime/dependency-check/manifests/edit.js +259 -0
  140. package/dist/hooks/runtime/dependency-check/manifests/edit.js.map +1 -0
  141. package/dist/hooks/runtime/dependency-check/manifests/json.js +109 -0
  142. package/dist/hooks/runtime/dependency-check/manifests/json.js.map +1 -0
  143. package/dist/hooks/runtime/dependency-check/manifests/kind.js +40 -0
  144. package/dist/hooks/runtime/dependency-check/manifests/kind.js.map +1 -0
  145. package/dist/hooks/runtime/dependency-check/manifests/patch.js +179 -0
  146. package/dist/hooks/runtime/dependency-check/manifests/patch.js.map +1 -0
  147. package/dist/hooks/runtime/dependency-check/manifests/text.js +665 -0
  148. package/dist/hooks/runtime/dependency-check/manifests/text.js.map +1 -0
  149. package/dist/hooks/runtime/dependency-check/manifests/toml.js +350 -0
  150. package/dist/hooks/runtime/dependency-check/manifests/toml.js.map +1 -0
  151. package/dist/hooks/runtime/dependency-check/manifests.js +14 -0
  152. package/dist/hooks/runtime/dependency-check/manifests.js.map +1 -0
  153. package/dist/hooks/runtime/dependency-check/messages.js +270 -0
  154. package/dist/hooks/runtime/dependency-check/messages.js.map +1 -0
  155. package/dist/hooks/runtime/dependency-check/net-baseline.js +157 -0
  156. package/dist/hooks/runtime/dependency-check/net-baseline.js.map +1 -0
  157. package/dist/hooks/runtime/dependency-check/net-state.js +70 -0
  158. package/dist/hooks/runtime/dependency-check/net-state.js.map +1 -0
  159. package/dist/hooks/runtime/dependency-check/pending-forces.js +54 -0
  160. package/dist/hooks/runtime/dependency-check/pending-forces.js.map +1 -0
  161. package/dist/hooks/runtime/dependency-check/post-tool-use.js +108 -0
  162. package/dist/hooks/runtime/dependency-check/post-tool-use.js.map +1 -0
  163. package/dist/hooks/runtime/dependency-check/ranges.js +369 -0
  164. package/dist/hooks/runtime/dependency-check/ranges.js.map +1 -0
  165. package/dist/hooks/runtime/dependency-check/requirement-files.js +144 -0
  166. package/dist/hooks/runtime/dependency-check/requirement-files.js.map +1 -0
  167. package/dist/hooks/runtime/dependency-check/resolvers/bun.js +38 -0
  168. package/dist/hooks/runtime/dependency-check/resolvers/bun.js.map +1 -0
  169. package/dist/hooks/runtime/dependency-check/resolvers/bundler.js +218 -0
  170. package/dist/hooks/runtime/dependency-check/resolvers/bundler.js.map +1 -0
  171. package/dist/hooks/runtime/dependency-check/resolvers/cargo.js +303 -0
  172. package/dist/hooks/runtime/dependency-check/resolvers/cargo.js.map +1 -0
  173. package/dist/hooks/runtime/dependency-check/resolvers/composer.js +250 -0
  174. package/dist/hooks/runtime/dependency-check/resolvers/composer.js.map +1 -0
  175. package/dist/hooks/runtime/dependency-check/resolvers/config-files.js +27 -0
  176. package/dist/hooks/runtime/dependency-check/resolvers/config-files.js.map +1 -0
  177. package/dist/hooks/runtime/dependency-check/resolvers/direct-only-registry.js +409 -0
  178. package/dist/hooks/runtime/dependency-check/resolvers/direct-only-registry.js.map +1 -0
  179. package/dist/hooks/runtime/dependency-check/resolvers/direct-only.js +290 -0
  180. package/dist/hooks/runtime/dependency-check/resolvers/direct-only.js.map +1 -0
  181. package/dist/hooks/runtime/dependency-check/resolvers/gem.js +89 -0
  182. package/dist/hooks/runtime/dependency-check/resolvers/gem.js.map +1 -0
  183. package/dist/hooks/runtime/dependency-check/resolvers/go.js +313 -0
  184. package/dist/hooks/runtime/dependency-check/resolvers/go.js.map +1 -0
  185. package/dist/hooks/runtime/dependency-check/resolvers/npm.js +81 -0
  186. package/dist/hooks/runtime/dependency-check/resolvers/npm.js.map +1 -0
  187. package/dist/hooks/runtime/dependency-check/resolvers/pip.js +229 -0
  188. package/dist/hooks/runtime/dependency-check/resolvers/pip.js.map +1 -0
  189. package/dist/hooks/runtime/dependency-check/resolvers/pipx.js +8 -0
  190. package/dist/hooks/runtime/dependency-check/resolvers/pipx.js.map +1 -0
  191. package/dist/hooks/runtime/dependency-check/resolvers/pnpm.js +68 -0
  192. package/dist/hooks/runtime/dependency-check/resolvers/pnpm.js.map +1 -0
  193. package/dist/hooks/runtime/dependency-check/resolvers/poetry.js +70 -0
  194. package/dist/hooks/runtime/dependency-check/resolvers/poetry.js.map +1 -0
  195. package/dist/hooks/runtime/dependency-check/resolvers/project.js +208 -0
  196. package/dist/hooks/runtime/dependency-check/resolvers/project.js.map +1 -0
  197. package/dist/hooks/runtime/dependency-check/resolvers/python-index.js +270 -0
  198. package/dist/hooks/runtime/dependency-check/resolvers/python-index.js.map +1 -0
  199. package/dist/hooks/runtime/dependency-check/resolvers/python.js +229 -0
  200. package/dist/hooks/runtime/dependency-check/resolvers/python.js.map +1 -0
  201. package/dist/hooks/runtime/dependency-check/resolvers/registry.js +221 -0
  202. package/dist/hooks/runtime/dependency-check/resolvers/registry.js.map +1 -0
  203. package/dist/hooks/runtime/dependency-check/resolvers/shared.js +440 -0
  204. package/dist/hooks/runtime/dependency-check/resolvers/shared.js.map +1 -0
  205. package/dist/hooks/runtime/dependency-check/resolvers/tree.js +131 -0
  206. package/dist/hooks/runtime/dependency-check/resolvers/tree.js.map +1 -0
  207. package/dist/hooks/runtime/dependency-check/resolvers/uv.js +433 -0
  208. package/dist/hooks/runtime/dependency-check/resolvers/uv.js.map +1 -0
  209. package/dist/hooks/runtime/dependency-check/resolvers/xml-lite.js +132 -0
  210. package/dist/hooks/runtime/dependency-check/resolvers/xml-lite.js.map +1 -0
  211. package/dist/hooks/runtime/dependency-check/resolvers/yarn-berry.js +106 -0
  212. package/dist/hooks/runtime/dependency-check/resolvers/yarn-berry.js.map +1 -0
  213. package/dist/hooks/runtime/dependency-check/sandbox.js +328 -0
  214. package/dist/hooks/runtime/dependency-check/sandbox.js.map +1 -0
  215. package/dist/hooks/runtime/dependency-check/specs.js +171 -0
  216. package/dist/hooks/runtime/dependency-check/specs.js.map +1 -0
  217. package/dist/hooks/runtime/dependency-check/static-view.js +90 -0
  218. package/dist/hooks/runtime/dependency-check/static-view.js.map +1 -0
  219. package/dist/hooks/runtime/dependency-check/stop-net.js +278 -0
  220. package/dist/hooks/runtime/dependency-check/stop-net.js.map +1 -0
  221. package/dist/hooks/runtime/dependency-check/stop-wiring.js +94 -0
  222. package/dist/hooks/runtime/dependency-check/stop-wiring.js.map +1 -0
  223. package/dist/hooks/runtime/dependency-check/tool-call.js +130 -0
  224. package/dist/hooks/runtime/dependency-check/tool-call.js.map +1 -0
  225. package/dist/hooks/runtime/dependency-check/types.js +96 -0
  226. package/dist/hooks/runtime/dependency-check/types.js.map +1 -0
  227. package/dist/hooks/runtime/emit.js +240 -52
  228. package/dist/hooks/runtime/emit.js.map +1 -1
  229. package/dist/hooks/runtime/exit-deadlock-guard.js +24 -8
  230. package/dist/hooks/runtime/exit-deadlock-guard.js.map +1 -1
  231. package/dist/hooks/runtime/fetch-rules.js +78 -29
  232. package/dist/hooks/runtime/fetch-rules.js.map +1 -1
  233. package/dist/hooks/runtime/grep-include.js +228 -0
  234. package/dist/hooks/runtime/grep-include.js.map +1 -0
  235. package/dist/hooks/runtime/pre-compact.js +1 -1
  236. package/dist/hooks/runtime/pre-compact.js.map +1 -1
  237. package/dist/hooks/runtime/pre-invocation.js +3 -3
  238. package/dist/hooks/runtime/pre-invocation.js.map +1 -1
  239. package/dist/hooks/runtime/repo-registry.js +72 -0
  240. package/dist/hooks/runtime/repo-registry.js.map +1 -0
  241. package/dist/hooks/runtime/repo-scope.js +75 -0
  242. package/dist/hooks/runtime/repo-scope.js.map +1 -0
  243. package/dist/hooks/runtime/resolve.js +11 -2
  244. package/dist/hooks/runtime/resolve.js.map +1 -1
  245. package/dist/hooks/runtime/runner-args.js +17 -2
  246. package/dist/hooks/runtime/runner-args.js.map +1 -1
  247. package/dist/hooks/runtime/script-resolve.js +21 -5
  248. package/dist/hooks/runtime/script-resolve.js.map +1 -1
  249. package/dist/hooks/runtime/session-activation.js +71 -18
  250. package/dist/hooks/runtime/session-activation.js.map +1 -1
  251. package/dist/hooks/runtime/session-review.js +136 -66
  252. package/dist/hooks/runtime/session-review.js.map +1 -1
  253. package/dist/hooks/runtime/session-start.js +68 -13
  254. package/dist/hooks/runtime/session-start.js.map +1 -1
  255. package/dist/hooks/runtime/session-writes.js +11 -5
  256. package/dist/hooks/runtime/session-writes.js.map +1 -1
  257. package/dist/hooks/runtime/shell-writes.js +7 -88
  258. package/dist/hooks/runtime/shell-writes.js.map +1 -1
  259. package/dist/hooks/runtime/sniff.js +227 -2
  260. package/dist/hooks/runtime/sniff.js.map +1 -1
  261. package/dist/hooks/runtime/target-resolve.js +32 -17
  262. package/dist/hooks/runtime/target-resolve.js.map +1 -1
  263. package/dist/hooks/runtime/unmapped-tools.js +77 -1
  264. package/dist/hooks/runtime/unmapped-tools.js.map +1 -1
  265. package/dist/hooks/runtime/user-prompt-submit.js +1 -1
  266. package/dist/hooks/runtime/user-prompt-submit.js.map +1 -1
  267. package/dist/hooks/runtime/work-dir.js +3 -0
  268. package/dist/hooks/runtime/work-dir.js.map +1 -1
  269. package/dist/hooks/shim.js +27 -20
  270. package/dist/hooks/shim.js.map +1 -1
  271. package/dist/index.js +40 -3
  272. package/dist/index.js.map +1 -1
  273. package/dist/install-scope.js +12 -0
  274. package/dist/install-scope.js.map +1 -0
  275. package/dist/install.js +188 -78
  276. package/dist/install.js.map +1 -1
  277. package/dist/link.js +55 -5
  278. package/dist/link.js.map +1 -1
  279. package/dist/mcp/config/hook.js +25 -0
  280. package/dist/mcp/config/hook.js.map +1 -1
  281. package/dist/org.js +3 -1
  282. package/dist/org.js.map +1 -1
  283. package/dist/prompts.js +96 -12
  284. package/dist/prompts.js.map +1 -1
  285. package/dist/refresh-hooks.js +67 -15
  286. package/dist/refresh-hooks.js.map +1 -1
  287. package/dist/repo/exclude-block.js +112 -0
  288. package/dist/repo/exclude-block.js.map +1 -0
  289. package/dist/repo/footer.js +93 -0
  290. package/dist/repo/footer.js.map +1 -0
  291. package/dist/repo/git-repo.js +77 -0
  292. package/dist/repo/git-repo.js.map +1 -0
  293. package/dist/repo/guarded-write.js +45 -0
  294. package/dist/repo/guarded-write.js.map +1 -0
  295. package/dist/repo/install-repo.js +508 -0
  296. package/dist/repo/install-repo.js.map +1 -0
  297. package/dist/repo/machine-wiring.js +122 -0
  298. package/dist/repo/machine-wiring.js.map +1 -0
  299. package/dist/repo/mcp-json.js +57 -0
  300. package/dist/repo/mcp-json.js.map +1 -0
  301. package/dist/repo/registry.js +53 -0
  302. package/dist/repo/registry.js.map +1 -0
  303. package/dist/repo/repo-mode-guard.js +83 -0
  304. package/dist/repo/repo-mode-guard.js.map +1 -0
  305. package/dist/repo/repo-setups.js +123 -0
  306. package/dist/repo/repo-setups.js.map +1 -0
  307. package/dist/repo/repo-status.js +283 -0
  308. package/dist/repo/repo-status.js.map +1 -0
  309. package/dist/repo/uninstall-repo.js +56 -0
  310. package/dist/repo/uninstall-repo.js.map +1 -0
  311. package/dist/repo/unsupported.js +14 -0
  312. package/dist/repo/unsupported.js.map +1 -0
  313. package/dist/shim.js +9 -7
  314. package/dist/status.js +53 -11
  315. package/dist/status.js.map +1 -1
  316. package/dist/uninstall.js +51 -3
  317. package/dist/uninstall.js.map +1 -1
  318. package/dist/update.js +6 -1
  319. package/dist/update.js.map +1 -1
  320. package/package.json +5 -2
@@ -0,0 +1,270 @@
1
+ /**
2
+ * Which index a Python package comes from, when the tree was not resolved
3
+ * (a fallback to the direct packages, and every manifest edit): read from the
4
+ * configuration each manager reads, as files, never from the network and
5
+ * never by running anything. Public only while every index the
6
+ * configuration names is PyPI's simple index; a links directory, `no-index`,
7
+ * or a file that cannot be read makes nothing public, so a private package's
8
+ * name never reaches a third party. A full resolution does not use these: it
9
+ * says where each package came from.
10
+ */
11
+ import { devNull } from 'node:os';
12
+ import { isAbsolute, join } from 'node:path';
13
+ import { parse as parseToml } from 'smol-toml';
14
+ import { asObject, isPublicPypiIndex } from '../lockfiles/graph.js';
15
+ import { UNREADABLE, readSetting } from './config-files.js';
16
+ import { envValue } from './registry.js';
17
+ /**
18
+ * Public only while every index the configuration names is PyPI's. A links
19
+ * directory, `no-index`, or a file that cannot be read makes nothing public:
20
+ * a private package's name must never reach a third party.
21
+ */
22
+ export class IndexView {
23
+ publicOnly = true;
24
+ named = false;
25
+ /** An index or a links location the configuration names. */
26
+ index(url) {
27
+ if (!isPublicPypiIndex(url))
28
+ this.custom();
29
+ }
30
+ /** A package source other than PyPI's simple index (`no-index` included: links locations only). */
31
+ custom() {
32
+ this.publicOnly = false;
33
+ this.named = true;
34
+ }
35
+ /** A setting that could not be read: where packages come from is unknown. */
36
+ unknown() {
37
+ this.publicOnly = false;
38
+ }
39
+ isPublic() {
40
+ return this.publicOnly;
41
+ }
42
+ /** Whether the configuration names a package source other than PyPI's simple index. */
43
+ namesCustomSource() {
44
+ return this.named;
45
+ }
46
+ }
47
+ const listOf = (v) => (Array.isArray(v) ? v : v === undefined ? [] : [v]);
48
+ const truthy = (v) => v !== undefined && v !== '' && !/^(0|false|no|off)$/i.test(v);
49
+ const words = (v) => (v ?? '').split(/\s+/).filter(Boolean);
50
+ /** A TOML file's root, or null; one that exists but cannot be read or parsed makes the view unknown. */
51
+ function tomlOf(view, text) {
52
+ if (text === null)
53
+ return null;
54
+ if (text === UNREADABLE) {
55
+ view.unknown();
56
+ return null;
57
+ }
58
+ try {
59
+ return parseToml(text);
60
+ }
61
+ catch {
62
+ view.unknown();
63
+ return null;
64
+ }
65
+ }
66
+ /** The pip settings that say where packages come from, by pip's name for them. */
67
+ const PIP_INDEX_KEYS = new Set(['index-url', 'extra-index-url', 'find-links', 'no-index']);
68
+ /** pip's name for a setting: `PIP_INDEX_URL`, `index_url` and `--index-url` are all `index-url`. */
69
+ const pipName = (raw) => raw.trim().toLowerCase().replace(/_/g, '-').replace(/^--/, '');
70
+ function addPipSetting(v, key, value) {
71
+ if (key === 'no-index') {
72
+ if (truthy(value.trim()))
73
+ v.custom();
74
+ }
75
+ else if (PIP_INDEX_KEYS.has(key))
76
+ for (const u of words(value))
77
+ v.index(u);
78
+ }
79
+ /** pip's index settings, from the environment and from `pip config list` (null: not read). */
80
+ export function pipIndexView(env, config) {
81
+ const v = new IndexView();
82
+ if (config === null)
83
+ v.unknown();
84
+ for (const key of PIP_INDEX_KEYS) {
85
+ const value = envValue(env, `PIP_${key.toUpperCase().replace(/-/g, '_')}`) ?? config?.get(key);
86
+ if (value !== undefined)
87
+ addPipSetting(v, key, value);
88
+ }
89
+ return v;
90
+ }
91
+ /**
92
+ * The index settings of a `pip.conf` as pip reads it (configparser's
93
+ * format): the `[global]` and `[install]` sections, `key = value` or
94
+ * `key: value`, `#` and `;` comment lines, a value continued on lines
95
+ * indented deeper than its key. Null when the text is not that format.
96
+ */
97
+ export function readPipConf(text) {
98
+ const settings = [];
99
+ let section = null;
100
+ // The setting a deeper-indented line continues: its index in `settings` (-1 when not kept) and its indent.
101
+ let open = null;
102
+ for (const raw of text.replace(/^\uFEFF/, '').split(/\r?\n/)) {
103
+ const line = raw.trim();
104
+ if (line === '' || line.startsWith('#') || line.startsWith(';'))
105
+ continue;
106
+ const indent = raw.length - raw.trimStart().length;
107
+ if (open !== null && indent > open.indent) {
108
+ if (open.at >= 0)
109
+ settings[open.at][1] += ` ${line}`;
110
+ continue;
111
+ }
112
+ const header = /^\[(.+)\]/.exec(line);
113
+ if (header) {
114
+ section = header[1].trim().toLowerCase();
115
+ open = null;
116
+ continue;
117
+ }
118
+ const option = /^([^=:]+?)\s*[=:]\s*(.*)$/.exec(line);
119
+ if (option === null || section === null)
120
+ return null;
121
+ const key = pipName(option[1]);
122
+ const kept = (section === 'global' || section === 'install') && PIP_INDEX_KEYS.has(key);
123
+ if (kept)
124
+ settings.push([key, option[2]]);
125
+ open = { at: kept ? settings.length - 1 : -1, indent };
126
+ }
127
+ return settings;
128
+ }
129
+ /** `PIP_CONFIG_FILE` naming the null device: pip reads no configuration file. */
130
+ const isNullDevice = (p) => p === devNull || p === '/dev/null' || p.toLowerCase() === 'nul';
131
+ /**
132
+ * Every `pip.conf` pip may read: `PIP_CONFIG_FILE` (unless it is the null
133
+ * device), the user's (`~/.pip`, `~/.config/pip`, `$XDG_CONFIG_HOME/pip`, and
134
+ * on macOS `~/Library/Application Support/pip`; on Windows `~\pip` and
135
+ * `%APPDATA%\pip`), the system's (`$XDG_CONFIG_DIRS/pip`, `/etc`, on macOS
136
+ * `/Library/Application Support/pip`; on Windows `%PROGRAMDATA%\pip`) and
137
+ * the active virtualenv's. More than pip reads in some cases (a
138
+ * `PIP_CONFIG_FILE` hides the user's from pip): a file read too many only
139
+ * makes fewer packages public.
140
+ */
141
+ export function pipConfigFiles(ctx) {
142
+ const { env, home, platform } = ctx;
143
+ const root = ctx.systemRoot ?? '/';
144
+ const files = [];
145
+ const named = envValue(env, 'PIP_CONFIG_FILE');
146
+ if (named && !isNullDevice(named))
147
+ files.push(named);
148
+ if (platform === 'win32') {
149
+ files.push(join(home, 'pip', 'pip.ini'));
150
+ for (const base of [envValue(env, 'APPDATA'), envValue(env, 'PROGRAMDATA')])
151
+ if (base)
152
+ files.push(join(base, 'pip', 'pip.ini'));
153
+ }
154
+ else {
155
+ files.push(join(home, '.pip', 'pip.conf'), join(home, '.config', 'pip', 'pip.conf'));
156
+ const xdg = envValue(env, 'XDG_CONFIG_HOME');
157
+ if (xdg && isAbsolute(xdg))
158
+ files.push(join(xdg, 'pip', 'pip.conf'));
159
+ for (const d of (envValue(env, 'XDG_CONFIG_DIRS') || join(root, 'etc', 'xdg')).split(':').filter((p) => isAbsolute(p)))
160
+ files.push(join(d, 'pip', 'pip.conf'));
161
+ files.push(join(root, 'etc', 'pip.conf'));
162
+ if (platform === 'darwin')
163
+ files.push(join(home, 'Library', 'Application Support', 'pip', 'pip.conf'), join(root, 'Library', 'Application Support', 'pip', 'pip.conf'));
164
+ }
165
+ const venv = envValue(env, 'VIRTUAL_ENV');
166
+ if (venv && isAbsolute(venv))
167
+ files.push(join(venv, platform === 'win32' ? 'pip.ini' : 'pip.conf'));
168
+ return [...new Set(files)];
169
+ }
170
+ /**
171
+ * pip's index settings for an edit, read statically (nothing runs, `pip
172
+ * config list` included): every `PIP_*` variable pip reads, whatever the case
173
+ * of its name, then every file of `pipConfigFiles`. Any index other than
174
+ * PyPI's simple index, a links location or `no-index` names a custom source;
175
+ * a file that exists but cannot be read or parsed (or a relative
176
+ * `PIP_CONFIG_FILE`) leaves the source unknown. Either makes nothing public.
177
+ */
178
+ export function pipConfigView(ctx) {
179
+ const v = new IndexView();
180
+ for (const [name, value] of Object.entries(ctx.env)) {
181
+ const m = /^pip_(.+)$/i.exec(name);
182
+ if (m !== null && value !== undefined)
183
+ addPipSetting(v, pipName(m[1]), value);
184
+ }
185
+ for (const file of pipConfigFiles(ctx)) {
186
+ const text = isAbsolute(file) ? readSetting(file) : UNREADABLE;
187
+ if (text === null)
188
+ continue;
189
+ const settings = text === UNREADABLE ? null : readPipConf(text);
190
+ if (settings === null)
191
+ v.unknown();
192
+ else
193
+ for (const [key, value] of settings)
194
+ addPipSetting(v, key, value);
195
+ }
196
+ return v;
197
+ }
198
+ /** uv's settings table (`uv.toml`, or `[tool.uv]`), and its `[pip]` table. */
199
+ function addUvSettings(v, settings) {
200
+ for (const t of [settings, asObject(settings?.pip)]) {
201
+ if (t === null || t === undefined)
202
+ continue;
203
+ if (t['index-url'] !== undefined)
204
+ v.index(t['index-url']);
205
+ for (const u of listOf(t['extra-index-url']))
206
+ v.index(u);
207
+ for (const idx of listOf(t.index))
208
+ v.index(asObject(idx)?.url);
209
+ for (const u of listOf(t['find-links']))
210
+ v.index(u);
211
+ if (t['no-index'] === true)
212
+ v.custom();
213
+ }
214
+ }
215
+ /** The user's and the system's `uv.toml`, as uv looks for them. */
216
+ export function uvConfigFiles(ctx) {
217
+ const { env, home, platform } = ctx;
218
+ const root = ctx.systemRoot ?? '/';
219
+ const files = [];
220
+ const named = envValue(env, 'UV_CONFIG_FILE');
221
+ if (named)
222
+ files.push(named);
223
+ if (platform === 'win32') {
224
+ for (const base of [envValue(env, 'APPDATA'), envValue(env, 'PROGRAMDATA')])
225
+ if (base)
226
+ files.push(join(base, 'uv', 'uv.toml'));
227
+ return files;
228
+ }
229
+ const xdg = envValue(env, 'XDG_CONFIG_HOME');
230
+ files.push(join(xdg && isAbsolute(xdg) ? xdg : join(home, '.config'), 'uv', 'uv.toml'));
231
+ for (const d of (envValue(env, 'XDG_CONFIG_DIRS') || join(root, 'etc', 'xdg')).split(':').filter((p) => isAbsolute(p)))
232
+ files.push(join(d, 'uv', 'uv.toml'));
233
+ files.push(join(root, 'etc', 'uv', 'uv.toml'));
234
+ return files;
235
+ }
236
+ /**
237
+ * uv's index settings: the environment, the project's `pyproject.toml` files
238
+ * (`[tool.uv]`) and `uv.toml`, the user's and the system's `uv.toml`.
239
+ */
240
+ export function uvIndexView(ctx, pyprojects, uvToml) {
241
+ const v = new IndexView();
242
+ const env = ctx.env;
243
+ for (const name of ['UV_INDEX_URL', 'UV_DEFAULT_INDEX']) {
244
+ const value = envValue(env, name);
245
+ if (value)
246
+ v.index(value.trim());
247
+ }
248
+ for (const u of words(envValue(env, 'UV_EXTRA_INDEX_URL')))
249
+ v.index(u);
250
+ for (const w of words(envValue(env, 'UV_INDEX')))
251
+ v.index(/^[A-Za-z0-9_-]+=/.test(w) ? w.slice(w.indexOf('=') + 1) : w);
252
+ for (const u of words(envValue(env, 'UV_FIND_LINKS')))
253
+ v.index(u);
254
+ if (truthy(envValue(env, 'UV_NO_INDEX')))
255
+ v.custom();
256
+ for (const text of pyprojects)
257
+ addUvSettings(v, asObject(asObject(tomlOf(v, text)?.tool)?.uv));
258
+ addUvSettings(v, tomlOf(v, uvToml));
259
+ for (const f of uvConfigFiles(ctx))
260
+ addUvSettings(v, tomlOf(v, readSetting(f)));
261
+ return v;
262
+ }
263
+ /** Poetry's sources: `[[tool.poetry.source]]` of the project. */
264
+ export function poetryIndexView(pyproject) {
265
+ const v = new IndexView();
266
+ for (const src of listOf(asObject(asObject(tomlOf(v, pyproject)?.tool)?.poetry)?.source))
267
+ v.index(asObject(src)?.url);
268
+ return v;
269
+ }
270
+ //# sourceMappingURL=python-index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"python-index.js","sourceRoot":"","sources":["../../../../../src/hooks/runtime/dependency-check/resolvers/python-index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAC7C,OAAO,EAAE,KAAK,IAAI,SAAS,EAAE,MAAM,WAAW,CAAC;AAC/C,OAAO,EAAE,QAAQ,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AACpE,OAAO,EAAE,UAAU,EAAE,WAAW,EAAoB,MAAM,mBAAmB,CAAC;AAC9E,OAAO,EAAE,QAAQ,EAAqB,MAAM,eAAe,CAAC;AAW5D;;;;GAIG;AACH,MAAM,OAAO,SAAS;IACZ,UAAU,GAAG,IAAI,CAAC;IAClB,KAAK,GAAG,KAAK,CAAC;IAEtB,4DAA4D;IAC5D,KAAK,CAAC,GAAY;QAChB,IAAI,CAAC,iBAAiB,CAAC,GAAG,CAAC;YAAE,IAAI,CAAC,MAAM,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F,aAAa,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC;IACpC,KAAK,MAAM,CAAC,IAAI,aAAa,CAAC,GAAG,CAAC;QAAE,aAAa,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,EAAE,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAChF,OAAO,CAAC,CAAC;AACX,CAAC;AAED,iEAAiE;AACjE,MAAM,UAAU,eAAe,CAAC,SAAwB;IACtD,MAAM,CAAC,GAAG,IAAI,SAAS,EAAE,CAAC;IAC1B,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,EAAE,SAAS,CAAC,EAAE,IAAI,CAAC,EAAE,MAAM,CAAC,EAAE,MAAM,CAAC;QAAE,CAAC,CAAC,KAAK,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,GAAG,CAAC,CAAC;IACtH,OAAO,CAAC,CAAC;AACX,CAAC"}
@@ -0,0 +1,229 @@
1
+ /**
2
+ * What the Python resolvers (pip, pipx, uv, Poetry) share. Nothing here runs
3
+ * a process: the interpreter a command asks, the environment it gets, the
4
+ * requirement lines a manager is given, the package a failed run names as
5
+ * having no wheel, the index configuration that decides `publicRegistry` when
6
+ * the tree was not resolved, and which resolver a manifest edit goes to.
7
+ *
8
+ * Every Python resolution is restricted to wheels: nothing is ever built, and
9
+ * a direct reference (`x @ file:…`, `git+…`, a URL, a path, `-e`) never
10
+ * reaches a manager, even where E2 and E3 already kept it out.
11
+ *
12
+ * A manifest edit starts no interpreter at all: every Python edit is checked
13
+ * on its direct packages only (`project_code`). Any interpreter an edit could
14
+ * run (the active virtualenv's, the PATH's, the one uv would query) can load
15
+ * files of the project, through a virtualenv's `.pth` files or `sys.path`,
16
+ * and on an edit nothing the agent wrote may run.
17
+ */
18
+ import { lstatSync } from 'node:fs';
19
+ import { homedir } from 'node:os';
20
+ import { dirname, isAbsolute, join } from 'node:path';
21
+ import { pep503 } from '../lockfiles/graph.js';
22
+ import { ancestors, isFile } from './project.js';
23
+ import { envValue } from './registry.js';
24
+ import { RUN_MARGIN_MS, dedupe, directOnly, managerEnv, resolverDeps, told } from './shared.js';
25
+ export function pythonDeps(over = {}) {
26
+ return { ...resolverDeps(over), platform: over.platform ?? process.platform };
27
+ }
28
+ /** A step that cannot go on: the resolution falls back to the direct packages. */
29
+ export class Stop extends Error {
30
+ why;
31
+ sourceOnly;
32
+ constructor(why,
33
+ /** With `source_only`: the packages the manager said have no wheel. */
34
+ sourceOnly = []) {
35
+ super(why);
36
+ this.why = why;
37
+ this.sourceOnly = sourceOnly;
38
+ }
39
+ }
40
+ // ---------------------------------------------------------------------------
41
+ // Names, versions, requirement lines
42
+ // ---------------------------------------------------------------------------
43
+ export const PEP508_NAME_RE = /^[A-Za-z0-9](?:[A-Za-z0-9._-]*[A-Za-z0-9])?$/;
44
+ /** A PEP 503 name when the spec names a package, else the word as it was given. */
45
+ export const pyName = (name) => (PEP508_NAME_RE.test(name) ? pep503(name) : name);
46
+ /** A released version as PyPI normalises it: `2.9.0.post0`, `1.0rc1`, `3.10`. */
47
+ const VERSION_RE = /^\d+(?:\.\d+)*(?:(?:a|b|rc)\d+)?(?:\.post\d+)?(?:\.dev\d+)?(?:\+[a-z0-9]+(?:\.[a-z0-9]+)*)?$/i;
48
+ const unwrap = (range) => {
49
+ const r = range.trim();
50
+ return r.startsWith('(') && r.endsWith(')') ? r.slice(1, -1).trim() : r;
51
+ };
52
+ /** The exact version a spec pins (`==1.2.3`, `===1.2.3`, or a bare `1.2.3` from `uvx x@1.2.3` or Poetry), else null. */
53
+ export function pythonExact(range) {
54
+ if (range === undefined)
55
+ return null;
56
+ let r = unwrap(range);
57
+ if (r.startsWith('==='))
58
+ r = r.slice(3).trim();
59
+ else if (r.startsWith('=='))
60
+ r = r.slice(2).trim();
61
+ else if (/^[<>!~=^]/.test(r))
62
+ return null;
63
+ return VERSION_RE.test(r) ? r : null;
64
+ }
65
+ const SPECIFIER = '(?:===|==|!=|<=|>=|~=|<|>)\\s*[A-Za-z0-9.*+!_-]+';
66
+ /**
67
+ * One token of a PEP 508 environment marker: a name (a variable such as
68
+ * `python_version` or the legacy `platform.python_implementation`, or `and`,
69
+ * `or`, `not`, `in`), a comparison, a quoted string (no `$`, `@`, backslash or
70
+ * quote of its kind inside), parentheses. A name ends at a word boundary and a comparison is never
71
+ * followed by another comparison character, so a line splits into tokens one
72
+ * way only (no backtracking on a long line).
73
+ */
74
+ const MARKER_TOKEN = `(?:\\(|\\)|(?:===|==|!=|<=|>=|~=|<|>)(?![=<>!~])|[A-Za-z_][A-Za-z0-9_]*(?:\\.[A-Za-z_][A-Za-z0-9_]*)?\\b|'[^'$@\\\\\\n]*'|"[^"$@\\\\\\n]*")`;
75
+ /**
76
+ * A requirement naming a registry package and nothing else: a name, extras,
77
+ * version specifiers and an environment marker made of marker tokens only.
78
+ * No `@` (a direct reference), no `$` (pip expands variables in requirement
79
+ * files), no path, URL or option.
80
+ */
81
+ const REGISTRY_REQUIREMENT_RE = new RegExp(`^[A-Za-z0-9](?:[A-Za-z0-9._-]*[A-Za-z0-9])?(?:\\s*\\[[A-Za-z0-9._,\\s-]*\\])?\\s*(?:${SPECIFIER}(?:\\s*,\\s*${SPECIFIER})*)?\\s*(?:;(?:\\s*${MARKER_TOKEN})+\\s*)?$`);
82
+ export const isRegistryRequirement = (line) => !/:\/\/|file:/i.test(line) && REGISTRY_REQUIREMENT_RE.test(line);
83
+ /** The requirement line a command gives pip and uv for a spec, or null when it is not a registry package. */
84
+ export function requirementLine(spec) {
85
+ if (!PEP508_NAME_RE.test(spec.name))
86
+ return null;
87
+ let r = unwrap(spec.range ?? '');
88
+ if (r === '' || r === '*' || r === 'latest')
89
+ return spec.name;
90
+ if (!/^[=<>!~]/.test(r))
91
+ r = `==${r}`; // `uvx ruff@0.5.0`
92
+ const line = `${spec.name}${r}`;
93
+ return isRegistryRequirement(line) ? line : null;
94
+ }
95
+ /** Why a spec reached no manager: a direct reference, or a word that cannot be one. */
96
+ export const refusedReason = (spec) => /@|:\/\/|^file:|^[./~]/.test(`${spec.name} ${spec.range ?? ''}`.trim()) && !spec.name.startsWith('-') ? 'git_or_url' : 'resolution_failed';
97
+ export function pyJob(input, deps, toArg) {
98
+ const t = input.trigger;
99
+ const notes = told(input);
100
+ const specs = [];
101
+ const args = [];
102
+ for (const s of (t.kind === 'edit' ? t.changes.specs : t.specs).filter((x) => x.ecosystem === 'PyPI')) {
103
+ const arg = s.name.startsWith('-') ? null : toArg(s);
104
+ if (arg === null)
105
+ notes.push({ name: pyName(s.name), reason: refusedReason(s) });
106
+ else {
107
+ specs.push(s);
108
+ args.push(arg);
109
+ }
110
+ }
111
+ return {
112
+ input,
113
+ deps,
114
+ deadlineAt: deps.now() + Math.max(0, input.deadlineMs),
115
+ specs,
116
+ args,
117
+ notes: dedupe(notes),
118
+ start: t.kind === 'edit' ? dirname(t.path) : input.root,
119
+ };
120
+ }
121
+ export const timeLeft = (job) => job.deadlineAt - job.deps.now() - RUN_MARGIN_MS;
122
+ /**
123
+ * The direct packages only, PEP 503 named; `sourceOnly` names the packages a
124
+ * manager said have no wheel, told `source_only` in place of any other reason.
125
+ */
126
+ export function pythonDirectOnly(specs, why, view, notes, sourceOnly = []) {
127
+ const named = specs.map((s) => ({ ...s, name: pep503(s.name) }));
128
+ const r = directOnly(named, why, view, notes, (s) => pythonExact(s.range));
129
+ if (sourceOnly.length === 0)
130
+ return r;
131
+ const names = new Set(sourceOnly);
132
+ return { ...r, notVerified: dedupe([...r.notVerified.filter((n) => !names.has(n.name)), ...sourceOnly.map((name) => ({ name, reason: 'source_only' }))]) };
133
+ }
134
+ /**
135
+ * A manifest edit's answer, nothing run: its direct packages, public as
136
+ * `view` says (the configuration read as files). `custom_registry` when the
137
+ * configuration or the manifest names a package source other than PyPI's
138
+ * simple index, else `project_code`.
139
+ */
140
+ export function editDirectOnly(job, view, namesCustomSource) {
141
+ const custom = namesCustomSource || job.specs.some((s) => s.registry === 'custom');
142
+ return pythonDirectOnly(job.specs, custom ? 'custom_registry' : 'project_code', view, job.notes);
143
+ }
144
+ /** The answer when nothing resolvable was asked: what the trigger could not read, nothing else. */
145
+ export const nothingToResolve = (job) => ({ packages: [], notVerified: job.notes, mode: 'full' });
146
+ /**
147
+ * The interpreters a command tries, in order: those the real command would
148
+ * run. The active virtualenv's only when `VIRTUAL_ENV` (the user's own,
149
+ * activated) names one whose python is a regular file or a link; a `.venv` of
150
+ * the project is never looked for, since an agent can plant one. Then
151
+ * `python3` (Windows: `py -3`, then `python`). An edit runs none.
152
+ */
153
+ export function interpreters(env, platform, useVirtualEnv) {
154
+ const venv = useVirtualEnv ? activeVirtualenvPython(env, platform) : null;
155
+ const list = venv === null ? [] : [{ cmd: venv, args: [] }];
156
+ if (platform === 'win32')
157
+ list.push({ cmd: 'py', args: ['-3'] }, { cmd: 'python', args: [] });
158
+ else
159
+ list.push({ cmd: 'python3', args: [] });
160
+ return list;
161
+ }
162
+ /** The python of the virtualenv `VIRTUAL_ENV` names, when it is absolute and its python a regular file or a link. */
163
+ export function activeVirtualenvPython(env, platform) {
164
+ const venv = envValue(env, 'VIRTUAL_ENV');
165
+ if (!venv || !isAbsolute(venv))
166
+ return null;
167
+ const python = platform === 'win32' ? join(venv, 'Scripts', 'python.exe') : join(venv, 'bin', 'python');
168
+ try {
169
+ const st = lstatSync(python);
170
+ return st.isFile() || st.isSymbolicLink() ? python : null;
171
+ }
172
+ catch {
173
+ return null;
174
+ }
175
+ }
176
+ const PYTHON_FORCED = { PIP_NO_INPUT: '1', PIP_DISABLE_PIP_VERSION_CHECK: '1', PYTHONDONTWRITEBYTECODE: '1' };
177
+ /** Python reads code from these at start-up (`-I` ignores them too, for pip). */
178
+ const PYTHON_DROPPED = ['PYTHONSTARTUP', 'PYTHONPATH', 'PYTHONHOME'];
179
+ /** The user's environment (their index configuration included), never prompting, with Python's start-up hooks dropped. */
180
+ export function pythonEnv(base, extra = {}, drop = []) {
181
+ return managerEnv(base, { ...PYTHON_FORCED, ...extra }, [...PYTHON_DROPPED, ...drop]);
182
+ }
183
+ // ---------------------------------------------------------------------------
184
+ // A package without a wheel
185
+ // ---------------------------------------------------------------------------
186
+ const NAME = '([A-Za-z0-9](?:[A-Za-z0-9._-]*[A-Za-z0-9])?)';
187
+ /**
188
+ * The packages a failed uv run names as having no wheel: uv says so plainly
189
+ * (`hint: Wheels are required for \`docopt\``, `docopt==0.6.2 has no usable
190
+ * wheels`). pip is never read for this: its `(from versions: none)` reads
191
+ * the same for a package with only a source distribution, a name its index
192
+ * does not hold, and an index it could not reach (offline, VPN, DNS; pip logs
193
+ * the connection error at debug level only), so pip's failure stays
194
+ * `resolution_failed`.
195
+ */
196
+ export function sourceOnlyNames(output) {
197
+ const text = output.replace(/\u001b\[[0-9;]*[A-Za-z]/g, '').replace(/\s+/g, ' ');
198
+ const names = new Set();
199
+ for (const m of text.matchAll(new RegExp(`Wheels are required for \`${NAME}\``, 'g')))
200
+ names.add(pep503(m[1]));
201
+ for (const m of text.matchAll(new RegExp(`${NAME}(?:\\[[^\\]]*\\])?(?:(?:==|<=|>=|!=|~=|<|>)\\S+)? (?:has|have) no usable wheels`, 'g')))
202
+ names.add(pep503(m[1]));
203
+ return [...names].sort();
204
+ }
205
+ // ---------------------------------------------------------------------------
206
+ // Which resolver an edit goes to
207
+ // ---------------------------------------------------------------------------
208
+ /**
209
+ * The Python resolver for a manifest edit. Every one checks the edit on its
210
+ * direct packages only (`project_code`) and runs nothing; the choice decides
211
+ * whose configuration says whether those packages come from PyPI: pip for a
212
+ * requirements file and a Pipfile; for `pyproject.toml`, the manager whose
213
+ * lockfile is nearest (`uv.lock` or `poetry.lock`), else Poetry when the file
214
+ * has a `[tool.poetry]` table, else uv. Null for any other manifest.
215
+ */
216
+ export function pythonEditManager(t, home = homedir()) {
217
+ if (t.manifestKind === 'requirements*.txt' || t.manifestKind === 'Pipfile')
218
+ return 'pip';
219
+ if (t.manifestKind !== 'pyproject.toml')
220
+ return null;
221
+ for (const d of ancestors(dirname(t.path), home)) {
222
+ if (isFile(join(d, 'uv.lock')))
223
+ return 'uv';
224
+ if (isFile(join(d, 'poetry.lock')))
225
+ return 'poetry';
226
+ }
227
+ return /^\s*\[tool\.poetry[.\]]/m.test(t.content) ? 'poetry' : 'uv';
228
+ }
229
+ //# sourceMappingURL=python.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"python.js","sourceRoot":"","sources":["../../../../../src/hooks/runtime/dependency-check/resolvers/python.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AACH,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AACpC,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACtD,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAE/C,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AACjD,OAAO,EAAE,QAAQ,EAAqB,MAAM,eAAe,CAAC;AAC5D,OAAO,EAAE,aAAa,EAAE,MAAM,EAAE,UAAU,EAAE,UAAU,EAAE,YAAY,EAAE,IAAI,EAA0C,MAAM,aAAa,CAAC;AASxI,MAAM,UAAU,UAAU,CAAC,OAA4B,EAAE;IACvD,OAAO,EAAE,GAAG,YAAY,CAAC,IAAI,CAAC,EAAE,QAAQ,EAAE,IAAI,CAAC,QAAQ,IAAI,OAAO,CAAC,QAAQ,EAAE,CAAC;AAChF,CAAC;AAED,kFAAkF;AAClF,MAAM,OAAO,IAAK,SAAQ,KAAK;IAElB;IAEA;IAHX,YACW,GAAmB;IAC5B,uEAAuE;IAC9D,aAAuB,EAAE;QAElC,KAAK,CAAC,GAAG,CAAC,CAAC;QAJF,QAAG,GAAH,GAAG,CAAgB;QAEnB,eAAU,GAAV,UAAU,CAAe;IAGpC,CAAC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