@cbartens/bkit 6.0.0 → 6.1.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 +154 -151
- package/.bkit/core/.agents/context.md +95 -29
- package/.bkit/core/.agents/docs.md +17 -15
- package/.bkit/core/.agents/plugins/bkit/hooks/bkit-gateguard.cjs +1 -0
- package/.bkit/core/.agents/plugins/bkit/hooks/bkit-guardrails.cjs +6 -5
- package/.bkit/core/.agents/plugins/bkit/hooks/bkit-readguard.cjs +1 -0
- package/.bkit/core/.agents/plugins/bkit/hooks/bkit-rules.cjs +65 -0
- package/.bkit/core/.agents/rules.md +108 -107
- package/.bkit/core/.agents/skills.md +63 -15
- package/.bkit/core/.bkit/README.md +154 -151
- package/.bkit/core/.bkit/authoring.md +714 -84
- package/.bkit/core/.bkit/cli.md +407 -0
- package/.bkit/core/.bkit/cloud.md +281 -193
- package/.bkit/core/.bkit/comparison.md +43 -41
- package/.bkit/core/.bkit/install.md +154 -84
- package/.bkit/core/.bkit/jsonl.md +193 -130
- package/.bkit/core/.bkit/pipeline.md +114 -114
- package/.bkit/core/.bkit/prompts.md +272 -165
- package/.bkit/core/.bkit/providers.md +457 -271
- package/.bkit/core/.bkit/router.md +69 -0
- package/.bkit/core/.bkit/templates.md +529 -256
- package/.bkit/core/.bkit/trackers.md +80 -52
- package/.bkit/core/.bkit/workflows.md +589 -504
- package/.bkit/core/.claude/hooks/bkit-gateguard.cjs +2 -2
- package/.bkit/core/.claude/hooks/bkit-guardrails.cjs +3 -3
- package/.bkit/core/.claude/hooks/bkit-preflight.sh +45 -14
- package/.bkit/core/.codex/hooks/bkit-guardrails.cjs +3 -3
- package/.bkit/core/.codex/hooks/bkit-rules.cjs +57 -0
- package/.bkit/core/.cursor/hooks/bkit-guardrails.cjs +7 -7
- package/.bkit/core/.cursor/hooks/bkit-preflight.sh +47 -12
- package/.bkit/core/.opencode/plugin/bkit-rules.js +89 -0
- package/.bkit/core/AGENTS.md +5 -73
- package/.bkit/core/docs/templates/bkit-audit-accessibility.md +127 -105
- package/.bkit/core/docs/templates/bkit-audit-adoption.md +104 -70
- package/.bkit/core/docs/templates/bkit-audit-agents.md +94 -72
- package/.bkit/core/docs/templates/bkit-audit-aio-seo.md +99 -78
- package/.bkit/core/docs/templates/bkit-audit-analytics.md +140 -82
- package/.bkit/core/docs/templates/bkit-audit-annotations.md +98 -72
- package/.bkit/core/docs/templates/bkit-audit-app-performance.md +121 -96
- package/.bkit/core/docs/templates/bkit-audit-app-store.md +157 -76
- package/.bkit/core/docs/templates/bkit-audit-architecture.md +113 -71
- package/.bkit/core/docs/templates/bkit-audit-ci-performance.md +75 -72
- package/.bkit/core/docs/templates/bkit-audit-config.md +122 -76
- package/.bkit/core/docs/templates/bkit-audit-cost.md +85 -74
- package/.bkit/core/docs/templates/bkit-audit-coverage.md +75 -68
- package/.bkit/core/docs/templates/bkit-audit-database.md +101 -70
- package/.bkit/core/docs/templates/bkit-audit-dead-code.md +164 -83
- package/.bkit/core/docs/templates/bkit-audit-deferrals.md +115 -86
- package/.bkit/core/docs/templates/bkit-audit-dependencies.md +264 -88
- package/.bkit/core/docs/templates/bkit-audit-documentation.md +118 -93
- package/.bkit/core/docs/templates/bkit-audit-duplication.md +139 -86
- package/.bkit/core/docs/templates/bkit-audit-failures.md +110 -81
- package/.bkit/core/docs/templates/bkit-audit-flakes.md +99 -74
- package/.bkit/core/docs/templates/bkit-audit-gates.md +105 -77
- package/.bkit/core/docs/templates/bkit-audit-issues.md +104 -80
- package/.bkit/core/docs/templates/bkit-audit-llm.md +131 -58
- package/.bkit/core/docs/templates/bkit-audit-logs.md +123 -100
- package/.bkit/core/docs/templates/bkit-audit-models.md +98 -53
- package/.bkit/core/docs/templates/bkit-audit-privacy.md +56 -52
- package/.bkit/core/docs/templates/bkit-audit-prompts.md +63 -54
- package/.bkit/core/docs/templates/bkit-audit-red-team.md +124 -68
- package/.bkit/core/docs/templates/bkit-audit-reliability.md +95 -70
- package/.bkit/core/docs/templates/bkit-audit-repo.md +169 -73
- package/.bkit/core/docs/templates/bkit-audit-security.md +206 -96
- package/.bkit/core/docs/templates/bkit-audit-slop.md +77 -70
- package/.bkit/core/docs/templates/bkit-audit-testing.md +162 -114
- package/.bkit/core/docs/templates/bkit-audit-usability.md +113 -71
- package/.bkit/core/docs/templates/bkit-plan.md +138 -132
- package/.bkit/core/engine/checks/after/auth.ts +40 -37
- package/.bkit/core/engine/checks/after/ci-yml.ts +65 -2
- package/.bkit/core/engine/checks/after/index.ts +12 -2
- package/.bkit/core/engine/checks/after/tools.ts +80 -33
- package/.bkit/core/engine/checks/before/context-fetch.ts +227 -33
- package/.bkit/core/engine/checks/before/env.ts +1 -1
- package/.bkit/core/engine/checks/before/index.ts +7 -0
- package/.bkit/core/engine/checks/before/repo.ts +40 -0
- package/.bkit/core/engine/checks/status-holes.ts +916 -123
- package/.bkit/core/engine/checks/tips/catalogue.ts +68 -17
- package/.bkit/core/engine/checks/tips/detect.ts +32 -0
- package/.bkit/core/engine/checks/tips/index.ts +47 -6
- package/.bkit/core/engine/cli.ts +238 -84
- package/.bkit/core/engine/commands/analysis.ts +128 -76
- package/.bkit/core/engine/commands/ci/ci.ts +363 -29
- package/.bkit/core/engine/commands/ci/pins.ts +172 -0
- package/.bkit/core/engine/commands/ci/push-gate.ts +223 -0
- package/.bkit/core/engine/commands/install/uninstall.ts +21 -27
- package/.bkit/core/engine/commands/install/upgrade.ts +32 -15
- package/.bkit/core/engine/commands/land.ts +126 -11
- package/.bkit/core/engine/commands/lib.ts +303 -6
- package/.bkit/core/engine/commands/registry.ts +6 -2
- package/.bkit/core/engine/commands/setup/setup.ts +1 -0
- package/.bkit/core/engine/commands/stats.ts +91 -35
- package/.bkit/core/engine/commands/workflow/branches.ts +1477 -117
- package/.bkit/core/engine/commands/workflow/challenge.ts +114 -39
- package/.bkit/core/engine/commands/workflow/completeness.ts +109 -0
- package/.bkit/core/engine/commands/workflow/context.ts +433 -55
- package/.bkit/core/engine/commands/workflow/counters.ts +244 -39
- package/.bkit/core/engine/commands/workflow/decisions.ts +61 -17
- package/.bkit/core/engine/commands/workflow/disk.ts +237 -55
- package/.bkit/core/engine/commands/workflow/fids.ts +19 -1
- package/.bkit/core/engine/commands/workflow/issues.ts +6 -0
- package/.bkit/core/engine/commands/workflow/ledgers.ts +458 -18
- package/.bkit/core/engine/commands/workflow/locks.ts +2 -0
- package/.bkit/core/engine/commands/workflow/plan-blocks.ts +124 -15
- package/.bkit/core/engine/commands/workflow/plans.ts +257 -0
- package/.bkit/core/engine/commands/workflow/prs.ts +12 -3
- package/.bkit/core/engine/commands/workflow/repo.ts +8 -0
- package/.bkit/core/engine/commands/workflow/roadmap.ts +56 -15
- package/.bkit/core/engine/commands/workflow/run-facts.ts +22 -31
- package/.bkit/core/engine/commands/workflow/runs.ts +652 -34
- package/.bkit/core/engine/commands/workflow/runtime.ts +3 -0
- package/.bkit/core/engine/commands/workflow/skills.ts +1 -0
- package/.bkit/core/engine/commands/workflow/status.ts +200 -17
- package/.bkit/core/engine/commands/workflow/step-table.ts +75 -33
- package/.bkit/core/engine/commands/workflow/steps.ts +635 -24
- package/.bkit/core/engine/commands/workflow/summary-findings.ts +177 -0
- package/.bkit/core/engine/commands/workflow/summary.ts +192 -46
- package/.bkit/core/engine/commands/workflow/tasks.ts +409 -0
- package/.bkit/core/engine/commands/workflow/test-blocks.ts +254 -0
- package/.bkit/core/engine/commands/workflow/tests-changed.ts +201 -0
- package/.bkit/core/engine/commands/workflow/tests.ts +1285 -356
- package/.bkit/core/engine/commands/workflow/workflows.ts +228 -43
- package/.bkit/core/engine/commands/workflow/worktrees.ts +389 -47
- package/.bkit/core/engine/install/cloud-env.ts +251 -121
- package/.bkit/core/engine/install/context-ci-workflow.ts +102 -0
- package/.bkit/core/engine/install/manifest.ts +60 -12
- package/.bkit/core/engine/install/modules/antigravity.ts +3 -2
- package/.bkit/core/engine/install/modules/cloud.ts +3 -3
- package/.bkit/core/engine/install/modules/codex.ts +15 -2
- package/.bkit/core/engine/install/modules/core.ts +956 -52
- package/.bkit/core/engine/install/modules/cursor.ts +6 -6
- package/.bkit/core/engine/install/modules/opencode.ts +16 -4
- package/.bkit/core/engine/install/template-notes.ts +130 -0
- package/.bkit/core/engine/install/version-file.ts +3 -2
- package/.bkit/core/engine/install/write.ts +5 -0
- package/.bkit/core/engine/ledgers/compact.ts +124 -0
- package/.bkit/core/engine/ledgers/journal.ts +291 -0
- package/.bkit/core/engine/ledgers/status.ts +160 -9
- package/.bkit/core/engine/ledgers/telemetry.ts +158 -21
- package/.bkit/core/engine/render/hosts.ts +114 -14
- package/.bkit/core/engine/shared/bkit-latest.ts +26 -4
- package/.bkit/core/engine/shared/dep-updater.ts +60 -0
- package/.bkit/core/engine/shared/egress.ts +1 -1
- package/.bkit/core/engine/shared/package-manager.ts +9 -0
- package/.bkit/core/engine/shared/settings.ts +92 -17
- package/.bkit/core/engine/shared/timeouts.ts +2 -0
- package/.bkit/core/engine/tools/cli-doc.ts +111 -0
- package/.bkit/core/engine/tools/grammar-density.ts +1 -1
- package/.bkit/core/engine/tools/instructions-sources.ts +15 -17
- package/.bkit/core/engine/tools/instructions.ts +94 -43
- package/.bkit/core/hooks/antigravity-hook.js +25 -10
- package/.bkit/core/hooks/gateguard-engine.js +53 -29
- package/.bkit/core/hooks/guardrails-shell.js +4 -4
- package/.bkit/core/hooks/guardrails-tiers.js +3 -3
- package/.bkit/core/hooks/preflight-linear.sh +9 -9
- package/.bkit/core/hooks/preflight-rules.sh +8 -0
- package/.bkit/core/hooks/readguard-engine.js +29 -10
- package/.bkit/core/hooks/session-rules-advisory.js +61 -0
- package/.bkit/core/prompts/bkit-audit-generate.md +187 -116
- package/.bkit/core/prompts/bkit-build-challenge-1.md +56 -37
- package/.bkit/core/prompts/bkit-build-challenge-2.md +65 -45
- package/.bkit/core/prompts/bkit-build-install-skills.md +38 -29
- package/.bkit/core/prompts/bkit-build-plan-convert.md +43 -32
- package/.bkit/core/prompts/bkit-build-plan-current.md +49 -39
- package/.bkit/core/prompts/bkit-build-plan-gaps-remediate.md +79 -55
- package/.bkit/core/prompts/bkit-build-plan-tasks.md +149 -0
- package/.bkit/core/prompts/bkit-build-plan-tests.md +120 -0
- package/.bkit/core/prompts/bkit-build-plan-verify.md +87 -50
- package/.bkit/core/prompts/bkit-debug-abort-handover.md +36 -35
- package/.bkit/core/prompts/bkit-debug-failure-diagnose.md +96 -64
- package/.bkit/core/prompts/bkit-debug-failure-remediate.md +54 -45
- package/.bkit/core/prompts/bkit-debug-failure-reproduce.md +42 -33
- package/.bkit/core/prompts/bkit-debug-failure-soak.md +53 -37
- package/.bkit/core/prompts/bkit-design-brainstorm-ideate-1.md +35 -30
- package/.bkit/core/prompts/bkit-design-brainstorm-ideate-2.md +34 -29
- package/.bkit/core/prompts/bkit-design-brainstorm-ideate-3.md +32 -28
- package/.bkit/core/prompts/bkit-design-generate.md +68 -52
- package/.bkit/core/prompts/bkit-design-organise.md +73 -35
- package/.bkit/core/prompts/bkit-design-review-1.md +58 -54
- package/.bkit/core/prompts/bkit-design-review-2.md +54 -50
- package/.bkit/core/prompts/bkit-design-spike.md +54 -47
- package/.bkit/core/prompts/bkit-design-update.md +42 -31
- package/.bkit/core/prompts/bkit-plan-generate.md +76 -58
- package/.bkit/core/prompts/bkit-plan-review-1.md +63 -49
- package/.bkit/core/prompts/bkit-plan-review-2.md +60 -48
- package/.bkit/core/prompts/bkit-plan-scope-check.md +53 -46
- package/.bkit/core/prompts/bkit-plan-update.md +70 -52
- package/.bkit/core/prompts/bkit-ship-conflict-resolve.md +82 -50
- package/.bkit/core/prompts/bkit-ship-deferred-sweep.md +80 -45
- package/.bkit/core/prompts/bkit-ship-update-docs.md +35 -29
- package/.bkit/core/prompts/bkit-utility-compress-markdown.md +55 -49
- package/.bkit/core/prompts/bkit-utility-update-decisions.md +76 -49
- package/.bkit/core/prompts/bkit-utility-update-deferrals.md +70 -41
- package/.bkit/core/prompts/bkit-utility-update-documentation.md +33 -30
- package/.bkit/core/prompts/bkit-utility-update-failures.md +73 -43
- package/.bkit/core/prompts/bkit-utility-update-knowledge.md +77 -50
- package/.bkit/core/prompts/bkit-utility-update-roadmap.md +77 -45
- package/.bkit/core/prompts/bkit-utility-update-tracker.md +144 -68
- package/.bkit/core/workflows/bkit-auto.md +53 -30
- package/.bkit/core/workflows/bkit-build.md +635 -304
- package/.bkit/core/workflows/bkit-debug.md +301 -148
- package/.bkit/core/workflows/bkit-design.md +167 -95
- package/.bkit/core/workflows/bkit-plan.md +172 -84
- package/.bkit/core/workflows/bkit-ship.md +299 -152
- package/.bkit/shared/.agents/plugins/bkit/hooks.json +10 -0
- package/.bkit/shared/.claude/bkit-cloud.md +12 -10
- package/.bkit/shared/.claude/settings.json +3 -0
- package/.bkit/shared/.codex/bkit-cloud.md +98 -0
- package/.bkit/shared/.codex/hooks.json +20 -0
- package/.bkit/shared/.cursor/bkit-cloud.md +3 -3
- package/.bkit/shared/.opencode/opencode.json +1 -1
- package/.bkit/shared/CLAUDE.md +5 -1
- package/.bkit/shared/GEMINI.md +4 -1
- package/.bkit/shared/docs/architecture.md +4 -7
- package/.bkit/shared/docs/data-schema.md +4 -7
- package/.bkit/shared/docs/deployments.md +239 -166
- package/.bkit/shared/docs/design.md +11 -12
- package/.bkit/shared/docs/noise.md +8 -7
- package/.bkit/shared/docs/observability.md +5 -8
- package/.bkit/shared/docs/security.md +35 -17
- package/.bkit/shared/docs/setup.md +29 -18
- package/.bkit/shared/docs/technology.md +3 -6
- package/.bkit/shared/docs/testing.md +282 -176
- package/.bkit/shared/gitignore +6 -2
- package/.bkit/templates/.claude/hooks/bkit-cloud-bootstrap.sh +15 -16
- package/.bkit/templates/.cursor/Dockerfile +12 -8
- package/.bkit/templates/.cursor/environment.json +1 -1
- package/.bkit/templates/.github/ISSUE_TEMPLATE/bkit-bug.yml +10 -8
- package/.bkit/templates/.github/ISSUE_TEMPLATE/bkit-change.yml +24 -12
- package/.bkit/templates/.github/ISSUE_TEMPLATE/bkit-idea.yml +3 -3
- package/.bkit/templates/.github/renovate.json5 +34 -6
- package/.bkit/templates/.github/workflows/bkit-ci.yml +53 -50
- package/.bkit/templates/.github/workflows/bkit-cloud.yml +13 -14
- package/.bkit/templates/.github/workflows/bkit-health.yml +97 -0
- package/.bkit/templates/.github/workflows/bkit-renovate.yml +5 -4
- package/.bkit/templates/.github/workflows/bkit-trivy.yml +5 -4
- package/.bkit/templates/.husky/pre-commit +2 -2
- package/.bkit/templates/.husky/pre-push +95 -35
- package/.bkit/templates/.prettierignore +6 -7
- package/.bkit/templates/.vale.ini +27 -27
- package/.bkit/templates/context/bkit-cloudrun.md +23 -15
- package/.bkit/templates/context/bkit-expo.md +70 -52
- package/.bkit/templates/context/bkit-github.md +93 -56
- package/.bkit/templates/context/bkit-inngest.md +21 -15
- package/.bkit/templates/context/bkit-maestro.md +22 -16
- package/.bkit/templates/context/bkit-playwright.md +23 -17
- package/.bkit/templates/context/bkit-resend.md +12 -10
- package/.bkit/templates/context/bkit-sentry.md +30 -20
- package/.bkit/templates/context/bkit-serena.md +8 -7
- package/.bkit/templates/context/bkit-stripe.md +14 -13
- package/.bkit/templates/context/bkit-supabase.md +16 -13
- package/.bkit/templates/context/bkit-tavily.md +14 -11
- package/.bkit/templates/context/bkit-vercel.md +27 -18
- package/.bkit/templates/docs/capabilities.md +15 -14
- package/.bkit/templates/scripts/ci/{check-accepted-divergences.mjs → bkit-check-accepted-divergences.mjs} +6 -3
- package/.bkit/templates/scripts/ci/{check-accepted-divergences.test.mjs → bkit-check-accepted-divergences.test.mjs} +3 -3
- package/.bkit/templates/scripts/ci/{check-capstone.mjs → bkit-check-capstone.mjs} +2 -2
- package/.bkit/templates/scripts/ci/{check-capstone.test.mjs → bkit-check-capstone.test.mjs} +4 -4
- package/.bkit/templates/scripts/ci/{check-dependency-audit.mjs → bkit-check-dependency-audit.mjs} +103 -18
- package/.bkit/templates/scripts/ci/{check-dependency-audit.test.mjs → bkit-check-dependency-audit.test.mjs} +31 -3
- package/.bkit/templates/scripts/ci/bkit-machine-lock.sh +387 -0
- package/.bkit/templates/scripts/ci/bkit-test-awake.mjs +75 -0
- package/.bkit/templates/scripts/ci/bkit-test-awake.test.mjs +160 -0
- package/.bkit/templates/scripts/ci/lanes/{resolve-push-base.mjs → bkit-resolve-push-base.mjs} +3 -3
- package/.bkit/templates/scripts/ci/lanes/{resolve-push-base.test.mjs → bkit-resolve-push-base.test.mjs} +4 -4
- package/.bkit/templates/scripts/cleanup/bkit-disk-prune.mjs +9 -1
- package/.bkit/templates/scripts/graphify/bkit-graph-drift.py +1 -1
- package/.bkit/templates/scripts/graphify/bkit-graph-eager.py +3 -3
- package/.bkit/templates/scripts/graphify/bkit-graph-embed.py +63 -0
- package/.bkit/templates/scripts/graphify/bkit-graph-imports.py +2 -2
- package/.bkit/templates/scripts/graphify/bkit-graph-pre-push.sh +69 -18
- package/.bkit/templates/scripts/graphify/bkit-graph-repair.py +3 -3
- package/.bkit/templates/scripts/graphify/bkit-graph-surface.py +1 -1
- package/.bkit/templates/scripts/graphify/bkit-graphify-graphml.py +1 -1
- package/.bkit/templates/scripts/graphify/bkit-graphify-rollup.py +197 -126
- package/.bkit/templates/scripts/graphify/bkit-graphify.sh +64 -41
- package/.bkit/templates/scripts/slop/bkit-slop-type-suppression.mjs +23 -7
- package/.bkit/templates/slop-scan.config.json +9 -2
- package/CHANGELOG.md +119 -0
- package/README.md +250 -76
- package/dist/checks/after/auth.js +36 -33
- package/dist/checks/after/ci-yml.js +52 -2
- package/dist/checks/after/index.js +12 -4
- package/dist/checks/after/tools.js +73 -33
- package/dist/checks/before/context-fetch.js +218 -33
- package/dist/checks/before/env.js +1 -1
- package/dist/checks/before/index.js +6 -2
- package/dist/checks/before/repo.js +35 -1
- package/dist/checks/status-holes.js +739 -114
- package/dist/checks/tips/catalogue.js +59 -17
- package/dist/checks/tips/detect.js +30 -0
- package/dist/checks/tips/index.js +48 -6
- package/dist/cli.js +222 -84
- package/dist/commands/analysis.js +77 -53
- package/dist/commands/ci/ci.js +302 -25
- package/dist/commands/ci/pins.js +142 -0
- package/dist/commands/ci/push-gate.js +194 -0
- package/dist/commands/install/uninstall.js +23 -27
- package/dist/commands/install/upgrade.js +21 -11
- package/dist/commands/land.js +126 -10
- package/dist/commands/lib.js +244 -5
- package/dist/commands/registry.js +6 -2
- package/dist/commands/setup/setup.js +1 -0
- package/dist/commands/stats.js +69 -30
- package/dist/commands/workflow/branches.js +1232 -111
- package/dist/commands/workflow/challenge.js +90 -37
- package/dist/commands/workflow/completeness.js +97 -0
- package/dist/commands/workflow/context.js +371 -51
- package/dist/commands/workflow/counters.js +206 -40
- package/dist/commands/workflow/decisions.js +60 -17
- package/dist/commands/workflow/disk.js +213 -55
- package/dist/commands/workflow/fids.js +18 -1
- package/dist/commands/workflow/issues.js +6 -0
- package/dist/commands/workflow/ledgers.js +372 -21
- package/dist/commands/workflow/locks.js +2 -0
- package/dist/commands/workflow/plan-blocks.js +78 -14
- package/dist/commands/workflow/plans.js +205 -0
- package/dist/commands/workflow/prs.js +12 -3
- package/dist/commands/workflow/repo.js +6 -0
- package/dist/commands/workflow/roadmap.js +50 -17
- package/dist/commands/workflow/run-facts.js +23 -28
- package/dist/commands/workflow/runs.js +530 -33
- package/dist/commands/workflow/runtime.js +3 -0
- package/dist/commands/workflow/skills.js +1 -0
- package/dist/commands/workflow/status.js +166 -19
- package/dist/commands/workflow/step-table.js +61 -29
- package/dist/commands/workflow/steps.js +542 -26
- package/dist/commands/workflow/summary-findings.js +117 -0
- package/dist/commands/workflow/summary.js +154 -41
- package/dist/commands/workflow/tasks.js +378 -0
- package/dist/commands/workflow/test-blocks.js +231 -0
- package/dist/commands/workflow/tests-changed.js +172 -0
- package/dist/commands/workflow/tests.js +1013 -321
- package/dist/commands/workflow/workflows.js +191 -38
- package/dist/commands/workflow/worktrees.js +310 -42
- package/dist/install/cloud-env.js +233 -99
- package/dist/install/context-ci-workflow.js +85 -0
- package/dist/install/manifest.js +57 -12
- package/dist/install/modules/antigravity.js +3 -2
- package/dist/install/modules/cloud.js +3 -3
- package/dist/install/modules/codex.js +12 -2
- package/dist/install/modules/core.js +851 -53
- package/dist/install/modules/cursor.js +6 -6
- package/dist/install/modules/opencode.js +11 -5
- package/dist/install/template-notes.js +116 -0
- package/dist/install/version-file.js +3 -2
- package/dist/ledgers/compact.js +87 -0
- package/dist/ledgers/journal.js +233 -0
- package/dist/ledgers/status.js +115 -5
- package/dist/ledgers/telemetry.js +121 -17
- package/dist/render/hosts.js +100 -14
- package/dist/shared/bkit-latest.js +26 -4
- package/dist/shared/dep-updater.js +49 -0
- package/dist/shared/egress.js +1 -1
- package/dist/shared/package-manager.js +6 -0
- package/dist/shared/settings.js +59 -10
- package/dist/shared/timeouts.js +2 -0
- package/dist/tools/cli-doc.js +97 -0
- package/dist/tools/grammar-density.js +1 -1
- package/dist/tools/instructions-sources.js +15 -16
- package/dist/tools/instructions.js +83 -39
- package/package.json +58 -42
- package/.bkit/core/.bkit/lite.md +0 -73
- package/.bkit/core/engine/commands/workflow/workstreams.ts +0 -172
- package/.bkit/core/prompts/bkit-build-plan-execute.md +0 -124
- package/.bkit/templates/scripts/ci/bkit-local-stack-lock.sh +0 -194
- package/dist/commands/workflow/workstreams.js +0 -149
- /package/.bkit/templates/.vale/styles/{House → Bkit}/Filler.yml +0 -0
- /package/.bkit/templates/.vale/styles/{House → Bkit}/Hedging.yml +0 -0
- /package/.bkit/templates/.vale/styles/{House → Bkit}/LLMSlop.yml +0 -0
- /package/.bkit/templates/.vale/styles/{House → Bkit}/Verbose.yml +0 -0
- /package/.bkit/templates/scripts/ci/{accepted-advisories.json → bkit-accepted-advisories.json} +0 -0
- /package/.bkit/templates/scripts/ci/{accepted-divergences.json → bkit-accepted-divergences.json} +0 -0
- /package/.bkit/templates/scripts/launchd/{launchd.env.example → bkit-launchd.env.example} +0 -0
- /package/.bkit/templates/scripts/launchd/{ai.bkit.launchd.plist → bkit-launchd.plist} +0 -0
package/dist/commands/ci/ci.js
CHANGED
|
@@ -1,30 +1,43 @@
|
|
|
1
1
|
// bkit ci — the gates CI and the git hooks run.
|
|
2
2
|
//
|
|
3
|
-
// `slop` — the enforcing slop gate (`slop:delta`). `lint:slop` (`slop-scan scan`) only
|
|
3
|
+
// `slop` — the enforcing slop gate (`bkit:slop:delta`). `lint:slop` (`slop-scan scan`) only
|
|
4
4
|
// reports. This gate checks the base ref out as a detached worktree, runs
|
|
5
5
|
// `slop-scan delta` against the working tree, and fails when the change makes the repo
|
|
6
6
|
// worse on NET: more findings, or a higher score. It gates on the net figures, not on
|
|
7
7
|
// "added": slop-scan's delta is keyed by position, so editing above a pre-existing
|
|
8
8
|
// finding reports it as resolved at the old line and added at the new one, netting to
|
|
9
|
-
// zero. The pre-existing baseline is never the change's to fix.
|
|
9
|
+
// zero. The pre-existing baseline is never the change's to fix. On failure it names each
|
|
10
|
+
// net-new or worsened finding (`path:line`, rule, message), with line shifts dropped.
|
|
10
11
|
//
|
|
11
|
-
// `prose` — the prose gate (`lint:prose`): Vale over the markdown files the globs
|
|
12
|
-
// select.
|
|
13
|
-
//
|
|
12
|
+
// `prose` — the prose gate (`bkit:lint:prose`): Vale over the markdown files the globs
|
|
13
|
+
// select. Restores the gitignored write-good package from the main worktree (else
|
|
14
|
+
// `vale sync`) when it is missing, and fails when vale or write-good is unavailable.
|
|
14
15
|
//
|
|
15
16
|
// `skip-token` — whether a commit message carries a GitHub skip-CI token
|
|
16
17
|
// (`SKIP_CI_TOKEN`), for the `.husky/pre-push` CI-suppressor guard.
|
|
17
18
|
//
|
|
18
|
-
// `min-push` — whether every file a push changes
|
|
19
|
+
// `min-push` — whether every file a push changes is one bkit's workflows write (ship's bookkeeping
|
|
20
|
+
// allow-list, the plans tree) or one `bkit.testing.minPushPaths` / `ciSkipPaths` adds, so
|
|
19
21
|
// `.husky/pre-push` runs `bkit:gate:min`. Files decide, never `[skip ci]` (a typed label
|
|
20
22
|
// GitHub reads off the last commit only).
|
|
23
|
+
//
|
|
24
|
+
// `bookkeeping-push` — whether a feature-branch push adds bookkeeping only on top of the
|
|
25
|
+
// head the remote holds (ship's `--scope=pr` allow-list, the one `bkit ledgers
|
|
26
|
+
// only-bookkeeping` and the merge gate's carry-forward read). The `.husky/pre-push`
|
|
27
|
+
// CI-suppressor guard lets a `[skip ci]` head through to an open PR on exit 0: the PR's
|
|
28
|
+
// checks at the remote head still cover every line of code.
|
|
29
|
+
//
|
|
30
|
+
// `pins` — downloads each `*_VERSION` + `*_SHA256` pinned tool the files name and checks
|
|
31
|
+
// the hash, so a version-only Renovate bump goes red in its own PR (`pins.ts`).
|
|
21
32
|
import { spawnSync } from "node:child_process";
|
|
22
33
|
import * as fs from "node:fs";
|
|
23
34
|
import * as os from "node:os";
|
|
24
35
|
import * as path from "node:path";
|
|
25
36
|
import { readBkitConfig } from "../../shared/settings.js";
|
|
26
37
|
import { CommandError, commitMessage, EXIT, git, parseJson, runGit, SKIP_CI_TOKEN, } from "../lib.js";
|
|
27
|
-
import { changedOutside } from "../workflow/ledgers.js";
|
|
38
|
+
import { bookPathspecs, changedOutside, checkOnlyBookkeeping, globPathspecs, } from "../workflow/ledgers.js";
|
|
39
|
+
import { pins } from "./pins.js";
|
|
40
|
+
import { hasVerifiedIncrement, runPushGate } from "./push-gate.js";
|
|
28
41
|
/** Exit code: slop-scan could not be started (not installed, not executable). */
|
|
29
42
|
export const EXIT_SLOP_UNAVAILABLE = 3;
|
|
30
43
|
/** Exit code: slop-scan ran but failed, or its JSON lacks the fields the gate reads. */
|
|
@@ -104,6 +117,70 @@ export function readSummary(raw) {
|
|
|
104
117
|
return out;
|
|
105
118
|
}
|
|
106
119
|
export const gateFails = (s) => s.netFindingCount > 0 || s.netRepoScore > SCORE_EPSILON;
|
|
120
|
+
const asArray = (v) => (Array.isArray(v) ? v : []);
|
|
121
|
+
function toFinding(status, c) {
|
|
122
|
+
const loc = c.head?.primaryLocation ?? c.head?.locations?.[0];
|
|
123
|
+
return {
|
|
124
|
+
status,
|
|
125
|
+
path: typeof c.path === "string" ? c.path : null,
|
|
126
|
+
line: typeof loc?.line === "number" ? loc.line : null,
|
|
127
|
+
ruleId: String(c.ruleId),
|
|
128
|
+
message: typeof c.head?.message === "string" ? c.head.message : "",
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* The net-new and worsened findings in a `slop-scan delta --json` report. Grouped by file
|
|
133
|
+
* and rule: a group that resolves as many as it adds is a line shift and is dropped; in a
|
|
134
|
+
* group that adds more, each resolved finding cancels one added finding with the same
|
|
135
|
+
* message, and the rest are listed. Empty when the report carries no change lists.
|
|
136
|
+
*/
|
|
137
|
+
export function netNewFindings(raw) {
|
|
138
|
+
const parsed = parseJson(raw);
|
|
139
|
+
if (!parsed.ok)
|
|
140
|
+
return [];
|
|
141
|
+
const report = parsed.value;
|
|
142
|
+
const changes = [
|
|
143
|
+
...asArray(report?.paths).flatMap((p) => asArray(p?.changes)),
|
|
144
|
+
...asArray(report?.repoChanges),
|
|
145
|
+
];
|
|
146
|
+
const groups = new Map();
|
|
147
|
+
const findings = [];
|
|
148
|
+
for (const c of changes) {
|
|
149
|
+
if (c.status === "worsened")
|
|
150
|
+
findings.push(toFinding("worsened", c));
|
|
151
|
+
if (c.status !== "added" && c.status !== "resolved")
|
|
152
|
+
continue;
|
|
153
|
+
const key = `${String(c.path)}\0${String(c.ruleId)}`;
|
|
154
|
+
const group = groups.get(key) ?? { added: [], resolved: [] };
|
|
155
|
+
groups.set(key, group);
|
|
156
|
+
group[c.status].push(c);
|
|
157
|
+
}
|
|
158
|
+
for (const { added, resolved } of groups.values()) {
|
|
159
|
+
if (added.length <= resolved.length)
|
|
160
|
+
continue;
|
|
161
|
+
const left = [...added];
|
|
162
|
+
for (const r of resolved) {
|
|
163
|
+
const i = left.findIndex((a) => a.head?.message === r.base?.message);
|
|
164
|
+
if (i >= 0)
|
|
165
|
+
left.splice(i, 1);
|
|
166
|
+
}
|
|
167
|
+
findings.push(...left.map((c) => toFinding("added", c)));
|
|
168
|
+
}
|
|
169
|
+
return findings;
|
|
170
|
+
}
|
|
171
|
+
/** One log line per finding: status, `path:line`, rule, message. */
|
|
172
|
+
export function formatFindings(findings) {
|
|
173
|
+
if (findings.length === 0) {
|
|
174
|
+
return ["slop-scan's report names no single net-new finding; the rise is spread across files."];
|
|
175
|
+
}
|
|
176
|
+
return [
|
|
177
|
+
"Net-new / worsened findings:",
|
|
178
|
+
...findings.map((f) => {
|
|
179
|
+
const where = `${f.path ?? "(repo)"}${f.line === null ? "" : `:${f.line}`}`;
|
|
180
|
+
return ` ${f.status.padEnd(8)} ${where} ${f.ruleId} ${f.message}`.trimEnd();
|
|
181
|
+
}),
|
|
182
|
+
];
|
|
183
|
+
}
|
|
107
184
|
/** Whether a failed slop-scan run means it never started, rather than that it failed. */
|
|
108
185
|
function couldNotRun(res, viaNpx) {
|
|
109
186
|
if (res.error?.code === "ENOENT")
|
|
@@ -154,7 +231,14 @@ function slop(ctx) {
|
|
|
154
231
|
throw new CommandError(EXIT.USAGE, `not inside a git repository: ${ctx.cwd}`);
|
|
155
232
|
const given = typeof ctx.flags.base === "string" ? ctx.flags.base : undefined;
|
|
156
233
|
const baseRef = resolveBaseRef(ctx.cwd, given || process.env.SLOP_BASE_REF || undefined);
|
|
157
|
-
const empty = {
|
|
234
|
+
const empty = {
|
|
235
|
+
added: 0,
|
|
236
|
+
resolved: 0,
|
|
237
|
+
worsened: 0,
|
|
238
|
+
netFindingCount: 0,
|
|
239
|
+
netScore: 0,
|
|
240
|
+
findings: [],
|
|
241
|
+
};
|
|
158
242
|
const sha = runGit(ctx.cwd, ["rev-parse", "--verify", "--quiet", `${baseRef}^{commit}`]);
|
|
159
243
|
if (!sha.ok) {
|
|
160
244
|
ctx.log(`base ref '${baseRef}' not found locally — fetch it (CI needs fetch-depth: 0). Skipping.`);
|
|
@@ -217,8 +301,9 @@ function slop(ctx) {
|
|
|
217
301
|
ctx.log(`added ${s.addedCount}, resolved ${s.resolvedCount}, worsened ${s.worsenedCount}; ` +
|
|
218
302
|
`net findings ${s.netFindingCount}, net score ${s.netRepoScore.toFixed(2)}`);
|
|
219
303
|
const failed = gateFails(s);
|
|
304
|
+
const findings = netNewFindings(stdout);
|
|
220
305
|
for (const line of failed
|
|
221
|
-
? FAIL_GUIDANCE
|
|
306
|
+
? [...formatFindings(findings), ...FAIL_GUIDANCE]
|
|
222
307
|
: ["OK — no net-new or worsened findings (baseline line-shifts ignored)."]) {
|
|
223
308
|
ctx.log(line);
|
|
224
309
|
}
|
|
@@ -232,6 +317,7 @@ function slop(ctx) {
|
|
|
232
317
|
worsened: s.worsenedCount,
|
|
233
318
|
netFindingCount: s.netFindingCount,
|
|
234
319
|
netScore: s.netRepoScore,
|
|
320
|
+
findings,
|
|
235
321
|
});
|
|
236
322
|
return failed ? EXIT.NO : EXIT.OK;
|
|
237
323
|
}, removeWorktree);
|
|
@@ -347,11 +433,16 @@ function prose(ctx) {
|
|
|
347
433
|
ctx.emit({ passed: true, skipped, files: 0 });
|
|
348
434
|
return EXIT.OK;
|
|
349
435
|
};
|
|
436
|
+
const unavailable = (skipped, message) => {
|
|
437
|
+
ctx.log(message);
|
|
438
|
+
ctx.emit({ passed: false, skipped, files: 0 });
|
|
439
|
+
return EXIT_VALE_FAILED;
|
|
440
|
+
};
|
|
350
441
|
if (!onPath("vale")) {
|
|
351
|
-
return
|
|
442
|
+
return unavailable("vale-missing", "vale not installed - prose lint unavailable (install vale, then run vale sync)");
|
|
352
443
|
}
|
|
353
444
|
if (!restoreWriteGood(ctx)) {
|
|
354
|
-
return
|
|
445
|
+
return unavailable("write-good-missing", "PROSE LINT UNAVAILABLE: vale is installed but .vale/styles/write-good could not be restored (main-worktree copy and vale sync both failed). Run: vale sync");
|
|
355
446
|
}
|
|
356
447
|
const files = proseFiles(ctx.cwd, globs);
|
|
357
448
|
if (files.length === 0) {
|
|
@@ -383,8 +474,19 @@ function skipToken(ctx) {
|
|
|
383
474
|
// ---------------------------------------------------------------------------
|
|
384
475
|
// min-push
|
|
385
476
|
// ---------------------------------------------------------------------------
|
|
386
|
-
/**
|
|
387
|
-
|
|
477
|
+
/**
|
|
478
|
+
* The min-push pathspecs: ship's `pr` bookkeeping allow-list for every month and feature
|
|
479
|
+
* (the same list `bkit ci bookkeeping-push` and the ship gate accept untested, including
|
|
480
|
+
* `bkit.testing.ciSkipPaths`), the plans tree bkit's workflows write, and whatever the repo
|
|
481
|
+
* adds in `bkit.testing.minPushPaths` (`:(glob)` unless an entry carries its own magic).
|
|
482
|
+
* The engine hardcodes no consumer file: the floor is what bkit itself writes.
|
|
483
|
+
*/
|
|
484
|
+
export function minPushPathspecs(cfg) {
|
|
485
|
+
return [
|
|
486
|
+
...bookPathspecs("*", "*", "pr", cfg.ciSkipPaths),
|
|
487
|
+
...globPathspecs(["docs/plans/**", ...cfg.minPushPaths]),
|
|
488
|
+
];
|
|
489
|
+
}
|
|
388
490
|
/** Where a pushed commit's range starts: its merge-base with origin/dev, else origin/main. */
|
|
389
491
|
export function pushBase(cwd, sha) {
|
|
390
492
|
for (const cand of BASE_CANDIDATES) {
|
|
@@ -403,14 +505,20 @@ function minPush(ctx) {
|
|
|
403
505
|
const given = ctx.flags.ref;
|
|
404
506
|
const refs = Array.isArray(given) && given.length > 0 ? given.map(String) : ["HEAD"];
|
|
405
507
|
const baseFlag = typeof ctx.flags.base === "string" && ctx.flags.base ? ctx.flags.base : null;
|
|
406
|
-
const paths = readBkitConfig(top.stdout)
|
|
407
|
-
const
|
|
508
|
+
const paths = minPushPathspecs(readBkitConfig(top.stdout));
|
|
509
|
+
const updates = ctx.flags.update;
|
|
510
|
+
if (Array.isArray(updates) && updates.length > 0) {
|
|
511
|
+
if ((Array.isArray(given) && given.length > 0) || baseFlag) {
|
|
512
|
+
throw new CommandError(EXIT.USAGE, "--update cannot be combined with --ref or --base");
|
|
513
|
+
}
|
|
514
|
+
return minPushUpdates(ctx, top.stdout, updates.map(String), paths);
|
|
515
|
+
}
|
|
408
516
|
const changed = new Set();
|
|
409
517
|
const outside = new Set();
|
|
410
518
|
for (const ref of refs) {
|
|
411
519
|
const sha = git(ctx.cwd, ["rev-parse", "--verify", "--quiet", `${ref}^{commit}`]);
|
|
412
520
|
const base = sha ? (baseFlag ?? pushBase(ctx.cwd, sha)) : null;
|
|
413
|
-
const diff = sha && base ? changedOutside(top.stdout, base, sha,
|
|
521
|
+
const diff = sha && base ? changedOutside(top.stdout, base, sha, paths) : null;
|
|
414
522
|
if (!diff?.ok) {
|
|
415
523
|
const why = !sha
|
|
416
524
|
? `cannot read commit '${ref}'`
|
|
@@ -437,9 +545,6 @@ function minPush(ctx) {
|
|
|
437
545
|
});
|
|
438
546
|
return code;
|
|
439
547
|
};
|
|
440
|
-
if (paths.length === 0) {
|
|
441
|
-
return result("no-paths", EXIT.NO, "bkit.testing.minPushPaths is empty — not a min push");
|
|
442
|
-
}
|
|
443
548
|
if (changed.size === 0) {
|
|
444
549
|
return result("no-changes", EXIT.NO, "the push changes no files — not proven a min push");
|
|
445
550
|
}
|
|
@@ -449,12 +554,108 @@ function minPush(ctx) {
|
|
|
449
554
|
}
|
|
450
555
|
return result(null, EXIT.OK, `all ${changed.size} changed files match min-push paths`);
|
|
451
556
|
}
|
|
557
|
+
function minPushUpdates(ctx, cwd, updates, paths) {
|
|
558
|
+
const changed = new Set();
|
|
559
|
+
const outside = new Set();
|
|
560
|
+
let unknown = false;
|
|
561
|
+
let failed = false;
|
|
562
|
+
for (const update of updates) {
|
|
563
|
+
const pair = /^([0-9a-f]{40}|[0-9a-f]{64}):([0-9a-f]{40}|[0-9a-f]{64})$/.exec(update);
|
|
564
|
+
if (!pair)
|
|
565
|
+
throw new CommandError(EXIT.USAGE, "--update requires <old-sha>:<new-sha>");
|
|
566
|
+
const oldSha = pair[1];
|
|
567
|
+
const newSha = pair[2];
|
|
568
|
+
const isNew = /^0+$/.test(oldSha);
|
|
569
|
+
if (!isNew && !runGit(cwd, ["merge-base", "--is-ancestor", oldSha, newSha]).ok) {
|
|
570
|
+
failed = true;
|
|
571
|
+
unknown = true;
|
|
572
|
+
continue;
|
|
573
|
+
}
|
|
574
|
+
const increment = isNew ? null : changedOutside(cwd, oldSha, newSha, paths);
|
|
575
|
+
const base = pushBase(cwd, newSha);
|
|
576
|
+
const whole = base ? changedOutside(cwd, base, newSha, paths) : null;
|
|
577
|
+
if (hasVerifiedIncrement(cwd, oldSha, newSha, paths)) {
|
|
578
|
+
if (increment?.ok)
|
|
579
|
+
for (const file of increment.changed)
|
|
580
|
+
changed.add(file);
|
|
581
|
+
ctx.log(`${oldSha}..${newSha}: covered by a successful full push gate`);
|
|
582
|
+
continue;
|
|
583
|
+
}
|
|
584
|
+
if (whole?.ok) {
|
|
585
|
+
for (const file of whole.changed)
|
|
586
|
+
changed.add(file);
|
|
587
|
+
for (const file of whole.outside)
|
|
588
|
+
outside.add(file);
|
|
589
|
+
if (whole.changed.length > 0 &&
|
|
590
|
+
whole.outside.length === 0 &&
|
|
591
|
+
(isNew || (increment?.ok && increment.changed.length > 0)))
|
|
592
|
+
continue;
|
|
593
|
+
}
|
|
594
|
+
else
|
|
595
|
+
unknown = true;
|
|
596
|
+
failed = true;
|
|
597
|
+
}
|
|
598
|
+
const reason = !failed ? null : unknown ? "unknown" : outside.size ? "outside" : "no-changes";
|
|
599
|
+
ctx.emit({
|
|
600
|
+
minPush: !failed,
|
|
601
|
+
reason,
|
|
602
|
+
changed: changed.size,
|
|
603
|
+
outside: [...outside].sort(),
|
|
604
|
+
paths,
|
|
605
|
+
});
|
|
606
|
+
ctx.log(failed
|
|
607
|
+
? "push is not covered by minimum paths or verified full-gate proof"
|
|
608
|
+
: "every update qualifies for the minimum push gate");
|
|
609
|
+
return !failed ? EXIT.OK : unknown ? EXIT_RANGE_UNKNOWN : EXIT.NO;
|
|
610
|
+
}
|
|
611
|
+
// ---------------------------------------------------------------------------
|
|
612
|
+
// bookkeeping-push
|
|
613
|
+
// ---------------------------------------------------------------------------
|
|
614
|
+
/** A feature branch, as the workflows name one; the FID is the slug after `feat/`. */
|
|
615
|
+
const FEAT_BRANCH = /^feat\/([a-z0-9][a-z0-9-]*)$/;
|
|
616
|
+
function bookkeepingPush(ctx) {
|
|
617
|
+
const top = runGit(ctx.cwd, ["rev-parse", "--show-toplevel"]);
|
|
618
|
+
if (!top.ok)
|
|
619
|
+
throw new CommandError(EXIT.USAGE, `not inside a git repository: ${ctx.cwd}`);
|
|
620
|
+
const from = String(ctx.flags.from);
|
|
621
|
+
const toRef = typeof ctx.flags.to === "string" && ctx.flags.to !== "" ? ctx.flags.to : "HEAD";
|
|
622
|
+
const branch = typeof ctx.flags.branch === "string" && ctx.flags.branch !== ""
|
|
623
|
+
? ctx.flags.branch
|
|
624
|
+
: (git(ctx.cwd, ["rev-parse", "--abbrev-ref", "HEAD"]) ?? "");
|
|
625
|
+
const result = (reason, code, outside, message) => {
|
|
626
|
+
ctx.log(message);
|
|
627
|
+
ctx.emit({ bookkeepingPush: reason === null, reason, branch, from, to: toRef, outside });
|
|
628
|
+
return code;
|
|
629
|
+
};
|
|
630
|
+
const fid = FEAT_BRANCH.exec(branch)?.[1];
|
|
631
|
+
if (fid === undefined) {
|
|
632
|
+
return result("not-a-feature-branch", EXIT.NO, [], `'${branch}' is not a feat/{FID} branch — not a bookkeeping push`);
|
|
633
|
+
}
|
|
634
|
+
if (/^0+$/.test(from)) {
|
|
635
|
+
return result("no-remote-head", EXIT.NO, [], "the remote holds no head for this branch — nothing to carry CI forward from");
|
|
636
|
+
}
|
|
637
|
+
// Every plan month: the hook knows the branch, not the run's `{YYYYMM}`.
|
|
638
|
+
const check = checkOnlyBookkeeping(top.stdout, { month: "*", fid, from, to: toRef });
|
|
639
|
+
switch (check.kind) {
|
|
640
|
+
case "ok":
|
|
641
|
+
return result(null, EXIT.OK, [], `every file changed in ${from}..${toRef} is bookkeeping`);
|
|
642
|
+
case "not-ancestor":
|
|
643
|
+
return result("not-ancestor", EXIT.NO, [], `${from} is not an ancestor of ${toRef} — the push rewrites the PR head`);
|
|
644
|
+
case "outside":
|
|
645
|
+
return result("outside", EXIT.NO, check.outside, `${check.outside.length} changed file(s) outside the bookkeeping allow-list (first: ${check.outside[0]})`);
|
|
646
|
+
case "unknown-commit":
|
|
647
|
+
throw new CommandError(EXIT_RANGE_UNKNOWN, `cannot read commit '${check.ref}'`);
|
|
648
|
+
case "diff-failed":
|
|
649
|
+
throw new CommandError(EXIT_RANGE_UNKNOWN, `'git diff' failed for ${from}..${toRef}: ${check.stderr}`);
|
|
650
|
+
}
|
|
651
|
+
}
|
|
452
652
|
export const ciCommand = {
|
|
453
653
|
noun: "ci",
|
|
454
654
|
summary: "Gates CI and the git hooks run.",
|
|
455
655
|
verbs: {
|
|
456
656
|
slop: {
|
|
457
657
|
summary: "Fail when the working tree adds or worsens slop on net against a base ref.",
|
|
658
|
+
use: "by-hand",
|
|
458
659
|
flags: [
|
|
459
660
|
{
|
|
460
661
|
name: "base",
|
|
@@ -473,6 +674,7 @@ export const ciCommand = {
|
|
|
473
674
|
worsened: "findings worsened",
|
|
474
675
|
netFindingCount: "net change in finding count — gated on",
|
|
475
676
|
netScore: "net change in slop score — gated on",
|
|
677
|
+
findings: "net-new and worsened findings ({status, path, line, ruleId, message}); line shifts dropped",
|
|
476
678
|
},
|
|
477
679
|
exitCodes: {
|
|
478
680
|
[EXIT_SLOP_UNAVAILABLE]: "slop-scan could not run (not installed or not executable)",
|
|
@@ -482,7 +684,8 @@ export const ciCommand = {
|
|
|
482
684
|
run: slop,
|
|
483
685
|
},
|
|
484
686
|
prose: {
|
|
485
|
-
summary: "Run Vale over the markdown files the globs select;
|
|
687
|
+
summary: "Run Vale over the markdown files the globs select; fail when Vale or required styles are unavailable.",
|
|
688
|
+
use: "by-hand",
|
|
486
689
|
flags: [
|
|
487
690
|
{
|
|
488
691
|
name: "glob",
|
|
@@ -492,7 +695,7 @@ export const ciCommand = {
|
|
|
492
695
|
},
|
|
493
696
|
],
|
|
494
697
|
output: {
|
|
495
|
-
passed: "false when vale reported alerts",
|
|
698
|
+
passed: "false when vale reported alerts or required tooling is unavailable",
|
|
496
699
|
skipped: "vale-missing | write-good-missing | no-files when nothing was linted, else null",
|
|
497
700
|
files: "how many files vale linted",
|
|
498
701
|
},
|
|
@@ -503,6 +706,7 @@ export const ciCommand = {
|
|
|
503
706
|
},
|
|
504
707
|
"skip-token": {
|
|
505
708
|
summary: "Whether a commit message carries a GitHub skip-CI token ([skip ci] and kin).",
|
|
709
|
+
use: "by-hand",
|
|
506
710
|
flags: [{ name: "ref", type: "string", help: "commit to read (default HEAD)" }],
|
|
507
711
|
output: {
|
|
508
712
|
ref: "the ref read",
|
|
@@ -512,7 +716,8 @@ export const ciCommand = {
|
|
|
512
716
|
run: skipToken,
|
|
513
717
|
},
|
|
514
718
|
"min-push": {
|
|
515
|
-
summary: "Exit 0 when every file a push changes
|
|
719
|
+
summary: "Exit 0 when every file a push changes is one bkit writes or bkit.testing.minPushPaths / ciSkipPaths adds (the pre-push light gate).",
|
|
720
|
+
use: "by-hand",
|
|
516
721
|
flags: [
|
|
517
722
|
{
|
|
518
723
|
name: "ref",
|
|
@@ -521,18 +726,90 @@ export const ciCommand = {
|
|
|
521
726
|
help: "a pushed commit (default HEAD); its range starts at its merge-base with origin/dev, else origin/main",
|
|
522
727
|
},
|
|
523
728
|
{ name: "base", type: "string", help: "start every range here instead" },
|
|
729
|
+
{
|
|
730
|
+
name: "update",
|
|
731
|
+
type: "string",
|
|
732
|
+
repeatable: true,
|
|
733
|
+
help: "actual <old-sha>:<new-sha> push update; permits verified bookkeeping increments; excludes --ref and --base",
|
|
734
|
+
},
|
|
524
735
|
],
|
|
525
736
|
output: {
|
|
526
|
-
minPush: "true when every changed file matches
|
|
527
|
-
reason: "null when a min push; else no-
|
|
737
|
+
minPush: "true when every changed file matches a min-push path",
|
|
738
|
+
reason: "null when a min push; else no-changes | outside | unknown",
|
|
528
739
|
changed: "files the push changes, across every ref",
|
|
529
740
|
outside: "the changed files no min-push path matches",
|
|
530
|
-
paths: "bkit.testing.
|
|
741
|
+
paths: "the min-push pathspecs in force: ship's pr bookkeeping allow-list (with bkit.testing.ciSkipPaths), docs/plans/**, bkit.testing.minPushPaths",
|
|
531
742
|
},
|
|
532
743
|
exitCodes: {
|
|
533
744
|
[EXIT_RANGE_UNKNOWN]: "a pushed commit, its base, or its git diff could not be read",
|
|
534
745
|
},
|
|
535
746
|
run: minPush,
|
|
536
747
|
},
|
|
748
|
+
"push-gate": {
|
|
749
|
+
summary: "Run a consumer push gate and record successful full-gate proof for the exact clean commit.",
|
|
750
|
+
use: "by-hand",
|
|
751
|
+
flags: [
|
|
752
|
+
{
|
|
753
|
+
name: "gate",
|
|
754
|
+
type: "string",
|
|
755
|
+
required: true,
|
|
756
|
+
help: "consumer package script to execute",
|
|
757
|
+
},
|
|
758
|
+
],
|
|
759
|
+
output: { gate: "the script executed", passed: "whether it exited zero" },
|
|
760
|
+
run: (ctx) => {
|
|
761
|
+
const gate = String(ctx.flags.gate);
|
|
762
|
+
const status = runPushGate(ctx.cwd, gate, ctx.log);
|
|
763
|
+
ctx.emit({ gate, passed: status === 0 });
|
|
764
|
+
return status;
|
|
765
|
+
},
|
|
766
|
+
},
|
|
767
|
+
"bookkeeping-push": {
|
|
768
|
+
summary: "Exit 0 when a feature-branch push adds bookkeeping only on top of the remote head (ship's --scope=pr allow-list).",
|
|
769
|
+
use: "by-hand",
|
|
770
|
+
flags: [
|
|
771
|
+
{
|
|
772
|
+
name: "from",
|
|
773
|
+
type: "string",
|
|
774
|
+
required: true,
|
|
775
|
+
help: "the head the remote holds (git's remote sha on the hook's stdin)",
|
|
776
|
+
},
|
|
777
|
+
{ name: "to", type: "string", help: "the head being pushed (default HEAD)" },
|
|
778
|
+
{
|
|
779
|
+
name: "branch",
|
|
780
|
+
type: "string",
|
|
781
|
+
help: "the feat/{FID} branch (default the current branch); the FID picks the plan log dir",
|
|
782
|
+
},
|
|
783
|
+
],
|
|
784
|
+
output: {
|
|
785
|
+
bookkeepingPush: "true when every file changed in from..to is bookkeeping",
|
|
786
|
+
reason: "null when bookkeeping only; else not-a-feature-branch | no-remote-head | not-ancestor | outside",
|
|
787
|
+
branch: "the branch read",
|
|
788
|
+
from: "the remote head as given",
|
|
789
|
+
to: "the pushed head as given",
|
|
790
|
+
outside: "the changed files outside the allow-list",
|
|
791
|
+
},
|
|
792
|
+
exitCodes: {
|
|
793
|
+
[EXIT_RANGE_UNKNOWN]: "a commit or the git diff could not be read",
|
|
794
|
+
},
|
|
795
|
+
run: bookkeepingPush,
|
|
796
|
+
},
|
|
797
|
+
pins: {
|
|
798
|
+
summary: "Download each *_VERSION + *_SHA256 pinned tool in the files and fail when a hash differs.",
|
|
799
|
+
use: "by-hand",
|
|
800
|
+
flags: [
|
|
801
|
+
{
|
|
802
|
+
name: "file",
|
|
803
|
+
type: "string",
|
|
804
|
+
repeatable: true,
|
|
805
|
+
help: "a file holding pins (shell `X=v`, `export X=v`, Dockerfile `ARG X=v`)",
|
|
806
|
+
},
|
|
807
|
+
],
|
|
808
|
+
output: {
|
|
809
|
+
passed: "false when any pin failed",
|
|
810
|
+
pins: "one row per pin ({file, tool, version, url, status, expected, actual, error}); status ok | skipped (no download) | mismatch | unreachable | missing-sha256 | missing-version | unresolved-url | ambiguous-url",
|
|
811
|
+
},
|
|
812
|
+
run: (ctx) => pins(ctx),
|
|
813
|
+
},
|
|
537
814
|
},
|
|
538
815
|
};
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
// bkit ci pins — download each version + sha256 pinned tool and check its hash.
|
|
2
|
+
//
|
|
3
|
+
// A file pins a tool as `<TOOL>_VERSION` plus `<TOOL>_SHA256` (shell `X="v"`, `export X=v`,
|
|
4
|
+
// Dockerfile `ARG X=v`) and downloads it from a URL that spells `${<TOOL>_VERSION}`.
|
|
5
|
+
// Renovate bumps the version and leaves the hash, so a version-only bump fails only when
|
|
6
|
+
// the image is rebuilt or the setup script reruns. This check fails first, naming the tool:
|
|
7
|
+
// on a hash that differs, a download that fails, or a downloaded version with no hash.
|
|
8
|
+
// A version no URL in the file uses (pnpm through corepack) is not a download: skipped.
|
|
9
|
+
import { createHash } from "node:crypto";
|
|
10
|
+
import * as fs from "node:fs";
|
|
11
|
+
import * as path from "node:path";
|
|
12
|
+
import { CommandError, EXIT } from "../lib.js";
|
|
13
|
+
const ASSIGNMENT = /^\s*(?:ARG\s+|export\s+)?([A-Z][A-Z0-9]*)_(VERSION|SHA256)=("?)([^"\s]+)\3\s*$/gm;
|
|
14
|
+
const URL = /https?:\/\/[^\s"'<>]+/g;
|
|
15
|
+
const VERSION_REF = /\$\{?([A-Z][A-Z0-9]*)_VERSION\}?/g;
|
|
16
|
+
const ATTEMPTS = 3;
|
|
17
|
+
const TIMEOUT_MS = 120_000;
|
|
18
|
+
/** Every `*_VERSION` / `*_SHA256` pin in `text`, with the URL its version downloads from. */
|
|
19
|
+
export function parsePins(text) {
|
|
20
|
+
const versions = new Map();
|
|
21
|
+
const hashes = new Map();
|
|
22
|
+
for (const m of text.matchAll(ASSIGNMENT)) {
|
|
23
|
+
(m[2] === "VERSION" ? versions : hashes).set(m[1], m[4]);
|
|
24
|
+
}
|
|
25
|
+
const urls = new Map();
|
|
26
|
+
for (const [raw] of text.matchAll(URL)) {
|
|
27
|
+
for (const ref of raw.matchAll(VERSION_REF)) {
|
|
28
|
+
const filled = raw.replace(VERSION_REF, (whole, tool) => versions.get(tool) ?? whole);
|
|
29
|
+
const seen = urls.get(ref[1]) ?? new Set();
|
|
30
|
+
urls.set(ref[1], seen.add(filled));
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
const tools = [...new Set([...versions.keys(), ...hashes.keys()])].sort();
|
|
34
|
+
return tools.map((tool) => {
|
|
35
|
+
const version = versions.get(tool) ?? null;
|
|
36
|
+
const sha256 = hashes.get(tool) ?? null;
|
|
37
|
+
const found = [...(urls.get(tool) ?? [])];
|
|
38
|
+
const url = found.length === 1 ? found[0] : null;
|
|
39
|
+
const problem = version === null
|
|
40
|
+
? "missing-version"
|
|
41
|
+
: found.length > 1
|
|
42
|
+
? "ambiguous-url"
|
|
43
|
+
: url !== null && url.includes("$")
|
|
44
|
+
? "unresolved-url"
|
|
45
|
+
: url !== null && sha256 === null
|
|
46
|
+
? "missing-sha256"
|
|
47
|
+
: null;
|
|
48
|
+
return { tool, version, sha256, url, problem };
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
/** GET `url` and return its body; retried, a non-2xx status or a timeout throws. */
|
|
52
|
+
export const fetchAsset = async (url) => {
|
|
53
|
+
let last;
|
|
54
|
+
for (let attempt = 1; attempt <= ATTEMPTS; attempt++) {
|
|
55
|
+
try {
|
|
56
|
+
const res = await fetch(url, { signal: AbortSignal.timeout(TIMEOUT_MS) });
|
|
57
|
+
if (!res.ok)
|
|
58
|
+
throw new Error(`HTTP ${res.status}`);
|
|
59
|
+
return Buffer.from(await res.arrayBuffer());
|
|
60
|
+
}
|
|
61
|
+
catch (err) {
|
|
62
|
+
last = err;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
throw last instanceof Error ? last : new Error(String(last));
|
|
66
|
+
};
|
|
67
|
+
/** Check every pin of every file; each URL is downloaded once. */
|
|
68
|
+
export async function checkPins(files, download) {
|
|
69
|
+
const digests = new Map();
|
|
70
|
+
const digest = (url) => {
|
|
71
|
+
const known = digests.get(url);
|
|
72
|
+
if (known)
|
|
73
|
+
return known;
|
|
74
|
+
const pending = download(url).then((body) => createHash("sha256").update(body).digest("hex"));
|
|
75
|
+
digests.set(url, pending);
|
|
76
|
+
return pending;
|
|
77
|
+
};
|
|
78
|
+
const results = [];
|
|
79
|
+
for (const { file, text } of files) {
|
|
80
|
+
for (const pin of parsePins(text)) {
|
|
81
|
+
const base = { file, tool: pin.tool, version: pin.version, url: pin.url };
|
|
82
|
+
const expected = pin.sha256?.toLowerCase() ?? null;
|
|
83
|
+
const none = { expected, actual: null, error: null };
|
|
84
|
+
if (pin.problem) {
|
|
85
|
+
results.push({ ...base, ...none, status: pin.problem });
|
|
86
|
+
}
|
|
87
|
+
else if (pin.url === null || expected === null) {
|
|
88
|
+
results.push({ ...base, ...none, status: "skipped" });
|
|
89
|
+
}
|
|
90
|
+
else {
|
|
91
|
+
try {
|
|
92
|
+
const actual = await digest(pin.url);
|
|
93
|
+
const status = actual === expected ? "ok" : "mismatch";
|
|
94
|
+
results.push({ ...base, expected, actual, error: null, status });
|
|
95
|
+
}
|
|
96
|
+
catch (err) {
|
|
97
|
+
const error = err instanceof Error ? err.message : String(err);
|
|
98
|
+
results.push({ ...base, ...none, status: "unreachable", error });
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
return results;
|
|
104
|
+
}
|
|
105
|
+
const FAILURE = {
|
|
106
|
+
mismatch: (r) => `sha256 is ${r.actual}, the pin says ${r.expected} (${r.url})`,
|
|
107
|
+
unreachable: (r) => `download failed: ${r.error} (${r.url})`,
|
|
108
|
+
"missing-sha256": (r) => `downloaded from ${r.url} but has no ${r.tool}_SHA256 beside it`,
|
|
109
|
+
"missing-version": (r) => `${r.tool}_SHA256 has no ${r.tool}_VERSION beside it`,
|
|
110
|
+
"unresolved-url": (r) => `download URL still has an unknown variable: ${r.url}`,
|
|
111
|
+
"ambiguous-url": (r) => `${r.tool}_VERSION is used in more than one download URL`,
|
|
112
|
+
};
|
|
113
|
+
/** `bkit ci pins`: exit 0 when every download pin's sha256 matches what its URL serves. */
|
|
114
|
+
export async function pins(ctx, download = fetchAsset) {
|
|
115
|
+
const given = ctx.flags.file;
|
|
116
|
+
const names = Array.isArray(given) ? given : typeof given === "string" ? [given] : [];
|
|
117
|
+
if (names.length === 0)
|
|
118
|
+
throw new CommandError(EXIT.USAGE, "give at least one --file");
|
|
119
|
+
const files = names.map((file) => {
|
|
120
|
+
const abs = path.resolve(ctx.cwd, file);
|
|
121
|
+
if (!fs.existsSync(abs))
|
|
122
|
+
throw new CommandError(EXIT.USAGE, `no such file: ${file}`);
|
|
123
|
+
return { file, text: fs.readFileSync(abs, "utf-8") };
|
|
124
|
+
});
|
|
125
|
+
const results = await checkPins(files, download);
|
|
126
|
+
for (const r of results) {
|
|
127
|
+
const label = `${r.tool} ${r.version ?? "(no version)"} in ${r.file}`;
|
|
128
|
+
if (r.status === "ok")
|
|
129
|
+
ctx.log(`ok ${label}`);
|
|
130
|
+
else if (r.status === "skipped")
|
|
131
|
+
ctx.log(`skipped ${label}: no download URL uses it`);
|
|
132
|
+
else
|
|
133
|
+
ctx.log(`FAIL ${label}: ${FAILURE[r.status](r)}`);
|
|
134
|
+
}
|
|
135
|
+
for (const { file } of files) {
|
|
136
|
+
if (!results.some((r) => r.file === file))
|
|
137
|
+
ctx.log(`no *_VERSION / *_SHA256 pins in ${file}`);
|
|
138
|
+
}
|
|
139
|
+
const passed = results.every((r) => r.status === "ok" || r.status === "skipped");
|
|
140
|
+
ctx.emit({ passed, pins: results });
|
|
141
|
+
return passed ? EXIT.OK : EXIT.NO;
|
|
142
|
+
}
|