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
@@ -16,15 +16,13 @@ import { FLOOR_IDS } from './core/floor.ts'
16
16
  export { resolveFloor, type FloorResolution, type FloorSource } from './core/floor.ts'
17
17
  import type { ContractManifest } from './contracts/contract-types.ts'
18
18
  import { validateSmokeConfig, type SmokeConfig } from './smoke/run-smoke.ts'
19
- import { RULE_ID_RE, validateRules } from './rules/rule.ts'
20
19
  import { builtinCheckIds } from './gate/discover-checks.ts'
21
20
  import { RETIRED_CHECK_IDS } from './core/retired-checks.ts'
22
- import { parseWhen } from './core/when.ts'
23
21
  import { normalizeVendored, vendoredOfText, vendoredProblem } from './core/vendored.ts'
24
22
  import { foreignOfText } from './core/foreign.ts'
25
23
  import { budgetValueProblem } from './core/budget.ts'
24
+ import { heavyProblem } from './core/admission.ts'
26
25
  import { browsersProblem } from './core/slots.ts'
27
- import type { Rule } from './check.ts'
28
26
  import { leakAllowProblems } from './hooks/leak-guard.ts'
29
27
  import type { HooksConfig } from './hooks/run-hooks.ts'
30
28
  import type { ReleaseConfig } from './release/run-release.ts'
@@ -103,7 +101,7 @@ export type ServeConfig = {
103
101
  * for a site's last production deployment with it */
104
102
  cloudflareToken?: string
105
103
  /** only in the house config: the advisors page's address, `advisors.<domain>` under a zone of the Cloudflare account;
106
- * `sk advisors expose --host <it>`, in his terminal, sets it up once (wiki tools/shipkit/advisors.md, The advisors page and its server) */
104
+ * `sk advisors expose --host <it>`, in his terminal, sets it up once (wiki tools/shipkit/advisors.md, Who calls) */
107
105
  advisorsHost?: string
108
106
  /** only in the house config: the hub theme every shot of the machine draws a page in (`sk shot`, `shotUrl`, the
109
107
  * browser checks), unless it asks its own (`--theme`); absent, each browser's own scheme */
@@ -154,12 +152,8 @@ export type RepoConfig = {
154
152
  * declares what its own `test` script reads (`{ test: { inputs:
155
153
  * ['tests', 'src'] } }`) without restating the command: the read set is
156
154
  * repo knowledge, the command is already in package.json, and restating
157
- * it is a second source of truth. A slot set to `false` is RETIRED, read
158
- * as `off` while SK029 ports it there: a slot turns off like any check */
159
- defaults?: Record<string, Partial<TaskDef> | false>
160
- /** DEPRECATED, read through 0.40 and rewritten by `shipkit check --fix
161
- * SK016`: a build step is a `<name>.check.ts` file with `build: true` */
162
- tasks?: TaskDef[]
155
+ * it is a second source of truth. A slot turns off like any check, in `off` */
156
+ defaults?: Record<string, Partial<TaskDef>>
163
157
  /** the human action queue, each ask a thread of the repo's store: the line the all-clear prints (`shipkit asks`) */
164
158
  asks?: {
165
159
  /** the `shipkit asks` all-clear line, in the repo's own voice */
@@ -266,15 +260,10 @@ export type RepoConfig = {
266
260
  /** THE CHECKS THIS REPO TURNS OFF, check id → why, for a whole check it
267
261
  * does not own (one false finding is waived at its site instead): where
268
262
  * a check runs is its own declaration (tools/shipkit/runs.md), and an
269
- * off check runs in no context. `defineRepo` throws on a blank reason and on a rule id no
270
- * check carries. The hub writes this map through the managed block in
263
+ * off check runs in no context. `defineRepo` throws on a blank reason and on a built-in id no
264
+ * built-in carries. The hub writes this map through the managed block in
271
265
  * this file (core/when-block.ts). */
272
266
  off?: Record<string, string>
273
- /** RETIRED, read only while SK029 ports it into `off`: an `'off:<why>'`
274
- * value reads as `off`, and any other word is refused, because a repo
275
- * no longer places a check. Dies once `shipkit fleet` shows no repo
276
- * carrying it */
277
- when?: Record<string, string>
278
267
  /** WHAT A HEALTHY RUN OF EACH CHECK TAKES, in ms, keyed by check id. A
279
268
  * check that passes over its budget prints a WARN and reads yellow, and
280
269
  * never blocks. It wins over the check's own `budgetMs` and the default
@@ -287,11 +276,6 @@ export type RepoConfig = {
287
276
  * a save fails the gate unless it is named here; SK046 then warns on the
288
277
  * runs the harness recorded. `defineRepo` throws on a blank reason */
289
278
  instantHooks?: Record<string, string>
290
- /** RETIRED, read as `off` while SK029 ports it there: rule id → the reason
291
- * this repo breaks that invariant on purpose. An exempted rule does not
292
- * lint and prints a skip line carrying the reason. `defineRepo` throws on
293
- * an unknown id or a blank reason */
294
- ruleExempt?: Record<string, string>
295
279
  /** the repo is done for now: nothing processes it. The house discovery
296
280
  * leaves it out, so it has no tile on the project bar, no hub (no file watch, no plan
297
281
  * rows, no automatic gates), no processes or widgets, no identity fill,
@@ -362,10 +346,6 @@ export type RepoConfig = {
362
346
  * route and the shell deny both drop for each one named */
363
347
  exempt?: string[]
364
348
  }
365
- /** DEPRECATED, read through 0.40: a repo invariant is a `<name>.check.ts`
366
- * file whose `run` is the old `lint`. SK016 names each entry, and moving
367
- * one is a hand pass because it holds a function */
368
- rules?: Rule[]
369
349
  /** `shipkit release`, branch, tag shape, changelog, npm + GitHub release.
370
350
  * Absent is fine: the defaults (main, `v{version}`, CHANGELOG.md, npm only
371
351
  * when public, GitHub release on) fit most repos. release/run-release.ts */
@@ -403,14 +383,6 @@ export type RepoConfig = {
403
383
  * repo's own commands. `shipkit hooks list` enumerates them, so what blocks
404
384
  * a commit is answerable without reading shell. hooks/run-hooks.ts */
405
385
  hooks?: HooksConfig
406
- /** DEPRECATED, read through 0.40: what a legacy `*.check.ts` with no
407
- * `export const blocking` means. `shipkit check --fix SK016` names the
408
- * value in each script's port, where `blocking` is required, and drops
409
- * the key once no script leans on it */
410
- checkDefaults?: {
411
- /** what a `*.check.ts` with no `export const blocking` means here */
412
- blocking?: boolean
413
- }
414
386
  /** `shipkit smoke`: the deployed url, the routes a read only browser pass
415
387
  * visits after a deploy, and how it logs in. The password is a secret
416
388
  * NAME: the value never sits in config, argv or env. smoke/run-smoke.ts */
@@ -445,6 +417,10 @@ export type RepoConfig = {
445
417
  * slow suites the quick tier leaves out, and the suites that cannot run in
446
418
  * parallel, each with its reason. suite/judge-suites.ts */
447
419
  tests?: TestsConfig
420
+ /** sk command lines that wait while the machine is full, like ['trailer', 'assets gen']: each matches the argv it
421
+ * starts, and waits with a line every 10 s that names who uses the CPU, until its bound, then runs with a WARN.
422
+ * The gate's heavy checks, a clip, a loop of shots and sk smoke wait without being listed. core/admission.ts */
423
+ heavy?: string[]
448
424
  /** the live dashboard, `shipkit tui`. */
449
425
  tui?: {
450
426
  /** extra dashboard panels, appended after the built-in build steps and checks panels (`shipkit tui`) */
@@ -480,7 +456,22 @@ export type RepoConfig = {
480
456
  logDir?: string
481
457
  }
482
458
 
483
- 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', 'privateApps', 'ownerRepo', 'archived', 'foreign', 'onSave', 'history', 'reviewer', 'oneWayIn', 'rules', 'release', 'units', 'notReleasable', 'vendored', 'hooks', 'checkDefaults', 'tui', 'serve', 'recorder', 'identity', 'guiColor', 'appIcon', 'logDir', 'smoke', 'tests', 'browsers', 'start'])
459
+ const KNOWN_KEYS = new Set(['name', 'id', 'venues', 'social', 'speaksAs', 'backup', 'annex','docsBase', 'defaults', 'asks', 'creds', 'credsCommand', 'credsReadCommand', 'retired', 'notifyCommand', 'contracts', 'gitignore', 'ignoredInputs', 'untrackGenerated', 'nested', 'off', 'budgets', 'instantHooks', 'visibility', 'privateApps', 'ownerRepo', 'archived', 'foreign', 'onSave', 'history', 'reviewer', 'oneWayIn', 'release', 'units', 'notReleasable', 'vendored', 'hooks', 'tui', 'serve', 'recorder', 'identity', 'guiColor', 'appIcon', 'logDir', 'smoke', 'tests', 'browsers', 'heavy', 'start'])
460
+
461
+ /** a key that is gone, and what to write instead */
462
+ const REMOVED_KEYS: Record<string, string> = {
463
+ checks: "checks:[] was removed; drop a <name>.check.shipkit.ts file instead ('shipkit check' auto-discovers it)",
464
+ home: 'home.resources was removed; declare each one in a <name>.shipkit.ts file as `export default globalProcess({...})`',
465
+ prose: 'prose was removed with rule SK014: delete the key',
466
+ when: "when was removed: every check declares where it runs (tools/shipkit/runs.md), and a repo turns one off with off: { <id>: '<why>' }",
467
+ ruleExempt: "ruleExempt was removed: a repo turns a check off with off: { <id>: '<why>' }",
468
+ checkDefaults: 'checkDefaults was removed with the check script: every check file declares its own `blocking`; delete the key',
469
+ rules: 'rules:[] was removed: each rule is a <name>.check.shipkit.ts file whose `run` is the old `lint` (tools/shipkit/writing-a-check.md)',
470
+ tasks: 'tasks:[] was removed: each task is a <name>.check.shipkit.ts file with `build: true` and its `cmd` (tools/shipkit/writing-a-check.md)',
471
+ }
472
+
473
+ /** an empty `tasks: []` still loads: every scaffold wrote one, it means nothing, and SK055's repair drops the line */
474
+ const emptyTasks = (c: object, k: string): boolean => k === 'tasks' && Array.isArray((c as { tasks?: unknown }).tasks) && (c as { tasks: unknown[] }).tasks.length === 0
484
475
 
485
476
  export function defineRepo(c: RepoConfig): RepoConfig {
486
477
  if (typeof c.name !== 'string' || c.name === '') throw new Error('defineRepo: name is required')
@@ -502,6 +493,8 @@ export function defineRepo(c: RepoConfig): RepoConfig {
502
493
  const names = (v: unknown): boolean => v == null || (Array.isArray(v) && v.every((x) => typeof x === 'string' && x !== ''))
503
494
  if (c.history != null && (typeof c.history !== 'object' || !names(c.history.skip) || !names(c.history.also)))
504
495
  throw new Error('defineRepo: history is { skip: [folder names], also: [folders] }')
496
+ if (c.hooks != null && 'disable' in c.hooks)
497
+ throw new Error(`defineRepo: hooks.disable was removed: a commit gate turns off like any check, off: { <gate id>: '<why>' }`)
505
498
  if (c.serve != null && 'processes' in c.serve)
506
499
  throw new Error(`defineRepo: serve.processes was removed; declare each process in a <name>.shipkit.ts file as \`export default globalProcess({...})\``)
507
500
  if (c.ignoredInputs != null && (typeof c.ignoredInputs !== 'object' || Array.isArray(c.ignoredInputs)))
@@ -515,8 +508,8 @@ export function defineRepo(c: RepoConfig): RepoConfig {
515
508
  // unknown keys die loud — a typo'd or removed key silently changing the
516
509
  // gate is exactly the never-silence failure mode (A23)
517
510
  for (const k of Object.keys(c))
518
- if (!KNOWN_KEYS.has(k))
519
- throw new Error(`defineRepo: unknown key '${k}'${k === 'checks' ? ` — checks:[] was removed; drop a <name>.check.ts file instead ('shipkit check' auto-discovers it)` : k === 'home' ? ` — home.resources was removed; declare each one in a <name>.shipkit.ts file as \`export default globalProcess({...})\`` : k === 'prose' ? ` — prose was removed with rule SK014: delete the key` : ''}`)
511
+ if (!KNOWN_KEYS.has(k) && !emptyTasks(c, k))
512
+ throw new Error(`defineRepo: unknown key '${k}'${REMOVED_KEYS[k] != null ? `: ${REMOVED_KEYS[k]}` : ''}`)
520
513
  if (c.release?.publisher != null && !(PUBLISHERS as readonly string[]).includes(c.release.publisher))
521
514
  throw new Error(`defineRepo: release.publisher '${String(c.release.publisher)}' is not a publisher (${PUBLISHERS.join(', ')})`)
522
515
  // a typo'd unit key would silently drop a target and release the wrong shape
@@ -553,17 +546,12 @@ export function defineRepo(c: RepoConfig): RepoConfig {
553
546
  // is not a type error at any call site and lands as a task that is
554
547
  // simply never cached, silently, which is the one direction this file
555
548
  // promises a typo cannot go.
556
- if (slot === false || slot == null) continue
549
+ if ((slot as unknown) === false) throw new Error(`defineRepo: defaults.${k} false was removed: a slot turns off like any check, off: { '${k}': '<why>' }`)
550
+ if (slot == null) continue
557
551
  for (const f of Object.keys(slot))
558
552
  if (!(TASK_DEF_KEYS as readonly string[]).includes(f))
559
553
  throw new Error(`defineRepo: defaults.${k}.${f} is not a task field (fields: ${TASK_DEF_KEYS.join(', ')})`)
560
554
  }
561
- // same promise for a repo task: repo.config.ts is often outside every
562
- // tsconfig, so `reads` for `inputs` is no type error and the task never caches
563
- for (const t of c.tasks ?? [])
564
- for (const f of Object.keys(t))
565
- if (!(TASK_DEF_KEYS as readonly string[]).includes(f))
566
- throw new Error(`defineRepo: tasks['${t.id}'].${f} is not a task field (fields: ${TASK_DEF_KEYS.join(', ')})`)
567
555
  // a slow or serial suite carries its case, or the declaration does not load
568
556
  if (c.tests != null) {
569
557
  const problems = testsConfigProblems(c.tests)
@@ -572,49 +560,33 @@ export function defineRepo(c: RepoConfig): RepoConfig {
572
560
  for (const n of c.oneWayIn?.exempt ?? [])
573
561
  if (!(ROUTED_SCRIPTS as readonly string[]).includes(n))
574
562
  throw new Error(`defineRepo: oneWayIn.exempt '${n}' is not a governed script name (governed: ${ROUTED_SCRIPTS.join(', ')})`)
575
- // repo rules are validated against the built-ins, so a bad id, a duplicate,
576
- // or an SK squatter dies at config load, not silently mid-check
577
- if (c.rules != null) validateRules(c.rules, { label: 'defineRepo: rules', taken: builtinCheckIds() })
578
563
  // `off` silences a check, so it names one that exists and says why. The
579
- // RULE namespace is the one this file can check: a task is resolved from
564
+ // built-in namespace is the one this file can check: a task is resolved from
580
565
  // the floor and a check is discovered on disk, so those two are caught by
581
566
  // the gate against the real inventory (core/when.ts unknownOffIds)
582
567
  for (const [id, reason] of Object.entries(c.off ?? {})) {
583
568
  if (id.trim() === '') throw new Error(`defineRepo: off has an entry with no check id`)
584
569
  if (typeof reason !== 'string' || reason.trim() === '') throw new Error(`defineRepo: off.${id} needs a reason: a check nobody can explain is a silenced gate`)
585
570
  if (RETIRED_CHECK_IDS[id] != null) throw new Error(`defineRepo: off.${id} names a retired rule (${RETIRED_CHECK_IDS[id]}): delete the entry`)
586
- if (RULE_ID_RE.test(id) && !builtinCheckIds().includes(id) && !(c.rules ?? []).some((r) => r.id === id))
571
+ if (/^SK\d{3}$/.test(id) && !builtinCheckIds().includes(id))
587
572
  throw new Error(`defineRepo: off.${id} names no rule, the ids are in \`shipkit checks\``)
588
573
  }
589
574
  for (const [command, reason] of Object.entries(c.instantHooks ?? {})) {
590
575
  if (command.trim() === '') throw new Error(`defineRepo: instantHooks has an entry with no command`)
591
576
  if (typeof reason !== 'string' || reason.trim() === '') throw new Error(`defineRepo: instantHooks entry \`${command}\` needs a reason: why it answers at once`)
592
577
  }
593
- // the retired `when`: only its `off:<why>` word still means something
594
- for (const [id, raw] of Object.entries(c.when ?? {})) {
595
- const w = parseWhen(raw)
596
- if (typeof w === 'string') throw new Error(`defineRepo: when.${id} ${w}`)
597
- if (w.at !== 'off')
598
- throw new Error(`defineRepo: when.${id} '${raw}' no longer places a check: every check declares where it runs (tools/shipkit/runs.md). A repo can only turn one off: off: { ${id}: '<why>' }`)
599
- }
600
578
  // a budget turns a slow pass yellow, so a value it cannot compare with dies here
601
579
  for (const [id, v] of Object.entries(c.budgets ?? {})) {
602
580
  if (id.trim() === '') throw new Error(`defineRepo: budgets has an entry with no check id`)
603
581
  const bad = budgetValueProblem(v)
604
582
  if (bad != null) throw new Error(`defineRepo: budgets.${id} ${bad}`)
605
583
  }
606
- // an exemption silences a gate, so it names a rule that exists and says why
607
- for (const [id, reason] of Object.entries(c.ruleExempt ?? {})) {
608
- if (RETIRED_CHECK_IDS[id] != null) throw new Error(`defineRepo: ruleExempt.${id} names a retired rule (${RETIRED_CHECK_IDS[id]}): delete the entry`)
609
- if (!builtinCheckIds().includes(id) && !(c.rules ?? []).some((r) => r.id === id))
610
- throw new Error(`defineRepo: ruleExempt.${id} names no rule, the ids are in \`shipkit checks\``)
611
- if (typeof reason !== 'string' || reason.trim() === '')
612
- throw new Error(`defineRepo: ruleExempt.${id} needs a reason, an exemption nobody can explain is a silenced gate`)
613
- }
614
584
  // a smoke typo would land as a run that visits nothing and exits 0
615
585
  if (c.smoke != null) validateSmokeConfig(c.smoke)
616
586
  const browsers = browsersProblem(c.browsers)
617
587
  if (browsers != null) throw new Error(`defineRepo: ${browsers}`)
588
+ const heavy = heavyProblem(c.heavy)
589
+ if (heavy != null) throw new Error(`defineRepo: ${heavy}`)
618
590
  // a malformed skip list would let sk start wire the checkout it exists to leave alone
619
591
  if (c.start !== undefined) {
620
592
  const skip = (c.start as { skip?: unknown }).skip
@@ -1,7 +1,7 @@
1
1
  // what each answer kind of a question waits for and what his answer says (wiki tools/shipkit/threads-asks.md, Answer
2
2
  // kinds): one reading for the store, the turn, the watch and the hub; pure and browser safe
3
3
  import { choiceName } from './instructions.ts'
4
- import { partyOf, wordsAnswerOf, type AnswerKind, type Message } from './model.ts'
4
+ import { partyOf, type AnswerKind, type Message } from './model.ts'
5
5
 
6
6
  export const kindOfAsk = (m: Message): AnswerKind => m.ask?.kind ?? 'choice'
7
7
 
@@ -15,6 +15,48 @@ export const pickedName = (m: Message, option: number, pick: number | undefined)
15
15
  }
16
16
 
17
17
 
18
+ /** the rows of the question with a row per thing that `m` is one row of, in row order; empty for any other question */
19
+ export const rowsOf = (thread: readonly Message[], m: Message): Message[] => {
20
+ const g = m.ask?.row?.group
21
+ return g === undefined ? [] : thread.filter((y) => y.ask?.row?.group === g).sort((a, b) => a.ask!.row!.i - b.ask!.row!.i)
22
+ }
23
+
24
+ /** the owner's words with a pick (« pick with a remark »): the answer's text past the option's label, which the store writes
25
+ * `<label>: <words>` (store.ts answerAsk); '' for a plain pick */
26
+ export const remarkOf = (label: string, text: string | undefined): string => {
27
+ const t = (text ?? '').trim()
28
+ return t === label ? '' : t.startsWith(`${label}:`) ? t.slice(label.length + 1).trim() : t
29
+ }
30
+
31
+ /** a pick as one line: « B », or « B with a remark: « rounder » » */
32
+ export const pickWords = (name: string, remark: string): string => (remark === '' ? name : `${name} with a remark: « ${remark} »`)
33
+
34
+ export type RowPick = { label: string; pick: number | null; name: string | null; words: string | null; remark: string }
35
+
36
+ /** each row's thing and the last answer on it: the option picked, or words alone (« none of these: … »), both
37
+ * null while he answered nothing; up to `upTo` when given */
38
+ export function rowPicks(thread: readonly Message[], m: Message, upTo?: string): RowPick[] {
39
+ return rowsOf(thread, m).map((r) => {
40
+ const last = [...answersTo(thread, r, upTo)].reverse().find((y) => y.answer?.option !== undefined || wordsAlone(y))
41
+ const pick = last?.answer?.option ?? null
42
+ const words = last !== undefined && wordsAlone(last) ? (last.text ?? '') : null
43
+ const name = pick === null ? null : (r.ask!.options[pick] ?? `option ${pick + 1}`)
44
+ return { label: r.ask!.row!.label, pick, name, words, remark: name === null ? '' : remarkOf(name, last?.text) }
45
+ })
46
+ }
47
+
48
+ export const rowAnswered = (p: RowPick): boolean => p.pick !== null || p.words !== null
49
+
50
+ /** the rows as one line: « Arrivée B · Adieu none of these: « rounder » · Deuil (none yet) » */
51
+ export const rowPicksText = (picks: readonly RowPick[]): string => picks.map((p) => `${p.label} ${p.name !== null ? pickWords(p.name, p.remark) : p.words !== null ? `none of these: « ${p.words} »` : '(none yet)'}`).join(' · ')
52
+
53
+ /** where the rows stand after his answer, for the agent's line: « ; 1 of 3 rows answered », or every row once all are */
54
+ export function rowsStandText(thread: readonly Message[], m: Message, upTo: string, flat: (s: string) => string): string {
55
+ const picks = rowPicks(thread, m, upTo)
56
+ const done = picks.filter(rowAnswered).length
57
+ return done === picks.length ? `; all ${picks.length} rows answered: ${flat(rowPicksText(picks))}` : `; ${done} of ${picks.length} rows answered`
58
+ }
59
+
18
60
  /** a checklist's or a confirm's tick lines: a confirm has one, its question */
19
61
  export const ticks = (k: AnswerKind): boolean => k === 'checklist' || k === 'confirm'
20
62
 
@@ -40,11 +82,9 @@ export const reopenedAt = (thread: readonly Message[]): number | null => {
40
82
  export const answersTo = (thread: readonly Message[], m: Message, upTo?: string): Message[] => {
41
83
  const end = upTo === undefined ? thread.length : thread.findIndex((y) => y.id === upTo) + 1
42
84
  const of = m.step?.carries
43
- // his plain words after it answer it too, as words alone (model.ts wordsAnswerOf)
44
- const words = wordsAnswerOf(thread, m)
45
85
  const reopened = m.ask?.kind === 'secret' ? reopenedAt(thread) : null
46
86
  const stale = (y: Message): boolean => reopened !== null && y.answer?.stored !== undefined && Date.parse(y.carried?.at ?? y.at) < reopened
47
- return thread.slice(0, end > 0 ? end : thread.length).filter((y) => y === words || ((y.re === m.id || (of !== undefined && y.re === of)) && partyOf(y.who) === 'owner' && !stale(y)))
87
+ return thread.slice(0, end > 0 ? end : thread.length).filter((y) => (y.re === m.id || (of !== undefined && y.re === of)) && partyOf(y.who) === 'owner' && !stale(y))
48
88
  }
49
89
 
50
90
  /** each line's tick as he left it last, the lines done before he looked first; up to `upTo` when given */
@@ -76,6 +116,23 @@ export function tickCount(thread: readonly Message[], m: Message, upTo?: string)
76
116
  /** 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 */
77
117
  export const wordsAlone = (y: Message): boolean => y.answer === undefined
78
118
 
119
+ /** the question whose control shows the owner's words `m` as his answer in words (a choice's « none of these » while no
120
+ * option of his is picked on it, another kind's words alone as its last answer; a checklist's words only ride on it):
121
+ * his answer draws there once, so `m` reads as one trace line, never a second bubble; undefined otherwise */
122
+ export function noneAnswered(thread: readonly Message[], m: Message): Message | undefined {
123
+ if (m.answer !== undefined || m.op !== undefined || !m.text?.trim() || partyOf(m.who) !== 'owner') return undefined
124
+ return thread.find((q) => {
125
+ // a verdict is words on a question only as his tone on it (store.ts answerAsk `tone`), which names it
126
+ if (m.verdict !== undefined && m.re !== q.id) return false
127
+ // a question the ask bar answers draws nowhere (cells.ts): the owner's words there stay a reply
128
+ if (q.ask === undefined || q.step !== undefined || thread.some((y) => y.askBar?.includes(q.id) === true)) return false
129
+ const k = kindOfAsk(q)
130
+ if (k === 'checklist') return false
131
+ if (k !== 'choice') return answersTo(thread, q).at(-1) === m
132
+ return !thread.some((y) => y.re === q.id && y.answer !== undefined && partyOf(y.who) === 'owner') && answersTo(thread, q).find(wordsAlone) === m
133
+ })
134
+ }
135
+
79
136
  /** whether the question waits on him: a checklist until every line is ticked; any other kind until he answers it, his
80
137
  * words alone answering it as none */
81
138
  export function askOpen(thread: readonly Message[], m: Message): boolean {
@@ -137,6 +194,8 @@ export function kindCellAsk(thread: readonly Message[], m: Message) {
137
194
  ...(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 } : {}) } } : {}),
138
195
  ...(m.ask?.secret ? { secret: { name: m.ask.secret.name, ...(m.ask.secret.login ? { login: true } : {}), ...(stored ? { stored: stored.at } : {}) } } : {}),
139
196
  ...(none !== undefined ? { none } : {}),
197
+ // his your call or no answer from the question's row (store.ts answerAsk `tone`)
198
+ ...(none !== undefined && last?.verdict !== undefined ? { tone: last.verdict } : {}),
140
199
  }
141
200
  }
142
201
 
@@ -0,0 +1,11 @@
1
+ // the store's guard on a blocked card (review/blocked-object.ts), a leaf the store imports: an agent's own post,
2
+ // question, proposal, update or link on a `blocked:` thread is refused, since the card is answered by the owner's
3
+ // click alone and its write is his act
4
+
5
+ /** what an agent says to him in place of the command or the rule */
6
+ export const AGENT_LINE = 'blocked: the card in threads'
7
+
8
+ export function refuseBlockedByAgent(on: string | undefined, verb: string): void {
9
+ if (on === undefined || !on.startsWith('blocked:')) return
10
+ throw new Error(`${on}: a blocked card is the owner's to answer in the hub (allow, edit, refuse): an agent may not ${verb} on it; say « ${AGENT_LINE} » and wait for his answer (a session on its watch, a lane by ending its turn on that line)`)
11
+ }
@@ -0,0 +1,298 @@
1
+ // a command the auto mode classifier refused, as a card the owner allows in one click (wiki tools/shipkit/thread-kinds.md,
2
+ // `blocked:`): its record in `.shipkit/blocked/<hash>.json` (git ignores `.shipkit/*`) is its truth, the card reads it
3
+ // live, its thread `blocked:<repo>/<hash>` holds the conversation and is held by the session that was refused.
4
+ // The one constraint a reader breaks first: the settings write is the owner's act alone. It runs from the hub's
5
+ // action route (an owner word route, http/owner-word.ts), never from a verb an agent types, and the store refuses an
6
+ // agent's post, question, proposal, update or link on a `blocked:` thread (refuseBlockedByAgent)
7
+ import { createHash } from 'crypto'
8
+ import { existsSync, mkdirSync, readdirSync, readFileSync, statSync } from 'fs'
9
+ import { join } from 'path'
10
+ import { atomicWrite, atomicWriteJson } from '../core/atomic-write.ts'
11
+ import { riskOf } from '../core/agent-allow-policy.ts'
12
+ import { foreignOfText } from '../core/foreign.ts'
13
+ import { agentAllowRowsOf } from '../core/allow-rows.ts'
14
+ import { canonicalAddress, type Message } from './model.ts'
15
+ import { appendMessage, openThread, postAction, readAll, readItem, specOf, storeDir } from './store.ts'
16
+ import { threadOfAddress } from './threads.ts'
17
+
18
+ export const BLOCKED = 'blocked'
19
+ export const BLOCKED_DIR = '.shipkit/blocked'
20
+
21
+ /** what the agent that was refused hears once the owner answered (its watch prints the owner's act) */
22
+ export const ALLOWED_WORDS = (rules: readonly string[]): string => `allowed: ${rules.join(', ')}; run it once`
23
+ export const REFUSED_WORDS = 'refused by the owner: do not ask again'
24
+ export { AGENT_LINE } from './blocked-guard.ts'
25
+
26
+ /** one refusal of the command, as the transcript says it */
27
+ export interface Refused {
28
+ /** the tool call's id: the same refusal read twice counts once */
29
+ call: string
30
+ at: number
31
+ session: string
32
+ lane: string | null
33
+ /** the session as `sk session` names it */
34
+ label: string
35
+ /** the classifier's reason line (`[Destructive or Unwanted Actions]`) */
36
+ reason: string
37
+ }
38
+
39
+ export type BlockedState = 'open' | 'allowed' | 'refused'
40
+
41
+ export interface BlockedRecord {
42
+ address: string
43
+ command: string
44
+ /** the index keeps a long command's head and tail alone: no exact rule can be read from it */
45
+ clipped: boolean
46
+ refusals: Refused[]
47
+ state: BlockedState
48
+ /** the item that heads its thread */
49
+ thread: string | null
50
+ decided?: { name: string; rules: string[]; file: string | null; at: string }
51
+ }
52
+
53
+ export const commandHash = (command: string): string => createHash('sha256').update(command.trim()).digest('hex').slice(0, 10)
54
+
55
+ export const blockedAddress = (repo: string, hash: string): string => canonicalAddress(`${BLOCKED}:${repo}/${hash}`) ?? `${BLOCKED}:${repo}/${hash}`
56
+
57
+ export function blockedOfAddress(address: string): { repo: string; hash: string } | null {
58
+ const m = /^blocked:([^/]+)\/([0-9a-f]{10})$/.exec(address.trim())
59
+ return m === null ? null : { repo: m[1]!, hash: m[2]! }
60
+ }
61
+
62
+ const recordPath = (root: string, hash: string): string => join(root, BLOCKED_DIR, `${hash}.json`)
63
+
64
+ export function readBlockedRecord(root: string, hash: string): BlockedRecord | null {
65
+ try {
66
+ const r = JSON.parse(readFileSync(recordPath(root, hash), 'utf8')) as BlockedRecord
67
+ return typeof r.command === 'string' && Array.isArray(r.refusals) ? r : null
68
+ } catch {
69
+ return null
70
+ }
71
+ }
72
+
73
+ const writeRecord = (root: string, hash: string, r: BlockedRecord): void => {
74
+ mkdirSync(join(root, BLOCKED_DIR), { recursive: true })
75
+ atomicWriteJson(recordPath(root, hash), r, { indent: 2 })
76
+ }
77
+
78
+ /** the parts Claude Code judges one by one (`a && b`, `a; b`, `a | b`), quotes kept whole; a command with a newline, a
79
+ * heredoc or a substitution stays one part, since no split of it is sure */
80
+ export function partsOf(command: string): string[] {
81
+ const c = command.trim()
82
+ if (/[\n`]|<<|\$\(/.test(c)) return [c]
83
+ const out: string[] = []
84
+ let cur = ''
85
+ let q: string | null = null
86
+ for (let i = 0; i < c.length; i++) {
87
+ const ch = c[i]!
88
+ if (q !== null) {
89
+ cur += ch
90
+ if (ch === q) q = null
91
+ continue
92
+ }
93
+ if (ch === '"' || ch === "'") {
94
+ q = ch
95
+ cur += ch
96
+ continue
97
+ }
98
+ const two = c.slice(i, i + 2)
99
+ if (two === '&&' || two === '||') {
100
+ out.push(cur)
101
+ cur = ''
102
+ i++
103
+ continue
104
+ }
105
+ if (ch === ';' || (ch === '|' && c[i - 1] !== '>')) {
106
+ out.push(cur)
107
+ cur = ''
108
+ continue
109
+ }
110
+ cur += ch
111
+ }
112
+ out.push(cur)
113
+ const parts = out.map((p) => p.trim()).filter((p) => p !== '')
114
+ return q !== null || parts.length === 0 ? [c] : parts
115
+ }
116
+
117
+ /** the narrowest rules that let this exact command through: one exact `Bash(<part>)` a part, never a wildcard */
118
+ export const rulesOf = (command: string): string[] => [...new Set(partsOf(command).map((p) => `Bash(${p})`))]
119
+
120
+ /** the command of an exact Bash rule, null for another shape */
121
+ const commandOfRule = (rule: string): string | null => /^Bash\((.+)\)$/s.exec(rule.trim())?.[1] ?? null
122
+
123
+ /** why a rule lets through more than a read (riskOf): each rule with its reason, the safe ones left out */
124
+ export const risksOf = (rules: readonly string[]): { rule: string; why: string }[] =>
125
+ rules.flatMap((rule) => {
126
+ const c = commandOfRule(rule)
127
+ const why = c === null ? (rule.includes('*') || !rule.includes('(') ? 'a rule wider than one command' : null) : c.includes('*') ? 'a wildcard: more than this command' : riskOf(c)
128
+ return why === null ? [] : [{ rule, why }]
129
+ })
130
+
131
+ /** the card's words: what the card shows, read by the thread from the record each time */
132
+ export function blockedMd(r: BlockedRecord): string {
133
+ const last = r.refusals.at(-1)
134
+ const rules = r.decided?.rules ?? rulesOf(r.command)
135
+ const risks = risksOf(rules)
136
+ const n = r.refusals.length
137
+ const sessions = [...new Set(r.refusals.map((x) => `${x.label}${x.lane ? ` (lane ${x.lane})` : ''}`))]
138
+ const fence = r.command.includes('```') ? '````' : '```'
139
+ return [
140
+ `# Blocked: ${oneLineOf(r.command)}`,
141
+ '',
142
+ `Refused ${n === 1 ? 'once' : `${n} times`} by the auto mode classifier${last?.reason ? `: ${last.reason}` : ''}.`,
143
+ '',
144
+ `${fence}sh`,
145
+ r.command,
146
+ fence,
147
+ '',
148
+ `Session: ${sessions.join(', ') || 'unknown'}`,
149
+ '',
150
+ ...(r.clipped ? ['The index kept only the head and the tail of this long command: edit the rule before you allow it.', ''] : []),
151
+ // one line a rule, each `Rule: ` first: the edit box starts with them (KindAction fill)
152
+ ...rules.flatMap((x) => [`Rule: \`${x}\``, '']),
153
+ // a blockquote: the card draws it orange (review.css .rv-objwhole)
154
+ ...risks.flatMap((x) => [`> ⚠️ \`${x.rule}\` ${x.why}: one click still allows it.`, '']),
155
+ ...(r.state === 'allowed' ? [`Allowed in ${r.decided?.file ?? 'the settings'}.`] : r.state === 'refused' ? ['Refused: the agent does not ask again.'] : []),
156
+ ].join('\n').trim()
157
+ }
158
+
159
+ const oneLineOf = (command: string): string => {
160
+ const l = command.trim().split('\n')[0] ?? ''
161
+ return l.length > 70 ? `${l.slice(0, 69)}…` : l
162
+ }
163
+
164
+ /** the card as a thread reads it (cells.ts ObjectRead): open while he has not answered */
165
+ export function readBlocked(root: string, hash: string): { title: string; md: string; standing: boolean; state: 'open' | 'folded' | 'gone' } | null {
166
+ const r = readBlockedRecord(root, hash)
167
+ if (r === null) return null
168
+ return { title: `Blocked: ${oneLineOf(r.command)}`, md: blockedMd(r), standing: r.state === 'open', state: r.state === 'open' ? 'open' : 'folded' }
169
+ }
170
+
171
+ /** the card's hold on its thread (review/holds-sync.ts): held while he has not answered it */
172
+ export function blockedHold(key: string, ctx: { root: string }): { held: boolean; words: string } {
173
+ const hash = /\/([0-9a-f]{10})$/.exec(key)?.[1]
174
+ const r = hash === undefined ? null : readBlockedRecord(ctx.root, hash)
175
+ if (r === null) return { held: false, words: `blocked:${key}: its record is gone` }
176
+ return r.state === 'open' ? { held: true, words: 'waits on your allow, your edit of the rule, or your refuse' } : { held: false, words: `answered: ${r.state}` }
177
+ }
178
+
179
+ /** a word that moves when a card's record moves, for the thread view's tag */
180
+ export function blockedTag(root: string): string {
181
+ const dir = join(root, BLOCKED_DIR)
182
+ let h = 0
183
+ try {
184
+ for (const f of readdirSync(dir).sort()) {
185
+ const w = `${f}:${statSync(join(dir, f)).mtimeMs}`
186
+ for (let i = 0; i < w.length; i++) h = (h * 31 + w.charCodeAt(i)) | 0
187
+ }
188
+ } catch {
189
+ return '0'
190
+ }
191
+ return (h >>> 0).toString(36)
192
+ }
193
+
194
+ /** a refusal onto its card: one card a command, its thread opened the first time; the same call twice counts once; a
195
+ * command refused again after his answer opens its card again (an allowed rule that does not cover it). The thread is
196
+ * held by the refused session (and its lane), so its watch hears his answer */
197
+ export async function recordRefusal(root: string, repo: string, command: string, f: Refused & { clipped?: boolean }, now = new Date()): Promise<{ address: string; opened: boolean; counted: boolean; record: BlockedRecord }> {
198
+ const hash = commandHash(command)
199
+ const address = blockedAddress(repo, hash)
200
+ const was = readBlockedRecord(root, hash)
201
+ const refused: Refused = { call: f.call, at: f.at, session: f.session, lane: f.lane, label: f.label, reason: f.reason }
202
+ if (was !== null && was.refusals.some((x) => x.call === f.call)) return { address, opened: false, counted: false, record: was }
203
+ const again = was !== null && was.state !== 'open'
204
+ const r: BlockedRecord = was === null ? { address, command: command.trim(), clipped: f.clipped === true, refusals: [refused], state: 'open', thread: null } : { ...was, refusals: [...was.refusals, refused], state: 'open' }
205
+ // his answer stays in the thread; the card asks again
206
+ if (again) delete r.decided
207
+ const dir = storeDir(root)
208
+ let opened = false
209
+ const own = threadOfAddress(address, readAll(dir).items, specOf(dir))
210
+ let head = own?.head.item.id ?? null
211
+ if (head === null) {
212
+ const item = await openThread(dir, address, { title: `Blocked: ${oneLineOf(command)}`, what: 'The auto mode classifier refused a command: its card is below. Allow it in one click, or refuse it.', machine: true, now })
213
+ head = item.id
214
+ opened = true
215
+ }
216
+ r.thread = head
217
+ writeRecord(root, hash, r)
218
+ // the link names the refused session: the newest act holds the thread, so that session hears his answer
219
+ const last = readItem(dir, head)?.thread.filter((m) => m.about?.includes(address)).at(-1)
220
+ if (opened || again || last === undefined || last.session !== f.session || (last.who !== (f.lane ?? 'agent'))) {
221
+ appendMessage(dir, head, { who: f.lane ?? 'agent', session: f.session, text: again ? `refused again after your answer: ${address}` : `attached ${address}`, about: [address] }, { now })
222
+ }
223
+ return { address, opened, counted: true, record: r }
224
+ }
225
+
226
+ /** the file the owner's rules go into: the tracked settings, or this machine's own for a foreign repo (its tracked file
227
+ * is the team's), as SK054 decides */
228
+ export function settingsFileOf(root: string): string {
229
+ let foreign = false
230
+ try {
231
+ foreign = foreignOfText(readFileSync(join(root, 'repo.config.ts'), 'utf8'))
232
+ } catch {}
233
+ return foreign ? '.claude/settings.local.json' : '.claude/settings.json'
234
+ }
235
+
236
+ /** his rules into `permissions.allow` of the repo's settings through SK054's writer: the missing ones appended in the
237
+ * file's own layout, every other byte kept; a rule already there writes nothing */
238
+ export function allowRules(root: string, rules: readonly string[]): { file: string; added: string[] } {
239
+ const file = settingsFileOf(root)
240
+ const path = join(root, file)
241
+ const text = existsSync(path) ? readFileSync(path, 'utf8') : null
242
+ const r = agentAllowRowsOf(text, rules, [])
243
+ if (r === 'broken') throw new Error(`${file} is not a JSON object with a permissions.allow list: fix it by hand first, nothing written`)
244
+ if (r.missing.length > 0) {
245
+ mkdirSync(join(root, '.claude'), { recursive: true })
246
+ atomicWrite(path, r.text)
247
+ }
248
+ return { file, added: r.missing }
249
+ }
250
+
251
+ /** a rule as he may type it: one Claude Code permission rule, `Tool` or `Tool(<what>)` */
252
+ const RULE = /^[A-Z][A-Za-z0-9_]*(?:\(.+\))?$/s
253
+
254
+ /** the owner's edited rules out of the words he sent: one a line, the card's address before them left out */
255
+ export function editedRules(text: string, address: string): string[] {
256
+ const words = text.startsWith(`${address}:`) ? text.slice(address.length + 1) : text === address ? '' : text
257
+ const rules = words.split('\n').map((l) => l.trim().replace(/^Rule:\s*/, '').replace(/^`(.*)`$/s, '$1')).filter((l) => l !== '')
258
+ if (rules.length === 0) throw new Error('allow the edited rule: type the rule, one a line, like Bash(sk bump patch)')
259
+ for (const x of rules) if (!RULE.test(x)) throw new Error(`« ${x} » is no permission rule: Bash(<the command>), one a line`)
260
+ return rules
261
+ }
262
+
263
+ export const BLOCKED_ACTIONS = ['allow', 'edit', 'refuse'] as const
264
+
265
+ /** the address a link message of the thread names, the act's `re` */
266
+ const linkedAddress = (m: Message | undefined): string | null => m?.about?.find((a) => blockedOfAddress(a) !== null) ?? null
267
+
268
+ /** the blocked card an action on this item names, null for any other item: by its link (`re`), else the item's own address */
269
+ export function blockedOfAct(dir: string, id: string, re: string | undefined): { address: string; repo: string; hash: string } | null {
270
+ const x = readItem(dir, id)
271
+ if (x === null) return null
272
+ const address = (re !== undefined ? linkedAddress(x.thread.find((m) => m.id === re)) : null) ?? (x.item.on !== undefined && blockedOfAddress(x.item.on) !== null ? x.item.on : null)
273
+ const b = address === null ? null : blockedOfAddress(address)
274
+ return b === null || address === null ? null : { address, ...b }
275
+ }
276
+
277
+ /** the owner's act on a card, from the hub's action route: allow writes the card's rules, edit his own, refuse writes
278
+ * nothing; the act lands on its link with the words the refused session's watch prints */
279
+ export function actOnBlocked(root: string, id: string, a: { name: string; text?: string; re?: string; now?: Date }): { message: Message; added: string[]; file: string | null } {
280
+ const dir = storeDir(root)
281
+ const b = blockedOfAct(dir, id, a.re)
282
+ if (b === null) throw new Error(`${id}: no blocked card on this item`)
283
+ if (!(BLOCKED_ACTIONS as readonly string[]).includes(a.name)) throw new Error(`action: ${a.name} is none of ${BLOCKED_ACTIONS.join(', ')}`)
284
+ const r = readBlockedRecord(root, b.hash)
285
+ if (r === null) throw new Error(`${b.address}: its record is gone from ${BLOCKED_DIR}/`)
286
+ if (r.state !== 'open') throw new Error(`${b.address}: answered already (${r.state})`)
287
+ const now = a.now ?? new Date()
288
+ const re = a.re ?? readItem(dir, id)?.thread.filter((m) => m.about?.includes(b.address)).at(-1)?.id
289
+ if (a.name === 'refuse') {
290
+ writeRecord(root, b.hash, { ...r, state: 'refused', decided: { name: 'refuse', rules: [], file: null, at: now.toISOString() } })
291
+ return { message: postAction(dir, id, { name: 'refuse', text: REFUSED_WORDS, ...(re ? { re } : {}), now }), added: [], file: null }
292
+ }
293
+ if (a.name === 'allow' && r.clipped) throw new Error(`${b.address}: the command was kept in part only, so no exact rule reads from it: edit the rule`)
294
+ const rules = a.name === 'edit' ? editedRules(a.text?.trim() ?? '', b.address) : rulesOf(r.command)
295
+ const w = allowRules(root, rules)
296
+ writeRecord(root, b.hash, { ...r, state: 'allowed', decided: { name: a.name, rules, file: w.file, at: now.toISOString() } })
297
+ return { message: postAction(dir, id, { name: a.name, text: ALLOWED_WORDS(rules), ...(re ? { re } : {}), now }), added: w.added, file: w.file }
298
+ }