@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
@@ -167,3 +167,35 @@ export function hasTestLinter(cwd) {
167
167
  }
168
168
  return eslintConfigs.some((text) => TEST_LINT_PLUGIN.test(text));
169
169
  }
170
+ /** Consumer-owned folders whose files may run bkit and read what it prints. */
171
+ const OUTPUT_READER_DIRS = [".claude/hooks", ".husky", ".github/workflows", "scripts"];
172
+ /**
173
+ * A line that reads bkit's stdout as JSON without asking for it: a bkit call piped to `jq`,
174
+ * or a bkit argument list (`"bkit", "<noun>", "<verb>", …]`) passed to a spawn.
175
+ */
176
+ const READS_BKIT_TEXT = [
177
+ /\bbkit\b(?:(?!--json)[^\n|])*\|\s*jq\b/i,
178
+ /"bkit",\s*"[a-z-]+",\s*"[a-z-]+"(?:(?!"--json")[^\n\]])*\]/,
179
+ ];
180
+ /** Files under `dir` (relative to `cwd`), `node_modules` left out, at most 4 levels down. */
181
+ function filesUnder(cwd, dir, depth = 4) {
182
+ const abs = path.join(cwd, dir);
183
+ if (depth === 0 || !fs.existsSync(abs) || !fs.statSync(abs).isDirectory())
184
+ return [];
185
+ return fs.readdirSync(abs, { withFileTypes: true }).flatMap((e) => {
186
+ const rel = path.posix.join(dir, e.name);
187
+ if (e.isDirectory())
188
+ return e.name === "node_modules" ? [] : filesUnder(cwd, rel, depth - 1);
189
+ return e.isFile() ? [rel] : [];
190
+ });
191
+ }
192
+ /**
193
+ * Hooks, CI workflows and scripts that parse bkit's output as JSON without `--json`;
194
+ * bkit prints text by default, so each one reads nothing.
195
+ */
196
+ export function readsBkitText(cwd) {
197
+ return OUTPUT_READER_DIRS.flatMap((dir) => filesUnder(cwd, dir)).filter((rel) => {
198
+ const text = readText(cwd, rel);
199
+ return text.split("\n").some((line) => READS_BKIT_TEXT.some((re) => re.test(line)));
200
+ });
201
+ }
@@ -17,9 +17,9 @@ export function silenceLine(ids) {
17
17
  const names = ids.map((id) => `\`${id}\``);
18
18
  const list = names.length > 1 ? `${names.slice(0, -1).join(", ")} and ${names.at(-1)}` : names[0];
19
19
  const what = ids.length > 1 ? "these tips" : "this tip";
20
- return `Want to silence ${what}? Ask your agent to "add ${list} to \`bkit.ignoreAdvisories\` in package.json".`;
20
+ return `**Want to silence ${what}?** Ask your agent to "add ${list} to \`bkit.advisories.ignore\` in package.json".`;
21
21
  }
22
- /** `bkit.ignoreAdvisories` key that silences `STAR_TIP`. */
22
+ /** `bkit.advisories.ignore` key that silences `STAR_TIP`. */
23
23
  export const STAR_TIP_ID = "bkit-star";
24
24
  /** Older key that also silences `STAR_TIP`, so repos that set it keep the line off. */
25
25
  export const STAR_TIP_OLD_ID = "star";
@@ -29,8 +29,10 @@ export const STAR_TIP_OLD_ID = "star";
29
29
  * gap, so never in the checklist.
30
30
  */
31
31
  export const STAR_TIP = "Do you like bkit? Then give it a star at [https://github.com/cbartens/bkit](https://github.com/cbartens/bkit)!";
32
+ /** `STAR_TIP` for a workflow's `## bkit Tips`, its question bold like each tip's title. */
33
+ export const STAR_TIP_PARAGRAPH = STAR_TIP.replace("Do you like bkit?", "**Do you like bkit?**");
32
34
  /** Intro of the Setup tips section: who reads which field, and how to silence a tip. */
33
- export const TIPS_SECTION_INTRO = "Things not set up yet, most useful first. For the person: each tip says what goes wrong today and a sentence to ask your agent. For an AI agent: follow each tip's Agent steps unless the person declines it. Silence a tip by adding its id to `bkit.ignoreAdvisories` in package.json. Full template catalogue: .bkit/templates.md.";
35
+ export const TIPS_SECTION_INTRO = "Things not set up yet, most useful first. For the person: each tip says what goes wrong today and a sentence to ask your agent. For an AI agent: follow each tip's Agent steps unless the person declines it. Silence a tip by adding its id to `bkit.advisories.ignore` in package.json. Full template catalogue: .bkit/templates.md.";
34
36
  /** True when advisory `id` matches catalogue pattern `pattern` (trailing `*` = prefix). */
35
37
  export function matchesAdvisory(pattern, id) {
36
38
  return pattern.endsWith("*") ? id.startsWith(pattern.slice(0, -1)) : id === pattern;
@@ -60,7 +62,7 @@ export function collectTips(cwd, catalogue = SETUP_TIPS) {
60
62
  }
61
63
  /**
62
64
  * Drop advisory findings whose tip the root package.json silenced, so one
63
- * `bkit.ignoreAdvisories` entry silences a tip and the advisories it reuses. Blockers are
65
+ * `bkit.advisories.ignore` entry silences a tip and the advisories it reuses. Blockers are
64
66
  * never dropped.
65
67
  */
66
68
  export function dropTipSilencedAdvisories(findings, cwd, onSuppressed, catalogue = SETUP_TIPS) {
@@ -126,7 +128,7 @@ function formatWorkflowTips(tips, workflow, star) {
126
128
  const ids = shown.map((t) => t.id);
127
129
  const parts = shown.map(tipParagraph);
128
130
  if (star) {
129
- parts.push(STAR_TIP);
131
+ parts.push(STAR_TIP_PARAGRAPH);
130
132
  ids.push(STAR_TIP_ID);
131
133
  }
132
134
  if (ids.length === 0)
package/dist/cli.js CHANGED
@@ -10,8 +10,7 @@ import { runCommand } from "./commands/lib.js";
10
10
  import { launchApp } from "./commands/launch.js";
11
11
  import { runStatus, runDoctor } from "./commands/install/doctor.js";
12
12
  import { runComplyCommand } from "./commands/comply.js";
13
- import { runHarvestCommand } from "./commands/harvest.js";
14
- import { runAnalysisCommand } from "./commands/analysis.js";
13
+ import { runStatsCommand } from "./commands/stats.js";
15
14
  import { runTelemetryCommand } from "./commands/telemetry.js";
16
15
  import { runTipsCommand } from "./commands/tips.js";
17
16
  import { runUpgradeCommand } from "./commands/install/upgrade.js";
@@ -39,8 +38,7 @@ export const CLASSIC_VERBS = new Set([
39
38
  "uninstall",
40
39
  "upgrade",
41
40
  "comply",
42
- "harvest",
43
- "analysis",
41
+ "stats",
44
42
  "telemetry",
45
43
  "tips",
46
44
  "cursor",
@@ -149,21 +147,12 @@ export function parseArgs(argv) {
149
147
  verb = "comply";
150
148
  args.shift();
151
149
  }
152
- else if (firstArg === "harvest") {
153
- verb = "harvest";
150
+ else if (firstArg === "stats") {
151
+ verb = "stats";
154
152
  args.shift();
155
- // harvest takes no flags — reject any remaining args
153
+ // stats takes no flags — reject any remaining positional args
156
154
  if (args.length > 0 && !args[0]?.startsWith("-")) {
157
- console.error(`[bkit] \`bkit harvest\` takes no positional args. Run \`bkit help\` for usage.`);
158
- process.exit(1);
159
- }
160
- }
161
- else if (firstArg === "analysis") {
162
- verb = "analysis";
163
- args.shift();
164
- // analysis takes no flags — reject any remaining positional args
165
- if (args.length > 0 && !args[0]?.startsWith("-")) {
166
- console.error(`[bkit] \`bkit analysis\` takes no positional args. Run \`bkit help\` for usage.`);
155
+ console.error(`[bkit] \`bkit stats\` takes no positional args. Run \`bkit help\` for usage.`);
167
156
  process.exit(1);
168
157
  }
169
158
  }
@@ -472,7 +461,7 @@ Usage:
472
461
  workflow runs this at its close; audit and utility do the
473
462
  same for audits and the ledger / roadmap updaters);
474
463
  --all lists every one. Ends with a star line ("bkit-star"
475
- in bkit.ignoreAdvisories silences it), except under
464
+ in bkit.advisories.ignore silences it), except under
476
465
  --workflow=audit|utility. Local checks only. Exits 0.
477
466
  bkit status Read-only host/provider status. Reports current host+provider
478
467
  (sampled from .claude/, .cursor/, package.json, and the
@@ -493,18 +482,6 @@ Usage:
493
482
  never gates a workflow. Appends kind:"compliance"
494
483
  rows to .bkit/stats.jsonl. Fail-open: always exits 0.
495
484
  Valid phases: design, plan, build, debug, ship.
496
- bkit harvest Cross-repo harvest — COPIES consumer .bkit/stats.jsonl
497
- and MOVES .bkit/friction.jsonl into harvest/ (COUNT-ONLY
498
- for docs/deferrals.jsonl and docs/failures.jsonl).
499
- Reads consumer paths from harvest/consumers.md.
500
- DESTRUCTIVE: harvested friction rows are REMOVED from
501
- the consumer, but only after they are fsync'd and read
502
- back from harvest/. stats.jsonl is never modified.
503
- harvest/ accumulates and is never cleared; it is
504
- gitignored, so it is the only record of pruned rows —
505
- back it up. Never commits
506
- in any repo. Deduplicates by per-kind composite
507
- identity. Advisory + fail-open: exits 0.
508
485
  bkit telemetry summary [--phase=<workflow>]
509
486
  Per-workflow telemetry report: THIS run's metrics
510
487
  (duration, size, friction/deferrals/failures added,
@@ -514,13 +491,12 @@ Usage:
514
491
  --phase=<workflow>: the workflow to report
515
492
  (design|plan|build|debug|ship). Without it, prints the
516
493
  ledger-health line only. Read-only: exits 0.
517
- bkit analysis Cross-repo analysis — reports counts/rates/elapsed-time,
518
- change-size vs outcome regression, dispatch-size threshold,
519
- counterSource trust labelling, per-rule compliance
520
- rate over kind:"compliance" rows, and the
521
- unjustified-deferral rate per (subagent, model)
522
- over kind:"deferral" rows. Reads from harvest/,
523
- .bkit/stats.jsonl and docs/deferrals.jsonl.
494
+ bkit stats This repo's stats report: counts, durations, change-size vs
495
+ outcome, counterSource trust, per-rule and per-version
496
+ compliance, and the unjustified-deferral rate per
497
+ (subagent, model). Reads .bkit/stats.jsonl,
498
+ .bkit/friction.jsonl and docs/deferrals.jsonl of THIS repo
499
+ only; writes .bkit/stats.md and prints it.
524
500
  Advisory + inform-only: exits 0.
525
501
  bkit help Print this message.
526
502
 
@@ -548,7 +524,7 @@ Module flags (composable; symmetric install ↔ uninstall):
548
524
  Ships .opencode/** (agents, commands, opencode.json, bkit-gateguard.js,
549
525
  bkit-readguard.js).
550
526
  Configure your provider key; verify with \`bkit doctor\`. All installed
551
- providers tracked in bkit.opencodeProviders.
527
+ providers tracked in bkit.providers.opencode.installed.
552
528
  --codex Codex CLI host. BARE flag — takes no value: Codex runs on one gateway
553
529
  (openai), so only --opencode is provider-pluggable. Ships .codex/agents/*.toml
554
530
  + .codex/hooks.json + .codex/hooks/bkit-{gateguard,guardrails,readguard}.cjs,
@@ -579,7 +555,7 @@ Dependency updaters (copy an example and own it):
579
555
 
580
556
  Cross-cutting / modifiers:
581
557
  --tracker=<name> Wire issue tracker integration. Values: github, linear, jira, none
582
- (default). Records bkit.issueTracker in package.json and substitutes
558
+ (default). Records bkit.tracker.default in package.json and substitutes
583
559
  tracker snippets into command mirrors. Re-renders every installed
584
560
  host, and works alone (bkit install --tracker=github). Switching is
585
561
  free; a switch removes the old linear or jira MCP entry unless you
@@ -597,7 +573,7 @@ Uninstall flags:
597
573
  --dry-run Print decision table (FILE / DECISION / REASON) without writing.
598
574
  --opencode=<provider>
599
575
  Surgical provider removal: removes that provider's block from
600
- opencode.json + drops it from bkit.opencodeProviders. Does NOT remove
576
+ opencode.json + drops it from bkit.providers.opencode.installed. Does NOT remove
601
577
  agents/commands/gateguard. If the removed provider was active, the first
602
578
  remaining provider becomes active and the agents are re-rendered to its
603
579
  model pins.
@@ -644,7 +620,7 @@ function commandsUsage() {
644
620
  return [
645
621
  "",
646
622
  "",
647
- "Workflow commands (bkit <noun> <verb> --flags; JSON on stdout; bkit <noun> --help):",
623
+ "Workflow commands (bkit <noun> <verb> --flags; text on stdout, --json for JSON; bkit <noun> --help):",
648
624
  ...COMMANDS.map((c) => ` bkit ${c.noun.padEnd(width)} ${c.summary}`),
649
625
  ].join("\n");
650
626
  }
@@ -698,12 +674,8 @@ export async function main() {
698
674
  runComplyCommand(complyPhase);
699
675
  return;
700
676
  }
701
- if (verb === "harvest") {
702
- runHarvestCommand();
703
- return;
704
- }
705
- if (verb === "analysis") {
706
- runAnalysisCommand();
677
+ if (verb === "stats") {
678
+ runStatsCommand();
707
679
  return;
708
680
  }
709
681
  if (verb === "telemetry") {
@@ -1,57 +1,96 @@
1
- // commands/analysis.ts — Analysis CLI for bkit telemetry.
1
+ // commands/analysis.ts — the computations behind `bkit stats` (commands/stats.ts) and the
2
+ // cross-repo section of the harvest report (scripts/harvest/, bkit's checkout only).
2
3
  //
3
4
  // Provides:
4
5
  // 1. Counts/rates/elapsed-time over telemetry rows.
5
- // 2. Size↔outcome regression (logistic approximation: error ~ log(linesAdded)
6
- // + filesChanged) over `kind:"outcome"` rows.
7
- // 3. Dispatch-size threshold computation for plan-complexity-check / plan-split.
8
- // 4. `counterSource` trust labelling: each outcome row is joined to its `counter` row
9
- // (model-self-report pre-P3, shell-bus post-P3).
6
+ // 2. Size↔outcome regression (error rate per `lines.total.added` bucket) over
7
+ // `kind:"outcome"` rows.
8
+ // 3. Dispatch-size threshold computation, printed by `bkit stats` and the harvest report.
9
+ // 4. `counter.source` trust labelling: each outcome row is joined to its `counter` row
10
+ // (model-self-report or shell-bus).
10
11
  // 5. Per-rule compliance rate over `kind:"compliance"` rows.
11
- // 6. Per-`bkitVersion`→CHANGELOG release-attributed regression.
12
+ // 6. Per-`bkit.version` release-attributed regression.
12
13
  //
13
- // Backfill scope (DE-37): GitHub-API backfill limited to the repo where bkit is
14
- // installed; PRs closed >= `--since` date; fields: additions, deletions, changedFiles,
15
- // commits count (for correctiveCommits proxy). Model-self-report counterSource.
14
+ // Rows are read folded, so rows written without `schema` arrive in the current shape.
16
15
  //
17
16
  // All computation is advisory + inform-only; never gates any workflow.
18
17
  // See DE-34 for the shared-entrypoint + crash-isolation contract.
19
- import * as fs from "node:fs";
20
- import * as path from "node:path";
21
- import { UNJUSTIFIED_REASON, foldFrom, } from "../ledgers/telemetry.js";
22
- import { HARVEST_DEST_DIR } from "./harvest.js";
18
+ import { AGENT_CONTEXT_CAP, UNJUSTIFIED_REASON, foldFrom, } from "../ledgers/telemetry.js";
23
19
  export function computeCounts(events) {
24
20
  const byKind = {};
25
21
  const byWorkflow = {};
26
22
  const byRepo = {};
27
23
  for (const ev of events) {
28
24
  byKind[ev.kind] = (byKind[ev.kind] ?? 0) + 1;
29
- byWorkflow[ev.workflow] = (byWorkflow[ev.workflow] ?? 0) + 1;
25
+ const workflow = ev.by?.workflow ?? "unknown";
26
+ byWorkflow[workflow] = (byWorkflow[workflow] ?? 0) + 1;
30
27
  byRepo[ev.repo] = (byRepo[ev.repo] ?? 0) + 1;
31
28
  }
32
29
  return { total: events.length, byKind, byWorkflow, byRepo };
33
30
  }
31
+ /** Over the rows that carry `time.totalMinutes`. */
34
32
  export function computeElapsedStats(rows) {
35
- if (rows.length === 0) {
33
+ const durations = rows
34
+ .map((r) => r.time?.totalMinutes)
35
+ .filter((m) => typeof m === "number")
36
+ .sort((a, b) => a - b);
37
+ if (durations.length === 0) {
36
38
  return {
37
39
  count: 0,
38
- totalSeconds: 0,
39
- meanSeconds: 0,
40
- minSeconds: 0,
41
- maxSeconds: 0,
42
- p50Seconds: 0,
40
+ totalMinutes: 0,
41
+ meanMinutes: 0,
42
+ minMinutes: 0,
43
+ maxMinutes: 0,
44
+ p50Minutes: 0,
43
45
  };
44
46
  }
45
- const durations = rows.map((r) => r.durationSeconds).sort((a, b) => a - b);
46
47
  const total = durations.reduce((s, v) => s + v, 0);
47
- const p50 = durations[Math.floor(durations.length / 2)] ?? 0;
48
48
  return {
49
- count: rows.length,
50
- totalSeconds: total,
51
- meanSeconds: total / rows.length,
52
- minSeconds: durations[0] ?? 0,
53
- maxSeconds: durations[durations.length - 1] ?? 0,
54
- p50Seconds: p50,
49
+ count: durations.length,
50
+ totalMinutes: total,
51
+ meanMinutes: total / durations.length,
52
+ minMinutes: durations[0] ?? 0,
53
+ maxMinutes: durations[durations.length - 1] ?? 0,
54
+ p50Minutes: durations[Math.floor(durations.length / 2)] ?? 0,
55
+ };
56
+ }
57
+ /** Over the outcome rows whose `build.challenge.gate` is set. */
58
+ export function computeChallengeGate(rows) {
59
+ const out = { runs: 0, small: 0, large: 0 };
60
+ for (const r of rows) {
61
+ const gate = r.build?.challenge?.gate;
62
+ if (gate === undefined)
63
+ continue;
64
+ out.runs++;
65
+ if (gate.skipped)
66
+ out.small++;
67
+ else
68
+ out.large++;
69
+ }
70
+ return out;
71
+ }
72
+ /** Each agent type's context peak over the outcome rows' `context` blocks, against `cap`. */
73
+ export function computeAgentContext(rows, cap = AGENT_CONTEXT_CAP) {
74
+ const by = {};
75
+ let recorded = 0;
76
+ for (const r of rows) {
77
+ if (r.context === undefined)
78
+ continue;
79
+ recorded++;
80
+ for (const [agent, a] of Object.entries(r.context.byAgent)) {
81
+ const e = (by[agent] ??= { agent, subagents: 0, runs: 0, peak: 0, overCap: 0 });
82
+ e.subagents += a.runs;
83
+ e.runs++;
84
+ e.peak = Math.max(e.peak, a.peak);
85
+ if (a.peak > cap)
86
+ e.overCap++;
87
+ }
88
+ }
89
+ return {
90
+ cap,
91
+ outcomes: rows.length,
92
+ recorded,
93
+ byAgent: Object.values(by).sort((a, b) => b.peak - a.peak || a.agent.localeCompare(b.agent)),
55
94
  };
56
95
  }
57
96
  const SIZE_BUCKETS = [
@@ -64,7 +103,7 @@ const SIZE_BUCKETS = [
64
103
  /**
65
104
  * Per-run NEW failures = this row's cumulative total minus the previous row's.
66
105
  *
67
- * `outcome.failures` is the repo's CUMULATIVE distinct-failure count at ship time.
106
+ * `ledgers.failures.repo` is the repo's CUMULATIVE distinct-failure count at close.
68
107
  *
69
108
  * Previous = the newest outcome row for the SAME repo strictly before this one; the
70
109
  * first row for a repo has no predecessor, so its total IS its delta.
@@ -75,25 +114,22 @@ export function newFailuresThisRun(row, allRows) {
75
114
  const previous = allRows
76
115
  .filter((r) => r.repo === row.repo && r.ts < row.ts)
77
116
  .sort((a, b) => b.ts - a.ts)[0];
117
+ const failures = (r) => r.ledgers?.failures?.repo ?? 0;
78
118
  if (!previous)
79
- return row.failures;
80
- return Math.max(0, row.failures - previous.failures);
81
- }
82
- function isErrorRun(row, allRows) {
83
- return ((row.ciTrySuccess !== undefined && row.ciTrySuccess > 1) ||
84
- (row.correctiveCommits !== undefined && row.correctiveCommits > 0) ||
85
- (row.reviewIterations !== undefined && row.reviewIterations > 1) ||
86
- newFailuresThisRun(row, allRows) > 0);
119
+ return failures(row);
120
+ return Math.max(0, failures(row) - failures(previous));
87
121
  }
122
+ const isErrorRun = (row, allRows) => newFailuresThisRun(row, allRows) > 0;
88
123
  /** Identity of one workflow run: the key the close writes on both its counter and outcome rows. */
89
124
  function runKey(row) {
90
- return row.parentSha ? JSON.stringify([row.repo, row.workflow, row.parentSha]) : undefined;
125
+ const sha = row.run?.parentSha;
126
+ return sha ? JSON.stringify([row.repo, row.by?.workflow, sha]) : undefined;
91
127
  }
92
128
  export function computeRegression(rows, counterRows) {
93
129
  const shellBusRuns = new Set();
94
130
  for (const c of counterRows) {
95
131
  const key = runKey(c);
96
- if (c.counterSource === "shell-bus" && key !== undefined)
132
+ if (c.counter?.source === "shell-bus" && key !== undefined)
97
133
  shellBusRuns.add(key);
98
134
  }
99
135
  const buckets = SIZE_BUCKETS.map((b) => ({
@@ -115,8 +151,8 @@ export function computeRegression(rows, counterRows) {
115
151
  else {
116
152
  modelSelfReportCount++;
117
153
  }
118
- // Bucket by linesAdded
119
- const lines = row.linesAdded;
154
+ // Bucket by lines added
155
+ const lines = row.lines?.total?.added ?? 0;
120
156
  for (const bucket of buckets) {
121
157
  if (lines >= bucket.minLines && lines <= bucket.maxLines) {
122
158
  bucket.count++;
@@ -150,14 +186,15 @@ export function computeRegression(rows, counterRows) {
150
186
  export function computeComplianceRates(rows) {
151
187
  const byRule = {};
152
188
  for (const row of rows) {
153
- if (!byRule[row.rule]) {
154
- byRule[row.rule] = { passCount: 0, failCount: 0, naCount: 0, totalCount: 0 };
189
+ const id = row.rule?.id ?? "unknown";
190
+ if (!byRule[id]) {
191
+ byRule[id] = { passCount: 0, failCount: 0, naCount: 0, totalCount: 0 };
155
192
  }
156
- const r = byRule[row.rule];
193
+ const r = byRule[id];
157
194
  r.totalCount++;
158
- if (row.result === "pass")
195
+ if (row.rule?.verdict === "pass")
159
196
  r.passCount++;
160
- else if (row.result === "fail")
197
+ else if (row.rule?.verdict === "fail")
161
198
  r.failCount++;
162
199
  else
163
200
  r.naCount++;
@@ -171,20 +208,21 @@ export function computeComplianceRates(rows) {
171
208
  export function computeVersionCompliance(rows) {
172
209
  const byVersion = {};
173
210
  for (const row of rows) {
174
- if (!byVersion[row.bkitVersion])
175
- byVersion[row.bkitVersion] = { pass: 0, total: 0 };
176
- const v = byVersion[row.bkitVersion];
211
+ const version = row.bkit?.version ?? "unknown";
212
+ if (!byVersion[version])
213
+ byVersion[version] = { pass: 0, total: 0 };
214
+ const v = byVersion[version];
177
215
  v.total++;
178
- if (row.result === "pass")
216
+ if (row.rule?.verdict === "pass")
179
217
  v.pass++;
180
218
  }
181
219
  return Object.entries(byVersion)
182
- .map(([bkitVersion, { pass, total }]) => ({
183
- bkitVersion,
220
+ .map(([version, { pass, total }]) => ({
221
+ version,
184
222
  passRate: total > 0 ? pass / total : 0,
185
223
  totalRuns: total,
186
224
  }))
187
- .sort((a, b) => a.bkitVersion.localeCompare(b.bkitVersion, undefined, { numeric: true }));
225
+ .sort((a, b) => a.version.localeCompare(b.version, undefined, { numeric: true }));
188
226
  }
189
227
  /**
190
228
  * Unjustified-rate per `(subagent, model)`.
@@ -196,8 +234,8 @@ export function computeVersionCompliance(rows) {
196
234
  export function computeDeferralDiscipline(rows) {
197
235
  const byWriter = {};
198
236
  for (const row of rows) {
199
- const writer = row.subagent ?? (row.workflow ? `${row.workflow} (orchestrator)` : "unattributed");
200
- const model = row.model ?? "unknown";
237
+ const writer = row.by?.subagent ?? (row.by?.workflow ? `${row.by.workflow} (orchestrator)` : "unattributed");
238
+ const model = row.by?.model ?? "unknown";
201
239
  const id = `${writer}\u0000${model}`;
202
240
  if (!byWriter[id])
203
241
  byWriter[id] = { writer, model, total: 0, unjustifiedCount: 0, byReason: {} };
@@ -222,9 +260,10 @@ export function computeDeferralDiscipline(rows) {
222
260
  b.total - a.total ||
223
261
  a.writer.localeCompare(b.writer));
224
262
  }
225
- export function runAnalysis(paths) {
263
+ /** Analyse the folded rows of `paths`, leaving out rows of `skipKinds`. */
264
+ export function runAnalysis(paths, skipKinds = new Set()) {
226
265
  const { state, rowCount, malformedLineCount } = foldFrom(paths);
227
- const events = [...state.values()];
266
+ const events = [...state.values()].filter((ev) => !skipKinds.has(ev.kind));
228
267
  const outcomeRows = [];
229
268
  const counterRows = [];
230
269
  const complianceRows = [];
@@ -249,6 +288,8 @@ export function runAnalysis(paths) {
249
288
  const complianceRates = computeComplianceRates(complianceRows);
250
289
  const versionCompliance = computeVersionCompliance(complianceRows);
251
290
  const deferralDiscipline = computeDeferralDiscipline(deferralRows);
291
+ const challengeGate = computeChallengeGate(outcomeRows);
292
+ const agentContext = computeAgentContext(outcomeRows);
252
293
  const reportLines = [
253
294
  `[bkit-analysis] Telemetry rows: ${rowCount} | malformed: ${malformedLineCount}`,
254
295
  `[bkit-analysis] Kinds: ${JSON.stringify(counts.byKind)}`,
@@ -256,16 +297,19 @@ export function runAnalysis(paths) {
256
297
  `[bkit-analysis] Run outcomes: ${outcomeRows.length} | Compliance rows: ${complianceRows.length}`,
257
298
  ];
258
299
  if (elapsed.count > 0) {
259
- reportLines.push(`[bkit-analysis] Duration (s): mean=${elapsed.meanSeconds.toFixed(0)} | p50=${elapsed.p50Seconds.toFixed(0)} | min=${elapsed.minSeconds} | max=${elapsed.maxSeconds}`);
300
+ reportLines.push(`[bkit-analysis] Duration (min): mean=${elapsed.meanMinutes.toFixed(1)} | p50=${elapsed.p50Minutes.toFixed(1)} | min=${elapsed.minMinutes} | max=${elapsed.maxMinutes}`);
260
301
  }
261
302
  // Regression report
262
- reportLines.push(`[bkit-analysis] #183 Size↔outcome regression (dispatch-size threshold: ${regression.dispatchSizeThreshold} linesAdded):`);
303
+ reportLines.push(`[bkit-analysis] #183 Size↔outcome regression (dispatch-size threshold: ${regression.dispatchSizeThreshold} lines added):`);
263
304
  for (const b of regression.buckets) {
264
305
  if (b.count > 0) {
265
306
  reportLines.push(` ${b.label}: ${b.count} runs, ${b.errorCount} errors (${(b.errorRate * 100).toFixed(1)}%)`);
266
307
  }
267
308
  }
268
- reportLines.push(`[bkit-analysis] counterSource trust: shell-bus=${regression.shellBusCount} (trusted) | model-self-report=${regression.modelSelfReportCount} (untrusted, pre-P3)`);
309
+ reportLines.push(`[bkit-analysis] counter.source trust: shell-bus=${regression.shellBusCount} (trusted) | model-self-report=${regression.modelSelfReportCount} (untrusted)`);
310
+ if (challengeGate.runs > 0) {
311
+ reportLines.push(`[bkit-analysis] Build challenge size: ${challengeGate.small} small (challenge-1 skipped) | ${challengeGate.large} large, of ${challengeGate.runs} runs`);
312
+ }
269
313
  // Compliance rates
270
314
  if (complianceRates.length > 0) {
271
315
  reportLines.push(`[bkit-analysis] Per-rule compliance rates:`);
@@ -275,9 +319,9 @@ export function runAnalysis(paths) {
275
319
  }
276
320
  // Version compliance
277
321
  if (versionCompliance.length > 0) {
278
- reportLines.push(`[bkit-analysis] Per-bkitVersion compliance:`);
322
+ reportLines.push(`[bkit-analysis] Per-bkit.version compliance:`);
279
323
  for (const v of versionCompliance) {
280
- reportLines.push(` v${v.bkitVersion}: ${(v.passRate * 100).toFixed(1)}% pass (${v.totalRuns} runs)`);
324
+ reportLines.push(` v${v.version}: ${(v.passRate * 100).toFixed(1)}% pass (${v.totalRuns} runs)`);
281
325
  }
282
326
  }
283
327
  // Deferral discipline — who defers work they should have finished.
@@ -299,43 +343,8 @@ export function runAnalysis(paths) {
299
343
  complianceRates,
300
344
  versionCompliance,
301
345
  deferralDiscipline,
346
+ challengeGate,
347
+ agentContext,
302
348
  reportLines,
303
349
  };
304
350
  }
305
- // analysis — cross-repo analysis CLI.
306
- // Reports counts/rates/elapsed-time, size↔outcome regression, per-rule compliance
307
- // rate, dispatch-size threshold, counterSource trust labelling. Advisory + inform-only.
308
- // See DE-34 for the shared-entrypoint + crash-isolation contract.
309
- export function runAnalysisCommand() {
310
- try {
311
- const cwd = process.cwd();
312
- // Analyse: bkit's own stats.jsonl + harvested consumer rows.
313
- // Harvest dest is sourced from the constant, NOT re-spelled here.
314
- const statsPath = path.join(cwd, ".bkit", "stats.jsonl");
315
- const harvestStatsPath = path.join(cwd, HARVEST_DEST_DIR, "stats.jsonl");
316
- const harvestFrictionPath = path.join(cwd, HARVEST_DEST_DIR, "friction.jsonl");
317
- const frictionPath = path.join(cwd, ".bkit", "friction.jsonl");
318
- // deferrals is LOCAL-only: harvest takes it count-only (prose never leaves the
319
- // consumer), so the discipline rate is this repo's own writers, not a fleet view.
320
- const deferralsPath = path.join(cwd, "docs", "deferrals.jsonl");
321
- const paths = [
322
- statsPath,
323
- harvestStatsPath,
324
- harvestFrictionPath,
325
- frictionPath,
326
- deferralsPath,
327
- ].filter((p) => fs.existsSync(p));
328
- if (paths.length === 0) {
329
- console.log("[bkit-analysis] No telemetry files found. Run `bkit harvest` first, or accumulate telemetry via bkit workflows.");
330
- return;
331
- }
332
- const report = runAnalysis(paths);
333
- for (const line of report.reportLines) {
334
- console.log(line);
335
- }
336
- }
337
- catch (err) {
338
- const msg = err instanceof Error ? err.message : String(err);
339
- console.error(`[bkit-analysis] analysis error (fail-open): ${msg}`);
340
- }
341
- }
@@ -15,7 +15,7 @@
15
15
  // `skip-token` — whether a commit message carries a GitHub skip-CI token
16
16
  // (`SKIP_CI_TOKEN`), for the `.husky/pre-push` CI-suppressor guard.
17
17
  //
18
- // `min-push` — whether every file a push changes matches `bkit.minPushPaths`, so
18
+ // `min-push` — whether every file a push changes matches `bkit.testing.minPushPaths`, so
19
19
  // `.husky/pre-push` runs `bkit:gate:min`. Files decide, never `[skip ci]` (a typed label
20
20
  // GitHub reads off the last commit only).
21
21
  import { spawnSync } from "node:child_process";
@@ -383,7 +383,7 @@ function skipToken(ctx) {
383
383
  // ---------------------------------------------------------------------------
384
384
  // min-push
385
385
  // ---------------------------------------------------------------------------
386
- /** `bkit.minPushPaths` as git pathspecs: `:(glob)` unless an entry carries its own magic. */
386
+ /** `bkit.testing.minPushPaths` as git pathspecs: `:(glob)` unless an entry carries its own magic. */
387
387
  export const minPushPathspecs = (paths) => paths.map((p) => (p.startsWith(":") ? p : `:(glob)${p}`));
388
388
  /** Where a pushed commit's range starts: its merge-base with origin/dev, else origin/main. */
389
389
  export function pushBase(cwd, sha) {
@@ -438,7 +438,7 @@ function minPush(ctx) {
438
438
  return code;
439
439
  };
440
440
  if (paths.length === 0) {
441
- return result("no-paths", EXIT.NO, "bkit.minPushPaths is empty — not a min push");
441
+ return result("no-paths", EXIT.NO, "bkit.testing.minPushPaths is empty — not a min push");
442
442
  }
443
443
  if (changed.size === 0) {
444
444
  return result("no-changes", EXIT.NO, "the push changes no files — not proven a min push");
@@ -512,7 +512,7 @@ export const ciCommand = {
512
512
  run: skipToken,
513
513
  },
514
514
  "min-push": {
515
- summary: "Exit 0 when every file a push changes matches bkit.minPushPaths (the pre-push light gate).",
515
+ summary: "Exit 0 when every file a push changes matches bkit.testing.minPushPaths (the pre-push light gate).",
516
516
  flags: [
517
517
  {
518
518
  name: "ref",
@@ -523,11 +523,11 @@ export const ciCommand = {
523
523
  { name: "base", type: "string", help: "start every range here instead" },
524
524
  ],
525
525
  output: {
526
- minPush: "true when every changed file matches bkit.minPushPaths",
526
+ minPush: "true when every changed file matches bkit.testing.minPushPaths",
527
527
  reason: "null when a min push; else no-paths | no-changes | outside | unknown",
528
528
  changed: "files the push changes, across every ref",
529
529
  outside: "the changed files no min-push path matches",
530
- paths: "bkit.minPushPaths as read",
530
+ paths: "bkit.testing.minPushPaths as read",
531
531
  },
532
532
  exitCodes: {
533
533
  [EXIT_RANGE_UNKNOWN]: "a pushed commit, its base, or its git diff could not be read",