rvlib-shipkit 2.12.0 → 2.14.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 (378) hide show
  1. package/CHANGELOG.md +75 -21
  2. package/README.md +1 -1
  3. package/package.json +4 -2
  4. package/src/agent-time/store.ts +2 -2
  5. package/src/assets/run-assets.ts +2 -2
  6. package/src/assets/server/studio-server.ts +27 -23
  7. package/src/check.ts +4 -4
  8. package/src/checks/SK001-package-json-shape.check.ts +8 -4
  9. package/src/checks/SK002-contracts-fulfillness.check.ts +2 -2
  10. package/src/checks/SK003-claude-md-shape.check.ts +20 -13
  11. package/src/checks/SK004-gitignore-policy.check.ts +45 -6
  12. package/src/checks/SK005-rvlib-versions.check.ts +2 -2
  13. package/src/checks/SK006-npm-publish-safety.check.ts +3 -3
  14. package/src/checks/SK007-github-visibility.check.ts +2 -2
  15. package/src/checks/SK008-reviewer-agent.check.ts +3 -3
  16. package/src/checks/SK010-undeclared-unit.check.ts +2 -2
  17. package/src/checks/SK011-sibling-unit-ranges.check.ts +2 -2
  18. package/src/checks/SK012-config-barrel-import.check.ts +2 -2
  19. package/src/checks/SK013-one-way-in-policy.check.ts +2 -2
  20. package/src/checks/SK015-nested-repo.check.ts +3 -3
  21. package/src/checks/SK016-legacy-check-shapes.check.ts +2 -2
  22. package/src/checks/SK017-vscode-hub-task.check.ts +2 -2
  23. package/src/checks/SK018-test-files-run.check.ts +2 -2
  24. package/src/checks/SK019-tests-run-in-units.check.ts +2 -2
  25. package/src/checks/SK020-self-spawning-check.check.ts +2 -2
  26. package/src/checks/SK022-machine-runs-the-pin.check.ts +2 -2
  27. package/src/checks/SK024-identity-colors.check.ts +1 -1
  28. package/src/checks/SK025-release-drift.check.ts +2 -2
  29. package/src/checks/SK026-asks-autoclose.check.ts +2 -2
  30. package/src/checks/SK027-agent-wiki-links.check.ts +8 -2
  31. package/src/checks/SK028-readme.check.ts +2 -2
  32. package/src/checks/SK029-explicit-check-files.check.ts +3 -3
  33. package/src/checks/SK030-cache-audit.check.ts +7 -5
  34. package/src/checks/SK031-trace-audit.check.ts +7 -7
  35. package/src/checks/SK032-ignored-inputs.check.ts +3 -3
  36. package/src/checks/SK033-global-contribution.check.ts +11 -4
  37. package/src/checks/SK034-commit-gates-armed.check.ts +2 -2
  38. package/src/checks/SK035-public-clean.check.ts +46 -0
  39. package/src/checks/SK036-draft-media-size.check.ts +28 -0
  40. package/src/checks/SK037-keyword-additions.check.ts +43 -0
  41. package/src/cli/cmd_Backup.ts +152 -0
  42. package/src/cli/cmd_Ci.ts +8 -11
  43. package/src/cli/cmd_Commands.ts +4 -4
  44. package/src/cli/cmd_ConfigKeys.ts +2 -2
  45. package/src/cli/cmd_Drill.ts +145 -0
  46. package/src/cli/cmd_Home.ts +50 -3
  47. package/src/cli/cmd_Init.ts +1 -1
  48. package/src/cli/cmd_Media.ts +10 -8
  49. package/src/cli/cmd_Mv.ts +14 -7
  50. package/src/cli/cmd_Review.ts +6 -4
  51. package/src/cli/cmd_Shot.ts +5 -2
  52. package/src/cli/cmd_Smoke.ts +5 -2
  53. package/src/cli/cmd_Social.ts +226 -0
  54. package/src/cli/cmd_Sound.ts +1 -1
  55. package/src/cli/cmd_Start.ts +1 -1
  56. package/src/cli/cmd_Time.ts +1 -1
  57. package/src/cli/cmd_TraceAudit.ts +6 -6
  58. package/src/cli/cmd_Trailer.ts +7 -4
  59. package/src/cli/cmd_Veille.ts +173 -0
  60. package/src/cli/cmd_When.ts +2 -2
  61. package/src/cli/family-pages.ts +19 -16
  62. package/src/cli/registry.ts +13 -2
  63. package/src/cli.ts +5 -2
  64. package/src/collections/actions.ts +1 -49
  65. package/src/collections/checks.ts +2 -1
  66. package/src/collections/collection-types.ts +12 -3
  67. package/src/collections/providers.ts +4 -4
  68. package/src/collections/review.ts +3 -2
  69. package/src/collections/tests.ts +19 -8
  70. package/src/comfy/comfy-panel.ts +2 -2
  71. package/src/contracts/apply-contracts.ts +1 -3
  72. package/src/contracts/contract-manifests.ts +2 -3
  73. package/src/contracts/contract-types.ts +0 -1
  74. package/src/contracts/contracts-engine.ts +0 -3
  75. package/src/contracts/manifests/discord.contract.ts +1 -1
  76. package/src/contracts/manifests/identity.contract.ts +1 -1
  77. package/src/contracts/manifests/itch.contract.ts +1 -1
  78. package/src/contracts/manifests/steam.contract.ts +1 -1
  79. package/src/core/agent-dir-at.ts +12 -0
  80. package/src/core/agent-dir.ts +16 -0
  81. package/src/core/app-icon.ts +9 -3
  82. package/src/core/budget.ts +1 -1
  83. package/src/core/bun-builtins.ts +2 -2
  84. package/src/core/canonical-scripts.ts +2 -2
  85. package/src/core/discover-checks.ts +38 -6
  86. package/src/core/fix-scope.ts +4 -2
  87. package/src/core/floor-resolve.ts +68 -48
  88. package/src/core/floor.ts +9 -0
  89. package/src/core/git-root.ts +24 -0
  90. package/src/core/global-contribution.ts +4 -1
  91. package/src/core/ignored-block.ts +1 -1
  92. package/src/core/ignored-inputs.ts +3 -2
  93. package/src/core/last-good.ts +3 -1
  94. package/src/core/layout.ts +8 -0
  95. package/src/core/log-stamp.ts +36 -0
  96. package/src/core/loop-watch.ts +93 -0
  97. package/src/core/machine-link.ts +134 -0
  98. package/src/core/memory-watch.ts +41 -0
  99. package/src/core/motherhome.ts +2 -2
  100. package/src/core/one-way-in-policy.ts +34 -26
  101. package/src/core/run-ci.ts +9 -11
  102. package/src/core/run-fixers.ts +9 -9
  103. package/src/core/runs-matrix.ts +1 -1
  104. package/src/core/slots.ts +30 -0
  105. package/src/core/trace-audit.ts +50 -9
  106. package/src/core/tree-rev.ts +60 -0
  107. package/src/core/unit-files.ts +42 -0
  108. package/src/drill/render.ts +140 -0
  109. package/src/drill/run.ts +269 -0
  110. package/src/fleet/scan-fleet.ts +6 -5
  111. package/src/home/daemon-jobs.ts +201 -0
  112. package/src/home/global-context.ts +44 -8
  113. package/src/home/gui-app/ShipkitGui.swift +91 -2
  114. package/src/home/home-routes.ts +22 -15
  115. package/src/home/hubs.ts +10 -3
  116. package/src/home/inbox-shape.ts +54 -5
  117. package/src/home/inbox.ts +17 -2
  118. package/src/home/lib-watch.ts +10 -3
  119. package/src/home/machine-stores.ts +15 -29
  120. package/src/home/pm-config.ts +4 -1
  121. package/src/home/pm-inputs.ts +2 -0
  122. package/src/home/resources.ts +7 -2
  123. package/src/home/run-daemon.ts +15 -18
  124. package/src/home/run-pm.ts +3 -1
  125. package/src/home/serve-daemon.ts +4 -3
  126. package/src/home/serve-web.ts +104 -1
  127. package/src/hooks/commit-message.ts +29 -20
  128. package/src/hooks/hook-gates.ts +1 -1
  129. package/src/hooks/leak-guard.ts +69 -9
  130. package/src/hooks/run-hooks.ts +18 -22
  131. package/src/identities/identities.ts +334 -0
  132. package/src/identities/machine-route.ts +126 -0
  133. package/src/identities/machine.ts +62 -0
  134. package/src/init-repo.ts +3 -3
  135. package/src/ledger/check-stats.ts +10 -9
  136. package/src/ledger/gate-checks.ts +32 -1
  137. package/src/ledger/record-kept.ts +112 -0
  138. package/src/ledger/repo-view.ts +10 -0
  139. package/src/ledger/run-log.ts +17 -12
  140. package/src/ledger/run-timeline.ts +8 -4
  141. package/src/ledger/store.ts +7 -0
  142. package/src/ledger/suite-log.ts +17 -13
  143. package/src/media-kinds.ts +3 -2
  144. package/src/media-store/backup/daemon.ts +73 -0
  145. package/src/media-store/backup/keys.ts +25 -0
  146. package/src/media-store/backup/manifest.ts +193 -0
  147. package/src/media-store/backup/restore.ts +192 -0
  148. package/src/media-store/backup/run.ts +278 -0
  149. package/src/media-store/backup/secret.ts +86 -0
  150. package/src/media-store/backup/snapshot.ts +64 -0
  151. package/src/media-store/backup/sources.ts +199 -0
  152. package/src/media-store/content.ts +1 -1
  153. package/src/media-store/daemon.ts +56 -70
  154. package/src/media-store/db.ts +1 -1
  155. package/src/media-store/fact.ts +1 -1
  156. package/src/media-store/hand.ts +1 -1
  157. package/src/media-store/kind.ts +1 -1
  158. package/src/media-store/purge.ts +1 -1
  159. package/src/media-store/put.ts +5 -3
  160. package/src/media-store/remote.ts +1 -1
  161. package/src/media-store/space.ts +24 -5
  162. package/src/mv/mv-md.ts +63 -22
  163. package/src/pages/forward.ts +35 -0
  164. package/src/pages/frame-client.ts +118 -0
  165. package/src/pages/routes.ts +29 -0
  166. package/src/pages/unit.ts +92 -0
  167. package/src/plan/planner.ts +12 -0
  168. package/src/plan/repo-source.ts +19 -5
  169. package/src/reflect/transcript.ts +35 -10
  170. package/src/release/public-clean.ts +319 -0
  171. package/src/release/published-here.ts +22 -0
  172. package/src/release/run-bump.ts +3 -2
  173. package/src/release/run-release.ts +7 -4
  174. package/src/repo-config.ts +71 -13
  175. package/src/review/anim.ts +1 -1
  176. package/src/review/auto.ts +1 -1
  177. package/src/review/cells.ts +15 -1
  178. package/src/review/format.ts +2 -2
  179. package/src/review/http.ts +16 -2
  180. package/src/review/marks.ts +1 -1
  181. package/src/review/media-kind.ts +1 -1
  182. package/src/review/media-read.ts +1 -1
  183. package/src/review/model.ts +27 -6
  184. package/src/review/notes.ts +125 -0
  185. package/src/review/previews.ts +1 -1
  186. package/src/review/project.ts +7 -39
  187. package/src/review/role.ts +1 -1
  188. package/src/review/routes.ts +18 -14
  189. package/src/review/store.ts +42 -2
  190. package/src/review/threads.ts +1 -1
  191. package/src/review/trailer-desk.ts +3 -3
  192. package/src/review/trailer-media.ts +8 -5
  193. package/src/review/trailer-model.ts +1 -1
  194. package/src/review/trailer-routes.ts +1 -1
  195. package/src/review/trailer-shots.ts +22 -5
  196. package/src/review/unit.ts +2 -2
  197. package/src/scaffold/files/agent-handoff.md +3 -0
  198. package/src/scaffold/files/agent-index.md +4 -12
  199. package/src/scaffold/files/tsconfig.json +1 -1
  200. package/src/scaffold/project-scaffold.ts +6 -5
  201. package/src/serve/embed.ts +2 -2
  202. package/src/serve/hub-app/check-words.ts +1 -1
  203. package/src/serve/hub-app/col-card.tsx +3 -17
  204. package/src/serve/hub-app/col-tables-view.tsx +2 -1
  205. package/src/serve/hub-app/cols-svc.ts +0 -13
  206. package/src/serve/hub-app/dock-st.ts +4 -2
  207. package/src/serve/hub-app/dock-view.tsx +2 -0
  208. package/src/serve/hub-app/frames-st.ts +35 -0
  209. package/src/serve/hub-app/hash-route.ts +64 -1
  210. package/src/serve/hub-app/home-st.ts +32 -8
  211. package/src/serve/hub-app/home-strip.css +9 -1
  212. package/src/serve/hub-app/home-strip.tsx +7 -6
  213. package/src/serve/hub-app/home.html +5 -0
  214. package/src/serve/hub-app/hub-app.tsx +51 -7
  215. package/src/serve/hub-app/hub.css +29 -11
  216. package/src/serve/hub-app/icons.tsx +16 -1
  217. package/src/serve/hub-app/identities-st.ts +210 -0
  218. package/src/serve/hub-app/identities-view.tsx +353 -0
  219. package/src/serve/hub-app/identities.css +48 -0
  220. package/src/serve/hub-app/identity-address.ts +52 -0
  221. package/src/serve/hub-app/inbox-st.ts +60 -7
  222. package/src/serve/hub-app/inbox-view.tsx +49 -7
  223. package/src/serve/hub-app/inbox.css +12 -1
  224. package/src/serve/hub-app/index.html +3 -0
  225. package/src/serve/hub-app/kept-cols.tsx +30 -0
  226. package/src/serve/hub-app/keys.ts +10 -2
  227. package/src/serve/hub-app/list-walk.ts +89 -0
  228. package/src/serve/hub-app/machine-st.ts +12 -0
  229. package/src/serve/hub-app/media-svc.ts +1 -1
  230. package/src/serve/hub-app/media-view.tsx +2 -1
  231. package/src/serve/hub-app/pages-frames.tsx +134 -0
  232. package/src/serve/hub-app/pages-svc.ts +111 -0
  233. package/src/serve/hub-app/palette-st.ts +18 -3
  234. package/src/serve/hub-app/palette-view.tsx +9 -2
  235. package/src/serve/hub-app/planned-view.tsx +2 -1
  236. package/src/serve/hub-app/project-list.css +18 -14
  237. package/src/serve/hub-app/project-list.tsx +88 -49
  238. package/src/serve/hub-app/projects-svc.ts +33 -3
  239. package/src/serve/hub-app/repo-sections.ts +19 -2
  240. package/src/serve/hub-app/repo-st.ts +76 -20
  241. package/src/serve/hub-app/review/review-board.tsx +1 -1
  242. package/src/serve/hub-app/review/review-cells.tsx +6 -5
  243. package/src/serve/hub-app/review/review-kit.ts +30 -7
  244. package/src/serve/hub-app/review/review-page.tsx +6 -5
  245. package/src/serve/hub-app/review/review-st.ts +34 -15
  246. package/src/serve/hub-app/review/review-thread.tsx +63 -14
  247. package/src/serve/hub-app/review/review-views.tsx +133 -51
  248. package/src/serve/hub-app/review/thread-st.ts +80 -37
  249. package/src/serve/hub-app/review/trailer-page.tsx +7 -5
  250. package/src/serve/hub-app/review/trailer-st.ts +1 -1
  251. package/src/serve/hub-app/review.css +26 -9
  252. package/src/serve/hub-app/site/site-part.tsx +173 -0
  253. package/src/serve/hub-app/site/site-st.ts +157 -0
  254. package/src/serve/hub-app/site.css +35 -0
  255. package/src/serve/hub-app/social/calendar.tsx +182 -0
  256. package/src/serve/hub-app/social/comms-page.tsx +330 -0
  257. package/src/serve/hub-app/social/kit.tsx +244 -0
  258. package/src/serve/hub-app/social/post-card.tsx +456 -0
  259. package/src/serve/hub-app/social/problems.tsx +60 -0
  260. package/src/serve/hub-app/social/social-model.ts +154 -0
  261. package/src/serve/hub-app/social/social-page.tsx +681 -0
  262. package/src/serve/hub-app/social/social-st.ts +1014 -0
  263. package/src/serve/hub-app/social.css +289 -0
  264. package/src/serve/hub-app/stores/stores-page.tsx +312 -0
  265. package/src/serve/hub-app/stores/stores-st.ts +286 -0
  266. package/src/serve/hub-app/stores.css +54 -0
  267. package/src/serve/hub-app/timeline-geometry.ts +1 -1
  268. package/src/serve/hub-app/timeline-view.tsx +3 -2
  269. package/src/serve/hub-app/tree-build.ts +6 -0
  270. package/src/serve/hub-app/tree-row.tsx +27 -4
  271. package/src/serve/hub-app/tree-svc.ts +18 -49
  272. package/src/serve/hub-app/veille/veille-page.tsx +515 -0
  273. package/src/serve/hub-app/veille/veille-st.ts +443 -0
  274. package/src/serve/hub-app/veille.css +84 -0
  275. package/src/serve/hub-runtime.ts +20 -11
  276. package/src/serve/project-gutter-route.ts +44 -12
  277. package/src/serve/run-lanes.ts +7 -4
  278. package/src/serve/same-origin.ts +1 -1
  279. package/src/serve/serve-hub.ts +20 -12
  280. package/src/serve/tracked-watch.ts +24 -3
  281. package/src/serve/warm-cell.ts +5 -1
  282. package/src/shipkit-files.ts +15 -4
  283. package/src/shipkit.ts +0 -1
  284. package/src/shot/box.ts +160 -0
  285. package/src/shot/browser-slot.ts +74 -0
  286. package/src/shot/client.ts +42 -7
  287. package/src/shot/clip-encoder.ts +108 -24
  288. package/src/shot/film-box.ts +292 -0
  289. package/src/shot/shooter.ts +71 -17
  290. package/src/shot/shot-ask.ts +10 -2
  291. package/src/shot/stepped-clip.ts +5 -4
  292. package/src/site/desk.ts +242 -0
  293. package/src/site/routes.ts +66 -0
  294. package/src/site/unit.ts +62 -0
  295. package/src/social/brands.ts +22 -0
  296. package/src/social/card-drafts.ts +24 -0
  297. package/src/social/compose.ts +97 -0
  298. package/src/social/desk-index.ts +123 -0
  299. package/src/social/desk-wire.ts +64 -0
  300. package/src/social/drafts.ts +183 -0
  301. package/src/social/house.ts +24 -0
  302. package/src/social/load.ts +332 -0
  303. package/src/social/md.ts +70 -0
  304. package/src/social/media-facts.ts +53 -0
  305. package/src/social/media-kind.ts +189 -0
  306. package/src/social/media-limit.ts +42 -0
  307. package/src/social/media-of.ts +30 -0
  308. package/src/social/migrate.ts +123 -0
  309. package/src/social/open.ts +17 -0
  310. package/src/social/post-url.ts +158 -0
  311. package/src/social/presence.ts +332 -0
  312. package/src/social/public-read.ts +53 -0
  313. package/src/social/publish/bluesky.ts +168 -0
  314. package/src/social/publish/discord.ts +76 -0
  315. package/src/social/publish/index.ts +24 -0
  316. package/src/social/publish/secret.ts +13 -0
  317. package/src/social/push.ts +37 -0
  318. package/src/social/richtext.ts +37 -0
  319. package/src/social/routes.ts +186 -0
  320. package/src/social/stats.ts +134 -0
  321. package/src/social/text.ts +267 -0
  322. package/src/social/tracker-route.ts +39 -0
  323. package/src/social/tracker.ts +255 -0
  324. package/src/social/unit.ts +53 -0
  325. package/src/social/writes.ts +130 -0
  326. package/src/start-repo.ts +14 -9
  327. package/src/stores/collection.ts +27 -0
  328. package/src/stores/desk.ts +336 -0
  329. package/src/stores/model.ts +187 -0
  330. package/src/stores/routes.ts +126 -0
  331. package/src/stores/unit.ts +57 -0
  332. package/src/suite/calibrate.ts +127 -0
  333. package/src/suite/core-counters.ts +91 -0
  334. package/src/suite/judge-suites.ts +95 -35
  335. package/src/suite/suite-cli.ts +44 -10
  336. package/src/suite/suite-cpu-preload.ts +34 -9
  337. package/src/trace/tracer.ts +12 -5
  338. package/src/trailer/adapter.ts +5 -1
  339. package/src/trailer/build.ts +45 -12
  340. package/src/trailer/ffmpeg.ts +11 -0
  341. package/src/trailer/footage.ts +30 -13
  342. package/src/trailer/grammar.ts +18 -2
  343. package/src/trailer/graph.ts +28 -6
  344. package/src/trailer/holes.ts +1 -1
  345. package/src/trailer/passage.ts +18 -6
  346. package/src/trailer/plan.ts +74 -3
  347. package/src/trailer/prune.ts +1 -1
  348. package/src/trailer/states.ts +1 -1
  349. package/src/trailer/stitch.ts +67 -26
  350. package/src/trailer/url.ts +1 -1
  351. package/src/trailer/versions.ts +24 -0
  352. package/src/trailer/words.ts +1 -1
  353. package/src/ts/gate-typecheck.ts +32 -0
  354. package/src/ts/typecheck-cli.ts +9 -11
  355. package/src/tui/run-tui.ts +1 -1
  356. package/src/tui/tui-app.tsx +0 -1
  357. package/src/tui/tui-store.ts +1 -1
  358. package/src/veille/asks.ts +155 -0
  359. package/src/veille/auto.ts +31 -0
  360. package/src/veille/batch.ts +27 -0
  361. package/src/veille/chrome.ts +127 -0
  362. package/src/veille/collection.ts +28 -0
  363. package/src/veille/desk.ts +242 -0
  364. package/src/veille/identity.ts +80 -0
  365. package/src/veille/import.ts +68 -0
  366. package/src/veille/log.ts +183 -0
  367. package/src/veille/platforms.ts +118 -0
  368. package/src/veille/reads.ts +66 -0
  369. package/src/veille/replied.ts +110 -0
  370. package/src/veille/routes.ts +185 -0
  371. package/src/veille/service.ts +81 -0
  372. package/src/veille/watch.ts +116 -0
  373. package/src/veille/worth.ts +46 -0
  374. package/src/wiki/scan-md.ts +18 -0
  375. package/src/collections/posts.ts +0 -142
  376. package/src/contracts/manifests/social.contract.ts +0 -20
  377. package/src/scaffold/files/agent-coding.md +0 -35
  378. package/src/ts/typecheck-cache.ts +0 -11
@@ -0,0 +1,93 @@
1
+ // the daemon's one loop answers every page and runs every background job, so a job that holds the loop holds every
2
+ // page. Work names itself as a span (a request, a tick, a backup run); a beat that comes late says the loop stood
3
+ // still, and names the spans that overlapped the stall, longest overlap first. A span that blocked synchronously has
4
+ // already ended when the late beat fires, so the finished spans are kept too
5
+ export type Span = { what: string; at: number; end: number | null }
6
+
7
+ /** a stall shorter than this is the machine's ordinary jitter: the bar of wiki tools/shipkit/home.md (Nothing heavy on the daemon's loop) */
8
+ export const STALL_MS = 200
9
+ const BEAT_MS = 250
10
+ const KEEP = 300
11
+ /** a parent span (a request, the tick) and its named steps both fit on the line */
12
+ const NAMED = 6
13
+
14
+ export class LoopWatch {
15
+ private active = new Set<Span>()
16
+ private done: Span[] = []
17
+ private last: number
18
+
19
+ constructor(private now: () => number = Date.now, private stallMs = STALL_MS, private beatMs = BEAT_MS) {
20
+ this.last = now()
21
+ }
22
+
23
+ /** starts a span; the function it returns ends it */
24
+ span(what: string): () => void {
25
+ const s: Span = { what, at: this.now(), end: null }
26
+ this.active.add(s)
27
+ return () => {
28
+ if (s.end != null) return
29
+ s.end = this.now()
30
+ this.active.delete(s)
31
+ this.done.push(s)
32
+ if (this.done.length > KEEP) this.done.splice(0, this.done.length - KEEP)
33
+ }
34
+ }
35
+
36
+ /** sync `f` inside a span: the span ends even when `f` throws */
37
+ timed<T>(what: string, f: () => T): T {
38
+ const end = this.span(what)
39
+ try {
40
+ return f()
41
+ } finally {
42
+ end()
43
+ }
44
+ }
45
+
46
+ /** `f` inside a span, sync or async */
47
+ async spanned<T>(what: string, f: () => Promise<T> | T): Promise<T> {
48
+ const end = this.span(what)
49
+ try {
50
+ return await f()
51
+ } finally {
52
+ end()
53
+ }
54
+ }
55
+
56
+ /** the spans that overlapped [from, to], longest overlap first, with that overlap in ms */
57
+ overlapping(from: number, to: number): { what: string; ms: number; open: boolean }[] {
58
+ return [...this.done, ...this.active]
59
+ .map((s) => ({ what: s.what, ms: Math.min(s.end ?? to, to) - Math.max(s.at, from), open: s.end == null }))
60
+ .filter((x) => x.ms > 0)
61
+ .sort((a, b) => b.ms - a.ms)
62
+ }
63
+
64
+ /** one beat: the stall line when the loop stood still since the last beat, else null */
65
+ beat(): string | null {
66
+ const t = this.now()
67
+ const gap = t - this.last - this.beatMs
68
+ const from = this.last
69
+ this.last = t
70
+ if (gap < this.stallMs) return null
71
+ const by = this.overlapping(from, t)
72
+ const named = by.slice(0, NAMED).map((x) => `${x.what} ${(x.ms / 1000).toFixed(1)}s${x.open ? ' (still running)' : ''}`)
73
+ const more = by.length > NAMED ? `, ${by.length - NAMED} more` : ''
74
+ return `the loop stood still ${(gap / 1000).toFixed(1)}s: ${named.length === 0 ? 'no named work ran in it' : `${named.join(', ')}${more}`}`
75
+ }
76
+
77
+ /** beats on a timer and says each stall; returns its stop */
78
+ start(say: (l: string) => void): () => void {
79
+ this.last = this.now()
80
+ const t = setInterval(() => {
81
+ const l = this.beat()
82
+ if (l != null) say(`WARN ${l}`)
83
+ }, this.beatMs)
84
+ t.unref()
85
+ return () => clearInterval(t)
86
+ }
87
+ }
88
+
89
+ /** the loop back to whoever waits (a request, a beat), between two steps of a long piece of work */
90
+ export const yieldLoop = (): Promise<void> => new Promise((r) => setImmediate(r))
91
+
92
+ /** the process's one watch: the daemon starts it, its jobs and requests name themselves on it */
93
+ export const loopWatch = new LoopWatch()
@@ -0,0 +1,134 @@
1
+ // a house repo's node_modules/rvlib-shipkit is the machine's copy, linked:
2
+ // every path that loads the lib by name (bun test, a bun script, tsc, the
3
+ // editor, the commit hooks) runs the source `sk` runs, so a change made in the
4
+ // house is usable in every house repo at once, and a release is for npm only.
5
+ // Every cli run makes it, a few lstats when it is already there.
6
+ //
7
+ // the one constraint a reader breaks first: a link to a source tree (no
8
+ // node_modules in its real path) is never touched, a worktree linked for live
9
+ // hacking included. Only an install is swapped.
10
+ import { existsSync, lstatSync, readFileSync, realpathSync, renameSync, rmSync, symlinkSync, writeFileSync } from 'fs'
11
+ import { homedir } from 'os'
12
+ import { dirname, join, relative, resolve, sep } from 'path'
13
+ import { CLAUDE_FILES } from '../home/pm-inputs.ts'
14
+
15
+ const NAME = 'rvlib-shipkit'
16
+
17
+ type Env = Record<string, string | undefined>
18
+ const set = (v: string | undefined): boolean => v != null && v !== ''
19
+
20
+ /** the nearest dir at or above `cwd` whose node_modules holds the lib, as bun
21
+ * resolves it from there, else null */
22
+ export function consumerOf(cwd: string): string | null {
23
+ for (let dir = resolve(cwd); ; dir = dirname(dir)) {
24
+ try {
25
+ lstatSync(join(dir, 'node_modules', NAME))
26
+ return dir
27
+ } catch { /* not here */ }
28
+ if (dirname(dir) === dir) return null
29
+ }
30
+ }
31
+
32
+ /** an install (npm, bun, a cache) rather than a source tree */
33
+ export const isInstall = (real: string): boolean => real.split(sep).includes('node_modules')
34
+
35
+ const declares = (dir: string): boolean => {
36
+ try {
37
+ const pkg = JSON.parse(readFileSync(join(dir, 'package.json'), 'utf8')) as { dependencies?: Record<string, string>; devDependencies?: Record<string, string> }
38
+ const spec = pkg.dependencies?.[NAME] ?? pkg.devDependencies?.[NAME]
39
+ return spec != null && !spec.startsWith('link:') && !spec.startsWith('file:')
40
+ } catch {
41
+ return false
42
+ }
43
+ }
44
+
45
+ const versionOf = (dir: string): string => {
46
+ try {
47
+ return (JSON.parse(readFileSync(join(dir, 'package.json'), 'utf8')) as { version?: string }).version ?? '?'
48
+ } catch {
49
+ return '?'
50
+ }
51
+ }
52
+
53
+ export type LinkPlan =
54
+ | { action: 'none' }
55
+ | { action: 'link'; repo: string; lib: string; was: string }
56
+ | { action: 'no-house'; repo: string; index: string; was: string }
57
+
58
+ /** what the run should do in `repo`, whose node_modules holds an install of
59
+ * the lib. `lib` is the machine's copy, null when this machine has no house */
60
+ export function planLink(o: { repo: string; env: Env; declared: boolean; lib: string | null; house: string | null; missingIndex: string | null; was: string }): LinkPlan {
61
+ if (set(o.env.CI) || set(o.env.SHIPKIT_NO_HOME) || o.env.SHIPKIT_FROZEN === '1' || !o.declared) return { action: 'none' }
62
+ if (o.lib == null || o.house == null) return o.missingIndex == null ? { action: 'none' } : { action: 'no-house', repo: o.repo, index: o.missingIndex, was: o.was }
63
+ // the house runs its source by path: an install inside it is its own business
64
+ if (o.repo === o.house || o.repo.startsWith(`${o.house}${sep}`)) return { action: 'none' }
65
+ return { action: 'link', repo: o.repo, lib: o.lib, was: o.was }
66
+ }
67
+
68
+ /** swap the install for a relative link to `lib`, the shape `bun link` makes.
69
+ * The install is moved aside first and put back when the link fails */
70
+ export function swapInLink(repo: string, lib: string): void {
71
+ const nm = join(repo, 'node_modules')
72
+ const at = join(nm, NAME)
73
+ const aside = join(nm, `.${NAME}-installed-${process.pid}`)
74
+ renameSync(at, aside)
75
+ try {
76
+ // from the real dir: a node_modules that is itself a link sits at another depth
77
+ symlinkSync(relative(realpathSync(nm), lib), at)
78
+ } catch (e) {
79
+ try {
80
+ renameSync(aside, at)
81
+ } catch {
82
+ throw new Error(`${e instanceof Error ? e.message : String(e)}; the install stays at ${aside}`)
83
+ }
84
+ throw e
85
+ }
86
+ try {
87
+ rmSync(aside, { recursive: true, force: true })
88
+ } catch (e) {
89
+ throw new Error(`linked, but the old install stays at ${aside}: ${e instanceof Error ? e.message : String(e)}`)
90
+ }
91
+ }
92
+
93
+ /** an install, or a link that resolves nowhere (its target moved): both are swapped */
94
+ export function needsLink(at: string): boolean {
95
+ try {
96
+ return isInstall(realpathSync(at))
97
+ } catch {
98
+ return lstatSync(at).isSymbolicLink()
99
+ }
100
+ }
101
+
102
+ const NO_HOUSE_MARK = `.${NAME}-no-house`
103
+
104
+ /** the cli's step: link the machine's copy into the repo `cwd` sits in. Never
105
+ * throws, prints one line when it links, and one line per install when the
106
+ * repo names a house this machine lacks */
107
+ export async function linkMachineCopy(cwd: string = process.cwd(), env: Env = process.env, print: (s: string) => void = (s) => console.error(s)): Promise<void> {
108
+ try {
109
+ const repo = consumerOf(cwd)
110
+ if (repo == null) return
111
+ const at = join(repo, 'node_modules', NAME)
112
+ if (!needsLink(at)) return
113
+ // a stranger's npm repo names no house: no house lookup on each run
114
+ if (!CLAUDE_FILES.some((f) => existsSync(join(repo, f)))) return
115
+ const { houseCli, houseRootOf } = await import('../home/home-start.ts')
116
+ const { includeTargets } = await import('../serve/project-gutter.ts')
117
+ const house = houseRootOf(repo)
118
+ const cli = house == null ? null : houseCli(house, '')
119
+ const lib = cli == null || cli === '' ? null : resolve(dirname(cli), '..')
120
+ const missingIndex = house == null ? includeTargets(repo, homedir()).find((t) => !t.startsWith(`${repo}${sep}`) && !existsSync(t)) ?? null : null
121
+ const plan = planLink({ repo, env, declared: declares(repo), lib: lib != null && existsSync(join(lib, 'package.json')) ? lib : null, house, missingIndex, was: existsSync(at) ? versionOf(at) : 'a dangling link' })
122
+ if (plan.action === 'link') {
123
+ swapInLink(plan.repo, plan.lib)
124
+ print(`shipkit: ${relative(homedir(), plan.repo) || plan.repo}/node_modules/${NAME} was ${plan.was === 'a dangling link' ? plan.was : `the installed ${plan.was}`}, now a link to the machine's copy (${relative(homedir(), plan.lib)}): bun, tsc and the hooks here run it`)
125
+ } else if (plan.action === 'no-house') {
126
+ const mark = join(repo, 'node_modules', NO_HOUSE_MARK)
127
+ if (existsSync(mark)) return
128
+ writeFileSync(mark, `${plan.index}\n`)
129
+ print(`shipkit: no machine copy here (${plan.index} is absent): this repo runs its installed ${NAME} ${plan.was}`)
130
+ }
131
+ } catch (e) {
132
+ print(`WARN shipkit: node_modules/${NAME} and the machine's copy: ${e instanceof Error ? e.message : String(e)}`)
133
+ }
134
+ }
@@ -0,0 +1,41 @@
1
+ // the daemon's memory as a trend in its log: one line every 10 minutes, and only when it moved by a tenth since the
2
+ // line before, so a steady daemon writes nothing and a leak reads as a climb. At most 6 lines an hour, and pm trims
3
+ // the log past its cap (capLog), so the disk never fills from it. A restart in place starts it again from zero
4
+ export const MEMORY_EVERY_MS = 10 * 60_000
5
+ /** a move smaller than this share of the last said value says nothing */
6
+ export const MEMORY_STEP = 0.1
7
+
8
+ export type Memory = { rss: number; heap: number }
9
+
10
+ const mb = (b: number): string => `${Math.round(b / 1e6)} MB`
11
+
12
+ export class MemoryWatch {
13
+ private said: Memory | null = null
14
+ private readonly from: Memory
15
+
16
+ constructor(private read: () => Memory = () => {
17
+ const m = process.memoryUsage()
18
+ return { rss: m.rss, heap: m.heapUsed }
19
+ }) {
20
+ this.from = read()
21
+ }
22
+
23
+ /** one look: the line when the resident size moved by MEMORY_STEP since the last line (or the start), else null */
24
+ look(): string | null {
25
+ const m = this.read()
26
+ const base = this.said ?? this.from
27
+ if (Math.abs(m.rss - base.rss) < base.rss * MEMORY_STEP) return null
28
+ this.said = m
29
+ return `memory: ${mb(m.rss)} resident, ${mb(m.heap)} heap (${m.rss >= base.rss ? 'up' : 'down'} from ${mb(base.rss)}, ${mb(this.from.rss)} at start)`
30
+ }
31
+
32
+ /** looks on a timer and says each move; returns its stop */
33
+ start(say: (l: string) => void): () => void {
34
+ const t = setInterval(() => {
35
+ const l = this.look()
36
+ if (l != null) say(`ok: ${l}`)
37
+ }, MEMORY_EVERY_MS)
38
+ t.unref()
39
+ return () => clearInterval(t)
40
+ }
41
+ }
@@ -1,5 +1,5 @@
1
1
  // Report to the motherhome: a repo's row in the docsBase wiki's
2
- // `build/shipkit/local-projects.md`, in two halves.
2
+ // `tools/shipkit/local-projects.md`, in two halves.
3
3
  //
4
4
  // - `reportToMotherhome` (every ci/check/init) files the row in the MACHINE
5
5
  // DB and nothing else. A gate answers about its own repo, so it never
@@ -68,7 +68,7 @@ export function reportToMotherhome(root: string, config: RepoConfig, today: stri
68
68
  // absolute local paths only: a relative docsBase would resolve
69
69
  // against CWD, a URL is a display prefix
70
70
  if (!base.startsWith('/')) return { wrote: false }
71
- const page = join(base, 'build/shipkit/local-projects.md')
71
+ const page = join(base, 'tools/shipkit/local-projects.md')
72
72
  if (!existsSync(page)) return { wrote: false }
73
73
  // a linked worktree is a temporary side checkout: its runs are
74
74
  // covered when its branch merges
@@ -1,4 +1,4 @@
1
- // ONE WAY IN, the harness half (build/shipkit/one-way-in.md). The package.json half
1
+ // ONE WAY IN, the harness half (tools/shipkit/one-way-in.md). The package.json half
2
2
  // (rule SK001) routes `bun run test` into shipkit, but `bun test` is a bun
3
3
  // BUILTIN: no script can intercept it, so a package.json alone leaves the
4
4
  // reflex wide open. Claude Code permission rules can close it.
@@ -14,7 +14,7 @@
14
14
  // The deny is the floor and the hook is the messenger. When the hook cannot
15
15
  // run, enforcement degrades to terse rather than to nothing.
16
16
  //
17
- // Subprocesses are NOT intercepted (verified): shipkit spawning tsc or
17
+ // Subprocesses are NOT intercepted (verified): shipkit spawning bun check or
18
18
  // `bun run test:raw` from inside a permitted `shipkit ci` is invisible to
19
19
  // these rules, which is exactly what makes the gate itself still work.
20
20
 
@@ -25,34 +25,42 @@ export type RawRunner = {
25
25
  * the shell command together: a repo that keeps `test` raw is not then
26
26
  * refused `bun test` */
27
27
  slot: 'test' | 'typecheck'
28
- /** the shipkit command that answers the same question, cache and all */
28
+ /** what is wrong with the raw call, after its head */
29
+ why: string
30
+ /** the command to type instead */
29
31
  use: string
30
- /** the narrower way in, when there is one: iterating on a single repro
32
+ /** the other way in, with what it is for: iterating on a single repro
31
33
  * test while you fix a bug is not a verification and stays normal. A
32
34
  * FILE filter (measured): bun's positional argument matches the test FILE
33
35
  * path, and a test NAME needs `-- -t "<name>"` forwarded through bun run */
34
- iterate?: string
36
+ also?: string
35
37
  }
36
38
 
39
+ const BYPASS = 'bypasses shipkit, so nothing is cached and no other agent\'s run can be attached to'
40
+ const TEST: Omit<RawRunner, 'head'> = { slot: 'test', why: BYPASS, use: 'shipkit ci --only test', also: '`bun run test:raw <test file>` to iterate on ONE suite while you fix a bug' }
41
+ // bun check is bun's own checker: tsc's errors on every core, so it runs bare
42
+ // like `bun lint`. A package.json `check` script runs in its place (SK001 warns)
43
+ const TYPECHECK: Omit<RawRunner, 'head'> = { slot: 'typecheck', why: 'is not the house type checker', use: 'bun check', also: '`shipkit ci --only typecheck` for the gate\'s verdict, cached. Where package.json has a `check` script, `bun check --no-script`' }
44
+
37
45
  // the house stack, plus the foreign runners a wired repo is actually found
38
46
  // carrying. Kept tight on purpose: a deny an agent hits for no good reason
39
47
  // teaches it to route around the whole file.
40
48
  export const RAW_RUNNERS: readonly RawRunner[] = [
41
- { head: 'bun test', slot: 'test', use: 'shipkit ci --only test', iterate: 'bun run test:raw <test file>' },
42
- { head: 'bunx vitest', slot: 'test', use: 'shipkit ci --only test', iterate: 'bun run test:raw <test file>' },
43
- { head: 'npx vitest', slot: 'test', use: 'shipkit ci --only test', iterate: 'bun run test:raw <test file>' },
44
- { head: 'vitest', slot: 'test', use: 'shipkit ci --only test', iterate: 'bun run test:raw <test file>' },
45
- { head: 'npx jest', slot: 'test', use: 'shipkit ci --only test', iterate: 'bun run test:raw <test file>' },
46
- { head: 'jest', slot: 'test', use: 'shipkit ci --only test', iterate: 'bun run test:raw <test file>' },
47
- { head: 'bunx tsc', slot: 'typecheck', use: 'shipkit ci --only typecheck' },
48
- { head: 'npx tsc', slot: 'typecheck', use: 'shipkit ci --only typecheck' },
49
- { head: 'tsc', slot: 'typecheck', use: 'shipkit ci --only typecheck' },
49
+ { head: 'bun test', ...TEST },
50
+ { head: 'bunx vitest', ...TEST },
51
+ { head: 'npx vitest', ...TEST },
52
+ { head: 'vitest', ...TEST },
53
+ { head: 'npx jest', ...TEST },
54
+ { head: 'jest', ...TEST },
55
+ { head: 'bunx tsc', ...TYPECHECK },
56
+ { head: 'npx tsc', ...TYPECHECK },
57
+ { head: 'tsc', ...TYPECHECK },
50
58
  ]
51
59
 
52
- // the LINTER and the FORMATTER are deliberately absent. `bun lint` and
53
- // `bun fmt` are the house way in: bun's built-ins cover a whole repo in well
54
- // under a second, so a cache has nothing to save, and the formatter is a
55
- // manual tool the gate never runs.
60
+ // the LINTER, the FORMATTER and `bun check` are deliberately absent. `bun
61
+ // lint`, `bun fmt` and `bun check` are the house way in: bun's built-ins
62
+ // are fast enough over a whole repo that a cache has little to save, and the
63
+ // formatter is a manual tool the gate never runs.
56
64
 
57
65
  /** the `permissions.deny` entries, in the syntax Claude Code matches:
58
66
  * `Bash(<head>*)` is a prefix match, and a compound command is checked one
@@ -63,7 +71,7 @@ export const denyRules = (exemptSlots: Iterable<string> = []): string[] => {
63
71
  }
64
72
 
65
73
  // `git stash` in a tree that other agents share takes every agent's
66
- // uncommitted work, not just the caller's (identity/how-we-commit.md: never
74
+ // uncommitted work, not just the caller's (preferences/how-we-commit/index.md: never
67
75
  // stash as a side effect). The deny row is the floor. Claude Code matches it
68
76
  // per subcommand of a compound and inside `$(...)`, and never inside
69
77
  // `bash -c '...'`, after git's own global options (`git -C dir stash`), or
@@ -166,7 +174,7 @@ export function stashCallIn(command: string, depth = 0): string | null {
166
174
 
167
175
  /** what a stash refusal says: why, what to do instead, how to lift it */
168
176
  export function stashRefusal(segment: string): string {
169
- return `\`${segment.slice(0, 80)}\` stashes: in a tree that other agents share, a stash takes every agent's uncommitted work, not just yours. Set your own work aside with a commit by pathspec (git commit -m … -- <paths>), and read an existing stash by revision: \`git log -g --oneline refs/stash\`, \`git show stash@{0}:<file>\`. Reading a stash (\`git stash list\`, \`git stash show\`) is never refused. SK013 writes these rows in every shipkit repo (identity/how-we-commit.md): lifting them is a change to that rule, not a settings edit.`
177
+ return `\`${segment.slice(0, 80)}\` stashes: in a tree that other agents share, a stash takes every agent's uncommitted work, not just yours. Set your own work aside with a commit by pathspec (git commit -m … -- <paths>), and read an existing stash by revision: \`git log -g --oneline refs/stash\`, \`git show stash@{0}:<file>\`. Reading a stash (\`git stash list\`, \`git stash show\`) is never refused. SK013 writes these rows in every shipkit repo (preferences/how-we-commit/index.md): lifting them is a change to that rule, not a settings edit.`
170
178
  }
171
179
 
172
180
  /** what a refusal says. Never just the ban: a refusal with no replacement
@@ -175,9 +183,9 @@ export function stashRefusal(segment: string): string {
175
183
  * does: a long compound refused on `CI=1 bun test --timeout 5` otherwise
176
184
  * leaves the reader guessing which of its clauses was the problem */
177
185
  export function refusal(r: RawRunner, segment?: string): string {
178
- const alt = r.iterate == null ? '' : `, or \`${r.iterate}\` to iterate on ONE suite while you fix a bug`
186
+ const alt = r.also == null ? '' : `, or ${r.also}`
179
187
  const which = segment == null || segment.trim() === '' || segment.trim() === r.head ? '' : ` (refused on \`${segment.trim().slice(0, 80)}\`)`
180
- return `\`${r.head}\`${which} bypasses shipkit, so nothing is cached and no other agent's run can be attached to. Use \`${r.use}\`${alt}. Lifting this for good: delete the "Bash(${r.head}*)" line from .claude/settings.json permissions.deny (build/shipkit/one-way-in.md).`
188
+ return `\`${r.head}\`${which} ${r.why}. Use \`${r.use}\`${alt}. Lifting this for good: delete the "Bash(${r.head}*)" line from .claude/settings.json permissions.deny (tools/shipkit/one-way-in.md).`
181
189
  }
182
190
 
183
191
  /** shell wrappers that do not change what is being run */
@@ -268,13 +276,13 @@ function programWords(seg: string): string[] {
268
276
  return s.split(/\s+/).filter((w) => w !== '')
269
277
  }
270
278
 
271
- /** true when the words run a GATE: `shipkit ci`, the cli by path
279
+ /** true when the words run a GATE: `shipkit ci` or `sk ci` (one cli, two names), the cli by path
272
280
  * (`bun <dir>/cli.ts ci`), or the `test` and `ci` package scripts. One suite
273
281
  * while iterating (`bun run test:raw <file>`) is not a gate */
274
282
  function isGate(words: string[]): boolean {
275
283
  const [a, b, c] = words.map((w) => w.split('/').pop() ?? w)
276
- if (a === 'shipkit') return b === 'ci'
277
- if ((a === 'bunx' || a === 'npx') && b === 'shipkit') return c === 'ci'
284
+ if (a === 'shipkit' || a === 'sk') return b === 'ci'
285
+ if ((a === 'bunx' || a === 'npx') && (b === 'shipkit' || b === 'sk')) return c === 'ci'
278
286
  if (a === 'cli.ts') return b === 'ci'
279
287
  if (a === 'bun' || a === 'node') {
280
288
  if (b === 'cli.ts') return c === 'ci'
@@ -301,7 +309,7 @@ export function pipedGateIn(command: string): string | null {
301
309
 
302
310
  /** what a piped gate refusal says: why, what to type instead, how to lift it */
303
311
  export function pipedGateRefusal(segment: string): string {
304
- return `\`${segment.slice(0, 80)}\` pipes a gate: a pipeline exits with its LAST command's code, so a red gate reads green. Run the gate bare (a \`> file\` redirect keeps its exit code and is fine), then read its output in a separate call. Lifting this: put \`set -o pipefail;\` first, or remove the one-way-in-guard hook from .claude/settings.json (agent/process.md, never pipe a gating command).`
312
+ return `\`${segment.slice(0, 80)}\` pipes a gate: a pipeline exits with its LAST command's code, so a red gate reads green. Run the gate bare (a \`> file\` redirect keeps its exit code and is fine), then read its output in a separate call. Lifting this: put \`set -o pipefail;\` first, or remove the one-way-in-guard hook from .claude/settings.json.`
305
313
  }
306
314
 
307
315
  /** the raw runner this shell command reaches for, plus the segment that
@@ -5,7 +5,7 @@
5
5
  // prints the structured summary. Every run refreshes STATUS.md
6
6
  // (write-status.ts — atomic + lock) unless status:false, and the fix pass plus
7
7
  // some checks WRITE, so a run is not read-only unless frozen is set and
8
- // --no-fix is passed.
8
+ // fix is false (internal callers only).
9
9
  import { loadRepoConfig, type RepoConfig } from '../repo-config.ts'
10
10
  import { reportToMotherhome } from './motherhome.ts'
11
11
  import { passScope, runCheckPass, type CheckOpts } from './run-check.ts'
@@ -144,12 +144,10 @@ export async function runCi(root: string, o: CiOpts = {}): Promise<number> {
144
144
  let c = o.config ?? (await loadRepoConfig(root))
145
145
  // mechanical failures are not information, so they never cost a round trip
146
146
  let fixFailed = false
147
- // a NARROWED run repairs nothing unless --fix asks, and even then only
148
- // what the named checks own: their own ci repair and the fixer slot that
149
- // governs one of them. `bun run test` routes here and must answer the one
150
- // question its name promises without leaving files in the agent's diff
151
- // that it never wrote: in a shared tree a tree wide fixer rewrites every
152
- // other agent's files too. Arming rewrites hooks/: the full gate's price alone
147
+ // a NARROWED run repairs only what the named checks own: their own ci
148
+ // repair and the fixer slot that governs one of them. No formatter is a
149
+ // fixer, so a repair is mechanical and safe in a shared tree. Arming
150
+ // rewrites hooks/: the full gate's price alone
153
151
  const narrowed = (o.onlyIds ?? []).length > 0
154
152
  if (fixPassRuns(o)) {
155
153
  const pass = await runFixPass(root, c, { rules: o.fixRules !== false, armHooks: !narrowed && o.armHooks === true, print: sink, detail, ...(narrowed ? { only: o.onlyIds } : {}) })
@@ -163,7 +161,7 @@ export async function runCi(root: string, o: CiOpts = {}): Promise<number> {
163
161
  return 1
164
162
  }
165
163
  }
166
- } else detail(o.fix === false ? 'skip: fix pass (--no-fix)' : 'skip: fix pass (a --only run leaves the tree alone, --fix repairs first)')
164
+ } else detail('skip: fix pass (a report-only run)')
167
165
  const tier: TestTier = o.tests ?? envTier()
168
166
  // announced BEFORE the run (under --verbose, and in every release log),
169
167
  // so a log that died mid-way still says which tier it was asking for
@@ -184,8 +182,8 @@ export async function runCi(root: string, o: CiOpts = {}): Promise<number> {
184
182
  // rather than leaving it with `unknown check id` and no next move
185
183
  if ((o.onlyIds ?? []).includes(u.id))
186
184
  sink(u.id === 'lint'
187
- ? ` fix: add a [lint] section to bunfig.toml, then \`shipkit ci --only lint\` runs \`bun lint\` (build/typescript.md)`
188
- : ` fix: add a '${u.id}:raw' script holding the tool, then \`shipkit ci --only ${u.id}\` runs it (meta/rv-conventions/package-json.md)`)
185
+ ? ` fix: add a [lint] section to bunfig.toml, then \`shipkit ci --only lint\` runs \`bun lint\` (patterns/typescript/index.md)`
186
+ : ` fix: add a '${u.id}:raw' script holding the tool, then \`shipkit ci --only ${u.id}\` runs it (patterns/rv-conventions/package-json.md)`)
189
187
  }
190
188
  // the run record: one run id for every check of this gate, so a breakdown
191
189
  // of the wall time is reconstructable. It is never read here, only written
@@ -237,7 +235,7 @@ export async function runCi(root: string, o: CiOpts = {}): Promise<number> {
237
235
  })
238
236
  const reg = ledger.layer.registration
239
237
  for (const e of reg.errors) { registrationFailed = true; sink(`FAIL: ${e}`) }
240
- if (registrationFailed) sink(' fix: each check declares one cache that its body can honour: files, reads, ttl, fact or never (build/shipkit/runs.md)')
238
+ if (registrationFailed) sink(' fix: each check declares one cache that its body can honour: files, reads, ttl, fact or never (tools/shipkit/runs.md)')
241
239
  // both counts, always. Printing only the burn-down made `never:` the
242
240
  // cheap way to shrink the visible number, and that field carries no
243
241
  // verification at all: a growing decided population has to be as
@@ -1,9 +1,9 @@
1
1
  // what `shipkit ci` repairs before it gates.
2
2
  //
3
- // mechanical slots only (the import canonicaliser): it rewrites the files the
4
- // agent is already editing and its output is total. structural SK rule fixers
5
- // rewrite repo config, so they stay behind --fix-rules. no formatter runs
6
- // here: formatting is a manual `bun fmt`, never a gate step.
3
+ // mechanical slots (the import canonicaliser) and the structural SK rule
4
+ // repairs. Each output is total and mechanical, so every run applies them, in
5
+ // a tree other agents share too. no formatter runs here: formatting is a
6
+ // manual `bun fmt`, never a gate step.
7
7
  //
8
8
  // under CI the same fixers run in verify mode instead: a gate that silently
9
9
  // rewrites the tree it checks can turn red green with no commit. one
@@ -204,7 +204,7 @@ export type FixPassOpts = {
204
204
  * mutate the tree they are about to ship) */
205
205
  armHooks?: boolean
206
206
  print: (line: string) => void
207
- /** a narrowed pass (`sk ci --only <ids> --fix`): only the repairs these
207
+ /** a narrowed pass (`sk ci --only <ids>`): only the repairs these
208
208
  * ids own, their own ci repair and the fixer slot that governs one of
209
209
  * them */
210
210
  only?: string[]
@@ -235,7 +235,7 @@ export async function runFixPass(root: string, config: RepoConfig, o: FixPassOpt
235
235
  // loser waits rather than skipping, because a skipped repair never
236
236
  // happens; a live holder that outlasts the cap is REFUSED by name rather
237
237
  // than overlapped, and the gate below still runs, unrepaired and saying so.
238
- const lease = await withMutateLease(mutateLease(root, 'fix'), { label: 'fix pass', print: o.print, escape: '--no-fix' }, () => fixPassBody(root, config, o, verify))
238
+ const lease = await withMutateLease(mutateLease(root, 'fix'), { label: 'fix pass', print: o.print }, () => fixPassBody(root, config, o, verify))
239
239
  if (lease.ok) return lease.value
240
240
  // in VERIFY mode the fix pass is the whole check: reporting "not run" and
241
241
  // exiting 0 would pass a commit nobody verified, which is the one failure
@@ -243,7 +243,7 @@ export async function runFixPass(root: string, config: RepoConfig, o: FixPassOpt
243
243
  // checks below still ran and still mean what they say.
244
244
  if (verify) {
245
245
  o.print(`FAIL: fixers never ran — ${lease.warn}`)
246
- o.print(' fix: nothing was verified. re-run once that process finishes, or pass --no-fix to state that on purpose')
246
+ o.print(' fix: nothing was verified. re-run once that process finishes')
247
247
  return { ran: false, touched: [], failed: true, reshaped: false }
248
248
  }
249
249
  o.print(`WARN fix pass skipped — ${lease.warn}`)
@@ -258,7 +258,7 @@ async function fixPassBody(root: string, loaded: RepoConfig, o: FixPassOpts, ver
258
258
  // path: a move is not a decision, so it lands as one machine commit and
259
259
  // only what a machine cannot decide reaches a human. Runs before the tree
260
260
  // snapshot, and before hooks arm, because the hooks folder may be what moves
261
- if (!verify) {
261
+ if (!verify && o.only == null) {
262
262
  const m = migrateLayout(root, { config, renderGitignore: (t, legacy, cfg) => renderPolicy(t, cfg ?? config, legacy) })
263
263
  // the move rewrote repo.config.ts, so the config loaded before it names
264
264
  // folders that are gone, and every fixer below must read the new one
@@ -334,7 +334,7 @@ async function fixPassBody(root: string, loaded: RepoConfig, o: FixPassOpts, ver
334
334
  }
335
335
  putBack(`fix ${s.id} (${s.cmd.join(' ').slice(0, 60)})`)
336
336
  }
337
- // structural repo-config repair is never implicit, and never in verify mode
337
+ // structural repo-config repair: never in verify mode
338
338
  if (o.rules === true && !verify) {
339
339
  await runFix(root, { quiet: true, print: o.print, detail: o.detail, config, ...(o.only == null ? {} : { scope: o.only }) })
340
340
  putBack('the rule repairs')
@@ -15,7 +15,7 @@ export const MATRIX_AXES: readonly MatrixAxis[] = [...RUNS_KEYS, 'fix']
15
15
  /** one axis of the legend: the command or event it is, and every value */
16
16
  export type LegendAxis = { axis: MatrixAxis | 'cache'; short: string; context: string; values: { value: string; means: string }[] }
17
17
 
18
- /** THE legend. Every surface prints it verbatim, and build/shipkit/runs.md is
18
+ /** THE legend. Every surface prints it verbatim, and tools/shipkit/runs.md is
19
19
  * generated from it */
20
20
  export const RUNS_LEGEND: readonly LegendAxis[] = [
21
21
  {
package/src/core/slots.ts CHANGED
@@ -44,6 +44,36 @@ export const poolDir = (): string => {
44
44
  * (a terminal, a button) never takes it, so it never waits behind one */
45
45
  export const autoGatePool = (): SlotPool => ({ dir: `${poolDir()}-auto-gate`, size: 1 })
46
46
 
47
+ /** the headless browsers one repo runs at once (repo.config.ts `browsers.max`, shot/browser-slot.ts): one pool per
48
+ * repo NAME, so its worktrees and checkouts share it */
49
+ export const browserPool = (repo: string, size: number): SlotPool => ({ dir: join(`${poolDir()}-browsers`, repo.replace(/[^\w.-]/g, '_')), size })
50
+
51
+ /** a repo's browser cap when its config names none */
52
+ export const DEFAULT_BROWSERS = 2
53
+
54
+ /** the box's browsers at once when its config names none */
55
+ export const DEFAULT_BOX_BROWSERS = 2
56
+
57
+ /** why a `browsers` config is refused, or null when it holds */
58
+ export function browsersProblem(v: unknown): string | null {
59
+ if (v === undefined) return null
60
+ const whole = (x: unknown) => typeof x === 'number' && Number.isInteger(x) && x >= 1
61
+ if (v === null || typeof v !== 'object' || Array.isArray(v)) return `browsers is an object, { max: <browsers at once>, box?: { host: <ssh host>, max?: <browsers at once there> } }, got ${JSON.stringify(v)}`
62
+ const extra = Object.keys(v).filter((k) => k !== 'max' && k !== 'box')
63
+ if (extra.length > 0) return `browsers has unknown key(s) ${extra.join(', ')}: it takes only max and box`
64
+ const max = (v as { max?: unknown }).max
65
+ if (max !== undefined && !whole(max)) return `browsers.max is a whole number of browsers, 1 or more (default ${DEFAULT_BROWSERS}), got ${JSON.stringify(max)}`
66
+ const box = (v as { box?: unknown }).box
67
+ if (box === undefined) return null
68
+ if (box === null || typeof box !== 'object' || Array.isArray(box)) return `browsers.box is { host: <ssh host>, max?: <browsers at once there> }, like { host: 'wm', max: 5 }, got ${JSON.stringify(box)}`
69
+ const boxExtra = Object.keys(box).filter((k) => k !== 'host' && k !== 'max')
70
+ if (boxExtra.length > 0) return `browsers.box has unknown key(s) ${boxExtra.join(', ')}: it takes only host and max`
71
+ const { host, max: boxMax } = box as { host?: unknown; max?: unknown }
72
+ if (!(typeof host === 'string' && /^[\w.-]+$/.test(host))) return `browsers.box.host is the ssh host whose browser films for this repo, like 'wm', got ${JSON.stringify(host)}`
73
+ if (boxMax !== undefined && !whole(boxMax)) return `browsers.box.max is a whole number of browsers on the box, 1 or more (default ${DEFAULT_BOX_BROWSERS}), got ${JSON.stringify(boxMax)}`
74
+ return null
75
+ }
76
+
47
77
  /** this process's pool, or null when it runs inside a check that holds one */
48
78
  export function machinePool(): SlotPool | null {
49
79
  return process.env[SLOT_HELD_ENV] === '1' ? null : { dir: poolDir(), size: parallelCap(), load: machineLoad }