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
@@ -2,8 +2,9 @@
2
2
  // media, and `thread/`, one file per message, never rewritten. An item is built in a dot folder and renamed, every file
3
3
  // written beside its place and renamed, so no reader sees half of one. The format is a project's own store's, verbatim. A folder of
4
4
  // the old shape (request.json, feedback.json, a message with `seen`) fails loud. With the switch cards-in-db on, the
5
- // heads and the messages are rows of the daemon's file instead (card-rows.ts), through the same functions: `io` picks
5
+ // heads and the messages are rows of the daemon's file instead (item-rows.ts), through the same functions: `io` picks
6
6
  // the backend, every function above it is one code path
7
+ import { ownerCursorAt } from './owner-read.ts'
7
8
  import * as fs from 'node:fs'
8
9
  import { existsSync, readdirSync, readFileSync, statSync, watch } from 'node:fs'
9
10
  import { basename, dirname, extname, join, resolve } from 'node:path'
@@ -14,9 +15,9 @@ import { probe, sizeOf, stillAt } from './media.ts'
14
15
  import { factsOf } from '../media-store/content.ts'
15
16
  import { anyWebp, exactWebp, webpable } from '../media-store/webp.ts'
16
17
  import { mediaDb, tryWrite } from '../media-store/db.ts'
17
- import { cardsInDb, cardsMoving, cardsOn } from '../hq/switch.ts'
18
- import { rowsAll, rowsIO, rowsStamp, type CardBackend } from './card-rows.ts'
19
- import { moveFolder, repoIdOf, spoolOf } from './card-db.ts'
18
+ import { threadsInDb, threadsMoving, threadsOn } from '../hq/switch.ts'
19
+ import { rowsAll, rowsIO, rowsStamp, type ItemBackend } from './item-rows.ts'
20
+ import { moveFolder, repoIdOf, spoolOf } from './item-db.ts'
20
21
  import { machineDbPath } from '../core/machine-db.ts'
21
22
  import { jsonText, revOf } from './rev.ts'
22
23
  import { GONE, goneEntryFor } from './gone.ts'
@@ -25,9 +26,9 @@ import {
25
26
  ANSWER_KINDS,
26
27
  type AnswerKind,
27
28
  type MessageAsk,
29
+ itemWithdrawOf,
28
30
  ownAddressOf,
29
31
  partyOf,
30
- proposeOpen,
31
32
  AGENT_RE,
32
33
  allowed,
33
34
  FILE_RE,
@@ -39,6 +40,12 @@ import {
39
40
  isMarkItem,
40
41
  itemProblems,
41
42
  MESSAGE_FILE_RE,
43
+ MESSAGE_FILES_MAX,
44
+ attachFile,
45
+ cleanFileName,
46
+ isThreadMedia,
47
+ mimeOf,
48
+ type MessageFile,
42
49
  MESSAGE_RE,
43
50
  messageIdOf,
44
51
  messageProblems,
@@ -58,20 +65,24 @@ import {
58
65
  updatesOf,
59
66
  type UpdateState,
60
67
  type GalleryTile,
61
- type CardChangelog,
68
+ type ItemChangelog,
62
69
  type Item,
63
70
  type Message,
71
+ type Mention,
72
+ mayReadNamed,
64
73
  type Op,
65
74
  type Origin,
66
- type Party,
67
75
  type Rect,
68
76
  type ReviewClip,
69
77
  type ReviewFiles,
70
78
  type ReviewItem,
71
79
  type ReviewMark,
80
+ type ReviewScene,
72
81
  type ReviewView,
73
- type TrailerCard,
74
- type DraftCard,
82
+ panoRefusal,
83
+ SPACE_EXT,
84
+ type ItemTrailer,
85
+ type ItemDraft,
75
86
  type Spec,
76
87
  type Subject,
77
88
  type Verdict,
@@ -87,15 +98,24 @@ import {
87
98
  type ProposeField,
88
99
  type StoredState,
89
100
  type AskHead,
101
+ docProblem,
102
+ type ItemDoc,
90
103
  } from './model.ts'
91
104
  import { kindOfValue, valueKindOf } from './kinds.ts'
92
- import { askOpen, linesOf } from './answer-kinds.ts'
93
- import { choiceName } from './instructions.ts'
105
+ import { askOpen, linesOf, tickText } from './answer-kinds.ts'
106
+ import { isObject, objectOpen } from './supersede.ts'
107
+ import { asksVerdict } from './verdict-items.ts'
94
108
  import { SECRET_NAME } from '../secrets/name.ts'
95
109
  import { beatRole, roleOf } from './role.ts'
96
- import { chainOf, coveringHead, followedIds, isFollowed, threadOfAddress } from './threads.ts'
110
+ import { chainOf, coveringHead, followedIds, isFollowed, threadIdOf, threadOfAddress } from './threads.ts'
97
111
  import { liveWatchers } from './watchers.ts'
112
+ import { liveUrlRefusal, type ViewLive } from './live-view.ts'
113
+ import { STILLS_LABEL } from './kind-still.ts'
98
114
  import { noteSession } from '../agent-time/registry.ts'
115
+ import { modelWatch } from './model-moved.ts'
116
+ import { isLockFile, withLease, withLeaseSync } from '../core/locked-write.ts'
117
+ import { wroteOnLoop } from '../core/on-loop.ts'
118
+ import { atomicWrite } from '../core/atomic-write.ts'
99
119
 
100
120
  /** the store of a repo */
101
121
  export const storeDir = (root: string): string => join(root, LAYOUT.review)
@@ -115,27 +135,26 @@ let wrote = 0
115
135
  const renameSync = (a: string, b: string): void => (fs.renameSync(a, b), touched(a), touched(b))
116
136
  const rmSync = (p: string, o?: fs.RmOptions): void => (fs.rmSync(p, o), touched(p))
117
137
  const copyFileSync = (a: string, b: string): void => (fs.copyFileSync(a, b), touched(b))
118
- const writeFileSync = (p: string, d: string): void => (fs.writeFileSync(p, d), touched(p))
119
138
  const mkdirSync = (p: string, o?: fs.MakeDirectoryOptions): void => (fs.mkdirSync(p, o), touched(p))
120
139
 
121
140
  export { jsonText, revOf }
122
141
 
142
+ /** the bytes jsonText gives, so the rev of a file is the rev of its value */
123
143
  function writeJson(file: string, v: unknown): void {
124
- const tmp = `${file}.tmp`
125
- writeFileSync(tmp, jsonText(v))
126
- renameSync(tmp, file)
144
+ atomicWrite(file, jsonText(v))
145
+ touched(file)
127
146
  }
128
147
 
129
148
  /** where the store's operations read and write: the rows of the local copy while the switch cards-in-db is on, else
130
149
  * the files. Picked once an operation, so one operation never reads one backend and writes the other */
131
- const io = (dir: string): CardBackend => (cardsInDb() ? rowsIO(dir) : filesIO(dir))
150
+ const io = (dir: string): ItemBackend => (threadsInDb() ? rowsIO(dir) : filesIO(dir))
132
151
 
133
- /** the store holds this card's head, or this message of its thread: what the machine has, never what it sent */
134
- export const holdsCard = (dir: string, id: string): boolean => io(dir).has(id)
152
+ /** the store holds this item's head, or this message of its thread: what the machine has, never what it sent */
153
+ export const holdsItem = (dir: string, id: string): boolean => io(dir).has(id)
135
154
  export const holdsMessage = (dir: string, id: string, mid: string): boolean => io(dir).hasMessage(id, mid)
136
155
 
137
- /** the store's files, as they always were: one folder a card */
138
- export function filesIO(dir: string): CardBackend {
156
+ /** the store's files, as they always were: one folder an item */
157
+ export function filesIO(dir: string): ItemBackend {
139
158
  const folder = (id: string): string => join(dir, id)
140
159
  return {
141
160
  rows: false,
@@ -160,25 +179,31 @@ export function filesIO(dir: string): CardBackend {
160
179
  hasMessage: (id, mid) => existsSync(join(dir, id, 'thread', `${mid}.json`)),
161
180
  raw: (id) => readRawFile(dir, id),
162
181
  create: (id, tmp, head) => {
182
+ wroteOnLoop()
163
183
  writeJson(join(tmp, 'item.json'), head)
164
- // a card begun while the rows were the store: its folder comes from the spool
184
+ // an item begun while the rows were the store: its folder comes from the spool
165
185
  moveFolder(tmp, folder(id))
166
186
  touched(tmp)
167
187
  touched(folder(id))
168
188
  },
169
189
  write: (id, head, at) => {
190
+ wroteOnLoop()
170
191
  const f = join(dir, id, 'item.json')
171
192
  writeJson(f, head)
172
193
  if (at !== undefined) fs.utimesSync(f, new Date(at), new Date(at))
173
194
  },
174
195
  append: (id, m) => {
196
+ wroteOnLoop()
175
197
  const t = join(dir, id, 'thread')
176
198
  if (!existsSync(t)) mkdirSync(t)
177
199
  writeJson(join(t, `${m.id}.json`), m)
178
200
  },
179
- lock: (id, fn, waitMs) => locked(dir, id, fn, waitMs),
201
+ lock: (id, fn, waitMs) => lockedItem(dir, id, fn, waitMs),
180
202
  setAside: (id, o) => setAsideFile(dir, id, o),
181
- keepReplaced: (id, head) => writeJson(join(folder(id), REPLACED), head),
203
+ keepReplaced: (id, head) => {
204
+ wroteOnLoop()
205
+ writeJson(join(folder(id), REPLACED), head)
206
+ },
182
207
  hasReplaced: (id) => ID_RE.test(id) && existsSync(join(dir, id, REPLACED)),
183
208
  stamp: (id) => stampOf(folder(id)),
184
209
  folder,
@@ -192,12 +217,19 @@ export interface ViewInput {
192
217
  image?: string
193
218
  video?: string
194
219
  audio?: string
220
+ /** an equirectangular panorama (2:1): one image he looks around in */
221
+ pano?: string
222
+ /** a Gaussian splat (.ply, .spz) or a .glb mesh he moves in, `image` its poster; loaded only in the lightbox */
223
+ splat?: string
224
+ mesh?: string
195
225
  before?: string
196
226
  after?: string
197
227
  /** a list of small images shown as a wrapping grid, each with its label; never the first view */
198
- gallery?: { file: string; label: string; before?: string; group?: string }[]
199
- /** a line on this view alone: an option's description on a choice card */
228
+ gallery?: { file: string; label: string; before?: string; group?: string; view?: string }[]
229
+ /** a line on this view alone: an option's description on a choice version */
200
230
  note?: string
231
+ /** a live view: the page the hub frames over `image`, its shot (review/live-view.ts) */
232
+ live?: ViewLive
201
233
  }
202
234
 
203
235
  /** the most one side of a version of an object weighs, as json */
@@ -209,13 +241,16 @@ export interface AddInput {
209
241
  /** the public line for a post of it (`--post`); the caller runs the repo's guard on it first */
210
242
  post?: string
211
243
  /** the change its approval adds to next.md (`--changelog`); the caller runs the repo's guard on it first */
212
- changelog?: CardChangelog
244
+ changelog?: ItemChangelog
213
245
  /** what is judged; a plain shot by default */
214
246
  subject?: Subject
215
247
  topic?: string
216
248
  image?: string
217
249
  video?: string
218
250
  audio?: string
251
+ pano?: string
252
+ splat?: string
253
+ mesh?: string
219
254
  before?: string
220
255
  after?: string
221
256
  commit?: string
@@ -224,7 +259,7 @@ export interface AddInput {
224
259
  /** written by the machine (a check run, the reflections queue): no lane and no session, so nobody holds it */
225
260
  machine?: true
226
261
  supersedes?: string
227
- /** the raised items (a report, his note) this card answers, by id */
262
+ /** the raised items (a report, his note) this version answers, by id */
228
263
  answers?: string[]
229
264
  /** its subject's address when the agent names it (`--on`): one thread per address */
230
265
  on?: string
@@ -232,7 +267,7 @@ export interface AddInput {
232
267
  about?: string[]
233
268
  /** what a new version of an approved look keeps of it: required then */
234
269
  keeps?: string
235
- /** another subject on purpose, next to an active card: needs `why` */
270
+ /** another subject on purpose, next to an active version: needs `why` */
236
271
  fresh?: boolean
237
272
  why?: string
238
273
  /** the first view's label, and the other views of the same subject */
@@ -242,7 +277,7 @@ export interface AddInput {
242
277
  marks?: ReviewMark[][]
243
278
  /** the shots used the review light over a dark place */
244
279
  light?: 'review'
245
- /** a draft card on a live shot: its image a live frame, no verdict until it is ready */
280
+ /** a draft version on a live shot: its image a live frame, no verdict until it is ready */
246
281
  wip?: { live: string }
247
282
  /** every view is an option he picks one of */
248
283
  choice?: boolean
@@ -250,18 +285,22 @@ export interface AddInput {
250
285
  asksVerdict?: true
251
286
  /** on a choice: the option the agent suggests, by its label or its letter */
252
287
  agentPick?: string
253
- /** a trailer card: the cut the hub plays in its body; its one view is the cut's strip */
254
- trailer?: TrailerCard
255
- /** a draft card: the post draft the hub shows in its body, read live; it holds no view */
256
- draft?: DraftCard
257
- /** every picture as given, never a webp: the file itself kept, where the card holds only its webp otherwise */
288
+ /** a trailer version: the cut the hub plays in its body; its one view is the cut's strip */
289
+ trailer?: ItemTrailer
290
+ /** a draft version: the post draft the hub shows in its body, read live; it holds no view */
291
+ draft?: ItemDraft
292
+ /** every picture as given, never a webp: the file itself kept, where the item holds only its webp otherwise */
258
293
  keep?: boolean
259
294
  /** a thread opened with words on its address (`on`): no media, nothing he judges (openThread) */
260
295
  opening?: boolean
261
296
  /** a version of an object of a kind (`on`): its two states as the kind read them; it holds no view */
262
297
  states?: { before?: StoredState; after: StoredState }
298
+ /** a save of the object in its home (review/doc-save.ts): who saved it; it holds its states */
299
+ saved?: { by: string }
263
300
  /** an ask's facts, on the head of its thread `ask:<id>` (asks/ask-store.ts) */
264
301
  ask?: AskHead
302
+ /** a document as the version's subject (`--md`, `--html`); views beside it are allowed */
303
+ doc?: ItemDoc
265
304
  now?: Date
266
305
  }
267
306
 
@@ -274,21 +313,24 @@ interface Loaded {
274
313
  clip?: { duration: number; fps: number; from: string }
275
314
  /** a sound: its length, and the files its waveforms are drawn from (the after's or the one's, then the before's) */
276
315
  audio?: { duration: number; from: string; before?: string }
277
- tiles?: { path: string; label: string; size: { w: number; h: number }; before?: string; group?: string }[]
316
+ scene?: ReviewScene
317
+ /** a splat's or a mesh's 3D file, copied beside its poster as `space.<ext>` */
318
+ space?: string
319
+ tiles?: { path: string; label: string; size: { w: number; h: number }; before?: string; group?: string; view?: string }[]
278
320
  /** the webps made of its pictures, by the name of each in place of its source (`<source>.webp`, no such file) */
279
321
  webps?: Map<string, Uint8Array>
280
322
  }
281
323
 
282
- /** the view's pictures as the card keeps them: each png a lossless webp found exact (media-store/webp.ts), made in
283
- * memory and written where the card is by copyFiles; never with `keep`. The sides of a pair, and a tile and its
324
+ /** the view's pictures as the item keeps them: each png a lossless webp found exact (media-store/webp.ts), made in
325
+ * memory and written where the item is by copyFiles; never with `keep`. The sides of a pair, and a tile and its
284
326
  * before, are webps together or stay as given together, so two sides never differ in kind. `always`: a webp whatever
285
- * the picture holds (a draft's live frame, whose name its card made a webp) */
327
+ * the picture holds (a draft's live frame, whose name its item made a webp) */
286
328
  async function asWebp(v: Loaded, keep: boolean, always: boolean): Promise<Loaded> {
287
329
  if (keep || v.clip || v.audio) return v
288
330
  const pics = [...v.sources.map(([, p]) => p), ...(v.tiles ?? []).flatMap((t) => [t.path, ...(t.before ? [t.before] : [])])]
289
331
  if (!pics.some(webpable) && !always) return v
290
332
  const webps = new Map<string, Uint8Array>()
291
- /** the paths of a group as the card keeps them: every one a webp, or every one as given */
333
+ /** the paths of a group as the item keeps them: every one a webp, or every one as given */
292
334
  const group = async (paths: readonly string[]): Promise<string[]> => {
293
335
  const made = await Promise.all(paths.map(async (p) => (always ? { bytes: await anyWebp(p) } : await exactWebp(p))))
294
336
  if (made.some((m) => 'keep' in m)) return [...paths]
@@ -315,8 +357,8 @@ async function loadView(v: ViewInput, which: string, o: { keep?: boolean; always
315
357
  /** a view's files checked and sized, as given */
316
358
  async function checkView(v: ViewInput, which: string): Promise<Loaded> {
317
359
  if (v.gallery !== undefined) {
318
- if (v.image !== undefined || v.video !== undefined || v.audio !== undefined || v.before !== undefined || v.after !== undefined)
319
- throw new Error(`${which}: a gallery is a list of images, no --image, --video or pair beside it`)
360
+ if (v.image !== undefined || v.video !== undefined || v.audio !== undefined || v.pano !== undefined || v.splat !== undefined || v.mesh !== undefined || v.before !== undefined || v.after !== undefined)
361
+ throw new Error(`${which}: a gallery is a list of images, no --image, --video, --pano, --splat, --mesh or pair beside it`)
320
362
  if (v.gallery.length === 0) throw new Error(`${which}: a gallery needs at least one image`)
321
363
  const tiles = await Promise.all(
322
364
  v.gallery.map(async (t) => {
@@ -328,11 +370,13 @@ async function checkView(v: ViewInput, which: string): Promise<Loaded> {
328
370
  }
329
371
  const path = image(t.file)
330
372
  const group = t.group?.trim()
331
- return { path, label: t.label.trim(), size: await sizeOf(path), ...(t.before !== undefined ? { before: image(t.before) } : {}), ...(group ? { group } : {}) }
373
+ return { path, label: t.label.trim(), size: await sizeOf(path), ...(t.before !== undefined ? { before: image(t.before) } : {}), ...(group ? { group } : {}), ...(t.view !== undefined ? { view: t.view } : {}) }
332
374
  }),
333
375
  )
334
376
  return { label: v.label.trim(), sources: [], size: tiles[0]?.size ?? { w: 0, h: 0 }, tiles }
335
377
  }
378
+ if (v.pano !== undefined) return checkPano(v, which)
379
+ if (v.splat !== undefined || v.mesh !== undefined) return checkSpace(v, which)
336
380
  if ([v.image, v.video, v.audio].filter((x) => x !== undefined).length > 1) throw new Error(`${which}: give one of an image, a clip or a sound`)
337
381
  const one = v.image ?? v.video ?? v.audio
338
382
  const pair = v.before !== undefined || v.after !== undefined
@@ -382,7 +426,36 @@ async function checkView(v: ViewInput, which: string): Promise<Loaded> {
382
426
  return { label: v.label.trim(), sources, size: { w: b.w, h: b.h }, clip: { duration: b.duration, fps: b.fps, from: main[1] } }
383
427
  }
384
428
 
385
- /** what a card records of a clip: its size, its length and its rate, to the millisecond */
429
+ /** a panorama's one image, checked 2:1: a view whose files are an image's, drawn by the hub's scene viewer */
430
+ async function checkPano(v: ViewInput, which: string): Promise<Loaded> {
431
+ if ([v.image, v.video, v.audio, v.before, v.after].some((x) => x !== undefined)) throw new Error(`${which}: --pano is the view's one image, no --image, --video, --audio or pair beside it`)
432
+ const path = resolve(v.pano ?? '')
433
+ if (!existsSync(path)) throw new Error(`${path}: no such file`)
434
+ if (!IMAGE_EXT.test(extname(path).toLowerCase())) throw new Error(`--pano ${path}: a png, jpg or webp`)
435
+ const size = await sizeOf(path)
436
+ const why = panoRefusal(size)
437
+ if (why) throw new Error(`--pano ${path}: ${why}`)
438
+ return { label: v.label.trim(), sources: [['image', path]], size, scene: { kind: 'pano' } }
439
+ }
440
+
441
+ /** a splat or a mesh: its 3D file of the kind's own type, and its poster, the view's one image (the cli shoots one when
442
+ * none is given). The file is never read here: 66 to 79 MB, the lightbox loads it */
443
+ async function checkSpace(v: ViewInput, which: string): Promise<Loaded> {
444
+ const kind = v.splat !== undefined ? 'splat' : 'mesh'
445
+ const file = v.splat ?? v.mesh ?? ''
446
+ if (v.splat !== undefined && v.mesh !== undefined) throw new Error(`${which}: one 3D file a view, --splat or --mesh`)
447
+ if ([v.video, v.audio, v.pano, v.before, v.after].some((x) => x !== undefined)) throw new Error(`${which}: --${kind} is the view's 3D file and --image its poster, no --video, --audio, --pano or pair beside it`)
448
+ const path = resolve(file)
449
+ if (!existsSync(path)) throw new Error(`${path}: no such file`)
450
+ if (!SPACE_EXT[kind].test(path)) throw new Error(`--${kind} ${path}: ${kind === 'splat' ? 'a Gaussian splat, .ply or .spz' : 'a .glb mesh'}`)
451
+ if (v.image === undefined) throw new Error(`${which}: --${kind} needs its poster, --image <a.png> (sk thread post shoots one when none is given)`)
452
+ const poster = resolve(v.image)
453
+ if (!existsSync(poster)) throw new Error(`${poster}: no such file`)
454
+ if (!IMAGE_EXT.test(extname(poster).toLowerCase())) throw new Error(`--image ${poster}: the poster of a ${kind}, a png, jpg or webp`)
455
+ return { label: v.label.trim(), sources: [['image', poster]], size: await sizeOf(poster), scene: { kind, file: '' }, space: path }
456
+ }
457
+
458
+ /** what an item records of a clip: its size, its length and its rate, to the millisecond */
386
459
  function clipInfo(file: string): { w: number; h: number; duration: number; fps: number } {
387
460
  let p: ReturnType<typeof probe>
388
461
  try {
@@ -421,18 +494,32 @@ async function writeWaves(v: Loaded, n: number, folder: string): Promise<void> {
421
494
  }
422
495
 
423
496
  const prefix = (n: number): string => (n > 0 ? `v${n}-` : '')
497
+ /** a scene's 3D file in the folder (model.ts SPACE_RE) */
498
+ const spaceName = (n: number, path: string): string => `${prefix(n)}space${extname(path).toLowerCase()}`
424
499
 
425
500
  /** the file name of tile `k` of gallery view `n` */
426
501
  const tileName = (n: number, k: number, path: string, side = ''): string => `v${n}-g${k}${side}${extname(path).toLowerCase()}`
427
502
 
503
+ /** a live view's page beside its shot: an image alone, its url past the wall the cli holds (live-view.ts) */
504
+ function liveOf(v: ViewInput, which: string): { live: ViewLive } | Record<string, never> {
505
+ if (v.live === undefined) return {}
506
+ if (v.image === undefined || isClipFile(v.image) || [v.video, v.audio, v.before, v.after, v.gallery].some((x) => x !== undefined)) throw new Error(`${which}: a live view keeps one image, its shot`)
507
+ const why = liveUrlRefusal(v.live.url, [])
508
+ if (why) throw new Error(`${which}: ${why}`)
509
+ if (Number.isNaN(Date.parse(v.live.at))) throw new Error(`${which}: a live view says when its shot was taken`)
510
+ return { live: { url: v.live.url, at: v.live.at } }
511
+ }
512
+
513
+ const withLive = (v: ReviewView, l: { live?: ViewLive } | undefined): ReviewView => (l?.live && !isGallery(v) ? { ...v, live: l.live } : v)
514
+
428
515
  function viewOf(v: Loaded, n: number, marks: readonly ReviewMark[] = [], note?: string, message?: true): ReviewView {
429
516
  if (v.tiles)
430
517
  return {
431
518
  label: v.label,
432
- gallery: v.tiles.map((t, k): GalleryTile => ({ file: tileName(n, k, t.path), label: t.label, size: t.size, ...(t.before ? { before: tileName(n, k, t.before, '-before') } : {}), ...(t.group ? { group: t.group } : {}) })),
519
+ gallery: v.tiles.map((t, k): GalleryTile => ({ file: tileName(n, k, t.path), label: t.label, size: t.size, ...(t.before ? { before: tileName(n, k, t.before, '-before') } : {}), ...(t.group ? { group: t.group } : {}), ...(t.view ? { view: t.view } : {}) })),
433
520
  }
434
521
  const audio = v.audio ? { audio: { duration: v.audio.duration, wave: `${prefix(n)}wave.png`, ...(v.audio.before ? { waveBefore: `${prefix(n)}before-wave.png` } : {}) } } : {}
435
- return { label: v.label, files: filesOf(v, n), size: v.size, ...clipOf(v, n), ...audio, ...(marks.length > 0 ? { marks: [...marks] } : {}), ...(note?.trim() ? { note: note.trim() } : {}), ...(message ? { message } : {}) }
522
+ return { label: v.label, files: filesOf(v, n), size: v.size, ...clipOf(v, n), ...audio, ...(v.scene ? { scene: v.space && v.scene.kind !== 'pano' ? { kind: v.scene.kind, file: spaceName(n, v.space) } : v.scene } : {}), ...(marks.length > 0 ? { marks: [...marks] } : {}), ...(note?.trim() ? { note: note.trim() } : {}), ...(message ? { message } : {}) }
436
523
  }
437
524
 
438
525
  /** the file names of view `n` in the folder: `image.png` on the first, `v2-before.png` on a later one */
@@ -468,17 +555,17 @@ function coveredText(c: { head: ReviewItem; by: 'subject' | 'near' | 'title' }):
468
555
  * or it names none (the older guard decides) */
469
556
  export function threadLink(
470
557
  dir: string,
471
- card: Pick<Item, 'subject' | 'on' | 'trailer'>,
558
+ item: Pick<Item, 'subject' | 'on' | 'trailer'>,
472
559
  given: { supersedes?: string; answers: readonly string[] },
473
560
  spec: Spec = specOf(dir),
474
561
  ): { own: string | null; thread: string | null; supersedes?: string; answers: string[] } {
475
- const own = ownAddressOf({ ...card, origin: { by: 'agent' } } as Item, spec)
562
+ const own = ownAddressOf({ ...item, origin: { by: 'agent' } } as Item, spec)
476
563
  const t = own === null ? null : threadOfAddress(own, readAll(dir).items, spec)
477
564
  if (!t) return { own, thread: null, ...given, answers: [...given.answers] }
478
565
  const head = t.head.item
479
566
  const want = head.origin.by === 'agent' ? head.id : undefined
480
567
  if (given.supersedes !== undefined && given.supersedes !== want)
481
- throw new Error(`${own} already has its thread ${head.id} "${head.title}": a new version of it supersedes its newest version${want ? ` ${want}` : ', here none: its head is his note'}, never ${given.supersedes}; or leave --supersedes out and the tool links it`)
568
+ throw new Error(`${own} already has its thread ${threadIdOf(t)} "${head.title}": a new version of it supersedes its newest version${want ? ` ${want}` : ', here none: its head is his note'}, never ${given.supersedes}; or leave --supersedes out and the tool links it`)
482
569
  return { own, thread: head.id, ...(want !== undefined ? { supersedes: want } : {}), answers: [...given.answers] }
483
570
  }
484
571
 
@@ -488,7 +575,7 @@ export async function openThread(dir: string, address: string, o: { title: strin
488
575
  // an ask is made with its facts (asks/ask-store.ts createAsk): a bare ask: thread would wait on him and no count would hold it
489
576
  if (address.startsWith('ask:') && o.ask === undefined) throw new Error(`${address}: an ask is made with sk ask, its thread opened with its facts`)
490
577
  const own = threadOfAddress(address, readAll(dir).items, specOf(dir))
491
- if (own) throw new Error(`${address} already has its thread ${own.head.item.id} "${own.head.item.title}": write in it`)
578
+ if (own) throw new Error(`${address} already has its thread ${threadIdOf(own)} "${own.head.item.title}": write in it`)
492
579
  const first = o.title.trim().split('\n')[0] ?? ''
493
580
  const title = first.length > 80 ? `${first.slice(0, 79).trimEnd()}…` : first
494
581
  return addItem(dir, { title, what: o.what?.trim() || (o.ask ? '' : `the thread of ${address}`), subject: { kind: 'object', address }, on: address, opening: true, ...(o.lane ? { lane: o.lane } : {}), ...(o.machine ? { machine: true } : {}), ...(o.now ? { now: o.now } : {}), ...(o.ask ? { ask: o.ask } : {}), ...(o.asksVerdict ? { asksVerdict: o.asksVerdict } : {}) })
@@ -506,37 +593,45 @@ export async function addItem(dir: string, input: AddInput): Promise<Item> {
506
593
  if (!input.title.trim()) throw new Error('--title: required')
507
594
  // an ask's head holds its facts alone: its words are its instructions, a message (asks/ask-store.ts createAsk)
508
595
  if (!input.what.trim() && input.ask === undefined) throw new Error('--what: required, what changed and why')
509
- const first = input.image !== undefined || input.video !== undefined || input.audio !== undefined || input.before !== undefined || input.after !== undefined
510
- const given: ViewInput[] = [...(first ? [{ label: input.label ?? '', image: input.image, video: input.video, audio: input.audio, before: input.before, after: input.after }] : []), ...(input.views ?? [])].map(
596
+ const first = input.image !== undefined || input.video !== undefined || input.audio !== undefined || input.pano !== undefined || input.splat !== undefined || input.mesh !== undefined || input.before !== undefined || input.after !== undefined
597
+ const given: ViewInput[] = [...(first ? [{ label: input.label ?? '', image: input.image, video: input.video, audio: input.audio, pano: input.pano, splat: input.splat, mesh: input.mesh, before: input.before, after: input.after }] : []), ...(input.views ?? [])].map(
511
598
  (v) => Object.fromEntries(Object.entries(v).filter(([, x]) => x !== undefined)) as unknown as ViewInput,
512
599
  )
513
600
  if (input.draft && given.length > 0) throw new Error('--draft: the version shows the draft itself, no image, clip, sound or view beside it')
514
601
  if (input.opening && (given.length > 0 || input.draft || input.trailer)) throw new Error('a thread opened with words holds no media: a version with media goes into it after')
515
602
  if (input.opening && !input.on) throw new Error('a thread opened with words names its address')
516
603
  if (input.states && (given.length > 0 || input.draft || input.trailer || !input.on)) throw new Error('a version of an object shows its two states alone: its address (on), no image, clip, sound or view beside it')
604
+ if (input.saved && !input.states) throw new Error('a save of an object shows its two states: the text before and after')
517
605
  for (const [side, st] of Object.entries(input.states ?? {})) if (st && JSON.stringify(st).length > STATE_MAX) throw new Error(`--${side}: the state is ${Math.round(JSON.stringify(st).length / 1024)} KB, over ${STATE_MAX / 1024} KB: a kind reads what the owner judges, not the whole repo`)
518
- if (given.length === 0 && !input.draft && !input.opening && !input.states) throw new Error('give --image, --video or --audio, or --before and --after, or --view "<label>" <image>')
606
+ if (input.doc) {
607
+ const why = docProblem(input.doc)
608
+ if (why !== null) throw new Error(why)
609
+ const beside = input.draft ? '--draft' : input.trailer ? '--trailer' : input.states ? 'an object\'s states' : input.opening ? 'a thread opened with words' : input.wip ? '--wip --live' : input.choice ? '--choice' : null
610
+ if (beside !== null) throw new Error(`--${input.doc.kind}: a document is the version's subject, never with ${beside}`)
611
+ }
612
+ if (given.length === 0 && !input.draft && !input.opening && !input.states && !input.doc) throw new Error('give --md <file.md>, --html <file.html>, --image, --video, --audio or --pano, or --before and --after, or --view "<label>" <image>')
519
613
  for (const [i, v] of given.entries()) if (i > 0 && !v.label.trim()) throw new Error('--view: every view after the first needs its label')
520
614
  if (input.choice && given.length < 2) throw new Error('--choice: a choice has two options or more, one --view each')
521
- if (input.agentPick !== undefined && !input.choice) throw new Error('--pick: only on a --choice card')
615
+ if (input.agentPick !== undefined && !input.choice) throw new Error('--pick: only on a --choice version')
522
616
  const agentPick = input.agentPick === undefined ? undefined : pickIndex(given, input.agentPick)
523
617
  for (const v of given) if (v.note !== undefined && v.gallery) throw new Error(`--view "${v.label}": a note goes on an image, a clip or a sound, never a gallery`)
618
+ const lives = given.map((v, i) => liveOf(v, i === 0 ? 'the first view' : `--live "${v.label}"`))
524
619
  const loaded = await Promise.all(given.map((v, i) => loadView(v, i === 0 ? 'the first view' : `--view "${v.label}"`, { keep: input.keep === true })))
525
620
  const c = io(dir)
526
- if (input.supersedes !== undefined && !c.has(input.supersedes)) throw new Error(`--supersedes ${input.supersedes}: no such card in ${dir}`)
621
+ if (input.supersedes !== undefined && !c.has(input.supersedes)) throw new Error(`--supersedes ${input.supersedes}: no such thread in ${dir}`)
527
622
  if (input.supersedes !== undefined && readItem(dir, input.supersedes)?.item.origin.by !== 'agent')
528
623
  throw new Error(`--supersedes ${input.supersedes}: a report or a note is answered, never superseded: --answers ${input.supersedes}`)
529
624
  const answers = [...new Set(input.answers ?? [])]
530
625
  for (const a of answers) {
531
626
  const y = ID_RE.test(a) ? readItem(dir, a) : null
532
627
  if (!y) throw new Error(`--answers ${a}: no such item in ${dir}`)
533
- if (y.item.origin.by === 'agent') throw new Error(`--answers ${a}: an agent's card; a new version of it passes --supersedes ${a}`)
628
+ if (y.item.origin.by === 'agent') throw new Error(`--answers ${a}: an agent's version; a newer one passes --supersedes ${a}`)
534
629
  }
535
630
  const subject: Subject = input.subject ?? { kind: 'shot' }
536
631
  const topic = input.topic?.trim() || undefined
537
632
  const wrong = specProblems({ subject, ...(topic ? { topic } : {}) } as Item, spec)
538
633
  if (wrong.length > 0) throw new Error(wrong.join('; '))
539
- if (input.wip && (given.length > 2 || given.slice(1).some((v) => !v.gallery))) throw new Error('--wip: the card shows the live frame, and its history as a gallery, nothing else')
634
+ if (input.wip && (given.length > 2 || given.slice(1).some((v) => !v.gallery))) throw new Error('--wip: the version shows the live frame, and its history as a gallery, nothing else')
540
635
  if (input.marks && input.marks.length > given.length) throw new Error(`marks: ${input.marks.length} lists for ${given.length} views`)
541
636
  const about = [...new Set((input.about ?? []).map(addressOrThrow))]
542
637
  const on = input.on?.trim() ? addressOrThrow(input.on) : undefined
@@ -546,7 +641,9 @@ export async function addItem(dir: string, input: AddInput): Promise<Item> {
546
641
  * refusal costs no write, and again under the address's lock, where the version is written */
547
642
  const settle = (): { own: string | null; supersedes?: string; answers: string[] } => {
548
643
  const link = threadLink(dir, { subject, ...(on ? { on } : {}), ...(input.trailer ? { trailer: input.trailer } : {}) }, given0, spec)
549
- if (link.supersedes !== undefined && !input.keeps?.trim()) {
644
+ // a draft settled is posted, not a look he locked: its next save shows as the next version (review/settle.ts);
645
+ // a save of the object in its home (review/doc-save.ts) moved it already
646
+ if (link.supersedes !== undefined && !input.keeps?.trim() && input.draft === undefined && input.saved === undefined) {
550
647
  const all = readAll(dir).items
551
648
  const old = all.find((x) => x.item.id === link.supersedes)
552
649
  const answered = old ? chainOf(old, all).find((x) => verdictOf(x)) : undefined
@@ -559,7 +656,7 @@ export async function addItem(dir: string, input: AddInput): Promise<Item> {
559
656
  // an address decides alone: the older guard reads titles only for a version that names none
560
657
  if (link.supersedes === undefined && link.thread === null && link.own === null) {
561
658
  if (input.fresh === true) {
562
- if (!input.why?.trim()) throw new Error('--new needs --why "<reason>": why this is another subject than the active card next to it')
659
+ if (!input.why?.trim()) throw new Error('--new needs --why "<reason>": why this is another subject than the active thread next to it')
563
660
  } else {
564
661
  const others = readAll(dir).items.filter((x) => !link.answers.includes(x.item.id))
565
662
  const c = coveringHead({ title: input.title, ...(topic ? { topic } : {}), subject }, others, spec)
@@ -589,7 +686,7 @@ export async function addItem(dir: string, input: AddInput): Promise<Item> {
589
686
  ...(input.changelog ? { changelog: { category: input.changelog.category.trim(), line: input.changelog.line.trim(), ...(input.changelog.rating ? { rating: input.changelog.rating } : {}) } } : {}),
590
687
  ...(topic ? { topic } : {}),
591
688
  ...(input.commit ? { commit: input.commit } : {}),
592
- views: loaded.map((v, n) => viewOf(v, n, input.marks?.[n], given[n]?.note)),
689
+ views: loaded.map((v, n) => withLive(viewOf(v, n, input.marks?.[n], given[n]?.note), lives[n])),
593
690
  ...(link.supersedes ? { supersedes: link.supersedes } : {}),
594
691
  ...(link.answers.length > 0 ? { answers: link.answers } : {}),
595
692
  ...(on ? { on } : {}),
@@ -604,7 +701,9 @@ export async function addItem(dir: string, input: AddInput): Promise<Item> {
604
701
  ...(input.trailer ? { trailer: input.trailer } : {}),
605
702
  ...(input.draft ? { draft: input.draft } : {}),
606
703
  ...(input.states ? { states: input.states } : {}),
704
+ ...(input.saved ? { saved: { by: input.saved.by } } : {}),
607
705
  ...(input.ask ? { ask: input.ask } : {}),
706
+ ...(input.doc ? { doc: { kind: input.doc.kind, text: input.doc.text } } : {}),
608
707
  })
609
708
  const problems = itemProblems(itemOf(early))
610
709
  if (problems.length > 0) throw new Error(problems.join('; '))
@@ -614,7 +713,7 @@ export async function addItem(dir: string, input: AddInput): Promise<Item> {
614
713
  const media = await factsOf(tmp, viewFilesOf(itemOf(early)))
615
714
  try {
616
715
  // the link read and the version written under one lock: two posts at once on one address make one thread
617
- return addressLocked(dir, early.own, () => {
716
+ return await addressLocked(dir, early.own, () => {
618
717
  const head: Item = { ...itemOf(settle()), media }
619
718
  createAtCommit(dir, c, id, tmp, head)
620
719
  return head
@@ -625,51 +724,49 @@ export async function addItem(dir: string, input: AddInput): Promise<Item> {
625
724
  }
626
725
  }
627
726
 
628
- /** where the lock of one own address lives: the store's `.locks/` while the cards are files (a store per checkout),
727
+ /** where the lock of one own address lives: the store's `.locks/` while the items are files (a store per checkout),
629
728
  * else beside the machine db, keyed by the repo the rows belong to, so every worktree of a repo takes one lock */
630
729
  export function addressLockPath(dir: string, address: string): string {
631
- const rows = cardsInDb()
730
+ const rows = threadsInDb()
632
731
  const key = new Bun.CryptoHasher('sha1').update(rows ? `${repoIdOf(dir)}\n${address}` : address).digest('hex').slice(0, 16)
633
732
  return join(rows ? join(dirname(machineDbPath()), 'thread-locks') : join(dir, '.locks'), key)
634
733
  }
635
734
 
636
- /** the lock of one own address while its thread is read and a version written into it (the item lock's atomic folder);
637
- * no address, no lock */
638
- function addressLocked<T>(dir: string, address: string | null, fn: () => T): T {
735
+ /** the lease of one own address (`<addressLockPath>.lock`) while its thread is read and a version written into it,
736
+ * waited on off the thread (the daemon's loop answers meanwhile); no address, no lock */
737
+ async function addressLocked<T>(dir: string, address: string | null, fn: () => T): Promise<T> {
639
738
  if (address === null) return fn()
640
739
  const at = addressLockPath(dir, address)
641
- mkdirSync(at, { recursive: true })
642
- try {
643
- return locked(dirname(at), basename(at), fn, 2000)
644
- } catch (e) {
645
- throw (e as Error).message.endsWith('locked by another process') ? new Error(`${address}: another post on it holds its lock past 2 s; post again`) : e
646
- }
740
+ mkdirSync(dirname(at), { recursive: true })
741
+ const r = await withLease(at, { label: `the address ${address}`, waitMs: 2000 }, fn)
742
+ if (!r.ok) throw new Error(`${address}: another post on it holds its lock past 2 s; post again`)
743
+ return r.value
647
744
  }
648
745
 
649
- /** the empty folder a new card's files are written in, beside the folder they become: the repo's store, or the spool */
650
- function tmpOf(c: CardBackend, id: string): string {
746
+ /** the empty folder a new item's files are written in, beside the folder they become: the repo's store, or the spool */
747
+ function tmpOf(c: ItemBackend, id: string): string {
651
748
  const tmp = join(dirname(c.folder(id)), `.${id}.tmp`)
652
749
  rmSync(tmp, { recursive: true, force: true })
653
750
  mkdirSync(tmp, { recursive: true })
654
751
  return tmp
655
752
  }
656
753
 
657
- /** where a store's card media are: the folder of each card in the repo, or, with the cards as rows, the spool beside the
658
- * daemon's file (card-db.ts spoolOf). A card's file is `join(mediaDir(dir), id, name)` either way */
659
- export const mediaDir = (dir: string): string => (cardsInDb() ? spoolOf(dir) : dir)
754
+ /** where a store's item media are: the folder of each item in the repo, or, with the items as rows, the spool beside the
755
+ * daemon's file (item-db.ts spoolOf). An item's file is `join(mediaDir(dir), id, name)` either way */
756
+ export const mediaDir = (dir: string): string => (threadsInDb() ? spoolOf(dir) : dir)
660
757
 
661
- /** a new card committed to the store the switch names NOW: its files took their time (a clip, a big picture), and a
758
+ /** a new item committed to the store the switch names NOW: its files took their time (a clip, a big picture), and a
662
759
  * move may have turned the switch meanwhile, past its lag. Its id was free in the store it was chosen in */
663
- function createAtCommit(dir: string, picked: CardBackend, id: string, tmp: string, head: Item): void {
760
+ function createAtCommit(dir: string, picked: ItemBackend, id: string, tmp: string, head: Item): void {
664
761
  const now = io(dir)
665
- if (now.rows !== picked.rows && now.taken(id)) throw new Error(`${id}: the store moved while this card was written, and the id is taken there: add it again`)
762
+ if (now.rows !== picked.rows && now.taken(id)) throw new Error(`${id}: the store moved while this item was written, and the id is taken there: add it again`)
666
763
  now.create(id, tmp, head)
667
764
  }
668
765
 
669
766
  /** every file of view `n` into the folder, each as `<name>.tmp` renamed, so no reader sees half of one */
670
767
  function copyFiles(v: Loaded, n: number, into: string): void {
671
768
  const files = filesOf(v, n) as Record<string, string>
672
- const copies: [string, string][] = [...v.sources.map(([name, p]): [string, string] => [p, files[name] ?? name]), ...(v.tiles ?? []).flatMap((t, k): [string, string][] => [[t.path, tileName(n, k, t.path)], ...(t.before ? [[t.before, tileName(n, k, t.before, '-before')] as [string, string]] : [])])]
769
+ const copies: [string, string][] = [...v.sources.map(([name, p]): [string, string] => [p, files[name] ?? name]), ...(v.space ? [[v.space, spaceName(n, v.space)] as [string, string]] : []), ...(v.tiles ?? []).flatMap((t, k): [string, string][] => [[t.path, tileName(n, k, t.path)], ...(t.before ? [[t.before, tileName(n, k, t.before, '-before')] as [string, string]] : [])])]
673
770
  for (const [from, name] of copies) {
674
771
  const to = join(into, name)
675
772
  putFile(v, from, `${to}.tmp`)
@@ -688,11 +785,11 @@ function putFile(v: Loaded, from: string, to: string): void {
688
785
  /** the command that posts an update, as a refusal names it */
689
786
  const updateLine = (id: string): string => `sk thread update ${id} <${UPDATE_STATES.join('|')}> "<one line>" <file> | <before> <after>`
690
787
 
691
- /** another angle of an open card's subject, appended as its next view; refused once he answered, except the view of an
788
+ /** another angle of an open version's subject, appended as its next view; refused once he answered, except the view of an
692
789
  * update (`update`), which goes on at any time */
693
790
  export async function addView(dir: string, id: string, v: ViewInput, o: { marks?: ReviewMark[]; light?: 'review'; message?: true; keep?: boolean } = {}): Promise<Item> {
694
791
  const x = readItem(dir, id)
695
- if (!x) throw new Error(`no card ${id}`)
792
+ if (!x) throw new Error(`no item ${id}`)
696
793
  if (verdictOf(x) && !o.message) throw new Error(`${id} has the owner's answer already: a picture of the work since goes on as an update, ${updateLine(id)}; a new version passes --supersedes ${id}`)
697
794
  if (v.note !== undefined && v.gallery) throw new Error(`"${v.label}": a note goes on an image, a clip or a sound, never a gallery`)
698
795
  if (!v.label.trim()) throw new Error('add-view: the view needs its label')
@@ -712,6 +809,50 @@ export async function addView(dir: string, id: string, v: ViewInput, o: { marks?
712
809
  })
713
810
  }
714
811
 
812
+ /** a view and the views a repo's `addView` hook adds after it (`also`), each through `addView`, in order; the added
813
+ * views take no marks. The item after the last, and the number of each view added */
814
+ export async function addViewAlso(dir: string, id: string, v: ViewInput, o: { marks?: ReviewMark[]; light?: 'review'; keep?: boolean; also?: readonly ViewInput[] } = {}): Promise<{ item: Item; added: number[] }> {
815
+ const { also = [], ...first } = o
816
+ let item = await addView(dir, id, v, first)
817
+ const added = [item.views.length - 1]
818
+ for (const a of also) {
819
+ item = await addView(dir, id, a, o.keep ? { keep: true } : {})
820
+ added.push(item.views.length - 1)
821
+ }
822
+ return { item, added }
823
+ }
824
+
825
+ /** the still of a version a kind's page draws (review/kind-still.ts): one image, or a before and an after of one size,
826
+ * copied into its folder under a first view's names (a version of an object holds no view) */
827
+ export async function setStill(dir: string, id: string, s: { image: string } | { before: string; after: string }): Promise<Item> {
828
+ const x = readItem(dir, id)
829
+ if (!x?.item.states) throw new Error(`${id}: a still goes on a version of an object, which holds its states`)
830
+ const loaded = await loadView({ label: '', ...s }, 'the still')
831
+ if (loaded.clip || loaded.audio || loaded.tiles || loaded.scene) throw new Error('the still: a png, jpg or webp image')
832
+ const folder = io(dir).folder(id)
833
+ if (!existsSync(folder)) mkdirSync(folder, { recursive: true })
834
+ copyFiles(loaded, 0, folder)
835
+ const files = filesOf(loaded, 0) as { image: string } | { before: string; after: string }
836
+ const facts = await factsOf(folder, Object.values(files))
837
+ return updateHead(dir, id, (cur) => ({ ...cur, states: { ...cur.states!, still: { files, size: loaded.size } }, media: { ...cur.media, ...facts } }))
838
+ }
839
+
840
+ /** the stills of a version of an object whose state names its views (review/kind-still.ts): one gallery tile a view,
841
+ * its label the legend under it, its id the tile's `view`, a before beside each view the before has; the version's
842
+ * one view, set once */
843
+ export async function setKindStills(dir: string, id: string, tiles: readonly { view: string; label: string; file: string; before?: string }[]): Promise<Item> {
844
+ const x = readItem(dir, id)
845
+ if (!x?.item.states) throw new Error(`${id}: stills go on a version of an object, which holds its states`)
846
+ if (x.item.views.length > 0) throw new Error(`${id}: its stills are set once, when it is posted`)
847
+ const loaded = await loadView({ label: STILLS_LABEL, gallery: tiles.map((t) => ({ file: t.file, label: t.label, view: t.view, ...(t.before !== undefined ? { before: t.before } : {}) })) }, 'the stills')
848
+ const folder = io(dir).folder(id)
849
+ if (!existsSync(folder)) mkdirSync(folder, { recursive: true })
850
+ copyFiles(loaded, 0, folder)
851
+ const view = viewOf(loaded, 0)
852
+ const facts = await factsOf(folder, isGallery(view) ? view.gallery.flatMap((g) => [g.file, ...(g.before ? [g.before] : [])]) : [])
853
+ return updateHead(dir, id, (cur) => ({ ...cur, views: [view], media: { ...cur.media, ...facts } }))
854
+ }
855
+
715
856
  /** the option the agent suggests, by its label or its letter; throws naming every option */
716
857
  function pickIndex(views: readonly { label: string }[], ref: string, flag = '--pick'): number {
717
858
  try {
@@ -721,12 +862,12 @@ function pickIndex(views: readonly { label: string }[], ref: string, flag = '--p
721
862
  }
722
863
  }
723
864
 
724
- /** the agent's pick set on an open choice card, by the view's label or letter; refused once he answered */
865
+ /** the agent's pick set on an open choice version, by the view's label or letter; refused once he answered */
725
866
  export function setAgentPick(dir: string, id: string, ref: string): Item {
726
867
  const x = readItem(dir, id)
727
- if (!x) throw new Error(`no card ${id}`)
868
+ if (!x) throw new Error(`no item ${id}`)
728
869
  if (verdictOf(x)) throw new Error(`${id} has his answer already: the pick shows what was suggested, never rewritten after`)
729
- if (x.item.choice !== true) throw new Error(`${id} is no choice card: a pick names one of its options`)
870
+ if (x.item.choice !== true) throw new Error(`${id} is no choice version: a pick names one of its options`)
730
871
  const n = pickIndex(x.item.views, ref, 'pick')
731
872
  return updateHead(dir, id, (cur) => ({ ...cur, agentPick: n }))
732
873
  }
@@ -736,7 +877,7 @@ export function updateHead(dir: string, id: string, fn: (cur: Item) => Item): It
736
877
  const c = io(dir)
737
878
  return c.lock(id, () => {
738
879
  const held = c.head(id)
739
- if (held == null) throw Object.assign(new Error(`no card ${id}`), { code: 'ENOENT' })
880
+ if (held == null) throw Object.assign(new Error(`no item ${id}`), { code: 'ENOENT' })
740
881
  const next = fn(held.head as Item)
741
882
  const problems = itemProblems(next)
742
883
  if (problems.length > 0) throw new Error(problems.join('; '))
@@ -745,16 +886,16 @@ export function updateHead(dir: string, id: string, fn: (cur: Item) => Item): It
745
886
  })
746
887
  }
747
888
 
748
- /** the ids of a store's cards, as their folders name them */
749
- export const cardIds = (dir: string): string[] => io(dir).names().filter((n) => ID_RE.test(n))
889
+ /** the ids of a store's items, as their folders name them */
890
+ export const itemIds = (dir: string): string[] => io(dir).names().filter((n) => ID_RE.test(n))
750
891
 
751
- /** a card's stamp: any write of its head or its thread moves it */
752
- export const cardStamp = (dir: string, id: string): string => io(dir).stamp(id)
892
+ /** an item's stamp: any write of its head or its thread moves it */
893
+ export const itemStamp = (dir: string, id: string): string => io(dir).stamp(id)
753
894
 
754
- /** a card's head as it is stored, and the time it was written; null with no head */
895
+ /** an item's head as it is stored, and the time it was written; null with no head */
755
896
  export const rawHead = (dir: string, id: string): { head: unknown; at: number } | null => io(dir).head(id)
756
897
 
757
- /** the ids of a card's messages, oldest first */
898
+ /** the ids of an item's messages, oldest first */
758
899
  export const threadIds = (dir: string, id: string): string[] => (ID_RE.test(id) ? io(dir).threadIds(id) : [])
759
900
 
760
901
  /** one message as it is stored */
@@ -762,17 +903,17 @@ export const rawMessage = (dir: string, id: string, mid: string): unknown => io(
762
903
 
763
904
  export type LandedFile = { did: 'landed' | 'same' | 'kept'; why?: string }
764
905
 
765
- /** the longest card or message id a card carried between machines may have: a folder or file name of about 120
906
+ /** the longest item or message id an item carried between machines may have: a folder or file name of about 120
766
907
  * characters fits every file system, with its `.tmp` and `.land-<pid>` beside it */
767
908
  export const MAX_ID_LENGTH = 120
768
909
 
769
- /** a head made on another machine written as this card's item.json: a new card built in a dot folder and renamed,
910
+ /** a head made on another machine written as this item's item.json: a new item built in a dot folder and renamed,
770
911
  * an existing one rewritten under its lock once `keep` (given the head as the file says now) has no reason to keep
771
912
  * it. A head that is no item of that id is kept out. `dry` says what it would do */
772
913
  export function landHead(dir: string, id: string, head: unknown, o: { keep: (cur: Item) => string | null; aside?: (cur: Item) => boolean; dry?: boolean; waitMs?: number }): LandedFile {
773
- if (id.length > MAX_ID_LENGTH) return { did: 'kept', why: `card ${id.slice(0, 40)}…: its id is over ${MAX_ID_LENGTH} characters` }
914
+ if (id.length > MAX_ID_LENGTH) return { did: 'kept', why: `item ${id.slice(0, 40)}…: its id is over ${MAX_ID_LENGTH} characters` }
774
915
  const problems = itemProblems(head)
775
- if (problems.length > 0 || (head as Item).id !== id) return { did: 'kept', why: `card ${id}: its head is no item of that id (${problems.join('; ') || 'another id'})` }
916
+ if (problems.length > 0 || (head as Item).id !== id) return { did: 'kept', why: `item ${id}: its head is no item of that id (${problems.join('; ') || 'another id'})` }
776
917
  const c = io(dir)
777
918
  const folder = c.folder(id)
778
919
  const decide = (cur: Item): LandedFile | null => {
@@ -782,7 +923,7 @@ export function landHead(dir: string, id: string, head: unknown, o: { keep: (cur
782
923
  }
783
924
  if (!c.has(id)) {
784
925
  if (o.dry) return { did: 'landed' }
785
- // the rows land a new card under the lock below, in one transaction
926
+ // the rows land a new item under the lock below, in one transaction
786
927
  if (!c.rows && !c.taken(id)) {
787
928
  mkdirSync(dir, { recursive: true })
788
929
  const tmp = join(dir, `.${id}.land-${process.pid}`)
@@ -793,7 +934,7 @@ export function landHead(dir: string, id: string, head: unknown, o: { keep: (cur
793
934
  renameSync(tmp, folder)
794
935
  return { did: 'landed' }
795
936
  } catch {
796
- // a card of that id came meanwhile: its lock decides below
937
+ // an item of that id came meanwhile: its lock decides below
797
938
  rmSync(tmp, { recursive: true, force: true })
798
939
  }
799
940
  }
@@ -818,7 +959,7 @@ export function landHead(dir: string, id: string, head: unknown, o: { keep: (cur
818
959
  ...(aside ? [`a head made apart replaced this machine's, which is kept beside it as ${REPLACED}`] : []),
819
960
  ...(moved.length > 0 ? [`this machine's files of the names the landing head gives to other bytes are kept as ${moved.join(', ')}`] : []),
820
961
  ]
821
- return said.length > 0 ? { did: 'landed', why: `card ${id}: ${said.join('; ')}` } : { did: 'landed' }
962
+ return said.length > 0 ? { did: 'landed', why: `item ${id}: ${said.join('; ')}` } : { did: 'landed' }
822
963
  }, o.waitMs)
823
964
  }
824
965
 
@@ -847,20 +988,20 @@ function setAsideClashes(folder: string, head: Item): string[] {
847
988
  return moved
848
989
  }
849
990
 
850
- /** does that card keep a head a landing replaced */
991
+ /** does that item keep a head a landing replaced */
851
992
  export const hasReplaced = (dir: string, id: string): boolean => ID_RE.test(id) && io(dir).hasReplaced(id)
852
993
 
853
- /** a message made on another machine written into its card's thread, once: never over a file of its id. `no-card`
854
- * while the card has no head here: the caller holds it. A message that is not one is kept out */
855
- export function landMessage(dir: string, id: string, m: unknown, o: { dry?: boolean } = {}): LandedFile | { did: 'no-card' } {
994
+ /** a message made on another machine written into its item's thread, once: never over a file of its id. `no-item`
995
+ * while the item has no head here: the caller holds it. A message that is not one is kept out */
996
+ export function landMessage(dir: string, id: string, m: unknown, o: { dry?: boolean } = {}): LandedFile | { did: 'no-item' } {
856
997
  const mid = m != null && typeof m === 'object' ? (m as { id?: unknown }).id : undefined
857
998
  const problems = typeof mid === 'string' && MESSAGE_RE.test(mid) ? messageProblems(m, mid) : ['no message id']
858
- if (id.length > MAX_ID_LENGTH || (typeof mid === 'string' && mid.length > MAX_ID_LENGTH)) return { did: 'kept', why: `a message of card ${id.slice(0, 40)}: an id over ${MAX_ID_LENGTH} characters` }
859
- if (!ID_RE.test(id) || problems.length > 0) return { did: 'kept', why: `a message of card ${id}: ${problems.join('; ') || 'no card id'}` }
999
+ if (id.length > MAX_ID_LENGTH || (typeof mid === 'string' && mid.length > MAX_ID_LENGTH)) return { did: 'kept', why: `a message of item ${id.slice(0, 40)}: an id over ${MAX_ID_LENGTH} characters` }
1000
+ if (!ID_RE.test(id) || problems.length > 0) return { did: 'kept', why: `a message of item ${id}: ${problems.join('; ') || 'no item id'}` }
860
1001
  const c = io(dir)
861
- if (!c.has(id)) return { did: 'no-card' }
1002
+ if (!c.has(id)) return { did: 'no-item' }
862
1003
  // one id is made on two machines only by one party in one millisecond: the one here stays, and it is said
863
- if (c.hasMessage(id, mid as string)) return revOf(c.message(id, mid as string)) === revOf(m) ? { did: 'same' } : { did: 'kept', why: `message ${mid as string} of card ${id}: another message of that id is on this machine, each machine keeps its own` }
1004
+ if (c.hasMessage(id, mid as string)) return revOf(c.message(id, mid as string)) === revOf(m) ? { did: 'same' } : { did: 'kept', why: `message ${mid as string} of item ${id}: another message of that id is on this machine, each machine keeps its own` }
864
1005
  if (o.dry) return { did: 'landed' }
865
1006
  c.append(id, m as Message)
866
1007
  return { did: 'landed' }
@@ -901,15 +1042,15 @@ export function readItem(dir: string, id: string): ReviewItem | null {
901
1042
  /** one item as it is stored, whatever the unit: what the index keeps */
902
1043
  const readRaw = (dir: string, id: string): ReviewItem | null => (ID_RE.test(id) ? (io(dir).raw(id) ?? (healed(dir, id) ? io(dir).raw(id) : null)) : null)
903
1044
 
904
- /** a card this process misses while a move runs: a process that read the switch before it turned made it on the side
1045
+ /** an item this process misses while a move runs: a process that read the switch before it turned made it on the side
905
1046
  * the move left, so it is carried over now, as the move's own pass after its lag would. Whether it is here now */
906
1047
  function healed(dir: string, id: string): boolean {
907
- if (!cardsMoving()) return false
1048
+ if (!threadsMoving()) return false
908
1049
  const c = io(dir)
909
1050
  const other = c.rows ? filesIO(dir) : rowsIO(dir)
910
1051
  if (!other.has(id)) return false
911
- const { carryCard } = require('./move.ts') as typeof import('./move.ts')
912
- carryCard(dir, id, other, c)
1052
+ const { carryItem } = require('./move.ts') as typeof import('./move.ts')
1053
+ carryItem(dir, id, other, c)
913
1054
  return c.has(id)
914
1055
  }
915
1056
 
@@ -947,15 +1088,22 @@ function readThread(dir: string, id: string): Message[] {
947
1088
  }
948
1089
 
949
1090
  /** appends one message to an item's thread, its image copied in beside it; the id never collides */
950
- export function appendMessage(dir: string, id: string, m: Omit<Message, 'id' | 'at'>, o: { image?: string; now?: Date; machine?: true } = {}): Message {
1091
+ export function appendMessage(dir: string, id: string, m: Omit<Message, 'id' | 'at'>, o: { image?: string; files?: readonly { path: string; name: string }[]; now?: Date; machine?: true } = {}): Message {
951
1092
  const now = o.now ?? new Date()
952
1093
  if (o.image !== undefined) {
953
1094
  if (!existsSync(o.image)) throw new Error(`${o.image}: no such file`)
954
1095
  if (!IMAGE_EXT.test(extname(o.image).toLowerCase())) throw new Error(`${o.image}: a png, jpg or webp`)
955
1096
  }
956
- // a card with no head here (set aside, deleted) gets no thread: a folder with no head would read as a broken card
1097
+ const given = o.files ?? []
1098
+ if (given.length > MESSAGE_FILES_MAX) throw new Error(`at most ${MESSAGE_FILES_MAX} files on one message`)
1099
+ const sizes = given.map((f) => {
1100
+ const st = statSync(f.path, { throwIfNoEntry: false })
1101
+ if (!st?.isFile()) throw new Error(`${f.name}: no such file`)
1102
+ return st.size
1103
+ })
1104
+ // an item with no head here (set aside, deleted) gets no thread: a folder with no head would read as a broken item
957
1105
  const c = io(dir)
958
- if (!c.has(id) && !healed(dir, id)) throw new Error(`no card ${id}`)
1106
+ if (!c.has(id) && !healed(dir, id)) throw new Error(`no item ${id}`)
959
1107
  const folder = join(c.folder(id), 'thread')
960
1108
  const base = messageIdOf(now, m.who)
961
1109
  let n = 1
@@ -967,9 +1115,15 @@ export function appendMessage(dir: string, id: string, m: Omit<Message, 'id' | '
967
1115
  mkdirSync(folder, { recursive: true })
968
1116
  copyFileSync(o.image, join(folder, file))
969
1117
  }
1118
+ const files: MessageFile[] = given.map((f, i) => {
1119
+ const name = cleanFileName(f.name)
1120
+ return { file: attachFile(mid, i + 1, name), name, size: sizes[i]!, type: mimeOf(name) }
1121
+ })
1122
+ if (files.length > 0) mkdirSync(folder, { recursive: true })
1123
+ for (const [i, f] of files.entries()) copyFileSync(given[i]!.path, join(folder, f.file))
970
1124
  const session = !o.machine && partyOf(m.who) === 'agent' && m.session === undefined ? sessionId() : null
971
1125
  if (session) noteSession(dir)
972
- const out: Message = { id: mid, at: now.toISOString(), ...m, ...(session ? { session } : {}), ...(file ? { image: file } : {}) }
1126
+ const out: Message = { id: mid, at: now.toISOString(), ...m, ...(session ? { session } : {}), ...(file ? { image: file } : {}), ...(files.length > 0 ? { files } : {}) }
973
1127
  try {
974
1128
  c.append(id, out)
975
1129
  return out
@@ -983,13 +1137,15 @@ export function appendMessage(dir: string, id: string, m: Omit<Message, 'id' | '
983
1137
 
984
1138
  /** a reply on an item from `who` (the owner, or an agent by its name), with an optional image; `re` the message of the
985
1139
  * item it answers (his hint on an update); throws with the reason */
986
- export function addMessage(dir: string, id: string, who: string, text: unknown, image?: string, now = new Date(), re?: unknown): Message {
1140
+ export function addMessage(dir: string, id: string, who: string, text: unknown, image?: string, now = new Date(), re?: unknown, files?: readonly { path: string; name: string }[], to?: readonly Mention[]): Message {
987
1141
  const x = readItem(dir, id)
988
- if (!x) throw new Error(`no card ${id}`)
989
- const t = textOf(text)
1142
+ if (!x) throw new Error(`no item ${id}`)
1143
+ // files alone are a reply too: their words may be empty
1144
+ const bare = (files?.length ?? 0) > 0 && (text === undefined || (typeof text === 'string' && text.trim() === ''))
1145
+ const t = bare ? { text: '' } : textOf(text)
990
1146
  if ('error' in t) throw new Error(t.error)
991
1147
  if (re !== undefined && !(typeof re === 'string' && x.thread.some((m) => m.id === re))) throw new Error(`re: ${String(re)} is no message of ${id}`)
992
- return appendMessage(dir, id, { who, text: t.text, ...(typeof re === 'string' ? { re } : {}) }, { ...(image !== undefined ? { image } : {}), now })
1148
+ return appendMessage(dir, id, { who, text: t.text, ...(typeof re === 'string' ? { re } : {}), ...(to !== undefined && to.length > 0 ? { to: [...to] } : {}) }, { ...(image !== undefined ? { image } : {}), ...(files !== undefined && files.length > 0 ? { files } : {}), now })
993
1149
  }
994
1150
 
995
1151
  /** one option of a question: its words, and its media, one file (a picture, a clip, a sound) or a before and an after */
@@ -1001,7 +1157,7 @@ export interface AskOption {
1001
1157
  /** an agent's question to the owner on a thread's item: its words, two options or more, each words or a media, the
1002
1158
  * option it picks; each option's media becomes a view the message holds (addView `message`), and the owner answers in
1003
1159
  * one click (answerAsk) */
1004
- export async function postAsk(dir: string, id: string, q: { who: string; text: unknown; options?: readonly (string | AskOption)[]; pick?: number; kind?: AnswerKind; secret?: { name: string; login?: boolean }; done?: readonly number[]; now?: Date; replaces?: string; step?: { of: string; i: number } }): Promise<Message> {
1160
+ export async function postAsk(dir: string, id: string, q: { who: string; text: unknown; options?: readonly (string | AskOption)[]; pick?: number; kind?: AnswerKind; secret?: { name: string; login?: boolean }; done?: readonly number[]; now?: Date; replaces?: string; step?: { of: string; i: number; carries?: string } }): Promise<Message> {
1005
1161
  const x = readItem(dir, id)
1006
1162
  if (!x) throw new Error(`no item ${id}`)
1007
1163
  const t = textOf(q.text)
@@ -1132,8 +1288,7 @@ export function answerAsk(dir: string, id: string, a: { re: string; option?: num
1132
1288
  const choice = m.ask.choices?.[o] ?? null
1133
1289
  if (a.pick !== undefined && choice === null) throw new Error(`pick: the step « ${lines[o]} » holds no choice`)
1134
1290
  if (a.pick !== undefined && !(Number.isInteger(a.pick) && a.pick >= 0 && a.pick < choice!.options.length && tick)) throw new Error(`pick: one of 0 to ${choice!.options.length - 1}, with a tick`)
1135
- const picked = a.pick !== undefined ? `: ${choiceName(choice!.options[a.pick]!)}` : ''
1136
- return appendMessage(dir, id, { who: 'owner', re: a.re, answer: { option: o, tick, ...(a.pick !== undefined ? { pick: a.pick } : {}) }, text: words === '' ? `${tick ? '✓' : '✗'} ${lines[o]}${picked}` : words }, at)
1291
+ return appendMessage(dir, id, { who: 'owner', re: a.re, answer: { option: o, tick, ...(a.pick !== undefined ? { pick: a.pick } : {}) }, text: words === '' ? tickText(m, o, tick, a.pick) : words }, at)
1137
1292
  }
1138
1293
  if (m.ask && (kind === 'text' || kind === 'url')) {
1139
1294
  const value = a.value?.trim() ?? ''
@@ -1160,20 +1315,23 @@ export function answerAsk(dir: string, id: string, a: { re: string; option?: num
1160
1315
  }
1161
1316
 
1162
1317
  /** the open secret question `re` of item `id`, or why there is none; its name and whether an account goes with it */
1163
- export function secretQuestion(dir: string, id: string, re: string): { name: string; login: boolean } | { error: string } {
1318
+ export function secretQuestion(dir: string, id: string, re: string, o: { again?: true } = {}): { name: string; login: boolean; open: boolean; at: number } | { error: string } {
1164
1319
  const x = readItem(dir, id)
1165
1320
  const m = x?.thread.find((y) => y.id === re)
1166
1321
  if (!x || !m || m.ask?.kind !== 'secret' || !m.ask.secret) return { error: `${re} is no secret question of ${id}` }
1167
- if (!askOpen(x.thread, m)) return { error: `${m.ask.secret.name} is no longer asked here` }
1168
- return { name: m.ask.secret.name, login: m.ask.secret.login === true }
1322
+ const open = askOpen(x.thread, m)
1323
+ // `again`: a value stored already may be replaced, the question answered once more
1324
+ if (!open && o.again !== true) return { error: `${m.ask.secret.name} is no longer asked here` }
1325
+ return { name: m.ask.secret.name, login: m.ask.secret.login === true, open, at: Date.parse(m.at) }
1169
1326
  }
1170
1327
 
1171
1328
  /** the owner's answer to a secret question once its value is in the house secret manager: the name and the time, never
1172
1329
  * the value, which this function never sees */
1173
- export function answerSecret(dir: string, id: string, a: { re: string; now?: Date }): Message {
1174
- const q = secretQuestion(dir, id, a.re)
1330
+ export function answerSecret(dir: string, id: string, a: { re: string; now?: Date; again?: true; found?: true }): Message {
1331
+ const q = secretQuestion(dir, id, a.re, a.again ? { again: true } : {})
1175
1332
  if ('error' in q) throw new Error(q.error)
1176
- return appendMessage(dir, id, { who: 'owner', re: a.re, answer: { stored: q.name }, text: `stored as ${q.name}` }, a.now ? { now: a.now } : {})
1333
+ // `found`: the store holds it since the question, put there from a terminal, not typed in the field
1334
+ return appendMessage(dir, id, { who: 'owner', re: a.re, answer: { stored: q.name }, text: `stored as ${q.name}${a.found ? ', found in the store' : ''}` }, a.now ? { now: a.now } : {})
1177
1335
  }
1178
1336
 
1179
1337
  /** the owner's click on one of the kind's actions on the thread's object: a message the holder's watch prints */
@@ -1217,12 +1375,12 @@ export interface UpdateInput {
1217
1375
  machine?: true
1218
1376
  }
1219
1377
 
1220
- /** an agent's update on its card, at any time, before or after his answer: its file, or its pair, becomes the card's next view
1378
+ /** an agent's update on its version, at any time, before or after his answer: its file, or its pair, becomes the version's next view
1221
1379
  * (labelled `update <k>: <state>`, the line its note), then one message carries the state and the line. Still broken
1222
- * or better holds the card in work, fixed asks the owner's verdict again (model.ts stateOf) */
1380
+ * or better holds the version in work, fixed asks the owner's verdict again (model.ts stateOf) */
1223
1381
  export async function postUpdate(dir: string, id: string, u: UpdateInput): Promise<{ item: Item; message: Message; tag: string; view: number | null }> {
1224
1382
  const x = readItem(dir, id)
1225
- if (!x) throw new Error(`no card ${id}`)
1383
+ if (!x) throw new Error(`no item ${id}`)
1226
1384
  if (x.item.origin.by !== 'agent') return lineOnNote(dir, x, u)
1227
1385
  if (x.item.wip) throw new Error(`${id} is a draft on a live shot: its frame refreshes itself, sk thread ready ${id} when it is done`)
1228
1386
  if (!UPDATE_STATES.includes(u.state as UpdateState)) throw new Error(`the state: one of ${UPDATE_STATES.join(', ')}, not « ${u.state} »`)
@@ -1255,16 +1413,40 @@ async function lineOnNote(dir: string, x: ReviewItem, u: UpdateInput): Promise<{
1255
1413
  return { item: x.item, message, tag: `update ${k} (${UPDATE_WORDS[state]})`, view: null }
1256
1414
  }
1257
1415
 
1258
- /** `party` read what the other party wrote on an item: one `seen` message naming them; how many it read. `only`: the
1259
- * messages a page drew, so a word that came after it is never marked read */
1260
- export function markRead(dir: string, id: string, party: Party, who: string = party === 'owner' ? 'owner' : agentName(), now = new Date(), only?: readonly string[]): number {
1416
+ /** agent `who` read what the owner wrote on an item: one `seen` message naming them; how many it read. `only`: the words
1417
+ * it may read, as `sk thread seen` reads them with the registry (threads.ts seenOnly). The owner's read: markOwnerRead */
1418
+ export function markRead(dir: string, id: string, who: string = agentName(), now = new Date(), only?: readonly string[]): number {
1261
1419
  const x = ID_RE.test(id) ? readItem(dir, id) : null
1262
1420
  if (!x) return 0
1263
- const of = toAcknowledge(x, party).filter((m) => only === undefined || only.includes(m))
1421
+ // a word that names other agents is theirs to read (wiki tools/shipkit/threads-how-it-fits.md, Mentions); `only`, read
1422
+ // with the registry, already says which reach the caller
1423
+ const theirs = new Set(only === undefined ? x.thread.filter((m) => !mayReadNamed(m, who, sessionId())).map((m) => m.id) : [])
1424
+ const of = toAcknowledge(x, 'agent').filter((m) => (only === undefined || only.includes(m)) && !theirs.has(m))
1264
1425
  if (of.length > 0) appendMessage(dir, id, { who, op: 'seen', of }, { now })
1265
1426
  return of.length
1266
1427
  }
1267
1428
 
1429
+ /** his cursor moves to `upTo`, the newest thing the page drew of the thread `ids` (head first): every agent word up to it
1430
+ * goes read, and the read mark is dated `upTo` itself (never later than now), so what an agent wrote after it stays new
1431
+ * to him (review/owner-read.ts). The number of read marks written: 0 when his cursor already passed `upTo` */
1432
+ export function markOwnerRead(dir: string, ids: readonly string[], upTo: string, now = new Date()): number {
1433
+ const at = new Date(Math.min(Date.parse(upTo), now.getTime()))
1434
+ if (Number.isNaN(at.getTime())) throw new Error('upTo: the time of the newest thing the page drew')
1435
+ const members = ids.flatMap((id) => (ID_RE.test(id) ? (readItem(dir, id) ?? []) : []))
1436
+ const to = at.toISOString()
1437
+ if (members.length === 0 || ownerCursorAt(members) >= to) return 0
1438
+ let wrote = 0
1439
+ for (const x of members) {
1440
+ const before = new Set(x.thread.filter((m) => m.at <= to).map((m) => m.id))
1441
+ const of = toAcknowledge(x, 'owner').filter((m) => before.has(m))
1442
+ if (of.length === 0) continue
1443
+ appendMessage(dir, x.item.id, { who: 'owner', op: 'seen', of }, { now: at })
1444
+ wrote++
1445
+ }
1446
+ if (wrote === 0) appendMessage(dir, members[0]!.item.id, { who: 'owner', op: 'seen', of: [] }, { now: at })
1447
+ return Math.max(wrote, 1)
1448
+ }
1449
+
1268
1450
  /** the path of a message's image, null for any other name */
1269
1451
  export function threadImage(dir: string, id: string, name: string): string | null {
1270
1452
  if (!ID_RE.test(id) || !MESSAGE_FILE_RE.test(name)) return null
@@ -1272,6 +1454,13 @@ export function threadImage(dir: string, id: string, name: string): string | nul
1272
1454
  return existsSync(f) ? f : null
1273
1455
  }
1274
1456
 
1457
+ /** the path of a message's image or attached file on the disk, null for any other name or when the disk let it go */
1458
+ export function threadFile(dir: string, id: string, name: string): string | null {
1459
+ if (!ID_RE.test(id) || !isThreadMedia(`thread/${name}`)) return null
1460
+ const f = join(io(dir).folder(id), 'thread', name)
1461
+ return existsSync(f) ? f : null
1462
+ }
1463
+
1275
1464
  /** an item's stamp: its folder and its thread. Every write renames a file into one of them (the head into the folder, a
1276
1465
  * message into thread/), which moves that directory's change time, so any write moves it. Two stats an item, never
1277
1466
  * three: on a 3000 item store each stat is 10 ms of every read */
@@ -1301,7 +1490,12 @@ function readOne(dir: string, id: string): Read {
1301
1490
 
1302
1491
  /** every item of the store as its unit reads it: an item its unit refuses (a subject kind or a topic it does not
1303
1492
  * declare, a subject's problems) is broken; the index keeps the raw reads, so a unit's change never invalidates it */
1304
- export const readAll = (dir: string): ReadAll => checked(cardsInDb() ? rowsAll(dir) : readRaws(dir), specOf(dir))
1493
+ export function readAll(dir: string): ReadAll {
1494
+ const all = checked(threadsInDb() ? rowsAll(dir) : readRaws(dir), specOf(dir))
1495
+ // a long running reader whose model moved restarts on it (model-moved.ts)
1496
+ if (all.broken.length > 0) modelWatch.readFailed()
1497
+ return all
1498
+ }
1305
1499
 
1306
1500
  const checks = new WeakMap<ReadAll, { spec: Spec; all: ReadAll }>()
1307
1501
 
@@ -1412,48 +1606,53 @@ function* readRawsSteps(dir: string, stamps?: Map<string, string>): Generator<vo
1412
1606
  /** the owner's verdict, checked against its item, appended as his message */
1413
1607
  export function writeVerdict(dir: string, id: string, body: unknown, now = new Date()): { ok: true; message: Message } | { ok: false; errors: string[] } {
1414
1608
  const x = readItem(dir, id)
1415
- if (!x) return { ok: false, errors: [`no card ${id}`] }
1416
- if (x.item.wip) return { ok: false, errors: [`${id} is a draft card: the agent makes it ready before a verdict; a comment goes in a reply`] }
1417
- if (x.item.origin.by !== 'agent') return { ok: false, errors: [`${id} was raised, not shown by an agent: a verdict goes on the card that shows its fix; a word goes in a reply`] }
1609
+ if (!x) return { ok: false, errors: [`no item ${id}`] }
1610
+ if (x.item.wip) return { ok: false, errors: [`${id} is a draft version: the agent makes it ready before a verdict; a comment goes in a reply`] }
1611
+ if (x.item.origin.by !== 'agent') return { ok: false, errors: [`${id} was raised, not shown by an agent: a verdict goes on the version that shows its fix; a word goes in a reply`] }
1418
1612
  const r = verdictMessageOf(body, x.item)
1419
1613
  if (!r.ok) return r
1420
1614
  return { ok: true, message: appendMessage(dir, id, { who: 'owner', ...r.message }, { now }) }
1421
1615
  }
1422
1616
 
1423
1617
  /** an agent acted on the verdict and the owner's replies; false when the item has neither */
1424
- export function markSeen(dir: string, id: string, now = new Date()): boolean {
1618
+ export function markSeen(dir: string, id: string, now = new Date(), only?: readonly string[]): boolean {
1425
1619
  const x = ID_RE.test(id) ? readItem(dir, id) : null
1426
1620
  if (!x) return false
1427
- const read = markRead(dir, id, 'agent', agentName(), now)
1621
+ const read = markRead(dir, id, agentName(), now, only)
1622
+ if (only !== undefined) return read > 0
1428
1623
  return verdictOf(x) !== null || read > 0
1429
1624
  }
1430
1625
 
1431
- /** takes an unanswered card back; `already` names who took it back before, `refused` says why it may not and what to type */
1626
+ /** takes an unanswered version back; `already` names who took it back before, `refused` says why it may not and what to type */
1432
1627
  export function withdraw(dir: string, id: string, why: string, now = new Date()): { already?: string } | { refused: string } {
1433
1628
  const x = ID_RE.test(id) ? readItem(dir, id) : null
1434
- if (!x) return { refused: `no card ${id}` }
1435
- const before = x.thread.filter((m) => m.op === 'withdraw').at(-1)
1629
+ if (!x) return { refused: `no item ${id}` }
1630
+ const o = x.item.origin
1631
+ if (o.by === 'owner' || o.by === 'player')
1632
+ return { refused: `${id} was raised by ${o.by === 'owner' ? 'the owner' : 'a player'}: an agent never takes it back; close it with sk thread fixed ${id} "<what was done>", or sk thread wontfix ${id} --note "<why>"` }
1633
+ const before = itemWithdrawOf(x)
1436
1634
  if (before) return { already: `by ${before.who}, ${before.at.slice(0, 16).replace('T', ' ')} UTC` }
1437
1635
  const v = verdictOf(x)
1438
1636
  if (v) {
1439
1637
  const owes = v.status === 'approved-with-fix' ? `sk thread done ${id} "<what changed>", ` : ''
1440
- const close = v.status === 'approved-with-fix' || v.status === 'rejected' ? `; what it owes: ${owes}--supersedes ${id} on its new card, or sk thread wontfix ${id} --note "<why>"` : ''
1638
+ const close = v.status === 'approved-with-fix' || v.status === 'rejected' ? `; what it owes: ${owes}--supersedes ${id} on its new version, or sk thread wontfix ${id} --note "<why>"` : ''
1441
1639
  return { refused: `${id}: he answered it (${v.status}), so it waits on him no more${close}` }
1442
1640
  }
1443
1641
  appendMessage(dir, id, { who: agentName(), op: 'withdraw', note: why }, { now })
1444
1642
  return {}
1445
1643
  }
1446
1644
 
1447
- /** takes back one open question or proposed change of an agent (`re`, its message id), with the reason: it waits on
1448
- * nobody from then, read only, its line « withdrawn: <why> » (review/supersede.ts). The words he said elsewhere (in
1449
- * chat) go in the reason, quoted, so a question answered outside the hub never stays open */
1645
+ /** takes back one object of an agent (`re`, its message id: a question, a proposed change, words), with the reason: it
1646
+ * waits on nobody from then, read only, its line « withdrawn: <why> » (review/supersede.ts). The words he said elsewhere
1647
+ * (in chat) go in the reason, quoted, so a question answered outside the hub never stays open. The owner's words are never one */
1450
1648
  export function withdrawObject(dir: string, re: string, why: string, now = new Date()): { item: string } | { refused: string } {
1451
1649
  const x = readAll(dir).items.find((y) => y.thread.some((m) => m.id === re))
1452
1650
  const m = x?.thread.find((y) => y.id === re)
1453
1651
  if (!x || !m) return { refused: `no message ${re} (sk thread show <address> lists them)` }
1454
- if (partyOf(m.who) !== 'agent' || (m.ask === undefined && m.propose === undefined) || m.instructions !== undefined)
1455
- return { refused: `${re} is no question or proposed change of an agent: withdraw takes those back (an ask's instructions: sk ask … --replaces, or its bar)` }
1456
- if (m.ask !== undefined ? !askOpen(x.thread, m) : !proposeOpen(x.thread, m)) return { refused: `${re}: he answered it already, so it waits on him no more` }
1652
+ if (partyOf(m.who) !== 'agent') return { refused: `${re} is the owner's: an agent never takes back what he wrote` }
1653
+ if (m.instructions !== undefined) return { refused: `${re} is an ask's instructions: sk ask … --replaces, or its bar` }
1654
+ if (!isObject(m)) return { refused: `${re} is no question, proposed change or words of an agent: withdraw takes those back` }
1655
+ if ((m.ask !== undefined || m.propose !== undefined || asksVerdict(m)) && !objectOpen(x.thread, m)) return { refused: `${re}: he answered it already, so it waits on him no more` }
1457
1656
  const before = x.thread.find((y) => y.op === 'withdraw' && y.re === re)
1458
1657
  if (before) return { refused: `${re}: withdrawn already by ${before.who} (${before.note ?? ''})` }
1459
1658
  appendMessage(dir, x.item.id, { who: agentName(), op: 'withdraw', re, note: why }, { now })
@@ -1463,7 +1662,7 @@ export function withdrawObject(dir: string, re: string, why: string, now = new D
1463
1662
  /** the reason a question answered in chat is withdrawn with: the owner's words, quoted */
1464
1663
  export const answeredInChat = (words: string): string => `answered in chat by the owner: « ${words.replace(/\s+/g, ' ').trim()} »`
1465
1664
 
1466
- /** an answered card waits for his answer again: its verdict stays in the thread, before the reopen. `who`: an agent
1665
+ /** an answered version waits for his answer again: its verdict stays in the thread, before the reopen. `who`: an agent
1467
1666
  * (the CLI), or the owner taking the verdict back (the hub). The verdict reopened, null when it has none */
1468
1667
  export function reopen(dir: string, id: string, o: { who?: string; now?: Date } = {}): Verdict | null {
1469
1668
  const x = ID_RE.test(id) ? readItem(dir, id) : null
@@ -1486,7 +1685,7 @@ export interface RaiseInput {
1486
1685
  subject: Subject
1487
1686
  origin: Exclude<Origin, { by: 'agent' }>
1488
1687
  title: string
1489
- /** an auto item's markdown, what its rule saw: shown as a card's `what` */
1688
+ /** an auto item's markdown, what its rule saw: shown as a version's `what` */
1490
1689
  what?: string
1491
1690
  topic?: string
1492
1691
  commit?: string
@@ -1496,6 +1695,8 @@ export interface RaiseInput {
1496
1695
  rects?: Rect[]
1497
1696
  /** the image the item shows, copied in as its first view */
1498
1697
  image?: string
1698
+ /** files of the first message, staged (stagedFiles): its words name them by their tags */
1699
+ files?: readonly { path: string; name: string }[]
1499
1700
  now?: Date
1500
1701
  }
1501
1702
 
@@ -1534,7 +1735,7 @@ export async function raiseItem(dir: string, input: RaiseInput): Promise<ReviewI
1534
1735
  const head = { ...item, ...(image ? { media: await factsOf(tmp, [image]) } : {}) }
1535
1736
  createAtCommit(dir, c, id, tmp, head)
1536
1737
  const who = input.origin.by === 'player' ? 'player' : 'owner'
1537
- if (text) appendMessage(dir, id, { who, text, ...(input.rects && input.rects.length > 0 ? { rects: input.rects } : {}) }, { now })
1738
+ if (text) appendMessage(dir, id, { who, text, ...(input.rects && input.rects.length > 0 ? { rects: input.rects } : {}) }, { now, ...(input.files && input.files.length > 0 ? { files: input.files } : {}) })
1538
1739
  return readItem(dir, id) as ReviewItem
1539
1740
  }
1540
1741
 
@@ -1573,33 +1774,11 @@ export async function ownerVerdict(dir: string, o: { subject: Subject; from: str
1573
1774
  else appendMessage(dir, x.item.id, { who: 'owner', op: 'reopen' }, at)
1574
1775
  }
1575
1776
 
1576
- /** the lock of one item while an act is checked and written: a folder made atomically, waited on for at most 2 s */
1577
- function locked<T>(dir: string, id: string, fn: () => T, waitMs = 2000): T {
1578
- const lock = join(dir, id, '.lock')
1579
- const until = Date.now() + waitMs
1580
- for (;;) {
1581
- try {
1582
- mkdirSync(lock)
1583
- break
1584
- } catch (e) {
1585
- // only a lock another holds is waited for: a folder that is missing or a file in the way is said at once
1586
- if ((e as { code?: unknown }).code !== 'EEXIST') throw e
1587
- if (Date.now() >= until) {
1588
- // a lock left by a dead process: older than the wait itself
1589
- if (Date.now() - statSync(lock).mtimeMs > 2000) {
1590
- rmSync(lock, { recursive: true, force: true })
1591
- continue
1592
- }
1593
- throw new Error(`${id}: locked by another process`)
1594
- }
1595
- Bun.sleepSync(10)
1596
- }
1597
- }
1598
- try {
1599
- return fn()
1600
- } finally {
1601
- rmSync(lock, { recursive: true, force: true })
1602
- }
1777
+ /** the lease of one item (`<id>/.item.lock`) while an act is checked and written, waited on for at most `waitMs` */
1778
+ export function lockedItem<T>(dir: string, id: string, fn: () => T, waitMs = 2000): T {
1779
+ const r = withLeaseSync(join(dir, id, '.item'), { label: `the item ${id}`, waitMs }, fn)
1780
+ if (!r.ok) throw new Error(`${id}: locked by another process`)
1781
+ return r.value
1603
1782
  }
1604
1783
 
1605
1784
  /** a state change on an item by `who`, checked by `allowed` under the item's lock, so two workers claiming at once
@@ -1615,13 +1794,13 @@ export function act(dir: string, id: string, op: Exclude<Op, 'seen'>, who: strin
1615
1794
  if (o.topic !== undefined && Object.keys(spec.topics).length > 0 && !spec.topics[o.topic]) throw new Error(`no topic « ${o.topic} »: ${Object.keys(spec.topics).join(', ')}`)
1616
1795
  if (o.commit !== undefined && !/^[0-9a-f]{7,40}$/.test(o.commit)) throw new Error(`« ${o.commit} » is no commit`)
1617
1796
  const now = o.now ?? new Date()
1618
- // the first read of a process reads every card: done before the lock, the read under it only takes what moved
1797
+ // the first read of a process reads every item: done before the lock, the read under it only takes what moved
1619
1798
  readAll(dir)
1620
1799
  return io(dir).lock(id, () => {
1621
1800
  const x = readItem(dir, id) as ReviewItem
1622
1801
  const superseded = isFollowed(id, readAll(dir).items)
1623
1802
  const role = spec.dispatcher ? (roleOf(dir)?.name ?? null) : null
1624
- const why = op === 'claim' && superseded && x.item.origin.by === 'agent' ? 'a newer card redoes it: claim that one' : allowed(stateOf(x, superseded), op, who, role, spec.dispatcher, o.holds === true)
1803
+ const why = op === 'claim' && superseded && x.item.origin.by === 'agent' ? 'a newer version redoes it: claim that one' : allowed(stateOf(x, superseded), op, who, role, spec.dispatcher, o.holds === true)
1625
1804
  if (why) throw new Error(`${id}: ${why}`)
1626
1805
  const m = appendMessage(
1627
1806
  dir,
@@ -1665,7 +1844,7 @@ export function claimNext(dir: string, by: { lane: string } | { topic: string },
1665
1844
  return null
1666
1845
  }
1667
1846
 
1668
- /** the owner deletes what he raised himself (a note he takes back): its folder goes; an agent's card is never deleted
1847
+ /** the owner deletes what he raised himself (a note he takes back): its folder goes; an agent's version is never deleted
1669
1848
  * this way */
1670
1849
  export function deleteRaised(dir: string, id: string): void {
1671
1850
  const x = ID_RE.test(id) ? readItem(dir, id) : null
@@ -1684,35 +1863,36 @@ export function deleteReport(dir: string, id: string): void {
1684
1863
 
1685
1864
  export { GONE, GONE_KEEP_MS, goneCreated, goneEntries, sweepGone } from './gone.ts'
1686
1865
 
1687
- /** a card out of the store: set aside while this machine carries its cards to the hq (the switch hq-cards), so the
1866
+ /** an item out of the store: set aside while this machine carries its items to the hq (the switch hq-cards), so the
1688
1867
  * job sends its deletion, and always as rows (kept GONE_KEEP_MS, the way back), else removed as it always was */
1689
1868
  function removeItem(dir: string, id: string): void {
1690
1869
  const c = io(dir)
1691
- // while a move runs, a deletion stays as a card set aside, so neither pass carries the card back
1692
- if (c.rows || cardsOn() || cardsMoving()) c.setAside(id, {})
1870
+ // while a move runs, a deletion stays as an item set aside, so neither pass carries the item back
1871
+ if (c.rows || threadsOn() || threadsMoving()) c.setAside(id, {})
1693
1872
  else rmSync(join(dir, id), { recursive: true, force: true })
1694
1873
  }
1695
1874
 
1696
- /** a card's folder moved to `.gone/<id>` (or `<id>.<n>` beside an earlier one), whole and under its lock: the one way
1697
- * a card leaves the store when another machine deleted it. `created`: only the card made at that moment, so another
1698
- * card under that id stays. What it did */
1875
+ /** an item's folder moved to `.gone/<id>` (or `<id>.<n>` beside an earlier one), whole and under its lock: the one way
1876
+ * an item leaves the store when another machine deleted it. `created`: only the item made at that moment, so another
1877
+ * item under that id stays. What it did */
1699
1878
  export const setAside = (dir: string, id: string, o: { created?: string; before?: number } = {}): 'moved' | 'none' | 'other' => (ID_RE.test(id) ? io(dir).setAside(id, o) : 'none')
1700
1879
 
1701
1880
  /** the files' set aside: the folder moved, whole */
1702
1881
  function setAsideFile(dir: string, id: string, o: { created?: string; before?: number }): 'moved' | 'none' | 'other' {
1703
1882
  if (!ID_RE.test(id) || !existsSync(join(dir, id))) return 'none'
1704
- return locked(dir, id, () => {
1883
+ return lockedItem(dir, id, () => {
1705
1884
  if (o.created !== undefined || o.before !== undefined) {
1706
1885
  const f = join(dir, id, 'item.json')
1707
1886
  const cur = existsSync(f) ? (JSON.parse(readFileSync(f, 'utf8')) as { created?: unknown }) : null
1708
1887
  if (o.created !== undefined && cur?.created !== o.created) return 'other'
1709
- // `before`: only a card made before that moment
1888
+ // `before`: only an item made before that moment
1710
1889
  if (o.before !== undefined && !(Date.parse(String(cur?.created)) < o.before)) return 'other'
1711
1890
  }
1712
1891
  mkdirSync(join(dir, GONE), { recursive: true })
1713
1892
  const to = join(dir, GONE, goneEntryFor(dir, id))
1714
1893
  renameSync(join(dir, id), to)
1715
- // the lock moved with the folder: the card is no longer here to lock
1894
+ // the lock moved with the folder: the item is no longer here to lock (`.lock`, the folder of before the lease)
1895
+ rmSync(join(to, '.item.lock'), { force: true })
1716
1896
  rmSync(join(to, '.lock'), { recursive: true, force: true })
1717
1897
  return 'moved'
1718
1898
  })
@@ -1749,19 +1929,19 @@ function itemOfPrefix(dir: string, ref: string): ReviewItem | null {
1749
1929
  /** a player's report as the owner names it: `live#85`; any other item by its id */
1750
1930
  export const refOf = (x: ReviewItem): string => (x.item.origin.by === 'player' ? `${x.item.origin.server}#${x.item.origin.serverId}` : x.item.id)
1751
1931
 
1752
- /** a draft card's live frame and its history again: the first view's image replaced, the history a gallery view; the
1932
+ /** a draft version's live frame and its history again: the first view's image replaced, the history a gallery view; the
1753
1933
  * draft's frame count moves */
1754
1934
  export async function refreshDraft(dir: string, id: string, o: { image: string; history?: { file: string; label: string }[] }): Promise<Item> {
1755
1935
  const x = readItem(dir, id)
1756
- if (!x) throw new Error(`no card ${id}`)
1936
+ if (!x) throw new Error(`no item ${id}`)
1757
1937
  const r = x.item
1758
- if (!r.wip || verdictOf(x)) throw new Error(`${id} is not a draft card waiting`)
1938
+ if (!r.wip || verdictOf(x)) throw new Error(`${id} is not a draft version waiting`)
1759
1939
  const f0 = r.views[0]
1760
1940
  if (!f0 || isGallery(f0) || !('image' in f0.files)) throw new Error(`${id}: its first view is no image`)
1761
1941
  const folder = io(dir).folder(id)
1762
1942
  mkdirSync(folder, { recursive: true })
1763
1943
  const image = f0.files.image
1764
- // the frame keeps the name the card gave its first one: a webp, or a picture as given before cards kept webps
1944
+ // the frame keeps the name the version gave its first one: a webp, or a picture as given before items kept webps
1765
1945
  const webp = extname(image) === '.webp'
1766
1946
  const main = await loadView({ label: f0.label, image: o.image }, 'the live frame', webp ? { always: true } : { keep: true })
1767
1947
  putFile(main, main.sources[0]?.[1] ?? '', join(folder, `${image}.tmp`))
@@ -1782,21 +1962,21 @@ export async function refreshDraft(dir: string, id: string, o: { image: string;
1782
1962
  return updateHead(dir, id, () => ({ ...next, media }))
1783
1963
  }
1784
1964
 
1785
- /** the label of a draft card's history view */
1965
+ /** the label of a draft version's history view */
1786
1966
  export const HISTORY = 'history'
1787
1967
 
1788
- /** a draft card made a card he answers: its image the last frame or `image`, the draft state gone */
1968
+ /** a draft version made a version he answers: its image the last frame or `image`, the draft state gone */
1789
1969
  export async function readyItem(dir: string, id: string, o: { image?: string; now?: Date } = {}): Promise<Item> {
1790
1970
  const x = readItem(dir, id)
1791
- if (!x) throw new Error(`no card ${id}`)
1971
+ if (!x) throw new Error(`no item ${id}`)
1792
1972
  const { wip, ...rest } = x.item
1793
1973
  if (!wip && inWork(x)) {
1794
- // a card its updates hold in work: ready asks the owner's verdict, its newest picture goes on as an update
1974
+ // a version its updates hold in work: ready asks the owner's verdict, its newest picture goes on as an update
1795
1975
  if (o.image !== undefined) throw new Error(`${id} is in work by its updates: its new picture goes on as one, ${updateLine(id).replace('<broken|better|fixed>', 'fixed')}`)
1796
1976
  appendMessage(dir, id, { who: agentName(), op: 'ready' }, o.now ? { now: o.now } : {})
1797
1977
  return x.item
1798
1978
  }
1799
- if (!wip) throw new Error(`${id} is not a draft card: it already takes a verdict`)
1979
+ if (!wip) throw new Error(`${id} is not a draft version: it already takes a verdict`)
1800
1980
  let item: Item = rest
1801
1981
  if (o.image !== undefined) {
1802
1982
  const f0 = rest.views[0]
@@ -1840,7 +2020,7 @@ const folderStamp = (key: string): string => {
1840
2020
  }
1841
2021
 
1842
2022
  /** the disk checked under the watch, which goes silent under load (FSEvents drops events) and must never freeze the
1843
- * list: each call stats the store folder (1 µs), which a card's arrival or removal moves (a rename in it), and every
2023
+ * list: each call stats the store folder (1 µs), which an item's arrival or removal moves (a rename in it), and every
1844
2024
  * SWEEP_MS the stamp of each item. What moved unheard goes dirty and moves the ETag */
1845
2025
  function verify(key: string, w: Watched, now: number): void {
1846
2026
  if (!w.held) return
@@ -1884,11 +2064,11 @@ function touched(path: string): void {
1884
2064
  }
1885
2065
 
1886
2066
  const STORE_SEGMENT = `/${LAYOUT.review}/`
1887
- /** a write in a card moves the store folder's own times: a process with no watch of it (the daemon's due, a watch that
2067
+ /** a write in an item moves the store folder's own times: a process with no watch of it (the daemon's due, a watch that
1888
2068
  * died) sees any process's write with one stat of the folder. A lock is no change of the store */
1889
2069
  function stampStore(p: string): void {
1890
2070
  const i = p.lastIndexOf(STORE_SEGMENT)
1891
- if (i < 0 || p.endsWith('/.lock')) return
2071
+ if (i < 0 || isLockFile(p)) return
1892
2072
  const now = new Date()
1893
2073
  try {
1894
2074
  fs.utimesSync(p.slice(0, i + STORE_SEGMENT.length - 1), now, now)
@@ -1904,7 +2084,7 @@ function watchOf(dir: string): Watched | null {
1904
2084
  try {
1905
2085
  // an item's lock is no change of the list
1906
2086
  const watcher = watch(key, { recursive: true }, (_, name) => {
1907
- if (name?.endsWith('.lock')) return
2087
+ if (name != null && isLockFile(name)) return
1908
2088
  w.moved++
1909
2089
  if (name) w.dirty.add(name.split('/')[0] ?? '')
1910
2090
  else w.held = null
@@ -1922,7 +2102,7 @@ function watchOf(dir: string): Watched | null {
1922
2102
  /** a watched store read whole before a page asks, the loop given back between two steps: the first read after a boot
1923
2103
  * is the only whole one, every later one reads the items that moved */
1924
2104
  export async function warmStore(dir: string): Promise<void> {
1925
- if (cardsInDb()) return void rowsAll(dir)
2105
+ if (threadsInDb()) return void rowsAll(dir)
1926
2106
  if (!existsSync(dir)) return
1927
2107
  const w = watchOf(dir)
1928
2108
  if (!w || (w.held && w.all)) return
@@ -1938,7 +2118,7 @@ export async function warmStore(dir: string): Promise<void> {
1938
2118
  /** changes when anything the list is built from changes: watched, a count of writes and what the disk check found;
1939
2119
  * else a scan. The list's ETag */
1940
2120
  export function storeStamp(dir: string, now = Date.now()): string {
1941
- if (cardsInDb()) return rowsStamp(dir)
2121
+ if (threadsInDb()) return rowsStamp(dir)
1942
2122
  if (!existsSync(dir)) return 'none'
1943
2123
  const w = watchOf(dir)
1944
2124
  if (!w) return scanStamp(dir)
@@ -1949,22 +2129,22 @@ export function storeStamp(dir: string, now = Date.now()): string {
1949
2129
  /** what moved the store, from what this process heard: its watch's events, its own writes, the store folder (one
1950
2130
  * stat). Never a stat of its items: an event the watch missed waits for the next walk of the caller's own */
1951
2131
  export function storeMoved(dir: string): string {
1952
- if (cardsInDb()) return rowsStamp(dir)
2132
+ if (threadsInDb()) return rowsStamp(dir)
1953
2133
  if (!existsSync(dir)) return 'none'
1954
2134
  const key = resolve(dir)
1955
2135
  const w = watchOf(dir)
1956
2136
  return w ? `${BOOT}.${w.moved}.${wrote}.${folderStamp(key)}` : `${BOOT}.-.${wrote}.${folderStamp(key)}`
1957
2137
  }
1958
2138
 
1959
- /** does the store hold anything: its folder, or with the switch cards-in-db its rows (a repo's cards may have no folder) */
1960
- export const hasStore = (dir: string): boolean => (cardsInDb() ? rowsStamp(dir) !== 'none' : existsSync(dir))
2139
+ /** does the store hold anything: its folder, or with the switch cards-in-db its rows (a repo's items may have no folder) */
2140
+ export const hasStore = (dir: string): boolean => (threadsInDb() ? rowsStamp(dir) !== 'none' : existsSync(dir))
1961
2141
 
1962
2142
  /** the store's stamp and who listens (the live watchers' pids), so a watch that starts or dies moves it too */
1963
2143
  export const listingStamp = (dir: string): string => `${storeStamp(dir)}~${liveWatchers(dir).map((w) => w.pid).join(',')}`
1964
2144
 
1965
2145
  /** the stamp from a scan of every item's files: the safety net of a watcher that may miss an event */
1966
2146
  export function scanStamp(dir: string): string {
1967
- if (cardsInDb()) return rowsStamp(dir)
2147
+ if (threadsInDb()) return rowsStamp(dir)
1968
2148
  const h = new Bun.CryptoHasher('sha1')
1969
2149
  if (!existsSync(dir)) return 'none'
1970
2150
  const mark = (f: string): void => {
@@ -1983,7 +2163,7 @@ export function scanStamp(dir: string): string {
1983
2163
  let cached: { dir: string; tag: string; all: ReadAll } | null = null
1984
2164
 
1985
2165
  /** readAll kept while nothing it reads changed: watched, only the items written since are read again */
1986
- export const readAllCached = (dir: string): ReadAll => checked(cardsInDb() ? rowsAll(dir) : readRawsCached(dir), specOf(dir))
2166
+ export const readAllCached = (dir: string): ReadAll => checked(threadsInDb() ? rowsAll(dir) : readRawsCached(dir), specOf(dir))
1987
2167
 
1988
2168
  function readRawsCached(dir: string): ReadAll {
1989
2169
  const w = existsSync(dir) ? watchOf(dir) : null