rvlib-shipkit 2.26.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 (442) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/package.json +1 -1
  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 +6 -4
  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 +122 -21
  11. package/src/agent-time/report-cache.ts +57 -0
  12. package/src/agent-time/report.ts +314 -40
  13. package/src/agent-time/shape.ts +50 -3
  14. package/src/agent-time/store.ts +320 -99
  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/SK047-login-in-description.check.ts +36 -0
  34. package/src/checks/SK048-one-local-file.check.ts +36 -0
  35. package/src/cli/cmd_Asks.ts +71 -5
  36. package/src/cli/cmd_Backup.ts +2 -2
  37. package/src/cli/cmd_Capacity.ts +2 -2
  38. package/src/cli/cmd_CrossRepoActivity.ts +5 -4
  39. package/src/cli/cmd_Db.ts +253 -0
  40. package/src/cli/cmd_History.ts +212 -0
  41. package/src/cli/cmd_Home.ts +31 -3
  42. package/src/cli/cmd_Hq.ts +516 -0
  43. package/src/cli/cmd_Machines.ts +36 -0
  44. package/src/cli/cmd_Media.ts +38 -6
  45. package/src/cli/cmd_Reflect.ts +23 -2
  46. package/src/cli/cmd_Review.ts +548 -116
  47. package/src/cli/cmd_Secret.ts +62 -12
  48. package/src/cli/cmd_Social.ts +83 -1
  49. package/src/cli/cmd_Space.ts +324 -0
  50. package/src/cli/cmd_Time.ts +76 -5
  51. package/src/cli/cmd_Tmp.ts +28 -4
  52. package/src/cli/cmd_Trailer.ts +14 -10
  53. package/src/cli/cmd_Urls.ts +56 -0
  54. package/src/cli/cmd_Vault.ts +583 -0
  55. package/src/cli/family-help.ts +4 -2
  56. package/src/cli/family-pages.ts +1 -1
  57. package/src/cli/registry.ts +24 -3
  58. package/src/collections/actions.ts +63 -13
  59. package/src/collections/collection-types.ts +23 -1
  60. package/src/collections/providers.ts +117 -23
  61. package/src/collections/review.ts +4 -4
  62. package/src/contracts/contract-manifests.ts +6 -5
  63. package/src/contracts/contract-types.ts +6 -4
  64. package/src/contracts/contracts-engine.ts +11 -0
  65. package/src/contracts/manifests/chrome-web-store.contract.ts +31 -0
  66. package/src/core/budget.ts +12 -17
  67. package/src/core/capacity.ts +27 -18
  68. package/src/core/check-runner.ts +7 -4
  69. package/src/core/layout.ts +3 -0
  70. package/src/core/machine-busy.ts +127 -0
  71. package/src/core/machine-commit.ts +6 -1
  72. package/src/core/machine-db.ts +368 -20
  73. package/src/core/machine-layout.ts +137 -0
  74. package/src/core/machine-read.ts +81 -0
  75. package/src/core/migrate-layout.ts +1 -1
  76. package/src/core/one-way-in-policy.ts +64 -7
  77. package/src/core/polling-policy.ts +27 -0
  78. package/src/core/retention.ts +16 -2
  79. package/src/core/scope.ts +107 -14
  80. package/src/core/slots.ts +5 -4
  81. package/src/drill/clean.ts +25 -1
  82. package/src/drill/run.ts +1 -1
  83. package/src/drill/seal.ts +27 -4
  84. package/src/home/activity-shape.ts +2 -0
  85. package/src/home/activity.ts +66 -3
  86. package/src/home/app-sign.ts +15 -4
  87. package/src/home/daemon-jobs.ts +149 -7
  88. package/src/home/database-projects.ts +111 -0
  89. package/src/home/database-words.ts +203 -0
  90. package/src/home/databases.ts +460 -0
  91. package/src/home/global-units.ts +6 -0
  92. package/src/home/gui-app/ShipkitGui.swift +122 -1
  93. package/src/home/gui-app.ts +6 -3
  94. package/src/home/home-move.ts +514 -0
  95. package/src/home/home-paths.ts +12 -3
  96. package/src/home/home-routes.ts +68 -0
  97. package/src/home/inbox-shape.ts +24 -14
  98. package/src/home/machine-fold.ts +820 -0
  99. package/src/home/machine-host.ts +20 -5
  100. package/src/home/machine-repair.ts +503 -0
  101. package/src/home/machine-stores.ts +66 -15
  102. package/src/home/machine-temp.ts +547 -86
  103. package/src/home/resume.ts +79 -0
  104. package/src/home/run-daemon.ts +25 -4
  105. package/src/home/run-pm.ts +18 -5
  106. package/src/home/serve-daemon.ts +18 -3
  107. package/src/home/serve-web.ts +175 -7
  108. package/src/home/space-job.ts +115 -0
  109. package/src/home/space-page.ts +257 -0
  110. package/src/home/space-route.ts +167 -0
  111. package/src/home/space-words.ts +103 -0
  112. package/src/home/time-page-shape.ts +202 -0
  113. package/src/home/time-page.ts +64 -0
  114. package/src/home/vault-page.ts +482 -0
  115. package/src/home/vault-words.ts +132 -0
  116. package/src/hooks/leak-guard.ts +40 -13
  117. package/src/hooks/one-way-in-guard.ts +17 -4
  118. package/src/hq/cards.ts +581 -0
  119. package/src/hq/door-route.ts +43 -0
  120. package/src/hq/door.ts +163 -0
  121. package/src/hq/files-send.ts +348 -0
  122. package/src/hq/forgotten-log.ts +35 -0
  123. package/src/hq/history-check.ts +255 -0
  124. package/src/hq/history-place.ts +146 -0
  125. package/src/hq/history-send.ts +487 -0
  126. package/src/hq/hq-db.ts +99 -0
  127. package/src/hq/hq-local.ts +469 -0
  128. package/src/hq/hq-routes.ts +196 -0
  129. package/src/hq/hq-store.ts +599 -0
  130. package/src/hq/kinds/ask.ts +147 -0
  131. package/src/hq/kinds/card-gone.ts +83 -0
  132. package/src/hq/kinds/card-msg.ts +66 -0
  133. package/src/hq/kinds/card.ts +99 -0
  134. package/src/hq/kinds/index.ts +21 -0
  135. package/src/hq/kinds/kind.ts +126 -0
  136. package/src/hq/kinds/media.ts +125 -0
  137. package/src/hq/kinds/prompt.ts +219 -0
  138. package/src/hq/kinds/reflection.ts +128 -0
  139. package/src/hq/kinds/report.ts +55 -0
  140. package/src/hq/kinds/time-day.ts +236 -0
  141. package/src/hq/ledger.ts +473 -0
  142. package/src/hq/machine-key.ts +44 -0
  143. package/src/hq/machine-notes.ts +131 -0
  144. package/src/hq/outbox.ts +372 -0
  145. package/src/hq/replica.ts +168 -0
  146. package/src/hq/repo-id.ts +4 -0
  147. package/src/hq/report-facts.ts +117 -0
  148. package/src/hq/report.ts +274 -0
  149. package/src/hq/switch.ts +151 -0
  150. package/src/hq/vault-grant.ts +92 -0
  151. package/src/identities/identities.ts +15 -3
  152. package/src/identities/steps.ts +31 -0
  153. package/src/ledger/db.ts +73 -26
  154. package/src/ledger/gate-checks.ts +6 -2
  155. package/src/ledger/run-log.ts +11 -3
  156. package/src/ledger/store.ts +26 -4
  157. package/src/media-store/backup/daemon.ts +25 -17
  158. package/src/media-store/backup/kept.ts +241 -0
  159. package/src/media-store/backup/restore.ts +14 -4
  160. package/src/media-store/backup/run.ts +11 -11
  161. package/src/media-store/backup/secret.ts +6 -4
  162. package/src/media-store/backup/snapshot.ts +4 -2
  163. package/src/media-store/backup/sources.ts +67 -16
  164. package/src/media-store/copy/config.ts +77 -0
  165. package/src/media-store/copy/copy.ts +194 -0
  166. package/src/media-store/copy/lifecycle.ts +43 -0
  167. package/src/media-store/copy/night.ts +90 -0
  168. package/src/media-store/copy/proof.ts +151 -0
  169. package/src/media-store/copy/snapshot.ts +152 -0
  170. package/src/media-store/copy/store.ts +62 -0
  171. package/src/media-store/copy/stream.ts +176 -0
  172. package/src/media-store/daemon.ts +66 -16
  173. package/src/media-store/db.ts +22 -11
  174. package/src/media-store/forget.ts +23 -3
  175. package/src/media-store/hand.ts +4 -3
  176. package/src/media-store/hq-find.ts +75 -0
  177. package/src/media-store/hq-send.ts +277 -0
  178. package/src/media-store/kind.ts +2 -0
  179. package/src/media-store/purge.ts +18 -15
  180. package/src/media-store/put.ts +24 -8
  181. package/src/media-store/remote.ts +16 -7
  182. package/src/media-store/space-listing.ts +240 -0
  183. package/src/media-store/space.ts +40 -21
  184. package/src/media-store/sync.ts +5 -5
  185. package/src/media-store/tidy.ts +98 -0
  186. package/src/media-store/upload.ts +3 -3
  187. package/src/media-store/webp.ts +66 -0
  188. package/src/messages/model.ts +16 -7
  189. package/src/messages/routes.ts +14 -4
  190. package/src/messages/score.ts +2 -2
  191. package/src/messages/suggest.ts +96 -0
  192. package/src/pages/frame-client.ts +10 -0
  193. package/src/plan/planner.ts +28 -17
  194. package/src/recordings/media-kind.ts +1 -0
  195. package/src/recordings/model.ts +1 -1
  196. package/src/recordings/recorder-app/Capture.swift +9 -7
  197. package/src/reflect/hq-corpus.ts +56 -0
  198. package/src/reflect/prompt-corpus.ts +3 -1
  199. package/src/reflect/transcript.ts +129 -37
  200. package/src/release/machine-words.ts +67 -0
  201. package/src/release/public-clean.ts +8 -3
  202. package/src/releases/from-card.ts +1 -1
  203. package/src/releases/routes.ts +10 -5
  204. package/src/releases/store.ts +10 -1
  205. package/src/repo-config.ts +32 -2
  206. package/src/review/anim.ts +2 -2
  207. package/src/review/auto.ts +2 -2
  208. package/src/review/card-db.ts +244 -0
  209. package/src/review/card-rows.ts +266 -0
  210. package/src/review/cells.ts +76 -5
  211. package/src/review/draft-card.ts +41 -0
  212. package/src/review/draft-model.ts +78 -0
  213. package/src/review/format.ts +29 -10
  214. package/src/review/gone.ts +98 -0
  215. package/src/review/inbox-hook.ts +4 -4
  216. package/src/review/marks.ts +1 -1
  217. package/src/review/media-kind.ts +7 -5
  218. package/src/review/media-read.ts +9 -7
  219. package/src/review/media.ts +32 -5
  220. package/src/review/model.ts +202 -39
  221. package/src/review/move.ts +491 -0
  222. package/src/review/notes.ts +12 -20
  223. package/src/review/previews.ts +15 -19
  224. package/src/review/project.ts +1 -1
  225. package/src/review/rev.ts +8 -0
  226. package/src/review/role.ts +1 -1
  227. package/src/review/routes.ts +64 -13
  228. package/src/review/stage-card.ts +8 -4
  229. package/src/review/stage-routes.ts +1 -1
  230. package/src/review/store.ts +529 -83
  231. package/src/review/thread-fold.ts +51 -0
  232. package/src/review/threads.ts +147 -9
  233. package/src/review/trailer-auto-mock.ts +63 -0
  234. package/src/review/trailer-card.ts +4 -4
  235. package/src/review/trailer-desk.ts +41 -7
  236. package/src/review/trailer-media.ts +1 -0
  237. package/src/review/trailer-model.ts +8 -0
  238. package/src/review/trailer-notes.ts +1 -1
  239. package/src/review/trailer-routes.ts +9 -1
  240. package/src/review/unit.ts +6 -6
  241. package/src/review/watchers.ts +1 -1
  242. package/src/rules/untrack-generated.ts +92 -8
  243. package/src/secrets/held.ts +16 -0
  244. package/src/secrets/keychain.ts +113 -0
  245. package/src/secrets/list.ts +16 -6
  246. package/src/secrets/manager.ts +24 -10
  247. package/src/secrets/read.ts +257 -0
  248. package/src/secrets/who-reads.ts +49 -0
  249. package/src/serve/door-forward.ts +268 -0
  250. package/src/serve/door-names.ts +47 -0
  251. package/src/serve/embed.ts +1 -1
  252. package/src/serve/hub-app/activity-view.tsx +56 -32
  253. package/src/serve/hub-app/activity.css +7 -1
  254. package/src/serve/hub-app/asks-page.tsx +48 -0
  255. package/src/serve/hub-app/asks-st.ts +25 -0
  256. package/src/serve/hub-app/clock-svc.ts +1 -2
  257. package/src/serve/hub-app/col-card.tsx +64 -13
  258. package/src/serve/hub-app/col-list-page.tsx +122 -0
  259. package/src/serve/hub-app/col-list-st.ts +103 -0
  260. package/src/serve/hub-app/col-tables-view.tsx +10 -41
  261. package/src/serve/hub-app/col-tables.ts +76 -8
  262. package/src/serve/hub-app/cols-svc.ts +70 -16
  263. package/src/serve/hub-app/database-st.ts +260 -0
  264. package/src/serve/hub-app/database-view.tsx +289 -0
  265. package/src/serve/hub-app/database.css +32 -0
  266. package/src/serve/hub-app/entry-bar.css +14 -0
  267. package/src/serve/hub-app/entry-bar.tsx +33 -0
  268. package/src/serve/hub-app/entry-pick.ts +31 -0
  269. package/src/serve/hub-app/floating.tsx +1 -0
  270. package/src/serve/hub-app/hash-route.ts +11 -1
  271. package/src/serve/hub-app/header-bar.tsx +14 -18
  272. package/src/serve/hub-app/home-st.ts +89 -9
  273. package/src/serve/hub-app/home-strip.css +5 -19
  274. package/src/serve/hub-app/home-strip.tsx +58 -92
  275. package/src/serve/hub-app/home.html +7 -0
  276. package/src/serve/hub-app/hub-app.tsx +31 -142
  277. package/src/serve/hub-app/hub-types.ts +3 -1
  278. package/src/serve/hub-app/hub.css +109 -23
  279. package/src/serve/hub-app/icons.tsx +18 -1
  280. package/src/serve/hub-app/identities-st.ts +56 -6
  281. package/src/serve/hub-app/identities-view.tsx +100 -58
  282. package/src/serve/hub-app/identities.css +17 -15
  283. package/src/serve/hub-app/identity-address.ts +5 -0
  284. package/src/serve/hub-app/inbox-st.ts +41 -24
  285. package/src/serve/hub-app/inbox-view.tsx +37 -41
  286. package/src/serve/hub-app/inbox.css +2 -5
  287. package/src/serve/hub-app/index.html +7 -0
  288. package/src/serve/hub-app/kept-cols.tsx +7 -0
  289. package/src/serve/hub-app/keys.ts +28 -15
  290. package/src/serve/hub-app/later.tsx +26 -0
  291. package/src/serve/hub-app/list-filter.tsx +14 -0
  292. package/src/serve/hub-app/list-walk.ts +72 -3
  293. package/src/serve/hub-app/machines-st.ts +251 -0
  294. package/src/serve/hub-app/machines-view.tsx +224 -0
  295. package/src/serve/hub-app/machines.css +76 -0
  296. package/src/serve/hub-app/md-copy.tsx +79 -0
  297. package/src/serve/hub-app/media-view.tsx +2 -0
  298. package/src/serve/hub-app/messages/messages-page.tsx +79 -7
  299. package/src/serve/hub-app/messages/messages-st.ts +99 -3
  300. package/src/serve/hub-app/messages.css +14 -0
  301. package/src/serve/hub-app/page-keys.ts +175 -0
  302. package/src/serve/hub-app/pages-frames.tsx +11 -3
  303. package/src/serve/hub-app/palette-st.ts +58 -11
  304. package/src/serve/hub-app/palette-view.tsx +3 -1
  305. package/src/serve/hub-app/project-list.css +54 -8
  306. package/src/serve/hub-app/project-list.tsx +128 -59
  307. package/src/serve/hub-app/projects-svc.ts +78 -7
  308. package/src/serve/hub-app/reader-chips.tsx +13 -0
  309. package/src/serve/hub-app/readme-view.tsx +2 -3
  310. package/src/serve/hub-app/readme.css +27 -5
  311. package/src/serve/hub-app/reflections-page.tsx +42 -0
  312. package/src/serve/hub-app/reflections-st.ts +17 -0
  313. package/src/serve/hub-app/releases/releases-page.tsx +25 -2
  314. package/src/serve/hub-app/releases/releases-st.ts +1 -1
  315. package/src/serve/hub-app/repo-sections.ts +9 -5
  316. package/src/serve/hub-app/repo-st.ts +35 -8
  317. package/src/serve/hub-app/review/draft-card.tsx +163 -0
  318. package/src/serve/hub-app/review/kit.tsx +50 -7
  319. package/src/serve/hub-app/review/note-place.ts +1 -1
  320. package/src/serve/hub-app/review/review-board.tsx +2 -2
  321. package/src/serve/hub-app/review/review-cells.tsx +145 -65
  322. package/src/serve/hub-app/review/review-kit.ts +27 -1
  323. package/src/serve/hub-app/review/review-list.tsx +68 -30
  324. package/src/serve/hub-app/review/review-page.tsx +7 -8
  325. package/src/serve/hub-app/review/review-st.ts +111 -24
  326. package/src/serve/hub-app/review/review-thread.tsx +49 -19
  327. package/src/serve/hub-app/review/review-views.tsx +475 -144
  328. package/src/serve/hub-app/review/thread-control-st.ts +115 -0
  329. package/src/serve/hub-app/review/thread-control.tsx +74 -0
  330. package/src/serve/hub-app/review/thread-st.ts +73 -26
  331. package/src/serve/hub-app/review/trailer-card.tsx +1 -1
  332. package/src/serve/hub-app/review/trailer-page.tsx +37 -16
  333. package/src/serve/hub-app/review/trailer-st.ts +41 -7
  334. package/src/serve/hub-app/review.css +267 -61
  335. package/src/serve/hub-app/side-lists.ts +72 -0
  336. package/src/serve/hub-app/sidebar.tsx +6 -3
  337. package/src/serve/hub-app/site/site-part.tsx +2 -8
  338. package/src/serve/hub-app/site/site-st.ts +4 -4
  339. package/src/serve/hub-app/social/comms-page.tsx +20 -5
  340. package/src/serve/hub-app/social/kit.tsx +30 -4
  341. package/src/serve/hub-app/social/post-card.tsx +139 -49
  342. package/src/serve/hub-app/social/serial-writes.ts +13 -0
  343. package/src/serve/hub-app/social/social-model.ts +11 -0
  344. package/src/serve/hub-app/social/social-page.tsx +94 -35
  345. package/src/serve/hub-app/social/social-st.ts +120 -36
  346. package/src/serve/hub-app/social/stage-popup.tsx +1 -1
  347. package/src/serve/hub-app/social/stage-st.ts +1 -1
  348. package/src/serve/hub-app/social/step-layout.ts +1 -1
  349. package/src/serve/hub-app/social.css +3 -0
  350. package/src/serve/hub-app/space-st.ts +209 -0
  351. package/src/serve/hub-app/space-view.tsx +196 -0
  352. package/src/serve/hub-app/space.css +27 -0
  353. package/src/serve/hub-app/stores/stores-page.tsx +91 -23
  354. package/src/serve/hub-app/stores/stores-st.ts +44 -19
  355. package/src/serve/hub-app/stores.css +6 -1
  356. package/src/serve/hub-app/theme-st.ts +22 -9
  357. package/src/serve/hub-app/time-charts.tsx +291 -0
  358. package/src/serve/hub-app/time-pages.tsx +749 -0
  359. package/src/serve/hub-app/time-st.ts +162 -0
  360. package/src/serve/hub-app/time-view.tsx +76 -0
  361. package/src/serve/hub-app/time.css +138 -0
  362. package/src/serve/hub-app/tree-build.ts +52 -42
  363. package/src/serve/hub-app/tree-row.tsx +4 -4
  364. package/src/serve/hub-app/tree-svc.ts +18 -9
  365. package/src/serve/hub-app/urls-svc.ts +154 -0
  366. package/src/serve/hub-app/urls-view.tsx +117 -0
  367. package/src/serve/hub-app/urls.css +30 -0
  368. package/src/serve/hub-app/vault-st.ts +127 -0
  369. package/src/serve/hub-app/vault-view.tsx +154 -0
  370. package/src/serve/hub-app/vault.css +38 -0
  371. package/src/serve/hub-app/veille/veille-st.ts +12 -10
  372. package/src/serve/hub-app/waiting-svc.ts +29 -0
  373. package/src/serve/hub-app/wikis-view.tsx +2 -2
  374. package/src/serve/hub-runtime.ts +15 -2
  375. package/src/serve/project-gutter-route.ts +27 -14
  376. package/src/serve/project-gutter.ts +25 -12
  377. package/src/serve/same-origin.ts +10 -0
  378. package/src/serve/serve-hub.ts +13 -4
  379. package/src/shipkit-files.ts +16 -2
  380. package/src/shipkit.ts +1 -1
  381. package/src/shot/shooter.ts +616 -420
  382. package/src/shot/shot-ask.ts +246 -155
  383. package/src/site/desk.ts +2 -2
  384. package/src/smoke/run-smoke.ts +3 -2
  385. package/src/social/cover.ts +202 -0
  386. package/src/social/discord-layout.ts +37 -13
  387. package/src/social/drafts.ts +3 -0
  388. package/src/social/load.ts +23 -2
  389. package/src/social/media-kind.ts +2 -1
  390. package/src/social/publish/discord.ts +5 -2
  391. package/src/social/publish/secret.ts +2 -2
  392. package/src/social/release-stage.ts +28 -13
  393. package/src/social/routes.ts +26 -1
  394. package/src/social/stage.ts +1 -1
  395. package/src/social/stats.ts +12 -9
  396. package/src/social/strip.ts +4 -1
  397. package/src/social/thumbnail.ts +255 -0
  398. package/src/stores/collection.ts +15 -11
  399. package/src/stores/desk.ts +236 -42
  400. package/src/stores/model.ts +72 -6
  401. package/src/stores/routes.ts +37 -12
  402. package/src/stores/unit.ts +14 -8
  403. package/src/suite/judge-suites.ts +41 -11
  404. package/src/suite/select.ts +45 -3
  405. package/src/suite/suite-cli.ts +16 -10
  406. package/src/trailer/bed.ts +1 -1
  407. package/src/trailer/build.ts +134 -21
  408. package/src/trailer/ffmpeg.ts +7 -0
  409. package/src/trailer/fonts.ts +3 -2
  410. package/src/trailer/grammar.ts +201 -2
  411. package/src/trailer/graph.ts +42 -5
  412. package/src/trailer/look.ts +21 -0
  413. package/src/trailer/mock.ts +154 -0
  414. package/src/trailer/passage.ts +65 -26
  415. package/src/trailer/score/heard.ts +89 -0
  416. package/src/trailer/score/sound.ts +14 -8
  417. package/src/trailer/sound/run.ts +16 -6
  418. package/src/trailer/stitch.ts +26 -5
  419. package/src/trailer/titles.ts +82 -19
  420. package/src/trailer/versions.ts +1 -3
  421. package/src/trailer/vertical.ts +3 -1
  422. package/src/urls/frame.ts +195 -0
  423. package/src/urls/routes.ts +43 -0
  424. package/src/urls/rows.ts +171 -0
  425. package/src/urls/unit.ts +73 -0
  426. package/src/vault/house-keys.ts +42 -0
  427. package/src/vault/layout.ts +50 -0
  428. package/src/vault/policy.ts +165 -0
  429. package/src/vault/vault-audit.ts +276 -0
  430. package/src/vault/vault-client.ts +40 -0
  431. package/src/vault/vault-config.ts +159 -0
  432. package/src/vault/vault-destroy.ts +78 -0
  433. package/src/vault/vault-handover.ts +305 -0
  434. package/src/vault/vault-http.ts +352 -0
  435. package/src/vault/vault-import.ts +208 -0
  436. package/src/vault/vault-init.ts +328 -0
  437. package/src/vault/vault-minter.ts +271 -0
  438. package/src/vault/vault-restore.ts +333 -0
  439. package/src/vault/vault-serve.ts +342 -0
  440. package/src/vault/vault-snapshot.ts +281 -0
  441. package/src/veille/asks.ts +1 -1
  442. package/src/veille/desk.ts +2 -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,10 +622,10 @@ 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'], ['as a Claude Code hook, on UserPromptSubmit and on Stop', 'sk review inbox --hook']],
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' })
570
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' })
@@ -580,7 +641,7 @@ export class ReviewInboxCommand extends Command {
580
641
  const h = input == null ? hh : { ...hh, out: (l: string) => void unseenLines.push(l) }
581
642
  const { liveWatchers } = await import('../review/watchers.ts')
582
643
  const { readAll } = await import('../review/store.ts')
583
- 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')
584
645
  const { followedIds, threadOfItem, threadsOf, unseen } = await import('../review/threads.ts')
585
646
  const { detail, threadDetail, untakenLine } = await import('../review/format.ts')
586
647
  const kinds = [...Object.keys(h.say.spec.kinds), ...Object.keys(BUILTIN_KINDS)]
@@ -589,7 +650,9 @@ export class ReviewInboxCommand extends Command {
589
650
  await pull(h)
590
651
  const all = readAll(h.dir)
591
652
  for (const b of all.broken) h.err(`review: FAIL ${b.id}: ${b.error}`)
592
- 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)
593
656
  const news = unseen(all.items).filter(of)
594
657
  const followed = followedIds(all.items)
595
658
  // what he or a player raised and nobody closed is the agents' move, read or not
@@ -616,12 +679,12 @@ export class ReviewInboxCommand extends Command {
616
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')
617
680
  const owedLine = (x: (typeof all.items)[number]): string => {
618
681
  const fix = verdictOf(x)?.status === 'approved-with-fix'
619
- const close = fix ? `sk review done ${x.item.id} "<what changed>"` : `--supersedes ${x.item.id} on its new version`
620
- 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>"`
621
684
  }
622
685
  if (input != null) {
623
686
  const approvals = news.filter(plain)
624
- if (approvals.length > 0) h.out(`${approvals.length} plain approval(s), nothing to do: sk review seen ${approvals.map((x) => x.item.id).join(' ')}`)
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(' ')}`)
625
688
  const said = unseenLines.filter((l) => l !== 'review: no unseen feedback or reply').join('\n').trim()
626
689
  const answer = hookAnswer(input, said, owed.map((t) => t.head.item.id))
627
690
  if (answer != null) hh.out(answer)
@@ -635,8 +698,8 @@ export class ReviewInboxCommand extends Command {
635
698
  })
636
699
  if (untaken.length > 0) h.out(`not taken:\n${untaken.join('\n')}\n`)
637
700
  const approvals = this.all ? [] : news.filter(plain)
638
- 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(' ')}`)
639
- 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>"')
640
703
  return all.broken.length > 0 ? 1 : 0
641
704
  })
642
705
  }
@@ -685,7 +748,7 @@ export class ReviewSeenCommand extends Command {
685
748
  export class ReviewReplyCommand extends Command {
686
749
  static override paths = [['review', 'reply']]
687
750
  static essential = { args: '<id> <text>' }
688
- 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 })
689
752
  id = Option.String()
690
753
  text = Option.String()
691
754
  image = Option.String('--image', { description: 'an image beside the words' })
@@ -709,13 +772,13 @@ export class ReviewUpdateCommand extends Command {
709
772
  static essential = { args: '<id> <state> <text>' }
710
773
  static override usage = Command.Usage({
711
774
  category: 'Review',
712
- description: "where a card's work stands, any time: broken, better or fixed, a line, a file or a pair",
713
- 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.`,
714
777
  examples: [
715
- ['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'],
716
- ['better, not done', 'SK_AGENT=L2 sk review update <id> better "the crossing is gone, the landing still snaps" take.mp4'],
717
- ['fixed: he answers again', 'SK_AGENT=L2 sk review update <id> fixed "no crossing, no snap over the whole clip" take.mp4'],
718
- ['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'],
719
782
  ],
720
783
  })
721
784
  id = Option.String()
@@ -723,6 +786,7 @@ export class ReviewUpdateCommand extends Command {
723
786
  text = Option.String()
724
787
  files = Option.Rest()
725
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' })
726
790
 
727
791
  async execute(): Promise<number> {
728
792
  return run(this.context, async (h) => {
@@ -734,12 +798,12 @@ export class ReviewUpdateCommand extends Command {
734
798
  const id = threadOfId(asked, threadsOf(readAll(h.dir).items))?.head.item.id ?? asked
735
799
  const refused = await answererRefusal(h.dir, id, this.as, 'reply')
736
800
  if (refused !== null) throw new Error(refused)
737
- const r = await postUpdate(h.dir, id, { who: laneOfCaller(this.as) ?? agentName(), state: this.state, text: this.text, files: this.files })
738
- 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')
739
803
  const { readItem } = await import('../review/store.ts')
740
804
  const x = readItem(h.dir, id)
741
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'
742
- 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}`)
743
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)
744
808
  const { unheardLine } = await import('../review/model.ts')
745
809
  const { liveWatchers } = await import('../review/watchers.ts')
@@ -752,7 +816,7 @@ export class ReviewUpdateCommand extends Command {
752
816
 
753
817
  export class ReviewWithdrawCommand extends Command {
754
818
  static override paths = [['review', 'withdraw']]
755
- 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 })
756
820
  ids = Option.Rest({ required: 1 })
757
821
  why = Option.String('--why,--note', { required: true, description: 'why it goes (--note says the same, as on fixed, wontfix, blocked and drop)' })
758
822
 
@@ -772,7 +836,7 @@ export class ReviewWithdrawCommand extends Command {
772
836
 
773
837
  export class ReviewReopenCommand extends Command {
774
838
  static override paths = [['review', 'reopen']]
775
- 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 })
776
840
  ids = Option.Rest({ required: 1 })
777
841
 
778
842
  async execute(): Promise<number> {
@@ -796,9 +860,9 @@ export class ReviewPickCommand extends Command {
796
860
  static override paths = [['review', 'pick']]
797
861
  static override usage = Command.Usage({
798
862
  category: 'Review',
799
- description: "the option you suggest on a choice card he has not answered: the hub's « my pick » pill on it",
800
- 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>.`,
801
- 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"']],
802
866
  })
803
867
  id = Option.String({ required: true })
804
868
  view = Option.String({ required: true })
@@ -806,11 +870,11 @@ export class ReviewPickCommand extends Command {
806
870
  async execute(): Promise<number> {
807
871
  return run(this.context, async (h) => {
808
872
  const { setAgentPick } = await import('../review/store.ts')
809
- const { viewLetter, viewName } = await import('../review/model.ts')
873
+ const { viewNo, viewName } = await import('../review/model.ts')
810
874
  const id = await idOf(h.dir, this.id)
811
875
  const item = setAgentPick(h.dir, id, this.view)
812
876
  const n = item.agentPick ?? 0
813
- 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)}"`)
814
878
  return 0
815
879
  })
816
880
  }
@@ -829,15 +893,27 @@ function actCommand(op: ActOp, description: string, o: { note?: 'required' | 'op
829
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' })
830
894
  commit = Option.String('--commit', { description: 'the commit that holds the fix' })
831
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
832
898
 
833
899
  async execute(): Promise<number> {
834
900
  return run(this.context, async (h) => {
835
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
+ }
836
912
  const { stateOf } = await import('../review/model.ts')
837
913
  const { detail } = await import('../review/format.ts')
838
914
  if (this.words !== undefined && o.text === undefined && o.topic === undefined) throw new Error(`unexpected ${this.words}`)
839
915
  if (o.text && !this.words?.trim()) throw new Error(`${op} <id> "<${o.text}>"`)
840
- 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)`)
841
917
  const id = await idOf(h.dir, this.id)
842
918
  const who = actor(this.as, o.named, op)
843
919
  if (op === 'done') {
@@ -849,11 +925,11 @@ function actCommand(op: ActOp, description: string, o: { note?: 'required' | 'op
849
925
  const st = was ? stateOf(was, followed) : null
850
926
  if (st?.state === 'closed') {
851
927
  h.out(`${id}: closed already (${st.why ?? 'closed'}${followed ? ', a newer card follows it' : ''}), nothing to close`)
852
- 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>"`)
853
929
  return 0
854
930
  }
855
931
  if (st?.state === 'asks' || st?.state === 'draft')
856
- 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`)
857
933
  }
858
934
  act(h.dir, id, op, who, {
859
935
  ...(this.note ? { note: this.note } : {}),
@@ -872,16 +948,16 @@ function actCommand(op: ActOp, description: string, o: { note?: 'required' | 'op
872
948
  }
873
949
  }
874
950
 
875
- 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']] })
876
- 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"']] })
877
- 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']] })
878
- 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']] })
879
- 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']] })
880
- 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"']] })
881
- 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']] })
882
- 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']] })
883
- 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']] })
884
- 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']] })
885
961
 
886
962
  export class ReviewDispatcherCommand extends Command {
887
963
  static override paths = [['review', 'dispatcher']]
@@ -889,7 +965,7 @@ export class ReviewDispatcherCommand extends Command {
889
965
  category: 'Review',
890
966
  description: 'take the dispatcher role: one session at a time routes what is raised',
891
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.`,
892
- examples: [['take the role', 'sk review dispatcher --as orchestrator']],
968
+ examples: [['take the role', 'sk thread dispatcher --as orchestrator']],
893
969
  })
894
970
  as = Option.String('--as', { description: 'who takes it (else SK_AGENT)' })
895
971
  take = Option.Boolean('--take', false, { description: 'take it from an active holder' })
@@ -913,7 +989,7 @@ export class ReviewNextCommand extends Command {
913
989
  category: 'Review',
914
990
  description: 'claim the oldest open item of a topic, or raised to a lane, and show it with the pages to read first',
915
991
  details: DETAILS,
916
- 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']],
917
993
  })
918
994
  topic = Option.String({ required: false })
919
995
  lane = Option.String('--lane', { description: 'the lane he or a rule raised it to' })
@@ -961,7 +1037,7 @@ export class ReviewBoardCommand extends Command {
961
1037
  category: 'Review',
962
1038
  description: 'every open raised item by state, topic and worker, stale claims marked; who is the dispatcher',
963
1039
  details: DETAILS,
964
- 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']],
965
1041
  })
966
1042
  topic = Option.String('--topic', { description: 'one topic' })
967
1043
  all = Option.Boolean('--all', false, { description: 'the closed ones too' })
@@ -978,7 +1054,7 @@ export class ReviewBoardCommand extends Command {
978
1054
  for (const b of all.broken) h.err(`review: FAIL ${b.id}: ${b.error}`)
979
1055
  if (h.say.spec.dispatcher) {
980
1056
  const role = roleOf(h.dir)
981
- 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>)')
982
1058
  }
983
1059
  const now = new Date()
984
1060
  const followed = followedIds(all.items)
@@ -1000,7 +1076,7 @@ export class ReviewBoardCommand extends Command {
1000
1076
 
1001
1077
  export class ReviewReadyCommand extends Command {
1002
1078
  static override paths = [['review', 'ready']]
1003
- 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 })
1004
1080
  id = Option.String()
1005
1081
  image = Option.String('--image', { description: 'the image that stays' })
1006
1082
 
@@ -1023,7 +1099,7 @@ export class ReviewDeleteCommand extends Command {
1023
1099
  category: 'Review',
1024
1100
  description: "a player's test report removed at its source and here, or an item the owner raised removed here",
1025
1101
  details: DETAILS,
1026
- examples: [['a test report', 'sk review delete live#3']],
1102
+ examples: [['a test report', 'sk thread delete live#3']],
1027
1103
  })
1028
1104
  refs = Option.Rest({ required: 1 })
1029
1105
 
@@ -1055,7 +1131,7 @@ export class ReviewMarksCommand extends Command {
1055
1131
  category: 'Review',
1056
1132
  description: "the owner's marks kept in the store: per subject its latest stars, mark and note",
1057
1133
  details: DETAILS,
1058
- 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']],
1059
1135
  })
1060
1136
  subject = Option.String('--subject', { description: 'one subject kind' })
1061
1137
  json = Option.Boolean('--json', false, { description: 'every subject key, its latest mark and its history count' })
@@ -1086,11 +1162,11 @@ export class ReviewAnimCommand extends Command {
1086
1162
  static override paths = [['review', 'anim']]
1087
1163
  static override usage = Command.Usage({
1088
1164
  category: 'Review',
1089
- description: "a card's before and after as a looping animation to send: a cut, a fade or a wipe, mp4 or gif",
1090
- 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/).`,
1091
1167
  examples: [
1092
- ['a fade, mp4', 'sk review anim <id>'],
1093
- ['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'],
1094
1170
  ],
1095
1171
  })
1096
1172
  id = Option.String({ required: false })
@@ -1131,12 +1207,12 @@ export class ReviewStageCommand extends Command {
1131
1207
  static override paths = [['review', 'stage']]
1132
1208
  static override usage = Command.Usage({
1133
1209
  category: 'Review',
1134
- description: "one media of a card staged as a post: a draft in .shipkit/social/drafts/, never posted",
1135
- 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`,
1136
1212
  examples: [
1137
- ['the first media, a safe post', 'sk review stage <id> --text "Hands now pinch and lift." --rating safe'],
1138
- ["the second view's wipe, polished by an agent", 'sk review stage <id> --view B --side wipe --text "…" --rating mild --polish'],
1139
- ['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'],
1140
1216
  ],
1141
1217
  })
1142
1218
  id = Option.String({ required: true })
@@ -1161,7 +1237,7 @@ export class ReviewStageCommand extends Command {
1161
1237
  const { dirname, join } = await import('node:path')
1162
1238
  const { isPostRating, POST_RATINGS } = await import('../identities/rating.ts')
1163
1239
  const missing = [this.text === undefined ? '--text "<the post>"' : null, this.rating === undefined ? `--rating <${POST_RATINGS.join('|')}>` : null].filter((x) => x !== null)
1164
- 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 ')}`)
1165
1241
  const { stageInputOf, stageOfCard } = await import('../review/stage-card.ts')
1166
1242
  const { askPolish, fitStage, stagedKind, stageDraft, stageDry } = await import('../social/stage.ts')
1167
1243
  const { loadSocialUnit } = await import('../social/unit.ts')
@@ -1171,9 +1247,12 @@ export class ReviewStageCommand extends Command {
1171
1247
  const s = stageOfCard(h.dir, id)
1172
1248
  let pick: string | undefined
1173
1249
  if (this.view) {
1174
- const m = /^(?:(\d+)\.)?([A-Z]+)$/i.exec(this.view)
1175
- if (m == null) throw new Error(`--view ${this.view}: a letter, or <n>.<letter>`)
1176
- 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}`
1177
1256
  const of = s.media.filter((x) => x.label.startsWith(`${tag} `))
1178
1257
  const tile = this.tile
1179
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'))
@@ -1202,8 +1281,8 @@ export class ReviewAutoCommand extends Command {
1202
1281
  static override usage = Command.Usage({
1203
1282
  category: 'Review',
1204
1283
  description: "the repo's auto rules: period, last run and answer, last item, next run; `auto run <id>` runs one",
1205
- details: `${DETAILS}\n\nsk review auto | sk review auto run <id> [--dry]. The hub's daemon runs them on their clocks.`,
1206
- 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']],
1207
1286
  })
1208
1287
  verb = Option.String({ required: false })
1209
1288
  rule = Option.String({ required: false })
@@ -1256,16 +1335,17 @@ export class ReviewWatchCommand extends Command {
1256
1335
  category: 'Review',
1257
1336
  description: 'one line per verdict, reply or raised note as it lands; every unseen one first; ends with its owner',
1258
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.`,
1259
- 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']],
1260
1339
  })
1261
- mine = Option.Boolean('--mine', false, { description: "only this Claude Code session's cards" })
1262
- 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" })
1263
1342
  lane = Option.String('--lane', { description: "only that lane's items" })
1264
1343
 
1265
1344
  async execute(): Promise<number> {
1266
1345
  return run(this.context, async (h) => {
1267
1346
  const { existsSync, mkdirSync, watch } = await import('node:fs')
1268
1347
  const { readAll, scanStamp } = await import('../review/store.ts')
1348
+ const { cardsInDb } = await import('../hq/switch.ts')
1269
1349
  const { AGENT_RE, coversCard, laneOf, UNTAKEN_AGAIN_MS, untakenOf } = await import('../review/model.ts')
1270
1350
  const { followedIds, unseen } = await import('../review/threads.ts')
1271
1351
  const { raisedLine, untakenLine, watchLines } = await import('../review/format.ts')
@@ -1273,7 +1353,9 @@ export class ReviewWatchCommand extends Command {
1273
1353
  const session = await sessionOf(this.mine, this.session)
1274
1354
  const lane = this.lane?.trim() || null
1275
1355
  if (lane !== null && !AGENT_RE.test(lane)) throw new Error(`--lane: « ${lane} » is no lane id (${AGENT_RE.source})`)
1276
- 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)
1277
1359
  if (session === null && lane === null) {
1278
1360
  const { bareWatchTaken } = await import('../review/model.ts')
1279
1361
  const taken = bareWatchTaken(liveWatchers(h.dir), process.pid)
@@ -1283,8 +1365,24 @@ export class ReviewWatchCommand extends Command {
1283
1365
  // before any await: a pull that hangs never keeps a watch alive past its owner
1284
1366
  exitWithOwner()
1285
1367
  const shown = new Set<string>()
1286
- 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 => {
1287
1384
  const all = readAll(h.dir)
1385
+ byItem = threadByItem(threadsOf(all.items, h.say.spec))
1288
1386
  for (const b of all.broken) {
1289
1387
  const key = `broken ${b.id} ${b.error}`
1290
1388
  if (!shown.has(key)) h.err(`review: FAIL ${b.id}: ${b.error}`)
@@ -1320,31 +1418,353 @@ export class ReviewWatchCommand extends Command {
1320
1418
  tick()
1321
1419
  // the grace and the reminder pass with time alone: one read a minute
1322
1420
  setInterval(tick, 60_000)
1323
- // 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
1324
1424
  let soon: ReturnType<typeof setTimeout> | null = null
1325
1425
  const again = (): void => {
1326
1426
  if (soon) clearTimeout(soon)
1327
1427
  soon = setTimeout(() => {
1328
1428
  soon = null
1329
1429
  tick()
1330
- }, 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
+ })
1331
1440
  }
1332
- if (!existsSync(h.dir)) mkdirSync(h.dir, { recursive: true })
1333
- watch(h.dir, { recursive: true }, again)
1441
+ if (!cardsInDb()) watchFolder()
1334
1442
  // the sources: pulled now and every 30 s, a new item lands and the tick prints it
1335
1443
  await pull(h)
1336
1444
  if (h.unit?.sources?.length) setInterval(() => void pull(h), 30_000)
1337
- let stamp = scanStamp(h.dir)
1445
+ let stamp = ''
1446
+ let scanned = Date.now()
1338
1447
  setInterval(() => {
1339
- const now = scanStamp(h.dir)
1340
- if (now !== stamp) again()
1341
- stamp = now
1342
- }, 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)
1343
1464
  return new Promise<number>(() => {})
1344
1465
  })
1345
1466
  }
1346
1467
  }
1347
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
+
1348
1768
  export const REVIEW_COMMANDS = [
1349
1769
  ReviewLsCommand,
1350
1770
  ReviewAddCommand,
@@ -1378,4 +1798,16 @@ export const REVIEW_COMMANDS = [
1378
1798
  ReviewStageCommand,
1379
1799
  ReviewAutoCommand,
1380
1800
  ReviewWatchCommand,
1801
+ ReviewMoveCommand,
1802
+ ReviewExportCommand,
1803
+ ReviewMigrateCommand,
1804
+ ThreadPostCommand,
1805
+ ThreadProposeCommand,
1806
+ ThreadAttachCommand,
1381
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
+ }