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
@@ -1,112 +0,0 @@
1
- // SK029 explicit check files (tools/shipkit/runs.md owns the declaration):
2
- // every check file of the repo declares runs, cache, fix and applies, with
3
- // no retired key. A file that does not does not load, and discovery shows
4
- // it as one failing row. The repair ports it with the values the retired
5
- // keys resolved to (core/port-check-file.ts), so the check keeps running
6
- // where it ran, and the ci fix pass applies it before the gate reads the
7
- // files: a repo carried across by its first `shipkit ci`. The same holds for
8
- // the config: a retired `when` (only its `off:<why>` entries still load),
9
- // `ruleExempt`, `hooks.disable` and a `defaults` slot set to false become
10
- // `off` entries in the managed block.
11
- import { join } from 'path'
12
- import { check, type FixResult } from '../check.ts'
13
- import { unportedCheckFiles } from '../core/port-check-files.ts'
14
- import type { PortRun } from '../core/port-check-cli.ts'
15
- import type { ConfigPlan, ConfigRewrite } from '../core/config-rewrite.ts'
16
- import type { RepoConfig } from '../repo-config.ts'
17
- import { legacyOffReason } from '../core/when.ts'
18
-
19
- /** the write half, run as its own process: it walks import closures on disk */
20
- const PORT_CLI = join(import.meta.dir, '../core/port-check-cli.ts')
21
- /** the config half, run as its own process: it loads repo.config.ts */
22
- const CONFIG_REWRITE = join(import.meta.dir, '../core/config-rewrite.ts')
23
-
24
- /** the retired config spellings this repo still carries, and the `off`
25
- * entries they become. defineRepo already refused every `when` word but
26
- * `off:<why>`. `hooks.disable` and a `defaults` slot set to false never said
27
- * why, so they are lifted with the comment above them, else with a reason
28
- * that says none was recorded (core/when.ts legacyOffReason) */
29
- export function retiredOff(c: RepoConfig): { keys: string[]; off: Record<string, string>; lift: NonNullable<ConfigPlan['lift']> } {
30
- const off: Record<string, string> = {}
31
- for (const [id, raw] of Object.entries(c.when ?? {})) off[id] = raw.trim().replace(/^off:?/, '').trim()
32
- for (const [id, why] of Object.entries(c.ruleExempt ?? {})) off[id] ??= why
33
- const lift: NonNullable<ConfigPlan['lift']> = []
34
- const disable = c.hooks?.disable ?? []
35
- if (c.hooks?.disable != null)
36
- lift.push({ parent: 'hooks', entry: 'disable', value: '\\[[^\\]\\[]*\\]', ids: disable, reason: Object.fromEntries(disable.map((id) => [id, legacyOffReason('hooks.disable', id)])) })
37
- const slots = Object.entries(c.defaults ?? {}).filter(([, d]) => d === false).map(([id]) => id)
38
- for (const id of slots) lift.push({ parent: 'defaults', entry: id, value: 'false', ids: [id], reason: { [id]: legacyOffReason('defaults', id) } })
39
- const keys = [
40
- ...(c.when != null ? ['when'] : []),
41
- ...(c.ruleExempt != null ? ['ruleExempt'] : []),
42
- ...(c.hooks?.disable != null ? ['hooks.disable'] : []),
43
- ...slots.map((id) => `defaults.${id}: false`),
44
- ]
45
- return { keys, off, lift }
46
- }
47
-
48
- export const explicitCheckFiles = check({
49
- id: 'SK029',
50
- title: 'explicit check files',
51
- description: 'every check file declares runs, cache, fix and applies, and the config says only off',
52
- owner: 'tools/shipkit/runs.md',
53
- blocking: true,
54
- runs: { onPreCommit: false, onCi: true, onFull: true, onRelease: true, onHealth: true, onSave: 'moved', onClock: false },
55
- // the listing of check files and their sources, read through `c`
56
- cache: { by: 'reads' },
57
- // the port is mechanical: every value it writes is what the retired keys
58
- // resolved to, so the fix pass applies it without asking
59
- fix: 'ci',
60
- applies: 'always',
61
- run: (c) => {
62
- const files = unportedCheckFiles(c)
63
- const cfg = retiredOff(c.config)
64
- if (files.length === 0 && cfg.keys.length === 0) return c.ok('every check file declares runs, cache, fix and applies, and the config says only off')
65
- for (const f of files) c.fail(`${f.rel} still declares the retired shape (${f.keys.join(', ')}), so it does not load`)
66
- if (cfg.keys.length > 0) c.fail(`repo.config.ts still carries ${cfg.keys.join(' and ')}: a repo only turns a check off, as off: { <id>: '<why>' }`)
67
- c.fail(`${files.length + (cfg.keys.length > 0 ? 1 : 0)} file(s) to port`, 'shipkit check --fix SK029 ports each one with the values it ran on, and `shipkit ci` does it in its fix pass')
68
- },
69
- repair: async (c): Promise<FixResult> => {
70
- const files = unportedCheckFiles(c)
71
- const cfg = retiredOff(c.config)
72
- if (files.length === 0 && cfg.keys.length === 0) return { changed: false, summary: 'every check file is explicit already, and the config says only off' }
73
- const did: string[] = []
74
- const hand: string[] = []
75
- if (files.length > 0) {
76
- const r = await c.exec([process.execPath, PORT_CLI, c.root, ...files.map((f) => f.rel)], { cwd: c.root, timeoutMs: 60_000 })
77
- try {
78
- const run = JSON.parse(r.out.trim().split('\n').at(-1) ?? '') as PortRun
79
- if (run.did.length > 0) did.push(`ported ${run.did.join('; ')}`)
80
- hand.push(...run.hand)
81
- } catch {
82
- hand.push(`the port did not answer (exit ${r.code}: ${r.out.trim().slice(0, 160)}): port ${files.map((f) => f.rel).join(', ')} by hand (tools/shipkit/runs.md)`)
83
- }
84
- }
85
- if (cfg.keys.length > 0) {
86
- // `when` sits inside the managed block, so it goes first and the
87
- // block describes the config again before the entries land
88
- const plan: ConfigPlan = {
89
- off: cfg.off,
90
- drop: [
91
- ...(c.config.when != null ? [{ key: 'when', why: 'its off entries are `off` now', phase: 'first' as const }] : []),
92
- ...(c.config.ruleExempt != null ? [{ key: 'ruleExempt', why: 'its exemptions are `off` now', phase: 'afterOff' as const }] : []),
93
- ],
94
- name: c.config.name,
95
- lift: cfg.lift,
96
- }
97
- const r = await c.exec([process.execPath, CONFIG_REWRITE, c.root, JSON.stringify(plan)], { cwd: c.root, timeoutMs: 60_000 })
98
- try {
99
- const out = JSON.parse(r.out.trim().split('\n').at(-1) ?? '') as ConfigRewrite
100
- did.push(...out.did)
101
- hand.push(...out.hand)
102
- if (out.restored != null) hand.push(`repo.config.ts was left as it was: ${out.restored}`)
103
- } catch {
104
- hand.push(`the repo.config.ts rewrite did not answer (exit ${r.code}): write off: ${JSON.stringify({ ...Object.assign({}, ...cfg.lift.map((l) => l.reason)), ...cfg.off })} by hand and drop ${cfg.keys.join(', ')}`)
105
- }
106
- }
107
- const summary = [did.length > 0 ? did.join('; ') : 'nothing ported', ...(hand.length > 0 ? [`${hand.length} by hand: ${hand.join(' | ')}`] : [])].join('. ')
108
- return { changed: did.length > 0, summary }
109
- },
110
- })
111
-
112
- export default explicitCheckFiles
@@ -1,36 +0,0 @@
1
- // SK048 the one local file (tools/shipkit/home.md): where this machine's fold of the media index, the agent time index
2
- // and the daemon's file into the machine db stands (home/machine-fold.ts), said in the house repo only, since it is the machine's and
3
- // not a repo's. It warns, never fails: a walk stopped half way, a store refused as damaged, a file this code does not
4
- // read. The fold off is a state the owner may keep, said in its ok line, as the day, the rows and the copies once folded
5
- import { check } from '../check.ts'
6
-
7
- export const oneLocalFile = check({
8
- id: 'SK048',
9
- blocking: false,
10
- title: 'the one local file',
11
- description: "the media index, the agent time index and the daemon's file are tables of the machine db",
12
- owner: 'tools/shipkit/home.md',
13
- runs: { onPreCommit: false, onCi: false, onFull: true, onRelease: false, onHealth: true, onSave: false, onClock: false },
14
- cache: { by: 'never', why: 'it reads the machine db and two lstats, a few ms, and the machine moves outside git' },
15
- fix: 'none',
16
- applies: (env) => {
17
- // a require at the call: the module reads the house index, never at the load of the checks
18
- const { houseRootOf } = require('../home/home-start.ts') as typeof import('../home/home-start.ts')
19
- return houseRootOf(env.root) === env.root ? null : "the machine's fold is said in the house repo"
20
- },
21
- run: async (c) => {
22
- const { foldWords } = await import('../home/machine-fold.ts')
23
- let words: string[]
24
- try {
25
- words = foldWords()
26
- } catch (e) {
27
- return c.warn(`the machine db does not read, the fold's state is unknown: ${(e as Error).message}`)
28
- }
29
- // off is a state the owner may keep; a walk half way, a damaged file or a file this code does not read is not
30
- const stuck = words.some((w) => /half way|is damaged|shape of before the fold/.test(w))
31
- if (stuck) for (const w of words) c.warn(w)
32
- else c.ok(words.join('; '))
33
- },
34
- })
35
-
36
- export default oneLocalFile
@@ -1,111 +0,0 @@
1
- // THE CONFIG HALF of the SK016 and SK029 migrations, in its own process. Writing the
2
- // managed block and reading the result back both LOAD repo.config.ts as a
3
- // module, which no check context read can stand for, so the fixer reaches it
4
- // through `c.exec` and the check file itself never imports the loader.
5
- //
6
- // bun config-rewrite.ts <root> '<plan json>' → one json line on stdout
7
- //
8
- // The order is the migration's: a key the managed block holds (the retired
9
- // `when`) is dropped first, so the block describes the config again, then the
10
- // `off` entries are written into the block, then each other key is dropped
11
- // only once what leaned on it has a home. The result is read back through the
12
- // loader and the previous bytes go back when it does not survive.
13
- import { readFileSync } from 'fs'
14
- import { join } from 'path'
15
- import { atomicWrite } from './locked-write.ts'
16
- import { dropConfigEntry, dropConfigKey } from './legacy-shapes.ts'
17
- import { writeGateBlock } from './when-block.ts'
18
- import { loadRepoConfig } from '../repo-config.ts'
19
-
20
- export type ConfigPlan = {
21
- /** check id → why it is off, written into the managed block */
22
- off: Record<string, string>
23
- /** keys to drop, in order. `first` drops before the block is written (a
24
- * key inside it), `afterOff` only once the block took the entries */
25
- drop: { key: string; why: string; phase?: 'first' | 'afterOff' }[]
26
- /** the config's `name` before the rewrite: what the read back must still say */
27
- name: string
28
- /** entries of an object key to lift into `off` (`hooks.disable`, a
29
- * `defaults` slot set to false), dropped once the block took them. The
30
- * comment written right above an entry becomes the reason of every id it
31
- * carries, since it is the author's own words; `reason` is the honest
32
- * fallback when there is none */
33
- lift?: { parent: string; entry: string; value: string; ids: string[]; reason: Record<string, string> }[]
34
- }
35
-
36
- export type ConfigRewrite = {
37
- did: string[]
38
- hand: string[]
39
- /** set when the rewrite did not load back and the previous bytes went back */
40
- restored?: string
41
- }
42
-
43
- export async function rewriteConfig(root: string, plan: ConfigPlan): Promise<ConfigRewrite> {
44
- const did: string[] = []
45
- const hand: string[] = []
46
- const path = join(root, 'repo.config.ts')
47
- const before = readFileSync(path, 'utf8')
48
- const drop = (text: string, d: ConfigPlan['drop'][number]): string => {
49
- const next = dropConfigKey(text, d.key)
50
- if (next == null) { hand.push(`repo.config.ts \`${d.key}\`: ${d.why}, and the key could not be read mechanically — delete it by hand`); return text }
51
- did.push(`repo.config.ts drops \`${d.key}\``)
52
- return next
53
- }
54
- let first = before
55
- for (const d of plan.drop.filter((x) => x.phase === 'first')) first = drop(first, d)
56
- if (first !== before) atomicWrite(path, first)
57
- // each lifted entry's reason, read off the text before anything moves
58
- const off = { ...plan.off }
59
- for (const l of plan.lift ?? []) {
60
- const seen = dropConfigEntry(first, l.parent, l.entry, l.value)
61
- for (const id of l.ids) off[id] ??= seen?.comment ?? l.reason[id] ?? ''
62
- }
63
- let offWritten = false
64
- if (Object.keys(off).length > 0) {
65
- try {
66
- await writeGateBlock(root, { off })
67
- offWritten = true
68
- did.push(`${Object.keys(off).length} off entr(ies) written into the managed block`)
69
- } catch (e) {
70
- // a key dropped first held these entries: without the block they
71
- // would be gone, so the file goes back as it was
72
- if (first !== before) { atomicWrite(path, before); return { did: [], hand, restored: `the managed block refused off ${JSON.stringify(off)}: ${String(e).slice(0, 160)}` } }
73
- hand.push(`the managed block refused the rewrite (${String(e).slice(0, 160)}) — write off: ${JSON.stringify(off)} into it by hand`)
74
- }
75
- }
76
- const mid = readFileSync(path, 'utf8')
77
- let text = mid
78
- for (const d of plan.drop.filter((x) => x.phase !== 'first')) {
79
- if (d.phase === 'afterOff' && !offWritten) continue
80
- text = drop(text, d)
81
- }
82
- // a lifted entry goes only once the block holds it, so it is never lost
83
- for (const l of offWritten ? plan.lift ?? [] : []) {
84
- const next = dropConfigEntry(text, l.parent, l.entry, l.value)
85
- if (next == null) { hand.push(`repo.config.ts \`${l.parent}.${l.entry}\` is \`off\` now, and the entry could not be read mechanically — delete it by hand`); continue }
86
- did.push(`repo.config.ts drops \`${l.parent}.${l.entry}\``)
87
- text = next.text
88
- }
89
- if (text !== mid) atomicWrite(path, text)
90
- if (text !== before) {
91
- try {
92
- const after = await loadRepoConfig(root, { fresh: true })
93
- if (after.name !== plan.name) throw new Error(`the config reads as '${String(after.name)}'`)
94
- const lost = Object.keys(off).filter((id) => after.off?.[id] == null)
95
- if (offWritten && lost.length > 0) throw new Error(`the config no longer turns ${lost.join(', ')} off`)
96
- } catch (e) {
97
- atomicWrite(path, before)
98
- return { did, hand, restored: String(e).slice(0, 160) }
99
- }
100
- }
101
- return { did, hand }
102
- }
103
-
104
- if (import.meta.main) {
105
- const [root, plan] = process.argv.slice(2)
106
- if (root == null || plan == null) {
107
- console.error('usage: bun config-rewrite.ts <root> <plan json>')
108
- process.exit(2)
109
- }
110
- console.log(JSON.stringify(await rewriteConfig(root, JSON.parse(plan) as ConfigPlan)))
111
- }
@@ -1,10 +0,0 @@
1
- // the daemon's internal port, apart from home/home-paths.ts so the inbox hook's ask of the daemon (review/hook-ask.ts)
2
- // loads one file: every repo runtime and every api answer here, and the web on the home port is the one door a
3
- // browser uses
4
-
5
- export const DEFAULT_DAEMON_PORT = 4798
6
-
7
- export const daemonPort = (env: Record<string, string | undefined> = process.env): number => {
8
- const port = Number(env.SHIPKIT_DAEMON_PORT)
9
- return Number.isInteger(port) && port > 0 ? port : DEFAULT_DAEMON_PORT
10
- }
@@ -1,263 +0,0 @@
1
- // THE MIGRATION, as code: what a repo still declares in a shape the check
2
- // file replaced, and the mechanical rewrite of each one. Check SK016 reports
3
- // this list and applies these rewrites.
4
- //
5
- // Every shape here is READ through 0.40 and refused at the first release
6
- // after `shipkit fleet` shows no repo below it, so a repo keeps working while
7
- // it carries them and learns what to write instead on every run.
8
- //
9
- // What is mechanical, and what is not, is the whole design of this module. A
10
- // `checkDefaults` value, a `ruleExempt` entry and a task that is DATA are
11
- // rewritten without guessing. A legacy check script, a `rules: []` entry and
12
- // a task whose body is `logic` are not: a script prints and exits in a
13
- // process of its own, which a check file never does (SK020), and a function
14
- // closes over the lexical scope of the file it was written in. Those are
15
- // LISTED by name with what they become, never half rewritten.
16
- //
17
- // It reads ONLY through the check context it is handed, so SK016 is cached
18
- // on the listing of check files and their sources.
19
- import { basename, join, relative, resolve } from 'path'
20
- import { statementEnd } from './statement-end.ts'
21
- import { fallbackNames, isCheckFilePath, readLegacyCheck, type LegacyCheck } from './check-file-names.ts'
22
- import type { ScanCtx } from './check-ctx.ts'
23
- import type { RepoConfig } from '../repo-config.ts'
24
- import { descriptionProblem, type TaskDef } from '../check.ts'
25
- import { deriveExplicit, type Derived } from './port-check-file.ts'
26
-
27
- /** the narrow module every rewritten file imports `check` from, and the ONE
28
- * spelling: the barrel costs 400ms of module load and discovery imports
29
- * every one of these. A repo that INSTALLS the toolkit resolves it through
30
- * node_modules, and a repo that hosts the source resolves the same bare
31
- * specifier through its tsconfig `paths`, which is also what keeps one copy
32
- * of every shared peer reachable. A nested package carrying its own tsconfig
33
- * repeats that one mapping. */
34
- export const CHECK_MODULE = 'rvlib-shipkit/src/check.ts'
35
-
36
- /** the opening and closing lines of a rewritten check file. A repo that
37
- * reaches the toolkit only through the global launcher resolves nothing, so
38
- * it gets the plain object: discovery re-validates it through `check()`
39
- * either way, and an import it cannot resolve takes every check down. */
40
- export function checkWrapper(root: string): { head: string[]; open: string; close: string } {
41
- try {
42
- Bun.resolveSync(CHECK_MODULE, root)
43
- return { head: [`import { check } from '${CHECK_MODULE}'`, ''], open: 'export default check({', close: '})' }
44
- } catch {
45
- return { head: [], open: 'export default {', close: '}' }
46
- }
47
- }
48
-
49
- export type LegacyCheckFile = {
50
- /** repo-relative path of the legacy check script */
51
- rel: string
52
- /** what the static reader read out of it, verbatim */
53
- read: LegacyCheck
54
- }
55
-
56
- export type LegacyTask = {
57
- id: string
58
- /** a task that is pure DATA (`cmd` and its decorations) is rewritten into
59
- * a file. One whose body is `logic` is a function, so it is hand work */
60
- data: boolean
61
- optIn: boolean
62
- }
63
-
64
- export type LegacyShapes = {
65
- checkFiles: LegacyCheckFile[]
66
- /** ids declared through `repo.config.ts rules: []` */
67
- rules: string[]
68
- tasks: LegacyTask[]
69
- /** the repo sets `checkDefaults`, which lets a file forget `blocking` */
70
- checkDefaults: boolean
71
- /** ids exempted through `ruleExempt`, the spelling `when` replaced */
72
- ruleExempt: string[]
73
- /** check files still opening with the TODO description the migration
74
- * wrote. Not a legacy shape, so not in `count`: the file loads and
75
- * runs, and only its author can write the sentence */
76
- placeholders: string[]
77
- /** every shape, counted once */
78
- count: number
79
- }
80
-
81
- /** every check file the repo carries, as discovery would find it, with its
82
- * source. Listed through `c.list`, so it is what git sees: a gitignored
83
- * check file is no declaration of this repo */
84
- export function repoCheckSources(d: Pick<ScanCtx, 'root' | 'list' | 'read'>): { rel: string; abs: string; src: string | null }[] {
85
- return d.list(`**/*.check.ts`)
86
- .filter(isCheckFilePath)
87
- .map((rel) => ({ rel, abs: join(d.root, rel), src: d.read(rel) }))
88
- }
89
-
90
- export function legacyShapes(d: Pick<ScanCtx, 'root' | 'list' | 'read'>, c: RepoConfig): LegacyShapes {
91
- const files = repoCheckSources(d)
92
- const names = fallbackNames(d.root, files.map((f) => f.abs))
93
- const checkFiles: LegacyCheckFile[] = []
94
- for (const f of files) {
95
- const read = f.src == null ? null : readLegacyCheck(f.abs, names.get(f.abs)!, f.src)
96
- if (read != null) checkFiles.push({ rel: f.rel, read })
97
- }
98
- const rules = (c.rules ?? []).map((r) => r.id)
99
- const tasks = (c.tasks ?? []).map((t): LegacyTask => ({ id: t.id, data: t.logic == null && t.cmd != null, optIn: t.optIn === true }))
100
- const ruleExempt = Object.keys(c.ruleExempt ?? {})
101
- const checkDefaults = c.checkDefaults != null
102
- const placeholders = files.filter((f) => f.src?.includes(PLACEHOLDER_MARK) === true).map((f) => f.rel)
103
- return {
104
- placeholders,
105
- checkFiles,
106
- rules,
107
- tasks,
108
- checkDefaults,
109
- ruleExempt,
110
- count: checkFiles.length + rules.length + tasks.length + (checkDefaults ? 1 : 0) + ruleExempt.length,
111
- }
112
- }
113
-
114
- // ── what a check script becomes ──────────────────────────────────────────
115
-
116
- /** a TS string literal, escapes and all */
117
- const q = (s: string): string => `'${s.replace(/\\/g, '\\\\').replace(/'/g, "\\'")}'`
118
-
119
- /** what a check file says when no line was given for it. It passes the shape,
120
- * so the repo keeps running, and it carries the marker SK016 reports, so a
121
- * human writes the line. */
122
- export const descriptionPlaceholder = (): string => `${PLACEHOLDER_MARK}, in one line`
123
-
124
- /** the words every placeholder carries, and what SK016 looks for */
125
- export const PLACEHOLDER_MARK = 'TODO: state what must be true'
126
-
127
- /** the hand port of one check script, named for its author. A script prints
128
- * and exits in a process of its own, and a check file never does (SK020):
129
- * its prints become calls on `c` inside `run`, which only a reader of that
130
- * body can write. The declarations it carries are spelled out so the port
131
- * drops none of them. */
132
- export function scriptPort(read: LegacyCheck, fallbackBlocking: boolean | undefined): string {
133
- const blocking = read.blocking ?? fallbackBlocking
134
- // what the ported `run` body resolves to: the script's own declarations,
135
- // read as the gate read them, on a body keyed on what it reads
136
- const d = explicitOf(deriveExplicit({
137
- when: read.gate ? null : 'health',
138
- build: false,
139
- body: 'run',
140
- ...(read.inputs != null ? { inputs: `[${read.inputs.map(q).join(', ')}]` } : {}),
141
- ...(read.ttl != null ? { ttl: q(read.ttl) } : {}),
142
- ...(read.never != null ? { never: q(read.never) } : {}),
143
- repair: false,
144
- rawAccess: null,
145
- }, q))
146
- const fields = [
147
- blocking == null ? 'blocking: <true | false, it declares none>' : `blocking: ${blocking}`,
148
- `runs: ${d.runs}`,
149
- `cache: ${d.cache}`,
150
- `fix: ${q(d.fix)}`,
151
- `applies: ${d.applies}`,
152
- ]
153
- return `a check script, run as its own process: port it by hand into \`export default check({ description, ${fields.join(', ')}, run: (c) => … })\`, each print a call on c (c.ok, c.warn, c.fail)`
154
- }
155
-
156
- /** a derivation that cannot fail on what a script or a task can declare */
157
- function explicitOf(d: Derived | { error: string }): Derived {
158
- if ('error' in d) throw new Error(`the legacy declaration has no explicit form: ${d.error}`)
159
- return d
160
- }
161
-
162
- /** the check file a task's argv runs through bun, `bun <file>` or `bun run
163
- * <file>`, relative, `./` prefixed or absolute, resolved against the task's
164
- * cwd. `rest` is what the argv passes after the file: a task that passes its
165
- * own arguments asks a different question, so it is never folded. */
166
- export function checkFileRunBy(t: Pick<TaskDef, 'cmd' | 'cwd'>, root: string): { rel: string; rest: string[] } | null {
167
- const cmd = t.cmd
168
- if (cmd == null || cmd.length < 2 || basename(cmd[0]!) !== 'bun') return null
169
- const at = cmd[1] === 'run' ? 2 : 1
170
- const arg = cmd[at]
171
- if (arg == null || !arg.endsWith('.check.ts')) return null
172
- const rel = relative(root, resolve(root, t.cwd ?? '.', arg)).replace(/\\/g, '/')
173
- if (rel.startsWith('..')) return null
174
- return { rel, rest: cmd.slice(at + 1) }
175
- }
176
-
177
- /** a task that is DATA, as its own check file. `build: true` is what a task
178
- * always was: the gate runs it and the health pass leaves it out. */
179
- export function taskCheckSource(t: TaskDef, root: string): string {
180
- const own = t.description != null && descriptionProblem(t.description) == null ? t.description.trim() : null
181
- // where it ran and how it was kept, as the gate and the planner read a
182
- // task: an optIn one ran only by name
183
- const d = explicitOf(deriveExplicit({
184
- when: t.optIn === true ? 'health' : null,
185
- build: true,
186
- body: 'cmd',
187
- ...(t.inputs != null ? { inputs: `[${t.inputs.map(q).join(', ')}]` } : {}),
188
- ...(t.ttl != null ? { ttl: q(t.ttl) } : {}),
189
- ...(t.never != null ? { never: q(t.never) } : {}),
190
- repair: false,
191
- rawAccess: null,
192
- }, q))
193
- const fields = [`id: ${q(t.id)},`, `description: ${q(own ?? descriptionPlaceholder())},`, 'blocking: true,', 'build: true,', `runs: ${d.runs},`, `cache: ${d.cache},`, `fix: ${q(d.fix)},`, `applies: ${d.applies},`, `cmd: [${t.cmd!.map(q).join(', ')}],`]
194
- if (t.deps != null && t.deps.length > 0) fields.push(`deps: [${t.deps.map(q).join(', ')}],`)
195
- if (t.group != null) fields.push(`group: ${q(t.group)},`)
196
- if (t.timeoutMs != null) fields.push(`timeoutMs: ${t.timeoutMs},`)
197
- if (t.env != null) fields.push(`env: { ${Object.entries(t.env).map(([k, v]) => `${q(k)}: ${q(v)}`).join(', ')} },`)
198
- if (t.cwd != null) fields.push(`cwd: ${q(t.cwd)},`)
199
- const w = checkWrapper(root)
200
- return [...w.head, w.open, ...fields.map((f) => ` ${f}`), w.close, ''].join('\n')
201
- }
202
-
203
- /** a file name for a check whose id carries characters a path should not */
204
- export const checkFileName = (id: string): string => `${id.replace(/[^A-Za-z0-9._-]+/g, '-')}.check.ts`
205
-
206
- // ── editing repo.config.ts ───────────────────────────────────────────────
207
-
208
-
209
- /** the config text without one top level key, its trailing comma and the
210
- * comment block written above it. Null when the key is not there, or when it
211
- * appears more than once: a machine that picks one of two is guessing. */
212
- export function dropConfigKey(text: string, key: string): string | null {
213
- const lines = text.split('\n')
214
- const at = lines.map((l, i) => (new RegExp(`^\\s*${key}\\s*:`).test(l) ? i : -1)).filter((i) => i !== -1)
215
- if (at.length !== 1) return null
216
- const start = at[0]!
217
- const end = statementEnd(lines, start)
218
- let from = start
219
- // the comment block above the key goes with it, never a managed block
220
- // marker (`// >>> shipkit …`): the key may be the first line inside one
221
- while (from > 0 && lines[from - 1]!.trim().startsWith('//') && !/^\/\/ (>>>|<<<) shipkit/.test(lines[from - 1]!.trim())) from--
222
- return [...lines.slice(0, from), ...lines.slice(end + 1)].join('\n')
223
- }
224
-
225
- const esc = (s: string): string => s.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')
226
-
227
- /** the config text without one entry of a top level object key, as in
228
- * `disable` inside `hooks` or `lint: false` inside `defaults`, plus the words
229
- * of the comment written right above the entry, which are the closest thing
230
- * to a reason the entry ever had. `value` is the entry's value as a regex
231
- * source, so only the shape the caller expects is touched. The parent goes
232
- * too once nothing is left in it. Null when the parent or the entry is not
233
- * there exactly once, or sits in a shape this reader does not follow */
234
- export function dropConfigEntry(text: string, parent: string, entry: string, value: string): { text: string; comment: string | null } | null {
235
- const lines = text.split('\n')
236
- const at = lines.map((l, i) => (new RegExp(`^\\s*${esc(parent)}\\s*:`).test(l) ? i : -1)).filter((i) => i !== -1)
237
- if (at.length !== 1) return null
238
- const start = at[0]!
239
- const end = statementEnd(lines, start)
240
- const key = `(['"]?)${esc(entry)}\\1\\s*:\\s*(?:${value})`
241
- if (start === end) {
242
- // one line: `hooks: { blockedPaths: [...], disable: ['leak-guard'] },`
243
- const line = lines[start]!
244
- const hits = line.match(new RegExp(`(?<![\\w$])${key}`, 'g')) ?? []
245
- if (hits.length !== 1) return null
246
- let next = line.replace(new RegExp(`,\\s*${key}`), '')
247
- if (next === line) next = line.replace(new RegExp(`(?<![\\w$])${key}\\s*,\\s*`), '')
248
- if (next === line) next = line.replace(new RegExp(`(?<![\\w$])${key}`), '')
249
- const out = [...lines.slice(0, start), next, ...lines.slice(start + 1)].join('\n')
250
- return { text: /:\s*\{\s*\}\s*,?\s*(\/\/.*)?$/.test(next) ? (dropConfigKey(out, parent) ?? out) : out, comment: null }
251
- }
252
- const inner = lines.map((l, i) => (i > start && i <= end && new RegExp(`^\\s*${key}\\s*,?\\s*$`).test(l) ? i : -1)).filter((i) => i !== -1)
253
- if (inner.length !== 1) return null
254
- const i = inner[0]!
255
- let from = i
256
- while (from - 1 > start && lines[from - 1]!.trim().startsWith('//')) from--
257
- const comment = lines.slice(from, i).map((l) => l.trim().replace(/^\/\/\s?/, '')).join(' ').trim()
258
- const kept = [...lines.slice(0, from), ...lines.slice(i + 1)]
259
- const body = kept.slice(start + 1, end - (i - from + 1))
260
- const empty = body.every((l) => l.trim() === '' || l.trim().startsWith('//'))
261
- const out = kept.join('\n')
262
- return { text: empty ? (dropConfigKey(out, parent) ?? out) : out, comment: comment === '' ? null : comment }
263
- }