@cbartens/bkit 5.5.0 → 6.0.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 (297) hide show
  1. package/.bkit/README.md +30 -20
  2. package/.bkit/core/.agents/docs.md +1 -0
  3. package/.bkit/core/.agents/rules.md +51 -26
  4. package/.bkit/core/.bkit/README.md +29 -19
  5. package/.bkit/core/.bkit/authoring.md +117 -0
  6. package/.bkit/core/.bkit/cloud.md +11 -11
  7. package/.bkit/core/.bkit/comparison.md +5 -5
  8. package/.bkit/core/.bkit/install.md +20 -20
  9. package/.bkit/core/.bkit/jsonl.md +202 -122
  10. package/.bkit/core/.bkit/lite.md +1 -1
  11. package/.bkit/core/.bkit/pipeline.md +49 -52
  12. package/.bkit/core/.bkit/prompts.md +106 -167
  13. package/.bkit/core/.bkit/providers.md +29 -32
  14. package/.bkit/core/.bkit/templates.md +44 -18
  15. package/.bkit/core/.bkit/trackers.md +60 -28
  16. package/.bkit/core/.bkit/workflows.md +399 -359
  17. package/.bkit/core/AGENTS.md +16 -22
  18. package/.bkit/core/docs/templates/bkit-audit-accessibility.md +14 -38
  19. package/.bkit/core/docs/templates/bkit-audit-adoption.md +16 -40
  20. package/.bkit/core/docs/templates/bkit-audit-agents.md +19 -43
  21. package/.bkit/core/docs/templates/bkit-audit-aio-seo.md +16 -40
  22. package/.bkit/core/docs/templates/bkit-audit-analytics.md +14 -38
  23. package/.bkit/core/docs/templates/bkit-audit-annotations.md +11 -35
  24. package/.bkit/core/docs/templates/bkit-audit-app-performance.md +15 -39
  25. package/.bkit/core/docs/templates/bkit-audit-app-store.md +12 -36
  26. package/.bkit/core/docs/templates/bkit-audit-architecture.md +16 -40
  27. package/.bkit/core/docs/templates/bkit-audit-ci-performance.md +16 -40
  28. package/.bkit/core/docs/templates/bkit-audit-config.md +18 -42
  29. package/.bkit/core/docs/templates/bkit-audit-cost.md +16 -40
  30. package/.bkit/core/docs/templates/bkit-audit-coverage.md +15 -39
  31. package/.bkit/core/docs/templates/bkit-audit-database.md +16 -40
  32. package/.bkit/core/docs/templates/bkit-audit-dead-code.md +15 -39
  33. package/.bkit/core/docs/templates/bkit-audit-deferrals.md +15 -38
  34. package/.bkit/core/docs/templates/bkit-audit-dependencies.md +16 -40
  35. package/.bkit/core/docs/templates/bkit-audit-documentation.md +11 -35
  36. package/.bkit/core/docs/templates/bkit-audit-duplication.md +18 -42
  37. package/.bkit/core/docs/templates/bkit-audit-failures.md +13 -37
  38. package/.bkit/core/docs/templates/bkit-audit-flakes.md +12 -36
  39. package/.bkit/core/docs/templates/bkit-audit-gates.md +14 -38
  40. package/.bkit/core/docs/templates/bkit-audit-issues.md +15 -39
  41. package/.bkit/core/docs/templates/bkit-audit-llm.md +16 -40
  42. package/.bkit/core/docs/templates/bkit-audit-logs.md +14 -38
  43. package/.bkit/core/docs/templates/bkit-audit-models.md +12 -36
  44. package/.bkit/core/docs/templates/bkit-audit-privacy.md +12 -36
  45. package/.bkit/core/docs/templates/bkit-audit-prompts.md +15 -39
  46. package/.bkit/core/docs/templates/bkit-audit-red-team.md +15 -39
  47. package/.bkit/core/docs/templates/bkit-audit-reliability.md +15 -39
  48. package/.bkit/core/docs/templates/bkit-audit-repo.md +12 -36
  49. package/.bkit/core/docs/templates/bkit-audit-security.md +13 -37
  50. package/.bkit/core/docs/templates/bkit-audit-slop.md +14 -38
  51. package/.bkit/core/docs/templates/bkit-audit-testing.md +12 -36
  52. package/.bkit/core/docs/templates/bkit-audit-usability.md +16 -40
  53. package/.bkit/core/docs/templates/bkit-plan.md +97 -226
  54. package/.bkit/core/engine/checks/after/ci-yml.ts +39 -30
  55. package/.bkit/core/engine/checks/after/github.ts +101 -72
  56. package/.bkit/core/engine/checks/after/index.ts +10 -12
  57. package/.bkit/core/engine/checks/after/suppression.ts +8 -5
  58. package/.bkit/core/engine/checks/after/tools.ts +47 -92
  59. package/.bkit/core/engine/checks/before/env.ts +2 -2
  60. package/.bkit/core/engine/checks/before/files.ts +5 -4
  61. package/.bkit/core/engine/checks/before/index.ts +18 -1
  62. package/.bkit/core/engine/checks/before/repo.ts +168 -2
  63. package/.bkit/core/engine/checks/tips/catalogue.ts +16 -5
  64. package/.bkit/core/engine/checks/tips/detect.ts +34 -0
  65. package/.bkit/core/engine/checks/tips/index.ts +10 -7
  66. package/.bkit/core/engine/cli.ts +20 -53
  67. package/.bkit/core/engine/commands/analysis.ts +171 -140
  68. package/.bkit/core/engine/commands/ci/ci.ts +6 -6
  69. package/.bkit/core/engine/commands/comply.ts +77 -103
  70. package/.bkit/core/engine/commands/install/doctor.ts +2 -2
  71. package/.bkit/core/engine/commands/install/install.ts +57 -18
  72. package/.bkit/core/engine/commands/install/uninstall.ts +65 -28
  73. package/.bkit/core/engine/commands/land.ts +18 -12
  74. package/.bkit/core/engine/commands/lib.ts +79 -17
  75. package/.bkit/core/engine/commands/registry.ts +4 -0
  76. package/.bkit/core/engine/commands/setup/setup.ts +7 -7
  77. package/.bkit/core/engine/commands/stats.ts +204 -0
  78. package/.bkit/core/engine/commands/tips.ts +10 -5
  79. package/.bkit/core/engine/commands/workflow/branches.ts +741 -62
  80. package/.bkit/core/engine/commands/workflow/challenge.ts +673 -0
  81. package/.bkit/core/engine/commands/workflow/context.ts +853 -29
  82. package/.bkit/core/engine/commands/workflow/counters.ts +267 -84
  83. package/.bkit/core/engine/commands/workflow/decisions.ts +541 -0
  84. package/.bkit/core/engine/commands/workflow/disk.ts +2 -2
  85. package/.bkit/core/engine/commands/workflow/fids.ts +793 -33
  86. package/.bkit/core/engine/commands/workflow/issues.ts +427 -105
  87. package/.bkit/core/engine/commands/workflow/ledgers.ts +884 -27
  88. package/.bkit/core/engine/commands/workflow/locks.ts +26 -2
  89. package/.bkit/core/engine/commands/workflow/plan-blocks.ts +582 -0
  90. package/.bkit/core/engine/commands/workflow/plan-versions.ts +21 -0
  91. package/.bkit/core/engine/commands/workflow/prs.ts +166 -30
  92. package/.bkit/core/engine/commands/workflow/repo.ts +59 -7
  93. package/.bkit/core/engine/commands/workflow/roadmap.ts +16 -7
  94. package/.bkit/core/engine/commands/workflow/run-facts.ts +501 -0
  95. package/.bkit/core/engine/commands/workflow/runs.ts +179 -49
  96. package/.bkit/core/engine/commands/workflow/runtime.ts +22 -1
  97. package/.bkit/core/engine/commands/workflow/status.ts +142 -29
  98. package/.bkit/core/engine/commands/workflow/step-table.ts +339 -0
  99. package/.bkit/core/engine/commands/workflow/steps.ts +213 -88
  100. package/.bkit/core/engine/commands/workflow/summary.ts +398 -0
  101. package/.bkit/core/engine/commands/workflow/tests.ts +1013 -148
  102. package/.bkit/core/engine/commands/workflow/tracker.ts +1195 -0
  103. package/.bkit/core/engine/commands/workflow/workflows.ts +984 -207
  104. package/.bkit/core/engine/commands/workflow/workstreams.ts +11 -5
  105. package/.bkit/core/engine/commands/workflow/worktrees.ts +276 -22
  106. package/.bkit/core/engine/install/manifest.ts +11 -9
  107. package/.bkit/core/engine/install/modules/cloud.ts +21 -13
  108. package/.bkit/core/engine/install/modules/core.ts +325 -7
  109. package/.bkit/core/engine/install/modules/opencode.ts +2 -2
  110. package/.bkit/core/engine/install/version-file.ts +6 -2
  111. package/.bkit/core/engine/ledgers/migrate.ts +92 -0
  112. package/.bkit/core/engine/ledgers/status.ts +92 -15
  113. package/.bkit/core/engine/ledgers/telemetry.ts +1261 -254
  114. package/.bkit/core/engine/render/hosts.ts +4 -0
  115. package/.bkit/core/engine/render/models.ts +12 -0
  116. package/.bkit/core/engine/shared/branches.ts +4 -1
  117. package/.bkit/core/engine/shared/egress.ts +7 -0
  118. package/.bkit/core/engine/shared/json.ts +25 -7
  119. package/.bkit/core/engine/shared/settings.ts +202 -33
  120. package/.bkit/core/engine/shared/text.ts +361 -0
  121. package/.bkit/core/engine/tools/grammar-density.ts +215 -0
  122. package/.bkit/core/engine/tools/instructions-sources.ts +834 -0
  123. package/.bkit/core/engine/tools/instructions.ts +1751 -0
  124. package/.bkit/core/hooks/gateguard-engine.js +24 -23
  125. package/.bkit/core/hooks/guardrails-shell.js +2 -3
  126. package/.bkit/core/hooks/guardrails-tiers.js +7 -1
  127. package/.bkit/core/hooks/readguard-engine.js +2 -2
  128. package/.bkit/core/prompts/bkit-audit-generate.md +62 -25
  129. package/.bkit/core/prompts/bkit-build-challenge-1.md +40 -17
  130. package/.bkit/core/prompts/bkit-build-challenge-2.md +44 -17
  131. package/.bkit/core/prompts/bkit-build-install-skills.md +26 -13
  132. package/.bkit/core/prompts/bkit-build-plan-convert.md +74 -0
  133. package/.bkit/core/prompts/bkit-build-plan-current.md +26 -13
  134. package/.bkit/core/prompts/bkit-build-plan-execute.md +74 -26
  135. package/.bkit/core/prompts/bkit-build-plan-gaps-remediate.md +64 -23
  136. package/.bkit/core/prompts/bkit-build-plan-verify.md +57 -33
  137. package/.bkit/core/prompts/bkit-debug-abort-handover.md +30 -14
  138. package/.bkit/core/prompts/bkit-debug-failure-diagnose.md +34 -14
  139. package/.bkit/core/prompts/bkit-debug-failure-remediate.md +34 -17
  140. package/.bkit/core/prompts/bkit-debug-failure-reproduce.md +26 -13
  141. package/.bkit/core/prompts/bkit-debug-failure-soak.md +31 -16
  142. package/.bkit/core/prompts/bkit-design-brainstorm-ideate-1.md +21 -11
  143. package/.bkit/core/prompts/bkit-design-brainstorm-ideate-2.md +20 -11
  144. package/.bkit/core/prompts/bkit-design-brainstorm-ideate-3.md +20 -11
  145. package/.bkit/core/prompts/bkit-design-generate.md +33 -13
  146. package/.bkit/core/prompts/bkit-design-organise.md +25 -12
  147. package/.bkit/core/prompts/bkit-design-review-1.md +31 -15
  148. package/.bkit/core/prompts/bkit-design-review-2.md +28 -13
  149. package/.bkit/core/prompts/bkit-design-spike.md +30 -13
  150. package/.bkit/core/prompts/bkit-design-update.md +33 -19
  151. package/.bkit/core/prompts/bkit-plan-generate.md +75 -19
  152. package/.bkit/core/prompts/bkit-plan-review-1.md +50 -27
  153. package/.bkit/core/prompts/bkit-plan-review-2.md +59 -28
  154. package/.bkit/core/prompts/bkit-plan-scope-check.md +109 -0
  155. package/.bkit/core/prompts/bkit-plan-update.md +61 -24
  156. package/.bkit/core/prompts/bkit-ship-conflict-resolve.md +27 -15
  157. package/.bkit/core/prompts/bkit-ship-deferred-sweep.md +31 -16
  158. package/.bkit/core/prompts/bkit-ship-update-docs.md +30 -15
  159. package/.bkit/core/prompts/bkit-utility-compress-markdown.md +24 -14
  160. package/.bkit/core/prompts/bkit-utility-update-decisions.md +32 -14
  161. package/.bkit/core/prompts/bkit-utility-update-deferrals.md +29 -14
  162. package/.bkit/core/prompts/bkit-utility-update-documentation.md +28 -13
  163. package/.bkit/core/prompts/bkit-utility-update-failures.md +31 -14
  164. package/.bkit/core/prompts/bkit-utility-update-knowledge.md +33 -14
  165. package/.bkit/core/prompts/bkit-utility-update-roadmap.md +38 -17
  166. package/.bkit/core/prompts/bkit-utility-update-tracker.md +43 -20
  167. package/.bkit/core/workflows/bkit-auto.md +54 -46
  168. package/.bkit/core/workflows/bkit-build.md +577 -458
  169. package/.bkit/core/workflows/bkit-debug.md +348 -333
  170. package/.bkit/core/workflows/bkit-design.md +201 -237
  171. package/.bkit/core/workflows/bkit-plan.md +210 -321
  172. package/.bkit/core/workflows/bkit-ship.md +328 -278
  173. package/.bkit/shared/.bkit/.env.example +2 -2
  174. package/.bkit/shared/.claude/settings.json +11 -0
  175. package/.bkit/shared/.cursor/mcp.json +1 -1
  176. package/.bkit/shared/.cursor/rules/bkit-rules.mdc +1 -1
  177. package/.bkit/shared/.gitattributes +1 -1
  178. package/.bkit/shared/.mcp.json +1 -1
  179. package/.bkit/shared/.opencode/opencode.json +11 -0
  180. package/.bkit/shared/CLAUDE.md +2 -2
  181. package/.bkit/shared/GEMINI.md +2 -2
  182. package/.bkit/shared/docs/architecture.md +1 -1
  183. package/.bkit/shared/docs/data-schema.md +1 -1
  184. package/.bkit/shared/docs/deployments.md +16 -28
  185. package/.bkit/shared/docs/design.md +1 -1
  186. package/.bkit/shared/docs/noise.md +1 -1
  187. package/.bkit/shared/docs/observability.md +2 -2
  188. package/.bkit/shared/docs/security.md +1 -1
  189. package/.bkit/shared/docs/setup.md +1 -1
  190. package/.bkit/shared/docs/technology.md +1 -1
  191. package/.bkit/shared/docs/testing.md +27 -10
  192. package/.bkit/templates/.claude/hooks/bkit-cloud-bootstrap.sh +1 -1
  193. package/.bkit/templates/.github/ISSUE_TEMPLATE/bkit-change.yml +26 -5
  194. package/.bkit/templates/.github/workflows/bkit-ci.yml +22 -84
  195. package/.bkit/templates/.github/workflows/bkit-cloud.yml +21 -19
  196. package/.bkit/templates/.husky/pre-push +52 -13
  197. package/.bkit/templates/.prettierignore +7 -0
  198. package/.bkit/templates/scripts/ci/bkit-local-stack-lock.sh +194 -0
  199. package/.bkit/templates/scripts/ci/check-capstone.mjs +2 -4
  200. package/.bkit/templates/scripts/ci/check-capstone.test.mjs +4 -23
  201. package/.bkit/templates/scripts/ci/lanes/resolve-push-base.mjs +104 -23
  202. package/.bkit/templates/scripts/ci/lanes/resolve-push-base.test.mjs +103 -6
  203. package/.bkit/templates/scripts/cleanup/bkit-disk-prune.mjs +1 -1
  204. package/.bkit/templates/scripts/graphify/bkit-graph-pre-push.sh +3 -1
  205. package/.bkit/templates/scripts/prettier/bkit-insert-ignore.mjs +49 -29
  206. package/CHANGELOG.md +142 -0
  207. package/README.md +58 -34
  208. package/dist/checks/after/ci-yml.js +39 -29
  209. package/dist/checks/after/github.js +99 -72
  210. package/dist/checks/after/index.js +11 -13
  211. package/dist/checks/after/suppression.js +8 -5
  212. package/dist/checks/after/tools.js +40 -83
  213. package/dist/checks/before/env.js +2 -2
  214. package/dist/checks/before/files.js +5 -3
  215. package/dist/checks/before/index.js +15 -2
  216. package/dist/checks/before/repo.js +163 -2
  217. package/dist/checks/tips/catalogue.js +14 -5
  218. package/dist/checks/tips/detect.js +32 -0
  219. package/dist/checks/tips/index.js +7 -5
  220. package/dist/cli.js +19 -47
  221. package/dist/commands/analysis.js +109 -100
  222. package/dist/commands/ci/ci.js +6 -6
  223. package/dist/commands/comply.js +54 -91
  224. package/dist/commands/install/doctor.js +2 -2
  225. package/dist/commands/install/install.js +50 -19
  226. package/dist/commands/install/uninstall.js +59 -28
  227. package/dist/commands/land.js +16 -12
  228. package/dist/commands/lib.js +51 -16
  229. package/dist/commands/registry.js +4 -0
  230. package/dist/commands/setup/setup.js +7 -7
  231. package/dist/commands/stats.js +136 -0
  232. package/dist/commands/tips.js +7 -3
  233. package/dist/commands/workflow/branches.js +656 -56
  234. package/dist/commands/workflow/challenge.js +556 -0
  235. package/dist/commands/workflow/context.js +709 -30
  236. package/dist/commands/workflow/counters.js +208 -75
  237. package/dist/commands/workflow/decisions.js +441 -0
  238. package/dist/commands/workflow/disk.js +2 -2
  239. package/dist/commands/workflow/fids.js +689 -33
  240. package/dist/commands/workflow/issues.js +362 -99
  241. package/dist/commands/workflow/ledgers.js +762 -27
  242. package/dist/commands/workflow/locks.js +24 -2
  243. package/dist/commands/workflow/plan-blocks.js +437 -0
  244. package/dist/commands/workflow/plan-versions.js +22 -0
  245. package/dist/commands/workflow/prs.js +142 -32
  246. package/dist/commands/workflow/repo.js +52 -7
  247. package/dist/commands/workflow/roadmap.js +9 -7
  248. package/dist/commands/workflow/run-facts.js +426 -0
  249. package/dist/commands/workflow/runs.js +144 -43
  250. package/dist/commands/workflow/runtime.js +12 -1
  251. package/dist/commands/workflow/status.js +130 -29
  252. package/dist/commands/workflow/step-table.js +276 -0
  253. package/dist/commands/workflow/steps.js +171 -80
  254. package/dist/commands/workflow/summary.js +275 -0
  255. package/dist/commands/workflow/tests.js +834 -136
  256. package/dist/commands/workflow/tracker.js +983 -0
  257. package/dist/commands/workflow/workflows.js +834 -195
  258. package/dist/commands/workflow/workstreams.js +11 -5
  259. package/dist/commands/workflow/worktrees.js +221 -22
  260. package/dist/install/manifest.js +11 -9
  261. package/dist/install/modules/cloud.js +22 -13
  262. package/dist/install/modules/core.js +326 -7
  263. package/dist/install/modules/opencode.js +2 -2
  264. package/dist/install/version-file.js +6 -2
  265. package/dist/ledgers/migrate.js +81 -0
  266. package/dist/ledgers/status.js +61 -8
  267. package/dist/ledgers/telemetry.js +905 -124
  268. package/dist/render/hosts.js +4 -0
  269. package/dist/render/models.js +12 -0
  270. package/dist/shared/branches.js +3 -1
  271. package/dist/shared/egress.js +7 -0
  272. package/dist/shared/json.js +20 -7
  273. package/dist/shared/settings.js +147 -26
  274. package/dist/shared/text.js +333 -0
  275. package/dist/tools/grammar-density.js +183 -0
  276. package/dist/tools/instructions-sources.js +721 -0
  277. package/dist/tools/instructions.js +1579 -0
  278. package/package.json +114 -23
  279. package/.bkit/core/engine/commands/harvest.ts +0 -459
  280. package/.bkit/core/engine/tools/wording.ts +0 -748
  281. package/.bkit/core/prompts/bkit-build-challenge-reconcile.md +0 -69
  282. package/.bkit/core/prompts/bkit-build-challenge-remediate.md +0 -71
  283. package/.bkit/core/prompts/bkit-build-challenge-tests.md +0 -74
  284. package/.bkit/core/prompts/bkit-build-summary.md +0 -94
  285. package/.bkit/core/prompts/bkit-debug-summary.md +0 -96
  286. package/.bkit/core/prompts/bkit-design-summary.md +0 -107
  287. package/.bkit/core/prompts/bkit-plan-complexity-check.md +0 -67
  288. package/.bkit/core/prompts/bkit-plan-complexity-split.md +0 -88
  289. package/.bkit/core/prompts/bkit-plan-review-3.md +0 -93
  290. package/.bkit/core/prompts/bkit-plan-scope-check-1.md +0 -85
  291. package/.bkit/core/prompts/bkit-plan-scope-check-2.md +0 -85
  292. package/.bkit/core/prompts/bkit-plan-summary.md +0 -107
  293. package/.bkit/core/prompts/bkit-ship-summary.md +0 -78
  294. package/.bkit/templates/scripts/ci/lanes/check-tree-cache.mjs +0 -138
  295. package/.bkit/templates/scripts/ci/lanes/check-tree-cache.test.mjs +0 -181
  296. package/dist/commands/harvest.js +0 -353
  297. package/dist/tools/wording.js +0 -680
@@ -1,9 +1,11 @@
1
- // bkit branches sync|push|rebase|switch|land|anchor-stamp|anchor-read — the
2
- // branch mechanics every phase workflow repeated inline: bring a feature branch
3
- // up to date with dev, push it the one safe way for its kind, auto-resolve the
4
- // rebase conflicts that lose nothing, return the main checkout to dev after a
5
- // merge, land a design / plan close on dev, and stamp / read the base commit a
6
- // design or plan doc was written against.
1
+ // bkit branches sync|push|rebase|switch|land|fast-forward|scan-diff|force-build|
2
+ // anchor-stamp|anchor-read — the branch mechanics every phase workflow repeated
3
+ // inline: bring a feature branch up to date with dev, push it the one safe way
4
+ // for its kind, auto-resolve the rebase conflicts that lose nothing, return the
5
+ // main checkout to dev after a merge, land a design / plan close on dev,
6
+ // fast-forward onto a remote branch, route on what a branch's diff holds, force
7
+ // a full CI build, and stamp / read the base commit a design or plan doc was
8
+ // written against.
7
9
  //
8
10
  // Every verb works on `origin` and the integration branch `dev`, as the
9
11
  // workflows do. A push is always EXACTLY ONE `git push`: `dev` / `main` get a
@@ -16,15 +18,19 @@ import * as os from "node:os";
16
18
  import * as path from "node:path";
17
19
 
18
20
  import { gitEnv } from "../../ledgers/telemetry.js";
21
+ import { actionHash, actionKey, alreadyDone, recordAction } from "../../ledgers/status.js";
19
22
  import {
20
23
  bodySkipToken,
21
24
  CommandError,
22
25
  DEV,
23
26
  EXIT,
27
+ ghUnavailable,
24
28
  git,
25
29
  isSharedBranch,
30
+ OUTPUT_LIMIT,
26
31
  parseJson,
27
32
  repoRoot,
33
+ runGh,
28
34
  runGit,
29
35
  SKIP_CI_TOKEN,
30
36
  type CommandSpec,
@@ -33,9 +39,17 @@ import {
33
39
  import { bkitVersionStatus, type BkitVersionStatus } from "../../shared/bkit-latest.js";
34
40
  import { landBackoffMs, landDir, pushToDev, sleep } from "../land.js";
35
41
  import { TIMEOUTS } from "../../shared/timeouts.js";
36
- import { commitBookkeeping } from "./ledgers.js";
42
+ import {
43
+ activeRecord,
44
+ commitBookkeeping,
45
+ markRecordPushed,
46
+ recordOnBranch,
47
+ type SharedCheckoutRecord,
48
+ } from "./ledgers.js";
37
49
  import { releaseLock, resolveMonth, workflowLockPath } from "./locks.js";
38
50
  import {
51
+ EXIT_BASE_NOT_DEV,
52
+ FORCE_BUILD,
39
53
  closeTransportRow,
40
54
  crossCheckRows,
41
55
  mergePr,
@@ -43,9 +57,10 @@ import {
43
57
  probePr,
44
58
  updateBranch,
45
59
  } from "./prs.js";
60
+ import { AUTO_LABEL, AUTO_ROUTE_SUFFIX } from "./issues.js";
46
61
  import { appendFeature } from "./roadmap.js";
47
62
  import { detect } from "./runtime.js";
48
- import { readStatusRows, readStatusRowsAt } from "./status.js";
63
+ import { readRuns, readStatusRows, readStatusRowsAt } from "./status.js";
49
64
  import { removeWorktree, worktreeDir } from "./worktrees.js";
50
65
  import {
51
66
  COULD_NOT_RUN_EXIT_CODES,
@@ -73,28 +88,26 @@ export const EXIT_INSTALL_FAILED = 16;
73
88
  export const EXIT_LAND_STOPPED = 17;
74
89
  export const EXIT_LANDED_UNVERIFIED = 18;
75
90
  export const EXIT_LOCK_LEFT = 19;
91
+ export const EXIT_NO_RECORD = 20;
92
+ export const EXIT_NOTHING_TO_PUSH = 21;
93
+ export const EXIT_DIVERGED = 22;
94
+ export const EXIT_DIFF_FAILED = 23;
76
95
 
77
96
  // ---------------------------------------------------------------------------
78
97
  // Process helpers
79
98
  // ---------------------------------------------------------------------------
80
99
 
81
100
  /** git with a non-interactive editor, so `--continue` / `--skip` / merge commits never open one. */
82
- const quietGit = (cwd: string, args: string[]) => {
83
- const res = spawnSync("git", args, {
84
- cwd,
85
- encoding: "utf-8",
86
- env: { ...gitEnv(), GIT_EDITOR: "true" },
87
- });
88
- return {
89
- ok: res.status === 0,
90
- stdout: (res.stdout ?? "").trim(),
91
- stderr: (res.stderr ?? "").trim(),
92
- };
93
- };
101
+ const quietGit = (cwd: string, args: string[]) => runGit(cwd, args, { GIT_EDITOR: "true" });
94
102
 
95
- /** `git show :<stage>:<path>` as raw bytes; empty when that stage does not exist. */
96
- function stageBytes(top: string, stage: 1 | 2 | 3, file: string): Buffer {
97
- const res = spawnSync("git", ["show", `:${stage}:${file}`], { cwd: top, env: gitEnv() });
103
+ /** `git show :<stage>:<path>` as raw bytes; empty when that stage does not exist, null when git could not run. */
104
+ function stageBytes(top: string, stage: 1 | 2 | 3, file: string): Buffer | null {
105
+ const res = spawnSync("git", ["show", `:${stage}:${file}`], {
106
+ cwd: top,
107
+ env: gitEnv(),
108
+ maxBuffer: OUTPUT_LIMIT,
109
+ });
110
+ if (res.error) return null;
98
111
  // A missing stage is a legitimate shape (add/add, delete/modify): merge against empty.
99
112
  return res.status === 0 ? res.stdout : Buffer.alloc(0);
100
113
  }
@@ -127,7 +140,7 @@ const currentBranch = (cwd: string) => git(cwd, ["branch", "--show-current"]) ??
127
140
  * ledger or is missing.
128
141
  *
129
142
  * `.bkit/friction.jsonl` ships WITHOUT `merge=union` but is listed here; a row union
130
- * resurrects after `bkit harvest` drained it is re-banked by the next harvest.
143
+ * resurrects after the harvest drained it is re-banked by the next harvest.
131
144
  *
132
145
  * `docs/roadmap.md` is not append-only — it is regenerated from
133
146
  * `.bkit/issues.jsonl` — but every workflow close re-folds it, so both sides of
@@ -191,7 +204,9 @@ export function unionResolve(
191
204
  try {
192
205
  const sides = { base: 1, ours: 2, theirs: 3 } as const;
193
206
  for (const [name, stage] of Object.entries(sides)) {
194
- fs.writeFileSync(path.join(tmp, name), stageBytes(top, stage, file));
207
+ const bytes = stageBytes(top, stage, file);
208
+ if (bytes === null) return { ok: false, problem: `git show :${stage}:${file} failed` };
209
+ fs.writeFileSync(path.join(tmp, name), bytes);
195
210
  }
196
211
  const merged = spawnSync(
197
212
  "git",
@@ -203,10 +218,11 @@ export function unionResolve(
203
218
  path.join(tmp, "base"),
204
219
  path.join(tmp, "theirs"),
205
220
  ],
206
- { cwd: top, env: gitEnv() },
221
+ { cwd: top, env: gitEnv(), maxBuffer: OUTPUT_LIMIT },
207
222
  );
208
223
  // --union never leaves conflict markers, so a non-zero exit is an I/O failure.
209
- if (merged.status !== 0) return { ok: false, problem: "git merge-file --union failed" };
224
+ if (merged.error || merged.status !== 0)
225
+ return { ok: false, problem: "git merge-file --union failed" };
210
226
  let text = merged.stdout.toString("utf-8");
211
227
  if (file.endsWith(".jsonl")) {
212
228
  if (!text.split("\n").every((l) => l.trim() === "" || parseJson(l).ok)) {
@@ -458,6 +474,7 @@ function openPrNumber(cwd: string, branch: string): number | null {
458
474
  {
459
475
  cwd,
460
476
  encoding: "utf-8",
477
+ maxBuffer: OUTPUT_LIMIT,
461
478
  },
462
479
  );
463
480
  const parsed = res.status === 0 ? parseJson(res.stdout ?? "") : { ok: false as const };
@@ -544,6 +561,8 @@ export interface PushOutcome {
544
561
  forced: boolean;
545
562
  skipped: string | null;
546
563
  prNumber: number | null;
564
+ /** The run's commits went out as copies cherry-picked onto a fresh origin/dev. */
565
+ replayed: boolean;
547
566
  };
548
567
  }
549
568
 
@@ -551,17 +570,24 @@ export interface PushOutcome {
551
570
  * Push the current branch with exactly one `git push`: plain for dev / main,
552
571
  * `--force-with-lease` otherwise. `abort` never pushes into an open PR (`openPr`:
553
572
  * the answer MCP gave; undefined asks gh, which throws EXIT.USE_MCP when it cannot).
573
+ * An in-place run on dev (a shared-checkout record exists) pushes only the
574
+ * commits it made: plain when they are all that local dev holds beyond
575
+ * origin/dev, else replayed onto a fresh origin/dev through `pushToDev`.
554
576
  */
555
- export function pushBranch(
577
+ export async function pushBranch(
556
578
  cwd: string,
557
579
  o: {
558
- mode: "feature" | "abort" | "dev";
580
+ mode: "feature" | "abort" | "dev" | "plain";
559
581
  setUpstream?: boolean;
582
+ /** --mode=plain: refuse when HEAD has no commits beyond this ref (fetched first when origin/<b>). */
583
+ aheadOf?: string;
560
584
  requireCi?: boolean;
561
585
  openPr?: string;
586
+ /** The in-place run's FID: selects its shared-checkout record, and a missing record refuses the push. */
587
+ fid?: string;
562
588
  },
563
589
  log: (m: string) => void,
564
- ): PushOutcome {
590
+ ): Promise<PushOutcome> {
565
591
  const { mode, openPr: openPrFlag } = o;
566
592
  if (openPrFlag !== undefined && openPrFlag !== "none" && !/^[1-9][0-9]*$/.test(openPrFlag)) {
567
593
  throw new CommandError(
@@ -579,6 +605,7 @@ export function pushBranch(
579
605
  forced: false,
580
606
  skipped: null,
581
607
  prNumber: null,
608
+ replayed: false,
582
609
  ...extra,
583
610
  },
584
611
  });
@@ -590,8 +617,24 @@ export function pushBranch(
590
617
  log(`--mode=dev pushes ${DEV}, but the checkout is on ${branch}`);
591
618
  return notPushed(EXIT_NOT_DEV);
592
619
  }
620
+ if (mode === "plain") return pushPlain(cwd, branch, o, log, notPushed);
621
+ const shared = isSharedBranch(branch);
622
+ const rec = !shared
623
+ ? null
624
+ : o.fid === undefined
625
+ ? recordOnBranch(cwd, branch)
626
+ : activeRecord(cwd, o.fid);
627
+ // Without the run's record the push would carry all of local dev, not the run's commits.
628
+ if (shared && rec === null && (mode === "dev" || o.fid !== undefined)) {
629
+ log(
630
+ `no shared-checkout record${o.fid === undefined ? "" : ` for ${o.fid}`} on ${branch} — refusing to push: it would carry commits the run does not own`,
631
+ );
632
+ return notPushed(EXIT_NO_RECORD);
633
+ }
593
634
  if (o.requireCi === true) {
594
- const message = git(cwd, ["log", "-1", "--pretty=%B"]) ?? "";
635
+ // With a record, the commit that reaches the remote last is the run's own.
636
+ const last = rec?.commits.at(-1) ?? "HEAD";
637
+ const message = git(cwd, ["log", "-1", "--pretty=%B", last]) ?? "";
595
638
  if (SKIP_CI_TOKEN.test(message)) {
596
639
  log(
597
640
  `HEAD message on ${branch} carries a CI-suppressing token, and this push needs a CI run — refusing`,
@@ -599,7 +642,7 @@ export function pushBranch(
599
642
  return notPushed(EXIT_SKIP_CI, { skipped: "skip-ci" });
600
643
  }
601
644
  }
602
- const shared = isSharedBranch(branch);
645
+ if (rec !== null) return pushOwnCommits(cwd, rec, o, log, notPushed);
603
646
  if (mode === "abort" && !shared) {
604
647
  const pr =
605
648
  openPrFlag === undefined
@@ -636,30 +679,539 @@ export function pushBranch(
636
679
  forced: !shared,
637
680
  skipped: null,
638
681
  prNumber: null,
682
+ replayed: false,
639
683
  },
640
684
  };
641
685
  }
642
686
 
643
- function pushVerb(ctx: RunContext): number {
687
+ /**
688
+ * `git fetch` of `ref` when it names a branch of origin (`origin/<b>`); null when
689
+ * it names anything else (a SHA, a local branch), which needs no fetch.
690
+ */
691
+ export function fetchRemoteRef(cwd: string, ref: string): { ok: boolean; stderr: string } | null {
692
+ const m = new RegExp(`^${REMOTE}/(.+)$`).exec(ref);
693
+ if (!m) return null;
694
+ return runGit(cwd, ["fetch", REMOTE, `+refs/heads/${m[1]}:refs/remotes/${REMOTE}/${m[1]}`]);
695
+ }
696
+
697
+ /** Commits HEAD holds beyond `ref`; 0 when the count cannot be read. */
698
+ function commitsAhead(cwd: string, ref: string): number {
699
+ const n = Number(git(cwd, ["rev-list", "--count", `${ref}..HEAD`]) ?? "0");
700
+ return Number.isFinite(n) ? n : 0;
701
+ }
702
+
703
+ /**
704
+ * `--mode=plain`: one `git push [-u] origin <branch>`, never forced. A feature
705
+ * branch only: dev / main and a branch with nothing beyond `aheadOf` have nothing to ship.
706
+ */
707
+ function pushPlain(
708
+ cwd: string,
709
+ branch: string,
710
+ o: { setUpstream?: boolean; aheadOf?: string; requireCi?: boolean },
711
+ log: (m: string) => void,
712
+ notPushed: (code: number, extra?: Partial<PushOutcome["out"]>) => PushOutcome,
713
+ ): PushOutcome {
714
+ if (isSharedBranch(branch)) {
715
+ log(`Nothing to ship: on '${branch}', no feature branch`);
716
+ return notPushed(EXIT_NOTHING_TO_PUSH);
717
+ }
718
+ if (o.aheadOf !== undefined) {
719
+ const fetched = fetchRemoteRef(cwd, o.aheadOf);
720
+ if (fetched !== null && !fetched.ok) {
721
+ log(`git fetch for ${o.aheadOf} failed: ${fetched.stderr} — counting against the local ref`);
722
+ }
723
+ if (commitsAhead(cwd, o.aheadOf) === 0) {
724
+ log(`Nothing to ship: ${branch} has no commits ahead of ${o.aheadOf}`);
725
+ return notPushed(EXIT_NOTHING_TO_PUSH);
726
+ }
727
+ }
728
+ if (o.requireCi === true && SKIP_CI_TOKEN.test(git(cwd, ["log", "-1", "--pretty=%B"]) ?? "")) {
729
+ log(
730
+ `HEAD message on ${branch} carries a CI-suppressing token, and this push needs a CI run — refusing`,
731
+ );
732
+ return notPushed(EXIT_SKIP_CI, { skipped: "skip-ci" });
733
+ }
734
+ const args = ["push", ...(o.setUpstream === true ? ["-u"] : []), REMOTE, branch];
735
+ const res = runGit(cwd, args);
736
+ if (!res.ok) {
737
+ log(`git ${args.join(" ")} failed: ${res.stderr}`);
738
+ return notPushed(EXIT_PUSH_FAILED);
739
+ }
740
+ log(`pushed ${branch}`);
741
+ return {
742
+ code: EXIT.OK,
743
+ out: {
744
+ pushed: true,
745
+ ref: branch,
746
+ sha: git(cwd, ["rev-parse", "HEAD"]),
747
+ forced: false,
748
+ skipped: null,
749
+ prNumber: null,
750
+ replayed: false,
751
+ },
752
+ };
753
+ }
754
+
755
+ /**
756
+ * The `key` of an engine-action row for a marker commit this run makes: keyed on the
757
+ * workflow's latest run, in progress or just closed by `workflows close`.
758
+ */
759
+ function markerKey(file: string, workflow: string, what: string): string {
760
+ const runs = fs.existsSync(file) ? readRuns(file).filter((r) => r.workflow === workflow) : [];
761
+ return actionKey(workflow, Math.max(runs.length, 1), what);
762
+ }
763
+
764
+ /**
765
+ * Make a marker commit once per run: an engine-action row with the same key and
766
+ * message whose commit is still on HEAD means it is already made (`deduped`).
767
+ * `addAll` stages every change first (`git add -A`); the commit is always
768
+ * allowed to be empty. The row is written before the caller pushes.
769
+ */
770
+ function markerCommit(
771
+ cwd: string,
772
+ o: { file: string; key: string; message: string; addAll: boolean },
773
+ ): { sha: string; deduped: boolean } {
774
+ const hash = actionHash(o.message);
775
+ const prior = alreadyDone(o.file, o.key, hash);
776
+ if (prior?.ref && runGit(cwd, ["merge-base", "--is-ancestor", prior.ref, "HEAD"]).ok) {
777
+ return { sha: prior.ref, deduped: true };
778
+ }
779
+ if (o.addAll) {
780
+ const added = runGit(cwd, ["add", "-A"]);
781
+ if (!added.ok) throw new CommandError(EXIT_PUSH_FAILED, `git add -A failed: ${added.stderr}`);
782
+ }
783
+ const made = runGit(cwd, ["commit", "--allow-empty", "-m", o.message]);
784
+ if (!made.ok) {
785
+ throw new CommandError(EXIT_PUSH_FAILED, `git commit failed: ${made.stderr || made.stdout}`);
786
+ }
787
+ const sha = git(cwd, ["rev-parse", "HEAD"]) ?? "";
788
+ recordAction(o.file, { action: "commit", key: o.key, hash, ref: sha });
789
+ return { sha, deduped: false };
790
+ }
791
+
792
+ const autoRouteSuffix = (labels: string[]) =>
793
+ labels.includes(AUTO_LABEL) ? AUTO_ROUTE_SUFFIX : "";
794
+
795
+ /** A replayed commit that does not apply onto origin/dev without the foreign commits it builds on. */
796
+ class ReplayConflict extends Error {}
797
+
798
+ /**
799
+ * The `pushToDev` build callback that replays `shas` (oldest first) onto the
800
+ * fresh origin/dev in `dir`, each as a cherry-pick that keeps its message and
801
+ * author and keeps empty commits. A commit that does not apply throws a
802
+ * ReplayConflict naming the conflicting paths, after aborting the cherry-pick.
803
+ */
804
+ export function replayBuild(shas: string[]): (dir: string) => void {
805
+ return (dir) => {
806
+ for (const sha of shas) {
807
+ const picked = runGit(dir, ["cherry-pick", "--allow-empty", "--keep-redundant-commits", sha]);
808
+ if (picked.ok) continue;
809
+ const paths = (git(dir, ["diff", "--name-only", "--diff-filter=U"]) ?? "")
810
+ .split("\n")
811
+ .filter(Boolean);
812
+ runGit(dir, ["cherry-pick", "--abort"]);
813
+ throw new ReplayConflict(
814
+ `commit ${sha.slice(0, 12)} does not apply onto ${UPSTREAM} without the local ${DEV} commits it builds on — ${
815
+ paths.length > 0 ? `conflicts in: ${paths.join(", ")}` : picked.stderr
816
+ }`,
817
+ );
818
+ }
819
+ };
820
+ }
821
+
822
+ /**
823
+ * Push only the commits an in-place run on dev made (the record's `commits`).
824
+ * Plain push of their tip SHA when origin/dev is an ancestor of local dev and they
825
+ * are exactly what local dev holds beyond it; otherwise (a foreign commit among
826
+ * them, origin/dev moved, or the plain push is rejected) they are replayed onto a
827
+ * fresh origin/dev in the throwaway checkout and pushed from there.
828
+ */
829
+ async function pushOwnCommits(
830
+ cwd: string,
831
+ rec: SharedCheckoutRecord,
832
+ o: { setUpstream?: boolean },
833
+ log: (m: string) => void,
834
+ notPushed: (code: number, extra?: Partial<PushOutcome["out"]>) => PushOutcome,
835
+ ): Promise<PushOutcome> {
836
+ const gone = rec.commits.filter(
837
+ (c) => !runGit(cwd, ["merge-base", "--is-ancestor", c, "HEAD"]).ok,
838
+ );
839
+ if (gone.length > 0) {
840
+ log(
841
+ `the run's commit(s) ${gone.map((c) => c.slice(0, 12)).join(", ")} are no longer on ${rec.branch} — refusing to push`,
842
+ );
843
+ return notPushed(EXIT_PUSH_FAILED);
844
+ }
845
+ const fetched = runGit(cwd, ["fetch", REMOTE, `+refs/heads/${DEV}:refs/remotes/${UPSTREAM}`]);
846
+ if (!fetched.ok) {
847
+ log(`git fetch ${REMOTE} ${DEV} failed: ${fetched.stderr}`);
848
+ return notPushed(EXIT_FETCH_FAILED);
849
+ }
850
+ // Oldest first, minus what origin/dev already has (pushed plain before) and
851
+ // what an earlier replay already landed.
852
+ const mine = new Set(rec.commits);
853
+ const landed = new Set(rec.pushed ?? []);
854
+ const range = runGit(cwd, ["rev-parse", "-q", "--verify", `${rec.startSha}^{commit}`]).ok
855
+ ? `${rec.startSha}..HEAD`
856
+ : "HEAD";
857
+ const pending = (git(cwd, ["rev-list", "--reverse", range]) ?? "")
858
+ .split("\n")
859
+ .filter(
860
+ (c) =>
861
+ mine.has(c) &&
862
+ !landed.has(c) &&
863
+ !runGit(cwd, ["merge-base", "--is-ancestor", c, UPSTREAM]).ok,
864
+ );
865
+ if (pending.length === 0) {
866
+ log("every commit the run made is already on origin/dev — nothing to push");
867
+ return notPushed(EXIT.OK, { skipped: "no-run-commits" });
868
+ }
869
+ const ahead = (git(cwd, ["rev-list", "--reverse", `${UPSTREAM}..HEAD`]) ?? "")
870
+ .split("\n")
871
+ .filter(Boolean);
872
+ // Plain only when origin/dev is an ancestor of local dev (a fast-forward) and
873
+ // the run's commits are all local dev holds beyond it; the explicit SHA keeps
874
+ // a commit made after the check out of the push.
875
+ const fastForward = runGit(cwd, ["merge-base", "--is-ancestor", UPSTREAM, "HEAD"]).ok;
876
+ if (fastForward && ahead.length === pending.length && ahead.every((c, i) => c === pending[i])) {
877
+ const last = pending[pending.length - 1];
878
+ const args = [
879
+ "push",
880
+ ...(o.setUpstream === true ? ["-u"] : []),
881
+ REMOTE,
882
+ `${last}:refs/heads/${rec.branch}`,
883
+ ];
884
+ const res = runGit(cwd, args);
885
+ if (res.ok) {
886
+ log(`pushed ${rec.branch}: the run's ${pending.length} commit(s) are all local dev holds`);
887
+ return {
888
+ code: EXIT.OK,
889
+ out: {
890
+ pushed: true,
891
+ ref: rec.branch,
892
+ sha: last,
893
+ forced: false,
894
+ skipped: null,
895
+ prNumber: null,
896
+ replayed: false,
897
+ },
898
+ };
899
+ }
900
+ log(`git ${args.join(" ")} failed: ${res.stderr} — replaying onto a fresh ${UPSTREAM}`);
901
+ }
902
+
903
+ const root = repoRoot(cwd);
904
+ let res: Awaited<ReturnType<typeof pushToDev>>;
905
+ try {
906
+ res = await pushToDev({
907
+ root,
908
+ dir: landDir(root, rec.fid),
909
+ build: replayBuild(pending),
910
+ log,
911
+ });
912
+ } catch (err) {
913
+ if (!(err instanceof ReplayConflict)) throw err;
914
+ log(`replaying the run's commits onto ${UPSTREAM} stopped: ${err.message}`);
915
+ return notPushed(EXIT_MERGE_CONFLICT);
916
+ }
917
+ switch (res.kind) {
918
+ case "landed":
919
+ markRecordPushed(cwd, rec.fid, pending);
920
+ log(
921
+ `pushed ${pending.length} commit(s) of the run to ${DEV} as copies on a fresh ${UPSTREAM} (${res.sha.slice(0, 12)}); local ${DEV} still holds the originals beside other commits — resync with: git pull --rebase ${REMOTE} ${DEV}`,
922
+ );
923
+ return {
924
+ code: EXIT.OK,
925
+ out: {
926
+ pushed: true,
927
+ ref: rec.branch,
928
+ sha: res.sha,
929
+ forced: false,
930
+ skipped: null,
931
+ prNumber: null,
932
+ replayed: true,
933
+ },
934
+ };
935
+ case "refused":
936
+ log(`${DEV} refused the push: ${res.stderr}`);
937
+ return notPushed(EXIT_PUSH_FAILED);
938
+ case "push-failed":
939
+ log(`push to ${DEV} failed without a server answer: ${res.stderr}`);
940
+ return notPushed(EXIT_PUSH_FAILED);
941
+ case "exhausted":
942
+ log(`${DEV} moved before each of ${res.attempts} pushes`);
943
+ return notPushed(EXIT_PUSH_FAILED);
944
+ case "fetch-failed":
945
+ log(`git fetch ${REMOTE} ${DEV} failed: ${res.stderr}`);
946
+ return notPushed(EXIT_FETCH_FAILED);
947
+ case "setup-failed":
948
+ log(`throwaway checkout failed: ${res.stderr}`);
949
+ return notPushed(EXIT_PUSH_FAILED);
950
+ }
951
+ }
952
+
953
+ async function pushVerb(ctx: RunContext): Promise<number> {
644
954
  const mode = String(ctx.flags.mode);
645
- if (!["feature", "abort", "dev"].includes(mode)) {
646
- throw new CommandError(EXIT.USAGE, "--mode must be feature, abort, or dev");
955
+ if (!["feature", "abort", "dev", "plain"].includes(mode)) {
956
+ throw new CommandError(EXIT.USAGE, "--mode must be feature, abort, dev, or plain");
957
+ }
958
+ const aheadOf = str(ctx.flags.aheadOf);
959
+ if (aheadOf !== undefined && mode !== "plain") {
960
+ throw new CommandError(EXIT.USAGE, "--ahead-of applies to --mode=plain only");
961
+ }
962
+ const commitMessage = str(ctx.flags.commit);
963
+ let marker: { sha: string; deduped: boolean } | undefined;
964
+ if (commitMessage !== undefined) {
965
+ const file = str(ctx.flags.file);
966
+ const workflow = str(ctx.flags.workflow);
967
+ if (mode !== "feature" || file === undefined || workflow === undefined) {
968
+ throw new CommandError(
969
+ EXIT.USAGE,
970
+ "--commit needs --mode=feature, --file (status.jsonl) and --workflow",
971
+ );
972
+ }
973
+ const branch = currentBranch(ctx.cwd);
974
+ if (branch === "") {
975
+ ctx.log("no branch checked out (detached HEAD) — refusing to commit and push");
976
+ return EXIT_DETACHED;
977
+ }
978
+ if (isSharedBranch(branch)) {
979
+ ctx.log(
980
+ `Nothing to ship: --commit makes a marker commit on a feature branch, not '${branch}'`,
981
+ );
982
+ return EXIT_NOTHING_TO_PUSH;
983
+ }
984
+ const message = `${commitMessage}${autoRouteSuffix((ctx.flags.label as string[] | undefined) ?? [])}`;
985
+ if (ctx.flags.requireCi === true && SKIP_CI_TOKEN.test(message)) {
986
+ ctx.log(
987
+ "the --commit message carries a CI-suppressing token, and this push needs a CI run — refusing",
988
+ );
989
+ ctx.emit({
990
+ pushed: false,
991
+ ref: null,
992
+ sha: null,
993
+ forced: false,
994
+ skipped: "skip-ci",
995
+ prNumber: null,
996
+ replayed: false,
997
+ });
998
+ return EXIT_SKIP_CI;
999
+ }
1000
+ marker = markerCommit(ctx.cwd, {
1001
+ file: path.resolve(ctx.cwd, file),
1002
+ key: markerKey(path.resolve(ctx.cwd, file), workflow, "push-commit"),
1003
+ message,
1004
+ addAll: true,
1005
+ });
1006
+ if (marker.deduped)
1007
+ ctx.log(`marker commit ${marker.sha.slice(0, 12)} already made this run — pushing it`);
647
1008
  }
648
- const r = pushBranch(
1009
+ const r = await pushBranch(
649
1010
  ctx.cwd,
650
1011
  {
651
- mode: mode as "feature" | "abort" | "dev",
1012
+ mode: mode as "feature" | "abort" | "dev" | "plain",
652
1013
  setUpstream: ctx.flags.setUpstream === true,
1014
+ aheadOf,
653
1015
  requireCi: ctx.flags.requireCi === true,
654
1016
  openPr: str(ctx.flags.openPr),
1017
+ fid: str(ctx.flags.fid),
655
1018
  },
656
1019
  ctx.log,
657
1020
  );
658
1021
  // A detached HEAD and a wrong checkout print nothing, as the push never got to run.
659
- if (r.code !== EXIT_DETACHED && r.code !== EXIT_NOT_DEV) ctx.emit(r.out);
1022
+ if (r.code !== EXIT_DETACHED && r.code !== EXIT_NOT_DEV) {
1023
+ ctx.emit(
1024
+ marker === undefined ? r.out : { ...r.out, commit: marker.sha, deduped: marker.deduped },
1025
+ );
1026
+ }
660
1027
  return r.code;
661
1028
  }
662
1029
 
1030
+ function fastForwardVerb(ctx: RunContext): number {
1031
+ const onto = String(ctx.flags.onto);
1032
+ const top = topLevel(ctx.cwd);
1033
+ const fetched = fetchRemoteRef(top, onto);
1034
+ if (fetched !== null && !fetched.ok) {
1035
+ ctx.log(`git fetch for ${onto} failed: ${fetched.stderr}`);
1036
+ return EXIT_FETCH_FAILED;
1037
+ }
1038
+ if (!runGit(top, ["rev-parse", "-q", "--verify", `${onto}^{commit}`]).ok) {
1039
+ ctx.log(`unknown ref: ${onto}`);
1040
+ return EXIT_FETCH_FAILED;
1041
+ }
1042
+ const before = git(top, ["rev-parse", "HEAD"]);
1043
+ if (runGit(top, ["merge-base", "--is-ancestor", onto, "HEAD"]).ok) {
1044
+ ctx.emit({ moved: false, head: before });
1045
+ return EXIT.OK;
1046
+ }
1047
+ const merged = runGit(top, ["merge", "--ff-only", onto]);
1048
+ if (!merged.ok) {
1049
+ ctx.log(`local ${currentBranch(top) || "HEAD"} diverged from ${onto} — reconcile, then re-run`);
1050
+ return EXIT_DIVERGED;
1051
+ }
1052
+ const head = git(top, ["rev-parse", "HEAD"]);
1053
+ ctx.log(`fast-forwarded onto ${onto} (${head?.slice(0, 12) ?? ""})`);
1054
+ ctx.emit({ moved: head !== before, head });
1055
+ return EXIT.OK;
1056
+ }
1057
+
1058
+ /** Paths a source-change check leaves out: plan logs and the append-only ledgers. */
1059
+ const NOT_CODE = [":(exclude)docs/plans", ":(exclude)docs/*.jsonl", ":(exclude).bkit/*.jsonl"];
1060
+
1061
+ function scanDiffVerb(ctx: RunContext): number {
1062
+ const base = String(ctx.flags.base);
1063
+ const pattern = str(ctx.flags.paths);
1064
+ const marker = str(ctx.flags.marker);
1065
+ const code = ctx.flags.code === true;
1066
+ if ([pattern !== undefined, marker !== undefined, code].filter(Boolean).length !== 1) {
1067
+ throw new CommandError(EXIT.USAGE, "give exactly one of --paths, --marker, --code");
1068
+ }
1069
+ let re: RegExp | undefined;
1070
+ if (pattern !== undefined) {
1071
+ try {
1072
+ re = new RegExp(pattern, "i");
1073
+ } catch (err) {
1074
+ ctx.log(`--paths is not a valid pattern: ${(err as Error).message}`);
1075
+ return EXIT.USAGE;
1076
+ }
1077
+ }
1078
+ const top = topLevel(ctx.cwd);
1079
+ const fetched = fetchRemoteRef(top, base);
1080
+ if (fetched !== null && !fetched.ok) {
1081
+ ctx.log(`git fetch for ${base} failed: ${fetched.stderr} — diffing against the local ref`);
1082
+ }
1083
+ if (!runGit(top, ["rev-parse", "-q", "--verify", `${base}^{commit}`]).ok) {
1084
+ ctx.log(`unknown base: ${base}`);
1085
+ return EXIT_DIFF_FAILED;
1086
+ }
1087
+ const range = `${base}...HEAD`;
1088
+ let paths: string[];
1089
+ if (marker !== undefined) {
1090
+ const diff = quietGit(top, ["diff", "--no-renames", range, "--", ".", ":(exclude)docs/plans"]);
1091
+ if (!diff.ok) {
1092
+ ctx.log(`git diff ${range} failed: ${diff.stderr}`);
1093
+ return EXIT_DIFF_FAILED;
1094
+ }
1095
+ const hits = new Set<string>();
1096
+ let file = "";
1097
+ for (const line of diff.stdout.split("\n")) {
1098
+ if (line.startsWith("+++ ")) {
1099
+ file = line.replace(/^\+\+\+ (b\/)?/, "");
1100
+ continue;
1101
+ }
1102
+ if (line.startsWith("+") && line.includes(marker)) hits.add(file);
1103
+ }
1104
+ paths = [...hits];
1105
+ } else {
1106
+ const diff = quietGit(top, [
1107
+ "diff",
1108
+ "--name-only",
1109
+ "-z",
1110
+ "--no-renames",
1111
+ range,
1112
+ ...(code ? ["--", ".", ...NOT_CODE] : []),
1113
+ ]);
1114
+ if (!diff.ok) {
1115
+ ctx.log(`git diff ${range} failed: ${diff.stderr}`);
1116
+ return EXIT_DIFF_FAILED;
1117
+ }
1118
+ paths = diff.stdout.split("\0").filter(Boolean);
1119
+ if (re !== undefined) paths = paths.filter((p) => re.test(p));
1120
+ }
1121
+ ctx.emit({ found: paths.length > 0, paths });
1122
+ if (ctx.flags.expectNone === true) {
1123
+ if (paths.length > 0) {
1124
+ ctx.log(
1125
+ marker !== undefined
1126
+ ? `added lines still carry ${marker} in: ${paths.join(", ")}`
1127
+ : `expected no match, found: ${paths.join(", ")}`,
1128
+ );
1129
+ }
1130
+ return paths.length > 0 ? EXIT.NO : EXIT.OK;
1131
+ }
1132
+ return paths.length > 0 ? EXIT.OK : EXIT.NO;
1133
+ }
1134
+
1135
+ async function forceBuildVerb(ctx: RunContext): Promise<number> {
1136
+ const f = ctx.flags;
1137
+ const fid = String(f.fid);
1138
+ const file = path.resolve(ctx.cwd, String(f.file));
1139
+ const workflow = String(f.workflow);
1140
+ const openPrFlag = str(f.openPr);
1141
+ if (openPrFlag !== undefined && openPrFlag !== "none" && !/^[1-9][0-9]*$/.test(openPrFlag)) {
1142
+ throw new CommandError(
1143
+ EXIT.USAGE,
1144
+ `--open-pr must be a PR number or none, got "${openPrFlag}"`,
1145
+ );
1146
+ }
1147
+ const branch = currentBranch(ctx.cwd);
1148
+ if (branch === "") {
1149
+ ctx.log("no branch checked out (detached HEAD) — refusing to force a build");
1150
+ return EXIT_DETACHED;
1151
+ }
1152
+ if (isSharedBranch(branch)) {
1153
+ ctx.log(`Nothing to ship: force-build marks a feature branch, not '${branch}'`);
1154
+ return EXIT_NOTHING_TO_PUSH;
1155
+ }
1156
+
1157
+ // (1) The PR title: CI reads the marker from it on pull_request events.
1158
+ const viaMcp = (why: string) => {
1159
+ ctx.log(
1160
+ `${why} — add " bkit ${FORCE_BUILD}" to the open PR's title through update_pull_request (skip when no PR is open), then re-run with --title-set`,
1161
+ );
1162
+ return EXIT.USE_MCP;
1163
+ };
1164
+ let prNumber: number | null = null;
1165
+ let titleChanged = false;
1166
+ if (f.titleSet !== true && openPrFlag !== "none") {
1167
+ const probe = probePr(
1168
+ ctx.cwd,
1169
+ openPrFlag === undefined
1170
+ ? { head: branch, state: "open" }
1171
+ : { number: openPrFlag, state: "open" },
1172
+ );
1173
+ if (probe.kind !== "ok") return viaMcp(probe.message);
1174
+ if (probe.pr) {
1175
+ prNumber = probe.pr.number;
1176
+ if (!probe.pr.title.includes(FORCE_BUILD)) {
1177
+ const next = `${probe.pr.title} bkit ${FORCE_BUILD}`;
1178
+ const edit = runGh(ctx.cwd, ["pr", "edit", String(prNumber), "--title", next]);
1179
+ if (!edit.ok) {
1180
+ return viaMcp(
1181
+ ghUnavailable(edit)
1182
+ ? "gh unavailable for gh pr edit"
1183
+ : `gh pr edit ${prNumber} failed: ${edit.stderr}`,
1184
+ );
1185
+ }
1186
+ titleChanged = true;
1187
+ ctx.log(`PR #${prNumber} title now carries ${FORCE_BUILD}`);
1188
+ }
1189
+ }
1190
+ }
1191
+
1192
+ // (2) The empty marker commit, once per run; its push is the event that starts the run.
1193
+ const message = `chore(${fid}): force build bkit ${FORCE_BUILD}${autoRouteSuffix((f.label as string[] | undefined) ?? [])}`;
1194
+ const marker = markerCommit(ctx.cwd, {
1195
+ file,
1196
+ key: markerKey(file, workflow, "force-build"),
1197
+ message,
1198
+ addAll: false,
1199
+ });
1200
+ if (marker.deduped)
1201
+ ctx.log(`force-build commit ${marker.sha.slice(0, 12)} already made this run — pushing it`);
1202
+ const pushed = await pushBranch(ctx.cwd, { mode: "feature", requireCi: true }, ctx.log);
1203
+ ctx.emit({
1204
+ prNumber,
1205
+ titleChanged,
1206
+ commit: marker.sha,
1207
+ deduped: marker.deduped,
1208
+ pushed: pushed.out.pushed,
1209
+ ref: pushed.out.ref,
1210
+ sha: pushed.out.sha,
1211
+ });
1212
+ return pushed.code;
1213
+ }
1214
+
663
1215
  /** Resolve sync's docs-merge conflicts: ledgers by union, other `docs/` paths take dev's side. */
664
1216
  function resolveDocsMerge(top: string): { resolved: Resolution[] } | { refused: string } {
665
1217
  const conflicts = unmergedPaths(top);
@@ -769,13 +1321,6 @@ function syncVerb(ctx: RunContext): number {
769
1321
  */
770
1322
  function syncDevVerb(ctx: RunContext): number {
771
1323
  const root = repoRoot(ctx.cwd);
772
- // `bkit install` can leave core.bare=true on the main checkout, which breaks `merge --ff-only` there.
773
- if (
774
- git(root, ["config", "--get", "core.bare"]) === "true" &&
775
- fs.statSync(path.join(root, ".git"), { throwIfNoEntry: false })?.isDirectory()
776
- ) {
777
- runGit(root, ["config", "core.bare", "false"]);
778
- }
779
1324
  const fetch = runGit(root, ["fetch", REMOTE, DEV]);
780
1325
  if (!fetch.ok) {
781
1326
  ctx.log(`git fetch ${REMOTE} ${DEV} failed: ${fetch.stderr}`);
@@ -810,7 +1355,7 @@ function install(ctx: RunContext, root: string): boolean | null {
810
1355
  /** What a design / plan close may bring to dev: docs and ledgers, nothing else. */
811
1356
  const CLOSE_DOCS = /^docs\/plans\/|^docs\/roadmap\.md$|^docs\/[^/]+\.jsonl$|^\.bkit\/[^/]+\.jsonl$/;
812
1357
 
813
- /** The canonical docs `ref` carries for the feature: design, or plan plus sub-plans. */
1358
+ /** The canonical doc `ref` carries for the feature: `{fid}-design.md` or `{fid}-plan.md`. */
814
1359
  function canonicalDocs(
815
1360
  root: string,
816
1361
  ref: string,
@@ -818,10 +1363,7 @@ function canonicalDocs(
818
1363
  month: string,
819
1364
  fid: string,
820
1365
  ): string[] {
821
- const re =
822
- workflow === "plan"
823
- ? new RegExp(`^docs/plans/${month}/${fid}-plan(-[0-9]+)?\\.md$`)
824
- : new RegExp(`^docs/plans/${month}/${fid}-design\\.md$`);
1366
+ const re = new RegExp(`^docs/plans/${month}/${fid}-${workflow}\\.md$`);
825
1367
  return (git(root, ["ls-tree", "-r", "--name-only", ref, "--", `docs/plans/${month}/`]) ?? "")
826
1368
  .split("\n")
827
1369
  .filter((f) => re.test(f));
@@ -1064,7 +1606,7 @@ async function landPr(
1064
1606
  EXIT_LAND_STOPPED,
1065
1607
  `${o.workflow} close diff carries non-doc files:\n${stray.join("\n")}`,
1066
1608
  );
1067
- const pushed = pushBranch(tree, { mode: "feature" }, ctx.log);
1609
+ const pushed = await pushBranch(tree, { mode: "feature" }, ctx.log);
1068
1610
  if (pushed.code !== EXIT.OK)
1069
1611
  throw new Stop(
1070
1612
  EXIT_PUSH_FAILED,
@@ -1099,6 +1641,11 @@ async function landPr(
1099
1641
  ctx.emit({ stage: "merge", prNumber: Number(prNumber), subject, body: "" });
1100
1642
  return EXIT.USE_MCP;
1101
1643
  }
1644
+ if (merged.code === EXIT_BASE_NOT_DEV)
1645
+ throw new Stop(
1646
+ EXIT_LAND_STOPPED,
1647
+ `PR ${prNumber} does not target ${DEV} — bkit merges into ${DEV} only, releases stay manual; nothing merged, PR left open`,
1648
+ );
1102
1649
  if (merged.out.merged) {
1103
1650
  sha = merged.out.mergeCommitOid ?? "";
1104
1651
  break;
@@ -1214,13 +1761,6 @@ async function landVerb(ctx: RunContext): Promise<number> {
1214
1761
  const fid = String(ctx.flags.fid);
1215
1762
  const root = repoRoot(ctx.cwd);
1216
1763
  const month = resolveMonth(root, fid, str(ctx.flags.month));
1217
- // `bkit install` can leave core.bare=true on the main checkout, which breaks every worktree below.
1218
- if (
1219
- git(root, ["config", "--get", "core.bare"]) === "true" &&
1220
- fs.statSync(path.join(root, ".git"), { throwIfNoEntry: false })?.isDirectory()
1221
- ) {
1222
- runGit(root, ["config", "core.bare", "false"]);
1223
- }
1224
1764
  const worktreeStatus = path.join(
1225
1765
  git(ctx.cwd, ["rev-parse", "--show-toplevel"]) ?? root,
1226
1766
  "docs",
@@ -1464,9 +2004,27 @@ export const branchesCommand: CommandSpec = {
1464
2004
  name: "mode",
1465
2005
  type: "string",
1466
2006
  required: true,
1467
- help: "feature (a step's push) | abort (Failure Path: never into an open PR) | dev (the checkout must be on dev)",
2007
+ help: "feature (a step's push) | abort (Failure Path: never into an open PR) | dev (the checkout must be on dev) | plain (a feature branch, never forced)",
1468
2008
  },
1469
2009
  { name: "set-upstream", type: "boolean", help: "push with -u" },
2010
+ {
2011
+ name: "ahead-of",
2012
+ type: "string",
2013
+ help: "--mode=plain: refuse (21) when HEAD has no commits beyond this ref; an origin/<branch> ref is fetched first",
2014
+ },
2015
+ {
2016
+ name: "commit",
2017
+ type: "string",
2018
+ help: "--mode=feature: `git add -A`, then an allow-empty commit with this message (plus ` bkit [auto route]` when --label holds bkit:auto), once per run, before the push",
2019
+ },
2020
+ {
2021
+ name: "label",
2022
+ type: "string",
2023
+ repeatable: true,
2024
+ help: "--commit: the issue's labels, one per flag",
2025
+ },
2026
+ { name: "file", type: "string", help: "--commit: status.jsonl for the engine-action row" },
2027
+ { name: "workflow", type: "string", help: "--commit: the workflow, for the run number" },
1470
2028
  {
1471
2029
  name: "require-ci",
1472
2030
  type: "boolean",
@@ -1477,25 +2035,146 @@ export const branchesCommand: CommandSpec = {
1477
2035
  type: "string",
1478
2036
  help: "--mode=abort: the open-PR answer from MCP (a number, or none) instead of asking gh",
1479
2037
  },
2038
+ {
2039
+ name: "fid",
2040
+ type: "string",
2041
+ help: "an in-place run on dev: its FID, which selects the run's shared-checkout record; with it a missing record refuses the push",
2042
+ },
1480
2043
  ],
1481
2044
  output: {
1482
2045
  pushed: "true when the push ran and succeeded",
2046
+ replayed:
2047
+ "true when the run's commits went out as copies cherry-picked onto a fresh origin/dev (an in-place run on dev whose local dev holds other commits); sha is then the landed origin/dev commit",
1483
2048
  ref: "the branch pushed — link handover artifacts to this ref; null when nothing was pushed",
1484
2049
  sha: "HEAD commit pushed (null when not pushed)",
1485
2050
  forced: "true when pushed with --force-with-lease",
1486
- skipped: "why the push did not run: open-pr | skip-ci (null otherwise)",
2051
+ skipped:
2052
+ "why the push did not run: open-pr | skip-ci | no-run-commits (an in-place run on dev with nothing new to push) (null otherwise)",
1487
2053
  prNumber: "the open PR that stopped an abort push (null otherwise)",
2054
+ commit: "--commit: the marker commit's sha",
2055
+ deduped: "--commit: the marker commit was already made this run (not made again)",
1488
2056
  },
1489
2057
  exitCodes: {
1490
2058
  [EXIT_DETACHED]: "no branch checked out",
2059
+ [EXIT_NOTHING_TO_PUSH]:
2060
+ "--mode=plain or --commit on dev / main, or --ahead-of and HEAD has no commits beyond it",
1491
2061
  [EXIT_SKIP_CI]: "--require-ci and the HEAD message carries a skip-CI token",
1492
2062
  [EXIT_OPEN_PR]:
1493
2063
  "--mode=abort and the branch has an open PR: push skipped, remote HEAD kept",
1494
- [EXIT_PUSH_FAILED]: "git push failed",
2064
+ [EXIT_PUSH_FAILED]:
2065
+ "git push failed, or dev refused a replayed push (in-place run on dev: the refusal is printed)",
1495
2066
  [EXIT_NOT_DEV]: "--mode=dev and the checkout is not on dev",
2067
+ [EXIT_NO_RECORD]:
2068
+ "--mode=dev, or --fid, on dev with no shared-checkout record for the run: nothing pushed",
2069
+ [EXIT_FETCH_FAILED]: "in-place run on dev: fetching origin/dev failed",
2070
+ [EXIT_MERGE_CONFLICT]:
2071
+ "in-place run on dev: a run commit does not apply onto origin/dev without the local commits it builds on; the conflicting paths are printed, nothing pushed",
1496
2072
  },
1497
2073
  run: pushVerb,
1498
2074
  },
2075
+ "fast-forward": {
2076
+ summary: "Fetch a remote branch and fast-forward the checkout onto it; refuse when diverged.",
2077
+ flags: [
2078
+ {
2079
+ name: "onto",
2080
+ type: "string",
2081
+ required: true,
2082
+ help: "the ref to fast-forward onto; an origin/<branch> ref is fetched first",
2083
+ },
2084
+ ],
2085
+ output: { moved: "HEAD moved", head: "HEAD after" },
2086
+ exitCodes: {
2087
+ [EXIT_FETCH_FAILED]: "fetching --onto failed, or it does not resolve",
2088
+ [EXIT_DIVERGED]: "the checkout has commits --onto lacks: nothing moved",
2089
+ },
2090
+ run: fastForwardVerb,
2091
+ },
2092
+ "scan-diff": {
2093
+ summary:
2094
+ "Exit 0 when the branch's diff from --base matches (paths, an added marker line, or a source change); 1 when not.",
2095
+ flags: [
2096
+ {
2097
+ name: "base",
2098
+ type: "string",
2099
+ required: true,
2100
+ help: "diff <base>...HEAD; an origin/<branch> base is fetched first",
2101
+ },
2102
+ {
2103
+ name: "paths",
2104
+ type: "string",
2105
+ help: "a changed path matches this pattern (case-insensitive)",
2106
+ },
2107
+ {
2108
+ name: "marker",
2109
+ type: "string",
2110
+ help: "an added line carries this text, outside docs/plans",
2111
+ },
2112
+ {
2113
+ name: "code",
2114
+ type: "boolean",
2115
+ help: "a path changed outside docs/plans, docs/*.jsonl and .bkit/*.jsonl",
2116
+ },
2117
+ {
2118
+ name: "expect-none",
2119
+ type: "boolean",
2120
+ help: "invert the exit: 0 when nothing matched, 1 (naming the paths on stderr) when something did",
2121
+ },
2122
+ ],
2123
+ output: { found: "something matched", paths: "the matching paths" },
2124
+ exitCodes: {
2125
+ [EXIT_DIFF_FAILED]: "--base does not resolve, or git diff failed",
2126
+ },
2127
+ run: scanDiffVerb,
2128
+ },
2129
+ "force-build": {
2130
+ summary: `Force a full CI build: put ${FORCE_BUILD} on the open PR's title, then push an empty marker commit (once per run).`,
2131
+ flags: [
2132
+ { name: "fid", type: "string", required: true, help: "feature id, for the commit subject" },
2133
+ {
2134
+ name: "file",
2135
+ type: "string",
2136
+ required: true,
2137
+ help: "status.jsonl for the engine-action row",
2138
+ },
2139
+ {
2140
+ name: "workflow",
2141
+ type: "string",
2142
+ required: true,
2143
+ help: "the workflow, for the run number",
2144
+ },
2145
+ {
2146
+ name: "label",
2147
+ type: "string",
2148
+ repeatable: true,
2149
+ help: "the issue's labels; bkit:auto adds ` bkit [auto route]` to the commit",
2150
+ },
2151
+ {
2152
+ name: "open-pr",
2153
+ type: "string",
2154
+ help: "the open-PR answer from MCP (a number, or none) instead of asking gh",
2155
+ },
2156
+ {
2157
+ name: "title-set",
2158
+ type: "boolean",
2159
+ help: "the title is handled (set through MCP, or no PR is open): skip gh",
2160
+ },
2161
+ ],
2162
+ output: {
2163
+ prNumber: "the open PR whose title was checked, or null",
2164
+ titleChanged: `the title gained ${FORCE_BUILD}`,
2165
+ commit: "the marker commit's sha",
2166
+ deduped: "the marker commit was already made this run",
2167
+ pushed: "the push ran and succeeded",
2168
+ ref: "the branch pushed",
2169
+ sha: "HEAD pushed",
2170
+ },
2171
+ exitCodes: {
2172
+ [EXIT_DETACHED]: "no branch checked out",
2173
+ [EXIT_NOTHING_TO_PUSH]: "on dev / main",
2174
+ [EXIT_PUSH_FAILED]: "git commit or git push failed",
2175
+ },
2176
+ run: forceBuildVerb,
2177
+ },
1499
2178
  rebase: {
1500
2179
  summary:
1501
2180
  "Drive a rebase to completion, auto-resolving ledger (union) and lockfile (regenerate) conflicts; refuse and abort on anything else.",
@@ -1592,7 +2271,7 @@ export const branchesCommand: CommandSpec = {
1592
2271
  "dev moved before every one of LAND_ATTEMPTS pushes, or the PR branch push failed (nothing landed)",
1593
2272
  [EXIT_FETCH_FAILED]: `git fetch ${REMOTE} ${DEV} failed (nothing landed)`,
1594
2273
  [EXIT_LAND_STOPPED]:
1595
- "a guard stopped the land: stray files, failed squash, staged non-doc files, canonical blob mismatch, no checkout holds the branch, PR not opened / not merged after LAND_ATTEMPTS tries (nothing landed; the PR stays open)",
2274
+ "a guard stopped the land: stray files, failed squash, staged non-doc files, canonical blob mismatch, no checkout holds the branch, PR not opened / not merged after LAND_ATTEMPTS tries, PR base not dev or unreadable (nothing landed; the PR stays open)",
1596
2275
  [EXIT_LANDED_UNVERIFIED]:
1597
2276
  "landed, but the body scan, transport cross-check or canonical-on-dev check failed",
1598
2277
  [EXIT_LOCK_LEFT]: "landed and audited, but the workflow lock file survived removal",