rvlib-shipkit 2.27.0 → 2.28.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 (338) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/package.json +1 -1
  3. package/src/agent-time/hooks.ts +10 -3
  4. package/src/agent-time/live.ts +11 -5
  5. package/src/agent-time/registry.ts +289 -0
  6. package/src/agent-time/store.ts +2 -2
  7. package/src/annex/born.ts +2 -2
  8. package/src/annex/offload.ts +12 -11
  9. package/src/asks/ask-after.ts +6 -2
  10. package/src/asks/ask-bar-fold.ts +57 -0
  11. package/src/asks/ask-migrate.ts +280 -0
  12. package/src/asks/ask-steps-fold.ts +166 -0
  13. package/src/asks/ask-store.ts +586 -0
  14. package/src/assets/kits/identity-kit.ts +106 -38
  15. package/src/assets/kits/poster-thumbnail.ts +282 -0
  16. package/src/checks/SK003-claude-md-shape.check.ts +92 -25
  17. package/src/checks/SK004-gitignore-policy.check.ts +8 -4
  18. package/src/checks/SK013-one-way-in-policy.check.ts +10 -0
  19. package/src/checks/SK026-asks-autoclose.check.ts +9 -23
  20. package/src/checks/SK038-speaks-as.check.ts +3 -3
  21. package/src/checks/SK042-post-kinds.check.ts +26 -24
  22. package/src/checks/SK049-thread-answers-hook.check.ts +81 -0
  23. package/src/checks/SK050-retired-commands.check.ts +127 -0
  24. package/src/cli/cmd_Asks.ts +204 -53
  25. package/src/cli/cmd_Backup.ts +151 -8
  26. package/src/cli/cmd_Calls.ts +1 -0
  27. package/src/cli/cmd_Commands.ts +140 -34
  28. package/src/cli/cmd_Contracts.ts +1 -0
  29. package/src/cli/cmd_Keys.ts +1 -0
  30. package/src/cli/cmd_Lanes.ts +15 -4
  31. package/src/cli/cmd_Messages.ts +152 -1
  32. package/src/cli/cmd_Needs.ts +1 -0
  33. package/src/cli/cmd_Review.ts +931 -229
  34. package/src/cli/cmd_Secret.ts +255 -34
  35. package/src/cli/cmd_Social.ts +36 -33
  36. package/src/cli/cmd_SocialDrafts.ts +235 -0
  37. package/src/cli/cmd_Sound.ts +22 -1
  38. package/src/cli/cmd_Start.ts +3 -2
  39. package/src/cli/cmd_ThreadHolds.ts +34 -0
  40. package/src/cli/cmd_ThreadKinds.ts +146 -0
  41. package/src/cli/cmd_ThreadReflect.ts +83 -0
  42. package/src/cli/cmd_ThreadSyncNeeds.ts +62 -0
  43. package/src/cli/cmd_Vault.ts +1 -1
  44. package/src/cli/cmd_When.ts +1 -0
  45. package/src/cli/family-help.ts +2 -2
  46. package/src/cli/family-pages.ts +1 -1
  47. package/src/cli/kit/builtins.ts +1 -0
  48. package/src/cli/kit/verb.ts +6 -2
  49. package/src/cli/registry.ts +21 -2
  50. package/src/cli.ts +5 -2
  51. package/src/collections/actions.ts +25 -74
  52. package/src/collections/collection-types.ts +9 -5
  53. package/src/collections/md-body.ts +5 -3
  54. package/src/collections/pings.ts +13 -6
  55. package/src/collections/providers.ts +53 -61
  56. package/src/collections/reflections.ts +9 -4
  57. package/src/core/discover-checks.ts +18 -3
  58. package/src/core/git.ts +31 -0
  59. package/src/core/house-layout.ts +17 -0
  60. package/src/core/layout.ts +10 -5
  61. package/src/core/locked-write.ts +4 -1
  62. package/src/core/machine-db.ts +5 -3
  63. package/src/core/migrate-layout.ts +8 -10
  64. package/src/home/activity.ts +8 -15
  65. package/src/home/daemon-jobs.ts +13 -1
  66. package/src/home/home-paths.ts +6 -3
  67. package/src/home/home-routes.ts +8 -0
  68. package/src/home/inbox-shape.ts +233 -100
  69. package/src/home/inbox.ts +26 -71
  70. package/src/home/machine-fold.ts +10 -15
  71. package/src/home/machine-host.ts +19 -1
  72. package/src/home/other-macs.ts +2 -2
  73. package/src/home/serve-web.ts +6 -5
  74. package/src/home/space-page.ts +1 -1
  75. package/src/home/vault-page.ts +51 -17
  76. package/src/home/vault-words.ts +2 -2
  77. package/src/hooks/one-way-in-guard.ts +24 -2
  78. package/src/hq/files-send.ts +27 -28
  79. package/src/hq/hq-db.ts +4 -1
  80. package/src/hq/hq-local.ts +37 -4
  81. package/src/hq/hq-routes.ts +10 -2
  82. package/src/hq/hq-store.ts +6 -2
  83. package/src/hq/kinds/ask.ts +6 -6
  84. package/src/hq/outbox.ts +5 -3
  85. package/src/hq/replica.ts +1 -2
  86. package/src/hq/vault-route.ts +112 -0
  87. package/src/identities/collection.ts +2 -2
  88. package/src/identities/identities.ts +9 -8
  89. package/src/identities/machine-route.ts +8 -3
  90. package/src/ledger/db.ts +8 -1
  91. package/src/media-store/backup/daemon.ts +48 -8
  92. package/src/media-store/backup/keys.ts +1 -1
  93. package/src/media-store/backup/manifest.ts +20 -2
  94. package/src/media-store/backup/prune.ts +365 -0
  95. package/src/media-store/backup/retention.ts +122 -0
  96. package/src/media-store/backup/run.ts +14 -8
  97. package/src/media-store/backup/sources.ts +18 -17
  98. package/src/media-store/backup/thread-copy.ts +340 -0
  99. package/src/media-store/copy/config.ts +3 -4
  100. package/src/media-store/copy/store.ts +2 -2
  101. package/src/media-store/db.ts +2 -2
  102. package/src/media-store/forget.ts +118 -0
  103. package/src/media-store/purge.ts +3 -2
  104. package/src/media-store/space-listing.ts +20 -4
  105. package/src/media-store/space.ts +6 -5
  106. package/src/messages/guard.ts +49 -0
  107. package/src/messages/model.ts +1 -1
  108. package/src/messages/objects.ts +201 -0
  109. package/src/messages/routes.ts +2 -2
  110. package/src/messages/score.ts +1 -1
  111. package/src/messages/write.ts +285 -0
  112. package/src/pages/frame-client.ts +181 -4
  113. package/src/reflections/reflections-queue.ts +1 -1
  114. package/src/release/gate-checkout.ts +2 -1
  115. package/src/release/git-facts.ts +3 -2
  116. package/src/release/public-clean.ts +3 -2
  117. package/src/repo-config.ts +40 -18
  118. package/src/review/anim.ts +1 -1
  119. package/src/review/answer-kinds.ts +131 -0
  120. package/src/review/band.ts +53 -0
  121. package/src/review/branch-hold.ts +84 -0
  122. package/src/review/card-db.ts +16 -6
  123. package/src/review/card-rows.ts +4 -3
  124. package/src/review/cells.ts +297 -65
  125. package/src/review/close.ts +92 -0
  126. package/src/review/draft-card.ts +8 -16
  127. package/src/review/draft-model.ts +2 -2
  128. package/src/review/events.ts +171 -0
  129. package/src/review/format.ts +128 -14
  130. package/src/review/glyphs.ts +63 -0
  131. package/src/review/gone.ts +1 -1
  132. package/src/review/holds-sync.ts +62 -0
  133. package/src/review/holds.ts +85 -0
  134. package/src/review/house-kind-defs.ts +41 -0
  135. package/src/review/inbox-hook.ts +22 -9
  136. package/src/review/inbox-read.ts +201 -0
  137. package/src/review/instructions.ts +199 -0
  138. package/src/review/kind-apply.ts +61 -0
  139. package/src/review/kind-catalog.ts +96 -0
  140. package/src/review/kinds.ts +278 -0
  141. package/src/review/lane-ask.ts +109 -0
  142. package/src/review/model.ts +396 -86
  143. package/src/review/move.ts +3 -3
  144. package/src/review/need-address.ts +15 -0
  145. package/src/review/need-threads.ts +93 -0
  146. package/src/review/object-card.ts +48 -0
  147. package/src/review/object-read.ts +31 -0
  148. package/src/review/owner-verdict.ts +36 -0
  149. package/src/review/parties.ts +182 -0
  150. package/src/review/previews.ts +3 -1
  151. package/src/review/projections.ts +235 -0
  152. package/src/review/referring.ts +54 -0
  153. package/src/review/reflection-object.ts +195 -0
  154. package/src/review/routes.ts +137 -32
  155. package/src/review/secret-route.ts +80 -0
  156. package/src/review/snooze.ts +38 -0
  157. package/src/review/stage-card.ts +4 -4
  158. package/src/review/store.ts +366 -85
  159. package/src/review/supersede.ts +116 -0
  160. package/src/review/take-back.ts +52 -0
  161. package/src/review/thread-fold.ts +20 -7
  162. package/src/review/threads.ts +236 -39
  163. package/src/review/traces.ts +218 -0
  164. package/src/review/trailer-card.ts +2 -2
  165. package/src/review/unit.ts +71 -5
  166. package/src/review/verdict-items.ts +73 -0
  167. package/src/review/verdict-write.ts +15 -0
  168. package/src/review/wait.ts +85 -0
  169. package/src/review/watchers.ts +22 -9
  170. package/src/scaffold/files/claude-settings-local.json +2 -0
  171. package/src/secrets/archive-mark.ts +52 -0
  172. package/src/secrets/archive.ts +83 -0
  173. package/src/secrets/copy.ts +14 -14
  174. package/src/secrets/keychain-write.ts +48 -0
  175. package/src/secrets/keychain.ts +8 -5
  176. package/src/secrets/lapse-mark.ts +33 -0
  177. package/src/secrets/lapse.ts +60 -0
  178. package/src/secrets/list.ts +16 -22
  179. package/src/secrets/manager.ts +31 -16
  180. package/src/secrets/read.ts +161 -33
  181. package/src/secrets/tail.ts +31 -0
  182. package/src/serve/hub-app/asks-page.tsx +2 -1
  183. package/src/serve/hub-app/auto-text.tsx +14 -6
  184. package/src/serve/hub-app/benign-errors.ts +15 -1
  185. package/src/serve/hub-app/card-head.tsx +49 -0
  186. package/src/serve/hub-app/check-view.tsx +3 -2
  187. package/src/serve/hub-app/code-copy.ts +35 -0
  188. package/src/serve/hub-app/col-card.tsx +31 -40
  189. package/src/serve/hub-app/col-list-page.tsx +5 -2
  190. package/src/serve/hub-app/col-tables-view.tsx +7 -4
  191. package/src/serve/hub-app/col-tables.ts +5 -5
  192. package/src/serve/hub-app/cols-svc.ts +4 -79
  193. package/src/serve/hub-app/commands/commands-page.tsx +2 -1
  194. package/src/serve/hub-app/controls.css +83 -0
  195. package/src/serve/hub-app/frames-st.ts +17 -1
  196. package/src/serve/hub-app/git-view.tsx +3 -2
  197. package/src/serve/hub-app/home-st.ts +57 -6
  198. package/src/serve/hub-app/home-strip.css +1 -6
  199. package/src/serve/hub-app/home-strip.tsx +2 -1
  200. package/src/serve/hub-app/home.html +3 -0
  201. package/src/serve/hub-app/house-wiki-view.tsx +20 -0
  202. package/src/serve/hub-app/hub-app.tsx +48 -32
  203. package/src/serve/hub-app/hub-types.ts +2 -0
  204. package/src/serve/hub-app/hub.css +50 -61
  205. package/src/serve/hub-app/icons.tsx +14 -4
  206. package/src/serve/hub-app/identities-view.tsx +4 -3
  207. package/src/serve/hub-app/inbox-st.ts +203 -42
  208. package/src/serve/hub-app/inbox-view.tsx +189 -101
  209. package/src/serve/hub-app/inbox.css +47 -44
  210. package/src/serve/hub-app/index.html +3 -0
  211. package/src/serve/hub-app/instructions.css +30 -0
  212. package/src/serve/hub-app/keys.ts +5 -3
  213. package/src/serve/hub-app/machine-st.ts +2 -2
  214. package/src/serve/hub-app/machines-view.tsx +4 -11
  215. package/src/serve/hub-app/machines.css +0 -9
  216. package/src/serve/hub-app/markdown.css +51 -0
  217. package/src/serve/hub-app/md-copy.tsx +18 -40
  218. package/src/serve/hub-app/md.ts +25 -9
  219. package/src/serve/hub-app/media-view.tsx +2 -2
  220. package/src/serve/hub-app/messages/messages-page.tsx +2 -1
  221. package/src/serve/hub-app/messages/messages-st.ts +1 -1
  222. package/src/serve/hub-app/messages.css +0 -1
  223. package/src/serve/hub-app/objects.css +51 -0
  224. package/src/serve/hub-app/page-keys.ts +1 -1
  225. package/src/serve/hub-app/pages-frames.tsx +11 -1
  226. package/src/serve/hub-app/palette-st.ts +4 -4
  227. package/src/serve/hub-app/pane-boundary.tsx +72 -0
  228. package/src/serve/hub-app/pane-errors.ts +54 -0
  229. package/src/serve/hub-app/plan-view.tsx +3 -2
  230. package/src/serve/hub-app/planned-view.tsx +3 -3
  231. package/src/serve/hub-app/planned.css +0 -4
  232. package/src/serve/hub-app/processes-view.tsx +3 -2
  233. package/src/serve/hub-app/project-list.css +5 -13
  234. package/src/serve/hub-app/project-list.tsx +3 -6
  235. package/src/serve/hub-app/projects-svc.ts +6 -2
  236. package/src/serve/hub-app/readme.css +9 -15
  237. package/src/serve/hub-app/reflections-page.tsx +54 -1
  238. package/src/serve/hub-app/releases/releases-page.tsx +3 -2
  239. package/src/serve/hub-app/releases.css +0 -1
  240. package/src/serve/hub-app/review/code-colors.ts +30 -0
  241. package/src/serve/hub-app/review/diff-view.tsx +75 -0
  242. package/src/serve/hub-app/review/dock.tsx +104 -0
  243. package/src/serve/hub-app/review/draft-card.tsx +2 -2
  244. package/src/serve/hub-app/review/group-block.tsx +209 -0
  245. package/src/serve/hub-app/review/instructions-view.tsx +116 -0
  246. package/src/serve/hub-app/review/item-verdict.tsx +38 -0
  247. package/src/serve/hub-app/review/kind-states.tsx +193 -0
  248. package/src/serve/hub-app/review/kind-view.tsx +1 -37
  249. package/src/serve/hub-app/review/kit.tsx +57 -54
  250. package/src/serve/hub-app/review/lane-bar.tsx +64 -0
  251. package/src/serve/hub-app/review/object-card.tsx +62 -0
  252. package/src/serve/hub-app/review/object-panel.tsx +179 -0
  253. package/src/serve/hub-app/review/question-views.tsx +385 -0
  254. package/src/serve/hub-app/review/review-cells.tsx +86 -105
  255. package/src/serve/hub-app/review/review-list.tsx +104 -47
  256. package/src/serve/hub-app/review/review-page.tsx +5 -4
  257. package/src/serve/hub-app/review/review-st.ts +68 -28
  258. package/src/serve/hub-app/review/review-thread.tsx +171 -40
  259. package/src/serve/hub-app/review/review-views.tsx +35 -31
  260. package/src/serve/hub-app/review/thread-close.tsx +124 -0
  261. package/src/serve/hub-app/review/thread-control.tsx +4 -4
  262. package/src/serve/hub-app/review/thread-st.ts +222 -22
  263. package/src/serve/hub-app/review/trailer-card.tsx +1 -1
  264. package/src/serve/hub-app/review/trailer-timeline.tsx +2 -2
  265. package/src/serve/hub-app/review.css +216 -57
  266. package/src/serve/hub-app/section-head.tsx +51 -0
  267. package/src/serve/hub-app/social/calendar.tsx +5 -11
  268. package/src/serve/hub-app/social/comms-page.tsx +23 -10
  269. package/src/serve/hub-app/social/kit.tsx +8 -15
  270. package/src/serve/hub-app/social/next-release.tsx +3 -5
  271. package/src/serve/hub-app/social/post-card.tsx +3 -0
  272. package/src/serve/hub-app/social/post-page.tsx +80 -0
  273. package/src/serve/hub-app/social/problems.tsx +5 -9
  274. package/src/serve/hub-app/social/social-model.ts +13 -5
  275. package/src/serve/hub-app/social/social-page.tsx +1 -1
  276. package/src/serve/hub-app/social/social-st.ts +42 -5
  277. package/src/serve/hub-app/social.css +7 -17
  278. package/src/serve/hub-app/space.css +1 -1
  279. package/src/serve/hub-app/stores/stores-page.tsx +6 -2
  280. package/src/serve/hub-app/thread-row.tsx +101 -0
  281. package/src/serve/hub-app/time-ago.tsx +3 -2
  282. package/src/serve/hub-app/time-view.tsx +2 -1
  283. package/src/serve/hub-app/time.css +2 -5
  284. package/src/serve/hub-app/tree-row.tsx +1 -9
  285. package/src/serve/hub-app/vault-view.tsx +4 -4
  286. package/src/serve/hub-app/veille/veille-page.tsx +2 -11
  287. package/src/serve/hub-app/veille.css +0 -1
  288. package/src/serve/hub-app/waiting-svc.ts +4 -4
  289. package/src/serve/hub-app/when-view.tsx +6 -3
  290. package/src/serve/hub-app/wiki-st.ts +30 -4
  291. package/src/serve/hub-app/wikis-view.tsx +4 -3
  292. package/src/serve/hub-runtime.ts +20 -6
  293. package/src/serve/project-gutter-route.ts +16 -6
  294. package/src/serve/project-gutter.ts +6 -53
  295. package/src/serve/same-origin.ts +3 -0
  296. package/src/serve/secret-gate.ts +21 -0
  297. package/src/serve/serve-hub.ts +29 -20
  298. package/src/serve/tailnet-caller.ts +117 -0
  299. package/src/shipkit.ts +2 -2
  300. package/src/site/desk.ts +2 -2
  301. package/src/smoke/run-smoke.ts +3 -4
  302. package/src/social/brands.ts +4 -0
  303. package/src/social/card-drafts.ts +11 -19
  304. package/src/social/desk-index.ts +34 -13
  305. package/src/social/drafts.ts +4 -4
  306. package/src/social/import-drafts.ts +244 -0
  307. package/src/social/kind-pages.ts +3 -3
  308. package/src/social/kinds.ts +1 -1
  309. package/src/social/load.ts +89 -64
  310. package/src/social/media-kind.ts +68 -161
  311. package/src/social/media-of.ts +5 -4
  312. package/src/social/open.ts +3 -2
  313. package/src/social/post-object.ts +120 -0
  314. package/src/social/post-sources.ts +136 -0
  315. package/src/social/post-text.ts +103 -0
  316. package/src/social/posts.ts +378 -0
  317. package/src/social/presence.ts +7 -5
  318. package/src/social/publish/index.ts +17 -5
  319. package/src/social/publish/secret.ts +2 -2
  320. package/src/social/release-stage.ts +58 -57
  321. package/src/social/routes.ts +64 -24
  322. package/src/social/stage.ts +42 -57
  323. package/src/social/text.ts +4 -3
  324. package/src/social/thumbnail.ts +135 -43
  325. package/src/social/tracker.ts +1 -1
  326. package/src/social/writes.ts +12 -29
  327. package/src/stores/desk.ts +16 -11
  328. package/src/stores/unit.ts +2 -2
  329. package/src/trailer/sound/eleven.ts +33 -3
  330. package/src/urls/rows.ts +1 -1
  331. package/src/vault/vault-http.ts +11 -3
  332. package/src/vault/vault-import.ts +6 -1
  333. package/src/veille/identity.ts +2 -2
  334. package/src/wiki/graph-pages.ts +13 -1
  335. package/src/wiki/scan-md.ts +1 -1
  336. package/src/asks/asks-queue.ts +0 -424
  337. package/src/messages/suggest.ts +0 -96
  338. package/src/social/migrate.ts +0 -123
@@ -76,7 +76,7 @@ export type ServeConfig = {
76
76
  uses?: string[]
77
77
  /** the house's private S3 bucket that keeps every file of the machine's
78
78
  * media store (review cards, trailer cuts...), read only in the house
79
- * config; its key pair read through `credsReadCommand` */
79
+ * config; its key pair read through the house store */
80
80
  mediaSpace?: import('./media-store/space.ts').MediaSpace
81
81
  /** only in the house config: the bucket that holds the second copy of the hq's database, sent by Litestream
82
82
  * (wiki tools/shipkit/hq.md). A bucket of its own, with versioning off */
@@ -94,8 +94,11 @@ export type ServeConfig = {
94
94
  * stale scratch there; a repo's own `annex` adds to it (wiki
95
95
  * tools/shipkit/annex.md, Scratch by itself) */
96
96
  annexScratch?: import('./annex/tidy.ts').AnnexScratch
97
+ /** which backups stay, read only in the house config: every one of the last hours, then the newest of each day,
98
+ * week and month counted back (wiki tools/shipkit/media-store-backup.md, Retention). Absent: nothing is deleted */
99
+ backupRetention?: import('./media-store/backup/retention.ts').BackupRetention
97
100
  /** the secret whose value is a Cloudflare API token, read through
98
- * `credsReadCommand`, only in the house config: the site desk asks Pages
101
+ * the house store, only in the house config: the site desk asks Pages
99
102
  * for a site's last production deployment with it */
100
103
  cloudflareToken?: string
101
104
  }
@@ -125,9 +128,9 @@ export type RepoConfig = {
125
128
  id?: string
126
129
  /** venue ids this repo ships on — selects which contracts are REQUIRED */
127
130
  venues?: string[]
128
- /** retired with the v2 social contract: read by nothing; delete the line (`sk social migrate` moves the posts) */
131
+ /** retired with the v2 social contract: read by nothing; delete the line */
129
132
  social?: string[]
130
- /** the identity that speaks for this repo in public, an id of the house repo's `.shipkit/identities/` (`sk
133
+ /** the identity that speaks for this repo in public, an id of the house repo's `wiki/identities/` (`sk
131
134
  * identities`); required on a machine with identities (SK038). A draft may name another (wiki
132
135
  * tools/shipkit/social.md) */
133
136
  speaksAs?: string
@@ -150,11 +153,8 @@ export type RepoConfig = {
150
153
  /** DEPRECATED, read through 0.40 and rewritten by `shipkit check --fix
151
154
  * SK016`: a build step is a `<name>.check.ts` file with `build: true` */
152
155
  tasks?: TaskDef[]
153
- /** the human action queue: the folder it lives in, and the line the
154
- * all-clear prints (`shipkit asks`). */
156
+ /** the human action queue, each ask a thread of the repo's store: the line the all-clear prints (`shipkit asks`) */
155
157
  asks?: {
156
- /** the queue folder, repo-relative (default '.shipkit/asks') */
157
- dir?: string
158
158
  /** the `shipkit asks` all-clear line, in the repo's own voice */
159
159
  emptyText?: string
160
160
  }
@@ -183,14 +183,38 @@ export type RepoConfig = {
183
183
  level?: 'core' | 'used' | 'minor'
184
184
  /** the repos and identities it is for (`sk secret list` shows a repo only its own). Absent: every repo */
185
185
  for?: Scope
186
+ /** kept but out of use since `at` (`sk secret archive`): every read refuses it, `sk secret list` hides it */
187
+ archived?: {
188
+ /** the day it was archived, YYYY-MM-DD */
189
+ at: string
190
+ /** why it was archived, as `--why` said it */
191
+ why: string
192
+ }
193
+ /** a token that expires by design: expired, its probe prints a note and passes, and a consumer that needs it
194
+ * fails with this command and opens the ask (secrets/lapse.ts) */
195
+ lapses?: {
196
+ /** the one command that refreshes it */
197
+ refresh: string
198
+ }
199
+ }[]
200
+ /** in the house config: commands the house retired, each with the command that replaces it. SK050 warns on every
201
+ * live mention in a house repo (history folders aside), and `sk check --fix SK050` rewrites the plain forms of
202
+ * `verbs` (`<command> <verb>`, and `'<command>', '<verb>'` in an argv), and drops a manager template that names
203
+ * the command. Every other mention is fixed by hand */
204
+ retired?: {
205
+ /** the retired command, as it is typed: `old-tool` */
206
+ command: string
207
+ /** what replaces it, the words a rewrite puts in its place: `kit tool` */
208
+ use: string
209
+ /** the verbs the two share word for word, the only forms `--fix` rewrites */
210
+ verbs: string[]
186
211
  }[]
187
- /** store-command template for a missing secret tile, `{name}` substituted, as in your secret manager's set command */
212
+ /** for secrets kept in another manager than the house store (the vault, else the login keychain, `sk secret`):
213
+ * its store-command template, `{name}` substituted, the value on its stdin. Absent: `sk secret set` */
188
214
  credsCommand?: string
189
- /** READ-command template, the twin of `credsCommand`: prints one field of
190
- * a secret, `{name}` and `{field}` (get = the value, account = the
191
- * identity stored beside it) substituted, run WITHOUT a shell. The one
192
- * way a value reaches a command (`shipkit smoke` login), so it never sits
193
- * in config, argv or env. Required when `smoke.login` is declared. */
215
+ /** READ-command template, the twin of `credsCommand`, for secrets kept in another manager: prints one field of
216
+ * a secret, `{name}` and `{field}` (get = the value, account = the identity stored beside it) substituted, run
217
+ * WITHOUT a shell. Absent: the house store answers (`sk secret get`) */
194
218
  credsReadCommand?: string
195
219
  /** notify command for new RED needs while the hub serves, `{message}` substituted, as in a push-notification CLI */
196
220
  notifyCommand?: string
@@ -416,7 +440,7 @@ export type RepoConfig = {
416
440
  logDir?: string
417
441
  }
418
442
 
419
- const KNOWN_KEYS = new Set(['name', 'id', 'venues', 'social', 'speaksAs', 'backup', 'annex','docsBase', 'defaults', 'tasks', 'asks', 'creds', 'credsCommand', 'credsReadCommand', 'notifyCommand', 'contracts', 'gitignore', 'ignoredInputs', 'untrackGenerated', 'nested', 'off', 'when', 'budgets', 'instantHooks', 'ruleExempt', 'visibility', 'archived', 'history', 'reviewer', 'oneWayIn', 'rules', 'release', 'units', 'notReleasable', 'vendored', 'hooks', 'checkDefaults', 'tui', 'serve', 'recorder', 'identity', 'logDir', 'smoke', 'tests', 'browsers', 'start'])
443
+ const KNOWN_KEYS = new Set(['name', 'id', 'venues', 'social', 'speaksAs', 'backup', 'annex','docsBase', 'defaults', 'tasks', 'asks', 'creds', 'credsCommand', 'credsReadCommand', 'retired', 'notifyCommand', 'contracts', 'gitignore', 'ignoredInputs', 'untrackGenerated', 'nested', 'off', 'when', 'budgets', 'instantHooks', 'ruleExempt', 'visibility', 'archived', 'history', 'reviewer', 'oneWayIn', 'rules', 'release', 'units', 'notReleasable', 'vendored', 'hooks', 'checkDefaults', 'tui', 'serve', 'recorder', 'identity', 'logDir', 'smoke', 'tests', 'browsers', 'start'])
420
444
 
421
445
  export function defineRepo(c: RepoConfig): RepoConfig {
422
446
  if (typeof c.name !== 'string' || c.name === '') throw new Error('defineRepo: name is required')
@@ -559,11 +583,9 @@ export function defineRepo(c: RepoConfig): RepoConfig {
559
583
  }
560
584
  if (c.credsReadCommand != null && !/\{name\}/.test(c.credsReadCommand))
561
585
  throw new Error(`defineRepo: credsReadCommand must carry {name} (and {field} for get | account), e.g. 'my-secrets {field} {name}'`)
562
- if (c.smoke?.login != null && (c.credsReadCommand ?? '') === '')
563
- throw new Error(`defineRepo: smoke.login reads its password through credsReadCommand, which this repo does not declare (e.g. 'my-secrets {field} {name}')`)
564
586
  // without {field} the account read answers the VALUE, and the run types the
565
587
  // password into the identity box, where a failed-login journal keeps it
566
- if (c.smoke?.login?.emailSecret != null && !/\{field\}/.test(c.credsReadCommand ?? ''))
588
+ if (c.smoke?.login?.emailSecret != null && c.credsReadCommand != null && !/\{field\}/.test(c.credsReadCommand))
567
589
  throw new Error(`defineRepo: smoke.login.emailSecret needs credsReadCommand to carry {field}, or the account read answers the password itself`)
568
590
  return c
569
591
  }
@@ -159,7 +159,7 @@ const making = new Map<string, Promise<Anim>>()
159
159
  /** the animation of view `ask.view` of card `id`, made once and kept under `<dir>/.anims/` (readAll skips dot names) */
160
160
  export async function pairAnimation(dir: string, id: string, ask: AnimAsk): Promise<Anim> {
161
161
  const x = readItem(dir, id)
162
- if (!x) return Promise.reject(new Error(`no card ${id}`))
162
+ if (!x) return Promise.reject(new Error(`no item ${id}`))
163
163
  const v = x.item.views[ask.view]
164
164
  if (!v) return Promise.reject(new Error(`card ${id} has no view ${ask.view} (it has ${x.item.views.length})`))
165
165
  if (isGallery(v) || !isPair(v.files)) return Promise.reject(new Error(`view ${ask.view} of ${id} is not a before and after`))
@@ -0,0 +1,131 @@
1
+ // what each answer kind of a question waits for and what his answer says (wiki tools/shipkit/threads-asks.md, Answer
2
+ // kinds): one reading for the store, the turn, the watch and the hub; pure and browser safe
3
+ import { choiceName } from './instructions.ts'
4
+ import { partyOf, type AnswerKind, type Message } from './model.ts'
5
+
6
+ export const kindOfAsk = (m: Message): AnswerKind => m.ask?.kind ?? 'choice'
7
+
8
+ /** the words a question goes by in one line: an ask's instructions by their title, never their whole markdown */
9
+ export const questionWords = (m: Message): string => m.instructions?.title ?? m.text ?? ''
10
+
11
+ /** the name of the option he picked on a choice step of an ask's instructions, null for none */
12
+ export const pickedName = (m: Message, option: number, pick: number | undefined): string | null => {
13
+ const o = pick === undefined ? undefined : m.ask?.choices?.[option]?.options[pick]
14
+ return o === undefined ? null : choiceName(o)
15
+ }
16
+
17
+
18
+ /** a checklist's or a confirm's tick lines: a confirm has one, its question */
19
+ export const ticks = (k: AnswerKind): boolean => k === 'checklist' || k === 'confirm'
20
+
21
+ /** the lines a checklist or a confirm ticks */
22
+ export const linesOf = (m: Message): string[] => (kindOfAsk(m) === 'confirm' ? [m.text ?? 'done'] : (m.ask?.options ?? []))
23
+
24
+ /** his answers to the question `m`, oldest first, up to `upTo` (a message id, included) */
25
+ const answersTo = (thread: readonly Message[], m: Message, upTo?: string): Message[] => {
26
+ const end = upTo === undefined ? thread.length : thread.findIndex((y) => y.id === upTo) + 1
27
+ return thread.slice(0, end > 0 ? end : thread.length).filter((y) => y.re === m.id && partyOf(y.who) === 'owner')
28
+ }
29
+
30
+ /** each line's tick as he left it last, the lines done before he looked first; up to `upTo` when given */
31
+ export function ticksOf(thread: readonly Message[], m: Message, upTo?: string): Map<number, { tick: boolean; at: string | null; pick?: number }> {
32
+ const out = new Map<number, { tick: boolean; at: string | null; pick?: number }>()
33
+ for (const i of m.ask?.done ?? []) out.set(i, { tick: true, at: null })
34
+ for (const y of answersTo(thread, m, upTo))
35
+ if (y.answer?.option !== undefined && y.answer.tick !== undefined) out.set(y.answer.option, { tick: y.answer.tick, at: y.at, ...(y.answer.tick && y.answer.pick !== undefined ? { pick: y.answer.pick } : {}) })
36
+ // a step of an ask's instructions with fields ticks itself once each of its fields is answered, unless he unticked it
37
+ if (m.instructions !== undefined) {
38
+ const fields = thread.filter((q) => q.step?.of === m.id && partyOf(q.who) === 'agent')
39
+ for (const i of new Set(fields.map((q) => q.step!.i))) {
40
+ if (out.has(i)) continue
41
+ const mine = fields.filter((q) => q.step!.i === i)
42
+ if (mine.every((q) => !askOpen(thread.slice(0, upTo === undefined ? thread.length : thread.findIndex((z) => z.id === upTo) + 1 || thread.length), q)))
43
+ out.set(i, { tick: true, at: answersTo(thread, mine.at(-1)!, upTo).at(-1)?.at ?? null })
44
+ }
45
+ }
46
+ return out
47
+ }
48
+
49
+ /** how many lines are ticked, of how many */
50
+ export function tickCount(thread: readonly Message[], m: Message, upTo?: string): { done: number; of: number } {
51
+ const t = ticksOf(thread, m, upTo)
52
+ const lines = linesOf(m)
53
+ return { done: lines.filter((_, i) => t.get(i)?.tick === true).length, of: lines.length }
54
+ }
55
+
56
+ /** the owner's words alone on it: none of the options, no value; a checklist takes them as a reply and stays as it is */
57
+ export const wordsAlone = (y: Message): boolean => y.answer === undefined
58
+
59
+ /** whether the question waits on him: a checklist until every line is ticked; any other kind until he answers it, his
60
+ * words alone answering it as none */
61
+ export function askOpen(thread: readonly Message[], m: Message): boolean {
62
+ if (m.ask === undefined) return false
63
+ const k = kindOfAsk(m)
64
+ const mine = answersTo(thread, m)
65
+ if (k === 'checklist') {
66
+ const c = tickCount(thread, m)
67
+ return c.done < c.of
68
+ }
69
+ if (k === 'confirm') return !mine.some((y) => wordsAlone(y) || y.answer?.tick === true) || mine.at(-1)?.answer?.tick === false
70
+ return mine.length === 0
71
+ }
72
+
73
+ /** the one line an agent reads for his answer `y` to the question `m` of item `id`, null when `y` answers it with no kind
74
+ * of its own (a choice's option and words alone stay with the caller) */
75
+ export function kindAnswerLine(id: string, thread: readonly Message[], m: Message, y: Message, flat: (s: string) => string): string | null {
76
+ const k = kindOfAsk(m)
77
+ const q = `"${flat(questionWords(m))}"`
78
+ const a = y.answer
79
+ if (a === undefined) return null
80
+ if (k === 'checklist' && a.option !== undefined && a.tick !== undefined) {
81
+ const line = flat(linesOf(m)[a.option] ?? `line ${a.option + 1}`)
82
+ if (!a.tick) return `${id} unticked "${line}" of ${q}`
83
+ const c = tickCount(thread, m, y.id)
84
+ const name = pickedName(m, a.option, a.pick)
85
+ const picked = name === null ? '' : `: picked ${a.pick! + 1} « ${flat(name)} »`
86
+ return c.done === c.of ? `${id} all ${c.of} done ${q} (last: "${line}")${picked}` : `${id} ticked ${c.done}/${c.of} "${line}" of ${q}${picked}`
87
+ }
88
+ if (k === 'confirm' && a.tick !== undefined) return a.tick ? `${id} done ${q} at ${y.at}` : `${id} not done after all ${q}`
89
+ if ((k === 'text' || k === 'url') && a.value !== undefined) return `${id} answered ${q}: ${flat(a.value)}${k === 'url' ? (a.opens ? ` (opens ${a.opens})` : ' (did not open from here)') : ''}`
90
+ if (k === 'secret' && a.stored !== undefined) return `${id} answered ${q}: stored as ${a.stored}; read it with sk secret get ${a.stored}`
91
+ if (k === 'file' && a.view !== undefined) return `${id} answered ${q}: file in view ${a.view + 1} of ${id} (sk thread show ${id})`
92
+ return null
93
+ }
94
+
95
+ /** a question of another kind than a choice as its cell draws it: its lines and his ticks, his value, a secret's name and
96
+ * when it was stored, the owner's words alone, and whether it still waits on him */
97
+ export function kindCellAsk(thread: readonly Message[], m: Message) {
98
+ const k = kindOfAsk(m)
99
+ const mine = answersTo(thread, m)
100
+ const last = mine.at(-1)
101
+ const t = ticksOf(thread, m)
102
+ const valued = [...mine].reverse().find((y) => y.answer?.value !== undefined || y.answer?.view !== undefined)
103
+ const stored = [...mine].reverse().find((y) => y.answer?.stored !== undefined)
104
+ const none = k !== 'checklist' && last !== undefined && wordsAlone(last) ? last.text ?? '' : undefined
105
+ return {
106
+ kind: k,
107
+ options: m.ask?.options ?? [],
108
+ open: askOpen(thread, m),
109
+ ...(ticks(k) ? { lines: linesOf(m).map((text, i) => ({ text, tick: t.get(i)?.tick === true, at: t.get(i)?.at ?? null, ...(t.get(i)?.pick !== undefined ? { pick: t.get(i)!.pick } : {}) })) } : {}),
110
+ ...(m.ask?.choices ? { choices: m.ask.choices } : {}),
111
+ ...(valued?.answer ? { value: { text: valued.answer.value ?? '', at: valued.at, ...(valued.answer.opens !== undefined ? { opens: valued.answer.opens } : {}), ...(valued.answer.view !== undefined ? { view: valued.answer.view } : {}) } } : {}),
112
+ ...(m.ask?.secret ? { secret: { name: m.ask.secret.name, ...(m.ask.secret.login ? { login: true } : {}), ...(stored ? { stored: stored.at } : {}) } } : {}),
113
+ ...(none !== undefined ? { none } : {}),
114
+ }
115
+ }
116
+
117
+ /** a question as the agent's inbox lists it: its kind and where it stands */
118
+ export function askStateText(thread: readonly Message[], m: Message): string {
119
+ const k = kindOfAsk(m)
120
+ if (k === 'checklist') {
121
+ const t = ticksOf(thread, m)
122
+ return linesOf(m)
123
+ .map((l, i) => {
124
+ const name = pickedName(m, i, t.get(i)?.pick)
125
+ return `${t.get(i)?.tick ? '[x]' : '[ ]'} ${l}${name === null ? '' : ` (picked « ${name} »)`}`
126
+ })
127
+ .join(' · ')
128
+ }
129
+ if (k === 'secret') return `a secret field for ${m.ask?.secret?.name ?? '?'}${m.ask?.secret?.login ? ' (a login: its account too)' : ''}`
130
+ return `a ${k} field`
131
+ }
@@ -0,0 +1,53 @@
1
+ // the band a thread reads in (wiki tools/shipkit/threads-how-it-fits.md, The bands): who acts now (threads.ts turnOf),
2
+ // and on an agent's move whether a live agent works it now or it waits for one. Pure and browser safe: the hub reads it
3
+ // with the parties it polls, so a lane's end moves its threads to « waiting for an agent » with no reload
4
+ // the one constraint a reader breaks first: « an agent works on it » is a fact of the registry, never of the store alone
5
+ import { laneAskOwed, type LaneAsk } from './lane-ask.ts'
6
+ import type { Parties } from './parties.ts'
7
+ import type { Turn } from './threads.ts'
8
+
9
+ export const BANDS = ['yours', 'aside', 'working', 'waiting', 'done'] as const
10
+ export type Band = (typeof BANDS)[number]
11
+
12
+ export const BAND_WORDS: Record<Band, string> = { yours: 'your turn', aside: 'set aside', working: 'an agent works on it', waiting: 'waiting for an agent', done: 'done' }
13
+
14
+ /** what the band reads of a thread: its turn, its holder, and the agent of its `working` not ended (traces.ts
15
+ * workingsOf), `agent` for a session's own */
16
+ export interface BandFacts {
17
+ turn: Turn
18
+ holder?: { lane?: string; session?: string }
19
+ working?: string
20
+ /** his request for a lane (review/lane-ask.ts): owed to the orchestrator, the thread waits for an agent */
21
+ laneAsk?: LaneAsk
22
+ }
23
+
24
+ const laneOf = (p: Parties, name: string, session: string | undefined) => p.lanes.find((l) => l.name === name && (session === undefined || l.session === session))
25
+
26
+ /** a live agent works the thread now: its `working` not ended, of a session or a lane still live; a live lane that holds
27
+ * it; a session that holds it with a live watch. A lane the registry cannot find has ended unless its watch lives (wiki
28
+ * tools/shipkit/threads-how-it-fits.md, The parties); a live session with no watch hears at its next prompt, and works
29
+ * nothing yet */
30
+ export function worksNow(f: Omit<BandFacts, 'turn'>, p: Parties): boolean {
31
+ const h = f.holder
32
+ if (f.working !== undefined) {
33
+ if (f.working === 'agent') {
34
+ if (h?.session !== undefined && p.sessions.some((s) => s.id === h.session && s.live)) return true
35
+ } else {
36
+ const l = laneOf(p, f.working, h?.lane === f.working ? h.session : undefined)
37
+ if (l !== undefined && (l.live || l.watch)) return true
38
+ }
39
+ }
40
+ if (h === undefined) return false
41
+ if (h.lane !== undefined) {
42
+ const l = laneOf(p, h.lane, h.session)
43
+ return l !== undefined && (l.live || l.watch)
44
+ }
45
+ return h.session !== undefined && p.sessions.some((s) => s.id === h.session && s.live && s.watch)
46
+ }
47
+
48
+ /** the band: the turn, an agent's move split by whether a live agent works it now */
49
+ export const bandOf = (f: BandFacts, p: Parties): Band =>
50
+ f.turn !== 'agents' ? f.turn : (f.laneAsk !== undefined && laneAskOwed(f.laneAsk, p)) || !worksNow(f, p) ? 'waiting' : 'working'
51
+
52
+ /** the words a « waiting for an agent » head says: who takes one */
53
+ export const waitingWords = (repo: string): string => `nobody works on these now: a session in ${repo} takes one with sk thread take <address>`
@@ -0,0 +1,84 @@
1
+ // the house kind `branch:<repo>/<name>` (wiki tools/shipkit/threads-how-it-fits.md, Kinds): a branch of a house repo
2
+ // holds its thread open until merged into the branch `sk bump` merges into (`release.branch`, else main). Local refs
3
+ // alone, never a fetch: a merge done on the remote only counts once the local base has it.
4
+ //
5
+ // the one constraint a reader breaks first: a branch with no commit of its own is an ancestor of its base too, so it
6
+ // counts as merged only once it moved since the last check, or had commits of its own then (`ahead`)
7
+ import { basename } from 'node:path'
8
+ import type { HoldState } from './holds.ts'
9
+
10
+ interface Git {
11
+ code: number
12
+ out: string
13
+ }
14
+ const git = (root: string, args: string[]): Git => {
15
+ const r = Bun.spawnSync(['git', '-C', root, ...args], { stdout: 'pipe', stderr: 'pipe' })
16
+ return { code: r.exitCode, out: r.stdout.toString().trim() }
17
+ }
18
+
19
+ /** the checkout of a house repo by its name: the thread's own repo, else one the house index lists */
20
+ export async function repoRootOf(repo: string, root: string): Promise<string | null> {
21
+ const { homeRepo, houseRepos } = await import('../serve/project-gutter.ts')
22
+ const home = homeRepo(root)
23
+ if (basename(home) === repo) return home
24
+ try {
25
+ const { homedir } = await import('node:os')
26
+ return houseRepos(root, homedir()).repos.find((r) => r.name === repo)?.path ?? null
27
+ } catch {
28
+ return null
29
+ }
30
+ }
31
+
32
+ /** the branch a repo releases from: its config's `release.branch`, else main, else master */
33
+ async function baseOf(root: string): Promise<string | null> {
34
+ let want = 'main'
35
+ try {
36
+ const { loadRepoConfig } = await import('../repo-config.ts')
37
+ want = (await loadRepoConfig(root)).release?.branch ?? 'main'
38
+ } catch {
39
+ // a repo with no config releases from main
40
+ }
41
+ for (const b of [want, 'main', 'master']) if (git(root, ['rev-parse', '--verify', '--quiet', `refs/heads/${b}`]).code === 0) return b
42
+ return null
43
+ }
44
+
45
+ const isAncestor = (root: string, a: string, b: string): boolean => git(root, ['merge-base', '--is-ancestor', a, b]).code === 0
46
+
47
+ /** where the diff of the branch reads: the remote's compare page on GitHub, else the command */
48
+ function diffOf(root: string, base: string, name: string): { url?: string; command: string } {
49
+ const command = `git -C ${root} diff ${base}...${name}`
50
+ const remote = git(root, ['remote', 'get-url', 'origin']).out
51
+ const gh = /github\.com[:/]([^/]+)\/(.+?)(?:\.git)?$/.exec(remote)
52
+ return gh ? { url: `https://github.com/${gh[1]}/${gh[2]}/compare/${base}...${encodeURIComponent(name)}`, command } : { command }
53
+ }
54
+
55
+ /** the branch now, against its base: `sha` and `ahead` the last check's, from its newest hold message */
56
+ export async function branchHold(key: string, ctx: { root: string; sha?: string; ahead?: number }): Promise<HoldState> {
57
+ const slash = key.indexOf('/')
58
+ const address = `branch:${key}`
59
+ if (slash <= 0) return { held: false, words: `${address}: not <repo>/<name>, nothing to hold` }
60
+ const repo = key.slice(0, slash)
61
+ const name = key.slice(slash + 1)
62
+ const root = await repoRootOf(repo, ctx.root)
63
+ if (root === null) return { held: true, words: `held open by ${address}: no house repo named ${repo} on this machine` }
64
+ const base = await baseOf(root)
65
+ if (base === null) return { held: true, words: `held open by ${address}: ${repo} has no main branch` }
66
+ const tip = git(root, ['rev-parse', '--verify', '--quiet', `refs/heads/${name}`])
67
+ // gone: the line says the fact, never a cause (a squash merge leaves no ancestry, a rename looks the same)
68
+ if (tip.code !== 0) {
69
+ if (ctx.sha === undefined) return { held: false, words: `${address}: no such branch in ${repo}: nothing holds the thread open` }
70
+ if (isAncestor(root, ctx.sha, base))
71
+ return { held: false, words: (ctx.ahead ?? 0) > 0 ? `${address} merged into ${base}, then deleted: nothing holds the thread open` : `${address} deleted with no commit of its own: nothing holds the thread open` }
72
+ return { held: false, words: `${address} deleted, its last commit ${ctx.sha.slice(0, 8)} is not in ${base}: nothing holds the thread open` }
73
+ }
74
+ const sha = tip.out
75
+ const count = (range: string): number => Number(git(root, ['rev-list', '--count', range]).out) || 0
76
+ const ahead = count(`${base}..${sha}`)
77
+ const behind = count(`${sha}..${base}`)
78
+ const [short, subject, at] = git(root, ['log', '-1', '--format=%h%x09%s%x09%cI', sha]).out.split('\t')
79
+ const facts = { repo, name, base, ahead, behind, last: { sha: short, subject, at }, diff: diffOf(root, base, name) }
80
+ const moved = ctx.sha !== undefined && ctx.sha !== sha
81
+ if (ahead === 0 && (moved || (ctx.ahead ?? 0) > 0)) return { held: false, words: `${address} merged into ${base}: nothing holds the thread open`, sha, facts: { ...facts, merged: true } }
82
+ const words = ahead === 0 ? `held open by ${address}: no commit of its own yet` : `held open by ${address}: ${ahead} ahead of ${base}${behind > 0 ? `, ${behind} behind` : ''}`
83
+ return { held: true, words, sha, facts: { ...facts, merged: false } }
84
+ }
@@ -31,8 +31,8 @@ create index if not exists review_repos_keys on review_repos (dir);
31
31
 
32
32
  /** the connection a write inside another transaction of this process must use */
33
33
  let bound: Database | null = null
34
- /** this process's own connection, a file */
35
- const opened = new Map<string, Database>()
34
+ /** this process's own connection, a file, with the inode it opened: a file deleted or replaced since is opened again */
35
+ const opened = new Map<string, { db: Database; ino: number }>()
36
36
  /** the daemon file's own path as these connections found it: a fold puts a tombstone there, a way back a file, each a
37
37
  * new inode; null before the first open */
38
38
  let walked: number | null = null
@@ -64,7 +64,15 @@ export function cardsDb(): Database {
64
64
  walked = ino
65
65
  let path = daemonDbPath()
66
66
  const held = opened.get(path)
67
- if (held != null) return held
67
+ if (held != null) {
68
+ if (lstatSync(path, { throwIfNoEntry: false })?.ino === held.ino) return held.db
69
+ try {
70
+ held.db.close()
71
+ } catch {
72
+ // already gone with its file
73
+ }
74
+ opened.delete(path)
75
+ }
68
76
  let db = openDaemonDb(path)
69
77
  if (db == null) {
70
78
  const { foldRefusal } = require('../core/machine-db.ts') as typeof import('../core/machine-db.ts')
@@ -80,7 +88,9 @@ export function cardsDb(): Database {
80
88
  throw new Error(`the daemon's database ${path} does not open: the review cards live there while the switch cards-in-db is on`)
81
89
  }
82
90
  }
83
- opened.set(path, db)
91
+ opened.set(path, { db, ino: lstatSync(path, { throwIfNoEntry: false })?.ino ?? 0 })
92
+ // no file before this open: the file it made is the one these connections found, never a walk
93
+ if (ino === 0) walked = lstatSync(oldStorePath('daemon file'), { throwIfNoEntry: false })?.ino ?? 0
84
94
  return db
85
95
  }
86
96
 
@@ -117,14 +127,14 @@ export function walkedUnder(e: unknown): unknown {
117
127
  forgetStoreHomes()
118
128
  walked = null
119
129
  if (why != null) return cardsRefused(why)
120
- const ended = waitRefused(`a ${isTombstone(old) ? 'fold' : 'way back'} of the daemon file moved the cards as this ran: run it again`)
130
+ const ended = waitRefused(`a ${isTombstone(old) ? 'fold' : 'way back'} of the daemon file moved the threads as this ran: run it again`)
121
131
  ended.message = `the review cards do not read now: ${ended.message}`
122
132
  return ended
123
133
  }
124
134
 
125
135
  /** closes this process's connections to the copy (a fold of this process, a test that moves it) */
126
136
  export function closeCardsDb(): void {
127
- for (const db of opened.values()) {
137
+ for (const { db } of opened.values()) {
128
138
  try {
129
139
  db.close()
130
140
  } catch {
@@ -50,7 +50,7 @@ export interface CardBackend {
50
50
  }
51
51
 
52
52
  /** a write's error that names its card, as the files' backend says it */
53
- const noCard = (id: string): Error => Object.assign(new Error(`no card ${id}`), { code: 'ENOENT' })
53
+ const noCard = (id: string): Error => Object.assign(new Error(`no item ${id}`), { code: 'ENOENT' })
54
54
 
55
55
  /** the rows of one store folder's repo */
56
56
  export function rowsIO(dir: string): CardBackend {
@@ -89,7 +89,7 @@ export function rowsIO(dir: string): CardBackend {
89
89
  if (readdirSync(tmp).length > 0) moveFolder(tmp, join(spoolOf(dir), id))
90
90
  else rmSync(tmp, { recursive: true, force: true })
91
91
  tx(() => {
92
- if (has(id)) throw new Error(`${id}: another card took this id meanwhile, add it again`)
92
+ if (has(id)) throw new Error(`${id}: another item took this id meanwhile, add it again`)
93
93
  write(id, head, Date.now())
94
94
  })
95
95
  },
@@ -173,8 +173,9 @@ const readOf = (head: string, msgs: readonly { id: string; body: string }[]): Re
173
173
  * written since. A count that disagrees with what is held reads every card again: a card never stays shown after
174
174
  * it went, nor missing after it came */
175
175
  function rowsAllHere(dir: string): ReadAll {
176
- const db = cardsDb()
176
+ // the repo first: its own ask for the connection may open it again after a walk, never under the one held here
177
177
  const repo = repoIdOf(dir)
178
+ const db = cardsDb()
178
179
  let byRepo = helds.get(db)
179
180
  if (byRepo == null) helds.set(db, (byRepo = new Map()))
180
181
  // the numbers before the rows: a write between the two is read again next time, never lost