@stringsync/splates 0.0.60 → 1.13.3

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 (734) hide show
  1. package/README.md +2 -2
  2. package/artifact.d.ts +2 -2
  3. package/blockers.d.ts +1 -1
  4. package/config.d.ts +12 -0
  5. package/config.js +0 -0
  6. package/creds.d.ts +2 -2
  7. package/evals.d.ts +2 -2
  8. package/flags.d.ts +4 -4
  9. package/handoff.d.ts +3 -4
  10. package/hook.d.ts +2 -2
  11. package/index.js +108 -108
  12. package/lane.d.ts +2 -2
  13. package/mirror.d.ts +14 -0
  14. package/mirror.js +22 -0
  15. package/package.json +12 -4
  16. package/projects.d.ts +2 -2
  17. package/queue.d.ts +2 -2
  18. package/replica.d.ts +2 -2
  19. package/server.d.ts +2 -2
  20. package/setup.d.ts +2 -2
  21. package/ship.d.ts +2 -2
  22. package/slots.d.ts +2 -2
  23. package/splates.d.ts +2 -2
  24. package/task.d.ts +2 -2
  25. package/tunnel.d.ts +2 -2
  26. package/vendor/@stringsync/splates-server/LICENSE +21 -0
  27. package/vendor/@stringsync/splates-server/age.d.ts +2 -0
  28. package/vendor/@stringsync/splates-server/agents/acp-extensions.d.ts +92 -0
  29. package/vendor/@stringsync/splates-server/agents/agents.d.ts +19 -0
  30. package/vendor/@stringsync/splates-server/agents/compaction.d.ts +17 -0
  31. package/vendor/@stringsync/splates-server/agents/connection.d.ts +191 -0
  32. package/vendor/@stringsync/splates-server/agents/errors.d.ts +8 -0
  33. package/vendor/@stringsync/splates-server/agents/fold.d.ts +45 -0
  34. package/vendor/@stringsync/splates-server/agents/index.d.ts +16 -0
  35. package/vendor/@stringsync/splates-server/agents/index.js +60 -0
  36. package/vendor/@stringsync/splates-server/agents/process.d.ts +67 -0
  37. package/vendor/@stringsync/splates-server/agents/scratch.d.ts +7 -0
  38. package/vendor/@stringsync/splates-server/agents/shared-browser.d.ts +47 -0
  39. package/vendor/@stringsync/splates-server/agents/start-lock.d.ts +24 -0
  40. package/vendor/@stringsync/splates-server/agents/stream.d.ts +91 -0
  41. package/vendor/@stringsync/splates-server/agents/tool-calls.d.ts +18 -0
  42. package/vendor/@stringsync/splates-server/agents/watch.d.ts +46 -0
  43. package/vendor/@stringsync/splates-server/agents/watched.d.ts +43 -0
  44. package/vendor/@stringsync/splates-server/artifacts/artifact.d.ts +33 -0
  45. package/vendor/@stringsync/splates-server/artifacts/artifacts.d.ts +162 -0
  46. package/vendor/@stringsync/splates-server/artifacts/attach.d.ts +31 -0
  47. package/vendor/@stringsync/splates-server/artifacts/attachments.d.ts +50 -0
  48. package/vendor/@stringsync/splates-server/artifacts/index.d.ts +8 -0
  49. package/vendor/@stringsync/splates-server/artifacts/index.js +38 -0
  50. package/vendor/@stringsync/splates-server/artifacts/room.d.ts +46 -0
  51. package/vendor/@stringsync/splates-server/artifacts/routes.d.ts +22 -0
  52. package/vendor/@stringsync/splates-server/artifacts/viewers.d.ts +6 -0
  53. package/vendor/@stringsync/splates-server/auto-pick/classes.d.ts +29 -0
  54. package/vendor/@stringsync/splates-server/auto-pick/classify.d.ts +60 -0
  55. package/vendor/@stringsync/splates-server/auto-pick/clef.d.ts +15 -0
  56. package/vendor/@stringsync/splates-server/auto-pick/decide.d.ts +78 -0
  57. package/vendor/@stringsync/splates-server/auto-pick/defaults.d.ts +3 -0
  58. package/vendor/@stringsync/splates-server/auto-pick/follow-up.d.ts +25 -0
  59. package/vendor/@stringsync/splates-server/auto-pick/index.d.ts +24 -0
  60. package/vendor/@stringsync/splates-server/auto-pick/jev.d.ts +38 -0
  61. package/vendor/@stringsync/splates-server/auto-pick/judge.d.ts +21 -0
  62. package/vendor/@stringsync/splates-server/auto-pick/judged.d.ts +33 -0
  63. package/vendor/@stringsync/splates-server/auto-pick/key.d.ts +6 -0
  64. package/vendor/@stringsync/splates-server/auto-pick/lift.d.ts +18 -0
  65. package/vendor/@stringsync/splates-server/auto-pick/queue.d.ts +30 -0
  66. package/vendor/@stringsync/splates-server/auto-pick/rank.d.ts +10 -0
  67. package/vendor/@stringsync/splates-server/auto-pick/record.d.ts +19 -0
  68. package/vendor/@stringsync/splates-server/auto-pick/routes.d.ts +25 -0
  69. package/vendor/@stringsync/splates-server/auto-pick/rule-names.d.ts +9 -0
  70. package/vendor/@stringsync/splates-server/auto-pick/rules-routes.d.ts +49 -0
  71. package/vendor/@stringsync/splates-server/auto-pick/rules.d.ts +97 -0
  72. package/vendor/@stringsync/splates-server/auto-pick/start.d.ts +79 -0
  73. package/vendor/@stringsync/splates-server/auto-pick/store.d.ts +25 -0
  74. package/vendor/@stringsync/splates-server/auto-pick/system-one.d.ts +60 -0
  75. package/vendor/@stringsync/splates-server/auto-pick/trial.d.ts +32 -0
  76. package/vendor/@stringsync/splates-server/board/backlog.d.ts +4 -0
  77. package/vendor/@stringsync/splates-server/board/blocked-warning.d.ts +7 -0
  78. package/vendor/@stringsync/splates-server/board/browser.d.ts +8 -0
  79. package/vendor/@stringsync/splates-server/board/change-lane.d.ts +12 -0
  80. package/vendor/@stringsync/splates-server/board/deferral.d.ts +87 -0
  81. package/vendor/@stringsync/splates-server/board/elsewhere-links.d.ts +26 -0
  82. package/vendor/@stringsync/splates-server/board/elsewhere.d.ts +119 -0
  83. package/vendor/@stringsync/splates-server/board/index.d.ts +21 -0
  84. package/vendor/@stringsync/splates-server/board/index.js +112 -0
  85. package/vendor/@stringsync/splates-server/board/lane.d.ts +69 -0
  86. package/vendor/@stringsync/splates-server/board/lanes-from-tags.d.ts +17 -0
  87. package/vendor/@stringsync/splates-server/board/lanes.d.ts +117 -0
  88. package/vendor/@stringsync/splates-server/board/routes.d.ts +54 -0
  89. package/vendor/@stringsync/splates-server/board/store.d.ts +74 -0
  90. package/vendor/@stringsync/splates-server/board/task-edit.d.ts +81 -0
  91. package/vendor/@stringsync/splates-server/board/task-file.d.ts +24 -0
  92. package/vendor/@stringsync/splates-server/board/task-journal.d.ts +9 -0
  93. package/vendor/@stringsync/splates-server/board/task-lanes.d.ts +95 -0
  94. package/vendor/@stringsync/splates-server/board/task-list.d.ts +40 -0
  95. package/vendor/@stringsync/splates-server/board/task.d.ts +301 -0
  96. package/vendor/@stringsync/splates-server/board/tasks.d.ts +172 -0
  97. package/vendor/@stringsync/splates-server/chunk-files-jkqj87yx.js +14 -0
  98. package/vendor/@stringsync/splates-server/chunk-maps-mnjqydx4.txt +1 -0
  99. package/vendor/@stringsync/splates-server/chunks-3jkzx1q9.txt +1 -0
  100. package/vendor/@stringsync/splates-server/comma-list.d.ts +2 -0
  101. package/vendor/@stringsync/splates-server/comma-list.js +6 -0
  102. package/vendor/@stringsync/splates-server/config/browser.d.ts +1 -0
  103. package/vendor/@stringsync/splates-server/config/config.d.ts +210 -0
  104. package/vendor/@stringsync/splates-server/config/index.d.ts +6 -0
  105. package/vendor/@stringsync/splates-server/config/index.js +42 -0
  106. package/vendor/@stringsync/splates-server/config/legacy-names.d.ts +70 -0
  107. package/vendor/@stringsync/splates-server/config/legacy-ps.d.ts +32 -0
  108. package/vendor/@stringsync/splates-server/config/load.d.ts +46 -0
  109. package/vendor/@stringsync/splates-server/config/source.d.ts +7 -0
  110. package/vendor/@stringsync/splates-server/config/type-config.d.ts +14 -0
  111. package/vendor/@stringsync/splates-server/conversations/answered.d.ts +7 -0
  112. package/vendor/@stringsync/splates-server/conversations/archive.d.ts +16 -0
  113. package/vendor/@stringsync/splates-server/conversations/background.d.ts +21 -0
  114. package/vendor/@stringsync/splates-server/conversations/browser.d.ts +12 -0
  115. package/vendor/@stringsync/splates-server/conversations/choice.d.ts +8 -0
  116. package/vendor/@stringsync/splates-server/conversations/compact.d.ts +6 -0
  117. package/vendor/@stringsync/splates-server/conversations/conversation.d.ts +420 -0
  118. package/vendor/@stringsync/splates-server/conversations/conversations.d.ts +181 -0
  119. package/vendor/@stringsync/splates-server/conversations/entry.d.ts +286 -0
  120. package/vendor/@stringsync/splates-server/conversations/events.d.ts +36 -0
  121. package/vendor/@stringsync/splates-server/conversations/files.d.ts +62 -0
  122. package/vendor/@stringsync/splates-server/conversations/given.d.ts +18 -0
  123. package/vendor/@stringsync/splates-server/conversations/heard.d.ts +8 -0
  124. package/vendor/@stringsync/splates-server/conversations/host.d.ts +176 -0
  125. package/vendor/@stringsync/splates-server/conversations/index.d.ts +22 -0
  126. package/vendor/@stringsync/splates-server/conversations/index.js +80 -0
  127. package/vendor/@stringsync/splates-server/conversations/listing.d.ts +15 -0
  128. package/vendor/@stringsync/splates-server/conversations/log.d.ts +117 -0
  129. package/vendor/@stringsync/splates-server/conversations/messages.d.ts +23 -0
  130. package/vendor/@stringsync/splates-server/conversations/name.d.ts +38 -0
  131. package/vendor/@stringsync/splates-server/conversations/options.d.ts +87 -0
  132. package/vendor/@stringsync/splates-server/conversations/outside.d.ts +14 -0
  133. package/vendor/@stringsync/splates-server/conversations/reference.d.ts +2 -0
  134. package/vendor/@stringsync/splates-server/conversations/routes.d.ts +109 -0
  135. package/vendor/@stringsync/splates-server/conversations/search.d.ts +15 -0
  136. package/vendor/@stringsync/splates-server/conversations/spent.d.ts +19 -0
  137. package/vendor/@stringsync/splates-server/conversations/state.d.ts +606 -0
  138. package/vendor/@stringsync/splates-server/conversations/stream.d.ts +34 -0
  139. package/vendor/@stringsync/splates-server/conversations/transcript.d.ts +9 -0
  140. package/vendor/@stringsync/splates-server/conversations/tree.d.ts +11 -0
  141. package/vendor/@stringsync/splates-server/conversations/turn-end.d.ts +30 -0
  142. package/vendor/@stringsync/splates-server/conversations/turns.d.ts +134 -0
  143. package/vendor/@stringsync/splates-server/conversations/updates.d.ts +21 -0
  144. package/vendor/@stringsync/splates-server/creds/creds.d.ts +86 -0
  145. package/vendor/@stringsync/splates-server/creds/index.d.ts +6 -0
  146. package/vendor/@stringsync/splates-server/creds/index.js +28 -0
  147. package/vendor/@stringsync/splates-server/creds/key-file.d.ts +21 -0
  148. package/vendor/@stringsync/splates-server/creds/requests.d.ts +54 -0
  149. package/vendor/@stringsync/splates-server/creds/routes.d.ts +16 -0
  150. package/vendor/@stringsync/splates-server/creds/stores.d.ts +37 -0
  151. package/vendor/@stringsync/splates-server/dictate/connection.d.ts +18 -0
  152. package/vendor/@stringsync/splates-server/dictate/dictate.d.ts +16 -0
  153. package/vendor/@stringsync/splates-server/dictate/index.d.ts +4 -0
  154. package/vendor/@stringsync/splates-server/dictate/personal.d.ts +26 -0
  155. package/vendor/@stringsync/splates-server/dictate/transcriber.d.ts +16 -0
  156. package/vendor/@stringsync/splates-server/dictate/vocabulary.d.ts +12 -0
  157. package/vendor/@stringsync/splates-server/evals/agents-routes.d.ts +27 -0
  158. package/vendor/@stringsync/splates-server/evals/agents.d.ts +25 -0
  159. package/vendor/@stringsync/splates-server/evals/contract.d.ts +73 -0
  160. package/vendor/@stringsync/splates-server/evals/done.d.ts +11 -0
  161. package/vendor/@stringsync/splates-server/evals/import.d.ts +10 -0
  162. package/vendor/@stringsync/splates-server/evals/index.d.ts +19 -0
  163. package/vendor/@stringsync/splates-server/evals/index.js +40 -0
  164. package/vendor/@stringsync/splates-server/evals/inspect.d.ts +66 -0
  165. package/vendor/@stringsync/splates-server/evals/launch-routes.d.ts +39 -0
  166. package/vendor/@stringsync/splates-server/evals/launch.d.ts +123 -0
  167. package/vendor/@stringsync/splates-server/evals/routes.d.ts +39 -0
  168. package/vendor/@stringsync/splates-server/evals/store.d.ts +17 -0
  169. package/vendor/@stringsync/splates-server/evals/target.d.ts +3 -0
  170. package/vendor/@stringsync/splates-server/evals/types.d.ts +105 -0
  171. package/vendor/@stringsync/splates-server/exit.d.ts +55 -0
  172. package/vendor/@stringsync/splates-server/exit.js +12 -0
  173. package/vendor/@stringsync/splates-server/git-identity.d.ts +17 -0
  174. package/vendor/@stringsync/splates-server/git-process.d.ts +8 -0
  175. package/vendor/@stringsync/splates-server/git.d.ts +168 -0
  176. package/vendor/@stringsync/splates-server/hooks/commands.d.ts +31 -0
  177. package/vendor/@stringsync/splates-server/hooks/edit.d.ts +24 -0
  178. package/vendor/@stringsync/splates-server/hooks/events.d.ts +20 -0
  179. package/vendor/@stringsync/splates-server/hooks/groomer.d.ts +8 -0
  180. package/vendor/@stringsync/splates-server/hooks/index.d.ts +17 -0
  181. package/vendor/@stringsync/splates-server/hooks/index.js +61 -0
  182. package/vendor/@stringsync/splates-server/hooks/now.d.ts +9 -0
  183. package/vendor/@stringsync/splates-server/hooks/routes.d.ts +39 -0
  184. package/vendor/@stringsync/splates-server/hooks/runner.d.ts +75 -0
  185. package/vendor/@stringsync/splates-server/hooks/runs.d.ts +38 -0
  186. package/vendor/@stringsync/splates-server/hooks/schedule.d.ts +10 -0
  187. package/vendor/@stringsync/splates-server/hooks/scheduler.d.ts +28 -0
  188. package/vendor/@stringsync/splates-server/hooks/store.d.ts +110 -0
  189. package/vendor/@stringsync/splates-server/index-01z7ycdk.js +6 -0
  190. package/vendor/@stringsync/splates-server/index-0jttnv86.js +1309 -0
  191. package/vendor/@stringsync/splates-server/index-5axhdy8c.js +692 -0
  192. package/vendor/@stringsync/splates-server/index-76t8y8h5.js +779 -0
  193. package/vendor/@stringsync/splates-server/index-7s01973c.js +2356 -0
  194. package/vendor/@stringsync/splates-server/index-acbcm66f.js +1468 -0
  195. package/vendor/@stringsync/splates-server/index-caep3sde.js +27140 -0
  196. package/vendor/@stringsync/splates-server/index-e9z7s5hh.js +641 -0
  197. package/vendor/@stringsync/splates-server/index-g18nxyn7.js +99 -0
  198. package/vendor/@stringsync/splates-server/index-kmzdvvt0.js +23 -0
  199. package/vendor/@stringsync/splates-server/index-raqrwzdq.js +952 -0
  200. package/vendor/@stringsync/splates-server/index-t9w5a8ed.js +60 -0
  201. package/vendor/@stringsync/splates-server/limited.d.ts +8 -0
  202. package/vendor/@stringsync/splates-server/log.d.ts +14 -0
  203. package/vendor/@stringsync/splates-server/log.js +32 -0
  204. package/vendor/@stringsync/splates-server/merge/attribution.d.ts +24 -0
  205. package/vendor/@stringsync/splates-server/merge/batch.d.ts +119 -0
  206. package/vendor/@stringsync/splates-server/merge/blame.d.ts +21 -0
  207. package/vendor/@stringsync/splates-server/merge/branches.d.ts +151 -0
  208. package/vendor/@stringsync/splates-server/merge/charge.d.ts +18 -0
  209. package/vendor/@stringsync/splates-server/merge/clear-gate.d.ts +7 -0
  210. package/vendor/@stringsync/splates-server/merge/cores.d.ts +60 -0
  211. package/vendor/@stringsync/splates-server/merge/estimates.d.ts +28 -0
  212. package/vendor/@stringsync/splates-server/merge/finish.d.ts +43 -0
  213. package/vendor/@stringsync/splates-server/merge/follow.d.ts +50 -0
  214. package/vendor/@stringsync/splates-server/merge/gate.d.ts +108 -0
  215. package/vendor/@stringsync/splates-server/merge/github-app.d.ts +99 -0
  216. package/vendor/@stringsync/splates-server/merge/github-refused.d.ts +5 -0
  217. package/vendor/@stringsync/splates-server/merge/groups.d.ts +8 -0
  218. package/vendor/@stringsync/splates-server/merge/index.d.ts +19 -0
  219. package/vendor/@stringsync/splates-server/merge/index.js +46 -0
  220. package/vendor/@stringsync/splates-server/merge/landed.d.ts +28 -0
  221. package/vendor/@stringsync/splates-server/merge/landing.d.ts +38 -0
  222. package/vendor/@stringsync/splates-server/merge/local-landing.d.ts +11 -0
  223. package/vendor/@stringsync/splates-server/merge/merge-state.d.ts +37 -0
  224. package/vendor/@stringsync/splates-server/merge/merge.d.ts +45 -0
  225. package/vendor/@stringsync/splates-server/merge/output.d.ts +19 -0
  226. package/vendor/@stringsync/splates-server/merge/phases.d.ts +27 -0
  227. package/vendor/@stringsync/splates-server/merge/pre-lock.d.ts +28 -0
  228. package/vendor/@stringsync/splates-server/merge/preflight.d.ts +16 -0
  229. package/vendor/@stringsync/splates-server/merge/queue-failures.d.ts +11 -0
  230. package/vendor/@stringsync/splates-server/merge/rebase.d.ts +34 -0
  231. package/vendor/@stringsync/splates-server/merge/recent-failures.d.ts +10 -0
  232. package/vendor/@stringsync/splates-server/merge/refusal.d.ts +58 -0
  233. package/vendor/@stringsync/splates-server/merge/split.d.ts +34 -0
  234. package/vendor/@stringsync/splates-server/merge/steps.d.ts +37 -0
  235. package/vendor/@stringsync/splates-server/merge/test-report.d.ts +29 -0
  236. package/vendor/@stringsync/splates-server/merge/timing.d.ts +20 -0
  237. package/vendor/@stringsync/splates-server/merge/trunk.d.ts +69 -0
  238. package/vendor/@stringsync/splates-server/models/codex-limits.d.ts +19 -0
  239. package/vendor/@stringsync/splates-server/models/effort.d.ts +22 -0
  240. package/vendor/@stringsync/splates-server/models/index.d.ts +13 -0
  241. package/vendor/@stringsync/splates-server/models/index.js +76 -0
  242. package/vendor/@stringsync/splates-server/models/kimi-limits.d.ts +37 -0
  243. package/vendor/@stringsync/splates-server/models/kimi-usage.d.ts +19 -0
  244. package/vendor/@stringsync/splates-server/models/kimi.d.ts +10 -0
  245. package/vendor/@stringsync/splates-server/models/limits.d.ts +32 -0
  246. package/vendor/@stringsync/splates-server/models/models.d.ts +36 -0
  247. package/vendor/@stringsync/splates-server/models/offered.d.ts +47 -0
  248. package/vendor/@stringsync/splates-server/models/opencode-usage.d.ts +37 -0
  249. package/vendor/@stringsync/splates-server/models/roster.d.ts +130 -0
  250. package/vendor/@stringsync/splates-server/plans/asked.d.ts +99 -0
  251. package/vendor/@stringsync/splates-server/plans/browser.d.ts +13 -0
  252. package/vendor/@stringsync/splates-server/plans/decided.d.ts +12 -0
  253. package/vendor/@stringsync/splates-server/plans/demo.d.ts +29 -0
  254. package/vendor/@stringsync/splates-server/plans/index.d.ts +16 -0
  255. package/vendor/@stringsync/splates-server/plans/index.js +137 -0
  256. package/vendor/@stringsync/splates-server/plans/needs.d.ts +131 -0
  257. package/vendor/@stringsync/splates-server/plans/permission.d.ts +64 -0
  258. package/vendor/@stringsync/splates-server/plans/plan.d.ts +223 -0
  259. package/vendor/@stringsync/splates-server/plans/prompts.d.ts +148 -0
  260. package/vendor/@stringsync/splates-server/plans/reply.d.ts +45 -0
  261. package/vendor/@stringsync/splates-server/plans/run-command.d.ts +21 -0
  262. package/vendor/@stringsync/splates-server/plans/store.d.ts +26 -0
  263. package/vendor/@stringsync/splates-server/plans/unanswered.d.ts +15 -0
  264. package/vendor/@stringsync/splates-server/ports/index.d.ts +8 -0
  265. package/vendor/@stringsync/splates-server/ports/index.js +36 -0
  266. package/vendor/@stringsync/splates-server/ports/list.d.ts +22 -0
  267. package/vendor/@stringsync/splates-server/ports/routes.d.ts +64 -0
  268. package/vendor/@stringsync/splates-server/ports/slot-tunnel.d.ts +24 -0
  269. package/vendor/@stringsync/splates-server/ports/slot.d.ts +28 -0
  270. package/vendor/@stringsync/splates-server/ports/slots.d.ts +150 -0
  271. package/vendor/@stringsync/splates-server/ports/socket.d.ts +26 -0
  272. package/vendor/@stringsync/splates-server/ports/task-ports.d.ts +39 -0
  273. package/vendor/@stringsync/splates-server/prices/index.d.ts +2 -0
  274. package/vendor/@stringsync/splates-server/prices/prices.d.ts +65 -0
  275. package/vendor/@stringsync/splates-server/projects/everywhere-routes.d.ts +110 -0
  276. package/vendor/@stringsync/splates-server/projects/everywhere.d.ts +43 -0
  277. package/vendor/@stringsync/splates-server/projects/general.d.ts +4 -0
  278. package/vendor/@stringsync/splates-server/projects/index.d.ts +10 -0
  279. package/vendor/@stringsync/splates-server/projects/index.js +36 -0
  280. package/vendor/@stringsync/splates-server/projects/init.d.ts +28 -0
  281. package/vendor/@stringsync/splates-server/projects/picker.d.ts +64 -0
  282. package/vendor/@stringsync/splates-server/projects/projects.d.ts +155 -0
  283. package/vendor/@stringsync/splates-server/projects/reaches.d.ts +26 -0
  284. package/vendor/@stringsync/splates-server/push/index.d.ts +2 -0
  285. package/vendor/@stringsync/splates-server/push/notices.d.ts +44 -0
  286. package/vendor/@stringsync/splates-server/push/push.d.ts +91 -0
  287. package/vendor/@stringsync/splates-server/queue/commands.d.ts +44 -0
  288. package/vendor/@stringsync/splates-server/queue/index.d.ts +7 -0
  289. package/vendor/@stringsync/splates-server/queue/index.js +44 -0
  290. package/vendor/@stringsync/splates-server/queue/moves.d.ts +15 -0
  291. package/vendor/@stringsync/splates-server/queue/name.d.ts +9 -0
  292. package/vendor/@stringsync/splates-server/queue/order.d.ts +50 -0
  293. package/vendor/@stringsync/splates-server/queue/runner.d.ts +129 -0
  294. package/vendor/@stringsync/splates-server/records/elsewhere.d.ts +27 -0
  295. package/vendor/@stringsync/splates-server/records/events.d.ts +556 -0
  296. package/vendor/@stringsync/splates-server/records/format.d.ts +92 -0
  297. package/vendor/@stringsync/splates-server/records/home.d.ts +72 -0
  298. package/vendor/@stringsync/splates-server/records/index.d.ts +10 -0
  299. package/vendor/@stringsync/splates-server/records/index.js +40 -0
  300. package/vendor/@stringsync/splates-server/records/journal.d.ts +65 -0
  301. package/vendor/@stringsync/splates-server/records/lease-lock.d.ts +29 -0
  302. package/vendor/@stringsync/splates-server/records/migration.d.ts +94 -0
  303. package/vendor/@stringsync/splates-server/records/one-task-store.d.ts +15 -0
  304. package/vendor/@stringsync/splates-server/records/repository.d.ts +137 -0
  305. package/vendor/@stringsync/splates-server/records/task-files.d.ts +8 -0
  306. package/vendor/@stringsync/splates-server/records/task-stages.d.ts +7 -0
  307. package/vendor/@stringsync/splates-server/records/to-sqlite.d.ts +3 -0
  308. package/vendor/@stringsync/splates-server/replica/aws-sign.d.ts +30 -0
  309. package/vendor/@stringsync/splates-server/replica/dir.d.ts +17 -0
  310. package/vendor/@stringsync/splates-server/replica/index.d.ts +14 -0
  311. package/vendor/@stringsync/splates-server/replica/index.js +29 -0
  312. package/vendor/@stringsync/splates-server/replica/layout.d.ts +45 -0
  313. package/vendor/@stringsync/splates-server/replica/place.d.ts +31 -0
  314. package/vendor/@stringsync/splates-server/replica/replica.d.ts +37 -0
  315. package/vendor/@stringsync/splates-server/replica/replicator.d.ts +102 -0
  316. package/vendor/@stringsync/splates-server/replica/restore.d.ts +40 -0
  317. package/vendor/@stringsync/splates-server/replica/s3.d.ts +45 -0
  318. package/vendor/@stringsync/splates-server/replica/shipped.d.ts +2 -0
  319. package/vendor/@stringsync/splates-server/replica/status.d.ts +18 -0
  320. package/vendor/@stringsync/splates-server/server/assets.d.ts +35 -0
  321. package/vendor/@stringsync/splates-server/server/automations.d.ts +26 -0
  322. package/vendor/@stringsync/splates-server/server/chunk-files.d.ts +4 -0
  323. package/vendor/@stringsync/splates-server/server/conflict-watch.d.ts +22 -0
  324. package/vendor/@stringsync/splates-server/server/early-warning.d.ts +7 -0
  325. package/vendor/@stringsync/splates-server/server/general.d.ts +53 -0
  326. package/vendor/@stringsync/splates-server/server/groomer.d.ts +53 -0
  327. package/vendor/@stringsync/splates-server/server/held.d.ts +10 -0
  328. package/vendor/@stringsync/splates-server/server/http.d.ts +76 -0
  329. package/vendor/@stringsync/splates-server/server/index.d.ts +16 -0
  330. package/vendor/@stringsync/splates-server/server/index.js +14342 -0
  331. package/vendor/@stringsync/splates-server/server/interrupt.d.ts +24 -0
  332. package/vendor/@stringsync/splates-server/server/loop-watch.d.ts +12 -0
  333. package/vendor/@stringsync/splates-server/server/migrations.d.ts +46 -0
  334. package/vendor/@stringsync/splates-server/server/options.d.ts +143 -0
  335. package/vendor/@stringsync/splates-server/server/pages.d.ts +35 -0
  336. package/vendor/@stringsync/splates-server/server/ports.d.ts +11 -0
  337. package/vendor/@stringsync/splates-server/server/premerge.d.ts +61 -0
  338. package/vendor/@stringsync/splates-server/server/project-watch.d.ts +94 -0
  339. package/vendor/@stringsync/splates-server/server/project.d.ts +239 -0
  340. package/vendor/@stringsync/splates-server/server/pulse.d.ts +8 -0
  341. package/vendor/@stringsync/splates-server/server/release.d.ts +41 -0
  342. package/vendor/@stringsync/splates-server/server/replicas.d.ts +23 -0
  343. package/vendor/@stringsync/splates-server/server/restart.d.ts +177 -0
  344. package/vendor/@stringsync/splates-server/server/runtime-deps.d.ts +19 -0
  345. package/vendor/@stringsync/splates-server/server/server.d.ts +19 -0
  346. package/vendor/@stringsync/splates-server/server/servers.d.ts +31 -0
  347. package/vendor/@stringsync/splates-server/server/serving.d.ts +28 -0
  348. package/vendor/@stringsync/splates-server/server/shared.d.ts +14 -0
  349. package/vendor/@stringsync/splates-server/server/skills.d.ts +16 -0
  350. package/vendor/@stringsync/splates-server/server/sockets.d.ts +13 -0
  351. package/vendor/@stringsync/splates-server/server/start-settings.d.ts +15 -0
  352. package/vendor/@stringsync/splates-server/server/start.d.ts +21 -0
  353. package/vendor/@stringsync/splates-server/server/suite-grant.d.ts +26 -0
  354. package/vendor/@stringsync/splates-server/server/supervise.d.ts +81 -0
  355. package/vendor/@stringsync/splates-server/server/ticketed-lock.d.ts +80 -0
  356. package/vendor/@stringsync/splates-server/server/update-records.d.ts +8 -0
  357. package/vendor/@stringsync/splates-server/server/update.d.ts +56 -0
  358. package/vendor/@stringsync/splates-server/server/versions.d.ts +53 -0
  359. package/vendor/@stringsync/splates-server/setup/area-auto-pick.d.ts +7 -0
  360. package/vendor/@stringsync/splates-server/setup/area-dictation.d.ts +3 -0
  361. package/vendor/@stringsync/splates-server/setup/area-droplet.d.ts +3 -0
  362. package/vendor/@stringsync/splates-server/setup/area-evals.d.ts +3 -0
  363. package/vendor/@stringsync/splates-server/setup/area-github.d.ts +8 -0
  364. package/vendor/@stringsync/splates-server/setup/area-native.d.ts +7 -0
  365. package/vendor/@stringsync/splates-server/setup/area-opencode.d.ts +5 -0
  366. package/vendor/@stringsync/splates-server/setup/area-remote.d.ts +3 -0
  367. package/vendor/@stringsync/splates-server/setup/area-replica.d.ts +3 -0
  368. package/vendor/@stringsync/splates-server/setup/area-workers.d.ts +5 -0
  369. package/vendor/@stringsync/splates-server/setup/areas.d.ts +7 -0
  370. package/vendor/@stringsync/splates-server/setup/checks.d.ts +8 -0
  371. package/vendor/@stringsync/splates-server/setup/fields.d.ts +69 -0
  372. package/vendor/@stringsync/splates-server/setup/index.d.ts +8 -0
  373. package/vendor/@stringsync/splates-server/setup/index.js +25 -0
  374. package/vendor/@stringsync/splates-server/setup/opencode-model-error.d.ts +3 -0
  375. package/vendor/@stringsync/splates-server/setup/opencode-models.d.ts +44 -0
  376. package/vendor/@stringsync/splates-server/setup/opencode-recipe.d.ts +33 -0
  377. package/vendor/@stringsync/splates-server/setup/opencode-routes.d.ts +17 -0
  378. package/vendor/@stringsync/splates-server/setup/opencode.d.ts +61 -0
  379. package/vendor/@stringsync/splates-server/setup/project.d.ts +10 -0
  380. package/vendor/@stringsync/splates-server/setup/routes.d.ts +31 -0
  381. package/vendor/@stringsync/splates-server/setup/setup.d.ts +235 -0
  382. package/vendor/@stringsync/splates-server/setup/step-problem.d.ts +3 -0
  383. package/vendor/@stringsync/splates-server/setup/undo.d.ts +80 -0
  384. package/vendor/@stringsync/splates-server/ship/approval-watch.d.ts +57 -0
  385. package/vendor/@stringsync/splates-server/ship/approval.d.ts +17 -0
  386. package/vendor/@stringsync/splates-server/ship/cascade-routes.d.ts +25 -0
  387. package/vendor/@stringsync/splates-server/ship/cascade.d.ts +70 -0
  388. package/vendor/@stringsync/splates-server/ship/commands.d.ts +26 -0
  389. package/vendor/@stringsync/splates-server/ship/git.d.ts +31 -0
  390. package/vendor/@stringsync/splates-server/ship/graph.d.ts +60 -0
  391. package/vendor/@stringsync/splates-server/ship/history.d.ts +51 -0
  392. package/vendor/@stringsync/splates-server/ship/index.d.ts +28 -0
  393. package/vendor/@stringsync/splates-server/ship/live.d.ts +40 -0
  394. package/vendor/@stringsync/splates-server/ship/mechanical.d.ts +30 -0
  395. package/vendor/@stringsync/splates-server/ship/npm-terminal.d.ts +14 -0
  396. package/vendor/@stringsync/splates-server/ship/plan.d.ts +90 -0
  397. package/vendor/@stringsync/splates-server/ship/progress.d.ts +3 -0
  398. package/vendor/@stringsync/splates-server/ship/published-notice.d.ts +29 -0
  399. package/vendor/@stringsync/splates-server/ship/record.d.ts +55 -0
  400. package/vendor/@stringsync/splates-server/ship/registry.d.ts +13 -0
  401. package/vendor/@stringsync/splates-server/ship/release-events.d.ts +47 -0
  402. package/vendor/@stringsync/splates-server/ship/release-steps.d.ts +66 -0
  403. package/vendor/@stringsync/splates-server/ship/routes.d.ts +14 -0
  404. package/vendor/@stringsync/splates-server/ship/run.d.ts +132 -0
  405. package/vendor/@stringsync/splates-server/ship/selection.d.ts +36 -0
  406. package/vendor/@stringsync/splates-server/ship/served.d.ts +4 -0
  407. package/vendor/@stringsync/splates-server/ship/stages.d.ts +69 -0
  408. package/vendor/@stringsync/splates-server/ship/steps.d.ts +69 -0
  409. package/vendor/@stringsync/splates-server/ship/token-request.d.ts +11 -0
  410. package/vendor/@stringsync/splates-server/ship/token.d.ts +21 -0
  411. package/vendor/@stringsync/splates-server/spend/adapters.d.ts +5 -0
  412. package/vendor/@stringsync/splates-server/spend/billing.d.ts +38 -0
  413. package/vendor/@stringsync/splates-server/spend/index.d.ts +15 -0
  414. package/vendor/@stringsync/splates-server/spend/plans.d.ts +45 -0
  415. package/vendor/@stringsync/splates-server/spend/providers.d.ts +45 -0
  416. package/vendor/@stringsync/splates-server/spend/rates.d.ts +23 -0
  417. package/vendor/@stringsync/splates-server/spend/report.d.ts +39 -0
  418. package/vendor/@stringsync/splates-server/spend/routes.d.ts +46 -0
  419. package/vendor/@stringsync/splates-server/spend/spend.d.ts +15 -0
  420. package/vendor/@stringsync/splates-server/spend/totals.d.ts +63 -0
  421. package/vendor/@stringsync/splates-server/spend/turn.d.ts +39 -0
  422. package/vendor/@stringsync/splates-server/stats/adherence.d.ts +40 -0
  423. package/vendor/@stringsync/splates-server/stats/baselines.d.ts +55 -0
  424. package/vendor/@stringsync/splates-server/stats/budget-routes.d.ts +21 -0
  425. package/vendor/@stringsync/splates-server/stats/fact-tasks.d.ts +19 -0
  426. package/vendor/@stringsync/splates-server/stats/finding-facts.d.ts +37 -0
  427. package/vendor/@stringsync/splates-server/stats/findings.d.ts +89 -0
  428. package/vendor/@stringsync/splates-server/stats/index.d.ts +12 -0
  429. package/vendor/@stringsync/splates-server/stats/index.js +30 -0
  430. package/vendor/@stringsync/splates-server/stats/landed.d.ts +14 -0
  431. package/vendor/@stringsync/splates-server/stats/outcomes.d.ts +207 -0
  432. package/vendor/@stringsync/splates-server/stats/overrides.d.ts +19 -0
  433. package/vendor/@stringsync/splates-server/stats/routes.d.ts +23 -0
  434. package/vendor/@stringsync/splates-server/stats/scry-models.d.ts +22 -0
  435. package/vendor/@stringsync/splates-server/stats/skill-checks.d.ts +59 -0
  436. package/vendor/@stringsync/splates-server/stats/stats.d.ts +176 -0
  437. package/vendor/@stringsync/splates-server/stats/task-log.d.ts +67 -0
  438. package/vendor/@stringsync/splates-server/storage/atomic.d.ts +13 -0
  439. package/vendor/@stringsync/splates-server/storage/collection.d.ts +30 -0
  440. package/vendor/@stringsync/splates-server/storage/document.d.ts +26 -0
  441. package/vendor/@stringsync/splates-server/storage/fs-collection.d.ts +26 -0
  442. package/vendor/@stringsync/splates-server/storage/fs-document.d.ts +16 -0
  443. package/vendor/@stringsync/splates-server/storage/fs-log.d.ts +31 -0
  444. package/vendor/@stringsync/splates-server/storage/fs.d.ts +48 -0
  445. package/vendor/@stringsync/splates-server/storage/index.d.ts +11 -0
  446. package/vendor/@stringsync/splates-server/storage/index.js +18 -0
  447. package/vendor/@stringsync/splates-server/storage/json.d.ts +10 -0
  448. package/vendor/@stringsync/splates-server/storage/key.d.ts +7 -0
  449. package/vendor/@stringsync/splates-server/storage/log.d.ts +60 -0
  450. package/vendor/@stringsync/splates-server/storage/schema.d.ts +7 -0
  451. package/vendor/@stringsync/splates-server/storage/sqlite-collection.d.ts +31 -0
  452. package/vendor/@stringsync/splates-server/storage/sqlite-db.d.ts +62 -0
  453. package/vendor/@stringsync/splates-server/storage/sqlite-document.d.ts +20 -0
  454. package/vendor/@stringsync/splates-server/storage/sqlite-import.d.ts +11 -0
  455. package/vendor/@stringsync/splates-server/storage/sqlite-keys.d.ts +17 -0
  456. package/vendor/@stringsync/splates-server/storage/sqlite-lock.d.ts +25 -0
  457. package/vendor/@stringsync/splates-server/storage/sqlite-log.d.ts +31 -0
  458. package/vendor/@stringsync/splates-server/storage/sqlite.d.ts +53 -0
  459. package/vendor/@stringsync/splates-server/storage/storage.d.ts +87 -0
  460. package/vendor/@stringsync/splates-server/table.d.ts +5 -0
  461. package/vendor/@stringsync/splates-server/tasks/add.d.ts +45 -0
  462. package/vendor/@stringsync/splates-server/tasks/browser.d.ts +5 -0
  463. package/vendor/@stringsync/splates-server/tasks/checkpoint.d.ts +39 -0
  464. package/vendor/@stringsync/splates-server/tasks/claim.d.ts +14 -0
  465. package/vendor/@stringsync/splates-server/tasks/conflicts.d.ts +19 -0
  466. package/vendor/@stringsync/splates-server/tasks/diff.d.ts +29 -0
  467. package/vendor/@stringsync/splates-server/tasks/dispatched.d.ts +15 -0
  468. package/vendor/@stringsync/splates-server/tasks/editors.d.ts +22 -0
  469. package/vendor/@stringsync/splates-server/tasks/finished.d.ts +81 -0
  470. package/vendor/@stringsync/splates-server/tasks/follow.d.ts +48 -0
  471. package/vendor/@stringsync/splates-server/tasks/index.d.ts +30 -0
  472. package/vendor/@stringsync/splates-server/tasks/index.js +90 -0
  473. package/vendor/@stringsync/splates-server/tasks/landings.d.ts +17 -0
  474. package/vendor/@stringsync/splates-server/tasks/list.d.ts +18 -0
  475. package/vendor/@stringsync/splates-server/tasks/merge-output.d.ts +13 -0
  476. package/vendor/@stringsync/splates-server/tasks/open.d.ts +15 -0
  477. package/vendor/@stringsync/splates-server/tasks/overlaps.d.ts +16 -0
  478. package/vendor/@stringsync/splates-server/tasks/path.d.ts +13 -0
  479. package/vendor/@stringsync/splates-server/tasks/recommend.d.ts +30 -0
  480. package/vendor/@stringsync/splates-server/tasks/remove.d.ts +47 -0
  481. package/vendor/@stringsync/splates-server/tasks/retry.d.ts +35 -0
  482. package/vendor/@stringsync/splates-server/tasks/routes.d.ts +23 -0
  483. package/vendor/@stringsync/splates-server/tasks/show.d.ts +137 -0
  484. package/vendor/@stringsync/splates-server/tasks/snapshot.d.ts +86 -0
  485. package/vendor/@stringsync/splates-server/tasks/started-records.d.ts +71 -0
  486. package/vendor/@stringsync/splates-server/tasks/wait.d.ts +47 -0
  487. package/vendor/@stringsync/splates-server/tasks/worktree-checkouts.d.ts +10 -0
  488. package/vendor/@stringsync/splates-server/tasks/worktree-service.d.ts +151 -0
  489. package/vendor/@stringsync/splates-server/tasks/worktree.d.ts +342 -0
  490. package/vendor/@stringsync/splates-server/terminal/connection.d.ts +19 -0
  491. package/vendor/@stringsync/splates-server/terminal/held.d.ts +22 -0
  492. package/vendor/@stringsync/splates-server/terminal/index.d.ts +7 -0
  493. package/vendor/@stringsync/splates-server/terminal/pty.d.ts +45 -0
  494. package/vendor/@stringsync/splates-server/terminal/remote-pty.d.ts +34 -0
  495. package/vendor/@stringsync/splates-server/terminal/shell.d.ts +70 -0
  496. package/vendor/@stringsync/splates-server/terminal/spawn.d.ts +22 -0
  497. package/vendor/@stringsync/splates-server/terminal/terminal.d.ts +52 -0
  498. package/vendor/@stringsync/splates-server/tunnel/access.d.ts +61 -0
  499. package/vendor/@stringsync/splates-server/tunnel/cloudflare-api.d.ts +25 -0
  500. package/vendor/@stringsync/splates-server/tunnel/cloudflare-error.d.ts +5 -0
  501. package/vendor/@stringsync/splates-server/tunnel/cloudflared.d.ts +43 -0
  502. package/vendor/@stringsync/splates-server/tunnel/index.d.ts +14 -0
  503. package/vendor/@stringsync/splates-server/tunnel/index.js +70 -0
  504. package/vendor/@stringsync/splates-server/tunnel/machine.d.ts +18 -0
  505. package/vendor/@stringsync/splates-server/tunnel/provider.d.ts +37 -0
  506. package/vendor/@stringsync/splates-server/tunnel/remove.d.ts +35 -0
  507. package/vendor/@stringsync/splates-server/tunnel/saved-ports-host.d.ts +26 -0
  508. package/vendor/@stringsync/splates-server/tunnel/saved.d.ts +63 -0
  509. package/vendor/@stringsync/splates-server/tunnel/setup.d.ts +123 -0
  510. package/vendor/@stringsync/splates-server/tunnel/tunnel.d.ts +38 -0
  511. package/vendor/@stringsync/splates-server/workers/admin.d.ts +37 -0
  512. package/vendor/@stringsync/splates-server/workers/call-host.d.ts +68 -0
  513. package/vendor/@stringsync/splates-server/workers/channel.d.ts +90 -0
  514. package/vendor/@stringsync/splates-server/workers/connection.d.ts +24 -0
  515. package/vendor/@stringsync/splates-server/workers/coordinator-state.d.ts +44 -0
  516. package/vendor/@stringsync/splates-server/workers/daemon.d.ts +128 -0
  517. package/vendor/@stringsync/splates-server/workers/darwin-footprint.d.ts +7 -0
  518. package/vendor/@stringsync/splates-server/workers/darwin-temperature.d.ts +7 -0
  519. package/vendor/@stringsync/splates-server/workers/frame-too-large.d.ts +5 -0
  520. package/vendor/@stringsync/splates-server/workers/git.d.ts +11 -0
  521. package/vendor/@stringsync/splates-server/workers/gone.d.ts +36 -0
  522. package/vendor/@stringsync/splates-server/workers/identity.d.ts +30 -0
  523. package/vendor/@stringsync/splates-server/workers/index.d.ts +40 -0
  524. package/vendor/@stringsync/splates-server/workers/index.js +90 -0
  525. package/vendor/@stringsync/splates-server/workers/lifecycle.d.ts +14 -0
  526. package/vendor/@stringsync/splates-server/workers/list.d.ts +93 -0
  527. package/vendor/@stringsync/splates-server/workers/load.d.ts +55 -0
  528. package/vendor/@stringsync/splates-server/workers/local-id.d.ts +11 -0
  529. package/vendor/@stringsync/splates-server/workers/local-update.d.ts +81 -0
  530. package/vendor/@stringsync/splates-server/workers/log-file.d.ts +24 -0
  531. package/vendor/@stringsync/splates-server/workers/machine.d.ts +47 -0
  532. package/vendor/@stringsync/splates-server/workers/orphan.d.ts +31 -0
  533. package/vendor/@stringsync/splates-server/workers/os-sensors.d.ts +49 -0
  534. package/vendor/@stringsync/splates-server/workers/placement.d.ts +39 -0
  535. package/vendor/@stringsync/splates-server/workers/process-host.d.ts +60 -0
  536. package/vendor/@stringsync/splates-server/workers/process.d.ts +33 -0
  537. package/vendor/@stringsync/splates-server/workers/protocol.d.ts +153 -0
  538. package/vendor/@stringsync/splates-server/workers/pty-host.d.ts +35 -0
  539. package/vendor/@stringsync/splates-server/workers/queue.d.ts +39 -0
  540. package/vendor/@stringsync/splates-server/workers/records.d.ts +43 -0
  541. package/vendor/@stringsync/splates-server/workers/registry.d.ts +101 -0
  542. package/vendor/@stringsync/splates-server/workers/replay.d.ts +25 -0
  543. package/vendor/@stringsync/splates-server/workers/routes.d.ts +119 -0
  544. package/vendor/@stringsync/splates-server/workers/run-options.d.ts +11 -0
  545. package/vendor/@stringsync/splates-server/workers/run.d.ts +10 -0
  546. package/vendor/@stringsync/splates-server/workers/scheduler.d.ts +171 -0
  547. package/vendor/@stringsync/splates-server/workers/server-of.d.ts +23 -0
  548. package/vendor/@stringsync/splates-server/workers/server-socket.d.ts +25 -0
  549. package/vendor/@stringsync/splates-server/workers/session.d.ts +240 -0
  550. package/vendor/@stringsync/splates-server/workers/socket.d.ts +21 -0
  551. package/vendor/@stringsync/splates-server/workers/unix-listener.d.ts +23 -0
  552. package/vendor/@stringsync/splates-server/workers/unix-socket.d.ts +30 -0
  553. package/vendor/@stringsync/splates-server/workers/websocket-socket.d.ts +24 -0
  554. package/vendor/@stringsync/splates-server/workers/worker.d.ts +98 -0
  555. package/vendor/core/LICENSE +21 -0
  556. package/vendor/core/abort/aborts.d.ts +10 -0
  557. package/vendor/core/abort/index.d.ts +1 -0
  558. package/vendor/core/abort/index.js +24 -0
  559. package/vendor/core/assert/assert-error.d.ts +4 -0
  560. package/vendor/core/assert/assert.d.ts +24 -0
  561. package/vendor/core/assert/ensure.d.ts +18 -0
  562. package/vendor/core/assert/index.d.ts +3 -0
  563. package/vendor/core/assert/index.js +75 -0
  564. package/vendor/core/cmd/cli.d.ts +70 -0
  565. package/vendor/core/cmd/command.d.ts +96 -0
  566. package/vendor/core/cmd/deps.d.ts +12 -0
  567. package/vendor/core/cmd/help.d.ts +16 -0
  568. package/vendor/core/cmd/index.d.ts +6 -0
  569. package/vendor/core/cmd/index.js +477 -0
  570. package/vendor/core/cmd/middleware.d.ts +15 -0
  571. package/vendor/core/cmd/timed.d.ts +15 -0
  572. package/vendor/core/creds/credential-proxy.d.ts +55 -0
  573. package/vendor/core/creds/credential-source.d.ts +19 -0
  574. package/vendor/core/creds/credentials.d.ts +28 -0
  575. package/vendor/core/creds/dotenv-file.d.ts +22 -0
  576. package/vendor/core/creds/environment.d.ts +18 -0
  577. package/vendor/core/creds/index.d.ts +8 -0
  578. package/vendor/core/creds/index.js +337 -0
  579. package/vendor/core/creds/memory-secret-store.d.ts +33 -0
  580. package/vendor/core/creds/secret-store.d.ts +14 -0
  581. package/vendor/core/creds/system-secret-store.d.ts +49 -0
  582. package/vendor/core/dictate/buffered-sink.d.ts +9 -0
  583. package/vendor/core/dictate/cue.d.ts +10 -0
  584. package/vendor/core/dictate/dictation-failure.d.ts +5 -0
  585. package/vendor/core/dictate/dictation-link.d.ts +18 -0
  586. package/vendor/core/dictate/dictation-message.d.ts +24 -0
  587. package/vendor/core/dictate/dictation-relay.d.ts +28 -0
  588. package/vendor/core/dictate/index.d.ts +10 -0
  589. package/vendor/core/dictate/index.js +132 -0
  590. package/vendor/core/dictate/microphone.d.ts +42 -0
  591. package/vendor/core/dictate/openai-transcriber.d.ts +22 -0
  592. package/vendor/core/dictate/openai-transcription.d.ts +27 -0
  593. package/vendor/core/dictate/pcm.d.ts +5 -0
  594. package/vendor/core/dictate/pcm16-encoder.d.ts +20 -0
  595. package/vendor/core/dictate/server.d.ts +1 -0
  596. package/vendor/core/dictate/server.js +153 -0
  597. package/vendor/core/dictate/transcriber.d.ts +23 -0
  598. package/vendor/core/disposable/async-disposer.d.ts +15 -0
  599. package/vendor/core/disposable/async-resource.d.ts +4 -0
  600. package/vendor/core/disposable/disposables.d.ts +8 -0
  601. package/vendor/core/disposable/disposer.d.ts +13 -0
  602. package/vendor/core/disposable/index.d.ts +5 -0
  603. package/vendor/core/disposable/index.js +96 -0
  604. package/vendor/core/disposable/resource.d.ts +4 -0
  605. package/vendor/core/events/dispatcher.d.ts +18 -0
  606. package/vendor/core/events/eventful.d.ts +7 -0
  607. package/vendor/core/events/events.d.ts +14 -0
  608. package/vendor/core/events/index.d.ts +4 -0
  609. package/vendor/core/events/index.js +75 -0
  610. package/vendor/core/events/noop-events.d.ts +6 -0
  611. package/vendor/core/id/counter-id-provider.d.ts +6 -0
  612. package/vendor/core/id/id-provider.d.ts +7 -0
  613. package/vendor/core/id/index.d.ts +3 -0
  614. package/vendor/core/id/index.js +17 -0
  615. package/vendor/core/id/uuid-provider.d.ts +11 -0
  616. package/vendor/core/index-qk5dj664.js +4 -0
  617. package/vendor/core/log/color.d.ts +22 -0
  618. package/vendor/core/log/composite-logger.d.ts +7 -0
  619. package/vendor/core/log/console-logger.d.ts +6 -0
  620. package/vendor/core/log/index.d.ts +8 -0
  621. package/vendor/core/log/index.js +154 -0
  622. package/vendor/core/log/level-prefix-logger.d.ts +12 -0
  623. package/vendor/core/log/logger.d.ts +12 -0
  624. package/vendor/core/log/mdc-logger.d.ts +14 -0
  625. package/vendor/core/log/memory-logger.d.ts +8 -0
  626. package/vendor/core/log/prefix-logger.d.ts +12 -0
  627. package/vendor/core/md/index.d.ts +2 -0
  628. package/vendor/core/md/index.js +182 -0
  629. package/vendor/core/md/markdown.d.ts +56 -0
  630. package/vendor/core/md/writer.d.ts +22 -0
  631. package/vendor/core/push/base64url.d.ts +2 -0
  632. package/vendor/core/push/encrypt.d.ts +12 -0
  633. package/vendor/core/push/index.d.ts +4 -0
  634. package/vendor/core/push/index.js +137 -0
  635. package/vendor/core/push/push-failure.d.ts +7 -0
  636. package/vendor/core/push/pusher.d.ts +24 -0
  637. package/vendor/core/push/vapid.d.ts +18 -0
  638. package/vendor/core/push/web-pusher.d.ts +20 -0
  639. package/vendor/core/ship/artifact/artifact.d.ts +52 -0
  640. package/vendor/core/ship/bundle/bun-bundle.d.ts +71 -0
  641. package/vendor/core/ship/bundle/bundle-artifact.d.ts +21 -0
  642. package/vendor/core/ship/bundle/bundle.d.ts +13 -0
  643. package/vendor/core/ship/bundle/published.d.ts +45 -0
  644. package/vendor/core/ship/bundle/reach.d.ts +43 -0
  645. package/vendor/core/ship/bundle/vendor-bundle.d.ts +47 -0
  646. package/vendor/core/ship/cut.d.ts +64 -0
  647. package/vendor/core/ship/dry-run.d.ts +63 -0
  648. package/vendor/core/ship/git/cli-git.d.ts +25 -0
  649. package/vendor/core/ship/git/git-artifact.d.ts +23 -0
  650. package/vendor/core/ship/git/git.d.ts +19 -0
  651. package/vendor/core/ship/github/cli-github.d.ts +31 -0
  652. package/vendor/core/ship/github/cli-workflows.d.ts +25 -0
  653. package/vendor/core/ship/github/github-artifact.d.ts +18 -0
  654. package/vendor/core/ship/github/github.d.ts +10 -0
  655. package/vendor/core/ship/github/login.d.ts +3 -0
  656. package/vendor/core/ship/github/workflows.d.ts +27 -0
  657. package/vendor/core/ship/index.d.ts +26 -0
  658. package/vendor/core/ship/index.js +3203 -0
  659. package/vendor/core/ship/mirror/agent-files.d.ts +6 -0
  660. package/vendor/core/ship/mirror/mirror-build.d.ts +63 -0
  661. package/vendor/core/ship/mirror/mirror-guard.d.ts +10 -0
  662. package/vendor/core/ship/mirror/mirror-options.d.ts +75 -0
  663. package/vendor/core/ship/mirror/mirror-step.d.ts +109 -0
  664. package/vendor/core/ship/mirror/mirror-tooling.d.ts +59 -0
  665. package/vendor/core/ship/mirror/source-manifest.d.ts +27 -0
  666. package/vendor/core/ship/order.d.ts +15 -0
  667. package/vendor/core/ship/publish-workflow.d.ts +32 -0
  668. package/vendor/core/ship/registry/github-actions.d.ts +76 -0
  669. package/vendor/core/ship/registry/npm-registry.d.ts +70 -0
  670. package/vendor/core/ship/registry/registry-artifact.d.ts +31 -0
  671. package/vendor/core/ship/registry/registry.d.ts +85 -0
  672. package/vendor/core/ship/release-file.d.ts +22 -0
  673. package/vendor/core/ship/release-options.d.ts +122 -0
  674. package/vendor/core/ship/release.d.ts +61 -0
  675. package/vendor/core/ship/releases.d.ts +119 -0
  676. package/vendor/core/ship/shipped.d.ts +54 -0
  677. package/vendor/core/ship/skill-artifact.d.ts +27 -0
  678. package/vendor/core/ship/step-events.d.ts +91 -0
  679. package/vendor/core/ship/step-runner.d.ts +16 -0
  680. package/vendor/core/ship/step.d.ts +49 -0
  681. package/vendor/core/ship/trust.d.ts +11 -0
  682. package/vendor/core/ship/version.d.ts +9 -0
  683. package/vendor/core/ship/workspace/manifest-workspace.d.ts +61 -0
  684. package/vendor/core/ship/workspace/workspace.d.ts +29 -0
  685. package/vendor/core/skills/index.d.ts +1 -0
  686. package/vendor/core/skills/index.js +77 -0
  687. package/vendor/core/skills/project-skills.d.ts +53 -0
  688. package/vendor/core/system/fs/fs.d.ts +58 -0
  689. package/vendor/core/system/fs/node-fs.d.ts +18 -0
  690. package/vendor/core/system/glob/glob.d.ts +11 -0
  691. package/vendor/core/system/glob/node-glob.d.ts +12 -0
  692. package/vendor/core/system/heavy/heavy-jobs.d.ts +84 -0
  693. package/vendor/core/system/host-mapper/file-host-mapper.d.ts +20 -0
  694. package/vendor/core/system/host-mapper/host-mapper.d.ts +11 -0
  695. package/vendor/core/system/host-mapper/noop-host-mapper.d.ts +4 -0
  696. package/vendor/core/system/index.d.ts +25 -0
  697. package/vendor/core/system/index.js +1385 -0
  698. package/vendor/core/system/ip-provider/darwin-ip-provider.d.ts +6 -0
  699. package/vendor/core/system/ip-provider/ip-provider.d.ts +8 -0
  700. package/vendor/core/system/ip-provider/linux-ip-provider.d.ts +6 -0
  701. package/vendor/core/system/ip-provider/platform-ip-provider.d.ts +6 -0
  702. package/vendor/core/system/ip-provider/sequential-ip-provider.d.ts +6 -0
  703. package/vendor/core/system/ip-provider/static-ip-provider.d.ts +8 -0
  704. package/vendor/core/system/ip-provider/win32-ip-provider.d.ts +6 -0
  705. package/vendor/core/system/lock/file-lock.d.ts +50 -0
  706. package/vendor/core/system/lock/lock.d.ts +11 -0
  707. package/vendor/core/system/lock/memory-lock.d.ts +13 -0
  708. package/vendor/core/system/port-provider/open-port-provider.d.ts +38 -0
  709. package/vendor/core/system/port-provider/port-provider.d.ts +14 -0
  710. package/vendor/core/system/process-like/process-like.d.ts +22 -0
  711. package/vendor/core/system/ps/file-process.d.ts +40 -0
  712. package/vendor/core/system/ps/listening.d.ts +20 -0
  713. package/vendor/core/system/ps/node-ps.d.ts +39 -0
  714. package/vendor/core/system/ps/ps.d.ts +161 -0
  715. package/vendor/core/system/ps/reap.d.ts +22 -0
  716. package/vendor/core/system/undumpable.d.ts +32 -0
  717. package/vendor/core/system/walk.d.ts +10 -0
  718. package/vendor/core/time/clock/clock.d.ts +5 -0
  719. package/vendor/core/time/clock/system-clock.d.ts +5 -0
  720. package/vendor/core/time/debouncer.d.ts +25 -0
  721. package/vendor/core/time/duration.d.ts +38 -0
  722. package/vendor/core/time/index.d.ts +13 -0
  723. package/vendor/core/time/index.js +271 -0
  724. package/vendor/core/time/sleep.d.ts +2 -0
  725. package/vendor/core/time/stopwatch.d.ts +34 -0
  726. package/vendor/core/time/throttler.d.ts +26 -0
  727. package/vendor/core/time/time-ago.d.ts +14 -0
  728. package/vendor/core/time/timeouts.d.ts +12 -0
  729. package/vendor/core/time/timer/system-timer.d.ts +7 -0
  730. package/vendor/core/time/timer/timer.d.ts +11 -0
  731. package/vendor/core/time/wall-clock/system-wall-clock.d.ts +4 -0
  732. package/vendor/core/time/wall-clock/wall-clock.d.ts +14 -0
  733. package/waiting.d.ts +2 -2
  734. package/worker.d.ts +2 -2
@@ -0,0 +1,3203 @@
1
+ // ship/bundle/published.ts
2
+ var LOCAL = new Set([
3
+ "devDependencies",
4
+ "scripts",
5
+ "files",
6
+ "private",
7
+ "workspaces",
8
+ "trustedDependencies",
9
+ "main",
10
+ "module",
11
+ "types",
12
+ "exports",
13
+ "bin"
14
+ ]);
15
+ var WORKSPACE = /^workspace:/;
16
+ var CATALOG = /^catalog:/;
17
+ var SOURCE = /\.tsx?$/;
18
+ function published(manifest, opts = {}) {
19
+ const version = manifest.version;
20
+ if (version === undefined) {
21
+ throw new Error(`${manifest.name ?? "a package"} has no version to publish`);
22
+ }
23
+ const out = {};
24
+ for (const [field, value] of Object.entries(manifest)) {
25
+ if (!LOCAL.has(field)) {
26
+ out[field] = value;
27
+ }
28
+ }
29
+ const main = built(entry(manifest.exports, ".") ?? manifest.module);
30
+ if (main !== undefined) {
31
+ out.main = main;
32
+ out.types = types(main);
33
+ }
34
+ if (manifest.exports !== undefined) {
35
+ out.exports = conditions(manifest.exports);
36
+ }
37
+ if (manifest.bin !== undefined) {
38
+ out.bin = typeof manifest.bin === "string" ? built(manifest.bin) ?? manifest.bin : Object.fromEntries(Object.entries(manifest.bin).map(([name, path]) => [
39
+ name,
40
+ built(path) ?? path
41
+ ]));
42
+ }
43
+ for (const field of ["dependencies", "peerDependencies"]) {
44
+ const deps = manifest[field];
45
+ if (deps !== undefined) {
46
+ out[field] = ranges(manifest.name, deps, version, opts);
47
+ }
48
+ }
49
+ return out;
50
+ }
51
+ function conditions(exports) {
52
+ if (typeof exports === "string") {
53
+ const main = built(exports);
54
+ return main === undefined ? exports : { types: types(main), default: main };
55
+ }
56
+ return Object.fromEntries(Object.entries(exports).map(([key, value]) => [key, conditions(value)]));
57
+ }
58
+ function built(path) {
59
+ return path !== undefined && SOURCE.test(path) ? path.replace(SOURCE, ".js") : undefined;
60
+ }
61
+ function types(path) {
62
+ return path.replace(/\.js$/, ".d.ts");
63
+ }
64
+ function entry(exports, key) {
65
+ if (exports === undefined) {
66
+ return;
67
+ }
68
+ if (typeof exports === "string") {
69
+ return key === "." ? exports : undefined;
70
+ }
71
+ const found = exports[key];
72
+ return typeof found === "string" ? found : undefined;
73
+ }
74
+ function ranges(name, deps, version, opts) {
75
+ return Object.fromEntries(Object.entries(deps).map(([dep, range]) => {
76
+ if (WORKSPACE.test(range)) {
77
+ return [dep, `^${opts.versions?.[dep] ?? version}`];
78
+ }
79
+ if (CATALOG.test(range)) {
80
+ const given = opts.catalog?.[dep];
81
+ if (given === undefined) {
82
+ throw new Error(`${name ?? "a package"} takes ${dep} from the catalog, which has no ${dep}`);
83
+ }
84
+ return [dep, given];
85
+ }
86
+ return [dep, range];
87
+ }));
88
+ }
89
+ // ship/bundle/vendor-bundle.ts
90
+ import { dirname as dirname3, relative } from "node:path";
91
+ import { NodeFs as NodeFs3, NodePs as NodePs3, walk as walk2 } from "../system/index.js";
92
+
93
+ // ship/workspace/manifest-workspace.ts
94
+ import { dirname } from "node:path";
95
+ import { NodeFs, NodePs } from "../system/index.js";
96
+
97
+ class ManifestWorkspace {
98
+ root;
99
+ fs;
100
+ ps;
101
+ project;
102
+ constructor(root, opts = {}) {
103
+ this.root = root;
104
+ this.fs = opts.fs ?? new NodeFs;
105
+ this.ps = opts.ps ?? new NodePs;
106
+ this.project = opts.project;
107
+ }
108
+ static async at(from, opts = {}) {
109
+ const fs = opts.fs ?? new NodeFs;
110
+ let single = null;
111
+ for (let dir = from;; dir = dirname(dir)) {
112
+ const manifest = await read(fs, dir);
113
+ if (manifest?.workspaces !== undefined) {
114
+ return new ManifestWorkspace(dir, { ...opts, fs });
115
+ }
116
+ if (single === null && manifest?.name !== undefined) {
117
+ single = dir;
118
+ }
119
+ if (dirname(dir) === dir) {
120
+ if (single === null) {
121
+ throw new Error(`no workspace above ${from}`);
122
+ }
123
+ return new ManifestWorkspace(single, { ...opts, fs });
124
+ }
125
+ }
126
+ }
127
+ async version() {
128
+ if (this.project !== undefined) {
129
+ for (const dir of await this.dirs()) {
130
+ const version = (await read(this.fs, dir))?.version;
131
+ if (version !== undefined) {
132
+ return version;
133
+ }
134
+ }
135
+ return "0.0.0";
136
+ }
137
+ return (await this.manifest()).version ?? "0.0.0";
138
+ }
139
+ async packages() {
140
+ const found = [];
141
+ for (const dir of await this.dirs()) {
142
+ const manifest = await read(this.fs, dir);
143
+ if (manifest?.name !== undefined) {
144
+ found.push({ dir, manifest: { ...manifest, name: manifest.name } });
145
+ }
146
+ }
147
+ const names = new Set(found.map((one) => one.manifest.name));
148
+ return found.map(({ dir, manifest }) => ({
149
+ name: manifest.name,
150
+ dir,
151
+ private: manifest.private === true,
152
+ dependencies: Object.keys({
153
+ ...manifest.dependencies,
154
+ ...manifest.peerDependencies
155
+ }).filter((dep) => names.has(dep)),
156
+ ...repositoryOf(manifest)
157
+ })).sort((left, right) => left.name.localeCompare(right.name));
158
+ }
159
+ async setVersion(version) {
160
+ const dirs = (await this.dirs()).filter((dir) => dir !== this.root);
161
+ for (const dir of dirs) {
162
+ await this.stamp(dir, version);
163
+ }
164
+ await this.lock();
165
+ if (this.project === undefined) {
166
+ await this.stamp(this.root, version);
167
+ }
168
+ }
169
+ async dirs() {
170
+ const declared = (await this.manifest()).workspaces;
171
+ const workspaces = Array.isArray(declared) ? declared : declared?.packages;
172
+ if (workspaces === undefined) {
173
+ return [this.root];
174
+ }
175
+ const dirs = [];
176
+ for (const pattern of workspaces) {
177
+ dirs.push(...await this.expand(this.root, pattern.split("/")));
178
+ }
179
+ if (this.project === undefined) {
180
+ const root = await this.manifest();
181
+ const published = root.name !== undefined && root.private !== true;
182
+ return published && !dirs.includes(this.root) ? [this.root, ...dirs] : dirs;
183
+ }
184
+ return dirs.filter((dir) => dir.startsWith(`${this.root}/${this.project}/`));
185
+ }
186
+ async expand(dir, segments) {
187
+ const [head, ...rest] = segments;
188
+ if (head === undefined) {
189
+ return [dir];
190
+ }
191
+ if (head !== "*") {
192
+ return this.expand(`${dir}/${head}`, rest);
193
+ }
194
+ const found = [];
195
+ for (const entry of await this.fs.readdir(dir).catch(() => [])) {
196
+ found.push(...await this.expand(`${dir}/${entry}`, rest));
197
+ }
198
+ return found;
199
+ }
200
+ async lock() {
201
+ if (!await this.fs.exists(`${this.root}/bun.lock`)) {
202
+ return;
203
+ }
204
+ const { exitCode, stdout, stderr } = await this.ps.spawnCapture(["bun", "install", "--lockfile-only"], { cwd: this.root });
205
+ if (exitCode !== 0) {
206
+ throw new Error(`bun install --lockfile-only: ${stderr.trim() || stdout.trim()}`);
207
+ }
208
+ }
209
+ async manifest() {
210
+ return await read(this.fs, this.root) ?? {};
211
+ }
212
+ async stamp(dir, version) {
213
+ const path = `${dir}/package.json`;
214
+ const manifest = await read(this.fs, dir);
215
+ if (manifest === null) {
216
+ return;
217
+ }
218
+ manifest.version = version;
219
+ await this.fs.write(path, `${JSON.stringify(manifest, null, "\t")}
220
+ `);
221
+ }
222
+ }
223
+ async function read(fs, dir) {
224
+ try {
225
+ return JSON.parse(await fs.read(`${dir}/package.json`));
226
+ } catch {
227
+ return null;
228
+ }
229
+ }
230
+ function repositoryOf(manifest) {
231
+ const { repository } = manifest;
232
+ const url = typeof repository === "string" ? repository : repository?.url;
233
+ return url === undefined ? {} : { repository: url };
234
+ }
235
+
236
+ // ship/bundle/bun-bundle.ts
237
+ import {
238
+ NodeFs as NodeFs2,
239
+ NodeGlob,
240
+ NodePs as NodePs2,
241
+ walk
242
+ } from "../system/index.js";
243
+
244
+ // ship/bundle/reach.ts
245
+ import { builtinModules } from "node:module";
246
+ import { dirname as dirname2, resolve as resolvePath } from "node:path";
247
+ var SPECIFIER = /\b(from|import)(\s*\(?\s*)"([^"]+)"/g;
248
+ var SOURCE_SPECIFIER = /\b(from|import)(\s*\(?\s*)(["'])([^"'\n]+)\3/g;
249
+ var SOURCE2 = /\.tsx?$/;
250
+ var PACKAGE_NAME = /^(@[a-z0-9~-][a-z0-9._~-]*\/)?[a-z0-9~-][a-z0-9._~-]*$/;
251
+ function keyOf(pkg, exported, specifier) {
252
+ const key = `.${specifier.slice(pkg.name.length)}`;
253
+ if (!exported.has(key)) {
254
+ throw new Error(`${pkg.name} exports no "${key}", imported as "${specifier}"`);
255
+ }
256
+ return key;
257
+ }
258
+ async function reach(fs, pkg, keys) {
259
+ const manifest = await manifestAt(fs, pkg.dir);
260
+ const exported = entries(manifest.exports ?? {});
261
+ const found = new Set;
262
+ const seen = new Set;
263
+ const queue = [...keys];
264
+ while (queue.length > 0) {
265
+ const key = queue.pop();
266
+ if (found.has(key)) {
267
+ continue;
268
+ }
269
+ found.add(key);
270
+ const files = [`${pkg.dir}/${exported.get(key).slice(2)}`];
271
+ while (files.length > 0) {
272
+ const file = files.pop();
273
+ if (seen.has(file) || file.endsWith(".test.ts")) {
274
+ continue;
275
+ }
276
+ seen.add(file);
277
+ for (const specifier of await specifiers(file, fs)) {
278
+ if (isPackage(specifier, pkg.name)) {
279
+ queue.push(keyOf(pkg, exported, specifier));
280
+ } else if (specifier.startsWith(".")) {
281
+ const next = await resolve(fs, resolvePath(dirname2(file), specifier));
282
+ if (next !== undefined) {
283
+ files.push(next);
284
+ }
285
+ }
286
+ }
287
+ }
288
+ }
289
+ return { keys: found, files: seen };
290
+ }
291
+ async function resolve(fs, path) {
292
+ const candidates = SOURCE2.test(path) ? [path] : [`${path}.ts`, `${path}.tsx`, `${path}/index.ts`, `${path}/index.tsx`];
293
+ for (const candidate of candidates) {
294
+ if (await fs.exists(candidate)) {
295
+ return candidate;
296
+ }
297
+ }
298
+ return;
299
+ }
300
+ function isPackage(specifier, name) {
301
+ return specifier === name || specifier.startsWith(`${name}/`);
302
+ }
303
+ function outsider(specifier) {
304
+ if (specifier.startsWith(".") || specifier.startsWith("node:") || specifier.startsWith("bun:") || specifier === "bun") {
305
+ return;
306
+ }
307
+ const parts = specifier.split("/");
308
+ const name = specifier.startsWith("@") ? parts.slice(0, 2).join("/") : parts[0];
309
+ return name === undefined || !PACKAGE_NAME.test(name) || builtinModules.includes(name) ? undefined : name;
310
+ }
311
+ async function specifiers(path, fs) {
312
+ const text = await fs.read(path);
313
+ return [...text.matchAll(SOURCE_SPECIFIER)].map((match) => match[4]);
314
+ }
315
+ function entries(exports) {
316
+ const found = new Map;
317
+ if (typeof exports === "string") {
318
+ return found.set(".", exports);
319
+ }
320
+ for (const [key, value] of Object.entries(exports)) {
321
+ const path = pathOf(value);
322
+ if (path !== undefined) {
323
+ found.set(key, path);
324
+ }
325
+ }
326
+ return found;
327
+ }
328
+ function pathOf(exports) {
329
+ if (typeof exports === "string") {
330
+ return exports;
331
+ }
332
+ for (const value of Object.values(exports)) {
333
+ const path = pathOf(value);
334
+ if (path !== undefined) {
335
+ return path;
336
+ }
337
+ }
338
+ return;
339
+ }
340
+ async function manifestAt(fs, dir) {
341
+ return JSON.parse(await fs.read(`${dir}/package.json`));
342
+ }
343
+ async function catalogAt(fs, root) {
344
+ const manifest = await manifestAt(fs, root);
345
+ const nested = Array.isArray(manifest.workspaces) ? undefined : manifest.workspaces?.catalog;
346
+ return { ...manifest.catalog, ...nested };
347
+ }
348
+
349
+ // ship/bundle/bun-bundle.ts
350
+ var SPECIFIER2 = /(from\s*"|import\(")(\.[^"]*)(")/g;
351
+ var EXTENSION = /\.[a-z]+$/;
352
+ var SOURCE3 = /\.tsx?$/;
353
+ var DOCS = ["README.md", "LICENSE", "LICENSE.md", "CHANGELOG.md"];
354
+
355
+ class BunBundle {
356
+ fs;
357
+ ps;
358
+ glob;
359
+ constructor(opts = {}) {
360
+ this.fs = opts.fs ?? new NodeFs2;
361
+ this.ps = opts.ps ?? new NodePs2;
362
+ this.glob = opts.glob ?? new NodeGlob;
363
+ }
364
+ async build(dir) {
365
+ const manifest = JSON.parse(await this.fs.read(`${dir}/package.json`));
366
+ const out = `${dir}/dist`;
367
+ if (manifest.scripts?.build !== undefined) {
368
+ await this.run(["bun", "run", "build"], dir);
369
+ }
370
+ await this.compile(dir, sources(manifest));
371
+ await this.fs.mkdir(out);
372
+ await this.point(dir);
373
+ await this.fs.write(`${out}/package.json`, `${JSON.stringify(published(manifest, await this.resolving(dir, manifest)), null, "\t")}
374
+ `);
375
+ for (const doc of DOCS) {
376
+ if (await this.fs.exists(`${dir}/${doc}`)) {
377
+ await this.fs.write(`${out}/${doc}`, await this.fs.read(`${dir}/${doc}`));
378
+ }
379
+ }
380
+ await this.copy(dir, manifest.files ?? []);
381
+ return out;
382
+ }
383
+ async resolving(dir, manifest) {
384
+ const ranges = Object.values({
385
+ ...manifest.dependencies,
386
+ ...manifest.peerDependencies
387
+ });
388
+ if (!ranges.some((range) => /^(workspace|catalog):/.test(range))) {
389
+ return {};
390
+ }
391
+ const workspace = await ManifestWorkspace.at(dir, {
392
+ fs: this.fs,
393
+ ps: this.ps
394
+ });
395
+ const versions = {};
396
+ for (const pkg of await workspace.packages()) {
397
+ const { version } = await manifestAt(this.fs, pkg.dir);
398
+ if (version !== undefined) {
399
+ versions[pkg.name] = version;
400
+ }
401
+ }
402
+ return { versions, catalog: await catalogAt(this.fs, workspace.root) };
403
+ }
404
+ async clean(dir) {
405
+ await this.fs.rm(`${dir}/dist`, { recursive: true, force: true });
406
+ }
407
+ async copy(dir, patterns) {
408
+ if (patterns.length === 0) {
409
+ return;
410
+ }
411
+ const out = `${dir}/dist`;
412
+ for await (const path of walk(dir, { fs: this.fs })) {
413
+ if (path.startsWith(`${out}/`)) {
414
+ continue;
415
+ }
416
+ const relative = path.slice(dir.length + 1);
417
+ if (patterns.some((pattern) => this.glob.matches(pattern, relative))) {
418
+ await this.fs.mkdir(`${out}/${relative}`.replace(/\/[^/]*$/, ""));
419
+ await this.fs.writeBytes(`${out}/${relative}`, await this.fs.readBytes(path));
420
+ }
421
+ }
422
+ }
423
+ async compile(dir, entries, outdir = "dist") {
424
+ if (entries.length === 0) {
425
+ return;
426
+ }
427
+ await this.run([
428
+ "bun",
429
+ "build",
430
+ ...entries,
431
+ "--outdir",
432
+ outdir,
433
+ "--root",
434
+ ".",
435
+ "--target",
436
+ "node",
437
+ "--packages",
438
+ "external",
439
+ "--splitting"
440
+ ], dir);
441
+ await this.run([
442
+ "bunx",
443
+ "tsc",
444
+ "--ignoreConfig",
445
+ "--emitDeclarationOnly",
446
+ "--declaration",
447
+ "--outDir",
448
+ outdir,
449
+ "--rootDir",
450
+ ".",
451
+ "--module",
452
+ "preserve",
453
+ "--moduleResolution",
454
+ "bundler",
455
+ "--target",
456
+ "esnext",
457
+ "--lib",
458
+ "esnext,dom",
459
+ "--types",
460
+ "bun",
461
+ "--strict",
462
+ "--skipLibCheck",
463
+ ...entries,
464
+ ...await this.ambient(dir)
465
+ ], dir);
466
+ }
467
+ async ambient(dir) {
468
+ const entries = await this.fs.readdir(dir);
469
+ return entries.filter((entry) => entry.endsWith(".d.ts")).map((entry) => `./${entry}`);
470
+ }
471
+ async point(dir) {
472
+ for await (const path of walk(`${dir}/dist`, { fs: this.fs })) {
473
+ if (!path.endsWith(".d.ts")) {
474
+ continue;
475
+ }
476
+ const before = await this.fs.read(path);
477
+ const after = before.replace(SPECIFIER2, (match, head, specifier, tail) => EXTENSION.test(specifier) ? match : `${head}${specifier}.js${tail}`);
478
+ if (after !== before) {
479
+ await this.fs.write(path, after);
480
+ }
481
+ }
482
+ }
483
+ async run(argv, cwd) {
484
+ const { exitCode } = await this.ps.spawn(argv, { cwd });
485
+ if (exitCode !== 0) {
486
+ throw new Error(`\`${argv.join(" ")}\` failed in ${cwd}`);
487
+ }
488
+ }
489
+ }
490
+ function sources(manifest) {
491
+ const found = new Set;
492
+ const gather = (entry) => {
493
+ if (typeof entry === "string") {
494
+ if (SOURCE3.test(entry)) {
495
+ found.add(entry);
496
+ }
497
+ return;
498
+ }
499
+ for (const value of Object.values(entry)) {
500
+ gather(value);
501
+ }
502
+ };
503
+ gather(manifest.exports ?? {});
504
+ gather(manifest.bin ?? {});
505
+ return [...found];
506
+ }
507
+
508
+ // ship/bundle/vendor-bundle.ts
509
+ var NEVER = ["scry", "vet"];
510
+
511
+ class VendorBundle {
512
+ opts;
513
+ fs;
514
+ ps;
515
+ bundle;
516
+ constructor(opts = {}) {
517
+ this.opts = opts;
518
+ this.fs = opts.fs ?? new NodeFs3;
519
+ this.ps = opts.ps ?? new NodePs3;
520
+ this.bundle = opts.bundle ?? new BunBundle({ fs: this.fs, ps: this.ps });
521
+ }
522
+ async build(dir) {
523
+ const source = await manifestAt(this.fs, dir);
524
+ const workspace = this.opts.workspace ?? await ManifestWorkspace.at(dir, { fs: this.fs, ps: this.ps });
525
+ const private_ = (await workspace.packages()).filter((pkg) => pkg.private);
526
+ const vendored = private_.filter((pkg) => source.dependencies?.[pkg.name]?.startsWith("workspace:"));
527
+ const never = this.opts.never ?? NEVER;
528
+ for (const pkg of vendored) {
529
+ if (never.includes(pkg.name)) {
530
+ throw new Error(`${source.name} depends on ${pkg.name}, which stays in the repository and cannot be vendored`);
531
+ }
532
+ }
533
+ const out = await this.bundle.build(dir);
534
+ if (vendored.length === 0) {
535
+ return out;
536
+ }
537
+ const catalog = await catalogAt(this.fs, workspace.root);
538
+ const published = await manifestAt(this.fs, out);
539
+ for (const pkg of vendored) {
540
+ delete published.dependencies?.[pkg.name];
541
+ await this.vendor(pkg, out, published, catalog);
542
+ }
543
+ await this.fs.write(`${out}/package.json`, `${JSON.stringify(published, null, "\t")}
544
+ `);
545
+ return out;
546
+ }
547
+ async clean(dir) {
548
+ await this.bundle.clean(dir);
549
+ }
550
+ async vendor(pkg, out, published, catalog) {
551
+ const manifest = await manifestAt(this.fs, pkg.dir);
552
+ const exported = entries(manifest.exports ?? {});
553
+ const root = `${out}/vendor/${pkg.name}`;
554
+ const names = (path) => specifiers(path, this.fs);
555
+ const wanted = new Set;
556
+ for (const path of await this.built(out)) {
557
+ for (const specifier of await names(path)) {
558
+ if (isPackage(specifier, pkg.name)) {
559
+ wanted.add(keyOf(pkg, exported, specifier));
560
+ }
561
+ }
562
+ }
563
+ const reached = (await reach(this.fs, pkg, [...wanted])).keys;
564
+ if (reached.size === 0) {
565
+ return;
566
+ }
567
+ const sources = [...reached].map((key) => exported.get(key));
568
+ await this.bundle.compile(pkg.dir, sources, root);
569
+ const where = new Map([...reached].map((key) => [
570
+ key === "." ? pkg.name : `${pkg.name}/${key.slice(2)}`,
571
+ `${root}/${exported.get(key).replace(SOURCE2, ".js")}`
572
+ ]));
573
+ for (const path of await this.built(out)) {
574
+ const before = await this.fs.read(path);
575
+ const after = before.replace(SPECIFIER, (match, head, gap, specifier) => {
576
+ const target = isPackage(specifier, pkg.name) ? where.get(specifier) : undefined;
577
+ if (target === undefined) {
578
+ return match;
579
+ }
580
+ const next = relative(dirname3(path), target);
581
+ return `${head}${gap}"${next.startsWith(".") ? next : `./${next}`}"`;
582
+ });
583
+ if (after !== before) {
584
+ await this.fs.write(path, after);
585
+ }
586
+ }
587
+ const needed = new Set;
588
+ for await (const path of walk2(root, { fs: this.fs })) {
589
+ if (!/\.(js|d\.ts)$/.test(path)) {
590
+ continue;
591
+ }
592
+ for (const specifier of await names(path)) {
593
+ const outside = outsider(specifier);
594
+ if (outside !== undefined) {
595
+ needed.add(outside);
596
+ }
597
+ }
598
+ }
599
+ this.declare(pkg.name, manifest, published, catalog, needed);
600
+ for (const doc of ["LICENSE", "LICENSE.md"]) {
601
+ if (await this.fs.exists(`${pkg.dir}/${doc}`)) {
602
+ await this.fs.write(`${root}/${doc}`, await this.fs.read(`${pkg.dir}/${doc}`));
603
+ }
604
+ }
605
+ }
606
+ async built(out) {
607
+ const found = [];
608
+ for await (const path of walk2(out, { fs: this.fs })) {
609
+ if (/\.(js|d\.ts)$/.test(path)) {
610
+ found.push(path);
611
+ }
612
+ }
613
+ return found.toSorted();
614
+ }
615
+ declare(vendored, manifest, published, catalog, needed) {
616
+ for (const name of [...needed].toSorted()) {
617
+ if (published.dependencies?.[name] !== undefined || published.peerDependencies?.[name] !== undefined) {
618
+ continue;
619
+ }
620
+ const field = manifest.dependencies?.[name] !== undefined ? "dependencies" : manifest.peerDependencies?.[name] !== undefined ? "peerDependencies" : undefined;
621
+ if (field === undefined) {
622
+ throw new Error(`${vendored} imports ${name}, which it does not declare`);
623
+ }
624
+ const range = manifest[field]?.[name];
625
+ const resolved = range.startsWith("catalog:") ? catalog[name] : range;
626
+ if (resolved === undefined || resolved.startsWith("workspace:")) {
627
+ throw new Error(`${vendored} declares ${name} as ${range}, which no registry can resolve`);
628
+ }
629
+ published[field] = { ...published[field], [name]: resolved };
630
+ const meta = manifest.peerDependenciesMeta?.[name];
631
+ if (field === "peerDependencies" && meta !== undefined) {
632
+ published.peerDependenciesMeta = {
633
+ ...published.peerDependenciesMeta,
634
+ [name]: meta
635
+ };
636
+ }
637
+ }
638
+ }
639
+ }
640
+ // ship/cut.ts
641
+ import { ConsoleLogger } from "../log/index.js";
642
+
643
+ class Cut {
644
+ version;
645
+ packages;
646
+ tag;
647
+ log;
648
+ root;
649
+ dryRun;
650
+ staged = new Map;
651
+ constructor(version, packages, opts = {}) {
652
+ this.version = version;
653
+ this.packages = packages;
654
+ this.tag = `v${version}`;
655
+ this.log = opts.log ?? new ConsoleLogger;
656
+ this.root = opts.root ?? ".";
657
+ this.dryRun = opts.dryRun;
658
+ }
659
+ dir(name) {
660
+ const pkg = this.packages.find((one) => one.name === name);
661
+ return pkg === undefined ? undefined : this.staged.get(name) ?? pkg.dir;
662
+ }
663
+ stage(name, dir) {
664
+ this.staged.set(name, dir);
665
+ }
666
+ }
667
+ // ship/mirror/mirror-build.ts
668
+ import { join as join2, relative as relative4 } from "node:path";
669
+ import { color as color2 } from "../log/index.js";
670
+ import { NodeFs as NodeFs6, NodePs as NodePs6 } from "../system/index.js";
671
+ import { Duration as Duration2 } from "../time/index.js";
672
+
673
+ // ship/git/cli-git.ts
674
+ import { NodePs as NodePs4 } from "../system/index.js";
675
+
676
+ class CliGit {
677
+ root;
678
+ ps;
679
+ constructor(root, opts = {}) {
680
+ this.root = root;
681
+ this.ps = opts.ps ?? new NodePs4;
682
+ }
683
+ async clean() {
684
+ return await this.out("status", "--porcelain") === "";
685
+ }
686
+ branch() {
687
+ return this.out("rev-parse", "--abbrev-ref", "HEAD");
688
+ }
689
+ head() {
690
+ return this.out("rev-parse", "HEAD");
691
+ }
692
+ async defaultBranch() {
693
+ const head = await this.run("symbolic-ref", "--short", "refs/remotes/origin/HEAD");
694
+ return head.exitCode === 0 ? head.stdout.trim().replace(/^origin\//, "") : "main";
695
+ }
696
+ async discard() {
697
+ await this.out("checkout", "HEAD", "--", ":/");
698
+ }
699
+ async commitAll(message) {
700
+ if (await this.clean()) {
701
+ return;
702
+ }
703
+ await this.out("commit", "--all", "--message", message);
704
+ }
705
+ async tag(tag) {
706
+ const { exitCode } = await this.run("rev-parse", "--verify", "--quiet", `refs/tags/${tag}`);
707
+ if (exitCode === 0) {
708
+ return;
709
+ }
710
+ await this.out("tag", tag);
711
+ }
712
+ async push(ref) {
713
+ await this.out("push", "origin", ref);
714
+ }
715
+ async remoteTags(pattern) {
716
+ const out = await this.out("ls-remote", "--tags", "--refs", "origin", pattern);
717
+ return out.split(`
718
+ `).filter((line) => line !== "").map((line) => line.replace(/^\S+\trefs\/tags\//, ""));
719
+ }
720
+ run(...args) {
721
+ return this.ps.spawnCapture(["git", "-C", this.root, ...args]);
722
+ }
723
+ async out(...args) {
724
+ const { exitCode, stdout, stderr } = await this.run(...args);
725
+ if (exitCode !== 0) {
726
+ throw new Error(`git ${args.join(" ")}: ${stderr.trim() || stdout.trim()}`);
727
+ }
728
+ return stdout.trim();
729
+ }
730
+ }
731
+
732
+ // ship/publish-workflow.ts
733
+ import { dirname as dirname4, resolve as resolve2 } from "node:path";
734
+ import { NodeFs as NodeFs4 } from "../system/index.js";
735
+ var PUBLISH_WORKFLOW_PATH = ".github/workflows/webappwiz-publish.yml";
736
+
737
+ class PublishWorkflow {
738
+ command;
739
+ fs;
740
+ constructor(opts) {
741
+ this.command = opts.command;
742
+ this.fs = opts.fs ?? new NodeFs4;
743
+ }
744
+ text() {
745
+ return `# Generated by webappwiz; do not edit. A release rewrites it when it is stale.
746
+ # npm's trusted publisher entries name this file, so keep its path.
747
+ name: webappwiz publish
748
+
749
+ on:
750
+ workflow_dispatch:
751
+ inputs:
752
+ ref:
753
+ description: The release commit to publish
754
+ required: true
755
+
756
+ permissions:
757
+ contents: read
758
+ id-token: write
759
+
760
+ jobs:
761
+ publish:
762
+ runs-on: ubuntu-latest
763
+ steps:
764
+ - uses: actions/checkout@v4
765
+ with:
766
+ ref: \${{ inputs.ref }}
767
+ - uses: oven-sh/setup-bun@v2
768
+ - uses: actions/setup-node@v4
769
+ with:
770
+ node-version: 24
771
+ registry-url: https://registry.npmjs.org
772
+ - run: npm install -g npm@latest
773
+ - run: bun install --frozen-lockfile
774
+ - run: ${this.command}
775
+ `;
776
+ }
777
+ async drift(root) {
778
+ const path = resolve2(root, PUBLISH_WORKFLOW_PATH);
779
+ if (!await this.fs.exists(path)) {
780
+ return "missing";
781
+ }
782
+ return await this.fs.read(path) === this.text() ? undefined : "stale";
783
+ }
784
+ async write(root) {
785
+ if (await this.drift(root) === undefined) {
786
+ return false;
787
+ }
788
+ const path = resolve2(root, PUBLISH_WORKFLOW_PATH);
789
+ await this.fs.mkdir(dirname4(path), { recursive: true });
790
+ await this.fs.write(path, this.text());
791
+ return true;
792
+ }
793
+ async check(root) {
794
+ const drift = await this.drift(root);
795
+ if (drift !== undefined) {
796
+ throw new Error(`${PUBLISH_WORKFLOW_PATH} is ${drift}: run a release to regenerate it, and commit it`);
797
+ }
798
+ }
799
+ }
800
+
801
+ // ship/mirror/mirror-step.ts
802
+ import { tmpdir } from "node:os";
803
+ import { dirname as dirname6, join, relative as relative3 } from "node:path";
804
+ import { color } from "../log/index.js";
805
+ import {
806
+ NodeFs as NodeFs5,
807
+ NodeGlob as NodeGlob2,
808
+ NodePs as NodePs5
809
+ } from "../system/index.js";
810
+ import { Duration } from "../time/index.js";
811
+
812
+ // ship/mirror/agent-files.ts
813
+ var AGENT_FILES = [
814
+ "**/AGENTS.md",
815
+ "**/CLAUDE.md",
816
+ "**/.claude/**",
817
+ "**/.agents/**",
818
+ "skills/**",
819
+ "splates.config.ts",
820
+ "SPLATES.md"
821
+ ];
822
+
823
+ // ship/mirror/mirror-guard.ts
824
+ var TRAILER = "Mirrored-from";
825
+ async function guard(ps, mirror, project, adopt) {
826
+ const git = async (...args) => {
827
+ const result = await ps.spawnCapture(["git", ...args], { cwd: mirror });
828
+ if (result.exitCode !== 0) {
829
+ throw new Error(`git ${args.join(" ")} failed: ${result.stderr.trim()}`);
830
+ }
831
+ return result.stdout.trim();
832
+ };
833
+ const head = await ps.spawnCapture(["git", "rev-parse", "HEAD"], {
834
+ cwd: mirror
835
+ });
836
+ if (head.exitCode !== 0) {
837
+ return;
838
+ }
839
+ const last = await git("log", "--first-parent", "--max-count=1", "--format=%H", "--extended-regexp", `--grep=^${TRAILER}: [0-9a-f]{40}$`, `--grep=^Mirror ${escapeRegExp(project)} at `);
840
+ const from = last !== "" ? last : adopt;
841
+ if (from === undefined) {
842
+ throw new Error(`${project}'s remote has commits but none is a mirror commit; name the commit the mirror takes over from with \`adopt\` to take it over on purpose`);
843
+ }
844
+ const known = await ps.spawnCapture(["git", "cat-file", "-e", `${from}^{commit}`], { cwd: mirror });
845
+ if (known.exitCode !== 0) {
846
+ throw new Error(`${project} adopts ${from}, which the remote branch does not hold`);
847
+ }
848
+ const foreign = await git("log", "--format=%h %an %s", `${from}..HEAD`);
849
+ if (foreign !== "") {
850
+ throw new Error(`${project}'s remote has commits the mirror did not make, which this run would revert:
851
+ ${foreign}
852
+ Import them into mono, or drop them from the remote on purpose, then ship again`);
853
+ }
854
+ }
855
+ function escapeRegExp(text) {
856
+ return text.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
857
+ }
858
+
859
+ // ship/mirror/mirror-tooling.ts
860
+ import { dirname as dirname5, relative as relative2 } from "node:path";
861
+
862
+ class MirrorTooling {
863
+ opts;
864
+ constructor(opts) {
865
+ this.opts = opts;
866
+ }
867
+ get fs() {
868
+ return this.opts.fs;
869
+ }
870
+ get ps() {
871
+ return this.opts.ps;
872
+ }
873
+ async tsconfigs(dir, files) {
874
+ for (const path of files) {
875
+ if (!path.endsWith("/tsconfig.json")) {
876
+ continue;
877
+ }
878
+ const base = relative2(dirname5(path), dir) || ".";
879
+ const before = await this.fs.read(path);
880
+ const after = before.replace(/("extends"\s*:\s*")(?:\.\.\/)+(tsconfig\.base\.json")/g, `$1${base}/$2`);
881
+ if (after !== before) {
882
+ await this.fs.write(path, after);
883
+ }
884
+ }
885
+ }
886
+ async gitignore(root, mirror) {
887
+ const own = `${mirror}/.gitignore`;
888
+ const base = await this.fs.exists(`${root}/.gitignore`) ? (await this.fs.read(`${root}/.gitignore`)).split(`
889
+ `).flatMap((line) => this.rooted(line)).join(`
890
+ `) : `node_modules
891
+ dist
892
+ *.tgz
893
+ `;
894
+ const theirs = await this.fs.exists(own) ? await this.fs.read(own) : "";
895
+ await this.fs.write(own, theirs === "" ? base : `${base.trimEnd()}
896
+
897
+ ${theirs}`);
898
+ }
899
+ rooted(line) {
900
+ const negated = line.startsWith("!");
901
+ const pattern = (negated ? line.slice(1) : line).replace(/^\//, "");
902
+ const prefix = `${this.opts.project}/`;
903
+ if (pattern.startsWith(prefix)) {
904
+ return [`${negated ? "!" : ""}${pattern.slice(prefix.length)}`];
905
+ }
906
+ const anchored = pattern.replace(/\/$/, "").includes("/") && !pattern.startsWith("**/") && !line.trimStart().startsWith("#");
907
+ return anchored ? [] : [line];
908
+ }
909
+ async bunfig(root, mirror) {
910
+ if (!await this.fs.exists(`${root}/bunfig.toml`)) {
911
+ return;
912
+ }
913
+ const base = await this.fs.read(`${root}/bunfig.toml`);
914
+ const own = `${mirror}/bunfig.toml`;
915
+ if (!await this.fs.exists(own)) {
916
+ await this.fs.write(own, base);
917
+ return;
918
+ }
919
+ const mine = await this.fs.read(own);
920
+ const clash = tables(base).filter((table) => tables(mine).includes(table));
921
+ if (clash.length > 0) {
922
+ throw new Error(`${this.opts.project} and the root both set [${clash[0]}] in bunfig.toml`);
923
+ }
924
+ await this.fs.write(own, `${base.trimEnd()}
925
+
926
+ ${mine}`);
927
+ }
928
+ async lint(root, mirror, source) {
929
+ if (!await this.fs.exists(`${root}/biome.json`)) {
930
+ return;
931
+ }
932
+ const base = JSON.parse(await this.fs.read(`${root}/biome.json`));
933
+ if (Array.isArray(base.overrides)) {
934
+ base.overrides = this.overrides(base.overrides);
935
+ }
936
+ const own = `${mirror}/biome.json`;
937
+ let config = base;
938
+ if (await this.fs.exists(own)) {
939
+ const {
940
+ root: _root,
941
+ extends: _extends,
942
+ ...rest
943
+ } = JSON.parse(await this.fs.read(own));
944
+ config = merge(base, rest);
945
+ }
946
+ config.files = {
947
+ ...config.files,
948
+ includes: [...config.files?.includes ?? ["**"], `!${source}`]
949
+ };
950
+ await this.fs.write(own, `${JSON.stringify(config, null, "\t")}
951
+ `);
952
+ await this.format(root, mirror, ["biome.json"]);
953
+ }
954
+ overrides(overrides) {
955
+ const prefix = `${this.opts.project}/`;
956
+ const out = [];
957
+ for (const override of overrides) {
958
+ if (!isObject(override) || !Array.isArray(override.includes)) {
959
+ out.push(override);
960
+ continue;
961
+ }
962
+ const includes = [];
963
+ for (const include of override.includes) {
964
+ const negated = include.startsWith("!");
965
+ const path = negated ? include.slice(1) : include;
966
+ if (path.startsWith("*")) {
967
+ includes.push(include);
968
+ } else if (path.startsWith(prefix)) {
969
+ includes.push(`${negated ? "!" : ""}${path.slice(prefix.length)}`);
970
+ }
971
+ }
972
+ if (includes.some((include) => !include.startsWith("!"))) {
973
+ out.push({ ...override, includes });
974
+ }
975
+ }
976
+ return out;
977
+ }
978
+ async format(root, mirror, paths) {
979
+ const biome = `${root}/node_modules/.bin/biome`;
980
+ if (!await this.fs.exists(biome)) {
981
+ return;
982
+ }
983
+ const result = await this.ps.spawnCapture([biome, "format", "--write", ...paths], { cwd: mirror });
984
+ if (result.exitCode !== 0) {
985
+ throw new Error(`biome format failed in ${mirror}: ${result.stderr.trim()}`);
986
+ }
987
+ }
988
+ }
989
+ function merge(base, over) {
990
+ if (isObject(base) && isObject(over)) {
991
+ const out = { ...base };
992
+ for (const [key, value] of Object.entries(over)) {
993
+ out[key] = key in base ? merge(base[key], value) : value;
994
+ }
995
+ return out;
996
+ }
997
+ return over;
998
+ }
999
+ function isObject(value) {
1000
+ return typeof value === "object" && value !== null && !Array.isArray(value);
1001
+ }
1002
+ function tables(toml) {
1003
+ return [...toml.matchAll(/^\s*\[([^\]]+)\]\s*$/gm)].map((match) => match[1]);
1004
+ }
1005
+
1006
+ // ship/mirror/source-manifest.ts
1007
+ var FIELDS = [
1008
+ "dependencies",
1009
+ "peerDependencies",
1010
+ "devDependencies"
1011
+ ];
1012
+ async function sourceManifest(fs, core, { keys, files, catalog, version }) {
1013
+ const manifest = await manifestAt(fs, core.dir);
1014
+ const exported = entries(manifest.exports ?? {});
1015
+ const out = {
1016
+ name: core.name,
1017
+ version,
1018
+ private: true,
1019
+ type: "module",
1020
+ exports: Object.fromEntries([...keys].toSorted().map((key) => [key, exported.get(key)]))
1021
+ };
1022
+ if (typeof manifest.license === "string") {
1023
+ out.license = manifest.license;
1024
+ }
1025
+ const needed = new Set;
1026
+ for (const file of files) {
1027
+ for (const specifier of await specifiers(file, fs)) {
1028
+ const outside = outsider(specifier);
1029
+ if (outside !== undefined && outside !== core.name) {
1030
+ needed.add(outside);
1031
+ }
1032
+ }
1033
+ }
1034
+ for (const name of [...needed].toSorted()) {
1035
+ const field = FIELDS.find((one) => manifest[one]?.[name] !== undefined);
1036
+ if (field === undefined) {
1037
+ throw new Error(`${core.name} imports ${name}, which it does not declare`);
1038
+ }
1039
+ const range = manifest[field]?.[name];
1040
+ const resolved = range.startsWith("catalog:") ? catalog[name] : range;
1041
+ if (resolved === undefined || resolved.startsWith("workspace:")) {
1042
+ throw new Error(`${core.name} declares ${name} as ${range}, which no registry can resolve`);
1043
+ }
1044
+ out[field] = { ...out[field], [name]: resolved };
1045
+ const meta = manifest.peerDependenciesMeta?.[name];
1046
+ if (field === "peerDependencies" && meta !== undefined) {
1047
+ out.peerDependenciesMeta = {
1048
+ ...out.peerDependenciesMeta,
1049
+ [name]: meta
1050
+ };
1051
+ }
1052
+ const types = typesOf(name);
1053
+ const typed = manifest.devDependencies?.[types];
1054
+ if (typed !== undefined) {
1055
+ const resolvedTypes = typed.startsWith("catalog:") ? catalog[types] : typed;
1056
+ if (resolvedTypes === undefined) {
1057
+ throw new Error(`${types} is ${typed}, which the catalog lacks`);
1058
+ }
1059
+ out.devDependencies = {
1060
+ ...out.devDependencies,
1061
+ [types]: resolvedTypes
1062
+ };
1063
+ }
1064
+ }
1065
+ return out;
1066
+ }
1067
+ function typesOf(name) {
1068
+ return `@types/${name.startsWith("@") ? name.slice(1).replace("/", "__") : name}`;
1069
+ }
1070
+
1071
+ // ship/mirror/mirror-step.ts
1072
+ var NEVER2 = ["scry", "vet"];
1073
+ var SKIPPED = new Set([".git", "node_modules", "dist"]);
1074
+ var SOURCE_DIR = "packages";
1075
+
1076
+ class MirrorStep {
1077
+ opts;
1078
+ name;
1079
+ deadline = Duration.mins(5);
1080
+ stage = "tag";
1081
+ fs;
1082
+ ps;
1083
+ glob;
1084
+ tooling;
1085
+ constructor(opts) {
1086
+ this.opts = opts;
1087
+ this.name = `Mirror ${opts.project}`;
1088
+ this.fs = opts.fs ?? new NodeFs5;
1089
+ this.ps = opts.ps ?? new NodePs5;
1090
+ this.glob = opts.glob ?? new NodeGlob2;
1091
+ this.tooling = new MirrorTooling({
1092
+ project: opts.project,
1093
+ fs: this.fs,
1094
+ ps: this.ps
1095
+ });
1096
+ }
1097
+ async run(cut) {
1098
+ try {
1099
+ await this.push(cut, await this.prepare(cut));
1100
+ } finally {
1101
+ await this.fs.rm(this.scratch, { recursive: true, force: true });
1102
+ }
1103
+ }
1104
+ get scratch() {
1105
+ return this.opts.scratch ?? join(tmpdir(), `mirror-${this.opts.project}-${this.ps.pid}`);
1106
+ }
1107
+ async prepare(cut, opts = {}) {
1108
+ const { project, remote } = this.opts;
1109
+ const branch = this.opts.branch ?? "main";
1110
+ const mirror = `${this.scratch}/${project}`;
1111
+ await this.fs.rm(this.scratch, { recursive: true, force: true });
1112
+ await this.fs.mkdir(this.scratch);
1113
+ await this.git(this.scratch, "clone", remote, mirror);
1114
+ await this.checkout(mirror, branch);
1115
+ await guard(this.ps, mirror, project, this.opts.adopt);
1116
+ for (const entry of await this.fs.readdir(mirror)) {
1117
+ if (entry !== ".git") {
1118
+ await this.fs.rm(`${mirror}/${entry}`, { recursive: true });
1119
+ }
1120
+ }
1121
+ const root = await this.build(cut, mirror);
1122
+ await opts.before?.(mirror);
1123
+ await this.git(mirror, "add", "--all");
1124
+ const status = await this.git(mirror, "status", "--porcelain");
1125
+ if (status.trim() === "") {
1126
+ return { dir: mirror, from: `${root}/${project}`, changed: false };
1127
+ }
1128
+ const from = (await this.git(cut.root, "rev-parse", "HEAD")).trim();
1129
+ await this.git(mirror, "commit", "--message", `Mirror ${project} at ${cut.tag}`, "--message", `${TRAILER}: ${from}`);
1130
+ return { dir: mirror, from: `${root}/${project}`, changed: true };
1131
+ }
1132
+ async push(cut, prepared) {
1133
+ const { project, remote } = this.opts;
1134
+ if (prepared.changed) {
1135
+ await this.git(prepared.dir, "push", "origin", this.opts.branch ?? "main");
1136
+ } else {
1137
+ cut.log.info(`${project} mirror is already current`);
1138
+ }
1139
+ if (this.opts.tag && !await this.tagged(prepared.dir, cut.tag)) {
1140
+ await this.git(prepared.dir, "tag", cut.tag);
1141
+ await this.git(prepared.dir, "push", "origin", cut.tag);
1142
+ }
1143
+ if (prepared.changed) {
1144
+ cut.log.info(`${project} mirrored to ${remote} at ${cut.tag}`);
1145
+ }
1146
+ }
1147
+ async dryRun(cut) {
1148
+ await (await this.rehearsal(cut)).run(cut);
1149
+ cut.log.info(`${this.opts.project} ${color.yellow("would push to")} ${this.opts.remote}`);
1150
+ }
1151
+ async rehearsal(cut) {
1152
+ if (cut.dryRun === undefined) {
1153
+ throw new Error("a mirror's dry run needs the dry run's directory");
1154
+ }
1155
+ const { dir } = cut.dryRun;
1156
+ const remotes = `${dir}/remotes`;
1157
+ const local = `${remotes}/${this.opts.project.replaceAll("/", "-")}.git`;
1158
+ await this.fs.rm(local, { recursive: true, force: true });
1159
+ await this.fs.mkdir(remotes);
1160
+ await this.git(remotes, "clone", "--bare", "--quiet", this.opts.remote, local);
1161
+ return new MirrorStep({
1162
+ ...this.opts,
1163
+ remote: local,
1164
+ scratch: `${dir}/mirror-scratch`
1165
+ });
1166
+ }
1167
+ async build(cut, mirror) {
1168
+ const { project } = this.opts;
1169
+ const source = this.opts.source ?? "core";
1170
+ const workspace = this.opts.workspace ?? await ManifestWorkspace.at(cut.root, { fs: this.fs, ps: this.ps });
1171
+ const root = workspace.root;
1172
+ const excludes = this.opts.config?.exclude ?? [];
1173
+ const keeps = this.opts.config?.keep ?? [];
1174
+ const packages = await workspace.packages();
1175
+ const own = packages.filter((pkg) => pkg.dir === `${root}/${project}` || pkg.dir.startsWith(`${root}/${project}/`));
1176
+ const core = packages.find((pkg) => pkg.name === source);
1177
+ if (own.length === 0) {
1178
+ throw new Error(`${project} holds no workspace packages to mirror`);
1179
+ }
1180
+ if (core === undefined) {
1181
+ throw new Error(`the workspace has no ${source} package to mirror`);
1182
+ }
1183
+ const published = await this.checkDependencies(own, core.name, packages);
1184
+ const copied = await this.copy(`${root}/${project}`, mirror, (rel) => this.excluded(AGENT_FILES, rel) && !this.excluded(keeps, rel) || this.excluded(excludes, `${project}/${rel}`));
1185
+ await this.publish(mirror, `${root}/${project}`, own, published);
1186
+ await this.replace(mirror);
1187
+ await this.rewrite(mirror);
1188
+ const catalog = await catalogAt(this.fs, root);
1189
+ const used = await this.reached(copied, core);
1190
+ const coreOut = `${mirror}/${SOURCE_DIR}/${core.name}`;
1191
+ for (const file of used.files) {
1192
+ const rel = relative3(core.dir, file);
1193
+ if (this.excluded(excludes, relative3(root, file))) {
1194
+ throw new Error(`${project} reaches ${relative3(root, file)}, which the exclude globs leave out of the mirror`);
1195
+ }
1196
+ await this.copyFile(file, `${coreOut}/${rel}`);
1197
+ }
1198
+ for (const extra of ["tsconfig.json", "LICENSE"]) {
1199
+ if (await this.fs.exists(`${core.dir}/${extra}`)) {
1200
+ await this.copyFile(`${core.dir}/${extra}`, `${coreOut}/${extra}`);
1201
+ }
1202
+ }
1203
+ await this.write(`${coreOut}/package.json`, await sourceManifest(this.fs, core, {
1204
+ keys: used.keys,
1205
+ files: used.files,
1206
+ catalog,
1207
+ version: cut.version
1208
+ }));
1209
+ await this.tooling.tsconfigs(mirror, await this.files(mirror));
1210
+ await this.rootFiles(root, mirror, own, project, cut.version, catalog);
1211
+ return root;
1212
+ }
1213
+ async checkDependencies(own, source, all) {
1214
+ const names = new Set(own.map((pkg) => pkg.name));
1215
+ const published = new Map;
1216
+ for (const pkg of own) {
1217
+ const manifest = await manifestAt(this.fs, pkg.dir);
1218
+ for (const field of FIELDS) {
1219
+ for (const [name, range] of Object.entries(manifest[field] ?? {})) {
1220
+ if (NEVER2.includes(name)) {
1221
+ throw new Error(`${pkg.name} depends on ${name}, which is never copied out of the repository`);
1222
+ }
1223
+ if (range.startsWith("workspace:") && name !== source && !names.has(name)) {
1224
+ const other = all.find((one) => one.name === name);
1225
+ if (other === undefined || other.private) {
1226
+ throw new Error(`${pkg.name} depends on ${name}, which the mirror would not hold`);
1227
+ }
1228
+ published.set(name, other.dir);
1229
+ }
1230
+ }
1231
+ }
1232
+ }
1233
+ return published;
1234
+ }
1235
+ async replace(mirror) {
1236
+ for (const [to, from] of Object.entries(this.opts.config?.replace ?? {})) {
1237
+ if (!await this.fs.exists(`${mirror}/${from}`)) {
1238
+ throw new Error(`${this.opts.project} replaces ${to} with ${from}, which the mirror does not hold`);
1239
+ }
1240
+ await this.copyFile(`${mirror}/${from}`, `${mirror}/${to}`);
1241
+ await this.fs.rm(`${mirror}/${from}`);
1242
+ }
1243
+ }
1244
+ async rewrite(mirror) {
1245
+ for (const [file, rules] of Object.entries(this.opts.config?.rewrite ?? {})) {
1246
+ if (!await this.fs.exists(`${mirror}/${file}`)) {
1247
+ throw new Error(`${this.opts.project} rewrites ${file}, which the mirror does not hold`);
1248
+ }
1249
+ let text = await this.fs.read(`${mirror}/${file}`);
1250
+ for (const [pattern, to] of rules) {
1251
+ const next = text.replace(pattern, to);
1252
+ if (next === text) {
1253
+ throw new Error(`${this.opts.project} rewrites ${file} with ${pattern}, which matches nothing`);
1254
+ }
1255
+ text = next;
1256
+ }
1257
+ await this.fs.write(`${mirror}/${file}`, text);
1258
+ }
1259
+ }
1260
+ async publish(mirror, projectDir, own, published) {
1261
+ if (published.size === 0) {
1262
+ return;
1263
+ }
1264
+ const versions = new Map;
1265
+ for (const [name, dir] of published) {
1266
+ const manifest = await manifestAt(this.fs, dir);
1267
+ versions.set(name, manifest.version ?? "0.0.0");
1268
+ }
1269
+ for (const pkg of own) {
1270
+ const path = join(mirror, relative3(projectDir, pkg.dir), "package.json");
1271
+ const manifest = JSON.parse(await this.fs.read(path));
1272
+ for (const field of FIELDS) {
1273
+ const deps = manifest[field];
1274
+ for (const name of Object.keys(deps ?? {})) {
1275
+ const version = versions.get(name);
1276
+ if (version !== undefined && deps?.[name]?.startsWith("workspace:")) {
1277
+ deps[name] = `^${version}`;
1278
+ }
1279
+ }
1280
+ }
1281
+ await this.write(path, manifest);
1282
+ }
1283
+ }
1284
+ async reached(copied, core) {
1285
+ const manifest = await manifestAt(this.fs, core.dir);
1286
+ const exported = entries(manifest.exports ?? {});
1287
+ const wanted = new Set;
1288
+ for (const path of copied) {
1289
+ if (!/\.tsx?$/.test(path)) {
1290
+ continue;
1291
+ }
1292
+ for (const specifier of await specifiers(path, this.fs)) {
1293
+ if (isPackage(specifier, core.name)) {
1294
+ wanted.add(keyOf(core, exported, specifier));
1295
+ }
1296
+ }
1297
+ }
1298
+ return reach(this.fs, core, [...wanted]);
1299
+ }
1300
+ async rootFiles(root, mirror, own, project, version, catalog) {
1301
+ const rootManifest = await manifestAt(this.fs, root);
1302
+ const devDependencies = Object.fromEntries(Object.entries(rootManifest.devDependencies ?? {}).filter(([name]) => !NEVER2.includes(name)));
1303
+ const manifests = [{ devDependencies }];
1304
+ for (const pkg of own) {
1305
+ manifests.push(await manifestAt(this.fs, join(mirror, relative3(`${root}/${project}`, pkg.dir))));
1306
+ }
1307
+ const used = {};
1308
+ for (const manifest of manifests) {
1309
+ for (const field of FIELDS) {
1310
+ for (const [name, range] of Object.entries(manifest[field] ?? {})) {
1311
+ if (range.startsWith("catalog:")) {
1312
+ const resolved = catalog[name];
1313
+ if (resolved === undefined) {
1314
+ throw new Error(`${name} is ${range}, which the catalog lacks`);
1315
+ }
1316
+ used[name] = resolved;
1317
+ }
1318
+ }
1319
+ }
1320
+ }
1321
+ const dirs = own.map((pkg) => relative3(`${root}/${project}`, pkg.dir));
1322
+ const workspaces = {
1323
+ packages: [
1324
+ ...dirs.filter((one) => one !== "").toSorted(),
1325
+ `${SOURCE_DIR}/${this.opts.source ?? "core"}`
1326
+ ],
1327
+ catalog: used
1328
+ };
1329
+ const scripts = this.opts.config?.scripts;
1330
+ const top = dirs.includes("") ? JSON.parse(await this.fs.read(`${mirror}/package.json`)) : undefined;
1331
+ await this.write(`${mirror}/package.json`, top === undefined ? {
1332
+ name: project,
1333
+ version,
1334
+ private: true,
1335
+ type: "module",
1336
+ workspaces,
1337
+ devDependencies,
1338
+ ...scripts === undefined ? {} : { scripts }
1339
+ } : {
1340
+ ...top,
1341
+ workspaces,
1342
+ devDependencies: { ...devDependencies, ...top.devDependencies },
1343
+ ...scripts === undefined ? {} : { scripts: { ...top.scripts, ...scripts } }
1344
+ });
1345
+ await this.copyFile(`${root}/tsconfig.base.json`, `${mirror}/tsconfig.base.json`);
1346
+ await this.tooling.bunfig(root, mirror);
1347
+ await this.tooling.lint(root, mirror, `${SOURCE_DIR}/${this.opts.source ?? "core"}`);
1348
+ await this.tooling.gitignore(root, mirror);
1349
+ }
1350
+ async files(dir) {
1351
+ const found = [];
1352
+ for (const entry of await this.fs.readdir(dir)) {
1353
+ if (SKIPPED.has(entry)) {
1354
+ continue;
1355
+ }
1356
+ const path = `${dir}/${entry}`;
1357
+ if ((await this.fs.stat(path)).isDirectory()) {
1358
+ found.push(...await this.files(path));
1359
+ } else {
1360
+ found.push(path);
1361
+ }
1362
+ }
1363
+ return found.toSorted();
1364
+ }
1365
+ async copy(from, to, skip) {
1366
+ const copied = [];
1367
+ for (const path of await this.files(from)) {
1368
+ const rel = relative3(from, path);
1369
+ if (skip(rel)) {
1370
+ continue;
1371
+ }
1372
+ await this.copyFile(path, `${to}/${rel}`);
1373
+ copied.push(`${to}/${rel}`);
1374
+ }
1375
+ return copied;
1376
+ }
1377
+ async copyFile(from, to) {
1378
+ await this.fs.mkdir(dirname6(to));
1379
+ await this.fs.writeBytes(to, await this.fs.readBytes(from));
1380
+ const { mode } = await this.fs.stat(from);
1381
+ if ((mode & 73) !== 0) {
1382
+ await this.fs.chmod(to, mode & 511);
1383
+ }
1384
+ }
1385
+ async write(path, value) {
1386
+ await this.fs.mkdir(dirname6(path));
1387
+ await this.fs.write(path, `${JSON.stringify(value, null, "\t")}
1388
+ `);
1389
+ }
1390
+ excluded(globs, rel) {
1391
+ return globs.some((glob) => this.glob.matches(glob, rel));
1392
+ }
1393
+ async tagged(mirror, tag) {
1394
+ const found = await this.git(mirror, "ls-remote", "--tags", "origin", `refs/tags/${tag}`);
1395
+ return found.trim() !== "";
1396
+ }
1397
+ async checkout(mirror, branch) {
1398
+ const has = await this.ps.spawnCapture(["git", "rev-parse", "--verify", "--quiet", `origin/${branch}`], { cwd: mirror });
1399
+ if (has.exitCode === 0) {
1400
+ await this.git(mirror, "checkout", "-B", branch, `origin/${branch}`);
1401
+ } else {
1402
+ await this.git(mirror, "checkout", "-B", branch);
1403
+ }
1404
+ }
1405
+ async git(cwd, ...args) {
1406
+ const result = await this.ps.spawnCapture(["git", ...args], { cwd });
1407
+ if (result.exitCode !== 0) {
1408
+ throw new Error(`git ${args.join(" ")} failed in ${cwd}: ${result.stderr.trim()}`);
1409
+ }
1410
+ return result.stdout;
1411
+ }
1412
+ }
1413
+
1414
+ // ship/mirror/mirror-build.ts
1415
+ class MirrorBuild {
1416
+ opts;
1417
+ packages = [];
1418
+ stage = "build";
1419
+ name;
1420
+ fs;
1421
+ ps;
1422
+ mirror;
1423
+ bundle;
1424
+ built;
1425
+ constructor(opts) {
1426
+ this.opts = opts;
1427
+ this.name = `Build ${opts.project} in its mirror`;
1428
+ this.fs = opts.fs ?? new NodeFs6;
1429
+ this.ps = opts.ps ?? new NodePs6;
1430
+ this.mirror = new MirrorStep(opts);
1431
+ this.bundle = opts.bundle ?? new VendorBundle({ fs: this.fs, ps: this.ps });
1432
+ }
1433
+ steps() {
1434
+ const build = (cut) => this.build(cut);
1435
+ const push = (cut) => this.push(cut);
1436
+ return [
1437
+ {
1438
+ name: this.name,
1439
+ deadline: Duration2.mins(15),
1440
+ stage: "build",
1441
+ run: build,
1442
+ dryRun: build
1443
+ },
1444
+ {
1445
+ name: `Mirror ${this.opts.project}`,
1446
+ deadline: Duration2.mins(5),
1447
+ stage: "tag",
1448
+ run: push,
1449
+ dryRun: async (cut) => {
1450
+ await push(cut);
1451
+ cut.log.info(`${this.opts.project} ${color2.yellow("would push to")} ${this.opts.remote}`);
1452
+ }
1453
+ }
1454
+ ];
1455
+ }
1456
+ async publish(cut) {
1457
+ await this.build(cut);
1458
+ await this.push(cut);
1459
+ }
1460
+ async clean() {
1461
+ if (this.built !== undefined) {
1462
+ await this.fs.rm(this.built.step.scratch, {
1463
+ recursive: true,
1464
+ force: true
1465
+ });
1466
+ this.built = undefined;
1467
+ }
1468
+ }
1469
+ async build(cut) {
1470
+ await this.clean();
1471
+ const step = cut.dryRun === undefined ? this.mirror : await this.mirror.rehearsal(cut);
1472
+ const prepared = await step.prepare(cut, {
1473
+ before: async (mirror) => {
1474
+ if (this.opts.publish !== undefined) {
1475
+ await new PublishWorkflow({
1476
+ command: this.opts.publish,
1477
+ fs: this.fs
1478
+ }).write(mirror);
1479
+ }
1480
+ await this.spawn(["bun", "install"], mirror);
1481
+ }
1482
+ });
1483
+ this.built = { step, prepared };
1484
+ this.opts.via?.use(new CliGit(prepared.dir, { ps: this.ps }));
1485
+ const going = cut.packages.filter((pkg) => !pkg.private && (pkg.dir === prepared.from || pkg.dir.startsWith(`${prepared.from}/`)));
1486
+ for (const pkg of going) {
1487
+ const dir = join2(prepared.dir, relative4(prepared.from, pkg.dir));
1488
+ cut.stage(pkg.name, await this.bundle.build(dir));
1489
+ }
1490
+ cut.log.info(`${going.length} packages ${color2.green("built")} in the ${this.opts.project} mirror`);
1491
+ }
1492
+ async push(cut) {
1493
+ if (this.built === undefined) {
1494
+ throw new Error(`the ${this.opts.project} mirror was never built, so there is nothing to push`);
1495
+ }
1496
+ await this.built.step.push(cut, this.built.prepared);
1497
+ }
1498
+ async spawn(argv, cwd) {
1499
+ const { exitCode, stdout, stderr } = await this.ps.spawnCapture(argv, {
1500
+ cwd
1501
+ });
1502
+ if (exitCode !== 0) {
1503
+ const said = `${stdout}
1504
+ ${stderr}`.trim().split(`
1505
+ `).slice(-20);
1506
+ throw new Error(`${argv.join(" ")} failed in the ${this.opts.project} mirror:
1507
+ ${said.join(`
1508
+ `)}`);
1509
+ }
1510
+ }
1511
+ }
1512
+ // ship/order.ts
1513
+ function order(packages) {
1514
+ let remaining = [...packages].sort((left, right) => left.name.localeCompare(right.name));
1515
+ const siblings = new Set(remaining.map((pkg) => pkg.name));
1516
+ const published = new Set;
1517
+ const ordered = [];
1518
+ while (remaining.length > 0) {
1519
+ const ready = remaining.filter((pkg) => pkg.dependencies.every((dep) => !siblings.has(dep) || published.has(dep)));
1520
+ if (ready.length === 0) {
1521
+ throw new Error(`dependency cycle: ${remaining.map((pkg) => pkg.name).join(", ")} each wait on another, so no order releases them`);
1522
+ }
1523
+ for (const pkg of ready) {
1524
+ ordered.push(pkg);
1525
+ published.add(pkg.name);
1526
+ }
1527
+ remaining = remaining.filter((pkg) => !published.has(pkg.name));
1528
+ }
1529
+ return ordered;
1530
+ }
1531
+ // ship/registry/github-actions.ts
1532
+ import { basename } from "node:path";
1533
+ import { NodePs as NodePs8 } from "../system/index.js";
1534
+ import { Duration as Duration3, sleep } from "../time/index.js";
1535
+
1536
+ // ship/github/cli-workflows.ts
1537
+ import { NodePs as NodePs7 } from "../system/index.js";
1538
+
1539
+ // ship/github/login.ts
1540
+ async function ghLogin(ps) {
1541
+ if ((await ps.spawnCapture(["gh", "auth", "status"])).exitCode === 0) {
1542
+ return;
1543
+ }
1544
+ if (ps.env("CI") !== undefined) {
1545
+ throw new Error("not logged in to GitHub: set GH_TOKEN");
1546
+ }
1547
+ const { exitCode } = await ps.spawn(["gh", "auth", "login"]);
1548
+ if (exitCode !== 0) {
1549
+ throw new Error("gh auth login failed");
1550
+ }
1551
+ }
1552
+
1553
+ // ship/github/cli-workflows.ts
1554
+ class CliWorkflows {
1555
+ ps;
1556
+ named;
1557
+ constructor(opts = {}) {
1558
+ this.ps = opts.ps ?? new NodePs7;
1559
+ this.named = opts.repo;
1560
+ }
1561
+ repo() {
1562
+ if (this.named !== undefined) {
1563
+ return Promise.resolve(this.named);
1564
+ }
1565
+ return this.gh(["repo", "view", "--json", "nameWithOwner", "--jq", ".nameWithOwner"], false);
1566
+ }
1567
+ async registered(file) {
1568
+ await ghLogin(this.ps);
1569
+ const { exitCode, stdout } = await this.ps.spawnCapture([
1570
+ "gh",
1571
+ "api",
1572
+ `repos/${await this.repo()}/actions/workflows/${file}`,
1573
+ "--jq",
1574
+ ".state"
1575
+ ]);
1576
+ return exitCode === 0 && stdout.trim() === "active";
1577
+ }
1578
+ async dispatch(file, branch, inputs) {
1579
+ await this.gh([
1580
+ "workflow",
1581
+ "run",
1582
+ file,
1583
+ "--ref",
1584
+ branch,
1585
+ ...Object.entries(inputs).flatMap(([key, value]) => [
1586
+ "--field",
1587
+ `${key}=${value}`
1588
+ ])
1589
+ ]);
1590
+ }
1591
+ async runs(file, sha) {
1592
+ const out = await this.gh([
1593
+ "run",
1594
+ "list",
1595
+ "--workflow",
1596
+ file,
1597
+ "--commit",
1598
+ sha,
1599
+ "--json",
1600
+ "databaseId,url,status,conclusion,attempt",
1601
+ "--limit",
1602
+ "10"
1603
+ ]);
1604
+ const found = JSON.parse(out || "[]");
1605
+ return found.map((run) => ({
1606
+ id: String(run.databaseId),
1607
+ url: run.url,
1608
+ status: run.status,
1609
+ ...run.conclusion === "" ? {} : { conclusion: run.conclusion },
1610
+ attempt: run.attempt
1611
+ }));
1612
+ }
1613
+ async rerun(id, failedOnly) {
1614
+ await this.gh(["run", "rerun", id, ...failedOnly ? ["--failed"] : []]);
1615
+ }
1616
+ async failedLog(id) {
1617
+ return this.gh(["run", "view", id, "--log-failed"], false);
1618
+ }
1619
+ async gh(args, login = true) {
1620
+ if (login) {
1621
+ await ghLogin(this.ps);
1622
+ }
1623
+ const { exitCode, stdout, stderr } = await this.ps.spawnCapture([
1624
+ "gh",
1625
+ ...args,
1626
+ ...this.named === undefined ? [] : ["--repo", this.named]
1627
+ ]);
1628
+ if (exitCode !== 0) {
1629
+ throw new Error(`gh ${args.slice(0, 2).join(" ")}: ${stderr.trim() || stdout.trim()}`);
1630
+ }
1631
+ return stdout.trim();
1632
+ }
1633
+ }
1634
+
1635
+ // ship/registry/github-actions.ts
1636
+ var LOG_LINES = 20;
1637
+ var REGISTER_WITHIN = Duration3.mins(2);
1638
+ var REGISTER_EVERY = Duration3.secs(5);
1639
+ function githubActions(opts = {}) {
1640
+ return new GithubActions(opts);
1641
+ }
1642
+
1643
+ class GithubActions {
1644
+ file = basename(PUBLISH_WORKFLOW_PATH);
1645
+ git;
1646
+ workflows;
1647
+ rerunFrom;
1648
+ trustCommand;
1649
+ pause;
1650
+ constructor(opts = {}) {
1651
+ const ps = opts.ps ?? new NodePs8;
1652
+ this.git = opts.git ?? new CliGit(ps.cwd(), { ps });
1653
+ this.workflows = opts.workflows ?? new CliWorkflows({ ps, repo: opts.repo });
1654
+ this.trustCommand = opts.trustCommand ?? "bunx @webappwiz/cli ship trust";
1655
+ this.pause = opts.pause ?? sleep;
1656
+ }
1657
+ use(git) {
1658
+ this.git = git;
1659
+ }
1660
+ repo() {
1661
+ return this.workflows.repo();
1662
+ }
1663
+ async start() {
1664
+ const branch = await this.git.branch();
1665
+ await this.git.push(branch);
1666
+ await this.untilRegistered();
1667
+ const sha = await this.git.head();
1668
+ const [latest] = await this.workflows.runs(this.file, sha);
1669
+ if (latest === undefined) {
1670
+ await this.workflows.dispatch(this.file, branch, { ref: sha });
1671
+ return;
1672
+ }
1673
+ if (latest.status === "completed" && latest.conclusion !== "success") {
1674
+ this.rerunFrom = { id: latest.id, attempt: latest.attempt };
1675
+ await this.workflows.rerun(latest.id, latest.conclusion === "failure");
1676
+ }
1677
+ }
1678
+ async untilRegistered() {
1679
+ let waited = Duration3.zero();
1680
+ while (!await this.workflows.registered(this.file)) {
1681
+ if (waited.ms >= REGISTER_WITHIN.ms) {
1682
+ throw new Error(`GitHub has not registered ${this.file} ${REGISTER_WITHIN.ms / 1000}s after the push: check that it is on the repository's default branch, then ship again`);
1683
+ }
1684
+ await this.pause(REGISTER_EVERY);
1685
+ waited = waited.add(REGISTER_EVERY);
1686
+ }
1687
+ }
1688
+ async watch(name, live) {
1689
+ const [run] = await this.workflows.runs(this.file, await this.git.head());
1690
+ if (run === undefined) {
1691
+ return live ? { passed: true } : { passed: false, status: "waiting" };
1692
+ }
1693
+ const { url } = run;
1694
+ if (run.status !== "completed") {
1695
+ return { passed: false, status: run.status, url };
1696
+ }
1697
+ if (this.rerunFrom?.id === run.id && run.attempt <= this.rerunFrom.attempt) {
1698
+ return { passed: false, status: "queued", url };
1699
+ }
1700
+ if (run.conclusion === "success") {
1701
+ return { passed: true, url };
1702
+ }
1703
+ throw new Error(await this.failure(name, run.id, url, run.conclusion));
1704
+ }
1705
+ async failure(name, id, url, conclusion) {
1706
+ const log = await this.workflows.failedLog(id);
1707
+ const tail = log.split(`
1708
+ `).slice(-LOG_LINES).join(`
1709
+ `);
1710
+ const refused = /OIDC token exchange/i.test(log) ? `
1711
+ ${await this.setup(name)}` : "";
1712
+ return `the publish run ${conclusion ?? "ended"}: ${url}
1713
+ ${tail}${refused}`;
1714
+ }
1715
+ async setup(name) {
1716
+ const repo = await this.workflows.repo();
1717
+ return [
1718
+ `npm refused the run: ${name} has no trusted publisher entry for it. Run \`${this.trustCommand}\` to set one up for every package, or for this one alone:`,
1719
+ ` npm trust github ${name} --repo ${repo} --file ${this.file} --allow-publish`,
1720
+ "The package must already exist. A new entry lapses after about two days unless a publish uses it. Then ship again to rerun the failed run."
1721
+ ].join(`
1722
+ `);
1723
+ }
1724
+ }
1725
+ // ship/release.ts
1726
+ import { mkdtemp } from "node:fs/promises";
1727
+ import { tmpdir as tmpdir2 } from "node:os";
1728
+ import { join as join3 } from "node:path";
1729
+ import { ConsoleLogger as ConsoleLogger3, color as color5 } from "../log/index.js";
1730
+ import { NodeFs as NodeFs8, NodePs as NodePs9 } from "../system/index.js";
1731
+ import { Duration as Duration7 } from "../time/index.js";
1732
+
1733
+ // ship/artifact/artifact.ts
1734
+ var STAGES = [
1735
+ "stamp",
1736
+ "build",
1737
+ "publish",
1738
+ "approve",
1739
+ "tag",
1740
+ "notes"
1741
+ ];
1742
+
1743
+ // ship/dry-run.ts
1744
+ import { rm } from "node:fs/promises";
1745
+ import { color as color3 } from "../log/index.js";
1746
+ import { Duration as Duration4 } from "../time/index.js";
1747
+ var SCRIPT = /\.[cm]?js$/;
1748
+ var TESTING = /(^|\/)testing$/;
1749
+ async function rehearse(opts) {
1750
+ const { preflight, before, versionStep, going, cut, runner, git } = opts;
1751
+ const install = {
1752
+ id: "dry-run:install",
1753
+ step: installStep({ packages: opts.packages, fs: opts.fs, ps: opts.ps })
1754
+ };
1755
+ const after = going.findIndex(({ step }) => STAGES.indexOf(step.stage === "preflight" ? "publish" : step.stage ?? "publish") > STAGES.indexOf("publish"));
1756
+ const declared = [preflight, ...before, versionStep];
1757
+ const steps = [
1758
+ ...declared,
1759
+ ...after === -1 ? going : going.slice(0, after),
1760
+ install,
1761
+ ...after === -1 ? [] : going.slice(after)
1762
+ ];
1763
+ await runner.declare(steps);
1764
+ let stamped = false;
1765
+ try {
1766
+ for (const declaration of steps) {
1767
+ stamped ||= declaration === versionStep;
1768
+ await runner.run(rehearsed(declaration), cut);
1769
+ }
1770
+ } finally {
1771
+ for (const artifact of opts.artifacts) {
1772
+ await artifact.clean?.(cut);
1773
+ }
1774
+ if (stamped) {
1775
+ await git.discard();
1776
+ }
1777
+ if (opts.owned && cut.dryRun !== undefined) {
1778
+ await rm(cut.dryRun.dir, { recursive: true, force: true });
1779
+ }
1780
+ }
1781
+ cut.log.info(color3.green(`rehearsed ${cut.version}: nothing went out`));
1782
+ }
1783
+ function installStep(opts) {
1784
+ return {
1785
+ name: "Install the packs",
1786
+ deadline: Duration4.mins(5),
1787
+ stage: "approve",
1788
+ run: (cut) => install(cut, opts),
1789
+ dryRun: (cut) => install(cut, opts)
1790
+ };
1791
+ }
1792
+ async function install(cut, opts) {
1793
+ const { fs, ps } = opts;
1794
+ if (cut.dryRun === undefined || opts.packages.length === 0) {
1795
+ return;
1796
+ }
1797
+ const packs = `${cut.dryRun.dir}/packs`;
1798
+ const tarballs = (await fs.readdir(packs)).filter((file) => file.endsWith(".tgz")).map((file) => `${packs}/${file}`);
1799
+ if (tarballs.length === 0) {
1800
+ return;
1801
+ }
1802
+ const consumer = `${cut.dryRun.dir}/consumer`;
1803
+ await fs.rm(consumer, { recursive: true, force: true });
1804
+ await fs.mkdir(consumer);
1805
+ await fs.write(`${consumer}/package.json`, `${JSON.stringify({ name: "dry-run", private: true, type: "module" })}
1806
+ `);
1807
+ await spawn(ps, [
1808
+ "npm",
1809
+ "install",
1810
+ "--no-audit",
1811
+ "--no-fund",
1812
+ "--no-package-lock",
1813
+ ...tarballs
1814
+ ], consumer);
1815
+ const specifiers = [];
1816
+ let runtime = "node";
1817
+ for (const name of opts.packages) {
1818
+ const dir = `${consumer}/node_modules/${name}`;
1819
+ const manifest = JSON.parse(await fs.read(`${dir}/package.json`));
1820
+ specifiers.push(...importable(name, manifest));
1821
+ if (runsOnBun(manifest)) {
1822
+ runtime = "bun";
1823
+ }
1824
+ for (const bin of Object.values(bins(manifest))) {
1825
+ if (!await fs.exists(`${dir}/${bin}`)) {
1826
+ throw new Error(`${name} names bin ${bin}, which it does not hold`);
1827
+ }
1828
+ }
1829
+ }
1830
+ await fs.write(`${consumer}/imports.mjs`, specifiers.map((specifier) => `await import(${JSON.stringify(specifier)});`).join(`
1831
+ `));
1832
+ await spawn(ps, [runtime, "imports.mjs"], consumer);
1833
+ cut.log.info(`${opts.packages.join(" ")} ${color3.green("installed")} from the packs, ${specifiers.length} imports resolving`);
1834
+ }
1835
+ function importable(name, manifest) {
1836
+ if (manifest.exports === undefined) {
1837
+ return manifest.main !== undefined && SCRIPT.test(manifest.main) ? [name] : [];
1838
+ }
1839
+ if (typeof manifest.exports === "string") {
1840
+ return SCRIPT.test(manifest.exports) ? [name] : [];
1841
+ }
1842
+ return Object.entries(manifest.exports).filter(([key, target]) => key.startsWith(".") && !TESTING.test(key) && script(target)).map(([key]) => key === "." ? name : `${name}/${key.slice(2)}`);
1843
+ }
1844
+ function script(target) {
1845
+ if (typeof target === "string") {
1846
+ return SCRIPT.test(target);
1847
+ }
1848
+ const chosen = target.import ?? target.default;
1849
+ return chosen !== undefined && script(chosen);
1850
+ }
1851
+ function runsOnBun(manifest) {
1852
+ const engines = manifest.engines;
1853
+ return typeof engines === "object" && engines !== null && "bun" in engines;
1854
+ }
1855
+ function bins(manifest) {
1856
+ const { bin, name } = manifest;
1857
+ if (bin === undefined) {
1858
+ return {};
1859
+ }
1860
+ return typeof bin === "string" ? { [name ?? "bin"]: bin } : bin;
1861
+ }
1862
+ async function spawn(ps, argv, cwd) {
1863
+ const { exitCode, stdout, stderr } = await ps.spawnCapture(argv, { cwd });
1864
+ if (exitCode !== 0) {
1865
+ const said = `${stdout}
1866
+ ${stderr}`.trim().split(`
1867
+ `).slice(-20).join(`
1868
+ `);
1869
+ throw new Error(`${argv.slice(0, 2).join(" ")} failed in ${cwd}:
1870
+ ${said}`);
1871
+ }
1872
+ }
1873
+ var LOCAL2 = ["preflight", "stamp", "build"];
1874
+ function rehearsed(declaration) {
1875
+ const { step } = declaration;
1876
+ const name = step.name;
1877
+ if (step.dryRun !== undefined) {
1878
+ const dryRun = step.dryRun.bind(step);
1879
+ return {
1880
+ ...declaration,
1881
+ step: { name, deadline: step.deadline, stage: step.stage, run: dryRun }
1882
+ };
1883
+ }
1884
+ if (LOCAL2.includes(step.stage ?? "publish")) {
1885
+ return declaration;
1886
+ }
1887
+ return {
1888
+ ...declaration,
1889
+ step: {
1890
+ name,
1891
+ deadline: step.deadline,
1892
+ stage: step.stage,
1893
+ run: async (cut) => {
1894
+ cut.log.info(color3.yellow(`would run ${name}, which has no dry run`));
1895
+ }
1896
+ }
1897
+ };
1898
+ }
1899
+
1900
+ // ship/release-file.ts
1901
+ import { NodeFs as NodeFs7 } from "../system/index.js";
1902
+
1903
+ class ReleaseFile {
1904
+ path;
1905
+ fs;
1906
+ constructor(root, opts = {}) {
1907
+ this.path = `${root}/RELEASE`;
1908
+ this.fs = opts.fs ?? new NodeFs7;
1909
+ }
1910
+ async read() {
1911
+ if (!await this.fs.exists(this.path)) {
1912
+ return null;
1913
+ }
1914
+ const state = parse(await this.fs.read(this.path));
1915
+ if (state === null) {
1916
+ throw new Error(`${this.path} does not hold release state: finish the release it was tracking or delete it`);
1917
+ }
1918
+ return state;
1919
+ }
1920
+ async write(state) {
1921
+ await this.fs.write(this.path, `${JSON.stringify(state, null, "\t")}
1922
+ `);
1923
+ }
1924
+ async clear() {
1925
+ await this.fs.rm(this.path, { force: true });
1926
+ }
1927
+ }
1928
+ function parse(contents) {
1929
+ try {
1930
+ const state = JSON.parse(contents);
1931
+ if (typeof state.version !== "string" || !Array.isArray(state.done) || !state.done.every((key) => typeof key === "string")) {
1932
+ return null;
1933
+ }
1934
+ return { version: state.version, done: state.done };
1935
+ } catch {
1936
+ return null;
1937
+ }
1938
+ }
1939
+
1940
+ // ship/step-events.ts
1941
+ import { SystemWallClock } from "../time/index.js";
1942
+ var EVENTS_SCHEMA = 1;
1943
+
1944
+ class StepEvents {
1945
+ path;
1946
+ fs;
1947
+ clock;
1948
+ progress;
1949
+ constructor(path, fs, clock = new SystemWallClock, progress) {
1950
+ this.path = path;
1951
+ this.fs = fs;
1952
+ this.clock = clock;
1953
+ this.progress = progress;
1954
+ }
1955
+ async declared({
1956
+ id,
1957
+ step,
1958
+ packages,
1959
+ artifact
1960
+ }) {
1961
+ await this.write({
1962
+ type: "declared",
1963
+ id,
1964
+ name: step.name,
1965
+ stage: step.stage ?? "publish",
1966
+ packages: [...packages ?? []],
1967
+ ...artifact === undefined ? {} : { artifact },
1968
+ deadlineMs: step.deadline.ms,
1969
+ at: this.at()
1970
+ });
1971
+ }
1972
+ async started({ id, step }) {
1973
+ this.report(id, "start");
1974
+ await this.write({ type: "started", id, name: step.name, at: this.at() });
1975
+ }
1976
+ async staged({ id, step }, info) {
1977
+ await this.write({
1978
+ type: "staged",
1979
+ id,
1980
+ name: step.name,
1981
+ ...info,
1982
+ at: this.at()
1983
+ });
1984
+ }
1985
+ async check(declaration, { passed, status, url }) {
1986
+ await this.write({
1987
+ type: "check",
1988
+ id: declaration.id,
1989
+ name: declaration.step.name,
1990
+ passed,
1991
+ ...status === undefined ? {} : { status },
1992
+ ...url === undefined ? {} : { url },
1993
+ at: this.at()
1994
+ });
1995
+ }
1996
+ async done({ id, step }) {
1997
+ this.report(id, "done");
1998
+ await this.write({ type: "done", id, name: step.name, at: this.at() });
1999
+ }
2000
+ async skipped({ id, step }) {
2001
+ this.report(id, "skipped");
2002
+ await this.write({ type: "skipped", id, name: step.name, at: this.at() });
2003
+ }
2004
+ async failed({ id, step }, error) {
2005
+ this.report(id, "failed");
2006
+ await this.write({
2007
+ type: "failed",
2008
+ id,
2009
+ name: step.name,
2010
+ error: error instanceof Error ? error.message : String(error),
2011
+ at: this.at()
2012
+ });
2013
+ }
2014
+ report(id, state) {
2015
+ this.progress?.line(JSON.stringify({ event: "step", id, state, at: this.at() }));
2016
+ }
2017
+ async write(event) {
2018
+ if (this.path !== undefined && this.path !== "") {
2019
+ await this.fs.append(this.path, `${JSON.stringify({ schema: EVENTS_SCHEMA, ...event })}
2020
+ `);
2021
+ }
2022
+ }
2023
+ at() {
2024
+ return new Date(this.clock.now()).toISOString();
2025
+ }
2026
+ }
2027
+
2028
+ // ship/step-runner.ts
2029
+ import { Duration as Duration5, SystemTimer } from "../time/index.js";
2030
+ var CHECK_INTERVAL = Duration5.secs(10);
2031
+ var CHECK_BACKOFF_MAX = Duration5.mins(2);
2032
+
2033
+ class StepRunner {
2034
+ events;
2035
+ timer;
2036
+ constructor(events, timer = new SystemTimer) {
2037
+ this.events = events;
2038
+ this.timer = timer;
2039
+ }
2040
+ async declare(steps) {
2041
+ for (const step of steps) {
2042
+ await this.events.declared(step);
2043
+ }
2044
+ }
2045
+ async run(declaration, cut, opts = {}) {
2046
+ if (opts.done === true) {
2047
+ await this.events.skipped(declaration);
2048
+ return;
2049
+ }
2050
+ await this.events.started(declaration);
2051
+ try {
2052
+ await declaration.step.run(cut, {
2053
+ staged: (info) => this.events.staged(declaration, info)
2054
+ });
2055
+ let waited = Duration5.zero();
2056
+ let interval = CHECK_INTERVAL;
2057
+ while (declaration.step.check !== undefined) {
2058
+ const found = await declaration.step.check(cut, waited);
2059
+ const report = typeof found === "boolean" ? { passed: found } : found;
2060
+ await this.events.check(declaration, report);
2061
+ if (report.passed) {
2062
+ break;
2063
+ }
2064
+ const every = declaration.step.checkEvery ?? interval;
2065
+ await this.wait(every);
2066
+ waited = waited.add(every);
2067
+ interval = Duration5.min(interval.multiply(2), CHECK_BACKOFF_MAX);
2068
+ }
2069
+ await this.events.done(declaration);
2070
+ } catch (error) {
2071
+ await this.events.failed(declaration, error);
2072
+ throw error;
2073
+ }
2074
+ }
2075
+ async wait(interval) {
2076
+ await new Promise((resolve) => {
2077
+ const waiting = this.timer.setTimeout(() => {
2078
+ waiting.dispose();
2079
+ resolve();
2080
+ }, interval);
2081
+ });
2082
+ }
2083
+ }
2084
+
2085
+ // ship/trust.ts
2086
+ import { ConsoleLogger as ConsoleLogger2, color as color4 } from "../log/index.js";
2087
+ import { Duration as Duration6, sleep as sleep2 } from "../time/index.js";
2088
+ async function trust(artifacts, opts = {}) {
2089
+ const log = opts.log ?? new ConsoleLogger2;
2090
+ const pause = opts.pause ?? Duration6.secs(2);
2091
+ const trusting = artifacts.flatMap((artifact) => {
2092
+ const trust = artifact.trust?.bind(artifact);
2093
+ return trust === undefined ? [] : [{ artifact, trust }];
2094
+ });
2095
+ if (trusting.length === 0) {
2096
+ throw new Error("nothing in this release publishes from CI: give its registry `via: githubActions()`");
2097
+ }
2098
+ const failed = [];
2099
+ for (const [index, { artifact, trust }] of trusting.entries()) {
2100
+ if (index > 0) {
2101
+ await sleep2(pause);
2102
+ }
2103
+ const name = artifact.name ?? statusName(artifact);
2104
+ try {
2105
+ await trust(log);
2106
+ log.info(`${name} ${color4.green("trusts the publish workflow")}`);
2107
+ } catch (error) {
2108
+ failed.push(error.message);
2109
+ }
2110
+ }
2111
+ if (failed.length > 0) {
2112
+ throw new Error(failed.join(`
2113
+ `));
2114
+ }
2115
+ }
2116
+
2117
+ // ship/version.ts
2118
+ var SEMVER = /^(\d+)\.(\d+)\.(\d+)$/;
2119
+ function newest(versions) {
2120
+ let best;
2121
+ for (const version of versions) {
2122
+ const match = SEMVER.exec(version);
2123
+ if (match === null) {
2124
+ continue;
2125
+ }
2126
+ const parts = match.slice(1).map(Number);
2127
+ if (best === undefined || compare(parts, best.parts) > 0) {
2128
+ best = { version, parts };
2129
+ }
2130
+ }
2131
+ return best?.version;
2132
+ }
2133
+ function compare(left, right) {
2134
+ for (const [index, part] of left.entries()) {
2135
+ const diff = part - (right[index] ?? 0);
2136
+ if (diff !== 0) {
2137
+ return diff;
2138
+ }
2139
+ }
2140
+ return 0;
2141
+ }
2142
+ function bump(version, type) {
2143
+ const parts = SEMVER.exec(version);
2144
+ if (parts === null) {
2145
+ throw new Error(`invalid version: "${version}" (expected major.minor.patch)`);
2146
+ }
2147
+ const [major, minor, patch] = [
2148
+ Number(parts[1]),
2149
+ Number(parts[2]),
2150
+ Number(parts[3])
2151
+ ];
2152
+ switch (type) {
2153
+ case "major":
2154
+ return `${major + 1}.0.0`;
2155
+ case "minor":
2156
+ return `${major}.${minor + 1}.0`;
2157
+ case "patch":
2158
+ return `${major}.${minor}.${patch + 1}`;
2159
+ }
2160
+ }
2161
+
2162
+ // ship/release.ts
2163
+ class Release {
2164
+ artifacts;
2165
+ steps;
2166
+ constructor(artifacts, steps = []) {
2167
+ this.artifacts = artifacts.toSorted((left, right) => STAGES.indexOf(left.stage ?? "publish") - STAGES.indexOf(right.stage ?? "publish"));
2168
+ this.steps = steps;
2169
+ }
2170
+ get packages() {
2171
+ return this.artifacts.flatMap((artifact) => [...artifact.packages]);
2172
+ }
2173
+ async status(opts = {}) {
2174
+ const ps = opts.ps ?? new NodePs9;
2175
+ const workspace = opts.workspace ?? await ManifestWorkspace.at(ps.cwd(), {
2176
+ fs: opts.fs,
2177
+ ps,
2178
+ project: opts.project
2179
+ });
2180
+ const reading = this.artifacts.flatMap((artifact) => {
2181
+ const deployed = artifact.deployed?.bind(artifact);
2182
+ return deployed === undefined ? [] : [{ artifact, deployed }];
2183
+ });
2184
+ const [version, artifacts] = await Promise.all([
2185
+ workspace.version(),
2186
+ Promise.all(reading.map(async ({ artifact, deployed }) => ({
2187
+ name: artifact.name ?? statusName(artifact),
2188
+ packages: artifact.packages,
2189
+ deployed: await deployed()
2190
+ })))
2191
+ ]);
2192
+ return { version, artifacts };
2193
+ }
2194
+ async release(opts = {}) {
2195
+ const ps = opts.ps ?? new NodePs9;
2196
+ const log = opts.log ?? new ConsoleLogger3;
2197
+ const fs = opts.fs ?? new NodeFs8;
2198
+ const workspace = opts.workspace ?? await ManifestWorkspace.at(ps.cwd(), { fs, ps, project: opts.project });
2199
+ const git = opts.git ?? new CliGit(workspace.root, { ps });
2200
+ const packages = order(await workspace.packages());
2201
+ const file = new ReleaseFile(workspace.root, { fs });
2202
+ const found = await file.read();
2203
+ const next = {
2204
+ bump: opts.bump ?? "patch",
2205
+ resuming: found !== null,
2206
+ current: await workspace.version()
2207
+ };
2208
+ const version = found?.version ?? bump(next.current, next.bump);
2209
+ const owned = opts.dryRun === true ? { dir: await mkdtemp(join3(tmpdir2(), "ship-dry-run-")) } : undefined;
2210
+ const dryRun = owned ?? (typeof opts.dryRun === "object" ? opts.dryRun : undefined);
2211
+ if (dryRun !== undefined) {
2212
+ await fs.mkdir(`${dryRun.dir}/packs`);
2213
+ }
2214
+ const cut = new Cut(version, packages, {
2215
+ log,
2216
+ root: workspace.root,
2217
+ dryRun
2218
+ });
2219
+ const runner = new StepRunner(new StepEvents(ps.env("WEBAPPWIZ_SHIP_EVENTS") ?? ps.env("SPLATES_SHIP_EVENTS"), fs, opts.wallClock, ps.env("WEBAPPWIZ_SHIP_PROGRESS") === "1" ? { line: (text) => log.info(text) } : undefined), opts.timer);
2220
+ const declared = this.declare({
2221
+ workspace,
2222
+ git,
2223
+ packages,
2224
+ cut,
2225
+ version
2226
+ });
2227
+ if (dryRun !== undefined) {
2228
+ await rehearse({
2229
+ ...declared,
2230
+ artifacts: this.artifacts,
2231
+ packages: this.packages,
2232
+ cut,
2233
+ runner,
2234
+ git,
2235
+ fs,
2236
+ ps,
2237
+ owned: owned !== undefined
2238
+ });
2239
+ return;
2240
+ }
2241
+ const { preflight, before, versionStep, going } = declared;
2242
+ await runner.declare([preflight, ...before, versionStep, ...going]);
2243
+ await runner.run(preflight, cut);
2244
+ for (const step of before) {
2245
+ await runner.run(step, cut);
2246
+ }
2247
+ if (!confirm(opts.prompt ?? prompt, log, this.packages, version, next, opts.yes)) {
2248
+ log.info(color5.red("aborted"));
2249
+ return;
2250
+ }
2251
+ const state = found ?? { version, done: [] };
2252
+ await file.write(state);
2253
+ try {
2254
+ await runner.run(versionStep, cut);
2255
+ for (const declaration of going) {
2256
+ const done = declaration.step.stage !== "build" && state.done.includes(declaration.id);
2257
+ await runner.run(declaration, cut, { done });
2258
+ if (!state.done.includes(declaration.id)) {
2259
+ state.done.push(declaration.id);
2260
+ }
2261
+ await file.write(state);
2262
+ }
2263
+ } finally {
2264
+ for (const artifact of this.artifacts) {
2265
+ await artifact.clean?.(cut);
2266
+ }
2267
+ }
2268
+ await file.clear();
2269
+ log.info(color5.green(`shipped ${version}`));
2270
+ }
2271
+ async trust(opts = {}) {
2272
+ await trust(this.artifacts, opts);
2273
+ }
2274
+ async publish(opts = {}) {
2275
+ const ps = opts.ps ?? new NodePs9;
2276
+ const log = opts.log ?? new ConsoleLogger3;
2277
+ const fs = opts.fs ?? new NodeFs8;
2278
+ const workspace = opts.workspace ?? await ManifestWorkspace.at(ps.cwd(), { fs, ps, project: opts.project });
2279
+ const packages = order(await workspace.packages());
2280
+ declares(this.packages, packages);
2281
+ const version = await workspace.version();
2282
+ const cut = new Cut(version, packages, { log, root: workspace.root });
2283
+ const going = sequence(this.artifacts.filter((artifact) => artifact.stage === "build" || artifact.stage === undefined || artifact.stage === "publish"), packages);
2284
+ const publishing = going.map((artifact) => artifact.trusted?.() ?? artifact);
2285
+ const steps = publishing.flatMap((artifact) => stepsFor(artifact, cut)).filter((step) => step.stage === "build" || step.stage === "publish").toSorted((left, right) => stageRank(left) - stageRank(right)).map((step, index) => ({
2286
+ id: `step:${index}:${step.name}`,
2287
+ step
2288
+ }));
2289
+ const runner = new StepRunner(new StepEvents(ps.env("WEBAPPWIZ_SHIP_EVENTS") ?? ps.env("SPLATES_SHIP_EVENTS"), fs, opts.wallClock), opts.timer);
2290
+ await runner.declare(steps);
2291
+ try {
2292
+ for (const declaration of steps) {
2293
+ await runner.run(declaration, cut);
2294
+ }
2295
+ } finally {
2296
+ for (const artifact of publishing) {
2297
+ await artifact.clean?.(cut);
2298
+ }
2299
+ }
2300
+ log.info(color5.green(`published ${version}`));
2301
+ }
2302
+ declare(at) {
2303
+ const { workspace, git, packages, cut, version } = at;
2304
+ const preflight = {
2305
+ id: "preflight",
2306
+ step: {
2307
+ name: "Preflight",
2308
+ deadline: Duration7.secs(30),
2309
+ stage: "preflight",
2310
+ run: async () => {
2311
+ const [branch, trunk] = [
2312
+ await git.branch(),
2313
+ await git.defaultBranch()
2314
+ ];
2315
+ if (branch !== trunk) {
2316
+ if (cut.dryRun === undefined) {
2317
+ throw new Error(`on "${branch}": releases go out from "${trunk}"`);
2318
+ }
2319
+ cut.log.info(color5.yellow(`on "${branch}": a release would refuse it, as releases go out from "${trunk}"`));
2320
+ }
2321
+ if (!await git.clean()) {
2322
+ throw new Error("uncommitted changes: releases go out from a clean tree, so commit or discard them first");
2323
+ }
2324
+ declares(this.packages, packages);
2325
+ for (const artifact of this.artifacts) {
2326
+ await artifact.verify?.(cut);
2327
+ }
2328
+ }
2329
+ }
2330
+ };
2331
+ const before = this.steps.filter((step) => step.stage === "preflight").map((step, index) => ({ id: `preflight:${index}:${step.name}`, step }));
2332
+ const ordered = sequence(this.artifacts, packages);
2333
+ const stamps = ordered.filter((artifact) => artifact.stage === "stamp");
2334
+ const stamping = this.steps.filter((step) => step.stage === "stamp");
2335
+ const versionStep = {
2336
+ id: "version",
2337
+ step: {
2338
+ name: `Version ${version}`,
2339
+ deadline: Duration7.mins(2),
2340
+ stage: "stamp",
2341
+ run: async () => {
2342
+ await workspace.setVersion(version);
2343
+ for (const artifact of stamps) {
2344
+ await artifact.publish(cut);
2345
+ }
2346
+ for (const step of stamping) {
2347
+ await step.run(cut);
2348
+ }
2349
+ if (cut.dryRun === undefined) {
2350
+ await git.commitAll(`Release ${version}`);
2351
+ }
2352
+ }
2353
+ }
2354
+ };
2355
+ const going = [
2356
+ ...ordered.filter((artifact) => artifact.stage !== "stamp").flatMap((artifact) => stepsFor(artifact, cut).map((step) => ({ step, artifact }))),
2357
+ ...this.steps.filter((step) => step.stage !== "preflight" && step.stage !== "stamp").map((step) => ({ step, artifact: undefined }))
2358
+ ].toSorted((left, right) => stageRank(left.step) - stageRank(right.step)).map(({ step, artifact }, index) => ({
2359
+ id: `step:${index}:${step.name}`,
2360
+ step,
2361
+ artifact: artifact && (artifact.name ?? statusName(artifact)),
2362
+ packages: artifact?.packages
2363
+ }));
2364
+ return { preflight, before, versionStep, going };
2365
+ }
2366
+ async plan(opts = {}) {
2367
+ const ps = opts.ps ?? new NodePs9;
2368
+ const fs = opts.fs ?? new NodeFs8;
2369
+ const workspace = opts.workspace ?? await ManifestWorkspace.at(ps.cwd(), { fs, ps, project: opts.project });
2370
+ const git = opts.git ?? new CliGit(workspace.root, { ps });
2371
+ const packages = order(await workspace.packages());
2372
+ const found = await new ReleaseFile(workspace.root, { fs }).read();
2373
+ const version = found?.version ?? bump(await workspace.version(), opts.bump ?? "patch");
2374
+ const cut = new Cut(version, packages, {
2375
+ log: opts.log ?? new ConsoleLogger3,
2376
+ root: workspace.root
2377
+ });
2378
+ const { preflight, before, versionStep, going } = this.declare({
2379
+ workspace,
2380
+ git,
2381
+ packages,
2382
+ cut,
2383
+ version
2384
+ });
2385
+ return {
2386
+ schema: 1,
2387
+ version,
2388
+ resuming: found !== null,
2389
+ steps: [preflight, ...before, versionStep, ...going].map(({ id, step, artifact, packages: covered }) => ({
2390
+ id,
2391
+ name: step.name,
2392
+ stage: step.stage ?? "publish",
2393
+ packages: [...covered ?? []],
2394
+ ...artifact === undefined ? {} : { artifact },
2395
+ deadlineMs: step.deadline.ms
2396
+ }))
2397
+ };
2398
+ }
2399
+ }
2400
+ function sequence(artifacts, packages) {
2401
+ const rank = new Map(packages.map((pkg, index) => [pkg.name, index]));
2402
+ const at = (artifact) => {
2403
+ const ranks = artifact.packages.map((name) => rank.get(name) ?? packages.length);
2404
+ return ranks.length === 0 ? packages.length : Math.min(...ranks);
2405
+ };
2406
+ return artifacts.toSorted((left, right) => {
2407
+ const stages = STAGES.indexOf(left.stage ?? "publish") - STAGES.indexOf(right.stage ?? "publish");
2408
+ return stages !== 0 ? stages : at(left) - at(right);
2409
+ });
2410
+ }
2411
+ function stepsFor(artifact, cut) {
2412
+ if (artifact.steps !== undefined) {
2413
+ return artifact.steps(cut).map((step) => ({
2414
+ ...step,
2415
+ stage: step.stage ?? artifact.stage
2416
+ }));
2417
+ }
2418
+ return [
2419
+ {
2420
+ name: artifactName(artifact),
2421
+ deadline: deadlineFor(artifact.stage),
2422
+ stage: artifact.stage,
2423
+ run: (at) => artifact.publish(at),
2424
+ ...artifact.dryRun === undefined ? {} : { dryRun: (at) => artifact.dryRun?.(at) ?? Promise.resolve() }
2425
+ }
2426
+ ];
2427
+ }
2428
+ function artifactName(artifact) {
2429
+ if (artifact.packages.length > 0) {
2430
+ return `Publish ${artifact.packages.join(" ")}`;
2431
+ }
2432
+ switch (artifact.stage) {
2433
+ case "build":
2434
+ return "Build";
2435
+ case "tag":
2436
+ return "Tag";
2437
+ case "notes":
2438
+ return "Release notes";
2439
+ case "stamp":
2440
+ return "Stamp";
2441
+ default:
2442
+ return "Publish";
2443
+ }
2444
+ }
2445
+ function statusName(artifact) {
2446
+ return artifact.packages.length > 0 ? artifact.packages.join(" ") : artifact.stage ?? "publish";
2447
+ }
2448
+ function deadlineFor(stage) {
2449
+ switch (stage) {
2450
+ case "build":
2451
+ return Duration7.mins(10);
2452
+ case "tag":
2453
+ case "notes":
2454
+ return Duration7.mins(2);
2455
+ default:
2456
+ return Duration7.mins(5);
2457
+ }
2458
+ }
2459
+ function stageRank(step) {
2460
+ return STAGES.indexOf(step.stage === "preflight" ? "publish" : step.stage ?? "publish");
2461
+ }
2462
+ function declares(declared, packages) {
2463
+ if (declared.length === 0) {
2464
+ throw new Error("no packages are declared: there is nothing to publish");
2465
+ }
2466
+ const drift = [];
2467
+ const byName = new Map(packages.map((pkg) => [pkg.name, pkg]));
2468
+ const names = new Set(declared);
2469
+ for (const name of names) {
2470
+ const pkg = byName.get(name);
2471
+ if (pkg === undefined || pkg.private) {
2472
+ drift.push(`"${name}" is declared but the workspace has no public package by that name`);
2473
+ }
2474
+ }
2475
+ for (const pkg of packages) {
2476
+ if (!pkg.private && !names.has(pkg.name)) {
2477
+ drift.push(`"${pkg.name}" is public but not declared: declare it or mark it private`);
2478
+ }
2479
+ }
2480
+ if (drift.length > 0) {
2481
+ throw new Error(drift.join(`
2482
+ `));
2483
+ }
2484
+ }
2485
+ function confirm(ask, log, packages, version, next, yes = false) {
2486
+ log.info(next.resuming ? `finishing the release of ${version}` : `${next.current} -> ${version} (${next.bump})`);
2487
+ for (const name of packages) {
2488
+ log.info(` ${name}`);
2489
+ }
2490
+ if (yes) {
2491
+ return true;
2492
+ }
2493
+ const answer = ask(color5.yellow(`publish ${packages.length} packages as ${version}? (y/n)`));
2494
+ return answer?.trim().toLowerCase() === "y";
2495
+ }
2496
+ // ship/releases.ts
2497
+ import { color as color12 } from "../log/index.js";
2498
+ import { NodePs as NodePs14 } from "../system/index.js";
2499
+ import { Duration as Duration12 } from "../time/index.js";
2500
+
2501
+ // ship/bundle/bundle-artifact.ts
2502
+ import { color as color6 } from "../log/index.js";
2503
+ class BundleArtifact {
2504
+ bundle;
2505
+ packages = [];
2506
+ stage = "build";
2507
+ constructor(bundle = new BunBundle) {
2508
+ this.bundle = bundle;
2509
+ }
2510
+ async publish(cut) {
2511
+ const going = cut.packages.filter((pkg) => !pkg.private);
2512
+ for (const pkg of going) {
2513
+ cut.stage(pkg.name, await this.bundle.build(pkg.dir));
2514
+ }
2515
+ cut.log.info(`${going.length} packages ${color6.green("built")}`);
2516
+ }
2517
+ async clean(cut) {
2518
+ for (const pkg of cut.packages) {
2519
+ await this.bundle.clean(pkg.dir);
2520
+ }
2521
+ }
2522
+ }
2523
+
2524
+ // ship/git/git-artifact.ts
2525
+ import { color as color7 } from "../log/index.js";
2526
+ import { NodePs as NodePs10 } from "../system/index.js";
2527
+ import { Duration as Duration8 } from "../time/index.js";
2528
+ class GitArtifact {
2529
+ name = "git tag";
2530
+ packages = [];
2531
+ stage = "tag";
2532
+ git;
2533
+ constructor(opts = {}) {
2534
+ const ps = opts.ps ?? new NodePs10;
2535
+ this.git = opts.git ?? new CliGit(ps.cwd(), { ps });
2536
+ }
2537
+ steps(cut) {
2538
+ return [
2539
+ {
2540
+ name: "Push branch",
2541
+ deadline: Duration8.mins(2),
2542
+ stage: "tag",
2543
+ run: () => this.pushBranch(),
2544
+ dryRun: async (at) => at.log.info(color7.yellow("would push the branch"))
2545
+ },
2546
+ {
2547
+ name: `Tag ${cut.tag}`,
2548
+ deadline: Duration8.secs(30),
2549
+ stage: "tag",
2550
+ run: async () => this.git.tag(cut.tag),
2551
+ dryRun: async (at) => at.log.info(color7.yellow(`would tag ${at.tag}`))
2552
+ },
2553
+ {
2554
+ name: `Push ${cut.tag}`,
2555
+ deadline: Duration8.mins(2),
2556
+ stage: "tag",
2557
+ run: async () => {
2558
+ await this.git.push(cut.tag);
2559
+ cut.log.info(`${cut.tag} ${color7.green("pushed")}`);
2560
+ },
2561
+ dryRun: async (at) => at.log.info(color7.yellow(`would push ${at.tag}`))
2562
+ }
2563
+ ];
2564
+ }
2565
+ async publish(cut) {
2566
+ await this.pushBranch();
2567
+ await this.git.tag(cut.tag);
2568
+ await this.git.push(cut.tag);
2569
+ cut.log.info(`${cut.tag} ${color7.green("pushed")}`);
2570
+ }
2571
+ async deployed() {
2572
+ const tags = await this.git.remoteTags("v*");
2573
+ return newest(tags.map((tag) => tag.slice(1)));
2574
+ }
2575
+ async pushBranch() {
2576
+ await this.git.push(await this.git.branch());
2577
+ }
2578
+ }
2579
+
2580
+ // ship/github/cli-github.ts
2581
+ import { NodePs as NodePs11 } from "../system/index.js";
2582
+ class CliGithub {
2583
+ ps;
2584
+ on;
2585
+ constructor(opts = {}) {
2586
+ this.ps = opts.ps ?? new NodePs11;
2587
+ this.on = opts.repo === undefined ? [] : ["--repo", opts.repo];
2588
+ }
2589
+ get repo() {
2590
+ return this.on[1];
2591
+ }
2592
+ async release(tag) {
2593
+ await this.login();
2594
+ const existing = await this.ps.spawnCapture([
2595
+ "gh",
2596
+ "release",
2597
+ "view",
2598
+ tag,
2599
+ ...this.on
2600
+ ]);
2601
+ if (existing.exitCode === 0) {
2602
+ return;
2603
+ }
2604
+ const { exitCode, stderr } = await this.ps.spawnCapture([
2605
+ "gh",
2606
+ "release",
2607
+ "create",
2608
+ tag,
2609
+ "--generate-notes",
2610
+ ...this.on
2611
+ ]);
2612
+ if (exitCode !== 0) {
2613
+ throw new Error(`gh release create ${tag}: ${stderr.trim()}`);
2614
+ }
2615
+ }
2616
+ async latest() {
2617
+ const { exitCode, stdout, stderr } = await this.ps.spawnCapture([
2618
+ "gh",
2619
+ "release",
2620
+ "view",
2621
+ "--json",
2622
+ "tagName",
2623
+ "--jq",
2624
+ ".tagName",
2625
+ ...this.on
2626
+ ]);
2627
+ if (exitCode === 0) {
2628
+ return stdout.trim() || undefined;
2629
+ }
2630
+ if (stderr.includes("release not found")) {
2631
+ return;
2632
+ }
2633
+ throw new Error(`gh release view: ${stderr.trim() || stdout.trim()}`);
2634
+ }
2635
+ login() {
2636
+ return ghLogin(this.ps);
2637
+ }
2638
+ }
2639
+
2640
+ // ship/github/github-artifact.ts
2641
+ import { color as color8 } from "../log/index.js";
2642
+
2643
+ class GithubArtifact {
2644
+ github;
2645
+ name = "GitHub release";
2646
+ packages = [];
2647
+ stage = "notes";
2648
+ constructor(github) {
2649
+ this.github = github;
2650
+ }
2651
+ async publish(cut) {
2652
+ await this.github.release(cut.tag);
2653
+ }
2654
+ async dryRun(cut) {
2655
+ cut.log.info(color8.yellow(`would write the GitHub notes for ${cut.tag}`));
2656
+ }
2657
+ async deployed() {
2658
+ return (await this.github.latest())?.replace(/^v/, "");
2659
+ }
2660
+ }
2661
+
2662
+ // ship/registry/npm-registry.ts
2663
+ import { NodePs as NodePs12 } from "../system/index.js";
2664
+ import { Duration as Duration9 } from "../time/index.js";
2665
+
2666
+ class NpmRegistry {
2667
+ staged;
2668
+ scans = true;
2669
+ publishDeadline;
2670
+ watch;
2671
+ trust;
2672
+ ps;
2673
+ isTrusted;
2674
+ via;
2675
+ authed;
2676
+ saidSkip = false;
2677
+ constructor(opts = {}) {
2678
+ this.ps = opts.ps ?? new NodePs12;
2679
+ this.isTrusted = opts.trusted === true;
2680
+ this.via = opts.via;
2681
+ this.staged = !this.isTrusted && this.via === undefined;
2682
+ const { via } = this;
2683
+ if (via !== undefined) {
2684
+ this.watch = async (name, version) => via.watch(name, await this.published(name, version));
2685
+ this.publishDeadline = Duration9.mins(30);
2686
+ this.trust = (name, log) => this.trustWorkflow(name, via, log);
2687
+ }
2688
+ }
2689
+ async trustWorkflow(name, via, log) {
2690
+ if (!this.saidSkip) {
2691
+ this.saidSkip = true;
2692
+ log.info("npm asks you to authenticate in a browser: choose to skip two-factor authentication for the next 5 minutes, and the other packages go through without asking");
2693
+ }
2694
+ const argv = [
2695
+ "npm",
2696
+ "trust",
2697
+ "github",
2698
+ name,
2699
+ "--repo",
2700
+ await via.repo(),
2701
+ "--file",
2702
+ via.file,
2703
+ "--allow-publish",
2704
+ "--yes"
2705
+ ];
2706
+ const { exitCode } = await this.ps.spawn(argv);
2707
+ if (exitCode !== 0) {
2708
+ throw new Error(`${argv.join(" ")} failed: if ${name} already trusts another workflow, \`npm trust list ${name}\` shows it and \`npm trust revoke ${name} --id <id>\` clears it`);
2709
+ }
2710
+ }
2711
+ async verify({ name, repository: url = "" }) {
2712
+ if (this.via === undefined) {
2713
+ return;
2714
+ }
2715
+ const expected = `https://github.com/${await this.via.repo()}`;
2716
+ if (sameRepository(url, expected)) {
2717
+ return;
2718
+ }
2719
+ throw new Error(`${name}'s package.json has repository.url ${JSON.stringify(url)}, and npm refuses a publish from ${expected}'s workflow unless it names that repository: set it to "git+${expected}.git"`);
2720
+ }
2721
+ trusted() {
2722
+ return new NpmRegistry({ ps: this.ps, trusted: true });
2723
+ }
2724
+ async pack(dir, into) {
2725
+ const { exitCode, stderr } = await this.ps.spawnCapture(["npm", "pack", "--pack-destination", into], { cwd: dir });
2726
+ if (exitCode !== 0) {
2727
+ throw new Error(`npm pack in ${dir}: ${stderr.trim()}`);
2728
+ }
2729
+ }
2730
+ async published(name, version) {
2731
+ const { exitCode, stdout } = await this.ps.spawnCapture([
2732
+ "npm",
2733
+ "view",
2734
+ `${name}@${version}`,
2735
+ "version"
2736
+ ]);
2737
+ return exitCode === 0 && stdout.trim() !== "";
2738
+ }
2739
+ async deployed(name) {
2740
+ const { exitCode, stdout, stderr } = await this.ps.spawnCapture([
2741
+ "npm",
2742
+ "view",
2743
+ name,
2744
+ "dist-tags.latest"
2745
+ ]);
2746
+ if (exitCode === 0) {
2747
+ return stdout.trim() || undefined;
2748
+ }
2749
+ if (stderr.includes("E404")) {
2750
+ return;
2751
+ }
2752
+ throw new Error(`npm view ${name}: ${stderr.trim() || stdout.trim()}`);
2753
+ }
2754
+ async publish(dir) {
2755
+ if (this.via !== undefined && !this.isTrusted) {
2756
+ await this.via.start();
2757
+ return {};
2758
+ }
2759
+ if (this.isTrusted) {
2760
+ return this.publishTrusted(dir);
2761
+ }
2762
+ this.authed ??= this.checkVersion().then(() => this.login());
2763
+ await this.authed;
2764
+ const { exitCode, stdout, stderr } = await this.ps.spawnCapture(["npm", "stage", "publish", "--access", "public"], { cwd: dir });
2765
+ if (exitCode !== 0) {
2766
+ if (/E409|previously published/i.test(`${stdout}
2767
+ ${stderr}`)) {
2768
+ return { already: true };
2769
+ }
2770
+ throw new Error(`stage publish failed in ${dir}: ${stderr.trim() || stdout.trim()}`);
2771
+ }
2772
+ const found = /\+ (\S+)@[^@\s]+ \(staged with id ([^)\s]+)\)/.exec(`${stdout}
2773
+ ${stderr}`);
2774
+ if (found?.[1] === undefined || found[2] === undefined) {
2775
+ throw new Error(`npm staged ${dir} but printed no stage id`);
2776
+ }
2777
+ return {
2778
+ staged: {
2779
+ stageId: found[2],
2780
+ url: `https://www.npmjs.com/package/${found[1]}`
2781
+ }
2782
+ };
2783
+ }
2784
+ async publishTrusted(dir) {
2785
+ const { exitCode, stdout, stderr } = await this.ps.spawnCapture(["npm", "publish", "--access", "public", "--loglevel", "verbose"], { cwd: dir });
2786
+ if (exitCode === 0) {
2787
+ return {};
2788
+ }
2789
+ const output = `${stdout}
2790
+ ${stderr}`;
2791
+ if (/E409|previously published/i.test(output)) {
2792
+ return { already: true };
2793
+ }
2794
+ if (/OIDC token exchange error/i.test(output)) {
2795
+ throw new Error(`npm refused the OIDC token exchange for ${dir}: the package has no trusted publisher entry naming this repository and workflow, or it does not exist yet`);
2796
+ }
2797
+ throw new Error(`publish failed in ${dir}: ${stderr.trim() || stdout.trim()}`);
2798
+ }
2799
+ page(name, version) {
2800
+ return `https://www.npmjs.com/package/${name}/v/${version}`;
2801
+ }
2802
+ async checkVersion() {
2803
+ const { stdout } = await this.ps.spawnCapture(["npm", "--version"]);
2804
+ const found = /^(\d+)\.(\d+)/.exec(stdout.trim());
2805
+ if (!found) {
2806
+ return;
2807
+ }
2808
+ const [major, minor] = [Number(found[1]), Number(found[2])];
2809
+ if (major < 11 || major === 11 && minor < 15) {
2810
+ throw new Error(`npm ${stdout.trim()} cannot stage packages: npm 11.15 or newer is required (npm install -g npm@latest)`);
2811
+ }
2812
+ }
2813
+ async login() {
2814
+ if ((await this.ps.spawnCapture(["npm", "whoami"])).exitCode === 0) {
2815
+ return;
2816
+ }
2817
+ if (this.ps.env("CI") !== undefined) {
2818
+ throw new Error("not logged in to npm: set NPM_TOKEN");
2819
+ }
2820
+ const { exitCode } = await this.ps.spawn([
2821
+ "npm",
2822
+ "login",
2823
+ "--auth-type=web"
2824
+ ]);
2825
+ if (exitCode !== 0) {
2826
+ throw new Error("npm login failed");
2827
+ }
2828
+ }
2829
+ }
2830
+ function sameRepository(url, expected) {
2831
+ const normal = url.replace(/^git\+/, "").replace(/\.git$/, "").replace(/^git@github\.com:/, "https://github.com/").replace(/^github:/, "https://github.com/").replace(/^(?=[\w.-]+\/[\w.-]+$)/, "https://github.com/");
2832
+ return normal.toLowerCase() === expected.toLowerCase();
2833
+ }
2834
+
2835
+ // ship/registry/registry-artifact.ts
2836
+ import { color as color9 } from "../log/index.js";
2837
+ import { Duration as Duration10 } from "../time/index.js";
2838
+ var RUN_CHECK_EVERY = Duration10.secs(5);
2839
+ var HELD_AFTER = Duration10.mins(20);
2840
+
2841
+ class RegistryArtifact {
2842
+ name;
2843
+ registry;
2844
+ packages;
2845
+ stage = "publish";
2846
+ trust;
2847
+ verify;
2848
+ saidHeld = false;
2849
+ runStatus;
2850
+ constructor(name, registry) {
2851
+ this.name = name;
2852
+ this.registry = registry;
2853
+ this.packages = [name];
2854
+ const { trust } = registry;
2855
+ if (trust !== undefined) {
2856
+ this.trust = (log) => trust.call(registry, name, log);
2857
+ }
2858
+ const { verify } = registry;
2859
+ if (verify !== undefined) {
2860
+ this.verify = async (cut) => {
2861
+ const pkg = cut.packages.find((one) => one.name === name);
2862
+ if (pkg !== undefined) {
2863
+ await verify.call(registry, pkg);
2864
+ }
2865
+ };
2866
+ }
2867
+ }
2868
+ trusted() {
2869
+ const registry = this.registry.trusted?.();
2870
+ return registry === undefined ? this : new RegistryArtifact(this.name, registry);
2871
+ }
2872
+ deployed() {
2873
+ return this.registry.deployed(this.name);
2874
+ }
2875
+ steps(cut) {
2876
+ const publish = {
2877
+ name: `${this.registry.staged ? "Stage" : "Publish"} ${this.name}@${cut.version}`,
2878
+ deadline: this.registry.publishDeadline ?? Duration10.mins(5),
2879
+ stage: "publish",
2880
+ run: (at, report) => this.publish(at, report),
2881
+ dryRun: (at) => this.pack(at),
2882
+ ...this.watching()
2883
+ };
2884
+ if (this.registry.staged !== true && this.registry.scans !== true) {
2885
+ return [publish];
2886
+ }
2887
+ return [
2888
+ publish,
2889
+ {
2890
+ name: `Live ${this.name}@${cut.version}`,
2891
+ deadline: Duration10.hrs(1),
2892
+ stage: "approve",
2893
+ run: async () => {},
2894
+ dryRun: async () => {},
2895
+ check: (at, waited) => this.live(at, waited)
2896
+ }
2897
+ ];
2898
+ }
2899
+ async pack(cut) {
2900
+ const { version, log, dryRun } = cut;
2901
+ const dir = cut.dir(this.name);
2902
+ if (dir === undefined) {
2903
+ throw new Error(`"${this.name}" has no workspace package`);
2904
+ }
2905
+ if (this.registry.pack === undefined || dryRun === undefined) {
2906
+ log.info(`${this.name}@${version} ${color9.yellow("would publish")}`);
2907
+ return;
2908
+ }
2909
+ await this.registry.pack(dir, `${dryRun.dir}/packs`);
2910
+ log.info(`${this.name}@${version} ${color9.green("packed")}`);
2911
+ }
2912
+ watching() {
2913
+ const { watch } = this.registry;
2914
+ if (watch === undefined) {
2915
+ return {};
2916
+ }
2917
+ return {
2918
+ checkEvery: RUN_CHECK_EVERY,
2919
+ check: async ({ version, log }, waited) => {
2920
+ const found = await watch.call(this.registry, this.name, version);
2921
+ if (found.passed) {
2922
+ const after = waited.isEqual(Duration10.zero()) ? "" : ` after ${waited.human()}`;
2923
+ log.info(`${this.name}@${version} ${color9.green("publish run finished")}${after}`);
2924
+ return found;
2925
+ }
2926
+ if (found.status !== this.runStatus) {
2927
+ this.runStatus = found.status;
2928
+ const doing = (found.status ?? "waiting").replaceAll("_", " ");
2929
+ log.info(`${this.name}@${version} publish run ${color9.yellow(doing)}${found.url === undefined ? "" : `: ${found.url}`}`);
2930
+ }
2931
+ return found;
2932
+ }
2933
+ };
2934
+ }
2935
+ async live(cut, waited) {
2936
+ const { version, log } = cut;
2937
+ if (await this.registry.published(this.name, version)) {
2938
+ return { passed: true };
2939
+ }
2940
+ const url = this.registry.page?.(this.name, version);
2941
+ const status = waited.isLessThan(HELD_AFTER) ? "pending" : "held";
2942
+ if (waited.isEqual(Duration10.zero())) {
2943
+ this.saidHeld = false;
2944
+ log.info(`${this.name}@${version} ${color9.yellow("not live yet")}: waiting for ${this.registry.staged === true ? "approval and " : ""}the registry's checks`);
2945
+ } else if (status === "held" && !this.saidHeld) {
2946
+ this.saidHeld = true;
2947
+ log.info(`${this.name}@${version} ${color9.yellow("still not live")} after ${waited.human()}: the registry may be holding it for review${url === undefined ? "" : `, see ${url}`}`);
2948
+ }
2949
+ return { passed: false, status, ...url === undefined ? {} : { url } };
2950
+ }
2951
+ async publish(cut, report) {
2952
+ const { version, log } = cut;
2953
+ if (await this.registry.published(this.name, version)) {
2954
+ log.info(`${this.name}@${version} ${color9.green("already published")}`);
2955
+ return;
2956
+ }
2957
+ const dir = cut.dir(this.name);
2958
+ if (dir === undefined) {
2959
+ throw new Error(`"${this.name}" has no workspace package`);
2960
+ }
2961
+ const { already, staged } = await this.registry.publish(dir);
2962
+ if (already === true) {
2963
+ log.info(`${this.name}@${version} ${color9.green("already accepted")}: the registry took it on an earlier run`);
2964
+ return;
2965
+ }
2966
+ if (staged === undefined) {
2967
+ log.info(this.registry.watch === undefined ? `${this.name}@${version} ${color9.green("published")}` : `${this.name}@${version} ${color9.green("publish run started")}`);
2968
+ return;
2969
+ }
2970
+ log.info(`${this.name}@${version} ${color9.green("staged")}: approve ${staged.stageId} at ${staged.url}`);
2971
+ await report?.staged({ package: this.name, version, ...staged });
2972
+ }
2973
+ }
2974
+
2975
+ // ship/shipped.ts
2976
+ import { relative as relative5 } from "node:path";
2977
+ import { color as color10 } from "../log/index.js";
2978
+ import { NodeFs as NodeFs9, NodePs as NodePs13 } from "../system/index.js";
2979
+ import { Duration as Duration11 } from "../time/index.js";
2980
+ var FIELDS2 = ["dependencies", "peerDependencies"];
2981
+
2982
+ class ShippedCheck {
2983
+ opts;
2984
+ name = "Dependencies shipped";
2985
+ deadline = Duration11.mins(1);
2986
+ stage = "preflight";
2987
+ fs;
2988
+ ps;
2989
+ constructor(opts) {
2990
+ this.opts = opts;
2991
+ this.fs = opts.fs ?? new NodeFs9;
2992
+ this.ps = opts.ps ?? new NodePs13;
2993
+ }
2994
+ async run(cut) {
2995
+ const unshipped = await this.unshipped(cut);
2996
+ if (unshipped.length === 0) {
2997
+ return;
2998
+ }
2999
+ this.list(cut, unshipped);
3000
+ const ask = this.opts.prompt ?? prompt;
3001
+ const answer = ask("go ahead without shipping them first? [y/N]");
3002
+ if (answer?.trim().toLowerCase() !== "y") {
3003
+ throw new Error(`ship ${unshipped.map((one) => one.project).join(", ")} first`);
3004
+ }
3005
+ }
3006
+ async dryRun(cut) {
3007
+ const unshipped = await this.unshipped(cut);
3008
+ if (unshipped.length > 0) {
3009
+ this.list(cut, unshipped);
3010
+ cut.log.info(color10.yellow("a release would ask whether to go ahead"));
3011
+ }
3012
+ }
3013
+ async unshipped(cut) {
3014
+ const workspace = this.opts.workspace ?? await ManifestWorkspace.at(cut.root, { fs: this.fs, ps: this.ps });
3015
+ const root = workspace.root;
3016
+ const packages = await workspace.packages();
3017
+ const inside = (dir, project) => dir === `${root}/${project}` || dir.startsWith(`${root}/${project}/`);
3018
+ const own = packages.filter((pkg) => !pkg.private && inside(pkg.dir, this.opts.project));
3019
+ const needed = new Set;
3020
+ for (const pkg of own) {
3021
+ const manifest = await manifestAt(this.fs, pkg.dir);
3022
+ for (const field of FIELDS2) {
3023
+ for (const [name, range] of Object.entries(manifest[field] ?? {})) {
3024
+ if (range.startsWith("workspace:")) {
3025
+ needed.add(name);
3026
+ }
3027
+ }
3028
+ }
3029
+ }
3030
+ const found = [];
3031
+ for (const pkg of packages) {
3032
+ if (!needed.has(pkg.name) || pkg.private || inside(pkg.dir, this.opts.project)) {
3033
+ continue;
3034
+ }
3035
+ const project = relative5(root, pkg.dir).split("/")[0];
3036
+ const release = await this.git(root, "log", "-1", "--format=%H", "-G", '"version":', "--", `${relative5(root, pkg.dir)}/package.json`);
3037
+ const commits = await this.git(root, "log", "--format=%h %s", ...release === "" ? ["HEAD"] : [`${release}..HEAD`], "--", relative5(root, pkg.dir));
3038
+ if (commits !== "") {
3039
+ found.push({ name: pkg.name, project, commits: commits.split(`
3040
+ `) });
3041
+ }
3042
+ }
3043
+ return found;
3044
+ }
3045
+ list(cut, unshipped) {
3046
+ for (const one of unshipped) {
3047
+ cut.log.info(`${one.name} ${color10.yellow("has changes not yet shipped")}, so this release would go out against the version the registry has, without them:`);
3048
+ for (const commit of one.commits) {
3049
+ cut.log.info(` ${commit}`);
3050
+ }
3051
+ }
3052
+ }
3053
+ async git(cwd, ...args) {
3054
+ const result = await this.ps.spawnCapture(["git", ...args], { cwd });
3055
+ if (result.exitCode !== 0) {
3056
+ throw new Error(`git ${args.join(" ")} failed in ${cwd}: ${result.stderr.trim()}`);
3057
+ }
3058
+ return result.stdout.trim();
3059
+ }
3060
+ }
3061
+
3062
+ // ship/skill-artifact.ts
3063
+ import { resolve as resolve3 } from "node:path";
3064
+ import { color as color11 } from "../log/index.js";
3065
+ import { NodeFs as NodeFs10 } from "../system/index.js";
3066
+ var FRONTMATTER = /^---\n[\s\S]*?\n---/;
3067
+ var VERSION = /^version:.*$/m;
3068
+
3069
+ class SkillArtifact {
3070
+ path;
3071
+ packages = [];
3072
+ stage = "stamp";
3073
+ fs;
3074
+ constructor(path, opts = {}) {
3075
+ this.path = path;
3076
+ this.fs = opts.fs ?? new NodeFs10;
3077
+ }
3078
+ async publish(cut) {
3079
+ const path = resolve3(cut.root, this.path);
3080
+ const stamped = stamp(await this.fs.read(path), cut.version, this.path);
3081
+ await this.fs.write(path, stamped);
3082
+ cut.log.info(`${this.path} ${color11.green(`stamped ${cut.version}`)}`);
3083
+ }
3084
+ }
3085
+ function stamp(doc, version, path) {
3086
+ const front = FRONTMATTER.exec(doc)?.[0];
3087
+ if (front === undefined || !VERSION.test(front)) {
3088
+ throw new Error(`${path} has no "version:" line in its frontmatter: add one for the release to stamp`);
3089
+ }
3090
+ return front.replace(VERSION, () => `version: ${version}`) + doc.slice(front.length);
3091
+ }
3092
+
3093
+ // ship/releases.ts
3094
+ class releases {
3095
+ constructor() {}
3096
+ static npm(name, opts = {}) {
3097
+ return new Release([new RegistryArtifact(name, new NpmRegistry(opts))]);
3098
+ }
3099
+ static custom(name, registry) {
3100
+ return new Release([new RegistryArtifact(name, registry)]);
3101
+ }
3102
+ static step(step) {
3103
+ return new Release([], [step]);
3104
+ }
3105
+ static shipped(opts) {
3106
+ return releases.step(new ShippedCheck(opts));
3107
+ }
3108
+ static push(opts = {}) {
3109
+ return releases.step({
3110
+ name: "Push commits",
3111
+ deadline: Duration12.mins(2),
3112
+ stage: "preflight",
3113
+ run: async (cut) => {
3114
+ const git = opts.git ?? new CliGit(cut.root, { ps: opts.ps });
3115
+ await git.push(await git.branch());
3116
+ },
3117
+ dryRun: async (cut) => {
3118
+ cut.log.info(color12.yellow("would push the branch's commits"));
3119
+ }
3120
+ });
3121
+ }
3122
+ static publishWorkflow(opts) {
3123
+ const workflow = new PublishWorkflow(opts);
3124
+ return releases.step({
3125
+ name: "Publish workflow",
3126
+ deadline: Duration12.secs(30),
3127
+ stage: "preflight",
3128
+ run: async (cut) => {
3129
+ if (await workflow.write(cut.root)) {
3130
+ cut.log.info("wrote the publish workflow: commit it with the release");
3131
+ }
3132
+ }
3133
+ });
3134
+ }
3135
+ static git(opts = {}) {
3136
+ return new Release([new GitArtifact(opts)]);
3137
+ }
3138
+ static build(bundle) {
3139
+ return new Release([new BundleArtifact(bundle)]);
3140
+ }
3141
+ static vendor(opts = {}) {
3142
+ return new Release([new BundleArtifact(new VendorBundle(opts))]);
3143
+ }
3144
+ static mirror(opts) {
3145
+ return releases.step(new MirrorStep(opts));
3146
+ }
3147
+ static mirrored(opts) {
3148
+ return new Release([new MirrorBuild(opts)]);
3149
+ }
3150
+ static skill(path, opts = {}) {
3151
+ return new Release([new SkillArtifact(path, opts)]);
3152
+ }
3153
+ static github(opts = {}) {
3154
+ return new Release([new GithubArtifact(new CliGithub(opts))]);
3155
+ }
3156
+ static lockstep(...declarations) {
3157
+ const artifacts = [];
3158
+ const steps = [];
3159
+ for (const declaration of declarations) {
3160
+ if (declaration instanceof Release) {
3161
+ artifacts.push(...declaration.artifacts);
3162
+ steps.push(...declaration.steps);
3163
+ } else if ("run" in declaration) {
3164
+ steps.push(declaration);
3165
+ } else {
3166
+ artifacts.push(declaration);
3167
+ }
3168
+ }
3169
+ return new Release(artifacts, steps);
3170
+ }
3171
+ static async workspace(opts = {}) {
3172
+ const ps = opts.ps ?? new NodePs14;
3173
+ const workspace = await ManifestWorkspace.at(ps.cwd(), {
3174
+ fs: opts.fs,
3175
+ ps,
3176
+ project: opts.project
3177
+ });
3178
+ const registry = new NpmRegistry({ ps, via: opts.via });
3179
+ const artifacts = (await workspace.packages()).filter((pkg) => !pkg.private).map((pkg) => new RegistryArtifact(pkg.name, registry));
3180
+ return new Release([
3181
+ new BundleArtifact(new BunBundle({ fs: opts.fs, ps })),
3182
+ ...artifacts,
3183
+ new GitArtifact({ git: new CliGit(workspace.root, { ps }) }),
3184
+ new GithubArtifact(new CliGithub({ ps }))
3185
+ ]);
3186
+ }
3187
+ }
3188
+ export {
3189
+ Cut,
3190
+ GithubActions,
3191
+ ManifestWorkspace,
3192
+ MirrorBuild,
3193
+ MirrorStep,
3194
+ PUBLISH_WORKFLOW_PATH,
3195
+ PublishWorkflow,
3196
+ Release,
3197
+ ShippedCheck,
3198
+ VendorBundle,
3199
+ githubActions,
3200
+ order,
3201
+ published,
3202
+ releases
3203
+ };