@cbartens/bkit 5.5.1 → 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 +167 -154
- package/.bkit/core/.agents/context.md +95 -29
- package/.bkit/core/.agents/docs.md +18 -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 +112 -102
- package/.bkit/core/.agents/skills.md +63 -15
- package/.bkit/core/.bkit/README.md +167 -154
- package/.bkit/core/.bkit/authoring.md +747 -0
- package/.bkit/core/.bkit/cli.md +407 -0
- package/.bkit/core/.bkit/cloud.md +283 -195
- package/.bkit/core/.bkit/comparison.md +45 -43
- package/.bkit/core/.bkit/install.md +166 -95
- package/.bkit/core/.bkit/jsonl.md +339 -196
- package/.bkit/core/.bkit/pipeline.md +142 -145
- package/.bkit/core/.bkit/prompts.md +295 -264
- package/.bkit/core/.bkit/providers.md +460 -277
- package/.bkit/core/.bkit/router.md +69 -0
- package/.bkit/core/.bkit/templates.md +530 -256
- package/.bkit/core/.bkit/trackers.md +116 -65
- package/.bkit/core/.bkit/workflows.md +742 -618
- 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 +6 -80
- package/.bkit/core/docs/templates/bkit-audit-accessibility.md +128 -130
- package/.bkit/core/docs/templates/bkit-audit-adoption.md +104 -94
- package/.bkit/core/docs/templates/bkit-audit-agents.md +96 -98
- package/.bkit/core/docs/templates/bkit-audit-aio-seo.md +100 -103
- package/.bkit/core/docs/templates/bkit-audit-analytics.md +141 -107
- package/.bkit/core/docs/templates/bkit-audit-annotations.md +99 -97
- package/.bkit/core/docs/templates/bkit-audit-app-performance.md +122 -121
- package/.bkit/core/docs/templates/bkit-audit-app-store.md +158 -101
- package/.bkit/core/docs/templates/bkit-audit-architecture.md +114 -96
- package/.bkit/core/docs/templates/bkit-audit-ci-performance.md +76 -97
- package/.bkit/core/docs/templates/bkit-audit-config.md +123 -101
- package/.bkit/core/docs/templates/bkit-audit-cost.md +86 -99
- package/.bkit/core/docs/templates/bkit-audit-coverage.md +76 -93
- package/.bkit/core/docs/templates/bkit-audit-database.md +102 -95
- package/.bkit/core/docs/templates/bkit-audit-dead-code.md +165 -108
- package/.bkit/core/docs/templates/bkit-audit-deferrals.md +115 -109
- package/.bkit/core/docs/templates/bkit-audit-dependencies.md +265 -113
- package/.bkit/core/docs/templates/bkit-audit-documentation.md +119 -118
- package/.bkit/core/docs/templates/bkit-audit-duplication.md +140 -111
- package/.bkit/core/docs/templates/bkit-audit-failures.md +111 -106
- package/.bkit/core/docs/templates/bkit-audit-flakes.md +100 -99
- package/.bkit/core/docs/templates/bkit-audit-gates.md +107 -103
- package/.bkit/core/docs/templates/bkit-audit-issues.md +105 -105
- package/.bkit/core/docs/templates/bkit-audit-llm.md +134 -85
- package/.bkit/core/docs/templates/bkit-audit-logs.md +124 -125
- package/.bkit/core/docs/templates/bkit-audit-models.md +99 -78
- package/.bkit/core/docs/templates/bkit-audit-privacy.md +56 -76
- package/.bkit/core/docs/templates/bkit-audit-prompts.md +63 -78
- package/.bkit/core/docs/templates/bkit-audit-red-team.md +125 -93
- package/.bkit/core/docs/templates/bkit-audit-reliability.md +97 -96
- package/.bkit/core/docs/templates/bkit-audit-repo.md +170 -98
- package/.bkit/core/docs/templates/bkit-audit-security.md +207 -121
- package/.bkit/core/docs/templates/bkit-audit-slop.md +78 -95
- package/.bkit/core/docs/templates/bkit-audit-testing.md +163 -139
- package/.bkit/core/docs/templates/bkit-audit-usability.md +114 -96
- package/.bkit/core/docs/templates/bkit-plan.md +158 -281
- package/.bkit/core/engine/checks/after/auth.ts +40 -37
- package/.bkit/core/engine/checks/after/ci-yml.ts +104 -31
- package/.bkit/core/engine/checks/after/github.ts +95 -17
- package/.bkit/core/engine/checks/after/index.ts +21 -8
- package/.bkit/core/engine/checks/after/suppression.ts +8 -5
- package/.bkit/core/engine/checks/after/tools.ts +125 -123
- package/.bkit/core/engine/checks/before/context-fetch.ts +227 -33
- package/.bkit/core/engine/checks/before/env.ts +3 -3
- package/.bkit/core/engine/checks/before/files.ts +5 -4
- package/.bkit/core/engine/checks/before/index.ts +25 -1
- package/.bkit/core/engine/checks/before/repo.ts +208 -2
- package/.bkit/core/engine/checks/status-holes.ts +916 -123
- package/.bkit/core/engine/checks/tips/catalogue.ts +82 -20
- package/.bkit/core/engine/checks/tips/detect.ts +66 -0
- package/.bkit/core/engine/checks/tips/index.ts +52 -11
- package/.bkit/core/engine/cli.ts +251 -130
- package/.bkit/core/engine/commands/analysis.ts +282 -199
- 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/comply.ts +77 -103
- package/.bkit/core/engine/commands/install/doctor.ts +2 -2
- package/.bkit/core/engine/commands/install/install.ts +57 -18
- package/.bkit/core/engine/commands/install/uninstall.ts +86 -55
- package/.bkit/core/engine/commands/install/upgrade.ts +32 -15
- package/.bkit/core/engine/commands/land.ts +139 -18
- package/.bkit/core/engine/commands/lib.ts +381 -22
- package/.bkit/core/engine/commands/registry.ts +10 -2
- package/.bkit/core/engine/commands/setup/setup.ts +8 -7
- package/.bkit/core/engine/commands/stats.ts +260 -0
- package/.bkit/core/engine/commands/tips.ts +10 -5
- package/.bkit/core/engine/commands/workflow/branches.ts +2215 -176
- package/.bkit/core/engine/commands/workflow/challenge.ts +748 -0
- package/.bkit/core/engine/commands/workflow/completeness.ts +109 -0
- package/.bkit/core/engine/commands/workflow/context.ts +1249 -47
- package/.bkit/core/engine/commands/workflow/counters.ts +483 -95
- package/.bkit/core/engine/commands/workflow/decisions.ts +585 -0
- package/.bkit/core/engine/commands/workflow/disk.ts +238 -56
- package/.bkit/core/engine/commands/workflow/fids.ts +811 -33
- package/.bkit/core/engine/commands/workflow/issues.ts +413 -64
- package/.bkit/core/engine/commands/workflow/ledgers.ts +1333 -36
- package/.bkit/core/engine/commands/workflow/locks.ts +28 -2
- package/.bkit/core/engine/commands/workflow/plan-blocks.ts +691 -0
- package/.bkit/core/engine/commands/workflow/plan-versions.ts +21 -0
- package/.bkit/core/engine/commands/workflow/plans.ts +257 -0
- package/.bkit/core/engine/commands/workflow/prs.ts +178 -33
- package/.bkit/core/engine/commands/workflow/repo.ts +66 -8
- package/.bkit/core/engine/commands/workflow/roadmap.ts +72 -22
- package/.bkit/core/engine/commands/workflow/run-facts.ts +492 -0
- package/.bkit/core/engine/commands/workflow/runs.ts +827 -79
- package/.bkit/core/engine/commands/workflow/runtime.ts +25 -1
- package/.bkit/core/engine/commands/workflow/skills.ts +1 -0
- package/.bkit/core/engine/commands/workflow/status.ts +329 -33
- package/.bkit/core/engine/commands/workflow/step-table.ts +381 -0
- package/.bkit/core/engine/commands/workflow/steps.ts +841 -105
- package/.bkit/core/engine/commands/workflow/summary-findings.ts +177 -0
- package/.bkit/core/engine/commands/workflow/summary.ts +544 -0
- 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 +2124 -330
- package/.bkit/core/engine/commands/workflow/tracker.ts +1195 -0
- package/.bkit/core/engine/commands/workflow/workflows.ts +1197 -235
- package/.bkit/core/engine/commands/workflow/worktrees.ts +543 -24
- 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 +67 -17
- package/.bkit/core/engine/install/modules/antigravity.ts +3 -2
- package/.bkit/core/engine/install/modules/cloud.ts +24 -16
- package/.bkit/core/engine/install/modules/codex.ts +15 -2
- package/.bkit/core/engine/install/modules/core.ts +1196 -45
- package/.bkit/core/engine/install/modules/cursor.ts +6 -6
- package/.bkit/core/engine/install/modules/opencode.ts +18 -6
- package/.bkit/core/engine/install/template-notes.ts +130 -0
- package/.bkit/core/engine/install/version-file.ts +9 -4
- 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/migrate.ts +92 -0
- package/.bkit/core/engine/ledgers/status.ts +249 -21
- package/.bkit/core/engine/ledgers/telemetry.ts +1397 -253
- package/.bkit/core/engine/render/hosts.ts +118 -14
- package/.bkit/core/engine/render/models.ts +12 -0
- package/.bkit/core/engine/shared/bkit-latest.ts +26 -4
- package/.bkit/core/engine/shared/branches.ts +4 -1
- package/.bkit/core/engine/shared/dep-updater.ts +60 -0
- package/.bkit/core/engine/shared/egress.ts +8 -1
- package/.bkit/core/engine/shared/json.ts +25 -7
- package/.bkit/core/engine/shared/package-manager.ts +9 -0
- package/.bkit/core/engine/shared/settings.ts +243 -31
- package/.bkit/core/engine/shared/text.ts +361 -0
- 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 +215 -0
- package/.bkit/core/engine/tools/instructions-sources.ts +832 -0
- package/.bkit/core/engine/tools/instructions.ts +1802 -0
- package/.bkit/core/hooks/antigravity-hook.js +25 -10
- package/.bkit/core/hooks/gateguard-engine.js +54 -29
- package/.bkit/core/hooks/guardrails-shell.js +4 -5
- package/.bkit/core/hooks/guardrails-tiers.js +10 -4
- 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 +202 -94
- package/.bkit/core/prompts/bkit-build-challenge-1.md +76 -34
- package/.bkit/core/prompts/bkit-build-challenge-2.md +85 -38
- package/.bkit/core/prompts/bkit-build-install-skills.md +50 -28
- package/.bkit/core/prompts/bkit-build-plan-convert.md +85 -0
- package/.bkit/core/prompts/bkit-build-plan-current.md +59 -36
- package/.bkit/core/prompts/bkit-build-plan-gaps-remediate.md +101 -36
- 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 +104 -43
- package/.bkit/core/prompts/bkit-debug-abort-handover.md +47 -32
- package/.bkit/core/prompts/bkit-debug-failure-diagnose.md +109 -57
- package/.bkit/core/prompts/bkit-debug-failure-remediate.md +65 -39
- package/.bkit/core/prompts/bkit-debug-failure-reproduce.md +53 -31
- package/.bkit/core/prompts/bkit-debug-failure-soak.md +65 -34
- package/.bkit/core/prompts/bkit-design-brainstorm-ideate-1.md +46 -31
- package/.bkit/core/prompts/bkit-design-brainstorm-ideate-2.md +45 -31
- package/.bkit/core/prompts/bkit-design-brainstorm-ideate-3.md +43 -30
- package/.bkit/core/prompts/bkit-design-generate.md +80 -46
- package/.bkit/core/prompts/bkit-design-organise.md +83 -32
- package/.bkit/core/prompts/bkit-design-review-1.md +70 -50
- package/.bkit/core/prompts/bkit-design-review-2.md +65 -46
- package/.bkit/core/prompts/bkit-design-spike.md +64 -40
- package/.bkit/core/prompts/bkit-design-update.md +53 -28
- package/.bkit/core/prompts/bkit-plan-generate.md +101 -29
- package/.bkit/core/prompts/bkit-plan-review-1.md +78 -41
- package/.bkit/core/prompts/bkit-plan-review-2.md +78 -35
- package/.bkit/core/prompts/bkit-plan-scope-check.md +116 -0
- package/.bkit/core/prompts/bkit-plan-update.md +86 -31
- package/.bkit/core/prompts/bkit-ship-conflict-resolve.md +94 -50
- package/.bkit/core/prompts/bkit-ship-deferred-sweep.md +91 -41
- package/.bkit/core/prompts/bkit-ship-update-docs.md +45 -24
- package/.bkit/core/prompts/bkit-utility-compress-markdown.md +65 -49
- package/.bkit/core/prompts/bkit-utility-update-decisions.md +87 -42
- package/.bkit/core/prompts/bkit-utility-update-deferrals.md +81 -37
- package/.bkit/core/prompts/bkit-utility-update-documentation.md +43 -25
- package/.bkit/core/prompts/bkit-utility-update-failures.md +84 -37
- package/.bkit/core/prompts/bkit-utility-update-knowledge.md +88 -42
- package/.bkit/core/prompts/bkit-utility-update-roadmap.md +92 -39
- package/.bkit/core/prompts/bkit-utility-update-tracker.md +159 -60
- package/.bkit/core/workflows/bkit-auto.md +89 -58
- package/.bkit/core/workflows/bkit-build.md +967 -517
- package/.bkit/core/workflows/bkit-debug.md +555 -387
- package/.bkit/core/workflows/bkit-design.md +319 -283
- package/.bkit/core/workflows/bkit-plan.md +319 -342
- package/.bkit/core/workflows/bkit-ship.md +525 -328
- package/.bkit/shared/.agents/plugins/bkit/hooks.json +10 -0
- package/.bkit/shared/.bkit/.env.example +2 -2
- package/.bkit/shared/.claude/bkit-cloud.md +12 -10
- package/.bkit/shared/.claude/settings.json +14 -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/.cursor/mcp.json +1 -1
- package/.bkit/shared/.cursor/rules/bkit-rules.mdc +1 -1
- package/.bkit/shared/.gitattributes +1 -1
- package/.bkit/shared/.mcp.json +1 -1
- package/.bkit/shared/.opencode/opencode.json +12 -1
- package/.bkit/shared/CLAUDE.md +6 -2
- package/.bkit/shared/GEMINI.md +5 -2
- package/.bkit/shared/docs/architecture.md +4 -7
- package/.bkit/shared/docs/data-schema.md +4 -7
- package/.bkit/shared/docs/deployments.md +241 -168
- 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 +289 -174
- 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 +45 -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 +54 -51
- package/.bkit/templates/.github/workflows/bkit-cloud.yml +34 -33
- 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 +96 -36
- package/.bkit/templates/.prettierignore +6 -0
- 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 +10 -2
- 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 +231 -0
- package/README.md +278 -89
- package/dist/checks/after/auth.js +36 -33
- package/dist/checks/after/ci-yml.js +91 -30
- package/dist/checks/after/github.js +91 -17
- package/dist/checks/after/index.js +22 -11
- package/dist/checks/after/suppression.js +8 -5
- package/dist/checks/after/tools.js +111 -114
- package/dist/checks/before/context-fetch.js +218 -33
- package/dist/checks/before/env.js +3 -3
- package/dist/checks/before/files.js +5 -3
- package/dist/checks/before/index.js +20 -3
- package/dist/checks/before/repo.js +197 -2
- package/dist/checks/status-holes.js +739 -114
- package/dist/checks/tips/catalogue.js +70 -19
- package/dist/checks/tips/detect.js +62 -0
- package/dist/checks/tips/index.js +51 -9
- package/dist/cli.js +234 -124
- package/dist/commands/analysis.js +174 -141
- 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/comply.js +54 -91
- package/dist/commands/install/doctor.js +2 -2
- package/dist/commands/install/install.js +50 -19
- package/dist/commands/install/uninstall.js +82 -55
- package/dist/commands/install/upgrade.js +21 -11
- package/dist/commands/land.js +137 -17
- package/dist/commands/lib.js +295 -21
- package/dist/commands/registry.js +10 -2
- package/dist/commands/setup/setup.js +8 -7
- package/dist/commands/stats.js +175 -0
- package/dist/commands/tips.js +7 -3
- package/dist/commands/workflow/branches.js +1873 -152
- package/dist/commands/workflow/challenge.js +609 -0
- package/dist/commands/workflow/completeness.js +97 -0
- package/dist/commands/workflow/context.js +1045 -46
- package/dist/commands/workflow/counters.js +385 -86
- package/dist/commands/workflow/decisions.js +484 -0
- package/dist/commands/workflow/disk.js +214 -56
- package/dist/commands/workflow/fids.js +706 -33
- package/dist/commands/workflow/issues.js +349 -59
- package/dist/commands/workflow/ledgers.js +1123 -37
- package/dist/commands/workflow/locks.js +26 -2
- package/dist/commands/workflow/plan-blocks.js +501 -0
- package/dist/commands/workflow/plan-versions.js +22 -0
- package/dist/commands/workflow/plans.js +205 -0
- package/dist/commands/workflow/prs.js +154 -35
- package/dist/commands/workflow/repo.js +58 -8
- package/dist/commands/workflow/roadmap.js +58 -23
- package/dist/commands/workflow/run-facts.js +421 -0
- package/dist/commands/workflow/runs.js +670 -72
- package/dist/commands/workflow/runtime.js +15 -1
- package/dist/commands/workflow/skills.js +1 -0
- package/dist/commands/workflow/status.js +282 -34
- package/dist/commands/workflow/step-table.js +308 -0
- package/dist/commands/workflow/steps.js +703 -96
- package/dist/commands/workflow/summary-findings.js +117 -0
- package/dist/commands/workflow/summary.js +388 -0
- 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 +1695 -305
- package/dist/commands/workflow/tracker.js +983 -0
- package/dist/commands/workflow/workflows.js +1014 -222
- package/dist/commands/workflow/worktrees.js +432 -26
- package/dist/install/cloud-env.js +233 -99
- package/dist/install/context-ci-workflow.js +85 -0
- package/dist/install/manifest.js +64 -17
- package/dist/install/modules/antigravity.js +3 -2
- package/dist/install/modules/cloud.js +25 -16
- package/dist/install/modules/codex.js +12 -2
- package/dist/install/modules/core.js +1090 -48
- package/dist/install/modules/cursor.js +6 -6
- package/dist/install/modules/opencode.js +13 -7
- package/dist/install/template-notes.js +116 -0
- package/dist/install/version-file.js +9 -4
- package/dist/ledgers/compact.js +87 -0
- package/dist/ledgers/journal.js +233 -0
- package/dist/ledgers/migrate.js +81 -0
- package/dist/ledgers/status.js +176 -13
- package/dist/ledgers/telemetry.js +1010 -125
- package/dist/render/hosts.js +104 -14
- package/dist/render/models.js +12 -0
- package/dist/shared/bkit-latest.js +26 -4
- package/dist/shared/branches.js +3 -1
- package/dist/shared/dep-updater.js +49 -0
- package/dist/shared/egress.js +8 -1
- package/dist/shared/json.js +20 -7
- package/dist/shared/package-manager.js +6 -0
- package/dist/shared/settings.js +181 -24
- package/dist/shared/text.js +333 -0
- package/dist/shared/timeouts.js +2 -0
- package/dist/tools/cli-doc.js +97 -0
- package/dist/tools/grammar-density.js +183 -0
- package/dist/tools/instructions-sources.js +720 -0
- package/dist/tools/instructions.js +1623 -0
- package/package.json +156 -51
- package/.bkit/core/.bkit/lite.md +0 -73
- package/.bkit/core/engine/commands/harvest.ts +0 -459
- package/.bkit/core/engine/commands/workflow/workstreams.ts +0 -166
- package/.bkit/core/engine/tools/wording.ts +0 -748
- package/.bkit/core/prompts/bkit-build-challenge-reconcile.md +0 -69
- package/.bkit/core/prompts/bkit-build-challenge-remediate.md +0 -71
- package/.bkit/core/prompts/bkit-build-challenge-tests.md +0 -74
- package/.bkit/core/prompts/bkit-build-plan-execute.md +0 -76
- package/.bkit/core/prompts/bkit-build-summary.md +0 -94
- package/.bkit/core/prompts/bkit-debug-summary.md +0 -96
- package/.bkit/core/prompts/bkit-design-summary.md +0 -107
- package/.bkit/core/prompts/bkit-plan-complexity-check.md +0 -67
- package/.bkit/core/prompts/bkit-plan-complexity-split.md +0 -88
- package/.bkit/core/prompts/bkit-plan-review-3.md +0 -93
- package/.bkit/core/prompts/bkit-plan-scope-check-1.md +0 -85
- package/.bkit/core/prompts/bkit-plan-scope-check-2.md +0 -85
- package/.bkit/core/prompts/bkit-plan-summary.md +0 -107
- package/.bkit/core/prompts/bkit-ship-summary.md +0 -78
- package/.bkit/templates/scripts/ci/bkit-local-stack-lock.sh +0 -194
- package/dist/commands/harvest.js +0 -353
- package/dist/commands/workflow/workstreams.js +0 -143
- package/dist/tools/wording.js +0 -680
- /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
|
@@ -21,17 +21,21 @@
|
|
|
21
21
|
// name and not "any check".
|
|
22
22
|
import * as fs from "node:fs";
|
|
23
23
|
import * as path from "node:path";
|
|
24
|
-
import {
|
|
25
|
-
import {
|
|
26
|
-
import {
|
|
24
|
+
import { readJsonFile } from "../../shared/json.js";
|
|
25
|
+
import { CI_TIERS, lastRun, statusTimestamp, validateCiSelection, } from "../../ledgers/status.js";
|
|
26
|
+
import { bodySkipToken, commitMessage, CommandError, DEV, EXIT, git, isSharedBranch, parseJson, runGh, runGit, runTool, SKIP_CI_TOKEN, wholeNumber, } from "../lib.js";
|
|
27
|
+
import { ciGeneratedSteps, readBkitConfig } from "../../shared/settings.js";
|
|
27
28
|
import { TIMEOUTS } from "../../shared/timeouts.js";
|
|
28
29
|
import { FID_PATTERNS, fromBranch, fromMarker, issueIdOf, readIssueTracker } from "./fids.js";
|
|
29
30
|
import { AUTO_LABEL, AUTO_ROUTE_SUFFIX } from "./issues.js";
|
|
30
|
-
import {
|
|
31
|
-
import {
|
|
31
|
+
import { fetchRemoteRef, pushBranch } from "./branches.js";
|
|
32
|
+
import { activeRecord, checkOnlyBookkeeping, retriggerCommit } from "./ledgers.js";
|
|
33
|
+
import { closeTransportRow, crossCheckFile, devRequiresChecks, prRepoSlug, probePr, } from "./prs.js";
|
|
32
34
|
import { resolveOwnerRepo, splitSlug } from "./repo.js";
|
|
33
|
-
import {
|
|
35
|
+
import { restateOutcome } from "./run-facts.js";
|
|
36
|
+
import { extraField, readRuns, str } from "./status.js";
|
|
34
37
|
import { writeStepRow } from "./steps.js";
|
|
38
|
+
import { attempt, issueRef, readLabels, trackerTarget } from "./tracker.js";
|
|
35
39
|
const GH_MISSING = "gh is not on PATH — use the mapped GitHub MCP tool instead";
|
|
36
40
|
/** Not JSON reads as undefined: every caller treats that as an API error, distinct from an empty answer. */
|
|
37
41
|
function jsonOrUndefined(raw) {
|
|
@@ -53,12 +57,306 @@ export function checkNamespace(capstoneJob) {
|
|
|
53
57
|
const i = capstoneJob.lastIndexOf("-");
|
|
54
58
|
return i > 0 ? capstoneJob.slice(0, i) : capstoneJob;
|
|
55
59
|
}
|
|
56
|
-
/** Whether `.github/workflows/<bkit.ciWorkflow>` exists — the only honest ground for a `no-ci` pass. */
|
|
60
|
+
/** Whether `.github/workflows/<bkit.testing.ciWorkflow>` exists — the only honest ground for a `no-ci` pass. */
|
|
57
61
|
export function ciDeclared(root) {
|
|
58
62
|
const { ciWorkflow } = readBkitConfig(root);
|
|
59
63
|
const rel = path.join(".github", "workflows", ciWorkflow);
|
|
60
64
|
return { declared: fs.existsSync(path.join(root, rel)), ciWorkflow, path: rel };
|
|
61
65
|
}
|
|
66
|
+
/** Only the winning reference kind is actionable; a run takes precedence over a PR. */
|
|
67
|
+
export function parseCiReference(input) {
|
|
68
|
+
const references = [];
|
|
69
|
+
const urls = [...input.matchAll(/https:\/\/github\.com\/[^\s<>"`]+/g)].map((match) => match[0].replace(/[),.;\]]+$/, ""));
|
|
70
|
+
const parsed = urls.flatMap((url) => {
|
|
71
|
+
const ref = /^https:\/\/github\.com\/([^/]+\/[^/]+)\/(actions\/runs|pull)\/([^/?#]*)([^?#]*)/.exec(url);
|
|
72
|
+
return ref ? [{ url, ref }] : [];
|
|
73
|
+
});
|
|
74
|
+
const winning = parsed.some(({ ref }) => ref[2] === "actions/runs") ? "actions/runs" : "pull";
|
|
75
|
+
for (const { url, ref } of parsed.filter(({ ref }) => ref[2] === winning)) {
|
|
76
|
+
const id = ref[3];
|
|
77
|
+
const suffix = ref[4];
|
|
78
|
+
const kind = ref[2] === "pull" ? "pr" : "run";
|
|
79
|
+
if (!/^[1-9][0-9]*$/.test(id))
|
|
80
|
+
throw new CommandError(EXIT.USAGE, `invalid ${kind} id in ${url}`);
|
|
81
|
+
let attempt;
|
|
82
|
+
if (kind === "run" && suffix !== "" && suffix !== "/") {
|
|
83
|
+
const pinned = /^\/attempts\/([1-9][0-9]*)\/?$/.exec(suffix);
|
|
84
|
+
if (!pinned || !Number.isSafeInteger(Number(pinned[1])))
|
|
85
|
+
throw new CommandError(EXIT.USAGE, `invalid run attempt in ${url}`);
|
|
86
|
+
attempt = Number(pinned[1]);
|
|
87
|
+
}
|
|
88
|
+
else if (kind === "pr" && suffix !== "" && suffix !== "/")
|
|
89
|
+
continue;
|
|
90
|
+
references.push({ kind, repo: ref[1], id, ...(attempt === undefined ? {} : { attempt }) });
|
|
91
|
+
}
|
|
92
|
+
const kind = references.some((ref) => ref.kind === "run") ? "run" : "pr";
|
|
93
|
+
const winners = [
|
|
94
|
+
...new Map(references.filter((ref) => ref.kind === kind).map((ref) => [JSON.stringify(ref), ref])).values(),
|
|
95
|
+
];
|
|
96
|
+
if (winners.length > 1)
|
|
97
|
+
throw new CommandError(8, `multiple ${kind} references were supplied; name one`);
|
|
98
|
+
return winners[0];
|
|
99
|
+
}
|
|
100
|
+
function selectionHeadRelation(cwd, selection, repo, branch) {
|
|
101
|
+
if (selection.repo.toLowerCase() !== repo.toLowerCase() || selection.headBranch !== branch) {
|
|
102
|
+
throw new CommandError(82, `selected evidence belongs to ${selection.repo} branch ${selection.headBranch}; adopted ${repo} branch ${branch}. Supply branch=${selection.headBranch} in its checkout`);
|
|
103
|
+
}
|
|
104
|
+
const head = git(cwd, ["rev-parse", "--verify", `refs/heads/${branch}^{commit}`]);
|
|
105
|
+
if (head === selection.headSha)
|
|
106
|
+
return "current";
|
|
107
|
+
if (head === null || !runGit(cwd, ["cat-file", "-e", `${selection.headSha}^{commit}`]).ok) {
|
|
108
|
+
throw new CommandError(82, `selected commit ${selection.headSha} or branch ${branch} is unavailable; ancestry is unknown`);
|
|
109
|
+
}
|
|
110
|
+
const relation = runTool("git", ["merge-base", "--is-ancestor", selection.headSha, head], cwd);
|
|
111
|
+
if (relation.status === 0)
|
|
112
|
+
return "ancestor";
|
|
113
|
+
throw new CommandError(82, relation.status === 1
|
|
114
|
+
? `selected commit ${selection.headSha} is divergent from ${branch}`
|
|
115
|
+
: `ancestry of ${selection.headSha} is unknown: ${relation.stderr}`);
|
|
116
|
+
}
|
|
117
|
+
function locateCi(ctx) {
|
|
118
|
+
const f = ctx.flags;
|
|
119
|
+
const repo = String(f.repo);
|
|
120
|
+
const branch = String(f.branch);
|
|
121
|
+
if (!/^[A-Za-z0-9][A-Za-z0-9_.-]*\/[A-Za-z0-9][A-Za-z0-9_.-]*$/.test(repo) ||
|
|
122
|
+
!runGit(ctx.cwd, ["check-ref-format", "--branch", branch]).ok) {
|
|
123
|
+
throw new CommandError(EXIT.USAGE, "--repo and --branch must name a repository and a valid branch");
|
|
124
|
+
}
|
|
125
|
+
const readInput = (flag) => f[flag] === undefined ? "" : fs.readFileSync(path.resolve(ctx.cwd, String(f[flag])), "utf8");
|
|
126
|
+
const prompt = readInput("promptFile");
|
|
127
|
+
const selectionFile = path.resolve(ctx.cwd, String(f.selectionOut));
|
|
128
|
+
const finish = (selection, failedJobs = []) => {
|
|
129
|
+
if (!validateCiSelection(selection))
|
|
130
|
+
throw new CommandError(82, "selected evidence has malformed or missing identity fields");
|
|
131
|
+
const headRelation = selection.mode === "ci" ? selectionHeadRelation(ctx.cwd, selection, repo, branch) : null;
|
|
132
|
+
if (headRelation === "ancestor")
|
|
133
|
+
ctx.log(`selected run ${selection.mode === "ci" ? selection.runId : ""} is historical ancestor evidence; inspect intervening changes before fixing`);
|
|
134
|
+
fs.mkdirSync(path.dirname(selectionFile), { recursive: true });
|
|
135
|
+
fs.writeFileSync(selectionFile, `${JSON.stringify(selection, null, 2)}\n`);
|
|
136
|
+
ctx.emit({
|
|
137
|
+
selection: selection.mode,
|
|
138
|
+
runId: selection.mode === "ci" ? selection.runId : null,
|
|
139
|
+
runUrl: selection.mode === "ci" ? selection.runUrl : null,
|
|
140
|
+
runAttempt: selection.mode === "ci" ? selection.runAttempt : null,
|
|
141
|
+
workflowId: selection.mode === "ci" ? selection.workflowId : null,
|
|
142
|
+
workflowPath: selection.mode === "ci" ? selection.workflowPath : null,
|
|
143
|
+
headSha: selection.mode === "ci" ? selection.headSha : null,
|
|
144
|
+
headRelation,
|
|
145
|
+
failedJobs,
|
|
146
|
+
tiers: selection.mode === "ci" ? selection.redTiers : [],
|
|
147
|
+
via: selection.mode === "ci" ? selection.via : null,
|
|
148
|
+
reason: selection.mode === "local" ? selection.reason : null,
|
|
149
|
+
selectionFile,
|
|
150
|
+
});
|
|
151
|
+
return selection.mode === "ci" ? EXIT.OK : 1;
|
|
152
|
+
};
|
|
153
|
+
if (/\[local\]/i.test(prompt))
|
|
154
|
+
return finish({ mode: "local", reason: "explicit-local" });
|
|
155
|
+
let reference = parseCiReference(prompt);
|
|
156
|
+
let via = reference ? `prompt-${reference.kind}` : "branch";
|
|
157
|
+
let saved;
|
|
158
|
+
if (!reference && f.file !== undefined && fs.existsSync(path.resolve(ctx.cwd, String(f.file)))) {
|
|
159
|
+
const active = lastRun(readRuns(path.resolve(ctx.cwd, String(f.file))), "debug");
|
|
160
|
+
if (active?.status === "IN_PROGRESS" && active.ciSelection !== undefined) {
|
|
161
|
+
if (!validateCiSelection(active.ciSelection))
|
|
162
|
+
throw new CommandError(82, "active saved CI selection is invalid");
|
|
163
|
+
saved = active.ciSelection;
|
|
164
|
+
if (saved.mode === "local")
|
|
165
|
+
return finish(saved);
|
|
166
|
+
reference = { kind: "run", repo: saved.repo, id: saved.runId, attempt: saved.runAttempt };
|
|
167
|
+
via = saved.via;
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
if (!reference) {
|
|
171
|
+
const issue = readInput("issueTextFile");
|
|
172
|
+
// issues text already removes generated comments; refuse a raw generated payload too.
|
|
173
|
+
reference = parseCiReference(/^######\s+bkit:generated/m.test(issue) ? "" : issue);
|
|
174
|
+
if (reference)
|
|
175
|
+
via = `issue-${reference.kind}`;
|
|
176
|
+
}
|
|
177
|
+
if (reference && reference.repo.toLowerCase() !== repo.toLowerCase())
|
|
178
|
+
throw new CommandError(82, `reference repository ${reference.repo} does not match adopted repository ${repo}`);
|
|
179
|
+
const declared = ciDeclared(checkoutRoot(ctx.cwd));
|
|
180
|
+
if (!reference && !declared.declared)
|
|
181
|
+
return finish({ mode: "local", reason: "no-configured-ci" });
|
|
182
|
+
const api = (endpoint, extra = []) => {
|
|
183
|
+
const response = runGh(ctx.cwd, ["api", endpoint, ...extra]);
|
|
184
|
+
if (!response.ok)
|
|
185
|
+
throw new CommandError(/HTTP 404/.test(response.stderr) ? 82 : EXIT.USE_MCP, `CI evidence unavailable: ${response.stderr || GH_MISSING}`);
|
|
186
|
+
const parsed = jsonOrUndefined(response.stdout);
|
|
187
|
+
if (parsed === undefined)
|
|
188
|
+
throw new CommandError(82, "CI evidence response is malformed");
|
|
189
|
+
return parsed;
|
|
190
|
+
};
|
|
191
|
+
const validateRun = (candidate) => {
|
|
192
|
+
const base = {
|
|
193
|
+
mode: "ci",
|
|
194
|
+
provider: "github",
|
|
195
|
+
repo,
|
|
196
|
+
runId: String(candidate.id),
|
|
197
|
+
runAttempt: Number(candidate.run_attempt),
|
|
198
|
+
runUrl: `https://github.com/${repo}/actions/runs/${candidate.id}/attempts/${candidate.run_attempt}`,
|
|
199
|
+
workflowId: String(candidate.workflow_id ?? ""),
|
|
200
|
+
workflowPath: text(candidate.path),
|
|
201
|
+
headBranch: text(candidate.head_branch),
|
|
202
|
+
headSha: text(candidate.head_sha),
|
|
203
|
+
conclusion: "failure",
|
|
204
|
+
redTiers: [],
|
|
205
|
+
via,
|
|
206
|
+
};
|
|
207
|
+
if (!validateCiSelection(base) ||
|
|
208
|
+
text(obj(candidate.repository).full_name).toLowerCase() !== repo.toLowerCase() ||
|
|
209
|
+
text(obj(candidate.head_repository).full_name).toLowerCase() !== repo.toLowerCase())
|
|
210
|
+
throw new CommandError(82, "run identity, repository or fork metadata is incomplete or mismatched");
|
|
211
|
+
if (candidate.head_branch !== branch)
|
|
212
|
+
throw new CommandError(82, `run branch ${text(candidate.head_branch)} differs from adopted branch ${branch}; supply branch=${text(candidate.head_branch)} in its checkout`);
|
|
213
|
+
if (reference?.kind !== "run" && candidate.path !== declared.path)
|
|
214
|
+
throw new CommandError(82, "discovered run does not belong to the configured workflow");
|
|
215
|
+
};
|
|
216
|
+
let run;
|
|
217
|
+
let jobs;
|
|
218
|
+
const requested = { repo, branch, kind: reference?.kind ?? "branch" };
|
|
219
|
+
if (reference?.kind === "run") {
|
|
220
|
+
requested.runId = reference.id;
|
|
221
|
+
if (reference.attempt !== undefined)
|
|
222
|
+
requested.runAttempt = reference.attempt;
|
|
223
|
+
}
|
|
224
|
+
else if (reference?.kind === "pr")
|
|
225
|
+
requested.pr = reference.id;
|
|
226
|
+
else
|
|
227
|
+
requested.workflow = declared.ciWorkflow;
|
|
228
|
+
if (f.evidenceFile !== undefined) {
|
|
229
|
+
const envelope = obj(jsonOrUndefined(readInput("evidenceFile")));
|
|
230
|
+
const request = obj(envelope.request);
|
|
231
|
+
if (envelope.complete !== true ||
|
|
232
|
+
!Object.entries(requested).every(([key, value]) => request[key] === value))
|
|
233
|
+
throw new CommandError(82, "fallback evidence is incomplete or its request identity differs");
|
|
234
|
+
if (envelope.noRed === true &&
|
|
235
|
+
!reference &&
|
|
236
|
+
typeof request.headSha === "string" &&
|
|
237
|
+
request.headSha === git(ctx.cwd, ["rev-parse", "HEAD"]))
|
|
238
|
+
return finish({ mode: "local", reason: "automatic-no-red" });
|
|
239
|
+
run = obj(envelope.run);
|
|
240
|
+
if (reference?.kind === "pr") {
|
|
241
|
+
const head = obj(obj(envelope.pr).head);
|
|
242
|
+
if (head.ref !== branch ||
|
|
243
|
+
head.sha !== run.head_sha ||
|
|
244
|
+
text(obj(head.repo).full_name).toLowerCase() !== repo.toLowerCase())
|
|
245
|
+
throw new CommandError(82, "fallback PR head is missing or differs from the selected run");
|
|
246
|
+
}
|
|
247
|
+
if (!Array.isArray(envelope.jobs) || envelope.jobs.some((job) => obj(job).id === undefined))
|
|
248
|
+
throw new CommandError(82, "fallback jobs are incomplete");
|
|
249
|
+
jobs = envelope.jobs.map(obj);
|
|
250
|
+
}
|
|
251
|
+
else {
|
|
252
|
+
let expectedHead;
|
|
253
|
+
if (reference?.kind === "pr") {
|
|
254
|
+
const pr = obj(api(`/repos/${repo}/pulls/${reference.id}`));
|
|
255
|
+
const head = obj(pr.head);
|
|
256
|
+
if (text(obj(head.repo).full_name).toLowerCase() !== repo.toLowerCase() ||
|
|
257
|
+
head.ref !== branch ||
|
|
258
|
+
!/^[0-9a-f]{40,64}$/.test(text(head.sha)))
|
|
259
|
+
throw new CommandError(82, `PR head does not match adopted ${repo} branch ${branch}; inspect its branch and fork repository`);
|
|
260
|
+
expectedHead = text(head.sha);
|
|
261
|
+
}
|
|
262
|
+
if (reference?.kind === "run") {
|
|
263
|
+
run = obj(api(`/repos/${repo}/actions/runs/${reference.id}${reference.attempt === undefined ? "" : `/attempts/${reference.attempt}`}`));
|
|
264
|
+
}
|
|
265
|
+
else {
|
|
266
|
+
const response = obj(api(`/repos/${repo}/actions/workflows/${queryValue(declared.ciWorkflow)}/runs?branch=${queryValue(branch)}&status=completed&per_page=100${expectedHead ? `&head_sha=${expectedHead}` : ""}`));
|
|
267
|
+
if (!Array.isArray(response.workflow_runs) ||
|
|
268
|
+
!Number.isSafeInteger(response.total_count) ||
|
|
269
|
+
Number(response.total_count) < 0 ||
|
|
270
|
+
Number(response.total_count) < response.workflow_runs.length)
|
|
271
|
+
throw new CommandError(82, "workflow lookup returned an incomplete response");
|
|
272
|
+
const candidates = response.workflow_runs
|
|
273
|
+
.map(obj)
|
|
274
|
+
.filter((candidate) => candidate.status === "completed");
|
|
275
|
+
run =
|
|
276
|
+
candidates.sort((a, b) => text(b.created_at).localeCompare(text(a.created_at)) || Number(b.id) - Number(a.id))[0] ?? {};
|
|
277
|
+
if (Object.keys(run).length === 0) {
|
|
278
|
+
if (Number(response.total_count) > 0)
|
|
279
|
+
throw new CommandError(82, "workflow lookup returned no completed records despite a nonempty result");
|
|
280
|
+
if (reference)
|
|
281
|
+
throw new CommandError(82, "named PR has no completed red run; choose [local] to discover locally");
|
|
282
|
+
return finish({ mode: "local", reason: "automatic-no-red" });
|
|
283
|
+
}
|
|
284
|
+
if (expectedHead && run.head_sha !== expectedHead)
|
|
285
|
+
throw new CommandError(82, "PR lookup returned a run from another head");
|
|
286
|
+
}
|
|
287
|
+
validateRun(run);
|
|
288
|
+
if (run.status !== "completed" ||
|
|
289
|
+
!["failure", "timed_out", "startup_failure"].includes(text(run.conclusion))) {
|
|
290
|
+
if (reference)
|
|
291
|
+
throw new CommandError(82, `named evidence is ${text(run.status)}/${text(run.conclusion)}; choose [local] to discover locally`);
|
|
292
|
+
if (run.status !== "completed" ||
|
|
293
|
+
!["success", "cancelled", "skipped", "neutral", "action_required", "stale"].includes(text(run.conclusion)))
|
|
294
|
+
throw new CommandError(82, "workflow run has an invalid state");
|
|
295
|
+
return finish({ mode: "local", reason: "automatic-no-red" });
|
|
296
|
+
}
|
|
297
|
+
const attempt = reference?.attempt ?? Number(run.run_attempt);
|
|
298
|
+
if (!Number.isSafeInteger(attempt) || attempt <= 0 || !/^[1-9][0-9]*$/.test(String(run.id)))
|
|
299
|
+
throw new CommandError(82, "run identity or attempt is missing");
|
|
300
|
+
const pages = api(`/repos/${repo}/actions/runs/${run.id}/attempts/${attempt}/jobs?per_page=100`, ["--paginate", "--slurp"]);
|
|
301
|
+
if (!Array.isArray(pages) || pages.length === 0)
|
|
302
|
+
throw new CommandError(82, "job pagination returned no complete pages");
|
|
303
|
+
const total = obj(pages[0]).total_count;
|
|
304
|
+
if (!Number.isSafeInteger(total) ||
|
|
305
|
+
Number(total) < 0 ||
|
|
306
|
+
pages.some((page) => !Array.isArray(obj(page).jobs) || obj(page).total_count !== total))
|
|
307
|
+
throw new CommandError(82, "job pagination returned incomplete pages");
|
|
308
|
+
jobs = pages.flatMap((page) => arr(obj(page).jobs).map(obj));
|
|
309
|
+
if (jobs.length !== total ||
|
|
310
|
+
new Set(jobs.map((job) => job.id)).size !== total ||
|
|
311
|
+
jobs.some((job) => !Number.isSafeInteger(job.id) ||
|
|
312
|
+
typeof job.name !== "string" ||
|
|
313
|
+
typeof job.conclusion !== "string"))
|
|
314
|
+
throw new CommandError(82, "job pagination did not return every job");
|
|
315
|
+
}
|
|
316
|
+
const attempt = reference?.attempt ?? Number(run.run_attempt);
|
|
317
|
+
validateRun(run);
|
|
318
|
+
if (jobs.some((job) => !Number.isSafeInteger(job.id) ||
|
|
319
|
+
typeof job.name !== "string" ||
|
|
320
|
+
job.name.length === 0 ||
|
|
321
|
+
typeof job.conclusion !== "string") ||
|
|
322
|
+
new Set(jobs.map((job) => job.id)).size !== jobs.length)
|
|
323
|
+
throw new CommandError(82, "job identities or conclusions are incomplete");
|
|
324
|
+
if (reference?.kind === "run" && String(run.id) !== reference.id)
|
|
325
|
+
throw new CommandError(82, "selected run differs from the requested run");
|
|
326
|
+
if (Number(run.run_attempt) !== attempt ||
|
|
327
|
+
run.status !== "completed" ||
|
|
328
|
+
text(obj(run.repository).full_name).toLowerCase() !== repo.toLowerCase() ||
|
|
329
|
+
text(obj(run.head_repository).full_name).toLowerCase() !== repo.toLowerCase())
|
|
330
|
+
throw new CommandError(82, "run attempt, repository or fork identity does not match");
|
|
331
|
+
const failedJobs = jobs.filter((job) => ["failure", "timed_out", "startup_failure"].includes(text(job.conclusion)));
|
|
332
|
+
const mapped = failedJobs
|
|
333
|
+
.filter((job) => job.name !== "bkit-tests-check")
|
|
334
|
+
.map((job) => /^bkit-tests-(static|unit|integration|e2e|live|migration)$/.exec(text(job.name))?.[1]);
|
|
335
|
+
const tiers = mapped.some((tier) => tier === undefined)
|
|
336
|
+
? []
|
|
337
|
+
: CI_TIERS.filter((tier) => mapped.includes(tier));
|
|
338
|
+
const selection = {
|
|
339
|
+
mode: "ci",
|
|
340
|
+
provider: "github",
|
|
341
|
+
repo,
|
|
342
|
+
runId: String(run.id),
|
|
343
|
+
runAttempt: attempt,
|
|
344
|
+
runUrl: `https://github.com/${repo}/actions/runs/${run.id}/attempts/${attempt}`,
|
|
345
|
+
workflowId: String(run.workflow_id ?? ""),
|
|
346
|
+
workflowPath: text(run.path),
|
|
347
|
+
headBranch: text(run.head_branch),
|
|
348
|
+
headSha: text(run.head_sha),
|
|
349
|
+
conclusion: text(run.conclusion),
|
|
350
|
+
redTiers: tiers,
|
|
351
|
+
via,
|
|
352
|
+
};
|
|
353
|
+
if (saved?.mode === "ci" &&
|
|
354
|
+
(saved.workflowId !== selection.workflowId ||
|
|
355
|
+
saved.headSha !== selection.headSha ||
|
|
356
|
+
saved.workflowPath !== selection.workflowPath))
|
|
357
|
+
throw new CommandError(82, "saved evidence identity differs from the returned run");
|
|
358
|
+
return finish(selection, failedJobs);
|
|
359
|
+
}
|
|
62
360
|
/** Skip-token scan of a landed commit's body (see `bodySkipToken`). */
|
|
63
361
|
export function scanBody(cwd, sha) {
|
|
64
362
|
const token = bodySkipToken(cwd, sha);
|
|
@@ -179,15 +477,17 @@ function currentPr(cwd, gh) {
|
|
|
179
477
|
}
|
|
180
478
|
/** Exit code: the re-trigger commit or its push failed. */
|
|
181
479
|
export const EXIT_RETRIGGER_FAILED = 6;
|
|
480
|
+
/** Push the current branch; the failure text is kept so the gate can name why. */
|
|
182
481
|
function pushCurrentBranch(cwd) {
|
|
183
482
|
const branch = git(cwd, ["branch", "--show-current"]);
|
|
184
483
|
if (!branch)
|
|
185
|
-
return false;
|
|
484
|
+
return { ok: false, error: "no branch checked out (detached HEAD)" };
|
|
186
485
|
// Shared branches never force; a feature branch is rewritten only by this run.
|
|
187
486
|
const args = isSharedBranch(branch)
|
|
188
487
|
? ["push", "origin", branch]
|
|
189
488
|
: ["push", "--force-with-lease", "origin", branch];
|
|
190
|
-
|
|
489
|
+
const res = runGit(cwd, args);
|
|
490
|
+
return { ok: res.ok, error: res.ok ? "" : res.stderr || res.stdout };
|
|
191
491
|
}
|
|
192
492
|
/**
|
|
193
493
|
* The CI-Dispatch Gate after build / debug's last push. Never pushes after the
|
|
@@ -197,7 +497,20 @@ export async function ciDispatchGate(o, deps) {
|
|
|
197
497
|
const root = checkoutRoot(o.cwd);
|
|
198
498
|
const { capstoneJob } = readBkitConfig(root);
|
|
199
499
|
const declared = ciDeclared(root);
|
|
200
|
-
const
|
|
500
|
+
const branch = git(o.cwd, ["branch", "--show-current"]) ?? "";
|
|
501
|
+
const shared = branch !== "" && isSharedBranch(branch);
|
|
502
|
+
// A run in place on a shared branch has no PR: CI is the push-event run at the pushed sha.
|
|
503
|
+
const byRun = o.pr === null && shared;
|
|
504
|
+
// The sha an own-commit push landed; null while the head is local HEAD.
|
|
505
|
+
let landed = byRun ? (o.sha ?? null) : null;
|
|
506
|
+
const head = () => landed ?? git(o.cwd, ["rev-parse", "HEAD"]) ?? "";
|
|
507
|
+
/** The landed copy lives on the remote only; the scan and the suppressor check read it locally. */
|
|
508
|
+
const fetchLanded = () => {
|
|
509
|
+
if (landed === null || runGit(o.cwd, ["cat-file", "-e", `${landed}^{commit}`]).ok)
|
|
510
|
+
return;
|
|
511
|
+
runGit(o.cwd, ["fetch", "origin", branch]);
|
|
512
|
+
};
|
|
513
|
+
fetchLanded();
|
|
201
514
|
const res = {
|
|
202
515
|
phase: "done",
|
|
203
516
|
handoff: 0,
|
|
@@ -206,13 +519,22 @@ export async function ciDispatchGate(o, deps) {
|
|
|
206
519
|
attempts: 0,
|
|
207
520
|
retrigger: o.retriggered,
|
|
208
521
|
ciWorkflow: declared.ciWorkflow,
|
|
522
|
+
runBranch: byRun ? branch : null,
|
|
209
523
|
};
|
|
210
|
-
const target =
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
524
|
+
const target = byRun
|
|
525
|
+
? {
|
|
526
|
+
kind: "run-present",
|
|
527
|
+
head: res.head,
|
|
528
|
+
branch,
|
|
529
|
+
ciWorkflow: declared.ciWorkflow,
|
|
530
|
+
namespace: checkNamespace(capstoneJob),
|
|
531
|
+
}
|
|
532
|
+
: {
|
|
533
|
+
kind: "pr-present",
|
|
534
|
+
pr: o.pr ?? undefined,
|
|
535
|
+
ciWorkflow: declared.ciWorkflow,
|
|
536
|
+
namespace: checkNamespace(capstoneJob),
|
|
537
|
+
};
|
|
216
538
|
const poll = async (phase) => {
|
|
217
539
|
// A supplied result answers only the poll that was handed off; later polls run fresh.
|
|
218
540
|
if (o.supplied && (phase === "repoll") === o.retriggered) {
|
|
@@ -220,9 +542,13 @@ export async function ciDispatchGate(o, deps) {
|
|
|
220
542
|
return o.supplied;
|
|
221
543
|
}
|
|
222
544
|
// No PR to read is the shell's empty-PR poll: zero attempts, all errored.
|
|
223
|
-
if (o.pr === null)
|
|
545
|
+
if (o.pr === null && !byRun)
|
|
224
546
|
return { pollResult: "err", attempts: 0, allErrored: true };
|
|
225
|
-
|
|
547
|
+
if (byRun)
|
|
548
|
+
target.head = head();
|
|
549
|
+
deps.log(byRun
|
|
550
|
+
? `polling for a ${target.ciWorkflow} run on ${branch} at ${target.head} (budget ${o.budgetS}s, interval ${o.intervalS}s)`
|
|
551
|
+
: `polling for a ${target.namespace} check on PR #${o.pr} (budget ${o.budgetS}s, interval ${o.intervalS}s)`);
|
|
226
552
|
const w = await waitLoop({ budgetS: o.budgetS, intervalS: o.intervalS, once: false }, () => pollOnce(target, deps.gh), deps.sleep, deps.log);
|
|
227
553
|
if (w.blocked || w.ghMissing) {
|
|
228
554
|
res.phase = phase;
|
|
@@ -258,14 +584,52 @@ export async function ciDispatchGate(o, deps) {
|
|
|
258
584
|
deps.log("unresolved(timeout-dirty): no run and the pushed head carries a CI suppressor — not re-triggering a dirty head");
|
|
259
585
|
return verdict("unresolved", "timeout-dirty");
|
|
260
586
|
}
|
|
261
|
-
const
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
587
|
+
const message = `chore(${o.fid}): re-trigger${o.autoRouteSuffix}`;
|
|
588
|
+
// A run in place on a shared branch commits and pushes only its own work; with
|
|
589
|
+
// no record of the run there, nothing is committed or pushed.
|
|
590
|
+
const rec = shared ? activeRecord(o.cwd, o.fid) : null;
|
|
591
|
+
if (shared && rec === null) {
|
|
592
|
+
deps.log(`no shared-checkout record for ${o.fid} on ${branch} — refusing to re-trigger: a commit and push here would carry work the run does not own; route to the Failure Path`);
|
|
593
|
+
res.phase = "repoll";
|
|
594
|
+
res.handoff = EXIT_RETRIGGER_FAILED;
|
|
595
|
+
return res;
|
|
596
|
+
}
|
|
597
|
+
let pushed;
|
|
598
|
+
let failure = "";
|
|
599
|
+
if (rec === null) {
|
|
600
|
+
landed = null;
|
|
601
|
+
const before = git(o.cwd, ["rev-parse", "HEAD"]);
|
|
602
|
+
const made = runGit(o.cwd, ["commit", "--allow-empty", "-m", message]);
|
|
603
|
+
if (!made.ok) {
|
|
604
|
+
pushed = false;
|
|
605
|
+
failure = made.stderr || made.stdout;
|
|
606
|
+
}
|
|
607
|
+
else {
|
|
608
|
+
const push = pushCurrentBranch(o.cwd);
|
|
609
|
+
pushed = push.ok;
|
|
610
|
+
if (!push.ok) {
|
|
611
|
+
failure = push.error;
|
|
612
|
+
// The commit never reached the remote: drop it so a re-run does not pile
|
|
613
|
+
// up orphan re-triggers. --soft restores the index exactly as the commit left it.
|
|
614
|
+
if (before !== null)
|
|
615
|
+
runGit(o.cwd, ["reset", "--soft", before]);
|
|
616
|
+
}
|
|
617
|
+
}
|
|
618
|
+
}
|
|
619
|
+
else {
|
|
620
|
+
const made = retriggerCommit(o.cwd, rec, message);
|
|
621
|
+
if (!made.ok)
|
|
622
|
+
deps.log(`re-trigger commit failed: ${made.error}`);
|
|
623
|
+
const out = made.ok
|
|
624
|
+
? await pushBranch(o.cwd, { mode: "feature", fid: o.fid }, deps.log)
|
|
625
|
+
: null;
|
|
626
|
+
landed = out?.out.pushed === true ? out.out.sha : landed;
|
|
627
|
+
pushed = out?.out.pushed === true && out.out.sha !== null;
|
|
628
|
+
if (pushed)
|
|
629
|
+
fetchLanded();
|
|
630
|
+
}
|
|
631
|
+
if (!pushed) {
|
|
632
|
+
deps.log(`re-trigger commit or push failed${failure ? `: ${failure}` : ""} — no verdict; route to the Failure Path`);
|
|
269
633
|
res.phase = "repoll";
|
|
270
634
|
res.handoff = EXIT_RETRIGGER_FAILED;
|
|
271
635
|
return res;
|
|
@@ -315,7 +679,7 @@ export const GATE = {
|
|
|
315
679
|
SUPERSEDED: 14,
|
|
316
680
|
/** The selected run was cancelled. */
|
|
317
681
|
CANCELLED: 15,
|
|
318
|
-
/** A lane named in bkit.
|
|
682
|
+
/** A lane named in bkit.testing.ciRequired concluded skipped. */
|
|
319
683
|
LANE_SKIPPED: 16,
|
|
320
684
|
/** --validated is not an ancestor of the head plus bookkeeping-only commits. */
|
|
321
685
|
NOT_BOOKKEEPING: 17,
|
|
@@ -344,6 +708,28 @@ export function onlyBookkeeping(root, o) {
|
|
|
344
708
|
};
|
|
345
709
|
}
|
|
346
710
|
}
|
|
711
|
+
/** Job and step conclusions that are not a failure. */
|
|
712
|
+
const NOT_FAILED = new Set(["success", "skipped", "neutral"]);
|
|
713
|
+
/**
|
|
714
|
+
* The failed steps of a run's jobs as `{job}/{step}`, the capstone left out: it fails
|
|
715
|
+
* only because another job did. A job that did not pass with no step that failed (a
|
|
716
|
+
* runner or setup failure) is `{job}/`, which no list entry matches.
|
|
717
|
+
*/
|
|
718
|
+
export function failedStepsOf(jobs, capstone) {
|
|
719
|
+
const out = [];
|
|
720
|
+
for (const job of jobs) {
|
|
721
|
+
const name = text(job.name);
|
|
722
|
+
if (name === capstone || NOT_FAILED.has(text(job.conclusion)))
|
|
723
|
+
continue;
|
|
724
|
+
const steps = arr(job.steps)
|
|
725
|
+
.map(obj)
|
|
726
|
+
.filter((st) => st.conclusion !== null && st.conclusion !== undefined)
|
|
727
|
+
.filter((st) => !NOT_FAILED.has(text(st.conclusion)))
|
|
728
|
+
.map((st) => `${name}/${text(st.name)}`);
|
|
729
|
+
out.push(...(steps.length > 0 ? steps : [`${name}/`]));
|
|
730
|
+
}
|
|
731
|
+
return out;
|
|
732
|
+
}
|
|
347
733
|
const toRun = (v) => {
|
|
348
734
|
const r = obj(v);
|
|
349
735
|
return {
|
|
@@ -379,9 +765,11 @@ export function shipGate(o, gh, log) {
|
|
|
379
765
|
repo: o.repo || null,
|
|
380
766
|
skippedLanes: [],
|
|
381
767
|
nonBookkeepingPaths: [],
|
|
768
|
+
failedSteps: [],
|
|
769
|
+
regenerable: false,
|
|
382
770
|
reason: "",
|
|
383
771
|
};
|
|
384
|
-
const requiredLanes = cfg.
|
|
772
|
+
const requiredLanes = cfg.ciRequired;
|
|
385
773
|
const refuse = (code, reason, runUrl) => {
|
|
386
774
|
log(reason);
|
|
387
775
|
log(`required head: ${r.head}`);
|
|
@@ -449,9 +837,9 @@ export function shipGate(o, gh, log) {
|
|
|
449
837
|
log(GH_MISSING);
|
|
450
838
|
return r;
|
|
451
839
|
};
|
|
452
|
-
/** The run's jobs
|
|
453
|
-
*
|
|
454
|
-
const
|
|
840
|
+
/** The run's jobs. `--slurp` turns --paginate's one-document-per-page stream into one
|
|
841
|
+
* array; without it a run with more than 100 jobs hides every page but the first. */
|
|
842
|
+
const listJobs = (run) => {
|
|
455
843
|
const jobsRes = gh([
|
|
456
844
|
"api",
|
|
457
845
|
`/repos/${r.repo}/actions/runs/${run.id}/jobs`,
|
|
@@ -459,16 +847,43 @@ export function shipGate(o, gh, log) {
|
|
|
459
847
|
"--slurp",
|
|
460
848
|
]);
|
|
461
849
|
if (jobsRes.missing)
|
|
850
|
+
return "missing";
|
|
851
|
+
if (!jobsRes.ok)
|
|
852
|
+
return "api-error";
|
|
853
|
+
const jobsJson = jsonOrUndefined(jobsRes.stdout);
|
|
854
|
+
if (jobsJson === undefined)
|
|
855
|
+
return "invalid";
|
|
856
|
+
const pages = Array.isArray(jobsJson) ? jobsJson : [jobsJson];
|
|
857
|
+
return pages.flatMap((p) => arr(obj(p).jobs).map(obj));
|
|
858
|
+
};
|
|
859
|
+
/** The run's jobs, or the refusal. */
|
|
860
|
+
const readJobs = (run) => {
|
|
861
|
+
const jobs = listJobs(run);
|
|
862
|
+
if (jobs === "missing")
|
|
462
863
|
return ghMissing();
|
|
463
|
-
if (
|
|
864
|
+
if (jobs === "api-error") {
|
|
464
865
|
return apiError(`jobs query failed for run ${run.id} — API error (distinct from 'no capstone')`, run.html_url);
|
|
465
866
|
}
|
|
466
|
-
|
|
467
|
-
if (jobsJson === undefined) {
|
|
867
|
+
if (jobs === "invalid") {
|
|
468
868
|
return refuse(GATE.API_ERROR, `jobs response for run ${run.id} is not valid JSON`, run.html_url);
|
|
469
869
|
}
|
|
470
|
-
|
|
471
|
-
|
|
870
|
+
return jobs;
|
|
871
|
+
};
|
|
872
|
+
/** A failed run's failed steps, and whether `bkit:generate` fixes each one. Jobs that
|
|
873
|
+
* cannot be read leave it unregenerable; the refusal itself does not change. */
|
|
874
|
+
const classifyFailure = (run) => {
|
|
875
|
+
const jobs = listJobs(run);
|
|
876
|
+
if (!Array.isArray(jobs)) {
|
|
877
|
+
log(`failed steps unknown: the jobs of run ${run.id} could not be read`);
|
|
878
|
+
return;
|
|
879
|
+
}
|
|
880
|
+
r.failedSteps = failedStepsOf(jobs, r.capstone);
|
|
881
|
+
const fixable = ciGeneratedSteps(cfg);
|
|
882
|
+
r.regenerable = r.failedSteps.length > 0 && r.failedSteps.every((st) => fixable.includes(st));
|
|
883
|
+
for (const st of r.failedSteps)
|
|
884
|
+
log(`failed step: ${st}`);
|
|
885
|
+
if (r.regenerable)
|
|
886
|
+
log("every failed step is one bkit:generate fixes (bkit.testing.ciGenerated)");
|
|
472
887
|
};
|
|
473
888
|
/** Capstone-only verdict: the capstone job's own result, whatever the run and its other jobs did. */
|
|
474
889
|
const capstoneVerdict = (run) => {
|
|
@@ -582,6 +997,7 @@ export function shipGate(o, gh, log) {
|
|
|
582
997
|
if (o.capstoneOnly)
|
|
583
998
|
return capstoneVerdict(selected);
|
|
584
999
|
if (selected.conclusion === "failure") {
|
|
1000
|
+
classifyFailure(selected);
|
|
585
1001
|
return refuse(GATE.FAILED, `selected run concluded FAILURE at head ${r.head}`, url);
|
|
586
1002
|
}
|
|
587
1003
|
if (selected.conclusion === "cancelled") {
|
|
@@ -613,7 +1029,7 @@ export function shipGate(o, gh, log) {
|
|
|
613
1029
|
log(`note: capstone '${r.capstone}' is green and owns the planned-vs-vacuous judgement for those lanes`);
|
|
614
1030
|
const required = r.skippedLanes.filter((l) => requiredLanes.includes(l));
|
|
615
1031
|
if (required.length) {
|
|
616
|
-
log(`declared in bkit.
|
|
1032
|
+
log(`declared in bkit.testing.ciRequired: ${requiredLanes.join(",")}`);
|
|
617
1033
|
return refuse(GATE.LANE_SKIPPED, `required lane(s) concluded 'skipped' at head ${r.head} — vacuous green: ${required.join(", ")}`, url);
|
|
618
1034
|
}
|
|
619
1035
|
}
|
|
@@ -715,15 +1131,6 @@ export const EXIT_TRIGGER_FAILED = 5;
|
|
|
715
1131
|
export const EXIT_SKIP_TOKEN = 4;
|
|
716
1132
|
/** Exit code: the pushed head's commit message could not be read for the body scan. */
|
|
717
1133
|
export const EXIT_SCAN_ERROR = 5;
|
|
718
|
-
const wholeNumber = (v, flag, fallback, min = 0) => {
|
|
719
|
-
if (v === undefined)
|
|
720
|
-
return fallback;
|
|
721
|
-
const s = String(v);
|
|
722
|
-
if (!/^[0-9]+$/.test(s) || Number(s) < min) {
|
|
723
|
-
throw new CommandError(EXIT.USAGE, `--${flag} takes a whole number >= ${min} (got "${s}")`);
|
|
724
|
-
}
|
|
725
|
-
return Number(s);
|
|
726
|
-
};
|
|
727
1134
|
const HEAD_FLAG = { name: "head", type: "string", help: "commit SHA" };
|
|
728
1135
|
const REPO_FLAG = {
|
|
729
1136
|
name: "repo",
|
|
@@ -733,12 +1140,12 @@ const REPO_FLAG = {
|
|
|
733
1140
|
const CI_WORKFLOW_FLAG = {
|
|
734
1141
|
name: "ci-workflow",
|
|
735
1142
|
type: "string",
|
|
736
|
-
help: "CI workflow file (default: package.json bkit.ciWorkflow)",
|
|
1143
|
+
help: "CI workflow file (default: package.json bkit.testing.ciWorkflow)",
|
|
737
1144
|
};
|
|
738
1145
|
const CAPSTONE_FLAG = {
|
|
739
1146
|
name: "capstone",
|
|
740
1147
|
type: "string",
|
|
741
|
-
help: "capstone job name (default: package.json bkit.
|
|
1148
|
+
help: "capstone job name (default: package.json bkit.testing.ciCapstone)",
|
|
742
1149
|
};
|
|
743
1150
|
const BUDGET_FLAG = { name: "budget-s", type: "string", help: "poll budget in seconds" };
|
|
744
1151
|
const INTERVAL_FLAG = {
|
|
@@ -874,6 +1281,14 @@ async function runDispatch(ctx) {
|
|
|
874
1281
|
}
|
|
875
1282
|
pr = found.pr;
|
|
876
1283
|
}
|
|
1284
|
+
const sha = str(f.sha);
|
|
1285
|
+
if (sha !== undefined && !/^[0-9a-f]{40}$/i.test(sha)) {
|
|
1286
|
+
throw new CommandError(EXIT.USAGE, "--sha must be the full 40-hex-digit commit sha (the CI run is matched on the full sha)");
|
|
1287
|
+
}
|
|
1288
|
+
const onShared = isSharedBranch(git(ctx.cwd, ["branch", "--show-current"]) ?? "");
|
|
1289
|
+
if (sha !== undefined && (pr !== null || !onShared)) {
|
|
1290
|
+
throw new CommandError(EXIT.USAGE, "--sha goes with a run in place on a shared branch that has no PR");
|
|
1291
|
+
}
|
|
877
1292
|
const pollResult = str(f.pollResult);
|
|
878
1293
|
if (pollResult !== undefined && !["found", "none", "err"].includes(pollResult)) {
|
|
879
1294
|
throw new CommandError(EXIT.USAGE, "--poll-result must be found, none, or err");
|
|
@@ -898,6 +1313,7 @@ async function runDispatch(ctx) {
|
|
|
898
1313
|
allErrored: f.allErrored === true,
|
|
899
1314
|
},
|
|
900
1315
|
retriggered: f.retriggered === true,
|
|
1316
|
+
sha,
|
|
901
1317
|
}, d);
|
|
902
1318
|
const scanResult = r.ciDispatch && r.ciDispatch.outcome !== "unresolved" ? scanBody(ctx.cwd, r.head) : null;
|
|
903
1319
|
// With --file / --step: the verdict lands on the step's row, and a passed one is
|
|
@@ -907,11 +1323,12 @@ async function runDispatch(ctx) {
|
|
|
907
1323
|
if ((file === undefined) !== (step === undefined))
|
|
908
1324
|
throw new CommandError(EXIT.USAGE, "--file and --step go together");
|
|
909
1325
|
let row = null;
|
|
1326
|
+
let progressLine;
|
|
910
1327
|
let transport = null;
|
|
911
1328
|
const code = dispatchCode(r, pr, scanResult, ctx.log);
|
|
912
1329
|
if (file !== undefined && r.ciDispatch !== null) {
|
|
913
1330
|
const status = path.resolve(ctx.cwd, file);
|
|
914
|
-
|
|
1331
|
+
const written = writeStepRow(ctx.cwd, {
|
|
915
1332
|
file: status,
|
|
916
1333
|
workflow: String(f.workflow ?? "build"),
|
|
917
1334
|
step: step,
|
|
@@ -921,7 +1338,13 @@ async function runDispatch(ctx) {
|
|
|
921
1338
|
ciDispatch: r.ciDispatch,
|
|
922
1339
|
},
|
|
923
1340
|
commit: "none",
|
|
924
|
-
}, ctx.log)
|
|
1341
|
+
}, ctx.log);
|
|
1342
|
+
row = written.row;
|
|
1343
|
+
progressLine = written.progressLine;
|
|
1344
|
+
if (/-close-workflow$/.test(step)) {
|
|
1345
|
+
const tree = git(ctx.cwd, ["rev-parse", "--show-toplevel"]) ?? ctx.cwd;
|
|
1346
|
+
restateOutcome(tree, status, String(f.workflow ?? "build"), { ...r.ciDispatch }, ctx.log);
|
|
1347
|
+
}
|
|
925
1348
|
if (code === EXIT.OK || code === EXIT_SKIP_TOKEN) {
|
|
926
1349
|
const check = crossCheckFile(status, "gh", ctx.log);
|
|
927
1350
|
if (!check.ok) {
|
|
@@ -937,6 +1360,7 @@ async function runDispatch(ctx) {
|
|
|
937
1360
|
ciWorkflow: r.ciWorkflow,
|
|
938
1361
|
row,
|
|
939
1362
|
transport,
|
|
1363
|
+
...(progressLine === undefined ? {} : { progressLine }),
|
|
940
1364
|
});
|
|
941
1365
|
return EXIT.NO;
|
|
942
1366
|
}
|
|
@@ -958,6 +1382,7 @@ async function runDispatch(ctx) {
|
|
|
958
1382
|
ciWorkflow: r.ciWorkflow,
|
|
959
1383
|
row,
|
|
960
1384
|
transport,
|
|
1385
|
+
...(progressLine === undefined ? {} : { progressLine }),
|
|
961
1386
|
});
|
|
962
1387
|
return code;
|
|
963
1388
|
}
|
|
@@ -965,7 +1390,10 @@ async function runDispatch(ctx) {
|
|
|
965
1390
|
function dispatchCode(r, pr, scanResult, log) {
|
|
966
1391
|
if (r.handoff === EXIT.AGENT_WAIT || r.handoff === EXIT.USE_MCP) {
|
|
967
1392
|
const again = r.phase === "repoll" ? " --retriggered" : "";
|
|
968
|
-
|
|
1393
|
+
const [wait, keep] = r.runBranch === null
|
|
1394
|
+
? [`--pr=${pr ?? "<n>"}`, ""]
|
|
1395
|
+
: [`--head=${r.head} --branch=${r.runBranch} --until=present`, ` --sha=${r.head}`];
|
|
1396
|
+
log(`${r.handoff === EXIT.USE_MCP ? GH_MISSING : "this runtime cannot wait"}: resolve the ${r.phase} each turn with \`bkit runs wait ${wait} --once\`, then re-run with --poll-result=<found|none|err> --attempts=<total>${again}${keep}`);
|
|
969
1397
|
return r.handoff;
|
|
970
1398
|
}
|
|
971
1399
|
if (r.handoff !== 0)
|
|
@@ -1010,9 +1438,26 @@ function logResolvedPrRepo(repoFlag, prNumber, pr, log) {
|
|
|
1010
1438
|
}
|
|
1011
1439
|
function runGate(ctx) {
|
|
1012
1440
|
const f = ctx.flags;
|
|
1441
|
+
let selection;
|
|
1442
|
+
const selectionFile = str(f.ciSelectionFile);
|
|
1443
|
+
if (selectionFile !== undefined) {
|
|
1444
|
+
const parsed = readJsonFile(path.resolve(ctx.cwd, selectionFile));
|
|
1445
|
+
if (!parsed.ok || !validateCiSelection(parsed.value))
|
|
1446
|
+
throw new CommandError(EXIT.USAGE, "cannot read validated CI selection: unreadable JSON or invalid selection");
|
|
1447
|
+
selection = parsed.value;
|
|
1448
|
+
}
|
|
1013
1449
|
const given = [f.head, f.pr, f.squashOf].filter((v) => v !== undefined).length;
|
|
1014
1450
|
if (given !== 1)
|
|
1015
1451
|
throw new CommandError(EXIT.USAGE, "give exactly one of --head, --pr, --squash-of");
|
|
1452
|
+
if (f.fetch === true) {
|
|
1453
|
+
const branch = str(f.branch);
|
|
1454
|
+
if (branch === undefined)
|
|
1455
|
+
throw new CommandError(EXIT.USAGE, "--fetch needs --branch");
|
|
1456
|
+
// Best-effort: the gate reads CI, not the local ref; a failed fetch is logged, not fatal.
|
|
1457
|
+
const fetched = fetchRemoteRef(ctx.cwd, `origin/${branch}`);
|
|
1458
|
+
if (fetched !== null && !fetched.ok)
|
|
1459
|
+
ctx.log(`fetch of origin/${branch} failed: ${fetched.stderr.trim()}`);
|
|
1460
|
+
}
|
|
1016
1461
|
const root = checkoutRoot(ctx.cwd);
|
|
1017
1462
|
const gh = (args) => runGh(ctx.cwd, args);
|
|
1018
1463
|
const record = str(f.record);
|
|
@@ -1095,7 +1540,7 @@ function runGate(ctx) {
|
|
|
1095
1540
|
// A title carrying a skip token would squash into a dev commit CI never runs on.
|
|
1096
1541
|
const title = pr?.kind === "ok" ? (pr.pr?.title ?? "") : "";
|
|
1097
1542
|
const titleToken = f.pr !== undefined ? SKIP_CI_TOKEN.exec(title)?.[0] : undefined;
|
|
1098
|
-
|
|
1543
|
+
let r = titleToken !== undefined
|
|
1099
1544
|
? {
|
|
1100
1545
|
code: GATE.TITLE_SKIP,
|
|
1101
1546
|
passed: false,
|
|
@@ -1111,6 +1556,8 @@ function runGate(ctx) {
|
|
|
1111
1556
|
repo: str(f.repo) ?? null,
|
|
1112
1557
|
skippedLanes: [],
|
|
1113
1558
|
nonBookkeepingPaths: [],
|
|
1559
|
+
failedSteps: [],
|
|
1560
|
+
regenerable: false,
|
|
1114
1561
|
reason: `PR title '${title}' contains the CI-suppressing token ${titleToken}`,
|
|
1115
1562
|
}
|
|
1116
1563
|
: shipGate({
|
|
@@ -1128,6 +1575,53 @@ function runGate(ctx) {
|
|
|
1128
1575
|
}, gh, ctx.log);
|
|
1129
1576
|
if (titleToken !== undefined)
|
|
1130
1577
|
ctx.log(r.reason);
|
|
1578
|
+
// Debug retains the configured gate above and also proves the original
|
|
1579
|
+
// selected workflow at the pushed head. A different workflow need not contain
|
|
1580
|
+
// the configured capstone, but its whole run must have completed successfully.
|
|
1581
|
+
let verifyingRun;
|
|
1582
|
+
if (r.code === EXIT.OK && selection?.mode === "ci") {
|
|
1583
|
+
const repo = str(f.repo) ?? r.repo;
|
|
1584
|
+
let reason = "";
|
|
1585
|
+
let code = GATE.FAILED;
|
|
1586
|
+
if (repo !== selection.repo) {
|
|
1587
|
+
reason = "selected CI repository differs from the gated repository";
|
|
1588
|
+
}
|
|
1589
|
+
else {
|
|
1590
|
+
const response = gh([
|
|
1591
|
+
"api",
|
|
1592
|
+
`/repos/${selection.repo}/actions/workflows/${selection.workflowId}/runs?head_sha=${queryValue(head)}`,
|
|
1593
|
+
]);
|
|
1594
|
+
if (!response.ok) {
|
|
1595
|
+
code = response.missing ? EXIT.USE_MCP : GATE.API_ERROR;
|
|
1596
|
+
reason = "selected workflow verification is unavailable";
|
|
1597
|
+
}
|
|
1598
|
+
else {
|
|
1599
|
+
const payload = jsonOrUndefined(response.stdout);
|
|
1600
|
+
const candidates = arr(obj(payload).workflow_runs)
|
|
1601
|
+
.filter((value) => String(obj(value).workflow_id) === selection.workflowId &&
|
|
1602
|
+
text(obj(obj(value).repository).full_name).toLowerCase() ===
|
|
1603
|
+
selection.repo.toLowerCase() &&
|
|
1604
|
+
text(obj(obj(value).head_repository).full_name).toLowerCase() ===
|
|
1605
|
+
selection.repo.toLowerCase() &&
|
|
1606
|
+
obj(value).head_branch === (str(f.branch) ?? selection.headBranch) &&
|
|
1607
|
+
(str(f.event) === undefined || obj(value).event === str(f.event)))
|
|
1608
|
+
.map(toRun)
|
|
1609
|
+
.filter((run) => run.head_sha === head && run.id !== null);
|
|
1610
|
+
verifyingRun = latest(candidates.filter((run) => run.status === "completed"));
|
|
1611
|
+
if (!verifyingRun) {
|
|
1612
|
+
code = candidates.length > 0 ? GATE.IN_PROGRESS : GATE.NO_RUN;
|
|
1613
|
+
reason = `selected workflow ${selection.workflowId} has no completed run at pushed head ${head}`;
|
|
1614
|
+
}
|
|
1615
|
+
else if (verifyingRun.conclusion !== "success") {
|
|
1616
|
+
reason = `selected workflow verification concluded '${verifyingRun.conclusion}' at pushed head ${head}`;
|
|
1617
|
+
}
|
|
1618
|
+
}
|
|
1619
|
+
}
|
|
1620
|
+
if (reason) {
|
|
1621
|
+
ctx.log(reason);
|
|
1622
|
+
r = { ...r, code, passed: false, overridden: false, reason };
|
|
1623
|
+
}
|
|
1624
|
+
}
|
|
1131
1625
|
if (recordFile !== undefined && r.code !== EXIT.USE_MCP) {
|
|
1132
1626
|
if (f.capstoneOnly === true) {
|
|
1133
1627
|
const verdict = r.code === EXIT.OK ? "PASS" : "FAIL";
|
|
@@ -1142,20 +1636,22 @@ function runGate(ctx) {
|
|
|
1142
1636
|
auditRow(recordFile, "ship-gate-refusal", { exitCode: r.code, head: r.mergeHead });
|
|
1143
1637
|
}
|
|
1144
1638
|
}
|
|
1145
|
-
ctx.emit({
|
|
1639
|
+
ctx.emit({
|
|
1640
|
+
...r,
|
|
1641
|
+
...(selection?.mode === "ci"
|
|
1642
|
+
? {
|
|
1643
|
+
originalRunId: selection.runId,
|
|
1644
|
+
originalRunUrl: selection.runUrl,
|
|
1645
|
+
verifyingRunId: verifyingRun?.id ?? null,
|
|
1646
|
+
verifyingRunUrl: verifyingRun?.html_url ?? null,
|
|
1647
|
+
}
|
|
1648
|
+
: {}),
|
|
1649
|
+
});
|
|
1146
1650
|
return r.code;
|
|
1147
1651
|
}
|
|
1148
1652
|
// ---------------------------------------------------------------------------
|
|
1149
1653
|
// revalidate
|
|
1150
1654
|
// ---------------------------------------------------------------------------
|
|
1151
|
-
/** Whether dev demands status checks (ruleset or branch protection): CI must then pass at the PR head. */
|
|
1152
|
-
function devRequiresChecks(gh, repo) {
|
|
1153
|
-
const rules = gh(["api", `repos/${repo}/rules/branches/dev`]);
|
|
1154
|
-
const list = rules.ok ? arr(jsonOrUndefined(rules.stdout)) : [];
|
|
1155
|
-
if (list.some((r) => obj(r).type === "required_status_checks"))
|
|
1156
|
-
return true;
|
|
1157
|
-
return gh(["api", `repos/${repo}/branches/dev/protection/required_status_checks`]).ok;
|
|
1158
|
-
}
|
|
1159
1655
|
async function runRevalidate(ctx) {
|
|
1160
1656
|
const f = ctx.flags;
|
|
1161
1657
|
const repoFlag = str(f.repo);
|
|
@@ -1308,25 +1804,25 @@ async function runContext(ctx) {
|
|
|
1308
1804
|
prState: null,
|
|
1309
1805
|
runId: null,
|
|
1310
1806
|
};
|
|
1807
|
+
const tracker = readIssueTracker(ctx.cwd);
|
|
1311
1808
|
if (chosen.mode === "BRIEF") {
|
|
1312
|
-
ctx.emit({ ...out, issueId: arg });
|
|
1809
|
+
ctx.emit(await withIssue(ctx, { ...out, issueId: arg }, tracker));
|
|
1313
1810
|
return EXIT.OK;
|
|
1314
1811
|
}
|
|
1315
|
-
const tracker = readIssueTracker(ctx.cwd);
|
|
1316
1812
|
if (!/^[0-9]+$/.test(arg)) {
|
|
1317
1813
|
// CI_DEV: a post-merge dev failure names the FID slug; checked before any path sees it.
|
|
1318
1814
|
if (!FID_PATTERNS.any.test(arg)) {
|
|
1319
1815
|
ctx.log(`Invalid CI_DEV FID: ${arg}`);
|
|
1320
1816
|
return EXIT_NO_FID;
|
|
1321
1817
|
}
|
|
1322
|
-
ctx.emit({
|
|
1818
|
+
ctx.emit(await withIssue(ctx, {
|
|
1323
1819
|
...out,
|
|
1324
1820
|
mode: "CI_DEV",
|
|
1325
1821
|
fid: arg,
|
|
1326
1822
|
issueId: tracker === "none" ? null : issueIdOf(arg, "any"),
|
|
1327
1823
|
branch: DEV,
|
|
1328
1824
|
headSha: git(ctx.cwd, ["rev-parse", "origin/dev"]) ?? "",
|
|
1329
|
-
});
|
|
1825
|
+
}, tracker));
|
|
1330
1826
|
return EXIT.OK;
|
|
1331
1827
|
}
|
|
1332
1828
|
const view = runGh(ctx.cwd, [
|
|
@@ -1389,9 +1885,30 @@ async function runContext(ctx) {
|
|
|
1389
1885
|
ctx.emit(out);
|
|
1390
1886
|
return EXIT_NO_FID;
|
|
1391
1887
|
}
|
|
1392
|
-
|
|
1888
|
+
if (parsed.issueId === null && tracker !== "none") {
|
|
1889
|
+
ctx.log(`FID ${parsed.fid} names no issue; /bkit-auto runs from an issue only`);
|
|
1890
|
+
ctx.emit(out);
|
|
1891
|
+
return EXIT_NO_FID;
|
|
1892
|
+
}
|
|
1893
|
+
ctx.emit(await withIssue(ctx, { ...out, fid: parsed.fid, issueId: parsed.issueId }, tracker));
|
|
1393
1894
|
return EXIT.OK;
|
|
1394
1895
|
}
|
|
1896
|
+
/**
|
|
1897
|
+
* `ref` (the issue as a workflow argument: `#N` on GitHub, the key uppercased on
|
|
1898
|
+
* Linear / Jira) and `labels` (read from the tracker; null when there is no issue
|
|
1899
|
+
* or the read failed, logged).
|
|
1900
|
+
*/
|
|
1901
|
+
async function withIssue(ctx, out, tracker) {
|
|
1902
|
+
const id = typeof out.issueId === "string" && out.issueId !== "" ? out.issueId : null;
|
|
1903
|
+
const ref = issueRef(id, tracker);
|
|
1904
|
+
if (id === null || tracker === "none")
|
|
1905
|
+
return { ...out, ref, labels: null };
|
|
1906
|
+
let labels = null;
|
|
1907
|
+
const read = await attempt("labels", ctx.log, async () => {
|
|
1908
|
+
labels = await readLabels(trackerTarget(ctx.cwd, { issue: id }));
|
|
1909
|
+
});
|
|
1910
|
+
return { ...out, ref, labels: "done" in read && read.done ? labels : null };
|
|
1911
|
+
}
|
|
1395
1912
|
async function runMirror(ctx) {
|
|
1396
1913
|
const f = ctx.flags;
|
|
1397
1914
|
const head = String(f.head);
|
|
@@ -1430,8 +1947,61 @@ export const runsCommand = {
|
|
|
1430
1947
|
noun: "runs",
|
|
1431
1948
|
summary: "CI runs: wait for one, prove one was dispatched, re-validate and gate a merge on one; auto's start context.",
|
|
1432
1949
|
verbs: {
|
|
1950
|
+
locate: {
|
|
1951
|
+
summary: "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.",
|
|
1952
|
+
use: "workflow",
|
|
1953
|
+
flags: [
|
|
1954
|
+
{
|
|
1955
|
+
name: "prompt-file",
|
|
1956
|
+
type: "string",
|
|
1957
|
+
required: true,
|
|
1958
|
+
help: "session prompt; [local] overrides all CI references",
|
|
1959
|
+
},
|
|
1960
|
+
{
|
|
1961
|
+
name: "issue-text-file",
|
|
1962
|
+
type: "string",
|
|
1963
|
+
help: "current issue description and human comments from issues text",
|
|
1964
|
+
},
|
|
1965
|
+
{ name: "branch", type: "string", required: true, help: "adopted existing branch" },
|
|
1966
|
+
{ name: "repo", type: "string", required: true, help: "owner/repository" },
|
|
1967
|
+
{
|
|
1968
|
+
name: "file",
|
|
1969
|
+
type: "string",
|
|
1970
|
+
help: "active debug status log; saved selection takes precedence over issue discovery",
|
|
1971
|
+
},
|
|
1972
|
+
{
|
|
1973
|
+
name: "selection-out",
|
|
1974
|
+
type: "string",
|
|
1975
|
+
required: true,
|
|
1976
|
+
help: "write the validated candidate selection; does not update active metadata",
|
|
1977
|
+
},
|
|
1978
|
+
{
|
|
1979
|
+
name: "evidence-file",
|
|
1980
|
+
type: "string",
|
|
1981
|
+
help: "normalized fallback JSON: exact request identity, run, complete jobs, complete:true; automatic no-red also identifies workflow and inspected head",
|
|
1982
|
+
},
|
|
1983
|
+
],
|
|
1984
|
+
output: {
|
|
1985
|
+
selection: "ci | local",
|
|
1986
|
+
runId: "selected run ID, or null",
|
|
1987
|
+
runUrl: "selected attempt URL, or null",
|
|
1988
|
+
runAttempt: "frozen attempt, or null",
|
|
1989
|
+
workflowId: "selected workflow ID, or null",
|
|
1990
|
+
workflowPath: "selected workflow path, or null",
|
|
1991
|
+
headSha: "selected commit, or null",
|
|
1992
|
+
headRelation: "current | ancestor | null; divergent or unknown evidence exits 82",
|
|
1993
|
+
failedJobs: "complete failed-job list",
|
|
1994
|
+
tiers: "known failed tiers; empty when any failed job is unknown",
|
|
1995
|
+
via: "prompt-run | prompt-pr | issue-run | issue-pr | branch, or null",
|
|
1996
|
+
reason: "local selection reason, or null",
|
|
1997
|
+
selectionFile: "validated candidate JSON path",
|
|
1998
|
+
},
|
|
1999
|
+
exitCodes: { 8: "ambiguous winning references" },
|
|
2000
|
+
run: locateCi,
|
|
2001
|
+
},
|
|
1433
2002
|
wait: {
|
|
1434
2003
|
summary: "Bounded poll for a CI check on a PR (--pr) or a CI run at a head (--head --branch), present or completed.",
|
|
2004
|
+
use: "by-hand",
|
|
1435
2005
|
flags: [
|
|
1436
2006
|
{ name: "pr", type: "string", help: "PR number: read its check rollup" },
|
|
1437
2007
|
{ ...HEAD_FLAG, help: "commit SHA: read the CI workflow's runs at it (with --branch)" },
|
|
@@ -1469,12 +2039,18 @@ export const runsCommand = {
|
|
|
1469
2039
|
run: runWait,
|
|
1470
2040
|
},
|
|
1471
2041
|
dispatch: {
|
|
1472
|
-
summary: "CI-Dispatch Gate after the last push: poll, one clean re-trigger, the ciDispatch verdict, and the body scan.",
|
|
2042
|
+
summary: "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.",
|
|
2043
|
+
use: "workflow",
|
|
1473
2044
|
flags: [
|
|
1474
2045
|
{
|
|
1475
2046
|
name: "pr",
|
|
1476
2047
|
type: "string",
|
|
1477
|
-
help: "PR number (default: the open PR from this branch into dev)",
|
|
2048
|
+
help: "PR number (default: the open PR from this branch into dev; none on dev itself: the push-event run at --sha is read instead)",
|
|
2049
|
+
},
|
|
2050
|
+
{
|
|
2051
|
+
name: "sha",
|
|
2052
|
+
type: "string",
|
|
2053
|
+
help: "a run in place on dev (no PR): the full 40-hex sha its push landed, which the CI run is looked up at (default: HEAD); an own-commit push lands copies, so pass the push's `sha`",
|
|
1478
2054
|
},
|
|
1479
2055
|
{
|
|
1480
2056
|
name: "fid",
|
|
@@ -1529,14 +2105,15 @@ export const runsCommand = {
|
|
|
1529
2105
|
output: {
|
|
1530
2106
|
ciDispatch: "{outcome, head, attempts, retrigger, reason?} — record with `bkit steps done --field ciDispatch=…` (local only, never pushed); null on a hand-off",
|
|
1531
2107
|
phase: "done | poll | repoll (which poll was handed to the agent)",
|
|
1532
|
-
pr: "PR number polled (null when none was found)",
|
|
1533
|
-
head: "the pushed head (the re-trigger commit after a re-trigger)",
|
|
2108
|
+
pr: "PR number polled (null when none was found, or a run in place on dev, whose run is read at head)",
|
|
2109
|
+
head: "the pushed head (the re-trigger commit after a re-trigger; on dev with a record, the sha its own-commit push landed)",
|
|
1534
2110
|
attempts: "poll attempts so far",
|
|
1535
2111
|
retrigger: "a re-trigger commit was pushed",
|
|
1536
2112
|
scanResult: "clean | skip-token-found | error — the pushed head's BODY scan; null when unresolved",
|
|
1537
2113
|
ciWorkflow: "the CI workflow file the no-ci check looked for",
|
|
1538
2114
|
row: "--file: the step-done row written (null on a hand-off)",
|
|
1539
2115
|
transport: "--file: the close-transport row written for a passed verdict, else null",
|
|
2116
|
+
progressLine: "--file: the exact chat progress line after a numbered completion is recorded",
|
|
1540
2117
|
},
|
|
1541
2118
|
exitCodes: {
|
|
1542
2119
|
[EXIT_SKIP_TOKEN]: "the pushed head's body carries a CI-suppression token",
|
|
@@ -1547,7 +2124,13 @@ export const runsCommand = {
|
|
|
1547
2124
|
},
|
|
1548
2125
|
gate: {
|
|
1549
2126
|
summary: "Ship merge gate: the capstone job present and green at the head (exit 0), or why not.",
|
|
2127
|
+
use: "workflow",
|
|
1550
2128
|
flags: [
|
|
2129
|
+
{
|
|
2130
|
+
name: "ci-selection-file",
|
|
2131
|
+
type: "string",
|
|
2132
|
+
help: "validated original debug selection: additionally require its workflow to succeed at the exact pushed head",
|
|
2133
|
+
},
|
|
1551
2134
|
{ ...HEAD_FLAG, help: "the PR head to merge (or --pr / --squash-of)" },
|
|
1552
2135
|
{
|
|
1553
2136
|
name: "pr",
|
|
@@ -1582,6 +2165,11 @@ export const runsCommand = {
|
|
|
1582
2165
|
type: "string",
|
|
1583
2166
|
help: "PR branch: tells a superseded head (14) from no run (10)",
|
|
1584
2167
|
},
|
|
2168
|
+
{
|
|
2169
|
+
name: "fetch",
|
|
2170
|
+
type: "boolean",
|
|
2171
|
+
help: "fetch origin/<--branch> first (best-effort, logged on failure)",
|
|
2172
|
+
},
|
|
1585
2173
|
{
|
|
1586
2174
|
name: "event",
|
|
1587
2175
|
type: "string",
|
|
@@ -1607,6 +2195,10 @@ export const runsCommand = {
|
|
|
1607
2195
|
testedHead: "head the selected (or superseded) run tested",
|
|
1608
2196
|
runId: "selected run id",
|
|
1609
2197
|
runUrl: "selected run URL",
|
|
2198
|
+
originalRunId: "--ci-selection-file: original failing run ID",
|
|
2199
|
+
originalRunUrl: "--ci-selection-file: original failing attempt URL",
|
|
2200
|
+
verifyingRunId: "--ci-selection-file: selected workflow's verifying run ID at the pushed head",
|
|
2201
|
+
verifyingRunUrl: "--ci-selection-file: selected workflow's verifying run URL at the pushed head",
|
|
1610
2202
|
conclusion: "selected run conclusion",
|
|
1611
2203
|
capstone: "capstone job name",
|
|
1612
2204
|
ciWorkflow: "CI workflow file",
|
|
@@ -1631,6 +2223,7 @@ export const runsCommand = {
|
|
|
1631
2223
|
},
|
|
1632
2224
|
revalidate: {
|
|
1633
2225
|
summary: "Ship: pick the head CI must pass at, probe for a run there, dispatch only when none, wait for it to complete.",
|
|
2226
|
+
use: "workflow",
|
|
1634
2227
|
flags: [
|
|
1635
2228
|
{ name: "pr", type: "string", required: true, help: "the PR number" },
|
|
1636
2229
|
{ name: "entry-head", type: "string", required: true, help: "the PR head read at Step 2" },
|
|
@@ -1679,6 +2272,7 @@ export const runsCommand = {
|
|
|
1679
2272
|
},
|
|
1680
2273
|
mirror: {
|
|
1681
2274
|
summary: "Release PR: wait for the branch's push run at the head and copy its capstone verdict.",
|
|
2275
|
+
use: "workflow",
|
|
1682
2276
|
flags: [
|
|
1683
2277
|
{ ...HEAD_FLAG, required: true, help: "the PR head (same SHA the push run tests)" },
|
|
1684
2278
|
{ name: "branch", type: "string", help: "branch whose push run to mirror (default dev)" },
|
|
@@ -1713,6 +2307,7 @@ export const runsCommand = {
|
|
|
1713
2307
|
},
|
|
1714
2308
|
context: {
|
|
1715
2309
|
summary: "/bkit-auto Step 1: the phase and mode, the repo, and the issue / FID / PR / run the dispatch carries.",
|
|
2310
|
+
use: "workflow",
|
|
1716
2311
|
flags: [
|
|
1717
2312
|
{
|
|
1718
2313
|
name: "phase",
|
|
@@ -1739,6 +2334,8 @@ export const runsCommand = {
|
|
|
1739
2334
|
owner: "owner half",
|
|
1740
2335
|
repo: "repo half",
|
|
1741
2336
|
issueId: "the issue (BRIEF: the arg; CI: from the marker or branch; null under no tracker)",
|
|
2337
|
+
ref: 'the issue as the phase workflow\'s argument: #N (GitHub), the key uppercased (Linear / Jira), else issueId verbatim or ""',
|
|
2338
|
+
labels: "the issue's labels read from the tracker; null with no issue or when the read failed (read them via the tracker MCP)",
|
|
1742
2339
|
fid: "the FID (CI / CI_DEV), else null",
|
|
1743
2340
|
prNumber: "the PR (CI), else null",
|
|
1744
2341
|
branch: "the PR head branch (CI), dev (CI_DEV), else null",
|
|
@@ -1751,12 +2348,13 @@ export const runsCommand = {
|
|
|
1751
2348
|
[EXIT_UNKNOWN_PHASE]: "the phase word is not one bkit dispatches",
|
|
1752
2349
|
[EXIT_PR_NOT_OPEN]: "the PR is not OPEN",
|
|
1753
2350
|
[EXIT_NO_RUN_ID]: "no CI run at the PR head",
|
|
1754
|
-
[EXIT_NO_FID]: "no valid FID (CI_DEV slug off the allowlist,
|
|
2351
|
+
[EXIT_NO_FID]: "no valid FID or no issue (CI_DEV slug off the allowlist, no marker / feat/{FID} branch, or an issue-less FID: /bkit-auto runs issue-only)",
|
|
1755
2352
|
},
|
|
1756
2353
|
run: runContext,
|
|
1757
2354
|
},
|
|
1758
2355
|
declared: {
|
|
1759
|
-
summary: "Whether the repo declares a CI workflow: .github/workflows/<bkit.ciWorkflow> exists (exit 0) or not (exit 1).",
|
|
2356
|
+
summary: "Whether the repo declares a CI workflow: .github/workflows/<bkit.testing.ciWorkflow> exists (exit 0) or not (exit 1).",
|
|
2357
|
+
use: "by-hand",
|
|
1760
2358
|
flags: [],
|
|
1761
2359
|
output: {
|
|
1762
2360
|
declared: "the workflow file exists",
|