rvlib-shipkit 2.27.0 → 2.29.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 (855) hide show
  1. package/CHANGELOG.md +71 -0
  2. package/package.json +10 -2
  3. package/src/advisors/acts.ts +277 -0
  4. package/src/advisors/advice.ts +384 -0
  5. package/src/advisors/advisor-view.ts +417 -0
  6. package/src/advisors/app-graph.ts +112 -0
  7. package/src/advisors/app.ts +75 -0
  8. package/src/advisors/door.ts +59 -0
  9. package/src/advisors/edge/api.ts +292 -0
  10. package/src/advisors/edge/bucket.ts +43 -0
  11. package/src/advisors/edge/certs.ts +20 -0
  12. package/src/advisors/edge/form.ts +45 -0
  13. package/src/advisors/edge/handler.ts +156 -0
  14. package/src/advisors/edge/jwt.ts +76 -0
  15. package/src/advisors/edge/shell.ts +27 -0
  16. package/src/advisors/edge/status.ts +12 -0
  17. package/src/advisors/edge/types.ts +137 -0
  18. package/src/advisors/edge/worker.ts +52 -0
  19. package/src/advisors/expose.ts +150 -0
  20. package/src/advisors/job.ts +35 -0
  21. package/src/advisors/owner-store.ts +226 -0
  22. package/src/advisors/photos.ts +182 -0
  23. package/src/advisors/project.ts +311 -0
  24. package/src/advisors/r2.ts +48 -0
  25. package/src/advisors/routes.ts +469 -0
  26. package/src/advisors/scan.ts +194 -0
  27. package/src/advisors/sync.ts +363 -0
  28. package/src/agent-time/accounts-usage-disk.ts +29 -0
  29. package/src/agent-time/accounts-usage.ts +97 -0
  30. package/src/agent-time/hooks.ts +73 -29
  31. package/src/agent-time/lane-name.ts +7 -0
  32. package/src/agent-time/leads.ts +95 -0
  33. package/src/agent-time/live.ts +11 -5
  34. package/src/agent-time/registry.ts +354 -0
  35. package/src/agent-time/render.ts +35 -4
  36. package/src/agent-time/report-cache.ts +4 -8
  37. package/src/agent-time/report.ts +19 -1
  38. package/src/agent-time/store.ts +10 -16
  39. package/src/annex/born.ts +2 -2
  40. package/src/annex/offload.ts +12 -11
  41. package/src/annex/snapshots.ts +3 -3
  42. package/src/annex/tidy.ts +10 -23
  43. package/src/asks/ask-after.ts +8 -3
  44. package/src/asks/ask-bar-fold.ts +57 -0
  45. package/src/asks/ask-carry.ts +190 -0
  46. package/src/asks/ask-close.ts +72 -0
  47. package/src/asks/ask-doc.ts +42 -0
  48. package/src/asks/ask-migrate.ts +280 -0
  49. package/src/asks/ask-steps-fold.ts +123 -0
  50. package/src/asks/ask-store.ts +703 -0
  51. package/src/asks/ask-words-fold.ts +208 -0
  52. package/src/assets/kits/identity-kit.ts +106 -38
  53. package/src/assets/kits/poster-thumbnail.ts +282 -0
  54. package/src/checks/SK001-package-json-shape.check.ts +5 -7
  55. package/src/checks/SK003-claude-md-shape.check.ts +92 -25
  56. package/src/checks/SK004-gitignore-policy.check.ts +21 -17
  57. package/src/checks/SK010-undeclared-unit.check.ts +77 -64
  58. package/src/checks/SK013-one-way-in-policy.check.ts +27 -5
  59. package/src/checks/SK026-asks-autoclose.check.ts +9 -23
  60. package/src/checks/SK027-agent-wiki-links.check.ts +46 -6
  61. package/src/checks/SK033-global-contribution.check.ts +1 -1
  62. package/src/checks/SK036-draft-media-size.check.ts +5 -4
  63. package/src/checks/SK038-speaks-as.check.ts +3 -3
  64. package/src/checks/SK039-vscode-watch-generated.check.ts +1 -1
  65. package/src/checks/SK040-release-words.check.ts +39 -10
  66. package/src/checks/SK042-post-kinds.check.ts +26 -24
  67. package/src/checks/SK045-slow-hooks.check.ts +5 -2
  68. package/src/checks/SK049-thread-answers-hook.check.ts +83 -0
  69. package/src/checks/SK050-retired-commands.check.ts +127 -0
  70. package/src/checks/SK051-no-formatter.check.ts +485 -0
  71. package/src/cli/cmd_Advisors.ts +336 -0
  72. package/src/cli/cmd_Annex.ts +10 -10
  73. package/src/cli/cmd_Asks.ts +303 -51
  74. package/src/cli/cmd_Backup.ts +157 -14
  75. package/src/cli/cmd_CacheAudit.ts +1 -1
  76. package/src/cli/cmd_Calls.ts +1 -0
  77. package/src/cli/cmd_Check.ts +3 -3
  78. package/src/cli/cmd_Checks.ts +1 -1
  79. package/src/cli/cmd_Ci.ts +15 -16
  80. package/src/cli/cmd_Commands.ts +140 -34
  81. package/src/cli/cmd_Contracts.ts +1 -0
  82. package/src/cli/cmd_Db.ts +9 -9
  83. package/src/cli/cmd_FleetPush.ts +1 -1
  84. package/src/cli/cmd_History.ts +2 -2
  85. package/src/cli/cmd_Home.ts +5 -6
  86. package/src/cli/cmd_Hooks.ts +13 -3
  87. package/src/cli/cmd_Hq.ts +30 -19
  88. package/src/cli/cmd_Keys.ts +2 -1
  89. package/src/cli/cmd_Lanes.ts +21 -4
  90. package/src/cli/cmd_Media.ts +59 -13
  91. package/src/cli/cmd_Messages.ts +152 -1
  92. package/src/cli/cmd_Needs.ts +1 -0
  93. package/src/cli/cmd_Orchestrator.ts +138 -0
  94. package/src/cli/cmd_Rec.ts +5 -2
  95. package/src/cli/cmd_Reflect.ts +17 -3
  96. package/src/cli/cmd_Releases.ts +38 -38
  97. package/src/cli/cmd_Review.ts +1500 -424
  98. package/src/cli/cmd_Secret.ts +255 -34
  99. package/src/cli/cmd_Shot.ts +14 -6
  100. package/src/cli/cmd_Social.ts +41 -37
  101. package/src/cli/cmd_SocialDrafts.ts +248 -0
  102. package/src/cli/cmd_Sound.ts +22 -1
  103. package/src/cli/cmd_Space.ts +1 -1
  104. package/src/cli/cmd_Start.ts +3 -2
  105. package/src/cli/cmd_ThreadHolds.ts +34 -0
  106. package/src/cli/cmd_ThreadKinds.ts +153 -0
  107. package/src/cli/cmd_ThreadReflect.ts +91 -0
  108. package/src/cli/cmd_ThreadSyncNeeds.ts +62 -0
  109. package/src/cli/cmd_Time.ts +2 -1
  110. package/src/cli/cmd_Tmp.ts +9 -8
  111. package/src/cli/cmd_TraceAudit.ts +1 -1
  112. package/src/cli/cmd_Trailer.ts +5 -5
  113. package/src/cli/cmd_Urls.ts +3 -3
  114. package/src/cli/cmd_Vault.ts +5 -5
  115. package/src/cli/cmd_When.ts +2 -1
  116. package/src/cli/cmd_Worktrees.ts +109 -0
  117. package/src/cli/family-help.ts +2 -2
  118. package/src/cli/family-pages.ts +1 -1
  119. package/src/cli/kit/builtins.ts +1 -0
  120. package/src/cli/kit/verb.ts +6 -2
  121. package/src/cli/registry.ts +35 -5
  122. package/src/cli.ts +26 -15
  123. package/src/collections/actions.ts +27 -75
  124. package/src/collections/checks.ts +1 -1
  125. package/src/collections/collection-types.ts +23 -8
  126. package/src/collections/md-body.ts +5 -3
  127. package/src/collections/pings.ts +16 -6
  128. package/src/collections/providers.ts +63 -71
  129. package/src/collections/reflections.ts +9 -4
  130. package/src/collections/review.ts +25 -23
  131. package/src/collections/state-rules.ts +8 -7
  132. package/src/comfy/comfy-panel.ts +2 -2
  133. package/src/commands/model.ts +1 -1
  134. package/src/commands/routes.ts +1 -1
  135. package/src/commands/runs.ts +1 -1
  136. package/src/core/app-icon.ts +3 -9
  137. package/src/core/atomic-write.ts +36 -0
  138. package/src/core/budget.ts +16 -1
  139. package/src/core/bun-builtins.ts +7 -7
  140. package/src/core/canonical-scripts.ts +4 -6
  141. package/src/core/check-ctx.ts +17 -3
  142. package/src/core/day-stamp.ts +20 -0
  143. package/src/core/git-bin.ts +10 -0
  144. package/src/core/git.ts +75 -0
  145. package/src/core/hard-reset.ts +1 -2
  146. package/src/core/history-files.ts +4 -8
  147. package/src/core/house-layout.ts +20 -0
  148. package/src/core/hub-theme.ts +16 -0
  149. package/src/core/identity.ts +1 -1
  150. package/src/core/in-base.ts +19 -0
  151. package/src/core/instance.ts +15 -5
  152. package/src/core/last-good.ts +42 -133
  153. package/src/core/layout.ts +11 -6
  154. package/src/core/load-probe.ts +4 -8
  155. package/src/core/locked-write.ts +116 -43
  156. package/src/core/loop-watch.ts +24 -3
  157. package/src/core/machine-db.ts +58 -14
  158. package/src/core/machine-link.ts +1 -1
  159. package/src/core/memory-watch.ts +3 -2
  160. package/src/core/migrate-layout.ts +8 -10
  161. package/src/core/motherhome.ts +2 -1
  162. package/src/core/nearest.ts +23 -0
  163. package/src/core/on-loop.ts +57 -0
  164. package/src/core/one-way-in-policy.ts +26 -13
  165. package/src/core/raw-access.ts +9 -2
  166. package/src/core/reexec.ts +3 -5
  167. package/src/core/repo-walk.ts +104 -0
  168. package/src/core/retention.ts +10 -12
  169. package/src/core/run-dirs.ts +45 -0
  170. package/src/core/runs-matrix.ts +1 -1
  171. package/src/core/slots.ts +2 -2
  172. package/src/core/slug.ts +33 -0
  173. package/src/core/spawn-timeout.ts +3 -1
  174. package/src/core/squircle.ts +0 -8
  175. package/src/core/throwaway-worktree.ts +21 -2
  176. package/src/core/unit-files.ts +4 -4
  177. package/src/core/when-block.ts +4 -5
  178. package/src/core/when.ts +1 -3
  179. package/src/core/words.ts +33 -0
  180. package/src/fleet/push-fleet.ts +4 -11
  181. package/src/{core → gate}/cache-audit.ts +1 -1
  182. package/src/{core → gate}/check-runner.ts +24 -54
  183. package/src/{core → gate}/discover-checks.ts +19 -101
  184. package/src/{core → gate}/discover-legacy-checks.ts +3 -3
  185. package/src/{ledger → gate}/gate-checks.ts +5 -5
  186. package/src/gate/head-gate.ts +151 -0
  187. package/src/{core → gate}/job-follow.ts +1 -1
  188. package/src/{core → gate}/job-run.ts +3 -3
  189. package/src/{core → gate}/pre-commit-discovery.ts +2 -2
  190. package/src/{core → gate}/run-check.ts +7 -7
  191. package/src/{core → gate}/run-ci.ts +9 -9
  192. package/src/gate/run-fix.ts +173 -0
  193. package/src/{core → gate}/run-fixers.ts +14 -14
  194. package/src/{core → gate}/trace-audit.ts +8 -8
  195. package/src/home/activity-shape.ts +1 -1
  196. package/src/home/activity.ts +21 -26
  197. package/src/home/app-sign.ts +17 -9
  198. package/src/home/daemon-guard.ts +6 -0
  199. package/src/home/daemon-jobs.ts +64 -10
  200. package/src/home/database-words.ts +21 -27
  201. package/src/home/databases.ts +3 -3
  202. package/src/home/global-context.ts +2 -2
  203. package/src/home/global-units.ts +1 -1
  204. package/src/home/gui-app/ShipkitGui.swift +129 -55
  205. package/src/home/gui-app.ts +1 -1
  206. package/src/home/handover.ts +126 -0
  207. package/src/home/home-move.ts +29 -16
  208. package/src/home/home-paths.ts +33 -8
  209. package/src/home/home-routes.ts +83 -5
  210. package/src/home/home-start.ts +1 -1
  211. package/src/home/home-state.ts +12 -6
  212. package/src/home/hubs.ts +28 -5
  213. package/src/home/inbox-shape.ts +250 -94
  214. package/src/home/inbox.ts +27 -71
  215. package/src/home/lib-watch.ts +93 -74
  216. package/src/home/machine-fold.ts +54 -56
  217. package/src/home/machine-host.ts +19 -1
  218. package/src/home/machine-repair.ts +5 -6
  219. package/src/home/machine-stores.ts +3 -3
  220. package/src/home/machine-temp.ts +58 -67
  221. package/src/home/other-macs.ts +2 -2
  222. package/src/home/page-build.ts +330 -0
  223. package/src/home/page-held.ts +338 -0
  224. package/src/home/pm-config.ts +10 -2
  225. package/src/home/pm.ts +35 -1
  226. package/src/home/process-apps.ts +3 -3
  227. package/src/home/push-sources.ts +132 -0
  228. package/src/home/run-daemon.ts +54 -4
  229. package/src/home/run-pm.ts +2 -1
  230. package/src/home/run-web.ts +11 -6
  231. package/src/home/search-shape.ts +54 -0
  232. package/src/home/search.ts +114 -0
  233. package/src/home/serve-daemon.ts +40 -18
  234. package/src/home/serve-web.ts +90 -148
  235. package/src/home/space-page.ts +8 -8
  236. package/src/home/space-words.ts +11 -10
  237. package/src/home/supervise.ts +24 -0
  238. package/src/home/time-page-shape.ts +0 -13
  239. package/src/home/vault-page.ts +64 -30
  240. package/src/home/vault-reveal.ts +29 -0
  241. package/src/home/vault-words.ts +5 -5
  242. package/src/home/via-hub.ts +3 -4
  243. package/src/home/worktree-tidy.ts +236 -0
  244. package/src/hooks/edit-guard.ts +12 -0
  245. package/src/hooks/hook-gates.ts +2 -0
  246. package/src/hooks/leak-guard.ts +9 -3
  247. package/src/hooks/one-way-in-guard.ts +32 -2
  248. package/src/hooks/run-hooks.ts +58 -5
  249. package/src/hooks/shared-file.ts +174 -0
  250. package/src/{serve → house}/project-gutter.ts +11 -54
  251. package/src/hq/door-route.ts +2 -2
  252. package/src/hq/door.ts +3 -3
  253. package/src/hq/files-send.ts +32 -33
  254. package/src/hq/forgotten-log.ts +1 -1
  255. package/src/hq/history-check.ts +7 -6
  256. package/src/hq/history-send.ts +12 -14
  257. package/src/hq/hq-db.ts +5 -2
  258. package/src/hq/hq-local.ts +48 -13
  259. package/src/hq/hq-routes.ts +10 -2
  260. package/src/hq/hq-store.ts +10 -6
  261. package/src/hq/kinds/ask.ts +9 -8
  262. package/src/hq/kinds/index.ts +4 -4
  263. package/src/hq/kinds/{card-gone.ts → item-gone.ts} +24 -25
  264. package/src/hq/kinds/{card-msg.ts → item-msg.ts} +25 -27
  265. package/src/hq/kinds/{card.ts → item.ts} +31 -29
  266. package/src/hq/kinds/kind.ts +3 -0
  267. package/src/hq/kinds/media.ts +2 -3
  268. package/src/hq/kinds/prompt.ts +2 -1
  269. package/src/hq/kinds/time-day.ts +5 -4
  270. package/src/hq/ledger.ts +22 -22
  271. package/src/hq/machine-notes.ts +14 -15
  272. package/src/hq/outbox.ts +35 -24
  273. package/src/hq/replica.ts +1 -2
  274. package/src/hq/report.ts +10 -12
  275. package/src/hq/switch.ts +20 -23
  276. package/src/hq/{cards.ts → thread-sync.ts} +127 -99
  277. package/src/hq/vault-route.ts +112 -0
  278. package/src/{serve → http}/door-forward.ts +11 -4
  279. package/src/http/loopback-serve.ts +84 -0
  280. package/src/{serve → http}/same-origin.ts +6 -2
  281. package/src/http/tailnet-caller.ts +118 -0
  282. package/src/identities/collection.ts +2 -2
  283. package/src/identities/identities.ts +9 -8
  284. package/src/identities/machine-route.ts +8 -3
  285. package/src/identities/shown.ts +2 -6
  286. package/src/ledger/check-table.ts +1 -1
  287. package/src/ledger/db.ts +9 -1
  288. package/src/ledger/git-key.ts +9 -3
  289. package/src/ledger/git-scan.ts +2 -2
  290. package/src/ledger/ledger.ts +6 -16
  291. package/src/media-kinds.ts +4 -1
  292. package/src/media-store/backup/daemon.ts +51 -10
  293. package/src/media-store/backup/keys.ts +1 -4
  294. package/src/media-store/backup/manifest.ts +21 -3
  295. package/src/media-store/backup/prune.ts +362 -0
  296. package/src/media-store/backup/retention.ts +122 -0
  297. package/src/media-store/backup/run.ts +22 -35
  298. package/src/media-store/backup/sources.ts +27 -27
  299. package/src/media-store/backup/thread-copy.ts +339 -0
  300. package/src/media-store/backup/watch.ts +10 -6
  301. package/src/media-store/content.ts +3 -0
  302. package/src/media-store/copy/config.ts +3 -4
  303. package/src/media-store/copy/night.ts +4 -4
  304. package/src/media-store/copy/store.ts +2 -2
  305. package/src/media-store/daemon.ts +5 -4
  306. package/src/media-store/db.ts +10 -20
  307. package/src/media-store/forget-one.ts +247 -0
  308. package/src/media-store/forget.ts +141 -4
  309. package/src/media-store/hq-send.ts +5 -4
  310. package/src/media-store/purge.ts +5 -4
  311. package/src/media-store/remote.ts +2 -2
  312. package/src/media-store/space-listing.ts +20 -9
  313. package/src/media-store/space.ts +7 -5
  314. package/src/media-store/tidy.ts +3 -3
  315. package/src/media-store/upload.ts +2 -2
  316. package/src/media-store/webp.ts +3 -3
  317. package/src/messages/guard.ts +49 -0
  318. package/src/messages/model.ts +1 -1
  319. package/src/messages/objects.ts +203 -0
  320. package/src/messages/routes.ts +2 -2
  321. package/src/messages/score.ts +2 -4
  322. package/src/messages/store-doc.ts +114 -0
  323. package/src/messages/verdicts.ts +6 -0
  324. package/src/messages/write.ts +285 -0
  325. package/src/mv/mv-md.ts +43 -12
  326. package/src/orchestrator/brief.md +29 -0
  327. package/src/orchestrator/deliver.ts +81 -0
  328. package/src/orchestrator/drill.ts +129 -0
  329. package/src/orchestrator/guards.ts +63 -0
  330. package/src/orchestrator/keeper.ts +332 -0
  331. package/src/orchestrator/phone.ts +98 -0
  332. package/src/orchestrator/pm.ts +20 -0
  333. package/src/orchestrator/presence-shape.ts +17 -0
  334. package/src/orchestrator/presence.ts +68 -0
  335. package/src/orchestrator/push.ts +102 -0
  336. package/src/orchestrator/routes.ts +113 -0
  337. package/src/orchestrator/state.ts +92 -0
  338. package/src/orchestrator/switch.ts +86 -0
  339. package/src/orchestrator/tmux.ts +82 -0
  340. package/src/orchestrator/unheard.ts +68 -0
  341. package/src/pages/frame-client.ts +181 -4
  342. package/src/pages/unit.ts +1 -1
  343. package/src/plan/repo-source.ts +1 -1
  344. package/src/recordings/load.ts +1 -1
  345. package/src/recordings/model.ts +18 -10
  346. package/src/recordings/place.ts +3 -3
  347. package/src/recordings/recorder-app/Capture.swift +69 -21
  348. package/src/recordings/recorder-app/Editor.swift +214 -11
  349. package/src/recordings/recorder-app/main.swift +229 -47
  350. package/src/recordings/recorder-app.ts +1 -1
  351. package/src/recordings/routes.ts +11 -1
  352. package/src/recordings/take.ts +7 -5
  353. package/src/recordings/view.ts +6 -0
  354. package/src/reflect/prompt-corpus.ts +5 -3
  355. package/src/reflect/thread-words.ts +51 -0
  356. package/src/reflections/reflection-close.ts +123 -0
  357. package/src/reflections/reflection-doc.ts +59 -0
  358. package/src/reflections/reflection-place.ts +60 -0
  359. package/src/reflections/reflections-queue.ts +1 -1
  360. package/src/release/gate-checkout.ts +124 -21
  361. package/src/release/git-facts.ts +11 -9
  362. package/src/release/machine-words.ts +21 -3
  363. package/src/release/public-clean.ts +81 -21
  364. package/src/release/run-bump.ts +3 -5
  365. package/src/release/run-release.ts +42 -38
  366. package/src/releases/add.ts +33 -87
  367. package/src/releases/{from-card.ts → from-thread.ts} +47 -46
  368. package/src/releases/model.ts +207 -36
  369. package/src/releases/routes.ts +2 -2
  370. package/src/releases/shape.ts +184 -0
  371. package/src/releases/store.ts +10 -10
  372. package/src/repo-config.ts +53 -21
  373. package/src/review/anim.ts +8 -8
  374. package/src/review/answer-kinds.ts +160 -0
  375. package/src/review/auto.ts +3 -3
  376. package/src/review/band.ts +145 -0
  377. package/src/review/branch-hold.ts +91 -0
  378. package/src/review/cells.ts +451 -96
  379. package/src/review/close.ts +92 -0
  380. package/src/review/doc-card.ts +41 -0
  381. package/src/review/doc-model.ts +100 -0
  382. package/src/review/doc-routes.ts +66 -0
  383. package/src/review/doc-save.ts +152 -0
  384. package/src/review/draft-item.ts +36 -0
  385. package/src/review/draft-model.ts +125 -17
  386. package/src/review/events.ts +164 -0
  387. package/src/review/file-tags.ts +52 -0
  388. package/src/review/format.ts +195 -38
  389. package/src/review/glyphs.ts +63 -0
  390. package/src/review/gone.ts +21 -21
  391. package/src/review/hand-over.ts +58 -0
  392. package/src/review/heard.ts +29 -0
  393. package/src/review/holds-sync.ts +62 -0
  394. package/src/review/holds.ts +85 -0
  395. package/src/review/house-kind-defs.ts +71 -0
  396. package/src/review/http.ts +1 -1
  397. package/src/review/inbox-hook.ts +69 -10
  398. package/src/review/inbox-read.ts +226 -0
  399. package/src/review/instructions.ts +241 -0
  400. package/src/review/{card-db.ts → item-db.ts} +48 -36
  401. package/src/review/{card-rows.ts → item-rows.ts} +79 -51
  402. package/src/review/kind-apply.ts +61 -0
  403. package/src/review/kind-catalog.ts +96 -0
  404. package/src/review/kind-still.ts +125 -0
  405. package/src/review/kinds.ts +314 -0
  406. package/src/review/lane-ask.ts +113 -0
  407. package/src/review/live-post.ts +107 -0
  408. package/src/review/live-view.ts +137 -0
  409. package/src/review/media-kind.ts +4 -4
  410. package/src/review/media-read.ts +4 -4
  411. package/src/review/media.ts +3 -5
  412. package/src/review/mentions.ts +100 -0
  413. package/src/review/model-moved.ts +76 -0
  414. package/src/review/model.ts +846 -214
  415. package/src/review/move.ts +62 -61
  416. package/src/review/need-address.ts +15 -0
  417. package/src/review/need-threads.ts +51 -0
  418. package/src/review/notes.ts +2 -1
  419. package/src/review/object-card.ts +48 -0
  420. package/src/review/object-read.ts +31 -0
  421. package/src/review/one-block.ts +64 -0
  422. package/src/review/owner-read.ts +41 -0
  423. package/src/review/owner-verdict.ts +36 -0
  424. package/src/review/parties.ts +274 -0
  425. package/src/review/paste.ts +4 -4
  426. package/src/review/phone-push.ts +137 -0
  427. package/src/review/previews.ts +19 -17
  428. package/src/review/project.ts +1 -1
  429. package/src/review/projections.ts +235 -0
  430. package/src/review/push.ts +269 -0
  431. package/src/review/referring.ts +76 -0
  432. package/src/review/reflection-object.ts +190 -0
  433. package/src/review/rev.ts +1 -1
  434. package/src/review/role.ts +3 -3
  435. package/src/review/routes.ts +227 -83
  436. package/src/review/search-index.ts +218 -0
  437. package/src/review/search-job.ts +40 -0
  438. package/src/review/search-ocr.ts +138 -0
  439. package/src/review/search-text.ts +129 -0
  440. package/src/review/secret-route.ts +110 -0
  441. package/src/review/settle.ts +67 -0
  442. package/src/review/snooze.ts +38 -0
  443. package/src/review/stage-routes.ts +15 -13
  444. package/src/review/{stage-card.ts → stage-thread.ts} +22 -21
  445. package/src/review/store-index.ts +49 -0
  446. package/src/review/store-parties.ts +20 -0
  447. package/src/review/store.ts +721 -260
  448. package/src/review/supersede.ts +132 -0
  449. package/src/review/take-back.ts +65 -0
  450. package/src/review/thread-fold.ts +20 -7
  451. package/src/review/threads.ts +397 -79
  452. package/src/review/traces.ts +206 -0
  453. package/src/review/trailer-desk.ts +7 -7
  454. package/src/review/{trailer-card.ts → trailer-item.ts} +12 -12
  455. package/src/review/trailer-model.ts +4 -4
  456. package/src/review/trailer-notes.ts +2 -2
  457. package/src/review/trailer-routes.ts +5 -4
  458. package/src/review/trailer-shots.ts +3 -3
  459. package/src/review/unit.ts +140 -13
  460. package/src/review/uploads.ts +103 -0
  461. package/src/review/verdict-items.ts +73 -0
  462. package/src/review/verdict-write.ts +15 -0
  463. package/src/review/view-layout.ts +69 -0
  464. package/src/review/wait.ts +91 -0
  465. package/src/review/wakes.ts +115 -0
  466. package/src/review/watch-feed.ts +183 -0
  467. package/src/review/watchers.ts +44 -10
  468. package/src/rules/untrack-generated.ts +40 -39
  469. package/src/scaffold/files/bunfig.toml +1 -9
  470. package/src/scaffold/files/claude-settings-local.json +2 -0
  471. package/src/scaffold/files/vscode-settings.json +1 -1
  472. package/src/scaffold/project-scaffold.ts +14 -10
  473. package/src/secrets/archive-mark.ts +52 -0
  474. package/src/secrets/archive.ts +84 -0
  475. package/src/secrets/copy.ts +14 -14
  476. package/src/secrets/keychain-write.ts +56 -0
  477. package/src/secrets/keychain.ts +8 -5
  478. package/src/secrets/lapse-mark.ts +38 -0
  479. package/src/secrets/lapse.ts +71 -0
  480. package/src/secrets/list.ts +16 -22
  481. package/src/secrets/manager.ts +31 -16
  482. package/src/secrets/read.ts +161 -33
  483. package/src/secrets/security-line.ts +19 -0
  484. package/src/secrets/tail.ts +31 -0
  485. package/src/serve/embed.ts +1 -1
  486. package/src/serve/house-runs.ts +1 -1
  487. package/src/serve/hub-app/accounts-line.tsx +67 -0
  488. package/src/serve/hub-app/activity-st.ts +46 -50
  489. package/src/serve/hub-app/advice-box.tsx +66 -0
  490. package/src/serve/hub-app/advisor-app.tsx +46 -0
  491. package/src/serve/hub-app/advisor-face.tsx +29 -0
  492. package/src/serve/hub-app/advisor-host.ts +142 -0
  493. package/src/serve/hub-app/advisor.html +22 -0
  494. package/src/serve/hub-app/advisors-st.ts +261 -0
  495. package/src/serve/hub-app/advisors-view.tsx +269 -0
  496. package/src/serve/hub-app/advisors.css +57 -0
  497. package/src/serve/hub-app/app-bridge.ts +27 -24
  498. package/src/serve/hub-app/ask-steps-st.ts +60 -0
  499. package/src/serve/hub-app/ask-steps.tsx +23 -0
  500. package/src/serve/hub-app/asks-page.tsx +9 -5
  501. package/src/serve/hub-app/asks-st.ts +1 -4
  502. package/src/serve/hub-app/auto-text.tsx +118 -18
  503. package/src/serve/hub-app/benign-errors.ts +15 -1
  504. package/src/serve/hub-app/card-head.tsx +49 -0
  505. package/src/serve/hub-app/check-view.tsx +3 -2
  506. package/src/serve/hub-app/checks-svc.ts +1 -1
  507. package/src/serve/hub-app/clock-svc.ts +21 -5
  508. package/src/serve/hub-app/code-copy.ts +196 -0
  509. package/src/serve/hub-app/col-card.tsx +24 -40
  510. package/src/serve/hub-app/col-list-page.tsx +7 -4
  511. package/src/serve/hub-app/col-list-st.ts +6 -1
  512. package/src/serve/hub-app/col-tables-view.tsx +7 -4
  513. package/src/serve/hub-app/col-tables.ts +19 -13
  514. package/src/serve/hub-app/cols-svc.ts +15 -80
  515. package/src/serve/hub-app/comfy-svc.ts +3 -2
  516. package/src/serve/hub-app/commands/commands-page.tsx +2 -1
  517. package/src/serve/hub-app/commands/commands-st.ts +36 -26
  518. package/src/serve/hub-app/controls.css +99 -0
  519. package/src/serve/hub-app/cursor-spot.ts +81 -0
  520. package/src/serve/hub-app/database-st.ts +31 -26
  521. package/src/serve/hub-app/database-view.tsx +12 -12
  522. package/src/serve/hub-app/dock-st.ts +51 -10
  523. package/src/serve/hub-app/dock-view.tsx +14 -1
  524. package/src/serve/hub-app/editor/doc-editor-st.ts +223 -0
  525. package/src/serve/hub-app/editor/doc-editor.tsx +116 -0
  526. package/src/serve/hub-app/editor/doc-saved.tsx +26 -0
  527. package/src/serve/hub-app/editor/doc-slot.ts +66 -0
  528. package/src/serve/hub-app/editor.css +36 -0
  529. package/src/serve/hub-app/emoji-names.ts +1915 -0
  530. package/src/serve/hub-app/emoji.ts +133 -0
  531. package/src/serve/hub-app/floating.tsx +162 -6
  532. package/src/serve/hub-app/frames-st.ts +17 -1
  533. package/src/serve/hub-app/git-st.ts +25 -19
  534. package/src/serve/hub-app/git-view.tsx +3 -2
  535. package/src/serve/hub-app/hash-route.ts +1 -1
  536. package/src/serve/hub-app/header-bar.tsx +4 -3
  537. package/src/serve/hub-app/held-keys.ts +25 -0
  538. package/src/serve/hub-app/home-st.ts +167 -18
  539. package/src/serve/hub-app/home-strip.css +4 -8
  540. package/src/serve/hub-app/home-strip.tsx +7 -3
  541. package/src/serve/hub-app/home.html +10 -0
  542. package/src/serve/hub-app/house-wiki-view.tsx +20 -0
  543. package/src/serve/hub-app/hub-app.tsx +102 -36
  544. package/src/serve/hub-app/hub-types.ts +2 -0
  545. package/src/serve/hub-app/hub.css +117 -92
  546. package/src/serve/hub-app/icons.tsx +24 -4
  547. package/src/serve/hub-app/identities-st.ts +35 -25
  548. package/src/serve/hub-app/identities-view.tsx +11 -7
  549. package/src/serve/hub-app/inbox-st.ts +241 -52
  550. package/src/serve/hub-app/inbox-view.tsx +198 -105
  551. package/src/serve/hub-app/inbox.css +53 -47
  552. package/src/serve/hub-app/index.html +10 -0
  553. package/src/serve/hub-app/insights-st.ts +27 -19
  554. package/src/serve/hub-app/instructions.css +33 -0
  555. package/src/serve/hub-app/kept-folds.ts +43 -0
  556. package/src/serve/hub-app/keys.ts +13 -5
  557. package/src/serve/hub-app/later.tsx +1 -1
  558. package/src/serve/hub-app/layout-st.ts +37 -6
  559. package/src/serve/hub-app/list-filter.tsx +1 -1
  560. package/src/serve/hub-app/live-bar.css +12 -0
  561. package/src/serve/hub-app/live-svc.ts +12 -2
  562. package/src/serve/hub-app/machine-st.ts +38 -12
  563. package/src/serve/hub-app/machines-st.ts +40 -34
  564. package/src/serve/hub-app/machines-view.tsx +9 -16
  565. package/src/serve/hub-app/machines.css +0 -9
  566. package/src/serve/hub-app/markdown.css +128 -0
  567. package/src/serve/hub-app/md-copy.tsx +18 -40
  568. package/src/serve/hub-app/md.ts +176 -14
  569. package/src/serve/hub-app/media-svc.ts +44 -11
  570. package/src/serve/hub-app/media-view.tsx +2 -2
  571. package/src/serve/hub-app/messages/messages-page.tsx +57 -12
  572. package/src/serve/hub-app/messages/messages-st.ts +27 -23
  573. package/src/serve/hub-app/messages.css +0 -1
  574. package/src/serve/hub-app/new-thread.tsx +121 -0
  575. package/src/serve/hub-app/objects.css +52 -0
  576. package/src/serve/hub-app/orchestrator-line.tsx +104 -0
  577. package/src/serve/hub-app/orchestrator.css +37 -0
  578. package/src/serve/hub-app/page-keys.ts +8 -5
  579. package/src/serve/hub-app/page-reload.ts +111 -0
  580. package/src/serve/hub-app/pages-frames.tsx +12 -1
  581. package/src/serve/hub-app/pages-svc.ts +8 -3
  582. package/src/serve/hub-app/palette-st.ts +11 -6
  583. package/src/serve/hub-app/pane-boundary.tsx +85 -0
  584. package/src/serve/hub-app/pane-errors.ts +55 -0
  585. package/src/serve/hub-app/pano.css +20 -0
  586. package/src/serve/hub-app/plan-view.tsx +4 -3
  587. package/src/serve/hub-app/planned-st.ts +30 -26
  588. package/src/serve/hub-app/planned-view.tsx +17 -10
  589. package/src/serve/hub-app/planned.css +0 -4
  590. package/src/serve/hub-app/polled.ts +201 -0
  591. package/src/serve/hub-app/presence-st.ts +110 -0
  592. package/src/serve/hub-app/processes-view.tsx +3 -2
  593. package/src/serve/hub-app/project-list.css +101 -66
  594. package/src/serve/hub-app/project-list.tsx +139 -155
  595. package/src/serve/hub-app/projects-svc.ts +113 -57
  596. package/src/serve/hub-app/push-sign.tsx +15 -0
  597. package/src/serve/hub-app/push-svc.ts +273 -0
  598. package/src/serve/hub-app/quiet-st.ts +59 -0
  599. package/src/serve/hub-app/rail-fly.tsx +95 -0
  600. package/src/serve/hub-app/reach.ts +16 -0
  601. package/src/serve/hub-app/readme.css +9 -15
  602. package/src/serve/hub-app/recordings-st.ts +169 -9
  603. package/src/serve/hub-app/recordings-take.ts +58 -0
  604. package/src/serve/hub-app/recordings-view.tsx +42 -35
  605. package/src/serve/hub-app/recordings.css +1 -1
  606. package/src/serve/hub-app/reflections-page.tsx +70 -5
  607. package/src/serve/hub-app/releases/releases-page.tsx +54 -20
  608. package/src/serve/hub-app/releases/releases-st.ts +39 -26
  609. package/src/serve/hub-app/releases.css +4 -1
  610. package/src/serve/hub-app/repo-sections.ts +21 -10
  611. package/src/serve/hub-app/repo-st.ts +36 -9
  612. package/src/serve/hub-app/review/advisor-bar.tsx +40 -0
  613. package/src/serve/hub-app/review/attach-st.ts +195 -0
  614. package/src/serve/hub-app/review/attach-view.tsx +260 -0
  615. package/src/serve/hub-app/review/clip-st.ts +1 -1
  616. package/src/serve/hub-app/review/code-colors.ts +30 -0
  617. package/src/serve/hub-app/review/cta.tsx +11 -0
  618. package/src/serve/hub-app/review/diff-view.tsx +77 -0
  619. package/src/serve/hub-app/review/doc-body.tsx +109 -0
  620. package/src/serve/hub-app/review/dock.tsx +118 -0
  621. package/src/serve/hub-app/review/draft-body.tsx +235 -0
  622. package/src/serve/hub-app/review/faces.tsx +26 -0
  623. package/src/serve/hub-app/review/group-block.tsx +239 -0
  624. package/src/serve/hub-app/review/heard-line.tsx +31 -0
  625. package/src/serve/hub-app/review/instructions-view.tsx +141 -0
  626. package/src/serve/hub-app/review/item-verdict.tsx +111 -0
  627. package/src/serve/hub-app/review/kind-states.tsx +265 -0
  628. package/src/serve/hub-app/review/kind-view.tsx +23 -44
  629. package/src/serve/hub-app/review/kit.tsx +54 -75
  630. package/src/serve/hub-app/review/lane-bar.tsx +64 -0
  631. package/src/serve/hub-app/review/lightbox.tsx +16 -0
  632. package/src/serve/hub-app/review/line-window.ts +149 -0
  633. package/src/serve/hub-app/review/live-bar-st.ts +145 -0
  634. package/src/serve/hub-app/review/live-bar.tsx +126 -0
  635. package/src/serve/hub-app/review/live-view.tsx +104 -0
  636. package/src/serve/hub-app/review/mention-st.ts +85 -0
  637. package/src/serve/hub-app/review/mesh-view.tsx +9 -0
  638. package/src/serve/hub-app/review/object-card.tsx +62 -0
  639. package/src/serve/hub-app/review/object-panel.tsx +197 -0
  640. package/src/serve/hub-app/review/pano-gl.ts +145 -0
  641. package/src/serve/hub-app/review/pano-view.tsx +192 -0
  642. package/src/serve/hub-app/review/phone-top.tsx +16 -0
  643. package/src/serve/hub-app/review/pictures-st.ts +38 -0
  644. package/src/serve/hub-app/review/question-views.tsx +387 -0
  645. package/src/serve/hub-app/review/review-board.tsx +1 -1
  646. package/src/serve/hub-app/review/review-cells.tsx +223 -184
  647. package/src/serve/hub-app/review/review-host.ts +69 -0
  648. package/src/serve/hub-app/review/review-kit.ts +34 -19
  649. package/src/serve/hub-app/review/review-list.tsx +211 -51
  650. package/src/serve/hub-app/review/review-page.tsx +10 -20
  651. package/src/serve/hub-app/review/review-st.ts +294 -151
  652. package/src/serve/hub-app/review/review-thread.tsx +605 -161
  653. package/src/serve/hub-app/review/review-views.tsx +547 -452
  654. package/src/serve/hub-app/review/scene-view.tsx +26 -0
  655. package/src/serve/hub-app/review/secret-facts.ts +26 -0
  656. package/src/serve/hub-app/review/space3d.tsx +114 -0
  657. package/src/serve/hub-app/review/splat-view.tsx +9 -0
  658. package/src/serve/hub-app/review/superseded-runs.ts +76 -0
  659. package/src/serve/hub-app/review/thread-close.tsx +134 -0
  660. package/src/serve/hub-app/review/thread-control-st.ts +2 -1
  661. package/src/serve/hub-app/review/thread-control.tsx +4 -4
  662. package/src/serve/hub-app/review/thread-st.ts +710 -140
  663. package/src/serve/hub-app/review/thread-views.ts +71 -0
  664. package/src/serve/hub-app/review/{trailer-card.tsx → trailer-body.tsx} +35 -35
  665. package/src/serve/hub-app/review/trailer-page.tsx +23 -25
  666. package/src/serve/hub-app/review/trailer-st.ts +38 -38
  667. package/src/serve/hub-app/review/trailer-timeline.tsx +24 -20
  668. package/src/serve/hub-app/review/trailer-voices.tsx +3 -2
  669. package/src/serve/hub-app/review.css +459 -188
  670. package/src/serve/hub-app/search-st.ts +138 -0
  671. package/src/serve/hub-app/search-view.tsx +92 -0
  672. package/src/serve/hub-app/section-head.tsx +52 -0
  673. package/src/serve/hub-app/shell-rows.ts +126 -0
  674. package/src/serve/hub-app/site/site-st.ts +18 -23
  675. package/src/serve/hub-app/social/calendar.tsx +5 -11
  676. package/src/serve/hub-app/social/comms-page.tsx +36 -20
  677. package/src/serve/hub-app/social/group-editor.tsx +44 -0
  678. package/src/serve/hub-app/social/kit.tsx +15 -61
  679. package/src/serve/hub-app/social/next-release.tsx +5 -7
  680. package/src/serve/hub-app/social/post-card.tsx +19 -52
  681. package/src/serve/hub-app/social/post-page.tsx +80 -0
  682. package/src/serve/hub-app/social/problems.tsx +9 -12
  683. package/src/serve/hub-app/social/social-model.ts +13 -5
  684. package/src/serve/hub-app/social/social-page.tsx +4 -4
  685. package/src/serve/hub-app/social/social-st.ts +67 -83
  686. package/src/serve/hub-app/social/stage-popup.tsx +6 -6
  687. package/src/serve/hub-app/social/stage-st.ts +9 -9
  688. package/src/serve/hub-app/social.css +7 -25
  689. package/src/serve/hub-app/space-st.ts +38 -48
  690. package/src/serve/hub-app/space-view.tsx +6 -6
  691. package/src/serve/hub-app/space.css +1 -1
  692. package/src/serve/hub-app/stores/stores-page.tsx +10 -6
  693. package/src/serve/hub-app/stores/stores-st.ts +19 -23
  694. package/src/serve/hub-app/terminal-input.ts +12 -0
  695. package/src/serve/hub-app/terminal-panel.tsx +40 -0
  696. package/src/serve/hub-app/terminal-st.ts +416 -0
  697. package/src/serve/hub-app/terminal.css +15 -0
  698. package/src/serve/hub-app/tests-svc.ts +3 -2
  699. package/src/serve/hub-app/theme-st.ts +1 -9
  700. package/src/serve/hub-app/thread-row.tsx +136 -0
  701. package/src/serve/hub-app/time-ago.tsx +40 -16
  702. package/src/serve/hub-app/time-st.ts +43 -27
  703. package/src/serve/hub-app/time-view.tsx +4 -3
  704. package/src/serve/hub-app/time.css +2 -5
  705. package/src/serve/hub-app/tree-build.ts +2 -2
  706. package/src/serve/hub-app/tree-row.tsx +44 -27
  707. package/src/serve/hub-app/tree-svc.ts +1 -1
  708. package/src/serve/hub-app/urls-svc.ts +6 -5
  709. package/src/serve/hub-app/vault-st.ts +32 -27
  710. package/src/serve/hub-app/vault-view.tsx +57 -6
  711. package/src/serve/hub-app/vault.css +2 -0
  712. package/src/serve/hub-app/veille/veille-page.tsx +5 -14
  713. package/src/serve/hub-app/veille/veille-st.ts +56 -49
  714. package/src/serve/hub-app/veille.css +0 -1
  715. package/src/serve/hub-app/view-layout.css +90 -0
  716. package/src/serve/hub-app/waiting-svc.ts +5 -4
  717. package/src/serve/hub-app/when-view.tsx +6 -3
  718. package/src/serve/hub-app/wiki-st.ts +33 -6
  719. package/src/serve/hub-app/wikis-view.tsx +22 -18
  720. package/src/serve/hub-app/words.tsx +15 -0
  721. package/src/serve/hub-collections.ts +105 -0
  722. package/src/serve/hub-runtime.ts +83 -91
  723. package/src/serve/live-hop.ts +102 -0
  724. package/src/serve/other-repos.ts +1 -1
  725. package/src/serve/project-gutter-route.ts +69 -46
  726. package/src/serve/read-thread.ts +76 -0
  727. package/src/serve/read-worker.ts +53 -0
  728. package/src/serve/run-serve.ts +11 -7
  729. package/src/serve/secret-gate.ts +21 -0
  730. package/src/serve/serve-hub.ts +129 -51
  731. package/src/serve/terminal-guard.ts +50 -0
  732. package/src/serve/terminal-route.ts +176 -0
  733. package/src/shipkit.ts +10 -10
  734. package/src/shot/client.ts +32 -16
  735. package/src/shot/dom-clip.ts +30 -5
  736. package/src/shot/film-box.ts +23 -8
  737. package/src/shot/serve-shot.ts +16 -5
  738. package/src/shot/shooter.ts +72 -24
  739. package/src/shot/shot-ask.ts +17 -6
  740. package/src/shot/shot-guard.ts +53 -0
  741. package/src/shot/shot-theme.ts +70 -0
  742. package/src/shot/still-file.ts +60 -0
  743. package/src/site/desk.ts +6 -5
  744. package/src/smoke/run-smoke.ts +3 -4
  745. package/src/social/brands.ts +4 -0
  746. package/src/social/compose.ts +13 -7
  747. package/src/social/cover.ts +4 -3
  748. package/src/social/desk-index.ts +34 -13
  749. package/src/social/draft-doc.ts +88 -0
  750. package/src/social/draft-versions.ts +80 -0
  751. package/src/social/drafts.ts +26 -8
  752. package/src/social/fit.ts +4 -3
  753. package/src/social/house.ts +1 -1
  754. package/src/social/import-drafts.ts +244 -0
  755. package/src/social/kind-pages.ts +3 -3
  756. package/src/social/kinds.ts +2 -2
  757. package/src/social/load.ts +106 -73
  758. package/src/social/media-facts.ts +1 -19
  759. package/src/social/media-kind.ts +68 -161
  760. package/src/social/media-limit.ts +3 -18
  761. package/src/social/media-of.ts +5 -4
  762. package/src/social/no-account.ts +38 -0
  763. package/src/social/open.ts +3 -2
  764. package/src/social/post-object.ts +120 -0
  765. package/src/social/post-sources.ts +136 -0
  766. package/src/social/post-text.ts +123 -0
  767. package/src/social/posts.ts +433 -0
  768. package/src/social/presence.ts +17 -13
  769. package/src/social/publish/index.ts +17 -5
  770. package/src/social/publish/secret.ts +2 -2
  771. package/src/social/release-stage.ts +76 -75
  772. package/src/social/routes.ts +72 -50
  773. package/src/social/stage.ts +45 -60
  774. package/src/social/stats.ts +3 -4
  775. package/src/social/strip.ts +4 -6
  776. package/src/social/text.ts +6 -4
  777. package/src/social/thread-drafts.ts +16 -0
  778. package/src/social/thumbnail.ts +135 -43
  779. package/src/social/tracker.ts +1 -1
  780. package/src/social/unit.ts +12 -3
  781. package/src/social/writes.ts +8 -31
  782. package/src/start-repo.ts +33 -13
  783. package/src/stores/desk.ts +17 -12
  784. package/src/stores/unit.ts +2 -2
  785. package/src/suite/core-counters.ts +31 -3
  786. package/src/suite/judge-suites.ts +69 -47
  787. package/src/suite/select.ts +1 -27
  788. package/src/suite/suite-cli.ts +18 -8
  789. package/src/suite/suite-cpu-preload.ts +10 -6
  790. package/src/trace/tracer.ts +4 -5
  791. package/src/trailer/build.ts +30 -15
  792. package/src/trailer/ffmpeg.ts +90 -31
  793. package/src/trailer/fonts.ts +5 -6
  794. package/src/trailer/footage.ts +9 -3
  795. package/src/trailer/grammar.ts +2 -1
  796. package/src/trailer/graph.ts +12 -10
  797. package/src/trailer/load-unit.ts +1 -1
  798. package/src/trailer/passage.ts +4 -3
  799. package/src/trailer/prune.ts +4 -4
  800. package/src/trailer/score/sound.ts +3 -3
  801. package/src/trailer/shot-plan.ts +5 -5
  802. package/src/trailer/shot-state.ts +25 -31
  803. package/src/trailer/sound/eleven.ts +34 -3
  804. package/src/trailer/sound/gen.ts +3 -3
  805. package/src/trailer/sound/run.ts +76 -64
  806. package/src/trailer/sound/takes.ts +0 -3
  807. package/src/trailer/take-fault.ts +41 -0
  808. package/src/trailer/titles.ts +17 -13
  809. package/src/trailer/url.ts +1 -1
  810. package/src/trailer/vertical-draw.ts +7 -7
  811. package/src/trailer/vertical.ts +3 -3
  812. package/src/trailer/vocab.ts +3 -4
  813. package/src/ts/config.ts +60 -24
  814. package/src/ts/cycles.ts +3 -1
  815. package/src/ts/imports.ts +17 -3
  816. package/src/ts/rename.ts +6 -7
  817. package/src/ts/source-graph.ts +15 -9
  818. package/src/ts/workspaces.ts +26 -0
  819. package/src/tui/build-steps-panel.ts +3 -3
  820. package/src/tui/checks-panel.ts +2 -2
  821. package/src/urls/frame.ts +3 -3
  822. package/src/urls/routes.ts +1 -1
  823. package/src/urls/rows.ts +2 -2
  824. package/src/vault/house-keys.ts +1 -1
  825. package/src/vault/vault-audit.ts +2 -3
  826. package/src/vault/vault-config.ts +6 -2
  827. package/src/vault/vault-http.ts +11 -3
  828. package/src/vault/vault-import.ts +6 -1
  829. package/src/vault/vault-restore.ts +3 -9
  830. package/src/vault/vault-serve.ts +47 -11
  831. package/src/vault/vault-snapshot.ts +5 -14
  832. package/src/veille/desk.ts +2 -2
  833. package/src/veille/identity.ts +2 -2
  834. package/src/veille/routes.ts +1 -1
  835. package/src/view3d/cam.ts +101 -0
  836. package/src/view3d/lib.ts +69 -0
  837. package/src/view3d/loop.ts +39 -0
  838. package/src/view3d/scene-cache.ts +62 -0
  839. package/src/view3d/viewer.ts +480 -0
  840. package/src/wiki/agent-paths.ts +55 -0
  841. package/src/wiki/graph-pages.ts +13 -1
  842. package/src/wiki/run-wiki.ts +4 -1
  843. package/src/wiki/scan-md.ts +1 -1
  844. package/src/wiki/serve-graph.ts +2 -3
  845. package/src/asks/asks-queue.ts +0 -424
  846. package/src/core/run-fix.ts +0 -120
  847. package/src/home/hmr-keep.ts +0 -134
  848. package/src/messages/suggest.ts +0 -96
  849. package/src/review/draft-card.ts +0 -41
  850. package/src/serve/hub-app/review/draft-card.tsx +0 -163
  851. package/src/serve/hub-app/review/note-place.ts +0 -31
  852. package/src/social/card-drafts.ts +0 -24
  853. package/src/social/migrate.ts +0 -123
  854. /package/src/{serve → http}/door-names.ts +0 -0
  855. /package/src/{serve → http}/hub-port.ts +0 -0
@@ -4,7 +4,12 @@
4
4
  // hub and every CLI write at once with no lost update. Pure and browser safe: the store, the routes and the hub page
5
5
  // share it. The on disk shape is the one a project's own review store writes, verbatim, so either store opens in the other.
6
6
  import type { MediaFact } from '../media-store/fact.ts'
7
+ import type { KindColor } from './glyphs.ts'
8
+ import type { HoldsOpen } from './holds.ts'
9
+ import type { StepChoice } from './instructions.ts'
7
10
  import { versionOf } from '../trailer/versions.ts'
11
+ import { SECRET_NAME } from '../secrets/name.ts'
12
+ import type { ViewLive } from './live-view.ts'
8
13
 
9
14
  /** WHAT is judged: `shot` (a plain image or clip), `screen`, `frame` (a frame of a trailer cut), or a kind a repo names
10
15
  * for itself (a game's place, creature, song...), read as is */
@@ -38,7 +43,7 @@ export interface StoreSubject extends Subject {
38
43
 
39
44
  export const isStoreSubject = (s: Subject): s is StoreSubject => s.kind === 'store' && typeof s.store === 'string' && typeof s.asset === 'string'
40
45
 
41
- /** a public post he asked for from a card: `card` the card's first version, so every later version asks the same */
46
+ /** a public post he asked for from a thread: `card` the thread's first version, so every later version asks the same */
42
47
  export interface PostSubject extends Subject {
43
48
  kind: 'post'
44
49
  card: string
@@ -46,17 +51,73 @@ export interface PostSubject extends Subject {
46
51
 
47
52
  export const isPostSubject = (s: Subject): s is PostSubject => s.kind === 'post' && typeof s.card === 'string' && s.card !== ''
48
53
 
49
- /** what a repo's `review({...})` unit says of one subject kind that the pure model reads (review/unit.ts holds the rest):
50
- * its words, and on the server its key, its near rule and its problems. The hub gets the words alone */
54
+ /** how two states of an object of a kind draw (wiki tools/shipkit/threads-how-it-fits.md, Kinds): its view twice, one
55
+ * shared state (one camera), or a table of its json fields; `diff.page` wins over both */
56
+ export const DIFF_DRAWS = ['views', 'fields'] as const
57
+ export type DiffDraw = (typeof DIFF_DRAWS)[number]
58
+
59
+ /** a question a kind asks of the owner: its words, and its answer: one of its options, or words */
60
+ export interface KindQuestion {
61
+ text: string
62
+ options?: readonly string[]
63
+ answer?: 'option' | 'words'
64
+ }
65
+
66
+ /** a button the owner clicks on an object of a kind: a message the thread holds, which the holder's watch prints */
67
+ export interface KindAction {
68
+ label: string
69
+ icon?: string
70
+ /** what the holder does on it, one line, shown as the button's tooltip */
71
+ what?: string
72
+ /** the click opens a word box: the owner's words ride with the action */
73
+ words?: boolean
74
+ }
75
+
76
+ /** an act of the owner on a version of a kind that answers its versions with its own acts (a draft: publish, drop,
77
+ * edit, ask a change) in place of the generic verdict (review/settle.ts) */
78
+ export interface KindAct {
79
+ label: string
80
+ /** what it does, one line: the button's tooltip */
81
+ what: string
82
+ /** done on a spot of the version (a place of a draft), it settles that spot; every spot settled is his yes */
83
+ settles?: true
84
+ /** the owner's words ride with it: the reply box's chip names the spot */
85
+ words?: true
86
+ }
87
+
88
+ /** one kind of object a thread is about, declared once (wiki tools/shipkit/threads-how-it-fits.md, Kinds): the house's
89
+ * (review/kinds.ts) and a repo's `review({ kinds })` the same way. The pure part the model, the store and the hub read;
90
+ * review/unit.ts adds what runs on the server (read, apply, the data view) */
51
91
  export interface SpecKind {
92
+ /** the word the threads list filters by */
52
93
  label: string
94
+ /** its icon: SVG path data on the hub's 20 unit grid, one stroke (review/glyphs.ts); none, a neutral square */
53
95
  icon?: string
96
+ /** its icon's colour, one of the kind hues (review/glyphs.ts KIND_HUES); none, the muted text colour */
97
+ color?: KindColor
98
+ /** the key's shape as an agent types it after `<kind>:` (`<species>`, `<screen>[/<part>]`): a kind with one, or with
99
+ * a `key`, names objects; one with neither is a subject kind only */
100
+ address?: string
54
101
  /** what names one subject of this kind exactly, the kind left out; null names nothing */
55
102
  key?(s: Subject): string | null
56
- /** two subjects of this kind, in one topic, close enough to be one card */
103
+ /** two subjects of this kind, in one topic, close enough to be one thread */
57
104
  near?(a: Subject, b: Subject): boolean
58
105
  /** what is wrong with a subject of this kind; empty: nothing */
59
106
  problems?(s: Subject): string[]
107
+ /** a page of the repo that draws ONE object from its state; its frame keys: threads-how-it-fits.md, The frame keys */
108
+ view?: { page: string }
109
+ /** how a change of an object of this kind draws: `draw` (`views` by default when the kind has a view, else `fields`),
110
+ * each json field's house value kind (`fields`: `color`, `code:<lang>`…), or a page of the repo that draws the whole
111
+ * change, which wins */
112
+ diff?: { draw?: DiffDraw; fields?: Record<string, string>; page?: string }
113
+ /** the questions this kind asks, by name */
114
+ questions?: Record<string, KindQuestion>
115
+ /** the buttons on an object of this kind, by name */
116
+ actions?: Record<string, KindAction>
117
+ /** its versions answered by these acts, by name, never by approve, fix, reject (review/settle.ts); none: the verdict */
118
+ acts?: Record<string, KindAct>
119
+ /** an object of this kind attached to a thread holds it open until its condition is met (review/holds.ts) */
120
+ holdsOpen?: HoldsOpen
60
121
  }
61
122
 
62
123
  /** an area raised items are routed to, and the pages its worker reads first */
@@ -75,7 +136,10 @@ export interface Spec {
75
136
  }
76
137
 
77
138
  /** the kinds every repo has, whatever its unit declares */
78
- export const BUILTIN_KINDS: Record<string, SpecKind> = { shot: { label: 'images' }, screen: { label: 'screens' }, frame: { label: 'trailer frames' }, trailer: { label: 'trailers', icon: '🎬' }, draft: { label: 'post drafts', icon: '📝' }, store: { label: 'store pages', icon: '🏪' }, post: { label: 'post requests', icon: '📣' }, object: { label: 'objects', icon: '🔗' } }
139
+ /** the house kinds: review/kinds.ts owns them, the one registry */
140
+ export { HOUSE_KINDS as BUILTIN_KINDS } from './kinds.ts'
141
+ import { HOUSE_KINDS as BUILTIN_KINDS } from './kinds.ts'
142
+ import { settlingOf } from './settle.ts'
79
143
 
80
144
  export const NO_SPEC: Spec = { kinds: {}, topics: {}, dispatcher: false }
81
145
 
@@ -85,7 +149,7 @@ export const subjectLabel = (kind: string, spec: Spec = NO_SPEC): string => (spe
85
149
  /** a topic's words, its id when no unit names it */
86
150
  export const topicLabel = (topic: string, spec: Spec = NO_SPEC): string => spec.topics[topic]?.label ?? topic
87
151
 
88
- /** WHO raised it: an agent's card goes back to its lane on a rejection */
152
+ /** WHO raised it: an agent's version goes back to its lane on a rejection */
89
153
  export type Origin =
90
154
  | { by: 'agent'; lane?: string; session?: string }
91
155
  | { by: 'owner'; from: string; kind?: string; lane?: string }
@@ -98,14 +162,60 @@ export type Origin =
98
162
  /** an object's address (wiki tools/shipkit/threads-store.md, Addresses): one thread per address, for its whole life */
99
163
  export const ADDRESS_RE = /^[a-z][a-z0-9-]*:[^\n]+$/
100
164
 
165
+ const canonical = new Map<string, string | null>()
166
+
167
+ /** an address in its one form, null when it is none (wiki tools/shipkit/threads-store.md, Addresses): trimmed and
168
+ * lowercased, no space around the colon, no empty or trailing `/`; a cut's file is its cut, a bare kept version the main
169
+ * cut (`trailer:x/v15`); `page:review` is `page:threads`, `topic:<slug>` is `talk:<slug>`. Every address written, read or compared goes through it */
170
+ export function canonicalAddress(raw: string): string | null {
171
+ const held = canonical.get(raw)
172
+ if (held !== undefined) return held
173
+ let a = raw.trim()
174
+ const file = /^trailer\/([^/\s]+)\/([^\s]+?)(?:\.trailer)?$/i.exec(a)
175
+ if (file) a = `trailer:${file[1]}/${file[2]}`
176
+ const colon = a.indexOf(':')
177
+ const kind = colon > 0 ? a.slice(0, colon).trim().toLowerCase() : ''
178
+ // a file's path and a branch's name keep their case: git and the disk read them case sensitive
179
+ const typed = colon > 0 ? a.slice(colon + 1).trim() : ''
180
+ let key = (kind === 'file' || kind === 'branch' ? typed : typed.toLowerCase()).replace(/\/+/g, '/').replace(/^\/|\/$/g, '')
181
+ if (kind === 'trailer') {
182
+ const parts = key.replace(/\.trailer$/, '').split('/')
183
+ if (parts.length >= 2 && /^v\d+$/.test(parts[1] ?? '')) parts[1] = versionOf(parts[1] ?? '')?.cut ?? parts[1] ?? ''
184
+ key = parts.join('/')
185
+ }
186
+ // an ask is named by its file: `ask:<id>.md` and `ask:<id>` are one thread
187
+ if (kind === 'ask') key = key.replace(/\.md$/, '')
188
+ let out: string | null = `${kind}:${key}`
189
+ if (out === 'page:review' || out.startsWith('page:review/')) out = `page:threads${out.slice('page:review'.length)}`
190
+ // a conversation in words is one kind: a thread an advisor's proposal opened was `topic:<slug>`
191
+ if (out.startsWith('topic:')) out = `talk:${out.slice('topic:'.length)}`
192
+ if (!/^[a-z][a-z0-9-]*$/.test(kind) || key === '' || /\s/.test(key) || !ADDRESS_RE.test(out)) out = null
193
+ canonical.set(raw, out)
194
+ return out
195
+ }
196
+
197
+ /** an address as typed, in its one form, or a one line refusal that names the form */
198
+ export function addressOrThrow(raw: string): string {
199
+ const a = canonicalAddress(raw)
200
+ const retired = a === null ? undefined : BUILTIN_KINDS[a.slice(0, a.indexOf(':'))]?.retired
201
+ if (retired !== undefined) throw new Error(`${a}: ${retired}`)
202
+ if (a !== null) return a
203
+ const colon = raw.indexOf(':')
204
+ if (colon > 0 && /\s/.test(raw.slice(colon + 1).trim())) throw new Error(`« ${raw.trim()} »: an address has no space: ${raw.trim().replace(/\s*:\s*/, ':').replace(/\s+/g, '-').toLowerCase()} ?`)
205
+ throw new Error(`« ${raw.trim()} » is no address: <kind>:<key>, like screen:orders/list, asset:sword or trailer:<name>/<cut>`)
206
+ }
207
+
208
+ /** an address as stored, in its one form; a stored one that reads as none stays as it was */
209
+ const canon = (a: string): string => canonicalAddress(a) ?? a
210
+
101
211
  /** a trailer's cut as an address: a kept version names the cut it was kept from, so every version is one thread. A
102
- * card names its cut itself; a name alone (an older card, a frame note) is read as a kept version when it reads as one */
103
- export const cutAddress = (trailer: string, cut: string, of?: string): string => `trailer:${trailer}/${of ?? versionOf(cut)?.cut ?? cut}`
212
+ * version names its cut itself; a name alone (an older version, a frame note) is read as a kept version when it reads as one */
213
+ export const cutAddress = (trailer: string, cut: string, of?: string): string => canon(`trailer:${trailer}/${of ?? versionOf(cut)?.cut ?? cut}`)
104
214
 
105
- /** the address that is an item's own: the one its agent named, else its subject's (a trailer card or a frame note: the
215
+ /** the address that is an item's own: the one its agent named, else its subject's (a trailer version or a frame note: the
106
216
  * cut); null when it names none (a plain shot). One thread per own address */
107
217
  export function ownAddressOf(i: Item, spec: Spec = NO_SPEC): string | null {
108
- if (i.on !== undefined) return i.on
218
+ if (i.on !== undefined) return canon(i.on)
109
219
  if (i.trailer) return cutAddress(i.trailer.trailer, i.trailer.after.cut, i.trailer.cut)
110
220
  if (isFrame(i.subject)) return cutAddress(i.subject.trailer, i.subject.cut)
111
221
  return subjectKey(i.subject, spec)
@@ -120,10 +230,15 @@ export function parentAddress(a: string): string | null {
120
230
  /** every address one item names: its own, then the objects it is about */
121
231
  export function addressesOf(i: Item, spec: Spec = NO_SPEC): string[] {
122
232
  const own = ownAddressOf(i, spec)
123
- return [...new Set([...(own !== null ? [own] : []), ...(i.about ?? [])])]
233
+ return [...new Set([...(own !== null ? [own] : []), ...(i.about ?? []).map(canon)])]
124
234
  }
125
235
 
126
236
  export function subjectKey(s: Subject, spec: Spec = NO_SPEC): string | null {
237
+ const k = subjectKeyRaw(s, spec)
238
+ return k === null ? null : canon(k)
239
+ }
240
+
241
+ function subjectKeyRaw(s: Subject, spec: Spec): string | null {
127
242
  // any object the hub shows, by its address: his note from its thread control
128
243
  if (s.kind === 'object') return typeof s.address === 'string' && ADDRESS_RE.test(s.address) ? s.address : null
129
244
  if (isFrame(s)) return `frame:${s.trailer}/${s.cut}/${s.shot}`
@@ -156,6 +271,30 @@ export interface ReviewAudio {
156
271
  waveBefore?: string
157
272
  }
158
273
 
274
+ /** a view he looks around in rather than at: the kind names the viewer the hub draws (serve/hub-app/review/scene-view.tsx).
275
+ * `pano`: the view's one image is an equirectangular panorama, twice as wide as tall, seen from its center. `splat` (a
276
+ * Gaussian splat, .ply or .spz) and `mesh` (a .glb): the view's image is its poster, `file` the 3D file beside it in the
277
+ * folder, loaded only in the lightbox (view3d/viewer.ts) */
278
+ export type ReviewScene = { kind: 'pano' } | { kind: 'splat' | 'mesh'; file: string }
279
+
280
+ export const SCENE_KINDS: readonly ReviewScene['kind'][] = ['pano', 'splat', 'mesh']
281
+
282
+ /** what each scene is called where he reads it */
283
+ export const SCENE_WORDS: Record<ReviewScene['kind'], string> = { pano: '360°', splat: 'splat', mesh: '3D mesh' }
284
+
285
+ /** the 3D files a scene takes, by its kind */
286
+ export const SPACE_EXT: Record<'splat' | 'mesh', RegExp> = { splat: /\.(ply|spz)$/i, mesh: /\.glb$/i }
287
+
288
+ /** a scene's 3D file in the item's folder: `space.<ext>` on the first view, `v<n>-space.<ext>` on a later one */
289
+ export const SPACE_RE = /^(v\d+-)?space\.(ply|spz|glb)$/
290
+
291
+ /** how far a panorama's width may be from twice its height, as a share */
292
+ export const PANO_SLACK = 0.02
293
+
294
+ /** why an image of this size is no equirectangular panorama, null when it is one */
295
+ export const panoRefusal = (size: { w: number; h: number }): string | null =>
296
+ Math.abs(size.w / size.h - 2) <= 2 * PANO_SLACK ? null : `${size.w}x${size.h}: an equirectangular panorama is twice as wide as tall (2:1)`
297
+
159
298
  /** a ring a repo drew over its own shot (a game's world tiles): its center normalized 0..1, its radius as a share of
160
299
  * the image width; `side` only on a pair */
161
300
  export interface ReviewMark {
@@ -167,16 +306,22 @@ export interface ReviewMark {
167
306
  side?: Side
168
307
  }
169
308
 
170
- /** one view of a card's subject: an image or a pair, its size, its marks; the first view's label may be empty */
309
+ /** one view of a version's subject: an image or a pair, its size, its marks; the first view's label may be empty */
171
310
  export interface MediaView {
172
311
  label: string
173
312
  files: ReviewFiles
174
313
  size: { w: number; h: number }
175
314
  clip?: ReviewClip
176
315
  audio?: ReviewAudio
316
+ /** a space he looks around in: its image is drawn by the scene's viewer, never as a flat picture */
317
+ scene?: ReviewScene
177
318
  marks?: ReviewMark[]
178
- /** a line on this view alone (an option's description on a choice card) */
319
+ /** a line on this view alone (an option's description on a choice version) */
179
320
  note?: string
321
+ /** a message holds it (an update, a question's option, a proposed sound): it draws in that message's cell */
322
+ message?: true
323
+ /** a live view: the running page the owner's hub frames over this image, its shot at post time (review/live-view.ts) */
324
+ live?: ViewLive
180
325
  }
181
326
 
182
327
  /** one image of a gallery view, a file of the folder (`v<n>-g<k>.<ext>`) */
@@ -188,6 +333,9 @@ export interface GalleryTile {
188
333
  before?: string
189
334
  /** the row it is a variant in: one asset per row, he picks at most one tile of a row */
190
335
  group?: string
336
+ /** the still of a view of a kind's page (its state's `views`, review/kind-still.ts): the lightbox frames that page,
337
+ * live, with `view=<id>`, in place of the picture */
338
+ view?: string
191
339
  }
192
340
 
193
341
  /** a tile's name in the CLI's lines: `vitality/b` for a variant, else its label */
@@ -201,8 +349,10 @@ export interface GalleryView {
201
349
  // this type: a consumer narrows with `'files' in view`, which an optional key here would stop
202
350
  clip?: undefined
203
351
  audio?: undefined
352
+ scene?: undefined
204
353
  marks?: undefined
205
354
  note?: undefined
355
+ live?: undefined
206
356
  }
207
357
 
208
358
  export type ReviewView = MediaView | GalleryView
@@ -212,8 +362,8 @@ export const isGallery = (v: ReviewView): v is GalleryView => 'gallery' in v
212
362
 
213
363
  export const SHA_RE = /^[0-9a-f]{64}$/
214
364
 
215
- /** a card's public change: the release category it goes under and its one line, the `### ` title */
216
- export interface CardChangelog {
365
+ /** a version's public change: the release category it goes under and its one line, the `### ` title */
366
+ export interface ItemChangelog {
217
367
  category: string
218
368
  line: string
219
369
  /** what its media shows (`--rating`): the rating its picture lands with; absent, unrated (it reads explicit) */
@@ -221,7 +371,7 @@ export interface CardChangelog {
221
371
  }
222
372
 
223
373
  /** `--changelog "<category>: <line>"` read; a line with no category throws saying the shape */
224
- export function changelogOfFlag(s: string): CardChangelog {
374
+ export function changelogOfFlag(s: string): ItemChangelog {
225
375
  const m = /^([^:]+):\s*(.+)$/.exec(s.trim())
226
376
  if (!m || m[1]!.trim() === '' || m[2]!.trim() === '') throw new Error(`--changelog "${s}": "<category>: <public line>", like "Studio: Move the body anywhere on the floor"`)
227
377
  return { category: m[1]!.trim(), line: m[2]!.trim() }
@@ -235,20 +385,20 @@ export interface Item {
235
385
  subject: Subject
236
386
  origin: Origin
237
387
  title: string
238
- /** an agent card's markdown: what changed and why */
388
+ /** an agent version's markdown: what changed and why */
239
389
  what?: string
240
390
  /** the public line its agent wrote for a post of it (`--post`), checked by the repo's guard at add */
241
391
  post?: string
242
- /** the change its approval adds to the release being filled (`--changelog "<category>: <line>"`, releases/from-card.ts),
392
+ /** the change its approval adds to the release being filled (`--changelog "<category>: <line>"`, releases/from-thread.ts),
243
393
  * checked by the repo's guard at add */
244
- changelog?: CardChangelog
394
+ changelog?: ItemChangelog
245
395
  topic?: string
246
396
  commit?: string
247
397
  /** a media view (an image, a clip, a sound, a pair) or a gallery of images, any of them first */
248
398
  views: ReviewView[]
249
- /** an earlier card this one is a new version of; never a raised item */
399
+ /** an earlier version this one follows; never a raised item */
250
400
  supersedes?: string
251
- /** the raised items (a report, his note) this card answers: one thread per bug */
401
+ /** the raised items (a report, his note) this version answers: one thread per bug */
252
402
  answers?: string[]
253
403
  /** its subject's address when the agent names it (`sk thread post <address>`, `--on`): one thread per address */
254
404
  on?: string
@@ -256,34 +406,141 @@ export interface Item {
256
406
  about?: string[]
257
407
  /** what this new version keeps of the approved look it follows */
258
408
  keeps?: string
259
- /** why this card passed --new next to an active card */
409
+ /** why this version passed --new next to an active version */
260
410
  why?: string
261
411
  light?: 'review'
262
- /** a draft card of a repo that shoots live: no verdict until it is ready */
412
+ /** a draft version of a repo that shoots live: no verdict until it is ready */
263
413
  wip?: { live: string; frame: number }
264
414
  /** a choice: every view is an option, he scores them and picks one */
265
415
  choice?: true
266
416
  /** on a choice: the option its agent suggests, the view's index (the hub's « my pick » pill); his own pick is the verdict's */
267
417
  agentPick?: number
268
- /** a trailer card: its body plays this cut in the trailer entry's player, never a compiled clip */
269
- trailer?: TrailerCard
270
- /** a draft card: its body shows this post draft read live, a block a message, never a picture of it */
271
- draft?: DraftCard
418
+ /** a trailer version: its body plays this cut in the trailer entry's player, never a compiled clip */
419
+ trailer?: ItemTrailer
420
+ /** a draft version: its body shows this post draft read live, a block a message, never a picture of it */
421
+ draft?: ItemDraft
422
+ /** a version of an object of a kind (its `on`): the object's two states as its kind read them when it was posted,
423
+ * drawn by the kind's diff (wiki tools/shipkit/threads-how-it-fits.md, Kinds); `still`, a picture of the kind's page
424
+ * taken when it was posted (review/kind-still.ts), what the thread shows of a version a page draws */
425
+ states?: { before?: StoredState; after: StoredState; still?: KindStill }
426
+ /** a save of the object itself in its home (review/doc-save.ts), its states the text before and after: who saved it,
427
+ * the owner or an agent's lane. The owner's own save holds nothing for him to judge */
428
+ saved?: { by: string }
272
429
  /** each media file the views name, by its name: what the Space keeps it under once the disk lets it go */
273
430
  media?: Record<string, MediaFact>
431
+ /** an ask's facts, on the head of its thread `ask:<id>` (asks/ask-store.ts): its status and closed day are the
432
+ * thread's askState messages, its later day the thread's snooze, its body `what` */
433
+ ask?: AskHead
434
+ /** it waits for the owner's verdict: set by `--verdict`; an agent's version asks it always, an opening of words only with it */
435
+ asksVerdict?: true
436
+ /** a version whose subject is a document (`--md`, `--html`): its text whole, drawn by the hub */
437
+ doc?: ItemDoc
438
+ }
439
+
440
+ /** a document a version shows (wiki tools/shipkit/threads.md, Every kind of version): markdown through the hub's one
441
+ * words renderer, or an html card in a sandboxed frame. The text lives in the head: the advisors' scan reads it */
442
+ export interface ItemDoc {
443
+ kind: 'md' | 'html'
444
+ text: string
445
+ }
446
+
447
+ export const DOC_KINDS: readonly ItemDoc['kind'][] = ['md', 'html']
448
+ /** the most a document weighs, in bytes: a report, never a dump */
449
+ export const DOC_MAX: Readonly<Record<ItemDoc['kind'], number>> = { md: 64 * 1024, html: 256 * 1024 }
450
+
451
+ /** why a document is refused, or null */
452
+ export function docProblem(d: unknown): string | null {
453
+ if (d === null || typeof d !== 'object') return 'doc: { kind: md | html, text }'
454
+ const { kind, text } = d as Partial<ItemDoc>
455
+ if (kind === undefined || !DOC_KINDS.includes(kind)) return 'doc.kind: md or html'
456
+ if (typeof text !== 'string' || text.trim() === '') return `doc.text: the ${kind} text, not empty`
457
+ const bytes = new TextEncoder().encode(text).length
458
+ if (bytes > DOC_MAX[kind]) return `--${kind}: ${Math.round(bytes / 1024)} KB, over ${DOC_MAX[kind] / 1024} KB: a document he reads, never a dump (the detail goes in a file he opens)`
459
+ return null
274
460
  }
275
461
 
276
- /** one render a trailer card plays: the cut, and the render pinned by its mtime in ms */
462
+ /** a thread head that is an ask: on `ask:<id>` with its facts. The one test of « is an ask », for every reader */
463
+ export const isAskItem = (i: Pick<Item, 'on' | 'ask'>): boolean => i.ask !== undefined && (i.on ?? '').startsWith('ask:')
464
+
465
+ /** what an ask asks of the owner's hands; `answer` a question only he answers */
466
+ export const ASK_KINDS = ['action', 'purchase', 'credential', 'decision', 'answer'] as const
467
+ export type AskKind = (typeof ASK_KINDS)[number]
468
+ /** the other spellings a kind was written with, read as the one kind */
469
+ export const ASK_KIND_ALIASES: Readonly<Record<string, AskKind>> = { cred: 'credential', token: 'credential' }
470
+ /** the kind a word names, null for none */
471
+ export const askKindOf = (w: string): AskKind | null => ((ASK_KINDS as readonly string[]).includes(w) ? (w as AskKind) : (ASK_KIND_ALIASES[w] ?? null))
472
+
473
+ /** where an ask stands (wiki tools/shipkit/threads-asks.md, Closing an ask): open, or closed one of four ways: done,
474
+ * declined (his no), cancelled (an agent: no longer needed), merged (into another ask that asks the same act) */
475
+ export const ASK_STATES = ['open', 'done', 'declined', 'cancelled', 'merged'] as const
476
+ export type AskState = (typeof ASK_STATES)[number]
477
+ export const CLOSED_ASK_STATES = ['done', 'declined', 'cancelled', 'merged'] as const
478
+ export type ClosedAskState = (typeof CLOSED_ASK_STATES)[number]
479
+ /** every reader asks this, never one state by name: a closed ask asks nothing, waits on nobody, counts nowhere */
480
+ export const isClosedAskState = (s: string | null | undefined): s is ClosedAskState => (CLOSED_ASK_STATES as readonly (string | null | undefined)[]).includes(s)
481
+
482
+ /** a warning an ask holds: the check that prints it and words of that one line */
483
+ export interface AskWait {
484
+ check: string
485
+ says: string
486
+ }
487
+
488
+ /** an ask's facts that its thread's messages do not already say */
489
+ /** the words of his « later » on a refresh ask (an ask with `lapses`): it closes as declined with them, and a
490
+ * project's need reopens it (secrets/lapse.ts) */
491
+ export const LAPSE_LATER = 'later: when a project needs it again'
492
+
493
+ export interface AskHead {
494
+ kind: AskKind
495
+ /** the day it was made, YYYY-MM-DD */
496
+ created: string
497
+ /** what it blocks, `-` for nothing named */
498
+ blocks: string
499
+ /** the shell probe that exits 0 once it is done */
500
+ check?: string
501
+ waits?: AskWait[]
502
+ /** the secret names a credential ask stores */
503
+ secrets?: string[]
504
+ /** those of its secrets stored with an account beside the value */
505
+ logins?: string[]
506
+ /** the day its one ping went, YYYY-MM-DD: never a second */
507
+ pinged?: string
508
+ /** the secret it refreshes, a token that lapses by design (wiki services/secrets, A secret that may lapse): his
509
+ * « later » sets it aside until a project needs it again */
510
+ lapses?: string
511
+ }
512
+
513
+ const DAY_RE = /^\d{4}-\d{2}-\d{2}$/
514
+
515
+ /** every reason a value is not an ask's head; empty, it is one */
516
+ export function askHeadProblems(v: unknown): string[] {
517
+ if (!obj(v)) return ['ask: { kind, created, blocks, … }']
518
+ const out: string[] = []
519
+ if (!(ASK_KINDS as readonly unknown[]).includes(v.kind)) out.push(`ask.kind: one of ${ASK_KINDS.join(', ')}`)
520
+ if (typeof v.created !== 'string' || !DAY_RE.test(v.created)) out.push('ask.created: YYYY-MM-DD')
521
+ if (typeof v.blocks !== 'string' || v.blocks === '') out.push('ask.blocks: a text, - for none')
522
+ if (v.check !== undefined && (typeof v.check !== 'string' || v.check.trim() === '')) out.push('ask.check: a shell line')
523
+ if (v.pinged !== undefined && (typeof v.pinged !== 'string' || !DAY_RE.test(v.pinged))) out.push('ask.pinged: YYYY-MM-DD')
524
+ if (v.lapses !== undefined && (typeof v.lapses !== 'string' || v.lapses === '')) out.push('ask.lapses: the secret name it refreshes')
525
+ const names = (x: unknown): boolean => Array.isArray(x) && x.every((n) => typeof n === 'string' && n !== '')
526
+ if (v.secrets !== undefined && !names(v.secrets)) out.push('ask.secrets: a list of secret names')
527
+ if (v.logins !== undefined && !(names(v.logins) && (v.logins as string[]).every((l) => Array.isArray(v.secrets) && v.secrets.includes(l)))) out.push('ask.logins: names among its secrets')
528
+ if (v.waits !== undefined && !(Array.isArray(v.waits) && v.waits.every((w) => obj(w) && typeof w.check === 'string' && w.check !== '' && typeof w.says === 'string' && w.says.trim() !== '')))
529
+ out.push('ask.waits: a list of { check, says }, the words required')
530
+ return out
531
+ }
532
+
533
+ /** one render a trailer version plays: the cut, and the render pinned by its mtime in ms */
277
534
  export interface TrailerSide {
278
535
  cut: string
279
536
  render: number
280
537
  }
281
538
 
282
- /** what a trailer card plays (wiki tools/shipkit/threads.md, A trailer): a cut of `trailer/<trailer>/`, the render it is
539
+ /** what a trailer version plays (wiki tools/shipkit/threads.md, A trailer): a cut of `trailer/<trailer>/`, the render it is
283
540
  * compared with, the shots the change touched by name */
284
- export interface TrailerCard {
541
+ export interface ItemTrailer {
285
542
  trailer: string
286
- /** the cut it is a version of: `main` for a kept `v15`; absent on a card made before it was written */
543
+ /** the cut it is a version of: `main` for a kept `v15`; absent on a version made before it was written */
287
544
  cut?: string
288
545
  after: TrailerSide
289
546
  before?: TrailerSide
@@ -292,54 +549,74 @@ export interface TrailerCard {
292
549
  size?: [number, number]
293
550
  }
294
551
 
295
- export const isTrailerCard = (i: Item): i is Item & { trailer: TrailerCard } => i.trailer !== undefined
552
+ export const isTrailerItem = (i: Item): i is Item & { trailer: ItemTrailer } => i.trailer !== undefined
296
553
 
297
- /** one message of a post draft as a draft card pinned it: its key in the draft (`x`, `reddit/comfyui`), its name as he
554
+ /** one message of a post draft as a draft version pinned it: its key in the draft (`x`, `reddit/comfyui`), its name as he
298
555
  * reads it (« Reddit · comfyui »), the hash of what the draft says of it */
299
- export interface DraftCardPost {
556
+ export interface ItemDraftPost {
300
557
  key: string
301
558
  name: string
302
559
  hash: string
560
+ /** the post was already posted or dropped when the version was made: that place is settled from the start */
561
+ state?: 'posted' | 'dropped'
562
+ /** what the draft said of it then, the snapshot its hash covers: the next version draws its diff against it */
563
+ words?: DraftWords
564
+ }
565
+
566
+ /** a place's words and options as a version keeps them, each field only when it says something */
567
+ export interface DraftWords {
568
+ body: string
569
+ title?: string
570
+ tags?: string
571
+ media?: string
572
+ place?: string
303
573
  }
304
574
 
305
- /** what a draft card shows (wiki tools/shipkit/threads.md, A post draft): the draft `.shipkit/social/drafts/<slug>/`, read
306
- * live. The hashes are the draft as it was sent: `hash` its head and angle, each message its own, so the card says what
307
- * moved since. No view: the card holds no picture */
308
- export interface DraftCard {
575
+ /** the fields of a place a version's line names, in this order */
576
+ export const DRAFT_FIELDS = ['body', 'title', 'tags', 'media', 'place'] as const satisfies readonly (keyof DraftWords)[]
577
+
578
+ /** what a draft version shows (wiki tools/shipkit/threads.md, A post draft): the draft `.shipkit/social/drafts/<slug>/`, read
579
+ * live. The hashes are the draft as it was sent: `hash` its head and angle, each message its own, so the version says what
580
+ * moved since. No view: the version holds no picture */
581
+ export interface ItemDraft {
309
582
  slug: string
310
583
  hash: string
311
- posts: DraftCardPost[]
584
+ posts: ItemDraftPost[]
585
+ /** what the draft said beside its places then: its title and angle, the snapshot `hash` covers */
586
+ head?: { title: string; angle?: string }
587
+ /** who saved the draft this version shows: `owner` for his edit in the hub, else the agent's lane */
588
+ by?: string
312
589
  }
313
590
 
314
- export const isDraftCard = (i: Item): i is Item & { draft: DraftCard } => i.draft !== undefined
591
+ export const isDraftItem = (i: Item): i is Item & { draft: ItemDraft } => i.draft !== undefined
315
592
 
316
593
  /** a message's key in its draft: `<account>`, or `<account>/<name>` for one of several there */
317
594
  export const POST_KEY = /^[a-z0-9-]+(?:\/[a-z0-9-]+)?$/
318
595
 
319
- /** a choice card: he picks one of its views */
596
+ /** a choice version: he picks one of its views */
320
597
  export const isChoice = (i: Item): boolean => i.choice === true
321
598
 
322
599
  /** a view that plays on its own: one clip or one sound, never a pair */
323
600
  export const isPlayable = (v: ReviewView | undefined): v is MediaView => v !== undefined && !isGallery(v) && !isPair(v.files) && (v.clip !== undefined || v.audio !== undefined)
324
601
 
325
- /** a card shown as options, one thin row a view: a choice, or two views or more that each play on their own */
602
+ /** a version shown as options, one thin row a view: a choice, or two views or more that each play on their own */
326
603
  export const asOptions = (i: Item): boolean => isChoice(i) || (i.views.length >= 2 && i.views.every(isPlayable))
327
604
 
328
605
  /** the most stars a reaction gives */
329
606
  export const STARS = 5
330
607
 
331
- /** where a card is, for a fresh agent session in any repo: the repo as `~/dev/<repo>`, the card's url where it is open
608
+ /** where a thread is, for a fresh agent session in any repo: the repo as `~/dev/<repo>`, the thread's url where it is open
332
609
  * now, and its phone url when the repo has a public host */
333
- export interface CardWhere {
610
+ export interface ThreadWhere {
334
611
  root: string
335
612
  open: string
336
613
  phone?: string | null
337
614
  }
338
615
 
339
- /** one paste that hands a card to any agent session: what it is, where, the command that shows it whole, its links */
340
- export function pasteBlock(i: Item, state: string, w: CardWhere): string {
616
+ /** one paste that hands a thread to any agent session: what it is, where, the command that shows it whole, its links */
617
+ export function pasteBlock(i: Item, state: string, w: ThreadWhere): string {
341
618
  return [
342
- `review card "${i.title}" (${state}), id ${i.id}`,
619
+ `thread "${i.title}" (${state}), id ${i.id}`,
343
620
  `repo: ${w.root}`,
344
621
  `see it whole: cd ${w.root} && sk thread show ${i.id}`,
345
622
  `open: ${w.open}`,
@@ -347,7 +624,7 @@ export function pasteBlock(i: Item, state: string, w: CardWhere): string {
347
624
  ].join('\n')
348
625
  }
349
626
 
350
- /** a view's number in its version: 1 for the first. Never a letter: a card's own views are often named A, B, C, and
627
+ /** a view's number in its version: 1 for the first. Never a letter: a version's own views are often named A, B, C, and
351
628
  * a letter assigned beside them would not match */
352
629
  export const viewNo = (i: number): string => String(i + 1)
353
630
 
@@ -379,12 +656,12 @@ export function viewIndexOf(views: readonly { label: string }[], ref: string): n
379
656
  throw new Error(`« ${ref} » names no view: ${views.map((v, i) => `${viewNo(i)}${v.label ? ` "${v.label}"` : ''}`).join(', ')}`)
380
657
  }
381
658
 
382
- /** every media file a card's views name: images, pairs, clips and their posters, sounds and their waveforms, tiles */
659
+ /** every media file an item's views name: images, pairs, clips and their posters, sounds and their waveforms, tiles */
383
660
  export function viewFilesOf(i: Item): string[] {
384
661
  return i.views.flatMap((v) => {
385
662
  if (isGallery(v)) return v.gallery.flatMap((g) => [g.file, ...(g.before ? [g.before] : [])])
386
- return [...Object.values(v.files), ...(v.clip ? [v.clip.poster] : []), ...(v.audio ? [v.audio.wave, ...(v.audio.waveBefore ? [v.audio.waveBefore] : [])] : [])]
387
- })
663
+ return [...Object.values(v.files), ...(v.scene && 'file' in v.scene ? [v.scene.file] : []), ...(v.clip ? [v.clip.poster] : []), ...(v.audio ? [v.audio.wave, ...(v.audio.waveBefore ? [v.audio.waveBefore] : [])] : [])]
664
+ }).concat(i.states?.still ? Object.values(i.states.still.files) : [])
388
665
  }
389
666
 
390
667
  /** the first view: media or a gallery; a note with no image has none */
@@ -405,8 +682,8 @@ export const onFrame = (t: number, time: number, fps: number): boolean => Math.f
405
682
  export type Side = 'before' | 'after'
406
683
 
407
684
  /** a rectangle on a view, normalized 0..1; w = h = 0 is a pin. `view` the index of its view, absent on the first;
408
- * `side` only on a pair (on a trailer card with a before, the render it is drawn on); `t` only on a clip or a trailer
409
- * card's frame */
685
+ * `side` only on a pair (on a trailer version with a before, the render it is drawn on); `t` only on a clip or a trailer
686
+ * version's frame */
410
687
  export interface Rect {
411
688
  x: number
412
689
  y: number
@@ -417,7 +694,7 @@ export interface Rect {
417
694
  side?: Side
418
695
  /** the clip time it was drawn at, in seconds */
419
696
  t?: number
420
- /** on a trailer card's frame: the shot it sits on and the seconds into it, so a new render places it */
697
+ /** on a trailer version's frame: the shot it sits on and the seconds into it, so a new render places it */
421
698
  shot?: { name: string; time: number }
422
699
  /** the gallery tile it is drawn on, its coordinates the tile's image */
423
700
  tile?: number
@@ -432,12 +709,12 @@ export type ReviewStatus = (typeof STATUSES)[number]
432
709
 
433
710
  export const isApproved = (s: ReviewStatus): boolean => s === 'approved' || s === 'approved-with-fix'
434
711
 
435
- /** the owner's reaction to one view, to one tile of a gallery view, or to one message of a draft card; one per view,
712
+ /** the owner's reaction to one view, to one tile of a gallery view, or to one message of a draft version; one per view,
436
713
  * tile or message */
437
714
  export interface ReviewReaction {
438
715
  view: number
439
716
  tile?: number
440
- /** on a draft card: the message of the draft it answers, by its key (`x`, `reddit/comfyui`) */
717
+ /** on a draft version: the message of the draft it answers, by its key (`x`, `reddit/comfyui`) */
441
718
  post?: string
442
719
  status?: ReviewStatus
443
720
  comment: string
@@ -447,8 +724,14 @@ export interface ReviewReaction {
447
724
  picked?: true
448
725
  }
449
726
 
450
- /** a state change, or a read mark (`seen`, with the ids it read in `of`) */
451
- export const OPS = ['dispatch', 'ask', 'answer', 'reassign', 'claim', 'release', 'blocked', 'fixed', 'done', 'wontfix', 'drop', 'withdraw', 'reopen', 'ready', 'seen'] as const
727
+ /** a state change, a read mark (`seen`, with the ids it read in `of`), a take (`take`: an agent holds the thread
728
+ * from now on, its state unchanged; review/parties.ts), or an agent on it (`working`, its line in `note`, none ends
729
+ * it; review/traces.ts) */
730
+ /** a `take` the machine wrote for a gone holder (review/hand-over.ts): no agent chose it, so it is no move, no act on
731
+ * his lane request, and no sign that anyone works the thread */
732
+ export const handedOver = (m: Pick<Message, 'op' | 'from'>): boolean => m.op === 'take' && m.from !== undefined
733
+
734
+ export const OPS = ['dispatch', 'ask', 'answer', 'reassign', 'claim', 'release', 'blocked', 'fixed', 'done', 'wontfix', 'drop', 'withdraw', 'reopen', 'ready', 'seen', 'take', 'working'] as const
452
735
  export type Op = (typeof OPS)[number]
453
736
 
454
737
  /** what an agent's update says of the work, at a glance: still broken, better, or fixed (it asks the owner's verdict again) */
@@ -456,12 +739,21 @@ export const UPDATE_STATES = ['broken', 'better', 'fixed'] as const
456
739
  export type UpdateState = (typeof UPDATE_STATES)[number]
457
740
  export const UPDATE_WORDS: Record<UpdateState, string> = { broken: 'still broken', better: 'better', fixed: 'fixed' }
458
741
 
459
- /** an agent's progress post on a card: its state, and the view of the card that holds its picture, clip or sound */
742
+ /** an agent's progress post on an item: its state, and the view of the item that holds its picture, clip or sound */
460
743
  export interface MessageUpdate {
461
744
  state: UpdateState
462
745
  view?: number
463
746
  }
464
747
 
748
+ /** a file attached to a message: `file` its name in `thread/`, `name` the name it came with, its bytes, its type by
749
+ * its extension */
750
+ export interface MessageFile {
751
+ file: string
752
+ name: string
753
+ size: number
754
+ type: string
755
+ }
756
+
465
757
  /** one act on an item, one file of `thread/`, never rewritten */
466
758
  export interface Message {
467
759
  id: string
@@ -472,10 +764,12 @@ export interface Message {
472
764
  text?: string
473
765
  /** a file of the folder's `thread/` beside it */
474
766
  image?: string
767
+ /** files of any kind attached to the message, each a file of `thread/` beside it (`<id>-f<n>.<ext>`) */
768
+ files?: MessageFile[]
475
769
  rects?: Rect[]
476
770
  reactions?: ReviewReaction[]
477
771
  verdict?: ReviewStatus
478
- /** the view he picked on a choice card, its index */
772
+ /** the view he picked on a choice version, its index */
479
773
  pick?: number
480
774
  /** a repo's own mark on a subject (stars, a song's mark): kept as written */
481
775
  rate?: { stars?: number; mark?: string; part?: string }
@@ -493,30 +787,206 @@ export interface Message {
493
787
  re?: string
494
788
  /** the Claude Code session of the agent that wrote it: the thread's holder */
495
789
  session?: string
790
+ /** a `take` that is a hand-over (review/hand-over.ts): the holder that was gone */
791
+ from?: { lane?: string; session?: string }
496
792
  /** the objects it attaches to its thread, each `<kind>:<key>` */
497
793
  about?: string[]
498
794
  /** a question to the owner: its words in `text`, its options, the option the agent picks */
499
795
  ask?: MessageAsk
796
+ /** a question that is a field inside a step of an ask's instructions (`of`: their message id, `i`: the step): drawn
797
+ * in that step, never beside it; the step counts ticked once its every field is answered (review/instructions.ts).
798
+ * `carries`: the question it took the place of when a fold moved that one into the step: his answers to it are its */
799
+ step?: { of: string; i: number; carries?: string }
500
800
  /** a change the agent proposes on an object's text: its words in `text` */
501
801
  propose?: MessagePropose
802
+ /** the owner clicked one of the kind's actions on the thread's object */
803
+ action?: MessageAction
804
+ /** an act of the version's kind done on one of its spots (review/settle.ts): `name` the kind's act, `post` the
805
+ * place of a draft, `url` where it went, `undo` it is taken back (a link cleared, a drop taken back); its line in
806
+ * `note`, never words he owes an answer */
807
+ act?: MessageAct
808
+ /** an ask's thread: its ask closed (done, declined, cancelled, merged) or opened again; a closed ask asks nothing
809
+ * more. `into`: the id of the ask a merged one went into */
810
+ askState?: { state: AskState; why?: string; into?: string }
811
+ /** an answer of his carried here by a merge from another ask (asks/ask-close.ts): `from` that ask's id, `at` when he
812
+ * gave it. His answer for every reader of the answer, never a new act of his: no thread word, no wake, no return
813
+ * from set aside */
814
+ carried?: { from: string; at: string }
815
+ /** the owner's own save of the thread's object from the hub's editor (review/doc-save.ts saveDoc): `of` the version it
816
+ * made (an item, or an ask's instructions message), or the version waiting on the owner's verdict that the save went over;
817
+ * its line of what changed in `text`, its changed lines in `diff` (`- ` gone, `+ ` new). His act, never the agent's:
818
+ * it wakes the thread's holder (wakes.ts `edit`). His saves of one burst are one wake (doc-save.ts ownerEdit): `base`
819
+ * the text before a burst's first save; a later save of it lands beside that first edit, its diff from `base`, and
820
+ * `folds` names the edit it takes the place of, a trace from then on (wakes.ts `edit-folded`) */
821
+ edit?: { of: string; diff: string[]; base?: string; folds?: string }
822
+ /** a thread set aside until `until` (an ISO time), his from the hub or an agent's when it posts; null brings it back */
823
+ snooze?: { until: string | null }
824
+ /** an agent's message that brings back a thread set aside (wiki tools/shipkit/threads-asks.md, Snooze) */
825
+ urgent?: true
502
826
  /** his answer to the question or the proposal `re` names: the option he clicked, or « apply » (an edit his `text`) */
503
827
  answer?: MessageAnswer
828
+ /** the agent's object of the same thread (a question, a change, its words) this newer one supersedes, by its message
829
+ * id (wiki tools/shipkit/threads-asks.md, Superseded objects) */
830
+ replaces?: string
831
+ /** an ask's questions that its bar answers (« done ✓ », « I will not do this », the proof url), by their message ids:
832
+ * drawn nowhere, docked nowhere, waiting on nobody (wiki tools/shipkit/threads-asks.md, The ask bar) */
833
+ askBar?: string[]
834
+ /** an ask's instructions after its first, superseding the ones before it in the store's order: its words in `text`,
835
+ * its title, its facts as they stand now (its day and its ping stay the head's), and the questions it folds */
836
+ instructions?: { title: string; ask: Omit<AskHead, 'created' | 'pinged'>; folds: string[] }
837
+ /** an agent's message that waits for the owner's verdict; the owner's answer is the owner's message with `verdict` and `re` naming it
838
+ * (review/verdict-items.ts) */
839
+ asksVerdict?: true
840
+ /** the machine's: an attached object's hold flipped (review/holds.ts), its words in `text` */
841
+ hold?: { address: string; held: boolean; sha?: string; ahead?: number }
842
+ /** the owner's close of a held thread: the holds it releases, by address */
843
+ unhold?: string[]
844
+ /** the owner asks for a lane on the thread (review/lane-ask.ts): the owner's words in `text`, the orchestrator it
845
+ * waited on when asked; no reply, the thread's holder never hears it as one */
846
+ laneAsk?: { for: string; session?: string }
847
+ /** the parties the owner's words name with `@` (review/mentions.ts): they wake those parties only */
848
+ to?: Mention[]
849
+ /** his bell on the thread: true, no push to his phone from it; false, pushes again (review/phone-push.ts) */
850
+ mute?: boolean
851
+ }
852
+
853
+ /** a party the owner's words name: a lane (and its session), a session alone (the orchestrator), or an advisor by id */
854
+ export interface Mention {
855
+ name: string
856
+ lane?: string
857
+ session?: string
858
+ advisor?: string
859
+ }
860
+
861
+ /** an act of a kind done on a spot of a version */
862
+ export interface MessageAct {
863
+ name: string
864
+ post?: string
865
+ url?: string
866
+ undo?: true
504
867
  }
505
868
 
869
+ /** what a question asks him for (wiki tools/shipkit/threads-asks.md, Answer kinds); absent on a question, a choice */
870
+ export const ANSWER_KINDS = ['choice', 'checklist', 'confirm', 'text', 'url', 'secret', 'file'] as const
871
+ export type AnswerKind = (typeof ANSWER_KINDS)[number]
872
+
873
+ /** `options`: a choice's options, a checklist's lines, empty for the other kinds */
506
874
  export interface MessageAsk {
875
+ kind?: AnswerKind
507
876
  options: string[]
508
877
  pick?: number
878
+ /** option i's media: the item's view that holds it, null for words alone */
879
+ views?: (number | null)[]
880
+ /** a checklist's lines done before he looked, ticked from the start */
881
+ done?: number[]
882
+ /** an ask's instructions: each step's choice, its options as markdown lines and the agent's pick, null a step with
883
+ * none (review/instructions.ts); his pick rides on his tick of that step */
884
+ choices?: (StepChoice | null)[]
885
+ /** a secret's name in the house secret manager; `login`: an account goes with it */
886
+ secret?: { name: string; login?: true }
887
+ }
888
+
889
+ /** how one field of a proposed change draws: a house kind (review/kinds.ts) */
890
+ export { DIFF_TYPES, type DiffType } from './kinds.ts'
891
+ import { DIFF_TYPES, sniffKind, type DiffType } from './kinds.ts'
892
+ import { slugOf } from '../core/slug.ts'
893
+
894
+ /** one field of a proposed change: its value before and after, how it draws; a sound's pair is a view of the item */
895
+ export interface ProposeField {
896
+ key: string
897
+ before?: string
898
+ after: string
899
+ type?: DiffType
900
+ lang?: string
901
+ view?: number
509
902
  }
510
903
 
511
- export interface MessagePropose {
904
+ /** one field flat (`key` empty), or several in `fields`, `after` then their lines for an older reader */
905
+ export interface MessagePropose extends Omit<ProposeField, 'key'> {
512
906
  on: string
513
- before?: string
514
- after: string
907
+ fields?: ProposeField[]
908
+ /** the repo's page that draws the change, its kind's `diff.page` when it was proposed */
909
+ page?: string
515
910
  }
516
911
 
517
912
  export interface MessageAnswer {
518
913
  option?: number
519
914
  apply?: true
915
+ /** the one field it applies; none only on a change of one field */
916
+ field?: string
917
+ /** the value he applied, the owner's edit or the agent's as it is; `text` keeps the owner's words, else the value; a
918
+ * text or a url question's answer */
919
+ value?: string
920
+ /** a checklist's line (`option`) ticked or unticked; a confirm's « done » */
921
+ tick?: boolean
922
+ /** on a tick of a choice step of an ask's instructions: the option he clicked */
923
+ pick?: number
924
+ /** a url answer: the status it opened with, 0 when it did not open */
925
+ opens?: number
926
+ /** a secret answer: the name its value went under; the value is never in the store */
927
+ stored?: string
928
+ /** a file answer: the item's view that holds the file */
929
+ view?: number
930
+ }
931
+
932
+ /** the fields of a proposed change as a list, one for the flat form */
933
+ export const proposeFields = (p: MessagePropose): ProposeField[] =>
934
+ p.fields ?? [{ key: '', after: p.after, ...(p.before !== undefined ? { before: p.before } : {}), ...(p.type ? { type: p.type } : {}), ...(p.lang ? { lang: p.lang } : {}), ...(p.view !== undefined ? { view: p.view } : {}) }]
935
+
936
+ /** each field of the proposal `m` he applied, by its key: the value he applied and when. An apply that names no field
937
+ * is a change of one field, or an older one that applied every field as proposed */
938
+ export function appliedFields(thread: readonly Message[], m: Message): Map<string, { text: string; at: string }> {
939
+ const out = new Map<string, { text: string; at: string }>()
940
+ if (!m.propose) return out
941
+ const fields = proposeFields(m.propose)
942
+ for (const y of thread) {
943
+ if (y.re !== m.id || y.answer?.apply !== true || partyOf(y.who) !== 'owner') continue
944
+ const named = y.answer.field
945
+ for (const f of fields) {
946
+ if (out.has(f.key) || (named !== undefined && named !== f.key)) continue
947
+ out.set(f.key, { text: y.answer.value ?? (named !== undefined || fields.length === 1 ? (y.text ?? f.after) : f.after), at: y.at })
948
+ }
949
+ }
950
+ return out
951
+ }
952
+
953
+ /** a proposal waits on him until each of its fields is applied, or a message of the owner's with words names it */
954
+ export function proposeOpen(thread: readonly Message[], m: Message): boolean {
955
+ if (!m.propose) return false
956
+ if (thread.some((y) => y.re === m.id && y.answer === undefined && partyOf(y.who) === 'owner')) return false
957
+ return appliedFields(thread, m).size < proposeFields(m.propose).length
958
+ }
959
+
960
+ /** how a field draws when nothing names it: the first house kind that takes its values, words otherwise */
961
+ export const diffTypeOf = sniffKind
962
+
963
+ /** an object as one side of a change: its json and its files (repo relative), and the git ref it was read at.
964
+ * `views`: the views its kind's page draws it in, one still each in the thread (review/kind-still.ts) */
965
+ export interface StoredState {
966
+ json: unknown
967
+ files?: Record<string, string>
968
+ at?: string
969
+ views?: KindViewRef[]
970
+ }
971
+
972
+ /** one view of a kind's page: its `view` frame key, and the legend under its still */
973
+ export interface KindViewRef {
974
+ id: string
975
+ label: string
976
+ }
977
+
978
+ /** a view's id: the `view` frame key a kind's page reads */
979
+ export const KIND_VIEW_RE = /^[a-z0-9][a-z0-9_-]*$/i
980
+
981
+ /** a still of a kind's page, its files in the item's folder as a view's: one image, or a before and an after */
982
+ export interface KindStill {
983
+ files: { image: string } | { before: string; after: string }
984
+ size: { w: number; h: number }
985
+ }
986
+
987
+ /** an owner's click on a kind's action (wiki tools/shipkit/threads-how-it-fits.md, Kinds): its name, the owner's words in `text` */
988
+ export interface MessageAction {
989
+ name: string
520
990
  }
521
991
 
522
992
  /** what the store reads of one folder, what the list sends */
@@ -531,13 +1001,67 @@ export type Party = 'agent' | 'owner'
531
1001
  export const partyOf = (who: string): Party => (who === 'owner' || who === 'player' ? 'owner' : 'agent')
532
1002
 
533
1003
  /** a message one party says to the other: a reply, a verdict, a rating, a question and its answer; never another op */
534
- const isTalk = (m: Message): boolean => m.op === undefined || ((m.op === 'ask' || m.op === 'answer') && m.text !== undefined)
1004
+ const isTalk = (m: Message): boolean => m.laneAsk === undefined && (m.op === undefined || ((m.op === 'ask' || m.op === 'answer') && m.text !== undefined))
535
1005
 
536
- /** a reply: talk with words that is no verdict and no rating (a message moving a pin alone is no reply) */
537
- export const isReply = (m: Message): boolean => isTalk(m) && m.verdict === undefined && m.rate === undefined && m.text !== undefined
1006
+ /** the owner's verdict on the version itself; one that names `re` judges that message (review/verdict-items.ts) */
1007
+ export const isVersionVerdict = (m: Pick<Message, 'verdict' | 're'>): boolean => m.verdict !== undefined && m.re === undefined
1008
+
1009
+ /** a reply: talk with words that is no verdict on the version and no rating (a message moving a pin alone is no reply);
1010
+ * the owner's verdict on a message is the answer the agent reads, words or none */
1011
+ export const isReply = (m: Message): boolean => isTalk(m) && !isVersionVerdict(m) && m.rate === undefined && (m.text !== undefined || m.verdict !== undefined)
538
1012
 
539
1013
  export const MESSAGE_RE = /^\d{8}-\d{6}-\d{3}-(agent|owner|player)(-[a-z0-9]+)*$/
540
1014
  export const MESSAGE_FILE_RE = /^\d{8}-\d{6}-\d{3}-(agent|owner|player)(-[a-z0-9]+)*\.(png|jpe?g|webp)$/
1015
+ /** a file attached to a message, `<id>-f<n>.<ext>`: any kind */
1016
+ export const MESSAGE_ATTACH_RE = /^(\d{8}-\d{6}-\d{3}-(agent|owner|player)(-[a-z0-9]+)*)-f([1-9]\d?)\.([a-z0-9]{1,8})$/
1017
+ /** the files one message carries at most */
1018
+ export const MESSAGE_FILES_MAX = 20
1019
+ /** the bytes one attached file may hold: under the 128 MiB every Bun server on its way takes by default (the web, the
1020
+ * daemon), which hold a request's body whole */
1021
+ export const UPLOAD_MAX = 100 * 1024 * 1024
1022
+ const FILE_NAME_MAX = 120
1023
+
1024
+ /** the name a file came with, as a message keeps it: no folder, no control character, at most 120 characters */
1025
+ export function cleanFileName(name: string): string {
1026
+ const base = name.split(/[/\\]/).pop() ?? ''
1027
+ // eslint-disable-next-line no-control-regex
1028
+ const clean = base.replace(/[\u0000-\u001f\u007f]/g, '').trim()
1029
+ if (clean === '' || clean === '.' || clean === '..') return 'file'
1030
+ if (clean.length <= FILE_NAME_MAX) return clean
1031
+ const dot = clean.lastIndexOf('.')
1032
+ const ext = dot > 0 && clean.length - dot <= 9 ? clean.slice(dot) : ''
1033
+ return `${clean.slice(0, FILE_NAME_MAX - ext.length)}${ext}`
1034
+ }
1035
+
1036
+ /** the extension a stored file takes from its name: lowercase letters and digits, 1 to 8, else `bin` */
1037
+ export function attachExt(name: string): string {
1038
+ const m = /\.([A-Za-z0-9]{1,8})$/.exec(name)
1039
+ return m ? m[1]!.toLowerCase() : 'bin'
1040
+ }
1041
+
1042
+ /** the name of a message's `n`th file (from 1) in `thread/` */
1043
+ export const attachFile = (messageId: string, n: number, name: string): string => `${messageId}-f${n}.${attachExt(name)}`
1044
+
1045
+ const MIME: Record<string, string> = {
1046
+ png: 'image/png', jpg: 'image/jpeg', jpeg: 'image/jpeg', webp: 'image/webp', gif: 'image/gif', svg: 'image/svg+xml', heic: 'image/heic',
1047
+ mp4: 'video/mp4', webm: 'video/webm', mov: 'video/quicktime', mkv: 'video/x-matroska',
1048
+ mp3: 'audio/mpeg', wav: 'audio/wav', ogg: 'audio/ogg', opus: 'audio/opus', m4a: 'audio/mp4', flac: 'audio/flac',
1049
+ pdf: 'application/pdf', zip: 'application/zip', gz: 'application/gzip', tgz: 'application/gzip', tar: 'application/x-tar', '7z': 'application/x-7z-compressed',
1050
+ txt: 'text/plain', md: 'text/markdown', csv: 'text/csv', json: 'application/json', html: 'text/html', htm: 'text/html',
1051
+ }
1052
+ /** a file's type by its extension, `application/octet-stream` when unknown */
1053
+ export const mimeOf = (file: string): string => MIME[attachExt(file)] ?? 'application/octet-stream'
1054
+
1055
+ /** how the hub shows a file in place: the kinds a browser plays safely on the hub's own origin. Never svg or html:
1056
+ * they run script there */
1057
+ export const INLINE: Record<string, 'image' | 'video' | 'audio'> = { png: 'image', jpg: 'image', jpeg: 'image', webp: 'image', gif: 'image', mp4: 'video', webm: 'video', mov: 'video', mp3: 'audio', wav: 'audio', ogg: 'audio', opus: 'audio', m4a: 'audio', flac: 'audio' }
1058
+ export const inlineOf = (file: string): 'image' | 'video' | 'audio' | null => INLINE[attachExt(file)] ?? null
1059
+
1060
+ const fileProblem = (f: unknown, id: string, i: number): boolean => {
1061
+ if (!obj(f)) return true
1062
+ const m = typeof f.file === 'string' ? MESSAGE_ATTACH_RE.exec(f.file) : null
1063
+ return m === null || m[1] !== id || Number(m[4]) !== i + 1 || typeof f.name !== 'string' || f.name === '' || cleanFileName(f.name) !== f.name || !(Number.isInteger(f.size) && (f.size as number) >= 0) || typeof f.type !== 'string'
1064
+ }
541
1065
  const MAX_TEXT = 4000
542
1066
 
543
1067
  /** an agent's name: its lane (`L135`, `REVIEW`) */
@@ -567,13 +1091,26 @@ export function textOf(v: unknown): { text: string } | { error: string } {
567
1091
  const readBy = (x: ReviewItem, party: Party): Set<string> =>
568
1092
  new Set(x.thread.flatMap((m) => (m.op === 'seen' && partyOf(m.who) === party ? (m.of ?? []) : [])))
569
1093
 
570
- /** the owner took a verdict back on an agent's card: news for the agent, which may have acted on that verdict */
1094
+ /** the owner took a verdict back on an agent's version: news for the agent, which may have acted on that verdict */
571
1095
  const isTakeBack = (x: ReviewItem, m: Message): boolean => m.op === 'reopen' && m.who === 'owner' && x.item.origin.by === 'agent'
572
1096
 
573
1097
  /** the talk of the other party that `party` has not read: replies, verdicts, ratings, his verdicts taken back */
1098
+ /** the owner's close or reopen of a whole thread from the hub: heard by its holder and acknowledged like the owner's words */
1099
+ const isOwnerClose = (m: Message): boolean => partyOf(m.who) === 'owner' && (m.op === 'fixed' || m.op === 'done' || m.op === 'wontfix' || m.op === 'reopen')
1100
+
1101
+ /** the agents the owner's words name with `@`, none for words that name no agent */
1102
+ export const agentsNamed = (m: Pick<Message, 'to'>): Mention[] => (m.to ?? []).filter((t) => t.advisor === undefined)
1103
+
1104
+ /** the words a `seen` of agent `who` (its session `session`) may read by default: every word, except one that names
1105
+ * agents and none of them is it. `sk thread seen` narrows it further with the registry (threads.ts seenOnly) */
1106
+ export const mayReadNamed = (m: Pick<Message, 'to'>, who: string, session: string | null): boolean => {
1107
+ const named = agentsNamed(m)
1108
+ return named.length === 0 || named.some((t) => (t.lane !== undefined && t.lane === who && (t.session === undefined || session === null || t.session === session)) || (who === 'agent' && session !== null && t.session === session))
1109
+ }
1110
+
574
1111
  const unreadTalk = (x: ReviewItem, party: Party): Message[] => {
575
1112
  const read = readBy(x, party)
576
- return x.thread.filter((m) => (isTalk(m) || isTakeBack(x, m)) && partyOf(m.who) !== party && !read.has(m.id))
1113
+ return x.thread.filter((m) => (isTalk(m) || isTakeBack(x, m) || isOwnerClose(m)) && partyOf(m.who) !== party && !read.has(m.id))
577
1114
  }
578
1115
 
579
1116
  /** each verdict the owner took back that no agent marked seen: his reopen and the verdict it took back */
@@ -582,7 +1119,7 @@ export function takenBackOf(x: ReviewItem): { m: Message; took: ReviewStatus; gi
582
1119
  const out: { m: Message; took: ReviewStatus; given: string }[] = []
583
1120
  let v: Message | undefined
584
1121
  for (const n of x.thread) {
585
- if (n.verdict !== undefined) v = n
1122
+ if (isVersionVerdict(n)) v = n
586
1123
  else if (n.op === 'reopen' || isFixedUpdate(n)) {
587
1124
  if (v?.verdict && isTakeBack(x, n) && unread.has(n.id)) out.push({ m: n, took: v.verdict, given: v.at })
588
1125
  v = undefined
@@ -597,14 +1134,14 @@ export const unreadBy = (x: ReviewItem, party: Party): Message[] => unreadTalk(x
597
1134
  /** what a `seen` of `party` reads on `x`: every message of the other party it has not read yet */
598
1135
  export const toAcknowledge = (x: ReviewItem, party: Party): string[] => unreadTalk(x, party).map((m) => m.id)
599
1136
 
600
- /** the owner's verdict as the card shows it: the latest one since the last reopen; `seen`: an agent read it */
1137
+ /** the owner's verdict as the version shows it: the latest one since the last reopen; `seen`: an agent read it */
601
1138
  export interface Verdict {
602
1139
  id: string
603
1140
  status: ReviewStatus
604
1141
  comment: string
605
1142
  rects: Rect[]
606
1143
  reactions?: ReviewReaction[]
607
- /** the view he picked, on a choice card */
1144
+ /** the view he picked, on a choice version */
608
1145
  pick?: number
609
1146
  at: string
610
1147
  seen: boolean
@@ -625,18 +1162,27 @@ export function updateTag(x: ReviewItem, id: string): string | null {
625
1162
  }
626
1163
 
627
1164
  export function verdictOf(x: ReviewItem): Verdict | null {
1165
+ // a version answered by its kind's acts: the act that settles its last spot is his yes, owing the agent nothing
1166
+ const settling = settlingOf(x)
1167
+ let settled: Pick<Message, 'id' | 'at'> | null = settling?.start ? { id: x.item.id, at: x.item.created } : null
628
1168
  let m: Message | undefined
629
1169
  let text: string | undefined
630
1170
  let rects: Rect[] | undefined
631
1171
  for (const n of x.thread) {
632
- if (n.op === 'reopen' || isFixedUpdate(n)) [m, text, rects] = [undefined, undefined, undefined]
633
- else if (n.verdict !== undefined) {
1172
+ const flip = settling?.flips.get(n.id)
1173
+ if (flip !== undefined) {
1174
+ settled = flip ? n : null
1175
+ if (flip) [m, text, rects] = [undefined, undefined, undefined]
1176
+ } else if (n.op === 'reopen' || isFixedUpdate(n)) [m, text, rects, settled] = [undefined, undefined, undefined, null]
1177
+ else if (isVersionVerdict(n)) {
634
1178
  if (m?.verdict !== n.verdict) [text, rects] = [undefined, undefined]
635
1179
  m = n
1180
+ settled = null
636
1181
  if (n.text !== undefined) text = n.text
637
1182
  if (n.rects !== undefined) rects = n.rects
638
1183
  }
639
1184
  }
1185
+ if (settled !== null) return { id: settled.id, status: 'approved', comment: '', rects: [], at: settled.at, seen: true }
640
1186
  if (!m?.verdict) return null
641
1187
  return {
642
1188
  id: m.id,
@@ -651,10 +1197,12 @@ export function verdictOf(x: ReviewItem): Verdict | null {
651
1197
  }
652
1198
  }
653
1199
 
654
- /** why the agent took the card back unanswered; undefined when it did not */
655
- export const withdrawnOf = (x: ReviewItem): string | undefined => x.thread.filter((m) => m.op === 'withdraw').at(-1)?.note
1200
+ /** the agent's withdraw of the version itself; one that names one object of it (`re`) leaves the version as it was */
1201
+ export const itemWithdrawOf = (x: ReviewItem): Message | undefined => x.thread.filter((m) => m.op === 'withdraw' && m.re === undefined).at(-1)
1202
+ /** why the agent took the version back unanswered; undefined when it did not */
1203
+ export const withdrawnOf = (x: ReviewItem): string | undefined => itemWithdrawOf(x)?.note
656
1204
 
657
- /** what the list says of an item: an agent's card by the owner's verdict, what he or a player raised by its state */
1205
+ /** what the list says of an item: an agent's version by the owner's verdict, what he or a player raised by its state */
658
1206
  export type ShownStatus = 'pending' | 'wip' | ReviewStatus | 'superseded' | 'withdrawn' | 'raised' | 'fixed' | 'wontfix' | 'rated'
659
1207
 
660
1208
  export const STATUS_LABEL: Record<ShownStatus, string> = {
@@ -663,7 +1211,7 @@ export const STATUS_LABEL: Record<ShownStatus, string> = {
663
1211
  approved: 'approved',
664
1212
  'approved-with-fix': 'ok with a fix',
665
1213
  rejected: 'rejected',
666
- archived: 'archived, later',
1214
+ archived: 'not doing it',
667
1215
  superseded: 'replaced',
668
1216
  withdrawn: 'withdrawn',
669
1217
  raised: 'open',
@@ -672,6 +1220,21 @@ export const STATUS_LABEL: Record<ShownStatus, string> = {
672
1220
  rated: 'rated',
673
1221
  }
674
1222
 
1223
+ /** a verdict as he reads it: a fix on a draft's places names them (« fix on X »), never the whole version, whose other
1224
+ * places still wait for publish or drop */
1225
+ export function verdictLabel(item: Pick<Item, 'draft'>, status: ShownStatus, reactions: readonly Pick<ReviewReaction, 'post' | 'status'>[] = []): string {
1226
+ if (status !== 'approved-with-fix' || item.draft === undefined) return STATUS_LABEL[status]
1227
+ const names = reactions.filter((r) => r.post !== undefined && r.status === 'approved-with-fix').map((r) => item.draft!.posts.find((p) => p.key === r.post)?.name ?? r.post!)
1228
+ return names.length === 0 ? STATUS_LABEL[status] : `fix on ${[...new Set(names)].join(', ')}`
1229
+ }
1230
+
1231
+ /** a draft verdict's words when the verdict itself holds none: each place's, « X: <words> » */
1232
+ export const placeWords = (reactions: readonly Pick<ReviewReaction, 'post' | 'comment'>[], item: Pick<Item, 'draft'>): string =>
1233
+ reactions
1234
+ .filter((r) => r.post !== undefined && r.comment.trim() !== '')
1235
+ .map((r) => `${item.draft?.posts.find((p) => p.key === r.post)?.name ?? r.post}: ${r.comment.trim()}`)
1236
+ .join('; ')
1237
+
675
1238
  /** the lifecycle (wiki tools/shipkit/threads.md, The lifecycle) */
676
1239
  export type State = 'draft' | 'new' | 'question' | 'open' | 'claimed' | 'blocked' | 'asks' | 'closed'
677
1240
  type ClosedWhy = ReviewStatus | 'fixed' | 'wontfix' | 'dropped' | 'superseded' | 'withdrawn' | 'rated'
@@ -682,7 +1245,7 @@ export interface ItemState {
682
1245
  topic?: string
683
1246
  /** who holds a claim */
684
1247
  worker?: string
685
- /** the time of the `claim` that holds it; none on the claim the owner's verdict gives the card's lane until it is read */
1248
+ /** the time of the `claim` that holds it; none on the claim the owner's verdict gives the version's lane until it is read */
686
1249
  since?: string
687
1250
  }
688
1251
 
@@ -691,28 +1254,49 @@ export type Move = 'owner' | 'agents' | 'none'
691
1254
  export const moveOf = (s: State): Move =>
692
1255
  s === 'asks' || s === 'question' || s === 'blocked' ? 'owner' : s === 'new' || s === 'open' || s === 'claimed' ? 'agents' : 'none'
693
1256
 
694
- export const MOVE_LABEL: Record<Move, string> = { owner: 'mine', agents: 'in work', none: 'done' }
1257
+ export const MOVE_LABEL: Record<Move, string> = { owner: 'mine', agents: "an agent's", none: 'done' }
1258
+
1259
+ /** a thread an agent opened with words (a question, a proposed change, a line): nothing to judge, so no verdict waits;
1260
+ * words posted with `--verdict` (asksVerdict) wait for it as a version does, so every reader takes them as one */
1261
+ export const isOpening = (i: Item): boolean => i.origin.by === 'agent' && i.on !== undefined && i.asksVerdict !== true && i.views.every((v) => !isGallery(v) && v.message === true) && i.draft === undefined && i.states === undefined && i.doc === undefined
695
1262
 
696
- /** where an item starts: an agent's card asks for the owner's verdict (a draft waits); what he raises from a tool that named
1263
+ /** the owner's own save of an object (review/doc-save.ts): his, done when made, nothing for him to judge. A post draft he
1264
+ * saved is no such save: its places still wait on his publish or drop (review/settle.ts) */
1265
+ export const ownSave = (i: Pick<Item, 'saved'>): boolean => i.saved?.by === 'owner'
1266
+
1267
+ /** a version that asks the owner no verdict: a thread opened with words, or his own save */
1268
+ export const asksNoVerdict = (i: Item): boolean => isOpening(i) || ownSave(i)
1269
+
1270
+ /** where an item starts: an agent's version asks for the owner's verdict (a draft waits); what he raises from a tool that named
697
1271
  * its topic (the trailer view: `film`) is open, else it waits on a dispatcher; an auto rule's item is open */
698
1272
  const startOf = (i: Item): ItemState =>
699
- i.origin.by === 'agent'
700
- ? { state: i.wip ? 'draft' : 'asks' }
1273
+ ownSave(i)
1274
+ ? { state: 'closed', why: 'fixed' }
1275
+ : i.origin.by === 'agent'
1276
+ ? { state: i.wip || isOpening(i) ? 'draft' : 'asks' }
701
1277
  : i.topic || i.origin.by === 'auto'
702
1278
  ? { state: 'open', ...(i.topic ? { topic: i.topic } : {}) }
703
1279
  : { state: 'new' }
704
1280
 
705
- /** the state of an item, folded from its thread. A verdict wins over a withdrawal, as on the card; `superseded`: a
706
- * later version follows it. « fix » and « no » give the card back to its author until an agent reads them */
1281
+ /** the state of an item, folded from its thread. A verdict wins over a withdrawal, as the thread shows it; `superseded`: a
1282
+ * later version follows it. « fix » and « no » give the version back to its author until an agent reads them */
707
1283
  export function stateOf(x: ReviewItem, superseded: boolean): ItemState {
708
1284
  const i = x.item
709
1285
  const lane = i.origin.by === 'agent' ? i.origin.lane : undefined
710
- let s: ItemState = startOf(i)
711
- // what his latest verdict left: a released or superseded rework of an agent's card goes back to it
1286
+ const settling = settlingOf(x)
1287
+ let s: ItemState = settling?.start ? { state: 'closed', why: 'approved' } : startOf(i)
1288
+ // what his latest verdict left: a released or superseded rework of an agent's version goes back to it
712
1289
  let given: ItemState = s
713
1290
  for (const m of x.thread) {
714
1291
  const keep = s.topic ? { topic: s.topic } : {}
715
- if (m.verdict !== undefined) {
1292
+ // a version answered by its kind's acts: every spot settled is his yes, a spot opened again waits on him
1293
+ const flip = settling?.flips.get(m.id)
1294
+ if (flip !== undefined) {
1295
+ s = flip ? { ...keep, state: 'closed', why: 'approved' } : { ...keep, state: 'asks' }
1296
+ given = s
1297
+ continue
1298
+ }
1299
+ if (m.verdict !== undefined && isVersionVerdict(m)) {
716
1300
  const v = m.verdict
717
1301
  // « fix » and « no » owe the lane work: reading the verdict is never doing it (done, wontfix or a new version closes it)
718
1302
  if (v === 'approved' || v === 'archived') s = { ...keep, state: 'closed', why: v }
@@ -724,10 +1308,12 @@ export function stateOf(x: ReviewItem, superseded: boolean): ItemState {
724
1308
  s = { ...keep, state: 'closed', why: 'rated' }
725
1309
  continue
726
1310
  }
727
- // an agent's update on its card: still broken or better holds it in work, fixed asks the owner's verdict again
1311
+ // an agent's update on its version: still broken or better holds it in work, fixed asks the owner's verdict again
728
1312
  if (m.update !== undefined && i.origin.by === 'agent' && partyOf(m.who) === 'agent') {
729
1313
  if (m.update.state === 'fixed') {
730
- if (s.state === 'draft' || s.state === 'claimed' || s.state === 'closed') s = { ...keep, state: 'asks' }
1314
+ // a thread opened with words holds nothing to judge: fixed ends its work, never asks a verdict
1315
+ if (isOpening(i)) s = { ...keep, state: 'closed', why: 'fixed' }
1316
+ else if (s.state === 'draft' || s.state === 'claimed' || s.state === 'closed') s = { ...keep, state: 'asks' }
731
1317
  given = s
732
1318
  } else if (s.state === 'asks') s = { ...keep, state: 'draft' }
733
1319
  continue
@@ -780,7 +1366,7 @@ export function stateOf(x: ReviewItem, superseded: boolean): ItemState {
780
1366
  break
781
1367
  }
782
1368
  }
783
- // the card that redoes it landed: the work its verdict owed is over
1369
+ // the version that redoes it landed: the work its verdict owed is over
784
1370
  const owed = verdictOf(x)?.status
785
1371
  if (superseded && i.origin.by === 'agent' && s.state === 'claimed' && owed !== undefined) return { ...(s.topic ? { topic: s.topic } : {}), state: 'closed', why: owed }
786
1372
  if (verdictOf(x) === null) {
@@ -790,11 +1376,11 @@ export function stateOf(x: ReviewItem, superseded: boolean): ItemState {
790
1376
  return s
791
1377
  }
792
1378
 
793
- /** a card in work: a draft on a live shot, or an agent's card its latest update calls still broken or better */
1379
+ /** a version in work: a draft on a live shot, or an agent's version its latest update calls still broken or better */
794
1380
  export const inWork = (x: ReviewItem): boolean => stateOf(x, false).state === 'draft'
795
1381
 
796
1382
  /** the states each op leaves from */
797
- const FROM: Record<Exclude<Op, 'seen'>, readonly State[]> = {
1383
+ const FROM: Record<Exclude<Op, 'seen' | 'take' | 'working'>, readonly State[]> = {
798
1384
  dispatch: ['new', 'blocked'],
799
1385
  ask: ['new', 'blocked'],
800
1386
  answer: ['question'],
@@ -815,9 +1401,10 @@ const WORKER_OPS = new Set<Op>(['release', 'blocked', 'fixed', 'done', 'wontfix'
815
1401
 
816
1402
  /** null when `who` may do `op` on an item in state `s`, else why not. The dispatcher (null: nobody holds the role)
817
1403
  * routes, a worker acts on its own claim, the owner answers and may act over a claim. `routed` false: the repo has no
818
- * dispatcher, so a worker takes a new item as it is */
819
- export function allowed(s: ItemState, op: Op, who: string, dispatcher: string | null, routed = true): string | null {
820
- if (op === 'seen') return null
1404
+ * dispatcher, so a worker takes a new item as it is; `holds`: the caller holds the item's thread or is the session of
1405
+ * the lane that does */
1406
+ export function allowed(s: ItemState, op: Op, who: string, dispatcher: string | null, routed = true, holds = false): string | null {
1407
+ if (op === 'seen' || op === 'take' || op === 'working') return op !== 'seen' && who === 'owner' ? `an agent ${op === 'take' ? 'takes a thread' : 'says it is on it'}, never the owner` : null
821
1408
  if (op === 'answer' && who !== 'owner') return 'only the owner answers a question'
822
1409
  if (DISPATCHER_OPS.has(op)) {
823
1410
  if (!routed) return 'this repo routes nothing: its review unit declares no dispatcher'
@@ -826,11 +1413,13 @@ export function allowed(s: ItemState, op: Op, who: string, dispatcher: string |
826
1413
  }
827
1414
  if (!routed && s.state === 'new' && (op === 'claim' || op === 'fixed' || op === 'wontfix')) return op === 'claim' && who === 'owner' ? 'a worker claims, never the owner' : null
828
1415
  if (op === 'claim' && (who === 'owner' || who === dispatcher)) return `a worker claims, never ${who === 'owner' ? 'the owner' : 'the dispatcher'}`
829
- if (WORKER_OPS.has(op) && who !== 'owner' && s.worker !== undefined && s.worker !== who) return `claimed by ${s.worker}, not by ${who}`
1416
+ // `holds`: the caller holds the thread or is its holder's session (review/parties.ts maySee), so a lane's claim never
1417
+ // locks its session out of its own thread
1418
+ if (WORKER_OPS.has(op) && who !== 'owner' && !holds && s.worker !== undefined && s.worker !== who) return `claimed by ${s.worker}, not by ${who}`
830
1419
  if (op === 'claim' && s.state === 'claimed' && s.since !== undefined && s.worker !== who) return `already claimed by ${s.worker}: release it first (--as ${s.worker})`
831
1420
  if (op === 'claim' && s.state === 'blocked' && s.worker !== undefined && s.worker !== who) return `blocked by ${s.worker}, who takes it back (--as ${s.worker}); the dispatcher routes it to another`
832
1421
  if (op === 'claim' && s.state === 'closed' && s.why !== 'rejected' && s.why !== 'approved-with-fix')
833
- return `claim needs open, or a card he answered « fix » or « no », it is closed (${s.why})`
1422
+ return `claim needs open, or a thread he answered « fix » or « no », it is closed (${s.why})`
834
1423
  if (!FROM[op].includes(s.state)) {
835
1424
  if (op === 'claim' && s.state === 'claimed') return `already claimed by ${s.worker ?? 'an agent'}`
836
1425
  if (op === 'claim' && s.state === 'new') return 'not dispatched yet: only the dispatcher sends an item to a topic'
@@ -846,7 +1435,7 @@ export const STALE_CLAIM_MS = 2 * 60 * 60 * 1000
846
1435
  export const isStale = (x: ReviewItem, now: Date): boolean =>
847
1436
  stateOf(x, false).state === 'claimed' && now.getTime() - Date.parse(x.thread.at(-1)?.at ?? x.item.created) > STALE_CLAIM_MS
848
1437
 
849
- /** the lane working on an item now: it claimed it, no later card redoes it, the claim is not stale; `until` is when it
1438
+ /** the lane working on an item now: it claimed it, no later version redoes it, the claim is not stale; `until` is when it
850
1439
  * goes stale with no new message. Null when nobody does */
851
1440
  export function reworkOf(x: ReviewItem, superseded: boolean, now: Date): { lane: string; since: string; until: number } | null {
852
1441
  const s = stateOf(x, superseded)
@@ -858,10 +1447,10 @@ export function reworkOf(x: ReviewItem, superseded: boolean, now: Date): { lane:
858
1447
  /** an item the owner opened for marks only: every message a rating (an empty one is a marks item just opened) */
859
1448
  export const isMarkItem = (x: ReviewItem): boolean => x.item.origin.by === 'owner' && x.item.views.length === 0 && x.thread.every((m) => m.rate !== undefined || m.op === 'seen')
860
1449
 
861
- /** the lane an item belongs to: the lane that made a card, or the one he raised an item to */
1450
+ /** the lane an item belongs to: the lane that made a version, or the one he raised an item to */
862
1451
  export const laneOf = (x: ReviewItem): string | undefined => (x.item.origin.by === 'player' ? undefined : x.item.origin.lane)
863
1452
 
864
- /** what a watch keeps: one session's cards (`--mine`), one lane's items (`--lane`); null keeps all */
1453
+ /** what a watch keeps: one session's items (`--mine`), one lane's items (`--lane`); null keeps all */
865
1454
  export interface WatchFilter {
866
1455
  session: string | null
867
1456
  lane: string | null
@@ -871,81 +1460,44 @@ export interface WatchFilter {
871
1460
  export interface Watcher extends WatchFilter {
872
1461
  pid: number
873
1462
  started: string
1463
+ /** the session that runs it (CLAUDE_CODE_SESSION_ID), whatever it filters on */
1464
+ by?: string
1465
+ /** its heartbeat, rewritten every few seconds while it reads */
1466
+ beat?: string
1467
+ /** one watch of `sk thread watch --house`: it hears every store its session holds threads in, a later one too */
1468
+ house?: true
874
1469
  }
875
1470
 
876
1471
  /** a watch with this filter reads his answers on `x` */
877
- export const coversCard = (f: WatchFilter, x: ReviewItem): boolean =>
1472
+ export const coversItem = (f: WatchFilter, x: ReviewItem): boolean =>
878
1473
  (f.session === null || (x.item.origin.by === 'agent' && x.item.origin.session === f.session)) && (f.lane === null || laneOf(x) === f.lane)
879
1474
 
880
- /** who answers an agent's card, its reply or its seen: the worker of a live claim on it, else the lane that made it,
881
- * else (a card with no lane) the session that sent it. null when `me` is that one, else why not and the way out.
882
- * Another session hearing the verdict (a bare watch) is refused, so it never answers over the maker; a plain approval,
883
- * which owes nothing, anyone marks seen. So does anyone once the maker stopped listening: `heardBy` is the live
884
- * watches of the store, and when none of a lane or of a session covers the card (the lane ended), whoever reads the
885
- * answer marks it seen; a reply stays the maker's. An item he raised, a player's or an auto one: the claim rules decide */
886
- export function notAnswererOf(x: ReviewItem, me: { lane: string | null; session: string | null }, op: 'reply' | 'seen', heardBy?: readonly WatchFilter[]): string | null {
887
- const o = x.item.origin
888
- if (o.by !== 'agent') return null
889
- const s = stateOf(x, false)
890
- if (op === 'seen' && s.state === 'closed' && s.why === 'approved') return null
891
- // a bare watch hears every card and is nobody's own: only a watch of a lane or of a session says the maker listens
892
- if (op === 'seen' && heardBy !== undefined && !heardBy.some((w) => (w.lane !== null || w.session !== null) && coversCard(w, x))) return null
893
- const id = x.item.id
894
- // the way out names claim only where claim takes it
895
- const noClaim = allowed(s, 'claim', me.lane ?? 'agent', null, false)
896
- const takeOver =
897
- noClaim === null
898
- ? `another lane takes it over with sk thread claim ${id} --as <lane>`
899
- : s.state === 'asks' || s.state === 'draft'
900
- ? 'no other lane takes it over before the verdict'
901
- : `no takeover: ${noClaim}`
902
- const claimed = s.state === 'claimed' && s.since !== undefined ? s.worker : undefined
903
- const lane = claimed ?? o.lane
904
- if (lane) return me.lane === lane ? null : `${id} is answered by lane ${lane} (${claimed ? 'its claim' : 'it made the card'}): as that lane, SK_AGENT=${lane} or --as ${lane}; ${takeOver}`
905
- if (!o.session || me.session === o.session) return null
906
- return `${id} is answered by the session that sent it (${o.session.slice(0, 8)}): ${takeOver}`
907
- }
908
-
909
- /** the live watchers that will read his answer on any of these cards */
910
- export const listenersOf = (cards: readonly ReviewItem[], watchers: readonly Watcher[]): Watcher[] => watchers.filter((w) => cards.some((x) => coversCard(w, x)))
911
-
912
- /** who listens, in plain words: one lane's watch by its lane, any other by « an agent », several by their count */
913
- export function listenWords(ws: readonly Watcher[]): string {
914
- if (ws.length === 0) return 'nobody listens'
915
- // a filtered watch is the card's own (its session or its lane); a bare one hears every card, for the dispatcher
916
- const own = ws.filter((w) => w.lane !== null || w.session !== null)
917
- const bare = ws.length - own.length
918
- if (own.length === 0) return 'only a watch of every card hears it'
919
- const lane = own.find((w) => w.lane !== null)?.lane
920
- const head = lane ? `the ${lane} lane is listening` : 'its agent is listening'
921
- return bare === 0 ? head : `${head} · ${bare} more ${bare === 1 ? 'watches' : 'watch'} every card`
922
- }
923
-
924
1475
  /** why a bare watch may not start: another one lives in the repo, so a verdict would reach two sessions. null when
925
- * none does. A repo keeps one, the dispatcher's; every other session watches its own cards or its lane's */
1476
+ * none does. A repo keeps one, the dispatcher's; every other session watches its own items or its lane's */
926
1477
  export function bareWatchTaken(live: readonly Watcher[], self: number): string | null {
927
1478
  const other = live.find((w) => w.pid !== self && w.lane === null && w.session === null)
928
- return other ? `a watch of every card already runs (pid ${other.pid}): a repo keeps one, the dispatcher's. Yours: sk thread watch --mine, or --lane <id>` : null
1479
+ return other ? `a watch of every thread already runs (pid ${other.pid}): a repo keeps one, the dispatcher's. Yours: sk thread watch --mine, or --lane <id>` : null
929
1480
  }
930
1481
 
931
- /** what `review add` says when no live watch of the card's own session or lane will read his answer, else null: an
1482
+ /** what `review add` says when no live watch of the item's own session or lane will read his answer, else null: an
932
1483
  * unfiltered watch (a dispatcher, another session) hears it for someone else */
933
1484
  export function unheardLine(item: Item, watchers: readonly Watcher[]): string | null {
934
1485
  const o = item.origin
935
1486
  if (o.by !== 'agent') return null
936
1487
  const own = o.session || o.lane ? watchers.filter((w) => (o.session && w.session === o.session) || (o.lane && w.lane === o.lane)) : watchers
937
- if (listenersOf([{ item, thread: [] }], own).length > 0) return null
1488
+ if (own.some((w) => coversItem(w, { item, thread: [] }))) return null
938
1489
  const watch = o.session ? 'sk thread watch --mine' : o.lane ? `sk thread watch --lane ${o.lane}` : 'sk thread watch'
939
- return `no watch hears this card: run \`${watch}\` under a monitor now, so his answer reaches you as it lands`
1490
+ return `no watch hears this thread: run \`${watch}\` under a monitor now, so his answer reaches you as it lands`
940
1491
  }
941
1492
 
942
- /** a card's own session has this long after its last message to claim it before a watch calls it untaken */
1493
+ /** an item's own session has this long after its last message to claim it before a watch calls it untaken */
943
1494
  export const UNTAKEN_GRACE_MS = 2 * 60 * 1000
944
- /** a card nobody takes is told again this often */
1495
+ /** an item nobody takes is told again this often */
945
1496
  export const UNTAKEN_AGAIN_MS = STALE_CLAIM_MS
946
1497
 
947
- /** why an item waits on the agents and nobody holds it, else null; `superseded`: a later card follows it */
948
- export function untakenOf(x: ReviewItem, superseded: boolean, watchers: readonly Watcher[], now: Date, routed = true): string | null {
1498
+ /** why an item waits on the agents and nobody holds it, else null; `superseded`: a later version follows it; `heard`: a
1499
+ * live watch hears its thread's holder (threads.ts listenersOf) */
1500
+ export function untakenOf(x: ReviewItem, superseded: boolean, heard: boolean, now: Date, routed = true): string | null {
949
1501
  if (superseded) return null
950
1502
  const quiet = now.getTime() - Date.parse(x.thread.at(-1)?.at ?? x.item.created)
951
1503
  if (quiet < UNTAKEN_GRACE_MS) return null
@@ -956,19 +1508,19 @@ export function untakenOf(x: ReviewItem, superseded: boolean, watchers: readonly
956
1508
  if (s.since !== undefined) return quiet > STALE_CLAIM_MS ? `${s.worker ?? 'its'} claim went stale` : null
957
1509
  // an agent read the verdict: the work it owes is taken, only not done yet
958
1510
  if (verdictOf(x)?.seen) return null
959
- return listenersOf([x], watchers).length === 0 ? `the owner's verdict went back to ${s.worker ?? 'its author'}, and no watch reads it` : null
1511
+ return !heard ? `the owner's verdict went back to ${s.worker ?? 'its author'}, and no watch reads it` : null
960
1512
  }
961
1513
 
962
1514
  export const ID_RE = /^\d{8}-\d{6}-[a-z0-9-]+$/
963
1515
 
964
1516
  const addressList = (v: unknown): boolean => Array.isArray(v) && v.length > 0 && v.every((a) => typeof a === 'string' && ADDRESS_RE.test(a))
965
- export const FILE_RE = /^((v\d+-)?((image|before|after|poster|wave|before-wave)\.(png|jpe?g|webp)|(video|before|after)\.(webm|mp4)|(audio|before|after)\.(wav|mp3|flac|ogg|opus|m4a))|v\d+-g\d+(-before)?\.(png|jpe?g|webp))$/
1517
+ export const FILE_RE = /^((v\d+-)?((image|before|after|poster|wave|before-wave)\.(png|jpe?g|webp)|(video|before|after)\.(webm|mp4)|(audio|before|after)\.(wav|mp3|flac|ogg|opus|m4a)|space\.(ply|spz|glb))|v\d+-g\d+(-before)?\.(png|jpe?g|webp))$/
966
1518
  /** a message's image as an item's media names it: `thread/<file>` */
967
- export const isThreadMedia = (n: string): boolean => n.startsWith('thread/') && MESSAGE_FILE_RE.test(n.slice('thread/'.length))
1519
+ export const isThreadMedia = (n: string): boolean => n.startsWith('thread/') && (MESSAGE_FILE_RE.test(n.slice('thread/'.length)) || MESSAGE_ATTACH_RE.test(n.slice('thread/'.length)))
968
1520
  /** a name an item's media may hold: a view's file or a message's image */
969
1521
  export const isMediaName = (n: string): boolean => FILE_RE.test(n) || isThreadMedia(n)
970
1522
  /** every file of an item the media store keeps: its views' files, then its messages' images */
971
- export const mediaFilesOf = (x: { item: Item; thread: readonly Message[] }): string[] => [...viewFilesOf(x.item), ...x.thread.flatMap((m) => (m.image ? [`thread/${m.image}`] : []))]
1523
+ export const mediaFilesOf = (x: { item: Item; thread: readonly Message[] }): string[] => [...viewFilesOf(x.item), ...x.thread.flatMap((m) => [...(m.image ? [`thread/${m.image}`] : []), ...(m.files ?? []).map((f) => `thread/${f.file}`)])]
972
1524
  /** the message images an item's media already holds: a rewrite of its views keeps their facts */
973
1525
  export const threadMediaOf = (i: Item): string[] => Object.keys(i.media ?? {}).filter(isThreadMedia)
974
1526
  const TILE_RE = /^v\d+-g\d+\.(png|jpe?g|webp)$/
@@ -985,34 +1537,17 @@ const WAVE_RE = /^(v\d+-)?(wave|before-wave)\.png$/
985
1537
 
986
1538
  export const isPair = (f: ReviewFiles): f is { before: string; after: string } => 'before' in f
987
1539
 
988
- /** what a card is about, as the list and the CLI name it: its topic, then its subject (once when they say the same) */
1540
+ /** what an item is about, as the list and the CLI name it: its topic, then its subject (once when they say the same).
1541
+ * The default subject (`shot`) names no kind of its own: an item on an address reads as that address's kind */
989
1542
  export function aboutText(i: Item, spec: Spec = NO_SPEC): string {
990
- const subject = subjectLabel(i.subject.kind, spec)
1543
+ const own = i.subject.kind === 'shot' && i.on !== undefined ? canonicalAddress(i.on) : null
1544
+ const subject = subjectLabel(own !== null ? own.slice(0, own.indexOf(':')) : i.subject.kind, spec)
991
1545
  const topic = i.topic ? topicLabel(i.topic, spec) : subject
992
1546
  return topic === subject ? subject : `${topic} · ${subject}`
993
1547
  }
994
1548
 
995
- /** the lowercase ascii words of a title */
996
- export const wordsOf = (title: string): string[] =>
997
- title
998
- .normalize('NFD')
999
- .replace(/\p{M}/gu, '')
1000
- .toLowerCase()
1001
- .split(/[^a-z0-9]+/)
1002
- .filter((w) => w !== '')
1003
-
1004
- /** the lowercase ascii words of a title, for the id, cut on a word */
1005
- function slugOf(title: string): string {
1006
- let s = ''
1007
- for (const w of wordsOf(title)) {
1008
- if (s && s.length + 1 + w.length > 40) break
1009
- s = s ? `${s}-${w}` : w.slice(0, 40)
1010
- }
1011
- return s || 'request'
1012
- }
1013
-
1014
1549
  /** `YYYYMMDD-HHMMSS-<slug>`, local time */
1015
- export const idOf = (at: Date, title: string): string => `${stampOf(at)}-${slugOf(title)}`
1550
+ export const idOf = (at: Date, title: string): string => `${stampOf(at)}-${slugOf(title, { max: 40 }) || 'request'}`
1016
1551
 
1017
1552
  const obj = (v: unknown): v is Record<string, unknown> => typeof v === 'object' && v !== null && !Array.isArray(v)
1018
1553
  const unit = (n: unknown): n is number => typeof n === 'number' && Number.isFinite(n) && n >= 0 && n <= 1
@@ -1024,10 +1559,10 @@ function subjectProblems(s: unknown, spec: Spec): string[] {
1024
1559
  if (!obj(s) || typeof s.kind !== 'string' || s.kind === '') return ['subject: { kind }']
1025
1560
  const kind = spec.kinds[s.kind]
1026
1561
  const declared = Object.keys(spec.kinds)
1027
- if (!kind && !BUILTIN_KINDS[s.kind] && declared.length > 0) return [`subject: kind « ${s.kind} » is none of ${[...declared, ...Object.keys(BUILTIN_KINDS)].join(', ')}`]
1562
+ if (!kind && !BUILTIN_KINDS[s.kind] && declared.length > 0) return [`subject: kind « ${s.kind} » is none of ${[...new Set([...declared, ...Object.keys(BUILTIN_KINDS)])].join(', ')}`]
1028
1563
  if (kind?.problems) return kind.problems(s as Subject).map((p) => `subject: ${p}`)
1029
1564
  if (s.kind === 'store' && !kind) return isStoreSubject(s as Subject) && s.store !== '' && s.asset !== '' ? [] : ['subject: a store thing has its store and asset']
1030
- if (s.kind === 'post' && !kind) return isPostSubject(s as Subject) ? [] : ['subject: a post request names its card']
1565
+ if (s.kind === 'post' && !kind) return isPostSubject(s as Subject) ? [] : ['subject: a post request names its thread']
1031
1566
  if (s.kind === 'object') return typeof s.address === 'string' && ADDRESS_RE.test(s.address) ? [] : ['subject: an object names its address <kind>:<key>']
1032
1567
  if (s.kind !== 'frame') return []
1033
1568
  const str = (k: string): boolean => typeof s[k] === 'string' && s[k] !== ''
@@ -1056,18 +1591,23 @@ function originProblems(o: unknown): string[] {
1056
1591
  return ['origin.by: agent, owner, player or auto']
1057
1592
  }
1058
1593
 
1059
- function draftCardProblems(d: unknown): string[] {
1594
+ function draftItemProblems(d: unknown): string[] {
1060
1595
  const text = (v: unknown): boolean => typeof v === 'string' && v !== ''
1061
1596
  if (!obj(d) || !text(d.slug) || !text(d.hash) || !Array.isArray(d.posts)) return ['draft: { slug, hash, posts: [{ key, name, hash }] }']
1062
1597
  const out: string[] = []
1063
1598
  d.posts.forEach((p: unknown, k: number) => {
1064
1599
  if (!obj(p) || typeof p.key !== 'string' || !POST_KEY.test(p.key) || !text(p.name) || !text(p.hash)) out.push(`draft.posts[${k}]: { key: <account>[/<name>], name, hash }`)
1600
+ else if (p.state !== undefined && p.state !== 'posted' && p.state !== 'dropped') out.push(`draft.posts[${k}].state: posted or dropped`)
1601
+ else if (p.words !== undefined && !(obj(p.words) && typeof p.words.body === 'string' && Object.entries(p.words).every(([f, v]) => (DRAFT_FIELDS as readonly string[]).includes(f) && typeof v === 'string')))
1602
+ out.push(`draft.posts[${k}].words: { body, title?, tags?, media?, place? }, each a text`)
1065
1603
  })
1604
+ if (d.head !== undefined && !(obj(d.head) && typeof d.head.title === 'string' && (d.head.angle === undefined || typeof d.head.angle === 'string'))) out.push('draft.head: { title, angle? }')
1605
+ if (d.by !== undefined && !text(d.by)) out.push('draft.by: who saved it')
1066
1606
  if (d.posts.length === 0) out.push('draft.posts: one message or more')
1067
1607
  return out
1068
1608
  }
1069
1609
 
1070
- function trailerCardProblems(t: unknown): string[] {
1610
+ function trailerItemProblems(t: unknown): string[] {
1071
1611
  const side = (v: unknown): boolean => obj(v) && typeof v.cut === 'string' && v.cut !== '' && typeof v.render === 'number' && Number.isFinite(v.render)
1072
1612
  if (!obj(t) || typeof t.trailer !== 'string' || t.trailer === '' || !side(t.after)) return ['trailer: { trailer, after: { cut, render }, before?, shots }']
1073
1613
  const out: string[] = []
@@ -1087,8 +1627,8 @@ export function itemProblems(v: unknown): string[] {
1087
1627
  out.push(...subjectProblems(v.subject, NO_SPEC), ...originProblems(v.origin))
1088
1628
  if (v.topic !== undefined && typeof v.topic !== 'string') out.push('topic: a text')
1089
1629
  const agent = obj(v.origin) && v.origin.by === 'agent'
1090
- // a draft card holds no picture: its body is the draft, read live
1091
- const needsView = agent && v.draft === undefined
1630
+ // a draft version holds no picture: its body is the draft, read live; a thread opened with words names its address
1631
+ const needsView = agent && v.draft === undefined && v.on === undefined && v.states === undefined && v.doc === undefined
1092
1632
  if (!Array.isArray(v.views) || (needsView && v.views.length === 0)) out.push(`views: a list${needsView ? ' of one view or more' : ''}`)
1093
1633
  else
1094
1634
  v.views.forEach((w: unknown, i: number) => {
@@ -1097,6 +1637,12 @@ export function itemProblems(v: unknown): string[] {
1097
1637
  else out.push(...viewProblems(obj(w) ? w : {}, `views[${i}].`))
1098
1638
  })
1099
1639
  if (v.about !== undefined && !addressList(v.about)) out.push('about: a list of addresses <kind>:<key>')
1640
+ const stateOk = (x: unknown): boolean => obj(x) && 'json' in x && (x.at === undefined || typeof x.at === 'string') && (x.files === undefined || (obj(x.files) && Object.values(x.files).every((f) => typeof f === 'string')))
1641
+ if (v.states !== undefined && !(obj(v.states) && stateOk(v.states.after) && (v.states.before === undefined || stateOk(v.states.before)) && typeof v.on === 'string')) out.push('states: { before?, after }, each { json, files?, at? }, on a version that names its object (on)')
1642
+ if (obj(v.states)) for (const side of ['before', 'after'] as const) if (obj(v.states[side]) && v.states[side].views !== undefined && !kindViewsOk(v.states[side].views)) out.push(`states.${side}.views: a list of { id, label }, each id once`)
1643
+ const stillOk = (x: unknown): boolean => obj(x) && obj(x.files) && obj(x.size) && Object.values(x.files).length > 0 && Object.values(x.files).every((f) => typeof f === 'string' && FILE_RE.test(f))
1644
+ if (obj(v.states) && v.states.still !== undefined && !stillOk(v.states.still)) out.push('states.still: { files: { image } | { before, after }, size }, files of its folder')
1645
+ if (v.saved !== undefined && !(obj(v.saved) && typeof v.saved.by === 'string' && v.saved.by !== '' && v.states !== undefined)) out.push('saved: { by }, on a version that holds its states')
1100
1646
  if (v.on !== undefined && !(typeof v.on === 'string' && ADDRESS_RE.test(v.on))) out.push('on: an address <kind>:<key>')
1101
1647
  if (v.answers !== undefined && !(Array.isArray(v.answers) && v.answers.length > 0 && v.answers.every((a) => typeof a === 'string' && ID_RE.test(a))))
1102
1648
  out.push('answers: a list of item ids')
@@ -1105,11 +1651,19 @@ export function itemProblems(v: unknown): string[] {
1105
1651
  out.push('changelog: { category, line, rating? }, or absent')
1106
1652
  if (v.light !== undefined && v.light !== 'review') out.push('light: review, or absent')
1107
1653
  if (v.wip !== undefined && !(obj(v.wip) && typeof v.wip.live === 'string' && v.wip.live !== '' && Number.isInteger(v.wip.frame))) out.push('wip: { live, frame }, or absent')
1108
- if (v.trailer !== undefined) out.push(...trailerCardProblems(v.trailer))
1109
- if (v.draft !== undefined) out.push(...draftCardProblems(v.draft))
1110
- if (v.choice !== undefined && !(v.choice === true && Array.isArray(v.views) && v.views.length >= 2)) out.push('choice: true on a card of two views or more, or absent')
1654
+ if (v.trailer !== undefined) out.push(...trailerItemProblems(v.trailer))
1655
+ if (v.draft !== undefined) out.push(...draftItemProblems(v.draft))
1656
+ if (v.doc !== undefined) {
1657
+ const p = docProblem(v.doc)
1658
+ if (p !== null) out.push(p)
1659
+ }
1660
+ if (v.choice !== undefined && !(v.choice === true && Array.isArray(v.views) && v.views.length >= 2)) out.push('choice: true on a version of two views or more, or absent')
1111
1661
  if (v.agentPick !== undefined && !(v.choice === true && Number.isInteger(v.agentPick) && Array.isArray(v.views) && (v.agentPick as number) >= 0 && (v.agentPick as number) < v.views.length))
1112
- out.push('agentPick: the index of one of its views, on a choice card, or absent')
1662
+ out.push('agentPick: the index of one of its views, on a choice version, or absent')
1663
+ if (v.ask !== undefined) {
1664
+ out.push(...askHeadProblems(v.ask))
1665
+ if (!(typeof v.on === 'string' && v.on.startsWith('ask:'))) out.push('ask: on the head of a thread ask:<id>')
1666
+ }
1113
1667
  if (v.media !== undefined) {
1114
1668
  if (!obj(v.media)) out.push('media: { <file name>: { sha, size, type } }, or absent')
1115
1669
  else
@@ -1130,6 +1684,8 @@ export function messageProblems(v: unknown, name: string): string[] {
1130
1684
  if (v.op !== undefined && !OPS.includes(v.op as Op)) out.push(`op: one of ${OPS.join(', ')}`)
1131
1685
  if (v.verdict !== undefined && !STATUSES.includes(v.verdict as ReviewStatus)) out.push(`verdict: one of ${STATUSES.join(', ')}`)
1132
1686
  for (const k of ['text', 'image', 'note']) if (v[k] !== undefined && typeof v[k] !== 'string') out.push(`${k}: a text`)
1687
+ if (v.files !== undefined && !(Array.isArray(v.files) && v.files.length >= 1 && v.files.length <= MESSAGE_FILES_MAX && v.files.every((f, i) => !fileProblem(f, name, i))))
1688
+ out.push(`files: 1 to ${MESSAGE_FILES_MAX} of { file: <id>-f<n>.<ext> in order, name: a clean file name, size, type }`)
1133
1689
  if (v.pick !== undefined && !(Number.isInteger(v.pick) && (v.pick as number) >= 0 && v.verdict !== undefined)) out.push('pick: a view index, on a verdict')
1134
1690
  if (v.op === 'seen' && !(Array.isArray(v.of) && v.of.every((x) => typeof x === 'string'))) out.push('of: the ids a seen message read')
1135
1691
  if (v.update !== undefined) {
@@ -1139,29 +1695,88 @@ export function messageProblems(v: unknown, name: string): string[] {
1139
1695
  if (typeof v.text !== 'string') out.push('update: its line in text')
1140
1696
  }
1141
1697
  if (v.re !== undefined && !(typeof v.re === 'string' && MESSAGE_RE.test(v.re))) out.push('re: the id of a message of the thread')
1698
+ if (v.step !== undefined && !(obj(v.step) && typeof v.step.of === 'string' && MESSAGE_RE.test(v.step.of) && Number.isInteger(v.step.i) && (v.step.i as number) >= 0 && (v.step.carries === undefined || (typeof v.step.carries === 'string' && MESSAGE_RE.test(v.step.carries))) && v.ask !== undefined))
1699
+ out.push("step: { of: an instructions message id, i: its step, carries?: a question's id }, on a question")
1142
1700
  if (v.session !== undefined && typeof v.session !== 'string') out.push('session: a text')
1143
1701
  if (v.about !== undefined && !addressList(v.about)) out.push('about: a list of addresses <kind>:<key>')
1144
1702
  if (v.ask !== undefined) {
1145
1703
  const a = v.ask
1146
- if (!obj(a) || !Array.isArray(a.options) || a.options.length < 2 || !a.options.every((o) => typeof o === 'string' && o.trim() !== '') || (a.pick !== undefined && !(Number.isInteger(a.pick) && (a.pick as number) >= 0 && (a.pick as number) < a.options.length)))
1147
- out.push('ask: { options: two texts or more, pick?: an option index }')
1704
+ const index = (x: unknown): boolean => Number.isInteger(x) && (x as number) >= 0
1705
+ const kind = obj(a) ? (a.kind ?? 'choice') : null
1706
+ const texts = obj(a) && Array.isArray(a.options) && a.options.every((o) => typeof o === 'string' && o.trim() !== '')
1707
+ if (!obj(a) || !ANSWER_KINDS.includes(kind as AnswerKind)) out.push(`ask: kind, one of ${ANSWER_KINDS.join(', ')}`)
1708
+ else if (kind === 'choice') {
1709
+ if (!texts || (a.options as unknown[]).length < 2 || (a.pick !== undefined && !(index(a.pick) && (a.pick as number) < (a.options as unknown[]).length)))
1710
+ out.push('ask: { options: two texts or more, pick?: an option index }')
1711
+ else if (a.views !== undefined && !(Array.isArray(a.views) && a.views.length === (a.options as unknown[]).length && a.views.every((x) => x === null || index(x)))) out.push('ask: views, one view index or null an option')
1712
+ } else if (kind === 'checklist') {
1713
+ if (!texts || (a.options as unknown[]).length < 1 || (a.done !== undefined && !(Array.isArray(a.done) && a.done.every((x) => index(x) && (x as number) < (a.options as unknown[]).length))))
1714
+ out.push('ask: a checklist, { options: its lines, one or more, done?: line indexes }')
1715
+ else if (a.choices !== undefined && !(Array.isArray(a.choices) && a.choices.length === (a.options as unknown[]).length && v.instructions !== undefined && a.choices.every((c) => c === null || (obj(c) && Array.isArray(c.options) && c.options.length >= 2 && c.options.every((o) => typeof o === 'string' && o.trim() !== '') && (c.pick === undefined || (index(c.pick) && (c.pick as number) < c.options.length))))))
1716
+ out.push("ask: choices, an instructions' steps only, one { options: two texts or more, pick? } or null a step")
1717
+ } else if (!(Array.isArray(a.options) && a.options.length === 0)) out.push(`ask: a ${kind} question holds no options`)
1718
+ if (kind === 'secret' && !(obj(a) && obj(a.secret) && typeof a.secret.name === 'string' && SECRET_NAME.test(a.secret.name) && (a.secret.login === undefined || a.secret.login === true)))
1719
+ out.push('ask: a secret question names its secret, { secret: { name, login? } }')
1148
1720
  if (typeof v.text !== 'string') out.push('ask: its question in text')
1149
1721
  }
1150
1722
  if (v.propose !== undefined) {
1151
1723
  const p = v.propose
1152
- if (!obj(p) || typeof p.on !== 'string' || !ADDRESS_RE.test(p.on) || typeof p.after !== 'string' || (p.before !== undefined && typeof p.before !== 'string')) out.push('propose: { on: an address, before?, after }')
1724
+ const field = (f: unknown, flat: boolean): boolean =>
1725
+ obj(f) &&
1726
+ (flat || (typeof f.key === 'string' && f.key.trim() !== '')) &&
1727
+ typeof f.after === 'string' &&
1728
+ (f.before === undefined || typeof f.before === 'string') &&
1729
+ (f.type === undefined || DIFF_TYPES.includes(f.type as DiffType)) &&
1730
+ (f.lang === undefined || typeof f.lang === 'string') &&
1731
+ (f.view === undefined || (Number.isInteger(f.view) && (f.view as number) >= 0))
1732
+ const keys = obj(p) && Array.isArray(p.fields) ? p.fields.map((f) => (obj(f) ? f.key : null)) : []
1733
+ if (!obj(p) || typeof p.on !== 'string' || !ADDRESS_RE.test(p.on) || !field(p, true) || (p.page !== undefined && typeof p.page !== 'string')) out.push('propose: { on: an address, before?, after, type?, lang?, view?, page? }')
1734
+ else if (p.fields !== undefined && !(Array.isArray(p.fields) && p.fields.length >= 1 && (p.fields.length >= 2 || keys[0] !== '') && p.fields.every((f) => field(f, false)) && new Set(keys).size === keys.length))
1735
+ out.push('propose: fields, one named or two or more, each { key, before?, after, type?, lang?, view? }, each key once')
1153
1736
  if (typeof v.text !== 'string') out.push('propose: its words in text')
1154
1737
  }
1738
+ if (v.askState !== undefined && !(obj(v.askState) && (ASK_STATES as readonly string[]).includes(v.askState.state as string) && (v.askState.why === undefined || typeof v.askState.why === 'string') && (v.askState.state === 'merged' ? typeof v.askState.into === 'string' && v.askState.into !== '' : v.askState.into === undefined)))
1739
+ out.push(`askState: { state: ${ASK_STATES.join(', ')}, why?, into: the ask's id on a merged one only }`)
1740
+ if (v.snooze !== undefined && !(obj(v.snooze) && (v.snooze.until === null || (typeof v.snooze.until === 'string' && !Number.isNaN(Date.parse(v.snooze.until)))))) out.push('snooze: { until: an ISO time, or null }')
1741
+ if (v.urgent !== undefined && v.urgent !== true) out.push('urgent: true')
1742
+ if (v.carried !== undefined && !(obj(v.carried) && typeof v.carried.from === 'string' && v.carried.from !== '' && typeof v.carried.at === 'string' && v.answer !== undefined)) out.push('carried: { from: an ask id, at: an ISO time }, on an answer only')
1743
+ if (v.edit !== undefined && !(obj(v.edit) && typeof v.edit.of === 'string' && v.edit.of !== '' && Array.isArray(v.edit.diff) && v.edit.diff.every((l) => typeof l === 'string') && (v.edit.base === undefined || typeof v.edit.base === 'string') && (v.edit.folds === undefined || (typeof v.edit.folds === 'string' && v.edit.folds !== '')) && v.who === 'owner' && typeof v.text === 'string'))
1744
+ out.push("edit: { of: a version's id, diff: its changed lines, base?: the text before, folds?: the edit it takes the place of }, the owner's, its line in text")
1745
+ if (v.action !== undefined && !(obj(v.action) && typeof v.action.name === 'string' && /^[a-z][a-z0-9-]*$/.test(v.action.name))) out.push('action: { name: a lowercase word }')
1746
+ if (v.act !== undefined && !(obj(v.act) && typeof v.act.name === 'string' && /^[a-z][a-z0-9-]*$/.test(v.act.name) && (v.act.post === undefined || (typeof v.act.post === 'string' && POST_KEY.test(v.act.post))) && (v.act.url === undefined || typeof v.act.url === 'string') && (v.act.undo === undefined || v.act.undo === true)))
1747
+ out.push('act: { name: a lowercase word, post?: <account>[/<name>], url?, undo?: true }')
1155
1748
  if (v.answer !== undefined) {
1156
1749
  const a = v.answer
1157
- if (!obj(a) || (a.option === undefined && a.apply !== true) || (a.option !== undefined && !(Number.isInteger(a.option) && (a.option as number) >= 0)) || (a.apply !== undefined && a.apply !== true)) out.push('answer: { option } or { apply: true }')
1750
+ const says = obj(a) && (a.option !== undefined || a.apply === true || typeof a.value === 'string' || typeof a.stored === 'string' || a.view !== undefined)
1751
+ if (!obj(a) || !says || (a.option !== undefined && !(Number.isInteger(a.option) && (a.option as number) >= 0)) || (a.apply !== undefined && a.apply !== true) || (a.field !== undefined && typeof a.field !== 'string') || (a.value !== undefined && typeof a.value !== 'string')
1752
+ || (a.tick !== undefined && !(typeof a.tick === 'boolean' && a.option !== undefined)) || (a.pick !== undefined && !(Number.isInteger(a.pick) && (a.pick as number) >= 0 && a.tick === true)) || (a.opens !== undefined && !(Number.isInteger(a.opens) && (a.opens as number) >= 0)) || (a.stored !== undefined && !(typeof a.stored === 'string' && SECRET_NAME.test(a.stored))) || (a.view !== undefined && !(Number.isInteger(a.view) && (a.view as number) >= 0)))
1753
+ out.push('answer: { option, tick? }, { apply: true, field?, value? }, { value, opens? }, { stored } or { view }')
1158
1754
  if (typeof v.re !== 'string') out.push('answer: the question or proposal it answers in re')
1159
1755
  }
1160
- if (v.op === undefined && v.verdict === undefined && v.rate === undefined && typeof v.text !== 'string' && !Array.isArray(v.rects))
1756
+ if (v.replaces !== undefined && !(typeof v.replaces === 'string' && MESSAGE_RE.test(v.replaces))) out.push('replaces: the id of a message of the thread')
1757
+ if (v.hold !== undefined && !(obj(v.hold) && typeof v.hold.address === 'string' && typeof v.hold.held === 'boolean' && (v.hold.sha === undefined || typeof v.hold.sha === 'string') && (v.hold.ahead === undefined || typeof v.hold.ahead === 'number') && typeof v.text === 'string')) out.push('hold: { address, held, sha?, ahead? } and its words in text')
1758
+ if (v.laneAsk !== undefined && !(obj(v.laneAsk) && typeof v.laneAsk.for === 'string' && (v.laneAsk.session === undefined || typeof v.laneAsk.session === 'string') && v.who === 'owner')) out.push("laneAsk: { for, session? }, the owner's")
1759
+ if (v.unhold !== undefined && !(Array.isArray(v.unhold) && v.unhold.length > 0 && v.unhold.every((a) => typeof a === 'string'))) out.push('unhold: the addresses it releases')
1760
+ if (v.askBar !== undefined && !(Array.isArray(v.askBar) && v.askBar.length > 0 && v.askBar.every((f) => typeof f === 'string' && MESSAGE_RE.test(f)))) out.push('askBar: the ids of messages of the thread')
1761
+ if (v.instructions !== undefined) {
1762
+ const i = v.instructions
1763
+ if (!obj(i) || typeof i.title !== 'string' || i.title.trim() === '' || !(Array.isArray(i.folds) && i.folds.every((f) => typeof f === 'string' && MESSAGE_RE.test(f)))) out.push('instructions: { title, ask, folds: message ids }')
1764
+ else if (!obj(i.ask) || 'created' in i.ask || 'pinged' in i.ask) out.push("instructions.ask: the facts, never the head's day or ping")
1765
+ else out.push(...askHeadProblems({ ...i.ask, created: '2000-01-01' }).map((p) => `instructions.${p}`))
1766
+ if (typeof v.text !== 'string') out.push('instructions: its words in text')
1767
+ if (v.replaces !== undefined) out.push('instructions: superseded by order, never by replaces')
1768
+ }
1769
+ if (v.to !== undefined && !(Array.isArray(v.to) && v.to.length > 0 && v.to.every(mentionOk) && typeof v.text === 'string' && v.who === 'owner')) out.push("to: the owner's words, one or more { name, lane, session? }, { name, session } or { name, advisor }")
1770
+ if (v.mute !== undefined && !(typeof v.mute === 'boolean' && v.who === 'owner')) out.push("mute: true or false, the owner's")
1771
+ if (v.op === undefined && v.verdict === undefined && v.rate === undefined && typeof v.text !== 'string' && !Array.isArray(v.rects) && v.snooze === undefined && v.askState === undefined && v.urgent === undefined && v.askBar === undefined && v.unhold === undefined && v.laneAsk === undefined && v.act === undefined && v.mute === undefined)
1161
1772
  out.push('a message says something: text, rects, verdict, rate or op')
1162
1773
  return out
1163
1774
  }
1164
1775
 
1776
+ const word = (x: unknown): boolean => typeof x === 'string' && x !== ''
1777
+ const mentionOk = (m: unknown): boolean =>
1778
+ obj(m) && word(m.name) && (m.advisor !== undefined ? word(m.advisor) && m.lane === undefined && m.session === undefined : m.lane !== undefined ? word(m.lane) && (m.session === undefined || word(m.session)) : word(m.session))
1779
+
1165
1780
  /** what is wrong with a gallery view: at least one image tile, each its file, its label and its size, and no media field */
1166
1781
  function galleryProblems(v: Record<string, unknown>, at: string): string[] {
1167
1782
  const g = v.gallery
@@ -1172,16 +1787,25 @@ function galleryProblems(v: Record<string, unknown>, at: string): string[] {
1172
1787
  if (!ok) out.push(`${at}gallery[${k}]: { file: v<n>-g<k>.<png|jpg|webp>, label, size: { w, h } }`)
1173
1788
  if (obj(t) && t.before !== undefined && !(typeof t.before === 'string' && TILE_BEFORE_RE.test(t.before))) out.push(`${at}gallery[${k}].before: v<n>-g<k>-before.<png|jpg|webp>`)
1174
1789
  if (obj(t) && t.group !== undefined && !(typeof t.group === 'string' && t.group.trim() !== '')) out.push(`${at}gallery[${k}].group: a text`)
1790
+ if (obj(t) && t.view !== undefined && !(typeof t.view === 'string' && KIND_VIEW_RE.test(t.view))) out.push(`${at}gallery[${k}].view: a view's id, letters, digits, - and _`)
1175
1791
  })
1176
1792
  for (const k of ['files', 'size', 'clip', 'marks']) if (v[k] !== undefined) out.push(`${at}${k}: none on a gallery view`)
1177
1793
  return out
1178
1794
  }
1179
1795
 
1796
+ /** a state's views: each { id, label }, the id a frame key value, each once */
1797
+ function kindViewsOk(x: unknown): boolean {
1798
+ if (!Array.isArray(x) || x.length === 0) return false
1799
+ const ids = x.map((v: unknown) => (obj(v) && typeof v.id === 'string' && KIND_VIEW_RE.test(v.id) && typeof v.label === 'string' && v.label.trim() !== '' ? v.id : null))
1800
+ return ids.every((id) => id !== null) && new Set(ids).size === ids.length
1801
+ }
1802
+
1180
1803
  /** what is wrong with one view's files, size and marks, each reason under `at` */
1181
1804
  function viewProblems(v: Record<string, unknown>, at: string): string[] {
1182
1805
  const out: string[] = []
1183
1806
  if (typeof v.label !== 'string') out.push(`${at}label: a text`)
1184
1807
  if (v.note !== undefined && typeof v.note !== 'string') out.push(`${at}note: a text`)
1808
+ if (v.message !== undefined && v.message !== true) out.push(`${at}message: true or absent`)
1185
1809
  const f = v.files
1186
1810
  const okImage = (n: unknown): boolean => typeof n === 'string' && FILE_RE.test(n) && !isClipFile(n) && !isAudioFile(n)
1187
1811
  const okClip = (n: unknown): boolean => typeof n === 'string' && FILE_RE.test(n) && isClipFile(n)
@@ -1204,6 +1828,14 @@ function viewProblems(v: Record<string, unknown>, at: string): string[] {
1204
1828
  if (!obj(c) || typeof c.poster !== 'string' || !POSTER_RE.test(c.poster) || !(Number(c.duration) > 0) || !(Number(c.fps) > 0)) out.push(`${at}clip: { poster, duration, fps } on a clip`)
1205
1829
  if (v.marks !== undefined) out.push(`${at}marks: none on a clip`)
1206
1830
  } else if (c !== undefined) out.push(`${at}clip: only on a clip`)
1831
+ const sc = v.scene
1832
+ if (sc !== undefined) {
1833
+ if (!obj(sc) || !SCENE_KINDS.includes(sc.kind as ReviewScene['kind'])) out.push(`${at}scene: { kind } of ${SCENE_KINDS.join(', ')}`)
1834
+ else if (sc.kind === 'pano' ? sc.file !== undefined : !(typeof sc.file === 'string' && SPACE_RE.test(sc.file) && SPACE_EXT[sc.kind as 'splat' | 'mesh'].test(sc.file)))
1835
+ out.push(sc.kind === 'pano' ? `${at}scene.file: none on a panorama` : `${at}scene.file: space.${sc.kind === 'splat' ? '<ply|spz>' : 'glb'} of its folder`)
1836
+ if (!obj(f) || !okImage(f.image)) out.push(`${at}scene: on one image`)
1837
+ if (v.marks !== undefined) out.push(`${at}marks: none on a scene`)
1838
+ }
1207
1839
  if (v.marks !== undefined) {
1208
1840
  const pair = obj(f) && typeof f.before === 'string'
1209
1841
  const ok =
@@ -1226,16 +1858,16 @@ function viewProblems(v: Record<string, unknown>, at: string): string[] {
1226
1858
  }
1227
1859
 
1228
1860
  /** the verdict the page sends for an item, checked: every rectangle inside its view, a side exactly on a pair */
1229
- /** what a rectangle on a trailer card's frame carries beyond its box: the time on the cut it was drawn at, the shot and
1861
+ /** what a rectangle on a trailer version's frame carries beyond its box: the time on the cut it was drawn at, the shot and
1230
1862
  * the seconds into it, and with a before the render it sits on; null with its errors pushed */
1231
- function trailerRect(r: Record<string, unknown>, t: TrailerCard, i: number, errors: string[]): Pick<Rect, 't' | 'shot' | 'side'> | null {
1863
+ function trailerRect(r: Record<string, unknown>, t: ItemTrailer, i: number, errors: string[]): Pick<Rect, 't' | 'shot' | 'side'> | null {
1232
1864
  const at = r.t
1233
1865
  const shot = r.shot as { name?: unknown; time?: unknown } | undefined
1234
1866
  const bad: string[] = []
1235
1867
  if (typeof at !== 'number' || !Number.isFinite(at) || at < 0) bad.push(`rects[${i}].t: the time on the cut it was drawn at`)
1236
1868
  if (!obj(shot) || typeof shot.name !== 'string' || shot.name === '' || typeof shot.time !== 'number' || !Number.isFinite(shot.time) || shot.time < 0)
1237
1869
  bad.push(`rects[${i}].shot: { name, time }, the shot it sits on and the seconds into it`)
1238
- if (t.before ? r.side !== 'before' && r.side !== 'after' : r.side !== undefined) bad.push(`rects[${i}].side: ${t.before ? 'before or after, the render it is drawn on' : 'none on a trailer card with no before'}`)
1870
+ if (t.before ? r.side !== 'before' && r.side !== 'after' : r.side !== undefined) bad.push(`rects[${i}].side: ${t.before ? 'before or after, the render it is drawn on' : 'none on a trailer version with no before'}`)
1239
1871
  errors.push(...bad)
1240
1872
  if (bad.length > 0 || !obj(shot)) return null
1241
1873
  return { t: at as number, shot: { name: shot.name as string, time: shot.time as number }, ...(t.before ? { side: r.side as Side } : {}) }
@@ -1260,7 +1892,7 @@ export function verdictMessageOf(body: unknown, item: Item): { ok: true; message
1260
1892
  const view = r.view === undefined ? 0 : r.view
1261
1893
  const on = typeof view === 'number' && Number.isInteger(view) && (r.view === undefined || view >= 1) ? views[view] : undefined
1262
1894
  if (!on) {
1263
- errors.push(`rects[${i}].view: the index of one of the card's other views (absent on the first)`)
1895
+ errors.push(`rects[${i}].view: the index of one of the version's other views (absent on the first)`)
1264
1896
  continue
1265
1897
  }
1266
1898
  if (isGallery(on)) {
@@ -1277,7 +1909,7 @@ export function verdictMessageOf(body: unknown, item: Item): { ok: true; message
1277
1909
  errors.push(`rects[${i}].view: no rectangle on a sound, react to the view instead`)
1278
1910
  continue
1279
1911
  }
1280
- if (view === 0 && isTrailerCard(item)) {
1912
+ if (view === 0 && isTrailerItem(item)) {
1281
1913
  const r2 = trailerRect(r, item.trailer, i, errors)
1282
1914
  if (r2) out.push({ x: r.x, y: r.y, w: r.w, h: r.h, comment: typeof r.comment === 'string' ? r.comment : '', ...r2 })
1283
1915
  continue
@@ -1295,11 +1927,11 @@ export function verdictMessageOf(body: unknown, item: Item): { ok: true; message
1295
1927
  if (clip && typeof t === 'number') rect.t = t
1296
1928
  out.push(rect)
1297
1929
  }
1298
- const reactions = reactionsOf(body.reactions, views, errors, isChoice(item), isDraftCard(item))
1930
+ const reactions = reactionsOf(body.reactions, views, errors, isChoice(item), isDraftItem(item))
1299
1931
  const pick = body.pick
1300
1932
  if (pick !== undefined) {
1301
- if (!isChoice(item)) errors.push('pick: only on a choice card')
1302
- else if (!(typeof pick === 'number' && Number.isInteger(pick) && pick >= 0 && pick < views.length)) errors.push(`pick: the index of one of the card's ${views.length} views`)
1933
+ if (!isChoice(item)) errors.push('pick: only on a choice version')
1934
+ else if (!(typeof pick === 'number' && Number.isInteger(pick) && pick >= 0 && pick < views.length)) errors.push(`pick: the index of one of the version's ${views.length} views`)
1303
1935
  else if (!isApproved(body.status as ReviewStatus)) errors.push('pick: goes with approved or approved-with-fix; rejecting every option is a plain rejected')
1304
1936
  }
1305
1937
  if (errors.length > 0) return { ok: false, errors }
@@ -1316,9 +1948,9 @@ export function verdictMessageOf(body: unknown, item: Item): { ok: true; message
1316
1948
  }
1317
1949
  }
1318
1950
 
1319
- /** the reactions the page sends, checked against the card's views: each on a view, a tile only on a gallery, one per view
1320
- * or tile; on a draft card each on a message of the draft, by its key (one the draft gained since the card is taken
1321
- * too: the card shows the draft live); an empty one is dropped */
1951
+ /** the reactions the page sends, checked against the version's views: each on a view, a tile only on a gallery, one per view
1952
+ * or tile; on a draft version each on a message of the draft, by its key (one the draft gained since the version is taken
1953
+ * too: the version shows the draft live); an empty one is dropped */
1322
1954
  function reactionsOf(v: unknown, views: readonly ReviewView[], errors: string[], choice: boolean, draft: boolean): ReviewReaction[] {
1323
1955
  if (v === undefined) return []
1324
1956
  if (!Array.isArray(v)) {
@@ -1336,7 +1968,7 @@ function reactionsOf(v: unknown, views: readonly ReviewView[], errors: string[],
1336
1968
  }
1337
1969
  const on = obj(r) && typeof r.view === 'number' && Number.isInteger(r.view) ? views[r.view] : undefined
1338
1970
  if (!obj(r) || !on) {
1339
- errors.push(`reactions[${i}].view: the index of one of the card's views`)
1971
+ errors.push(`reactions[${i}].view: the index of one of the version's views`)
1340
1972
  continue
1341
1973
  }
1342
1974
  const tiles = isGallery(on) ? on.gallery.length : 0
@@ -1348,7 +1980,7 @@ function reactionsOf(v: unknown, views: readonly ReviewView[], errors: string[],
1348
1980
  // a choice scores its options, a gallery each of its tiles
1349
1981
  const scored = choice || (typeof tile === 'number' && tiles > 0)
1350
1982
  if (stars !== undefined && !(scored && typeof stars === 'number' && Number.isInteger(stars) && stars >= 1 && stars <= STARS))
1351
- errors.push(scored ? `reactions[${i}].stars: 1 to ${STARS}` : `reactions[${i}].stars: only on a choice card or a gallery tile`)
1983
+ errors.push(scored ? `reactions[${i}].stars: 1 to ${STARS}` : `reactions[${i}].stars: only on a choice version or a gallery tile`)
1352
1984
  const key = `${String(r.view)}/${String(tile ?? '')}`
1353
1985
  if (seen.has(key)) errors.push(`reactions[${i}]: a second reaction on the same view or tile`)
1354
1986
  seen.add(key)
@@ -1374,11 +2006,11 @@ function reactionsOf(v: unknown, views: readonly ReviewView[], errors: string[],
1374
2006
  return out
1375
2007
  }
1376
2008
 
1377
- /** a reaction to one message of a draft card, checked: its key, OK, fix or no, his word; null with its errors pushed, or
2009
+ /** a reaction to one message of a draft version, checked: its key, OK, fix or no, his word; null with its errors pushed, or
1378
2010
  * when it says nothing */
1379
2011
  function postReaction(r: Record<string, unknown>, i: number, draft: boolean, seen: Set<string>, errors: string[]): ReviewReaction | null {
1380
2012
  const bad: string[] = []
1381
- if (!draft) bad.push(`reactions[${i}].post: only on a draft card`)
2013
+ if (!draft) bad.push(`reactions[${i}].post: only on a draft version`)
1382
2014
  else if (typeof r.post !== 'string' || !POST_KEY.test(r.post)) bad.push(`reactions[${i}].post: the key of one message of the draft, <account> or <account>/<name>`)
1383
2015
  if (r.status !== undefined && !STATUSES.includes(r.status as ReviewStatus)) bad.push(`reactions[${i}].status: one of ${STATUSES.join(', ')}`)
1384
2016
  if (r.comment !== undefined && typeof r.comment !== 'string') bad.push(`reactions[${i}].comment: a text`)
@@ -1392,12 +2024,12 @@ function postReaction(r: Record<string, unknown>, i: number, draft: boolean, see
1392
2024
  return { view: 0, post: r.post as string, ...(r.status !== undefined ? { status: r.status as ReviewStatus } : {}), comment }
1393
2025
  }
1394
2026
 
1395
- /** a draft card's message as the page and the CLI name it: the name the card pinned, else its key (one the draft gained since) */
1396
- export const postLabel = (draft: DraftCard | undefined, key: string): string => draft?.posts.find((p) => p.key === key)?.name ?? key
2027
+ /** a draft version's message as the page and the CLI name it: the name the version pinned, else its key (one the draft gained since) */
2028
+ export const postLabel = (draft: ItemDraft | undefined, key: string): string => draft?.posts.find((p) => p.key === key)?.name ?? key
1397
2029
 
1398
2030
  /** what a reaction or a rectangle is on, as the CLI prints it: its view's letter and label, `[B from above]`,
1399
- * `[C trees / oak-v2]`, `[A]`; on a draft card the message's name, `[Reddit · comfyui]` */
1400
- export function placeText(r: { view?: number | undefined; tile?: number | undefined; post?: string | undefined }, views: readonly ReviewView[], draft?: DraftCard): string {
2031
+ * `[C trees / oak-v2]`, `[A]`; on a draft version the message's name, `[Reddit · comfyui]` */
2032
+ export function placeText(r: { view?: number | undefined; tile?: number | undefined; post?: string | undefined }, views: readonly ReviewView[], draft?: ItemDraft): string {
1401
2033
  if (r.post !== undefined) return `[${postLabel(draft, r.post)}]`
1402
2034
  const i = r.view ?? 0
1403
2035
  const v = views[i]