@cbartens/bkit 5.5.1 → 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 (288) 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 +35 -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 +19 -18
  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 +91 -167
  13. package/.bkit/core/.bkit/providers.md +29 -32
  14. package/.bkit/core/.bkit/templates.md +12 -11
  15. package/.bkit/core/.bkit/trackers.md +51 -28
  16. package/.bkit/core/.bkit/workflows.md +394 -355
  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 -29
  55. package/.bkit/core/engine/checks/after/github.ts +95 -17
  56. package/.bkit/core/engine/checks/after/index.ts +10 -7
  57. package/.bkit/core/engine/checks/after/suppression.ts +8 -5
  58. package/.bkit/core/engine/checks/after/tools.ts +46 -91
  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 +6 -6
  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 +407 -64
  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 +58 -8
  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 +185 -8
  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 +250 -3
  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 +157 -20
  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 +29 -15
  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 +32 -14
  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 +72 -18
  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 +29 -14
  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 +27 -12
  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 +41 -18
  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 +11 -11
  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 +16 -7
  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 +1 -1
  195. package/.bkit/templates/.github/workflows/bkit-cloud.yml +21 -19
  196. package/.bkit/templates/.husky/pre-push +4 -4
  197. package/.bkit/templates/.prettierignore +7 -0
  198. package/.bkit/templates/scripts/cleanup/bkit-disk-prune.mjs +1 -1
  199. package/CHANGELOG.md +112 -0
  200. package/README.md +50 -35
  201. package/dist/checks/after/ci-yml.js +39 -28
  202. package/dist/checks/after/github.js +91 -17
  203. package/dist/checks/after/index.js +11 -8
  204. package/dist/checks/after/suppression.js +8 -5
  205. package/dist/checks/after/tools.js +39 -82
  206. package/dist/checks/before/env.js +2 -2
  207. package/dist/checks/before/files.js +5 -3
  208. package/dist/checks/before/index.js +15 -2
  209. package/dist/checks/before/repo.js +163 -2
  210. package/dist/checks/tips/catalogue.js +14 -5
  211. package/dist/checks/tips/detect.js +32 -0
  212. package/dist/checks/tips/index.js +4 -4
  213. package/dist/cli.js +19 -47
  214. package/dist/commands/analysis.js +109 -100
  215. package/dist/commands/ci/ci.js +6 -6
  216. package/dist/commands/comply.js +54 -91
  217. package/dist/commands/install/doctor.js +2 -2
  218. package/dist/commands/install/install.js +50 -19
  219. package/dist/commands/install/uninstall.js +59 -28
  220. package/dist/commands/land.js +16 -12
  221. package/dist/commands/lib.js +51 -16
  222. package/dist/commands/registry.js +4 -0
  223. package/dist/commands/setup/setup.js +7 -7
  224. package/dist/commands/stats.js +136 -0
  225. package/dist/commands/tips.js +7 -3
  226. package/dist/commands/workflow/branches.js +656 -56
  227. package/dist/commands/workflow/challenge.js +556 -0
  228. package/dist/commands/workflow/context.js +709 -30
  229. package/dist/commands/workflow/counters.js +208 -75
  230. package/dist/commands/workflow/decisions.js +441 -0
  231. package/dist/commands/workflow/disk.js +2 -2
  232. package/dist/commands/workflow/fids.js +689 -33
  233. package/dist/commands/workflow/issues.js +343 -59
  234. package/dist/commands/workflow/ledgers.js +762 -27
  235. package/dist/commands/workflow/locks.js +24 -2
  236. package/dist/commands/workflow/plan-blocks.js +437 -0
  237. package/dist/commands/workflow/plan-versions.js +22 -0
  238. package/dist/commands/workflow/prs.js +142 -32
  239. package/dist/commands/workflow/repo.js +52 -8
  240. package/dist/commands/workflow/roadmap.js +9 -7
  241. package/dist/commands/workflow/run-facts.js +426 -0
  242. package/dist/commands/workflow/runs.js +144 -43
  243. package/dist/commands/workflow/runtime.js +12 -1
  244. package/dist/commands/workflow/status.js +130 -29
  245. package/dist/commands/workflow/step-table.js +276 -0
  246. package/dist/commands/workflow/steps.js +171 -80
  247. package/dist/commands/workflow/summary.js +275 -0
  248. package/dist/commands/workflow/tests.js +834 -136
  249. package/dist/commands/workflow/tracker.js +983 -0
  250. package/dist/commands/workflow/workflows.js +834 -195
  251. package/dist/commands/workflow/workstreams.js +11 -5
  252. package/dist/commands/workflow/worktrees.js +147 -9
  253. package/dist/install/manifest.js +11 -9
  254. package/dist/install/modules/cloud.js +22 -13
  255. package/dist/install/modules/core.js +247 -3
  256. package/dist/install/modules/opencode.js +2 -2
  257. package/dist/install/version-file.js +6 -2
  258. package/dist/ledgers/migrate.js +81 -0
  259. package/dist/ledgers/status.js +61 -8
  260. package/dist/ledgers/telemetry.js +905 -124
  261. package/dist/render/hosts.js +4 -0
  262. package/dist/render/models.js +12 -0
  263. package/dist/shared/branches.js +3 -1
  264. package/dist/shared/egress.js +7 -0
  265. package/dist/shared/json.js +20 -7
  266. package/dist/shared/settings.js +125 -17
  267. package/dist/shared/text.js +333 -0
  268. package/dist/tools/grammar-density.js +183 -0
  269. package/dist/tools/instructions-sources.js +721 -0
  270. package/dist/tools/instructions.js +1579 -0
  271. package/package.json +113 -24
  272. package/.bkit/core/engine/commands/harvest.ts +0 -459
  273. package/.bkit/core/engine/tools/wording.ts +0 -748
  274. package/.bkit/core/prompts/bkit-build-challenge-reconcile.md +0 -69
  275. package/.bkit/core/prompts/bkit-build-challenge-remediate.md +0 -71
  276. package/.bkit/core/prompts/bkit-build-challenge-tests.md +0 -74
  277. package/.bkit/core/prompts/bkit-build-summary.md +0 -94
  278. package/.bkit/core/prompts/bkit-debug-summary.md +0 -96
  279. package/.bkit/core/prompts/bkit-design-summary.md +0 -107
  280. package/.bkit/core/prompts/bkit-plan-complexity-check.md +0 -67
  281. package/.bkit/core/prompts/bkit-plan-complexity-split.md +0 -88
  282. package/.bkit/core/prompts/bkit-plan-review-3.md +0 -93
  283. package/.bkit/core/prompts/bkit-plan-scope-check-1.md +0 -85
  284. package/.bkit/core/prompts/bkit-plan-scope-check-2.md +0 -85
  285. package/.bkit/core/prompts/bkit-plan-summary.md +0 -107
  286. package/.bkit/core/prompts/bkit-ship-summary.md +0 -78
  287. package/dist/commands/harvest.js +0 -353
  288. package/dist/tools/wording.js +0 -680
@@ -12,7 +12,16 @@ import * as path from "node:path";
12
12
 
13
13
  import type { IssueTracker } from "../../install/manifest.js";
14
14
  import { readBkitConfig } from "../../shared/settings.js";
15
- import { appendLine, statusTimestamp, type StatusRow } from "../../ledgers/status.js";
15
+ import {
16
+ actionHash,
17
+ actionKey,
18
+ alreadyDone,
19
+ appendLine,
20
+ recordAction,
21
+ runNumber,
22
+ statusTimestamp,
23
+ type StatusRow,
24
+ } from "../../ledgers/status.js";
16
25
  import {
17
26
  bodySkipToken,
18
27
  CommandError,
@@ -21,6 +30,7 @@ import {
21
30
  ghUnavailable,
22
31
  git,
23
32
  isSharedBranch,
33
+ MAIN,
24
34
  parseJson,
25
35
  repoRoot,
26
36
  runGh,
@@ -32,8 +42,11 @@ import {
32
42
  type GhResult,
33
43
  type RunContext,
34
44
  } from "../lib.js";
45
+ import { fidProblem } from "./fids.js";
35
46
  import { AUTO_LABEL, AUTO_ROUTE_SUFFIX } from "./issues.js";
36
- import { EXIT_NO_STATUS, FILE_FLAG, readStatusRows, statusFile, str } from "./status.js";
47
+ import { resolveOwnerRepo } from "./repo.js";
48
+ import { writeBodyFile } from "./tracker.js";
49
+ import { EXIT_NO_STATUS, FILE_FLAG, readRuns, readStatusRows, statusFile, str } from "./status.js";
37
50
 
38
51
  // ---------------------------------------------------------------------------
39
52
  // gh
@@ -165,29 +178,18 @@ function refFlag(value: FlagValue, flag: string): string {
165
178
  // open
166
179
  // ---------------------------------------------------------------------------
167
180
 
168
- /** FID allowlists per tracker — the same ones `/bkit-auto` asserts when it reads the marker back. */
169
- const FID_FORMAT: Record<IssueTracker, RegExp> = {
170
- github: /^[0-9]+-[a-z0-9-]+$/,
171
- linear: /^[a-z]+-[0-9]+-[a-z0-9-]+$/,
172
- jira: /^[a-z][a-z0-9]+-[0-9]+-[a-z0-9-]+$/,
173
- none: /^[a-z0-9][a-z0-9-]*$/,
174
- };
175
- const ISSUE_FORMAT: Record<Exclude<IssueTracker, "none">, RegExp> = {
176
- github: /^[0-9]+$/,
177
- linear: /^[A-Z]+-[0-9]+$/,
178
- jira: /^[A-Z][A-Z0-9]+-[0-9]+$/,
179
- };
180
-
181
- /** The PR-body marker line for this tracker (`.bkit/trackers.md` `pr-body-marker`). */
181
+ /**
182
+ * The PR-body marker line for this tracker (`.bkit/trackers.md` `pr-body-marker`). With
183
+ * no issue the marker is FID-only (`<!-- bkit:fid={FID} -->`, the `none` shape) and the
184
+ * FID any slug; with an issue, the FID must embed that same issue id.
185
+ */
182
186
  export function prMarker(tracker: IssueTracker, fid: string, issue: string | undefined): string {
183
- if (!FID_FORMAT[tracker].test(fid)) {
184
- throw new CommandError(EXIT.USAGE, `--fid "${fid}" is not a ${tracker} FID slug`);
185
- }
186
- if (tracker === "none") return `<!-- bkit:fid=${fid} -->`;
187
187
  const id = (issue ?? "").replace(/^#/, "");
188
- if (!ISSUE_FORMAT[tracker].test(id)) {
189
- throw new CommandError(EXIT.USAGE, `--issue "${issue ?? ""}" is not a ${tracker} issue id`);
188
+ const problem = fidProblem(fid, tracker, id);
189
+ if (problem !== undefined) {
190
+ throw new CommandError(EXIT.USAGE, `--fid "${fid}" / --issue "${issue ?? ""}": ${problem}`);
190
191
  }
192
+ if (tracker === "none" || id === "") return `<!-- bkit:fid=${fid} -->`;
191
193
  return tracker === "github"
192
194
  ? `<!-- bkit:issue=#${id} bkit:fid=${fid} -->`
193
195
  : `<!-- bkit:issue=${id} bkit:fid=${fid} -->`;
@@ -201,10 +203,16 @@ export function prBody(marker: string, notes: string[], plan: string | undefined
201
203
  .concat("\n");
202
204
  }
203
205
 
206
+ /** The CI marker `branches force-build` puts on the PR title; `prs merge` drops it from the squash subject. */
207
+ export const FORCE_BUILD = "[force build]";
208
+ const FORCE_BUILD_TAG = / ?(bkit )?\[force build\]/g;
209
+
204
210
  export const EXIT_PR_EXISTS = 3;
205
211
  export const EXIT_SKIP_CI_TITLE = 4;
206
212
  export const EXIT_GH_FAILED = 5;
207
213
  export const EXIT_WRONG_BASE = 6;
214
+ /** Exit code (open): `--base=main` — bkit never opens a PR into `main`. */
215
+ export const EXIT_BASE_MAIN = 7;
208
216
 
209
217
  export interface OpenInput {
210
218
  fid: string;
@@ -228,6 +236,8 @@ export interface OpenResult {
228
236
  head: string;
229
237
  title: string;
230
238
  body: string;
239
+ /** useMcp only: absolute path of a file holding `body` byte-for-byte. */
240
+ bodyFile?: string;
231
241
  } | null;
232
242
  }
233
243
 
@@ -246,6 +256,13 @@ export function openPrFor(cwd: string, o: OpenInput, log: (m: string) => void):
246
256
  }
247
257
 
248
258
  const base = refFlag(o.base ?? DEV, "base");
259
+ // `refs/heads/main`, `origin/main` and `heads/main` name the same branch for gh.
260
+ if (base.replace(/^(?:refs\/)?(?:heads\/|remotes\/)?(?:origin\/)?/, "") === MAIN) {
261
+ log(
262
+ `refusing to open a PR into ${MAIN}: bkit opens PRs into ${DEV} only, releases stay manual`,
263
+ );
264
+ return { code: EXIT_BASE_MAIN, out: null };
265
+ }
249
266
  const head = o.head === undefined ? currentBranch(cwd) : refFlag(o.head, "head");
250
267
  if (head === base || isSharedBranch(head)) {
251
268
  throw new CommandError(EXIT.USAGE, `refusing to open a PR from "${head}" into "${base}"`);
@@ -261,7 +278,17 @@ export function openPrFor(cwd: string, o: OpenInput, log: (m: string) => void):
261
278
  log(`${why} — create the PR through the GitHub MCP tool with this title and body`);
262
279
  return {
263
280
  code: EXIT.USE_MCP,
264
- out: { created: false, useMcp: true, number: null, url: null, base, head, title, body },
281
+ out: {
282
+ created: false,
283
+ useMcp: true,
284
+ number: null,
285
+ url: null,
286
+ base,
287
+ head,
288
+ title,
289
+ body,
290
+ bodyFile: writeBodyFile(cwd, "pr-body", body),
291
+ },
265
292
  };
266
293
  };
267
294
 
@@ -344,6 +371,25 @@ export function openPrFor(cwd: string, o: OpenInput, log: (m: string) => void):
344
371
  }
345
372
 
346
373
  function openPr(ctx: RunContext): number {
374
+ const fileFlag = str(ctx.flags.file);
375
+ const workflow = str(ctx.flags.workflow);
376
+ if (fileFlag !== undefined && workflow === undefined) {
377
+ throw new CommandError(EXIT.USAGE, "--file needs --workflow");
378
+ }
379
+ // A recorded open of this head into this base makes the PR now open on it this run's own.
380
+ let existing = str(ctx.flags.existing) as OpenInput["existing"];
381
+ let action: { file: string; key: string; hash: string } | undefined;
382
+ if (fileFlag !== undefined && workflow !== undefined) {
383
+ const file = path.resolve(ctx.cwd, fileFlag);
384
+ const head = str(ctx.flags.head) ?? currentBranch(ctx.cwd);
385
+ const run = fs.existsSync(file) ? runNumber(readRuns(file), workflow) : 1;
386
+ action = {
387
+ file,
388
+ key: actionKey(workflow, run, "pr-open"),
389
+ hash: actionHash(`${head}\n${str(ctx.flags.base) ?? DEV}`),
390
+ };
391
+ if (alreadyDone(action.file, action.key, action.hash)) existing = "reuse";
392
+ }
347
393
  const r = openPrFor(
348
394
  ctx.cwd,
349
395
  {
@@ -354,10 +400,18 @@ function openPr(ctx: RunContext): number {
354
400
  head: str(ctx.flags.head),
355
401
  plan: str(ctx.flags.plan),
356
402
  notes: (ctx.flags.note as string[] | undefined) ?? [],
357
- existing: str(ctx.flags.existing) as OpenInput["existing"],
403
+ existing,
358
404
  },
359
405
  ctx.log,
360
406
  );
407
+ if (action && r.code === EXIT.OK && r.out?.created === true) {
408
+ recordAction(action.file, {
409
+ action: "pr-open",
410
+ key: action.key,
411
+ hash: action.hash,
412
+ ref: r.out.url,
413
+ });
414
+ }
361
415
  if (r.out) ctx.emit(r.out);
362
416
  return r.code;
363
417
  }
@@ -368,6 +422,8 @@ function openPr(ctx: RunContext): number {
368
422
 
369
423
  /** Exit code (merge --expect-merged): the PR did not reach MERGED. */
370
424
  export const EXIT_NOT_MERGED = 7;
425
+ /** Exit code (merge): the PR's base is not `dev`, or could not be read — nothing merged. */
426
+ export const EXIT_BASE_NOT_DEV = 8;
371
427
 
372
428
  export interface MergeInput {
373
429
  number: string;
@@ -392,7 +448,9 @@ export interface MergeResult {
392
448
 
393
449
  /**
394
450
  * Squash-merge a PR with an explicit empty body (never the default concatenated
395
- * subjects), unless it is already MERGED, then read the state back. gh missing →
451
+ * subjects), unless it is already MERGED, then read the state back. A PR whose base
452
+ * (read by the same `pr view` that reads its state) is not `dev`, or is unreadable, is
453
+ * never merged (EXIT_BASE_NOT_DEV). gh missing →
396
454
  * EXIT.USE_MCP (merge through `merge_pull_request` with `subject`).
397
455
  */
398
456
  export function mergePr(cwd: string, o: MergeInput, log: (m: string) => void): MergeResult {
@@ -422,6 +480,12 @@ export function mergePr(cwd: string, o: MergeInput, log: (m: string) => void): M
422
480
  return result(EXIT_GH_FAILED, undefined, false);
423
481
  }
424
482
  if (before.pr?.state === "MERGED") return result(EXIT.OK, before.pr, true);
483
+ if (before.pr?.baseRefName !== DEV) {
484
+ log(
485
+ `refusing to merge PR ${o.number}: its base is ${before.pr?.baseRefName ?? "unknown"}, not ${DEV} — bkit merges into ${DEV} only, releases stay manual`,
486
+ );
487
+ return result(EXIT_BASE_NOT_DEV, before.pr, false);
488
+ }
425
489
  const args = ["pr", "merge", o.number, "--squash", "--subject", o.subject, "--body", ""];
426
490
  if (o.deleteBranch === true) args.push("--delete-branch");
427
491
  if (o.matchHead !== undefined) args.push("--match-head-commit", o.matchHead);
@@ -439,6 +503,14 @@ export function mergePr(cwd: string, o: MergeInput, log: (m: string) => void): M
439
503
  log(after.message);
440
504
  return result(EXIT_GH_FAILED, undefined, false);
441
505
  }
506
+ // A retarget between the base check and the merge is caught here, loudly.
507
+ if (after.pr?.state === "MERGED" && after.pr.baseRefName !== DEV) {
508
+ log(
509
+ `INTEGRITY FAILURE: PR ${o.number} merged into ${after.pr.baseRefName ?? "an unknown base"}, not ${DEV} — its base changed after the check; revert the merge`,
510
+ );
511
+ const r = result(EXIT_BASE_NOT_DEV, after.pr, false);
512
+ return { ...r, out: { ...r.out, verdict: "FAIL", failures: 1 } };
513
+ }
442
514
  return result(EXIT.OK, after.pr, false);
443
515
  }
444
516
 
@@ -451,17 +523,60 @@ export interface UpdateBranchResult {
451
523
  out: { number: string; updated: boolean } | null;
452
524
  }
453
525
 
526
+ /** Whether dev demands status checks (ruleset or branch protection): CI must then pass at the PR head. */
527
+ export function devRequiresChecks(gh: (args: string[]) => GhResult, repo: string): boolean {
528
+ const rules = gh(["api", `repos/${repo}/rules/branches/dev`]);
529
+ const read = rules.ok ? parseJson(rules.stdout) : { ok: false as const };
530
+ const list: unknown[] = read.ok && Array.isArray(read.value) ? read.value : [];
531
+ const hasCheckRule = list.some(
532
+ (r) =>
533
+ r !== null &&
534
+ typeof r === "object" &&
535
+ (r as { type?: unknown }).type === "required_status_checks",
536
+ );
537
+ if (hasCheckRule) return true;
538
+ return gh(["api", `repos/${repo}/branches/dev/protection/required_status_checks`]).ok;
539
+ }
540
+
454
541
  /**
455
542
  * Request a server-side base-into-head refresh (ship Step 4 B1). GitHub authors
456
543
  * the merge commit, so bkit cannot set its message and there is no local head to
457
544
  * read back — ship's Step 9 poll observes the new head. gh missing →
458
545
  * EXIT.USE_MCP (route through `update_pull_request_branch`).
546
+ *
547
+ * `onlyIfRequired`: refresh only when dev requires status checks. Otherwise the
548
+ * PR merges at the head CI already passed at, and the dev push run tests the
549
+ * merged result — a refresh would only re-run CI on the same feature change.
459
550
  */
460
551
  export function updateBranch(
461
552
  cwd: string,
462
553
  number: string,
463
554
  log: (m: string) => void,
555
+ o: { onlyIfRequired?: boolean } = {},
464
556
  ): UpdateBranchResult {
557
+ if (o.onlyIfRequired === true) {
558
+ const repo = resolveOwnerRepo(cwd)?.ownerRepo;
559
+ let ghMissing = false;
560
+ const gh = (args: string[]) => {
561
+ const res = runGh(cwd, args);
562
+ if (ghUnavailable(res)) ghMissing = true;
563
+ return res;
564
+ };
565
+ const required = repo === undefined || devRequiresChecks(gh, repo);
566
+ if (ghMissing) {
567
+ log(
568
+ "gh unavailable to read dev's required checks — update the branch through update_pull_request_branch",
569
+ );
570
+ return { code: EXIT.USE_MCP, out: null };
571
+ }
572
+ if (!required) {
573
+ log(
574
+ `dev requires no status checks — PR ${number} merges at the head CI passed at; the dev push run tests the merged result`,
575
+ );
576
+ return { code: EXIT.OK, out: { number, updated: false } };
577
+ }
578
+ if (repo === undefined) log("cannot resolve the repo to read dev's required checks — updating");
579
+ }
465
580
  const res = runGh(cwd, ["pr", "update-branch", number]);
466
581
  if (ghUnavailable(res)) {
467
582
  log(
@@ -805,22 +920,32 @@ export const prsCommand: CommandSpec = {
805
920
  type: "string",
806
921
  help: "an open PR already on --head: fail (default, exit 3) | reuse",
807
922
  },
923
+ {
924
+ name: "file",
925
+ type: "string",
926
+ help: "status.jsonl: record the open as an engine-action row; a re-run this run reuses that PR (needs --workflow)",
927
+ },
928
+ { name: "workflow", type: "string", help: "--file: the workflow, for the run number" },
808
929
  ],
809
930
  output: {
810
931
  created: "true when this run created the PR",
811
- useMcp: "true when gh is unavailable: create it through MCP with title/body/base/head",
932
+ useMcp:
933
+ "true when gh is unavailable: create it through MCP with title/base/head and the body read from bodyFile",
812
934
  number: "PR number, or null",
813
935
  url: "PR URL, or null",
814
936
  base: "base branch (read back from the PR when created)",
815
937
  head: "head branch",
816
938
  title: "PR title",
817
939
  body: "PR body, marker first",
940
+ bodyFile:
941
+ "useMcp only: absolute path of a file holding `body` byte-for-byte (the MCP fallback reads it); absent otherwise",
818
942
  },
819
943
  exitCodes: {
820
944
  [EXIT_PR_EXISTS]: "--head already has an open PR (with --existing=fail)",
821
945
  [EXIT_SKIP_CI_TITLE]: "the title carries a CI-suppressing token",
822
946
  [EXIT_GH_FAILED]: "gh errored (probe, create after one retry, or read-back)",
823
947
  [EXIT_WRONG_BASE]: "the created PR's base is not --base",
948
+ [EXIT_BASE_MAIN]: `--base is ${MAIN}: bkit opens PRs into ${DEV} only (no gh call made)`,
824
949
  },
825
950
  run: (ctx) => {
826
951
  const existing = str(ctx.flags.existing);
@@ -908,6 +1033,7 @@ export const prsCommand: CommandSpec = {
908
1033
  exitCodes: {
909
1034
  [EXIT_GH_FAILED]: "gh could not read the PR",
910
1035
  [EXIT_NOT_MERGED]: "--expect-merged and the PR did not reach MERGED",
1036
+ [EXIT_BASE_NOT_DEV]: `the PR's base is not ${DEV}, or could not be read — nothing merged`,
911
1037
  },
912
1038
  run: (ctx) => {
913
1039
  const number = String(ctx.flags.number);
@@ -924,7 +1050,7 @@ export const prsCommand: CommandSpec = {
924
1050
  ctx.log(pr.kind === "failed" ? pr.message : `PR #${number} not found`);
925
1051
  return EXIT_GH_FAILED;
926
1052
  }
927
- subject = `${pr.pr.title} (#${number})`;
1053
+ subject = `${pr.pr.title.replace(FORCE_BUILD_TAG, "")} (#${number})`;
928
1054
  }
929
1055
  if (((ctx.flags.label as string[] | undefined) ?? []).includes(AUTO_LABEL))
930
1056
  subject += AUTO_ROUTE_SUFFIX;
@@ -946,10 +1072,18 @@ export const prsCommand: CommandSpec = {
946
1072
  "update-branch": {
947
1073
  summary:
948
1074
  "Refresh a PR's head from its base server-side (exit 80: use update_pull_request_branch).",
949
- flags: [{ name: "number", type: "string", required: true, help: "the PR number" }],
1075
+ flags: [
1076
+ { name: "number", type: "string", required: true, help: "the PR number" },
1077
+ {
1078
+ name: "only-if-required",
1079
+ type: "boolean",
1080
+ help: "skip the update (updated: false) when dev requires no status checks",
1081
+ },
1082
+ ],
950
1083
  output: {
951
1084
  number: "the PR number",
952
- updated: "the update request succeeded (true even when already up to date)",
1085
+ updated:
1086
+ "the update request succeeded (true even when already up to date); false when --only-if-required skipped it",
953
1087
  },
954
1088
  exitCodes: {
955
1089
  [EXIT_GH_FAILED]: "gh could not update the branch (403 = actions:write scope)",
@@ -958,7 +1092,9 @@ export const prsCommand: CommandSpec = {
958
1092
  const number = String(ctx.flags.number);
959
1093
  if (!/^[1-9][0-9]*$/.test(number))
960
1094
  throw new CommandError(EXIT.USAGE, "--number must be a PR number");
961
- const r = updateBranch(ctx.cwd, number, ctx.log);
1095
+ const r = updateBranch(ctx.cwd, number, ctx.log, {
1096
+ onlyIfRequired: ctx.flags.onlyIfRequired === true,
1097
+ });
962
1098
  if (r.out) ctx.emit(r.out);
963
1099
  return r.code;
964
1100
  },
@@ -7,11 +7,12 @@
7
7
  // trails `origin/dev`, the main checkout, the bkit binary every later block calls,
8
8
  // and whether that bkit is behind the newest release ride along so Step 1 is one call.
9
9
 
10
+ import { randomBytes } from "node:crypto";
10
11
  import * as fs from "node:fs";
11
12
  import * as path from "node:path";
12
13
 
13
14
  import { parseRemoteUrlToSlug } from "../../ledgers/telemetry.js";
14
- import { DEV, EXIT, git, repoRoot, runGit, runTool, type CommandSpec } from "../lib.js";
15
+ import { DEV, EXIT, git, outboxRoot, repoRoot, runGit, runTool, type CommandSpec } from "../lib.js";
15
16
  import { bkitVersionStatus } from "../../shared/bkit-latest.js";
16
17
  import { readBkitConfig, trackerScope } from "../../shared/settings.js";
17
18
 
@@ -36,9 +37,15 @@ export function resolveOwnerRepo(
36
37
  cwd,
37
38
  );
38
39
  if (gh.status === 0 && splitSlug(gh.stdout)) return { ownerRepo: gh.stdout.trim(), source: "gh" };
40
+ const slug = originOwnerRepo(cwd);
41
+ return slug === null ? null : { ownerRepo: slug, source: "remote" };
42
+ }
43
+
44
+ /** `owner/repo` from the `origin` remote URL alone (no network); null when origin names none. */
45
+ export function originOwnerRepo(cwd: string): string | null {
39
46
  const url = git(cwd, ["remote", "get-url", "origin"]);
40
47
  const slug = url ? parseRemoteUrlToSlug(url) : "";
41
- return splitSlug(slug) ? { ownerRepo: slug, source: "remote" } : null;
48
+ return splitSlug(slug) ? slug : null;
42
49
  }
43
50
 
44
51
  /**
@@ -94,6 +101,34 @@ export function actionsPermissionsReadable(
94
101
  return { readable: res.found && res.status === 0, status: res.status, detail };
95
102
  }
96
103
 
104
+ /** Session folders older than this are pruned by `repo info`. */
105
+ export const SESSION_TTL_MS = 7 * 86_400_000;
106
+ const SESSION_NAME = /^(\d{4})(\d{2})(\d{2})T(\d{2})(\d{2})(\d{2})Z-[0-9a-f]+$/;
107
+
108
+ /**
109
+ * Creates `<outboxRoot>/sessions/<utc-time>-<random>/` and prunes session folders
110
+ * whose name stamps them older than {@link SESSION_TTL_MS}. Folders named any
111
+ * other way are left alone.
112
+ */
113
+ export function newSessionDir(outboxRoot: string, now: Date = new Date()): string {
114
+ const sessions = path.join(outboxRoot, "sessions");
115
+ fs.mkdirSync(sessions, { recursive: true });
116
+ for (const name of fs.readdirSync(sessions)) {
117
+ const m = SESSION_NAME.exec(name);
118
+ if (!m) continue;
119
+ const at = Date.UTC(+m[1]!, +m[2]! - 1, +m[3]!, +m[4]!, +m[5]!, +m[6]!);
120
+ if (now.getTime() - at > SESSION_TTL_MS)
121
+ fs.rmSync(path.join(sessions, name), { recursive: true, force: true });
122
+ }
123
+ const stamp = now
124
+ .toISOString()
125
+ .replace(/[-:]/g, "")
126
+ .replace(/\.\d{3}/, "");
127
+ const dir = path.join(sessions, `${stamp}-${randomBytes(4).toString("hex")}`);
128
+ fs.mkdirSync(dir);
129
+ return dir;
130
+ }
131
+
97
132
  export const repoCommand: CommandSpec = {
98
133
  noun: "repo",
99
134
  summary: "Repo facts for Step 1: owner/repo, current branch, and how far it trails dev.",
@@ -124,6 +159,8 @@ export const repoCommand: CommandSpec = {
124
159
  repoRoot: "the main checkout (the same from any worktree)",
125
160
  bkit: "the bkit binary the workflow blocks call: <repoRoot>/node_modules/.bin/bkit, else `bkit` on PATH",
126
161
  outboxRoot: "<git common dir>/bkit-outbox: per-run scratch files, never committed",
162
+ sessionDir:
163
+ "<outboxRoot>/sessions/<utc-time>-<random>/: a new, empty folder per call for this run's prompt.md and issue files; folders older than 7 days are pruned",
127
164
  bkitVersion:
128
165
  ".bkit/version pinnedVersion: the release this repo's bkit files came from (null when unpinned)",
129
166
  bkitLatest:
@@ -131,12 +168,18 @@ export const repoCommand: CommandSpec = {
131
168
  bkitOutdated:
132
169
  "true when bkitVersion is older than bkitLatest (null when either is unknown)",
133
170
  bkitAdvisory: "one line to show the user when bkitOutdated, else null",
134
- trackerTeam: "package.json bkit.linear.team under linear, else null",
171
+ trackerTeam: "package.json bkit.tracker.linear.team under linear, else null",
135
172
  trackerProject:
136
- "package.json bkit.linear.project under linear, bkit.jira.project under jira, else null",
137
- trackerSite: "package.json bkit.jira.site under jira (the MCP cloudId), else null",
173
+ "package.json bkit.tracker.linear.project under linear, bkit.tracker.jira.project under jira, else null",
174
+ trackerSite: "package.json bkit.tracker.jira.site under jira (the MCP cloudId), else null",
138
175
  trackerBoard:
139
- "{ownerType, owner, number} read from package.json bkit.github.project under github, else null",
176
+ "{ownerType, owner, number} read from package.json bkit.tracker.github.project under github, else null",
177
+ trackerProgress:
178
+ "the state an issue moves to when work starts: package.json bkit.tracker.<tracker>.progress for the wired tracker, at its default when unset (github `In progress`, linear `started`, jira `In Progress`); null under none",
179
+ trackerReview:
180
+ "the state an issue moves to when it is handed to a human: package.json bkit.tracker.<tracker>.review for the wired tracker, at its default when unset (github `In review`, linear `In Review`, jira `In Review`); null under none",
181
+ tasks:
182
+ "{maxPerGroup, maxTestsPerGroup, maxTestsPerTask, maxTestFilesPerTask}: the plan caps from package.json bkit.workflows.tasks, each missing or invalid key at its default",
140
183
  },
141
184
  exitCodes: {
142
185
  [EXIT_NO_REPO]: "neither gh nor the origin remote named an owner/repo",
@@ -173,6 +216,9 @@ export const repoCommand: CommandSpec = {
173
216
  const common = git(ctx.cwd, ["rev-parse", "--path-format=absolute", "--git-common-dir"]);
174
217
  const latest = bkitVersionStatus(root, common);
175
218
  if (latest.advisory !== null) ctx.log(latest.advisory);
219
+ const outbox = outboxRoot(ctx.cwd) ?? path.join(root, ".git", "bkit-outbox");
220
+ const config = readBkitConfig(root);
221
+ const states = config.issueTracker === "none" ? null : config[config.issueTracker];
176
222
  ctx.emit({
177
223
  ...resolved,
178
224
  owner,
@@ -181,12 +227,16 @@ export const repoCommand: CommandSpec = {
181
227
  ...behind,
182
228
  repoRoot: root,
183
229
  bkit: resolveBkitBinary(root),
184
- outboxRoot: path.join(common ?? path.join(root, ".git"), "bkit-outbox"),
230
+ outboxRoot: outbox,
231
+ sessionDir: newSessionDir(outbox),
185
232
  bkitVersion: latest.version,
186
233
  bkitLatest: latest.latest,
187
234
  bkitOutdated: latest.outdated,
188
235
  bkitAdvisory: latest.advisory,
189
- ...trackerScope(readBkitConfig(root)),
236
+ ...trackerScope(config),
237
+ trackerProgress: states?.progress ?? null,
238
+ trackerReview: states?.review ?? null,
239
+ tasks: config.tasks,
190
240
  });
191
241
  if (branch === null && ctx.flags.allowDetached !== true) {
192
242
  ctx.log("HEAD is detached — no current branch");
@@ -18,7 +18,14 @@
18
18
  import * as fs from "node:fs";
19
19
  import * as path from "node:path";
20
20
 
21
- import { compareTs, parse, resolveRepoSlug, validate } from "../../ledgers/telemetry.js";
21
+ import {
22
+ SCHEMA,
23
+ compareTs,
24
+ mintTs,
25
+ parse,
26
+ resolveRepoSlug,
27
+ validate,
28
+ } from "../../ledgers/telemetry.js";
22
29
  import { readBkitVersion } from "../../install/version-file.js";
23
30
  import {
24
31
  CommandError,
@@ -58,7 +65,7 @@ const ANALYSIS_PLACEHOLDER = "_(no analysis yet; run @bkit-utility-update-roadma
58
65
  const NOTES_PRE_PLACEHOLDER = "## Notes\n\n_(above the bkit list — yours, never overwritten)_";
59
66
  const NOTES_POST_PLACEHOLDER = "## Notes\n\n_(end of the board — yours, never overwritten)_";
60
67
  const BANNER =
61
- "> Generated tables — do not hand-edit the `bkit` tables; append to `.bkit/issues.jsonl` instead (an `ABANDONED` row hides a FID from every section). `## Notes` blocks are yours and are never overwritten. Everything above the first marker is also yours. notes-post is last. Analysis list length: `package.json` key `bkit.roadmapNext` (positive integer; absent or invalid → 25).";
68
+ "> Generated tables — do not hand-edit the `bkit` tables; append to `.bkit/issues.jsonl` instead (an `ABANDONED` row hides a FID from every section). `## Notes` blocks are yours and are never overwritten. Everything above the first marker is also yours. notes-post is last. Analysis list length: `package.json` key `bkit.prompts.roadmapNext` (positive integer; absent or invalid → 25).";
62
69
 
63
70
  /** Fixed related-utilities line; `@bkit-audit-generate` ends every run with the same text. */
64
71
  export const RELATED_UTILITIES =
@@ -331,13 +338,15 @@ export function featureRow(
331
338
  ): Record<string, unknown> {
332
339
  const phase = o.workflow.charAt(0).toUpperCase() + o.workflow.slice(1);
333
340
  return {
334
- ts: Date.now(),
341
+ schema: SCHEMA,
342
+ ts: mintTs(),
335
343
  kind: "feature",
336
- repo: resolveRepoSlug(root) || "unknown/repo",
337
- bkitVersion: readBkitVersion(path.join(root, ".bkit", "version"))?.pinnedVersion || "unknown",
338
- workflow: o.workflow,
339
- step: o.step,
340
344
  key: o.fid,
345
+ repo: resolveRepoSlug(root) || "unknown/repo",
346
+ bkit: {
347
+ version: readBkitVersion(path.join(root, ".bkit", "version"))?.pinnedVersion || "unknown",
348
+ },
349
+ by: { workflow: o.workflow, step: o.step },
341
350
  category: "agentic",
342
351
  description: `${phase} closed for ${o.fid}`,
343
352
  status: o.status,