@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,531 @@
|
|
|
1
|
+
// install/modules/core.ts — the core module: the core payload blocks, the canonical
|
|
2
|
+
// `.bkit/*.md` docs, package.json gate scripts and `.bkit/version` (written last, in
|
|
3
|
+
// postDispatch). Also the file helpers every host renderer shares.
|
|
4
|
+
import * as fs from "node:fs";
|
|
5
|
+
import * as path from "node:path";
|
|
6
|
+
import { writeTier1, writeTier2, ensurePackageJsonScripts } from "../write.js";
|
|
7
|
+
import { readBkitVersion, writeBkitVersion, hashFile, mergeCanonicalHashes, } from "../version-file.js";
|
|
8
|
+
import { listFilesRecursive, syncTemplateCopies } from "../template-copies.js";
|
|
9
|
+
import { PAYLOAD_LINK_RELPATHS, syncPayloadLinks } from "../payload-links.js";
|
|
10
|
+
import { getPkgRoot, getCoreRoot, getSharedRoot, getBkitDocsRoot, TEMPLATE_COPIES_DIR, } from "../../shared/package-roots.js";
|
|
11
|
+
import { getInstallManifest, BKIT_GATE_SCRIPTS, BKIT_OPTIONAL_GATES } from "../manifest.js";
|
|
12
|
+
export function listMdFiles(dir, prefix) {
|
|
13
|
+
if (!fs.existsSync(dir))
|
|
14
|
+
return [];
|
|
15
|
+
return fs
|
|
16
|
+
.readdirSync(dir)
|
|
17
|
+
.filter((f) => f.endsWith(".md"))
|
|
18
|
+
.filter((f) => (prefix ? f.startsWith(prefix) : true));
|
|
19
|
+
}
|
|
20
|
+
export function installFile(srcPath, destPath, transform, dryRun) {
|
|
21
|
+
if (!transform) {
|
|
22
|
+
if (fs.existsSync(destPath)) {
|
|
23
|
+
const src = fs.readFileSync(srcPath);
|
|
24
|
+
const dest = fs.readFileSync(destPath);
|
|
25
|
+
if (src.equals(dest))
|
|
26
|
+
return false;
|
|
27
|
+
}
|
|
28
|
+
if (!dryRun)
|
|
29
|
+
fs.copyFileSync(srcPath, destPath);
|
|
30
|
+
return true;
|
|
31
|
+
}
|
|
32
|
+
const src = fs.readFileSync(srcPath, "utf-8");
|
|
33
|
+
const transformed = transform(src);
|
|
34
|
+
if (fs.existsSync(destPath)) {
|
|
35
|
+
const existing = fs.readFileSync(destPath, "utf-8");
|
|
36
|
+
if (existing === transformed)
|
|
37
|
+
return false;
|
|
38
|
+
}
|
|
39
|
+
if (!dryRun)
|
|
40
|
+
fs.writeFileSync(destPath, transformed, "utf-8");
|
|
41
|
+
return true;
|
|
42
|
+
}
|
|
43
|
+
// Hard allowlist: orphan pruning may ONLY remove files from these generated IDE
|
|
44
|
+
// mirror dirs. Mirror SOURCES live package-side under `.bkit/{workflows,prompts}`.
|
|
45
|
+
const ORPHAN_PRUNE_DIRS = [
|
|
46
|
+
".claude/agents",
|
|
47
|
+
".claude/commands",
|
|
48
|
+
".cursor/agents",
|
|
49
|
+
".cursor/commands",
|
|
50
|
+
];
|
|
51
|
+
export function removeOrphans(destDir, sourceFiles, dryRun, prefix) {
|
|
52
|
+
const resolved = path.resolve(destDir);
|
|
53
|
+
if (!ORPHAN_PRUNE_DIRS.some((d) => path.resolve(d) === resolved)) {
|
|
54
|
+
throw new Error(`removeOrphans: refusing orphan removal outside allowlist: ${destDir}`);
|
|
55
|
+
}
|
|
56
|
+
if (!fs.existsSync(destDir))
|
|
57
|
+
return [];
|
|
58
|
+
const removed = [];
|
|
59
|
+
for (const f of fs.readdirSync(destDir)) {
|
|
60
|
+
if (!f.endsWith(".md"))
|
|
61
|
+
continue;
|
|
62
|
+
if (prefix && !f.startsWith(prefix))
|
|
63
|
+
continue;
|
|
64
|
+
if (!sourceFiles.has(f)) {
|
|
65
|
+
if (!dryRun)
|
|
66
|
+
fs.rmSync(path.join(destDir, f));
|
|
67
|
+
removed.push(f);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
return removed;
|
|
71
|
+
}
|
|
72
|
+
/** The markered-text `.agents/*.md` blocks core owns. */
|
|
73
|
+
const CORE_AGENT_FILES = ["context.md", "docs.md", "rules.md", "skills.md"];
|
|
74
|
+
// The two shared-root files core writes: stored in `shared/`, owned by the core
|
|
75
|
+
// manifest, written as html-comment managed blocks.
|
|
76
|
+
const CORE_SHARED_FILES = [
|
|
77
|
+
["gitignore", ".gitignore"],
|
|
78
|
+
[".gitattributes", ".gitattributes"],
|
|
79
|
+
];
|
|
80
|
+
// ---------------------------------------------------------------------------
|
|
81
|
+
// guardCoreRoot — fail-loud guard for the resolved core payload root.
|
|
82
|
+
// Exported so tests can inject an arbitrary (non-existent) path and assert
|
|
83
|
+
// the guard fires for ANY missing root — not just the literal ".bkit/core"
|
|
84
|
+
// string. This keeps the assertion valid across any future path changes.
|
|
85
|
+
//
|
|
86
|
+
// Called by runCoreTemplates (below) before any FS access.
|
|
87
|
+
// ---------------------------------------------------------------------------
|
|
88
|
+
export function guardCoreRoot(root, logPrefix = "[bkit-modules]") {
|
|
89
|
+
if (!fs.existsSync(root)) {
|
|
90
|
+
console.error(`${logPrefix} Core root not found at ${root} — package corrupt?`);
|
|
91
|
+
process.exit(1);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* The core-owned payload files, sourced from `root` (defaults to the resolved
|
|
96
|
+
* core root). Every file under `core/docs/templates/` is included; `AGENTS.md`
|
|
97
|
+
* and the `.agents/*.md` doctrine files are the block-merged rest.
|
|
98
|
+
*/
|
|
99
|
+
export function listCoreTemplateFiles(root = getCoreRoot()) {
|
|
100
|
+
const out = [];
|
|
101
|
+
const agentsDir = path.join(root, ".agents");
|
|
102
|
+
for (const name of CORE_AGENT_FILES) {
|
|
103
|
+
const src = path.join(agentsDir, name);
|
|
104
|
+
if (fs.existsSync(src)) {
|
|
105
|
+
out.push({ src, dst: path.join(".agents", name), scope: "block", marker: "html-comment" });
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
const agentsMd = path.join(root, "AGENTS.md");
|
|
109
|
+
if (fs.existsSync(agentsMd)) {
|
|
110
|
+
out.push({ src: agentsMd, dst: "AGENTS.md", scope: "block", marker: "html-comment" });
|
|
111
|
+
}
|
|
112
|
+
for (const abs of listFilesRecursive(path.join(root, "docs", "templates"))) {
|
|
113
|
+
out.push({
|
|
114
|
+
src: abs,
|
|
115
|
+
dst: path.relative(root, abs),
|
|
116
|
+
scope: "block",
|
|
117
|
+
marker: "html-comment",
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
return out;
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* The shared payload files core writes, sourced from `root` (defaults to the
|
|
124
|
+
* resolved shared root): the `docs/*.md` managed blocks and the two shared-root
|
|
125
|
+
* files the core manifest owns.
|
|
126
|
+
*/
|
|
127
|
+
export function listSharedTemplateFiles(root = getSharedRoot()) {
|
|
128
|
+
const out = [];
|
|
129
|
+
for (const [rel, dst] of CORE_SHARED_FILES) {
|
|
130
|
+
const src = path.join(root, rel);
|
|
131
|
+
if (fs.existsSync(src))
|
|
132
|
+
out.push({ src, dst, scope: "block", marker: "html-comment" });
|
|
133
|
+
}
|
|
134
|
+
for (const name of listMdFiles(path.join(root, "docs"))) {
|
|
135
|
+
out.push({
|
|
136
|
+
src: path.join(root, "docs", name),
|
|
137
|
+
dst: path.join("docs", name),
|
|
138
|
+
scope: "block",
|
|
139
|
+
marker: "html-comment",
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
return out;
|
|
143
|
+
}
|
|
144
|
+
function runCoreTemplates(dryRun, tokens, ws, logPrefix) {
|
|
145
|
+
const root = getCoreRoot();
|
|
146
|
+
guardCoreRoot(root, logPrefix);
|
|
147
|
+
const tag = dryRun ? "[dry-run] " : "";
|
|
148
|
+
const files = [...listCoreTemplateFiles(root), ...listSharedTemplateFiles()];
|
|
149
|
+
for (const { src, dst, scope, marker } of files) {
|
|
150
|
+
const prevLen = ws.writes.length;
|
|
151
|
+
if (scope === "whole")
|
|
152
|
+
writeTier1(src, dst, tokens, dryRun, ws);
|
|
153
|
+
else
|
|
154
|
+
writeTier2(src, dst, tokens, marker, dryRun, ws);
|
|
155
|
+
if (ws.writes.length > prevLen) {
|
|
156
|
+
console.log(`${logPrefix} ${tag}core: ${dst}`);
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
// ---------------------------------------------------------------------------
|
|
161
|
+
// runCoreModule — core templates + .bkit/version (LAST)
|
|
162
|
+
// ---------------------------------------------------------------------------
|
|
163
|
+
// Canonical bkit-authored reference docs that live package-side under
|
|
164
|
+
// `.bkit/core/.bkit/`. They are read from there at runtime (getBkitDocsRoot) AND
|
|
165
|
+
// mirrored into the consumer's `.bkit/` on every install so a consumer can read them
|
|
166
|
+
// in-repo without spelunking node_modules. Force-overwritten (Tier 1) — bkit owns
|
|
167
|
+
// them, so a consumer edit is replaced. Source of truth is the package's own
|
|
168
|
+
// `.bkit/core/.bkit/<name>`. (`advisories.md` is a regenerated runtime artifact,
|
|
169
|
+
// `wording.md` is repo-only tooling and `friction.md` is a consumer-owned seed —
|
|
170
|
+
// none belongs here. `LICENSE.md` is the PolyForm notice that travels with every
|
|
171
|
+
// file bkit writes: PolyForm's Notices section requires a passed-on copy to carry
|
|
172
|
+
// the terms or their URL and the Required Notice line.)
|
|
173
|
+
export const BKIT_CANONICAL_DOCS = [
|
|
174
|
+
"cloud.md",
|
|
175
|
+
"comparison.md",
|
|
176
|
+
"install.md",
|
|
177
|
+
"jsonl.md",
|
|
178
|
+
"LICENSE.md",
|
|
179
|
+
"providers.md",
|
|
180
|
+
"prompts.md",
|
|
181
|
+
"templates.md",
|
|
182
|
+
"trackers.md",
|
|
183
|
+
"workflows.md",
|
|
184
|
+
"README.md",
|
|
185
|
+
];
|
|
186
|
+
// Mirror the package's canonical `.bkit/*.md` docs into the consumer's `.bkit/`.
|
|
187
|
+
// Tier 1 (force-overwrite + ws-tracked for dry-run/install parity). Each source carries
|
|
188
|
+
// the `{{BKIT_MANAGED_MARKER}}` token. Skipped in dogfood: the consumer destination
|
|
189
|
+
// resolves to the repo's own installed copies, never the package source.
|
|
190
|
+
export function runBkitDocs(dryRun, tokens, ws, logPrefix) {
|
|
191
|
+
const tag = dryRun ? "[dry-run] " : "";
|
|
192
|
+
const docsRoot = getBkitDocsRoot();
|
|
193
|
+
// Per-doc write strategy from the manifest: markered-text docs (e.g. prompts.md,
|
|
194
|
+
// which carries the consumer-owned `## Model Overrides` section below `bkit:end`)
|
|
195
|
+
// are block-merged so consumer content survives; the rest are force-overwritten.
|
|
196
|
+
const formatByPath = new Map(getInstallManifest().map((e) => [e.path, e.format]));
|
|
197
|
+
for (const name of BKIT_CANONICAL_DOCS) {
|
|
198
|
+
const srcPath = path.join(docsRoot, name);
|
|
199
|
+
// A doc missing from a partial/corrupt package is skipped (writeTier1 throws on a
|
|
200
|
+
// missing src).
|
|
201
|
+
if (!fs.existsSync(srcPath))
|
|
202
|
+
continue;
|
|
203
|
+
const dstPath = path.join(".bkit", name);
|
|
204
|
+
const prevLen = ws.writes.length;
|
|
205
|
+
if (formatByPath.get(path.join(".bkit", name)) === "markered-text") {
|
|
206
|
+
writeTier2(srcPath, dstPath, tokens, "html-comment", dryRun, ws);
|
|
207
|
+
}
|
|
208
|
+
else {
|
|
209
|
+
writeTier1(srcPath, dstPath, tokens, dryRun, ws);
|
|
210
|
+
}
|
|
211
|
+
if (ws.writes.length > prevLen) {
|
|
212
|
+
console.log(`${logPrefix} ${tag}core: ${dstPath}`);
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
// ---------------------------------------------------------------------------
|
|
217
|
+
// Source-rendered host outputs — agents (.agents/prompts source) and commands
|
|
218
|
+
// (.bkit/workflows source). Extracted from the host module functions so BOTH
|
|
219
|
+
// `bkit install` (via the modules) AND `bkit upgrade` (via renderManagedOutputs)
|
|
220
|
+
// render them identically — a single source of truth that can never diverge.
|
|
221
|
+
//
|
|
222
|
+
// These are bkit-OWNED output files: force-overwritten (installFile), never
|
|
223
|
+
// drift-detected, never consumer config. They are NOT recorded in canonicalHashes
|
|
224
|
+
// (installFile does not touch ws), matching the install path exactly. Each returns
|
|
225
|
+
// the consumer-relative dest paths it wrote (for the upgrade summary).
|
|
226
|
+
// ---------------------------------------------------------------------------
|
|
227
|
+
// ---------------------------------------------------------------------------
|
|
228
|
+
// Managed-version stamping. The marker shape (stampManagedVersion + regexes) lives
|
|
229
|
+
// in install/version-file.ts, shared by the renderer and the `bkit check` detector. Here we
|
|
230
|
+
// only resolve WHICH version to stamp: ctx.version (set by install/upgrade) with a
|
|
231
|
+
// package-root fallback.
|
|
232
|
+
// ---------------------------------------------------------------------------
|
|
233
|
+
/**
|
|
234
|
+
* Best-effort read of the installing bkit version from the package root's
|
|
235
|
+
* package.json. Mirrors getInstallingVersion in commands/install/install.ts; duplicated here
|
|
236
|
+
* (not imported) to avoid a modules → install dependency cycle. Returns "0.0.0"
|
|
237
|
+
* when unreadable — the same non-fatal fallback the install side uses.
|
|
238
|
+
*/
|
|
239
|
+
export function readInstallingVersion() {
|
|
240
|
+
try {
|
|
241
|
+
const pkgPath = path.join(getPkgRoot(), "package.json");
|
|
242
|
+
const pkg = JSON.parse(fs.readFileSync(pkgPath, "utf-8"));
|
|
243
|
+
return pkg.version ?? "0.0.0";
|
|
244
|
+
}
|
|
245
|
+
catch {
|
|
246
|
+
return "0.0.0";
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
/** Record a host mirror would-write so `bkit check` exits 1 on content drift. */
|
|
250
|
+
export function trackMirrorWrite(ctx, relPath, written) {
|
|
251
|
+
written.push(relPath);
|
|
252
|
+
ctx.ws.writes.push({ path: relPath, action: "write" });
|
|
253
|
+
}
|
|
254
|
+
/**
|
|
255
|
+
* The package.json scripts core keeps: the `bkit:gate:*` / `bkit:deps:*` names every
|
|
256
|
+
* workflow, prompt and hook runs, seeded add-if-missing (a name already declared is
|
|
257
|
+
* never touched, whatever its value). Install (runCoreModule) and upgrade
|
|
258
|
+
* (renderManagedOutputs) both run it, so a
|
|
259
|
+
* clean upgrade leaves `bkit check` nothing to write. A missing gate name is a write,
|
|
260
|
+
* so `bkit check` reports it. A missing or malformed package.json is preflight's to
|
|
261
|
+
* report. Returns the paths written.
|
|
262
|
+
*/
|
|
263
|
+
export function seedCorePackageJsonScripts(ctx) {
|
|
264
|
+
const { dryRun, ws, logPrefix } = ctx;
|
|
265
|
+
const tag = dryRun ? "[dry-run] " : "";
|
|
266
|
+
const written = [];
|
|
267
|
+
const gates = ensurePackageJsonScripts({ ...BKIT_GATE_SCRIPTS }, dryRun, ws);
|
|
268
|
+
if (gates.added.length > 0) {
|
|
269
|
+
written.push("package.json");
|
|
270
|
+
console.log(`${logPrefix} ${tag}core: package.json scripts added [${gates.added.join(", ")}]`);
|
|
271
|
+
}
|
|
272
|
+
return written;
|
|
273
|
+
}
|
|
274
|
+
// Tokens that follow `pnpm` in a gate value but are not package.json scripts: the
|
|
275
|
+
// package manager's own subcommands (`install` in bkit:gate:install-static-unit-build,
|
|
276
|
+
// `audit` / `outdated` in the bkit:deps:* pair) and node_modules binaries pnpm resolves
|
|
277
|
+
// directly (`lint-staged` in bkit:gate:format). None can be "missing" as a script.
|
|
278
|
+
const PNPM_NOT_A_SCRIPT = new Set([
|
|
279
|
+
"install",
|
|
280
|
+
"run",
|
|
281
|
+
"exec",
|
|
282
|
+
"dlx",
|
|
283
|
+
"audit",
|
|
284
|
+
"outdated",
|
|
285
|
+
"lint-staged",
|
|
286
|
+
]);
|
|
287
|
+
/**
|
|
288
|
+
* Advisories for the `bkit:gate:*` scripts: the scripts a still-default gate
|
|
289
|
+
* chains that package.json does not declare, and the deeper test tiers the repo has
|
|
290
|
+
* but no gate runs. Read-only; an absent or unparseable package.json yields none.
|
|
291
|
+
*/
|
|
292
|
+
export function detectGateAdvisories(cwd) {
|
|
293
|
+
let declared;
|
|
294
|
+
try {
|
|
295
|
+
const pkg = JSON.parse(fs.readFileSync(path.join(cwd, "package.json"), "utf-8"));
|
|
296
|
+
declared = pkg.scripts ?? {};
|
|
297
|
+
}
|
|
298
|
+
catch {
|
|
299
|
+
// Absent or malformed package.json — preflight's no-package-json /
|
|
300
|
+
// malformed-package-json blockers already report it.
|
|
301
|
+
return [];
|
|
302
|
+
}
|
|
303
|
+
const findings = [];
|
|
304
|
+
// Every script a seeded gate default chains MUST exist, or the gate dies on the first
|
|
305
|
+
// missing one and the workflow reads that as a real failure. Checked only where the
|
|
306
|
+
// value is still bkit's default — a consumer who rewrote the gate owns what it calls.
|
|
307
|
+
const missing = new Set();
|
|
308
|
+
for (const [name, seeded] of Object.entries(BKIT_GATE_SCRIPTS)) {
|
|
309
|
+
if (declared[name] !== seeded)
|
|
310
|
+
continue;
|
|
311
|
+
for (const [, called] of seeded.matchAll(/\bpnpm ([\w:-]+)/g)) {
|
|
312
|
+
if (PNPM_NOT_A_SCRIPT.has(called))
|
|
313
|
+
continue;
|
|
314
|
+
if (!(called in declared) && !(called in BKIT_GATE_SCRIPTS))
|
|
315
|
+
missing.add(called);
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
if (missing.size > 0) {
|
|
319
|
+
const names = [...missing].sort().map((n) => `\`${n}\``);
|
|
320
|
+
findings.push({
|
|
321
|
+
id: "gate-missing-called-scripts",
|
|
322
|
+
severity: "advisory",
|
|
323
|
+
detect: `The bkit:gate scripts call scripts package.json does not declare: ${names.join(", ")}.`,
|
|
324
|
+
action: `Every bkit workflow runs a \`bkit:gate*\` script, so a missing link fails the whole gate. Add ${names.join(", ")} to package.json (\`.bkit/templates.md\` lists the tool scripts and the devDeps they need), or edit the \`bkit:gate*\` scripts to drop what this repo does not have.`,
|
|
325
|
+
});
|
|
326
|
+
}
|
|
327
|
+
// A repo that HAS a deeper tier but declares no gate for it is gated at
|
|
328
|
+
// bkit:gate:static-unit by both /bkit-build and /bkit-debug. bkit does not seed these
|
|
329
|
+
// gates; it detects the mismatch and hands over the line to paste.
|
|
330
|
+
const unwired = [];
|
|
331
|
+
for (const { gate, parent, declaredBy } of BKIT_OPTIONAL_GATES) {
|
|
332
|
+
const tierCall = declaredBy.find((s) => s in declared);
|
|
333
|
+
if (tierCall === undefined || gate in declared)
|
|
334
|
+
continue;
|
|
335
|
+
unwired.push(` "${gate}": "pnpm ${parent} && pnpm ${tierCall}"`);
|
|
336
|
+
}
|
|
337
|
+
if (unwired.length > 0) {
|
|
338
|
+
findings.push({
|
|
339
|
+
id: "gate-tier-not-wired",
|
|
340
|
+
severity: "advisory",
|
|
341
|
+
detect: "package.json declares deeper test tiers than any `bkit:gate*` script runs, so `/bkit-build` and `/bkit-debug` gate at `bkit:gate:static-unit` and never execute them.",
|
|
342
|
+
action: "Each workflow runs the DEEPEST gate you declare; an undeclared one is skipped, never guessed. Add the gates you want the agent loop to run:\n\n" +
|
|
343
|
+
unwired.join("\n") +
|
|
344
|
+
"\n\nOrder matters — each chains the one above it. Omit a level deliberately to keep it CI-only (E2E in the build loop costs a production build on every remediation attempt). `.bkit/templates.md` lists the tool scripts the gates chain.",
|
|
345
|
+
});
|
|
346
|
+
}
|
|
347
|
+
return findings;
|
|
348
|
+
}
|
|
349
|
+
/** One command that cannot fail: `true`, `:`, `exit 0`, or an `echo`. */
|
|
350
|
+
const NOOP_COMMAND = /^(?:true|:|exit 0|echo(?:\s.*)?)$/;
|
|
351
|
+
/** Whether a script value checks nothing: empty, or only no-op commands chained. */
|
|
352
|
+
export function isNoopScript(value) {
|
|
353
|
+
return value
|
|
354
|
+
.split(/&&|\|\||;|\n/)
|
|
355
|
+
.map((part) => part.trim())
|
|
356
|
+
.every((part) => part === "" || NOOP_COMMAND.test(part));
|
|
357
|
+
}
|
|
358
|
+
/**
|
|
359
|
+
* Advisory for every `bkit:gate:*` script that is empty or a no-op: it checks nothing,
|
|
360
|
+
* so every agent run and push passes it. Warn-only, at install and `bkit check`, on
|
|
361
|
+
* every branch. Read-only; an absent or unparseable package.json yields none.
|
|
362
|
+
*/
|
|
363
|
+
export function detectNoopGates(cwd) {
|
|
364
|
+
let declared;
|
|
365
|
+
try {
|
|
366
|
+
const pkg = JSON.parse(fs.readFileSync(path.join(cwd, "package.json"), "utf-8"));
|
|
367
|
+
declared = pkg.scripts ?? {};
|
|
368
|
+
}
|
|
369
|
+
catch {
|
|
370
|
+
// Absent or malformed package.json — preflight's blockers already report it.
|
|
371
|
+
return [];
|
|
372
|
+
}
|
|
373
|
+
const noop = Object.entries(declared)
|
|
374
|
+
.filter(([name, value]) => name.startsWith("bkit:gate:") && typeof value === "string")
|
|
375
|
+
.filter(([, value]) => isNoopScript(value))
|
|
376
|
+
.map(([name, value]) => `\`${name}\` (\`${String(value).trim() || "empty"}\`)`)
|
|
377
|
+
.sort();
|
|
378
|
+
if (noop.length === 0)
|
|
379
|
+
return [];
|
|
380
|
+
return [
|
|
381
|
+
{
|
|
382
|
+
id: "gate-noop",
|
|
383
|
+
severity: "advisory",
|
|
384
|
+
detect: `These bkit:gate scripts are empty or cannot fail, so they check nothing: ${noop.join(", ")}.`,
|
|
385
|
+
action: 'Every bkit workflow and the pre-push hook trust a green `bkit:gate*` script, so a no-op gate passes every agent run and push. Point each at the checks it should run (e.g. `"bkit:gate:static": "pnpm typecheck && pnpm lint"`), or delete it from package.json and run `bkit upgrade` to get bkit\'s default back.',
|
|
386
|
+
},
|
|
387
|
+
];
|
|
388
|
+
}
|
|
389
|
+
export function runCoreModule(ctx) {
|
|
390
|
+
const { dryRun, ws, advisories, logPrefix, postDispatch } = ctx;
|
|
391
|
+
const tag = dryRun ? "[dry-run] " : "";
|
|
392
|
+
const cwd = process.cwd();
|
|
393
|
+
const PKG_ROOT = getPkgRoot();
|
|
394
|
+
const PKG_PACKAGE_JSON = path.join(PKG_ROOT, "package.json");
|
|
395
|
+
if (!fs.existsSync(PKG_PACKAGE_JSON)) {
|
|
396
|
+
console.error(`${logPrefix} package.json not found at ${PKG_PACKAGE_JSON} — package corrupt?`);
|
|
397
|
+
process.exit(1);
|
|
398
|
+
}
|
|
399
|
+
const pkgVersion = JSON.parse(fs.readFileSync(PKG_PACKAGE_JSON, "utf-8")).version;
|
|
400
|
+
// Capture first-install signal NOW (before any writes) — used for the post-install banner.
|
|
401
|
+
// The .bkit/version write happens in postDispatch, so a mid-install crash in a later
|
|
402
|
+
// module leaves no .bkit/version on disk.
|
|
403
|
+
const versionFile = path.join(cwd, ".bkit", "version");
|
|
404
|
+
const isFirstInstall = !fs.existsSync(versionFile);
|
|
405
|
+
// 2. Core payload pass (AGENTS.md, `.agents/*.md`, `docs/templates/**`, the two
|
|
406
|
+
// shared-root files core owns). Each host module writes its own hook files.
|
|
407
|
+
console.log(`${logPrefix} ${tag}Running core payload pass`);
|
|
408
|
+
runCoreTemplates(dryRun, ctx.tokens, ws, logPrefix);
|
|
409
|
+
// 3b. bkit canonical docs pass — mirror the package's reference docs
|
|
410
|
+
// (cloud/IDEs/prompts/trackers/workflows/README/install/comparison) into the
|
|
411
|
+
// consumer's `.bkit/` so they are readable in-repo. Force-overwrite (Tier 1).
|
|
412
|
+
console.log(`${logPrefix} ${tag}Running bkit docs pass`);
|
|
413
|
+
runBkitDocs(dryRun, ctx.tokens, ws, logPrefix);
|
|
414
|
+
// 3b2. Template copies — the whole templates root into the consumer's
|
|
415
|
+
// `.bkit/templates/` (never applied to the repo; no-op in dogfood).
|
|
416
|
+
console.log(`${logPrefix} ${tag}Running template copies pass`);
|
|
417
|
+
const templateChanges = syncTemplateCopies(cwd, { dryRun, ws });
|
|
418
|
+
for (const [verb, paths] of Object.entries(templateChanges)) {
|
|
419
|
+
for (const p of paths) {
|
|
420
|
+
console.log(`${logPrefix} ${tag}template ${verb}: ${path.join(TEMPLATE_COPIES_DIR, p)}`);
|
|
421
|
+
}
|
|
422
|
+
}
|
|
423
|
+
// 3b3. Payload view links — `.bkit/core` + `.bkit/shared` symlinks into the
|
|
424
|
+
// installed package (browse-only, gitignored; no-op in dogfood). A real
|
|
425
|
+
// directory or file at either path is never clobbered (advisory); a platform
|
|
426
|
+
// refusal is an advisory, never a failure.
|
|
427
|
+
const linkChanges = syncPayloadLinks(cwd, { dryRun, ws });
|
|
428
|
+
for (const rel of linkChanges.created) {
|
|
429
|
+
console.log(`${logPrefix} ${tag}payload link: ${rel}`);
|
|
430
|
+
}
|
|
431
|
+
for (const rel of linkChanges.repaired) {
|
|
432
|
+
console.log(`${logPrefix} ${tag}payload link repaired: ${rel}`);
|
|
433
|
+
}
|
|
434
|
+
for (const rel of linkChanges.skippedRealDir) {
|
|
435
|
+
advisories.push({
|
|
436
|
+
id: "payload-link-real-dir",
|
|
437
|
+
severity: "advisory",
|
|
438
|
+
detect: `${rel} is a real directory or file, not a view symlink into the installed package — left untouched.`,
|
|
439
|
+
action: `bkit never overwrites consumer content. The ${rel} view is a symlink into node_modules/@cbartens/bkit; if you want it, remove your own ${rel} by hand and re-run \`bkit install\`.`,
|
|
440
|
+
});
|
|
441
|
+
}
|
|
442
|
+
for (const rel of linkChanges.failed) {
|
|
443
|
+
advisories.push({
|
|
444
|
+
id: "payload-link-failed",
|
|
445
|
+
severity: "advisory",
|
|
446
|
+
detect: `could not create the ${rel} view symlink into the installed package (the platform refused).`,
|
|
447
|
+
action: `Browse-only — bkit reads its payload from the package regardless. To add the view by hand on POSIX: ln -s ../node_modules/@cbartens/bkit/${rel} ${rel}`,
|
|
448
|
+
});
|
|
449
|
+
}
|
|
450
|
+
// 3c. The bkit:gate:* / bkit:deps:* package.json scripts (add-if-missing). The
|
|
451
|
+
// advisories read the result.
|
|
452
|
+
seedCorePackageJsonScripts(ctx);
|
|
453
|
+
if (!dryRun)
|
|
454
|
+
advisories.push(...detectGateAdvisories(cwd));
|
|
455
|
+
advisories.push(...detectNoopGates(cwd));
|
|
456
|
+
// 4. .bkit/version write — deferred to postDispatch so it only persists when ALL modules succeed.
|
|
457
|
+
// This ensures a mid-install crash in a subsequent module does not suppress the first-install
|
|
458
|
+
// banner on retry (MED-4).
|
|
459
|
+
// C3 fix: write JSON format with canonicalHashes populated from ws.writes (fully populated
|
|
460
|
+
// by the time postDispatch runs — all modules have completed). canonicalHashes records the
|
|
461
|
+
// sha256 of each bkit-managed consumer file as written, enabling drift detection on upgrade.
|
|
462
|
+
postDispatch.push(() => {
|
|
463
|
+
// Read existing file to check whether an update is needed.
|
|
464
|
+
const existingVersion = readBkitVersion(versionFile);
|
|
465
|
+
const existingCanonical = existingVersion?.canonicalHashes ?? {};
|
|
466
|
+
// Build new canonicalHashes entries from ws.writes (files written in this run).
|
|
467
|
+
// ws.writes is fully populated by the time postDispatch runs.
|
|
468
|
+
// Exclude .bkit/version itself and .agents/ internal files (not consumer-facing).
|
|
469
|
+
const newCanonicalEntries = {};
|
|
470
|
+
for (const entry of ws.writes) {
|
|
471
|
+
const absPath = path.isAbsolute(entry.path) ? entry.path : path.resolve(cwd, entry.path);
|
|
472
|
+
const relPath = path.relative(cwd, absPath);
|
|
473
|
+
if (relPath === path.join(".bkit", "version"))
|
|
474
|
+
continue;
|
|
475
|
+
if (relPath.startsWith(".agents" + path.sep))
|
|
476
|
+
continue;
|
|
477
|
+
// Template copies carry no hash.
|
|
478
|
+
if (relPath.startsWith(TEMPLATE_COPIES_DIR + path.sep))
|
|
479
|
+
continue;
|
|
480
|
+
// Payload view links carry no hash either — a symlink's bytes are the package's.
|
|
481
|
+
if (PAYLOAD_LINK_RELPATHS.has(relPath))
|
|
482
|
+
continue;
|
|
483
|
+
if (!fs.existsSync(absPath))
|
|
484
|
+
continue;
|
|
485
|
+
const hash = hashFile(absPath);
|
|
486
|
+
if (hash)
|
|
487
|
+
newCanonicalEntries[relPath] = hash;
|
|
488
|
+
}
|
|
489
|
+
// Merge: existing hashes preserved, new writes overwrite (hashes stay current),
|
|
490
|
+
// and entries whose path is gone are pruned (mergeCanonicalHashes).
|
|
491
|
+
const { canonicalHashes, pruned } = mergeCanonicalHashes(cwd, existingCanonical, newCanonicalEntries);
|
|
492
|
+
// Decide whether a write is needed: version mismatch, first install, new canonical
|
|
493
|
+
// entries, a pruned stale entry, or a changed claudeAllowDerived record.
|
|
494
|
+
const versionChanged = !existingVersion || existingVersion.pinnedVersion !== pkgVersion;
|
|
495
|
+
const hasNewEntries = Object.keys(newCanonicalEntries).length > 0;
|
|
496
|
+
const claudeAllowDerived = ctx.claudeAllowRecorded ?? existingVersion?.claudeAllowDerived ?? [];
|
|
497
|
+
const derivedChanged = JSON.stringify(claudeAllowDerived) !==
|
|
498
|
+
JSON.stringify(existingVersion?.claudeAllowDerived ?? []);
|
|
499
|
+
const needsWrite = versionChanged || hasNewEntries || pruned > 0 || derivedChanged;
|
|
500
|
+
if (needsWrite) {
|
|
501
|
+
console.log(`${logPrefix} ${tag}write version pin: ${path.relative(cwd, versionFile)} (${pkgVersion})`);
|
|
502
|
+
ws.writes.push({ path: versionFile, action: "write" });
|
|
503
|
+
if (!dryRun) {
|
|
504
|
+
writeBkitVersion(versionFile, {
|
|
505
|
+
pinnedVersion: pkgVersion,
|
|
506
|
+
canonicalHashes,
|
|
507
|
+
claudeAllowDerived: [...claudeAllowDerived],
|
|
508
|
+
});
|
|
509
|
+
}
|
|
510
|
+
}
|
|
511
|
+
});
|
|
512
|
+
// 5. First-run extra logging (only when .bkit/version was absent at start of install)
|
|
513
|
+
if (isFirstInstall) {
|
|
514
|
+
advisories.push({
|
|
515
|
+
id: "first-install-postinstall-steps",
|
|
516
|
+
severity: "advisory",
|
|
517
|
+
detect: "First install detected (.bkit/version was absent).",
|
|
518
|
+
action: "Post-install steps:\n\n" +
|
|
519
|
+
"1. Run `pnpm install` to refresh the lockfile, then commit.\n\n" +
|
|
520
|
+
"2. See `.bkit/install.md` for consumer setup and `.bkit/README.md` for ongoing ops.\n\n" +
|
|
521
|
+
"Note: bkit seeded the bkit:gate:* / bkit:deps:* package.json scripts every workflow\n" +
|
|
522
|
+
"runs (existing values are never touched). The tool scripts they chain (typecheck,\n" +
|
|
523
|
+
"lint, format:check, lint:prose, slop:delta) and the devDeps those need are yours to\n" +
|
|
524
|
+
"add: see .bkit/templates.md.",
|
|
525
|
+
});
|
|
526
|
+
}
|
|
527
|
+
}
|
|
528
|
+
// ---------------------------------------------------------------------------
|
|
529
|
+
// runClaudeModule — byte-identical mirror from .agents/ → .claude/
|
|
530
|
+
// ---------------------------------------------------------------------------
|
|
531
|
+
export const BKIT_PREFIX = "bkit-";
|