@cbartens/bkit 0.0.0-stage → 5.0.1
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.
- package/.bkit/README.md +417 -0
- package/.bkit/core/.agents/context.md +95 -0
- package/.bkit/core/.agents/docs.md +62 -0
- package/.bkit/core/.agents/rules.md +147 -0
- package/.bkit/core/.agents/skills.md +43 -0
- package/.bkit/core/.bkit/LICENSE.md +151 -0
- package/.bkit/core/.bkit/README.md +417 -0
- package/.bkit/core/.bkit/cloud.md +493 -0
- package/.bkit/core/.bkit/comparison.md +321 -0
- package/.bkit/core/.bkit/install.md +401 -0
- package/.bkit/core/.bkit/jsonl.md +497 -0
- package/.bkit/core/.bkit/prompts.md +474 -0
- package/.bkit/core/.bkit/providers.md +598 -0
- package/.bkit/core/.bkit/templates.md +470 -0
- package/.bkit/core/.bkit/trackers.md +95 -0
- package/.bkit/core/.bkit/workflows.md +1550 -0
- package/.bkit/core/.claude/hooks/bkit-gateguard.cjs +82 -0
- package/.bkit/core/.claude/hooks/bkit-guardrails.cjs +93 -0
- package/.bkit/core/.claude/hooks/bkit-preflight.sh +74 -0
- package/.bkit/core/.codex/hooks/bkit-gateguard.cjs +115 -0
- package/.bkit/core/.codex/hooks/bkit-guardrails.cjs +135 -0
- package/.bkit/core/.cursor/hooks/bkit-gateguard.cjs +111 -0
- package/.bkit/core/.cursor/hooks/bkit-guardrails.cjs +169 -0
- package/.bkit/core/.cursor/hooks/bkit-preflight.sh +63 -0
- package/.bkit/core/.opencode/plugin/bkit-gateguard.js +225 -0
- package/.bkit/core/AGENTS.md +77 -0
- package/.bkit/core/LICENSE.md +149 -0
- package/.bkit/core/docs/templates/bkit-audit-accessibility.md +272 -0
- package/.bkit/core/docs/templates/bkit-audit-adoption.md +223 -0
- package/.bkit/core/docs/templates/bkit-audit-agents.md +230 -0
- package/.bkit/core/docs/templates/bkit-audit-aio-seo.md +227 -0
- package/.bkit/core/docs/templates/bkit-audit-analytics.md +266 -0
- package/.bkit/core/docs/templates/bkit-audit-annotations.md +230 -0
- package/.bkit/core/docs/templates/bkit-audit-app-performance.md +270 -0
- package/.bkit/core/docs/templates/bkit-audit-app-store.md +254 -0
- package/.bkit/core/docs/templates/bkit-audit-architecture.md +221 -0
- package/.bkit/core/docs/templates/bkit-audit-ci-performance.md +241 -0
- package/.bkit/core/docs/templates/bkit-audit-config.md +230 -0
- package/.bkit/core/docs/templates/bkit-audit-cost.md +218 -0
- package/.bkit/core/docs/templates/bkit-audit-coverage.md +221 -0
- package/.bkit/core/docs/templates/bkit-audit-database.md +229 -0
- package/.bkit/core/docs/templates/bkit-audit-dead-code.md +251 -0
- package/.bkit/core/docs/templates/bkit-audit-deferrals.md +283 -0
- package/.bkit/core/docs/templates/bkit-audit-dependencies.md +268 -0
- package/.bkit/core/docs/templates/bkit-audit-documentation.md +280 -0
- package/.bkit/core/docs/templates/bkit-audit-duplication.md +253 -0
- package/.bkit/core/docs/templates/bkit-audit-failures.md +259 -0
- package/.bkit/core/docs/templates/bkit-audit-flakes.md +237 -0
- package/.bkit/core/docs/templates/bkit-audit-gates.md +250 -0
- package/.bkit/core/docs/templates/bkit-audit-issues.md +273 -0
- package/.bkit/core/docs/templates/bkit-audit-llm.md +239 -0
- package/.bkit/core/docs/templates/bkit-audit-logs.md +266 -0
- package/.bkit/core/docs/templates/bkit-audit-models.md +210 -0
- package/.bkit/core/docs/templates/bkit-audit-privacy.md +211 -0
- package/.bkit/core/docs/templates/bkit-audit-prompts.md +216 -0
- package/.bkit/core/docs/templates/bkit-audit-red-team.md +220 -0
- package/.bkit/core/docs/templates/bkit-audit-reliability.md +222 -0
- package/.bkit/core/docs/templates/bkit-audit-repo.md +224 -0
- package/.bkit/core/docs/templates/bkit-audit-security.md +274 -0
- package/.bkit/core/docs/templates/bkit-audit-slop.md +200 -0
- package/.bkit/core/docs/templates/bkit-audit-testing.md +270 -0
- package/.bkit/core/docs/templates/bkit-audit-usability.md +237 -0
- package/.bkit/core/docs/templates/bkit-plan.md +476 -0
- package/.bkit/core/engine/checks/after/auth.ts +149 -0
- package/.bkit/core/engine/checks/after/ci-yml.ts +701 -0
- package/.bkit/core/engine/checks/after/github.ts +424 -0
- package/.bkit/core/engine/checks/after/index.ts +530 -0
- package/.bkit/core/engine/checks/after/managed.ts +217 -0
- package/.bkit/core/engine/checks/after/suppression.ts +53 -0
- package/.bkit/core/engine/checks/after/tools.ts +427 -0
- package/.bkit/core/engine/checks/before/context-fetch.ts +429 -0
- package/.bkit/core/engine/checks/before/env.ts +187 -0
- package/.bkit/core/engine/checks/before/files.ts +204 -0
- package/.bkit/core/engine/checks/before/index.ts +206 -0
- package/.bkit/core/engine/checks/before/mcp.ts +127 -0
- package/.bkit/core/engine/checks/before/repo.ts +77 -0
- package/.bkit/core/engine/checks/before/version.ts +67 -0
- package/.bkit/core/engine/checks/status-holes.ts +479 -0
- package/.bkit/core/engine/cli.ts +867 -0
- package/.bkit/core/engine/commands/analysis.ts +550 -0
- package/.bkit/core/engine/commands/ci/ci.ts +483 -0
- package/.bkit/core/engine/commands/comply.ts +415 -0
- package/.bkit/core/engine/commands/harvest.ts +459 -0
- package/.bkit/core/engine/commands/install/check.ts +70 -0
- package/.bkit/core/engine/commands/install/doctor.ts +254 -0
- package/.bkit/core/engine/commands/install/install.ts +550 -0
- package/.bkit/core/engine/commands/install/uninstall.ts +995 -0
- package/.bkit/core/engine/commands/install/upgrade.ts +1037 -0
- package/.bkit/core/engine/commands/launch.ts +139 -0
- package/.bkit/core/engine/commands/lib.ts +495 -0
- package/.bkit/core/engine/commands/registry.ts +53 -0
- package/.bkit/core/engine/commands/setup/setup.ts +184 -0
- package/.bkit/core/engine/commands/telemetry.ts +32 -0
- package/.bkit/core/engine/commands/workflow/branches.ts +1514 -0
- package/.bkit/core/engine/commands/workflow/context.ts +961 -0
- package/.bkit/core/engine/commands/workflow/counters.ts +268 -0
- package/.bkit/core/engine/commands/workflow/fids.ts +243 -0
- package/.bkit/core/engine/commands/workflow/issues.ts +675 -0
- package/.bkit/core/engine/commands/workflow/ledgers.ts +575 -0
- package/.bkit/core/engine/commands/workflow/locks.ts +478 -0
- package/.bkit/core/engine/commands/workflow/prs.ts +1087 -0
- package/.bkit/core/engine/commands/workflow/repo.ts +220 -0
- package/.bkit/core/engine/commands/workflow/roadmap.ts +576 -0
- package/.bkit/core/engine/commands/workflow/runs.ts +2140 -0
- package/.bkit/core/engine/commands/workflow/runtime.ts +300 -0
- package/.bkit/core/engine/commands/workflow/skills.ts +118 -0
- package/.bkit/core/engine/commands/workflow/status.ts +455 -0
- package/.bkit/core/engine/commands/workflow/steps.ts +1300 -0
- package/.bkit/core/engine/commands/workflow/tests.ts +161 -0
- package/.bkit/core/engine/commands/workflow/workflows.ts +1573 -0
- package/.bkit/core/engine/commands/workflow/workstreams.ts +164 -0
- package/.bkit/core/engine/commands/workflow/worktrees.ts +534 -0
- package/.bkit/core/engine/install/cloud-env.ts +924 -0
- package/.bkit/core/engine/install/managed-block.ts +212 -0
- package/.bkit/core/engine/install/manifest.ts +448 -0
- package/.bkit/core/engine/install/modules/claude.ts +362 -0
- package/.bkit/core/engine/install/modules/cloud.ts +173 -0
- package/.bkit/core/engine/install/modules/codex.ts +219 -0
- package/.bkit/core/engine/install/modules/core.ts +620 -0
- package/.bkit/core/engine/install/modules/cursor.ts +231 -0
- package/.bkit/core/engine/install/modules/index.ts +242 -0
- package/.bkit/core/engine/install/modules/opencode.ts +573 -0
- package/.bkit/core/engine/install/payload-links.ts +150 -0
- package/.bkit/core/engine/install/placeholders.ts +108 -0
- package/.bkit/core/engine/install/template-copies.ts +119 -0
- package/.bkit/core/engine/install/version-file.ts +284 -0
- package/.bkit/core/engine/install/write.ts +467 -0
- package/.bkit/core/engine/ledgers/clamp-log.ts +32 -0
- package/.bkit/core/engine/ledgers/status.ts +213 -0
- package/.bkit/core/engine/ledgers/telemetry.ts +1143 -0
- package/.bkit/core/engine/render/hosts.ts +372 -0
- package/.bkit/core/engine/render/models.ts +323 -0
- package/.bkit/core/engine/render/parts.ts +38 -0
- package/.bkit/core/engine/render/trackers.ts +170 -0
- package/.bkit/core/engine/shared/egress.ts +345 -0
- package/.bkit/core/engine/shared/json.ts +16 -0
- package/.bkit/core/engine/shared/log-prefix.ts +9 -0
- package/.bkit/core/engine/shared/package-json.ts +29 -0
- package/.bkit/core/engine/shared/package-manager.ts +38 -0
- package/.bkit/core/engine/shared/package-roots.ts +163 -0
- package/.bkit/core/engine/shared/protected-paths.ts +164 -0
- package/.bkit/core/engine/shared/settings.ts +72 -0
- package/.bkit/core/engine/shared/timeouts.ts +20 -0
- package/.bkit/core/engine/tools/wording.ts +748 -0
- package/.bkit/core/hooks/gateguard-edit-payload.js +18 -0
- package/.bkit/core/hooks/gateguard-engine.js +193 -0
- package/.bkit/core/hooks/guardrails-shell.js +154 -0
- package/.bkit/core/hooks/guardrails-tiers.js +68 -0
- package/.bkit/core/hooks/preflight-linear.sh +73 -0
- package/.bkit/core/prompts/bkit-audit-generate.md +66 -0
- package/.bkit/core/prompts/bkit-build-challenge-1.md +79 -0
- package/.bkit/core/prompts/bkit-build-challenge-2.md +81 -0
- package/.bkit/core/prompts/bkit-build-challenge-reconcile.md +68 -0
- package/.bkit/core/prompts/bkit-build-challenge-remediate.md +70 -0
- package/.bkit/core/prompts/bkit-build-challenge-tests.md +73 -0
- package/.bkit/core/prompts/bkit-build-install-skills.md +67 -0
- package/.bkit/core/prompts/bkit-build-plan-current.md +75 -0
- package/.bkit/core/prompts/bkit-build-plan-execute.md +72 -0
- package/.bkit/core/prompts/bkit-build-plan-gaps-remediate.md +73 -0
- package/.bkit/core/prompts/bkit-build-plan-verify.md +88 -0
- package/.bkit/core/prompts/bkit-build-summary.md +93 -0
- package/.bkit/core/prompts/bkit-debug-abort-handover.md +90 -0
- package/.bkit/core/prompts/bkit-debug-failure-diagnose.md +151 -0
- package/.bkit/core/prompts/bkit-debug-failure-remediate.md +78 -0
- package/.bkit/core/prompts/bkit-debug-failure-soak.md +73 -0
- package/.bkit/core/prompts/bkit-debug-summary.md +95 -0
- package/.bkit/core/prompts/bkit-design-brainstorm-ideate-1.md +72 -0
- package/.bkit/core/prompts/bkit-design-brainstorm-ideate-2.md +72 -0
- package/.bkit/core/prompts/bkit-design-brainstorm-ideate-3.md +75 -0
- package/.bkit/core/prompts/bkit-design-generate.md +110 -0
- package/.bkit/core/prompts/bkit-design-organise.md +85 -0
- package/.bkit/core/prompts/bkit-design-review-1.md +121 -0
- package/.bkit/core/prompts/bkit-design-review-2.md +111 -0
- package/.bkit/core/prompts/bkit-design-spike.md +97 -0
- package/.bkit/core/prompts/bkit-design-summary.md +106 -0
- package/.bkit/core/prompts/bkit-design-update.md +66 -0
- package/.bkit/core/prompts/bkit-plan-complexity-check.md +66 -0
- package/.bkit/core/prompts/bkit-plan-complexity-split.md +87 -0
- package/.bkit/core/prompts/bkit-plan-generate.md +74 -0
- package/.bkit/core/prompts/bkit-plan-review-1.md +90 -0
- package/.bkit/core/prompts/bkit-plan-review-2.md +80 -0
- package/.bkit/core/prompts/bkit-plan-review-3.md +92 -0
- package/.bkit/core/prompts/bkit-plan-scope-check-1.md +84 -0
- package/.bkit/core/prompts/bkit-plan-scope-check-2.md +84 -0
- package/.bkit/core/prompts/bkit-plan-summary.md +106 -0
- package/.bkit/core/prompts/bkit-plan-update.md +68 -0
- package/.bkit/core/prompts/bkit-ship-conflict-resolve.md +90 -0
- package/.bkit/core/prompts/bkit-ship-deferred-sweep.md +94 -0
- package/.bkit/core/prompts/bkit-ship-summary.md +77 -0
- package/.bkit/core/prompts/bkit-ship-update-docs.md +71 -0
- package/.bkit/core/prompts/bkit-utility-compress-markdown.md +91 -0
- package/.bkit/core/prompts/bkit-utility-update-decisions.md +75 -0
- package/.bkit/core/prompts/bkit-utility-update-deferrals.md +76 -0
- package/.bkit/core/prompts/bkit-utility-update-documentation.md +61 -0
- package/.bkit/core/prompts/bkit-utility-update-failures.md +76 -0
- package/.bkit/core/prompts/bkit-utility-update-knowledge.md +75 -0
- package/.bkit/core/prompts/bkit-utility-update-roadmap.md +82 -0
- package/.bkit/core/workflows/bkit-auto.md +121 -0
- package/.bkit/core/workflows/bkit-build.md +802 -0
- package/.bkit/core/workflows/bkit-debug.md +649 -0
- package/.bkit/core/workflows/bkit-design.md +495 -0
- package/.bkit/core/workflows/bkit-plan.md +510 -0
- package/.bkit/core/workflows/bkit-ship.md +650 -0
- package/.bkit/shared/.bkit/.env.example +86 -0
- package/.bkit/shared/.claude/bkit-cloud.md +117 -0
- package/.bkit/shared/.claude/settings.json +88 -0
- package/.bkit/shared/.codex/hooks.json +26 -0
- package/.bkit/shared/.cursor/bkit-cloud.md +84 -0
- package/.bkit/shared/.cursor/hooks.json +26 -0
- package/.bkit/shared/.cursor/mcp.json +15 -0
- package/.bkit/shared/.cursor/rules/bkit-rules.mdc +12 -0
- package/.bkit/shared/.gitattributes +37 -0
- package/.bkit/shared/.mcp.json +16 -0
- package/.bkit/shared/.opencode/opencode.json +62 -0
- package/.bkit/shared/CLAUDE.md +11 -0
- package/.bkit/shared/LICENSE.md +22 -0
- package/.bkit/shared/docs/architecture.md +19 -0
- package/.bkit/shared/docs/data-schema.md +19 -0
- package/.bkit/shared/docs/deployments.md +433 -0
- package/.bkit/shared/docs/design.md +39 -0
- package/.bkit/shared/docs/noise.md +19 -0
- package/.bkit/shared/docs/observability.md +25 -0
- package/.bkit/shared/docs/security.md +42 -0
- package/.bkit/shared/docs/setup.md +30 -0
- package/.bkit/shared/docs/technology.md +18 -0
- package/.bkit/shared/docs/testing.md +413 -0
- package/.bkit/shared/gitignore +97 -0
- package/.bkit/templates/.claude/hooks/bkit-cloud-bootstrap.sh +187 -0
- package/.bkit/templates/.cursor/Dockerfile +68 -0
- package/.bkit/templates/.cursor/environment.json +6 -0
- package/.bkit/templates/.cursor/settings.json +11 -0
- package/.bkit/templates/.envrc +7 -0
- package/.bkit/templates/.github/dependabot.yml +52 -0
- package/.bkit/templates/.github/renovate.json5 +224 -0
- package/.bkit/templates/.github/workflows/bkit-ci.yml +1062 -0
- package/.bkit/templates/.github/workflows/bkit-cloud.yml +564 -0
- package/.bkit/templates/.github/workflows/bkit-renovate.yml +102 -0
- package/.bkit/templates/.graphifyignore +108 -0
- package/.bkit/templates/.husky/pre-commit +16 -0
- package/.bkit/templates/.husky/pre-push +91 -0
- package/.bkit/templates/.lintstagedrc.json +3 -0
- package/.bkit/templates/.prettierignore +41 -0
- package/.bkit/templates/.serena/project.yml +243 -0
- package/.bkit/templates/.vale/styles/House/Filler.yml +11 -0
- package/.bkit/templates/.vale/styles/House/Hedging.yml +12 -0
- package/.bkit/templates/.vale/styles/House/LLMSlop.yml +13 -0
- package/.bkit/templates/.vale/styles/House/Verbose.yml +12 -0
- package/.bkit/templates/.vale.ini +67 -0
- package/.bkit/templates/LICENSE.md +22 -0
- package/.bkit/templates/context/bkit-cloudrun.md +84 -0
- package/.bkit/templates/context/bkit-expo.md +186 -0
- package/.bkit/templates/context/bkit-github.md +79 -0
- package/.bkit/templates/context/bkit-inngest.md +45 -0
- package/.bkit/templates/context/bkit-maestro.md +76 -0
- package/.bkit/templates/context/bkit-playwright.md +62 -0
- package/.bkit/templates/context/bkit-resend.md +36 -0
- package/.bkit/templates/context/bkit-sentry.md +65 -0
- package/.bkit/templates/context/bkit-serena.md +33 -0
- package/.bkit/templates/context/bkit-stripe.md +36 -0
- package/.bkit/templates/context/bkit-supabase.md +59 -0
- package/.bkit/templates/context/bkit-tavily.md +49 -0
- package/.bkit/templates/context/bkit-vercel.md +64 -0
- package/.bkit/templates/docs/capabilities.md +72 -0
- package/.bkit/templates/scripts/ci/accepted-divergences.json +21 -0
- package/.bkit/templates/scripts/ci/check-accepted-divergences.mjs +152 -0
- package/.bkit/templates/scripts/ci/check-accepted-divergences.test.mjs +130 -0
- package/.bkit/templates/scripts/ci/lanes/resolve-push-base.mjs +98 -0
- package/.bkit/templates/scripts/ci/lanes/resolve-push-base.test.mjs +86 -0
- package/.bkit/templates/scripts/graphify/bkit-graph-drift-rules.json +23 -0
- package/.bkit/templates/scripts/graphify/bkit-graph-drift.py +208 -0
- package/.bkit/templates/scripts/graphify/bkit-graph-eager-rules.json +35 -0
- package/.bkit/templates/scripts/graphify/bkit-graph-eager.py +236 -0
- package/.bkit/templates/scripts/graphify/bkit-graph-external-rules.json +17 -0
- package/.bkit/templates/scripts/graphify/bkit-graph-imports.py +290 -0
- package/.bkit/templates/scripts/graphify/bkit-graph-pre-push.sh +19 -0
- package/.bkit/templates/scripts/graphify/bkit-graph-repair.py +120 -0
- package/.bkit/templates/scripts/graphify/bkit-graph-surface.py +232 -0
- package/.bkit/templates/scripts/graphify/bkit-graphify-graphml.py +36 -0
- package/.bkit/templates/scripts/graphify/bkit-graphify-rollup.py +927 -0
- package/.bkit/templates/scripts/graphify/bkit-graphify.sh +351 -0
- package/.bkit/templates/scripts/launchd/ai.bkit.launchd.plist +26 -0
- package/.bkit/templates/scripts/launchd/bkit-launchd-env.sh +53 -0
- package/.bkit/templates/scripts/launchd/launchd.env.example +13 -0
- package/.bkit/templates/scripts/prettier/bkit-insert-ignore.mjs +275 -0
- package/.bkit/templates/scripts/secrets/bkit-secrets.config.mjs +66 -0
- package/.bkit/templates/scripts/secrets/bkit-secrets.mjs +785 -0
- package/.bkit/templates/scripts/serena/bkit-serena-mcp.sh +30 -0
- package/.bkit/templates/scripts/serena/bkit-serena.mcp.json +9 -0
- package/.bkit/templates/scripts/slop/bkit-slop-type-suppression.mjs +286 -0
- package/.bkit/templates/slop-scan.config.json +120 -0
- package/CHANGELOG.md +1503 -0
- package/LICENSE.md +161 -0
- package/README.md +184 -2
- package/dist/checks/after/auth.js +140 -0
- package/dist/checks/after/ci-yml.js +681 -0
- package/dist/checks/after/github.js +400 -0
- package/dist/checks/after/index.js +431 -0
- package/dist/checks/after/managed.js +187 -0
- package/dist/checks/after/suppression.js +39 -0
- package/dist/checks/after/tools.js +351 -0
- package/dist/checks/before/context-fetch.js +426 -0
- package/dist/checks/before/env.js +163 -0
- package/dist/checks/before/files.js +187 -0
- package/dist/checks/before/index.js +162 -0
- package/dist/checks/before/mcp.js +111 -0
- package/dist/checks/before/repo.js +71 -0
- package/dist/checks/before/version.js +60 -0
- package/dist/checks/status-holes.js +393 -0
- package/dist/cli.js +688 -0
- package/dist/commands/analysis.js +325 -0
- package/dist/commands/ci/ci.js +438 -0
- package/dist/commands/comply.js +310 -0
- package/dist/commands/harvest.js +354 -0
- package/dist/commands/install/check.js +61 -0
- package/dist/commands/install/doctor.js +209 -0
- package/dist/commands/install/install.js +475 -0
- package/dist/commands/install/uninstall.js +839 -0
- package/dist/commands/install/upgrade.js +782 -0
- package/dist/commands/launch.js +118 -0
- package/dist/commands/lib.js +363 -0
- package/dist/commands/registry.js +50 -0
- package/dist/commands/setup/setup.js +158 -0
- package/dist/commands/telemetry.js +29 -0
- package/dist/commands/workflow/branches.js +1265 -0
- package/dist/commands/workflow/context.js +846 -0
- package/dist/commands/workflow/counters.js +227 -0
- package/dist/commands/workflow/fids.js +224 -0
- package/dist/commands/workflow/issues.js +585 -0
- package/dist/commands/workflow/ledgers.js +472 -0
- package/dist/commands/workflow/locks.js +364 -0
- package/dist/commands/workflow/prs.js +904 -0
- package/dist/commands/workflow/repo.js +199 -0
- package/dist/commands/workflow/roadmap.js +495 -0
- package/dist/commands/workflow/runs.js +1717 -0
- package/dist/commands/workflow/runtime.js +257 -0
- package/dist/commands/workflow/skills.js +110 -0
- package/dist/commands/workflow/status.js +392 -0
- package/dist/commands/workflow/steps.js +1093 -0
- package/dist/commands/workflow/tests.js +144 -0
- package/dist/commands/workflow/workflows.js +1342 -0
- package/dist/commands/workflow/workstreams.js +141 -0
- package/dist/commands/workflow/worktrees.js +473 -0
- package/dist/install/cloud-env.js +818 -0
- package/dist/install/managed-block.js +182 -0
- package/dist/install/manifest.js +376 -0
- package/dist/install/modules/claude.js +288 -0
- package/dist/install/modules/cloud.js +151 -0
- package/dist/install/modules/codex.js +193 -0
- package/dist/install/modules/core.js +531 -0
- package/dist/install/modules/cursor.js +186 -0
- package/dist/install/modules/index.js +152 -0
- package/dist/install/modules/opencode.js +504 -0
- package/dist/install/payload-links.js +119 -0
- package/dist/install/placeholders.js +87 -0
- package/dist/install/template-copies.js +106 -0
- package/dist/install/version-file.js +204 -0
- package/dist/install/write.js +342 -0
- package/dist/ledgers/clamp-log.js +27 -0
- package/dist/ledgers/status.js +156 -0
- package/dist/ledgers/telemetry.js +637 -0
- package/dist/render/hosts.js +339 -0
- package/dist/render/models.js +288 -0
- package/dist/render/parts.js +33 -0
- package/dist/render/trackers.js +135 -0
- package/dist/shared/egress.js +299 -0
- package/dist/shared/json.js +16 -0
- package/dist/shared/log-prefix.js +7 -0
- package/dist/shared/package-json.js +22 -0
- package/dist/shared/package-manager.js +32 -0
- package/dist/shared/package-roots.js +145 -0
- package/dist/shared/protected-paths.js +153 -0
- package/dist/shared/settings.js +44 -0
- package/dist/shared/timeouts.js +19 -0
- package/dist/tools/wording.js +680 -0
- package/package.json +101 -4
|
@@ -0,0 +1,459 @@
|
|
|
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
|
+
// the only record of pruned consumer friction until the caller commits it; readers
|
|
18
|
+
// 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 `docs/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
|
+
|
|
40
|
+
// ---------------------------------------------------------------------------
|
|
41
|
+
// Constants
|
|
42
|
+
// ---------------------------------------------------------------------------
|
|
43
|
+
|
|
44
|
+
/** Files to COPY from each consumer's `.bkit/` directory (content + dedup). */
|
|
45
|
+
export const HARVEST_COPY_FILES = ["stats.jsonl", "friction.jsonl"] as const;
|
|
46
|
+
/**
|
|
47
|
+
* Files PRUNED from the consumer after their rows are durably in the central store.
|
|
48
|
+
* Must be a subset of HARVEST_COPY_FILES. `stats.jsonl` is absent: it is copied, never
|
|
49
|
+
* moved.
|
|
50
|
+
*/
|
|
51
|
+
export const HARVEST_PRUNE_FILES = ["friction.jsonl"] as const;
|
|
52
|
+
/** Files to COUNT-ONLY from each consumer's `docs/` directory (metadata only). */
|
|
53
|
+
export const HARVEST_COUNT_FILES = ["deferrals.jsonl", "failures.jsonl"] as const;
|
|
54
|
+
/** Path (relative to bkit repo root) for the consumers list. */
|
|
55
|
+
export const CONSUMERS_FILE = "docs/consumers.md";
|
|
56
|
+
/**
|
|
57
|
+
* Destination directory in bkit for harvested data. Repo root, NOT under `.bkit/`
|
|
58
|
+
* (bkit's managed/installed surface).
|
|
59
|
+
*/
|
|
60
|
+
export const HARVEST_DEST_DIR = "harvest";
|
|
61
|
+
|
|
62
|
+
// ---------------------------------------------------------------------------
|
|
63
|
+
// Types
|
|
64
|
+
// ---------------------------------------------------------------------------
|
|
65
|
+
|
|
66
|
+
export interface HarvestConsumerResult {
|
|
67
|
+
consumerPath: string;
|
|
68
|
+
copiedRows: number;
|
|
69
|
+
/**
|
|
70
|
+
* Distinct ENTITIES per count-only ledger (same-key rows folded to one).
|
|
71
|
+
* This is the dimensional number: a triage pass that closes a deferral appends
|
|
72
|
+
* a second same-key row, which must not read as a second deferral.
|
|
73
|
+
*/
|
|
74
|
+
countOnlyRows: Record<string, number>;
|
|
75
|
+
/** Raw line count per count-only ledger. Diverges from countOnlyRows once rows are updated. */
|
|
76
|
+
countOnlyRawRows: Record<string, number>;
|
|
77
|
+
malformedLineCount: number;
|
|
78
|
+
skipped: boolean;
|
|
79
|
+
skipReason?: string;
|
|
80
|
+
/** Rows pruned from this consumer's ledgers, keyed by filename. */
|
|
81
|
+
prunedRows: Record<string, number>;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
export interface HarvestResult {
|
|
85
|
+
consumers: HarvestConsumerResult[];
|
|
86
|
+
totalCopiedRows: number;
|
|
87
|
+
totalCountOnly: Record<string, number>;
|
|
88
|
+
dedupedRows: number;
|
|
89
|
+
totalPrunedRows: number;
|
|
90
|
+
mergedState: FoldedState;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
// ---------------------------------------------------------------------------
|
|
94
|
+
// Read consumer list from `docs/consumers.md`
|
|
95
|
+
// ---------------------------------------------------------------------------
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* Read the list of consumer repo root paths from `docs/consumers.md`.
|
|
99
|
+
* Returns an array of absolute paths (non-empty lines, comments stripped).
|
|
100
|
+
*/
|
|
101
|
+
export function readConsumerPaths(bkitRoot: string): string[] {
|
|
102
|
+
const consumersFile = path.join(bkitRoot, CONSUMERS_FILE);
|
|
103
|
+
if (!fs.existsSync(consumersFile)) {
|
|
104
|
+
console.error(`[bkit-harvest] consumers file not found: ${consumersFile}`);
|
|
105
|
+
return [];
|
|
106
|
+
}
|
|
107
|
+
const raw = fs.readFileSync(consumersFile, "utf-8");
|
|
108
|
+
return raw
|
|
109
|
+
.split("\n")
|
|
110
|
+
.map((line) => line.trim())
|
|
111
|
+
.filter((line) => line.length > 0 && !line.startsWith("#"));
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
// ---------------------------------------------------------------------------
|
|
115
|
+
// Harvest a single consumer
|
|
116
|
+
// ---------------------------------------------------------------------------
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* Harvest one consumer's `.bkit/{stats,friction}.jsonl` (COPY) and
|
|
120
|
+
* `docs/{deferrals,failures}.jsonl` (COUNT-ONLY).
|
|
121
|
+
* NEVER writes to the consumer repo.
|
|
122
|
+
*/
|
|
123
|
+
export function harvestConsumer(consumerPath: string, bkitRoot: string): HarvestConsumerResult {
|
|
124
|
+
const result: HarvestConsumerResult = {
|
|
125
|
+
consumerPath,
|
|
126
|
+
copiedRows: 0,
|
|
127
|
+
countOnlyRows: {},
|
|
128
|
+
countOnlyRawRows: {},
|
|
129
|
+
malformedLineCount: 0,
|
|
130
|
+
skipped: false,
|
|
131
|
+
prunedRows: {},
|
|
132
|
+
};
|
|
133
|
+
|
|
134
|
+
if (!fs.existsSync(consumerPath)) {
|
|
135
|
+
result.skipped = true;
|
|
136
|
+
result.skipReason = `consumer path not found: ${consumerPath}`;
|
|
137
|
+
console.error(`[bkit-harvest] SKIP ${consumerPath} — path not found`);
|
|
138
|
+
return result;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
const destDir = path.join(bkitRoot, HARVEST_DEST_DIR);
|
|
142
|
+
if (!fs.existsSync(destDir)) {
|
|
143
|
+
fs.mkdirSync(destDir, { recursive: true });
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
// COPY: .bkit/{stats,friction}.jsonl
|
|
147
|
+
for (const filename of HARVEST_COPY_FILES) {
|
|
148
|
+
const srcPath = path.join(consumerPath, ".bkit", filename);
|
|
149
|
+
if (!fs.existsSync(srcPath)) {
|
|
150
|
+
console.error(`[bkit-harvest] ${consumerPath}/.bkit/${filename} — not found, skipping`);
|
|
151
|
+
continue;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
// Record mtime BEFORE reading (copy-only invariant verification support)
|
|
155
|
+
const statBefore = fs.statSync(srcPath);
|
|
156
|
+
const raw = fs.readFileSync(srcPath, "utf-8");
|
|
157
|
+
const statAfter = fs.statSync(srcPath);
|
|
158
|
+
|
|
159
|
+
// Verify consumer file was not modified by our read (should always hold)
|
|
160
|
+
if (statBefore.mtimeMs !== statAfter.mtimeMs) {
|
|
161
|
+
console.error(
|
|
162
|
+
`[bkit-harvest] WARNING: ${srcPath} mtime changed during read — harvest continues but data may be inconsistent`,
|
|
163
|
+
);
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
const parsed = parse(raw);
|
|
167
|
+
result.copiedRows += parsed.events.length;
|
|
168
|
+
result.malformedLineCount += parsed.malformedLineCount;
|
|
169
|
+
|
|
170
|
+
// Stamp repo on each event if missing
|
|
171
|
+
const consumerSlug = consumerPathToSlug(consumerPath);
|
|
172
|
+
const stamped = parsed.events.map((ev) => stampRepo(ev, consumerSlug));
|
|
173
|
+
|
|
174
|
+
// Write to harvest dest (append)
|
|
175
|
+
const destPath = path.join(destDir, filename);
|
|
176
|
+
for (const ev of stamped) {
|
|
177
|
+
fs.appendFileSync(destPath, JSON.stringify(ev) + "\n", "utf-8");
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
console.error(
|
|
181
|
+
`[bkit-harvest] ${consumerPath}/.bkit/${filename} — copied ${parsed.events.length} rows (malformed: ${parsed.malformedLineCount})`,
|
|
182
|
+
);
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
// COUNT-ONLY: docs/{deferrals,failures}.jsonl
|
|
186
|
+
for (const filename of HARVEST_COUNT_FILES) {
|
|
187
|
+
const srcPath = path.join(consumerPath, "docs", filename);
|
|
188
|
+
if (!fs.existsSync(srcPath)) {
|
|
189
|
+
continue;
|
|
190
|
+
}
|
|
191
|
+
const raw = fs.readFileSync(srcPath, "utf-8");
|
|
192
|
+
const parsed = parse(raw);
|
|
193
|
+
// Count ENTITIES, not lines: updating a deferral appends a new same-key row, and
|
|
194
|
+
// `fold` collapses same-key rows to the current state. See .bkit/jsonl.md § Updating
|
|
195
|
+
// a Row.
|
|
196
|
+
const folded = fold(parsed.events);
|
|
197
|
+
result.countOnlyRows[filename] = folded.size;
|
|
198
|
+
result.countOnlyRawRows[filename] = parsed.events.length;
|
|
199
|
+
result.malformedLineCount += parsed.malformedLineCount;
|
|
200
|
+
console.error(
|
|
201
|
+
`[bkit-harvest] ${consumerPath}/docs/${filename} — count-only: ${folded.size} entities (${parsed.events.length} rows)`,
|
|
202
|
+
);
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
return result;
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
// ---------------------------------------------------------------------------
|
|
209
|
+
// Prune — remove durably-stored rows from a consumer ledger
|
|
210
|
+
// ---------------------------------------------------------------------------
|
|
211
|
+
|
|
212
|
+
/**
|
|
213
|
+
* Stamp `repo` on an event when the consumer wrote the row without one.
|
|
214
|
+
* MUST be applied on both the store side and the prune side, or the two contents
|
|
215
|
+
* diverge and a stored row is never recognised as prunable.
|
|
216
|
+
*/
|
|
217
|
+
export function stampRepo(event: TelemetryEvent, consumerSlug: string): TelemetryEvent {
|
|
218
|
+
return {
|
|
219
|
+
...event,
|
|
220
|
+
repo: event.repo && event.repo.length > 0 ? event.repo : consumerSlug,
|
|
221
|
+
};
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
/** What the store durably holds, read back off disk after fsync. */
|
|
225
|
+
export interface DurableStore {
|
|
226
|
+
/** Canonical JSON of every confirmed row. THE prune gate — content, not identity. */
|
|
227
|
+
rows: Set<string>;
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
export interface PruneResult {
|
|
231
|
+
removed: number;
|
|
232
|
+
/** Lines left in the consumer: malformed, or appended after the copy. */
|
|
233
|
+
kept: number;
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
/**
|
|
237
|
+
* Remove from `srcPath` exactly those rows whose CONTENT is durably in the store.
|
|
238
|
+
*
|
|
239
|
+
* Gated on byte-for-byte content, NOT on identity.
|
|
240
|
+
*
|
|
241
|
+
* Line-level, NOT event-level: a line that does not parse is kept verbatim.
|
|
242
|
+
*
|
|
243
|
+
* Re-reads the file at prune time, so rows appended by the consumer DURING the harvest
|
|
244
|
+
* survive.
|
|
245
|
+
*
|
|
246
|
+
* Writes via temp-file + rename; an interrupted prune never leaves a torn ledger.
|
|
247
|
+
*/
|
|
248
|
+
export function pruneConsumerFile(
|
|
249
|
+
srcPath: string,
|
|
250
|
+
consumerSlug: string,
|
|
251
|
+
durable: DurableStore,
|
|
252
|
+
): PruneResult {
|
|
253
|
+
const raw = fs.readFileSync(srcPath, "utf-8");
|
|
254
|
+
const kept: string[] = [];
|
|
255
|
+
let removed = 0;
|
|
256
|
+
|
|
257
|
+
for (const line of raw.split("\n")) {
|
|
258
|
+
if (line.trim() === "") continue;
|
|
259
|
+
let event: TelemetryEvent;
|
|
260
|
+
try {
|
|
261
|
+
event = JSON.parse(line.trim()) as TelemetryEvent;
|
|
262
|
+
} catch {
|
|
263
|
+
kept.push(line); // malformed — never ours to delete
|
|
264
|
+
continue;
|
|
265
|
+
}
|
|
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 `docs/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}/ — commit it 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
|
+
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
// commands/install/check.ts — `bkit check`: the parts only check runs. Check is install in
|
|
2
|
+
// dry-run mode (commands/install/install.ts runInstall); this file holds the installed-module
|
|
3
|
+
// detection that scopes its drift gate and the drift verdict.
|
|
4
|
+
|
|
5
|
+
import * as fs from "node:fs";
|
|
6
|
+
import * as path from "node:path";
|
|
7
|
+
import type { ModuleFlag } from "../../cli.js";
|
|
8
|
+
import type { PreflightFinding } from "../../checks/before/index.js";
|
|
9
|
+
import { type MissingOwnedHook, describeMissingOwnedHook } from "../../checks/after/managed.js";
|
|
10
|
+
import { LOG_PREFIX } from "../../shared/log-prefix.js";
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Installed-module set, detected by sentinel-file presence. Always core, plus the installed
|
|
14
|
+
* subset of {claude, cursor, opencode, codex}. Two callers:
|
|
15
|
+
* - `bkit check` — scopes the drift gate, so a `--cursor`-only repo does not
|
|
16
|
+
* report `.claude/**` as drift.
|
|
17
|
+
* - `bkit upgrade` — scopes the template walk, so upgrade does NOT force-create files for a
|
|
18
|
+
* module the consumer never installed.
|
|
19
|
+
*
|
|
20
|
+
* opencode IS gated: the render inputs fall back to the INSTALLED provider/tracker
|
|
21
|
+
* (renderOpencodeProvider + the package.json tracker resolution), so an openrouter/opencode/…
|
|
22
|
+
* consumer is checked against its own config, and the dry-run path is read-only (installFile /
|
|
23
|
+
* writeTier1 / reconcileOpencodeJson honour dryRun; ensureDir is dryRun-gated). The remaining
|
|
24
|
+
* opt-in (cloud) stays out of the gate.
|
|
25
|
+
* Dependency-updater files are not modules: bkit never drift-checks them.
|
|
26
|
+
*/
|
|
27
|
+
export function detectInstalledModules(cwd: string): Set<ModuleFlag> {
|
|
28
|
+
const mods = new Set<ModuleFlag>(["core"]);
|
|
29
|
+
if (fs.existsSync(path.join(cwd, ".claude", "agents"))) mods.add("claude");
|
|
30
|
+
if (fs.existsSync(path.join(cwd, ".cursor", "agents"))) mods.add("cursor");
|
|
31
|
+
if (fs.existsSync(path.join(cwd, ".opencode", "agents"))) mods.add("opencode");
|
|
32
|
+
if (fs.existsSync(path.join(cwd, ".codex", "agents"))) mods.add("codex");
|
|
33
|
+
return mods;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
// Check mode: exit-1 on drift (totalWrites > 0). runInstall emits the banner first.
|
|
37
|
+
// Host agent/command mirrors push would-writes into ws.writes (content drift OR
|
|
38
|
+
// orphan delete). A stale managed-version marker on any stamped file ALSO surfaces as
|
|
39
|
+
// the bkit-managed-stale Phase-3 blocker, which counts as drift here. A missing owned
|
|
40
|
+
// hook file (owned-hook-missing) fails check too, by name. Other Phase-3 blockers
|
|
41
|
+
// are install-only.
|
|
42
|
+
//
|
|
43
|
+
// Gate on `severity === "blocker"`, NOT mere id-presence: detectManagedStale is
|
|
44
|
+
// branch-scoped (downgraded to `advisory` off main/dev), so on a feature branch the
|
|
45
|
+
// finding still surfaces in the checklist but does not exit-1. On main/dev (or a PR
|
|
46
|
+
// into them) it stays a blocker and hard-fails.
|
|
47
|
+
export function reportCheckDrift(
|
|
48
|
+
postFindings: PreflightFinding[],
|
|
49
|
+
totalWrites: number,
|
|
50
|
+
missingHooks: MissingOwnedHook[],
|
|
51
|
+
): void {
|
|
52
|
+
const managedStale = postFindings.some(
|
|
53
|
+
(f) => f.id === "bkit-managed-stale" && f.severity === "blocker",
|
|
54
|
+
);
|
|
55
|
+
if (totalWrites > 0 || managedStale || missingHooks.length > 0) {
|
|
56
|
+
if (totalWrites > 0) {
|
|
57
|
+
console.error(`${LOG_PREFIX} check: ${totalWrites} write(s) would occur — DRIFT DETECTED`);
|
|
58
|
+
}
|
|
59
|
+
if (managedStale) {
|
|
60
|
+
console.error(
|
|
61
|
+
`${LOG_PREFIX} check: bkit-managed files are stale (managed-version marker drift) — ` +
|
|
62
|
+
`see the bkit-managed-stale blocker above. Run \`pnpm bkit upgrade\` (or re-run install) and commit.`,
|
|
63
|
+
);
|
|
64
|
+
}
|
|
65
|
+
for (const hook of missingHooks) {
|
|
66
|
+
console.error(`${LOG_PREFIX} check: ${describeMissingOwnedHook(hook)}`);
|
|
67
|
+
}
|
|
68
|
+
process.exit(1);
|
|
69
|
+
}
|
|
70
|
+
}
|