@cbartens/bkit 5.5.1 → 6.0.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 +30 -20
- package/.bkit/core/.agents/docs.md +1 -0
- package/.bkit/core/.agents/rules.md +35 -26
- package/.bkit/core/.bkit/README.md +29 -19
- package/.bkit/core/.bkit/authoring.md +117 -0
- package/.bkit/core/.bkit/cloud.md +11 -11
- package/.bkit/core/.bkit/comparison.md +5 -5
- package/.bkit/core/.bkit/install.md +19 -18
- package/.bkit/core/.bkit/jsonl.md +202 -122
- package/.bkit/core/.bkit/lite.md +1 -1
- package/.bkit/core/.bkit/pipeline.md +49 -52
- package/.bkit/core/.bkit/prompts.md +91 -167
- package/.bkit/core/.bkit/providers.md +29 -32
- package/.bkit/core/.bkit/templates.md +12 -11
- package/.bkit/core/.bkit/trackers.md +51 -28
- package/.bkit/core/.bkit/workflows.md +394 -355
- package/.bkit/core/AGENTS.md +16 -22
- package/.bkit/core/docs/templates/bkit-audit-accessibility.md +14 -38
- package/.bkit/core/docs/templates/bkit-audit-adoption.md +16 -40
- package/.bkit/core/docs/templates/bkit-audit-agents.md +19 -43
- package/.bkit/core/docs/templates/bkit-audit-aio-seo.md +16 -40
- package/.bkit/core/docs/templates/bkit-audit-analytics.md +14 -38
- package/.bkit/core/docs/templates/bkit-audit-annotations.md +11 -35
- package/.bkit/core/docs/templates/bkit-audit-app-performance.md +15 -39
- package/.bkit/core/docs/templates/bkit-audit-app-store.md +12 -36
- package/.bkit/core/docs/templates/bkit-audit-architecture.md +16 -40
- package/.bkit/core/docs/templates/bkit-audit-ci-performance.md +16 -40
- package/.bkit/core/docs/templates/bkit-audit-config.md +18 -42
- package/.bkit/core/docs/templates/bkit-audit-cost.md +16 -40
- package/.bkit/core/docs/templates/bkit-audit-coverage.md +15 -39
- package/.bkit/core/docs/templates/bkit-audit-database.md +16 -40
- package/.bkit/core/docs/templates/bkit-audit-dead-code.md +15 -39
- package/.bkit/core/docs/templates/bkit-audit-deferrals.md +15 -38
- package/.bkit/core/docs/templates/bkit-audit-dependencies.md +16 -40
- package/.bkit/core/docs/templates/bkit-audit-documentation.md +11 -35
- package/.bkit/core/docs/templates/bkit-audit-duplication.md +18 -42
- package/.bkit/core/docs/templates/bkit-audit-failures.md +13 -37
- package/.bkit/core/docs/templates/bkit-audit-flakes.md +12 -36
- package/.bkit/core/docs/templates/bkit-audit-gates.md +14 -38
- package/.bkit/core/docs/templates/bkit-audit-issues.md +15 -39
- package/.bkit/core/docs/templates/bkit-audit-llm.md +16 -40
- package/.bkit/core/docs/templates/bkit-audit-logs.md +14 -38
- package/.bkit/core/docs/templates/bkit-audit-models.md +12 -36
- package/.bkit/core/docs/templates/bkit-audit-privacy.md +12 -36
- package/.bkit/core/docs/templates/bkit-audit-prompts.md +15 -39
- package/.bkit/core/docs/templates/bkit-audit-red-team.md +15 -39
- package/.bkit/core/docs/templates/bkit-audit-reliability.md +15 -39
- package/.bkit/core/docs/templates/bkit-audit-repo.md +12 -36
- package/.bkit/core/docs/templates/bkit-audit-security.md +13 -37
- package/.bkit/core/docs/templates/bkit-audit-slop.md +14 -38
- package/.bkit/core/docs/templates/bkit-audit-testing.md +12 -36
- package/.bkit/core/docs/templates/bkit-audit-usability.md +16 -40
- package/.bkit/core/docs/templates/bkit-plan.md +97 -226
- package/.bkit/core/engine/checks/after/ci-yml.ts +39 -29
- package/.bkit/core/engine/checks/after/github.ts +95 -17
- package/.bkit/core/engine/checks/after/index.ts +10 -7
- package/.bkit/core/engine/checks/after/suppression.ts +8 -5
- package/.bkit/core/engine/checks/after/tools.ts +46 -91
- package/.bkit/core/engine/checks/before/env.ts +2 -2
- package/.bkit/core/engine/checks/before/files.ts +5 -4
- package/.bkit/core/engine/checks/before/index.ts +18 -1
- package/.bkit/core/engine/checks/before/repo.ts +168 -2
- package/.bkit/core/engine/checks/tips/catalogue.ts +16 -5
- package/.bkit/core/engine/checks/tips/detect.ts +34 -0
- package/.bkit/core/engine/checks/tips/index.ts +6 -6
- package/.bkit/core/engine/cli.ts +20 -53
- package/.bkit/core/engine/commands/analysis.ts +171 -140
- package/.bkit/core/engine/commands/ci/ci.ts +6 -6
- 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 +65 -28
- package/.bkit/core/engine/commands/land.ts +18 -12
- package/.bkit/core/engine/commands/lib.ts +79 -17
- package/.bkit/core/engine/commands/registry.ts +4 -0
- package/.bkit/core/engine/commands/setup/setup.ts +7 -7
- package/.bkit/core/engine/commands/stats.ts +204 -0
- package/.bkit/core/engine/commands/tips.ts +10 -5
- package/.bkit/core/engine/commands/workflow/branches.ts +741 -62
- package/.bkit/core/engine/commands/workflow/challenge.ts +673 -0
- package/.bkit/core/engine/commands/workflow/context.ts +853 -29
- package/.bkit/core/engine/commands/workflow/counters.ts +267 -84
- package/.bkit/core/engine/commands/workflow/decisions.ts +541 -0
- package/.bkit/core/engine/commands/workflow/disk.ts +2 -2
- package/.bkit/core/engine/commands/workflow/fids.ts +793 -33
- package/.bkit/core/engine/commands/workflow/issues.ts +407 -64
- package/.bkit/core/engine/commands/workflow/ledgers.ts +884 -27
- package/.bkit/core/engine/commands/workflow/locks.ts +26 -2
- package/.bkit/core/engine/commands/workflow/plan-blocks.ts +582 -0
- package/.bkit/core/engine/commands/workflow/plan-versions.ts +21 -0
- package/.bkit/core/engine/commands/workflow/prs.ts +166 -30
- package/.bkit/core/engine/commands/workflow/repo.ts +58 -8
- package/.bkit/core/engine/commands/workflow/roadmap.ts +16 -7
- package/.bkit/core/engine/commands/workflow/run-facts.ts +501 -0
- package/.bkit/core/engine/commands/workflow/runs.ts +179 -49
- package/.bkit/core/engine/commands/workflow/runtime.ts +22 -1
- package/.bkit/core/engine/commands/workflow/status.ts +142 -29
- package/.bkit/core/engine/commands/workflow/step-table.ts +339 -0
- package/.bkit/core/engine/commands/workflow/steps.ts +213 -88
- package/.bkit/core/engine/commands/workflow/summary.ts +398 -0
- package/.bkit/core/engine/commands/workflow/tests.ts +1013 -148
- package/.bkit/core/engine/commands/workflow/tracker.ts +1195 -0
- package/.bkit/core/engine/commands/workflow/workflows.ts +984 -207
- package/.bkit/core/engine/commands/workflow/workstreams.ts +11 -5
- package/.bkit/core/engine/commands/workflow/worktrees.ts +185 -8
- package/.bkit/core/engine/install/manifest.ts +11 -9
- package/.bkit/core/engine/install/modules/cloud.ts +21 -13
- package/.bkit/core/engine/install/modules/core.ts +250 -3
- package/.bkit/core/engine/install/modules/opencode.ts +2 -2
- package/.bkit/core/engine/install/version-file.ts +6 -2
- package/.bkit/core/engine/ledgers/migrate.ts +92 -0
- package/.bkit/core/engine/ledgers/status.ts +92 -15
- package/.bkit/core/engine/ledgers/telemetry.ts +1261 -254
- package/.bkit/core/engine/render/hosts.ts +4 -0
- package/.bkit/core/engine/render/models.ts +12 -0
- package/.bkit/core/engine/shared/branches.ts +4 -1
- package/.bkit/core/engine/shared/egress.ts +7 -0
- package/.bkit/core/engine/shared/json.ts +25 -7
- package/.bkit/core/engine/shared/settings.ts +157 -20
- package/.bkit/core/engine/shared/text.ts +361 -0
- package/.bkit/core/engine/tools/grammar-density.ts +215 -0
- package/.bkit/core/engine/tools/instructions-sources.ts +834 -0
- package/.bkit/core/engine/tools/instructions.ts +1751 -0
- package/.bkit/core/hooks/gateguard-engine.js +24 -23
- package/.bkit/core/hooks/guardrails-shell.js +2 -3
- package/.bkit/core/hooks/guardrails-tiers.js +7 -1
- package/.bkit/core/hooks/readguard-engine.js +2 -2
- package/.bkit/core/prompts/bkit-audit-generate.md +62 -25
- package/.bkit/core/prompts/bkit-build-challenge-1.md +40 -17
- package/.bkit/core/prompts/bkit-build-challenge-2.md +44 -17
- package/.bkit/core/prompts/bkit-build-install-skills.md +26 -13
- package/.bkit/core/prompts/bkit-build-plan-convert.md +74 -0
- package/.bkit/core/prompts/bkit-build-plan-current.md +26 -13
- package/.bkit/core/prompts/bkit-build-plan-execute.md +74 -26
- package/.bkit/core/prompts/bkit-build-plan-gaps-remediate.md +64 -23
- package/.bkit/core/prompts/bkit-build-plan-verify.md +57 -33
- package/.bkit/core/prompts/bkit-debug-abort-handover.md +29 -15
- package/.bkit/core/prompts/bkit-debug-failure-diagnose.md +34 -14
- package/.bkit/core/prompts/bkit-debug-failure-remediate.md +34 -17
- package/.bkit/core/prompts/bkit-debug-failure-reproduce.md +26 -13
- package/.bkit/core/prompts/bkit-debug-failure-soak.md +31 -16
- package/.bkit/core/prompts/bkit-design-brainstorm-ideate-1.md +21 -11
- package/.bkit/core/prompts/bkit-design-brainstorm-ideate-2.md +20 -11
- package/.bkit/core/prompts/bkit-design-brainstorm-ideate-3.md +20 -11
- package/.bkit/core/prompts/bkit-design-generate.md +32 -14
- package/.bkit/core/prompts/bkit-design-organise.md +25 -12
- package/.bkit/core/prompts/bkit-design-review-1.md +31 -15
- package/.bkit/core/prompts/bkit-design-review-2.md +28 -13
- package/.bkit/core/prompts/bkit-design-spike.md +30 -13
- package/.bkit/core/prompts/bkit-design-update.md +33 -19
- package/.bkit/core/prompts/bkit-plan-generate.md +72 -18
- package/.bkit/core/prompts/bkit-plan-review-1.md +50 -27
- package/.bkit/core/prompts/bkit-plan-review-2.md +59 -28
- package/.bkit/core/prompts/bkit-plan-scope-check.md +109 -0
- package/.bkit/core/prompts/bkit-plan-update.md +61 -24
- package/.bkit/core/prompts/bkit-ship-conflict-resolve.md +27 -15
- package/.bkit/core/prompts/bkit-ship-deferred-sweep.md +31 -16
- package/.bkit/core/prompts/bkit-ship-update-docs.md +29 -14
- package/.bkit/core/prompts/bkit-utility-compress-markdown.md +24 -14
- package/.bkit/core/prompts/bkit-utility-update-decisions.md +32 -14
- package/.bkit/core/prompts/bkit-utility-update-deferrals.md +29 -14
- package/.bkit/core/prompts/bkit-utility-update-documentation.md +27 -12
- package/.bkit/core/prompts/bkit-utility-update-failures.md +31 -14
- package/.bkit/core/prompts/bkit-utility-update-knowledge.md +33 -14
- package/.bkit/core/prompts/bkit-utility-update-roadmap.md +38 -17
- package/.bkit/core/prompts/bkit-utility-update-tracker.md +41 -18
- package/.bkit/core/workflows/bkit-auto.md +54 -46
- package/.bkit/core/workflows/bkit-build.md +577 -458
- package/.bkit/core/workflows/bkit-debug.md +348 -333
- package/.bkit/core/workflows/bkit-design.md +201 -237
- package/.bkit/core/workflows/bkit-plan.md +210 -321
- package/.bkit/core/workflows/bkit-ship.md +328 -278
- package/.bkit/shared/.bkit/.env.example +2 -2
- package/.bkit/shared/.claude/settings.json +11 -0
- 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 +11 -0
- package/.bkit/shared/CLAUDE.md +2 -2
- package/.bkit/shared/GEMINI.md +2 -2
- package/.bkit/shared/docs/architecture.md +1 -1
- package/.bkit/shared/docs/data-schema.md +1 -1
- package/.bkit/shared/docs/deployments.md +11 -11
- package/.bkit/shared/docs/design.md +1 -1
- package/.bkit/shared/docs/noise.md +1 -1
- package/.bkit/shared/docs/observability.md +2 -2
- package/.bkit/shared/docs/security.md +1 -1
- package/.bkit/shared/docs/setup.md +1 -1
- package/.bkit/shared/docs/technology.md +1 -1
- package/.bkit/shared/docs/testing.md +16 -7
- package/.bkit/templates/.claude/hooks/bkit-cloud-bootstrap.sh +1 -1
- package/.bkit/templates/.github/ISSUE_TEMPLATE/bkit-change.yml +26 -5
- package/.bkit/templates/.github/workflows/bkit-ci.yml +1 -1
- package/.bkit/templates/.github/workflows/bkit-cloud.yml +21 -19
- package/.bkit/templates/.husky/pre-push +4 -4
- package/.bkit/templates/.prettierignore +7 -0
- package/.bkit/templates/scripts/cleanup/bkit-disk-prune.mjs +1 -1
- package/CHANGELOG.md +112 -0
- package/README.md +50 -35
- package/dist/checks/after/ci-yml.js +39 -28
- package/dist/checks/after/github.js +91 -17
- package/dist/checks/after/index.js +11 -8
- package/dist/checks/after/suppression.js +8 -5
- package/dist/checks/after/tools.js +39 -82
- package/dist/checks/before/env.js +2 -2
- package/dist/checks/before/files.js +5 -3
- package/dist/checks/before/index.js +15 -2
- package/dist/checks/before/repo.js +163 -2
- package/dist/checks/tips/catalogue.js +14 -5
- package/dist/checks/tips/detect.js +32 -0
- package/dist/checks/tips/index.js +4 -4
- package/dist/cli.js +19 -47
- package/dist/commands/analysis.js +109 -100
- package/dist/commands/ci/ci.js +6 -6
- 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 +59 -28
- package/dist/commands/land.js +16 -12
- package/dist/commands/lib.js +51 -16
- package/dist/commands/registry.js +4 -0
- package/dist/commands/setup/setup.js +7 -7
- package/dist/commands/stats.js +136 -0
- package/dist/commands/tips.js +7 -3
- package/dist/commands/workflow/branches.js +656 -56
- package/dist/commands/workflow/challenge.js +556 -0
- package/dist/commands/workflow/context.js +709 -30
- package/dist/commands/workflow/counters.js +208 -75
- package/dist/commands/workflow/decisions.js +441 -0
- package/dist/commands/workflow/disk.js +2 -2
- package/dist/commands/workflow/fids.js +689 -33
- package/dist/commands/workflow/issues.js +343 -59
- package/dist/commands/workflow/ledgers.js +762 -27
- package/dist/commands/workflow/locks.js +24 -2
- package/dist/commands/workflow/plan-blocks.js +437 -0
- package/dist/commands/workflow/plan-versions.js +22 -0
- package/dist/commands/workflow/prs.js +142 -32
- package/dist/commands/workflow/repo.js +52 -8
- package/dist/commands/workflow/roadmap.js +9 -7
- package/dist/commands/workflow/run-facts.js +426 -0
- package/dist/commands/workflow/runs.js +144 -43
- package/dist/commands/workflow/runtime.js +12 -1
- package/dist/commands/workflow/status.js +130 -29
- package/dist/commands/workflow/step-table.js +276 -0
- package/dist/commands/workflow/steps.js +171 -80
- package/dist/commands/workflow/summary.js +275 -0
- package/dist/commands/workflow/tests.js +834 -136
- package/dist/commands/workflow/tracker.js +983 -0
- package/dist/commands/workflow/workflows.js +834 -195
- package/dist/commands/workflow/workstreams.js +11 -5
- package/dist/commands/workflow/worktrees.js +147 -9
- package/dist/install/manifest.js +11 -9
- package/dist/install/modules/cloud.js +22 -13
- package/dist/install/modules/core.js +247 -3
- package/dist/install/modules/opencode.js +2 -2
- package/dist/install/version-file.js +6 -2
- package/dist/ledgers/migrate.js +81 -0
- package/dist/ledgers/status.js +61 -8
- package/dist/ledgers/telemetry.js +905 -124
- package/dist/render/hosts.js +4 -0
- package/dist/render/models.js +12 -0
- package/dist/shared/branches.js +3 -1
- package/dist/shared/egress.js +7 -0
- package/dist/shared/json.js +20 -7
- package/dist/shared/settings.js +125 -17
- package/dist/shared/text.js +333 -0
- package/dist/tools/grammar-density.js +183 -0
- package/dist/tools/instructions-sources.js +721 -0
- package/dist/tools/instructions.js +1579 -0
- package/package.json +113 -24
- package/.bkit/core/engine/commands/harvest.ts +0 -459
- 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-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/dist/commands/harvest.js +0 -353
- package/dist/tools/wording.js +0 -680
|
@@ -27,11 +27,14 @@ import { readBkitConfig } from "../../shared/settings.js";
|
|
|
27
27
|
import { TIMEOUTS } from "../../shared/timeouts.js";
|
|
28
28
|
import { FID_PATTERNS, fromBranch, fromMarker, issueIdOf, readIssueTracker } from "./fids.js";
|
|
29
29
|
import { AUTO_LABEL, AUTO_ROUTE_SUFFIX } from "./issues.js";
|
|
30
|
-
import {
|
|
31
|
-
import {
|
|
30
|
+
import { fetchRemoteRef, pushBranch } from "./branches.js";
|
|
31
|
+
import { activeRecord, checkOnlyBookkeeping, retriggerCommit } from "./ledgers.js";
|
|
32
|
+
import { closeTransportRow, crossCheckFile, devRequiresChecks, prRepoSlug, probePr, } from "./prs.js";
|
|
32
33
|
import { resolveOwnerRepo, splitSlug } from "./repo.js";
|
|
34
|
+
import { restateOutcome } from "./run-facts.js";
|
|
33
35
|
import { extraField, str } from "./status.js";
|
|
34
36
|
import { writeStepRow } from "./steps.js";
|
|
37
|
+
import { attempt, issueRef, readLabels, trackerTarget } from "./tracker.js";
|
|
35
38
|
const GH_MISSING = "gh is not on PATH — use the mapped GitHub MCP tool instead";
|
|
36
39
|
/** Not JSON reads as undefined: every caller treats that as an API error, distinct from an empty answer. */
|
|
37
40
|
function jsonOrUndefined(raw) {
|
|
@@ -53,7 +56,7 @@ export function checkNamespace(capstoneJob) {
|
|
|
53
56
|
const i = capstoneJob.lastIndexOf("-");
|
|
54
57
|
return i > 0 ? capstoneJob.slice(0, i) : capstoneJob;
|
|
55
58
|
}
|
|
56
|
-
/** Whether `.github/workflows/<bkit.ciWorkflow>` exists — the only honest ground for a `no-ci` pass. */
|
|
59
|
+
/** Whether `.github/workflows/<bkit.testing.ciWorkflow>` exists — the only honest ground for a `no-ci` pass. */
|
|
57
60
|
export function ciDeclared(root) {
|
|
58
61
|
const { ciWorkflow } = readBkitConfig(root);
|
|
59
62
|
const rel = path.join(".github", "workflows", ciWorkflow);
|
|
@@ -197,7 +200,20 @@ export async function ciDispatchGate(o, deps) {
|
|
|
197
200
|
const root = checkoutRoot(o.cwd);
|
|
198
201
|
const { capstoneJob } = readBkitConfig(root);
|
|
199
202
|
const declared = ciDeclared(root);
|
|
200
|
-
const
|
|
203
|
+
const branch = git(o.cwd, ["branch", "--show-current"]) ?? "";
|
|
204
|
+
const shared = branch !== "" && isSharedBranch(branch);
|
|
205
|
+
// A run in place on a shared branch has no PR: CI is the push-event run at the pushed sha.
|
|
206
|
+
const byRun = o.pr === null && shared;
|
|
207
|
+
// The sha an own-commit push landed; null while the head is local HEAD.
|
|
208
|
+
let landed = byRun ? (o.sha ?? null) : null;
|
|
209
|
+
const head = () => landed ?? git(o.cwd, ["rev-parse", "HEAD"]) ?? "";
|
|
210
|
+
/** The landed copy lives on the remote only; the scan and the suppressor check read it locally. */
|
|
211
|
+
const fetchLanded = () => {
|
|
212
|
+
if (landed === null || runGit(o.cwd, ["cat-file", "-e", `${landed}^{commit}`]).ok)
|
|
213
|
+
return;
|
|
214
|
+
runGit(o.cwd, ["fetch", "origin", branch]);
|
|
215
|
+
};
|
|
216
|
+
fetchLanded();
|
|
201
217
|
const res = {
|
|
202
218
|
phase: "done",
|
|
203
219
|
handoff: 0,
|
|
@@ -206,13 +222,22 @@ export async function ciDispatchGate(o, deps) {
|
|
|
206
222
|
attempts: 0,
|
|
207
223
|
retrigger: o.retriggered,
|
|
208
224
|
ciWorkflow: declared.ciWorkflow,
|
|
225
|
+
runBranch: byRun ? branch : null,
|
|
209
226
|
};
|
|
210
|
-
const target =
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
227
|
+
const target = byRun
|
|
228
|
+
? {
|
|
229
|
+
kind: "run-present",
|
|
230
|
+
head: res.head,
|
|
231
|
+
branch,
|
|
232
|
+
ciWorkflow: declared.ciWorkflow,
|
|
233
|
+
namespace: checkNamespace(capstoneJob),
|
|
234
|
+
}
|
|
235
|
+
: {
|
|
236
|
+
kind: "pr-present",
|
|
237
|
+
pr: o.pr ?? undefined,
|
|
238
|
+
ciWorkflow: declared.ciWorkflow,
|
|
239
|
+
namespace: checkNamespace(capstoneJob),
|
|
240
|
+
};
|
|
216
241
|
const poll = async (phase) => {
|
|
217
242
|
// A supplied result answers only the poll that was handed off; later polls run fresh.
|
|
218
243
|
if (o.supplied && (phase === "repoll") === o.retriggered) {
|
|
@@ -220,9 +245,13 @@ export async function ciDispatchGate(o, deps) {
|
|
|
220
245
|
return o.supplied;
|
|
221
246
|
}
|
|
222
247
|
// No PR to read is the shell's empty-PR poll: zero attempts, all errored.
|
|
223
|
-
if (o.pr === null)
|
|
248
|
+
if (o.pr === null && !byRun)
|
|
224
249
|
return { pollResult: "err", attempts: 0, allErrored: true };
|
|
225
|
-
|
|
250
|
+
if (byRun)
|
|
251
|
+
target.head = head();
|
|
252
|
+
deps.log(byRun
|
|
253
|
+
? `polling for a ${target.ciWorkflow} run on ${branch} at ${target.head} (budget ${o.budgetS}s, interval ${o.intervalS}s)`
|
|
254
|
+
: `polling for a ${target.namespace} check on PR #${o.pr} (budget ${o.budgetS}s, interval ${o.intervalS}s)`);
|
|
226
255
|
const w = await waitLoop({ budgetS: o.budgetS, intervalS: o.intervalS, once: false }, () => pollOnce(target, deps.gh), deps.sleep, deps.log);
|
|
227
256
|
if (w.blocked || w.ghMissing) {
|
|
228
257
|
res.phase = phase;
|
|
@@ -258,13 +287,35 @@ export async function ciDispatchGate(o, deps) {
|
|
|
258
287
|
deps.log("unresolved(timeout-dirty): no run and the pushed head carries a CI suppressor — not re-triggering a dirty head");
|
|
259
288
|
return verdict("unresolved", "timeout-dirty");
|
|
260
289
|
}
|
|
261
|
-
const
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
290
|
+
const message = `chore(${o.fid}): re-trigger${o.autoRouteSuffix}`;
|
|
291
|
+
// A run in place on a shared branch commits and pushes only its own work; with
|
|
292
|
+
// no record of the run there, nothing is committed or pushed.
|
|
293
|
+
const rec = shared ? activeRecord(o.cwd, o.fid) : null;
|
|
294
|
+
if (shared && rec === null) {
|
|
295
|
+
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`);
|
|
296
|
+
res.phase = "repoll";
|
|
297
|
+
res.handoff = EXIT_RETRIGGER_FAILED;
|
|
298
|
+
return res;
|
|
299
|
+
}
|
|
300
|
+
let pushed;
|
|
301
|
+
if (rec === null) {
|
|
302
|
+
landed = null;
|
|
303
|
+
pushed =
|
|
304
|
+
runGit(o.cwd, ["commit", "--allow-empty", "-m", message]).ok && pushCurrentBranch(o.cwd);
|
|
305
|
+
}
|
|
306
|
+
else {
|
|
307
|
+
const made = retriggerCommit(o.cwd, rec, message);
|
|
308
|
+
if (!made.ok)
|
|
309
|
+
deps.log(`re-trigger commit failed: ${made.error}`);
|
|
310
|
+
const out = made.ok
|
|
311
|
+
? await pushBranch(o.cwd, { mode: "feature", fid: o.fid }, deps.log)
|
|
312
|
+
: null;
|
|
313
|
+
landed = out?.out.pushed === true ? out.out.sha : landed;
|
|
314
|
+
pushed = out?.out.pushed === true && out.out.sha !== null;
|
|
315
|
+
if (pushed)
|
|
316
|
+
fetchLanded();
|
|
317
|
+
}
|
|
318
|
+
if (!pushed) {
|
|
268
319
|
deps.log("re-trigger commit or push failed — no verdict; route to the Failure Path");
|
|
269
320
|
res.phase = "repoll";
|
|
270
321
|
res.handoff = EXIT_RETRIGGER_FAILED;
|
|
@@ -315,7 +366,7 @@ export const GATE = {
|
|
|
315
366
|
SUPERSEDED: 14,
|
|
316
367
|
/** The selected run was cancelled. */
|
|
317
368
|
CANCELLED: 15,
|
|
318
|
-
/** A lane named in bkit.
|
|
369
|
+
/** A lane named in bkit.testing.shipGate concluded skipped. */
|
|
319
370
|
LANE_SKIPPED: 16,
|
|
320
371
|
/** --validated is not an ancestor of the head plus bookkeeping-only commits. */
|
|
321
372
|
NOT_BOOKKEEPING: 17,
|
|
@@ -613,7 +664,7 @@ export function shipGate(o, gh, log) {
|
|
|
613
664
|
log(`note: capstone '${r.capstone}' is green and owns the planned-vs-vacuous judgement for those lanes`);
|
|
614
665
|
const required = r.skippedLanes.filter((l) => requiredLanes.includes(l));
|
|
615
666
|
if (required.length) {
|
|
616
|
-
log(`declared in bkit.
|
|
667
|
+
log(`declared in bkit.testing.shipGate: ${requiredLanes.join(",")}`);
|
|
617
668
|
return refuse(GATE.LANE_SKIPPED, `required lane(s) concluded 'skipped' at head ${r.head} — vacuous green: ${required.join(", ")}`, url);
|
|
618
669
|
}
|
|
619
670
|
}
|
|
@@ -733,12 +784,12 @@ const REPO_FLAG = {
|
|
|
733
784
|
const CI_WORKFLOW_FLAG = {
|
|
734
785
|
name: "ci-workflow",
|
|
735
786
|
type: "string",
|
|
736
|
-
help: "CI workflow file (default: package.json bkit.ciWorkflow)",
|
|
787
|
+
help: "CI workflow file (default: package.json bkit.testing.ciWorkflow)",
|
|
737
788
|
};
|
|
738
789
|
const CAPSTONE_FLAG = {
|
|
739
790
|
name: "capstone",
|
|
740
791
|
type: "string",
|
|
741
|
-
help: "capstone job name (default: package.json bkit.
|
|
792
|
+
help: "capstone job name (default: package.json bkit.testing.ciCapstone)",
|
|
742
793
|
};
|
|
743
794
|
const BUDGET_FLAG = { name: "budget-s", type: "string", help: "poll budget in seconds" };
|
|
744
795
|
const INTERVAL_FLAG = {
|
|
@@ -874,6 +925,14 @@ async function runDispatch(ctx) {
|
|
|
874
925
|
}
|
|
875
926
|
pr = found.pr;
|
|
876
927
|
}
|
|
928
|
+
const sha = str(f.sha);
|
|
929
|
+
if (sha !== undefined && !/^[0-9a-f]{40}$/i.test(sha)) {
|
|
930
|
+
throw new CommandError(EXIT.USAGE, "--sha must be the full 40-hex-digit commit sha (the CI run is matched on the full sha)");
|
|
931
|
+
}
|
|
932
|
+
const onShared = isSharedBranch(git(ctx.cwd, ["branch", "--show-current"]) ?? "");
|
|
933
|
+
if (sha !== undefined && (pr !== null || !onShared)) {
|
|
934
|
+
throw new CommandError(EXIT.USAGE, "--sha goes with a run in place on a shared branch that has no PR");
|
|
935
|
+
}
|
|
877
936
|
const pollResult = str(f.pollResult);
|
|
878
937
|
if (pollResult !== undefined && !["found", "none", "err"].includes(pollResult)) {
|
|
879
938
|
throw new CommandError(EXIT.USAGE, "--poll-result must be found, none, or err");
|
|
@@ -898,6 +957,7 @@ async function runDispatch(ctx) {
|
|
|
898
957
|
allErrored: f.allErrored === true,
|
|
899
958
|
},
|
|
900
959
|
retriggered: f.retriggered === true,
|
|
960
|
+
sha,
|
|
901
961
|
}, d);
|
|
902
962
|
const scanResult = r.ciDispatch && r.ciDispatch.outcome !== "unresolved" ? scanBody(ctx.cwd, r.head) : null;
|
|
903
963
|
// With --file / --step: the verdict lands on the step's row, and a passed one is
|
|
@@ -922,6 +982,10 @@ async function runDispatch(ctx) {
|
|
|
922
982
|
},
|
|
923
983
|
commit: "none",
|
|
924
984
|
}, ctx.log).row;
|
|
985
|
+
if (/-close-workflow$/.test(step)) {
|
|
986
|
+
const tree = git(ctx.cwd, ["rev-parse", "--show-toplevel"]) ?? ctx.cwd;
|
|
987
|
+
restateOutcome(tree, status, String(f.workflow ?? "build"), { ...r.ciDispatch }, ctx.log);
|
|
988
|
+
}
|
|
925
989
|
if (code === EXIT.OK || code === EXIT_SKIP_TOKEN) {
|
|
926
990
|
const check = crossCheckFile(status, "gh", ctx.log);
|
|
927
991
|
if (!check.ok) {
|
|
@@ -965,7 +1029,10 @@ async function runDispatch(ctx) {
|
|
|
965
1029
|
function dispatchCode(r, pr, scanResult, log) {
|
|
966
1030
|
if (r.handoff === EXIT.AGENT_WAIT || r.handoff === EXIT.USE_MCP) {
|
|
967
1031
|
const again = r.phase === "repoll" ? " --retriggered" : "";
|
|
968
|
-
|
|
1032
|
+
const [wait, keep] = r.runBranch === null
|
|
1033
|
+
? [`--pr=${pr ?? "<n>"}`, ""]
|
|
1034
|
+
: [`--head=${r.head} --branch=${r.runBranch} --until=present`, ` --sha=${r.head}`];
|
|
1035
|
+
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
1036
|
return r.handoff;
|
|
970
1037
|
}
|
|
971
1038
|
if (r.handoff !== 0)
|
|
@@ -1013,6 +1080,15 @@ function runGate(ctx) {
|
|
|
1013
1080
|
const given = [f.head, f.pr, f.squashOf].filter((v) => v !== undefined).length;
|
|
1014
1081
|
if (given !== 1)
|
|
1015
1082
|
throw new CommandError(EXIT.USAGE, "give exactly one of --head, --pr, --squash-of");
|
|
1083
|
+
if (f.fetch === true) {
|
|
1084
|
+
const branch = str(f.branch);
|
|
1085
|
+
if (branch === undefined)
|
|
1086
|
+
throw new CommandError(EXIT.USAGE, "--fetch needs --branch");
|
|
1087
|
+
// Best-effort: the gate reads CI, not the local ref; a failed fetch is logged, not fatal.
|
|
1088
|
+
const fetched = fetchRemoteRef(ctx.cwd, `origin/${branch}`);
|
|
1089
|
+
if (fetched !== null && !fetched.ok)
|
|
1090
|
+
ctx.log(`fetch of origin/${branch} failed: ${fetched.stderr.trim()}`);
|
|
1091
|
+
}
|
|
1016
1092
|
const root = checkoutRoot(ctx.cwd);
|
|
1017
1093
|
const gh = (args) => runGh(ctx.cwd, args);
|
|
1018
1094
|
const record = str(f.record);
|
|
@@ -1148,14 +1224,6 @@ function runGate(ctx) {
|
|
|
1148
1224
|
// ---------------------------------------------------------------------------
|
|
1149
1225
|
// revalidate
|
|
1150
1226
|
// ---------------------------------------------------------------------------
|
|
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
1227
|
async function runRevalidate(ctx) {
|
|
1160
1228
|
const f = ctx.flags;
|
|
1161
1229
|
const repoFlag = str(f.repo);
|
|
@@ -1308,25 +1376,25 @@ async function runContext(ctx) {
|
|
|
1308
1376
|
prState: null,
|
|
1309
1377
|
runId: null,
|
|
1310
1378
|
};
|
|
1379
|
+
const tracker = readIssueTracker(ctx.cwd);
|
|
1311
1380
|
if (chosen.mode === "BRIEF") {
|
|
1312
|
-
ctx.emit({ ...out, issueId: arg });
|
|
1381
|
+
ctx.emit(await withIssue(ctx, { ...out, issueId: arg }, tracker));
|
|
1313
1382
|
return EXIT.OK;
|
|
1314
1383
|
}
|
|
1315
|
-
const tracker = readIssueTracker(ctx.cwd);
|
|
1316
1384
|
if (!/^[0-9]+$/.test(arg)) {
|
|
1317
1385
|
// CI_DEV: a post-merge dev failure names the FID slug; checked before any path sees it.
|
|
1318
1386
|
if (!FID_PATTERNS.any.test(arg)) {
|
|
1319
1387
|
ctx.log(`Invalid CI_DEV FID: ${arg}`);
|
|
1320
1388
|
return EXIT_NO_FID;
|
|
1321
1389
|
}
|
|
1322
|
-
ctx.emit({
|
|
1390
|
+
ctx.emit(await withIssue(ctx, {
|
|
1323
1391
|
...out,
|
|
1324
1392
|
mode: "CI_DEV",
|
|
1325
1393
|
fid: arg,
|
|
1326
1394
|
issueId: tracker === "none" ? null : issueIdOf(arg, "any"),
|
|
1327
1395
|
branch: DEV,
|
|
1328
1396
|
headSha: git(ctx.cwd, ["rev-parse", "origin/dev"]) ?? "",
|
|
1329
|
-
});
|
|
1397
|
+
}, tracker));
|
|
1330
1398
|
return EXIT.OK;
|
|
1331
1399
|
}
|
|
1332
1400
|
const view = runGh(ctx.cwd, [
|
|
@@ -1389,9 +1457,30 @@ async function runContext(ctx) {
|
|
|
1389
1457
|
ctx.emit(out);
|
|
1390
1458
|
return EXIT_NO_FID;
|
|
1391
1459
|
}
|
|
1392
|
-
|
|
1460
|
+
if (parsed.issueId === null && tracker !== "none") {
|
|
1461
|
+
ctx.log(`FID ${parsed.fid} names no issue; /bkit-auto runs from an issue only`);
|
|
1462
|
+
ctx.emit(out);
|
|
1463
|
+
return EXIT_NO_FID;
|
|
1464
|
+
}
|
|
1465
|
+
ctx.emit(await withIssue(ctx, { ...out, fid: parsed.fid, issueId: parsed.issueId }, tracker));
|
|
1393
1466
|
return EXIT.OK;
|
|
1394
1467
|
}
|
|
1468
|
+
/**
|
|
1469
|
+
* `ref` (the issue as a workflow argument: `#N` on GitHub, the key uppercased on
|
|
1470
|
+
* Linear / Jira) and `labels` (read from the tracker; null when there is no issue
|
|
1471
|
+
* or the read failed, logged).
|
|
1472
|
+
*/
|
|
1473
|
+
async function withIssue(ctx, out, tracker) {
|
|
1474
|
+
const id = typeof out.issueId === "string" && out.issueId !== "" ? out.issueId : null;
|
|
1475
|
+
const ref = issueRef(id, tracker);
|
|
1476
|
+
if (id === null || tracker === "none")
|
|
1477
|
+
return { ...out, ref, labels: null };
|
|
1478
|
+
let labels = null;
|
|
1479
|
+
const read = await attempt("labels", ctx.log, async () => {
|
|
1480
|
+
labels = await readLabels(trackerTarget(ctx.cwd, { issue: id }));
|
|
1481
|
+
});
|
|
1482
|
+
return { ...out, ref, labels: "done" in read && read.done ? labels : null };
|
|
1483
|
+
}
|
|
1395
1484
|
async function runMirror(ctx) {
|
|
1396
1485
|
const f = ctx.flags;
|
|
1397
1486
|
const head = String(f.head);
|
|
@@ -1469,12 +1558,17 @@ export const runsCommand = {
|
|
|
1469
1558
|
run: runWait,
|
|
1470
1559
|
},
|
|
1471
1560
|
dispatch: {
|
|
1472
|
-
summary: "CI-Dispatch Gate after the last push: poll, one clean re-trigger, the ciDispatch verdict, and the body scan.",
|
|
1561
|
+
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.",
|
|
1473
1562
|
flags: [
|
|
1474
1563
|
{
|
|
1475
1564
|
name: "pr",
|
|
1476
1565
|
type: "string",
|
|
1477
|
-
help: "PR number (default: the open PR from this branch into dev)",
|
|
1566
|
+
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)",
|
|
1567
|
+
},
|
|
1568
|
+
{
|
|
1569
|
+
name: "sha",
|
|
1570
|
+
type: "string",
|
|
1571
|
+
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
1572
|
},
|
|
1479
1573
|
{
|
|
1480
1574
|
name: "fid",
|
|
@@ -1529,8 +1623,8 @@ export const runsCommand = {
|
|
|
1529
1623
|
output: {
|
|
1530
1624
|
ciDispatch: "{outcome, head, attempts, retrigger, reason?} — record with `bkit steps done --field ciDispatch=…` (local only, never pushed); null on a hand-off",
|
|
1531
1625
|
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)",
|
|
1626
|
+
pr: "PR number polled (null when none was found, or a run in place on dev, whose run is read at head)",
|
|
1627
|
+
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
1628
|
attempts: "poll attempts so far",
|
|
1535
1629
|
retrigger: "a re-trigger commit was pushed",
|
|
1536
1630
|
scanResult: "clean | skip-token-found | error — the pushed head's BODY scan; null when unresolved",
|
|
@@ -1582,6 +1676,11 @@ export const runsCommand = {
|
|
|
1582
1676
|
type: "string",
|
|
1583
1677
|
help: "PR branch: tells a superseded head (14) from no run (10)",
|
|
1584
1678
|
},
|
|
1679
|
+
{
|
|
1680
|
+
name: "fetch",
|
|
1681
|
+
type: "boolean",
|
|
1682
|
+
help: "fetch origin/<--branch> first (best-effort, logged on failure)",
|
|
1683
|
+
},
|
|
1585
1684
|
{
|
|
1586
1685
|
name: "event",
|
|
1587
1686
|
type: "string",
|
|
@@ -1739,6 +1838,8 @@ export const runsCommand = {
|
|
|
1739
1838
|
owner: "owner half",
|
|
1740
1839
|
repo: "repo half",
|
|
1741
1840
|
issueId: "the issue (BRIEF: the arg; CI: from the marker or branch; null under no tracker)",
|
|
1841
|
+
ref: 'the issue as the phase workflow\'s argument: #N (GitHub), the key uppercased (Linear / Jira), else issueId verbatim or ""',
|
|
1842
|
+
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
1843
|
fid: "the FID (CI / CI_DEV), else null",
|
|
1743
1844
|
prNumber: "the PR (CI), else null",
|
|
1744
1845
|
branch: "the PR head branch (CI), dev (CI_DEV), else null",
|
|
@@ -1751,12 +1852,12 @@ export const runsCommand = {
|
|
|
1751
1852
|
[EXIT_UNKNOWN_PHASE]: "the phase word is not one bkit dispatches",
|
|
1752
1853
|
[EXIT_PR_NOT_OPEN]: "the PR is not OPEN",
|
|
1753
1854
|
[EXIT_NO_RUN_ID]: "no CI run at the PR head",
|
|
1754
|
-
[EXIT_NO_FID]: "no valid FID (CI_DEV slug off the allowlist,
|
|
1855
|
+
[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
1856
|
},
|
|
1756
1857
|
run: runContext,
|
|
1757
1858
|
},
|
|
1758
1859
|
declared: {
|
|
1759
|
-
summary: "Whether the repo declares a CI workflow: .github/workflows/<bkit.ciWorkflow> exists (exit 0) or not (exit 1).",
|
|
1860
|
+
summary: "Whether the repo declares a CI workflow: .github/workflows/<bkit.testing.ciWorkflow> exists (exit 0) or not (exit 1).",
|
|
1760
1861
|
flags: [],
|
|
1761
1862
|
output: {
|
|
1762
1863
|
declared: "the workflow file exists",
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
import * as fs from "node:fs";
|
|
24
24
|
import * as path from "node:path";
|
|
25
25
|
import { statusTimestamp } from "../../ledgers/status.js";
|
|
26
|
-
import { CommandError, EXIT, repoRoot, runTool } from "../lib.js";
|
|
26
|
+
import { CommandError, EXIT, git, repoRoot, runTool, } from "../lib.js";
|
|
27
27
|
import { EXIT_NO_STATUS, FILE_FLAG, WORKFLOW_FLAG, readStatusEvents, statusFile, str, } from "./status.js";
|
|
28
28
|
export const RUNTIMES = [
|
|
29
29
|
"LOCAL",
|
|
@@ -88,6 +88,17 @@ export function classify(env, root, log) {
|
|
|
88
88
|
const capable = (runtime) => runtime === "LOCAL" || runtime === "GITHUB_ACTION" || runtime === "CLOUD_CURSOR";
|
|
89
89
|
/** No human can reply into the session: a GitHub Actions run. */
|
|
90
90
|
const headless = (runtime) => runtime === "GITHUB_ACTION";
|
|
91
|
+
/**
|
|
92
|
+
* `classify` for a process working in `cwd`, which may be a build worktree: the Cursor
|
|
93
|
+
* marker sits in the main checkout (`repoRoot`), as `runtime detect` reads it. Outside a
|
|
94
|
+
* git repo the marker is looked for under `cwd`.
|
|
95
|
+
*/
|
|
96
|
+
export function classifyAt(cwd) {
|
|
97
|
+
const common = git(cwd, ["rev-parse", "--path-format=absolute", "--git-common-dir"]);
|
|
98
|
+
return classify(process.env, common ? path.dirname(common) : cwd, () => undefined);
|
|
99
|
+
}
|
|
100
|
+
/** Whether a process working in `cwd` runs headless, classified like `runtime detect`. */
|
|
101
|
+
export const headlessRun = (cwd) => headless(classifyAt(cwd));
|
|
91
102
|
/** The full table: classification, default capabilities, and the one live gh probe. */
|
|
92
103
|
export function detect(cwd, root, log) {
|
|
93
104
|
const runtime = classify(process.env, root, log);
|