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