@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
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cbartens/bkit",
3
- "version": "5.5.0",
3
+ "version": "6.0.0",
4
4
  "private": false,
5
5
  "description": "From vibe coding to production code. A senior engineering team's process, ready-made: AI agents design, plan, build, review, fix and ship your features on Claude Code, Cursor, Codex, Google Antigravity and opencode.",
6
6
  "keywords": [
@@ -68,16 +68,18 @@
68
68
  "lint": "oxlint -c .oxlintrc.json --type-aware --tsconfig tsconfig.test.json --deny-warnings .bkit/core/engine",
69
69
  "format": "prettier --write .",
70
70
  "format:check": "prettier --check .",
71
- "format:tables": "node scripts/prettier/bkit-insert-ignore.mjs .agents docs README.md .bkit/shared .bkit/core/.agents .bkit/core/docs",
72
- "format:tables:check": "node scripts/prettier/bkit-insert-ignore.mjs --check .agents docs README.md .bkit/shared .bkit/core/.agents .bkit/core/docs",
71
+ "format:tables": "node scripts/prettier/bkit-insert-ignore.mjs .agents docs README.md .bkit/instructions.md .bkit/shared .bkit/core/.agents .bkit/core/docs",
72
+ "format:tables:check": "node scripts/prettier/bkit-insert-ignore.mjs --check .agents docs README.md .bkit/instructions.md .bkit/shared .bkit/core/.agents .bkit/core/docs",
73
73
  "lint:prose": "bkit ci prose --glob='.agents/*.md' --glob='.bkit/core/.bkit/*.md' --glob='.bkit/core/workflows/**/*.md' --glob='.bkit/core/prompts/**/*.md' --glob='.bkit/core/.agents/*.md' --glob='.bkit/shared/docs/**/*.md' --glob='.bkit/core/docs/**/*.md' --glob='.bkit/templates/**/*.md' --glob='docs/*.md' --glob='*.md'",
74
74
  "lint:slop": "slop-scan scan .",
75
75
  "slop:delta": "bkit ci slop",
76
76
  "bkit:lint:workflows": "bash -c 'if command -v actionlint >/dev/null 2>&1; then actionlint; else echo \"[bkit] actionlint missing — skipping workflow lint (install actionlint to enable)\"; fi'",
77
77
  "test": "vitest run",
78
+ "harvest": "tsx scripts/harvest/bkit-harvest.mjs",
79
+ "test:harvest": "node scripts/harvest/bkit-harvest.test.mjs",
78
80
  "test:integration": "vitest run integration.test",
79
- "test:coverage:unit": "vitest run -c vitest.unit.config.ts --coverage --coverage.reportsDirectory=coverage/unit --exclude '**/*.integration.test.ts' --coverage.include='.bkit/core/engine/{cli,commands/analysis,install/cloud-env,commands/comply,commands/harvest,commands/install/install,commands/launch,install/manifest,install/managed-block,shared/package-roots,shared/protected-paths,checks/after/index,checks/after/auth,checks/after/ci-yml,checks/after/github,checks/after/managed,checks/after/tools,checks/after/suppression,checks/before/index,checks/before/context-fetch,checks/before/env,checks/before/files,checks/before/mcp,checks/before/repo,checks/before/version,ledgers/status,ledgers/telemetry,install/write,install/placeholders,install/template-copies,render/trackers,render/hosts,render/models,commands/install/uninstall,commands/install/upgrade,install/version-file,tools/wording}.ts' --coverage.include='.bkit/core/engine/commands/**/*.ts' --coverage.include='.bkit/core/engine/shared/{settings,package-json,package-manager,timeouts}.ts'",
80
- "bkit:test:bats": "pnpm exec bats tests/*.bats",
81
+ "test:coverage:unit": "vitest run -c vitest.unit.config.ts --coverage --coverage.reportsDirectory=coverage/unit --exclude '**/*.integration.test.ts' --coverage.include='.bkit/core/engine/{cli,commands/analysis,install/cloud-env,commands/comply,commands/install/install,commands/launch,install/manifest,install/managed-block,shared/package-roots,shared/protected-paths,checks/after/index,checks/after/auth,checks/after/ci-yml,checks/after/github,checks/after/managed,checks/after/tools,checks/after/suppression,checks/before/index,checks/before/context-fetch,checks/before/env,checks/before/files,checks/before/mcp,checks/before/repo,checks/before/version,ledgers/status,ledgers/telemetry,install/write,install/placeholders,install/template-copies,render/trackers,render/hosts,render/models,commands/install/uninstall,commands/install/upgrade,install/version-file,tools/instructions}.ts' --coverage.include='.bkit/core/engine/commands/**/*.ts' --coverage.include='.bkit/core/engine/shared/{settings,package-json,package-manager,timeouts}.ts'",
82
+ "bkit:test:bats": "pnpm exec bats ${BKIT_TEST_REPORT_DIR:+--report-formatter junit --output \"$BKIT_TEST_REPORT_DIR\"} tests/*.bats",
81
83
  "build": "tsc && chmod +x dist/cli.js",
82
84
  "bkit:check:dist": "rm -rf dist && tsc && chmod +x dist/cli.js && git diff --exit-code dist/ || (echo '[bkit] dist/ is stale — run pnpm build and commit the result' && exit 1)",
83
85
  "graph": "bash scripts/graphify/bkit-graphify.sh build",
@@ -90,7 +92,9 @@
90
92
  "graph:tree": "bash scripts/graphify/bkit-graphify.sh tree",
91
93
  "graph:update": "bash scripts/graphify/bkit-graphify.sh update",
92
94
  "bkit:audit:status": "tsx .bkit/core/engine/checks/status-holes.ts docs/plans/*/logs/*/status.jsonl",
93
- "wording:sync": "tsx .bkit/core/engine/tools/wording.ts --write",
95
+ "grammar:density": "tsx .bkit/core/engine/tools/grammar-density.ts",
96
+ "instructions:show": "tsx .bkit/core/engine/tools/instructions.ts --show",
97
+ "instructions:sync": "tsx .bkit/core/engine/tools/instructions.ts --write",
94
98
  "prepare": "husky"
95
99
  },
96
100
  "devDependencies": {
@@ -117,22 +121,109 @@
117
121
  }
118
122
  },
119
123
  "bkit": {
120
- "issueTracker": "github",
121
- "cloudAgents": "claude",
122
- "githubProject": false,
123
- "opencodeProvider": "openrouter",
124
- "opencodeProviders": [
125
- "opencode-go",
126
- "openrouter"
127
- ],
128
- "minPushPaths": [
129
- "docs/**",
130
- ".bkit/*.jsonl",
131
- "CHANGELOG.md",
132
- "README.md"
133
- ],
134
- "capstoneJob": "bkit-tests-check",
135
- "ciWorkflow": "bkit-ci.yml",
136
- "roadmapNext": 25
124
+ "tracker": {
125
+ "default": "github",
126
+ "github": {
127
+ "project": "https://github.com/users/cbartens/projects/1",
128
+ "progress": "In progress",
129
+ "review": "In review"
130
+ },
131
+ "linear": {
132
+ "team": "",
133
+ "project": "",
134
+ "progress": "started",
135
+ "review": "In Review"
136
+ },
137
+ "jira": {
138
+ "site": "",
139
+ "project": "",
140
+ "progress": "In Progress",
141
+ "review": "In Review"
142
+ }
143
+ },
144
+ "cloud": {
145
+ "agent": "claude"
146
+ },
147
+ "providers": {
148
+ "opencode": {
149
+ "default": "openrouter",
150
+ "installed": [
151
+ "opencode-go",
152
+ "openrouter"
153
+ ]
154
+ }
155
+ },
156
+ "testing": {
157
+ "minPushPaths": [
158
+ "docs/**",
159
+ ".bkit/*.jsonl",
160
+ "CHANGELOG.md",
161
+ "README.md"
162
+ ],
163
+ "ciCapstone": "bkit-tests-check",
164
+ "ciWorkflow": "bkit-ci.yml",
165
+ "shipGate": []
166
+ },
167
+ "workflows": {
168
+ "minFreeGb": 40,
169
+ "worktree": {
170
+ "copy": [
171
+ ".env",
172
+ ".env.local"
173
+ ],
174
+ "install": true
175
+ },
176
+ "tasks": {
177
+ "maxPerGroup": 3,
178
+ "maxTestsPerGroup": 15,
179
+ "maxTestsPerTask": 10,
180
+ "maxTestFilesPerTask": 3
181
+ },
182
+ "design": {
183
+ "grill": {
184
+ "ask": true,
185
+ "maxTurns": 6
186
+ }
187
+ },
188
+ "build": {
189
+ "verify": {
190
+ "ask": true,
191
+ "maxAttempts": 2
192
+ },
193
+ "challenge": {
194
+ "ask": true,
195
+ "maxAttempts": 2
196
+ },
197
+ "tests": {
198
+ "ask": true,
199
+ "maxAttempts": 2
200
+ }
201
+ },
202
+ "debug": {
203
+ "fix": {
204
+ "ask": true,
205
+ "maxAttempts": 2
206
+ },
207
+ "soak": {
208
+ "ask": true,
209
+ "maxAttempts": 2
210
+ }
211
+ },
212
+ "ship": {
213
+ "merge": {
214
+ "ask": true,
215
+ "maxAttempts": 2
216
+ }
217
+ }
218
+ },
219
+ "prompts": {
220
+ "roadmapNext": 25
221
+ },
222
+ "dependencies": {
223
+ "updater": ""
224
+ },
225
+ "advisories": {
226
+ "ignore": []
227
+ }
137
228
  }
138
229
  }
@@ -1,459 +0,0 @@
1
- // commands/harvest.ts — Cross-repo harvest CLI.
2
- //
3
- // MOVES consumer `.bkit/friction.jsonl` and COPIES `.bkit/stats.jsonl` into bkit's
4
- // central store at `harvest/`. COUNT-ONLY aggregates `docs/{deferrals,failures}.jsonl`
5
- // (dimensional counts from envelope metadata; prose NOT copied). Deduplicates by
6
- // row content; entity counts fold by per-kind composite identity.
7
- //
8
- // INVARIANTS (PII guard + move/copy contract):
9
- // - Touches ONLY the named .jsonl ledgers — never any .env/secret files.
10
- // - NEVER commits in any repo (bkit's or a consumer's) — the caller commits.
11
- // - stats.jsonl is COPY-ONLY: consumer mtime + content unchanged.
12
- // - friction.jsonl is MOVE: harvested rows are pruned from the consumer, but ONLY
13
- // after that exact row is durably fsync'd + read back from the central store.
14
- // - The prune gate is byte-for-byte CONTENT, never identity.
15
- // - The central store ACCUMULATES across runs (never cleared) and holds every
16
- // DISTINCT row, deduped by content only. It is never rewritten from the fold. It is
17
- // gitignored (private consumer content), so it is the only record of pruned consumer
18
- // friction; readers fold it.
19
- // - Malformed consumer lines are NEVER pruned (not ours to delete).
20
- // - Grep-able [bkit-harvest] log lines.
21
- // - Relies on the tolerant `parse` for half-written tails.
22
- //
23
- // Friction is moved, not copied: consumers start each cycle clean. Ordering is
24
- // copy -> fsync -> verify -> prune; a crash at any point re-copies idempotently on the
25
- // next run.
26
- //
27
- // Consumers are listed in `harvest/consumers.md` (one absolute path per line).
28
- // See DE-34 for the shared-entrypoint + crash-isolation contract.
29
-
30
- import * as fs from "node:fs";
31
- import * as path from "node:path";
32
- import {
33
- fold,
34
- parse,
35
- resolveRepoSlug,
36
- type FoldedState,
37
- type TelemetryEvent,
38
- } from "../ledgers/telemetry.js";
39
- import { parseJson } from "../shared/json.js";
40
-
41
- // ---------------------------------------------------------------------------
42
- // Constants
43
- // ---------------------------------------------------------------------------
44
-
45
- /** Files to COPY from each consumer's `.bkit/` directory (content + dedup). */
46
- export const HARVEST_COPY_FILES = ["stats.jsonl", "friction.jsonl"] as const;
47
- /**
48
- * Files PRUNED from the consumer after their rows are durably in the central store.
49
- * Must be a subset of HARVEST_COPY_FILES. `stats.jsonl` is absent: it is copied, never
50
- * moved.
51
- */
52
- export const HARVEST_PRUNE_FILES = ["friction.jsonl"] as const;
53
- /** Files to COUNT-ONLY from each consumer's `docs/` directory (metadata only). */
54
- export const HARVEST_COUNT_FILES = ["deferrals.jsonl", "failures.jsonl"] as const;
55
- /** Path (relative to bkit repo root) for the consumers list. */
56
- export const CONSUMERS_FILE = "harvest/consumers.md";
57
- /**
58
- * Destination directory in bkit for harvested data. Repo root, NOT under `.bkit/`
59
- * (bkit's managed/installed surface).
60
- */
61
- export const HARVEST_DEST_DIR = "harvest";
62
-
63
- // ---------------------------------------------------------------------------
64
- // Types
65
- // ---------------------------------------------------------------------------
66
-
67
- export interface HarvestConsumerResult {
68
- consumerPath: string;
69
- copiedRows: number;
70
- /**
71
- * Distinct ENTITIES per count-only ledger (same-key rows folded to one).
72
- * This is the dimensional number: a triage pass that closes a deferral appends
73
- * a second same-key row, which must not read as a second deferral.
74
- */
75
- countOnlyRows: Record<string, number>;
76
- /** Raw line count per count-only ledger. Diverges from countOnlyRows once rows are updated. */
77
- countOnlyRawRows: Record<string, number>;
78
- malformedLineCount: number;
79
- skipped: boolean;
80
- skipReason?: string;
81
- /** Rows pruned from this consumer's ledgers, keyed by filename. */
82
- prunedRows: Record<string, number>;
83
- }
84
-
85
- export interface HarvestResult {
86
- consumers: HarvestConsumerResult[];
87
- totalCopiedRows: number;
88
- totalCountOnly: Record<string, number>;
89
- dedupedRows: number;
90
- totalPrunedRows: number;
91
- mergedState: FoldedState;
92
- }
93
-
94
- // ---------------------------------------------------------------------------
95
- // Read consumer list from `harvest/consumers.md`
96
- // ---------------------------------------------------------------------------
97
-
98
- /**
99
- * Read the list of consumer repo root paths from `harvest/consumers.md`.
100
- * Returns an array of absolute paths (non-empty lines, comments stripped).
101
- */
102
- export function readConsumerPaths(bkitRoot: string): string[] {
103
- const consumersFile = path.join(bkitRoot, CONSUMERS_FILE);
104
- if (!fs.existsSync(consumersFile)) {
105
- console.error(`[bkit-harvest] consumers file not found: ${consumersFile}`);
106
- return [];
107
- }
108
- const raw = fs.readFileSync(consumersFile, "utf-8");
109
- return raw
110
- .split("\n")
111
- .map((line) => line.trim())
112
- .filter((line) => line.length > 0 && !line.startsWith("#"));
113
- }
114
-
115
- // ---------------------------------------------------------------------------
116
- // Harvest a single consumer
117
- // ---------------------------------------------------------------------------
118
-
119
- /**
120
- * Harvest one consumer's `.bkit/{stats,friction}.jsonl` (COPY) and
121
- * `docs/{deferrals,failures}.jsonl` (COUNT-ONLY).
122
- * NEVER writes to the consumer repo.
123
- */
124
- export function harvestConsumer(consumerPath: string, bkitRoot: string): HarvestConsumerResult {
125
- const result: HarvestConsumerResult = {
126
- consumerPath,
127
- copiedRows: 0,
128
- countOnlyRows: {},
129
- countOnlyRawRows: {},
130
- malformedLineCount: 0,
131
- skipped: false,
132
- prunedRows: {},
133
- };
134
-
135
- if (!fs.existsSync(consumerPath)) {
136
- result.skipped = true;
137
- result.skipReason = `consumer path not found: ${consumerPath}`;
138
- console.error(`[bkit-harvest] SKIP ${consumerPath} — path not found`);
139
- return result;
140
- }
141
-
142
- const destDir = path.join(bkitRoot, HARVEST_DEST_DIR);
143
- if (!fs.existsSync(destDir)) {
144
- fs.mkdirSync(destDir, { recursive: true });
145
- }
146
-
147
- // COPY: .bkit/{stats,friction}.jsonl
148
- for (const filename of HARVEST_COPY_FILES) {
149
- const srcPath = path.join(consumerPath, ".bkit", filename);
150
- if (!fs.existsSync(srcPath)) {
151
- console.error(`[bkit-harvest] ${consumerPath}/.bkit/${filename} — not found, skipping`);
152
- continue;
153
- }
154
-
155
- // Record mtime BEFORE reading (copy-only invariant verification support)
156
- const statBefore = fs.statSync(srcPath);
157
- const raw = fs.readFileSync(srcPath, "utf-8");
158
- const statAfter = fs.statSync(srcPath);
159
-
160
- // Verify consumer file was not modified by our read (should always hold)
161
- if (statBefore.mtimeMs !== statAfter.mtimeMs) {
162
- console.error(
163
- `[bkit-harvest] WARNING: ${srcPath} mtime changed during read — harvest continues but data may be inconsistent`,
164
- );
165
- }
166
-
167
- const parsed = parse(raw);
168
- result.copiedRows += parsed.events.length;
169
- result.malformedLineCount += parsed.malformedLineCount;
170
-
171
- // Stamp repo on each event if missing
172
- const consumerSlug = consumerPathToSlug(consumerPath);
173
- const stamped = parsed.events.map((ev) => stampRepo(ev, consumerSlug));
174
-
175
- // Write to harvest dest (append)
176
- const destPath = path.join(destDir, filename);
177
- for (const ev of stamped) {
178
- fs.appendFileSync(destPath, JSON.stringify(ev) + "\n", "utf-8");
179
- }
180
-
181
- console.error(
182
- `[bkit-harvest] ${consumerPath}/.bkit/${filename} — copied ${parsed.events.length} rows (malformed: ${parsed.malformedLineCount})`,
183
- );
184
- }
185
-
186
- // COUNT-ONLY: docs/{deferrals,failures}.jsonl
187
- for (const filename of HARVEST_COUNT_FILES) {
188
- const srcPath = path.join(consumerPath, "docs", filename);
189
- if (!fs.existsSync(srcPath)) {
190
- continue;
191
- }
192
- const raw = fs.readFileSync(srcPath, "utf-8");
193
- const parsed = parse(raw);
194
- // Count ENTITIES, not lines: updating a deferral appends a new same-key row, and
195
- // `fold` collapses same-key rows to the current state. See .bkit/jsonl.md § Updating
196
- // a Row.
197
- const folded = fold(parsed.events);
198
- result.countOnlyRows[filename] = folded.size;
199
- result.countOnlyRawRows[filename] = parsed.events.length;
200
- result.malformedLineCount += parsed.malformedLineCount;
201
- console.error(
202
- `[bkit-harvest] ${consumerPath}/docs/${filename} — count-only: ${folded.size} entities (${parsed.events.length} rows)`,
203
- );
204
- }
205
-
206
- return result;
207
- }
208
-
209
- // ---------------------------------------------------------------------------
210
- // Prune — remove durably-stored rows from a consumer ledger
211
- // ---------------------------------------------------------------------------
212
-
213
- /**
214
- * Stamp `repo` on an event when the consumer wrote the row without one.
215
- * MUST be applied on both the store side and the prune side, or the two contents
216
- * diverge and a stored row is never recognised as prunable.
217
- */
218
- export function stampRepo(event: TelemetryEvent, consumerSlug: string): TelemetryEvent {
219
- return {
220
- ...event,
221
- repo: event.repo && event.repo.length > 0 ? event.repo : consumerSlug,
222
- };
223
- }
224
-
225
- /** What the store durably holds, read back off disk after fsync. */
226
- export interface DurableStore {
227
- /** Canonical JSON of every confirmed row. THE prune gate — content, not identity. */
228
- rows: Set<string>;
229
- }
230
-
231
- export interface PruneResult {
232
- removed: number;
233
- /** Lines left in the consumer: malformed, or appended after the copy. */
234
- kept: number;
235
- }
236
-
237
- /**
238
- * Remove from `srcPath` exactly those rows whose CONTENT is durably in the store.
239
- *
240
- * Gated on byte-for-byte content, NOT on identity.
241
- *
242
- * Line-level, NOT event-level: a line that does not parse is kept verbatim.
243
- *
244
- * Re-reads the file at prune time, so rows appended by the consumer DURING the harvest
245
- * survive.
246
- *
247
- * Writes via temp-file + rename; an interrupted prune never leaves a torn ledger.
248
- */
249
- export function pruneConsumerFile(
250
- srcPath: string,
251
- consumerSlug: string,
252
- durable: DurableStore,
253
- ): PruneResult {
254
- const raw = fs.readFileSync(srcPath, "utf-8");
255
- const kept: string[] = [];
256
- let removed = 0;
257
-
258
- for (const line of raw.split("\n")) {
259
- if (line.trim() === "") continue;
260
- const parsed = parseJson(line.trim());
261
- if (!parsed.ok) {
262
- kept.push(line); // malformed — never ours to delete
263
- continue;
264
- }
265
- const event = parsed.value as TelemetryEvent;
266
- if (durable.rows.has(canonicalRow(stampRepo(event, consumerSlug)))) {
267
- removed++;
268
- continue;
269
- }
270
- kept.push(line);
271
- }
272
-
273
- if (removed === 0) return { removed: 0, kept: kept.length };
274
-
275
- const next = kept.length > 0 ? kept.join("\n") + "\n" : "";
276
- const tmpPath = `${srcPath}.bkit-harvest.tmp`;
277
- fs.writeFileSync(tmpPath, next, "utf-8");
278
- fs.renameSync(tmpPath, srcPath);
279
- return { removed, kept: kept.length };
280
- }
281
-
282
- /**
283
- * Canonical serialisation used to compare a consumer row against a stored row.
284
- * Safe as a plain `JSON.stringify`: the store was written from exactly this function's
285
- * output, and a JSON.parse -> JSON.stringify round-trip preserves key order, so the
286
- * store's own rewrite is byte-stable.
287
- */
288
- function canonicalRow(event: TelemetryEvent): string {
289
- return JSON.stringify(event);
290
- }
291
-
292
- /** fsync a file to disk, so a durability check is not just a page-cache read. */
293
- function fsyncFile(filePath: string): void {
294
- const fd = fs.openSync(filePath, "r+");
295
- try {
296
- fs.fsyncSync(fd);
297
- } finally {
298
- fs.closeSync(fd);
299
- }
300
- }
301
-
302
- // ---------------------------------------------------------------------------
303
- // Run harvest across all consumers
304
- // ---------------------------------------------------------------------------
305
-
306
- /**
307
- * Run harvest across all consumers listed in `harvest/consumers.md`.
308
- * Deduplicates the store by row content after collecting all rows.
309
- */
310
- export function runHarvest(bkitRoot: string): HarvestResult {
311
- const consumerPaths = readConsumerPaths(bkitRoot);
312
- console.error(`[bkit-harvest] Found ${consumerPaths.length} consumer(s) in ${CONSUMERS_FILE}`);
313
-
314
- const consumerResults: HarvestConsumerResult[] = [];
315
- let totalCopied = 0;
316
- const totalCountOnly: Record<string, number> = {};
317
-
318
- // The central store ACCUMULATES — it is NEVER cleared between runs. Re-copied rows
319
- // collapse via the content dedup below.
320
- const destDir = path.join(bkitRoot, HARVEST_DEST_DIR);
321
-
322
- for (const consumerPath of consumerPaths) {
323
- console.error(`[bkit-harvest] Harvesting: ${consumerPath}`);
324
- const res = harvestConsumer(consumerPath, bkitRoot);
325
- consumerResults.push(res);
326
- if (!res.skipped) {
327
- totalCopied += res.copiedRows;
328
- for (const [k, v] of Object.entries(res.countOnlyRows)) {
329
- totalCountOnly[k] = (totalCountOnly[k] ?? 0) + v;
330
- }
331
- }
332
- }
333
-
334
- // Deduplicate by content: drop exact re-copies, keep every distinct row in first-seen
335
- // order. Entity counts come from the fold, which is a read — never what is written.
336
- let mergedState: FoldedState = new Map();
337
- let dedupedRows = 0;
338
- /** Per-file durable content read BACK OFF DISK — the prune gate. */
339
- const durableByFile: Record<string, DurableStore> = {};
340
-
341
- for (const filename of HARVEST_COPY_FILES) {
342
- const destPath = path.join(destDir, filename);
343
- if (!fs.existsSync(destPath)) continue;
344
- const raw = fs.readFileSync(destPath, "utf-8");
345
- const parsed = parse(raw);
346
- const folded = fold(parsed.events);
347
- mergedState = new Map([...mergedState, ...folded]);
348
- dedupedRows += folded.size;
349
-
350
- const distinctLines = [...new Set(parsed.events.map((ev) => canonicalRow(ev)))].join("\n");
351
- fs.writeFileSync(destPath, distinctLines + (distinctLines.length > 0 ? "\n" : ""), "utf-8");
352
-
353
- // Durability gate: fsync, then read the rows BACK OFF DISK; prune against those.
354
- fsyncFile(destPath);
355
- const verified = parse(fs.readFileSync(destPath, "utf-8"));
356
- durableByFile[filename] = {
357
- rows: new Set(verified.events.map((ev) => canonicalRow(ev))),
358
- };
359
- }
360
-
361
- // Prune ONLY now — every row below is confirmed byte-for-byte in the store on disk.
362
- let totalPruned = 0;
363
- let totalKept = 0;
364
- for (const res of consumerResults) {
365
- if (res.skipped) continue;
366
- const consumerSlug = consumerPathToSlug(res.consumerPath);
367
- for (const filename of HARVEST_PRUNE_FILES) {
368
- const srcPath = path.join(res.consumerPath, ".bkit", filename);
369
- if (!fs.existsSync(srcPath)) continue;
370
- const durable = durableByFile[filename];
371
- if (!durable || durable.rows.size === 0) continue;
372
- const { removed, kept } = pruneConsumerFile(srcPath, consumerSlug, durable);
373
- if (removed > 0) {
374
- res.prunedRows[filename] = removed;
375
- totalPruned += removed;
376
- console.error(
377
- `[bkit-harvest] ${res.consumerPath}/.bkit/${filename} — pruned ${removed} harvested row(s)`,
378
- );
379
- }
380
- if (kept > 0) {
381
- totalKept += kept;
382
- console.error(
383
- `[bkit-harvest] ${res.consumerPath}/.bkit/${filename} — kept ${kept} line(s) not in the store (malformed, or appended after the copy)`,
384
- );
385
- }
386
- }
387
- }
388
-
389
- console.error(
390
- `[bkit-harvest] Done — total rows collected: ${totalCopied}, entities after fold: ${dedupedRows}, pruned from consumers: ${totalPruned}, kept in consumers: ${totalKept}`,
391
- );
392
- if (totalPruned > 0) {
393
- console.error(
394
- `[bkit-harvest] ${totalPruned} row(s) now exist ONLY in ${HARVEST_DEST_DIR}/ (gitignored) — back it up to make them durable.`,
395
- );
396
- }
397
-
398
- return {
399
- consumers: consumerResults,
400
- totalCopiedRows: totalCopied,
401
- totalCountOnly,
402
- dedupedRows,
403
- totalPrunedRows: totalPruned,
404
- mergedState,
405
- };
406
- }
407
-
408
- // ---------------------------------------------------------------------------
409
- // Helpers
410
- // ---------------------------------------------------------------------------
411
-
412
- /** Convert an absolute consumer path to a repo slug for stamping. */
413
- export function consumerPathToSlug(consumerPath: string): string {
414
- // The consumer's OWN git remote — the only authoritative source.
415
- const slug = resolveRepoSlug(consumerPath);
416
- if (slug) return slug;
417
-
418
- // Last resort, and loud: a remote-less consumer still harvests.
419
- const parts = consumerPath
420
- .replace(/\/+$/, "")
421
- .split("/")
422
- .filter((p) => p.length > 0);
423
- const fallback = parts[parts.length - 1] ?? consumerPath;
424
- console.error(
425
- `[bkit-harvest] no git remote at ${consumerPath} — falling back to path-derived slug "${fallback}". ` +
426
- `This is NOT an owner/repo slug and will not join rows from the same repo harvested elsewhere.`,
427
- );
428
- return fallback;
429
- }
430
-
431
- // harvest — cross-repo harvest CLI.
432
- // Copies consumer .bkit/stats.jsonl and MOVES .bkit/friction.jsonl into harvest/;
433
- // COUNT-ONLY for docs/{deferrals,failures}.jsonl. Friction rows are pruned from the
434
- // consumer only after they are fsync'd + read back from the store. Fail-open: exits 0.
435
- // See DE-34 for the shared-entrypoint + crash-isolation contract.
436
- export function runHarvestCommand(): void {
437
- try {
438
- const cwd = process.cwd();
439
- console.log("[bkit-harvest] Starting cross-repo harvest...");
440
- const result = runHarvest(cwd);
441
- console.log(
442
- `[bkit-harvest] Harvest complete — consumers: ${result.consumers.length}, rows copied: ${result.totalCopiedRows}, entities after fold: ${result.dedupedRows}, pruned from consumers: ${result.totalPrunedRows}`,
443
- );
444
- const countOnlyEntries = Object.entries(result.totalCountOnly);
445
- if (countOnlyEntries.length > 0) {
446
- for (const [file, count] of countOnlyEntries) {
447
- console.log(`[bkit-harvest] count-only ${file}: ${count} rows (not copied)`);
448
- }
449
- }
450
- if (result.totalPrunedRows > 0) {
451
- console.log(
452
- `[bkit-harvest] ${result.totalPrunedRows} friction row(s) were REMOVED from consumers and now exist only in ${HARVEST_DEST_DIR}/ — commit it.`,
453
- );
454
- }
455
- } catch (err: unknown) {
456
- const msg = err instanceof Error ? err.message : String(err);
457
- console.error(`[bkit-harvest] harvest error (fail-open): ${msg}`);
458
- }
459
- }