@cbartens/bkit 6.1.1 → 6.2.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 +14 -12
- package/.bkit/core/.agents/docs.md +1 -11
- package/.bkit/core/.agents/plugins/bkit/hooks/bkit-gateguard.cjs +30 -9
- package/.bkit/core/.agents/plugins/bkit/hooks/bkit-guardrails.cjs +25 -27
- package/.bkit/core/.agents/rules.md +22 -9
- package/.bkit/core/.bkit/README.md +13 -11
- package/.bkit/core/.bkit/authoring.md +58 -13
- package/.bkit/core/.bkit/cli.md +42 -32
- package/.bkit/core/.bkit/cloud.md +93 -30
- package/.bkit/core/.bkit/install.md +55 -16
- package/.bkit/core/.bkit/jsonl.md +24 -7
- package/.bkit/core/.bkit/pipeline.md +8 -8
- package/.bkit/core/.bkit/prompts.md +160 -43
- package/.bkit/core/.bkit/providers.md +97 -36
- package/.bkit/core/.bkit/templates.md +162 -34
- package/.bkit/core/.bkit/trackers.md +39 -6
- package/.bkit/core/.bkit/workflows.md +344 -136
- package/.bkit/core/.claude/hooks/bkit-guardrails.cjs +50 -27
- package/.bkit/core/.claude/hooks/bkit-preflight.sh +11 -11
- package/.bkit/core/.codex/hooks/bkit-gateguard.cjs +13 -8
- package/.bkit/core/.codex/hooks/bkit-guardrails.cjs +14 -25
- package/.bkit/core/.cursor/hooks/bkit-guardrails.cjs +20 -9
- package/.bkit/core/.cursor/hooks/bkit-preflight.sh +8 -8
- package/.bkit/core/.opencode/plugin/bkit-gateguard.js +14 -4
- package/.bkit/core/.opencode/plugin/bkit-guardrails.js +114 -0
- package/.bkit/core/docs/templates/bkit-audit-accessibility.md +1 -1
- package/.bkit/core/docs/templates/bkit-audit-adoption.md +30 -6
- package/.bkit/core/docs/templates/bkit-audit-agents.md +1 -1
- package/.bkit/core/docs/templates/bkit-audit-aio-seo.md +1 -1
- package/.bkit/core/docs/templates/bkit-audit-analytics.md +1 -1
- package/.bkit/core/docs/templates/bkit-audit-annotations.md +1 -1
- package/.bkit/core/docs/templates/bkit-audit-app-performance.md +1 -1
- package/.bkit/core/docs/templates/bkit-audit-app-store.md +1 -1
- package/.bkit/core/docs/templates/bkit-audit-architecture.md +1 -1
- package/.bkit/core/docs/templates/bkit-audit-ci-performance.md +2 -2
- package/.bkit/core/docs/templates/bkit-audit-config.md +3 -2
- package/.bkit/core/docs/templates/bkit-audit-cost.md +1 -1
- package/.bkit/core/docs/templates/bkit-audit-coverage.md +1 -1
- package/.bkit/core/docs/templates/bkit-audit-database.md +3 -3
- package/.bkit/core/docs/templates/bkit-audit-dead-code.md +1 -1
- package/.bkit/core/docs/templates/bkit-audit-deferrals.md +1 -1
- package/.bkit/core/docs/templates/bkit-audit-dependencies.md +3 -3
- package/.bkit/core/docs/templates/bkit-audit-documentation.md +32 -2
- package/.bkit/core/docs/templates/bkit-audit-duplication.md +1 -1
- package/.bkit/core/docs/templates/bkit-audit-failures.md +1 -1
- package/.bkit/core/docs/templates/bkit-audit-flakes.md +2 -2
- package/.bkit/core/docs/templates/bkit-audit-gates.md +5 -3
- package/.bkit/core/docs/templates/bkit-audit-issues.md +1 -1
- package/.bkit/core/docs/templates/bkit-audit-llm.md +2 -2
- package/.bkit/core/docs/templates/bkit-audit-logs.md +1 -1
- package/.bkit/core/docs/templates/bkit-audit-models.md +2 -2
- package/.bkit/core/docs/templates/bkit-audit-privacy.md +1 -1
- package/.bkit/core/docs/templates/bkit-audit-prompts.md +1 -1
- package/.bkit/core/docs/templates/bkit-audit-red-team.md +2 -2
- package/.bkit/core/docs/templates/bkit-audit-reliability.md +3 -2
- package/.bkit/core/docs/templates/bkit-audit-repo.md +1 -1
- package/.bkit/core/docs/templates/bkit-audit-security.md +1 -1
- package/.bkit/core/docs/templates/bkit-audit-slop.md +1 -1
- package/.bkit/core/docs/templates/bkit-audit-testing.md +3 -2
- package/.bkit/core/docs/templates/bkit-audit-usability.md +1 -1
- package/.bkit/core/docs/templates/bkit-plan.md +38 -8
- package/.bkit/core/engine/checks/after/auth.ts +118 -47
- package/.bkit/core/engine/checks/after/github.ts +89 -37
- package/.bkit/core/engine/checks/after/index.ts +15 -3
- package/.bkit/core/engine/checks/after/tools.ts +245 -1
- package/.bkit/core/engine/checks/before/files.ts +59 -1
- package/.bkit/core/engine/checks/before/index.ts +8 -0
- package/.bkit/core/engine/checks/status-holes.ts +20 -26
- package/.bkit/core/engine/checks/tips/catalogue.ts +107 -10
- package/.bkit/core/engine/checks/tips/detect.ts +36 -3
- package/.bkit/core/engine/checks/tips/index.ts +1 -1
- package/.bkit/core/engine/cli.ts +13 -13
- package/.bkit/core/engine/commands/ci/ci.ts +64 -11
- package/.bkit/core/engine/commands/ci/push-gate.ts +101 -43
- package/.bkit/core/engine/commands/install/install.ts +28 -25
- package/.bkit/core/engine/commands/install/uninstall.ts +42 -30
- package/.bkit/core/engine/commands/install/upgrade.ts +14 -2
- package/.bkit/core/engine/commands/land.ts +2 -3
- package/.bkit/core/engine/commands/lib.ts +394 -39
- package/.bkit/core/engine/commands/registry.ts +1 -1
- package/.bkit/core/engine/commands/workflow/branches.ts +351 -78
- package/.bkit/core/engine/commands/workflow/challenge.ts +63 -14
- package/.bkit/core/engine/commands/workflow/context.ts +71 -10
- package/.bkit/core/engine/commands/workflow/counters.ts +298 -23
- package/.bkit/core/engine/commands/workflow/decisions.ts +260 -125
- package/.bkit/core/engine/commands/workflow/disk.ts +2 -1
- package/.bkit/core/engine/commands/workflow/feature-base.ts +66 -0
- package/.bkit/core/engine/commands/workflow/issues.ts +312 -17
- package/.bkit/core/engine/commands/workflow/junit.ts +204 -0
- package/.bkit/core/engine/commands/workflow/ledgers.ts +904 -99
- package/.bkit/core/engine/commands/workflow/locks.ts +186 -29
- package/.bkit/core/engine/commands/workflow/loops.ts +87 -0
- package/.bkit/core/engine/commands/workflow/open-decision.ts +251 -0
- package/.bkit/core/engine/commands/workflow/plan-blocks.ts +8 -0
- package/.bkit/core/engine/commands/workflow/plans.ts +1 -1
- package/.bkit/core/engine/commands/workflow/prs.ts +311 -16
- package/.bkit/core/engine/commands/workflow/repo.ts +1 -1
- package/.bkit/core/engine/commands/workflow/run-facts.ts +6 -0
- package/.bkit/core/engine/commands/workflow/runs.ts +877 -174
- package/.bkit/core/engine/commands/workflow/runtime.ts +12 -4
- package/.bkit/core/engine/commands/workflow/status.ts +324 -11
- package/.bkit/core/engine/commands/workflow/step-table.ts +41 -15
- package/.bkit/core/engine/commands/workflow/steps.ts +604 -29
- package/.bkit/core/engine/commands/workflow/summary-findings.ts +1 -1
- package/.bkit/core/engine/commands/workflow/summary.ts +314 -8
- package/.bkit/core/engine/commands/workflow/tasks.ts +400 -27
- package/.bkit/core/engine/commands/workflow/tests-base.ts +319 -0
- package/.bkit/core/engine/commands/workflow/tests-changed.ts +138 -74
- package/.bkit/core/engine/commands/workflow/tests-jump.ts +93 -0
- package/.bkit/core/engine/commands/workflow/tests.ts +815 -182
- package/.bkit/core/engine/commands/workflow/tracker.ts +1134 -137
- package/.bkit/core/engine/commands/workflow/workflows.ts +100 -72
- package/.bkit/core/engine/commands/workflow/worktrees.ts +421 -57
- package/.bkit/core/engine/install/cloud-env.ts +38 -10
- package/.bkit/core/engine/install/managed-block.ts +105 -0
- package/.bkit/core/engine/install/manifest.ts +7 -1
- package/.bkit/core/engine/install/modules/claude.ts +6 -2
- package/.bkit/core/engine/install/modules/cloud.ts +84 -95
- package/.bkit/core/engine/install/modules/codex.ts +10 -2
- package/.bkit/core/engine/install/modules/core.ts +148 -14
- package/.bkit/core/engine/install/modules/opencode.ts +18 -23
- package/.bkit/core/engine/install/network-allowlist.ts +8 -3
- package/.bkit/core/engine/install/project-docs.ts +650 -0
- package/.bkit/core/engine/install/template-copies.ts +58 -5
- package/.bkit/core/engine/install/write.ts +128 -7
- package/.bkit/core/engine/ledgers/journal.ts +18 -10
- package/.bkit/core/engine/ledgers/migrate.ts +20 -8
- package/.bkit/core/engine/ledgers/status.ts +604 -8
- package/.bkit/core/engine/ledgers/telemetry.ts +115 -13
- package/.bkit/core/engine/render/trackers.ts +3 -1
- package/.bkit/core/engine/shared/package-manager.ts +7 -3
- package/.bkit/core/engine/shared/settings.ts +12 -1
- package/.bkit/core/engine/shared/text.ts +14 -0
- package/.bkit/core/engine/tools/instructions-sources.ts +1 -0
- package/.bkit/core/engine/tools/instructions.ts +116 -20
- package/.bkit/core/hooks/antigravity-hook.js +20 -4
- package/.bkit/core/hooks/gateguard-edit-payload.js +8 -5
- package/.bkit/core/hooks/gateguard-engine.js +249 -23
- package/.bkit/core/hooks/guardrails-deny.js +167 -0
- package/.bkit/core/hooks/guardrails-read.js +3 -3
- package/.bkit/core/hooks/guardrails-shell.js +1122 -167
- package/.bkit/core/hooks/guardrails-tiers.js +247 -176
- package/.bkit/core/hooks/preflight-tracker.sh +219 -0
- package/.bkit/core/prompts/bkit-audit-generate.md +23 -6
- package/.bkit/core/prompts/bkit-build-challenge-1.md +5 -4
- package/.bkit/core/prompts/bkit-build-challenge-2.md +6 -5
- package/.bkit/core/prompts/bkit-build-install-skills.md +2 -2
- package/.bkit/core/prompts/bkit-build-plan-convert.md +21 -7
- package/.bkit/core/prompts/bkit-build-plan-current.md +5 -4
- package/.bkit/core/prompts/bkit-build-plan-gaps-remediate.md +22 -17
- package/.bkit/core/prompts/bkit-build-plan-tasks.md +16 -12
- package/.bkit/core/prompts/bkit-build-plan-tests.md +14 -10
- package/.bkit/core/prompts/bkit-build-plan-verify.md +21 -8
- package/.bkit/core/prompts/bkit-debug-abort-handover.md +10 -5
- package/.bkit/core/prompts/bkit-debug-failure-diagnose.md +22 -6
- package/.bkit/core/prompts/bkit-debug-failure-remediate.md +19 -3
- package/.bkit/core/prompts/bkit-debug-failure-reproduce.md +22 -6
- package/.bkit/core/prompts/bkit-debug-failure-soak.md +10 -7
- package/.bkit/core/prompts/bkit-design-brainstorm-ideate-1.md +3 -3
- package/.bkit/core/prompts/bkit-design-brainstorm-ideate-2.md +4 -4
- package/.bkit/core/prompts/bkit-design-brainstorm-ideate-3.md +3 -3
- package/.bkit/core/prompts/bkit-design-generate.md +6 -4
- package/.bkit/core/prompts/bkit-design-organise.md +4 -3
- package/.bkit/core/prompts/bkit-design-review-1.md +5 -4
- package/.bkit/core/prompts/bkit-design-review-2.md +6 -5
- package/.bkit/core/prompts/bkit-design-spike.md +4 -3
- package/.bkit/core/prompts/bkit-design-update.md +6 -4
- package/.bkit/core/prompts/bkit-plan-generate.md +35 -14
- package/.bkit/core/prompts/bkit-plan-review-1.md +9 -7
- package/.bkit/core/prompts/bkit-plan-review-2.md +9 -7
- package/.bkit/core/prompts/bkit-plan-scope-check.md +8 -6
- package/.bkit/core/prompts/bkit-plan-update.md +22 -8
- package/.bkit/core/prompts/bkit-ship-conflict-resolve.md +11 -8
- package/.bkit/core/prompts/bkit-ship-deferred-sweep.md +9 -5
- package/.bkit/core/prompts/bkit-ship-update-docs.md +26 -4
- package/.bkit/core/prompts/bkit-utility-compress-markdown.md +3 -3
- package/.bkit/core/prompts/bkit-utility-update-decisions.md +10 -7
- package/.bkit/core/prompts/bkit-utility-update-deferrals.md +8 -5
- package/.bkit/core/prompts/bkit-utility-update-documentation.md +31 -7
- package/.bkit/core/prompts/bkit-utility-update-failures.md +8 -5
- package/.bkit/core/prompts/bkit-utility-update-knowledge.md +10 -7
- package/.bkit/core/prompts/bkit-utility-update-roadmap.md +4 -4
- package/.bkit/core/prompts/bkit-utility-update-tracker.md +4 -4
- package/.bkit/core/workflows/bkit-auto.md +23 -11
- package/.bkit/core/workflows/bkit-build.md +331 -100
- package/.bkit/core/workflows/bkit-debug.md +135 -64
- package/.bkit/core/workflows/bkit-design.md +58 -32
- package/.bkit/core/workflows/bkit-plan.md +73 -45
- package/.bkit/core/workflows/bkit-ship.md +233 -167
- package/.bkit/shared/.agents/plugins/bkit/hooks.json +1 -1
- package/.bkit/shared/.bkit/.env.example +5 -0
- package/.bkit/shared/.claude/bkit-cloud.md +7 -7
- package/.bkit/shared/.claude/settings.json +5 -1
- package/.bkit/shared/.cursor/bkit-cloud.md +1 -1
- package/.bkit/shared/.cursor/hooks.json +1 -1
- package/.bkit/shared/.opencode/opencode.json +11 -2
- package/.bkit/templates/.claude/hooks/bkit-cloud-bootstrap.sh +27 -0
- package/.bkit/templates/.cursor/Dockerfile +7 -7
- package/.bkit/templates/.github/ISSUE_TEMPLATE/bkit-idea.yml +1 -1
- package/.bkit/templates/.github/dependabot.yml +5 -0
- package/.bkit/templates/.github/renovate.json5 +5 -3
- package/.bkit/templates/.github/workflows/bkit-ci.yml +11 -11
- package/.bkit/templates/.github/workflows/bkit-cloud.yml +525 -161
- package/.bkit/templates/.github/workflows/bkit-renovate.yml +2 -2
- package/.bkit/templates/.husky/pre-push +123 -6
- package/.bkit/templates/context/bkit-serena.md +1 -1
- package/.bkit/templates/docs/architecture.md +98 -0
- package/.bkit/templates/docs/capabilities.md +33 -37
- package/.bkit/templates/docs/components.md +142 -0
- package/.bkit/templates/docs/data-schema.md +87 -0
- package/.bkit/{shared → templates}/docs/deployments.md +128 -142
- package/.bkit/templates/docs/design.md +117 -0
- package/.bkit/templates/docs/noise.md +54 -0
- package/.bkit/templates/docs/observability.md +99 -0
- package/.bkit/templates/docs/security.md +137 -0
- package/.bkit/templates/docs/setup.md +93 -0
- package/.bkit/templates/docs/technology.md +70 -0
- package/.bkit/{shared → templates}/docs/testing.md +200 -87
- package/.bkit/templates/scripts/ci/bkit-machine-lock.sh +511 -103
- package/.bkit/templates/scripts/ci/bkit-test-awake.mjs +228 -35
- package/.bkit/templates/scripts/ci/bkit-test-awake.test.mjs +270 -2
- package/.bkit/templates/scripts/graphify/bkit-graphify-graphml.py +1 -1
- package/.bkit/templates/scripts/graphify/bkit-graphify-rollup.py +92 -63
- package/.bkit/templates/scripts/graphify/bkit-graphify.sh +59 -11
- package/.bkit/templates/slop-scan.config.json +2 -0
- package/CHANGELOG.md +64 -0
- package/DETAILS.md +24 -19
- package/README.md +1 -1
- package/dist/checks/after/auth.js +114 -46
- package/dist/checks/after/github.js +77 -35
- package/dist/checks/after/index.js +12 -3
- package/dist/checks/after/tools.js +224 -1
- package/dist/checks/before/files.js +59 -1
- package/dist/checks/before/index.js +7 -1
- package/dist/checks/status-holes.js +20 -21
- package/dist/checks/tips/catalogue.js +99 -10
- package/dist/checks/tips/detect.js +35 -3
- package/dist/checks/tips/index.js +1 -1
- package/dist/cli.js +13 -13
- package/dist/commands/ci/ci.js +56 -12
- package/dist/commands/ci/push-gate.js +79 -44
- package/dist/commands/install/install.js +23 -22
- package/dist/commands/install/uninstall.js +36 -30
- package/dist/commands/install/upgrade.js +10 -2
- package/dist/commands/land.js +2 -3
- package/dist/commands/lib.js +323 -25
- package/dist/commands/workflow/branches.js +312 -72
- package/dist/commands/workflow/challenge.js +66 -13
- package/dist/commands/workflow/context.js +46 -10
- package/dist/commands/workflow/counters.js +231 -23
- package/dist/commands/workflow/decisions.js +221 -106
- package/dist/commands/workflow/disk.js +2 -1
- package/dist/commands/workflow/feature-base.js +60 -0
- package/dist/commands/workflow/issues.js +243 -15
- package/dist/commands/workflow/junit.js +137 -0
- package/dist/commands/workflow/ledgers.js +726 -112
- package/dist/commands/workflow/locks.js +150 -29
- package/dist/commands/workflow/loops.js +67 -0
- package/dist/commands/workflow/open-decision.js +199 -0
- package/dist/commands/workflow/plan-blocks.js +6 -0
- package/dist/commands/workflow/plans.js +1 -1
- package/dist/commands/workflow/prs.js +272 -16
- package/dist/commands/workflow/repo.js +1 -1
- package/dist/commands/workflow/run-facts.js +6 -0
- package/dist/commands/workflow/runs.js +747 -155
- package/dist/commands/workflow/runtime.js +8 -4
- package/dist/commands/workflow/status.js +259 -13
- package/dist/commands/workflow/step-table.js +41 -15
- package/dist/commands/workflow/steps.js +530 -26
- package/dist/commands/workflow/summary-findings.js +1 -1
- package/dist/commands/workflow/summary.js +289 -8
- package/dist/commands/workflow/tasks.js +294 -27
- package/dist/commands/workflow/tests-base.js +266 -0
- package/dist/commands/workflow/tests-changed.js +130 -56
- package/dist/commands/workflow/tests-jump.js +77 -0
- package/dist/commands/workflow/tests.js +608 -131
- package/dist/commands/workflow/tracker.js +920 -112
- package/dist/commands/workflow/workflows.js +80 -59
- package/dist/commands/workflow/worktrees.js +387 -58
- package/dist/install/cloud-env.js +32 -10
- package/dist/install/managed-block.js +101 -0
- package/dist/install/manifest.js +7 -1
- package/dist/install/modules/claude.js +6 -2
- package/dist/install/modules/cloud.js +73 -86
- package/dist/install/modules/codex.js +9 -2
- package/dist/install/modules/core.js +133 -14
- package/dist/install/modules/opencode.js +18 -23
- package/dist/install/network-allowlist.js +8 -3
- package/dist/install/project-docs.js +551 -0
- package/dist/install/template-copies.js +55 -5
- package/dist/install/write.js +117 -5
- package/dist/ledgers/journal.js +10 -8
- package/dist/ledgers/migrate.js +20 -9
- package/dist/ledgers/status.js +461 -8
- package/dist/ledgers/telemetry.js +71 -13
- package/dist/render/trackers.js +3 -1
- package/dist/shared/package-manager.js +7 -2
- package/dist/shared/settings.js +8 -0
- package/dist/shared/text.js +13 -0
- package/dist/tools/instructions-sources.js +1 -0
- package/dist/tools/instructions.js +97 -24
- package/package.json +22 -15
- package/.bkit/core/hooks/preflight-linear.sh +0 -73
- package/.bkit/shared/docs/architecture.md +0 -16
- package/.bkit/shared/docs/data-schema.md +0 -16
- package/.bkit/shared/docs/design.md +0 -38
- package/.bkit/shared/docs/noise.md +0 -20
- package/.bkit/shared/docs/observability.md +0 -22
- package/.bkit/shared/docs/security.md +0 -62
- package/.bkit/shared/docs/setup.md +0 -52
- package/.bkit/shared/docs/technology.md +0 -15
- /package/.bkit/templates/{.lintstagedrc.json → lintstagedrc.example.json} +0 -0
- /package/.bkit/templates/{.prettierignore → prettierignore.example} +0 -0
|
@@ -100,8 +100,48 @@ export function probePr(
|
|
|
100
100
|
number?: string;
|
|
101
101
|
/** Honour `--repo`: resolve the PR in this owner/repo, not the checkout's remote. */
|
|
102
102
|
repo?: string;
|
|
103
|
+
shipEntry?: boolean;
|
|
104
|
+
facts?: unknown;
|
|
103
105
|
},
|
|
104
106
|
): Probe {
|
|
107
|
+
const qualify = (pr: PrInfo | undefined): Probe =>
|
|
108
|
+
opts.shipEntry === true && pr?.state === "MERGED"
|
|
109
|
+
? qualifyMergedEntry(cwd, pr, opts.head, opts.base)
|
|
110
|
+
: { kind: "ok", pr };
|
|
111
|
+
if (opts.facts !== undefined) {
|
|
112
|
+
const facts = opts.facts;
|
|
113
|
+
if (
|
|
114
|
+
opts.shipEntry !== true ||
|
|
115
|
+
opts.repo === undefined ||
|
|
116
|
+
opts.head === undefined ||
|
|
117
|
+
opts.base === undefined ||
|
|
118
|
+
typeof facts !== "object" ||
|
|
119
|
+
facts === null ||
|
|
120
|
+
!("ownerRepo" in facts) ||
|
|
121
|
+
facts.ownerRepo !== opts.repo ||
|
|
122
|
+
!("headRefName" in facts) ||
|
|
123
|
+
facts.headRefName !== opts.head ||
|
|
124
|
+
!("baseRefName" in facts) ||
|
|
125
|
+
facts.baseRefName !== opts.base ||
|
|
126
|
+
!("pr" in facts)
|
|
127
|
+
)
|
|
128
|
+
return {
|
|
129
|
+
kind: "failed",
|
|
130
|
+
message: "ship PR facts require matching ownerRepo, headRefName and baseRefName scope",
|
|
131
|
+
};
|
|
132
|
+
if (facts.pr === null) return qualify(undefined);
|
|
133
|
+
if (
|
|
134
|
+
!validPrFacts(facts.pr) ||
|
|
135
|
+
prRepoSlug(facts.pr.url) !== opts.repo ||
|
|
136
|
+
facts.pr.headRefName !== opts.head ||
|
|
137
|
+
facts.pr.baseRefName !== opts.base
|
|
138
|
+
)
|
|
139
|
+
return {
|
|
140
|
+
kind: "failed",
|
|
141
|
+
message: "ship PR facts have an unreadable or mismatched PR identity, head or base scope",
|
|
142
|
+
};
|
|
143
|
+
return qualify(facts.pr);
|
|
144
|
+
}
|
|
105
145
|
if (opts.number !== undefined) {
|
|
106
146
|
const args = ["pr", "view", opts.number, "--json", `${PR_FIELDS},mergeable`];
|
|
107
147
|
if (opts.repo !== undefined) args.push("--repo", opts.repo);
|
|
@@ -109,7 +149,7 @@ export function probePr(
|
|
|
109
149
|
if (!res.ok) return ghFailure(res, `gh pr view ${opts.number}`);
|
|
110
150
|
const parsed = parseJson(res.stdout);
|
|
111
151
|
if (!parsed.ok) return { kind: "failed", message: "gh pr view printed no JSON" };
|
|
112
|
-
return
|
|
152
|
+
return qualify(parsed.value as PrInfo);
|
|
113
153
|
}
|
|
114
154
|
const args = ["pr", "list", "--head", opts.head!, "--state", opts.state, "--json", PR_FIELDS];
|
|
115
155
|
if (opts.base !== undefined) args.push("--base", opts.base);
|
|
@@ -125,7 +165,86 @@ export function probePr(
|
|
|
125
165
|
opts.state === "open"
|
|
126
166
|
? prs[0]
|
|
127
167
|
: (prs.find((p) => p.state === "OPEN") ?? prs.find((p) => p.state === "MERGED"));
|
|
128
|
-
return
|
|
168
|
+
return qualify(pr);
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
export function validPrFacts(value: unknown): value is PrInfo {
|
|
172
|
+
if (typeof value !== "object" || value === null) return false;
|
|
173
|
+
return (
|
|
174
|
+
"number" in value &&
|
|
175
|
+
typeof value.number === "number" &&
|
|
176
|
+
Number.isSafeInteger(value.number) &&
|
|
177
|
+
value.number > 0 &&
|
|
178
|
+
"url" in value &&
|
|
179
|
+
typeof value.url === "string" &&
|
|
180
|
+
"state" in value &&
|
|
181
|
+
typeof value.state === "string" &&
|
|
182
|
+
["OPEN", "MERGED", "CLOSED"].includes(value.state) &&
|
|
183
|
+
"baseRefName" in value &&
|
|
184
|
+
typeof value.baseRefName === "string" &&
|
|
185
|
+
"headRefName" in value &&
|
|
186
|
+
typeof value.headRefName === "string" &&
|
|
187
|
+
"headRefOid" in value &&
|
|
188
|
+
typeof value.headRefOid === "string" &&
|
|
189
|
+
/^[0-9a-f]{40,64}$/i.test(value.headRefOid) &&
|
|
190
|
+
"title" in value &&
|
|
191
|
+
typeof value.title === "string" &&
|
|
192
|
+
"mergeCommit" in value &&
|
|
193
|
+
(value.mergeCommit === null ||
|
|
194
|
+
(typeof value.mergeCommit === "object" &&
|
|
195
|
+
"oid" in value.mergeCommit &&
|
|
196
|
+
typeof value.mergeCommit.oid === "string"))
|
|
197
|
+
);
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
function qualifyMergedEntry(cwd: string, pr: PrInfo, head?: string, base?: string): Probe {
|
|
201
|
+
if (
|
|
202
|
+
!head ||
|
|
203
|
+
pr.headRefName !== head ||
|
|
204
|
+
pr.baseRefName !== (base ?? DEV) ||
|
|
205
|
+
!/^[0-9a-f]{40,64}$/i.test(pr.headRefOid)
|
|
206
|
+
)
|
|
207
|
+
return {
|
|
208
|
+
kind: "failed",
|
|
209
|
+
message: "merged ship entry has unreadable or mismatched feature head/base evidence",
|
|
210
|
+
};
|
|
211
|
+
const local = git(cwd, ["rev-parse", "--verify", "--quiet", `refs/heads/${head}^{commit}`]);
|
|
212
|
+
if (local === null)
|
|
213
|
+
return { kind: "failed", message: `cannot read local feature evidence for ${head}` };
|
|
214
|
+
const remote = runGit(cwd, ["ls-remote", "--heads", "origin", `refs/heads/${head}`]);
|
|
215
|
+
if (!remote.ok)
|
|
216
|
+
return {
|
|
217
|
+
kind: "failed",
|
|
218
|
+
message: `cannot read remote feature evidence for ${head}: ${remote.stderr}`,
|
|
219
|
+
};
|
|
220
|
+
let remoteHead: string | null = null;
|
|
221
|
+
if (remote.stdout.trim() !== "") {
|
|
222
|
+
const fetched = runGit(cwd, [
|
|
223
|
+
"fetch",
|
|
224
|
+
"origin",
|
|
225
|
+
`+refs/heads/${head}:refs/remotes/origin/${head}`,
|
|
226
|
+
]);
|
|
227
|
+
if (!fetched.ok)
|
|
228
|
+
return {
|
|
229
|
+
kind: "failed",
|
|
230
|
+
message: `cannot fetch feature evidence for ${head}: ${fetched.stderr}`,
|
|
231
|
+
};
|
|
232
|
+
remoteHead = git(cwd, [
|
|
233
|
+
"rev-parse",
|
|
234
|
+
"--verify",
|
|
235
|
+
"--quiet",
|
|
236
|
+
`refs/remotes/origin/${head}^{commit}`,
|
|
237
|
+
]);
|
|
238
|
+
if (remoteHead === null)
|
|
239
|
+
return { kind: "failed", message: `cannot read fetched feature evidence for ${head}` };
|
|
240
|
+
}
|
|
241
|
+
return {
|
|
242
|
+
kind: "ok",
|
|
243
|
+
pr:
|
|
244
|
+
local === pr.headRefOid && (remoteHead === null || remoteHead === pr.headRefOid)
|
|
245
|
+
? pr
|
|
246
|
+
: undefined,
|
|
247
|
+
};
|
|
129
248
|
}
|
|
130
249
|
|
|
131
250
|
export function prOutput(pr: PrInfo | undefined) {
|
|
@@ -431,6 +550,9 @@ export interface MergeInput {
|
|
|
431
550
|
/** `--match-head-commit`: the server refuses when the head moved. */
|
|
432
551
|
matchHead?: string;
|
|
433
552
|
deleteBranch?: boolean;
|
|
553
|
+
shipRetry?: boolean;
|
|
554
|
+
repo?: string;
|
|
555
|
+
facts?: unknown;
|
|
434
556
|
}
|
|
435
557
|
|
|
436
558
|
export interface MergeResult {
|
|
@@ -443,6 +565,8 @@ export interface MergeResult {
|
|
|
443
565
|
subject: string;
|
|
444
566
|
verdict: "PASS" | "FAIL";
|
|
445
567
|
failures: number;
|
|
568
|
+
route?: "merged" | "revalidate" | "integrate" | "stop";
|
|
569
|
+
reason?: string;
|
|
446
570
|
};
|
|
447
571
|
}
|
|
448
572
|
|
|
@@ -454,7 +578,14 @@ export interface MergeResult {
|
|
|
454
578
|
* EXIT.USE_MCP (merge through `merge_pull_request` with `subject`).
|
|
455
579
|
*/
|
|
456
580
|
export function mergePr(cwd: string, o: MergeInput, log: (m: string) => void): MergeResult {
|
|
457
|
-
|
|
581
|
+
if (o.shipRetry && !o.matchHead)
|
|
582
|
+
throw new CommandError(EXIT.USAGE, "--ship-retry requires --match-head");
|
|
583
|
+
if (o.shipRetry && o.deleteBranch)
|
|
584
|
+
throw new CommandError(
|
|
585
|
+
EXIT.USAGE,
|
|
586
|
+
"--ship-retry leaves branch cleanup to guarded workflow close",
|
|
587
|
+
);
|
|
588
|
+
const read = () => probePr(cwd, { number: o.number, state: "open", repo: o.repo });
|
|
458
589
|
const result = (code: number, pr: PrInfo | undefined, already: boolean): MergeResult => {
|
|
459
590
|
const merged = pr?.state === "MERGED";
|
|
460
591
|
return {
|
|
@@ -467,17 +598,84 @@ export function mergePr(cwd: string, o: MergeInput, log: (m: string) => void): M
|
|
|
467
598
|
subject: o.subject,
|
|
468
599
|
verdict: merged ? "PASS" : "FAIL",
|
|
469
600
|
failures: merged ? 0 : 1,
|
|
601
|
+
...(o.shipRetry
|
|
602
|
+
? {
|
|
603
|
+
route: merged ? ("merged" as const) : ("stop" as const),
|
|
604
|
+
reason: merged ? "PR merged" : "merge refused",
|
|
605
|
+
}
|
|
606
|
+
: {}),
|
|
470
607
|
},
|
|
471
608
|
};
|
|
472
609
|
};
|
|
473
|
-
const
|
|
610
|
+
const stop = (code: number, reason: string, pr?: PrInfo): MergeResult => {
|
|
611
|
+
log(reason);
|
|
612
|
+
const r = result(code, pr, false);
|
|
613
|
+
return o.shipRetry ? { ...r, out: { ...r.out, route: "stop", reason } } : r;
|
|
614
|
+
};
|
|
615
|
+
const classify = (pr: PrInfo | undefined): MergeResult => {
|
|
616
|
+
if (!o.shipRetry || pr?.state === "MERGED") return result(EXIT.OK, pr, false);
|
|
617
|
+
if (pr?.baseRefName !== DEV) return stop(EXIT_BASE_NOT_DEV, "merge reread base is not dev", pr);
|
|
618
|
+
if (pr.state !== "OPEN") return stop(EXIT_NOT_MERGED, "merge refused: PR is not open", pr);
|
|
619
|
+
if (!/^[0-9a-f]{40,64}$/i.test(pr.headRefOid))
|
|
620
|
+
return stop(EXIT_GH_FAILED, "merge head reread is unavailable", pr);
|
|
621
|
+
const moved = pr.headRefOid !== o.matchHead;
|
|
622
|
+
const conflict = pr.mergeable === "CONFLICTING";
|
|
623
|
+
if (!moved && !conflict)
|
|
624
|
+
return stop(EXIT_NOT_MERGED, "merge refused without a moved head or new dev conflict", pr);
|
|
625
|
+
const reason = moved
|
|
626
|
+
? "PR head moved after validation; revalidate the new head"
|
|
627
|
+
: "PR conflicts with dev; integrate the fresh base";
|
|
628
|
+
log(reason);
|
|
629
|
+
const r = result(moved ? 9 : 10, pr, false);
|
|
630
|
+
return { ...r, out: { ...r.out, route: moved ? "revalidate" : "integrate", reason } };
|
|
631
|
+
};
|
|
632
|
+
let before: Probe;
|
|
633
|
+
let afterFacts: PrInfo | undefined;
|
|
634
|
+
if (o.facts !== undefined) {
|
|
635
|
+
const facts = o.facts;
|
|
636
|
+
if (
|
|
637
|
+
!o.shipRetry ||
|
|
638
|
+
!o.repo ||
|
|
639
|
+
typeof facts !== "object" ||
|
|
640
|
+
facts === null ||
|
|
641
|
+
!("ownerRepo" in facts) ||
|
|
642
|
+
facts.ownerRepo !== o.repo ||
|
|
643
|
+
!("prNumber" in facts) ||
|
|
644
|
+
facts.prNumber !== Number(o.number) ||
|
|
645
|
+
!("matchHead" in facts) ||
|
|
646
|
+
facts.matchHead !== o.matchHead ||
|
|
647
|
+
!("headRefName" in facts) ||
|
|
648
|
+
typeof facts.headRefName !== "string" ||
|
|
649
|
+
!("baseRefName" in facts) ||
|
|
650
|
+
facts.baseRefName !== DEV ||
|
|
651
|
+
!("before" in facts) ||
|
|
652
|
+
!validPrFacts(facts.before) ||
|
|
653
|
+
!("after" in facts) ||
|
|
654
|
+
!validPrFacts(facts.after) ||
|
|
655
|
+
[facts.before, facts.after].some(
|
|
656
|
+
(pr) =>
|
|
657
|
+
pr.number !== Number(o.number) ||
|
|
658
|
+
prRepoSlug(pr.url) !== o.repo ||
|
|
659
|
+
pr.headRefName !== facts.headRefName ||
|
|
660
|
+
pr.baseRefName !== DEV,
|
|
661
|
+
) ||
|
|
662
|
+
facts.before.headRefOid !== o.matchHead ||
|
|
663
|
+
facts.before.state !== "OPEN"
|
|
664
|
+
)
|
|
665
|
+
return stop(
|
|
666
|
+
EXIT_GH_FAILED,
|
|
667
|
+
"merge facts scope or independent post-attempt reread is unavailable or mismatched",
|
|
668
|
+
);
|
|
669
|
+
before = { kind: "ok", pr: facts.before };
|
|
670
|
+
afterFacts = facts.after;
|
|
671
|
+
} else before = read();
|
|
474
672
|
if (before.kind === "unavailable") {
|
|
475
673
|
log(`${before.message} — merge through merge_pull_request with this subject and an empty body`);
|
|
476
674
|
return result(EXIT.USE_MCP, undefined, false);
|
|
477
675
|
}
|
|
478
676
|
if (before.kind === "failed") {
|
|
479
677
|
log(before.message);
|
|
480
|
-
return
|
|
678
|
+
return stop(EXIT_GH_FAILED, before.message);
|
|
481
679
|
}
|
|
482
680
|
if (before.pr?.state === "MERGED") return result(EXIT.OK, before.pr, true);
|
|
483
681
|
if (before.pr?.baseRefName !== DEV) {
|
|
@@ -486,7 +684,20 @@ export function mergePr(cwd: string, o: MergeInput, log: (m: string) => void): M
|
|
|
486
684
|
);
|
|
487
685
|
return result(EXIT_BASE_NOT_DEV, before.pr, false);
|
|
488
686
|
}
|
|
687
|
+
if (
|
|
688
|
+
o.shipRetry &&
|
|
689
|
+
(before.pr.number !== Number(o.number) ||
|
|
690
|
+
(o.repo !== undefined && prRepoSlug(before.pr.url) !== o.repo))
|
|
691
|
+
)
|
|
692
|
+
return stop(
|
|
693
|
+
EXIT_GH_FAILED,
|
|
694
|
+
"merge pre-attempt PR repository or number scope mismatch",
|
|
695
|
+
before.pr,
|
|
696
|
+
);
|
|
697
|
+
if (o.shipRetry && before.pr.headRefOid !== o.matchHead) return classify(before.pr);
|
|
698
|
+
if (afterFacts !== undefined) return classify(afterFacts);
|
|
489
699
|
const args = ["pr", "merge", o.number, "--squash", "--subject", o.subject, "--body", ""];
|
|
700
|
+
if (o.repo !== undefined) args.push("--repo", o.repo);
|
|
490
701
|
if (o.deleteBranch === true) args.push("--delete-branch");
|
|
491
702
|
if (o.matchHead !== undefined) args.push("--match-head-commit", o.matchHead);
|
|
492
703
|
const merged = runGh(cwd, args);
|
|
@@ -500,9 +711,19 @@ export function mergePr(cwd: string, o: MergeInput, log: (m: string) => void): M
|
|
|
500
711
|
log(`gh pr merge ${o.number} failed: ${merged.stderr || `exit ${String(merged.status)}`}`);
|
|
501
712
|
const after = read();
|
|
502
713
|
if (after.kind !== "ok") {
|
|
503
|
-
|
|
504
|
-
return result(EXIT_GH_FAILED, undefined, false);
|
|
714
|
+
return stop(EXIT_GH_FAILED, `merge state reread unavailable: ${after.message}`);
|
|
505
715
|
}
|
|
716
|
+
if (
|
|
717
|
+
o.shipRetry &&
|
|
718
|
+
(after.pr?.number !== Number(o.number) ||
|
|
719
|
+
after.pr.headRefName !== before.pr.headRefName ||
|
|
720
|
+
(o.repo !== undefined && prRepoSlug(after.pr.url) !== o.repo))
|
|
721
|
+
)
|
|
722
|
+
return stop(
|
|
723
|
+
EXIT_GH_FAILED,
|
|
724
|
+
"merge post-attempt PR repository, number or branch scope mismatch",
|
|
725
|
+
after.pr,
|
|
726
|
+
);
|
|
506
727
|
// A retarget between the base check and the merge is caught here, loudly.
|
|
507
728
|
if (after.pr?.state === "MERGED" && after.pr.baseRefName !== DEV) {
|
|
508
729
|
log(
|
|
@@ -511,7 +732,7 @@ export function mergePr(cwd: string, o: MergeInput, log: (m: string) => void): M
|
|
|
511
732
|
const r = result(EXIT_BASE_NOT_DEV, after.pr, false);
|
|
512
733
|
return { ...r, out: { ...r.out, verdict: "FAIL", failures: 1 } };
|
|
513
734
|
}
|
|
514
|
-
return
|
|
735
|
+
return classify(after.pr);
|
|
515
736
|
}
|
|
516
737
|
|
|
517
738
|
// ---------------------------------------------------------------------------
|
|
@@ -605,7 +826,10 @@ export interface ChecksOut {
|
|
|
605
826
|
number: string;
|
|
606
827
|
total: number;
|
|
607
828
|
passing: number;
|
|
829
|
+
/** Checks that finished red: the CI run itself failed. */
|
|
608
830
|
failed: number;
|
|
831
|
+
/** Checks that finished without a verdict (cancelled, action required, stale): not green, not red. */
|
|
832
|
+
cancelled: number;
|
|
609
833
|
pending: number;
|
|
610
834
|
green: boolean;
|
|
611
835
|
failing: string[];
|
|
@@ -614,12 +838,15 @@ export interface ChecksOut {
|
|
|
614
838
|
/** Conclusions / states a finished check may carry and still count as passing. */
|
|
615
839
|
const PASS_STATES = new Set(["SUCCESS", "NEUTRAL", "SKIPPED"]);
|
|
616
840
|
|
|
841
|
+
/** Conclusions of a check that finished without running to a verdict: it neither passed nor went red. */
|
|
842
|
+
const NO_VERDICT_STATES = new Set(["CANCELLED", "ACTION_REQUIRED", "STALE"]);
|
|
843
|
+
|
|
617
844
|
/**
|
|
618
845
|
* The PR's check rollup, classified (ship Step 2's post-open assert). `green` only
|
|
619
|
-
* when at least one check exists and none is failed or pending. A check run is
|
|
846
|
+
* when at least one check exists and none is failed, cancelled or pending. A check run is
|
|
620
847
|
* open until `status` = `COMPLETED`; a commit status is open while its `state` is
|
|
621
|
-
* `PENDING` / `EXPECTED`. gh missing → EXIT.USE_MCP (read the
|
|
622
|
-
* `pull_request_read` `
|
|
848
|
+
* `PENDING` / `EXPECTED`. gh missing → EXIT.USE_MCP (read the check runs through
|
|
849
|
+
* `pull_request_read` `get_check_runs`, or `actions_list` runs for the head SHA).
|
|
623
850
|
*/
|
|
624
851
|
export function checksFor(
|
|
625
852
|
cwd: string,
|
|
@@ -629,7 +856,7 @@ export function checksFor(
|
|
|
629
856
|
const res = runGh(cwd, ["pr", "view", number, "--json", "statusCheckRollup"]);
|
|
630
857
|
if (ghUnavailable(res)) {
|
|
631
858
|
log(
|
|
632
|
-
"gh unavailable for gh pr view --json statusCheckRollup — read the
|
|
859
|
+
"gh unavailable for gh pr view --json statusCheckRollup — read the check runs through pull_request_read (get_check_runs), or actions_list runs for the head SHA",
|
|
633
860
|
);
|
|
634
861
|
return { code: EXIT.USE_MCP, out: null };
|
|
635
862
|
}
|
|
@@ -648,6 +875,7 @@ export function checksFor(
|
|
|
648
875
|
const checks = (Array.isArray(rawRollup) ? rawRollup : []) as Array<Record<string, unknown>>;
|
|
649
876
|
let passing = 0;
|
|
650
877
|
let failed = 0;
|
|
878
|
+
let cancelled = 0;
|
|
651
879
|
let pending = 0;
|
|
652
880
|
const failing: string[] = [];
|
|
653
881
|
for (const c of checks) {
|
|
@@ -662,24 +890,27 @@ export function checksFor(
|
|
|
662
890
|
pending++;
|
|
663
891
|
} else if (PASS_STATES.has(conclusion || state)) {
|
|
664
892
|
passing++;
|
|
893
|
+
} else if (NO_VERDICT_STATES.has(conclusion || state)) {
|
|
894
|
+
cancelled++;
|
|
665
895
|
} else {
|
|
666
896
|
failed++;
|
|
667
897
|
if (name) failing.push(name);
|
|
668
898
|
}
|
|
669
899
|
}
|
|
670
|
-
const green = checks.length > 0 && failed === 0 && pending === 0;
|
|
900
|
+
const green = checks.length > 0 && failed === 0 && cancelled === 0 && pending === 0;
|
|
671
901
|
const out: ChecksOut = {
|
|
672
902
|
number,
|
|
673
903
|
total: checks.length,
|
|
674
904
|
passing,
|
|
675
905
|
failed,
|
|
906
|
+
cancelled,
|
|
676
907
|
pending,
|
|
677
908
|
green,
|
|
678
909
|
failing,
|
|
679
910
|
};
|
|
680
911
|
if (!green)
|
|
681
912
|
log(
|
|
682
|
-
`PR ${number} is not green: ${String(failed)} failed, ${String(pending)} pending, ${String(checks.length)} total`,
|
|
913
|
+
`PR ${number} is not green: ${String(failed)} failed, ${String(cancelled)} cancelled, ${String(pending)} pending, ${String(checks.length)} total`,
|
|
683
914
|
);
|
|
684
915
|
return { code: green ? EXIT.OK : EXIT.NO, out };
|
|
685
916
|
}
|
|
@@ -964,6 +1195,21 @@ export const prsCommand: CommandSpec = {
|
|
|
964
1195
|
{ name: "base", type: "string", help: "only PRs into this base (default: any base)" },
|
|
965
1196
|
{ name: "state", type: "string", help: "open (default) | all: OPEN wins, then MERGED" },
|
|
966
1197
|
{ name: "number", type: "string", help: "read this PR instead of listing by --head" },
|
|
1198
|
+
{
|
|
1199
|
+
name: "ship-entry",
|
|
1200
|
+
type: "boolean",
|
|
1201
|
+
help: "qualify a merged PR against fresh local and remote feature tips before resuming ship",
|
|
1202
|
+
},
|
|
1203
|
+
{
|
|
1204
|
+
name: "owner-repo",
|
|
1205
|
+
type: "string",
|
|
1206
|
+
help: "owner/repo scope for ship entry and MCP facts",
|
|
1207
|
+
},
|
|
1208
|
+
{
|
|
1209
|
+
name: "facts-file",
|
|
1210
|
+
type: "string",
|
|
1211
|
+
help: "ship entry: scoped MCP JSON {ownerRepo, headRefName, baseRefName, pr}, used without gh",
|
|
1212
|
+
},
|
|
967
1213
|
],
|
|
968
1214
|
output: PR_OUTPUT_KEYS,
|
|
969
1215
|
exitCodes: { 4: "gh errored — the probe could not answer" },
|
|
@@ -976,6 +1222,13 @@ export const prsCommand: CommandSpec = {
|
|
|
976
1222
|
if (number !== undefined && !/^[1-9][0-9]*$/.test(number)) {
|
|
977
1223
|
throw new CommandError(EXIT.USAGE, "--number must be a PR number");
|
|
978
1224
|
}
|
|
1225
|
+
const factsFile = str(ctx.flags.factsFile);
|
|
1226
|
+
const facts =
|
|
1227
|
+
factsFile === undefined
|
|
1228
|
+
? undefined
|
|
1229
|
+
: parseJson(fs.readFileSync(path.resolve(ctx.cwd, factsFile), "utf-8"));
|
|
1230
|
+
if (facts !== undefined && !facts.ok)
|
|
1231
|
+
throw new CommandError(EXIT.USAGE, "ship PR facts file is not valid JSON");
|
|
979
1232
|
const res = probePr(ctx.cwd, {
|
|
980
1233
|
number,
|
|
981
1234
|
state,
|
|
@@ -986,6 +1239,9 @@ export const prsCommand: CommandSpec = {
|
|
|
986
1239
|
? currentBranch(ctx.cwd)
|
|
987
1240
|
: refFlag(ctx.flags.head, "head"),
|
|
988
1241
|
base: ctx.flags.base === undefined ? undefined : refFlag(ctx.flags.base, "base"),
|
|
1242
|
+
repo: str(ctx.flags.ownerRepo),
|
|
1243
|
+
shipEntry: ctx.flags.shipEntry === true,
|
|
1244
|
+
facts: facts?.ok === true ? facts.value : undefined,
|
|
989
1245
|
});
|
|
990
1246
|
if (res.kind !== "ok") {
|
|
991
1247
|
ctx.log(res.message);
|
|
@@ -1000,6 +1256,21 @@ export const prsCommand: CommandSpec = {
|
|
|
1000
1256
|
"Squash-merge a PR with an empty body (skipped when already MERGED) and read its state back.",
|
|
1001
1257
|
use: "workflow",
|
|
1002
1258
|
flags: [
|
|
1259
|
+
{
|
|
1260
|
+
name: "ship-retry",
|
|
1261
|
+
type: "boolean",
|
|
1262
|
+
help: "ship only: classify independently re-read merge refusals as revalidate (9), integrate (10), or stop (7)",
|
|
1263
|
+
},
|
|
1264
|
+
{
|
|
1265
|
+
name: "facts-file",
|
|
1266
|
+
type: "string",
|
|
1267
|
+
help: "with --ship-retry: scoped pre-attempt and independent post-attempt MCP PR facts; classify without another mutation",
|
|
1268
|
+
},
|
|
1269
|
+
{
|
|
1270
|
+
name: "owner-repo",
|
|
1271
|
+
type: "string",
|
|
1272
|
+
help: "owner/repo for the merge and scoped MCP facts",
|
|
1273
|
+
},
|
|
1003
1274
|
{ name: "number", type: "string", required: true, help: "the PR number" },
|
|
1004
1275
|
{
|
|
1005
1276
|
name: "subject",
|
|
@@ -1032,19 +1303,40 @@ export const prsCommand: CommandSpec = {
|
|
|
1032
1303
|
subject: "the squash subject used",
|
|
1033
1304
|
verdict: "PASS when merged, else FAIL",
|
|
1034
1305
|
failures: "0 when merged, else 1",
|
|
1306
|
+
route: "--ship-retry: merged | revalidate | integrate | stop",
|
|
1307
|
+
reason: "--ship-retry: the reread decision or refusal",
|
|
1035
1308
|
},
|
|
1036
1309
|
exitCodes: {
|
|
1037
1310
|
[EXIT_GH_FAILED]: "gh could not read the PR",
|
|
1038
1311
|
[EXIT_NOT_MERGED]: "--expect-merged and the PR did not reach MERGED",
|
|
1039
1312
|
[EXIT_BASE_NOT_DEV]: `the PR's base is not ${DEV}, or could not be read — nothing merged`,
|
|
1313
|
+
9: "--ship-retry: PR head moved; revalidate",
|
|
1314
|
+
10: "--ship-retry: new dev conflict; integrate",
|
|
1040
1315
|
},
|
|
1041
1316
|
run: (ctx) => {
|
|
1042
1317
|
const number = String(ctx.flags.number);
|
|
1043
1318
|
if (!/^[1-9][0-9]*$/.test(number))
|
|
1044
1319
|
throw new CommandError(EXIT.USAGE, "--number must be a PR number");
|
|
1320
|
+
const factsPath = str(ctx.flags.factsFile);
|
|
1321
|
+
const parsed =
|
|
1322
|
+
factsPath === undefined
|
|
1323
|
+
? undefined
|
|
1324
|
+
: parseJson(fs.readFileSync(path.resolve(ctx.cwd, factsPath), "utf-8"));
|
|
1325
|
+
if (parsed !== undefined && !parsed.ok)
|
|
1326
|
+
throw new CommandError(EXIT.USAGE, "merge facts JSON is unreadable");
|
|
1327
|
+
const facts = parsed?.ok ? parsed.value : undefined;
|
|
1045
1328
|
let subject = str(ctx.flags.subject);
|
|
1046
1329
|
if (subject === undefined) {
|
|
1047
|
-
const
|
|
1330
|
+
const candidate =
|
|
1331
|
+
typeof facts === "object" && facts !== null && "before" in facts
|
|
1332
|
+
? facts.before
|
|
1333
|
+
: undefined;
|
|
1334
|
+
const pr: Probe =
|
|
1335
|
+
facts !== undefined
|
|
1336
|
+
? validPrFacts(candidate)
|
|
1337
|
+
? { kind: "ok", pr: candidate }
|
|
1338
|
+
: { kind: "failed", message: "merge facts pre-attempt PR is unreadable" }
|
|
1339
|
+
: probePr(ctx.cwd, { number, state: "open", repo: str(ctx.flags.ownerRepo) });
|
|
1048
1340
|
if (pr.kind === "unavailable") {
|
|
1049
1341
|
ctx.log(`${pr.message} — merge through merge_pull_request`);
|
|
1050
1342
|
return EXIT.USE_MCP;
|
|
@@ -1064,6 +1356,9 @@ export const prsCommand: CommandSpec = {
|
|
|
1064
1356
|
subject,
|
|
1065
1357
|
matchHead: str(ctx.flags.matchHead),
|
|
1066
1358
|
deleteBranch: ctx.flags.deleteBranch === true,
|
|
1359
|
+
shipRetry: ctx.flags.shipRetry === true,
|
|
1360
|
+
repo: str(ctx.flags.ownerRepo),
|
|
1361
|
+
facts,
|
|
1067
1362
|
},
|
|
1068
1363
|
ctx.log,
|
|
1069
1364
|
);
|
|
@@ -1105,7 +1400,7 @@ export const prsCommand: CommandSpec = {
|
|
|
1105
1400
|
},
|
|
1106
1401
|
checks: {
|
|
1107
1402
|
summary:
|
|
1108
|
-
"A PR's check rollup, classified: green when present and none failed or pending (exit 80: use MCP).",
|
|
1403
|
+
"A PR's check rollup, classified: green when present and none failed, cancelled or pending (exit 80: use MCP).",
|
|
1109
1404
|
use: "by-hand",
|
|
1110
1405
|
flags: [{ name: "number", type: "string", required: true, help: "the PR number" }],
|
|
1111
1406
|
output: {
|
|
@@ -161,7 +161,7 @@ export const repoCommand: CommandSpec = {
|
|
|
161
161
|
bkit: "the bkit binary the workflow blocks call: <repoRoot>/node_modules/.bin/bkit, else `bkit` on PATH",
|
|
162
162
|
outboxRoot: "<git common dir>/bkit-outbox: per-run scratch files, never committed",
|
|
163
163
|
sessionDir:
|
|
164
|
-
"<outboxRoot>/sessions/<utc-time>-<random>/: a new, empty folder per
|
|
164
|
+
"<outboxRoot>/sessions/<utc-time>-<random>/: a new, empty folder per invocation for prompt.md and issue files; pass it explicitly as --session-dir for workflow progress ownership; folders older than 7 days are pruned",
|
|
165
165
|
bkitVersion:
|
|
166
166
|
".bkit/version pinnedVersion: the release this repo's bkit files came from (null when unpinned)",
|
|
167
167
|
bkitLatest:
|
|
@@ -342,6 +342,12 @@ export const MARK_ROWS: ReadonlySet<string> = new Set([
|
|
|
342
342
|
"test-run",
|
|
343
343
|
"engine-call",
|
|
344
344
|
"completeness",
|
|
345
|
+
"invocation",
|
|
346
|
+
"ci-handoff",
|
|
347
|
+
"run-commits",
|
|
348
|
+
"correction-rejected",
|
|
349
|
+
"correction-candidate",
|
|
350
|
+
"correction-succeeded",
|
|
345
351
|
]);
|
|
346
352
|
|
|
347
353
|
/** The `session` fingerprints on the run's status rows, in row order, each once. */
|