@cbartens/bkit 0.0.0-stage → 5.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.bkit/README.md +421 -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 +421 -0
- package/.bkit/core/.bkit/cloud.md +502 -0
- package/.bkit/core/.bkit/comparison.md +318 -0
- package/.bkit/core/.bkit/install.md +496 -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 +471 -0
- package/.bkit/core/.bkit/trackers.md +95 -0
- package/.bkit/core/.bkit/workflows.md +1546 -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 +247 -0
- package/.bkit/core/engine/checks/after/ci-yml.ts +739 -0
- package/.bkit/core/engine/checks/after/github.ts +424 -0
- package/.bkit/core/engine/checks/after/index.ts +556 -0
- package/.bkit/core/engine/checks/after/managed.ts +217 -0
- package/.bkit/core/engine/checks/after/tools.ts +427 -0
- package/.bkit/core/engine/checks/after/vercel.ts +101 -0
- package/.bkit/core/engine/checks/before/context-fetch.ts +429 -0
- package/.bkit/core/engine/checks/before/env.ts +201 -0
- package/.bkit/core/engine/checks/before/files.ts +202 -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 +871 -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 +247 -0
- package/.bkit/core/engine/commands/install/install.ts +528 -0
- package/.bkit/core/engine/commands/install/uninstall.ts +972 -0
- package/.bkit/core/engine/commands/install/upgrade.ts +1026 -0
- package/.bkit/core/engine/commands/launch.ts +139 -0
- package/.bkit/core/engine/commands/lib.ts +494 -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 +925 -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 +174 -0
- package/.bkit/core/engine/install/modules/codex.ts +219 -0
- package/.bkit/core/engine/install/modules/core.ts +600 -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/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 +642 -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 +108 -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 +438 -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 +92 -0
- package/.bkit/templates/.claude/hooks/bkit-cloud-bootstrap.sh +192 -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 +239 -0
- package/.bkit/templates/.github/workflows/bkit-ci.yml +1082 -0
- package/.bkit/templates/.github/workflows/bkit-cloud.yml +566 -0
- package/.bkit/templates/.github/workflows/bkit-renovate.yml +107 -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 +1486 -0
- package/LICENSE.md +161 -0
- package/README.md +185 -2
- package/dist/checks/after/auth.js +232 -0
- package/dist/checks/after/ci-yml.js +718 -0
- package/dist/checks/after/github.js +400 -0
- package/dist/checks/after/index.js +447 -0
- package/dist/checks/after/managed.js +187 -0
- package/dist/checks/after/tools.js +351 -0
- package/dist/checks/after/vercel.js +102 -0
- package/dist/checks/before/context-fetch.js +426 -0
- package/dist/checks/before/env.js +173 -0
- package/dist/checks/before/files.js +185 -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 +692 -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 +207 -0
- package/dist/commands/install/install.js +461 -0
- package/dist/commands/install/uninstall.js +815 -0
- package/dist/commands/install/upgrade.js +771 -0
- package/dist/commands/launch.js +118 -0
- package/dist/commands/lib.js +362 -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 +819 -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 +152 -0
- package/dist/install/modules/codex.js +193 -0
- package/dist/install/modules/core.js +511 -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/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,362 @@
|
|
|
1
|
+
// install/modules/claude.ts — the claude host module: `.claude/` agents and commands, settings
|
|
2
|
+
// allows, and the tracker entry in the MCP config files (`.mcp.json`, `.cursor/mcp.json`).
|
|
3
|
+
|
|
4
|
+
import * as fs from "node:fs";
|
|
5
|
+
import * as path from "node:path";
|
|
6
|
+
import {
|
|
7
|
+
writeTier1,
|
|
8
|
+
writeTier2,
|
|
9
|
+
writeTier2JsonContained,
|
|
10
|
+
ensureDir,
|
|
11
|
+
type WriteSet,
|
|
12
|
+
type JsonValue,
|
|
13
|
+
} from "../write.js";
|
|
14
|
+
import { readBkitVersion, stampManagedVersion } from "../version-file.js";
|
|
15
|
+
import { applyEffortRemap } from "../../render/hosts.js";
|
|
16
|
+
import type { PreflightFinding } from "../../checks/before/index.js";
|
|
17
|
+
import {
|
|
18
|
+
getCoreRoot,
|
|
19
|
+
getSharedRoot,
|
|
20
|
+
getWorkflowsRoot,
|
|
21
|
+
getPromptsRoot,
|
|
22
|
+
} from "../../shared/package-roots.js";
|
|
23
|
+
import { type IssueTracker, DEFAULT_ISSUE_TRACKER } from "../manifest.js";
|
|
24
|
+
import { substituteWorkflow } from "../../render/trackers.js";
|
|
25
|
+
import { writeClaudeCloudDoc, resolveClaudeDerivedAllows } from "../cloud-env.js";
|
|
26
|
+
import type { ModuleContext } from "./index.js";
|
|
27
|
+
import {
|
|
28
|
+
BKIT_PREFIX,
|
|
29
|
+
installFile,
|
|
30
|
+
listMdFiles,
|
|
31
|
+
readInstallingVersion,
|
|
32
|
+
removeOrphans,
|
|
33
|
+
trackMirrorWrite,
|
|
34
|
+
} from "./core.js";
|
|
35
|
+
|
|
36
|
+
export function renderClaudeAgentsCommands(ctx: ModuleContext): string[] {
|
|
37
|
+
const { dryRun, logPrefix, effortMap } = ctx;
|
|
38
|
+
const tag = dryRun ? "[dry-run] " : "";
|
|
39
|
+
const issueTracker = ctx.issueTracker ?? DEFAULT_ISSUE_TRACKER;
|
|
40
|
+
const version = ctx.version ?? readInstallingVersion();
|
|
41
|
+
const written: string[] = [];
|
|
42
|
+
|
|
43
|
+
const pairs: Array<[string, string]> = [
|
|
44
|
+
[getWorkflowsRoot(), ".claude/commands"],
|
|
45
|
+
[getPromptsRoot(), ".claude/agents"],
|
|
46
|
+
];
|
|
47
|
+
|
|
48
|
+
for (const [src, dest] of pairs) {
|
|
49
|
+
ensureDir(dest);
|
|
50
|
+
const files = listMdFiles(src, BKIT_PREFIX);
|
|
51
|
+
const sourceSet = new Set(files);
|
|
52
|
+
|
|
53
|
+
for (const f of files) {
|
|
54
|
+
// Resolve tracker blocks for both; agents also remap effort via prompts.md
|
|
55
|
+
// Claude column. Managed-version marker stamped LAST.
|
|
56
|
+
const transform = (c: string) => {
|
|
57
|
+
const resolved = substituteWorkflow(c, issueTracker).output;
|
|
58
|
+
const body =
|
|
59
|
+
dest === ".claude/commands" ? resolved : applyEffortRemap(resolved, effortMap, "claude");
|
|
60
|
+
return stampManagedVersion(body, version);
|
|
61
|
+
};
|
|
62
|
+
if (installFile(path.join(src, f), path.join(dest, f), transform, dryRun)) {
|
|
63
|
+
const rel = path.join(dest, f);
|
|
64
|
+
console.log(`${logPrefix} ${tag}write: ${rel}`);
|
|
65
|
+
trackMirrorWrite(ctx, rel, written);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
for (const f of removeOrphans(dest, sourceSet, dryRun, BKIT_PREFIX)) {
|
|
70
|
+
const rel = path.join(dest, f);
|
|
71
|
+
console.log(`${logPrefix} ${tag}delete orphan: ${rel}`);
|
|
72
|
+
trackMirrorWrite(ctx, rel, written);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
return written;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export function runClaudeModule(ctx: ModuleContext): void {
|
|
79
|
+
const { dryRun, tokens, advisories, ws, logPrefix } = ctx;
|
|
80
|
+
const tag = dryRun ? "[dry-run] " : "";
|
|
81
|
+
|
|
82
|
+
const issueTracker = ctx.issueTracker ?? DEFAULT_ISSUE_TRACKER;
|
|
83
|
+
|
|
84
|
+
// Source-rendered agents/commands (.claude/agents from .bkit/prompts, .claude/commands
|
|
85
|
+
// from .bkit/workflows). Shared with `bkit upgrade` via renderClaudeAgentsCommands so it
|
|
86
|
+
// re-renders them identically — bkit-owned output, force-overwritten.
|
|
87
|
+
renderClaudeAgentsCommands(ctx);
|
|
88
|
+
|
|
89
|
+
// Root CLAUDE.md — Claude-Code redirect to .agents/rules.md.
|
|
90
|
+
// It is a ROOT file (not under .claude/), so the .claude/ template walk does not cover it
|
|
91
|
+
// and core does not emit it — the claude module writes it here. Tier-2 markered-text
|
|
92
|
+
// (writeTier2 html-comment). The matching canonicalHashes entry is recorded by core's
|
|
93
|
+
// postDispatch from ws (which aggregates every module's writes).
|
|
94
|
+
{
|
|
95
|
+
const src = path.join(getSharedRoot(), "CLAUDE.md");
|
|
96
|
+
const dst = "CLAUDE.md";
|
|
97
|
+
if (fs.existsSync(src)) {
|
|
98
|
+
const prevLen = ws.writes.length;
|
|
99
|
+
writeTier2(src, dst, tokens, "html-comment", dryRun, ws);
|
|
100
|
+
if (ws.writes.length > prevLen) {
|
|
101
|
+
console.log(`${logPrefix} ${tag}claude: ${dst}`);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
const claudeShared = path.join(getSharedRoot(), ".claude");
|
|
107
|
+
const claudeHooks = path.join(getCoreRoot(), ".claude", "hooks");
|
|
108
|
+
|
|
109
|
+
// Tier 2 JSON (contained) — deep-containment: settings.json
|
|
110
|
+
const settingsSrc = path.join(claudeShared, "settings.json");
|
|
111
|
+
const settingsDst = ".claude/settings.json";
|
|
112
|
+
if (fs.existsSync(settingsSrc)) {
|
|
113
|
+
const prevLen = ws.writes.length;
|
|
114
|
+
writeTier2JsonContained(settingsSrc, settingsDst, dryRun, ws);
|
|
115
|
+
ctx.claudeAllowRecorded = enrichClaudeSettingsAllows(
|
|
116
|
+
settingsDst,
|
|
117
|
+
process.cwd(),
|
|
118
|
+
dryRun,
|
|
119
|
+
ws,
|
|
120
|
+
advisories,
|
|
121
|
+
);
|
|
122
|
+
if (ws.writes.length > prevLen) {
|
|
123
|
+
console.log(`${logPrefix} ${tag}claude: ${settingsDst}`);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
// Markered-text — manifest format: "markered-text" — preflight hook.
|
|
128
|
+
// Uses writeTier2 (html-comment markers: # <!-- bkit:start --> / # <!-- bkit:end -->)
|
|
129
|
+
// to update only the bkit-managed block, preserving any consumer content outside markers.
|
|
130
|
+
// Changed from writeTier1 to align install dispatch with manifest format classification.
|
|
131
|
+
{
|
|
132
|
+
const src = path.join(claudeHooks, "bkit-preflight.sh");
|
|
133
|
+
const dst = ".claude/hooks/bkit-preflight.sh";
|
|
134
|
+
if (fs.existsSync(src)) {
|
|
135
|
+
const prevLen = ws.writes.length;
|
|
136
|
+
writeTier2(src, dst, tokens, "html-comment", dryRun, ws);
|
|
137
|
+
if (ws.writes.length > prevLen) {
|
|
138
|
+
console.log(`${logPrefix} ${tag}claude: ${dst}`);
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
// markered-text (slash-comment) — GateGuard advisory PreToolUse hook. bkit owns
|
|
144
|
+
// only the advisory engine between the markers; consumers own the stdin/stdout
|
|
145
|
+
// driver from first install onward (env vars BKIT_GATEGUARD / BKIT_ALLOW_CONFIG_EDIT
|
|
146
|
+
// still tune behaviour, same as before).
|
|
147
|
+
{
|
|
148
|
+
const src = path.join(claudeHooks, "bkit-gateguard.cjs");
|
|
149
|
+
const dst = ".claude/hooks/bkit-gateguard.cjs";
|
|
150
|
+
if (fs.existsSync(src)) {
|
|
151
|
+
const prevLen = ws.writes.length;
|
|
152
|
+
writeTier2(src, dst, tokens, "slash-comment", dryRun, ws);
|
|
153
|
+
if (ws.writes.length > prevLen) {
|
|
154
|
+
console.log(`${logPrefix} ${tag}claude: ${dst}`);
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
// markered-text (slash-comment) — shell advisories (PreToolUse matcher `Bash`).
|
|
160
|
+
// Covers what the permission table cannot express: URL hosts and shell-as-edit-channel.
|
|
161
|
+
{
|
|
162
|
+
const src = path.join(claudeHooks, "bkit-guardrails.cjs");
|
|
163
|
+
const dst = ".claude/hooks/bkit-guardrails.cjs";
|
|
164
|
+
if (fs.existsSync(src)) {
|
|
165
|
+
const prevLen = ws.writes.length;
|
|
166
|
+
writeTier2(src, dst, tokens, "slash-comment", dryRun, ws);
|
|
167
|
+
if (ws.writes.length > prevLen) {
|
|
168
|
+
console.log(`${logPrefix} ${tag}claude: ${dst}`);
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
// bkit-cloud-bootstrap.sh ships as a copy-and-own template; an install without `--auto=`
|
|
174
|
+
// ships zero cloud footprint. The SessionStart hook entry in .claude/settings.json
|
|
175
|
+
// is guarded (`test -f … || true`) so it no-ops when the consumer has not adopted
|
|
176
|
+
// the script. The `cloud-env-customize` advisory lives in the cloud module.
|
|
177
|
+
|
|
178
|
+
// .mcp.json — bkit owns only its tracker entry under `mcpServers`; every other key
|
|
179
|
+
// (the consumer's own servers) is kept as-is.
|
|
180
|
+
{
|
|
181
|
+
const mcpSrc = path.join(getSharedRoot(), ".mcp.json");
|
|
182
|
+
const mcpDst = ".mcp.json";
|
|
183
|
+
if (fs.existsSync(mcpSrc)) {
|
|
184
|
+
const prevLen = ws.writes.length;
|
|
185
|
+
reconcileMcpJson(mcpSrc, mcpDst, issueTracker, dryRun, ws);
|
|
186
|
+
if (ws.writes.length > prevLen) {
|
|
187
|
+
console.log(`${logPrefix} ${tag}claude: ${mcpDst}`);
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
// .bkit/.env.example — owned (Tier 1): the token-placeholder reference, overwritten on
|
|
193
|
+
// every install. Real values go in `.bkit/.env`. Not claude-specific, but the claude
|
|
194
|
+
// module is the default-runs-everywhere module.
|
|
195
|
+
{
|
|
196
|
+
const envExampleSrc = path.join(getSharedRoot(), ".bkit", ".env.example");
|
|
197
|
+
const envExampleDst = path.join(".bkit", ".env.example");
|
|
198
|
+
if (fs.existsSync(envExampleSrc)) {
|
|
199
|
+
const prevLen = ws.writes.length;
|
|
200
|
+
writeTier1(envExampleSrc, envExampleDst, tokens, dryRun, ws);
|
|
201
|
+
if (ws.writes.length > prevLen) {
|
|
202
|
+
console.log(`${logPrefix} ${tag}claude: ${envExampleDst}`);
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
// Generated copy-paste-ready Claude-on-web setup doc — `.claude/bkit-cloud.md`.
|
|
208
|
+
// UNTRACKED + gitignored (see the shared payload's gitignore): writeClaudeCloudDoc
|
|
209
|
+
// inlines REAL secret values resolved from the consumer's `.envrc` (dotenv
|
|
210
|
+
// sources minus its unsets minus session-hijack keys, per install/cloud-env.ts), so
|
|
211
|
+
// it is never committed and does NOT enter ws.writes / canonicalHashes / `bkit check`
|
|
212
|
+
// drift (values are machine-local). Skipped on dry-run (`bkit check`), which never
|
|
213
|
+
// writes secrets. Upgrade regenerates it via the same helper (see runUpgrade caller).
|
|
214
|
+
if (!dryRun && writeClaudeCloudDoc(process.cwd(), tokens)) {
|
|
215
|
+
console.log(
|
|
216
|
+
`${logPrefix} ${tag}claude: .claude/bkit-cloud.md (generated — gitignored, holds resolved secrets)`,
|
|
217
|
+
);
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
/**
|
|
222
|
+
* Ensure Claude `permissions.allow` covers {@link resolveClaudeDerivedAllows} —
|
|
223
|
+
* `WebFetch(domain:…)` per network-allowlist host and `mcp__…` per declared MCP server.
|
|
224
|
+
* Claude rules match a command prefix, not a URL host, so curl cannot be excepted
|
|
225
|
+
* by domain — network allowlisting for Claude is WebFetch-only; shell curl runs under
|
|
226
|
+
* Bash(*), gated by `deny` and the auto-mode classifier (no ask row).
|
|
227
|
+
* Called from install (`runClaudeModule`) and upgrade (mirror — upgrade does not
|
|
228
|
+
* dispatch modules).
|
|
229
|
+
*
|
|
230
|
+
* Adds AND prunes, but only ever removes a grant bkit itself recorded writing. The
|
|
231
|
+
* record is `claudeAllowDerived` in `.bkit/version`: a grant in that list and no longer
|
|
232
|
+
* in the derived set is bkit's to remove; a grant the consumer added by hand was
|
|
233
|
+
* never recorded, so it is never touched. An absent or empty record means bkit claims
|
|
234
|
+
* authorship of nothing and prunes nothing — old consumers converge by addition only.
|
|
235
|
+
*
|
|
236
|
+
* Returns the set to record for next time, or `null` when nothing was determined and
|
|
237
|
+
* the caller must leave the prior record alone: no settings file, unparseable JSON,
|
|
238
|
+
* a non-array `allow`, or a dry run. `null` is a statement about PROVENANCE, never
|
|
239
|
+
* about the write set — the `ws.writes` push below still fires under `dryRun`, because
|
|
240
|
+
* it is the entire `bkit check` drift signal for `.claude/settings.json`.
|
|
241
|
+
*/
|
|
242
|
+
export function enrichClaudeSettingsAllows(
|
|
243
|
+
settingsDst: string,
|
|
244
|
+
cwd: string,
|
|
245
|
+
dryRun: boolean,
|
|
246
|
+
ws: WriteSet,
|
|
247
|
+
advisories?: PreflightFinding[],
|
|
248
|
+
): readonly string[] | null {
|
|
249
|
+
if (!fs.existsSync(settingsDst)) return null;
|
|
250
|
+
let doc: {
|
|
251
|
+
permissions?: { allow?: string[] };
|
|
252
|
+
};
|
|
253
|
+
try {
|
|
254
|
+
doc = JSON.parse(fs.readFileSync(settingsDst, "utf-8")) as typeof doc;
|
|
255
|
+
} catch {
|
|
256
|
+
return null;
|
|
257
|
+
}
|
|
258
|
+
const allow = doc.permissions?.allow;
|
|
259
|
+
if (!Array.isArray(allow)) return null;
|
|
260
|
+
|
|
261
|
+
const needed = resolveClaudeDerivedAllows(cwd);
|
|
262
|
+
const recorded = readBkitVersion(path.join(cwd, ".bkit", "version"))?.claudeAllowDerived ?? [];
|
|
263
|
+
const add = needed.filter((r) => !allow.includes(r));
|
|
264
|
+
// Only what bkit recorded writing AND the derived set no longer wants.
|
|
265
|
+
const remove = recorded.filter((r) => !needed.includes(r) && allow.includes(r));
|
|
266
|
+
|
|
267
|
+
if (add.length > 0 || remove.length > 0) {
|
|
268
|
+
if (!dryRun) {
|
|
269
|
+
doc.permissions!.allow = [...allow.filter((r) => !remove.includes(r)), ...add];
|
|
270
|
+
fs.writeFileSync(settingsDst, JSON.stringify(doc, null, 2) + "\n", "utf-8");
|
|
271
|
+
}
|
|
272
|
+
// Outside the dryRun guard — see the provenance note above.
|
|
273
|
+
if (!ws.writes.some((w) => w.path === settingsDst)) {
|
|
274
|
+
ws.writes.push({ path: settingsDst, action: "write" });
|
|
275
|
+
}
|
|
276
|
+
if (remove.length > 0 && advisories) {
|
|
277
|
+
advisories.push({
|
|
278
|
+
id: "derived-grants-pruned",
|
|
279
|
+
severity: "advisory",
|
|
280
|
+
detect: `bkit removed ${remove.length} permissions.allow grant(s) it had previously added and no longer derives: ${remove.join(", ")}.`,
|
|
281
|
+
action:
|
|
282
|
+
"Nothing to do — a grant bkit added for a host or MCP server it no longer derives (dropped from .agents/context.md allowed-domains / mcp-servers, or no longer shipped) was withdrawn. To keep one, add it back to permissions.allow in .claude/settings.json by hand and bkit will leave it alone from then on.",
|
|
283
|
+
});
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
return dryRun ? null : needed;
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
// ---------------------------------------------------------------------------
|
|
290
|
+
// MCP config — `.mcp.json` (claude) and `.cursor/mcp.json` (cursor). bkit owns only
|
|
291
|
+
// its tracker entry under `mcpServers`; the rest of the file is the consumer's.
|
|
292
|
+
// ---------------------------------------------------------------------------
|
|
293
|
+
|
|
294
|
+
/**
|
|
295
|
+
* Render the tracker-filtered `.mcp.json` / `.cursor/mcp.json` content: keep only the selected
|
|
296
|
+
* tracker's `mcpServers` entry (none → empty map). Token-free. This is what a fresh install
|
|
297
|
+
* writes, and its one entry is what `reconcileMcpJson` owns in an existing file.
|
|
298
|
+
*/
|
|
299
|
+
export function buildMcpJson(templatePath: string, tracker: IssueTracker): string {
|
|
300
|
+
const template = JSON.parse(fs.readFileSync(templatePath, "utf-8")) as {
|
|
301
|
+
mcpServers?: Record<string, unknown>;
|
|
302
|
+
};
|
|
303
|
+
const all = template.mcpServers ?? {};
|
|
304
|
+
const filtered: Record<string, unknown> = {};
|
|
305
|
+
if (tracker !== "none" && Object.prototype.hasOwnProperty.call(all, tracker)) {
|
|
306
|
+
filtered[tracker] = all[tracker];
|
|
307
|
+
}
|
|
308
|
+
return JSON.stringify({ mcpServers: filtered }, null, 2) + "\n";
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
/**
|
|
312
|
+
* Reconcile bkit's tracker entry into a consumer's `.mcp.json` / `.cursor/mcp.json`. bkit
|
|
313
|
+
* owns exactly one key, `mcpServers[<tracker>]`, and sets it to the template's entry; every
|
|
314
|
+
* other key and the existing key order stay the consumer's. Absent file → write the
|
|
315
|
+
* `buildMcpJson` render. Malformed JSON → throw (refuse to merge; the consumer fixes it).
|
|
316
|
+
* Tracker `none` owns no entry, so a present file is left alone. Writes only on change, so
|
|
317
|
+
* dry-run and live compute the identical WriteSet. Another tracker's entry from an earlier
|
|
318
|
+
* install is left in place (`detectExtraMcpServers` advises on it).
|
|
319
|
+
*/
|
|
320
|
+
export function reconcileMcpJson(
|
|
321
|
+
templatePath: string,
|
|
322
|
+
relDst: string,
|
|
323
|
+
tracker: IssueTracker,
|
|
324
|
+
dryRun: boolean,
|
|
325
|
+
ws: WriteSet,
|
|
326
|
+
): void {
|
|
327
|
+
const rendered = buildMcpJson(templatePath, tracker);
|
|
328
|
+
if (!fs.existsSync(relDst)) {
|
|
329
|
+
if (!dryRun) {
|
|
330
|
+
ensureDir(path.dirname(relDst));
|
|
331
|
+
fs.writeFileSync(relDst, rendered, "utf-8");
|
|
332
|
+
}
|
|
333
|
+
ws.writes.push({ path: relDst, action: "write" });
|
|
334
|
+
return;
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
// Parse-or-sentinel idiom (see reconcileOpencodeJson): the throw stays out of the catch.
|
|
338
|
+
let existing: JsonValue | null = null;
|
|
339
|
+
try {
|
|
340
|
+
existing = JSON.parse(fs.readFileSync(relDst, "utf-8")) as JsonValue;
|
|
341
|
+
} catch {
|
|
342
|
+
existing = null;
|
|
343
|
+
}
|
|
344
|
+
if (existing === null || typeof existing !== "object" || Array.isArray(existing)) {
|
|
345
|
+
throw new Error(
|
|
346
|
+
`[bkit] ${relDst} is malformed JSON — fix manually before running bkit install`,
|
|
347
|
+
);
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
const owned = (JSON.parse(rendered) as { mcpServers: Record<string, JsonValue> }).mcpServers;
|
|
351
|
+
const servers = existing.mcpServers;
|
|
352
|
+
const serversObj =
|
|
353
|
+
servers !== null && typeof servers === "object" && !Array.isArray(servers) ? servers : {};
|
|
354
|
+
const inSync = Object.entries(owned).every(
|
|
355
|
+
([k, v]) => JSON.stringify(serversObj[k]) === JSON.stringify(v),
|
|
356
|
+
);
|
|
357
|
+
if (inSync) return;
|
|
358
|
+
|
|
359
|
+
const next = { ...existing, mcpServers: { ...serversObj, ...owned } };
|
|
360
|
+
if (!dryRun) fs.writeFileSync(relDst, JSON.stringify(next, null, 2) + "\n", "utf-8");
|
|
361
|
+
ws.writes.push({ path: relDst, action: "update" });
|
|
362
|
+
}
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
// install/modules/cloud.ts — the cloud module (`--auto=<variant>`): records the
|
|
2
|
+
// variant and prints the post-CI auto-routing setup advisories. It writes no files:
|
|
3
|
+
// every cloud file (the workflow, bkit-cloud-bootstrap.sh, the Cursor Dockerfile /
|
|
4
|
+
// environment) ships as a copy-and-own template.
|
|
5
|
+
|
|
6
|
+
import * as fs from "node:fs";
|
|
7
|
+
import * as path from "node:path";
|
|
8
|
+
import type { CloudAgents } from "../manifest.js";
|
|
9
|
+
import type { ModuleContext } from "./index.js";
|
|
10
|
+
|
|
11
|
+
// ---------------------------------------------------------------------------
|
|
12
|
+
// Helpers
|
|
13
|
+
// ---------------------------------------------------------------------------
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Persist a `bkit.<field>` value into the consumer's package.json so the
|
|
17
|
+
* post-install advisory can tell "deliberately none" from "undecided". Mirrors
|
|
18
|
+
* the `bkit.issueTracker` persist logic in commands/install/install.ts. Used for the opt-in
|
|
19
|
+
* decisions recorded by their owning modules (`cloudAgents`). No-op
|
|
20
|
+
* on dry-run or when package.json is absent/unparseable (non-fatal — the config
|
|
21
|
+
* file presence is still the primary signal).
|
|
22
|
+
*/
|
|
23
|
+
function setConsumerBkitField(field: string, value: string, dryRun: boolean): void {
|
|
24
|
+
if (dryRun) return;
|
|
25
|
+
const pkgPath = path.join(process.cwd(), "package.json");
|
|
26
|
+
if (!fs.existsSync(pkgPath)) return;
|
|
27
|
+
try {
|
|
28
|
+
const raw = fs.readFileSync(pkgPath, "utf-8");
|
|
29
|
+
const pkg = JSON.parse(raw) as Record<string, unknown>;
|
|
30
|
+
const bkit = (pkg.bkit ?? {}) as Record<string, unknown>;
|
|
31
|
+
if (bkit[field] === value) return; // already set — avoid a no-op rewrite
|
|
32
|
+
bkit[field] = value;
|
|
33
|
+
pkg.bkit = bkit;
|
|
34
|
+
const indentMatch = raw.match(/\n([ \t]+)"/);
|
|
35
|
+
const indent = indentMatch ? indentMatch[1] : " ";
|
|
36
|
+
const trailingNewline = raw.endsWith("\n") ? "\n" : "";
|
|
37
|
+
fs.writeFileSync(pkgPath, JSON.stringify(pkg, null, indent) + trailingNewline, "utf-8");
|
|
38
|
+
} catch {
|
|
39
|
+
// non-fatal — file presence is the primary signal
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
// The cloud workflow is a template (`.bkit/templates.md`). Shared first step of the
|
|
44
|
+
// claude and opencode setup advisories.
|
|
45
|
+
const CLOUD_WORKFLOW_ADOPT_STEP =
|
|
46
|
+
" - Copy `.bkit/templates/.github/workflows/bkit-cloud.yml` to `.github/workflows/bkit-cloud.yml` and own it: bkit never writes or overwrites that file. Replace the `{{CLOUD_RUNNER}}` placeholder in both jobs' `runs-on` with a runner label (e.g. `ubuntu-latest`). `.bkit/templates.md` lists every placeholder; on each `bkit upgrade`, diff the refreshed template against your copy.\n";
|
|
47
|
+
|
|
48
|
+
// ---------------------------------------------------------------------------
|
|
49
|
+
// runCloudModule — opt-in cloud-agent integration
|
|
50
|
+
// ---------------------------------------------------------------------------
|
|
51
|
+
//
|
|
52
|
+
// NOT shipped by a default install — opt-in via `bkit install --auto=<variant>`,
|
|
53
|
+
// so a default install ships ZERO cloud footprint. Every variant records
|
|
54
|
+
// `bkit.cloudAgents` and prints its setup advisories; none writes a file. The cloud
|
|
55
|
+
// workflow (bkit-cloud.yml), bkit-cloud-bootstrap.sh and the Cursor Background Agent
|
|
56
|
+
// files (.cursor/Dockerfile, .cursor/environment.json) are templates the advisories
|
|
57
|
+
// point at.
|
|
58
|
+
//
|
|
59
|
+
// Variant constraints are enforced in commands/install/install.ts before dispatch (tracker mismatch
|
|
60
|
+
// = hard error). The context's cloudVariant carries the chosen variant.
|
|
61
|
+
|
|
62
|
+
export function runCloudModule(ctx: ModuleContext): void {
|
|
63
|
+
const { dryRun, advisories } = ctx;
|
|
64
|
+
// Default to "claude" (the Claude/GitHub path) when cloudVariant is not set.
|
|
65
|
+
// Callers should always pass cloudVariant.
|
|
66
|
+
const variant: CloudAgents = ctx.cloudVariant ?? "claude";
|
|
67
|
+
|
|
68
|
+
if (variant === "claude") {
|
|
69
|
+
// --- cloud=claude: GitHub-tracker path ---
|
|
70
|
+
|
|
71
|
+
// Record the variant so the post-install advisory and `bkit check` stay consistent.
|
|
72
|
+
setConsumerBkitField("cloudAgents", "claude", dryRun);
|
|
73
|
+
|
|
74
|
+
// Advisory — cloud=claude setup checklist (App required; id-token: write).
|
|
75
|
+
advisories.push({
|
|
76
|
+
id: "bkit-cloud-setup",
|
|
77
|
+
severity: "advisory",
|
|
78
|
+
detect:
|
|
79
|
+
"Cloud agents (claude) need the unified cloud workflow (claude + opencode jobs, runtime-gated by secret presence), which ships as a template at `.bkit/templates/.github/workflows/bkit-cloud.yml`. The Claude GitHub App is required for `claude-code-action@v1` to authenticate via OIDC.",
|
|
80
|
+
action:
|
|
81
|
+
"Full recipe in bkit's `cloud.md` § Post-CI auto-routing.\n\n" +
|
|
82
|
+
"REQUIRED ONE-TIME SETUP:\n" +
|
|
83
|
+
CLOUD_WORKFLOW_ADOPT_STEP +
|
|
84
|
+
" - Run `/install-github-app` (Claude Code CLI) to install the Claude GitHub App on your repo. This is required — `claude-code-action@v1` authenticates as the App via OIDC (`id-token: write`); without the App it fails at boot with an OIDC error.\n" +
|
|
85
|
+
" - GitHub Actions permissions — flip BOTH org AND repo: Settings → Actions → General → Workflow permissions = **Read and write permissions** + tick **Allow GitHub Actions to create and approve pull requests**.\n" +
|
|
86
|
+
" - Add `ANTHROPIC_API_KEY` to repo secrets (Settings → Secrets and variables → Actions). Used by `claude-code-action@v1` (job env keeps this vendor name; local `.bkit/.env` stores it as `BKIT_ANTHROPIC_API_KEY`).\n" +
|
|
87
|
+
" - Do NOT add `BKIT_GH_TOKEN_INSTALL` to this workflow — it is package-install scoped and has no access to the consumer repo. Repo git/gh ops use the auto-provided `github.token` via the workflow's `permissions:` block.\n" +
|
|
88
|
+
" - Label the issue `bkit:auto` before pushing the build commit — without the label the CI auto-route exits no-op.\n\n" +
|
|
89
|
+
"OPTIONAL (manual phase launch): after `/install-github-app`, comment `@claude /bkit-plan` (or any phase) on a GitHub issue/PR to launch it from the tracker UI. The App's generated `claude.yml` triggers on mention events; `bkit-cloud.yml` triggers on CI completion + `workflow_dispatch` — the two coexist.\n\n" +
|
|
90
|
+
"Both the CI-driven path and the `@claude` mention path invoke the same `/bkit-auto` orchestrator (mirrored to `.claude/commands/bkit-auto.md` on each `pnpm bkit install`).",
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
// Advisory — cloud env scaffolding (Claude half).
|
|
94
|
+
advisories.push({
|
|
95
|
+
id: "cloud-env-customize",
|
|
96
|
+
severity: "advisory",
|
|
97
|
+
detect:
|
|
98
|
+
"Cloud env config splits across the repo (`.claude/hooks/bkit-cloud-bootstrap.sh`, a copy-and-own template you adopt) and the Claude app dashboard (setup script + env vars + auth tokens, manual).",
|
|
99
|
+
action:
|
|
100
|
+
"Two locations to touch — full recipe in bkit's `cloud.md`.\n\n" +
|
|
101
|
+
"IN REPO (copy-and-own; bkit never writes it):\n" +
|
|
102
|
+
" - Adopt `.bkit/templates/.claude/hooks/bkit-cloud-bootstrap.sh` as `.claude/hooks/bkit-cloud-bootstrap.sh` and edit it freely — the baseline runs `pnpm install` / `vale sync` and the gh login on each cloud session; add your own repo-specific steps (Supabase start, turbo prebuild, etc. — examples inlined). The `.claude/settings.json` SessionStart entry runs it only when present (`test -f … || true`).\n\n" +
|
|
103
|
+
"IN CLAUDE APP (claude.ai/code → environment selector → + Add environment):\n" +
|
|
104
|
+
" - Name: the repo name (e.g. `acme-web`) — one environment per repo, since secrets are per-repo.\n" +
|
|
105
|
+
" - Setup script: paste from bkit's `cloud.md` § Setup script (installs vale + gh + corepack-pinned pnpm — exact versions live in cloud.md, not duplicated here).\n" +
|
|
106
|
+
" - Environment variables: `BKIT_GH_TOKEN` (fine-grained PAT for GitHub MCP), `BKIT_GH_TOKEN_INSTALL` (classic PAT with read:packages), `CLAUDE_AUTOCOMPACT_PCT_OVERRIDE=70`.\n" +
|
|
107
|
+
" - Tracker env vars (GitHub): No tracker PAT needed. Run `gh auth login` once for CLI surface. MCP auth is browser OAuth (automatic on first tool call). Set `BKIT_GH_TOKEN` (fine-grained PAT for GitHub MCP server).\n" +
|
|
108
|
+
" - Network access: `Trusted` (default). One environment per repo (secrets differ per repo); the setup script + variable *names* are identical across repos, only the values change. See cloud.md § Sharing across repos → Claude.",
|
|
109
|
+
});
|
|
110
|
+
} else if (variant === "opencode") {
|
|
111
|
+
// --- cloud=opencode: GitHub-tracker path (same bkit-cloud.yml template, no OIDC) ---
|
|
112
|
+
|
|
113
|
+
// Record the variant.
|
|
114
|
+
setConsumerBkitField("cloudAgents", "opencode", dryRun);
|
|
115
|
+
|
|
116
|
+
// Advisory — cloud=opencode setup checklist.
|
|
117
|
+
advisories.push({
|
|
118
|
+
id: "bkit-cloud-setup",
|
|
119
|
+
severity: "advisory",
|
|
120
|
+
detect:
|
|
121
|
+
"Cloud agents (opencode) need the unified cloud workflow (claude + opencode jobs, runtime-gated by secret presence), which ships as a template at `.bkit/templates/.github/workflows/bkit-cloud.yml`. The opencode job runs when `OPENCODE_PROVIDER_KEY` is set.",
|
|
122
|
+
action:
|
|
123
|
+
"Full recipe in bkit's `cloud.md` § Post-CI auto-routing.\n\n" +
|
|
124
|
+
"REQUIRED ONE-TIME SETUP:\n" +
|
|
125
|
+
CLOUD_WORKFLOW_ADOPT_STEP +
|
|
126
|
+
" - Install the local opencode host first: `bkit install --opencode=<provider>` (e.g. `--opencode=opencode`). The cloud opencode job runs against the committed `.opencode/` config — provider and model pins come from there, not from this YAML.\n" +
|
|
127
|
+
" - Add `OPENCODE_PROVIDER_KEY` to repo secrets (Settings → Secrets and variables → Actions). Set it to your configured provider's API key. The workflow fans this one secret out to every supported provider env var name (`BKIT_OPENROUTER_API_KEY`/`BKIT_OLLAMA_API_KEY`/`BKIT_OPENCODE_API_KEY`) so the `.opencode/opencode.json` `{env:VAR}` reference resolves whichever provider you installed.\n" +
|
|
128
|
+
" - GitHub Actions permissions — flip BOTH org AND repo: Settings → Actions → General → Workflow permissions = **Read and write permissions** + tick **Allow GitHub Actions to create and approve pull requests**.\n" +
|
|
129
|
+
" - The opencode job does NOT use a Claude API key — it runs the opencode runner with your chosen provider key only. If you also install the claude job (separate secret), both jobs coexist on the same event.\n" +
|
|
130
|
+
" - Label the issue `bkit:auto` before pushing the build commit — without the label the CI auto-route exits no-op.\n\n" +
|
|
131
|
+
"REACTIVE HANDLER (separate, consumer self-installed): the stock `/oc` comment handler (`opencode github install`) is NOT managed by bkit — install it once per repo independently. It mirrors the `@claude`/`claude.yml` stance. `bkit-cloud.yml` handles the CI-driven + `workflow_dispatch` path only.",
|
|
132
|
+
});
|
|
133
|
+
} else {
|
|
134
|
+
// --- cloud=cursor: Linear-tracker path ---
|
|
135
|
+
|
|
136
|
+
// Record the variant.
|
|
137
|
+
setConsumerBkitField("cloudAgents", "cursor", dryRun);
|
|
138
|
+
|
|
139
|
+
// Advisory — cloud=cursor setup checklist.
|
|
140
|
+
advisories.push({
|
|
141
|
+
id: "bkit-cloud-setup",
|
|
142
|
+
severity: "advisory",
|
|
143
|
+
detect:
|
|
144
|
+
"Cloud agents (cursor) need the Cursor Background Agent scaffolding, which ships as templates at `.bkit/templates/.cursor/Dockerfile` and `.bkit/templates/.cursor/environment.json`. The Cursor Background Agent trigger is configured in the Cursor cloud agents dashboard — bkit cannot automate that step.",
|
|
145
|
+
action:
|
|
146
|
+
"Full recipe in bkit's `cloud.md` § Post-CI auto-routing.\n\n" +
|
|
147
|
+
"IN CURSOR DASHBOARD:\n" +
|
|
148
|
+
" - Cursor → Cloud Agents dashboard → Triggers → + Add trigger.\n" +
|
|
149
|
+
" - Event: CI workflow completion. Branch filter: `feat/**`.\n" +
|
|
150
|
+
" - Prompt (paste literally, no edits): `/bkit-auto $CI_STATUS $PR_NUMBER`.\n" +
|
|
151
|
+
" - Allowed concurrency: latest-supersedes.\n" +
|
|
152
|
+
" - Set `BKIT_LINEAR_API_KEY` as a **Runtime Secret** in the Cloud Agents dashboard (https://cursor.com/dashboard/cloud-agents) → your environment → Secrets tab.\n" +
|
|
153
|
+
" - Label the issue `bkit:auto` in Linear before pushing the build commit.\n\n" +
|
|
154
|
+
"IN REPO (copy each template and own it; bkit never writes or overwrites these files — see `.bkit/templates.md`):\n" +
|
|
155
|
+
" - `.bkit/templates/.cursor/Dockerfile` → `.cursor/Dockerfile`: change Node major if `engines.node` differs from 20; add Playwright / Supabase CLI / extra apt deps.\n" +
|
|
156
|
+
" - `.bkit/templates/.cursor/environment.json` → `.cursor/environment.json`: set `install` / `start` / `terminals[]` / `env` for your stack.",
|
|
157
|
+
});
|
|
158
|
+
|
|
159
|
+
// Advisory — cloud env scaffolding (Cursor half).
|
|
160
|
+
advisories.push({
|
|
161
|
+
id: "cloud-env-customize",
|
|
162
|
+
severity: "advisory",
|
|
163
|
+
detect:
|
|
164
|
+
"Cloud env config splits across the repo (`.cursor/Dockerfile` + `.cursor/environment.json`, copied from `.bkit/templates/.cursor/`) and the Cursor Cloud Agents dashboard (secrets, manual).",
|
|
165
|
+
action:
|
|
166
|
+
"Copy-paste-ready values (resolved from your `.envrc`) are written to `.cursor/bkit-cloud.md` (gitignored) on every install.\n\n" +
|
|
167
|
+
"IN THE CLOUD AGENTS DASHBOARD (https://cursor.com/dashboard/cloud-agents → your environment → Secrets tab) — add each as a **Runtime Secret** (loaded as an env var, redacted from the agent's transcript):\n" +
|
|
168
|
+
" - `BKIT_GH_TOKEN`, `BKIT_GH_TOKEN_INSTALL`.\n" +
|
|
169
|
+
" - Tracker secret (Linear): `BKIT_LINEAR_API_KEY` (generate at https://linear.app/settings/api). `LINEAR_ISSUE_ID` is injected per-session — don't hardcode.\n" +
|
|
170
|
+
" - First session after Dockerfile changes rebuilds the image; subsequent sessions reuse cached layers.\n\n" +
|
|
171
|
+
"Full recipe in bkit's `cloud.md`; the paste-ready block is in `.cursor/bkit-cloud.md`.",
|
|
172
|
+
});
|
|
173
|
+
}
|
|
174
|
+
}
|