@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
|
@@ -22,8 +22,16 @@
|
|
|
22
22
|
|
|
23
23
|
import * as fs from "node:fs";
|
|
24
24
|
import * as path from "node:path";
|
|
25
|
+
import { readJsonFile } from "../../shared/json.js";
|
|
25
26
|
|
|
26
|
-
import {
|
|
27
|
+
import {
|
|
28
|
+
CI_TIERS,
|
|
29
|
+
lastRun,
|
|
30
|
+
statusTimestamp,
|
|
31
|
+
validateCiSelection,
|
|
32
|
+
type CiSelection,
|
|
33
|
+
type CiTier,
|
|
34
|
+
} from "../../ledgers/status.js";
|
|
27
35
|
import {
|
|
28
36
|
bodySkipToken,
|
|
29
37
|
commitMessage,
|
|
@@ -35,14 +43,16 @@ import {
|
|
|
35
43
|
parseJson,
|
|
36
44
|
runGh,
|
|
37
45
|
runGit,
|
|
46
|
+
runTool,
|
|
38
47
|
SKIP_CI_TOKEN,
|
|
48
|
+
wholeNumber,
|
|
39
49
|
type CommandSpec,
|
|
40
50
|
type FlagSpec,
|
|
41
51
|
type FlagValue,
|
|
42
52
|
type GhResult,
|
|
43
53
|
type RunContext,
|
|
44
54
|
} from "../lib.js";
|
|
45
|
-
import { readBkitConfig } from "../../shared/settings.js";
|
|
55
|
+
import { ciGeneratedSteps, readBkitConfig } from "../../shared/settings.js";
|
|
46
56
|
import { TIMEOUTS } from "../../shared/timeouts.js";
|
|
47
57
|
import { FID_PATTERNS, fromBranch, fromMarker, issueIdOf, readIssueTracker } from "./fids.js";
|
|
48
58
|
import type { IssueTracker } from "../../install/manifest.js";
|
|
@@ -59,7 +69,7 @@ import {
|
|
|
59
69
|
} from "./prs.js";
|
|
60
70
|
import { resolveOwnerRepo, splitSlug } from "./repo.js";
|
|
61
71
|
import { restateOutcome } from "./run-facts.js";
|
|
62
|
-
import { extraField, str } from "./status.js";
|
|
72
|
+
import { extraField, readRuns, str } from "./status.js";
|
|
63
73
|
import { writeStepRow } from "./steps.js";
|
|
64
74
|
import { attempt, issueRef, readLabels, trackerTarget } from "./tracker.js";
|
|
65
75
|
|
|
@@ -105,6 +115,396 @@ export function ciDeclared(root: string): { declared: boolean; ciWorkflow: strin
|
|
|
105
115
|
return { declared: fs.existsSync(path.join(root, rel)), ciWorkflow, path: rel };
|
|
106
116
|
}
|
|
107
117
|
|
|
118
|
+
type CiReference = { kind: "run" | "pr"; repo: string; id: string; attempt?: number };
|
|
119
|
+
|
|
120
|
+
/** Only the winning reference kind is actionable; a run takes precedence over a PR. */
|
|
121
|
+
export function parseCiReference(input: string): CiReference | undefined {
|
|
122
|
+
const references: CiReference[] = [];
|
|
123
|
+
const urls = [...input.matchAll(/https:\/\/github\.com\/[^\s<>"`]+/g)].map((match) =>
|
|
124
|
+
match[0].replace(/[),.;\]]+$/, ""),
|
|
125
|
+
);
|
|
126
|
+
const parsed = urls.flatMap((url) => {
|
|
127
|
+
const ref =
|
|
128
|
+
/^https:\/\/github\.com\/([^/]+\/[^/]+)\/(actions\/runs|pull)\/([^/?#]*)([^?#]*)/.exec(url);
|
|
129
|
+
return ref ? [{ url, ref }] : [];
|
|
130
|
+
});
|
|
131
|
+
const winning = parsed.some(({ ref }) => ref[2] === "actions/runs") ? "actions/runs" : "pull";
|
|
132
|
+
for (const { url, ref } of parsed.filter(({ ref }) => ref[2] === winning)) {
|
|
133
|
+
const id = ref[3]!;
|
|
134
|
+
const suffix = ref[4]!;
|
|
135
|
+
const kind = ref[2] === "pull" ? "pr" : "run";
|
|
136
|
+
if (!/^[1-9][0-9]*$/.test(id))
|
|
137
|
+
throw new CommandError(EXIT.USAGE, `invalid ${kind} id in ${url}`);
|
|
138
|
+
let attempt: number | undefined;
|
|
139
|
+
if (kind === "run" && suffix !== "" && suffix !== "/") {
|
|
140
|
+
const pinned = /^\/attempts\/([1-9][0-9]*)\/?$/.exec(suffix);
|
|
141
|
+
if (!pinned || !Number.isSafeInteger(Number(pinned[1])))
|
|
142
|
+
throw new CommandError(EXIT.USAGE, `invalid run attempt in ${url}`);
|
|
143
|
+
attempt = Number(pinned[1]);
|
|
144
|
+
} else if (kind === "pr" && suffix !== "" && suffix !== "/") continue;
|
|
145
|
+
references.push({ kind, repo: ref[1]!, id, ...(attempt === undefined ? {} : { attempt }) });
|
|
146
|
+
}
|
|
147
|
+
const kind = references.some((ref) => ref.kind === "run") ? "run" : "pr";
|
|
148
|
+
const winners = [
|
|
149
|
+
...new Map(
|
|
150
|
+
references.filter((ref) => ref.kind === kind).map((ref) => [JSON.stringify(ref), ref]),
|
|
151
|
+
).values(),
|
|
152
|
+
];
|
|
153
|
+
if (winners.length > 1)
|
|
154
|
+
throw new CommandError(8, `multiple ${kind} references were supplied; name one`);
|
|
155
|
+
return winners[0];
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
function selectionHeadRelation(
|
|
159
|
+
cwd: string,
|
|
160
|
+
selection: Extract<CiSelection, { mode: "ci" }>,
|
|
161
|
+
repo: string,
|
|
162
|
+
branch: string,
|
|
163
|
+
): "current" | "ancestor" {
|
|
164
|
+
if (selection.repo.toLowerCase() !== repo.toLowerCase() || selection.headBranch !== branch) {
|
|
165
|
+
throw new CommandError(
|
|
166
|
+
82,
|
|
167
|
+
`selected evidence belongs to ${selection.repo} branch ${selection.headBranch}; adopted ${repo} branch ${branch}. Supply branch=${selection.headBranch} in its checkout`,
|
|
168
|
+
);
|
|
169
|
+
}
|
|
170
|
+
const head = git(cwd, ["rev-parse", "--verify", `refs/heads/${branch}^{commit}`]);
|
|
171
|
+
if (head === selection.headSha) return "current";
|
|
172
|
+
if (head === null || !runGit(cwd, ["cat-file", "-e", `${selection.headSha}^{commit}`]).ok) {
|
|
173
|
+
throw new CommandError(
|
|
174
|
+
82,
|
|
175
|
+
`selected commit ${selection.headSha} or branch ${branch} is unavailable; ancestry is unknown`,
|
|
176
|
+
);
|
|
177
|
+
}
|
|
178
|
+
const relation = runTool("git", ["merge-base", "--is-ancestor", selection.headSha, head], cwd);
|
|
179
|
+
if (relation.status === 0) return "ancestor";
|
|
180
|
+
throw new CommandError(
|
|
181
|
+
82,
|
|
182
|
+
relation.status === 1
|
|
183
|
+
? `selected commit ${selection.headSha} is divergent from ${branch}`
|
|
184
|
+
: `ancestry of ${selection.headSha} is unknown: ${relation.stderr}`,
|
|
185
|
+
);
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
function locateCi(ctx: RunContext): number {
|
|
189
|
+
const f = ctx.flags;
|
|
190
|
+
const repo = String(f.repo);
|
|
191
|
+
const branch = String(f.branch);
|
|
192
|
+
if (
|
|
193
|
+
!/^[A-Za-z0-9][A-Za-z0-9_.-]*\/[A-Za-z0-9][A-Za-z0-9_.-]*$/.test(repo) ||
|
|
194
|
+
!runGit(ctx.cwd, ["check-ref-format", "--branch", branch]).ok
|
|
195
|
+
) {
|
|
196
|
+
throw new CommandError(
|
|
197
|
+
EXIT.USAGE,
|
|
198
|
+
"--repo and --branch must name a repository and a valid branch",
|
|
199
|
+
);
|
|
200
|
+
}
|
|
201
|
+
const readInput = (flag: string) =>
|
|
202
|
+
f[flag] === undefined ? "" : fs.readFileSync(path.resolve(ctx.cwd, String(f[flag])), "utf8");
|
|
203
|
+
const prompt = readInput("promptFile");
|
|
204
|
+
const selectionFile = path.resolve(ctx.cwd, String(f.selectionOut));
|
|
205
|
+
const finish = (selection: CiSelection, failedJobs: Record<string, unknown>[] = []) => {
|
|
206
|
+
if (!validateCiSelection(selection))
|
|
207
|
+
throw new CommandError(82, "selected evidence has malformed or missing identity fields");
|
|
208
|
+
const headRelation =
|
|
209
|
+
selection.mode === "ci" ? selectionHeadRelation(ctx.cwd, selection, repo, branch) : null;
|
|
210
|
+
if (headRelation === "ancestor")
|
|
211
|
+
ctx.log(
|
|
212
|
+
`selected run ${selection.mode === "ci" ? selection.runId : ""} is historical ancestor evidence; inspect intervening changes before fixing`,
|
|
213
|
+
);
|
|
214
|
+
fs.mkdirSync(path.dirname(selectionFile), { recursive: true });
|
|
215
|
+
fs.writeFileSync(selectionFile, `${JSON.stringify(selection, null, 2)}\n`);
|
|
216
|
+
ctx.emit({
|
|
217
|
+
selection: selection.mode,
|
|
218
|
+
runId: selection.mode === "ci" ? selection.runId : null,
|
|
219
|
+
runUrl: selection.mode === "ci" ? selection.runUrl : null,
|
|
220
|
+
runAttempt: selection.mode === "ci" ? selection.runAttempt : null,
|
|
221
|
+
workflowId: selection.mode === "ci" ? selection.workflowId : null,
|
|
222
|
+
workflowPath: selection.mode === "ci" ? selection.workflowPath : null,
|
|
223
|
+
headSha: selection.mode === "ci" ? selection.headSha : null,
|
|
224
|
+
headRelation,
|
|
225
|
+
failedJobs,
|
|
226
|
+
tiers: selection.mode === "ci" ? selection.redTiers : [],
|
|
227
|
+
via: selection.mode === "ci" ? selection.via : null,
|
|
228
|
+
reason: selection.mode === "local" ? selection.reason : null,
|
|
229
|
+
selectionFile,
|
|
230
|
+
});
|
|
231
|
+
return selection.mode === "ci" ? EXIT.OK : 1;
|
|
232
|
+
};
|
|
233
|
+
if (/\[local\]/i.test(prompt)) return finish({ mode: "local", reason: "explicit-local" });
|
|
234
|
+
let reference = parseCiReference(prompt);
|
|
235
|
+
let via = reference ? `prompt-${reference.kind}` : "branch";
|
|
236
|
+
let saved: CiSelection | undefined;
|
|
237
|
+
if (!reference && f.file !== undefined && fs.existsSync(path.resolve(ctx.cwd, String(f.file)))) {
|
|
238
|
+
const active = lastRun(readRuns(path.resolve(ctx.cwd, String(f.file))), "debug");
|
|
239
|
+
if (active?.status === "IN_PROGRESS" && active.ciSelection !== undefined) {
|
|
240
|
+
if (!validateCiSelection(active.ciSelection))
|
|
241
|
+
throw new CommandError(82, "active saved CI selection is invalid");
|
|
242
|
+
saved = active.ciSelection;
|
|
243
|
+
if (saved.mode === "local") return finish(saved);
|
|
244
|
+
reference = { kind: "run", repo: saved.repo, id: saved.runId, attempt: saved.runAttempt };
|
|
245
|
+
via = saved.via;
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
if (!reference) {
|
|
249
|
+
const issue = readInput("issueTextFile");
|
|
250
|
+
// issues text already removes generated comments; refuse a raw generated payload too.
|
|
251
|
+
reference = parseCiReference(/^######\s+bkit:generated/m.test(issue) ? "" : issue);
|
|
252
|
+
if (reference) via = `issue-${reference.kind}`;
|
|
253
|
+
}
|
|
254
|
+
if (reference && reference.repo.toLowerCase() !== repo.toLowerCase())
|
|
255
|
+
throw new CommandError(
|
|
256
|
+
82,
|
|
257
|
+
`reference repository ${reference.repo} does not match adopted repository ${repo}`,
|
|
258
|
+
);
|
|
259
|
+
const declared = ciDeclared(checkoutRoot(ctx.cwd));
|
|
260
|
+
if (!reference && !declared.declared)
|
|
261
|
+
return finish({ mode: "local", reason: "no-configured-ci" });
|
|
262
|
+
const api = (endpoint: string, extra: string[] = []) => {
|
|
263
|
+
const response = runGh(ctx.cwd, ["api", endpoint, ...extra]);
|
|
264
|
+
if (!response.ok)
|
|
265
|
+
throw new CommandError(
|
|
266
|
+
/HTTP 404/.test(response.stderr) ? 82 : EXIT.USE_MCP,
|
|
267
|
+
`CI evidence unavailable: ${response.stderr || GH_MISSING}`,
|
|
268
|
+
);
|
|
269
|
+
const parsed = jsonOrUndefined(response.stdout);
|
|
270
|
+
if (parsed === undefined) throw new CommandError(82, "CI evidence response is malformed");
|
|
271
|
+
return parsed;
|
|
272
|
+
};
|
|
273
|
+
const validateRun = (candidate: Record<string, unknown>) => {
|
|
274
|
+
const base = {
|
|
275
|
+
mode: "ci",
|
|
276
|
+
provider: "github",
|
|
277
|
+
repo,
|
|
278
|
+
runId: String(candidate.id),
|
|
279
|
+
runAttempt: Number(candidate.run_attempt),
|
|
280
|
+
runUrl: `https://github.com/${repo}/actions/runs/${candidate.id}/attempts/${candidate.run_attempt}`,
|
|
281
|
+
workflowId: String(candidate.workflow_id ?? ""),
|
|
282
|
+
workflowPath: text(candidate.path),
|
|
283
|
+
headBranch: text(candidate.head_branch),
|
|
284
|
+
headSha: text(candidate.head_sha),
|
|
285
|
+
conclusion: "failure",
|
|
286
|
+
redTiers: [],
|
|
287
|
+
via,
|
|
288
|
+
};
|
|
289
|
+
if (
|
|
290
|
+
!validateCiSelection(base) ||
|
|
291
|
+
text(obj(candidate.repository).full_name).toLowerCase() !== repo.toLowerCase() ||
|
|
292
|
+
text(obj(candidate.head_repository).full_name).toLowerCase() !== repo.toLowerCase()
|
|
293
|
+
)
|
|
294
|
+
throw new CommandError(
|
|
295
|
+
82,
|
|
296
|
+
"run identity, repository or fork metadata is incomplete or mismatched",
|
|
297
|
+
);
|
|
298
|
+
if (candidate.head_branch !== branch)
|
|
299
|
+
throw new CommandError(
|
|
300
|
+
82,
|
|
301
|
+
`run branch ${text(candidate.head_branch)} differs from adopted branch ${branch}; supply branch=${text(candidate.head_branch)} in its checkout`,
|
|
302
|
+
);
|
|
303
|
+
if (reference?.kind !== "run" && candidate.path !== declared.path)
|
|
304
|
+
throw new CommandError(82, "discovered run does not belong to the configured workflow");
|
|
305
|
+
};
|
|
306
|
+
let run: Record<string, unknown>;
|
|
307
|
+
let jobs: Record<string, unknown>[];
|
|
308
|
+
const requested: Record<string, unknown> = { repo, branch, kind: reference?.kind ?? "branch" };
|
|
309
|
+
if (reference?.kind === "run") {
|
|
310
|
+
requested.runId = reference.id;
|
|
311
|
+
if (reference.attempt !== undefined) requested.runAttempt = reference.attempt;
|
|
312
|
+
} else if (reference?.kind === "pr") requested.pr = reference.id;
|
|
313
|
+
else requested.workflow = declared.ciWorkflow;
|
|
314
|
+
if (f.evidenceFile !== undefined) {
|
|
315
|
+
const envelope = obj(jsonOrUndefined(readInput("evidenceFile")));
|
|
316
|
+
const request = obj(envelope.request);
|
|
317
|
+
if (
|
|
318
|
+
envelope.complete !== true ||
|
|
319
|
+
!Object.entries(requested).every(([key, value]) => request[key] === value)
|
|
320
|
+
)
|
|
321
|
+
throw new CommandError(82, "fallback evidence is incomplete or its request identity differs");
|
|
322
|
+
if (
|
|
323
|
+
envelope.noRed === true &&
|
|
324
|
+
!reference &&
|
|
325
|
+
typeof request.headSha === "string" &&
|
|
326
|
+
request.headSha === git(ctx.cwd, ["rev-parse", "HEAD"])
|
|
327
|
+
)
|
|
328
|
+
return finish({ mode: "local", reason: "automatic-no-red" });
|
|
329
|
+
run = obj(envelope.run);
|
|
330
|
+
if (reference?.kind === "pr") {
|
|
331
|
+
const head = obj(obj(envelope.pr).head);
|
|
332
|
+
if (
|
|
333
|
+
head.ref !== branch ||
|
|
334
|
+
head.sha !== run.head_sha ||
|
|
335
|
+
text(obj(head.repo).full_name).toLowerCase() !== repo.toLowerCase()
|
|
336
|
+
)
|
|
337
|
+
throw new CommandError(82, "fallback PR head is missing or differs from the selected run");
|
|
338
|
+
}
|
|
339
|
+
if (!Array.isArray(envelope.jobs) || envelope.jobs.some((job) => obj(job).id === undefined))
|
|
340
|
+
throw new CommandError(82, "fallback jobs are incomplete");
|
|
341
|
+
jobs = envelope.jobs.map(obj);
|
|
342
|
+
} else {
|
|
343
|
+
let expectedHead: string | undefined;
|
|
344
|
+
if (reference?.kind === "pr") {
|
|
345
|
+
const pr = obj(api(`/repos/${repo}/pulls/${reference.id}`));
|
|
346
|
+
const head = obj(pr.head);
|
|
347
|
+
if (
|
|
348
|
+
text(obj(head.repo).full_name).toLowerCase() !== repo.toLowerCase() ||
|
|
349
|
+
head.ref !== branch ||
|
|
350
|
+
!/^[0-9a-f]{40,64}$/.test(text(head.sha))
|
|
351
|
+
)
|
|
352
|
+
throw new CommandError(
|
|
353
|
+
82,
|
|
354
|
+
`PR head does not match adopted ${repo} branch ${branch}; inspect its branch and fork repository`,
|
|
355
|
+
);
|
|
356
|
+
expectedHead = text(head.sha);
|
|
357
|
+
}
|
|
358
|
+
if (reference?.kind === "run") {
|
|
359
|
+
run = obj(
|
|
360
|
+
api(
|
|
361
|
+
`/repos/${repo}/actions/runs/${reference.id}${reference.attempt === undefined ? "" : `/attempts/${reference.attempt}`}`,
|
|
362
|
+
),
|
|
363
|
+
);
|
|
364
|
+
} else {
|
|
365
|
+
const response = obj(
|
|
366
|
+
api(
|
|
367
|
+
`/repos/${repo}/actions/workflows/${queryValue(declared.ciWorkflow)}/runs?branch=${queryValue(branch)}&status=completed&per_page=100${expectedHead ? `&head_sha=${expectedHead}` : ""}`,
|
|
368
|
+
),
|
|
369
|
+
);
|
|
370
|
+
if (
|
|
371
|
+
!Array.isArray(response.workflow_runs) ||
|
|
372
|
+
!Number.isSafeInteger(response.total_count) ||
|
|
373
|
+
Number(response.total_count) < 0 ||
|
|
374
|
+
Number(response.total_count) < response.workflow_runs.length
|
|
375
|
+
)
|
|
376
|
+
throw new CommandError(82, "workflow lookup returned an incomplete response");
|
|
377
|
+
const candidates = response.workflow_runs
|
|
378
|
+
.map(obj)
|
|
379
|
+
.filter((candidate) => candidate.status === "completed");
|
|
380
|
+
run =
|
|
381
|
+
candidates.sort(
|
|
382
|
+
(a, b) =>
|
|
383
|
+
text(b.created_at).localeCompare(text(a.created_at)) || Number(b.id) - Number(a.id),
|
|
384
|
+
)[0] ?? {};
|
|
385
|
+
if (Object.keys(run).length === 0) {
|
|
386
|
+
if (Number(response.total_count) > 0)
|
|
387
|
+
throw new CommandError(
|
|
388
|
+
82,
|
|
389
|
+
"workflow lookup returned no completed records despite a nonempty result",
|
|
390
|
+
);
|
|
391
|
+
if (reference)
|
|
392
|
+
throw new CommandError(
|
|
393
|
+
82,
|
|
394
|
+
"named PR has no completed red run; choose [local] to discover locally",
|
|
395
|
+
);
|
|
396
|
+
return finish({ mode: "local", reason: "automatic-no-red" });
|
|
397
|
+
}
|
|
398
|
+
if (expectedHead && run.head_sha !== expectedHead)
|
|
399
|
+
throw new CommandError(82, "PR lookup returned a run from another head");
|
|
400
|
+
}
|
|
401
|
+
validateRun(run);
|
|
402
|
+
if (
|
|
403
|
+
run.status !== "completed" ||
|
|
404
|
+
!["failure", "timed_out", "startup_failure"].includes(text(run.conclusion))
|
|
405
|
+
) {
|
|
406
|
+
if (reference)
|
|
407
|
+
throw new CommandError(
|
|
408
|
+
82,
|
|
409
|
+
`named evidence is ${text(run.status)}/${text(run.conclusion)}; choose [local] to discover locally`,
|
|
410
|
+
);
|
|
411
|
+
if (
|
|
412
|
+
run.status !== "completed" ||
|
|
413
|
+
!["success", "cancelled", "skipped", "neutral", "action_required", "stale"].includes(
|
|
414
|
+
text(run.conclusion),
|
|
415
|
+
)
|
|
416
|
+
)
|
|
417
|
+
throw new CommandError(82, "workflow run has an invalid state");
|
|
418
|
+
return finish({ mode: "local", reason: "automatic-no-red" });
|
|
419
|
+
}
|
|
420
|
+
const attempt = reference?.attempt ?? Number(run.run_attempt);
|
|
421
|
+
if (!Number.isSafeInteger(attempt) || attempt <= 0 || !/^[1-9][0-9]*$/.test(String(run.id)))
|
|
422
|
+
throw new CommandError(82, "run identity or attempt is missing");
|
|
423
|
+
const pages = api(
|
|
424
|
+
`/repos/${repo}/actions/runs/${run.id}/attempts/${attempt}/jobs?per_page=100`,
|
|
425
|
+
["--paginate", "--slurp"],
|
|
426
|
+
);
|
|
427
|
+
if (!Array.isArray(pages) || pages.length === 0)
|
|
428
|
+
throw new CommandError(82, "job pagination returned no complete pages");
|
|
429
|
+
const total = obj(pages[0]).total_count;
|
|
430
|
+
if (
|
|
431
|
+
!Number.isSafeInteger(total) ||
|
|
432
|
+
Number(total) < 0 ||
|
|
433
|
+
pages.some((page) => !Array.isArray(obj(page).jobs) || obj(page).total_count !== total)
|
|
434
|
+
)
|
|
435
|
+
throw new CommandError(82, "job pagination returned incomplete pages");
|
|
436
|
+
jobs = pages.flatMap((page) => arr(obj(page).jobs).map(obj));
|
|
437
|
+
if (
|
|
438
|
+
jobs.length !== total ||
|
|
439
|
+
new Set(jobs.map((job) => job.id)).size !== total ||
|
|
440
|
+
jobs.some(
|
|
441
|
+
(job) =>
|
|
442
|
+
!Number.isSafeInteger(job.id) ||
|
|
443
|
+
typeof job.name !== "string" ||
|
|
444
|
+
typeof job.conclusion !== "string",
|
|
445
|
+
)
|
|
446
|
+
)
|
|
447
|
+
throw new CommandError(82, "job pagination did not return every job");
|
|
448
|
+
}
|
|
449
|
+
const attempt = reference?.attempt ?? Number(run.run_attempt);
|
|
450
|
+
validateRun(run);
|
|
451
|
+
if (
|
|
452
|
+
jobs.some(
|
|
453
|
+
(job) =>
|
|
454
|
+
!Number.isSafeInteger(job.id) ||
|
|
455
|
+
typeof job.name !== "string" ||
|
|
456
|
+
job.name.length === 0 ||
|
|
457
|
+
typeof job.conclusion !== "string",
|
|
458
|
+
) ||
|
|
459
|
+
new Set(jobs.map((job) => job.id)).size !== jobs.length
|
|
460
|
+
)
|
|
461
|
+
throw new CommandError(82, "job identities or conclusions are incomplete");
|
|
462
|
+
if (reference?.kind === "run" && String(run.id) !== reference.id)
|
|
463
|
+
throw new CommandError(82, "selected run differs from the requested run");
|
|
464
|
+
if (
|
|
465
|
+
Number(run.run_attempt) !== attempt ||
|
|
466
|
+
run.status !== "completed" ||
|
|
467
|
+
text(obj(run.repository).full_name).toLowerCase() !== repo.toLowerCase() ||
|
|
468
|
+
text(obj(run.head_repository).full_name).toLowerCase() !== repo.toLowerCase()
|
|
469
|
+
)
|
|
470
|
+
throw new CommandError(82, "run attempt, repository or fork identity does not match");
|
|
471
|
+
const failedJobs = jobs.filter((job) =>
|
|
472
|
+
["failure", "timed_out", "startup_failure"].includes(text(job.conclusion)),
|
|
473
|
+
);
|
|
474
|
+
const mapped = failedJobs
|
|
475
|
+
.filter((job) => job.name !== "bkit-tests-check")
|
|
476
|
+
.map(
|
|
477
|
+
(job) =>
|
|
478
|
+
/^bkit-tests-(static|unit|integration|e2e|live|migration)$/.exec(text(job.name))?.[1],
|
|
479
|
+
);
|
|
480
|
+
const tiers: CiTier[] = mapped.some((tier) => tier === undefined)
|
|
481
|
+
? []
|
|
482
|
+
: CI_TIERS.filter((tier) => mapped.includes(tier));
|
|
483
|
+
const selection: CiSelection = {
|
|
484
|
+
mode: "ci",
|
|
485
|
+
provider: "github",
|
|
486
|
+
repo,
|
|
487
|
+
runId: String(run.id),
|
|
488
|
+
runAttempt: attempt,
|
|
489
|
+
runUrl: `https://github.com/${repo}/actions/runs/${run.id}/attempts/${attempt}`,
|
|
490
|
+
workflowId: String(run.workflow_id ?? ""),
|
|
491
|
+
workflowPath: text(run.path),
|
|
492
|
+
headBranch: text(run.head_branch),
|
|
493
|
+
headSha: text(run.head_sha),
|
|
494
|
+
conclusion: text(run.conclusion) as Extract<CiSelection, { mode: "ci" }>["conclusion"],
|
|
495
|
+
redTiers: tiers,
|
|
496
|
+
via,
|
|
497
|
+
};
|
|
498
|
+
if (
|
|
499
|
+
saved?.mode === "ci" &&
|
|
500
|
+
(saved.workflowId !== selection.workflowId ||
|
|
501
|
+
saved.headSha !== selection.headSha ||
|
|
502
|
+
saved.workflowPath !== selection.workflowPath)
|
|
503
|
+
)
|
|
504
|
+
throw new CommandError(82, "saved evidence identity differs from the returned run");
|
|
505
|
+
return finish(selection, failedJobs);
|
|
506
|
+
}
|
|
507
|
+
|
|
108
508
|
/** Skip-token scan of a landed commit's body (see `bodySkipToken`). */
|
|
109
509
|
export function scanBody(cwd: string, sha: string): "clean" | "skip-token-found" | "error" {
|
|
110
510
|
const token = bodySkipToken(cwd, sha);
|
|
@@ -324,14 +724,16 @@ export interface DispatchResult {
|
|
|
324
724
|
/** Exit code: the re-trigger commit or its push failed. */
|
|
325
725
|
export const EXIT_RETRIGGER_FAILED = 6;
|
|
326
726
|
|
|
327
|
-
|
|
727
|
+
/** Push the current branch; the failure text is kept so the gate can name why. */
|
|
728
|
+
function pushCurrentBranch(cwd: string): { ok: boolean; error: string } {
|
|
328
729
|
const branch = git(cwd, ["branch", "--show-current"]);
|
|
329
|
-
if (!branch) return false;
|
|
730
|
+
if (!branch) return { ok: false, error: "no branch checked out (detached HEAD)" };
|
|
330
731
|
// Shared branches never force; a feature branch is rewritten only by this run.
|
|
331
732
|
const args = isSharedBranch(branch)
|
|
332
733
|
? ["push", "origin", branch]
|
|
333
734
|
: ["push", "--force-with-lease", "origin", branch];
|
|
334
|
-
|
|
735
|
+
const res = runGit(cwd, args);
|
|
736
|
+
return { ok: res.ok, error: res.ok ? "" : res.stderr || res.stdout };
|
|
335
737
|
}
|
|
336
738
|
|
|
337
739
|
/**
|
|
@@ -454,10 +856,24 @@ export async function ciDispatchGate(
|
|
|
454
856
|
return res;
|
|
455
857
|
}
|
|
456
858
|
let pushed: boolean;
|
|
859
|
+
let failure = "";
|
|
457
860
|
if (rec === null) {
|
|
458
861
|
landed = null;
|
|
459
|
-
|
|
460
|
-
|
|
862
|
+
const before = git(o.cwd, ["rev-parse", "HEAD"]);
|
|
863
|
+
const made = runGit(o.cwd, ["commit", "--allow-empty", "-m", message]);
|
|
864
|
+
if (!made.ok) {
|
|
865
|
+
pushed = false;
|
|
866
|
+
failure = made.stderr || made.stdout;
|
|
867
|
+
} else {
|
|
868
|
+
const push = pushCurrentBranch(o.cwd);
|
|
869
|
+
pushed = push.ok;
|
|
870
|
+
if (!push.ok) {
|
|
871
|
+
failure = push.error;
|
|
872
|
+
// The commit never reached the remote: drop it so a re-run does not pile
|
|
873
|
+
// up orphan re-triggers. --soft restores the index exactly as the commit left it.
|
|
874
|
+
if (before !== null) runGit(o.cwd, ["reset", "--soft", before]);
|
|
875
|
+
}
|
|
876
|
+
}
|
|
461
877
|
} else {
|
|
462
878
|
const made = retriggerCommit(o.cwd, rec, message);
|
|
463
879
|
if (!made.ok) deps.log(`re-trigger commit failed: ${made.error}`);
|
|
@@ -469,7 +885,9 @@ export async function ciDispatchGate(
|
|
|
469
885
|
if (pushed) fetchLanded();
|
|
470
886
|
}
|
|
471
887
|
if (!pushed) {
|
|
472
|
-
deps.log(
|
|
888
|
+
deps.log(
|
|
889
|
+
`re-trigger commit or push failed${failure ? `: ${failure}` : ""} — no verdict; route to the Failure Path`,
|
|
890
|
+
);
|
|
473
891
|
res.phase = "repoll";
|
|
474
892
|
res.handoff = EXIT_RETRIGGER_FAILED;
|
|
475
893
|
return res;
|
|
@@ -528,7 +946,7 @@ export const GATE = {
|
|
|
528
946
|
SUPERSEDED: 14,
|
|
529
947
|
/** The selected run was cancelled. */
|
|
530
948
|
CANCELLED: 15,
|
|
531
|
-
/** A lane named in bkit.testing.
|
|
949
|
+
/** A lane named in bkit.testing.ciRequired concluded skipped. */
|
|
532
950
|
LANE_SKIPPED: 16,
|
|
533
951
|
/** --validated is not an ancestor of the head plus bookkeeping-only commits. */
|
|
534
952
|
NOT_BOOKKEEPING: 17,
|
|
@@ -600,9 +1018,39 @@ export interface GateResult {
|
|
|
600
1018
|
repo: string | null;
|
|
601
1019
|
skippedLanes: string[];
|
|
602
1020
|
nonBookkeepingPaths: string[];
|
|
1021
|
+
/**
|
|
1022
|
+
* Exit 12: `{job}/{step}` of each failed step outside the capstone; `{job}/` for a
|
|
1023
|
+
* failed job with no failed step. Empty when the jobs could not be read.
|
|
1024
|
+
*/
|
|
1025
|
+
failedSteps: string[];
|
|
1026
|
+
/** Exit 12, and every failed step is one `bkit:generate` fixes (`ciGeneratedSteps`). */
|
|
1027
|
+
regenerable: boolean;
|
|
603
1028
|
reason: string;
|
|
604
1029
|
}
|
|
605
1030
|
|
|
1031
|
+
/** Job and step conclusions that are not a failure. */
|
|
1032
|
+
const NOT_FAILED = new Set(["success", "skipped", "neutral"]);
|
|
1033
|
+
|
|
1034
|
+
/**
|
|
1035
|
+
* The failed steps of a run's jobs as `{job}/{step}`, the capstone left out: it fails
|
|
1036
|
+
* only because another job did. A job that did not pass with no step that failed (a
|
|
1037
|
+
* runner or setup failure) is `{job}/`, which no list entry matches.
|
|
1038
|
+
*/
|
|
1039
|
+
export function failedStepsOf(jobs: Array<Record<string, unknown>>, capstone: string): string[] {
|
|
1040
|
+
const out: string[] = [];
|
|
1041
|
+
for (const job of jobs) {
|
|
1042
|
+
const name = text(job.name);
|
|
1043
|
+
if (name === capstone || NOT_FAILED.has(text(job.conclusion))) continue;
|
|
1044
|
+
const steps = arr(job.steps)
|
|
1045
|
+
.map(obj)
|
|
1046
|
+
.filter((st) => st.conclusion !== null && st.conclusion !== undefined)
|
|
1047
|
+
.filter((st) => !NOT_FAILED.has(text(st.conclusion)))
|
|
1048
|
+
.map((st) => `${name}/${text(st.name)}`);
|
|
1049
|
+
out.push(...(steps.length > 0 ? steps : [`${name}/`]));
|
|
1050
|
+
}
|
|
1051
|
+
return out;
|
|
1052
|
+
}
|
|
1053
|
+
|
|
606
1054
|
interface Run {
|
|
607
1055
|
id: number | null;
|
|
608
1056
|
head_sha: string;
|
|
@@ -654,9 +1102,11 @@ export function shipGate(o: GateOptions, gh: Gh, log: (m: string) => void): Gate
|
|
|
654
1102
|
repo: o.repo || null,
|
|
655
1103
|
skippedLanes: [],
|
|
656
1104
|
nonBookkeepingPaths: [],
|
|
1105
|
+
failedSteps: [],
|
|
1106
|
+
regenerable: false,
|
|
657
1107
|
reason: "",
|
|
658
1108
|
};
|
|
659
|
-
const requiredLanes = cfg.
|
|
1109
|
+
const requiredLanes = cfg.ciRequired;
|
|
660
1110
|
|
|
661
1111
|
const refuse = (code: number, reason: string, runUrl?: string): GateResult => {
|
|
662
1112
|
log(reason);
|
|
@@ -726,32 +1176,59 @@ export function shipGate(o: GateOptions, gh: Gh, log: (m: string) => void): Gate
|
|
|
726
1176
|
return r;
|
|
727
1177
|
};
|
|
728
1178
|
|
|
729
|
-
/** The run's jobs
|
|
730
|
-
*
|
|
731
|
-
const
|
|
1179
|
+
/** The run's jobs. `--slurp` turns --paginate's one-document-per-page stream into one
|
|
1180
|
+
* array; without it a run with more than 100 jobs hides every page but the first. */
|
|
1181
|
+
const listJobs = (
|
|
1182
|
+
run: Run,
|
|
1183
|
+
): Array<Record<string, unknown>> | "missing" | "api-error" | "invalid" => {
|
|
732
1184
|
const jobsRes = gh([
|
|
733
1185
|
"api",
|
|
734
1186
|
`/repos/${r.repo}/actions/runs/${run.id}/jobs`,
|
|
735
1187
|
"--paginate",
|
|
736
1188
|
"--slurp",
|
|
737
1189
|
]);
|
|
738
|
-
if (jobsRes.missing) return
|
|
739
|
-
if (!jobsRes.ok)
|
|
1190
|
+
if (jobsRes.missing) return "missing";
|
|
1191
|
+
if (!jobsRes.ok) return "api-error";
|
|
1192
|
+
const jobsJson = jsonOrUndefined(jobsRes.stdout);
|
|
1193
|
+
if (jobsJson === undefined) return "invalid";
|
|
1194
|
+
const pages = Array.isArray(jobsJson) ? jobsJson : [jobsJson];
|
|
1195
|
+
return pages.flatMap((p) => arr(obj(p).jobs).map(obj));
|
|
1196
|
+
};
|
|
1197
|
+
|
|
1198
|
+
/** The run's jobs, or the refusal. */
|
|
1199
|
+
const readJobs = (run: Run): Array<Record<string, unknown>> | GateResult => {
|
|
1200
|
+
const jobs = listJobs(run);
|
|
1201
|
+
if (jobs === "missing") return ghMissing();
|
|
1202
|
+
if (jobs === "api-error") {
|
|
740
1203
|
return apiError(
|
|
741
1204
|
`jobs query failed for run ${run.id} — API error (distinct from 'no capstone')`,
|
|
742
1205
|
run.html_url,
|
|
743
1206
|
);
|
|
744
1207
|
}
|
|
745
|
-
|
|
746
|
-
if (jobsJson === undefined) {
|
|
1208
|
+
if (jobs === "invalid") {
|
|
747
1209
|
return refuse(
|
|
748
1210
|
GATE.API_ERROR,
|
|
749
1211
|
`jobs response for run ${run.id} is not valid JSON`,
|
|
750
1212
|
run.html_url,
|
|
751
1213
|
);
|
|
752
1214
|
}
|
|
753
|
-
|
|
754
|
-
|
|
1215
|
+
return jobs;
|
|
1216
|
+
};
|
|
1217
|
+
|
|
1218
|
+
/** A failed run's failed steps, and whether `bkit:generate` fixes each one. Jobs that
|
|
1219
|
+
* cannot be read leave it unregenerable; the refusal itself does not change. */
|
|
1220
|
+
const classifyFailure = (run: Run): void => {
|
|
1221
|
+
const jobs = listJobs(run);
|
|
1222
|
+
if (!Array.isArray(jobs)) {
|
|
1223
|
+
log(`failed steps unknown: the jobs of run ${run.id} could not be read`);
|
|
1224
|
+
return;
|
|
1225
|
+
}
|
|
1226
|
+
r.failedSteps = failedStepsOf(jobs, r.capstone);
|
|
1227
|
+
const fixable = ciGeneratedSteps(cfg);
|
|
1228
|
+
r.regenerable = r.failedSteps.length > 0 && r.failedSteps.every((st) => fixable.includes(st));
|
|
1229
|
+
for (const st of r.failedSteps) log(`failed step: ${st}`);
|
|
1230
|
+
if (r.regenerable)
|
|
1231
|
+
log("every failed step is one bkit:generate fixes (bkit.testing.ciGenerated)");
|
|
755
1232
|
};
|
|
756
1233
|
|
|
757
1234
|
/** Capstone-only verdict: the capstone job's own result, whatever the run and its other jobs did. */
|
|
@@ -911,6 +1388,7 @@ export function shipGate(o: GateOptions, gh: Gh, log: (m: string) => void): Gate
|
|
|
911
1388
|
if (o.capstoneOnly) return capstoneVerdict(selected);
|
|
912
1389
|
|
|
913
1390
|
if (selected.conclusion === "failure") {
|
|
1391
|
+
classifyFailure(selected);
|
|
914
1392
|
return refuse(GATE.FAILED, `selected run concluded FAILURE at head ${r.head}`, url);
|
|
915
1393
|
}
|
|
916
1394
|
if (selected.conclusion === "cancelled") {
|
|
@@ -963,7 +1441,7 @@ export function shipGate(o: GateOptions, gh: Gh, log: (m: string) => void): Gate
|
|
|
963
1441
|
);
|
|
964
1442
|
const required = r.skippedLanes.filter((l) => requiredLanes.includes(l));
|
|
965
1443
|
if (required.length) {
|
|
966
|
-
log(`declared in bkit.testing.
|
|
1444
|
+
log(`declared in bkit.testing.ciRequired: ${requiredLanes.join(",")}`);
|
|
967
1445
|
return refuse(
|
|
968
1446
|
GATE.LANE_SKIPPED,
|
|
969
1447
|
`required lane(s) concluded 'skipped' at head ${r.head} — vacuous green: ${required.join(", ")}`,
|
|
@@ -1109,15 +1587,6 @@ export const EXIT_SKIP_TOKEN = 4;
|
|
|
1109
1587
|
/** Exit code: the pushed head's commit message could not be read for the body scan. */
|
|
1110
1588
|
export const EXIT_SCAN_ERROR = 5;
|
|
1111
1589
|
|
|
1112
|
-
const wholeNumber = (v: FlagValue, flag: string, fallback: number, min = 0): number => {
|
|
1113
|
-
if (v === undefined) return fallback;
|
|
1114
|
-
const s = String(v);
|
|
1115
|
-
if (!/^[0-9]+$/.test(s) || Number(s) < min) {
|
|
1116
|
-
throw new CommandError(EXIT.USAGE, `--${flag} takes a whole number >= ${min} (got "${s}")`);
|
|
1117
|
-
}
|
|
1118
|
-
return Number(s);
|
|
1119
|
-
};
|
|
1120
|
-
|
|
1121
1590
|
const HEAD_FLAG: FlagSpec = { name: "head", type: "string", help: "commit SHA" };
|
|
1122
1591
|
const REPO_FLAG: FlagSpec = {
|
|
1123
1592
|
name: "repo",
|
|
@@ -1354,11 +1823,12 @@ async function runDispatch(ctx: RunContext): Promise<number> {
|
|
|
1354
1823
|
if ((file === undefined) !== (step === undefined))
|
|
1355
1824
|
throw new CommandError(EXIT.USAGE, "--file and --step go together");
|
|
1356
1825
|
let row: Record<string, unknown> | null = null;
|
|
1826
|
+
let progressLine: string | undefined;
|
|
1357
1827
|
let transport: Record<string, unknown> | null = null;
|
|
1358
1828
|
const code = dispatchCode(r, pr, scanResult, ctx.log);
|
|
1359
1829
|
if (file !== undefined && r.ciDispatch !== null) {
|
|
1360
1830
|
const status = path.resolve(ctx.cwd, file);
|
|
1361
|
-
|
|
1831
|
+
const written = writeStepRow(
|
|
1362
1832
|
ctx.cwd,
|
|
1363
1833
|
{
|
|
1364
1834
|
file: status,
|
|
@@ -1372,7 +1842,9 @@ async function runDispatch(ctx: RunContext): Promise<number> {
|
|
|
1372
1842
|
commit: "none",
|
|
1373
1843
|
},
|
|
1374
1844
|
ctx.log,
|
|
1375
|
-
)
|
|
1845
|
+
);
|
|
1846
|
+
row = written.row;
|
|
1847
|
+
progressLine = written.progressLine;
|
|
1376
1848
|
if (/-close-workflow$/.test(step!)) {
|
|
1377
1849
|
const tree = git(ctx.cwd, ["rev-parse", "--show-toplevel"]) ?? ctx.cwd;
|
|
1378
1850
|
restateOutcome(tree, status, String(f.workflow ?? "build"), { ...r.ciDispatch }, ctx.log);
|
|
@@ -1392,6 +1864,7 @@ async function runDispatch(ctx: RunContext): Promise<number> {
|
|
|
1392
1864
|
ciWorkflow: r.ciWorkflow,
|
|
1393
1865
|
row,
|
|
1394
1866
|
transport,
|
|
1867
|
+
...(progressLine === undefined ? {} : { progressLine }),
|
|
1395
1868
|
});
|
|
1396
1869
|
return EXIT.NO;
|
|
1397
1870
|
}
|
|
@@ -1413,6 +1886,7 @@ async function runDispatch(ctx: RunContext): Promise<number> {
|
|
|
1413
1886
|
ciWorkflow: r.ciWorkflow,
|
|
1414
1887
|
row,
|
|
1415
1888
|
transport,
|
|
1889
|
+
...(progressLine === undefined ? {} : { progressLine }),
|
|
1416
1890
|
});
|
|
1417
1891
|
return code;
|
|
1418
1892
|
}
|
|
@@ -1483,6 +1957,17 @@ function logResolvedPrRepo(
|
|
|
1483
1957
|
|
|
1484
1958
|
function runGate(ctx: RunContext): number {
|
|
1485
1959
|
const f = ctx.flags;
|
|
1960
|
+
let selection: CiSelection | undefined;
|
|
1961
|
+
const selectionFile = str(f.ciSelectionFile);
|
|
1962
|
+
if (selectionFile !== undefined) {
|
|
1963
|
+
const parsed = readJsonFile(path.resolve(ctx.cwd, selectionFile));
|
|
1964
|
+
if (!parsed.ok || !validateCiSelection(parsed.value))
|
|
1965
|
+
throw new CommandError(
|
|
1966
|
+
EXIT.USAGE,
|
|
1967
|
+
"cannot read validated CI selection: unreadable JSON or invalid selection",
|
|
1968
|
+
);
|
|
1969
|
+
selection = parsed.value;
|
|
1970
|
+
}
|
|
1486
1971
|
const given = [f.head, f.pr, f.squashOf].filter((v) => v !== undefined).length;
|
|
1487
1972
|
if (given !== 1)
|
|
1488
1973
|
throw new CommandError(EXIT.USAGE, "give exactly one of --head, --pr, --squash-of");
|
|
@@ -1585,7 +2070,7 @@ function runGate(ctx: RunContext): number {
|
|
|
1585
2070
|
// A title carrying a skip token would squash into a dev commit CI never runs on.
|
|
1586
2071
|
const title = pr?.kind === "ok" ? (pr.pr?.title ?? "") : "";
|
|
1587
2072
|
const titleToken = f.pr !== undefined ? SKIP_CI_TOKEN.exec(title)?.[0] : undefined;
|
|
1588
|
-
|
|
2073
|
+
let r: GateResult =
|
|
1589
2074
|
titleToken !== undefined
|
|
1590
2075
|
? {
|
|
1591
2076
|
code: GATE.TITLE_SKIP,
|
|
@@ -1602,6 +2087,8 @@ function runGate(ctx: RunContext): number {
|
|
|
1602
2087
|
repo: str(f.repo) ?? null,
|
|
1603
2088
|
skippedLanes: [],
|
|
1604
2089
|
nonBookkeepingPaths: [],
|
|
2090
|
+
failedSteps: [],
|
|
2091
|
+
regenerable: false,
|
|
1605
2092
|
reason: `PR title '${title}' contains the CI-suppressing token ${titleToken}`,
|
|
1606
2093
|
}
|
|
1607
2094
|
: shipGate(
|
|
@@ -1623,6 +2110,54 @@ function runGate(ctx: RunContext): number {
|
|
|
1623
2110
|
);
|
|
1624
2111
|
if (titleToken !== undefined) ctx.log(r.reason);
|
|
1625
2112
|
|
|
2113
|
+
// Debug retains the configured gate above and also proves the original
|
|
2114
|
+
// selected workflow at the pushed head. A different workflow need not contain
|
|
2115
|
+
// the configured capstone, but its whole run must have completed successfully.
|
|
2116
|
+
let verifyingRun: Run | undefined;
|
|
2117
|
+
if (r.code === EXIT.OK && selection?.mode === "ci") {
|
|
2118
|
+
const repo = str(f.repo) ?? r.repo;
|
|
2119
|
+
let reason = "";
|
|
2120
|
+
let code: number = GATE.FAILED;
|
|
2121
|
+
if (repo !== selection.repo) {
|
|
2122
|
+
reason = "selected CI repository differs from the gated repository";
|
|
2123
|
+
} else {
|
|
2124
|
+
const response = gh([
|
|
2125
|
+
"api",
|
|
2126
|
+
`/repos/${selection.repo}/actions/workflows/${selection.workflowId}/runs?head_sha=${queryValue(head)}`,
|
|
2127
|
+
]);
|
|
2128
|
+
if (!response.ok) {
|
|
2129
|
+
code = response.missing ? EXIT.USE_MCP : GATE.API_ERROR;
|
|
2130
|
+
reason = "selected workflow verification is unavailable";
|
|
2131
|
+
} else {
|
|
2132
|
+
const payload = jsonOrUndefined(response.stdout);
|
|
2133
|
+
const candidates = arr(obj(payload).workflow_runs)
|
|
2134
|
+
.filter(
|
|
2135
|
+
(value) =>
|
|
2136
|
+
String(obj(value).workflow_id) === selection.workflowId &&
|
|
2137
|
+
text(obj(obj(value).repository).full_name).toLowerCase() ===
|
|
2138
|
+
selection.repo.toLowerCase() &&
|
|
2139
|
+
text(obj(obj(value).head_repository).full_name).toLowerCase() ===
|
|
2140
|
+
selection.repo.toLowerCase() &&
|
|
2141
|
+
obj(value).head_branch === (str(f.branch) ?? selection.headBranch) &&
|
|
2142
|
+
(str(f.event) === undefined || obj(value).event === str(f.event)),
|
|
2143
|
+
)
|
|
2144
|
+
.map(toRun)
|
|
2145
|
+
.filter((run) => run.head_sha === head && run.id !== null);
|
|
2146
|
+
verifyingRun = latest(candidates.filter((run) => run.status === "completed"));
|
|
2147
|
+
if (!verifyingRun) {
|
|
2148
|
+
code = candidates.length > 0 ? GATE.IN_PROGRESS : GATE.NO_RUN;
|
|
2149
|
+
reason = `selected workflow ${selection.workflowId} has no completed run at pushed head ${head}`;
|
|
2150
|
+
} else if (verifyingRun.conclusion !== "success") {
|
|
2151
|
+
reason = `selected workflow verification concluded '${verifyingRun.conclusion}' at pushed head ${head}`;
|
|
2152
|
+
}
|
|
2153
|
+
}
|
|
2154
|
+
}
|
|
2155
|
+
if (reason) {
|
|
2156
|
+
ctx.log(reason);
|
|
2157
|
+
r = { ...r, code, passed: false, overridden: false, reason };
|
|
2158
|
+
}
|
|
2159
|
+
}
|
|
2160
|
+
|
|
1626
2161
|
if (recordFile !== undefined && r.code !== EXIT.USE_MCP) {
|
|
1627
2162
|
if (f.capstoneOnly === true) {
|
|
1628
2163
|
const verdict = r.code === EXIT.OK ? "PASS" : "FAIL";
|
|
@@ -1636,7 +2171,17 @@ function runGate(ctx: RunContext): number {
|
|
|
1636
2171
|
auditRow(recordFile, "ship-gate-refusal", { exitCode: r.code, head: r.mergeHead });
|
|
1637
2172
|
}
|
|
1638
2173
|
}
|
|
1639
|
-
ctx.emit({
|
|
2174
|
+
ctx.emit({
|
|
2175
|
+
...r,
|
|
2176
|
+
...(selection?.mode === "ci"
|
|
2177
|
+
? {
|
|
2178
|
+
originalRunId: selection.runId,
|
|
2179
|
+
originalRunUrl: selection.runUrl,
|
|
2180
|
+
verifyingRunId: verifyingRun?.id ?? null,
|
|
2181
|
+
verifyingRunUrl: verifyingRun?.html_url ?? null,
|
|
2182
|
+
}
|
|
2183
|
+
: {}),
|
|
2184
|
+
});
|
|
1640
2185
|
return r.code;
|
|
1641
2186
|
}
|
|
1642
2187
|
|
|
@@ -1966,9 +2511,63 @@ export const runsCommand: CommandSpec = {
|
|
|
1966
2511
|
summary:
|
|
1967
2512
|
"CI runs: wait for one, prove one was dispatched, re-validate and gate a merge on one; auto's start context.",
|
|
1968
2513
|
verbs: {
|
|
2514
|
+
locate: {
|
|
2515
|
+
summary:
|
|
2516
|
+
"Select and validate the red CI run for the adopted debug branch before local discovery: exit 0 selects red CI, 1 selects local discovery, 2 rejects arguments, 8 rejects ambiguous references, 80 requests read fallback, and 82 requires owner action for unavailable or mismatched evidence.",
|
|
2517
|
+
use: "workflow",
|
|
2518
|
+
flags: [
|
|
2519
|
+
{
|
|
2520
|
+
name: "prompt-file",
|
|
2521
|
+
type: "string",
|
|
2522
|
+
required: true,
|
|
2523
|
+
help: "session prompt; [local] overrides all CI references",
|
|
2524
|
+
},
|
|
2525
|
+
{
|
|
2526
|
+
name: "issue-text-file",
|
|
2527
|
+
type: "string",
|
|
2528
|
+
help: "current issue description and human comments from issues text",
|
|
2529
|
+
},
|
|
2530
|
+
{ name: "branch", type: "string", required: true, help: "adopted existing branch" },
|
|
2531
|
+
{ name: "repo", type: "string", required: true, help: "owner/repository" },
|
|
2532
|
+
{
|
|
2533
|
+
name: "file",
|
|
2534
|
+
type: "string",
|
|
2535
|
+
help: "active debug status log; saved selection takes precedence over issue discovery",
|
|
2536
|
+
},
|
|
2537
|
+
{
|
|
2538
|
+
name: "selection-out",
|
|
2539
|
+
type: "string",
|
|
2540
|
+
required: true,
|
|
2541
|
+
help: "write the validated candidate selection; does not update active metadata",
|
|
2542
|
+
},
|
|
2543
|
+
{
|
|
2544
|
+
name: "evidence-file",
|
|
2545
|
+
type: "string",
|
|
2546
|
+
help: "normalized fallback JSON: exact request identity, run, complete jobs, complete:true; automatic no-red also identifies workflow and inspected head",
|
|
2547
|
+
},
|
|
2548
|
+
],
|
|
2549
|
+
output: {
|
|
2550
|
+
selection: "ci | local",
|
|
2551
|
+
runId: "selected run ID, or null",
|
|
2552
|
+
runUrl: "selected attempt URL, or null",
|
|
2553
|
+
runAttempt: "frozen attempt, or null",
|
|
2554
|
+
workflowId: "selected workflow ID, or null",
|
|
2555
|
+
workflowPath: "selected workflow path, or null",
|
|
2556
|
+
headSha: "selected commit, or null",
|
|
2557
|
+
headRelation: "current | ancestor | null; divergent or unknown evidence exits 82",
|
|
2558
|
+
failedJobs: "complete failed-job list",
|
|
2559
|
+
tiers: "known failed tiers; empty when any failed job is unknown",
|
|
2560
|
+
via: "prompt-run | prompt-pr | issue-run | issue-pr | branch, or null",
|
|
2561
|
+
reason: "local selection reason, or null",
|
|
2562
|
+
selectionFile: "validated candidate JSON path",
|
|
2563
|
+
},
|
|
2564
|
+
exitCodes: { 8: "ambiguous winning references" },
|
|
2565
|
+
run: locateCi,
|
|
2566
|
+
},
|
|
1969
2567
|
wait: {
|
|
1970
2568
|
summary:
|
|
1971
2569
|
"Bounded poll for a CI check on a PR (--pr) or a CI run at a head (--head --branch), present or completed.",
|
|
2570
|
+
use: "by-hand",
|
|
1972
2571
|
flags: [
|
|
1973
2572
|
{ name: "pr", type: "string", help: "PR number: read its check rollup" },
|
|
1974
2573
|
{ ...HEAD_FLAG, help: "commit SHA: read the CI workflow's runs at it (with --branch)" },
|
|
@@ -2008,6 +2607,7 @@ export const runsCommand: CommandSpec = {
|
|
|
2008
2607
|
dispatch: {
|
|
2009
2608
|
summary:
|
|
2010
2609
|
"CI-Dispatch Gate after the last push: poll, one clean re-trigger, the ciDispatch verdict, and the body scan. A run in place on dev has no PR: it polls the push-event run at the pushed sha, and its re-trigger commits and pushes only the run's own work.",
|
|
2610
|
+
use: "workflow",
|
|
2011
2611
|
flags: [
|
|
2012
2612
|
{
|
|
2013
2613
|
name: "pr",
|
|
@@ -2082,6 +2682,8 @@ export const runsCommand: CommandSpec = {
|
|
|
2082
2682
|
ciWorkflow: "the CI workflow file the no-ci check looked for",
|
|
2083
2683
|
row: "--file: the step-done row written (null on a hand-off)",
|
|
2084
2684
|
transport: "--file: the close-transport row written for a passed verdict, else null",
|
|
2685
|
+
progressLine:
|
|
2686
|
+
"--file: the exact chat progress line after a numbered completion is recorded",
|
|
2085
2687
|
},
|
|
2086
2688
|
exitCodes: {
|
|
2087
2689
|
[EXIT_SKIP_TOKEN]: "the pushed head's body carries a CI-suppression token",
|
|
@@ -2093,7 +2695,13 @@ export const runsCommand: CommandSpec = {
|
|
|
2093
2695
|
gate: {
|
|
2094
2696
|
summary:
|
|
2095
2697
|
"Ship merge gate: the capstone job present and green at the head (exit 0), or why not.",
|
|
2698
|
+
use: "workflow",
|
|
2096
2699
|
flags: [
|
|
2700
|
+
{
|
|
2701
|
+
name: "ci-selection-file",
|
|
2702
|
+
type: "string",
|
|
2703
|
+
help: "validated original debug selection: additionally require its workflow to succeed at the exact pushed head",
|
|
2704
|
+
},
|
|
2097
2705
|
{ ...HEAD_FLAG, help: "the PR head to merge (or --pr / --squash-of)" },
|
|
2098
2706
|
{
|
|
2099
2707
|
name: "pr",
|
|
@@ -2158,6 +2766,12 @@ export const runsCommand: CommandSpec = {
|
|
|
2158
2766
|
testedHead: "head the selected (or superseded) run tested",
|
|
2159
2767
|
runId: "selected run id",
|
|
2160
2768
|
runUrl: "selected run URL",
|
|
2769
|
+
originalRunId: "--ci-selection-file: original failing run ID",
|
|
2770
|
+
originalRunUrl: "--ci-selection-file: original failing attempt URL",
|
|
2771
|
+
verifyingRunId:
|
|
2772
|
+
"--ci-selection-file: selected workflow's verifying run ID at the pushed head",
|
|
2773
|
+
verifyingRunUrl:
|
|
2774
|
+
"--ci-selection-file: selected workflow's verifying run URL at the pushed head",
|
|
2161
2775
|
conclusion: "selected run conclusion",
|
|
2162
2776
|
capstone: "capstone job name",
|
|
2163
2777
|
ciWorkflow: "CI workflow file",
|
|
@@ -2186,6 +2800,7 @@ export const runsCommand: CommandSpec = {
|
|
|
2186
2800
|
revalidate: {
|
|
2187
2801
|
summary:
|
|
2188
2802
|
"Ship: pick the head CI must pass at, probe for a run there, dispatch only when none, wait for it to complete.",
|
|
2803
|
+
use: "workflow",
|
|
2189
2804
|
flags: [
|
|
2190
2805
|
{ name: "pr", type: "string", required: true, help: "the PR number" },
|
|
2191
2806
|
{ name: "entry-head", type: "string", required: true, help: "the PR head read at Step 2" },
|
|
@@ -2235,6 +2850,7 @@ export const runsCommand: CommandSpec = {
|
|
|
2235
2850
|
mirror: {
|
|
2236
2851
|
summary:
|
|
2237
2852
|
"Release PR: wait for the branch's push run at the head and copy its capstone verdict.",
|
|
2853
|
+
use: "workflow",
|
|
2238
2854
|
flags: [
|
|
2239
2855
|
{ ...HEAD_FLAG, required: true, help: "the PR head (same SHA the push run tests)" },
|
|
2240
2856
|
{ name: "branch", type: "string", help: "branch whose push run to mirror (default dev)" },
|
|
@@ -2270,6 +2886,7 @@ export const runsCommand: CommandSpec = {
|
|
|
2270
2886
|
context: {
|
|
2271
2887
|
summary:
|
|
2272
2888
|
"/bkit-auto Step 1: the phase and mode, the repo, and the issue / FID / PR / run the dispatch carries.",
|
|
2889
|
+
use: "workflow",
|
|
2273
2890
|
flags: [
|
|
2274
2891
|
{
|
|
2275
2892
|
name: "phase",
|
|
@@ -2319,6 +2936,7 @@ export const runsCommand: CommandSpec = {
|
|
|
2319
2936
|
declared: {
|
|
2320
2937
|
summary:
|
|
2321
2938
|
"Whether the repo declares a CI workflow: .github/workflows/<bkit.testing.ciWorkflow> exists (exit 0) or not (exit 1).",
|
|
2939
|
+
use: "by-hand",
|
|
2322
2940
|
flags: [],
|
|
2323
2941
|
output: {
|
|
2324
2942
|
declared: "the workflow file exists",
|