rvlib-shipkit 2.31.0 → 2.33.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 (408) hide show
  1. package/CHANGELOG.md +51 -0
  2. package/package.json +1 -1
  3. package/src/advisors/acts.ts +16 -15
  4. package/src/advisors/advice.ts +56 -102
  5. package/src/advisors/advisor-view.ts +122 -76
  6. package/src/advisors/app-graph.ts +1 -1
  7. package/src/advisors/app.ts +3 -11
  8. package/src/advisors/cf-api.ts +1 -1
  9. package/src/advisors/dir-bucket.ts +4 -3
  10. package/src/advisors/edge/api.ts +20 -221
  11. package/src/advisors/edge/bucket.ts +2 -2
  12. package/src/advisors/edge/handler.ts +13 -155
  13. package/src/advisors/edge/here.ts +5 -5
  14. package/src/advisors/edge/pages.ts +12 -9
  15. package/src/advisors/edge/shell.ts +6 -5
  16. package/src/advisors/edge/sign-in.ts +101 -36
  17. package/src/advisors/edge/status.ts +19 -6
  18. package/src/advisors/edge/types.ts +36 -60
  19. package/src/advisors/expose.ts +29 -29
  20. package/src/advisors/here.ts +12 -12
  21. package/src/advisors/invite-send.ts +79 -35
  22. package/src/advisors/invite.ts +31 -8
  23. package/src/advisors/job.ts +24 -16
  24. package/src/advisors/login.ts +40 -15
  25. package/src/advisors/owner-store.ts +46 -22
  26. package/src/advisors/photos.ts +3 -3
  27. package/src/advisors/project.ts +27 -25
  28. package/src/advisors/reach.ts +89 -0
  29. package/src/advisors/rights.ts +1 -1
  30. package/src/advisors/routes.ts +55 -74
  31. package/src/advisors/scan.ts +0 -4
  32. package/src/advisors/setup-run.ts +14 -14
  33. package/src/advisors/share-trace.ts +3 -3
  34. package/src/advisors/{door-probe.ts → sign-in-probe.ts} +7 -6
  35. package/src/advisors/speaks.ts +29 -0
  36. package/src/advisors/sync.ts +97 -183
  37. package/src/advisors/tunnel.ts +6 -5
  38. package/src/advisors/users-listen.ts +92 -0
  39. package/src/advisors/users-router.ts +261 -87
  40. package/src/advisors/users-store.ts +81 -0
  41. package/src/agent-time/blocked-scan.ts +181 -0
  42. package/src/agent-time/registry.ts +12 -5
  43. package/src/agent-time/store.ts +9 -109
  44. package/src/asks/ask-bar-fold.ts +2 -1
  45. package/src/asks/ask-close.ts +2 -1
  46. package/src/asks/ask-doc.ts +2 -1
  47. package/src/asks/ask-migrate.ts +3 -2
  48. package/src/asks/ask-steps-fold.ts +2 -1
  49. package/src/asks/ask-store.ts +4 -3
  50. package/src/check.ts +3 -43
  51. package/src/checks/SK001-package-json-shape.check.ts +4 -55
  52. package/src/checks/SK004-gitignore-policy.check.ts +24 -69
  53. package/src/checks/SK013-one-way-in-policy.check.ts +3 -7
  54. package/src/checks/SK017-vscode-hub-task.check.ts +4 -4
  55. package/src/checks/SK019-tests-run-in-units.check.ts +3 -14
  56. package/src/checks/SK020-self-spawning-check.check.ts +5 -7
  57. package/src/checks/SK035-public-clean.check.ts +1 -1
  58. package/src/checks/SK039-vscode-watch-generated.check.ts +1 -1
  59. package/src/checks/SK042-post-kinds.check.ts +5 -14
  60. package/src/checks/SK054-agent-allow-list.check.ts +5 -74
  61. package/src/checks/SK055-retired-config-keys.check.ts +45 -0
  62. package/src/cli/cmd_Advisors.ts +11 -45
  63. package/src/cli/cmd_Asks.ts +3 -10
  64. package/src/cli/cmd_Backup.ts +25 -127
  65. package/src/cli/cmd_BackupTargets.ts +1 -1
  66. package/src/cli/cmd_Capacity.ts +6 -2
  67. package/src/cli/cmd_Checks.ts +0 -14
  68. package/src/cli/cmd_Ci.ts +2 -1
  69. package/src/cli/cmd_Db.ts +3 -82
  70. package/src/cli/cmd_Home.ts +4 -32
  71. package/src/cli/cmd_Hq.ts +0 -17
  72. package/src/cli/cmd_Releases.ts +57 -4
  73. package/src/cli/cmd_Review.ts +333 -354
  74. package/src/cli/cmd_Shot.ts +26 -4
  75. package/src/cli/cmd_SocialDrafts.ts +6 -13
  76. package/src/cli/cmd_ThreadSyncNeeds.ts +6 -2
  77. package/src/cli/cmd_Time.ts +1 -1
  78. package/src/cli/cmd_Trailer.ts +1 -1
  79. package/src/cli/inbox-hook-run.ts +5 -23
  80. package/src/cli/registry-heads.ts +5 -55
  81. package/src/cli/registry.ts +1 -5
  82. package/src/cli/review-here.ts +1 -1
  83. package/src/cli.ts +15 -4
  84. package/src/collections/collection-types.ts +1 -1
  85. package/src/collections/review.ts +5 -4
  86. package/src/core/admission.ts +268 -0
  87. package/src/core/agent-allow-policy.ts +32 -2
  88. package/src/core/agent-env.ts +8 -0
  89. package/src/core/allow-rows.ts +74 -0
  90. package/src/core/check-file-names.ts +19 -106
  91. package/src/core/code-lines.ts +36 -21
  92. package/src/core/footprint.ts +17 -13
  93. package/src/core/identities-root.ts +1 -4
  94. package/src/core/layout.ts +1 -2
  95. package/src/core/machine-db.ts +33 -208
  96. package/src/core/machine-layout.ts +14 -127
  97. package/src/core/machine-read.ts +5 -2
  98. package/src/core/mask-source.ts +60 -0
  99. package/src/core/memory-watch.ts +17 -14
  100. package/src/core/motherhome.ts +8 -35
  101. package/src/core/one-way-in-policy.ts +0 -3
  102. package/src/core/peer-sk.ts +8 -0
  103. package/src/core/repo-walk.ts +0 -9
  104. package/src/core/retention.ts +1 -9
  105. package/src/core/retired-checks.ts +2 -0
  106. package/src/core/tmux-policy.ts +1 -1
  107. package/src/core/tree-watch.ts +2 -2
  108. package/src/core/when.ts +7 -45
  109. package/src/gate/admit-heavy.ts +150 -0
  110. package/src/gate/check-runner.ts +6 -0
  111. package/src/gate/discover-checks.ts +42 -32
  112. package/src/gate/gate-checks.ts +21 -131
  113. package/src/gate/head-gate.ts +1 -1
  114. package/src/gate/job-run.ts +2 -1
  115. package/src/gate/pre-commit-discovery.ts +22 -28
  116. package/src/gate/run-check.ts +3 -4
  117. package/src/gate/run-ci.ts +4 -0
  118. package/src/gate/run-fix.ts +5 -17
  119. package/src/gate/run-fixers.ts +6 -42
  120. package/src/home/app-sign.ts +2 -2
  121. package/src/home/backup-status.ts +52 -92
  122. package/src/home/backup-verdict.ts +2 -2
  123. package/src/home/daemon-jobs.ts +51 -95
  124. package/src/home/database-words.ts +1 -2
  125. package/src/home/databases.ts +9 -25
  126. package/src/home/home-launchd.ts +0 -6
  127. package/src/home/home-paths.ts +8 -4
  128. package/src/home/home-routes.ts +3 -10
  129. package/src/home/home-state.ts +2 -14
  130. package/src/home/inbox-shape.ts +14 -15
  131. package/src/home/inbox.ts +1 -1
  132. package/src/home/machine-repair.ts +102 -103
  133. package/src/home/resume.ts +1 -15
  134. package/src/home/run-daemon.ts +7 -12
  135. package/src/home/space-page.ts +3 -2
  136. package/src/home/supervise.ts +3 -7
  137. package/src/hooks/commit-msg-run.ts +61 -0
  138. package/src/hooks/commit-run.ts +16 -166
  139. package/src/hooks/gate-outcome.ts +108 -0
  140. package/src/hooks/git-hook.ts +9 -9
  141. package/src/hooks/hook-config.ts +8 -8
  142. package/src/hooks/leak-guard.ts +1 -1
  143. package/src/hooks/pre-commit-checks.ts +1 -1
  144. package/src/hooks/run-hooks.ts +2 -6
  145. package/src/hooks/shared-file.ts +3 -2
  146. package/src/hq/daemon-db.ts +8 -8
  147. package/src/hq/door.ts +3 -16
  148. package/src/hq/hq-db.ts +4 -3
  149. package/src/hq/hq-local.ts +1 -2
  150. package/src/hq/hq-store.ts +0 -15
  151. package/src/hq/item-direct.ts +8 -10
  152. package/src/hq/item-fill.ts +37 -0
  153. package/src/hq/kinds/item-gone.ts +7 -10
  154. package/src/hq/kinds/item-msg.ts +12 -18
  155. package/src/hq/kinds/item.ts +13 -19
  156. package/src/hq/kinds/report.ts +3 -4
  157. package/src/hq/owner-switch.ts +3 -3
  158. package/src/hq/report.ts +5 -9
  159. package/src/hq/switch.ts +2 -11
  160. package/src/hq/thread-sync.ts +5 -17
  161. package/src/hq/{shapes-words.ts → threads-words.ts} +2 -12
  162. package/src/http/owner-word.ts +1 -1
  163. package/src/identities/machine.ts +16 -0
  164. package/src/init-repo.ts +0 -1
  165. package/src/ledger/check-stats.ts +6 -5
  166. package/src/ledger/db.ts +2 -4
  167. package/src/ledger/record-kept.ts +117 -48
  168. package/src/ledger/run-log.ts +21 -2
  169. package/src/ledger/slow-tests.ts +96 -0
  170. package/src/ledger/store.ts +3 -86
  171. package/src/ledger/suite-log.ts +8 -2
  172. package/src/media-store/backup/facts.ts +3 -37
  173. package/src/media-store/backup/keys.ts +1 -8
  174. package/src/media-store/backup/manifest.ts +6 -67
  175. package/src/media-store/backup/restore.ts +4 -13
  176. package/src/media-store/backup/retention.ts +13 -1
  177. package/src/media-store/backup/run.ts +6 -267
  178. package/src/media-store/backup/snapshot.ts +2 -38
  179. package/src/media-store/backup/sources.ts +3 -113
  180. package/src/media-store/backup/target-send.ts +5 -29
  181. package/src/media-store/db.ts +8 -7
  182. package/src/media-store/forget-one.ts +1 -1
  183. package/src/media-store/forget.ts +1 -80
  184. package/src/orchestrator/guards.ts +0 -1
  185. package/src/orchestrator/presence.ts +2 -2
  186. package/src/orchestrator/routes.ts +1 -1
  187. package/src/orchestrator/started.ts +0 -9
  188. package/src/orchestrator/talk-key.ts +3 -4
  189. package/src/orchestrator/unheard.ts +1 -1
  190. package/src/plan/planner.ts +3 -2
  191. package/src/recordings/edit.ts +3 -3
  192. package/src/recordings/marks-draw.ts +17 -6
  193. package/src/recordings/marks.ts +120 -9
  194. package/src/reflections/reflections-queue.ts +3 -10
  195. package/src/release/notes.ts +1 -1
  196. package/src/release/public-clean.ts +66 -6
  197. package/src/release/run-bump.ts +11 -0
  198. package/src/release/run-release.ts +4 -0
  199. package/src/releases/from-thread.ts +3 -3
  200. package/src/releases/model.ts +186 -36
  201. package/src/releases/store.ts +13 -3
  202. package/src/releases/validate.ts +83 -0
  203. package/src/repo-config.ts +36 -64
  204. package/src/review/answer-kinds.ts +63 -4
  205. package/src/review/blocked-guard.ts +11 -0
  206. package/src/review/blocked-object.ts +298 -0
  207. package/src/review/cells.ts +144 -230
  208. package/src/review/close.ts +39 -1
  209. package/src/review/doc-save.ts +3 -2
  210. package/src/review/draft-item.ts +1 -1
  211. package/src/review/events.ts +3 -7
  212. package/src/review/expect.ts +23 -39
  213. package/src/review/format.ts +79 -46
  214. package/src/review/glyphs.ts +1 -0
  215. package/src/review/hand-over.ts +3 -3
  216. package/src/review/heard.ts +1 -1
  217. package/src/review/holds-sync.ts +2 -1
  218. package/src/review/inbox-hook.ts +2 -2
  219. package/src/review/inbox-read.ts +39 -33
  220. package/src/review/instruction-guards.ts +12 -0
  221. package/src/review/instructions.ts +0 -1
  222. package/src/review/item-db.ts +13 -43
  223. package/src/review/item-hq.ts +2 -2
  224. package/src/review/item-rows.ts +3 -14
  225. package/src/review/kind-catalog.ts +3 -1
  226. package/src/review/kinds.ts +18 -8
  227. package/src/review/live-view.ts +3 -0
  228. package/src/review/media-kind.ts +1 -1
  229. package/src/review/mentions.ts +1 -2
  230. package/src/review/model.ts +158 -114
  231. package/src/review/move.ts +149 -0
  232. package/src/review/need-threads.ts +3 -2
  233. package/src/review/object-card.ts +11 -0
  234. package/src/review/object-read.ts +6 -1
  235. package/src/review/one-block.ts +1 -1
  236. package/src/review/owner-read.ts +1 -1
  237. package/src/review/phone-push.ts +10 -9
  238. package/src/review/previews.ts +32 -4
  239. package/src/review/push.ts +2 -2
  240. package/src/review/recap.ts +129 -0
  241. package/src/review/referring.ts +6 -3
  242. package/src/review/reflection-object.ts +4 -3
  243. package/src/review/routes.ts +51 -47
  244. package/src/review/secret-route.ts +3 -2
  245. package/src/review/settle.ts +0 -6
  246. package/src/review/snooze.ts +5 -3
  247. package/src/review/speaker.ts +68 -0
  248. package/src/review/start-title.ts +19 -0
  249. package/src/review/store-parties.ts +28 -0
  250. package/src/review/store.ts +94 -59
  251. package/src/review/{wakes.ts → thread-events.ts} +92 -7
  252. package/src/review/thread-md.ts +35 -14
  253. package/src/review/thread-state.ts +804 -0
  254. package/src/review/threads.ts +29 -347
  255. package/src/review/traces.ts +104 -7
  256. package/src/review/trailer-item.ts +1 -1
  257. package/src/review/unit.ts +7 -9
  258. package/src/review/verdict-items.ts +12 -10
  259. package/src/review/view-layout.ts +25 -1
  260. package/src/review/watch-feed.ts +1 -2
  261. package/src/review/working-guards.ts +2 -3
  262. package/src/rules/untrack-generated.ts +1 -15
  263. package/src/secrets/copy.ts +4 -4
  264. package/src/secrets/lapse.ts +2 -1
  265. package/src/serve/hub-app/advisor-app.tsx +4 -4
  266. package/src/serve/hub-app/advisor-face.tsx +9 -3
  267. package/src/serve/hub-app/advisor-host.ts +27 -27
  268. package/src/serve/hub-app/advisors-model.ts +17 -8
  269. package/src/serve/hub-app/advisors-rights.tsx +1 -1
  270. package/src/serve/hub-app/advisors-st.ts +15 -14
  271. package/src/serve/hub-app/advisors-view.tsx +13 -11
  272. package/src/serve/hub-app/app-bridge.ts +23 -3
  273. package/src/serve/hub-app/asks-page.tsx +1 -1
  274. package/src/serve/hub-app/auto-text.tsx +71 -16
  275. package/src/serve/hub-app/check-view.tsx +0 -8
  276. package/src/serve/hub-app/controls.css +14 -3
  277. package/src/serve/hub-app/database-view.tsx +1 -2
  278. package/src/serve/hub-app/dock-st.ts +1 -1
  279. package/src/serve/hub-app/git-view.tsx +3 -1
  280. package/src/serve/hub-app/hub.css +12 -5
  281. package/src/serve/hub-app/icons.tsx +1 -1
  282. package/src/serve/hub-app/inbox-view.tsx +1 -2
  283. package/src/serve/hub-app/live-sources.ts +2 -2
  284. package/src/serve/hub-app/main-panel.tsx +2 -1
  285. package/src/serve/hub-app/panel-repo.ts +0 -9
  286. package/src/serve/hub-app/pic.tsx +29 -12
  287. package/src/serve/hub-app/polled.ts +16 -2
  288. package/src/serve/hub-app/recordings-st.ts +23 -2
  289. package/src/serve/hub-app/recordings-view.tsx +68 -10
  290. package/src/serve/hub-app/ref-pill.ts +1 -1
  291. package/src/serve/hub-app/repo-st.ts +1 -2
  292. package/src/serve/hub-app/review/advisor-add.tsx +1 -1
  293. package/src/serve/hub-app/review/advisor-invite.tsx +1 -1
  294. package/src/serve/hub-app/review/draft-body.tsx +2 -2
  295. package/src/serve/hub-app/review/heard-line.tsx +1 -1
  296. package/src/serve/hub-app/review/instructions-view.tsx +1 -8
  297. package/src/serve/hub-app/review/kind-states.tsx +14 -9
  298. package/src/serve/hub-app/review/kit.tsx +4 -11
  299. package/src/serve/hub-app/review/lane-bar.tsx +3 -3
  300. package/src/serve/hub-app/review/lightbox.tsx +15 -11
  301. package/src/serve/hub-app/review/line-window.ts +4 -1
  302. package/src/serve/hub-app/review/live-bar-st.ts +2 -2
  303. package/src/serve/hub-app/review/live-view.tsx +57 -1
  304. package/src/serve/hub-app/review/object-panel.tsx +20 -8
  305. package/src/serve/hub-app/review/question-views.tsx +191 -53
  306. package/src/serve/hub-app/review/recap-bar.tsx +40 -0
  307. package/src/serve/hub-app/review/request-cell.tsx +48 -0
  308. package/src/serve/hub-app/review/review-cells.tsx +154 -96
  309. package/src/serve/hub-app/review/review-host.ts +8 -4
  310. package/src/serve/hub-app/review/review-kit.ts +17 -11
  311. package/src/serve/hub-app/review/review-list.tsx +30 -35
  312. package/src/serve/hub-app/review/review-st.ts +32 -42
  313. package/src/serve/hub-app/review/review-thread.tsx +139 -85
  314. package/src/serve/hub-app/review/review-views.tsx +127 -68
  315. package/src/serve/hub-app/review/share-lines.tsx +4 -4
  316. package/src/serve/hub-app/review/start-st.ts +2 -5
  317. package/src/serve/hub-app/review/superseded-runs.ts +4 -3
  318. package/src/serve/hub-app/review/thread-close.tsx +10 -7
  319. package/src/serve/hub-app/review/thread-st.ts +381 -202
  320. package/src/serve/hub-app/review/tone-bar.tsx +129 -0
  321. package/src/serve/hub-app/review/tones.ts +53 -0
  322. package/src/serve/hub-app/review/trailer-body.tsx +2 -2
  323. package/src/serve/hub-app/review/trailer-st.ts +3 -2
  324. package/src/serve/hub-app/review/trailer-voices-st.ts +3 -2
  325. package/src/serve/hub-app/review.css +189 -106
  326. package/src/serve/hub-app/search-view.tsx +1 -1
  327. package/src/serve/hub-app/social/social-model.ts +0 -4
  328. package/src/serve/hub-app/source-acts.ts +2 -1
  329. package/src/serve/hub-app/stores/stores-page.tsx +2 -2
  330. package/src/serve/hub-app/terminal-sources.tsx +2 -1
  331. package/src/serve/hub-app/thread-row.tsx +3 -4
  332. package/src/serve/hub-app/tree-build.ts +0 -4
  333. package/src/serve/hub-app/urls-view.tsx +2 -1
  334. package/src/serve/hub-app/view-layout.css +13 -3
  335. package/src/serve/hub-app/wikis-view.tsx +5 -2
  336. package/src/serve/hub-runtime.ts +7 -37
  337. package/src/serve/project-gutter-route.ts +6 -2
  338. package/src/serve/read-thread.ts +20 -2
  339. package/src/serve/read-worker.ts +9 -1
  340. package/src/serve/record-pages.ts +46 -0
  341. package/src/serve/serve-hub.ts +2 -2
  342. package/src/serve/terminal-host.ts +1 -1
  343. package/src/serve/terminal-route.ts +1 -3
  344. package/src/serve/tracked-watch.ts +1 -3
  345. package/src/setup-house.ts +2 -2
  346. package/src/shipkit-files.ts +1 -1
  347. package/src/shipkit.ts +1 -6
  348. package/src/shot/client.ts +2 -1
  349. package/src/shot/film-box.ts +0 -20
  350. package/src/shot/on-place.ts +141 -0
  351. package/src/social/drafts.ts +1 -1
  352. package/src/social/kinds.ts +6 -29
  353. package/src/social/load.ts +2 -2
  354. package/src/social/post-object.ts +3 -2
  355. package/src/social/release-stage.ts +1 -1
  356. package/src/social/stage.ts +2 -2
  357. package/src/stores/model.ts +4 -0
  358. package/src/stores/routes.ts +11 -3
  359. package/src/suite/judge-suites.ts +58 -0
  360. package/src/suite/red-alone.ts +54 -18
  361. package/src/suite/runner-shapes.ts +2 -2
  362. package/src/suite/suite-cli.ts +67 -14
  363. package/src/suite/test-units.ts +2 -1
  364. package/src/urls/fill.ts +1 -1
  365. package/src/urls/places.ts +1 -2
  366. package/src/vault/vault-config.ts +2 -2
  367. package/src/vault/vault-init.ts +1 -5
  368. package/src/wiki/graph-page.ts +14 -2
  369. package/src/advisors/copy-truth.ts +0 -49
  370. package/src/advisors/door-child.ts +0 -112
  371. package/src/advisors/door-serve.ts +0 -52
  372. package/src/advisors/door.ts +0 -118
  373. package/src/checks/SK016-legacy-check-shapes.check.ts +0 -189
  374. package/src/checks/SK029-explicit-check-files.check.ts +0 -112
  375. package/src/checks/SK048-one-local-file.check.ts +0 -36
  376. package/src/core/config-rewrite.ts +0 -111
  377. package/src/core/daemon-port.ts +0 -10
  378. package/src/core/legacy-shapes.ts +0 -263
  379. package/src/core/migrate-layout.ts +0 -638
  380. package/src/core/port-check-cli.ts +0 -52
  381. package/src/core/port-check-file.ts +0 -295
  382. package/src/core/port-check-files.ts +0 -31
  383. package/src/gate/discover-legacy-checks.ts +0 -26
  384. package/src/home/home-move.ts +0 -527
  385. package/src/home/machine-fold.ts +0 -810
  386. package/src/hq/item-shapes.ts +0 -54
  387. package/src/hq/kinds/items-read.ts +0 -4
  388. package/src/media-store/backup/daemon.ts +0 -220
  389. package/src/media-store/backup/kept.ts +0 -241
  390. package/src/media-store/backup/prune.ts +0 -359
  391. package/src/media-store/backup/secret.ts +0 -88
  392. package/src/media-store/backup/ssh-space.ts +0 -202
  393. package/src/media-store/backup/watch.ts +0 -117
  394. package/src/review/band.ts +0 -182
  395. package/src/review/folders.ts +0 -216
  396. package/src/review/hook-ask.ts +0 -58
  397. package/src/review/role.ts +0 -48
  398. package/src/review/thread-fold.ts +0 -64
  399. package/src/review/wait.ts +0 -91
  400. package/src/rules/rule.ts +0 -43
  401. package/src/serve/hook-thread.ts +0 -37
  402. package/src/serve/hook-work.ts +0 -92
  403. package/src/serve/hook-worker.ts +0 -57
  404. package/src/serve/hub-app/review/dock.tsx +0 -147
  405. package/src/serve/hub-app/review/faces.tsx +0 -18
  406. package/src/serve/hub-app/review/item-verdict.tsx +0 -112
  407. package/src/serve/hub-app/review/review-board.tsx +0 -48
  408. /package/src/{scaffold → core}/jsonc-spans.ts +0 -0
@@ -18,6 +18,7 @@ import {
18
18
  addressOrThrow,
19
19
  ANSWER_KINDS,
20
20
  type AnswerKind,
21
+ type AskRow,
21
22
  type MessageAsk,
22
23
  itemWithdrawOf,
23
24
  ownAddressOf,
@@ -48,12 +49,10 @@ import {
48
49
  specProblems,
49
50
  stateOf,
50
51
  subjectKey,
51
- laneOf,
52
52
  textOf,
53
53
  toAcknowledge,
54
54
  verdictMessageOf,
55
55
  verdictOf,
56
- viewIndexOf,
57
56
  inWork,
58
57
  UPDATE_STATES,
59
58
  UPDATE_WORDS,
@@ -65,7 +64,8 @@ import {
65
64
  type Message,
66
65
  type Mention,
67
66
  mayReadNamed,
68
- type Op,
67
+ laneOf,
68
+ type ActOp,
69
69
  type Origin,
70
70
  type Rect,
71
71
  type ReviewClip,
@@ -96,6 +96,10 @@ import {
96
96
  docProblem,
97
97
  type ItemDoc,
98
98
  isAskItem,
99
+ OWES_WORK,
100
+ QUESTION_TONES,
101
+ STATUS_LABEL,
102
+ type QuestionTone,
99
103
  } from './model.ts'
100
104
  import { secretSince } from '../asks/ask-since.ts'
101
105
  import { kindOfValue, valueKindOf } from './kinds.ts'
@@ -103,14 +107,16 @@ import { askOpen, linesOf, tickText } from './answer-kinds.ts'
103
107
  import { isObject, objectOpen } from './supersede.ts'
104
108
  import { asksVerdict } from './verdict-items.ts'
105
109
  import { SECRET_NAME } from '../secrets/name.ts'
106
- import { beatRole, roleOf } from './role.ts'
107
- import { chainOf, coveringHead, followedIds, isFollowed, membersOf, threadIdOf, threadOfAddress, threadOfItem, threadsOf, threadTitle, type Thread } from './threads.ts'
110
+ import { chainOf, followedIds, isFollowed, membersOf, threadIdOf, threadOfAddress, threadOfItem, threadsOf, threadTitle, type Thread } from './threads.ts'
111
+ import { RECAP_ASK_WORDS, recapProblems, recapStateOf } from './recap.ts'
108
112
  import { CODE_RE, codesOf, threadCode, type Codes } from './thread-code.ts'
109
113
  import { liveUrlRefusal, type ViewLive } from './live-view.ts'
110
114
  import { STILLS_LABEL } from './kind-still.ts'
111
115
  import { noteSession } from '../agent-time/registry.ts'
112
116
  import { modelWatch } from './model-moved.ts'
113
117
  import { withLease } from '../core/locked-write.ts'
118
+ import { coveringHead } from './thread-state.ts'
119
+ import { refuseBlockedByAgent } from './blocked-guard.ts'
114
120
 
115
121
  /** the store of a repo */
116
122
  export const storeDir = (root: string): string => join(root, LAYOUT.review)
@@ -203,12 +209,8 @@ export interface AddInput {
203
209
  light?: 'review'
204
210
  /** a draft version on a live shot: its image a live frame, no verdict until it is ready */
205
211
  wip?: { live: string }
206
- /** every view is an option he picks one of */
207
- choice?: boolean
208
212
  /** it waits for the owner's verdict (`--verdict`): an opening of words asks it only so, a version always */
209
213
  asksVerdict?: true
210
- /** on a choice: the option the agent suggests, by its label or its letter */
211
- agentPick?: string
212
214
  /** a trailer version: the cut the hub plays in its body; its one view is the cut's strip */
213
215
  trailer?: ItemTrailer
214
216
  /** a draft version: the post draft the hub shows in its body, read live; it holds no view */
@@ -520,6 +522,7 @@ export const agentName = (): string => process.env.SK_AGENT?.trim() || 'agent'
520
522
 
521
523
  /** copies the media in and writes item.json; throws with the reason on a bad input */
522
524
  export async function addItem(dir: string, input: AddInput): Promise<Item> {
525
+ if (!input.machine) refuseBlockedByAgent(input.on, 'post')
523
526
  const spec = specOf(dir)
524
527
  // an ask's head holds its facts alone: its words are its instructions, a message (asks/ask-store.ts createAsk)
525
528
  if (!input.what.trim() && input.ask === undefined) throw new Error('--what: required, what changed and why')
@@ -536,14 +539,11 @@ export async function addItem(dir: string, input: AddInput): Promise<Item> {
536
539
  if (input.doc) {
537
540
  const why = docProblem(input.doc)
538
541
  if (why !== null) throw new Error(why)
539
- 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
542
+ 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' : null
540
543
  if (beside !== null) throw new Error(`--${input.doc.kind}: a document is the version's subject, never with ${beside}`)
541
544
  }
542
545
  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>')
543
546
  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')
544
- if (input.choice && given.length < 2) throw new Error('--choice: a choice has two options or more, one --view each')
545
- if (input.agentPick !== undefined && !input.choice) throw new Error('--pick: only on a --choice version')
546
- const agentPick = input.agentPick === undefined ? undefined : pickIndex(given, input.agentPick)
547
547
  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`)
548
548
  const lives = given.map((v, i) => liveOf(v, i === 0 ? 'the first view' : `--live "${v.label}"`))
549
549
  const loaded = await Promise.all(given.map((v, i) => loadView(v, i === 0 ? 'the first view' : `--view "${v.label}"`, { keep: input.keep === true })))
@@ -630,10 +630,8 @@ export async function addItem(dir: string, input: AddInput): Promise<Item> {
630
630
  ...(link.supersedes && input.keeps?.trim() ? { keeps: input.keeps.trim() } : {}),
631
631
  ...(input.light ? { light: input.light } : {}),
632
632
  ...(input.wip ? { wip: { live: input.wip.live, frame: 1 } } : {}),
633
- ...(input.choice ? { choice: true as const } : {}),
634
633
  ...(input.asksVerdict ? { asksVerdict: true as const } : {}),
635
634
  ...(link.thread !== null && input.rename ? { rename: true as const } : {}),
636
- ...(agentPick !== undefined ? { agentPick } : {}),
637
635
  ...(input.trailer ? { trailer: input.trailer } : {}),
638
636
  ...(input.draft ? { draft: input.draft } : {}),
639
637
  ...(input.states ? { states: input.states } : {}),
@@ -780,25 +778,6 @@ export async function setKindStills(dir: string, id: string, tiles: readonly { v
780
778
  return updateHead(dir, id, (cur) => ({ ...cur, views: [view], media: { ...cur.media, ...facts } }))
781
779
  }
782
780
 
783
- /** the option the agent suggests, by its label or its letter; throws naming every option */
784
- function pickIndex(views: readonly { label: string }[], ref: string, flag = '--pick'): number {
785
- try {
786
- return viewIndexOf(views, ref)
787
- } catch (e) {
788
- throw new Error(`${flag}: ${(e as Error).message}`)
789
- }
790
- }
791
-
792
- /** the agent's pick set on an open choice version, by the view's label or letter; refused once he answered */
793
- export function setAgentPick(dir: string, id: string, ref: string): Item {
794
- const x = readItem(dir, id)
795
- if (!x) throw new Error(`no item ${id}`)
796
- if (verdictOf(x)) throw new Error(`${id} has his answer already: the pick shows what was suggested, never rewritten after`)
797
- if (x.item.choice !== true) throw new Error(`${id} is no choice version: a pick names one of its options`)
798
- const n = pickIndex(x.item.views, ref, 'pick')
799
- return updateHead(dir, id, (cur) => ({ ...cur, agentPick: n }))
800
- }
801
-
802
781
  /** the head rewritten under the item's lock, from what the file says now: a write that raced this one is never lost */
803
782
  export function updateHead(dir: string, id: string, fn: (cur: Item) => Item): Item {
804
783
  const c = io(dir)
@@ -813,6 +792,19 @@ export function updateHead(dir: string, id: string, fn: (cur: Item) => Item): It
813
792
  })
814
793
  }
815
794
 
795
+ /** an item copied whole into this store (review/move.ts): its head at the time it was written, then each message as
796
+ * stored, ids kept, under one lock; refused when the store holds that id. Its media are in its spool folder already */
797
+ export function landCopy(dir: string, id: string, head: unknown, at: number, messages: readonly unknown[]): void {
798
+ const problems = itemProblems(head)
799
+ if (problems.length > 0) throw new Error(`${id}: ${problems.join('; ')}`)
800
+ const c = io(dir)
801
+ c.lock(id, () => {
802
+ if (c.has(id)) throw new Error(`${id}: this store holds an item of that id`)
803
+ c.write(id, head, at)
804
+ for (const m of messages) c.append(id, m as Message)
805
+ })
806
+ }
807
+
816
808
  /** the ids of a store's items, as their folders name them */
817
809
  export const itemIds = (dir: string): string[] => io(dir).names().filter((n) => ID_RE.test(n))
818
810
 
@@ -1007,6 +999,29 @@ export function sentAs(dir: string, id: string, who: string, cid: unknown): Mess
1007
999
  return readItem(dir, id)?.thread.find((m) => m.cid === cid && m.who === who) ?? null
1008
1000
  }
1009
1001
 
1002
+ /** an agent's recap of the thread on its head (wiki tools/shipkit/threads.md, A recap): its words refused unless they hold
1003
+ * the four sections (review/recap.ts recapProblems); it asks the owner's verdict, and supersedes a recap of the thread still
1004
+ * waiting on it */
1005
+ export function postRecap(dir: string, id: string, r: { who: string; text: string; now?: Date }): Message {
1006
+ const all = readAll(dir).items
1007
+ const t = threadOfItem(id, threadsOf(all))
1008
+ if (t === null) throw new Error(`${id} reads in no thread`)
1009
+ if (partyOf(r.who) !== 'agent') throw new Error('a recap is an agent\'s')
1010
+ const members = membersOf(t)
1011
+ const ids = new Set(members.flatMap((x) => [x.item.id, ...x.thread.map((m) => m.id)]))
1012
+ const problems = recapProblems(r.text, ids)
1013
+ if (problems.length > 0) throw new Error(`the recap is refused:\n${problems.map((p) => ` ${p}`).join('\n')}`)
1014
+ const waits = recapStateOf(members)?.waits
1015
+ return appendMessage(dir, t.head.item.id, { who: r.who, text: r.text.trim(), recap: true, asksVerdict: true, ...(waits ? { replaces: waits.id } : {}) }, r.now ? { now: r.now } : {})
1016
+ }
1017
+
1018
+ /** the owner's request for a recap (the hub's « recap »): the owner's words on the thread's head that its holder hears */
1019
+ export function askRecap(dir: string, id: string, now = new Date()): Message {
1020
+ const t = threadOfItem(id, threadsOf(readAll(dir).items))
1021
+ if (t === null) throw new Error(`${id} reads in no thread`)
1022
+ return appendMessage(dir, t.head.item.id, { who: 'owner', text: RECAP_ASK_WORDS, recapAsk: true }, { now })
1023
+ }
1024
+
1010
1025
  /** a reply on an item from `who` (the owner, or an agent by its name), with an optional image; `re` the message of the
1011
1026
  * item it answers (his hint on an update); `cid` the send's own id: the same id twice is one message. Throws with the reason */
1012
1027
  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[], cid?: unknown): Message {
@@ -1031,9 +1046,10 @@ export interface AskOption {
1031
1046
  /** an agent's question to the owner on a thread's item: its words, two options or more, each words or a media, the
1032
1047
  * option it picks; each option's media becomes a view the message holds (addView `message`), and the owner answers in
1033
1048
  * one click (answerAsk) */
1034
- 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> {
1049
+ 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 }; row?: AskRow; move?: { to: string } }): Promise<Message> {
1035
1050
  const x = readItem(dir, id)
1036
1051
  if (!x) throw new Error(`no item ${id}`)
1052
+ if (partyOf(q.who) === 'agent') refuseBlockedByAgent(x.item.on, 'ask a question')
1037
1053
  const t = textOf(q.text)
1038
1054
  if ('error' in t) throw new Error(`the question: ${t.error.replace(/^text: /, '')}`)
1039
1055
  const kind = q.kind ?? 'choice'
@@ -1056,7 +1072,7 @@ export async function postAsk(dir: string, id: string, q: { who: string; text: u
1056
1072
  views.push(item.views.length - 1)
1057
1073
  }
1058
1074
  const media = views.some((v) => v !== null) ? { views } : {}
1059
- return appendMessage(dir, id, { who: q.who, text: t.text, ask: { options: labels, ...(q.pick !== undefined ? { pick: q.pick } : {}), ...media }, ...replaces }, q.now ? { now: q.now } : {})
1075
+ return appendMessage(dir, id, { who: q.who, text: t.text, ask: { options: labels, ...(q.pick !== undefined ? { pick: q.pick } : {}), ...media, ...(q.row !== undefined ? { row: q.row } : {}), ...(q.move !== undefined ? { move: q.move } : {}) }, ...replaces }, q.now ? { now: q.now } : {})
1060
1076
  }
1061
1077
 
1062
1078
  /** the longest text or url he answers with */
@@ -1108,7 +1124,9 @@ export interface ProposeInput {
1108
1124
  * after the owner's edit (answerAsk), and the agent lands what he applied. A field draws as the agent names it, else as the
1109
1125
  * object's kind declares (`diff`), else as its values read; a sound field's two files become a view the message holds */
1110
1126
  export async function postPropose(dir: string, id: string, p: { who: string; text: unknown; on: string; fields: readonly ProposeInput[]; now?: Date; replaces?: string }): Promise<Message> {
1111
- if (!readItem(dir, id)) throw new Error(`no item ${id}`)
1127
+ const x = readItem(dir, id)
1128
+ if (!x) throw new Error(`no item ${id}`)
1129
+ if (partyOf(p.who) === 'agent') for (const a of [x.item.on, p.on]) refuseBlockedByAgent(a, 'propose a change')
1112
1130
  const on = addressOrThrow(p.on)
1113
1131
  if (p.fields.length === 0) throw new Error('--after: the value it proposes')
1114
1132
  const many = p.fields.length > 1
@@ -1143,8 +1161,10 @@ export async function postPropose(dir: string, id: string, p: { who: string; tex
1143
1161
  }
1144
1162
 
1145
1163
  /** the owner's answer to a question (an option) or to a proposed change (apply one field, the value as proposed or the owner's
1146
- * edit of it in `value`), with the owner's words */
1147
- export function answerAsk(dir: string, id: string, a: { re: string; option?: number; apply?: boolean; field?: string; value?: string; text?: string; tick?: boolean; pick?: number; opens?: number; now?: Date }): Message {
1164
+ * edit of it in `value`), with the owner's words; `tone` on a choice: none of its options right (a rework, a wrong
1165
+ * direction), or his « your call », which takes the agent's pick if it still holds (model.ts QUESTION_TONES); on a
1166
+ * text or a url: your call or no answer; on a confirm: no answer */
1167
+ export function answerAsk(dir: string, id: string, a: { re: string; option?: number; apply?: boolean; field?: string; value?: string; text?: string; tick?: boolean; pick?: number; opens?: number; tone?: QuestionTone; now?: Date }): Message {
1148
1168
  const x = readItem(dir, id)
1149
1169
  if (!x) throw new Error(`no item ${id}`)
1150
1170
  const m = x.thread.find((y) => y.id === a.re)
@@ -1154,6 +1174,13 @@ export function answerAsk(dir: string, id: string, a: { re: string; option?: num
1154
1174
  const kind = m.ask?.kind ?? 'choice'
1155
1175
  if (m.ask && kind === 'secret') throw new Error('a secret is typed into its own field of the hub, and its value never goes into a thread')
1156
1176
  if (m.ask && kind === 'file') throw new Error('a file question is answered by the file he drops')
1177
+ // a text or a url takes the question's row too: your call or no answer; a confirm, a step only the owner does, no
1178
+ // answer alone; words alone say none
1179
+ if (m.ask && a.tone !== undefined && (kind === 'confirm' || kind === 'text' || kind === 'url')) {
1180
+ if (kind === 'confirm' && a.tone !== 'no-answer') throw new Error("tone: no-answer alone on a confirm, a step only the owner does; the owner's words alone answer it otherwise")
1181
+ if (a.tone !== 'your-call' && a.tone !== 'no-answer') throw new Error(`tone: your-call or no-answer on a ${kind}; the owner's words alone answer it otherwise`)
1182
+ return appendMessage(dir, id, { who: 'owner', re: a.re, verdict: a.tone, text: words === '' ? STATUS_LABEL[a.tone] : words }, at)
1183
+ }
1157
1184
  if (m.ask && (kind === 'checklist' || kind === 'confirm')) {
1158
1185
  const lines = linesOf(m)
1159
1186
  const o = kind === 'confirm' ? 0 : a.option
@@ -1172,6 +1199,13 @@ export function answerAsk(dir: string, id: string, a: { re: string; option?: num
1172
1199
  const opens = kind === 'url' && a.opens !== undefined && Number.isInteger(a.opens) && a.opens >= 0 ? { opens: a.opens } : {}
1173
1200
  return appendMessage(dir, id, { who: 'owner', re: a.re, answer: { value, ...opens }, text: words === '' ? value : words }, at)
1174
1201
  }
1202
+ if (m.ask && a.tone !== undefined) {
1203
+ if (kind !== 'choice') throw new Error(`tone: on a choice only, this question is a ${kind}`)
1204
+ if (!(QUESTION_TONES as readonly string[]).includes(a.tone)) throw new Error(`tone: one of ${QUESTION_TONES.join(', ')}`)
1205
+ const pick = a.tone === 'your-call' ? m.ask.pick : undefined
1206
+ const label = pick === undefined ? STATUS_LABEL[a.tone] : m.ask.options[pick]!
1207
+ return appendMessage(dir, id, { who: 'owner', re: a.re, verdict: a.tone, ...(pick !== undefined ? { answer: { option: pick } } : {}), text: words === '' ? label : pick === undefined ? words : `${label}: ${words}` }, at)
1208
+ }
1175
1209
  if (m.ask) {
1176
1210
  const o = a.option
1177
1211
  if (o === undefined || !Number.isInteger(o) || o < 0 || o >= m.ask.options.length) throw new Error(`option: one of 0 to ${m.ask.options.length - 1}`)
@@ -1217,13 +1251,23 @@ export function postAction(dir: string, id: string, a: { name: string; text?: st
1217
1251
  // `re`: the link of an object in the thread the action is on (a reflection's box), so the box reads its own answer
1218
1252
  if (a.re !== undefined && !x.thread.some((m) => m.id === a.re && m.about !== undefined)) throw new Error(`re: ${a.re} is no link of ${id}`)
1219
1253
  const words = a.text?.trim() ?? ''
1220
- return appendMessage(dir, id, { who: 'owner', action: { name: a.name }, text: words === '' ? a.name : words, ...(a.re !== undefined ? { re: a.re } : {}) }, a.now ? { now: a.now } : {})
1254
+ const text = words === '' ? a.name : words
1255
+ const now = a.now ?? new Date()
1256
+ // the same click twice (a double click, a second press while the first was on its way): one act, the first one
1257
+ const twice = x.thread.findLast((m) => m.action !== undefined && partyOf(m.who) === 'owner' && m.re === a.re)
1258
+ if (twice?.action?.name === a.name && twice.text === text && now.getTime() - Date.parse(twice.at) < SAME_ACT_MS) return twice
1259
+ return appendMessage(dir, id, { who: 'owner', action: { name: a.name }, text, ...(a.re !== undefined ? { re: a.re } : {}) }, { now })
1221
1260
  }
1222
1261
 
1262
+ /** how close two identical acts of the owner on one object are one act */
1263
+ const SAME_ACT_MS = 10_000
1264
+
1223
1265
  /** a link from a thread to another object: the thread names it, the object's thread control finds the thread */
1224
1266
  export function attachTo(dir: string, id: string, who: string, address: string, now = new Date(), o: { asksVerdict?: true } = {}): Message {
1225
- if (!readItem(dir, id)) throw new Error(`no item ${id}`)
1267
+ const x = readItem(dir, id)
1268
+ if (!x) throw new Error(`no item ${id}`)
1226
1269
  const a = addressOrThrow(address)
1270
+ if (partyOf(who) === 'agent') for (const on of [x.item.on, a]) refuseBlockedByAgent(on, 'link an object')
1227
1271
  return appendMessage(dir, id, { who, text: `attached ${a}`, about: [a], ...o }, { now })
1228
1272
  }
1229
1273
 
@@ -1256,6 +1300,7 @@ export interface UpdateInput {
1256
1300
  export async function postUpdate(dir: string, id: string, u: UpdateInput): Promise<{ item: Item; message: Message; tag: string; view: number | null }> {
1257
1301
  const x = readItem(dir, id)
1258
1302
  if (!x) throw new Error(`no item ${id}`)
1303
+ if (!u.machine) refuseBlockedByAgent(x.item.on, 'update')
1259
1304
  if (x.item.origin.by !== 'agent') return lineOnNote(dir, x, u)
1260
1305
  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`)
1261
1306
  if (!UPDATE_STATES.includes(u.state as UpdateState)) throw new Error(`the state: one of ${UPDATE_STATES.join(', ')}, not « ${u.state} »`)
@@ -1397,7 +1442,7 @@ export function withdraw(dir: string, id: string, why: string, now = new Date())
1397
1442
  const v = verdictOf(x)
1398
1443
  if (v) {
1399
1444
  const owes = v.status === 'approved-with-fix' ? `sk thread done ${id} "<what changed>", ` : ''
1400
- 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>"` : ''
1445
+ const close = OWES_WORK.has(v.status) ? `; what it owes: ${owes}--supersedes ${id} on its new version, or sk thread wontfix ${id} --note "<why>"` : ''
1401
1446
  return { refused: `${id}: he answered it (${v.status}), so it waits on him no more${close}` }
1402
1447
  }
1403
1448
  appendMessage(dir, id, { who: agentName(), op: 'withdraw', note: why }, { now })
@@ -1550,16 +1595,11 @@ export async function ownerVerdict(dir: string, o: { subject: Subject; from: str
1550
1595
  }
1551
1596
 
1552
1597
  /** a state change on an item by `who`, checked by `allowed` under the item's lock, so two workers claiming at once
1553
- * never both win; throws with the reason it is refused. The dispatcher's ops need the repo's unit to declare one, and
1554
- * its holder; a topic is one the unit declares */
1555
- export function act(dir: string, id: string, op: Exclude<Op, 'seen'>, who: string, o: { note?: string; text?: string; commit?: string; topic?: string; now?: Date; holds?: boolean } = {}): Message {
1556
- const spec = specOf(dir)
1598
+ * never both win; throws with the reason it is refused */
1599
+ export function act(dir: string, id: string, op: Exclude<ActOp, 'seen'>, who: string, o: { note?: string; commit?: string; now?: Date; holds?: boolean } = {}): Message {
1557
1600
  if (who !== 'owner' && who !== 'agent' && !AGENT_RE.test(who)) throw new Error(`« ${who} » is no agent name (${AGENT_RE.source})`)
1558
1601
  if (!ID_RE.test(id) || !readItem(dir, id)) throw new Error(`no item ${id}`)
1559
- if ((op === 'wontfix' || op === 'blocked' || op === 'drop') && !o.note?.trim()) throw new Error(`${op} says why (--note)`)
1560
- if ((op === 'ask' || op === 'answer') && !o.text?.trim()) throw new Error(`${op} says something`)
1561
- if (op === 'dispatch' && !o.topic) throw new Error('dispatch names a topic')
1562
- 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(', ')}`)
1602
+ if (op === 'wontfix' && !o.note?.trim()) throw new Error(`${op} says why (--note)`)
1563
1603
  if (o.commit !== undefined && !/^[0-9a-f]{7,40}$/.test(o.commit)) throw new Error(`« ${o.commit} » is no commit`)
1564
1604
  const now = o.now ?? new Date()
1565
1605
  // the first read of a process reads every item: done before the lock, the read under it only takes what moved
@@ -1567,8 +1607,7 @@ export function act(dir: string, id: string, op: Exclude<Op, 'seen'>, who: strin
1567
1607
  return io(dir).lock(id, () => {
1568
1608
  const x = readItem(dir, id) as ReviewItem
1569
1609
  const superseded = isFollowed(id, readAll(dir).items)
1570
- const role = spec.dispatcher ? (roleOf(dir)?.name ?? null) : null
1571
- 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)
1610
+ const why = op === 'claim' && superseded && x.item.origin.by === 'agent' ? 'a newer version redoes it: claim that one' : allowed(stateOf(x, superseded), op, who, o.holds === true)
1572
1611
  if (why) throw new Error(`${id}: ${why}`)
1573
1612
  const m = appendMessage(
1574
1613
  dir,
@@ -1576,29 +1615,25 @@ export function act(dir: string, id: string, op: Exclude<Op, 'seen'>, who: strin
1576
1615
  {
1577
1616
  who,
1578
1617
  op,
1579
- ...(o.text?.trim() ? { text: o.text.trim() } : {}),
1580
1618
  ...(o.note?.trim() ? { note: o.note.trim() } : {}),
1581
1619
  ...(o.commit ? { fix: { commit: o.commit } } : {}),
1582
- ...(o.topic ? { topic: o.topic } : {}),
1583
1620
  },
1584
1621
  { now },
1585
1622
  )
1586
- if (role !== null && role === who) beatRole(dir, now)
1587
1623
  return m
1588
1624
  })
1589
1625
  }
1590
1626
 
1591
- /** `who` claims the oldest open item raised to a lane, or of a topic, and gets it read back; null when none is open.
1592
- * Each claim runs under the item's lock, so two workers never take one item */
1627
+ /** `who` claims the oldest open or new item raised to a lane, or of a topic, and gets it read back; null when none is
1628
+ * waiting. Each claim runs under the item's lock, so two workers never take one item */
1593
1629
  export function claimNext(dir: string, by: { lane: string } | { topic: string }, who: string): ReviewItem | null {
1594
1630
  const store = readAll(dir).items
1595
1631
  const followed = followedIds(store)
1596
- const routed = specOf(dir).dispatcher
1597
1632
  const open = store
1598
1633
  .filter((x) => x.item.origin.by !== 'agent' && ('lane' in by ? laneOf(x) === by.lane : true))
1599
1634
  .filter((x) => {
1600
1635
  const st = stateOf(x, followed.has(x.item.id))
1601
- return (st.state === 'open' || (!routed && st.state === 'new')) && ('topic' in by ? st.topic === by.topic : true)
1636
+ return (st.state === 'open' || st.state === 'new') && ('topic' in by ? st.topic === by.topic : true)
1602
1637
  })
1603
1638
  .sort((a, b) => a.item.created.localeCompare(b.item.created) || a.item.id.localeCompare(b.item.id))
1604
1639
  for (const x of open) {
@@ -1,11 +1,11 @@
1
- // what of the owner's acts reaches an agent (wiki tools/shipkit/threads-how-it-fits.md, What wakes an agent): the
2
- // owner's words and every answer that finishes something wake it; a tick inside an unfinished list is a trace line of
3
- // the thread only.
4
- // The one reading of « unseen » for the inbox, its hook, the stop, the watch and the turn. Pure and browser safe
1
+ // the one classifier of a thread's messages (wiki tools/shipkit/threads-how-it-fits.md, What wakes an agent; the ball
2
+ // after a move): which act of the owner a message is and whether it wakes an agent (`eventOf`, `wakeOf`), what it does
3
+ // to the turn (`messageMove`, AFTER_MOVE), whether the owner's word asks an agent for work (`asksWork`). Nothing else
4
+ // classifies a message. Pure and browser safe
5
5
  // the one constraint a reader breaks first: an agent side reader of the owner's unread words goes through wakingUnread,
6
6
  // never unreadBy(x, 'agent'), or every tick wakes agents again
7
7
  import { kindOfAsk, tickCount, tickText } from './answer-kinds.ts'
8
- import { agentsNamed, isReply, partyOf, perItem, toAcknowledge, type Message, type ReviewItem } from './model.ts'
8
+ import { agentsNamed, handedOver, isAskItem, isReply, isVersionVerdict, partyOf, perItem, toAcknowledge, type Message, type ReviewItem } from './model.ts'
9
9
 
10
10
  /** wakes: an agent hears it as unseen words it owes a look (the inbox, the hook, the stop, the watch, the turn);
11
11
  * heard: the watch prints it once, nothing is owed; trace: a line of the thread's timeline, never news */
@@ -31,6 +31,9 @@ export const WAKES = {
31
31
  verdict: 'wakes',
32
32
  /** an approval with nothing said (no note, no rectangle, no reaction, no pick): the item is done, nobody owes it */
33
33
  approval: 'heard',
34
+ /** the owner's « no answer » on a question, a version or a message asking the owner's verdict: settled unanswered, by choice; no
35
+ * agent hears it */
36
+ 'no-answer': 'trace',
34
37
  /** a verdict taken back on a version */
35
38
  'take-back': 'wakes',
36
39
  /** a click on a kind's action */
@@ -85,9 +88,11 @@ export function eventOf(x: ReviewItem, m: Message): WakeEvent {
85
88
  if (m.laneAsk !== undefined || m.rate !== undefined) return 'other'
86
89
  if (m.op === 'reopen' && x.item.origin.by === 'agent') return 'take-back'
87
90
  if (m.op !== undefined && m.op !== 'ask' && m.op !== 'answer') return 'close'
88
- if (m.verdict !== undefined) return bareApproval(m) ? 'approval' : 'verdict'
91
+ if (m.verdict === 'no-answer') return 'no-answer'
92
+ // a tone on a question (store.ts answerAsk `tone`) is his answer to it, never a verdict: a pick, or words alone
93
+ const q = m.re !== undefined ? x.thread.find((y) => y.id === m.re) : undefined
94
+ if (m.verdict !== undefined && q?.ask === undefined) return bareApproval(m) ? 'approval' : 'verdict'
89
95
  if (m.action !== undefined) return 'action'
90
- const q = m.answer !== undefined && m.re !== undefined ? x.thread.find((y) => y.id === m.re) : undefined
91
96
  if (q === undefined || m.answer === undefined) return 'words'
92
97
  if (m.answer.apply) return 'apply'
93
98
  const list = listOf(x.thread, q)
@@ -117,3 +122,83 @@ const wakingKept = perItem((x: ReviewItem, _: null): readonly Message[] => {
117
122
  const unread = new Set(toAcknowledge(x, 'agent'))
118
123
  return x.thread.filter((m) => unread.has(m.id) && (isReply(m) || m.askState !== undefined) && wakeOf(x, m) === 'wakes')
119
124
  })
125
+
126
+ /** what the newest move of a thread does to the owner's turn while something waits on the owner (a version, a question):
127
+ * whoever spoke last does not hold the turn. `agents` the ball is theirs until one answers, what still waits on him stays
128
+ * owed as a quiet mark; `stands` the owner's turn stands; `none` no move, the move before it decides. Any other turn
129
+ * never changes here (thread-state.ts reads the owner's words) */
130
+ export const AFTER_MOVE = {
131
+ /** his reply, a note, a picture, rectangles: an agent answers them */
132
+ 'his-words': 'agents',
133
+ /** his request for a lane: the orchestrator gives it one */
134
+ 'his-request': 'agents',
135
+ /** the owner's verdict, or one taken back: what it settles decides */
136
+ 'his-verdict': 'stands',
137
+ /** his answer to an agent's question, apply, an action on an object an agent linked, a list he finished: an agent acts on it */
138
+ 'his-answer': 'agents',
139
+ /** his answer or a list he finished on an ask's own steps: the act is his until it is done, its bar waits on him */
140
+ 'his-step': 'stands',
141
+ /** his save of the object in the hub's editor: what waited on him still waits (a draft's places, a version's verdict,
142
+ * an ask's steps); with nothing waiting, the agents owe it a look (his unseen words) */
143
+ 'his-edit': 'stands',
144
+ /** his close or reopen (an ask, a list he opened again), an act on a spot of a version */
145
+ 'his-close': 'stands',
146
+ /** a tick inside an unfinished list, a rating, set aside, his read mark */
147
+ 'his-trace': 'none',
148
+ /** an agent's version, reply, update, question, proposed change, fix: it answers him */
149
+ 'agent-answer': 'stands',
150
+ /** an agent's working line: the agent is on it, the ball stays where it is */
151
+ 'agent-working': 'none',
152
+ /** an agent's read mark, take, assign, claim, a hand-over; a hold flipped, an object attached, a machine line: no answer */
153
+ 'agent-mark': 'none',
154
+ } as const satisfies Record<string, 'agents' | 'stands' | 'none'>
155
+ export type Move = keyof typeof AFTER_MOVE
156
+
157
+ const HIS: Partial<Record<WakeEvent, Move>> = {
158
+ words: 'his-words',
159
+ mention: 'his-words',
160
+ edit: 'his-edit',
161
+ verdict: 'his-verdict',
162
+ approval: 'his-verdict',
163
+ 'take-back': 'his-verdict',
164
+ answer: 'his-answer',
165
+ apply: 'his-answer',
166
+ action: 'his-answer',
167
+ 'list-done': 'his-answer',
168
+ 'list-reopened': 'his-close',
169
+ 'ask-closed': 'his-close',
170
+ close: 'his-close',
171
+ act: 'his-close',
172
+ }
173
+
174
+ // `ready` is no mark: it asks the owner's verdict, an answer
175
+ const AGENT_MARKS = new Set<Message['op']>(['seen', 'take', 'claim', 'release', 'dispatch', 'reassign'])
176
+
177
+ /** an agent's act that answers nothing: a mark, a rename, a hold the machine flipped, an object attached, a line the
178
+ * machine wrote */
179
+ const agentMark = (m: Message): boolean => AGENT_MARKS.has(m.op) || m.rename !== undefined || handedOver(m) || m.hold !== undefined || (m.about !== undefined && m.text === `attached ${m.about[0] ?? ''}`) || m.who === 'machine'
180
+
181
+ /** which row of AFTER_MOVE one message of a thread is */
182
+ export function messageMove(x: ReviewItem, m: Message): Move {
183
+ if (partyOf(m.who) === 'agent') return m.op === 'working' ? 'agent-working' : agentMark(m) ? 'agent-mark' : 'agent-answer'
184
+ if (m.op === 'seen' || m.carried !== undefined) return 'his-trace'
185
+ if (m.laneAsk !== undefined) return 'his-request'
186
+ const move = HIS[eventOf(x, m)] ?? 'his-trace'
187
+ return move === 'his-answer' && isAskItem(x.item) ? 'his-step' : move
188
+ }
189
+
190
+ /** the raised item's opening: his or the player's words and rectangles that raised it, none on an agent item */
191
+ export const openingOf = (x: ReviewItem): Message | undefined =>
192
+ x.item.origin.by === 'agent' ? undefined : x.thread.find((m) => m.op === undefined && partyOf(m.who) === 'owner' && (m.text !== undefined || m.rects !== undefined))
193
+
194
+ /** his word asks the agent for something: words he wrote (a reply, a note, an action with words), an « ok with a fix »,
195
+ * a « wrong direction », a « your call », a rework with words, a verdict he took back until his next verdict on the version answers it. An approval (its
196
+ * note is read, never owed an act: 😐 asks for work), an archive, a bare rework, his answer to a question, a set
197
+ * aside, a close ask nothing more */
198
+ export function asksWork(x: ReviewItem, m: Message): boolean {
199
+ if (m === openingOf(x)) return true
200
+ if (m.verdict !== undefined) return m.verdict === 'approved-with-fix' || m.verdict === 'wrong-direction' || m.verdict === 'your-call' || (m.verdict === 'rework' && (!!m.text?.trim() || (m.rects?.length ?? 0) > 0))
201
+ if (m.op === 'reopen') return x.item.origin.by === 'agent' && !x.thread.slice(x.thread.indexOf(m) + 1).some(isVersionVerdict)
202
+ if (m.op !== undefined || m.answer !== undefined || m.snooze !== undefined || m.askState !== undefined || m.askBar !== undefined) return false
203
+ return m.action !== undefined || !!m.text?.trim() || (m.rects?.length ?? 0) > 0 || m.image !== undefined || (m.files?.length ?? 0) > 0
204
+ }
@@ -8,8 +8,11 @@ import { isGallery, partyOf, verdictOf, type Message, type ReviewItem, type Spec
8
8
  import { mediaPath } from './format.ts'
9
9
  import { refHint, refsIn } from './refs.ts'
10
10
  import { replacersOf, titleOf } from './supersede.ts'
11
+ import { byAnAdvisor, notedOnce, speakerOf } from './speaker.ts'
11
12
  import { renameTrace } from './traces.ts'
12
- import { askFactsOf, firstTitleOf, nameOf, holderOf, membersOf, ownAddressesOf, threadIdOf, threadTitle, type Thread } from './threads.ts'
13
+ import { askFactsOf, nameAt, holderOf, membersOf, ownAddressesOf, threadIdOf, threadTitle, type Thread } from './threads.ts'
14
+ import { recapCut } from './thread-state.ts'
15
+ import { verdictOnMessage } from './verdict-items.ts'
13
16
 
14
17
  const flat = (t: string): string => t.replace(/\s+/g, ' ').trim()
15
18
  const when = (iso: string): string => iso.slice(0, 16).replace('T', ' ')
@@ -59,7 +62,8 @@ function itemOf(t: Thread, x: ReviewItem, media: string): string {
59
62
  const out = [`## ${when(x.item.created)} ${name} \`${x.item.id}\`: « ${x.item.title} »`]
60
63
  if (x.item.what) out.push('', fenced(x.item.what, 'markdown'))
61
64
  const v = verdictOf(x)
62
- if (v) out.push('', `verdict ${v.status} at ${when(v.at)}${v.comment ? `: ${flat(v.comment)}` : ''}`)
65
+ const vm = v ? x.thread.find((m) => m.id === v.id) : undefined
66
+ if (v) out.push('', `verdict ${v.status}${vm && speakerOf(vm) !== vm.who ? ` by ${speakerOf(vm)}` : ''} at ${when(v.at)}${v.comment ? `: ${flat(v.comment)}` : ''}`)
63
67
  const files = x.item.views.flatMap((w) => (isGallery(w) ? w.gallery.map((g) => g.file) : Object.values(w.files)))
64
68
  if (files.length > 0) out.push('', ...files.map((f) => `- file: \`${mediaPath(media, x.item.id, f)}\``))
65
69
  return out.join('\n')
@@ -67,8 +71,12 @@ function itemOf(t: Thread, x: ReviewItem, media: string): string {
67
71
 
68
72
  /** one message: an object whole (instructions, a question, a change, words), anything else one line */
69
73
  function messageOf(x: ReviewItem, m: Message, gone: Map<string, Message>, all: readonly Message[], media: string): string {
70
- const head = `${when(m.at)} ${m.who}`
74
+ const head = `${when(m.at)} ${speakerOf(m)}`
71
75
  const by = gone.get(m.id)
76
+ if (m.recap === true && !by) {
77
+ const v = verdictOnMessage(x.thread, m)
78
+ return [`### ${head}: the recap \`${m.id}\``, '', quoted(m.text ?? ''), '', `state: ${v === null ? "waits on the owner's verdict" : `verdict ${v.status} at ${when(v.at)}${v.text ? `: ${flat(v.text)}` : ''}`}`].join('\n')
79
+ }
72
80
  const what = m.instructions ? `instructions « ${m.instructions.title} »` : m.ask ? (m.step ? `field of step ${m.step.i + 1}` : `question (${kindOfAsk(m)})`) : m.propose ? `change of ${m.propose.on}` : 'words'
73
81
  if (by) return `- ${head}: ${what} \`${m.id}\`, ${by.op === 'withdraw' ? titleOf(by) : `superseded by \`${by.id}\` « ${titleOf(by)} »`}`
74
82
  const extra = mediaOf(m, media, x.item.id)
@@ -89,39 +97,52 @@ function messageOf(x: ReviewItem, m: Message, gone: Map<string, Message>, all: r
89
97
  if (m.verdict !== undefined) return `- ${head}: verdict ${m.verdict}${m.text ? `: ${flat(m.text)}` : ''}`
90
98
  if (m.text !== undefined && m.text.trim() !== '') {
91
99
  const refs = refsIn(m.text).map((r) => `- ${refHint(r).replace(/^(\S+)/, '`$1`')}`)
92
- return [`### ${head}: ${partyOf(m.who) === 'owner' ? "the owner's words" : 'words'} \`${m.id}\``, '', quoted(m.text), ...(refs.length > 0 ? ['', ...refs] : []), ...extra].join('\n')
100
+ return [`### ${head}: ${byAnAdvisor(m) ? "an advisor's words" : partyOf(m.who) === 'owner' ? "the owner's words" : 'words'} \`${m.id}\``, '', quoted(m.text), ...(refs.length > 0 ? ['', ...refs] : []), ...extra].join('\n')
93
101
  }
102
+ if (m.closes === 'thread') return `- ${head}: closed the thread: ${flat(m.note ?? '')}`
103
+ if (m.closes === 'version') return `- ${head}: no verdict needed: closed with its thread`
94
104
  if (m.op !== undefined) return `- ${head}: ${m.op}${m.note ? `: ${flat(m.note)}` : ''}`
105
+ if (m.rename !== undefined) return `- ${head}: renamed the thread: « ${m.rename.from} » → « ${m.rename.to} »`
106
+ if (m.moved !== undefined) return `- ${head}: moved the thread from ${m.moved.from} to ${m.moved.to}`
95
107
  return ''
96
108
  }
97
109
 
98
- /** the whole thread as markdown: its facts, then every item and message in the order they came */
110
+ /** the whole thread as markdown: its facts, then every item and message in the order they came; past the newest recap
111
+ * he accepted, from that recap on with what still waits or is owed before it (review/thread-state.ts recapCut), unless
112
+ * `all` */
99
113
  /** `extra`: lines read beside the store at their times (a share's acts, advisors/share-trace.ts), each one line of markdown */
100
- export function threadMarkdown(t: Thread, media: string, spec: Spec = NO_SPEC, extra: readonly { at: string; md: string }[] = []): string {
114
+ export function threadMarkdown(t: Thread, media: string, spec: Spec = NO_SPEC, extra: readonly { at: string; md: string }[] = [], o: { all?: boolean } = {}): string {
101
115
  const members = membersOf(t)
102
116
  const gone = replacersOf(members)
103
117
  const all = members.flatMap((x) => x.thread)
118
+ const cut = o.all ? null : recapCut(t)
119
+ let folded = 0
120
+ const shown = (item: string, m: Pick<Message, 'id' | 'at'> | null): boolean => {
121
+ if (cut === null || !cut.hidden(item, m)) return true
122
+ folded++
123
+ return false
124
+ }
104
125
  const entries: { at: string; i: number; md: string }[] = []
105
126
  for (const x of members) {
106
- entries.push({ at: x.item.created, i: entries.length, md: itemOf(t, x, media) })
127
+ if (shown(x.item.id, null)) entries.push({ at: x.item.created, i: entries.length, md: itemOf(t, x, media) })
107
128
  for (const m of x.thread) {
108
129
  if (m.op === 'seen') continue
109
130
  const md = messageOf(x, m, gone, all, media)
110
- if (md !== '') entries.push({ at: m.at, i: entries.length, md })
131
+ if (md !== '' && shown(x.item.id, m)) entries.push({ at: m.at, i: entries.length, md })
111
132
  }
112
133
  }
113
134
  // a version that renamed the thread: its line right after it, as the hub's trace
114
- const chain = [...t.versions].reverse()
115
- chain.forEach((x, k) => {
116
- const r = renameTrace(nameOf(chain.slice(0, k), firstTitleOf(t)), x)
135
+ t.versions.forEach((x) => {
136
+ const r = renameTrace(nameAt(t, x.item.created), x)
117
137
  const o = x.item.origin
118
- if (r !== null) entries.push({ at: x.item.created, i: entries.length, md: `- ${when(x.item.created)} ${o.by === 'agent' ? (o.lane ?? 'agent') : o.by}: ${r.did}` })
138
+ if (r !== null && (cut === null || !cut.hidden(x.item.id, null))) entries.push({ at: x.item.created, i: entries.length, md: `- ${when(x.item.created)} ${o.by === 'agent' ? (o.lane ?? 'agent') : o.by}: ${r.did}` })
119
139
  })
120
- for (const e of extra) entries.push({ at: e.at, i: entries.length, md: e.md })
140
+ for (const e of extra) if (cut === null || e.at >= cut.recap.at) entries.push({ at: e.at, i: entries.length, md: e.md })
121
141
  // by the moment, never the string: an item's day and a message's carry their milliseconds or not
122
142
  const ms = (iso: string): number => Date.parse(iso) || 0
123
143
  entries.sort((a, b) => ms(a.at) - ms(b.at) || a.i - b.i)
124
144
  // a run of one line entries reads as one list; an entry of its own stands apart
125
145
  const body = entries.map((e, i) => (i > 0 && e.md.startsWith('- ') && entries[i - 1]!.md.startsWith('- ') ? `\n${e.md}` : `\n\n${e.md}`)).join('')
126
- return `# ${threadTitle(t)}\n\n${factsOf(t, spec).join('\n')}\n\nOldest first: each answer under what it answers; a superseded or withdrawn object is one line.${body}\n`
146
+ const from = cut === null ? '' : `\n- read from the recap \`${cut.recap.id}\` he accepted (${when(cut.recap.at)}): ${folded} entr${folded === 1 ? 'y' : 'ies'} before it folded, what still waits or is owed kept; every one: \`sk thread show ${ownAddressesOf(t, spec)[0] ?? threadIdOf(t)} --md --all\``
147
+ return notedOnce(`# ${threadTitle(t)}\n\n${factsOf(t, spec).join('\n')}${from}\n\nOldest first: each answer under what it answers; a superseded or withdrawn object is one line.${body}\n`)
127
148
  }