rvlib-shipkit 2.25.0 → 2.27.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (456) hide show
  1. package/CHANGELOG.md +33 -0
  2. package/package.json +2 -2
  3. package/src/agent-time/diet.ts +77 -0
  4. package/src/agent-time/family.ts +72 -0
  5. package/src/agent-time/hooks.ts +331 -0
  6. package/src/agent-time/limits.ts +44 -0
  7. package/src/agent-time/live.ts +1 -3
  8. package/src/agent-time/mask.ts +96 -18
  9. package/src/agent-time/refused.ts +45 -0
  10. package/src/agent-time/render.ts +130 -17
  11. package/src/agent-time/report-cache.ts +57 -0
  12. package/src/agent-time/report.ts +349 -23
  13. package/src/agent-time/shape.ts +50 -3
  14. package/src/agent-time/store.ts +370 -95
  15. package/src/agent-time/timeline.ts +140 -21
  16. package/src/agent-time/turns.ts +18 -8
  17. package/src/annex/offload.ts +17 -6
  18. package/src/annex/tidy.ts +70 -10
  19. package/src/asks/ask-after.ts +40 -0
  20. package/src/asks/asks-queue.ts +205 -47
  21. package/src/assets/kit-config.ts +7 -3
  22. package/src/assets/kits/identity-kit.ts +289 -10
  23. package/src/check.ts +3 -1
  24. package/src/checks/SK004-gitignore-policy.check.ts +12 -5
  25. package/src/checks/SK013-one-way-in-policy.check.ts +8 -3
  26. package/src/checks/SK026-asks-autoclose.check.ts +5 -5
  27. package/src/checks/SK028-readme.check.ts +7 -66
  28. package/src/checks/SK030-cache-audit.check.ts +6 -1
  29. package/src/checks/SK031-trace-audit.check.ts +2 -0
  30. package/src/checks/SK033-global-contribution.check.ts +3 -1
  31. package/src/checks/SK035-public-clean.check.ts +2 -2
  32. package/src/checks/SK043-scratch-on-the-mac.check.ts +59 -4
  33. package/src/checks/SK045-slow-hooks.check.ts +47 -0
  34. package/src/checks/SK046-hook-records.check.ts +76 -0
  35. package/src/checks/SK047-login-in-description.check.ts +36 -0
  36. package/src/checks/SK048-one-local-file.check.ts +36 -0
  37. package/src/cli/cmd_Asks.ts +71 -5
  38. package/src/cli/cmd_Backup.ts +5 -3
  39. package/src/cli/cmd_Capacity.ts +2 -2
  40. package/src/cli/cmd_CrossRepoActivity.ts +5 -4
  41. package/src/cli/cmd_Db.ts +253 -0
  42. package/src/cli/cmd_History.ts +212 -0
  43. package/src/cli/cmd_Home.ts +31 -3
  44. package/src/cli/cmd_Hq.ts +516 -0
  45. package/src/cli/cmd_Machines.ts +36 -0
  46. package/src/cli/cmd_Media.ts +38 -6
  47. package/src/cli/cmd_Mv.ts +1 -1
  48. package/src/cli/cmd_Reflect.ts +23 -2
  49. package/src/cli/cmd_Releases.ts +30 -0
  50. package/src/cli/cmd_Review.ts +569 -118
  51. package/src/cli/cmd_Secret.ts +62 -12
  52. package/src/cli/cmd_Social.ts +83 -1
  53. package/src/cli/cmd_Space.ts +324 -0
  54. package/src/cli/cmd_Time.ts +82 -5
  55. package/src/cli/cmd_Tmp.ts +28 -4
  56. package/src/cli/cmd_Trailer.ts +14 -10
  57. package/src/cli/cmd_Urls.ts +56 -0
  58. package/src/cli/cmd_Vault.ts +583 -0
  59. package/src/cli/family-help.ts +4 -2
  60. package/src/cli/family-pages.ts +1 -1
  61. package/src/cli/registry.ts +26 -4
  62. package/src/collections/actions.ts +63 -13
  63. package/src/collections/collection-types.ts +23 -1
  64. package/src/collections/providers.ts +117 -23
  65. package/src/collections/review.ts +4 -4
  66. package/src/commands/runner.ts +5 -1
  67. package/src/contracts/contract-manifests.ts +6 -5
  68. package/src/contracts/contract-types.ts +6 -4
  69. package/src/contracts/contracts-engine.ts +11 -0
  70. package/src/contracts/manifests/chrome-web-store.contract.ts +31 -0
  71. package/src/core/budget.ts +12 -17
  72. package/src/core/capacity.ts +27 -18
  73. package/src/core/check-runner.ts +7 -4
  74. package/src/core/history-files.ts +9 -5
  75. package/src/core/layout.ts +3 -0
  76. package/src/core/machine-busy.ts +127 -0
  77. package/src/core/machine-commit.ts +6 -1
  78. package/src/core/machine-db.ts +368 -20
  79. package/src/core/machine-layout.ts +137 -0
  80. package/src/core/machine-read.ts +81 -0
  81. package/src/core/migrate-layout.ts +1 -1
  82. package/src/core/one-way-in-policy.ts +64 -7
  83. package/src/core/polling-policy.ts +27 -0
  84. package/src/core/retention.ts +16 -2
  85. package/src/core/scope.ts +107 -14
  86. package/src/core/signal-name.ts +6 -0
  87. package/src/core/slots.ts +5 -4
  88. package/src/core/trace-audit.ts +6 -1
  89. package/src/core/transient.ts +6 -0
  90. package/src/drill/clean.ts +25 -1
  91. package/src/drill/run.ts +2 -2
  92. package/src/drill/seal.ts +27 -4
  93. package/src/home/activity-shape.ts +2 -0
  94. package/src/home/activity.ts +66 -3
  95. package/src/home/app-sign.ts +15 -4
  96. package/src/home/daemon-jobs.ts +149 -7
  97. package/src/home/database-projects.ts +111 -0
  98. package/src/home/database-words.ts +203 -0
  99. package/src/home/databases.ts +460 -0
  100. package/src/home/global-units.ts +6 -0
  101. package/src/home/gui-app/ShipkitGui.swift +122 -1
  102. package/src/home/gui-app.ts +6 -3
  103. package/src/home/home-move.ts +514 -0
  104. package/src/home/home-paths.ts +12 -3
  105. package/src/home/home-routes.ts +68 -0
  106. package/src/home/inbox-shape.ts +24 -14
  107. package/src/home/machine-fold.ts +820 -0
  108. package/src/home/machine-host.ts +20 -5
  109. package/src/home/machine-repair.ts +503 -0
  110. package/src/home/machine-stores.ts +66 -15
  111. package/src/home/machine-temp.ts +547 -86
  112. package/src/home/resume.ts +79 -0
  113. package/src/home/run-daemon.ts +25 -4
  114. package/src/home/run-pm.ts +18 -5
  115. package/src/home/serve-daemon.ts +18 -3
  116. package/src/home/serve-web.ts +175 -7
  117. package/src/home/space-job.ts +115 -0
  118. package/src/home/space-page.ts +257 -0
  119. package/src/home/space-route.ts +167 -0
  120. package/src/home/space-words.ts +103 -0
  121. package/src/home/time-page-shape.ts +202 -0
  122. package/src/home/time-page.ts +64 -0
  123. package/src/home/vault-page.ts +482 -0
  124. package/src/home/vault-words.ts +132 -0
  125. package/src/hooks/leak-guard.ts +40 -13
  126. package/src/hooks/one-way-in-guard.ts +17 -4
  127. package/src/hq/cards.ts +581 -0
  128. package/src/hq/door-route.ts +43 -0
  129. package/src/hq/door.ts +163 -0
  130. package/src/hq/files-send.ts +348 -0
  131. package/src/hq/forgotten-log.ts +35 -0
  132. package/src/hq/history-check.ts +255 -0
  133. package/src/hq/history-place.ts +146 -0
  134. package/src/hq/history-send.ts +487 -0
  135. package/src/hq/hq-db.ts +99 -0
  136. package/src/hq/hq-local.ts +469 -0
  137. package/src/hq/hq-routes.ts +196 -0
  138. package/src/hq/hq-store.ts +599 -0
  139. package/src/hq/kinds/ask.ts +147 -0
  140. package/src/hq/kinds/card-gone.ts +83 -0
  141. package/src/hq/kinds/card-msg.ts +66 -0
  142. package/src/hq/kinds/card.ts +99 -0
  143. package/src/hq/kinds/index.ts +21 -0
  144. package/src/hq/kinds/kind.ts +126 -0
  145. package/src/hq/kinds/media.ts +125 -0
  146. package/src/hq/kinds/prompt.ts +219 -0
  147. package/src/hq/kinds/reflection.ts +128 -0
  148. package/src/hq/kinds/report.ts +55 -0
  149. package/src/hq/kinds/time-day.ts +236 -0
  150. package/src/hq/ledger.ts +473 -0
  151. package/src/hq/machine-key.ts +44 -0
  152. package/src/hq/machine-notes.ts +131 -0
  153. package/src/hq/outbox.ts +372 -0
  154. package/src/hq/replica.ts +168 -0
  155. package/src/hq/repo-id.ts +4 -0
  156. package/src/hq/report-facts.ts +117 -0
  157. package/src/hq/report.ts +274 -0
  158. package/src/hq/switch.ts +151 -0
  159. package/src/hq/vault-grant.ts +92 -0
  160. package/src/identities/identities.ts +15 -3
  161. package/src/identities/steps.ts +31 -0
  162. package/src/ledger/db.ts +73 -26
  163. package/src/ledger/gate-checks.ts +29 -4
  164. package/src/ledger/git-key.ts +3 -3
  165. package/src/ledger/git-scan.ts +49 -7
  166. package/src/ledger/run-log.ts +11 -3
  167. package/src/ledger/store.ts +26 -4
  168. package/src/media-store/backup/daemon.ts +36 -17
  169. package/src/media-store/backup/kept.ts +241 -0
  170. package/src/media-store/backup/restore.ts +14 -4
  171. package/src/media-store/backup/run.ts +11 -11
  172. package/src/media-store/backup/secret.ts +6 -4
  173. package/src/media-store/backup/snapshot.ts +4 -2
  174. package/src/media-store/backup/sources.ts +68 -20
  175. package/src/media-store/copy/config.ts +77 -0
  176. package/src/media-store/copy/copy.ts +194 -0
  177. package/src/media-store/copy/lifecycle.ts +43 -0
  178. package/src/media-store/copy/night.ts +90 -0
  179. package/src/media-store/copy/proof.ts +151 -0
  180. package/src/media-store/copy/snapshot.ts +152 -0
  181. package/src/media-store/copy/store.ts +62 -0
  182. package/src/media-store/copy/stream.ts +176 -0
  183. package/src/media-store/daemon.ts +66 -16
  184. package/src/media-store/db.ts +22 -11
  185. package/src/media-store/forget.ts +23 -3
  186. package/src/media-store/hand.ts +4 -3
  187. package/src/media-store/hq-find.ts +75 -0
  188. package/src/media-store/hq-send.ts +277 -0
  189. package/src/media-store/kind.ts +2 -0
  190. package/src/media-store/purge.ts +18 -15
  191. package/src/media-store/put.ts +24 -8
  192. package/src/media-store/remote.ts +16 -7
  193. package/src/media-store/space-listing.ts +240 -0
  194. package/src/media-store/space.ts +40 -21
  195. package/src/media-store/sync.ts +5 -5
  196. package/src/media-store/tidy.ts +98 -0
  197. package/src/media-store/upload.ts +3 -3
  198. package/src/media-store/webp.ts +66 -0
  199. package/src/messages/model.ts +16 -7
  200. package/src/messages/routes.ts +14 -4
  201. package/src/messages/score.ts +2 -2
  202. package/src/messages/suggest.ts +96 -0
  203. package/src/pages/frame-client.ts +10 -0
  204. package/src/plan/planner.ts +28 -17
  205. package/src/recordings/media-kind.ts +1 -0
  206. package/src/recordings/model.ts +1 -1
  207. package/src/recordings/recorder-app/Capture.swift +9 -7
  208. package/src/reflect/hq-corpus.ts +56 -0
  209. package/src/reflect/prompt-corpus.ts +3 -1
  210. package/src/reflect/transcript.ts +146 -36
  211. package/src/release/machine-words.ts +67 -0
  212. package/src/release/public-clean.ts +8 -3
  213. package/src/releases/from-card.ts +1 -1
  214. package/src/releases/model.ts +18 -0
  215. package/src/releases/routes.ts +10 -5
  216. package/src/releases/store.ts +23 -2
  217. package/src/repo-config.ts +42 -2
  218. package/src/review/anim.ts +2 -2
  219. package/src/review/auto.ts +2 -2
  220. package/src/review/card-db.ts +244 -0
  221. package/src/review/card-rows.ts +266 -0
  222. package/src/review/cells.ts +76 -5
  223. package/src/review/draft-card.ts +41 -0
  224. package/src/review/draft-model.ts +78 -0
  225. package/src/review/format.ts +29 -10
  226. package/src/review/gone.ts +98 -0
  227. package/src/review/inbox-hook.ts +35 -0
  228. package/src/review/marks.ts +1 -1
  229. package/src/review/media-kind.ts +7 -5
  230. package/src/review/media-read.ts +9 -7
  231. package/src/review/media.ts +32 -5
  232. package/src/review/model.ts +214 -45
  233. package/src/review/move.ts +491 -0
  234. package/src/review/notes.ts +12 -20
  235. package/src/review/previews.ts +15 -19
  236. package/src/review/project.ts +1 -1
  237. package/src/review/rev.ts +8 -0
  238. package/src/review/role.ts +1 -1
  239. package/src/review/routes.ts +64 -13
  240. package/src/review/stage-card.ts +8 -4
  241. package/src/review/stage-routes.ts +1 -1
  242. package/src/review/store.ts +529 -83
  243. package/src/review/thread-fold.ts +51 -0
  244. package/src/review/threads.ts +147 -9
  245. package/src/review/trailer-auto-mock.ts +63 -0
  246. package/src/review/trailer-card.ts +4 -4
  247. package/src/review/trailer-desk.ts +41 -7
  248. package/src/review/trailer-media.ts +1 -0
  249. package/src/review/trailer-model.ts +8 -0
  250. package/src/review/trailer-notes.ts +1 -1
  251. package/src/review/trailer-routes.ts +9 -1
  252. package/src/review/unit.ts +6 -6
  253. package/src/review/watchers.ts +1 -1
  254. package/src/rules/untrack-generated.ts +92 -8
  255. package/src/secrets/held.ts +16 -0
  256. package/src/secrets/keychain.ts +113 -0
  257. package/src/secrets/list.ts +16 -6
  258. package/src/secrets/manager.ts +24 -10
  259. package/src/secrets/read.ts +257 -0
  260. package/src/secrets/who-reads.ts +49 -0
  261. package/src/serve/door-forward.ts +268 -0
  262. package/src/serve/door-names.ts +47 -0
  263. package/src/serve/embed.ts +1 -1
  264. package/src/serve/hub-app/activity-view.tsx +56 -32
  265. package/src/serve/hub-app/activity.css +7 -1
  266. package/src/serve/hub-app/asks-page.tsx +48 -0
  267. package/src/serve/hub-app/asks-st.ts +25 -0
  268. package/src/serve/hub-app/clock-svc.ts +1 -2
  269. package/src/serve/hub-app/col-card.tsx +64 -13
  270. package/src/serve/hub-app/col-list-page.tsx +122 -0
  271. package/src/serve/hub-app/col-list-st.ts +103 -0
  272. package/src/serve/hub-app/col-tables-view.tsx +10 -41
  273. package/src/serve/hub-app/col-tables.ts +76 -8
  274. package/src/serve/hub-app/cols-svc.ts +70 -16
  275. package/src/serve/hub-app/database-st.ts +260 -0
  276. package/src/serve/hub-app/database-view.tsx +289 -0
  277. package/src/serve/hub-app/database.css +32 -0
  278. package/src/serve/hub-app/entry-bar.css +14 -0
  279. package/src/serve/hub-app/entry-bar.tsx +33 -0
  280. package/src/serve/hub-app/entry-pick.ts +31 -0
  281. package/src/serve/hub-app/floating.tsx +1 -0
  282. package/src/serve/hub-app/hash-route.ts +11 -1
  283. package/src/serve/hub-app/header-bar.tsx +14 -18
  284. package/src/serve/hub-app/home-st.ts +89 -9
  285. package/src/serve/hub-app/home-strip.css +5 -19
  286. package/src/serve/hub-app/home-strip.tsx +58 -92
  287. package/src/serve/hub-app/home.html +7 -0
  288. package/src/serve/hub-app/hub-app.tsx +31 -142
  289. package/src/serve/hub-app/hub-types.ts +3 -1
  290. package/src/serve/hub-app/hub.css +109 -23
  291. package/src/serve/hub-app/icons.tsx +18 -1
  292. package/src/serve/hub-app/identities-st.ts +56 -6
  293. package/src/serve/hub-app/identities-view.tsx +100 -58
  294. package/src/serve/hub-app/identities.css +17 -15
  295. package/src/serve/hub-app/identity-address.ts +5 -0
  296. package/src/serve/hub-app/inbox-st.ts +41 -24
  297. package/src/serve/hub-app/inbox-view.tsx +37 -41
  298. package/src/serve/hub-app/inbox.css +2 -5
  299. package/src/serve/hub-app/index.html +7 -0
  300. package/src/serve/hub-app/kept-cols.tsx +7 -0
  301. package/src/serve/hub-app/keys.ts +28 -15
  302. package/src/serve/hub-app/later.tsx +26 -0
  303. package/src/serve/hub-app/list-filter.tsx +14 -0
  304. package/src/serve/hub-app/list-walk.ts +72 -3
  305. package/src/serve/hub-app/machines-st.ts +251 -0
  306. package/src/serve/hub-app/machines-view.tsx +224 -0
  307. package/src/serve/hub-app/machines.css +76 -0
  308. package/src/serve/hub-app/md-copy.tsx +79 -0
  309. package/src/serve/hub-app/media-view.tsx +2 -0
  310. package/src/serve/hub-app/messages/messages-page.tsx +79 -7
  311. package/src/serve/hub-app/messages/messages-st.ts +99 -3
  312. package/src/serve/hub-app/messages.css +14 -0
  313. package/src/serve/hub-app/page-keys.ts +175 -0
  314. package/src/serve/hub-app/pages-frames.tsx +11 -3
  315. package/src/serve/hub-app/palette-st.ts +58 -11
  316. package/src/serve/hub-app/palette-view.tsx +3 -1
  317. package/src/serve/hub-app/project-list.css +54 -8
  318. package/src/serve/hub-app/project-list.tsx +128 -59
  319. package/src/serve/hub-app/projects-svc.ts +78 -7
  320. package/src/serve/hub-app/reader-chips.tsx +13 -0
  321. package/src/serve/hub-app/readme-view.tsx +2 -3
  322. package/src/serve/hub-app/readme.css +27 -5
  323. package/src/serve/hub-app/reflections-page.tsx +42 -0
  324. package/src/serve/hub-app/reflections-st.ts +17 -0
  325. package/src/serve/hub-app/releases/releases-page.tsx +25 -2
  326. package/src/serve/hub-app/releases/releases-st.ts +1 -1
  327. package/src/serve/hub-app/repo-sections.ts +9 -5
  328. package/src/serve/hub-app/repo-st.ts +35 -8
  329. package/src/serve/hub-app/review/draft-card.tsx +163 -0
  330. package/src/serve/hub-app/review/kit.tsx +50 -7
  331. package/src/serve/hub-app/review/note-place.ts +1 -1
  332. package/src/serve/hub-app/review/review-board.tsx +2 -2
  333. package/src/serve/hub-app/review/review-cells.tsx +145 -65
  334. package/src/serve/hub-app/review/review-kit.ts +27 -1
  335. package/src/serve/hub-app/review/review-list.tsx +68 -30
  336. package/src/serve/hub-app/review/review-page.tsx +7 -8
  337. package/src/serve/hub-app/review/review-st.ts +111 -24
  338. package/src/serve/hub-app/review/review-thread.tsx +49 -19
  339. package/src/serve/hub-app/review/review-views.tsx +475 -144
  340. package/src/serve/hub-app/review/thread-control-st.ts +115 -0
  341. package/src/serve/hub-app/review/thread-control.tsx +74 -0
  342. package/src/serve/hub-app/review/thread-st.ts +73 -26
  343. package/src/serve/hub-app/review/trailer-card.tsx +1 -1
  344. package/src/serve/hub-app/review/trailer-page.tsx +37 -16
  345. package/src/serve/hub-app/review/trailer-st.ts +41 -7
  346. package/src/serve/hub-app/review.css +267 -61
  347. package/src/serve/hub-app/side-lists.ts +72 -0
  348. package/src/serve/hub-app/sidebar.tsx +6 -3
  349. package/src/serve/hub-app/site/site-part.tsx +2 -8
  350. package/src/serve/hub-app/site/site-st.ts +4 -4
  351. package/src/serve/hub-app/social/comms-page.tsx +20 -5
  352. package/src/serve/hub-app/social/kit.tsx +30 -4
  353. package/src/serve/hub-app/social/post-card.tsx +139 -49
  354. package/src/serve/hub-app/social/serial-writes.ts +13 -0
  355. package/src/serve/hub-app/social/social-model.ts +11 -0
  356. package/src/serve/hub-app/social/social-page.tsx +94 -35
  357. package/src/serve/hub-app/social/social-st.ts +120 -36
  358. package/src/serve/hub-app/social/stage-popup.tsx +1 -1
  359. package/src/serve/hub-app/social/stage-st.ts +1 -1
  360. package/src/serve/hub-app/social/step-layout.ts +1 -1
  361. package/src/serve/hub-app/social.css +3 -0
  362. package/src/serve/hub-app/space-st.ts +209 -0
  363. package/src/serve/hub-app/space-view.tsx +196 -0
  364. package/src/serve/hub-app/space.css +27 -0
  365. package/src/serve/hub-app/stores/stores-page.tsx +91 -23
  366. package/src/serve/hub-app/stores/stores-st.ts +44 -19
  367. package/src/serve/hub-app/stores.css +6 -1
  368. package/src/serve/hub-app/theme-st.ts +22 -9
  369. package/src/serve/hub-app/time-charts.tsx +291 -0
  370. package/src/serve/hub-app/time-pages.tsx +749 -0
  371. package/src/serve/hub-app/time-st.ts +162 -0
  372. package/src/serve/hub-app/time-view.tsx +76 -0
  373. package/src/serve/hub-app/time.css +138 -0
  374. package/src/serve/hub-app/tree-build.ts +52 -42
  375. package/src/serve/hub-app/tree-row.tsx +4 -4
  376. package/src/serve/hub-app/tree-svc.ts +18 -9
  377. package/src/serve/hub-app/urls-svc.ts +154 -0
  378. package/src/serve/hub-app/urls-view.tsx +117 -0
  379. package/src/serve/hub-app/urls.css +30 -0
  380. package/src/serve/hub-app/vault-st.ts +127 -0
  381. package/src/serve/hub-app/vault-view.tsx +154 -0
  382. package/src/serve/hub-app/vault.css +38 -0
  383. package/src/serve/hub-app/veille/veille-st.ts +12 -10
  384. package/src/serve/hub-app/waiting-svc.ts +29 -0
  385. package/src/serve/hub-app/wikis-view.tsx +2 -2
  386. package/src/serve/hub-runtime.ts +15 -2
  387. package/src/serve/project-gutter-route.ts +27 -14
  388. package/src/serve/project-gutter.ts +25 -12
  389. package/src/serve/same-origin.ts +10 -0
  390. package/src/serve/serve-hub.ts +13 -4
  391. package/src/shipkit-files.ts +16 -2
  392. package/src/shipkit.ts +1 -1
  393. package/src/shot/shooter.ts +616 -420
  394. package/src/shot/shot-ask.ts +246 -155
  395. package/src/site/desk.ts +2 -2
  396. package/src/smoke/run-smoke.ts +3 -2
  397. package/src/social/cover.ts +202 -0
  398. package/src/social/discord-layout.ts +37 -13
  399. package/src/social/drafts.ts +3 -0
  400. package/src/social/load.ts +23 -2
  401. package/src/social/media-kind.ts +2 -1
  402. package/src/social/publish/discord.ts +5 -2
  403. package/src/social/publish/secret.ts +2 -2
  404. package/src/social/release-stage.ts +28 -13
  405. package/src/social/routes.ts +26 -1
  406. package/src/social/stage.ts +1 -1
  407. package/src/social/stats.ts +12 -9
  408. package/src/social/strip.ts +4 -1
  409. package/src/social/thumbnail.ts +255 -0
  410. package/src/stores/collection.ts +15 -11
  411. package/src/stores/desk.ts +236 -42
  412. package/src/stores/model.ts +72 -6
  413. package/src/stores/routes.ts +37 -12
  414. package/src/stores/unit.ts +14 -8
  415. package/src/suite/judge-suites.ts +113 -16
  416. package/src/suite/select.ts +45 -3
  417. package/src/suite/suite-cli.ts +81 -34
  418. package/src/trailer/bed.ts +1 -1
  419. package/src/trailer/build.ts +134 -21
  420. package/src/trailer/ffmpeg.ts +7 -0
  421. package/src/trailer/fonts.ts +3 -2
  422. package/src/trailer/grammar.ts +201 -2
  423. package/src/trailer/graph.ts +42 -5
  424. package/src/trailer/look.ts +21 -0
  425. package/src/trailer/mock.ts +154 -0
  426. package/src/trailer/passage.ts +65 -26
  427. package/src/trailer/score/heard.ts +89 -0
  428. package/src/trailer/score/sound.ts +14 -8
  429. package/src/trailer/sound/run.ts +16 -6
  430. package/src/trailer/stitch.ts +26 -5
  431. package/src/trailer/titles.ts +82 -19
  432. package/src/trailer/versions.ts +1 -3
  433. package/src/trailer/vertical.ts +3 -1
  434. package/src/urls/frame.ts +195 -0
  435. package/src/urls/routes.ts +43 -0
  436. package/src/urls/rows.ts +171 -0
  437. package/src/urls/unit.ts +73 -0
  438. package/src/vault/house-keys.ts +42 -0
  439. package/src/vault/layout.ts +50 -0
  440. package/src/vault/policy.ts +165 -0
  441. package/src/vault/vault-audit.ts +276 -0
  442. package/src/vault/vault-client.ts +40 -0
  443. package/src/vault/vault-config.ts +159 -0
  444. package/src/vault/vault-destroy.ts +78 -0
  445. package/src/vault/vault-handover.ts +305 -0
  446. package/src/vault/vault-http.ts +352 -0
  447. package/src/vault/vault-import.ts +208 -0
  448. package/src/vault/vault-init.ts +328 -0
  449. package/src/vault/vault-minter.ts +271 -0
  450. package/src/vault/vault-restore.ts +333 -0
  451. package/src/vault/vault-serve.ts +342 -0
  452. package/src/vault/vault-snapshot.ts +281 -0
  453. package/src/veille/asks.ts +1 -1
  454. package/src/veille/desk.ts +2 -2
  455. package/src/wiki/run-wiki.ts +2 -1
  456. package/src/wiki/scan-md.ts +42 -2
@@ -1,4 +1,4 @@
1
- // a thread read as one conversation (wiki tools/shipkit/review.md, The thread): every version of a card, every verdict,
1
+ // a thread read as one conversation (wiki tools/shipkit/threads.md, The thread): every version of a card, every verdict,
2
2
  // reply, note and state change is one cell, in time order, built at read time from the store's files (a supersedes chain
3
3
  // folds into one thread, nothing is rewritten). The paged list's rows and its query. Pure and browser safe: the routes
4
4
  // send these shapes, the hub page draws them
@@ -36,8 +36,9 @@ import {
36
36
  type ShownStatus,
37
37
  type Subject,
38
38
  type Verdict,
39
+ parentAddress,
39
40
  } from './model.ts'
40
- import { followedIds, isActive, membersOf, openingOf, orderedThreads, statusOf, waits, waitingOnOwner, type Thread } from './threads.ts'
41
+ import { addressesOfThread, ownAddressesOf, followedIds, holderOf, isActive, membersOf, openingOf, orderedThreads, statusOf, turnOf, waits, waitingOnOwner, type Thread, type Turn } from './threads.ts'
41
42
 
42
43
  export type CellKind = 'version' | 'verdict' | 'reply' | 'note' | 'event'
43
44
 
@@ -94,6 +95,14 @@ export interface ReplyCell extends CellOf<'reply'> {
94
95
  update?: { k: number; state: UpdateState; view?: number }
95
96
  /** his hint on an update: the update's cell id, its number and state */
96
97
  re?: { id: string; k: number; state: UpdateState }
98
+ /** an agent's question: its options, its pick, and the owner's answer once given (the option, the words) */
99
+ ask?: { options: string[]; pick?: number; answered?: { option: number; text: string; at: string } }
100
+ /** an agent's proposed change of an object's text, and whether he applied it (his text when he edited it) */
101
+ propose?: { on: string; before?: string; after: string; applied?: { text: string; at: string } }
102
+ /** his answer to a question or a proposal: the cell it answers */
103
+ answers?: string
104
+ /** the objects this message linked to the thread */
105
+ about?: string[]
97
106
  }
98
107
 
99
108
  /** what the owner or a player raised (its item, its opening words and rectangles), or the owner's mark on the subject */
@@ -219,7 +228,12 @@ function messageCells(x: ReviewItem, n: number, opening: Message | undefined): C
219
228
  const reOn = rk >= 0 ? updates[rk]!.update : undefined
220
229
  const re = reOn ? { id: `${id}/${m.re}`, k: rk + 1, state: reOn.state } : undefined
221
230
  const said = update ? `${UPDATE_WORDS[update.state]}: ` : re ? `on update ${re.k}: ` : ''
222
- out.push({ ...base, kind: 'reply', text: m.text ?? '', ...(m.image ? { image: m.image } : {}), ...(op ? { op } : {}), read: wasRead, ...(update ? { update } : {}), ...(re ? { re } : {}), summary: `${said}${firstLine(m.text)}` })
231
+ const reply = x.thread.find((y) => y.re === m.id && y.answer !== undefined && partyOf(y.who) === 'owner')
232
+ const ask = m.ask ? { options: m.ask.options, ...(m.ask.pick !== undefined ? { pick: m.ask.pick } : {}), ...(reply?.answer?.option !== undefined ? { answered: { option: reply.answer.option, text: reply.text ?? '', at: reply.at } } : {}) } : undefined
233
+ const propose = m.propose ? { ...m.propose, ...(reply?.answer?.apply ? { applied: { text: reply.text ?? m.propose.after, at: reply.at } } : {}) } : undefined
234
+ const asked = m.answer && m.re ? `${id}/${m.re}` : undefined
235
+ const what = ask ? (ask.answered ? 'answered: ' : 'asks: ') : propose ? (propose.applied ? 'applied: ' : 'proposes: ') : asked ? 'answer: ' : ''
236
+ out.push({ ...base, kind: 'reply', text: m.text ?? '', ...(m.image ? { image: m.image } : {}), ...(op ? { op } : {}), read: wasRead, ...(update ? { update } : {}), ...(re ? { re } : {}), ...(ask ? { ask } : {}), ...(propose ? { propose } : {}), ...(asked ? { answers: asked } : {}), ...(m.about ? { about: m.about } : {}), summary: `${what}${said}${firstLine(m.text)}` })
223
237
  } else if (m.op !== undefined) {
224
238
  const commit = m.fix?.commit
225
239
  out.push({
@@ -390,6 +404,12 @@ export interface ThreadRow {
390
404
  rework: { lane: string; since: string; until: number } | null
391
405
  /** every item id of the thread, the versions oldest first then the raised items: an old card's link finds its row */
392
406
  ids: string[]
407
+ /** who acts now: the owner, an agent, nobody */
408
+ turn: Turn
409
+ /** the agent that holds it: a live claim's worker, else its newest act */
410
+ holder?: { lane?: string; session?: string }
411
+ /** the addresses it owns, then its links */
412
+ addresses: string[]
393
413
  }
394
414
 
395
415
  /** what the list asks: `handled` adds the threads nobody needs; every other key narrows */
@@ -397,6 +417,8 @@ export interface ThreadQuery {
397
417
  handled: boolean
398
418
  subject: string | null
399
419
  whose: Move | null
420
+ /** who acts now */
421
+ turn: Turn | null
400
422
  status: ShownStatus | null
401
423
  lane: string | null
402
424
  q: string
@@ -417,11 +439,13 @@ export function queryOf(p: URLSearchParams): ThreadQuery {
417
439
  }
418
440
  const s = (k: string): string | null => (p.get(k) ?? '') || null
419
441
  const whose = s('whose')
442
+ const turn = s('turn')
420
443
  const status = s('status')
421
444
  return {
422
445
  handled: p.get('handled') === '1',
423
446
  subject: s('subject'),
424
447
  whose: whose && MOVES.has(whose) ? (whose as Move) : null,
448
+ turn: turn === 'yours' || turn === 'working' || turn === 'done' ? turn : null,
425
449
  status: status && status in STATUS_LABEL ? (status as ShownStatus) : null,
426
450
  lane: s('lane'),
427
451
  q: (p.get('q') ?? '').trim().toLowerCase(),
@@ -493,13 +517,24 @@ function rowOf(t: Thread, items: readonly ReviewItem[], followed: ReadonlySet<st
493
517
  unread: members.some((x) => unreadBy(x, 'owner').length > 0),
494
518
  rework: reworkOf(h, followed.has(h.item.id), now),
495
519
  ids: idsOf(t),
520
+ turn: turnOf(t, now),
521
+ ...holderRow(t),
522
+ addresses: addressesOfThread(t),
496
523
  }
497
524
  }
498
525
 
526
+ const holderRow = (t: Thread): { holder?: { lane?: string; session?: string } } => {
527
+ const h = holderOf(t)
528
+ return h ? { holder: { ...(h.lane ? { lane: h.lane } : {}), ...(h.session ? { session: h.session } : {}) } } : {}
529
+ }
530
+
531
+ const TURN_RANK: Record<Turn, number> = { yours: 0, working: 1, done: 2 }
532
+
499
533
  /** what a search reads of a thread: every item's title, words and id, and every message's words */
500
534
  const textOf = (t: Thread): string =>
501
535
  membersOf(t)
502
536
  .flatMap((x) => [x.item.title, x.item.what ?? '', x.item.id, ...x.thread.flatMap((m) => [m.text ?? '', m.note ?? ''])])
537
+ .concat(addressesOfThread(t))
503
538
  .join('\n')
504
539
  .toLowerCase()
505
540
 
@@ -507,8 +542,13 @@ const textOf = (t: Thread): string =>
507
542
  * rest newest first), one row and one search text per thread */
508
543
  export function threadIndex(items: readonly ReviewItem[], now = new Date()): ThreadIndex {
509
544
  const followed = followedIds(items)
510
- const entries = orderedThreads(items).map((t) => ({ t, row: rowOf(t, items, followed, now), text: textOf(t) }))
511
- const waiting = new Set(waitingOnOwner(items).map((t) => t.head.item.id))
545
+ // his turn first, then the agents' work, then what is done; the order within each the list's own
546
+ const entries = orderedThreads(items)
547
+ .map((t) => ({ t, row: rowOf(t, items, followed, now), text: textOf(t) }))
548
+ .map((e, i) => ({ e, i }))
549
+ .sort((a, b) => TURN_RANK[a.e.row.turn] - TURN_RANK[b.e.row.turn] || a.i - b.i)
550
+ .map(({ e }) => e)
551
+ const waiting = new Set([...waitingOnOwner(items).map((t) => t.head.item.id), ...entries.filter((e) => e.row.turn === 'yours').map((e) => e.row.head)])
512
552
  return {
513
553
  entries,
514
554
  counts: { threads: entries.length, active: entries.filter((e) => e.row.active).length, waiting: waiting.size },
@@ -526,6 +566,7 @@ export function pageOf(ix: ThreadIndex, q: ThreadQuery, broken: ThreadPage['brok
526
566
  (q.handled || row.active) &&
527
567
  (q.subject === null || row.subject === q.subject) &&
528
568
  (q.whose === null || row.move === q.whose) &&
569
+ (q.turn === null || row.turn === q.turn) &&
529
570
  (q.status === null || row.status === q.status) &&
530
571
  (q.lane === null || row.lane === q.lane) &&
531
572
  words.every((w) => text.includes(w)),
@@ -542,6 +583,36 @@ export function pageOf(ix: ThreadIndex, q: ThreadQuery, broken: ThreadPage['brok
542
583
  }
543
584
  }
544
585
 
586
+ // ── the thread control of an object ──
587
+
588
+ /** one thread as an object's control lists it */
589
+ export interface ObjectThread {
590
+ head: string
591
+ title: string
592
+ turn: Turn
593
+ status: ShownStatus
594
+ /** it owns the address (or the one above it): his note goes there */
595
+ owns: boolean
596
+ updated: string
597
+ }
598
+
599
+ /** what an object's thread control shows: the threads that name its address or a part of it, the one his note would go
600
+ * to, and the open threads he may attach it to */
601
+ export function threadsOfAddress(ix: ThreadIndex, threads: readonly Thread[], address: string): { address: string; threads: ObjectThread[]; noteGoesTo: string | null; open: ObjectThread[] } {
602
+ const rows = new Map(ix.entries.map((e) => [e.row.head, e.row]))
603
+ const as = (t: Thread, owns: boolean): ObjectThread | null => {
604
+ const r = rows.get(t.head.item.id)
605
+ return r ? { head: r.head, title: r.title, turn: r.turn, status: r.status, owns, updated: r.updated } : null
606
+ }
607
+ const up: string[] = []
608
+ for (let a: string | null = address; a !== null; a = parentAddress(a)) up.push(a)
609
+ const owner = up.map((a) => threads.find((t) => ownAddressesOf(t).includes(a))).find((t) => t !== undefined) ?? null
610
+ const naming = threads.filter((t) => addressesOfThread(t).some((a) => a === address || a.startsWith(`${address}/`)) || t === owner)
611
+ const list = naming.flatMap((t) => as(t, t === owner) ?? []).sort((a, b) => b.updated.localeCompare(a.updated))
612
+ const open = ix.entries.filter((e) => e.row.turn !== 'done' && !list.some((l) => l.head === e.row.head)).slice(0, 30).flatMap((e) => as(e.t, false) ?? [])
613
+ return { address, threads: list, noteGoesTo: owner?.head.item.id ?? null, open }
614
+ }
615
+
545
616
  // ── the dispatcher's board ──
546
617
 
547
618
  /** one raised item on the board: what he, a player or a rule raised, where it stands */
@@ -0,0 +1,41 @@
1
+ // a draft card as `sk thread add --draft` makes it (wiki tools/shipkit/threads.md, A post draft): the post draft a slug
2
+ // names, pinned by the hash of its head and of each message. No picture is made: the hub shows the draft itself, read
3
+ // live. A draft the loader does not take clean is refused in the loader's words
4
+ import { dirname, relative } from 'node:path'
5
+ import { accountOf, draftsDir, findDraft, type Desk, type Draft } from '../social/load.ts'
6
+ import { pinOf } from './draft-model.ts'
7
+ import type { DraftCard } from './model.ts'
8
+
9
+ /** the loader's lines on one draft folder: its file's, its folder's, its media's */
10
+ const linesOn = (desk: Desk, folder: string): string[] => desk.errors.filter((e) => e.startsWith(`${folder}/`) || e.startsWith(`${folder}:`))
11
+
12
+ /** the draft `ref` names (its folder's name, its topic or its path) as a card pins it; throws on a draft that does not
13
+ * load, one the loader reports an error on, and one with no message to judge */
14
+ export function draftCardOf(desk: Desk, ref: string, cwd: string): { card: DraftCard; draft: Draft } {
15
+ const where = relative(desk.root, draftsDir(desk.root))
16
+ let draft: Draft
17
+ try {
18
+ draft = findDraft(desk, ref, cwd)
19
+ } catch (e) {
20
+ // a draft the loader left out says why on its own lines
21
+ const name = ref.replace(/\/(draft\.md)?$/, '').split('/').pop() ?? ref
22
+ const said = desk.errors.filter((l) => {
23
+ const folder = l.startsWith(`${where}/`) ? (l.slice(where.length + 1).split(/[/:]/)[0] ?? '') : null
24
+ return folder !== null && (folder === name || folder.replace(/^\d{8}-\d{6}-/, '') === name)
25
+ })
26
+ throw new Error(said.length > 0 ? refusal(ref, said) : `--draft ${ref}: ${(e as Error).message}`)
27
+ }
28
+ const said = linesOn(desk, dirname(draft.file))
29
+ if (said.length > 0) throw new Error(refusal(ref, said))
30
+ if (draft.posts.length === 0) throw new Error(`--draft ${ref}: ${draft.file} holds no message, so nothing he could judge: a \`## <account>\` heading and its text make one`)
31
+ const card = pinOf(draft, (p) => {
32
+ try {
33
+ return accountOf(desk, p.identity, p.platform)
34
+ } catch {
35
+ return null
36
+ }
37
+ })
38
+ return { card, draft }
39
+ }
40
+
41
+ const refusal = (ref: string, said: readonly string[]): string => `--draft ${ref}: the draft does not load clean, fix it first. The loader says:\n${said.map((l) => ` ${l}`).join('\n')}`
@@ -0,0 +1,78 @@
1
+ // a draft card's pure half (wiki tools/shipkit/threads.md, A post draft): a message's name, the hash of what its draft
2
+ // says of it, a draft pinned as a card, and what moved since. Browser safe: the CLI pins with it, the hub compares with
3
+ // the same code, so the two never disagree on a hash
4
+ import type { DeskAccount, Draft, SocialPost } from '../social/load.ts'
5
+ import type { DraftCard } from './model.ts'
6
+
7
+ /** a text's hash, 53 bits as hex (cyrb53). It says « this text moved », nothing rides on it being hard to forge */
8
+ export function textHash(s: string): string {
9
+ let a = 0xdeadbeef
10
+ let b = 0x41c6ce57
11
+ for (let i = 0; i < s.length; i++) {
12
+ const c = s.charCodeAt(i)
13
+ a = Math.imul(a ^ c, 2654435761)
14
+ b = Math.imul(b ^ c, 1597334677)
15
+ }
16
+ a = Math.imul(a ^ (a >>> 16), 2246822507) ^ Math.imul(b ^ (b >>> 13), 3266489909)
17
+ b = Math.imul(b ^ (b >>> 16), 2246822507) ^ Math.imul(a ^ (a >>> 13), 3266489909)
18
+ return (4294967296 * (2097151 & b) + (a >>> 0)).toString(16).padStart(14, '0')
19
+ }
20
+
21
+ type Named = Pick<DeskAccount, 'name' | 'places'>
22
+
23
+ /** a message as he reads it: its account, its name among several there, the place it goes to (« Reddit · comfyui »,
24
+ * « Discord → devlog », « X ») */
25
+ export function postName(a: Named | null, p: Pick<SocialPost, 'platform' | 'name' | 'place'>): string {
26
+ const place = p.place === '' ? '' : ` → ${a?.places.find((x) => x.id === p.place)?.name ?? p.place}`
27
+ return `${a?.name ?? p.platform}${p.name ? ` · ${p.name}` : ''}${place}`
28
+ }
29
+
30
+ /** what the draft says of one message: the heading's own words, never the text composed for a day (a Saturday adds a
31
+ * tag) or filled from the identity's rows, so only an edit of the draft moves it */
32
+ export const postHash = (p: Pick<SocialPost, 'title' | 'body' | 'tags' | 'media' | 'place' | 'tier' | 'rating'>): string =>
33
+ textHash(JSON.stringify([p.title, p.body, p.tags, p.media?.name ?? '', p.place, p.tier, p.rating]))
34
+
35
+ /** what the draft says beside its messages: its title, kind, angle, description and media */
36
+ export const headHash = (d: Pick<Draft, 'title' | 'kind' | 'angle' | 'alt' | 'media'>): string => textHash(JSON.stringify([d.title, d.kind, d.angle, d.alt, d.media.map((m) => m.name)]))
37
+
38
+ type Pinned = Pick<Draft, 'slug' | 'title' | 'kind' | 'angle' | 'alt' | 'media'> & { posts: readonly SocialPost[] }
39
+
40
+ /** a draft as a card pins it, its messages in the draft's order; `accountOf` names each message's account */
41
+ export function pinOf(d: Pinned, accountOf: (p: SocialPost) => Named | null): DraftCard {
42
+ return { slug: d.slug, hash: headHash(d), posts: d.posts.map((p) => ({ key: p.key, name: postName(accountOf(p), p), hash: postHash(p) })) }
43
+ }
44
+
45
+ /** what moved in a draft since its card: the messages whose words changed, the ones it gained, the ones it lost, each
46
+ * by key and name, and whether its head or angle moved */
47
+ export interface DraftChange {
48
+ changed: { key: string; name: string }[]
49
+ added: { key: string; name: string }[]
50
+ gone: { key: string; name: string }[]
51
+ head: boolean
52
+ }
53
+
54
+ /** the draft as it stands against the card; null when nothing moved */
55
+ export function draftChange(card: DraftCard, now: DraftCard): DraftChange | null {
56
+ const was = new Map(card.posts.map((p) => [p.key, p]))
57
+ const is = new Map(now.posts.map((p) => [p.key, p]))
58
+ const pick = (p: { key: string; name: string }): { key: string; name: string } => ({ key: p.key, name: p.name })
59
+ const c: DraftChange = {
60
+ changed: now.posts.filter((p) => was.has(p.key) && was.get(p.key)!.hash !== p.hash).map(pick),
61
+ added: now.posts.filter((p) => !was.has(p.key)).map(pick),
62
+ gone: card.posts.filter((p) => !is.has(p.key)).map(pick),
63
+ head: card.hash !== now.hash,
64
+ }
65
+ return c.changed.length + c.added.length + c.gone.length === 0 && !c.head ? null : c
66
+ }
67
+
68
+ /** how one message of the live draft stands against the card */
69
+ export const postChange = (c: DraftChange | null, key: string): 'changed' | 'new' | null =>
70
+ c?.changed.some((p) => p.key === key) ? 'changed' : c?.added.some((p) => p.key === key) ? 'new' : null
71
+
72
+ /** the change in one line: « the draft changed since this card: 2 places (X · Mastodon, new) » */
73
+ export function changeLine(c: DraftChange): string {
74
+ const names = [...c.changed.map((p) => p.name), ...c.added.map((p) => `${p.name}, new`), ...c.gone.map((p) => `${p.name}, gone`)]
75
+ const n = names.length
76
+ if (n === 0) return 'the draft changed since this card: its head or its angle, no place'
77
+ return `the draft changed since this card: ${n} place${n > 1 ? 's' : ''} (${names.join(' · ')})${c.head ? ', and its head or its angle' : ''}`
78
+ }
@@ -1,7 +1,8 @@
1
- // what `sk review inbox`, `show`, `watch`, `next` and `board` print of an item and its answer (wiki tools/shipkit/review.md):
1
+ // what `sk thread inbox`, `show`, `watch`, `next` and `board` print of an item and its answer (wiki tools/shipkit/threads.md):
2
2
  // one record per thread, rectangles normalized and in pixels, a frame note's cut, shot and time into it, and the lines the
3
3
  // repo's unit adds (a kind's facts, a source's), handed in as `more` so this module stays pure
4
- import { aboutText, isFrame, isGallery, isPair, NO_SPEC, placeText, stateOf, takenBackOf, unreadBy, updateTag, verdictOf, type Message, type Rect, type ReviewItem, type ReviewStatus, type Spec, type Subject } from './model.ts'
4
+ import { aboutText, isFrame, isGallery, isPair, NO_SPEC, placeText, stateOf, takenBackOf, unreadBy, updateTag, verdictOf, type DraftCard, type Message, type Rect, type ReviewItem, type ReviewStatus, type Spec, type Subject } from './model.ts'
5
+ import { LAYOUT } from '../core/layout.ts'
5
6
  import { answererOf, conversationOf, membersOf, openingOf, type Thread } from './threads.ts'
6
7
 
7
8
  /** what a message is in a thread beyond its words: ` [update 2 (still broken)]` on an agent's update, ` (on update 2
@@ -28,9 +29,9 @@ const flat = (t: string): string => t.replace(/\s+/g, ' ').trim()
28
29
  const atText = (t: number | undefined, shot?: Rect['shot']): string =>
29
30
  (t === undefined ? '' : ` at ${t.toFixed(2)} s`) + (shot ? ` (shot ${shot.name} +${shot.time.toFixed(2)} s)` : '')
30
31
 
31
- /** each reaction to one view or tile: its place by label, its status, its comment */
32
+ /** each reaction to one view, tile or message of a draft: its place by label, its status, its comment */
32
33
  const reactionTexts = (x: ReviewItem): string[] =>
33
- (verdictOf(x)?.reactions ?? []).map((q) => `${placeText(q, x.item.views)}${q.picked ? ' picked' : ''}${q.status ? ` ${q.status}` : ''}${q.stars ? ` ★${q.stars}` : ''}${q.comment ? `: ${flat(q.comment)}` : ''}`)
34
+ (verdictOf(x)?.reactions ?? []).map((q) => `${placeText(q, x.item.views, x.item.draft)}${q.picked ? ' picked' : ''}${q.status ? ` ${q.status}` : ''}${q.stars ? ` ★${q.stars}` : ''}${q.comment ? `: ${flat(q.comment)}` : ''}`)
34
35
 
35
36
  /** the view he picked on a choice card, `picked [voice 1]`; null when he picked none */
36
37
  const pickText = (x: ReviewItem): string | null => {
@@ -54,7 +55,21 @@ export function line(x: ReviewItem): string {
54
55
  export const refOf = (x: ReviewItem): string => (x.item.origin.by === 'player' ? `${x.item.origin.server}#${x.item.origin.serverId}` : x.item.id)
55
56
 
56
57
  /** one owner reply, for a monitor; on an item a card answers, it reads on the card's thread */
58
+ /** his answer to a question or a proposed change, as an agent reads it: what was asked, what he picked or applied */
59
+ function answerLine(x: ReviewItem, m: Message): string | null {
60
+ const asked = m.answer && m.re ? x.thread.find((y) => y.id === m.re) : undefined
61
+ if (!asked || !m.answer) return null
62
+ if (asked.ask && m.answer.option !== undefined) {
63
+ const label = asked.ask.options[m.answer.option] ?? `option ${m.answer.option + 1}`
64
+ const words = (m.text ?? '').startsWith(label) ? (m.text ?? '').slice(label.length).replace(/^:\s*/, '') : (m.text ?? '')
65
+ return `${x.item.id} answered "${flat(asked.text ?? '')}": picked ${m.answer.option + 1} « ${label} »${asked.ask.pick === m.answer.option ? ' (your pick)' : ''}${words ? `: ${flat(words)}` : ''}`
66
+ }
67
+ if (asked.propose && m.answer.apply) return `${x.item.id} applied your change of ${asked.propose.on}: land this text: ${flat(m.text ?? asked.propose.after)}`
68
+ return null
69
+ }
70
+
57
71
  export const replyLine = (x: ReviewItem, m: Message, card: ReviewItem | null = null): string =>
72
+ answerLine(x, m) ??
58
73
  `${(card ?? x).item.id} reply "${(card ?? x).item.title}"${card ? ` (on ${refOf(x)})` : ''}${updateText(x, m)}: ${flat(m.text ?? '')}${m.image ? ` [image thread/${m.image}]` : ''}`
59
74
 
60
75
  const TOOK: Record<ReviewStatus, string> = { approved: 'approval', 'approved-with-fix': '« ok with a fix »', rejected: 'rejection', archived: '« archived, later »' }
@@ -63,7 +78,7 @@ const TOOK: Record<ReviewStatus, string> = { approved: 'approval', 'approved-wit
63
78
  export const takeBackTexts = (x: ReviewItem): { m: Message; text: string }[] =>
64
79
  takenBackOf(x).map(({ m, took, given }) => ({
65
80
  m,
66
- text: `he took his ${TOOK[took]} back (given ${given}): the card waits for his answer again and that ${TOOK[took]} no longer holds; hold or undo what you did on it, then sk review seen ${x.item.id}`,
81
+ text: `he took his ${TOOK[took]} back (given ${given}): the card waits for his answer again and that ${TOOK[took]} no longer holds; hold or undo what you did on it, then sk thread seen ${x.item.id}`,
67
82
  }))
68
83
 
69
84
  /** what watch prints of an item, each with the key it prints once under: a verdict he took back, an unseen feedback (again
@@ -84,12 +99,12 @@ export function watchLines(x: ReviewItem, items: readonly ReviewItem[] = []): {
84
99
  export function raisedLine(x: ReviewItem): { key: string; text: string } | null {
85
100
  const o = x.item.origin
86
101
  if (o.by !== 'auto' || stateOf(x, false).state !== 'open') return null
87
- return { key: `raised ${x.item.id}`, text: `${x.item.id} raised "${x.item.title}" (auto rule ${o.rule}, key ${o.key}) to ${o.lane}: take it: sk review next --lane ${o.lane}` }
102
+ return { key: `raised ${x.item.id}`, text: `${x.item.id} raised "${x.item.title}" (auto rule ${o.rule}, key ${o.key}) to ${o.lane}: take it: sk thread next --lane ${o.lane}` }
88
103
  }
89
104
 
90
105
  /** an item nobody takes, for a watch and the inbox */
91
106
  export const untakenLine = (x: ReviewItem, why: string, lane: string | null): string =>
92
- `${x.item.id} untaken "${x.item.title}" (${why}): ask the other sessions (ListAgents, then SendMessage) whether one of them wants it; if none answers, claim it: sk review claim ${x.item.id} --as ${lane ?? '<your lane>'}`
107
+ `${x.item.id} untaken "${x.item.title}" (${why}): ask the other sessions (ListAgents, then SendMessage) whether one of them wants it; if none answers, claim it: sk thread claim ${x.item.id} --as ${lane ?? '<your lane>'}`
93
108
 
94
109
  /** one thread as one record: each item the card answers, then the card, its older versions, and with `full` the whole conversation */
95
110
  export function threadDetail(t: Thread, dir: string, full = false, say: Say = PLAIN): string {
@@ -120,6 +135,9 @@ function subjectText(s: Subject): string | null {
120
135
  return null
121
136
  }
122
137
 
138
+ /** a draft card's draft: its file, and each message the card pinned by name, the names his answers come back under */
139
+ const draftText = (d: DraftCard): string => ` draft: ${LAYOUT.social}/drafts/${d.slug}/draft.md, ${d.posts.length} place${d.posts.length > 1 ? 's' : ''}: ${d.posts.map((p) => p.name).join(', ')}`
140
+
123
141
  const boxText = (b: { x0: number; y0: number; x1: number; y1: number }): string => `${b.x0},${b.y0}..${b.x1},${b.y1}`
124
142
 
125
143
  /** a rectangle's world box and the nodes under its middle, when the tool that drew it knew them */
@@ -142,7 +160,7 @@ export function detail(x: ReviewItem, dir: string, full = false, followed = fals
142
160
  const r = x.item
143
161
  const head = ` "${r.title}" (${aboutText(r, say.spec)})`
144
162
  const frame = subjectText(r.subject)
145
- const sub = [...(frame ? [frame] : []), ...say.more(x)]
163
+ const sub = [...(frame ? [frame] : []), ...(r.draft ? [draftText(r.draft)] : []), ...say.more(x)]
146
164
  const replies = unreadBy(x, 'agent').map((m) => ` reply ${m.at}${updateText(x, m)}: ${m.text}${m.image ? ` [image ${dir}/${r.id}/thread/${m.image}]` : ''}`)
147
165
  if (r.origin.by !== 'agent') {
148
166
  const st = stateOf(x, followed)
@@ -166,7 +184,7 @@ export function detail(x: ReviewItem, dir: string, full = false, followed = fals
166
184
  if (!f) return [`${r.id} ${back.length > 0 ? 'TAKEN BACK, NO VERDICT NOW' : 'NO VERDICT YET'}`, head, ...sub, ...back, ...replies].join('\n')
167
185
  const pick = pickText(x)
168
186
  const out = [`${r.id} ${f.status.toUpperCase()} ${f.at}`, head, ...sub, ...back, ...(pick ? [` ${pick}`] : []), ` comment: ${f.comment || '(none)'}`]
169
- for (const t of reactionTexts(x)) out.push(` view ${t}`)
187
+ for (const t of reactionTexts(x)) out.push(` ${r.draft ? 'place' : 'view'} ${t}`)
170
188
  const px = (v: number, of: number): number => Math.round(v * of)
171
189
  const views = r.views
172
190
  f.rects.forEach((q, i) => {
@@ -181,6 +199,7 @@ export function detail(x: ReviewItem, dir: string, full = false, followed = fals
181
199
  out.push(` #${i + 1}${on}${side} ${norm} (${pix})${atText(q.t, q.shot)}: ${q.comment || '(no comment)'}`)
182
200
  })
183
201
  const files = views.flatMap((v) => (isGallery(v) ? v.gallery.map((t) => t.file) : Object.values(v.files)))
184
- out.push(` files: ${files.map((n) => `${dir}/${r.id}/${n}`).join(' ')}`, ...replies)
202
+ if (files.length > 0) out.push(` files: ${files.map((n) => `${dir}/${r.id}/${n}`).join(' ')}`)
203
+ out.push(...replies)
185
204
  return out.join('\n')
186
205
  }
@@ -0,0 +1,98 @@
1
+ // the cards a store set aside (`.shipkit/review/.gone/<id>`, the rows of `review_gone` with the switch cards-in-db): a
2
+ // card deleted while its machine carries cards to the hq, or one another machine deleted. Kept 30 days, then removed by the repo's retention sweep, whatever the switch. A
3
+ // second card of one id set aside keeps the first: `<id>.2`, `<id>.3`. No heavy import: the retention reads it
4
+ import { existsSync, lstatSync, readdirSync, readFileSync, rmSync, statSync } from 'node:fs'
5
+ import { join } from 'node:path'
6
+ import { cardsInDb } from '../hq/switch.ts'
7
+ import { GONE } from './card-db.ts'
8
+ import { rowsGone, rowsGoneCreated, rowsGoneUse, rowsSweepGone } from './card-rows.ts'
9
+ import { ID_RE } from './model.ts'
10
+
11
+ export { GONE }
12
+ /** how long a card set aside stays before it goes for good */
13
+ export const GONE_KEEP_MS = 30 * 24 * 3600_000
14
+
15
+ const ENTRY_RE = /^(.+?)(?:\.(\d+))?$/
16
+
17
+ /** `.gone` as a real folder, never a link or a file: the sweep removes what is in it, and the job sends a deletion
18
+ * of each card it holds. True when it is one, false when there is none; throws when something else holds its name */
19
+ export function goneDir(dir: string): boolean {
20
+ const s = lstatSync(join(dir, GONE), { throwIfNoEntry: false })
21
+ if (s == null) return false
22
+ // a file in the way, as the disk says it: a card the hq deleted waits until the folder is one again
23
+ if (!s.isDirectory()) throw Object.assign(new Error(`${join(dir, GONE)} is not a folder (${s.isSymbolicLink() ? 'a link' : 'a file'}): no card is set aside, swept or sent through it`), { code: 'ENOTDIR' })
24
+ return true
25
+ }
26
+ const realGone = (dir: string): boolean => {
27
+ try {
28
+ return goneDir(dir)
29
+ } catch {
30
+ return false
31
+ }
32
+ }
33
+
34
+ /** the cards set aside in a store: each one's id and its folder's name there */
35
+ export const goneEntries = (dir: string): { id: string; entry: string }[] => (cardsInDb() ? rowsGone(dir) : goneFolders(dir))
36
+
37
+ /** the cards set aside in a store's files */
38
+ export function goneFolders(dir: string): { id: string; entry: string }[] {
39
+ const g = join(dir, GONE)
40
+ if (!realGone(dir)) return []
41
+ return readdirSync(g)
42
+ .flatMap((entry) => {
43
+ const id = ENTRY_RE.exec(entry)?.[1] ?? ''
44
+ return ID_RE.test(id) ? [{ id, entry }] : []
45
+ })
46
+ .sort((a, b) => (a.entry < b.entry ? -1 : 1))
47
+ }
48
+
49
+ /** a free name in `.gone` for that id: the id, else the id and the next number */
50
+ export function goneEntryFor(dir: string, id: string): string {
51
+ goneDir(dir)
52
+ if (!existsSync(join(dir, GONE, id))) return id
53
+ for (let n = 2; ; n++) if (!existsSync(join(dir, GONE, `${id}.${n}`))) return `${id}.${n}`
54
+ }
55
+
56
+ /** how many cards are set aside, and since when the oldest: the folder's change time is the moment it was moved */
57
+ export function goneUse(dir: string): { count: number; oldest: number | null } {
58
+ let oldest: number | null = null
59
+ const all = goneFolders(dir)
60
+ for (const e of all) {
61
+ const s = statSync(join(dir, GONE, e.entry), { throwIfNoEntry: false })
62
+ if (s) oldest = oldest == null ? s.ctimeMs : Math.min(oldest, s.ctimeMs)
63
+ }
64
+ if (!cardsInDb()) return { count: all.length, oldest }
65
+ // the rows, and the folders the files set aside before the move: an entry the move copied is counted once
66
+ const r = rowsGoneUse(dir)
67
+ const rows = new Set(rowsGone(dir).map((g) => g.entry))
68
+ return { count: r.count + all.filter((e) => !rows.has(e.entry)).length, oldest: r.oldest == null ? oldest : oldest == null ? r.oldest : Math.min(oldest, r.oldest) }
69
+ }
70
+
71
+ /** the cards set aside more than `keepMs` ago go for good: how many */
72
+ export function sweepGone(dir: string, now: number = Date.now(), keepMs: number = GONE_KEEP_MS): number {
73
+ // with the rows, the folders the files set aside before the move go at the same age: the rows hold each one
74
+ let n = cardsInDb() ? rowsSweepGone(dir, now, keepMs) : 0
75
+ const rows = cardsInDb() ? new Set(rowsGone(dir).map((g) => g.entry)) : new Set<string>()
76
+ for (const e of goneFolders(dir)) {
77
+ const f = join(dir, GONE, e.entry)
78
+ const s = statSync(f, { throwIfNoEntry: false })
79
+ if (s && s.ctimeMs < now - keepMs) {
80
+ rmSync(f, { recursive: true, force: true })
81
+ if (!rows.has(e.entry)) n++
82
+ }
83
+ }
84
+ return n
85
+ }
86
+
87
+ /** the `created` of a card set aside, null when its head does not read */
88
+ export const goneCreated = (dir: string, entry: string): string | null => (cardsInDb() ? rowsGoneCreated(dir, entry) : goneFolderCreated(dir, entry))
89
+
90
+ /** the `created` of a card set aside in a store's files */
91
+ export function goneFolderCreated(dir: string, entry: string): string | null {
92
+ try {
93
+ const v = JSON.parse(readFileSync(join(dir, GONE, entry, 'item.json'), 'utf8')) as { created?: unknown }
94
+ return typeof v.created === 'string' && v.created !== '' ? v.created : null
95
+ } catch {
96
+ return null
97
+ }
98
+ }
@@ -0,0 +1,35 @@
1
+ // `sk thread inbox --hook`: the inbox as a Claude Code hook, so the owner's answers reach a session that holds no
2
+ // watch. On a prompt (UserPromptSubmit) the unseen answers join the turn as context; at a turn's end (Stop) the turn
3
+ // is refused while one is unseen. An answer is seen once `sk thread seen <id>` ran, after the session acted on it.
4
+ // the one constraint a reader breaks first: a Stop the hook already refused once (`stop_hook_active`) passes, else
5
+ // a session that cannot mark an answer seen never ends its turn
6
+
7
+ /** what Claude Code hands a hook on stdin, the two fields read here */
8
+ export type HookInput = { hook_event_name?: string; stop_hook_active?: boolean }
9
+
10
+ export function parseHookInput(text: string): HookInput {
11
+ try {
12
+ const v = JSON.parse(text === '' ? '{}' : text) as unknown
13
+ return typeof v === 'object' && v !== null ? (v as HookInput) : {}
14
+ } catch {
15
+ return {}
16
+ }
17
+ }
18
+
19
+ /** true when the hook answers nothing and the inbox need not be read at all */
20
+ export const hookPasses = (input: HookInput): boolean => input.hook_event_name === 'Stop' && input.stop_hook_active === true
21
+
22
+ /** the one json line the hook prints, or null for none. `unseen`: the answers not marked seen, as the inbox prints
23
+ * them; `owed`: the ids of the answers read and not closed */
24
+ export function hookAnswer(input: HookInput, unseen: string, owed: readonly string[], bin = 'sk'): string | null {
25
+ if (hookPasses(input)) return null
26
+ if (input.hook_event_name === 'Stop') {
27
+ if (unseen === '') return null
28
+ return JSON.stringify({ decision: 'block', reason: `The owner's answers in threads are not marked seen. Read each, act on it (relay it to its lane, answer it), then \`${bin} thread seen <id>\`:\n${unseen}` })
29
+ }
30
+ const parts = [
31
+ unseen === '' ? '' : `Unseen answers of the owner in threads (act on each, then \`${bin} thread seen <id>\`):\n${unseen}`,
32
+ owed.length === 0 ? '' : `Answers read but not closed (done or wontfix): ${owed.join(', ')}`,
33
+ ].filter((p) => p !== '')
34
+ return parts.length === 0 ? null : JSON.stringify({ hookSpecificOutput: { hookEventName: 'UserPromptSubmit', additionalContext: parts.join('\n\n') } })
35
+ }
@@ -1,4 +1,4 @@
1
- // the owner's marks kept in the store (wiki tools/shipkit/review.md, Verbs on the store): a mark is a `rate` message of his
1
+ // the owner's marks kept in the store (wiki tools/shipkit/threads.md, Verbs on the store): a mark is a `rate` message of his
2
2
  // on a subject (stars, a mark word, a part's stars, a note); the latest is the mark, the older ones its history. Pure
3
3
  import { partyOf, subjectKey, type Message, type ReviewItem, type Spec } from './model.ts'
4
4
 
@@ -1,4 +1,4 @@
1
- // the review store as a kind of the media store (wiki tools/shipkit/review.md, Media in the Space): each file a card's
1
+ // the review store as a kind of the media store (wiki tools/shipkit/threads.md, Media in the Space): each file a card's
2
2
  // views name, by the facts its item.json keeps; kept on the disk while its thread is active or spoke in the window; an
3
3
  // image's previews and a clip's play copy sent up before it goes
4
4
  import { existsSync, statSync } from 'node:fs'
@@ -10,14 +10,16 @@ import { threadIndex } from './cells.ts'
10
10
  import { previewKey, REVIEW_KIND } from './media-read.ts'
11
11
  import { mediaFilesOf } from './model.ts'
12
12
  import { playsCopy, previewFile, PREVIEW_W, type PreviewSize } from './previews.ts'
13
- import { fillMedia, readAll, readAllCached, storeDir, storeStamp } from './store.ts'
13
+ import { fillMedia, mediaDir, readAll, readAllCached, storeDir, storeStamp } from './store.ts'
14
14
  import { membersOf } from './threads.ts'
15
15
 
16
16
  const IMAGE = /\.(png|jpe?g|webp)$/i
17
17
 
18
18
  export const reviewMedia: MediaKind = {
19
19
  kind: REVIEW_KIND,
20
- storeOf: (root) => storeDir(root),
20
+ what: 'the review cards\' pictures and clips, and their previews',
21
+ // the spool while the cards are rows (card-db.ts spoolOf): any verb of the store given it reads the same cards
22
+ storeOf: (root) => mediaDir(storeDir(root)),
21
23
  stamp: (dir) => storeStamp(dir),
22
24
  async scan(dir, o) {
23
25
  const rows: MediaRow[] = []
@@ -29,7 +31,7 @@ export const reviewMedia: MediaKind = {
29
31
  let item = x.item
30
32
  const names = mediaFilesOf({ item, thread: x.thread })
31
33
  if (names.length === 0) continue
32
- const size = (n: string): number | undefined => statSync(join(dir, id, n), { throwIfNoEntry: false })?.size
34
+ const size = (n: string): number | undefined => statSync(join(mediaDir(dir), id, n), { throwIfNoEntry: false })?.size
33
35
  const lacks = names.some((n) => {
34
36
  const s = size(n)
35
37
  return s !== undefined && item.media?.[n]?.size !== s
@@ -79,7 +81,7 @@ async function previewsUp(dir: string, space: Space, r: { item: string; name: st
79
81
  if (isUp(key)) continue
80
82
  const file = await previewFile(dir, r.item, r.name, size)
81
83
  // a copy that failed answers the clip itself, never sent up as its preview
82
- if (!file || !existsSync(file) || file === join(dir, r.item, r.name)) continue
84
+ if (!file || !existsSync(file) || file === join(mediaDir(dir), r.item, r.name)) continue
83
85
  const n = statSync(file).size
84
86
  await space.put(key, file, ext === 'mp4' ? 'video/mp4' : 'image/webp')
85
87
  if ((await space.head(key))?.size === n) recordUp(key, n)
@@ -1,11 +1,12 @@
1
- // the reads a route or a tool makes of a card's file (wiki tools/shipkit/review.md, Media in the Space): its key in the
1
+ // the reads a route or a tool makes of a card's file (wiki tools/shipkit/threads.md, Media in the Space): its key in the
2
2
  // Space by the facts its item.json keeps, a URL signed for a file the disk let go, the file fetched back for its bytes
3
- import { existsSync, readFileSync } from 'node:fs'
3
+ import { existsSync } from 'node:fs'
4
4
  import { join } from 'node:path'
5
5
  import { mediaKey } from '../media-store/content.ts'
6
6
  import type { MediaFact } from '../media-store/fact.ts'
7
7
  import { fetchBack, signedIfUp, signedUrl } from '../media-store/remote.ts'
8
8
  import { ID_RE, isMediaName } from './model.ts'
9
+ import { mediaDir, rawHead } from './store.ts'
9
10
 
10
11
  export const REVIEW_KIND = 'review'
11
12
 
@@ -15,12 +16,12 @@ export const reviewKey = (f: Pick<MediaFact, 'sha'>, name: string): string => me
15
16
  * is found from the item alone */
16
17
  export const previewKey = (f: Pick<MediaFact, 'sha'>, size: string, ext: 'webp' | 'mp4' = 'webp'): string => `${REVIEW_KIND}/${f.sha}.${size}.${ext}`
17
18
 
18
- /** the fact a head keeps for one of its files, read from its item.json alone */
19
+ /** the fact a head keeps for one of its files, read from its head alone */
19
20
  export function factOfFile(dir: string, id: string, name: string): MediaFact | null {
20
21
  if (!ID_RE.test(id) || !isMediaName(name)) return null
21
22
  try {
22
- const head = JSON.parse(readFileSync(join(dir, id, 'item.json'), 'utf8')) as { media?: Record<string, MediaFact> }
23
- return head.media?.[name] ?? null
23
+ const head = rawHead(dir, id)?.head as { media?: Record<string, MediaFact> } | undefined
24
+ return head?.media?.[name] ?? null
24
25
  } catch {
25
26
  return null
26
27
  }
@@ -42,8 +43,9 @@ export async function remotePreviewUrl(dir: string, id: string, name: string, si
42
43
  * holds it */
43
44
  export async function ensureLocal(dir: string, id: string, name: string): Promise<string | null> {
44
45
  if (!ID_RE.test(id) || !isMediaName(name)) return null
45
- const path = join(dir, id, name)
46
+ const media = mediaDir(dir)
47
+ const path = join(media, id, name)
46
48
  if (existsSync(path)) return path
47
49
  const f = factOfFile(dir, id, name)
48
- return f ? fetchBack(path, reviewKey(f, name), f, { store: dir, item: id, name }) : null
50
+ return f ? fetchBack(path, reviewKey(f, name), f, { store: media, item: id, name }) : null
49
51
  }