@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,101 @@
|
|
|
1
|
+
// checks/after/vercel.ts — the Vercel project link, env and install command auth.
|
|
2
|
+
|
|
3
|
+
import * as fs from "node:fs";
|
|
4
|
+
import * as path from "node:path";
|
|
5
|
+
import { execFileSync } from "node:child_process";
|
|
6
|
+
import type { TokenPresence } from "./auth.js";
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Detect whether a Vercel project exists in the consumer's repo.
|
|
10
|
+
* Heuristic: presence of vercel.json at root or under apps/<name>/.
|
|
11
|
+
*/
|
|
12
|
+
export function detectVercelProject(cwd: string): boolean {
|
|
13
|
+
if (fs.existsSync(path.join(cwd, "vercel.json"))) return true;
|
|
14
|
+
const appsDir = path.join(cwd, "apps");
|
|
15
|
+
if (!fs.existsSync(appsDir) || !fs.statSync(appsDir).isDirectory()) return false;
|
|
16
|
+
for (const entry of fs.readdirSync(appsDir, { withFileTypes: true })) {
|
|
17
|
+
if (!entry.isDirectory()) continue;
|
|
18
|
+
if (fs.existsSync(path.join(appsDir, entry.name, "vercel.json"))) return true;
|
|
19
|
+
}
|
|
20
|
+
return false;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Detect whether BKIT_GH_TOKEN_INSTALL is present in a Vercel environment.
|
|
25
|
+
*
|
|
26
|
+
* B3 Vercel CLI hang guard: pre-checks `.vercel/project.json` and SKIPS `vercel env ls`
|
|
27
|
+
* when the file is absent. Does NOT shell out unless the project file exists — this
|
|
28
|
+
* avoids the CLI login prompt / TTY hang in non-interactive CI environments.
|
|
29
|
+
*
|
|
30
|
+
* Fallback: if detectVercelProject finds vercel.json but .vercel/project.json is absent,
|
|
31
|
+
* the project is not yet linked to a Vercel deployment — skip CLI call.
|
|
32
|
+
*/
|
|
33
|
+
export function detectVercelEnv(
|
|
34
|
+
env: "preview" | "production",
|
|
35
|
+
cwd: string = process.cwd(),
|
|
36
|
+
): TokenPresence {
|
|
37
|
+
if (!detectVercelProject(cwd)) return "unknown";
|
|
38
|
+
// Runtime guard: reject unexpected env values even though TypeScript narrows them.
|
|
39
|
+
if (env !== "preview" && env !== "production") return "unknown";
|
|
40
|
+
// B3: Guard against `vercel env ls` hanging when the project is not linked.
|
|
41
|
+
// `.vercel/project.json` is written by `vercel link` — absent means not linked.
|
|
42
|
+
// Without this guard, `vercel env ls` blocks on a TTY login prompt in CI.
|
|
43
|
+
const vercelProjectFile = path.join(cwd, ".vercel", "project.json");
|
|
44
|
+
if (!fs.existsSync(vercelProjectFile)) return "unknown";
|
|
45
|
+
try {
|
|
46
|
+
const out = execFileSync("vercel", ["env", "ls", env], {
|
|
47
|
+
encoding: "utf-8",
|
|
48
|
+
stdio: ["ignore", "pipe", "ignore"],
|
|
49
|
+
timeout: 10000,
|
|
50
|
+
});
|
|
51
|
+
return out.includes("BKIT_GH_TOKEN_INSTALL") ? "present" : "missing";
|
|
52
|
+
} catch {
|
|
53
|
+
return "unknown";
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Detect Vercel projects whose `vercel.json` does not authenticate to GH Packages in its
|
|
59
|
+
* install step. Vercel runs `pnpm install` in a fresh container with no pre-install shell
|
|
60
|
+
* hook, so the token must be written by an `installCommand` that runs
|
|
61
|
+
* `pnpm config set "//npm.pkg.github.com/:_authToken=$BKIT_GH_TOKEN_INSTALL"` before install — the
|
|
62
|
+
* registry-only project .npmrc carries no token on pnpm >=10.34.3. A vercel.json with no
|
|
63
|
+
* installCommand (or one whose installCommand lacks that `pnpm config set`) 401s on the
|
|
64
|
+
* @cbartens/bkit download even when BKIT_GH_TOKEN_INSTALL is present in the Vercel env.
|
|
65
|
+
*
|
|
66
|
+
* Uses a raw-content regex (like detectCiYmlMissingTokenEnv), not JSON.parse, so a
|
|
67
|
+
* non-standard-but-valid vercel.json still matches.
|
|
68
|
+
*
|
|
69
|
+
* Returns the offending vercel.json paths (relative to cwd); empty when all authenticate.
|
|
70
|
+
*/
|
|
71
|
+
export function detectVercelInstallCommandMissingAuth(cwd: string): string[] {
|
|
72
|
+
// `\\?["']?` tolerates the JSON-escaped (`\"//npm…`), plain-quoted, and unquoted forms
|
|
73
|
+
// an installCommand string may take inside vercel.json.
|
|
74
|
+
const authPattern = /pnpm\s+config\s+set\s+\\?["']?\/\/npm\.pkg\.github\.com\/:_authToken=/;
|
|
75
|
+
const offenders: string[] = [];
|
|
76
|
+
const check = (file: string): void => {
|
|
77
|
+
if (!fs.existsSync(file)) return;
|
|
78
|
+
if (!authPattern.test(fs.readFileSync(file, "utf-8"))) offenders.push(path.relative(cwd, file));
|
|
79
|
+
};
|
|
80
|
+
check(path.join(cwd, "vercel.json"));
|
|
81
|
+
const appsDir = path.join(cwd, "apps");
|
|
82
|
+
if (fs.existsSync(appsDir)) {
|
|
83
|
+
for (const entry of fs.readdirSync(appsDir, { withFileTypes: true })) {
|
|
84
|
+
if (entry.isDirectory()) check(path.join(appsDir, entry.name, "vercel.json"));
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
return offenders;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
export const VERCEL_MISSING_ACTION =
|
|
91
|
+
"Add the @cbartens registry mapping to .npmrc at the repo root (the token is NOT stored here):\n\n" +
|
|
92
|
+
" @cbartens:registry=https://npm.pkg.github.com\n\n" +
|
|
93
|
+
"Commit this .npmrc — Vercel reads it during its build.\n\n" +
|
|
94
|
+
"Vercel runs pnpm install in a fresh container and cannot run a pre-install shell step, so write the auth token via an installCommand in vercel.json:\n\n" +
|
|
95
|
+
' "installCommand": "pnpm config set //npm.pkg.github.com/:_authToken=$BKIT_GH_TOKEN_INSTALL && pnpm install"\n\n' +
|
|
96
|
+
"Set BKIT_GH_TOKEN_INSTALL as a Vercel environment variable for each environment:\n\n" +
|
|
97
|
+
" vercel env add BKIT_GH_TOKEN_INSTALL preview\n" +
|
|
98
|
+
" vercel env add BKIT_GH_TOKEN_INSTALL production\n\n" +
|
|
99
|
+
"Or via web: Vercel project → Settings → Environment Variables.\n" +
|
|
100
|
+
"The token must be a GitHub PAT with read:packages scope (classic) or Packages: read permission (fine-grained).\n\n" +
|
|
101
|
+
"Why the installCommand: pnpm >=10.34.3 does not authenticate a project-.npmrc ${BKIT_GH_TOKEN_INSTALL} env-substitution (it 401s on download), so the token must reach pnpm's user-level config via `pnpm config set` before install.";
|
|
@@ -0,0 +1,429 @@
|
|
|
1
|
+
// checks/before/context-fetch.ts — the context-fetch blocks in `.agents/context.md`: present,
|
|
2
|
+
// covering each context, sources enabled, provision blocks in place.
|
|
3
|
+
|
|
4
|
+
import * as fs from "node:fs";
|
|
5
|
+
import * as path from "node:path";
|
|
6
|
+
import { getTemplatesRoot } from "../../shared/package-roots.js";
|
|
7
|
+
import { readPackageJson } from "../../shared/package-json.js";
|
|
8
|
+
import type { PreflightFinding } from "./index.js";
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Line-anchored consumer opt-out marker for the context-fetch advisories. A repo
|
|
12
|
+
* that legitimately enables no runtime-log source places this below
|
|
13
|
+
* `<!-- bkit:end -->` to dismiss both `context-fetch-missing` and
|
|
14
|
+
* `context-fetch-source-not-enabled`.
|
|
15
|
+
*/
|
|
16
|
+
const CONTEXT_FETCH_NONE_RE = /^<!-- context-fetch:none(?: [^>]*)? -->$/m;
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Every `context=` a `context-fetch` block may declare, in the order coverage is
|
|
20
|
+
* narrated. `runtime` is the default when the attribute is absent. The one list: the
|
|
21
|
+
* `bkit context` runner (commands/workflow/context.ts) and these advisories both read it.
|
|
22
|
+
*/
|
|
23
|
+
export const CONTEXT_FETCH_CONTEXTS: readonly string[] = ["runtime", "ci", "diff", "e2e", "web"];
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Contexts whose absence means an entire class of failure evidence is never fetched,
|
|
27
|
+
* each with the evidence it carries.
|
|
28
|
+
*
|
|
29
|
+
* A subset of {@link CONTEXT_FETCH_CONTEXTS}: `web` is valid-but-not-required (its
|
|
30
|
+
* self-skip names the host's built-in web tools as the fallback). `runtime` is covered
|
|
31
|
+
* by `context-fetch-missing` instead.
|
|
32
|
+
*/
|
|
33
|
+
const CONTEXT_FETCH_EVIDENCE_CONTEXTS: Record<string, string> = {
|
|
34
|
+
ci: "CI job/step failures and logs",
|
|
35
|
+
diff: "diff vs the last commit that passed CI",
|
|
36
|
+
e2e: "e2e reports / traces / device evidence",
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Contexts named on a `<!-- context-fetch:none ... -->` marker, which dismisses the
|
|
41
|
+
* context-coverage advisory for those contexts ONLY — a repo with no e2e lane says
|
|
42
|
+
* so without also silencing the advisories that catch a genuinely unwired repo.
|
|
43
|
+
* A bare marker names none and keeps its whole-file meaning.
|
|
44
|
+
*/
|
|
45
|
+
function contextFetchNoneContexts(consumer: string): Set<string> {
|
|
46
|
+
const m = /^<!-- context-fetch:none((?: [\w.-]+)*) -->$/m.exec(consumer);
|
|
47
|
+
if (!m) return new Set();
|
|
48
|
+
return new Set(m[1]!.split(/\s+/).filter((t) => CONTEXT_FETCH_CONTEXTS.includes(t)));
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* True ONLY for the blanket opt-out: a `context-fetch:none` marker naming no known
|
|
53
|
+
* context. A context-scoped marker (`context-fetch:none e2e`) dismisses that context's
|
|
54
|
+
* coverage advisory and nothing else — it must never silence the advisories that
|
|
55
|
+
* catch a repo with no blocks or an unenabled source.
|
|
56
|
+
*/
|
|
57
|
+
function contextFetchDismissesAll(consumer: string): boolean {
|
|
58
|
+
return CONTEXT_FETCH_NONE_RE.test(consumer) && contextFetchNoneContexts(consumer).size === 0;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Parse a `<!-- context-fetch:start [name] [context=<context>] -->` line. Attribute order
|
|
63
|
+
* is free and both parts are optional: a bare `context-fetch:start` is an unnamed
|
|
64
|
+
* `runtime` block. Runs of spaces and tabs separate tokens; the last name token wins.
|
|
65
|
+
* Returns `null` for non-matching lines. The one parser: the `bkit context` runner
|
|
66
|
+
* (commands/workflow/context.ts) and these advisories both read it.
|
|
67
|
+
*/
|
|
68
|
+
export function parseContextFetchStart(line: string): { name: string; context: string } | null {
|
|
69
|
+
const m = /^<!-- context-fetch:start((?:[ \t]+[\w.=-]+)*)[ \t]*-->$/.exec(line);
|
|
70
|
+
if (!m) return null;
|
|
71
|
+
let name = "";
|
|
72
|
+
let context = "runtime";
|
|
73
|
+
for (const token of m[1]!.split(/[ \t]+/).filter(Boolean)) {
|
|
74
|
+
if (token.startsWith("context=")) context = token.slice("context=".length);
|
|
75
|
+
else name = token;
|
|
76
|
+
}
|
|
77
|
+
return { name, context };
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/** Every `context-fetch:start` block declared in a section, in document order. */
|
|
81
|
+
function parseContextFetchStarts(section: string): { name: string; context: string }[] {
|
|
82
|
+
const out: { name: string; context: string }[] = [];
|
|
83
|
+
for (const line of section.split("\n")) {
|
|
84
|
+
const parsed = parseContextFetchStart(line);
|
|
85
|
+
if (parsed) out.push(parsed);
|
|
86
|
+
}
|
|
87
|
+
return out;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Map of context-fetch source name -> predicate proving THIS repo actually runs
|
|
92
|
+
* that backend. Evidence-gates `context-fetch-source-not-enabled`
|
|
93
|
+
* so a single-backend consumer (e.g. Vercel-only) is never nagged about a
|
|
94
|
+
* backend it does not use (e.g. Supabase). A shipped template whose name has no
|
|
95
|
+
* entry here is never flagged (cannot prove use => stay quiet).
|
|
96
|
+
*/
|
|
97
|
+
const CONTEXT_FETCH_BACKEND_EVIDENCE: Record<string, (cwd: string) => boolean> = {
|
|
98
|
+
supabase: (cwd) =>
|
|
99
|
+
fs.existsSync(path.join(cwd, "supabase", "config.toml")) ||
|
|
100
|
+
readDependencyNames(cwd).some((d) => d.startsWith("@supabase/")),
|
|
101
|
+
vercel: (cwd) =>
|
|
102
|
+
fs.existsSync(path.join(cwd, "vercel.json")) ||
|
|
103
|
+
fs.existsSync(path.join(cwd, ".vercel")) ||
|
|
104
|
+
readDependencyNames(cwd).includes("vercel"),
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
/** Every dependency name across the four package.json dependency fields. */
|
|
108
|
+
function readDependencyNames(cwd: string): string[] {
|
|
109
|
+
const read = readPackageJson(cwd);
|
|
110
|
+
if (!read.ok) return [];
|
|
111
|
+
const pkg = read.pkg;
|
|
112
|
+
const names: string[] = [];
|
|
113
|
+
for (const field of [
|
|
114
|
+
"dependencies",
|
|
115
|
+
"devDependencies",
|
|
116
|
+
"optionalDependencies",
|
|
117
|
+
"peerDependencies",
|
|
118
|
+
]) {
|
|
119
|
+
const deps = pkg[field];
|
|
120
|
+
if (deps && typeof deps === "object") {
|
|
121
|
+
names.push(...Object.keys(deps as Record<string, unknown>));
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
return names;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* Advisory: consumer's `.agents/context.md` has the bkit-managed block but no
|
|
129
|
+
* `<!-- context-fetch:start <name> --> ... <!-- context-fetch:end -->` block AFTER
|
|
130
|
+
* `<!-- bkit:end -->`.
|
|
131
|
+
*
|
|
132
|
+
* `/bkit-debug`'s runtime sub-fetch runs every `context-fetch` block occurring
|
|
133
|
+
* after `<!-- bkit:end -->` (consumer section). With no consumer-section block, no
|
|
134
|
+
* runtime-log artifact (`context-runtime-<name>-{ATTEMPT}.md`) is produced
|
|
135
|
+
* on any debug run. Ready-made blocks ship in `.bkit/templates/context/`.
|
|
136
|
+
*
|
|
137
|
+
* Markers may be named (`context-fetch:start vercel`) or unnamed. Only
|
|
138
|
+
* fires when the consumer has the bkit-managed block at all; consumers who fully
|
|
139
|
+
* own `.agents/context.md` (no markers) are not nagged. Dismissable with a
|
|
140
|
+
* `<!-- context-fetch:none ... -->` marker below `<!-- bkit:end -->`.
|
|
141
|
+
*/
|
|
142
|
+
export function detectContextFetchMissing(cwd: string): PreflightFinding | null {
|
|
143
|
+
const filePath = path.join(cwd, ".agents", "context.md");
|
|
144
|
+
if (!fs.existsSync(filePath)) return null;
|
|
145
|
+
const content = fs.readFileSync(filePath, "utf-8");
|
|
146
|
+
// Require the bkit-managed block (line-anchored `<!-- bkit:end -->`).
|
|
147
|
+
const endIdx = content.search(/^<!-- bkit:end -->$/m);
|
|
148
|
+
if (endIdx === -1) return null;
|
|
149
|
+
const afterBkitEnd = content.slice(endIdx);
|
|
150
|
+
// Consumer opt-out: dismiss when a `<!-- context-fetch:none ... -->` marker is
|
|
151
|
+
// present below `<!-- bkit:end -->` (repo legitimately enables no source).
|
|
152
|
+
if (contextFetchDismissesAll(afterBkitEnd)) return null;
|
|
153
|
+
// Consumer-section markers must be line-anchored to mirror the workflow's
|
|
154
|
+
// `sed`/`awk` extraction (`.bkit/workflows/bkit-debug.md` Step 5). The start
|
|
155
|
+
// marker carries an optional block name (`context-fetch:start vercel`).
|
|
156
|
+
const hasStart = parseContextFetchStarts(afterBkitEnd).length > 0;
|
|
157
|
+
const hasEnd = /^<!-- context-fetch:end -->$/m.test(afterBkitEnd);
|
|
158
|
+
if (hasStart && hasEnd) return null;
|
|
159
|
+
return {
|
|
160
|
+
id: "context-fetch-missing",
|
|
161
|
+
severity: "advisory",
|
|
162
|
+
detect:
|
|
163
|
+
"`.agents/context.md` has the bkit-managed block but no `<!-- context-fetch:start [name] --> ... <!-- context-fetch:end -->` block after `<!-- bkit:end -->`. `/bkit-debug` runs every block in that consumer section — with none, no runtime-log artifact is produced.",
|
|
164
|
+
action:
|
|
165
|
+
"Copy the blocks of a provider file in `.bkit/templates/context/` (e.g. `bkit-vercel.md`, `bkit-supabase.md`; index in `.bkit/templates.md` § Context-fetch blocks) and paste them after `<!-- bkit:end -->`, then set its env vars. REQUIRED: set the block's non-secret selector (e.g. `VERCEL_SCOPE` / `SUPABASE_PROJECT_ID`) by uncommenting the assignment line at the top of the copied block — committing it there is what makes the block run in headless cloud agents, which never read `.bkit/.env`. For cloud `/bkit-debug`, also set the secret tokens (`VERCEL_TOKEN` / `SUPABASE_ACCESS_TOKEN`) in your Claude/Cursor dashboard (or GitHub Actions secrets) and authenticate non-interactively (env tokens, never `vercel login`). Each block self-gates (missing CLI / token => a `[context-fetch:<name>] skipped — …` stderr breadcrumb, not an error), so enable only the sources you use; add your own block for any other log backend (`gcloud` / `aws` / `datadog`). Keep blocks read-only and idempotent — the agent customises severity / freshness / limit / target environment (e.g. Vercel preview vs production) at run-time.",
|
|
166
|
+
};
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
/**
|
|
170
|
+
* Advisory: the consumer section enables context-fetch blocks, but not for every
|
|
171
|
+
* evidence context — so `/bkit-debug` fetches an entire class of failure evidence
|
|
172
|
+
* for no run, ever.
|
|
173
|
+
*
|
|
174
|
+
* `/bkit-debug` Step 4 is fully block-driven: CI logs, the last-passing diff and
|
|
175
|
+
* e2e artifacts each come from a `context=`-tagged block, exactly as runtime logs
|
|
176
|
+
* do. bkit hardcodes no CI host, workflow filename, branch name or e2e framework.
|
|
177
|
+
*
|
|
178
|
+
* Distinct from `context-fetch-missing`, which owns the no-blocks-at-all case; this
|
|
179
|
+
* one only fires once at least one block exists. Dismissable per context —
|
|
180
|
+
* `<!-- context-fetch:none e2e -->` below `<!-- bkit:end -->`. A bare marker dismisses all.
|
|
181
|
+
*/
|
|
182
|
+
export function detectContextFetchContextMissing(cwd: string): PreflightFinding | null {
|
|
183
|
+
const filePath = path.join(cwd, ".agents", "context.md");
|
|
184
|
+
if (!fs.existsSync(filePath)) return null;
|
|
185
|
+
const content = fs.readFileSync(filePath, "utf-8");
|
|
186
|
+
const endIdx = content.search(/^<!-- bkit:end -->$/m);
|
|
187
|
+
if (endIdx === -1) return null;
|
|
188
|
+
const consumer = content.slice(endIdx);
|
|
189
|
+
|
|
190
|
+
const enabled = parseContextFetchStarts(consumer);
|
|
191
|
+
// No blocks at all => `context-fetch-missing` owns it (no double-fire).
|
|
192
|
+
if (enabled.length === 0) return null;
|
|
193
|
+
|
|
194
|
+
const dismissed = contextFetchNoneContexts(consumer);
|
|
195
|
+
// A bare `context-fetch:none` names no context and dismisses every advisory.
|
|
196
|
+
if (contextFetchDismissesAll(consumer)) return null;
|
|
197
|
+
|
|
198
|
+
const contexts = new Set(enabled.map((b) => b.context));
|
|
199
|
+
const missing = Object.keys(CONTEXT_FETCH_EVIDENCE_CONTEXTS).filter(
|
|
200
|
+
(r) => !contexts.has(r) && !dismissed.has(r),
|
|
201
|
+
);
|
|
202
|
+
if (missing.length === 0) return null;
|
|
203
|
+
|
|
204
|
+
const list = missing
|
|
205
|
+
.map((r) => `\`context=${r}\` (${CONTEXT_FETCH_EVIDENCE_CONTEXTS[r]})`)
|
|
206
|
+
.join(", ");
|
|
207
|
+
const plural = missing.length > 1;
|
|
208
|
+
return {
|
|
209
|
+
id: "context-fetch-context-missing",
|
|
210
|
+
severity: "advisory",
|
|
211
|
+
detect: `\`.agents/context.md\` enables context-fetch blocks below \`<!-- bkit:end -->\` but none for ${list}. \`/bkit-debug\` fetches ALL failure evidence from these blocks — it hardcodes no CI host, workflow filename, branch name or e2e framework — so ${plural ? "those classes" : "that class"} of evidence ${plural ? "are" : "is"} never fetched on any debug run. Every attempt reports \`context=<context> NOT CONFIGURED\`, and diagnosis must treat the gap as unchecked rather than clean.`,
|
|
212
|
+
action: `Copy the matching \`<!-- context-fetch:start <name> context=<context> --> ... <!-- context-fetch:end -->\` block(s) from \`.bkit/templates/context/\` (\`bkit-github.md\` for \`ci\` and \`diff\`, \`bkit-playwright.md\`, …; index in \`.bkit/templates.md\` § Context-fetch blocks) to below \`<!-- bkit:end -->\`, one per missing context: ${list}. The templates assume GitHub Actions and Playwright because that is the common case — they are examples, NOT the contract. Edit them to your setup: \`BASELINE_BRANCH\` / \`BASELINE_WORKFLOW\` must name YOUR trunk branch and workflow file, and \`E2E_ARTIFACT\` / \`E2E_JOB_RE\` must name YOUR upload-artifact and match ONLY the lane that block covers. On another CI host (GitLab, Bitbucket, Buildkite) replace the \`gh\` calls with that host's API — the context contract is just "write the evidence to stdout". A test lane whose evidence never reaches your CI host (a native lane whose reports stay on Expo EAS, Bitrise or Firebase Test Lab) needs its OWN \`context=e2e\` block fetching from that service (Expo EAS: \`bkit-maestro.md\`, the \`expo-workflows\` block in \`bkit-expo.md\`): widening another block's job regex to cover it makes that block download the WRONG lane's report and file it under the failing lane's name, which is worse than fetching nothing. Blocks are self-contained — each discovers the run it needs itself, so there is no ordering between them and none share variables. Give each block a name unique within its context; a repeated \`context\` + name pair writes both blocks to one artifact path. No such lane in this repo → name the context on the opt-out marker below \`<!-- bkit:end -->\`, space-separated for several: \`<!-- context-fetch:none ${missing.join(" ")} -->\`. That dismisses those contexts ONLY; a bare \`<!-- context-fetch:none intentional -->\` dismisses every context-fetch advisory.`,
|
|
213
|
+
};
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
/**
|
|
217
|
+
* Named fetch blocks bkit ships as templates, keyed by block name → the template file
|
|
218
|
+
* (`.bkit/templates/context/<file>`) that holds it. Read from the package, so the set
|
|
219
|
+
* follows the shipped templates without a hand-kept list.
|
|
220
|
+
*/
|
|
221
|
+
function shippedContextFetchTemplates(): Map<string, string> {
|
|
222
|
+
const dir = path.join(getTemplatesRoot(), "context");
|
|
223
|
+
const out = new Map<string, string>();
|
|
224
|
+
if (!fs.existsSync(dir)) return out;
|
|
225
|
+
for (const file of fs.readdirSync(dir).sort()) {
|
|
226
|
+
if (!file.endsWith(".md")) continue;
|
|
227
|
+
for (const { name } of parseContextFetchStarts(
|
|
228
|
+
fs.readFileSync(path.join(dir, file), "utf-8"),
|
|
229
|
+
)) {
|
|
230
|
+
if (name && !out.has(name)) out.set(name, file);
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
return out;
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
/**
|
|
237
|
+
* Advisory: bkit ships a NAMED context-fetch template (e.g. `supabase` in
|
|
238
|
+
* `.bkit/templates/context/bkit-supabase.md`), this repo demonstrably runs that backend,
|
|
239
|
+
* yet the consumer section after `<!-- bkit:end -->` enables no block for it — so
|
|
240
|
+
* `/bkit-debug` fetches no runtime logs for a source the repo uses.
|
|
241
|
+
*
|
|
242
|
+
* Distinct from `context-fetch-missing` (consumer section has NO block at all): this
|
|
243
|
+
* targets PARTIAL enablement — a consumer section holding a `vercel` block while the
|
|
244
|
+
* repo also runs Supabase. The two are mutually exclusive: this one only runs once the
|
|
245
|
+
* consumer section already has at least one block.
|
|
246
|
+
*
|
|
247
|
+
* Evidence-gated: a source is flagged only when `CONTEXT_FETCH_BACKEND_EVIDENCE[name]`
|
|
248
|
+
* proves the repo runs it. A source counts as enabled when its name appears anywhere
|
|
249
|
+
* in the consumer section — a named marker (`context-fetch:start supabase`) OR an
|
|
250
|
+
* unnamed block body (`vercel logs`, `api.supabase.com`). Dismissable via
|
|
251
|
+
* `<!-- context-fetch:none ... -->` below
|
|
252
|
+
* `<!-- bkit:end -->`.
|
|
253
|
+
*/
|
|
254
|
+
export function detectContextFetchSourceNotEnabled(cwd: string): PreflightFinding | null {
|
|
255
|
+
const filePath = path.join(cwd, ".agents", "context.md");
|
|
256
|
+
if (!fs.existsSync(filePath)) return null;
|
|
257
|
+
const content = fs.readFileSync(filePath, "utf-8");
|
|
258
|
+
const endIdx = content.search(/^<!-- bkit:end -->$/m);
|
|
259
|
+
if (endIdx === -1) return null;
|
|
260
|
+
const consumer = content.slice(endIdx);
|
|
261
|
+
// Consumer opt-out marker dismisses the advisory.
|
|
262
|
+
if (contextFetchDismissesAll(consumer)) return null;
|
|
263
|
+
// Only PARTIAL enablement: when the consumer section has no block at all,
|
|
264
|
+
// `context-fetch-missing` owns that case (avoid double-firing).
|
|
265
|
+
const hasStart = parseContextFetchStarts(consumer).length > 0;
|
|
266
|
+
const hasEnd = /^<!-- context-fetch:end -->$/m.test(consumer);
|
|
267
|
+
if (!(hasStart && hasEnd)) return null;
|
|
268
|
+
const shipped = shippedContextFetchTemplates();
|
|
269
|
+
const consumerLower = consumer.toLowerCase();
|
|
270
|
+
const missing = [...shipped.keys()].filter((name) => {
|
|
271
|
+
const evidence = CONTEXT_FETCH_BACKEND_EVIDENCE[name];
|
|
272
|
+
if (!evidence || !evidence(cwd)) return false; // no proof the repo runs it
|
|
273
|
+
return !consumerLower.includes(name.toLowerCase()); // name absent below bkit:end
|
|
274
|
+
});
|
|
275
|
+
if (missing.length === 0) return null;
|
|
276
|
+
const names = missing.join(", ");
|
|
277
|
+
const slash = missing.join("/");
|
|
278
|
+
const files = missing.map((n) => `\`.bkit/templates/context/${shipped.get(n)}\``).join(", ");
|
|
279
|
+
const plural = missing.length > 1;
|
|
280
|
+
return {
|
|
281
|
+
id: "context-fetch-source-not-enabled",
|
|
282
|
+
severity: "advisory",
|
|
283
|
+
detect: `bkit ships context-fetch template${plural ? "s" : ""} for ${names} and this repo uses ${plural ? "those backends" : "that backend"}, but \`.agents/context.md\` enables no ${slash} block after \`<!-- bkit:end -->\`. \`/bkit-debug\` will fetch no ${slash} runtime logs.`,
|
|
284
|
+
action: `Copy the blocks of ${files} to after \`<!-- bkit:end -->\` in \`.agents/context.md\`, then set each block's env vars — including committing each block's non-secret selector (e.g. \`VERCEL_SCOPE\` / \`SUPABASE_PROJECT_ID\`) by uncommenting the assignment line at the top of the block, so it runs in headless cloud agents too (they never read \`.bkit/.env\`). Each block self-gates (missing CLI / token => a \`[context-fetch:<name>] skipped — …\` stderr breadcrumb, not an error). If you do not use ${slash} for runtime logs, add \`<!-- context-fetch:none intentional -->\` below \`<!-- bkit:end -->\` to dismiss. Do not edit above \`<!-- bkit:end -->\` (install rewrites it).`,
|
|
285
|
+
};
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
/**
|
|
289
|
+
* Non-stack base tools assumed present in every cloud/CI environment: POSIX
|
|
290
|
+
* utilities plus the binaries bkit's own cloud setup installs (vale, gh, jq,
|
|
291
|
+
* pnpm/corepack, node, git, python3). A context-fetch block that self-guards on one
|
|
292
|
+
* of these needs NO `context-fetch:provision` block — only a STACK CLI (vercel,
|
|
293
|
+
* supabase, gcloud, aws, wrangler, …) does; bkit installs no stack CLIs itself. `jq`
|
|
294
|
+
* is here: the cloud setup script provisions it as a base tool, not per-block.
|
|
295
|
+
*/
|
|
296
|
+
const CONTEXT_FETCH_BASE_TOOLS = new Set<string>([
|
|
297
|
+
"curl",
|
|
298
|
+
"jq",
|
|
299
|
+
"date",
|
|
300
|
+
"sed",
|
|
301
|
+
"awk",
|
|
302
|
+
"grep",
|
|
303
|
+
"egrep",
|
|
304
|
+
"fgrep",
|
|
305
|
+
"bash",
|
|
306
|
+
"sh",
|
|
307
|
+
"cat",
|
|
308
|
+
"printf",
|
|
309
|
+
"echo",
|
|
310
|
+
"tr",
|
|
311
|
+
"cut",
|
|
312
|
+
"head",
|
|
313
|
+
"tail",
|
|
314
|
+
"sort",
|
|
315
|
+
"uniq",
|
|
316
|
+
"wc",
|
|
317
|
+
"xargs",
|
|
318
|
+
"tee",
|
|
319
|
+
"node",
|
|
320
|
+
"npm",
|
|
321
|
+
"npx",
|
|
322
|
+
"pnpm",
|
|
323
|
+
"corepack",
|
|
324
|
+
"git",
|
|
325
|
+
"python3",
|
|
326
|
+
"gh",
|
|
327
|
+
"vale",
|
|
328
|
+
]);
|
|
329
|
+
|
|
330
|
+
/**
|
|
331
|
+
* Advisory: an enabled `<!-- context-fetch:start <name> -->` block self-guards on a
|
|
332
|
+
* stack CLI (`command -v <cli>`) but ships no matching `<!-- context-fetch:provision
|
|
333
|
+
* <name> -->` block below `<!-- bkit:end -->`. bkit installs no stack CLIs itself,
|
|
334
|
+
* so in cloud that CLI is absent, the block's own guard trips, and it self-skips
|
|
335
|
+
* with a silent `exit 0` — `/bkit-debug` fetches NO runtime logs for that source.
|
|
336
|
+
* Both the `.claude/bkit-cloud.md` web setup-script snapshot and
|
|
337
|
+
* `.claude/hooks/bkit-cloud-bootstrap.sh` provision from the SAME `context-fetch:provision`
|
|
338
|
+
* recipes.
|
|
339
|
+
*
|
|
340
|
+
* Keyed on the block's OWN `command -v <cli>` self-guard, so a curl/jq/API block (no
|
|
341
|
+
* stack-CLI guard) never fires; base tools
|
|
342
|
+
* (`CONTEXT_FETCH_BASE_TOOLS`) are ignored. Only NAMED start blocks are checked (a
|
|
343
|
+
* provision block is matched by name). Dismissable via `<!-- context-fetch:none ...
|
|
344
|
+
* -->` below `<!-- bkit:end -->`.
|
|
345
|
+
*/
|
|
346
|
+
export function detectContextFetchProvisionMissing(cwd: string): PreflightFinding | null {
|
|
347
|
+
const filePath = path.join(cwd, ".agents", "context.md");
|
|
348
|
+
if (!fs.existsSync(filePath)) return null;
|
|
349
|
+
const content = fs.readFileSync(filePath, "utf-8");
|
|
350
|
+
const endIdx = content.search(/^<!-- bkit:end -->$/m);
|
|
351
|
+
if (endIdx === -1) return null;
|
|
352
|
+
const consumer = content.slice(endIdx);
|
|
353
|
+
if (contextFetchDismissesAll(consumer)) return null;
|
|
354
|
+
|
|
355
|
+
// Parse the consumer section into named start / provision blocks with fenced bodies.
|
|
356
|
+
type Block = { kind: "start" | "provision"; name: string; body: string[] };
|
|
357
|
+
const blocks: Block[] = [];
|
|
358
|
+
let cur: Block | null = null;
|
|
359
|
+
let inFence = false;
|
|
360
|
+
for (const line of consumer.split("\n")) {
|
|
361
|
+
const startM = parseContextFetchStart(line);
|
|
362
|
+
const provM = /^<!-- context-fetch:provision ([\w.-]+) -->$/.exec(line);
|
|
363
|
+
if (startM) {
|
|
364
|
+
// Unnamed blocks cannot be matched to a provision sibling (which is keyed
|
|
365
|
+
// by name), so they are parked under "" and filtered out downstream.
|
|
366
|
+
cur = { kind: "start", name: startM.name, body: [] };
|
|
367
|
+
inFence = false;
|
|
368
|
+
blocks.push(cur);
|
|
369
|
+
continue;
|
|
370
|
+
}
|
|
371
|
+
if (provM) {
|
|
372
|
+
cur = { kind: "provision", name: provM[1]!, body: [] };
|
|
373
|
+
inFence = false;
|
|
374
|
+
blocks.push(cur);
|
|
375
|
+
continue;
|
|
376
|
+
}
|
|
377
|
+
if (/^<!-- context-fetch:(end|none|start|provision)/.test(line)) {
|
|
378
|
+
cur = null;
|
|
379
|
+
inFence = false;
|
|
380
|
+
continue;
|
|
381
|
+
}
|
|
382
|
+
if (cur && /^```/.test(line)) {
|
|
383
|
+
inFence = !inFence;
|
|
384
|
+
continue;
|
|
385
|
+
}
|
|
386
|
+
if (cur && inFence) cur.body.push(line);
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
const provisionNames = new Set(blocks.filter((b) => b.kind === "provision").map((b) => b.name));
|
|
390
|
+
const provisionBody = blocks
|
|
391
|
+
.filter((b) => b.kind === "provision")
|
|
392
|
+
.map((b) => b.body.join("\n"))
|
|
393
|
+
.join("\n");
|
|
394
|
+
|
|
395
|
+
// For each enabled named start block, collect the stack CLIs it self-guards on
|
|
396
|
+
// that have no provisioner (matched by same-name block OR a provision body that
|
|
397
|
+
// installs that CLI). First-seen order; one entry per block name.
|
|
398
|
+
const seen = new Set<string>();
|
|
399
|
+
const items: string[] = [];
|
|
400
|
+
let firstName = "";
|
|
401
|
+
let firstCli = "";
|
|
402
|
+
for (const b of blocks) {
|
|
403
|
+
// Unnamed blocks are skipped: a provision sibling is matched by name.
|
|
404
|
+
if (b.kind !== "start" || !b.name || seen.has(b.name)) continue;
|
|
405
|
+
const body = b.body.join("\n");
|
|
406
|
+
for (const m of body.matchAll(/command -v ([\w.-]+)/g)) {
|
|
407
|
+
const cli = m[1]!;
|
|
408
|
+
if (CONTEXT_FETCH_BASE_TOOLS.has(cli)) continue;
|
|
409
|
+
if (provisionNames.has(b.name) || provisionBody.includes(cli)) continue;
|
|
410
|
+
seen.add(b.name);
|
|
411
|
+
items.push(`${b.name} (\`${cli}\`)`);
|
|
412
|
+
if (!firstName) {
|
|
413
|
+
firstName = b.name;
|
|
414
|
+
firstCli = cli;
|
|
415
|
+
}
|
|
416
|
+
break;
|
|
417
|
+
}
|
|
418
|
+
}
|
|
419
|
+
if (items.length === 0) return null;
|
|
420
|
+
|
|
421
|
+
const list = items.join(", ");
|
|
422
|
+
const plural = items.length > 1;
|
|
423
|
+
return {
|
|
424
|
+
id: "context-fetch-provision-missing",
|
|
425
|
+
severity: "advisory",
|
|
426
|
+
detect: `\`.agents/context.md\` enable${plural ? "" : "s"} context-fetch block${plural ? "s" : ""} that self-guard${plural ? "" : "s"} on a stack CLI but ship${plural ? "" : "s"} no matching \`<!-- context-fetch:provision <name> -->\` block below \`<!-- bkit:end -->\`: ${list}. bkit installs no stack CLIs itself, so in cloud the CLI is absent, the block's own \`command -v\` guard trips, and it self-skips (silent \`exit 0\`) — \`/bkit-debug\` fetches no runtime logs for ${plural ? "those sources" : "that source"} (reads as "clean", not "not wired up").`,
|
|
427
|
+
action: `For each flagged block, add a sibling \`<!-- context-fetch:provision <name> -->\` block below \`<!-- bkit:end -->\` — SAME name as the fetch block — whose bash body installs the CLI, self-guarded and install-only: \`command -v ${firstCli} >/dev/null 2>&1 || <install ${firstCli}>\` (e.g. \`pnpm add -g ${firstCli}\` for an npm-published CLI). If \`.bkit/templates/context/\` ships a ready-made \`context-fetch:provision ${firstName}\` recipe, copy that. Then re-run \`bkit install\` so the recipe bakes into \`.claude/bkit-cloud.md\`'s setup script; \`.claude/hooks/bkit-cloud-bootstrap.sh\` runs the same recipe on gh-runner / resumed sessions. A block that fetches via an MCP tool or only universal tools (curl/jq/date) needs no provision.`,
|
|
428
|
+
};
|
|
429
|
+
}
|