@joshuafolkken/kit 1.1010.0 → 1.1050.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 (350) hide show
  1. package/.claude/settings.json +1 -5
  2. package/.claude/skills/dependency-update/SKILL.md +6 -3
  3. package/.claude/skills/epic-commands/SKILL.md +46 -17
  4. package/.claude/skills/verify-ui/SKILL.md +1 -1
  5. package/.claude/skills/workflow-commands/SKILL.md +10 -25
  6. package/.claude/skills/workflow-commands/background-commands.md +1 -1
  7. package/.claude/skills/workflow-commands/backlogrun-child.md +6 -4
  8. package/.claude/skills/workflow-commands/backlogrun-lanes.md +1 -1
  9. package/.claude/skills/workflow-commands/backlogrun-park.md +6 -0
  10. package/.claude/skills/workflow-commands/backlogrun-progress.md +30 -36
  11. package/.claude/skills/workflow-commands/backlogrun-steps.md +16 -16
  12. package/.claude/skills/workflow-commands/backlogrun.md +3 -12
  13. package/.claude/skills/workflow-commands/chain-rule.md +2 -2
  14. package/.claude/skills/workflow-commands/followup-reference.md +2 -2
  15. package/.claude/skills/workflow-commands/fullrun-steps.md +4 -3
  16. package/.claude/skills/workflow-commands/fullrun.md +1 -1
  17. package/.claude/skills/workflow-commands/halfrun.md +2 -1
  18. package/.claude/skills/workflow-commands/into-target.md +1 -1
  19. package/.claude/skills/workflow-commands/issue-comments.md +1 -1
  20. package/.claude/skills/workflow-commands/observation-filing.md +80 -126
  21. package/.claude/skills/workflow-commands/pre-gate-cut.md +33 -36
  22. package/.claude/skills/workflow-commands/prerequisite.md +1 -1
  23. package/.claude/skills/workflow-commands/working-tree-hold.md +2 -2
  24. package/.codex/hooks.json +1 -5
  25. package/.github/workflows/auto-tag.yml +21 -0
  26. package/.github/workflows/publish.yml +9 -10
  27. package/.github/workflows/sonar-qube.yml +1 -1
  28. package/AGENTS.md +4 -25
  29. package/CLAUDE.md +24 -38
  30. package/GEMINI.md +4 -24
  31. package/README.md +22 -56
  32. package/dist/CLAUDE.md +24 -38
  33. package/dist/hooks/batch-guard.js +4 -4
  34. package/dist/hooks/{chunk-6PSTVOLH.js → chunk-5BK3K7V4.js} +114 -90
  35. package/dist/hooks/{chunk-PAXMLGSS.js → chunk-7VPDUBRN.js} +93 -175
  36. package/dist/hooks/{chunk-KPZN42RT.js → chunk-DMQN45FN.js} +3 -3
  37. package/dist/hooks/{chunk-WMIR5SNX.js → chunk-EJDX2TOB.js} +13 -3
  38. package/dist/hooks/{chunk-A2H5I2VD.js → chunk-GQ7KP45M.js} +2 -2
  39. package/dist/hooks/{chunk-4GDR2YTV.js → chunk-HJIISEAC.js} +4 -4
  40. package/dist/hooks/{chunk-AWTFKKFW.js → chunk-NAS4C7GP.js} +6 -33
  41. package/dist/hooks/{chunk-56LGMJJV.js → chunk-NJQOBE6L.js} +2 -2
  42. package/dist/hooks/{chunk-EZLHXKJ6.js → chunk-RLDX5SOC.js} +1222 -941
  43. package/dist/hooks/{chunk-GBJUERYK.js → chunk-WQ4OSBSS.js} +10 -3
  44. package/dist/hooks/codex-hook-adapter.js +10 -10
  45. package/dist/hooks/duplicate-read-guard.js +5 -5
  46. package/dist/hooks/format-edited.js +15 -34
  47. package/dist/hooks/investigation-guard.js +5 -5
  48. package/dist/hooks/pretool-guard.js +23 -16
  49. package/dist/hooks/stop-guard.js +21 -200
  50. package/dist/josh.js +42 -125
  51. package/dist/version/index.js +466 -42
  52. package/eslint/base.js +2 -11
  53. package/package.json +36 -10
  54. package/prompts/coding-standards.md +15 -290
  55. package/prompts/collaboration-workflow/cross-repo-epic.md +2 -51
  56. package/prompts/collaboration-workflow/epic-audit.md +2 -53
  57. package/prompts/collaboration-workflow/epic-bundle.md +2 -106
  58. package/prompts/collaboration-workflow/file-edits.md +6 -53
  59. package/prompts/collaboration-workflow/issue-template.md +4 -4
  60. package/prompts/collaboration-workflow/operating-rules.md +18 -75
  61. package/prompts/collaboration-workflow/principles.md +74 -0
  62. package/prompts/collaboration-workflow/residency.md +55 -15
  63. package/prompts/collaboration-workflow/rule-delivery.md +5 -46
  64. package/prompts/collaboration-workflow/shell-body.md +7 -9
  65. package/prompts/collaboration-workflow/turn-batching.md +21 -37
  66. package/prompts/collaboration-workflow/upstream-interrupt.md +1 -1
  67. package/prompts/collaboration-workflow/wip-cap.md +15 -18
  68. package/prompts/collaboration-workflow.md +22 -28
  69. package/prompts/sonar-hotspot-handling.md +1 -1
  70. package/scripts/adopt/adopt-logic.ts +2 -2
  71. package/scripts/adopt/adopt-toolkits.ts +3 -1
  72. package/scripts/adopt/adopt.ts +2 -2
  73. package/scripts/agent/agent-event.ts +2 -9
  74. package/scripts/agent/agent-exit-record.ts +2 -9
  75. package/scripts/auto-ok/auto-ok-cli.ts +9 -9
  76. package/scripts/backlog/backlog-budget-cli.ts +2 -6
  77. package/scripts/backlog/backlog-drive-cli.ts +20 -10
  78. package/scripts/backlog/backlog-drive.ts +50 -16
  79. package/scripts/backlog/backlog-next.ts +24 -8
  80. package/scripts/backlog/backlog-offer-cli.ts +6 -5
  81. package/scripts/backlog/backlog-plan-cli.ts +5 -1
  82. package/scripts/backlog/backlog-plan.ts +1 -1
  83. package/scripts/backlog/backlog-pool.ts +31 -11
  84. package/scripts/backlog/backlog-rank.ts +106 -0
  85. package/scripts/backlog/backlog-waves.ts +42 -29
  86. package/scripts/build/build-bin.ts +2 -1
  87. package/scripts/build/build-config-merge.ts +2 -1
  88. package/scripts/build/build-hooks.ts +31 -6
  89. package/scripts/build/build-managed-marker.ts +2 -1
  90. package/scripts/build/build-self-sync-guard.ts +2 -1
  91. package/scripts/build/build-version.ts +2 -1
  92. package/scripts/cases/cases-logic.ts +2 -6
  93. package/scripts/ci/pr-classification.ts +13 -11
  94. package/scripts/cost-runtime/cost-transcript.ts +4 -11
  95. package/scripts/delegation/delegation-policy.ts +11 -0
  96. package/scripts/doctor/doctor-consumer.ts +5 -12
  97. package/scripts/doctor/doctor-ports.ts +2 -2
  98. package/scripts/document/document-byte-budget.ts +13 -21
  99. package/scripts/document/document-section.ts +2 -6
  100. package/scripts/document/entry-read-budget.ts +6 -5
  101. package/scripts/{git/git-epic-add-body.ts → epic/epic-add-body.ts} +23 -23
  102. package/scripts/{git/git-epic-add-plan.ts → epic/epic-add-plan.ts} +23 -26
  103. package/scripts/{git/git-epic-add.ts → epic/epic-add.ts} +17 -17
  104. package/scripts/epic/epic-audit-cli.ts +4 -4
  105. package/scripts/epic/epic-audit-orphans.ts +2 -2
  106. package/scripts/epic/epic-audit-rationale.ts +1 -1
  107. package/scripts/epic/epic-audit.ts +1 -1
  108. package/scripts/{git/git-epic-body.ts → epic/epic-body.ts} +6 -6
  109. package/scripts/epic/epic-bundle-cli.ts +1 -1
  110. package/scripts/epic/epic-bundle.ts +2 -2
  111. package/scripts/epic/epic-candidate-confirm.ts +2 -1
  112. package/scripts/{git/git-epic-chains.ts → epic/epic-chains.ts} +4 -4
  113. package/{scripts-ai → scripts/epic}/epic-check.ts +5 -4
  114. package/{scripts-ai → scripts/epic}/epic-cli.ts +4 -4
  115. package/scripts/{git/git-epic-close-comment.ts → epic/epic-close-comment.ts} +9 -9
  116. package/scripts/{git/git-epic-close.ts → epic/epic-close.ts} +23 -19
  117. package/scripts/epic/epic-cross-repo.ts +21 -38
  118. package/scripts/{git/git-epic-decision.ts → epic/epic-decision.ts} +12 -14
  119. package/scripts/epic/epic-fetch.ts +3 -3
  120. package/scripts/epic/epic-graph.ts +3 -3
  121. package/scripts/epic/epic-index.ts +2 -2
  122. package/scripts/epic/epic-issue.ts +1 -1
  123. package/scripts/epic/epic-lane-offer.ts +11 -22
  124. package/scripts/epic/epic-next.ts +3 -3
  125. package/scripts/{git/git-epic-parse.ts → epic/epic-parse.ts} +3 -3
  126. package/scripts/{git/git-epic-promote.ts → epic/epic-promote.ts} +10 -10
  127. package/scripts/epic/epic-rank.ts +37 -0
  128. package/scripts/{git/git-epic-read.ts → epic/epic-read.ts} +9 -9
  129. package/scripts/{git/git-epic-reconcile.ts → epic/epic-reconcile.ts} +18 -20
  130. package/scripts/{git/git-epic-reference.ts → epic/epic-reference.ts} +4 -23
  131. package/scripts/epic/epic-relation-recheck.ts +4 -3
  132. package/scripts/{git/git-epic-relations.ts → epic/epic-relations.ts} +5 -5
  133. package/scripts/{git/git-epic-remove-plan.ts → epic/epic-remove-plan.ts} +17 -19
  134. package/scripts/{git/git-epic-remove.ts → epic/epic-remove.ts} +13 -13
  135. package/scripts/{git/git-epic-run.ts → epic/epic-run.ts} +27 -27
  136. package/scripts/{git/git-epic-sections.ts → epic/epic-sections.ts} +6 -6
  137. package/scripts/{git/git-epic-shape.ts → epic/epic-shape.ts} +7 -7
  138. package/scripts/epic/epic-solo.ts +29 -28
  139. package/scripts/{git/git-epic-validate.ts → epic/epic-validate.ts} +13 -13
  140. package/{scripts-ai → scripts/epic}/epic.ts +17 -16
  141. package/scripts/gh/fix-gh-packages.ts +2 -1
  142. package/scripts/gh/gh-spawn.ts +12 -10
  143. package/scripts/git/constants.ts +1 -1
  144. package/scripts/git/git-branch.ts +10 -1
  145. package/scripts/git/git-command.ts +2 -2
  146. package/scripts/git/git-error.ts +2 -5
  147. package/scripts/git/git-execa-error.ts +6 -1
  148. package/{scripts-ai → scripts/git}/git-followup-finish.ts +7 -7
  149. package/scripts/git/git-followup-flush.ts +74 -48
  150. package/scripts/git/git-followup-issue-close.ts +2 -2
  151. package/scripts/git/git-followup-label.ts +1 -1
  152. package/scripts/git/git-followup-pending.ts +1 -1
  153. package/{scripts-ai → scripts/git}/git-followup-workflow.ts +23 -11
  154. package/scripts/git/git-gh-exec.ts +85 -26
  155. package/scripts/git/git-gh-issue-read.ts +2 -2
  156. package/scripts/git/git-gh-issue-rest.ts +2 -2
  157. package/scripts/git/git-gh-issue-write.ts +6 -6
  158. package/scripts/git/git-gh-pr-read.ts +0 -21
  159. package/scripts/git/git-gh-pr.ts +2 -23
  160. package/scripts/git/git-next-issues.ts +34 -5
  161. package/scripts/git/git-pr-followup-wrapup.ts +2 -6
  162. package/scripts/git/git-preflight.ts +25 -10
  163. package/scripts/git/git-push-transport.ts +12 -69
  164. package/scripts/git/git-spawn.ts +79 -3
  165. package/scripts/git/git-ssh-keepalive.ts +74 -0
  166. package/scripts/git/git-staging.ts +21 -9
  167. package/{scripts-ai → scripts/git}/git-workflow.ts +11 -11
  168. package/scripts/git/github-issue-url.ts +1 -1
  169. package/scripts/git/gone-branch.ts +3 -2
  170. package/scripts/git/issue-labels.ts +13 -1
  171. package/scripts/git/issue-rank.ts +89 -0
  172. package/scripts/git/issue-reference.ts +19 -0
  173. package/scripts/git/main-merge.ts +2 -1
  174. package/scripts/git/main-sync.ts +3 -2
  175. package/scripts/git/schemas.ts +1 -1
  176. package/scripts/git/stash-pop-args.ts +7 -13
  177. package/scripts/git/stash-pop-cli.ts +2 -1
  178. package/{scripts-ai → scripts/git}/telegram-test-logic.ts +2 -2
  179. package/{scripts-ai → scripts/git}/telegram-test.ts +7 -7
  180. package/scripts/hooks/format-edited-cli.ts +15 -0
  181. package/scripts/hooks/format-edited-file.ts +2 -9
  182. package/scripts/hooks/format-rewrite-notice.ts +2 -8
  183. package/scripts/hooks/pretool-guard-cli.ts +21 -0
  184. package/scripts/hooks/pretool-guard.ts +14 -15
  185. package/scripts/init/init-ai-copy.ts +2 -5
  186. package/scripts/init/init.ts +8 -4
  187. package/scripts/init/start-exec.ts +7 -1
  188. package/scripts/init/start-plan.ts +18 -5
  189. package/scripts/init/start-setup-pr.ts +46 -19
  190. package/scripts/init/start-steps.ts +43 -10
  191. package/scripts/init/start.ts +42 -11
  192. package/scripts/issue/issue-cite.ts +19 -1
  193. package/scripts/issue/issue-comment-cli.ts +2 -1
  194. package/scripts/issue/issue-file-cli.ts +2 -1
  195. package/scripts/issue/issue-fold-cli.ts +9 -16
  196. package/scripts/issue/issue-scout-cli.ts +8 -13
  197. package/scripts/issue/measure-rerun-cli.ts +7 -6
  198. package/scripts/josh/josh-command-map.ts +0 -102
  199. package/scripts/josh/josh-commands-ai.ts +2 -2
  200. package/scripts/josh/josh-commands-backlog.ts +1 -1
  201. package/scripts/josh/josh-commands-development.ts +3 -3
  202. package/scripts/josh/josh-commands-project.ts +1 -1
  203. package/scripts/josh/josh-commands-workflow.ts +4 -4
  204. package/scripts/lane/lane-child-marker.ts +16 -2
  205. package/scripts/lane/lane-cli.ts +34 -15
  206. package/scripts/lane/lane-open.ts +3 -2
  207. package/scripts/lane/lane-registry.ts +3 -6
  208. package/scripts/lane/lane-report.ts +10 -4
  209. package/scripts/lib/cli-flags.ts +20 -2
  210. package/scripts/lib/error-message.ts +9 -0
  211. package/scripts/lib/read-file.ts +26 -2
  212. package/scripts/observations/observation-ledger-home.ts +98 -26
  213. package/scripts/observations/observation-ledger-migrate.ts +26 -21
  214. package/scripts/observations/observation-ledger-prepare.ts +10 -20
  215. package/scripts/observations/observation-ledger.ts +58 -25
  216. package/scripts/observations/observations-flush-cli.ts +6 -23
  217. package/scripts/observations/observations-flush-landing.ts +2 -1
  218. package/scripts/observations/observations-flush.ts +29 -20
  219. package/scripts/package/package-scout-cli.ts +8 -16
  220. package/scripts/ports/port-command.ts +2 -1
  221. package/scripts/propagate/propagate-plan.ts +185 -0
  222. package/scripts/propagate/propagate-publish.ts +6 -7
  223. package/scripts/propagate/propagate-run.ts +5 -1
  224. package/scripts/propagate/propagate-steps.ts +18 -2
  225. package/scripts/propagate/propagate-targets.ts +13 -2
  226. package/scripts/propagate/propagate.ts +63 -44
  227. package/scripts/refactor/import-graph.ts +2 -6
  228. package/scripts/registry-migration/migrate-logic.ts +1 -0
  229. package/scripts/registry-migration/migrate.ts +3 -2
  230. package/scripts/registry-migration/user-npmrc.ts +2 -2
  231. package/scripts/release/github-release.ts +1 -1
  232. package/scripts/release/release-cli.ts +2 -1
  233. package/scripts/repo/repo-setting.ts +10 -8
  234. package/scripts/review/review-attest.ts +44 -0
  235. package/scripts/review/review-brief-cli.ts +49 -2
  236. package/scripts/review/review-brief.ts +46 -1
  237. package/scripts/review/review-finding-ledger.ts +3 -3
  238. package/scripts/review/review-findings-cli.ts +4 -11
  239. package/scripts/review/review-record-cli.ts +14 -11
  240. package/scripts/review/review-record.ts +6 -16
  241. package/scripts/review/review-stamps.ts +7 -0
  242. package/scripts/rules/decision-oracle.ts +2 -2
  243. package/scripts/rules/implementation-cut.ts +1 -1
  244. package/scripts/rules/issue-fold.ts +1 -2
  245. package/scripts/rules/lane-carry-conflict.ts +1 -2
  246. package/scripts/rules/lane-park.ts +1 -2
  247. package/scripts/rules/pre-gate-cut.ts +2 -2
  248. package/scripts/rules/rule-body-guard.ts +2 -2
  249. package/scripts/rules/rule-value-cache.ts +99 -0
  250. package/scripts/rules/rule-value-cli.ts +10 -9
  251. package/scripts/rules/rule-value.ts +1 -1
  252. package/scripts/run/run-carry-args.ts +2 -6
  253. package/scripts/run/run-carry-cli.ts +5 -7
  254. package/scripts/run/run-cut-args.ts +7 -13
  255. package/scripts/run/run-ending-cli.ts +4 -7
  256. package/scripts/run/run-event-stream.ts +2 -5
  257. package/scripts/run/run-headless.ts +22 -6
  258. package/scripts/run/run-liveness-cli.ts +4 -7
  259. package/scripts/run/run-parent-cut-hook.ts +144 -0
  260. package/scripts/run/run-progress-args.ts +2 -6
  261. package/scripts/run/run-progress-cli.ts +2 -1
  262. package/scripts/run/run-progress-read.ts +2 -1
  263. package/scripts/run/run-progress.ts +21 -8
  264. package/scripts/run/run-ship-cli.ts +6 -74
  265. package/scripts/run/run-ship-preflight.ts +87 -0
  266. package/scripts/run/run-ship-review-steps.ts +5 -26
  267. package/scripts/run/run-ship-review.ts +9 -0
  268. package/scripts/run/run-ship-scoped.ts +44 -0
  269. package/scripts/run/run-ship-stage.ts +5 -1
  270. package/scripts/run/run-ship-steps.ts +105 -0
  271. package/scripts/run/run-ship.ts +2 -0
  272. package/scripts/run/run-tail-cli.ts +3 -3
  273. package/scripts/run/run-tidy-stashes.ts +7 -14
  274. package/scripts/run/run-wake-cli.ts +4 -8
  275. package/scripts/run/run-wake-describe.ts +19 -1
  276. package/scripts/run/run-wake-driver.ts +15 -2
  277. package/scripts/run/run-wake-session.ts +14 -4
  278. package/scripts/run/run-watcher-hook.ts +1 -1
  279. package/scripts/safe-chain/project-config.ts +3 -6
  280. package/scripts/security/security-audit-provision.ts +6 -7
  281. package/scripts/sonar/sonar-hotspots-cli.ts +2 -1
  282. package/scripts/sync/directory-copy-guard.ts +2 -1
  283. package/scripts/sync/sync-ai-files.ts +3 -3
  284. package/scripts/sync/template-source-logic.ts +3 -4
  285. package/scripts/test/e2e-retry-check.ts +3 -6
  286. package/scripts/time-runtime/time-bundle-call.ts +2 -2
  287. package/scripts/ui/ui-routes-cli.ts +3 -6
  288. package/scripts/version/bump-version.ts +2 -1
  289. package/scripts/version/npm-registry.ts +97 -0
  290. package/scripts/version/version-commands.ts +5 -4
  291. package/scripts/version/version-remote.ts +38 -33
  292. package/scripts/version/version-targets.ts +3 -3
  293. package/.claude/skills/workflow-commands/rule-residency.md +0 -267
  294. package/evals/scenarios/consult-not-execute.json +0 -20
  295. package/evals/scenarios/no-implicit-workflow.json +0 -26
  296. package/evals/scenarios/overrides-both-locations.json +0 -29
  297. package/evals/scenarios/upstream-interrupt.json +0 -23
  298. package/evals/scenarios/workflow-skill-loaded.json +0 -16
  299. package/prompts/agent-lint-protocol.json +0 -79
  300. package/prompts/agent-rules.md +0 -63
  301. package/prompts/collaboration-workflow/consultation-vs-execution.md +0 -8
  302. package/prompts/collaboration-workflow/distributed-docs.md +0 -7
  303. package/prompts/collaboration-workflow/durable-rules.md +0 -24
  304. package/prompts/collaboration-workflow/latest-first.md +0 -14
  305. package/prompts/collaboration-workflow/no-clones.md +0 -11
  306. package/prompts/collaboration-workflow/simplicity-first.md +0 -9
  307. package/prompts/collaboration-workflow/single-source-rules.md +0 -13
  308. package/scripts/build/shim-shell.ts +0 -25
  309. package/scripts/claude/skill-meta.ts +0 -37
  310. package/scripts/document/document-scan.ts +0 -108
  311. package/scripts/document/generate-catalog.ts +0 -69
  312. package/scripts/document/retired-phrases.ts +0 -143
  313. package/scripts/document/review-agent-type.ts +0 -46
  314. package/scripts/document/single-source.ts +0 -73
  315. package/scripts/git/git-fixture-workspace.ts +0 -88
  316. package/scripts/hooks/format-edited-file-fixtures.ts +0 -109
  317. package/scripts/hooks/prompt-hooks.ts +0 -38
  318. package/scripts/init/hook-command-bootstrap.ts +0 -83
  319. package/scripts/issue/issue-logic.ts +0 -50
  320. package/scripts/josh/__snapshots__/josh-command-map.test.ts.snap +0 -1227
  321. package/scripts/josh/josh-script-reader.ts +0 -11
  322. package/scripts/package/production-dependency-graph.ts +0 -68
  323. package/scripts/retrospective/retrospective-cli.ts +0 -97
  324. package/scripts/retrospective/retrospective.ts +0 -127
  325. package/scripts/rules/delivered-rules-harness.ts +0 -72
  326. package/scripts/rules/top-level-scripts-guard.ts +0 -47
  327. package/scripts/run/run-carry-flush.ts +0 -58
  328. package/scripts/run/run-transcript.golden.txt +0 -57
  329. package/scripts/run/run-wake-work.ts +0 -108
  330. package/scripts/sync/dependabot-pin-logic.ts +0 -135
  331. package/scripts/test/classify-isolation.ts +0 -149
  332. package/scripts/test/http-fault-injection.ts +0 -79
  333. package/scripts/test/josh-harness-environment.ts +0 -260
  334. package/scripts/test/josh-harness.ts +0 -96
  335. package/scripts/test/pilot-files.ts +0 -452
  336. package/scripts/test/pilot-measure.ts +0 -78
  337. package/scripts/test/test-network-guard.ts +0 -453
  338. package/scripts/test/test-repository-guard.ts +0 -317
  339. package/scripts/test/test-state-guard.ts +0 -85
  340. package/scripts/test/test-stdout-guard.ts +0 -54
  341. package/scripts/test/test-telegram-guard.ts +0 -90
  342. package/scripts/test/unit-guard-environment.ts +0 -12
  343. package/scripts/test/unit-projects.ts +0 -139
  344. package/scripts/test/vitest-include-globs.ts +0 -12
  345. package/scripts/time-runtime/time-batch-guard-fixtures.ts +0 -66
  346. package/scripts-ai/completion-gate.ts +0 -13
  347. package/scripts-ai/environment-loader.ts +0 -9
  348. /package/{scripts-ai → scripts/epic}/epic-cli-argv.ts +0 -0
  349. /package/{scripts-ai → scripts/epic}/epic-cli-remove.ts +0 -0
  350. /package/{scripts-ai → scripts/git}/followup-issue-number.ts +0 -0
@@ -9,13 +9,13 @@ import { epic_next } from '#scripts/epic/epic-next'
9
9
  import { epic_next_read, type EpicRead } from '#scripts/epic/epic-next-read'
10
10
  import type { EpicView } from '#scripts/epic/epic-next-views'
11
11
  import { epic_report, type EpicNextResult, type EpicVerdict } from '#scripts/epic/epic-report'
12
- import { epic_solo } from '#scripts/epic/epic-solo'
13
12
  import { epic_triage, type TriageVerdict } from '#scripts/epic/epic-triage'
14
13
  import { git_gh_command } from '#scripts/git/git-gh-command'
15
14
  import { PROJECT_ROOT } from '#scripts/init/init-paths'
16
15
  import { issue_citation } from '#scripts/rules/issue-citation'
17
16
  import { backlog_defect_priority } from './backlog-defect-priority'
18
17
  import { backlog_pool } from './backlog-pool'
18
+ import { backlog_rank } from './backlog-rank'
19
19
 
20
20
  // `josh backlog:next` — what the whole opted-in backlog may run next (joshuafolkken/kit#1630).
21
21
  //
@@ -235,12 +235,15 @@ async function resolve(context: PoolContext): Promise<EpicNextResult | undefined
235
235
  return undefined
236
236
  }
237
237
 
238
- // The defect priority is applied here rather than when printing, so `backlog:plan` shows the order
239
- // the run takes (joshuafolkken/kit#2455).
240
- return await backlog_defect_priority.prioritize(
238
+ // The defect priority and the ranking keys are applied here rather than when printing, so
239
+ // `backlog:plan` shows the order the run takes (joshuafolkken/kit#2455, joshuafolkken/kit#2928). The
240
+ // ranking goes last: its sort is stable, so the defect order survives as its final key.
241
+ const ordered = await backlog_defect_priority.prioritize(
241
242
  combine(views_from(reads, context), context),
242
243
  context.repo,
243
244
  )
245
+
246
+ return backlog_rank.rank_result(ordered, context.repo)
244
247
  }
245
248
 
246
249
  // Whether the `error` verdict is really a transport failure wearing the graph's clothes.
@@ -274,13 +277,25 @@ function report_retry(context: PoolContext): number {
274
277
  return SUCCESS_EXIT_CODE
275
278
  }
276
279
 
280
+ // The rows the offer's cap bounds — the standalone half, which `backlog:plan --waves` reads too.
281
+ function standalone_keys(context: PoolContext): ReadonlySet<string> {
282
+ return backlog_pool.standalone_keys(context.opted_in.issues, {
283
+ tracked: epic_index.withheld_children(context.tracking.index, context.opted_in.issues),
284
+ exclude: context.exclude,
285
+ repo: context.repo,
286
+ })
287
+ }
288
+
277
289
  // The `run:solo` gate is applied here rather than in `resolve`, because `backlog:plan` shares
278
290
  // `resolve` and a plan made before the run lists everything (joshuafolkken/kit#2776). The holders are
279
- // read only on a `run` answer — the one answer the gate can change.
280
- async function gate_solo(result: EpicNextResult, repo: string): Promise<EpicNextResult> {
291
+ // read only on a `run` answer — the one answer the gate can change. The cap follows the gate
292
+ // (`backlog-rank.ts`, joshuafolkken/kit#2928).
293
+ async function gate_solo(result: EpicNextResult, context: PoolContext): Promise<EpicNextResult> {
281
294
  if (result.verdict !== 'run') return result
282
295
 
283
- const gated = epic_solo.gate(result, await epic_busy.read_repository(repo), repo)
296
+ const { repo } = context
297
+ const read = await epic_busy.read_repository(repo)
298
+ const gated = backlog_rank.gate(result, read, repo, standalone_keys(context))
284
299
 
285
300
  if (gated.notice !== undefined) console.error(gated.notice)
286
301
 
@@ -314,7 +329,7 @@ async function answer_pool(context: PoolContext): Promise<number> {
314
329
 
315
330
  if (untriaged.length > 0) return report_triage(context, untriaged)
316
331
 
317
- return report(await gate_solo(result, context.repo), context)
332
+ return report(await gate_solo(result, context), context)
318
333
  }
319
334
 
320
335
  // A backlog nobody has opted into answers `none` before either listing below is asked for.
@@ -402,6 +417,7 @@ const backlog_next = {
402
417
  combine,
403
418
  views_from,
404
419
  resolve,
420
+ standalone_keys,
405
421
  is_transport_failure,
406
422
  report_retry,
407
423
  report_triage,
@@ -2,7 +2,7 @@
2
2
  import { fileURLToPath } from 'node:url'
3
3
  import { parseArgs } from 'node:util'
4
4
  import { josh_command } from '#scripts/josh/josh-run'
5
- import { rule_value_cli } from '#scripts/rules/rule-value-cli'
5
+ import { rule_value_cache } from '#scripts/rules/rule-value-cache'
6
6
  import { run_event_stream } from '#scripts/run/run-event-stream'
7
7
  import { run_event_stream_emit } from '#scripts/run/run-event-stream-emit'
8
8
  import { z } from 'zod'
@@ -242,11 +242,12 @@ async function run(argv: ReadonlyArray<string>): Promise<number> {
242
242
 
243
243
  if (values === undefined) return refuse()
244
244
 
245
- // The loop head is the one place `rule:value` is called from: once per iteration, the parent's
245
+ // The loop head is the one place `rule:value` is read from: once per iteration, the parent's
246
246
  // context still small, so a rule that never fires shows up as a printed row rather than as
247
- // something a person has to remember to measure (joshuafolkken/kit#2271). It reports to stderr and
248
- // never fails, so a broken reading never stops the backlog.
249
- rule_value_cli.emit()
247
+ // something a person has to remember to measure (joshuafolkken/kit#2271). It prints the cached
248
+ // reading and refreshes it in a detached process, so the offer never waits on the measurement
249
+ // (joshuafolkken/kit#2881), and it never fails, so a broken reading never stops the backlog.
250
+ rule_value_cache.emit()
250
251
 
251
252
  const counts = counts_of(values)
252
253
 
@@ -104,6 +104,9 @@ interface Plan {
104
104
  // past the listing cap. Carrying the *whole* index here instead would move that misreport rather
105
105
  // than remove it: the sentence would name an epic that is withholding nothing.
106
106
  tracked: ReadonlyMap<number, number>
107
+ // The rows the offer's cap bounds, so `--waves` cuts each wave where `backlog:next` does
108
+ // (joshuafolkken/kit#2928).
109
+ standalone: ReadonlySet<string>
107
110
  }
108
111
 
109
112
  // The listing plus whether it was cut. Carried together because the rows alone cannot say whether
@@ -138,6 +141,7 @@ async function classify(
138
141
  repo: context.repo,
139
142
  exclude,
140
143
  tracked: epic_index.withheld_children(context.tracking.index, context.opted_in.issues),
144
+ standalone: backlog_next.standalone_keys(context),
141
145
  }
142
146
  }
143
147
 
@@ -168,7 +172,7 @@ function print_plan(plan: Plan, listing: OpenListing, view: PlanView): void {
168
172
  const context = context_of(plan, listing)
169
173
 
170
174
  if (view.is_waves) {
171
- console.info(backlog_waves.format_waves(plan.result, context))
175
+ console.info(backlog_waves.format_waves(plan.result, context, plan.standalone))
172
176
 
173
177
  return
174
178
  }
@@ -1,8 +1,8 @@
1
1
  import type { EpicChild } from '#scripts/epic/epic-graph'
2
+ import type { IssueReference } from '#scripts/epic/epic-reference'
2
3
  import { epic_report, type EpicNextResult } from '#scripts/epic/epic-report'
3
4
  import { epic_solo } from '#scripts/epic/epic-solo'
4
5
  import { epic_triage } from '#scripts/epic/epic-triage'
5
- import type { IssueReference } from '#scripts/git/git-epic-reference'
6
6
  import { has_label_name, IN_PROGRESS_LABEL, RUN_SOLO_LABEL } from '#scripts/git/issue-labels'
7
7
  import type { OutOfScopeRow } from './backlog-scope'
8
8
 
@@ -37,6 +37,9 @@ const DECISION_LABELS: ReadonlySet<string> = new Set([NEEDS_DECISION_LABEL, ALRE
37
37
  // `tracked` is the narrowed set `epic_index.withheld_children` builds, not every child an epic
38
38
  // tracks (joshuafolkken/kit#1668) — the narrowing itself is defined there, once, for this half and
39
39
  // `auto-ok:next` alike.
40
+ // The part of the context that decides which rows the standalone half considers at all.
41
+ type ConsideredContext = Pick<StandaloneContext, 'tracked' | 'exclude' | 'repo'>
42
+
40
43
  interface StandaloneContext {
41
44
  tracked: ReadonlyMap<number, number>
42
45
  exclude: ReadonlyArray<number>
@@ -135,26 +138,28 @@ function standalone_rows(issues: ReadonlyArray<OpenIssueData>): ReadonlyArray<Op
135
138
  // are actually going to offer their children and applied here for the same reason. Which rows those
136
139
  // are is `epic_index.withheld_children`'s answer, not a second test made here. A row the caller
137
140
  // excluded is out of the pool entirely rather than merely unoffered: it has just merged.
138
- function is_considered(issue: OpenIssueData, context: StandaloneContext): boolean {
141
+ function is_considered(issue: OpenIssueData, context: ConsideredContext): boolean {
139
142
  return !context.tracked.has(issue.number) && !context.exclude.includes(issue.number)
140
143
  }
141
144
 
142
145
  // The standalone half, in the buckets the verdict is read from.
143
146
  //
144
- // The order is `git_next_issues.prioritize`'s and not a second one — the same ranking the
145
- // `🗒 Next issues` display and `auto-ok:next` already answer with, cap included, so the three cannot
146
- // disagree about what comes next. Anything it withholds is still open work: `needs-decision` is
147
- // waiting on a person, and everything else — a standing blocker, a run already in progress, a row
148
- // past the cap — resolves on its own and is waiting on time. **The cap is one of those**: a sixth
149
- // runnable standalone issue is reported as waiting rather than offered, and the next ask offers it
150
- // once one of the five above it merges, so the backlog drains without it ever being lost. That is
151
- // the cost of having one ranking rather than two, and `docs/josh-commands.md` states it.
147
+ // The order is `git_next_issues.order`'s and not a second one — the same ranking the
148
+ // `🗒 Next issues` display and `auto-ok:next` already answer with, so the three cannot disagree about
149
+ // what comes next. Anything it withholds is still open work: `needs-decision` is waiting on a person,
150
+ // and everything else — a standing blocker, a run already in progress — resolves on its own and is
151
+ // waiting on time.
152
+ //
153
+ // **The display's cap is not applied here** (joshuafolkken/kit#2928). Cut at this point, a sixth
154
+ // runnable `run:solo` issue never reached the gate that holds back what is ranked below it, so the
155
+ // cap is applied after that gate instead (`backlog-rank.ts`). A row past it is still reported as
156
+ // waiting and offered by a later ask, so the backlog drains without it ever being lost.
152
157
  function classify_standalone(
153
158
  issues: ReadonlyArray<OpenIssueData>,
154
159
  context: StandaloneContext,
155
160
  ): Classification {
156
161
  const considered = issues.filter((issue) => is_considered(issue, context))
157
- const runnable = git_next_issues.prioritize(
162
+ const runnable = git_next_issues.order(
158
163
  considered.filter((issue) => auto_ok_cli.is_runnable(issue, context.tracked, context.exclude)),
159
164
  )
160
165
  const offered = new Set(runnable.map((issue) => issue.number))
@@ -301,11 +306,26 @@ function merge_classifications(left: Classification, right: Classification): Cla
301
306
  }
302
307
  }
303
308
 
309
+ // The keys of the rows the standalone half considers — the rows the offer's cap bounds. An issue an
310
+ // opted-in epic tracks is that epic's child here, and never capped, exactly as before.
311
+ function standalone_keys(
312
+ issues: ReadonlyArray<OpenIssueData>,
313
+ context: ConsideredContext,
314
+ ): ReadonlySet<string> {
315
+ return keys_of(
316
+ to_children(
317
+ standalone_rows(issues).filter((issue) => is_considered(issue, context)),
318
+ context.repo,
319
+ ),
320
+ )
321
+ }
322
+
304
323
  const backlog_pool = {
305
324
  classify_standalone,
306
325
  cross_epic_cycles,
307
326
  running_set,
308
327
  settle_standalone,
328
+ standalone_keys,
309
329
  drop_excluded,
310
330
  epic_classification,
311
331
  is_epic_row,
@@ -319,4 +339,4 @@ const backlog_pool = {
319
339
  }
320
340
 
321
341
  export { backlog_pool }
322
- export type { StandaloneContext }
342
+ export type { ConsideredContext, StandaloneContext }
@@ -0,0 +1,106 @@
1
+ import type { BusyRead } from '#scripts/epic/epic-busy'
2
+ import { epic_graph, type EpicChild } from '#scripts/epic/epic-graph'
3
+ import { epic_rank } from '#scripts/epic/epic-rank'
4
+ import type { EpicNextResult } from '#scripts/epic/epic-report'
5
+ import { epic_solo, type SoloGate, type SoloSelection } from '#scripts/epic/epic-solo'
6
+ import { git_next_issues } from '#scripts/git/git-next-issues'
7
+
8
+ // What the backlog offers, in the order it is decided (joshuafolkken/kit#2928): rank, then the
9
+ // `run:solo` gate, then the cap. `backlog:next` and `backlog:plan --waves` both call `select`, so the
10
+ // plan's first wave is what the run starts into an idle repository rather than an order the run never
11
+ // takes.
12
+ //
13
+ // **The cap comes last.** It used to be applied while the standalone half was classified, before the
14
+ // gate, so a `run:solo` issue ranked sixth or lower was cut before the gate could see it — and the
15
+ // issues below it were offered past it. Cut after the gate, the cap only ever removes what the gate
16
+ // would have offered, so it cannot hide a waiting `run:solo` issue from it. It still bounds only the
17
+ // standalone rows, as it always has; an epic's children were never capped.
18
+
19
+ // Every child the classification placed, in the order it placed them: the ranked candidates first,
20
+ // then the waiting ones, then the ones waiting on a person.
21
+ function everything_in(result: EpicNextResult): ReadonlyArray<EpicChild> {
22
+ const candidates = result.candidates.flatMap((bundle) => bundle.children)
23
+
24
+ return [...candidates, ...result.waiting, ...result.blocked_on_people]
25
+ }
26
+
27
+ // The ranking is `epic_rank.rank`, shared with a named epic's lanes.
28
+ const { rank } = epic_rank
29
+
30
+ // This repository's candidates re-ranked inside the result, so `backlog:plan` prints the order the
31
+ // offer is decided in.
32
+ function rank_result(result: EpicNextResult, repo: string): EpicNextResult {
33
+ if (result.verdict !== 'run') return result
34
+
35
+ const pool = everything_in(result)
36
+
37
+ return {
38
+ ...result,
39
+ candidates: result.candidates.map((bundle) =>
40
+ bundle.repo === repo ? { ...bundle, children: rank(bundle.children, pool) } : bundle,
41
+ ),
42
+ }
43
+ }
44
+
45
+ // The standalone rows past the cap, in offer order.
46
+ function overflow_of(
47
+ offered: ReadonlyArray<EpicChild>,
48
+ standalone: ReadonlySet<string>,
49
+ ): ReadonlySet<string> {
50
+ const keys = offered.map((child) => epic_graph.key_of(child)).filter((key) => standalone.has(key))
51
+
52
+ return new Set(keys.slice(git_next_issues.DISPLAY_LIMIT))
53
+ }
54
+
55
+ function is_in(child: EpicChild, keys: ReadonlySet<string>): boolean {
56
+ return keys.has(epic_graph.key_of(child))
57
+ }
58
+
59
+ function cap(selection: SoloSelection, standalone: ReadonlySet<string>): SoloSelection {
60
+ const overflow = overflow_of(selection.offered, standalone)
61
+
62
+ if (overflow.size === 0) return selection
63
+
64
+ return {
65
+ ...selection,
66
+ offered: selection.offered.filter((child) => !is_in(child, overflow)),
67
+ withheld: [
68
+ ...selection.offered.filter((child) => is_in(child, overflow)),
69
+ ...selection.withheld,
70
+ ],
71
+ }
72
+ }
73
+
74
+ interface OfferInput {
75
+ candidates: ReadonlyArray<EpicChild>
76
+ pool: ReadonlyArray<EpicChild>
77
+ read: BusyRead
78
+ repo: string
79
+ // The keys of the standalone rows — the ones the cap bounds.
80
+ standalone: ReadonlySet<string>
81
+ }
82
+
83
+ function select(input: OfferInput): SoloSelection {
84
+ const ranked = rank(input.candidates, input.pool)
85
+
86
+ return cap(epic_solo.select(ranked, input.read, input.repo), input.standalone)
87
+ }
88
+
89
+ // `backlog:next`'s gate: `epic_solo.gate` with this selection in place of its bare one.
90
+ function gate(
91
+ result: EpicNextResult,
92
+ read: BusyRead,
93
+ repo: string,
94
+ standalone: ReadonlySet<string>,
95
+ ): SoloGate {
96
+ const pool = everything_in(result)
97
+
98
+ return epic_solo.gate(result, read, repo, (candidates) =>
99
+ select({ candidates, pool, read, repo, standalone }),
100
+ )
101
+ }
102
+
103
+ const backlog_rank = { everything_in, gate, rank, rank_result, select }
104
+
105
+ export { backlog_rank }
106
+ export type { OfferInput }
@@ -4,9 +4,9 @@ import { epic_cross_repo } from '#scripts/epic/epic-cross-repo'
4
4
  import { epic_graph, type EpicChild } from '#scripts/epic/epic-graph'
5
5
  import { epic_outside_blocker } from '#scripts/epic/epic-outside-blocker'
6
6
  import { epic_report, type EpicNextResult } from '#scripts/epic/epic-report'
7
- import { epic_solo } from '#scripts/epic/epic-solo'
8
7
  import { has_label_name, IN_PROGRESS_LABEL, NEEDS_DECISION_LABEL } from '#scripts/git/issue-labels'
9
8
  import { backlog_plan, type PlanContext } from './backlog-plan'
9
+ import { backlog_rank } from './backlog-rank'
10
10
 
11
11
  // The order a `backlogrun` takes, wave by wave, before it starts (joshuafolkken/kit#2778).
12
12
  //
@@ -14,13 +14,13 @@ import { backlog_plan, type PlanContext } from './backlog-plan'
14
14
  // made from, so the order past the first answer was left for a person to work out by hand. This plays
15
15
  // the asks forward under one assumption: **every issue of a wave merges before the next wave starts**.
16
16
  //
17
- // **No rule is written twice.** The first wave is `epic_solo.select` over the very candidates
18
- // `backlog:next` resolves, asked of an idle repository — so it is what `backlog:next` prints when
19
- // nothing is running. Each later wave marks the earlier waves closed and re-classifies the same pool
17
+ // **No rule is written twice.** The first wave is `backlog_rank.select` — rank, `run:solo` gate, cap —
18
+ // over the very candidates `backlog:next` resolves, asked of an idle repository — so it is what
19
+ // `backlog:next` prints when nothing is running (joshuafolkken/kit#2928). Each later wave marks the earlier waves closed and re-classifies the same pool
20
20
  // through `epic_classify.classify_children` with the resolver `epic:next` sorted it with the first
21
21
  // time — `epic_cross_repo.resolve_cross_repo`, so a blocker in another repository still waits for its
22
22
  // release rather than counting as done on close — then puts the runnable set through
23
- // `epic_solo.select` again.
23
+ // `backlog_rank.select` again.
24
24
 
25
25
  const IDLE: BusyRead = { kind: 'idle' }
26
26
  const CLOSED = 'CLOSED'
@@ -45,14 +45,6 @@ function is_running(child: EpicChild): boolean {
45
45
  return has_label_name(child.labels, IN_PROGRESS_LABEL)
46
46
  }
47
47
 
48
- // Every child the classification placed, in the order it placed them: the ranked candidates first,
49
- // then the waiting ones, then the ones waiting on a person.
50
- function everything_in(result: EpicNextResult): ReadonlyArray<EpicChild> {
51
- const candidates = result.candidates.flatMap((bundle) => bundle.children)
52
-
53
- return [...candidates, ...result.waiting, ...result.blocked_on_people]
54
- }
55
-
56
48
  function as_closed(child: EpicChild, done: ReadonlySet<string>): EpicChild {
57
49
  return done.has(epic_graph.key_of(child)) ? { ...child, state: CLOSED } : child
58
50
  }
@@ -63,24 +55,35 @@ interface WavePool {
63
55
  children: ReadonlyArray<EpicChild>
64
56
  running: ReadonlySet<string>
65
57
  repo: string
58
+ standalone: ReadonlySet<string>
66
59
  }
67
60
 
68
- function pool_of(result: EpicNextResult, repo: string): WavePool {
69
- const all = everything_in(result)
61
+ function pool_of(result: EpicNextResult, repo: string, standalone: ReadonlySet<string>): WavePool {
62
+ const all = backlog_rank.everything_in(result)
70
63
 
71
64
  return {
72
65
  children: all.filter((child) => !is_running(child)),
73
66
  running: epic_outside_blocker.running_keys(all),
74
67
  repo,
68
+ standalone,
75
69
  }
76
70
  }
77
71
 
78
- function offer(runnable: ReadonlyArray<EpicChild>, repo: string): ReadonlyArray<EpicChild> {
79
- return epic_solo.select(runnable, IDLE, repo).offered
72
+ function offer(
73
+ candidates: ReadonlyArray<EpicChild>,
74
+ children: ReadonlyArray<EpicChild>,
75
+ pool: WavePool,
76
+ ): ReadonlyArray<EpicChild> {
77
+ const { repo, standalone } = pool
78
+
79
+ return backlog_rank.select({ candidates, pool: children, read: IDLE, repo, standalone }).offered
80
80
  }
81
81
 
82
- function first_wave(result: EpicNextResult, repo: string): ReadonlyArray<EpicChild> {
83
- return offer(epic_report.candidates_for_repo(result, repo), repo)
82
+ // Ranked against the whole result, exactly as `backlog:next` ranks it, so the two agree.
83
+ function first_wave(result: EpicNextResult, pool: WavePool): ReadonlyArray<EpicChild> {
84
+ const candidates = epic_report.candidates_for_repo(result, pool.repo)
85
+
86
+ return offer(candidates, backlog_rank.everything_in(result), pool)
84
87
  }
85
88
 
86
89
  function next_wave(pool: WavePool, done: ReadonlySet<string>): ReadonlyArray<EpicChild> {
@@ -93,25 +96,31 @@ function next_wave(pool: WavePool, done: ReadonlySet<string>): ReadonlyArray<Epi
93
96
 
94
97
  return offer(
95
98
  runnable.filter((child) => child.repo === pool.repo),
96
- pool.repo,
99
+ children,
100
+ pool,
97
101
  )
98
102
  }
99
103
 
100
104
  // Each wave is closed before the next is asked for; a wave that offers nothing ends the plan, which
101
- // the pool's size bounds because every wave closes at least one child.
102
- function build(result: EpicNextResult, repo: string): WavePlan {
103
- const pool = pool_of(result, repo)
105
+ // the pool's size bounds because every wave closes at least one child. `standalone` names the rows the
106
+ // offer's cap bounds; left empty, no wave is capped.
107
+ function build(
108
+ result: EpicNextResult,
109
+ repo: string,
110
+ standalone: ReadonlySet<string> = new Set(),
111
+ ): WavePlan {
112
+ const pool = pool_of(result, repo, standalone)
104
113
  const done = new Set<string>()
105
114
  const waves: Array<ReadonlyArray<EpicChild>> = []
106
115
 
107
- for (let wave = first_wave(result, repo); wave.length > 0; wave = next_wave(pool, done)) {
116
+ for (let wave = first_wave(result, pool); wave.length > 0; wave = next_wave(pool, done)) {
108
117
  waves.push(wave)
109
118
  for (const child of wave) done.add(epic_graph.key_of(child))
110
119
  }
111
120
 
112
- const unreached = everything_in(result).filter(
113
- (child) => child.repo === repo && !done.has(epic_graph.key_of(child)),
114
- )
121
+ const unreached = backlog_rank
122
+ .everything_in(result)
123
+ .filter((child) => child.repo === repo && !done.has(epic_graph.key_of(child)))
115
124
 
116
125
  return { waves, unreached }
117
126
  }
@@ -139,10 +148,14 @@ function unreached_lines(plan: WavePlan, context: PlanContext): Array<string> {
139
148
  )
140
149
  }
141
150
 
142
- function format_waves(result: EpicNextResult, context: PlanContext): string {
151
+ function format_waves(
152
+ result: EpicNextResult,
153
+ context: PlanContext,
154
+ standalone: ReadonlySet<string> = new Set(),
155
+ ): string {
143
156
  if (result.verdict === 'error') return backlog_plan.format_unusable(result)
144
157
 
145
- const plan = build(result, context.repo)
158
+ const plan = build(result, context.repo, standalone)
146
159
  const waves = plan.waves.map((wave, index) => wave_line(wave, index, context.repo))
147
160
 
148
161
  return [
@@ -1,6 +1,7 @@
1
1
  #!/usr/bin/env tsx
2
2
  import path from 'node:path'
3
3
  import { fileURLToPath } from 'node:url'
4
+ import { error_text } from '#scripts/lib/error-message'
4
5
  import { build } from 'esbuild'
5
6
 
6
7
  const PACKAGE_DIR = path.join(path.dirname(fileURLToPath(import.meta.url)), '..', '..')
@@ -26,7 +27,7 @@ async function main(): Promise<void> {
26
27
  await build_bin()
27
28
  console.info(` ✔ ${OUTFILE} built`)
28
29
  } catch (error) {
29
- console.error(error instanceof Error ? error.message : String(error))
30
+ console.error(error_text.message_of(error))
30
31
  process.exit(1)
31
32
  }
32
33
  }
@@ -1,5 +1,6 @@
1
1
  #!/usr/bin/env tsx
2
2
  import { fileURLToPath } from 'node:url'
3
+ import { error_text } from '#scripts/lib/error-message'
3
4
  import { build_library, library_paths } from './build-library'
4
5
 
5
6
  const CONFIG_MERGE_LIBRARY = 'config-merge'
@@ -16,7 +17,7 @@ async function main(): Promise<void> {
16
17
  console.info(` ✔ ${CONFIG_MERGE_OUTFILE} built`)
17
18
  console.info(` ✔ ${CONFIG_MERGE_DTS_FILE} built`)
18
19
  } catch (error) {
19
- console.error(error instanceof Error ? error.message : String(error))
20
+ console.error(error_text.message_of(error))
20
21
  process.exit(1)
21
22
  }
22
23
  }
@@ -1,6 +1,8 @@
1
1
  #!/usr/bin/env tsx
2
+ import { readdirSync, rmSync } from 'node:fs'
2
3
  import path from 'node:path'
3
4
  import { fileURLToPath } from 'node:url'
5
+ import { error_text } from '#scripts/lib/error-message'
4
6
  import { build } from 'esbuild'
5
7
 
6
8
  const PACKAGE_DIR = path.join(path.dirname(fileURLToPath(import.meta.url)), '..', '..')
@@ -18,6 +20,11 @@ const OUT_DIR = path.join(PACKAGE_DIR, 'dist', 'hooks')
18
20
  // splitting keeps every entry in its own file with its own `import.meta.url`, so an imported guard's
19
21
  // `import.meta.url` never equals `argv[1]` and only the file actually launched runs its main.
20
22
  //
23
+ // **The flip side: an entry another entry imports loses its main** (joshuafolkken/kit#2922). Splitting
24
+ // moves a module two entries share into a chunk, so a launched hook whose own module is imported
25
+ // elsewhere becomes a re-export stub that runs nothing. Each launched hook is therefore a `*-cli.ts`
26
+ // file holding only the self-invoke, which no other module imports.
27
+ //
21
28
  // `packages: 'external'` keeps bare dependencies as runtime imports the consumer resolves from kit's
22
29
  // node_modules, exactly as the library bundles do, while kit's internal `#scripts/*` graph is inlined.
23
30
  // No shebang banner is added: unlike `dist/josh.js` (the `bin.josh` entry, executed directly), a hook
@@ -33,9 +40,9 @@ interface HookBundle {
33
40
  // `delivered-rules` (the fourth guard) has no self-invoke, so it stays inlined.
34
41
  const HOOK_BUNDLES: ReadonlyArray<HookBundle> = [
35
42
  { source: 'scripts/hooks/codex-hook-adapter.ts', out: 'codex-hook-adapter' },
36
- { source: 'scripts/hooks/pretool-guard.ts', out: 'pretool-guard' },
43
+ { source: 'scripts/hooks/pretool-guard-cli.ts', out: 'pretool-guard' },
37
44
  { source: 'scripts/hooks/stop-guard.ts', out: 'stop-guard' },
38
- { source: 'scripts/hooks/format-edited-file.ts', out: 'format-edited' },
45
+ { source: 'scripts/hooks/format-edited-cli.ts', out: 'format-edited' },
39
46
  { source: 'scripts/josh/session-language-cli.ts', out: 'session-lang' },
40
47
  { source: 'scripts/hooks/batch-guard.ts', out: 'batch-guard' },
41
48
  { source: 'scripts/delegation/investigation-guard.ts', out: 'investigation-guard' },
@@ -50,17 +57,35 @@ function outfile_for(bundle: HookBundle): string {
50
57
  return path.join(OUT_DIR, `${bundle.out}.js`)
51
58
  }
52
59
 
53
- async function build_hooks(): Promise<void> {
54
- await build({
60
+ // The output directory is flat (every entry and chunk sits at its top level), so a file whose name
61
+ // this build did not emit is a leftover of an earlier one.
62
+ function prune_stale_outputs(out_directory: string, outputs: ReadonlyArray<string>): void {
63
+ const live = new Set(outputs.map((output) => path.basename(output)))
64
+
65
+ for (const name of readdirSync(out_directory)) {
66
+ if (!live.has(name)) rmSync(path.join(out_directory, name), { recursive: true, force: true })
67
+ }
68
+ }
69
+
70
+ // With `splitting: true` every build emits freshly hashed `chunk-*.js` files, so without a cleanup
71
+ // the chunks of every earlier build pile up beside the live ones and ship in any local pack
72
+ // (joshuafolkken/kit#2885). The cleanup runs after the build rather than emptying the directory
73
+ // first: this checkout's own settings.json launches `node dist/hooks/<name>.js` on every tool call,
74
+ // and an emptied directory would make a hook launched mid-build fail to load and its guard fail open.
75
+ async function build_hooks(out_directory: string = OUT_DIR): Promise<void> {
76
+ const { metafile } = await build({
55
77
  entryPoints: HOOK_BUNDLES.map((bundle) => entry_point(bundle)),
56
- outdir: OUT_DIR,
78
+ outdir: out_directory,
57
79
  bundle: true,
58
80
  splitting: true,
59
81
  platform: 'node',
60
82
  format: 'esm',
61
83
  target: 'node22',
62
84
  packages: 'external',
85
+ metafile: true,
63
86
  })
87
+
88
+ prune_stale_outputs(out_directory, Object.keys(metafile.outputs))
64
89
  }
65
90
 
66
91
  async function main(): Promise<void> {
@@ -68,7 +93,7 @@ async function main(): Promise<void> {
68
93
  await build_hooks()
69
94
  for (const bundle of HOOK_BUNDLES) console.info(` ✔ ${outfile_for(bundle)} built`)
70
95
  } catch (error) {
71
- console.error(error instanceof Error ? error.message : String(error))
96
+ console.error(error_text.message_of(error))
72
97
  process.exit(1)
73
98
  }
74
99
  }
@@ -1,5 +1,6 @@
1
1
  #!/usr/bin/env tsx
2
2
  import { fileURLToPath } from 'node:url'
3
+ import { error_text } from '#scripts/lib/error-message'
3
4
  import { build_library, library_paths } from './build-library'
4
5
 
5
6
  const MANAGED_MARKER_LIBRARY = 'managed-marker'
@@ -16,7 +17,7 @@ async function main(): Promise<void> {
16
17
  console.info(` ✔ ${MANAGED_MARKER_OUTFILE} built`)
17
18
  console.info(` ✔ ${MANAGED_MARKER_DTS_FILE} built`)
18
19
  } catch (error) {
19
- console.error(error instanceof Error ? error.message : String(error))
20
+ console.error(error_text.message_of(error))
20
21
  process.exit(1)
21
22
  }
22
23
  }
@@ -1,5 +1,6 @@
1
1
  #!/usr/bin/env tsx
2
2
  import { fileURLToPath } from 'node:url'
3
+ import { error_text } from '#scripts/lib/error-message'
3
4
  import { build_library, library_paths } from './build-library'
4
5
 
5
6
  const SELF_SYNC_GUARD_LIBRARY = 'self-sync-guard'
@@ -16,7 +17,7 @@ async function main(): Promise<void> {
16
17
  console.info(` ✔ ${SELF_SYNC_GUARD_OUTFILE} built`)
17
18
  console.info(` ✔ ${SELF_SYNC_GUARD_DTS_FILE} built`)
18
19
  } catch (error) {
19
- console.error(error instanceof Error ? error.message : String(error))
20
+ console.error(error_text.message_of(error))
20
21
  process.exit(1)
21
22
  }
22
23
  }
@@ -1,5 +1,6 @@
1
1
  #!/usr/bin/env tsx
2
2
  import { fileURLToPath } from 'node:url'
3
+ import { error_text } from '#scripts/lib/error-message'
3
4
  import { build_library, library_paths } from './build-library'
4
5
 
5
6
  const VERSION_LIBRARY = 'version'
@@ -15,7 +16,7 @@ async function main(): Promise<void> {
15
16
  console.info(` ✔ ${VERSION_OUTFILE} built`)
16
17
  console.info(` ✔ ${VERSION_DTS_FILE} built`)
17
18
  } catch (error) {
18
- console.error(error instanceof Error ? error.message : String(error))
19
+ console.error(error_text.message_of(error))
19
20
  process.exit(1)
20
21
  }
21
22
  }
@@ -1,4 +1,4 @@
1
- import { readFileSync } from 'node:fs'
1
+ import { file_reader } from '#scripts/lib/read-file'
2
2
 
3
3
  // `josh cases <path...>` (joshuafolkken/kit#2246): read the changed paths and answer which I/O
4
4
  // boundaries the code crosses — network, process start, filesystem — then name the abnormal cases
@@ -63,11 +63,7 @@ const BOUNDARIES: ReadonlyArray<BoundaryDefinition> = [
63
63
  // A path that cannot be read counts as no boundary rather than an error: a deleted or renamed path in
64
64
  // a diff is still passed in, and the answer for it is simply "nothing crossed here".
65
65
  function read_file(path: string): string {
66
- try {
67
- return readFileSync(path, 'utf8')
68
- } catch {
69
- return ''
70
- }
66
+ return file_reader.read_if_readable(path) ?? ''
71
67
  }
72
68
 
73
69
  // The distinct boundaries any of the paths cross. The content is joined and each boundary is tested