rvlib-shipkit 2.25.0 → 2.27.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (456) hide show
  1. package/CHANGELOG.md +33 -0
  2. package/package.json +2 -2
  3. package/src/agent-time/diet.ts +77 -0
  4. package/src/agent-time/family.ts +72 -0
  5. package/src/agent-time/hooks.ts +331 -0
  6. package/src/agent-time/limits.ts +44 -0
  7. package/src/agent-time/live.ts +1 -3
  8. package/src/agent-time/mask.ts +96 -18
  9. package/src/agent-time/refused.ts +45 -0
  10. package/src/agent-time/render.ts +130 -17
  11. package/src/agent-time/report-cache.ts +57 -0
  12. package/src/agent-time/report.ts +349 -23
  13. package/src/agent-time/shape.ts +50 -3
  14. package/src/agent-time/store.ts +370 -95
  15. package/src/agent-time/timeline.ts +140 -21
  16. package/src/agent-time/turns.ts +18 -8
  17. package/src/annex/offload.ts +17 -6
  18. package/src/annex/tidy.ts +70 -10
  19. package/src/asks/ask-after.ts +40 -0
  20. package/src/asks/asks-queue.ts +205 -47
  21. package/src/assets/kit-config.ts +7 -3
  22. package/src/assets/kits/identity-kit.ts +289 -10
  23. package/src/check.ts +3 -1
  24. package/src/checks/SK004-gitignore-policy.check.ts +12 -5
  25. package/src/checks/SK013-one-way-in-policy.check.ts +8 -3
  26. package/src/checks/SK026-asks-autoclose.check.ts +5 -5
  27. package/src/checks/SK028-readme.check.ts +7 -66
  28. package/src/checks/SK030-cache-audit.check.ts +6 -1
  29. package/src/checks/SK031-trace-audit.check.ts +2 -0
  30. package/src/checks/SK033-global-contribution.check.ts +3 -1
  31. package/src/checks/SK035-public-clean.check.ts +2 -2
  32. package/src/checks/SK043-scratch-on-the-mac.check.ts +59 -4
  33. package/src/checks/SK045-slow-hooks.check.ts +47 -0
  34. package/src/checks/SK046-hook-records.check.ts +76 -0
  35. package/src/checks/SK047-login-in-description.check.ts +36 -0
  36. package/src/checks/SK048-one-local-file.check.ts +36 -0
  37. package/src/cli/cmd_Asks.ts +71 -5
  38. package/src/cli/cmd_Backup.ts +5 -3
  39. package/src/cli/cmd_Capacity.ts +2 -2
  40. package/src/cli/cmd_CrossRepoActivity.ts +5 -4
  41. package/src/cli/cmd_Db.ts +253 -0
  42. package/src/cli/cmd_History.ts +212 -0
  43. package/src/cli/cmd_Home.ts +31 -3
  44. package/src/cli/cmd_Hq.ts +516 -0
  45. package/src/cli/cmd_Machines.ts +36 -0
  46. package/src/cli/cmd_Media.ts +38 -6
  47. package/src/cli/cmd_Mv.ts +1 -1
  48. package/src/cli/cmd_Reflect.ts +23 -2
  49. package/src/cli/cmd_Releases.ts +30 -0
  50. package/src/cli/cmd_Review.ts +569 -118
  51. package/src/cli/cmd_Secret.ts +62 -12
  52. package/src/cli/cmd_Social.ts +83 -1
  53. package/src/cli/cmd_Space.ts +324 -0
  54. package/src/cli/cmd_Time.ts +82 -5
  55. package/src/cli/cmd_Tmp.ts +28 -4
  56. package/src/cli/cmd_Trailer.ts +14 -10
  57. package/src/cli/cmd_Urls.ts +56 -0
  58. package/src/cli/cmd_Vault.ts +583 -0
  59. package/src/cli/family-help.ts +4 -2
  60. package/src/cli/family-pages.ts +1 -1
  61. package/src/cli/registry.ts +26 -4
  62. package/src/collections/actions.ts +63 -13
  63. package/src/collections/collection-types.ts +23 -1
  64. package/src/collections/providers.ts +117 -23
  65. package/src/collections/review.ts +4 -4
  66. package/src/commands/runner.ts +5 -1
  67. package/src/contracts/contract-manifests.ts +6 -5
  68. package/src/contracts/contract-types.ts +6 -4
  69. package/src/contracts/contracts-engine.ts +11 -0
  70. package/src/contracts/manifests/chrome-web-store.contract.ts +31 -0
  71. package/src/core/budget.ts +12 -17
  72. package/src/core/capacity.ts +27 -18
  73. package/src/core/check-runner.ts +7 -4
  74. package/src/core/history-files.ts +9 -5
  75. package/src/core/layout.ts +3 -0
  76. package/src/core/machine-busy.ts +127 -0
  77. package/src/core/machine-commit.ts +6 -1
  78. package/src/core/machine-db.ts +368 -20
  79. package/src/core/machine-layout.ts +137 -0
  80. package/src/core/machine-read.ts +81 -0
  81. package/src/core/migrate-layout.ts +1 -1
  82. package/src/core/one-way-in-policy.ts +64 -7
  83. package/src/core/polling-policy.ts +27 -0
  84. package/src/core/retention.ts +16 -2
  85. package/src/core/scope.ts +107 -14
  86. package/src/core/signal-name.ts +6 -0
  87. package/src/core/slots.ts +5 -4
  88. package/src/core/trace-audit.ts +6 -1
  89. package/src/core/transient.ts +6 -0
  90. package/src/drill/clean.ts +25 -1
  91. package/src/drill/run.ts +2 -2
  92. package/src/drill/seal.ts +27 -4
  93. package/src/home/activity-shape.ts +2 -0
  94. package/src/home/activity.ts +66 -3
  95. package/src/home/app-sign.ts +15 -4
  96. package/src/home/daemon-jobs.ts +149 -7
  97. package/src/home/database-projects.ts +111 -0
  98. package/src/home/database-words.ts +203 -0
  99. package/src/home/databases.ts +460 -0
  100. package/src/home/global-units.ts +6 -0
  101. package/src/home/gui-app/ShipkitGui.swift +122 -1
  102. package/src/home/gui-app.ts +6 -3
  103. package/src/home/home-move.ts +514 -0
  104. package/src/home/home-paths.ts +12 -3
  105. package/src/home/home-routes.ts +68 -0
  106. package/src/home/inbox-shape.ts +24 -14
  107. package/src/home/machine-fold.ts +820 -0
  108. package/src/home/machine-host.ts +20 -5
  109. package/src/home/machine-repair.ts +503 -0
  110. package/src/home/machine-stores.ts +66 -15
  111. package/src/home/machine-temp.ts +547 -86
  112. package/src/home/resume.ts +79 -0
  113. package/src/home/run-daemon.ts +25 -4
  114. package/src/home/run-pm.ts +18 -5
  115. package/src/home/serve-daemon.ts +18 -3
  116. package/src/home/serve-web.ts +175 -7
  117. package/src/home/space-job.ts +115 -0
  118. package/src/home/space-page.ts +257 -0
  119. package/src/home/space-route.ts +167 -0
  120. package/src/home/space-words.ts +103 -0
  121. package/src/home/time-page-shape.ts +202 -0
  122. package/src/home/time-page.ts +64 -0
  123. package/src/home/vault-page.ts +482 -0
  124. package/src/home/vault-words.ts +132 -0
  125. package/src/hooks/leak-guard.ts +40 -13
  126. package/src/hooks/one-way-in-guard.ts +17 -4
  127. package/src/hq/cards.ts +581 -0
  128. package/src/hq/door-route.ts +43 -0
  129. package/src/hq/door.ts +163 -0
  130. package/src/hq/files-send.ts +348 -0
  131. package/src/hq/forgotten-log.ts +35 -0
  132. package/src/hq/history-check.ts +255 -0
  133. package/src/hq/history-place.ts +146 -0
  134. package/src/hq/history-send.ts +487 -0
  135. package/src/hq/hq-db.ts +99 -0
  136. package/src/hq/hq-local.ts +469 -0
  137. package/src/hq/hq-routes.ts +196 -0
  138. package/src/hq/hq-store.ts +599 -0
  139. package/src/hq/kinds/ask.ts +147 -0
  140. package/src/hq/kinds/card-gone.ts +83 -0
  141. package/src/hq/kinds/card-msg.ts +66 -0
  142. package/src/hq/kinds/card.ts +99 -0
  143. package/src/hq/kinds/index.ts +21 -0
  144. package/src/hq/kinds/kind.ts +126 -0
  145. package/src/hq/kinds/media.ts +125 -0
  146. package/src/hq/kinds/prompt.ts +219 -0
  147. package/src/hq/kinds/reflection.ts +128 -0
  148. package/src/hq/kinds/report.ts +55 -0
  149. package/src/hq/kinds/time-day.ts +236 -0
  150. package/src/hq/ledger.ts +473 -0
  151. package/src/hq/machine-key.ts +44 -0
  152. package/src/hq/machine-notes.ts +131 -0
  153. package/src/hq/outbox.ts +372 -0
  154. package/src/hq/replica.ts +168 -0
  155. package/src/hq/repo-id.ts +4 -0
  156. package/src/hq/report-facts.ts +117 -0
  157. package/src/hq/report.ts +274 -0
  158. package/src/hq/switch.ts +151 -0
  159. package/src/hq/vault-grant.ts +92 -0
  160. package/src/identities/identities.ts +15 -3
  161. package/src/identities/steps.ts +31 -0
  162. package/src/ledger/db.ts +73 -26
  163. package/src/ledger/gate-checks.ts +29 -4
  164. package/src/ledger/git-key.ts +3 -3
  165. package/src/ledger/git-scan.ts +49 -7
  166. package/src/ledger/run-log.ts +11 -3
  167. package/src/ledger/store.ts +26 -4
  168. package/src/media-store/backup/daemon.ts +36 -17
  169. package/src/media-store/backup/kept.ts +241 -0
  170. package/src/media-store/backup/restore.ts +14 -4
  171. package/src/media-store/backup/run.ts +11 -11
  172. package/src/media-store/backup/secret.ts +6 -4
  173. package/src/media-store/backup/snapshot.ts +4 -2
  174. package/src/media-store/backup/sources.ts +68 -20
  175. package/src/media-store/copy/config.ts +77 -0
  176. package/src/media-store/copy/copy.ts +194 -0
  177. package/src/media-store/copy/lifecycle.ts +43 -0
  178. package/src/media-store/copy/night.ts +90 -0
  179. package/src/media-store/copy/proof.ts +151 -0
  180. package/src/media-store/copy/snapshot.ts +152 -0
  181. package/src/media-store/copy/store.ts +62 -0
  182. package/src/media-store/copy/stream.ts +176 -0
  183. package/src/media-store/daemon.ts +66 -16
  184. package/src/media-store/db.ts +22 -11
  185. package/src/media-store/forget.ts +23 -3
  186. package/src/media-store/hand.ts +4 -3
  187. package/src/media-store/hq-find.ts +75 -0
  188. package/src/media-store/hq-send.ts +277 -0
  189. package/src/media-store/kind.ts +2 -0
  190. package/src/media-store/purge.ts +18 -15
  191. package/src/media-store/put.ts +24 -8
  192. package/src/media-store/remote.ts +16 -7
  193. package/src/media-store/space-listing.ts +240 -0
  194. package/src/media-store/space.ts +40 -21
  195. package/src/media-store/sync.ts +5 -5
  196. package/src/media-store/tidy.ts +98 -0
  197. package/src/media-store/upload.ts +3 -3
  198. package/src/media-store/webp.ts +66 -0
  199. package/src/messages/model.ts +16 -7
  200. package/src/messages/routes.ts +14 -4
  201. package/src/messages/score.ts +2 -2
  202. package/src/messages/suggest.ts +96 -0
  203. package/src/pages/frame-client.ts +10 -0
  204. package/src/plan/planner.ts +28 -17
  205. package/src/recordings/media-kind.ts +1 -0
  206. package/src/recordings/model.ts +1 -1
  207. package/src/recordings/recorder-app/Capture.swift +9 -7
  208. package/src/reflect/hq-corpus.ts +56 -0
  209. package/src/reflect/prompt-corpus.ts +3 -1
  210. package/src/reflect/transcript.ts +146 -36
  211. package/src/release/machine-words.ts +67 -0
  212. package/src/release/public-clean.ts +8 -3
  213. package/src/releases/from-card.ts +1 -1
  214. package/src/releases/model.ts +18 -0
  215. package/src/releases/routes.ts +10 -5
  216. package/src/releases/store.ts +23 -2
  217. package/src/repo-config.ts +42 -2
  218. package/src/review/anim.ts +2 -2
  219. package/src/review/auto.ts +2 -2
  220. package/src/review/card-db.ts +244 -0
  221. package/src/review/card-rows.ts +266 -0
  222. package/src/review/cells.ts +76 -5
  223. package/src/review/draft-card.ts +41 -0
  224. package/src/review/draft-model.ts +78 -0
  225. package/src/review/format.ts +29 -10
  226. package/src/review/gone.ts +98 -0
  227. package/src/review/inbox-hook.ts +35 -0
  228. package/src/review/marks.ts +1 -1
  229. package/src/review/media-kind.ts +7 -5
  230. package/src/review/media-read.ts +9 -7
  231. package/src/review/media.ts +32 -5
  232. package/src/review/model.ts +214 -45
  233. package/src/review/move.ts +491 -0
  234. package/src/review/notes.ts +12 -20
  235. package/src/review/previews.ts +15 -19
  236. package/src/review/project.ts +1 -1
  237. package/src/review/rev.ts +8 -0
  238. package/src/review/role.ts +1 -1
  239. package/src/review/routes.ts +64 -13
  240. package/src/review/stage-card.ts +8 -4
  241. package/src/review/stage-routes.ts +1 -1
  242. package/src/review/store.ts +529 -83
  243. package/src/review/thread-fold.ts +51 -0
  244. package/src/review/threads.ts +147 -9
  245. package/src/review/trailer-auto-mock.ts +63 -0
  246. package/src/review/trailer-card.ts +4 -4
  247. package/src/review/trailer-desk.ts +41 -7
  248. package/src/review/trailer-media.ts +1 -0
  249. package/src/review/trailer-model.ts +8 -0
  250. package/src/review/trailer-notes.ts +1 -1
  251. package/src/review/trailer-routes.ts +9 -1
  252. package/src/review/unit.ts +6 -6
  253. package/src/review/watchers.ts +1 -1
  254. package/src/rules/untrack-generated.ts +92 -8
  255. package/src/secrets/held.ts +16 -0
  256. package/src/secrets/keychain.ts +113 -0
  257. package/src/secrets/list.ts +16 -6
  258. package/src/secrets/manager.ts +24 -10
  259. package/src/secrets/read.ts +257 -0
  260. package/src/secrets/who-reads.ts +49 -0
  261. package/src/serve/door-forward.ts +268 -0
  262. package/src/serve/door-names.ts +47 -0
  263. package/src/serve/embed.ts +1 -1
  264. package/src/serve/hub-app/activity-view.tsx +56 -32
  265. package/src/serve/hub-app/activity.css +7 -1
  266. package/src/serve/hub-app/asks-page.tsx +48 -0
  267. package/src/serve/hub-app/asks-st.ts +25 -0
  268. package/src/serve/hub-app/clock-svc.ts +1 -2
  269. package/src/serve/hub-app/col-card.tsx +64 -13
  270. package/src/serve/hub-app/col-list-page.tsx +122 -0
  271. package/src/serve/hub-app/col-list-st.ts +103 -0
  272. package/src/serve/hub-app/col-tables-view.tsx +10 -41
  273. package/src/serve/hub-app/col-tables.ts +76 -8
  274. package/src/serve/hub-app/cols-svc.ts +70 -16
  275. package/src/serve/hub-app/database-st.ts +260 -0
  276. package/src/serve/hub-app/database-view.tsx +289 -0
  277. package/src/serve/hub-app/database.css +32 -0
  278. package/src/serve/hub-app/entry-bar.css +14 -0
  279. package/src/serve/hub-app/entry-bar.tsx +33 -0
  280. package/src/serve/hub-app/entry-pick.ts +31 -0
  281. package/src/serve/hub-app/floating.tsx +1 -0
  282. package/src/serve/hub-app/hash-route.ts +11 -1
  283. package/src/serve/hub-app/header-bar.tsx +14 -18
  284. package/src/serve/hub-app/home-st.ts +89 -9
  285. package/src/serve/hub-app/home-strip.css +5 -19
  286. package/src/serve/hub-app/home-strip.tsx +58 -92
  287. package/src/serve/hub-app/home.html +7 -0
  288. package/src/serve/hub-app/hub-app.tsx +31 -142
  289. package/src/serve/hub-app/hub-types.ts +3 -1
  290. package/src/serve/hub-app/hub.css +109 -23
  291. package/src/serve/hub-app/icons.tsx +18 -1
  292. package/src/serve/hub-app/identities-st.ts +56 -6
  293. package/src/serve/hub-app/identities-view.tsx +100 -58
  294. package/src/serve/hub-app/identities.css +17 -15
  295. package/src/serve/hub-app/identity-address.ts +5 -0
  296. package/src/serve/hub-app/inbox-st.ts +41 -24
  297. package/src/serve/hub-app/inbox-view.tsx +37 -41
  298. package/src/serve/hub-app/inbox.css +2 -5
  299. package/src/serve/hub-app/index.html +7 -0
  300. package/src/serve/hub-app/kept-cols.tsx +7 -0
  301. package/src/serve/hub-app/keys.ts +28 -15
  302. package/src/serve/hub-app/later.tsx +26 -0
  303. package/src/serve/hub-app/list-filter.tsx +14 -0
  304. package/src/serve/hub-app/list-walk.ts +72 -3
  305. package/src/serve/hub-app/machines-st.ts +251 -0
  306. package/src/serve/hub-app/machines-view.tsx +224 -0
  307. package/src/serve/hub-app/machines.css +76 -0
  308. package/src/serve/hub-app/md-copy.tsx +79 -0
  309. package/src/serve/hub-app/media-view.tsx +2 -0
  310. package/src/serve/hub-app/messages/messages-page.tsx +79 -7
  311. package/src/serve/hub-app/messages/messages-st.ts +99 -3
  312. package/src/serve/hub-app/messages.css +14 -0
  313. package/src/serve/hub-app/page-keys.ts +175 -0
  314. package/src/serve/hub-app/pages-frames.tsx +11 -3
  315. package/src/serve/hub-app/palette-st.ts +58 -11
  316. package/src/serve/hub-app/palette-view.tsx +3 -1
  317. package/src/serve/hub-app/project-list.css +54 -8
  318. package/src/serve/hub-app/project-list.tsx +128 -59
  319. package/src/serve/hub-app/projects-svc.ts +78 -7
  320. package/src/serve/hub-app/reader-chips.tsx +13 -0
  321. package/src/serve/hub-app/readme-view.tsx +2 -3
  322. package/src/serve/hub-app/readme.css +27 -5
  323. package/src/serve/hub-app/reflections-page.tsx +42 -0
  324. package/src/serve/hub-app/reflections-st.ts +17 -0
  325. package/src/serve/hub-app/releases/releases-page.tsx +25 -2
  326. package/src/serve/hub-app/releases/releases-st.ts +1 -1
  327. package/src/serve/hub-app/repo-sections.ts +9 -5
  328. package/src/serve/hub-app/repo-st.ts +35 -8
  329. package/src/serve/hub-app/review/draft-card.tsx +163 -0
  330. package/src/serve/hub-app/review/kit.tsx +50 -7
  331. package/src/serve/hub-app/review/note-place.ts +1 -1
  332. package/src/serve/hub-app/review/review-board.tsx +2 -2
  333. package/src/serve/hub-app/review/review-cells.tsx +145 -65
  334. package/src/serve/hub-app/review/review-kit.ts +27 -1
  335. package/src/serve/hub-app/review/review-list.tsx +68 -30
  336. package/src/serve/hub-app/review/review-page.tsx +7 -8
  337. package/src/serve/hub-app/review/review-st.ts +111 -24
  338. package/src/serve/hub-app/review/review-thread.tsx +49 -19
  339. package/src/serve/hub-app/review/review-views.tsx +475 -144
  340. package/src/serve/hub-app/review/thread-control-st.ts +115 -0
  341. package/src/serve/hub-app/review/thread-control.tsx +74 -0
  342. package/src/serve/hub-app/review/thread-st.ts +73 -26
  343. package/src/serve/hub-app/review/trailer-card.tsx +1 -1
  344. package/src/serve/hub-app/review/trailer-page.tsx +37 -16
  345. package/src/serve/hub-app/review/trailer-st.ts +41 -7
  346. package/src/serve/hub-app/review.css +267 -61
  347. package/src/serve/hub-app/side-lists.ts +72 -0
  348. package/src/serve/hub-app/sidebar.tsx +6 -3
  349. package/src/serve/hub-app/site/site-part.tsx +2 -8
  350. package/src/serve/hub-app/site/site-st.ts +4 -4
  351. package/src/serve/hub-app/social/comms-page.tsx +20 -5
  352. package/src/serve/hub-app/social/kit.tsx +30 -4
  353. package/src/serve/hub-app/social/post-card.tsx +139 -49
  354. package/src/serve/hub-app/social/serial-writes.ts +13 -0
  355. package/src/serve/hub-app/social/social-model.ts +11 -0
  356. package/src/serve/hub-app/social/social-page.tsx +94 -35
  357. package/src/serve/hub-app/social/social-st.ts +120 -36
  358. package/src/serve/hub-app/social/stage-popup.tsx +1 -1
  359. package/src/serve/hub-app/social/stage-st.ts +1 -1
  360. package/src/serve/hub-app/social/step-layout.ts +1 -1
  361. package/src/serve/hub-app/social.css +3 -0
  362. package/src/serve/hub-app/space-st.ts +209 -0
  363. package/src/serve/hub-app/space-view.tsx +196 -0
  364. package/src/serve/hub-app/space.css +27 -0
  365. package/src/serve/hub-app/stores/stores-page.tsx +91 -23
  366. package/src/serve/hub-app/stores/stores-st.ts +44 -19
  367. package/src/serve/hub-app/stores.css +6 -1
  368. package/src/serve/hub-app/theme-st.ts +22 -9
  369. package/src/serve/hub-app/time-charts.tsx +291 -0
  370. package/src/serve/hub-app/time-pages.tsx +749 -0
  371. package/src/serve/hub-app/time-st.ts +162 -0
  372. package/src/serve/hub-app/time-view.tsx +76 -0
  373. package/src/serve/hub-app/time.css +138 -0
  374. package/src/serve/hub-app/tree-build.ts +52 -42
  375. package/src/serve/hub-app/tree-row.tsx +4 -4
  376. package/src/serve/hub-app/tree-svc.ts +18 -9
  377. package/src/serve/hub-app/urls-svc.ts +154 -0
  378. package/src/serve/hub-app/urls-view.tsx +117 -0
  379. package/src/serve/hub-app/urls.css +30 -0
  380. package/src/serve/hub-app/vault-st.ts +127 -0
  381. package/src/serve/hub-app/vault-view.tsx +154 -0
  382. package/src/serve/hub-app/vault.css +38 -0
  383. package/src/serve/hub-app/veille/veille-st.ts +12 -10
  384. package/src/serve/hub-app/waiting-svc.ts +29 -0
  385. package/src/serve/hub-app/wikis-view.tsx +2 -2
  386. package/src/serve/hub-runtime.ts +15 -2
  387. package/src/serve/project-gutter-route.ts +27 -14
  388. package/src/serve/project-gutter.ts +25 -12
  389. package/src/serve/same-origin.ts +10 -0
  390. package/src/serve/serve-hub.ts +13 -4
  391. package/src/shipkit-files.ts +16 -2
  392. package/src/shipkit.ts +1 -1
  393. package/src/shot/shooter.ts +616 -420
  394. package/src/shot/shot-ask.ts +246 -155
  395. package/src/site/desk.ts +2 -2
  396. package/src/smoke/run-smoke.ts +3 -2
  397. package/src/social/cover.ts +202 -0
  398. package/src/social/discord-layout.ts +37 -13
  399. package/src/social/drafts.ts +3 -0
  400. package/src/social/load.ts +23 -2
  401. package/src/social/media-kind.ts +2 -1
  402. package/src/social/publish/discord.ts +5 -2
  403. package/src/social/publish/secret.ts +2 -2
  404. package/src/social/release-stage.ts +28 -13
  405. package/src/social/routes.ts +26 -1
  406. package/src/social/stage.ts +1 -1
  407. package/src/social/stats.ts +12 -9
  408. package/src/social/strip.ts +4 -1
  409. package/src/social/thumbnail.ts +255 -0
  410. package/src/stores/collection.ts +15 -11
  411. package/src/stores/desk.ts +236 -42
  412. package/src/stores/model.ts +72 -6
  413. package/src/stores/routes.ts +37 -12
  414. package/src/stores/unit.ts +14 -8
  415. package/src/suite/judge-suites.ts +113 -16
  416. package/src/suite/select.ts +45 -3
  417. package/src/suite/suite-cli.ts +81 -34
  418. package/src/trailer/bed.ts +1 -1
  419. package/src/trailer/build.ts +134 -21
  420. package/src/trailer/ffmpeg.ts +7 -0
  421. package/src/trailer/fonts.ts +3 -2
  422. package/src/trailer/grammar.ts +201 -2
  423. package/src/trailer/graph.ts +42 -5
  424. package/src/trailer/look.ts +21 -0
  425. package/src/trailer/mock.ts +154 -0
  426. package/src/trailer/passage.ts +65 -26
  427. package/src/trailer/score/heard.ts +89 -0
  428. package/src/trailer/score/sound.ts +14 -8
  429. package/src/trailer/sound/run.ts +16 -6
  430. package/src/trailer/stitch.ts +26 -5
  431. package/src/trailer/titles.ts +82 -19
  432. package/src/trailer/versions.ts +1 -3
  433. package/src/trailer/vertical.ts +3 -1
  434. package/src/urls/frame.ts +195 -0
  435. package/src/urls/routes.ts +43 -0
  436. package/src/urls/rows.ts +171 -0
  437. package/src/urls/unit.ts +73 -0
  438. package/src/vault/house-keys.ts +42 -0
  439. package/src/vault/layout.ts +50 -0
  440. package/src/vault/policy.ts +165 -0
  441. package/src/vault/vault-audit.ts +276 -0
  442. package/src/vault/vault-client.ts +40 -0
  443. package/src/vault/vault-config.ts +159 -0
  444. package/src/vault/vault-destroy.ts +78 -0
  445. package/src/vault/vault-handover.ts +305 -0
  446. package/src/vault/vault-http.ts +352 -0
  447. package/src/vault/vault-import.ts +208 -0
  448. package/src/vault/vault-init.ts +328 -0
  449. package/src/vault/vault-minter.ts +271 -0
  450. package/src/vault/vault-restore.ts +333 -0
  451. package/src/vault/vault-serve.ts +342 -0
  452. package/src/vault/vault-snapshot.ts +281 -0
  453. package/src/veille/asks.ts +1 -1
  454. package/src/veille/desk.ts +2 -2
  455. package/src/wiki/run-wiki.ts +2 -1
  456. package/src/wiki/scan-md.ts +42 -2
@@ -1,9 +1,9 @@
1
- // sk review: an agent shows the owner something as one card of the one store and reads his answer; a dispatcher routes
2
- // what he, a player or a rule raised, a worker claims and closes it (review/store.ts, wiki tools/shipkit/review.md).
1
+ // sk thread: an agent shows the owner something as one card of the one store and reads his answer; a dispatcher routes
2
+ // what he, a player or a rule raised, a worker claims and closes it (review/store.ts, wiki tools/shipkit/threads.md).
3
3
  // Every module loads inside execute: the cli registers this file on every `sk` call
4
4
  import { Command, Option } from 'clipanion'
5
5
 
6
- const DETAILS = `the one feedback store, .shipkit/review/<id>/: one subject is one card (other angles are views of it, a follow up --supersedes it), he answers it in the hub's review entry (approved, ok with a fix, rejected, archived, rectangles, reactions per view), you read his answer with inbox or watch. What he, a player or a rule raises is an item of the same store: a dispatcher routes it to a topic, a worker claims it and closes it. The repo's review unit names its kinds, topics, sources and rules. SK_AGENT names your lane. Page: wiki tools/shipkit/review.md`
6
+ const DETAILS = `threads, the one exchange with the owner: one thread per subject for its whole life (wiki tools/shipkit/threads.md). The store: .shipkit/review/<id>/ of each repo, or with the machine switch cards-in-db the rows of the daemon's database and their media in its spool (sk thread move). One subject is one card (other angles are views of it, a follow up --supersedes it), he answers it in the hub's review entry (approved, ok with a fix, rejected, archived, rectangles, reactions per view), you read his answer with inbox or watch. What he, a player or a rule raises is an item of the same store: a dispatcher routes it to a topic, a worker claims it and closes it. The repo's review unit names its kinds, topics, sources and rules. SK_AGENT names your lane. Page: wiki tools/shipkit/threads.md`
7
7
 
8
8
  type Ctx = { stdout: NodeJS.WritableStream; stderr: NodeJS.WritableStream }
9
9
  type Unit = import('../review/unit.ts').ReviewUnit
@@ -33,6 +33,9 @@ async function run(context: Ctx, body: (h: Here) => Promise<number> | number, o:
33
33
  const out = (l: string): void => void context.stdout.write(`${l}\n`)
34
34
  const err = (l: string): void => void context.stderr.write(`${l}\n`)
35
35
  try {
36
+ // the older name still works: it says the new one where a person reads it, never in a hook's or a script's output
37
+ const argv = process.argv.slice(2)
38
+ if (argv[0] === 'review' && !argv.includes('--hook') && !argv.includes('--json')) err(`sk review is now sk thread: sk thread ${argv.slice(1).map((a) => (/^[\w./=,@:+#-]+$/.test(a) ? a : JSON.stringify(a))).join(' ')}`)
36
39
  const root = await reviewRoot(process.cwd())
37
40
  if (root == null) throw new Error(`${process.cwd()} is in no shipkit repo (no repo.config.ts at its git root), so no hub would ever show what is stored here: run it from inside the repo the card is for`)
38
41
  if (o.unit === false) {
@@ -45,7 +48,9 @@ async function run(context: Ctx, body: (h: Here) => Promise<number> | number, o:
45
48
  return await body({ dir, unit, say: { spec: specOf(dir), more: (x) => factLines(unit, x) }, out, err })
46
49
  } catch (e) {
47
50
  err(`FAIL: review: ${e instanceof Error ? e.message : String(e)}`)
48
- return 1
51
+ // a walk of the cards' database runs: run it again once it ends
52
+ const { isStoreRefused, WAIT_EXIT } = await import('../core/machine-db.ts')
53
+ return isStoreRefused(e) && e.wait ? WAIT_EXIT : 1
49
54
  }
50
55
  }
51
56
 
@@ -60,9 +65,17 @@ function actor(as: string | undefined, need: boolean, verb: string): string {
60
65
  return 'agent'
61
66
  }
62
67
 
63
- /** an item id or a player report's ref (`live#3`) to its item id */
68
+ /** an item id, a player report's ref (`live#3`), or an address (`trailer:comfy-ts/main`, the newest version of the
69
+ * thread that owns it, or the one above it) to its item id */
64
70
  async function idOf(dir: string, ref: string): Promise<string> {
65
- const { itemOfRef } = await import('../review/store.ts')
71
+ const { itemOfRef, readAll, specOf } = await import('../review/store.ts')
72
+ const { ADDRESS_RE, ID_RE } = await import('../review/model.ts')
73
+ if (!ID_RE.test(ref) && ADDRESS_RE.test(ref)) {
74
+ const { threadOfAddress } = await import('../review/threads.ts')
75
+ const t = threadOfAddress(ref, readAll(dir).items, specOf(dir), { up: true })
76
+ if (!t) throw new Error(`no thread owns ${ref}: sk thread post ${ref} --title "…" --what "…" <media> starts it`)
77
+ return t.head.item.id
78
+ }
66
79
  const x = itemOfRef(dir, ref)
67
80
  if (!x) throw new Error(`no item ${ref}`)
68
81
  return x.item.id
@@ -135,7 +148,7 @@ export function takeViews(args: readonly string[]): { views: ViewInput[]; rest:
135
148
  return { views, rest }
136
149
  }
137
150
 
138
- const ADD_VIEW_USAGE = 'add-view <id> "<label>" <a.png> [<b.png>] | --image <a.png> | --before <a.png> --after <b.png> | --video <clip> | --audio <sound> | --gallery <a.png> … [--label "<label>"] [--note "<text>"]'
151
+ const ADD_VIEW_USAGE = 'add-view <id> "<label>" <a.png> [<b.png>] | --image <a.png> | --before <a.png> --after <b.png> | --video <clip> | --audio <sound> | --gallery <a.png> … [--label "<label>"] [--note "<text>"] [--keep]'
139
152
  const MEDIA_FILE = /\.(png|jpe?g|webp|gif|mp4|webm|mov|wav|mp3|flac|ogg|opus|m4a)$/i
140
153
  const quoted = (a: string): string => (/^[\w./=,@:+-]+$/.test(a) ? a : `"${a.replace(/"/g, '\\"')}"`)
141
154
 
@@ -172,7 +185,7 @@ export async function addViewArgs(args: readonly string[], own: readonly string[
172
185
  if (label === undefined && gallery?.[0] !== undefined && !MEDIA_FILE.test(gallery[0]) && !gallery[0].includes('=')) label = gallery.shift()
173
186
  const given = [files.length > 0 ? 'files' : '', one.image ? '--image' : '', one.video ? '--video' : '', one.audio ? '--audio' : '', one.before || one.after ? '--before --after' : '', gallery ? '--gallery' : ''].filter((x) => x !== '')
174
187
  if (given.length !== 1) throw new Error(`${given.length === 0 ? 'no media' : `one media a view, not ${given.join(' and ')}`}; ${ADD_VIEW_USAGE}`)
175
- if (!label?.trim()) throw new Error(`the view needs its label: sk review ${['add-view', id, '"<label>"', ...args.filter((a) => a !== id).map(quoted)].join(' ')}`)
188
+ if (!label?.trim()) throw new Error(`the view needs its label: sk thread ${['add-view', id, '"<label>"', ...args.filter((a) => a !== id).map(quoted)].join(' ')}`)
176
189
  if ((one.before === undefined) !== (one.after === undefined)) throw new Error(`--before and --after go together; ${ADD_VIEW_USAGE}`)
177
190
  if (gallery?.length === 0) throw new Error(`--gallery needs its images; ${ADD_VIEW_USAGE}`)
178
191
  const view: ViewInput = one.image
@@ -207,7 +220,7 @@ function flagsOf(args: readonly string[], values: readonly string[], repeat: rea
207
220
  on.add(name)
208
221
  continue
209
222
  }
210
- if (!values.includes(name) && !repeat.includes(name)) throw new Error(`${a}: no such flag (sk review add --help)`)
223
+ if (!values.includes(name) && !repeat.includes(name)) throw new Error(`${a}: no such flag (sk thread add --help)`)
211
224
  const v = args[i + 1]
212
225
  if (v === undefined) throw new Error(`${a}: needs a value`)
213
226
  i++
@@ -230,21 +243,25 @@ const ADD_FLAGS = `flags:
230
243
  --label "<label>" the first view's label
231
244
  --view "<label>" <a.png> [<b.png>] another view of the same subject (repeat it); --note "<text>" right after it: a line on that view
232
245
  --choice every view is an option he scores and picks one of (two --view or more)
233
- --pick <view> with --choice: the option you suggest, by its letter (B) or its label; the hub pills it « my pick » (later: sk review pick <id> <view>)
246
+ --pick <view> with --choice: the option you suggest, by its letter (B) or its label; the hub pills it « my pick » (later: sk thread pick <id> <view>)
234
247
  --gallery "<label>" <a.png> … a grid he rates tile by tile (stars, OK, fix or no, a word), alone or beside other views; a tile is "[<row>/]<label>=[<before>,]<after>": a redraw carries its before, a row holds one asset's variants
235
248
  --trailer <cut.trailer> a trailer cut, played in the card by the trailer entry's player, never a compiled clip; his notes land on its shots
236
249
  --version v<n> with --trailer: a kept version of that cut, else the cut's own render
237
250
  --before v<m> | <cut> with --trailer: the render he switches to on the same shot
238
251
  --shots <a,b> with --trailer: the shots the change touched (else, with --before, the shots whose block differs)
239
- --topic <topic> what part of the project it is about (sk review topics)
252
+ --draft <slug> a post draft of .shipkit/social/drafts/ (its folder, its topic or its path), shown itself in the card, read live: a block a place, each with its own OK, fix or no and his word; no image is made
253
+ --topic <topic> what part of the project it is about (sk thread topics)
240
254
  --subject <kind> what is judged (default shot; the repo's unit names its kinds)
241
255
  --commit <sha> the commit it shows
242
256
  --lane <id> the lane that made it; else SK_AGENT
243
- --wip "<what is still wrong>" a card sent in work: « in progress », no verdict asked; each step after: sk review update <id> <broken|better|fixed> "<line>" <file>
244
- --supersedes <id> the card it follows up, after his answer
257
+ --wip "<what is still wrong>" a card sent in work: « in progress », no verdict asked; each step after: sk thread update <id> <broken|better|fixed> "<line>" <file>
258
+ --on <address> the version's own address (page:review/lightbox, trailer:<name>/<cut>): it goes into the thread that owns it, one thread per address; a trailer or a draft names its own
259
+ --about <address> another object it is about, a link that finds it (repeat it); never its thread
260
+ --supersedes <id> the version it follows; with an address the tool links it, only a wrong link is refused
245
261
  --answers <id | live#3> the item it answers (a note he raised, a player's report), one thread (repeat it)
246
262
  --keeps "<what stays>" with --supersedes on an approved look: what of it stays
247
- --new --why "<reason>" a new card beside an active one of the same subject`
263
+ --new --why "<reason>" a new card beside an active one of the same subject
264
+ --keep every picture as given; otherwise a png lands as a lossless webp, its pixels checked exact, and the card keeps that webp alone (a jpeg always lands as given)`
248
265
 
249
266
  /** the help of add or add-view, then the flags this repo's review unit adds (any kind's, then each kind's under
250
267
  * `--subject <kind>`); a repo with no unit, or one that does not load, says so on one line */
@@ -290,20 +307,31 @@ export async function trailerOfFlags(o: Record<string, string>, others: boolean)
290
307
  }
291
308
  }
292
309
 
310
+ /** --draft as a card: the post draft its slug names, pinned by the hashes of its head and of each message; null without
311
+ * --draft. A draft that does not load clean is refused in the loader's words */
312
+ export async function draftOfFlags(o: Record<string, string>, others: boolean, cwd: string = process.cwd()): Promise<import('../review/model.ts').DraftCard | null> {
313
+ if (o.draft === undefined) return null
314
+ const clash = ['image', 'video', 'audio', 'before', 'after', 'label', 'live', 'trailer'].filter((k) => o[k] !== undefined)
315
+ if (clash.length > 0 || others) throw new Error(`--draft: the card shows the draft itself; no ${clash.length > 0 ? clash.map((k) => `--${k}`).join(', ') : '--view, --gallery or --choice'} beside it`)
316
+ const [{ findRepoRoot }, { openDesk }, { draftCardOf }] = await Promise.all([import('../ts/config.ts'), import('../social/open.ts'), import('../review/draft-card.ts')])
317
+ return draftCardOf((await openDesk(findRepoRoot(cwd))).desk, o.draft, cwd).card
318
+ }
319
+
293
320
  export class ReviewAddCommand extends Command {
294
321
  static override paths = [['review', 'add']]
295
322
  static essential = {}
296
323
  static override usage = Command.Usage({
297
324
  category: 'Review',
298
- description: 'show the owner a change as one card he answers in the hub: an image, a clip, a pair, views',
325
+ description: 'a version he answers in the hub: an image, a clip, a pair, views; into the thread of its subject',
299
326
  details: `${DETAILS}\n\n${ADD_FLAGS}`,
300
327
  examples: [
301
- ['one image', 'sk review add --title "the new menu" --what "the menu, bigger" --image shots/menu.png'],
302
- ['a before and after', 'sk review add --title "lamps lit" --what "..." --before a.png --after b.png'],
303
- ['a second version after his answer', 'sk review add --title "lamps lit" --what "..." --image c.png --supersedes <id>'],
304
- ['a pick among three voices, yours on the second', 'sk review add --choice --pick B --title "the narrator" --what "..." --view "voice 0" a.flac --note "low, breathy" --view "voice 1" b.flac --view "voice 2" c.flac'],
305
- ['icons he rates one by one', 'sk review add --title "buff icons" --what "..." --gallery "icons" vitality=a.png haste=b.png greed=c.png'],
306
- ['a trailer cut against its last kept version', 'sk review add --trailer trailer/demo/main.trailer --version v4 --before v3 --title "the drop, recut" --what "..."'],
328
+ ['one image', 'sk thread add --title "the new menu" --what "the menu, bigger" --image shots/menu.png'],
329
+ ['a before and after', 'sk thread add --title "lamps lit" --what "..." --before a.png --after b.png'],
330
+ ['a second version after his answer', 'sk thread add --title "lamps lit" --what "..." --image c.png --supersedes <id>'],
331
+ ['a pick among three voices, yours on the second', 'sk thread add --choice --pick B --title "the narrator" --what "..." --view "voice 0" a.flac --note "low, breathy" --view "voice 1" b.flac --view "voice 2" c.flac'],
332
+ ['icons he rates one by one', 'sk thread add --title "buff icons" --what "..." --gallery "icons" vitality=a.png haste=b.png greed=c.png'],
333
+ ['a trailer cut against its last kept version', 'sk thread add --trailer trailer/demo/main.trailer --version v4 --before v3 --title "the drop, recut" --what "..."'],
334
+ ['a post draft, each place answered on its own', 'sk thread add --draft 20261119-174922-trailer --title "the trailer post" --what "..."'],
307
335
  ],
308
336
  })
309
337
  args = Option.Proxy()
@@ -322,18 +350,19 @@ export class ReviewAddCommand extends Command {
322
350
  const kindName = rest[rest.indexOf('--subject') + 1]
323
351
  const kind = rest.includes('--subject') && kindName ? h.unit?.kinds?.[kindName] : undefined
324
352
  const own = [...Object.keys(kind?.flags ?? {}), ...Object.keys(h.unit?.flags ?? {})]
325
- const f = flagsOf(rest, ['title', 'what', 'post', 'changelog', 'rating', 'image', 'video', 'audio', 'before', 'after', 'label', 'topic', 'subject', 'commit', 'lane', 'supersedes', 'keeps', 'why', 'live', 'trailer', 'version', 'shots', 'pick'], ['answers', ...own], ['new', 'wip', 'choice'])
353
+ const f = flagsOf(rest, ['title', 'what', 'post', 'changelog', 'rating', 'image', 'video', 'audio', 'before', 'after', 'label', 'topic', 'subject', 'commit', 'lane', 'supersedes', 'keeps', 'why', 'live', 'trailer', 'version', 'shots', 'pick', 'draft', 'on'], ['answers', 'about', ...own], ['new', 'wip', 'choice', 'keep'])
326
354
  const o = f.one
327
355
  // a lone word is the title, as `sk ask <title>` takes it; a media file never is
328
356
  const [lone, ...more] = f.positionals
329
357
  if (lone !== undefined && more.length === 0 && o.title === undefined && !MEDIA_FILE.test(lone)) o.title = lone
330
- else if (lone !== undefined) throw new Error(`unexpected ${f.positionals.map(quoted).join(' ')}: the title is --title "<title>", the subject --image <a.png> (sk review add --help)`)
358
+ else if (lone !== undefined) throw new Error(`unexpected ${f.positionals.map(quoted).join(' ')}: the title is --title "<title>", the subject --image <a.png> (sk thread add --help)`)
331
359
  const trailer = await trailerOfFlags(o, views.length > 0 || f.on.has('wip') || f.on.has('choice'))
360
+ const draft = await draftOfFlags(o, views.length > 0 || f.on.has('choice'))
332
361
  const repoFlags = Object.fromEntries(own.flatMap((k) => (f.many[k] ? [[k, f.many[k]]] : [])))
333
362
  const parsed = kind?.parse ? kind.parse(Object.fromEntries(Object.keys(kind.flags ?? {}).map((k) => [k, f.many[k] ?? []]))) : null
334
363
  if (wipLine !== undefined && o.live !== undefined) throw new Error('--wip "<line>" sends a card in work; --wip --live <name> a draft on a live shot: one of the two')
335
364
  if (wipLine === undefined && f.on.has('wip') !== (o.live !== undefined))
336
- throw new Error('--wip "<what is still wrong>" sends a card in work (sk review update as it moves); --wip --live <name> a draft on a live shot')
365
+ throw new Error('--wip "<what is still wrong>" sends a card in work (sk thread update as it moves); --wip --live <name> a draft on a live shot')
337
366
  let wipViews: ViewInput[] = []
338
367
  if (o.live !== undefined) {
339
368
  if (!h.unit?.live) throw new Error("--live: the repo's review unit declares no live shots (live: { frames })")
@@ -375,9 +404,10 @@ export class ReviewAddCommand extends Command {
375
404
  what: o.what ?? '',
376
405
  ...(o.post ? { post: o.post } : {}),
377
406
  ...(changelog ? { changelog } : {}),
378
- ...(parsed ? { subject: parsed.subject } : o.subject ? { subject: { kind: o.subject } } : trailer ? { subject: { kind: 'trailer' } } : {}),
407
+ ...(parsed ? { subject: parsed.subject } : o.subject ? { subject: { kind: o.subject } } : trailer ? { subject: { kind: 'trailer' } } : draft ? { subject: { kind: 'draft', slug: draft.slug } } : {}),
379
408
  ...(topic ? { topic } : {}),
380
409
  ...(trailer ? { image: trailer.image, trailer: trailer.card } : {}),
410
+ ...(draft ? { draft } : {}),
381
411
  ...(o.image ? { image: o.image } : {}),
382
412
  ...(o.video ? { video: o.video } : {}),
383
413
  ...(o.audio ? { audio: o.audio } : {}),
@@ -390,24 +420,54 @@ export class ReviewAddCommand extends Command {
390
420
  ...(o.keeps ? { keeps: o.keeps } : {}),
391
421
  ...(o.why ? { why: o.why } : {}),
392
422
  ...(answers.length > 0 ? { answers } : {}),
423
+ ...(o.on ? { on: o.on } : {}),
424
+ ...((f.many.about ?? []).length > 0 ? { about: f.many.about } : {}),
393
425
  ...(f.on.has('new') ? { fresh: true } : {}),
394
426
  ...(f.on.has('choice') ? { choice: true } : {}),
427
+ ...(f.on.has('keep') ? { keep: true } : {}),
395
428
  ...(o.pick !== undefined ? { agentPick: o.pick } : {}),
396
429
  ...(o.live !== undefined ? { image: wipViews[0]?.image ?? '', views: wipViews.slice(1), wip: { live: o.live } } : { views }),
397
430
  }
398
431
  if (h.unit?.add) input = await h.unit.add(input, repoFlags)
399
432
  const item = await addItem(h.dir, input).finally(() => trailer?.drop())
400
433
  h.out(item.id)
434
+ // on stderr: a script reads the id alone on stdout
435
+ if (item.supersedes !== undefined && o.supersedes === undefined) h.err(`into its thread: the next version after ${item.supersedes}, its own address one thread`)
436
+ else if ((item.answers ?? []).some((a) => !answers.includes(a))) h.err(`into its thread: it answers the notes ${(item.answers ?? []).join(', ')}`)
401
437
  if (wipLine !== undefined) {
402
438
  const who = item.origin.by === 'agent' ? (item.origin.lane ?? agentName()) : agentName()
403
439
  await postUpdate(h.dir, item.id, { who, state: 'broken', text: wipLine })
404
- h.err(`in progress: he sees it, it waits on no verdict; post each step with sk review update ${item.id} <broken|better|fixed> "<line>" <file>`)
440
+ h.err(`in progress: he sees it, it waits on no verdict; post each step with sk thread update ${item.id} <broken|better|fixed> "<line>" <file>`)
405
441
  }
406
442
  // on stderr: a script reads the id alone on stdout
407
443
  for (const line of await (await import('../review/previews.ts')).playCopies(h.dir, item)) h.err(line)
408
444
  if (item.trailer) h.out(`trailer card: ${item.trailer.trailer}/${item.trailer.after.cut}${item.trailer.before ? ` against ${item.trailer.before.cut}` : ''}${item.trailer.shots.length > 0 ? `, shots ${item.trailer.shots.join(', ')}` : ''}`)
445
+ // a cut shown on a card is a version from then on: the next edit of its file makes the one after it
446
+ if (item.trailer && o.trailer !== undefined && o.version === undefined) {
447
+ try {
448
+ const [b, { keepShown, thumbnailKept, versionVideo }, { findRepoRoot }] = await Promise.all([import('../trailer/build.ts'), import('../trailer/passage.ts'), import('../ts/config.ts')])
449
+ const root = findRepoRoot(process.cwd())
450
+ const l = await b.load(b.trailerFile(o.trailer, root, process.cwd()), root)
451
+ if ((await import('node:fs')).existsSync(b.mockMark(l))) h.err('the cut this card shows is a MOCK (sk trailer --mock built it last): its --what must say so; for the filmed cut, sk trailer first')
452
+ // a version is a video a post may use: a cut that may not render (no thumbnail word) keeps none
453
+ if (l.errors.length > 0) throw new Error(`${l.errors[0]!.message} (line ${l.errors[0]!.line})`)
454
+ const lines: string[] = []
455
+ const v = keepShown(l, (line) => lines.push(line), process.cwd())
456
+ // what the keep says is left by hand (its index row, the commit, the tag) is said here too
457
+ for (const line of lines) h.err(line)
458
+ h.err(v ? `kept as ${v}: the trailer page lists it, and the file now makes the version after it` : 'this render is kept already: no new version')
459
+ const video = v ? versionVideo(l.dir, v) : null
460
+ if (video)
461
+ await thumbnailKept(l, video, (line) => h.err(line), process.cwd()).catch((e: unknown) =>
462
+ h.err(`WARN ${v} is kept, its thumbnail is not: ${(e as Error).message}`),
463
+ )
464
+ } catch (e) {
465
+ h.err(`WARN the card is sent, the cut was not kept as a version: ${(e as Error).message}`)
466
+ }
467
+ }
468
+ if (item.draft) h.out(`draft card: ${item.draft.slug}, ${item.draft.posts.length} place${item.draft.posts.length > 1 ? 's' : ''}: ${item.draft.posts.map((p) => p.name).join(', ')}`)
409
469
  if (item.origin.by === 'agent' && !item.origin.lane) h.err('no lane on the card: pass --lane <id> (or SK_AGENT), so the hub colours it')
410
- if (item.choice && item.agentPick === undefined) h.err(`a choice with no pick of yours: every question carries one, sk review pick ${item.id} <view> (or --pick on add)`)
470
+ if (item.choice && item.agentPick === undefined) h.err(`a choice with no pick of yours: every question carries one, sk thread pick ${item.id} <view> (or --pick on add)`)
411
471
  const { unheardLine } = await import('../review/model.ts')
412
472
  const { liveWatchers } = await import('../review/watchers.ts')
413
473
  const unheard = unheardLine(item, liveWatchers(h.dir))
@@ -422,11 +482,11 @@ export class ReviewAddViewCommand extends Command {
422
482
  static essential = {}
423
483
  static override usage = Command.Usage({
424
484
  category: 'Review',
425
- description: 'another angle on a card he has not answered yet: an image, a pair, a clip or a gallery',
485
+ description: 'another angle on a version he has not answered yet: an image, a pair, a clip or a gallery',
426
486
  details: `${DETAILS}\n\nsk ${ADD_VIEW_USAGE}. The view flags are add's; the id may be its moment alone (<YYYYMMDD-HHMMSS>).`,
427
487
  examples: [
428
- ['a view from above', 'sk review add-view <id> "from above" top.png'],
429
- ['a before and after', 'sk review add-view <id> --label "on a phone" --before a.png --after b.png'],
488
+ ['a view from above', 'sk thread add-view <id> "from above" top.png'],
489
+ ['a before and after', 'sk thread add-view <id> --label "on a phone" --before a.png --after b.png'],
430
490
  ],
431
491
  })
432
492
  args = Option.Proxy()
@@ -437,13 +497,14 @@ export class ReviewAddViewCommand extends Command {
437
497
  }
438
498
  return run(this.context, async (h) => {
439
499
  const { addView } = await import('../review/store.ts')
440
- const a = await addViewArgs(this.args, Object.keys(h.unit?.flags ?? {}))
500
+ const keep = this.args.includes('--keep')
501
+ const a = await addViewArgs(this.args.filter((x) => x !== '--keep'), Object.keys(h.unit?.flags ?? {}))
441
502
  const v = a.view
442
503
  const id = await idOf(h.dir, a.id)
443
504
  const extra = h.unit?.addView ? await h.unit.addView(v, a.repoFlags) : {}
444
- const item = await addView(h.dir, id, v, extra)
445
- const { viewLetter } = await import('../review/model.ts')
446
- h.out(`${id}: view ${viewLetter(item.views.length - 1)} "${v.label}" added`)
505
+ const item = await addView(h.dir, id, v, { ...extra, ...(keep ? { keep: true } : {}) })
506
+ const { viewNo } = await import('../review/model.ts')
507
+ h.out(`${id}: view ${viewNo(item.views.length - 1)} "${v.label}" added`)
447
508
  for (const line of await (await import('../review/previews.ts')).playCopies(h.dir, item, item.views.length - 1)) h.err(line)
448
509
  return 0
449
510
  })
@@ -454,9 +515,9 @@ export class ReviewLsCommand extends Command {
454
515
  static override paths = [['review'], ['review', 'ls']]
455
516
  static override usage = Command.Usage({
456
517
  category: 'Review',
457
- description: "the store's active threads, one line each: status, id, title; `sk review <verb>` runs a unit's verb",
458
- details: `${DETAILS}\n\nsk review [--all] lists; sk review <verb> … runs a verb the repo's review unit declares (verbs: {...}).`,
459
- examples: [['what is open', 'sk review ls'], ['every thread', 'sk review ls --all']],
518
+ description: "the store's active threads, one line each: status, id, title; `sk thread <verb>` runs a unit's verb",
519
+ details: `${DETAILS}\n\nsk thread [--all] lists; sk thread <verb> … runs a verb the repo's review unit declares (verbs: {...}).`,
520
+ examples: [['what is open', 'sk thread ls'], ['every thread', 'sk thread ls --all']],
460
521
  })
461
522
  args = Option.Proxy()
462
523
 
@@ -475,14 +536,14 @@ export class ReviewLsCommand extends Command {
475
536
  const { typoOf } = await import('./family-help.ts')
476
537
  const own = this.cli.definitions().map((d) => d.path.split(' ')).filter((w) => w[1] === 'review' && w.length === 3).map((w) => w[2]!)
477
538
  const close = typoOf(verb, [...own, ...Object.keys(verbs)], 2)
478
- throw new Error(`no verb « ${verb} »: ${close.length > 0 ? `did you mean ${close.map((c) => `sk review ${c}`).join(', ')} ? ` : ''}sk review --help lists sk's own; the repo's unit declares ${Object.keys(verbs).join(', ') || 'none'}`)
539
+ throw new Error(`no verb « ${verb} »: ${close.length > 0 ? `did you mean ${close.map((c) => `sk thread ${c}`).join(', ')} ? ` : ''}sk thread --help lists sk's own; the repo's unit declares ${Object.keys(verbs).join(', ') || 'none'}`)
479
540
  }
480
541
  const { dirname } = await import('node:path')
481
542
  return v.run(rest, { dir: h.dir, root: dirname(dirname(h.dir)), say: h.out, err: h.err })
482
543
  })
483
544
  const every = rest.length === 0 && verb === '--all'
484
545
  if (verb !== undefined && !every) {
485
- this.context.stderr.write(`FAIL: review: unexpected ${this.args.join(' ')} (sk review --help)\n`)
546
+ this.context.stderr.write(`FAIL: review: unexpected ${this.args.join(' ')} (sk thread --help)\n`)
486
547
  return 1
487
548
  }
488
549
  // the listing reads no unit: it stays the fast answer, and the unit's refusals show in inbox and the hub
@@ -510,7 +571,7 @@ export class ReviewShowCommand extends Command {
510
571
  category: 'Review',
511
572
  description: 'one item and its thread: the verdict, rectangles, reactions, the whole conversation',
512
573
  details: `${DETAILS}\n\nTakes an item id or a player report's ref (live#3). --paste prints the short block that hands the card to another agent session (the hub's copy button gives the same).`,
513
- examples: [['hand a card to another session', 'sk review show <id> --paste']],
574
+ examples: [['hand a card to another session', 'sk thread show <id> --paste']],
514
575
  })
515
576
  id = Option.String()
516
577
  paste = Option.Boolean('--paste', false, { description: 'the block another agent session acts on: title, repo, this command, the links' })
@@ -561,18 +622,26 @@ export class ReviewInboxCommand extends Command {
561
622
  category: 'Review',
562
623
  description: 'every answer not marked seen and every open item he raised, frame notes included',
563
624
  details: DETAILS,
564
- examples: [['what waits on you', 'sk review inbox'], ['his notes on trailer frames', 'sk review inbox --subject frame'], ['the cards this session sent', 'sk review inbox --mine']],
625
+ examples: [['what waits on you', 'sk thread inbox'], ['his notes on trailer frames', 'sk thread inbox --subject frame'], ['the cards this session sent', 'sk thread inbox --mine'], ['as a Claude Code hook, on UserPromptSubmit and on Stop', 'sk thread inbox --hook']],
565
626
  })
566
- mine = Option.Boolean('--mine', false, { description: "only this Claude Code session's cards" })
567
- session = Option.String('--session', { description: "only that session's cards" })
627
+ mine = Option.Boolean('--mine', false, { description: "only the threads this Claude Code session holds" })
628
+ session = Option.String('--session', { description: "only the threads that session holds" })
568
629
  subject = Option.String('--subject', { description: 'only items of this subject kind (frame, shot…)' })
569
630
  all = Option.Boolean('--all', false, { description: 'a plain approval too, not only the counted line' })
631
+ hook = Option.Boolean('--hook', false, { description: 'run as a Claude Code hook (UserPromptSubmit, Stop): the hook input on stdin, its json answer on stdout. The unseen answers join a prompt as context, and a turn does not end while one is unseen' })
570
632
 
571
633
  async execute(): Promise<number> {
572
- return run(this.context, async (h) => {
634
+ const { hookAnswer, hookPasses, parseHookInput } = await import('../review/inbox-hook.ts')
635
+ // the hook input is one small json on stdin; a terminal has none
636
+ const input = this.hook ? parseHookInput(process.stdin.isTTY === true ? '' : await new Response(Bun.stdin.stream()).text().catch(() => '')) : null
637
+ if (input != null && hookPasses(input)) return 0
638
+ return run(this.context, async (hh) => {
639
+ // as a hook, the lines of the inbox are the answer's text, never the output
640
+ const unseenLines: string[] = []
641
+ const h = input == null ? hh : { ...hh, out: (l: string) => void unseenLines.push(l) }
573
642
  const { liveWatchers } = await import('../review/watchers.ts')
574
643
  const { readAll } = await import('../review/store.ts')
575
- const { BUILTIN_KINDS, coversCard, moveOf, stateOf, unreadBy, untakenOf, verdictOf } = await import('../review/model.ts')
644
+ const { BUILTIN_KINDS, moveOf, stateOf, unreadBy, untakenOf, verdictOf } = await import('../review/model.ts')
576
645
  const { followedIds, threadOfItem, threadsOf, unseen } = await import('../review/threads.ts')
577
646
  const { detail, threadDetail, untakenLine } = await import('../review/format.ts')
578
647
  const kinds = [...Object.keys(h.say.spec.kinds), ...Object.keys(BUILTIN_KINDS)]
@@ -581,7 +650,9 @@ export class ReviewInboxCommand extends Command {
581
650
  await pull(h)
582
651
  const all = readAll(h.dir)
583
652
  for (const b of all.broken) h.err(`review: FAIL ${b.id}: ${b.error}`)
584
- const of = (x: (typeof all.items)[number]): boolean => coversCard({ session, lane: null }, x) && (this.subject === undefined || x.item.subject.kind === this.subject)
653
+ const { hears, threadByItem } = await import('../review/threads.ts')
654
+ const byItem = threadByItem(threadsOf(all.items, h.say.spec))
655
+ const of = (x: (typeof all.items)[number]): boolean => hears({ session, lane: null }, x, byItem) && (this.subject === undefined || x.item.subject.kind === this.subject)
585
656
  const news = unseen(all.items).filter(of)
586
657
  const followed = followedIds(all.items)
587
658
  // what he or a player raised and nobody closed is the agents' move, read or not
@@ -592,7 +663,9 @@ export class ReviewInboxCommand extends Command {
592
663
  const v = verdictOf(x)
593
664
  return v?.status === 'approved' && !v.seen && !v.comment && v.rects.length === 0 && !v.reactions && v.pick === undefined && unreadBy(x, 'agent').length === 0
594
665
  }
595
- const shown = [...(this.all ? news : news.filter((x) => !plain(x))), ...open]
666
+ // as a hook: a raised item a lane claimed is in that lane's hands until it closes it, so it never blocks a turn
667
+ const inHand = (x: (typeof news)[number]): boolean => input != null && x.item.origin.by !== 'agent' && stateOf(x, followed.has(x.item.id)).state === 'claimed'
668
+ const shown = [...(this.all ? news : news.filter((x) => !plain(x))), ...open].filter((x) => !inHand(x))
596
669
  if (shown.length === 0 && news.length === 0) h.out('review: no unseen feedback or reply')
597
670
  const threads = threadsOf(all.items)
598
671
  const printed = new Set<string>()
@@ -606,8 +679,16 @@ export class ReviewInboxCommand extends Command {
606
679
  const owed = threads.filter((t) => of(t.head) && !printed.has(t.head.item.id) && t.head.item.origin.by === 'agent' && verdictOf(t.head)?.seen === true && stateOf(t.head, false).state === 'claimed')
607
680
  const owedLine = (x: (typeof all.items)[number]): string => {
608
681
  const fix = verdictOf(x)?.status === 'approved-with-fix'
609
- const close = fix ? `sk review done ${x.item.id} "<what changed>"` : `--supersedes ${x.item.id} on its new version`
610
- return ` ${x.item.id} ${fix ? 'ok with a fix' : 'rejected'} "${x.item.title}": ${close}, or sk review wontfix ${x.item.id} --note "<why>"`
682
+ const close = fix ? `sk thread done ${x.item.id} "<what changed>"` : `--supersedes ${x.item.id} on its new version`
683
+ return ` ${x.item.id} ${fix ? 'ok with a fix' : 'rejected'} "${x.item.title}": ${close}, or sk thread wontfix ${x.item.id} --note "<why>"`
684
+ }
685
+ if (input != null) {
686
+ const approvals = news.filter(plain)
687
+ if (approvals.length > 0) h.out(`${approvals.length} plain approval(s), nothing to do: sk thread seen ${approvals.map((x) => x.item.id).join(' ')}`)
688
+ const said = unseenLines.filter((l) => l !== 'review: no unseen feedback or reply').join('\n').trim()
689
+ const answer = hookAnswer(input, said, owed.map((t) => t.head.item.id))
690
+ if (answer != null) hh.out(answer)
691
+ return 0
611
692
  }
612
693
  if (owed.length > 0) h.out(`owed, read and not done:\n${owed.map((t) => owedLine(t.head)).join('\n')}\n`)
613
694
  const watchers = liveWatchers(h.dir)
@@ -617,8 +698,8 @@ export class ReviewInboxCommand extends Command {
617
698
  })
618
699
  if (untaken.length > 0) h.out(`not taken:\n${untaken.join('\n')}\n`)
619
700
  const approvals = this.all ? [] : news.filter(plain)
620
- if (approvals.length > 0) h.out(`review: ${approvals.length} plain approval(s), nothing to do: sk review seen ${approvals.map((x) => x.item.id).join(' ')}`)
621
- if (shown.length > 0) h.out('mark each handled: sk review seen <id>; close a raised one: sk review fixed <id> --note "<what was done>"')
701
+ if (approvals.length > 0) h.out(`review: ${approvals.length} plain approval(s), nothing to do: sk thread seen ${approvals.map((x) => x.item.id).join(' ')}`)
702
+ if (shown.length > 0) h.out('mark each handled: sk thread seen <id>; close a raised one: sk thread fixed <id> --note "<what was done>"')
622
703
  return all.broken.length > 0 ? 1 : 0
623
704
  })
624
705
  }
@@ -631,8 +712,9 @@ const laneOfCaller = (as: string | undefined): string | null => as?.trim() || pr
631
712
  async function answererRefusal(dir: string, id: string, as: string | undefined, op: 'reply' | 'seen'): Promise<string | null> {
632
713
  const { readItem, sessionId } = await import('../review/store.ts')
633
714
  const { notAnswererOf } = await import('../review/model.ts')
715
+ const { liveWatchers } = await import('../review/watchers.ts')
634
716
  const x = readItem(dir, id)
635
- return x === null ? null : notAnswererOf(x, { lane: laneOfCaller(as), session: sessionId() }, op)
717
+ return x === null ? null : notAnswererOf(x, { lane: laneOfCaller(as), session: sessionId() }, op, op === 'seen' ? liveWatchers(dir) : undefined)
636
718
  }
637
719
 
638
720
  export class ReviewSeenCommand extends Command {
@@ -666,7 +748,7 @@ export class ReviewSeenCommand extends Command {
666
748
  export class ReviewReplyCommand extends Command {
667
749
  static override paths = [['review', 'reply']]
668
750
  static essential = { args: '<id> <text>' }
669
- static override usage = Command.Usage({ category: 'Review', description: "your message on a card's thread: what you changed, the answer to his question", details: DETAILS })
751
+ static override usage = Command.Usage({ category: 'Review', description: "your message in a thread: what you changed, the answer to his question", details: DETAILS })
670
752
  id = Option.String()
671
753
  text = Option.String()
672
754
  image = Option.String('--image', { description: 'an image beside the words' })
@@ -690,13 +772,13 @@ export class ReviewUpdateCommand extends Command {
690
772
  static essential = { args: '<id> <state> <text>' }
691
773
  static override usage = Command.Usage({
692
774
  category: 'Review',
693
- description: "where a card's work stands, any time: broken, better or fixed, a line, a file or a pair",
694
- details: `${DETAILS}\n\nsk review update <id> <broken|better|fixed> "<one line>" [<file> | <before> <after>]: the file (an image, a clip or a sound, as it is: no special file) becomes the card's next view, the line and the state go on its thread in time order. Two files make that view a before and after pair, as add --before --after does: two images of one size, two clips of one size and length, or two sounds, never one of each; the owner picks how he compares them (side by side, wipe, fade). broken or better holds the card « in progress » (not waiting on the owner's verdict, still new in the list), fixed asks the owner's verdict again on the same thread, even after an answer. The owner's hint on an update reaches watch and inbox as a reply « on update <k> ». Posted on the thread's newest version.`,
775
+ description: "where a thread's work stands, no answer needed: broken, better or fixed, a line, a file or a pair",
776
+ details: `${DETAILS}\n\nsk thread update <id> <broken|better|fixed> "<one line>" [<file> | <before> <after>]: the file (an image, a clip or a sound, as it is: no special file) becomes the card's next view, the line and the state go on its thread in time order. Two files make that view a before and after pair, as add --before --after does: two images of one size, two clips of one size and length, or two sounds, never one of each; the owner picks how he compares them (side by side, wipe, fade). broken or better holds the card « in progress » (not waiting on the owner's verdict, still new in the list), fixed asks the owner's verdict again on the same thread, even after an answer. The owner's hint on an update reaches watch and inbox as a reply « on update <k> ». Posted on the thread's newest version.`,
695
777
  examples: [
696
- ['still broken, the take as it is', 'SK_AGENT=L2 sk review update <id> broken "her arm still crosses her leg at 2 s" take.mp4'],
697
- ['better, not done', 'SK_AGENT=L2 sk review update <id> better "the crossing is gone, the landing still snaps" take.mp4'],
698
- ['fixed: he answers again', 'SK_AGENT=L2 sk review update <id> fixed "no crossing, no snap over the whole clip" take.mp4'],
699
- ['better, as a before and after he compares his way', 'SK_AGENT=L2 sk review update <id> better "the snap is half as deep" before.mp4 after.mp4'],
778
+ ['still broken, the take as it is', 'SK_AGENT=L2 sk thread update <id> broken "her arm still crosses her leg at 2 s" take.mp4'],
779
+ ['better, not done', 'SK_AGENT=L2 sk thread update <id> better "the crossing is gone, the landing still snaps" take.mp4'],
780
+ ['fixed: he answers again', 'SK_AGENT=L2 sk thread update <id> fixed "no crossing, no snap over the whole clip" take.mp4'],
781
+ ['better, as a before and after he compares his way', 'SK_AGENT=L2 sk thread update <id> better "the snap is half as deep" before.mp4 after.mp4'],
700
782
  ],
701
783
  })
702
784
  id = Option.String()
@@ -704,6 +786,7 @@ export class ReviewUpdateCommand extends Command {
704
786
  text = Option.String()
705
787
  files = Option.Rest()
706
788
  as = Option.String('--as', { description: 'the lane that posts (else SK_AGENT)' })
789
+ keep = Option.Boolean('--keep', false, { description: 'its pictures as given: a png lands as a lossless webp otherwise, its pixels checked exact, and the card keeps only the webp' })
707
790
 
708
791
  async execute(): Promise<number> {
709
792
  return run(this.context, async (h) => {
@@ -715,12 +798,12 @@ export class ReviewUpdateCommand extends Command {
715
798
  const id = threadOfId(asked, threadsOf(readAll(h.dir).items))?.head.item.id ?? asked
716
799
  const refused = await answererRefusal(h.dir, id, this.as, 'reply')
717
800
  if (refused !== null) throw new Error(refused)
718
- const r = await postUpdate(h.dir, id, { who: laneOfCaller(this.as) ?? agentName(), state: this.state, text: this.text, files: this.files })
719
- const { viewLetter, stateOf } = await import('../review/model.ts')
801
+ const r = await postUpdate(h.dir, id, { who: laneOfCaller(this.as) ?? agentName(), state: this.state, text: this.text, files: this.files, ...(this.keep ? { keep: true } : {}) })
802
+ const { viewNo, stateOf } = await import('../review/model.ts')
720
803
  const { readItem } = await import('../review/store.ts')
721
804
  const x = readItem(h.dir, id)
722
805
  const now = x && stateOf(x, false).state === 'asks' ? "waits for the owner's verdict" : x && stateOf(x, false).state === 'draft' ? 'in progress, no verdict asked' : 'in work'
723
- h.out(`${id}: ${r.tag}${r.view !== null ? `, view ${viewLetter(r.view)}` : ''}${id !== asked ? ` (on the newest version, ${asked} is older)` : ''}; the card ${now}`)
806
+ h.out(`${id}: ${r.tag}${r.view !== null ? `, view ${viewNo(r.view)}` : ''}${id !== asked ? ` (on the newest version, ${asked} is older)` : ''}; the card ${now}`)
724
807
  if (r.view !== null) for (const line of await (await import('../review/previews.ts')).playCopies(h.dir, r.item, r.view)) h.err(line)
725
808
  const { unheardLine } = await import('../review/model.ts')
726
809
  const { liveWatchers } = await import('../review/watchers.ts')
@@ -733,7 +816,7 @@ export class ReviewUpdateCommand extends Command {
733
816
 
734
817
  export class ReviewWithdrawCommand extends Command {
735
818
  static override paths = [['review', 'withdraw']]
736
- static override usage = Command.Usage({ category: 'Review', description: 'take an unanswered card back, with the reason', details: DETAILS })
819
+ static override usage = Command.Usage({ category: 'Review', description: 'take an unanswered version back, with the reason', details: DETAILS })
737
820
  ids = Option.Rest({ required: 1 })
738
821
  why = Option.String('--why,--note', { required: true, description: 'why it goes (--note says the same, as on fixed, wontfix, blocked and drop)' })
739
822
 
@@ -753,7 +836,7 @@ export class ReviewWithdrawCommand extends Command {
753
836
 
754
837
  export class ReviewReopenCommand extends Command {
755
838
  static override paths = [['review', 'reopen']]
756
- static override usage = Command.Usage({ category: 'Review', description: 'an answered card waits for his answer again; the old verdict stays in the thread', details: DETAILS })
839
+ static override usage = Command.Usage({ category: 'Review', description: 'an answered version waits for his answer again; the old verdict stays in the thread', details: DETAILS })
757
840
  ids = Option.Rest({ required: 1 })
758
841
 
759
842
  async execute(): Promise<number> {
@@ -777,9 +860,9 @@ export class ReviewPickCommand extends Command {
777
860
  static override paths = [['review', 'pick']]
778
861
  static override usage = Command.Usage({
779
862
  category: 'Review',
780
- description: "the option you suggest on a choice card he has not answered: the hub's « my pick » pill on it",
781
- details: `${DETAILS}\n\nsk review pick <id> <view>: the view by its letter (B) or its label; one pick a card, a new one replaces it. On add: --choice … --pick <view>.`,
782
- examples: [['suggest the second option', 'sk review pick <id> B'], ['by its label', 'sk review pick <id> "Zen Garden"']],
863
+ description: "the option you suggest on a choice he has not answered: the hub's « my pick » pill on it",
864
+ details: `${DETAILS}\n\nsk thread pick <id> <view>: the view by its letter (B) or its label; one pick a card, a new one replaces it. On add: --choice … --pick <view>.`,
865
+ examples: [['suggest the second option', 'sk thread pick <id> B'], ['by its label', 'sk thread pick <id> "Zen Garden"']],
783
866
  })
784
867
  id = Option.String({ required: true })
785
868
  view = Option.String({ required: true })
@@ -787,11 +870,11 @@ export class ReviewPickCommand extends Command {
787
870
  async execute(): Promise<number> {
788
871
  return run(this.context, async (h) => {
789
872
  const { setAgentPick } = await import('../review/store.ts')
790
- const { viewLetter, viewName } = await import('../review/model.ts')
873
+ const { viewNo, viewName } = await import('../review/model.ts')
791
874
  const id = await idOf(h.dir, this.id)
792
875
  const item = setAgentPick(h.dir, id, this.view)
793
876
  const n = item.agentPick ?? 0
794
- h.out(`${id}: my pick ${viewLetter(n)} "${viewName(item.views[n], n)}"`)
877
+ h.out(`${id}: my pick ${viewNo(n)} "${viewName(item.views[n], n)}"`)
795
878
  return 0
796
879
  })
797
880
  }
@@ -810,15 +893,27 @@ function actCommand(op: ActOp, description: string, o: { note?: 'required' | 'op
810
893
  note = o.note === 'required' ? Option.String('--note', { required: true, description: 'what was done, why not, or what is needed' }) : Option.String('--note', { description: 'what was done, or the reason' })
811
894
  commit = Option.String('--commit', { description: 'the commit that holds the fix' })
812
895
  as = Option.String('--as', { description: 'who acts (else SK_AGENT)' })
896
+ options = op === 'ask' ? Option.Array('--option', { description: 'a question he answers in one click: each option (two or more); any agent asks this way, the dispatcher asks without' }) : undefined
897
+ pick = op === 'ask' ? Option.String('--pick', { description: 'with --option: the option you pick, by its number from 1 (the house rule: a pick on every question)' }) : undefined
813
898
 
814
899
  async execute(): Promise<number> {
815
900
  return run(this.context, async (h) => {
816
901
  const { act, readItem } = await import('../review/store.ts')
902
+ if (op === 'ask' && this.options !== undefined) {
903
+ const { postAsk } = await import('../review/store.ts')
904
+ if (!this.words?.trim()) throw new Error('ask <address | id> "<question>" --option "<a>" --option "<b>" --pick <n>')
905
+ const id = await idOf(h.dir, this.id)
906
+ const pick = this.pick === undefined ? undefined : Number(this.pick) - 1
907
+ if (pick === undefined) h.err('no --pick: the house rule wants your pick on every question')
908
+ const m = postAsk(h.dir, id, { who: actor(this.as, false, op), text: this.words, options: this.options, ...(pick !== undefined ? { pick } : {}) })
909
+ h.out(`${id} asked: ${m.ask?.options.map((o, i) => `${i + 1} ${o}${m.ask?.pick === i ? ' (your pick)' : ''}`).join(' · ')}`)
910
+ return 0
911
+ }
817
912
  const { stateOf } = await import('../review/model.ts')
818
913
  const { detail } = await import('../review/format.ts')
819
914
  if (this.words !== undefined && o.text === undefined && o.topic === undefined) throw new Error(`unexpected ${this.words}`)
820
915
  if (o.text && !this.words?.trim()) throw new Error(`${op} <id> "<${o.text}>"`)
821
- if (o.topic === 'required' && !this.words) throw new Error(`${op} <id> <topic> (sk review topics)`)
916
+ if (o.topic === 'required' && !this.words) throw new Error(`${op} <id> <topic> (sk thread topics)`)
822
917
  const id = await idOf(h.dir, this.id)
823
918
  const who = actor(this.as, o.named, op)
824
919
  if (op === 'done') {
@@ -830,11 +925,11 @@ function actCommand(op: ActOp, description: string, o: { note?: 'required' | 'op
830
925
  const st = was ? stateOf(was, followed) : null
831
926
  if (st?.state === 'closed') {
832
927
  h.out(`${id}: closed already (${st.why ?? 'closed'}${followed ? ', a newer card follows it' : ''}), nothing to close`)
833
- if (this.words || this.note) h.err(`your words are not posted: sk review reply ${id} "<text>"`)
928
+ if (this.words || this.note) h.err(`your words are not posted: sk thread reply ${id} "<text>"`)
834
929
  return 0
835
930
  }
836
931
  if (st?.state === 'asks' || st?.state === 'draft')
837
- throw new Error(`${id}: done closes a card the owner answered « fix »; this one ${st.state === 'asks' ? "waits on the owner's verdict" : 'is in progress'}: sk review withdraw ${id} --why "<why>" takes it back`)
932
+ throw new Error(`${id}: done closes a card the owner answered « fix »; this one ${st.state === 'asks' ? "waits on the owner's verdict" : 'is in progress'}: sk thread withdraw ${id} --why "<why>" takes it back`)
838
933
  }
839
934
  act(h.dir, id, op, who, {
840
935
  ...(this.note ? { note: this.note } : {}),
@@ -853,16 +948,16 @@ function actCommand(op: ActOp, description: string, o: { note?: 'required' | 'op
853
948
  }
854
949
  }
855
950
 
856
- export const ReviewFixedCommand = actCommand('fixed', 'close an item he raised as done: the note says what was done (and --commit where)', { note: 'optional', named: false, examples: [['done, with its commit', 'sk review fixed <id> --note "the lamp lit" --commit abc1234']] })
857
- export const ReviewWontfixCommand = actCommand('wontfix', 'close an item he raised as not done, with the reason', { note: 'required', named: false, examples: [['not done', 'sk review wontfix <id> --note "the room is gone"']] })
858
- export const ReviewClaimCommand = actCommand('claim', 'take an item to work on it: the hub shows the card in work by your lane', { named: true, examples: [['take it', 'sk review claim <id> --as L12']] })
859
- export const ReviewReleaseCommand = actCommand('release', 'give back an item you claimed', { note: 'optional', named: true, examples: [['give it back', 'sk review release <id> --as L12']] })
860
- export const ReviewBlockedCommand = actCommand('blocked', 'an item you claimed goes back to the owner with what is needed', { note: 'required', named: true, examples: [['his decision is needed', 'sk review blocked <id> --note "which of the two doors?" --as L12']] })
861
- export const ReviewDoneCommand = actCommand('done', 'an « ok with a fix » card made with no new card: closed, the words say what changed', { text: 'what changed', named: false, examples: [['the fix made', 'sk review done <id> "the sign moved one tile up"']] })
862
- export const ReviewDispatchCommand = actCommand('dispatch', 'the dispatcher sends a raised item to a topic', { note: 'optional', topic: 'required', named: true, examples: [['to a topic', 'sk review dispatch <id> lieux --as orchestrator']] })
863
- export const ReviewAskCommand = actCommand('ask', 'the dispatcher asks the owner a question on a raised item; his reply answers it', { text: 'question', named: true, examples: [['a question', 'sk review ask <id> "which tower?" --as orchestrator']] })
864
- export const ReviewDropCommand = actCommand('drop', 'the dispatcher closes a raised item with the reason (a duplicate, already fixed)', { note: 'required', named: true, examples: [['a duplicate', 'sk review drop <id> --note "same as <other id>" --as orchestrator']] })
865
- export const ReviewReassignCommand = actCommand('reassign', 'the dispatcher takes a claim back, or sends the item to another topic', { note: 'optional', topic: 'optional', named: true, examples: [['a stale claim', 'sk review reassign <id> --as orchestrator']] })
951
+ export const ReviewFixedCommand = actCommand('fixed', 'close an item he raised as done: the note says what was done (and --commit where)', { note: 'optional', named: false, examples: [['done, with its commit', 'sk thread fixed <id> --note "the lamp lit" --commit abc1234']] })
952
+ export const ReviewWontfixCommand = actCommand('wontfix', 'close an item he raised as not done, with the reason', { note: 'required', named: false, examples: [['not done', 'sk thread wontfix <id> --note "the room is gone"']] })
953
+ export const ReviewClaimCommand = actCommand('claim', 'take an item to work on it: the hub shows the thread in work by your lane', { named: true, examples: [['take it', 'sk thread claim <id> --as L12']] })
954
+ export const ReviewReleaseCommand = actCommand('release', 'give back an item you claimed', { note: 'optional', named: true, examples: [['give it back', 'sk thread release <id> --as L12']] })
955
+ export const ReviewBlockedCommand = actCommand('blocked', 'an item you claimed goes back to the owner with what is needed', { note: 'required', named: true, examples: [['his decision is needed', 'sk thread blocked <id> --note "which of the two doors?" --as L12']] })
956
+ export const ReviewDoneCommand = actCommand('done', 'an « ok with a fix » version made with no new version: closed, the words say what changed', { text: 'what changed', named: false, examples: [['the fix made', 'sk thread done <id> "the sign moved one tile up"']] })
957
+ export const ReviewDispatchCommand = actCommand('dispatch', 'the dispatcher sends a raised item to a topic', { note: 'optional', topic: 'required', named: true, examples: [['to a topic', 'sk thread dispatch <id> lieux --as orchestrator']] })
958
+ export const ReviewAskCommand = actCommand('ask', 'the dispatcher asks the owner a question on a raised item; his reply answers it', { text: 'question', named: true, examples: [['a question', 'sk thread ask <id> "which tower?" --as orchestrator']] })
959
+ export const ReviewDropCommand = actCommand('drop', 'the dispatcher closes a raised item with the reason (a duplicate, already fixed)', { note: 'required', named: true, examples: [['a duplicate', 'sk thread drop <id> --note "same as <other id>" --as orchestrator']] })
960
+ export const ReviewReassignCommand = actCommand('reassign', 'the dispatcher takes a claim back, or sends the item to another topic', { note: 'optional', topic: 'optional', named: true, examples: [['a stale claim', 'sk thread reassign <id> --as orchestrator']] })
866
961
 
867
962
  export class ReviewDispatcherCommand extends Command {
868
963
  static override paths = [['review', 'dispatcher']]
@@ -870,7 +965,7 @@ export class ReviewDispatcherCommand extends Command {
870
965
  category: 'Review',
871
966
  description: 'take the dispatcher role: one session at a time routes what is raised',
872
967
  details: `${DETAILS}\n\nRefused while another holder acted in the last 30 minutes, unless --take. Only in a repo whose review unit declares a dispatcher.`,
873
- examples: [['take the role', 'sk review dispatcher --as orchestrator']],
968
+ examples: [['take the role', 'sk thread dispatcher --as orchestrator']],
874
969
  })
875
970
  as = Option.String('--as', { description: 'who takes it (else SK_AGENT)' })
876
971
  take = Option.Boolean('--take', false, { description: 'take it from an active holder' })
@@ -894,7 +989,7 @@ export class ReviewNextCommand extends Command {
894
989
  category: 'Review',
895
990
  description: 'claim the oldest open item of a topic, or raised to a lane, and show it with the pages to read first',
896
991
  details: DETAILS,
897
- examples: [['the next of a topic', 'sk review next lieux --as L12'], ['the next raised to a lane', 'sk review next --lane interaction --as interaction']],
992
+ examples: [['the next of a topic', 'sk thread next lieux --as L12'], ['the next raised to a lane', 'sk thread next --lane interaction --as interaction']],
898
993
  })
899
994
  topic = Option.String({ required: false })
900
995
  lane = Option.String('--lane', { description: 'the lane he or a rule raised it to' })
@@ -942,7 +1037,7 @@ export class ReviewBoardCommand extends Command {
942
1037
  category: 'Review',
943
1038
  description: 'every open raised item by state, topic and worker, stale claims marked; who is the dispatcher',
944
1039
  details: DETAILS,
945
- examples: [['what is open', 'sk review board'], ['one topic, closed ones too', 'sk review board --topic lieux --all']],
1040
+ examples: [['what is open', 'sk thread board'], ['one topic, closed ones too', 'sk thread board --topic lieux --all']],
946
1041
  })
947
1042
  topic = Option.String('--topic', { description: 'one topic' })
948
1043
  all = Option.Boolean('--all', false, { description: 'the closed ones too' })
@@ -959,7 +1054,7 @@ export class ReviewBoardCommand extends Command {
959
1054
  for (const b of all.broken) h.err(`review: FAIL ${b.id}: ${b.error}`)
960
1055
  if (h.say.spec.dispatcher) {
961
1056
  const role = roleOf(h.dir)
962
- h.out(role ? `dispatcher: ${role.name} (since ${role.since.slice(0, 16)})` : 'dispatcher: nobody (sk review dispatcher --as <name>)')
1057
+ h.out(role ? `dispatcher: ${role.name} (since ${role.since.slice(0, 16)})` : 'dispatcher: nobody (sk thread dispatcher --as <name>)')
963
1058
  }
964
1059
  const now = new Date()
965
1060
  const followed = followedIds(all.items)
@@ -981,7 +1076,7 @@ export class ReviewBoardCommand extends Command {
981
1076
 
982
1077
  export class ReviewReadyCommand extends Command {
983
1078
  static override paths = [['review', 'ready']]
984
- static override usage = Command.Usage({ category: 'Review', description: 'a draft card becomes a card he answers: its last frame, or the image given, stays', details: DETAILS })
1079
+ static override usage = Command.Usage({ category: 'Review', description: 'a draft version becomes one he answers: its last frame, or the image given, stays', details: DETAILS })
985
1080
  id = Option.String()
986
1081
  image = Option.String('--image', { description: 'the image that stays' })
987
1082
 
@@ -1004,7 +1099,7 @@ export class ReviewDeleteCommand extends Command {
1004
1099
  category: 'Review',
1005
1100
  description: "a player's test report removed at its source and here, or an item the owner raised removed here",
1006
1101
  details: DETAILS,
1007
- examples: [['a test report', 'sk review delete live#3']],
1102
+ examples: [['a test report', 'sk thread delete live#3']],
1008
1103
  })
1009
1104
  refs = Option.Rest({ required: 1 })
1010
1105
 
@@ -1036,7 +1131,7 @@ export class ReviewMarksCommand extends Command {
1036
1131
  category: 'Review',
1037
1132
  description: "the owner's marks kept in the store: per subject its latest stars, mark and note",
1038
1133
  details: DETAILS,
1039
- examples: [['every mark', 'sk review marks'], ['one kind, for a script', 'sk review marks --subject song --json']],
1134
+ examples: [['every mark', 'sk thread marks'], ['one kind, for a script', 'sk thread marks --subject song --json']],
1040
1135
  })
1041
1136
  subject = Option.String('--subject', { description: 'one subject kind' })
1042
1137
  json = Option.Boolean('--json', false, { description: 'every subject key, its latest mark and its history count' })
@@ -1067,11 +1162,11 @@ export class ReviewAnimCommand extends Command {
1067
1162
  static override paths = [['review', 'anim']]
1068
1163
  static override usage = Command.Usage({
1069
1164
  category: 'Review',
1070
- description: "a card's before and after as a looping animation to send: a cut, a fade or a wipe, mp4 or gif",
1071
- details: `${DETAILS}\n\nsk review anim <id> [--view n] | --before a.png --after b.png. Made once and kept under .shipkit/review/.anims/; --out <file | dir/> copies it out (default .shipkit/tmp/).`,
1165
+ description: "a version's before and after as a looping animation to send: a cut, a fade or a wipe, mp4 or gif",
1166
+ details: `${DETAILS}\n\nsk thread anim <id> [--view n] | --before a.png --after b.png. Made once and kept under .shipkit/review/.anims/; --out <file | dir/> copies it out (default .shipkit/tmp/).`,
1072
1167
  examples: [
1073
- ['a fade, mp4', 'sk review anim <id>'],
1074
- ['a wipe of the second view, gif', 'sk review anim <id> --view 1 --mode wipe --format gif'],
1168
+ ['a fade, mp4', 'sk thread anim <id>'],
1169
+ ['a wipe of the second view, gif', 'sk thread anim <id> --view 1 --mode wipe --format gif'],
1075
1170
  ],
1076
1171
  })
1077
1172
  id = Option.String({ required: false })
@@ -1112,12 +1207,12 @@ export class ReviewStageCommand extends Command {
1112
1207
  static override paths = [['review', 'stage']]
1113
1208
  static override usage = Command.Usage({
1114
1209
  category: 'Review',
1115
- description: "one media of a card staged as a post: a draft in .shipkit/social/drafts/, never posted",
1116
- details: `${DETAILS}\n\nThe media copied in with its metadata left out, the repo's guard run first, the draft committed by its paths. Without --view, the newest version's first media. Without --kind, iteration: feature, a change users can use now, is picked by hand. --dry prints the draft as it would be written, then each account, its place, its count, what it skips. It never publishes: Publish stays his, in Communications. Page: wiki tools/shipkit/review-raised-items.md, A post staged from a card`,
1210
+ description: "one media of a version staged as a post: a draft in .shipkit/social/drafts/, never posted",
1211
+ details: `${DETAILS}\n\nThe media copied in with its metadata left out, the repo's guard run first, the draft committed by its paths. Without --view, the newest version's first media. Without --kind, iteration: feature, a change users can use now, is picked by hand. --dry prints the draft as it would be written, then each account, its place, its count, what it skips. It never publishes: Publish stays his, in Communications. Page: wiki tools/shipkit/threads-raised-notes.md, A post staged from a card`,
1117
1212
  examples: [
1118
- ['the first media, a safe post', 'sk review stage <id> --text "Hands now pinch and lift." --rating safe'],
1119
- ["the second view's wipe, polished by an agent", 'sk review stage <id> --view B --side wipe --text "…" --rating mild --polish'],
1120
- ['what it would be', 'sk review stage <id> --text "…" --rating safe --dry'],
1213
+ ['the first media, a safe post', 'sk thread stage <id> --text "Hands now pinch and lift." --rating safe'],
1214
+ ["the second view's wipe, polished by an agent", 'sk thread stage <id> --view B --side wipe --text "…" --rating mild --polish'],
1215
+ ['what it would be', 'sk thread stage <id> --text "…" --rating safe --dry'],
1121
1216
  ],
1122
1217
  })
1123
1218
  id = Option.String({ required: true })
@@ -1142,7 +1237,7 @@ export class ReviewStageCommand extends Command {
1142
1237
  const { dirname, join } = await import('node:path')
1143
1238
  const { isPostRating, POST_RATINGS } = await import('../identities/rating.ts')
1144
1239
  const missing = [this.text === undefined ? '--text "<the post>"' : null, this.rating === undefined ? `--rating <${POST_RATINGS.join('|')}>` : null].filter((x) => x !== null)
1145
- if (this.text === undefined || this.rating === undefined) throw new Error(`sk review stage ${this.id} needs ${missing.join(' and ')}`)
1240
+ if (this.text === undefined || this.rating === undefined) throw new Error(`sk thread stage ${this.id} needs ${missing.join(' and ')}`)
1146
1241
  const { stageInputOf, stageOfCard } = await import('../review/stage-card.ts')
1147
1242
  const { askPolish, fitStage, stagedKind, stageDraft, stageDry } = await import('../social/stage.ts')
1148
1243
  const { loadSocialUnit } = await import('../social/unit.ts')
@@ -1152,9 +1247,12 @@ export class ReviewStageCommand extends Command {
1152
1247
  const s = stageOfCard(h.dir, id)
1153
1248
  let pick: string | undefined
1154
1249
  if (this.view) {
1155
- const m = /^(?:(\d+)\.)?([A-Z]+)$/i.exec(this.view)
1156
- if (m == null) throw new Error(`--view ${this.view}: a letter, or <n>.<letter>`)
1157
- const tag = `${m[1] ?? Math.max(...s.media.map((x) => Number(x.label.split('.')[0])))}.${m[2]!.toUpperCase()}`
1250
+ // a view's number, or the letter it had before; either alone or after its version's number
1251
+ const m = /^(?:(\d+)\.)?(\d+|[A-Z]+)$/i.exec(this.view)
1252
+ if (m == null) throw new Error(`--view ${this.view}: a view's number, or <version>.<number>`)
1253
+ const { viewNo, viewRef } = await import('../review/model.ts')
1254
+ const k = viewNo(viewRef(m[2]!))
1255
+ const tag = `${m[1] ?? Math.max(...s.media.map((x) => Number(x.label.split('.')[0])))}.${k}`
1158
1256
  const of = s.media.filter((x) => x.label.startsWith(`${tag} `))
1159
1257
  const tile = this.tile
1160
1258
  const hit = tile ? of.find((x) => x.tile !== undefined && (x.label.endsWith(`/${tile}`) || x.label.endsWith(` ${tile}`))) : of.find((x) => (x.side ?? 'after') === (this.side ?? 'after'))
@@ -1183,8 +1281,8 @@ export class ReviewAutoCommand extends Command {
1183
1281
  static override usage = Command.Usage({
1184
1282
  category: 'Review',
1185
1283
  description: "the repo's auto rules: period, last run and answer, last item, next run; `auto run <id>` runs one",
1186
- details: `${DETAILS}\n\nsk review auto | sk review auto run <id> [--dry]. The hub's daemon runs them on their clocks.`,
1187
- examples: [['every rule', 'sk review auto'], ['what one would raise', 'sk review auto run veille --dry']],
1284
+ details: `${DETAILS}\n\nsk thread auto | sk thread auto run <id> [--dry]. The hub's daemon runs them on their clocks.`,
1285
+ examples: [['every rule', 'sk thread auto'], ['what one would raise', 'sk thread auto run veille --dry']],
1188
1286
  })
1189
1287
  verb = Option.String({ required: false })
1190
1288
  rule = Option.String({ required: false })
@@ -1237,16 +1335,17 @@ export class ReviewWatchCommand extends Command {
1237
1335
  category: 'Review',
1238
1336
  description: 'one line per verdict, reply or raised note as it lands; every unseen one first; ends with its owner',
1239
1337
  details: `${DETAILS}\n\nRun it under a monitor, unfiltered (a grep holds a burst's last line). It registers itself, so the hub shows who listens. It exits within 2 s once a process above it at start is gone or nothing reads its output. An item nobody takes prints 2 minutes after its last message, then every 2 hours.`,
1240
- examples: [['the cards this session sent', 'sk review watch --mine'], ["one lane's items", 'sk review watch --lane interaction']],
1338
+ examples: [['the cards this session sent', 'sk thread watch --mine'], ["one lane's items", 'sk thread watch --lane interaction']],
1241
1339
  })
1242
- mine = Option.Boolean('--mine', false, { description: "only this Claude Code session's cards" })
1243
- session = Option.String('--session', { description: "only that session's cards" })
1340
+ mine = Option.Boolean('--mine', false, { description: "only the threads this Claude Code session holds" })
1341
+ session = Option.String('--session', { description: "only the threads that session holds" })
1244
1342
  lane = Option.String('--lane', { description: "only that lane's items" })
1245
1343
 
1246
1344
  async execute(): Promise<number> {
1247
1345
  return run(this.context, async (h) => {
1248
1346
  const { existsSync, mkdirSync, watch } = await import('node:fs')
1249
1347
  const { readAll, scanStamp } = await import('../review/store.ts')
1348
+ const { cardsInDb } = await import('../hq/switch.ts')
1250
1349
  const { AGENT_RE, coversCard, laneOf, UNTAKEN_AGAIN_MS, untakenOf } = await import('../review/model.ts')
1251
1350
  const { followedIds, unseen } = await import('../review/threads.ts')
1252
1351
  const { raisedLine, untakenLine, watchLines } = await import('../review/format.ts')
@@ -1254,7 +1353,9 @@ export class ReviewWatchCommand extends Command {
1254
1353
  const session = await sessionOf(this.mine, this.session)
1255
1354
  const lane = this.lane?.trim() || null
1256
1355
  if (lane !== null && !AGENT_RE.test(lane)) throw new Error(`--lane: « ${lane} » is no lane id (${AGENT_RE.source})`)
1257
- const mine = (x: Parameters<typeof coversCard>[1]): boolean => coversCard({ session, lane }, x)
1356
+ const { hears, threadByItem, threadsOf } = await import('../review/threads.ts')
1357
+ let byItem = new Map<string, import('../review/threads.ts').Thread>()
1358
+ const mine = (x: Parameters<typeof coversCard>[1]): boolean => hears({ session, lane }, x, byItem)
1258
1359
  if (session === null && lane === null) {
1259
1360
  const { bareWatchTaken } = await import('../review/model.ts')
1260
1361
  const taken = bareWatchTaken(liveWatchers(h.dir), process.pid)
@@ -1264,8 +1365,24 @@ export class ReviewWatchCommand extends Command {
1264
1365
  // before any await: a pull that hangs never keeps a watch alive past its owner
1265
1366
  exitWithOwner()
1266
1367
  const shown = new Set<string>()
1267
- const tick = (): void => {
1368
+ // a store refused for a while (a fold or a way back of the daemon file walks): one line, and the next poll
1369
+ // reads again; never a watch that dies and hears nothing more
1370
+ let refused: string | null = null
1371
+ const safely = (fn: () => void): void => {
1372
+ try {
1373
+ fn()
1374
+ if (refused !== null) h.err(`review: ok, the store reads again: this watch goes on`)
1375
+ refused = null
1376
+ } catch (e) {
1377
+ const why = (e as Error).message.split('\n')[0] ?? ''
1378
+ if (refused === null) h.err(`review: WARN the store does not read now (${why}): this watch reads again at its next poll`)
1379
+ refused = why
1380
+ }
1381
+ }
1382
+ const tick = (): void => safely(read)
1383
+ const read = (): void => {
1268
1384
  const all = readAll(h.dir)
1385
+ byItem = threadByItem(threadsOf(all.items, h.say.spec))
1269
1386
  for (const b of all.broken) {
1270
1387
  const key = `broken ${b.id} ${b.error}`
1271
1388
  if (!shown.has(key)) h.err(`review: FAIL ${b.id}: ${b.error}`)
@@ -1301,31 +1418,353 @@ export class ReviewWatchCommand extends Command {
1301
1418
  tick()
1302
1419
  // the grace and the reminder pass with time alone: one read a minute
1303
1420
  setInterval(tick, 60_000)
1304
- // a change under the folder asks again (debounced); a cheap stat stamp every 5 s catches a missed event
1421
+ // the store the switch names, read again at each poll (a process reads the switch at most once a second), so a
1422
+ // watch follows a move while it runs. The rows: their stamp is a query of a few µs, asked every 50 ms, read at
1423
+ // once. The files: a watch of the folder asks again (debounced), and a stat stamp every 5 s catches a missed event
1305
1424
  let soon: ReturnType<typeof setTimeout> | null = null
1306
1425
  const again = (): void => {
1307
1426
  if (soon) clearTimeout(soon)
1308
1427
  soon = setTimeout(() => {
1309
1428
  soon = null
1310
1429
  tick()
1311
- }, 150)
1430
+ }, cardsInDb() ? 0 : 150)
1431
+ }
1432
+ let folderWatched = false
1433
+ const watchFolder = (): void => {
1434
+ if (folderWatched) return
1435
+ folderWatched = true
1436
+ if (!existsSync(h.dir)) mkdirSync(h.dir, { recursive: true })
1437
+ watch(h.dir, { recursive: true }, () => {
1438
+ if (!cardsInDb()) again()
1439
+ })
1312
1440
  }
1313
- if (!existsSync(h.dir)) mkdirSync(h.dir, { recursive: true })
1314
- watch(h.dir, { recursive: true }, again)
1441
+ if (!cardsInDb()) watchFolder()
1315
1442
  // the sources: pulled now and every 30 s, a new item lands and the tick prints it
1316
1443
  await pull(h)
1317
1444
  if (h.unit?.sources?.length) setInterval(() => void pull(h), 30_000)
1318
- let stamp = scanStamp(h.dir)
1445
+ let stamp = ''
1446
+ let scanned = Date.now()
1319
1447
  setInterval(() => {
1320
- const now = scanStamp(h.dir)
1321
- if (now !== stamp) again()
1322
- stamp = now
1323
- }, 5000)
1448
+ const rows = cardsInDb()
1449
+ // the files' stamp walks every card: once every 5 s, never at the rows' pace
1450
+ if (!rows) {
1451
+ watchFolder()
1452
+ if (Date.now() - scanned < 5000) return
1453
+ }
1454
+ scanned = Date.now()
1455
+ // a refused stamp, or one read again after a refusal: the read says it, once
1456
+ try {
1457
+ const now = scanStamp(h.dir)
1458
+ if (now !== stamp || refused !== null) again()
1459
+ stamp = now
1460
+ } catch {
1461
+ again()
1462
+ }
1463
+ }, 50)
1324
1464
  return new Promise<number>(() => {})
1325
1465
  })
1326
1466
  }
1327
1467
  }
1328
1468
 
1469
+ /** the review folders of this machine's house, its archived repos included: what a move carries */
1470
+ async function houseStores(): Promise<string[]> {
1471
+ const { findRepoRoot } = await import('../ts/config.ts')
1472
+ const { houseRepos } = await import('../serve/project-gutter.ts')
1473
+ const { homedir } = await import('node:os')
1474
+ const { storeDir } = await import('../review/store.ts')
1475
+ const house = houseRepos(findRepoRoot(process.cwd()), homedir())
1476
+ if (house.index == null) throw new Error(`${process.cwd()} is in no house repo: run it from the house checkout, whose repos it moves`)
1477
+ const { existsSync } = await import('node:fs')
1478
+ const repos = [...house.repos, ...house.archived].map((r) => r.path)
1479
+ // a lane's worktree holds the cards it sent there: they join their repo's rows
1480
+ const trees = repos.flatMap((r) => {
1481
+ const p = Bun.spawnSync(['git', '-C', r, 'worktree', 'list', '--porcelain'], { stdout: 'pipe', stderr: 'ignore' })
1482
+ return (p.stdout?.toString() ?? '').split('\n').flatMap((l) => (l.startsWith('worktree ') && l.slice(9) !== r ? [l.slice(9)] : []))
1483
+ })
1484
+ return [...repos, ...trees.filter((t) => existsSync(storeDir(t)))].map((r) => storeDir(r))
1485
+ }
1486
+
1487
+ export class ReviewMoveCommand extends Command {
1488
+ static override paths = [['review', 'move']]
1489
+ static override usage = Command.Usage({
1490
+ category: 'Review',
1491
+ description: "this machine's cards into the daemon's database, or back into files",
1492
+ details:
1493
+ "The machine db switch cards-in-db picks where every review card of this machine is read and written: its repo's files (`.shipkit/review/<id>/`, off, the default), or the rows of the daemon's database (on). `--go` imports every card file of every house repo the rows lack (by id and rev), proves each is in the rows, turns the switch on, then reads the files once more after a second for a writer that had not seen it. With the switch hq-cards on, it first asks the hq: the hq and the files must hold the same cards, else nothing moves. The files stay where they are, untouched: the way back. `--back` is a look of the way back, `--back --go` first fetches from the Space any media file the spool let go (or refuses, naming how many it would lack), then writes every card of the rows into the files (the cards made since included), turns the switch off, and writes them out again after a second. During a move's lag (7 s) a reader in another process can miss a card a writer made on the side the move left; the second pass carries it, and none stays missed. Both keep the later of two heads and every message by its id, so a move stopped half way runs again. A card's media files stay in its folder. `--tidy` (a look, `--tidy --go` acts) removes a card's files from its repo only while the switch is on and once its rows hold all of them, the hq holds them (hq-cards on) and the Space each of its media files; a card whose rows differ stays, named; after it, `--back --go` writes the files again from the rows. It moves every house repo of the home it runs in, worktrees resolved to their checkout: a test names a scratch HOME. Page: wiki tools/shipkit/threads-store.md",
1494
+ examples: [['what the tidy would remove', 'sk thread move --tidy'], ['what a move would do', 'sk thread move'], ['move this machine', 'sk thread move --go'], ['what the way back would do', 'sk thread move --back'], ['go back to the files', 'sk thread move --back --go']],
1495
+ })
1496
+ go = Option.Boolean('--go', false, { description: 'do it: the move, or with --back the way back' })
1497
+ back = Option.Boolean('--back', false, { description: 'the way back: the rows into the files, the switch off' })
1498
+ tidy = Option.Boolean('--tidy', false, { description: 'remove the card files the rows, the hq and the Space all hold' })
1499
+
1500
+ async execute(): Promise<number> {
1501
+ const out = (l: string): void => void this.context.stdout.write(`${l}\n`)
1502
+ const err = (l: string): void => void this.context.stderr.write(`${l}\n`)
1503
+ try {
1504
+ if (this.tidy && this.back) throw new Error('--tidy or --back, not both')
1505
+ const stores = await houseStores()
1506
+ const { moveBack, moveGo, tidyFiles } = await import('../review/move.ts')
1507
+ const dry = !this.go
1508
+ // one move or look of the cards job at a time: the job would send what the move is writing
1509
+ const { cardsLease } = await import('../hq/cards.ts')
1510
+ const { leaseHolder, tryLease } = await import('../core/locked-write.ts')
1511
+ const lease = dry ? null : tryLease(cardsLease(), 'review move')
1512
+ if (!dry && lease == null) throw new Error(`a look of the cards job or another move runs (pid ${leaseHolder(cardsLease())?.pid ?? '?'}): run it again once it ended`)
1513
+ try {
1514
+ const r = this.tidy ? await tidyFiles(stores, { dry, proof: await tidyProof(stores) }) : this.back ? await moveBack(stores, { dry }) : await moveGo(stores, { dry, hqDiff: hqDiffOf(stores) })
1515
+ for (const l of r.lines) (l.startsWith('WARN') ? err : out)(l)
1516
+ const { cardsInDb } = await import('../hq/switch.ts')
1517
+ const { BACK_FIRST } = await import('../review/move.ts')
1518
+ if (cardsInDb()) out(BACK_FIRST)
1519
+ if (dry) out(`a look: nothing ${this.tidy ? 'removed' : 'moved'}. sk thread move ${this.tidy ? '--tidy --go removes' : this.back ? '--back --go moves' : '--go moves'}`)
1520
+ return r.ok ? 0 : 1
1521
+ } finally {
1522
+ lease?.release()
1523
+ }
1524
+ } catch (e) {
1525
+ err(`FAIL: review move: ${e instanceof Error ? e.message : String(e)}`)
1526
+ return 1
1527
+ }
1528
+ }
1529
+ }
1530
+
1531
+ /** what the tidy proves outside the store: the names of each repo's rows the hq lacks or holds at another rev (the
1532
+ * check hq-cards, the hq asked once), and the Space's word on each file */
1533
+ async function tidyProof(stores: readonly string[]): Promise<import('../review/move.ts').TidyProof> {
1534
+ const { cardsDiff, cardsOn, heldRepos } = await import('../hq/cards.ts')
1535
+ const { confirmedUp } = await import('../media-store/remote.ts')
1536
+ const up = (key: string, size: number): Promise<boolean> => confirmedUp(key, size)
1537
+ if (!cardsOn()) return { hqLacks: async () => ({ refused: 'the switch hq-cards is off: no hq holds them' }), up }
1538
+ const { myHq } = await import('../hq/hq-local.ts')
1539
+ const hq = myHq()
1540
+ if ('refused' in hq) return { hqLacks: async () => ({ refused: `the hq is not reached (${hq.refused})` }), up }
1541
+ const { dirname } = await import('node:path')
1542
+ const { held, left } = await heldRepos(stores.map((d) => ({ name: d, path: dirname(dirname(d)) })))
1543
+ const diff = await cardsDiff(hq, held)
1544
+ if ('refused' in diff) return { hqLacks: async () => ({ refused: `the hq refused the check: ${diff.refused}` }), up }
1545
+ const { repoIdOf } = await import('../review/card-db.ts')
1546
+ const byRepo = new Map(diff.map((d) => [d.repo, new Set([...d.onlyHere, ...d.differ])]))
1547
+ return {
1548
+ hqLacks: async (dir) => {
1549
+ const set = byRepo.get(repoIdOf(dir))
1550
+ if (set != null) return set
1551
+ return { refused: left.some((l) => dir.startsWith(l)) ? 'a repo with no remote: the hq carries none of its cards' : 'the hq holds no cards of this repo' }
1552
+ },
1553
+ up,
1554
+ }
1555
+ }
1556
+
1557
+ /** with the switch hq-cards on, what the hq and this machine's files do not hold alike, a line each: the move's
1558
+ * proof that nothing it leaves behind is missing elsewhere. Null with the switch off */
1559
+ function hqDiffOf(stores: readonly string[]): () => Promise<string[] | null> {
1560
+ return async () => {
1561
+ const { cardsDiff, cardsOn, heldRepos } = await import('../hq/cards.ts')
1562
+ if (!cardsOn()) return null
1563
+ const { myHq } = await import('../hq/hq-local.ts')
1564
+ const hq = myHq()
1565
+ if ('refused' in hq) return [`the hq is not reached (${hq.refused}): the check hq-cards cannot prove both sides equal`]
1566
+ const { dirname } = await import('node:path')
1567
+ const { held } = await heldRepos(stores.map((d) => ({ name: d, path: dirname(dirname(d)) })))
1568
+ const diff = await cardsDiff(hq, held)
1569
+ if ('refused' in diff) return [`the hq refused the check: ${diff.refused}`]
1570
+ return diff.flatMap((d) => (d.onlyHere.length + d.onlyHq.length + d.differ.length === 0 ? [] : [`${d.repo}: ${d.onlyHere.length} only here, ${d.onlyHq.length} only in the hq, ${d.differ.length} at two revs (${[...d.onlyHere, ...d.onlyHq, ...d.differ].slice(0, 3).join(', ')})`]))
1571
+ }
1572
+ }
1573
+
1574
+ export class ReviewExportCommand extends Command {
1575
+ static override paths = [['review', 'export']]
1576
+ static override usage = Command.Usage({
1577
+ category: 'Review',
1578
+ description: 'cards of this repo written as the files of a card, into a folder',
1579
+ details: `${DETAILS}\n\nWith the switch cards-in-db on, a card is rows of the daemon's database; export writes it as the folder the files backend keeps (\`<to>/<id>/item.json\`, \`thread/<message>.json\`, and each media file this machine still holds; a file the disk let go is named, its key in the head's media). Nothing in the store changes.`,
1580
+ examples: [['one card', 'sk thread export 20261118-210000-the-gate --to /tmp/cards'], ['every card of the repo', 'sk thread export --all --to /tmp/cards']],
1581
+ })
1582
+ all = Option.Boolean('--all', false, { description: 'every card of the repo' })
1583
+ to = Option.String('--to', { required: true, description: 'the folder the cards are written into' })
1584
+ ids = Option.Rest()
1585
+
1586
+ async execute(): Promise<number> {
1587
+ return run(this.context, async (h) => {
1588
+ const { cardsInDb } = await import('../hq/switch.ts')
1589
+ const { resolve } = await import('node:path')
1590
+ if (this.all === this.ids.length > 0) throw new Error('give card ids or --all')
1591
+ const to = resolve(this.to)
1592
+ if (to === resolve(h.dir)) throw new Error(`--to ${this.to}: the store itself; sk thread move --back --go writes the rows into the store`)
1593
+ const ids = this.all ? undefined : await Promise.all(this.ids.map((r) => idOf(h.dir, r)))
1594
+ let r: import('../review/move.ts').Moved
1595
+ if (cardsInDb()) r = (await import('../review/move.ts')).exportRows(h.dir, { to, ...(ids ? { ids } : {}) })
1596
+ else {
1597
+ // the files are the store: a copy of each folder is the export
1598
+ const { cpSync, existsSync } = await import('node:fs')
1599
+ const { cardIds } = await import('../review/store.ts')
1600
+ const { join } = await import('node:path')
1601
+ const want = ids ?? cardIds(h.dir)
1602
+ for (const id of want) if (!existsSync(join(to, id))) cpSync(join(h.dir, id), join(to, id), { recursive: true })
1603
+ r = { dir: h.dir, cards: want.length, heads: want.length, msgs: 0, gone: 0, same: 0, files: 0, kept: [], broken: [], read: [] }
1604
+ }
1605
+ h.out(`review: ${r.cards} cards written into ${to} (${r.heads} heads, ${r.msgs} messages${r.media ? `, ${r.media.copied} media files` : ''})`)
1606
+ for (const k of r.kept) h.out(` kept: ${k}`)
1607
+ for (const b of r.broken) h.err(` does not read: ${b}`)
1608
+ if (r.media && r.media.missing.length > 0) h.out(` ${r.media.missing.length} media files this machine no longer holds (the Space has them by their key in the head): ${r.media.missing.slice(0, 5).join(', ')}`)
1609
+ return r.broken.length > 0 ? 1 : 0
1610
+ })
1611
+ }
1612
+ }
1613
+
1614
+ /** `post <address | id>`: a version in the thread that owns the address (or holds the id), started when none does;
1615
+ * every flag of add after it */
1616
+ export class ThreadPostCommand extends Command {
1617
+ static override paths = [['thread', 'post']]
1618
+ static essential = {}
1619
+ static override usage = Command.Usage({
1620
+ category: 'Review',
1621
+ description: 'a version in the thread of an object, by its address; the thread starts when none owns it',
1622
+ details: `${DETAILS}\n\nThe address is the version's own (page:review/lightbox, draft:<slug>, trailer:<name>/<cut>); an item id names its thread instead. Every other flag is add's (sk thread add --help): --title, --what, the media, --keeps. The tool links it into the thread: you never type a --supersedes. Page: wiki tools/shipkit/threads.md`,
1623
+ examples: [['a version of a hub page', 'SK_AGENT=L12 sk thread post page:review/lightbox --title "…" --what "…" --before a.png --after b.png'], ['the next version of a thread', 'sk thread post 20261119-233610-trailer-v15 --title "…" --what "…" --image c.png']],
1624
+ })
1625
+ target = Option.String()
1626
+ rest = Option.Proxy()
1627
+
1628
+ async execute(): Promise<number> {
1629
+ const { ADDRESS_RE, ID_RE } = await import('../review/model.ts')
1630
+ const t = this.target.trim()
1631
+ let link: string[]
1632
+ if (ADDRESS_RE.test(t) && !ID_RE.test(t)) link = ['--on', t]
1633
+ else {
1634
+ const { storeDir, readAll } = await import('../review/store.ts')
1635
+ const root = await reviewRoot(process.cwd())
1636
+ if (root == null) throw new Error(`${process.cwd()} is in no shipkit repo`)
1637
+ const { openReview } = await import('../review/project.ts')
1638
+ const { dir } = await openReview(root)
1639
+ const id = await idOf(dir ?? storeDir(root), t)
1640
+ const { threadOfId } = await import('../review/cells.ts')
1641
+ const { threadsOf } = await import('../review/threads.ts')
1642
+ const head = threadOfId(id, threadsOf(readAll(dir).items))?.head.item
1643
+ if (!head) throw new Error(`no thread holds ${t}`)
1644
+ link = head.origin.by === 'agent' ? ['--supersedes', head.id] : ['--answers', head.id]
1645
+ }
1646
+ return this.cli.run(['thread', 'add', ...link, ...this.rest])
1647
+ }
1648
+ }
1649
+
1650
+ /** `propose <address> --after "<text>"`: a change of an object's text he applies in one click, or edits first */
1651
+ export class ThreadProposeCommand extends Command {
1652
+ static override paths = [['thread', 'propose']]
1653
+ static override usage = Command.Usage({
1654
+ category: 'Review',
1655
+ description: "a change of an object's text he applies in one click, or edits first; you land what he applied",
1656
+ details: `${DETAILS}\n\nIt goes into the thread that owns the address, or the one above it (--in <id> names another). --before and --after are the text (--before-file, --after-file read a file). His « apply » reaches your watch as \`<id> applied your change of <address>: land this text: …\`: you write it where the object lives and say so in the thread. Page: wiki tools/shipkit/threads.md`,
1657
+ examples: [['a phrasing', 'SK_AGENT=L12 sk thread propose messages:tui/u1 --before "Run any workflow" --after "Run your workflow from the terminal" "shorter, and says where"']],
1658
+ })
1659
+ address = Option.String()
1660
+ words = Option.String({ required: false })
1661
+ before = Option.String('--before', { description: 'the text as it is' })
1662
+ after = Option.String('--after', { description: 'the text you propose' })
1663
+ beforeFile = Option.String('--before-file', { description: 'the text as it is, from a file' })
1664
+ afterFile = Option.String('--after-file', { description: 'the text you propose, from a file' })
1665
+ into = Option.String('--in', { description: 'the thread to post it in, by an id or an address, when it is not the address own' })
1666
+ as = Option.String('--as', { description: 'who acts (else SK_AGENT)' })
1667
+
1668
+ async execute(): Promise<number> {
1669
+ return run(this.context, async (h) => {
1670
+ const { readFileSync } = await import('node:fs')
1671
+ const { postPropose } = await import('../review/store.ts')
1672
+ const read = (v: string | undefined, f: string | undefined): string | undefined => (f !== undefined ? readFileSync(f, 'utf8') : v)
1673
+ const after = read(this.after, this.afterFile)
1674
+ if (after === undefined) throw new Error('--after "<text>" (or --after-file): the text you propose')
1675
+ const before = read(this.before, this.beforeFile)
1676
+ const id = await idOf(h.dir, this.into ?? this.address)
1677
+ const m = postPropose(h.dir, id, { who: actor(this.as, false, 'propose'), text: this.words ?? `a change of ${this.address}`, on: this.address, ...(before !== undefined ? { before } : {}), after })
1678
+ h.out(`${id} proposed ${m.propose?.on}: he applies it in the hub`)
1679
+ return 0
1680
+ })
1681
+ }
1682
+ }
1683
+
1684
+ /** `attach <thread> <address>`: the thread links one more object */
1685
+ export class ThreadAttachCommand extends Command {
1686
+ static override paths = [['thread', 'attach']]
1687
+ static override usage = Command.Usage({
1688
+ category: 'Review',
1689
+ description: 'a thread links one more object: its thread control finds the thread; never its own address',
1690
+ details: `${DETAILS}\n\nA link: many threads may link one object. Page: wiki tools/shipkit/threads.md`,
1691
+ examples: [['link a media', 'sk thread attach 20261119-233610-trailer-v15 media:thumbnail-v3']],
1692
+ })
1693
+ thread = Option.String()
1694
+ address = Option.String()
1695
+ as = Option.String('--as', { description: 'who acts (else SK_AGENT)' })
1696
+
1697
+ async execute(): Promise<number> {
1698
+ return run(this.context, async (h) => {
1699
+ const { attachTo } = await import('../review/store.ts')
1700
+ const id = await idOf(h.dir, this.thread)
1701
+ attachTo(h.dir, id, actor(this.as, false, 'attach'), this.address)
1702
+ h.out(`${id} links ${this.address}`)
1703
+ return 0
1704
+ })
1705
+ }
1706
+ }
1707
+
1708
+ export class ReviewMigrateCommand extends Command {
1709
+ static override paths = [
1710
+ ['thread', 'migrate'],
1711
+ ['review', 'migrate'],
1712
+ ]
1713
+ static override usage = Command.Usage({
1714
+ category: 'Review',
1715
+ description: "fold the threads that own one address into one; dry run, --go after a backup",
1716
+ details: `${DETAILS}\n\nA look unless --go: per store, the links it would write (address, version, the version it supersedes) and the threads before and after. --go first runs sk backup (the machine db, where the daemon's rows are, goes to the Space as a snapshot) and stops when it fails, then writes each link through the head's one rewrite path. Only a missing link is written: a second run finds nothing. His notes read in their thread already: none is written. With hq-cards on, each changed head goes to the hq like any changed head. Page: wiki tools/shipkit/threads-store.md, The one thread guard`,
1717
+ examples: [['what it would fold here', 'sk thread migrate'], ['every house store', 'sk thread migrate --all'], ['fold them', 'sk thread migrate --all --go']],
1718
+ })
1719
+ go = Option.Boolean('--go', false, { description: 'write the links, after a backup' })
1720
+ all = Option.Boolean('--all', false, { description: 'every house store of this machine, not only this repo' })
1721
+
1722
+ async execute(): Promise<number> {
1723
+ return run(this.context, async (h) => {
1724
+ const { dirname } = await import('node:path')
1725
+ const { openReview } = await import('../review/project.ts')
1726
+ const { foldStore } = await import('../review/thread-fold.ts')
1727
+ const { repoIdOf } = await import('../review/card-db.ts')
1728
+ const { cardsInDb } = await import('../hq/switch.ts')
1729
+ const { existsSync } = await import('node:fs')
1730
+ const dirs = this.all ? await houseStores() : [h.dir]
1731
+ const seen = new Set<string>()
1732
+ const stores = dirs.filter((d) => {
1733
+ const key = cardsInDb() ? repoIdOf(d) : d
1734
+ if (seen.has(key)) return false
1735
+ seen.add(key)
1736
+ return cardsInDb() || existsSync(d)
1737
+ })
1738
+ const plans = []
1739
+ for (const d of stores) {
1740
+ await openReview(dirname(dirname(d)))
1741
+ plans.push({ d, ...foldStore(d, { go: false }) })
1742
+ }
1743
+ const todo = plans.filter((p) => p.links.length > 0)
1744
+ for (const p of plans) h.out(`${p.d}: ${p.links.length} links, ${p.before} threads to ${p.after}`)
1745
+ for (const p of todo) for (const l of p.links) h.out(` ${l.address}: ${l.id} supersedes ${l.supersedes}`)
1746
+ if (todo.length === 0) {
1747
+ h.out('ok: every address is one thread, nothing to fold')
1748
+ return 0
1749
+ }
1750
+ if (!this.go) {
1751
+ h.out(`a look: nothing written. ${this.all ? 'sk thread migrate --all --go' : 'sk thread migrate --go'} backs up, then folds`)
1752
+ return 0
1753
+ }
1754
+ h.out('backup first: sk backup')
1755
+ const b = Bun.spawnSync(['sk', 'backup'], { stdout: 'pipe', stderr: 'pipe' })
1756
+ const said = `${b.stdout?.toString() ?? ''}${b.stderr?.toString() ?? ''}`.trim()
1757
+ for (const l of said.split('\n').slice(-3)) h.out(` ${l}`)
1758
+ if (b.exitCode !== 0) throw new Error('sk backup failed: nothing folded, the stores are as they were')
1759
+ for (const p of todo) {
1760
+ const r = foldStore(p.d, { go: true })
1761
+ h.out(`${p.d}: ${r.links.length} links written, ${r.before} threads to ${r.after}`)
1762
+ }
1763
+ return 0
1764
+ })
1765
+ }
1766
+ }
1767
+
1329
1768
  export const REVIEW_COMMANDS = [
1330
1769
  ReviewLsCommand,
1331
1770
  ReviewAddCommand,
@@ -1359,4 +1798,16 @@ export const REVIEW_COMMANDS = [
1359
1798
  ReviewStageCommand,
1360
1799
  ReviewAutoCommand,
1361
1800
  ReviewWatchCommand,
1801
+ ReviewMoveCommand,
1802
+ ReviewExportCommand,
1803
+ ReviewMigrateCommand,
1804
+ ThreadPostCommand,
1805
+ ThreadProposeCommand,
1806
+ ThreadAttachCommand,
1362
1807
  ]
1808
+
1809
+ // every verb is `sk thread <verb>`, and `sk review <verb>` its older name (run() says the new form on stderr)
1810
+ for (const C of REVIEW_COMMANDS) {
1811
+ const paths = (C.paths ?? []).flatMap((p) => (p[0] === 'review' ? [['thread', ...p.slice(1)], p] : [p]))
1812
+ C.paths = paths.filter((p, i) => paths.findIndex((q) => q.join(' ') === p.join(' ')) === i)
1813
+ }