@cbartens/bkit 5.2.3 → 5.3.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 +29 -12
- package/.bkit/core/.agents/context.md +1 -1
- package/.bkit/core/.agents/docs.md +1 -1
- package/.bkit/core/.agents/plugins/bkit/hooks/bkit-guardrails.cjs +1 -1
- package/.bkit/core/.agents/rules.md +11 -0
- package/.bkit/core/.bkit/README.md +28 -11
- package/.bkit/core/.bkit/cloud.md +9 -8
- package/.bkit/core/.bkit/comparison.md +68 -345
- package/.bkit/core/.bkit/install.md +15 -9
- package/.bkit/core/.bkit/lite.md +73 -0
- package/.bkit/core/.bkit/pipeline.md +345 -0
- package/.bkit/core/.bkit/prompts.md +88 -73
- package/.bkit/core/.bkit/providers.md +41 -22
- package/.bkit/core/.bkit/templates.md +125 -18
- package/.bkit/core/.bkit/trackers.md +47 -1
- package/.bkit/core/.bkit/workflows.md +51 -45
- package/.bkit/core/.claude/hooks/bkit-guardrails.cjs +1 -1
- package/.bkit/core/.codex/hooks/bkit-guardrails.cjs +7 -4
- package/.bkit/core/.cursor/hooks/bkit-guardrails.cjs +8 -5
- package/.bkit/core/docs/templates/bkit-audit-accessibility.md +9 -1
- package/.bkit/core/docs/templates/bkit-audit-adoption.md +10 -2
- package/.bkit/core/docs/templates/bkit-audit-agents.md +9 -1
- package/.bkit/core/docs/templates/bkit-audit-aio-seo.md +9 -1
- package/.bkit/core/docs/templates/bkit-audit-analytics.md +9 -1
- package/.bkit/core/docs/templates/bkit-audit-annotations.md +10 -2
- package/.bkit/core/docs/templates/bkit-audit-app-performance.md +9 -1
- package/.bkit/core/docs/templates/bkit-audit-app-store.md +9 -1
- package/.bkit/core/docs/templates/bkit-audit-architecture.md +9 -1
- package/.bkit/core/docs/templates/bkit-audit-ci-performance.md +9 -1
- package/.bkit/core/docs/templates/bkit-audit-config.md +9 -1
- package/.bkit/core/docs/templates/bkit-audit-cost.md +10 -2
- package/.bkit/core/docs/templates/bkit-audit-coverage.md +9 -1
- package/.bkit/core/docs/templates/bkit-audit-database.md +9 -1
- package/.bkit/core/docs/templates/bkit-audit-dead-code.md +9 -1
- package/.bkit/core/docs/templates/bkit-audit-deferrals.md +9 -1
- package/.bkit/core/docs/templates/bkit-audit-dependencies.md +22 -10
- package/.bkit/core/docs/templates/bkit-audit-documentation.md +9 -1
- package/.bkit/core/docs/templates/bkit-audit-duplication.md +9 -1
- package/.bkit/core/docs/templates/bkit-audit-failures.md +9 -1
- package/.bkit/core/docs/templates/bkit-audit-flakes.md +10 -2
- package/.bkit/core/docs/templates/bkit-audit-gates.md +9 -1
- package/.bkit/core/docs/templates/bkit-audit-issues.md +9 -1
- package/.bkit/core/docs/templates/bkit-audit-llm.md +29 -15
- package/.bkit/core/docs/templates/bkit-audit-logs.md +10 -2
- package/.bkit/core/docs/templates/bkit-audit-models.md +9 -1
- package/.bkit/core/docs/templates/bkit-audit-privacy.md +9 -1
- package/.bkit/core/docs/templates/bkit-audit-prompts.md +11 -3
- package/.bkit/core/docs/templates/bkit-audit-red-team.md +19 -9
- package/.bkit/core/docs/templates/bkit-audit-reliability.md +9 -1
- package/.bkit/core/docs/templates/bkit-audit-repo.md +10 -2
- package/.bkit/core/docs/templates/bkit-audit-security.md +13 -5
- package/.bkit/core/docs/templates/bkit-audit-slop.md +9 -1
- package/.bkit/core/docs/templates/bkit-audit-testing.md +14 -5
- package/.bkit/core/docs/templates/bkit-audit-usability.md +9 -1
- package/.bkit/core/docs/templates/bkit-plan.md +8 -6
- package/.bkit/core/engine/checks/after/auth.ts +9 -9
- package/.bkit/core/engine/checks/after/ci-yml.ts +14 -12
- package/.bkit/core/engine/checks/after/github.ts +29 -120
- package/.bkit/core/engine/checks/after/index.ts +2 -2
- package/.bkit/core/engine/checks/after/managed.ts +8 -28
- package/.bkit/core/engine/checks/after/tools.ts +3 -15
- package/.bkit/core/engine/checks/before/context-fetch.ts +1 -21
- package/.bkit/core/engine/checks/before/index.ts +7 -43
- package/.bkit/core/engine/checks/before/mcp.ts +17 -8
- package/.bkit/core/engine/checks/before/repo.ts +9 -12
- package/.bkit/core/engine/checks/status-holes.ts +4 -5
- package/.bkit/core/engine/checks/tips/catalogue.ts +70 -24
- package/.bkit/core/engine/checks/tips/detect.ts +45 -2
- package/.bkit/core/engine/checks/tips/index.ts +37 -8
- package/.bkit/core/engine/cli.ts +39 -16
- package/.bkit/core/engine/commands/analysis.ts +36 -26
- package/.bkit/core/engine/commands/comply.ts +17 -16
- package/.bkit/core/engine/commands/harvest.ts +12 -12
- package/.bkit/core/engine/commands/install/doctor.ts +57 -28
- package/.bkit/core/engine/commands/install/install.ts +62 -126
- package/.bkit/core/engine/commands/install/uninstall.ts +191 -33
- package/.bkit/core/engine/commands/install/upgrade.ts +58 -53
- package/.bkit/core/engine/commands/lib.ts +35 -10
- package/.bkit/core/engine/commands/tips.ts +8 -5
- package/.bkit/core/engine/commands/workflow/branches.ts +65 -11
- package/.bkit/core/engine/commands/workflow/counters.ts +21 -12
- package/.bkit/core/engine/commands/workflow/fids.ts +46 -0
- package/.bkit/core/engine/commands/workflow/ledgers.ts +3 -1
- package/.bkit/core/engine/commands/workflow/prs.ts +4 -2
- package/.bkit/core/engine/commands/workflow/repo.ts +18 -4
- package/.bkit/core/engine/commands/workflow/roadmap.ts +4 -3
- package/.bkit/core/engine/commands/workflow/runs.ts +8 -7
- package/.bkit/core/engine/commands/workflow/steps.ts +1 -0
- package/.bkit/core/engine/commands/workflow/tests.ts +17 -5
- package/.bkit/core/engine/commands/workflow/workflows.ts +19 -17
- package/.bkit/core/engine/commands/workflow/workstreams.ts +2 -1
- package/.bkit/core/engine/commands/workflow/worktrees.ts +13 -5
- package/.bkit/core/engine/install/cloud-env.ts +10 -31
- package/.bkit/core/engine/install/manifest.ts +14 -7
- package/.bkit/core/engine/install/modules/antigravity.ts +15 -26
- package/.bkit/core/engine/install/modules/claude.ts +20 -28
- package/.bkit/core/engine/install/modules/cloud.ts +5 -2
- package/.bkit/core/engine/install/modules/codex.ts +15 -29
- package/.bkit/core/engine/install/modules/core.ts +91 -70
- package/.bkit/core/engine/install/modules/cursor.ts +6 -20
- package/.bkit/core/engine/install/modules/index.ts +7 -1
- package/.bkit/core/engine/install/modules/opencode.ts +48 -70
- package/.bkit/core/engine/install/network-allowlist.ts +73 -0
- package/.bkit/core/engine/install/placeholders.ts +3 -18
- package/.bkit/core/engine/install/write.ts +59 -12
- package/.bkit/core/engine/ledgers/telemetry.ts +6 -4
- package/.bkit/core/engine/render/hosts.ts +47 -67
- package/.bkit/core/engine/render/models.ts +29 -11
- package/.bkit/core/engine/shared/bkit-latest.ts +164 -0
- package/.bkit/core/engine/shared/branches.ts +13 -0
- package/.bkit/core/engine/shared/egress.ts +3 -3
- package/.bkit/core/engine/shared/json.ts +18 -1
- package/.bkit/core/engine/shared/package-json.ts +63 -0
- package/.bkit/core/engine/shared/package-roots.ts +0 -10
- package/.bkit/core/engine/shared/protected-paths.ts +5 -130
- package/.bkit/core/engine/shared/settings.ts +36 -0
- package/.bkit/core/engine/shared/timeouts.ts +6 -0
- package/.bkit/core/hooks/antigravity-hook.js +1 -0
- package/.bkit/core/hooks/guardrails-shell.js +186 -40
- package/.bkit/core/hooks/guardrails-tiers.js +5 -78
- package/.bkit/core/prompts/bkit-audit-generate.md +65 -10
- package/.bkit/core/prompts/bkit-build-challenge-1.md +1 -1
- package/.bkit/core/prompts/bkit-build-challenge-2.md +1 -1
- package/.bkit/core/prompts/bkit-build-challenge-reconcile.md +1 -1
- package/.bkit/core/prompts/bkit-build-challenge-remediate.md +1 -1
- package/.bkit/core/prompts/bkit-build-challenge-tests.md +1 -1
- package/.bkit/core/prompts/bkit-build-install-skills.md +1 -1
- package/.bkit/core/prompts/bkit-build-plan-current.md +1 -1
- package/.bkit/core/prompts/bkit-build-plan-execute.md +4 -4
- package/.bkit/core/prompts/bkit-build-plan-gaps-remediate.md +1 -1
- package/.bkit/core/prompts/bkit-build-plan-verify.md +2 -2
- package/.bkit/core/prompts/bkit-debug-abort-handover.md +1 -1
- package/.bkit/core/prompts/bkit-debug-failure-diagnose.md +1 -1
- package/.bkit/core/prompts/bkit-debug-failure-remediate.md +1 -1
- package/.bkit/core/prompts/bkit-debug-failure-reproduce.md +78 -0
- package/.bkit/core/prompts/bkit-debug-failure-soak.md +1 -1
- package/.bkit/core/prompts/bkit-debug-summary.md +3 -3
- package/.bkit/core/prompts/bkit-design-spike.md +1 -1
- package/.bkit/core/prompts/bkit-design-summary.md +2 -2
- package/.bkit/core/prompts/bkit-design-update.md +1 -1
- package/.bkit/core/prompts/bkit-plan-complexity-check.md +1 -1
- package/.bkit/core/prompts/bkit-plan-generate.md +1 -1
- package/.bkit/core/prompts/bkit-plan-scope-check-1.md +1 -1
- package/.bkit/core/prompts/bkit-plan-scope-check-2.md +1 -1
- package/.bkit/core/prompts/bkit-plan-summary.md +1 -1
- package/.bkit/core/prompts/bkit-plan-update.md +1 -1
- package/.bkit/core/prompts/bkit-ship-conflict-resolve.md +1 -1
- package/.bkit/core/prompts/bkit-ship-deferred-sweep.md +1 -1
- package/.bkit/core/prompts/bkit-ship-update-docs.md +1 -1
- package/.bkit/core/prompts/bkit-utility-update-decisions.md +9 -2
- package/.bkit/core/prompts/bkit-utility-update-deferrals.md +9 -2
- package/.bkit/core/prompts/bkit-utility-update-documentation.md +2 -1
- package/.bkit/core/prompts/bkit-utility-update-failures.md +9 -2
- package/.bkit/core/prompts/bkit-utility-update-knowledge.md +9 -2
- package/.bkit/core/prompts/bkit-utility-update-roadmap.md +11 -4
- package/.bkit/core/workflows/bkit-build.md +4 -4
- package/.bkit/core/workflows/bkit-debug.md +70 -34
- package/.bkit/core/workflows/bkit-design.md +3 -3
- package/.bkit/core/workflows/bkit-plan.md +12 -5
- package/.bkit/core/workflows/bkit-ship.md +6 -6
- package/.bkit/shared/.claude/bkit-cloud.md +46 -13
- package/.bkit/shared/.claude/settings.json +18 -0
- package/.bkit/shared/.cursor/mcp.json +2 -1
- package/.bkit/shared/.opencode/opencode.json +19 -1
- package/.bkit/shared/docs/deployments.md +20 -4
- package/.bkit/shared/docs/security.md +8 -6
- package/.bkit/shared/docs/testing.md +9 -5
- package/.bkit/templates/.cursor/Dockerfile +30 -16
- package/.bkit/templates/.github/ISSUE_TEMPLATE/bkit-bug.yml +78 -0
- package/.bkit/templates/.github/ISSUE_TEMPLATE/bkit-change.yml +91 -0
- package/.bkit/templates/.github/ISSUE_TEMPLATE/bkit-idea.yml +56 -0
- package/.bkit/templates/.github/renovate.json5 +91 -12
- package/.bkit/templates/.github/workflows/bkit-ci.yml +66 -53
- package/.bkit/templates/.github/workflows/bkit-cloud.yml +3 -1
- package/.bkit/templates/.github/workflows/bkit-renovate.yml +8 -1
- package/.bkit/templates/.github/workflows/bkit-trivy.yml +67 -0
- package/.bkit/templates/.husky/pre-push +15 -3
- package/.bkit/templates/.oxlintrc.json +21 -0
- package/.bkit/templates/docs/capabilities.md +1 -1
- package/.bkit/templates/scripts/ci/check-capstone.mjs +176 -0
- package/.bkit/templates/scripts/ci/check-capstone.test.mjs +311 -0
- package/.bkit/templates/scripts/cleanup/bkit-tmp-prune.mjs +115 -0
- package/.bkit/templates/scripts/graphify/bkit-graph-eager.py +2 -2
- package/.bkit/templates/scripts/graphify/bkit-graph-imports.py +43 -20
- package/.bkit/templates/scripts/graphify/bkit-graph-pre-push.sh +33 -11
- package/.bkit/templates/scripts/graphify/bkit-graph-repair.py +3 -2
- package/.bkit/templates/scripts/graphify/bkit-graphify-rollup.py +5 -5
- package/.bkit/templates/scripts/graphify/bkit-graphify.sh +79 -19
- package/CHANGELOG.md +67 -3
- package/README.md +258 -129
- package/dist/checks/after/auth.js +10 -11
- package/dist/checks/after/ci-yml.js +11 -14
- package/dist/checks/after/github.js +32 -125
- package/dist/checks/after/index.js +3 -2
- package/dist/checks/after/managed.js +8 -24
- package/dist/checks/after/tools.js +3 -16
- package/dist/checks/before/context-fetch.js +1 -21
- package/dist/checks/before/index.js +6 -42
- package/dist/checks/before/mcp.js +14 -9
- package/dist/checks/before/repo.js +8 -11
- package/dist/checks/status-holes.js +5 -6
- package/dist/checks/tips/catalogue.js +60 -18
- package/dist/checks/tips/detect.js +41 -2
- package/dist/checks/tips/index.js +25 -5
- package/dist/cli.js +34 -14
- package/dist/commands/analysis.js +21 -5
- package/dist/commands/comply.js +20 -18
- package/dist/commands/harvest.js +12 -13
- package/dist/commands/install/doctor.js +55 -23
- package/dist/commands/install/install.js +62 -118
- package/dist/commands/install/uninstall.js +165 -31
- package/dist/commands/install/upgrade.js +55 -49
- package/dist/commands/lib.js +32 -10
- package/dist/commands/tips.js +6 -3
- package/dist/commands/workflow/branches.js +57 -13
- package/dist/commands/workflow/counters.js +17 -7
- package/dist/commands/workflow/fids.js +39 -0
- package/dist/commands/workflow/ledgers.js +3 -1
- package/dist/commands/workflow/prs.js +3 -3
- package/dist/commands/workflow/repo.js +16 -4
- package/dist/commands/workflow/roadmap.js +4 -4
- package/dist/commands/workflow/runs.js +5 -5
- package/dist/commands/workflow/steps.js +1 -0
- package/dist/commands/workflow/tests.js +16 -3
- package/dist/commands/workflow/workflows.js +19 -18
- package/dist/commands/workflow/workstreams.js +2 -1
- package/dist/commands/workflow/worktrees.js +4 -5
- package/dist/install/cloud-env.js +10 -23
- package/dist/install/manifest.js +14 -7
- package/dist/install/modules/antigravity.js +15 -26
- package/dist/install/modules/claude.js +17 -21
- package/dist/install/modules/cloud.js +6 -2
- package/dist/install/modules/codex.js +15 -29
- package/dist/install/modules/core.js +82 -63
- package/dist/install/modules/cursor.js +6 -9
- package/dist/install/modules/index.js +6 -1
- package/dist/install/modules/opencode.js +41 -72
- package/dist/install/network-allowlist.js +62 -0
- package/dist/install/placeholders.js +3 -16
- package/dist/install/write.js +55 -15
- package/dist/ledgers/telemetry.js +5 -4
- package/dist/render/hosts.js +30 -55
- package/dist/render/models.js +20 -9
- package/dist/shared/bkit-latest.js +150 -0
- package/dist/shared/branches.js +11 -0
- package/dist/shared/egress.js +0 -2
- package/dist/shared/json.js +14 -0
- package/dist/shared/package-json.js +61 -0
- package/dist/shared/package-roots.js +0 -8
- package/dist/shared/protected-paths.js +5 -122
- package/dist/shared/settings.js +18 -1
- package/dist/shared/timeouts.js +6 -0
- package/package.json +21 -17
- package/.bkit/core/.agents/shortcuts.md +0 -73
|
@@ -14,7 +14,8 @@ import * as fs from "node:fs";
|
|
|
14
14
|
import * as os from "node:os";
|
|
15
15
|
import * as path from "node:path";
|
|
16
16
|
import { gitEnv } from "../../ledgers/telemetry.js";
|
|
17
|
-
import { bodySkipToken, CommandError, EXIT, git, parseJson, repoRoot, runGit, SKIP_CI_TOKEN, } from "../lib.js";
|
|
17
|
+
import { bodySkipToken, CommandError, DEV, EXIT, git, isSharedBranch, parseJson, repoRoot, runGit, SKIP_CI_TOKEN, } from "../lib.js";
|
|
18
|
+
import { bkitVersionStatus } from "../../shared/bkit-latest.js";
|
|
18
19
|
import { TIMEOUTS } from "../../shared/timeouts.js";
|
|
19
20
|
import { commitBookkeeping } from "./ledgers.js";
|
|
20
21
|
import { acquireDevLock, lockRoot, releaseLock, resolveMonth, workflowLockPath } from "./locks.js";
|
|
@@ -26,9 +27,7 @@ import { removeWorktree } from "./worktrees.js";
|
|
|
26
27
|
import { COULD_NOT_RUN_EXIT_CODES, LOCKFILE_REGENERATE, installCommand, } from "../../shared/package-manager.js";
|
|
27
28
|
import { str } from "./status.js";
|
|
28
29
|
const REMOTE = "origin";
|
|
29
|
-
const DEV = "dev";
|
|
30
30
|
const UPSTREAM = `${REMOTE}/${DEV}`;
|
|
31
|
-
const SHARED_BRANCHES = new Set([DEV, "main"]);
|
|
32
31
|
/** Exit codes, distinct across verbs so a code means one thing anywhere in this noun. */
|
|
33
32
|
export const EXIT_REFUSED = 3;
|
|
34
33
|
export const EXIT_NO_REBASE = 4;
|
|
@@ -284,7 +283,17 @@ export function resolveRebase(top, onLog = () => undefined) {
|
|
|
284
283
|
// ---------------------------------------------------------------------------
|
|
285
284
|
const ANCHOR_OPEN = "<!-- bkit:anchor";
|
|
286
285
|
const ANCHOR_CLOSE = "-->";
|
|
287
|
-
|
|
286
|
+
/** Ends the visible line a stamp writes under the block when the doc came from an outdated bkit. */
|
|
287
|
+
const OUTDATED_MARK = "<!-- bkit:outdated -->";
|
|
288
|
+
const OUTDATED_LINE = new RegExp(`^.*${OUTDATED_MARK}\n(?:\n)?`, "gm");
|
|
289
|
+
export const ANCHOR_FIELDS = [
|
|
290
|
+
"baseSha",
|
|
291
|
+
"baseRef",
|
|
292
|
+
"designPath",
|
|
293
|
+
"designBaseSha",
|
|
294
|
+
"bkitVersion",
|
|
295
|
+
"bkitLatest",
|
|
296
|
+
];
|
|
288
297
|
/** Lines of `text` with whether each sits inside an anchor block (a `sed '/open/,/close/'` range). */
|
|
289
298
|
function anchorLines(text) {
|
|
290
299
|
const lines = text.split("\n");
|
|
@@ -319,16 +328,38 @@ export function readAnchor(text) {
|
|
|
319
328
|
}
|
|
320
329
|
return out;
|
|
321
330
|
}
|
|
322
|
-
/**
|
|
323
|
-
|
|
331
|
+
/**
|
|
332
|
+
* The bkit release a doc is being generated from, for its anchor: undefined when
|
|
333
|
+
* this repo has no `.bkit/version` pin (nothing to record). Asks the registry for
|
|
334
|
+
* the newest release at most once a day; offline leaves `latest` null.
|
|
335
|
+
*/
|
|
336
|
+
export function anchorBkitStatus(cwd) {
|
|
337
|
+
const status = bkitVersionStatus(git(cwd, ["rev-parse", "--show-toplevel"]) ?? cwd, git(cwd, ["rev-parse", "--path-format=absolute", "--git-common-dir"]));
|
|
338
|
+
return status.version === null ? undefined : status;
|
|
339
|
+
}
|
|
340
|
+
/**
|
|
341
|
+
* `text` with a fresh anchor block on top and every prior one removed, so re-stamping
|
|
342
|
+
* is idempotent. With `bkit`, the block records the release the doc came from and the
|
|
343
|
+
* newest one (empty when unknown); an outdated release adds one visible warning line
|
|
344
|
+
* under the block, replaced or dropped by the next stamp like the block itself.
|
|
345
|
+
*/
|
|
346
|
+
export function stampAnchor(text, baseSha, design, baseRef = UPSTREAM, bkit) {
|
|
324
347
|
const header = [ANCHOR_OPEN, `baseSha: ${baseSha}`, `baseRef: ${baseRef}`];
|
|
325
348
|
if (design)
|
|
326
349
|
header.push(`designPath: ${design.path}`, `designBaseSha: ${design.baseSha}`);
|
|
350
|
+
if (bkit)
|
|
351
|
+
header.push(`bkitVersion: ${bkit.version ?? ""}`, `bkitLatest: ${bkit.latest ?? ""}`);
|
|
327
352
|
header.push(ANCHOR_CLOSE);
|
|
328
|
-
|
|
353
|
+
let body = anchorLines(text)
|
|
329
354
|
.filter((l) => !l.inBlock)
|
|
330
355
|
.map((l) => (l.last ? l.line : `${l.line}\n`))
|
|
331
|
-
.join("")
|
|
356
|
+
.join("")
|
|
357
|
+
.replace(OUTDATED_LINE, "");
|
|
358
|
+
if (bkit?.outdated === true) {
|
|
359
|
+
// Blank lines on both sides of the warning, as prettier writes them.
|
|
360
|
+
header.push("", `> **Outdated bkit:** generated with bkit ${bkit.version} while ${bkit.latest} was out, so its workflow and template text may be stale. Upgrade with \`pnpm bkit upgrade --latest\` and regenerate if that matters. ${OUTDATED_MARK}`);
|
|
361
|
+
body = `\n${body.replace(/^\n+/, "")}`;
|
|
362
|
+
}
|
|
332
363
|
return `${header.join("\n")}\n${body}`;
|
|
333
364
|
}
|
|
334
365
|
// ---------------------------------------------------------------------------
|
|
@@ -444,7 +475,7 @@ export function pushBranch(cwd, o, log) {
|
|
|
444
475
|
return notPushed(EXIT_SKIP_CI, { skipped: "skip-ci" });
|
|
445
476
|
}
|
|
446
477
|
}
|
|
447
|
-
const shared =
|
|
478
|
+
const shared = isSharedBranch(branch);
|
|
448
479
|
if (mode === "abort" && !shared) {
|
|
449
480
|
const pr = openPrFlag === undefined
|
|
450
481
|
? openPrNumber(cwd, branch)
|
|
@@ -565,7 +596,7 @@ function syncVerb(ctx) {
|
|
|
565
596
|
ctx.log("no branch checked out (detached HEAD) — cannot merge dev's docs");
|
|
566
597
|
return EXIT_DETACHED;
|
|
567
598
|
}
|
|
568
|
-
if (!
|
|
599
|
+
if (!isSharedBranch(branch) && docsBehind > 0) {
|
|
569
600
|
ctx.log(`docs/ is ${docsBehind} commit(s) behind ${UPSTREAM} — merging it in`);
|
|
570
601
|
if (!quietGit(top, ["merge", "--no-edit", UPSTREAM]).ok) {
|
|
571
602
|
const outcome = resolveDocsMerge(top);
|
|
@@ -956,8 +987,11 @@ function anchorStampVerb(ctx) {
|
|
|
956
987
|
baseSha: readAnchor(fs.readFileSync(designFile, "utf-8")).baseSha ?? "",
|
|
957
988
|
}
|
|
958
989
|
: undefined;
|
|
990
|
+
const bkit = anchorBkitStatus(ctx.cwd);
|
|
991
|
+
if (bkit?.advisory)
|
|
992
|
+
ctx.log(bkit.advisory);
|
|
959
993
|
const before = fs.readFileSync(file, "utf-8");
|
|
960
|
-
const after = stampAnchor(before, baseSha, design, baseRef);
|
|
994
|
+
const after = stampAnchor(before, baseSha, design, baseRef, bkit);
|
|
961
995
|
// Temp file + rename: a crash mid-write never leaves a half-stamped doc.
|
|
962
996
|
const tmp = `${file}.bkit-anchor.tmp`;
|
|
963
997
|
fs.writeFileSync(tmp, after);
|
|
@@ -968,6 +1002,10 @@ function anchorStampVerb(ctx) {
|
|
|
968
1002
|
baseRef,
|
|
969
1003
|
designPath: design?.path ?? null,
|
|
970
1004
|
designBaseSha: design?.baseSha ?? null,
|
|
1005
|
+
bkitVersion: bkit?.version ?? null,
|
|
1006
|
+
bkitLatest: bkit?.latest ?? null,
|
|
1007
|
+
bkitOutdated: bkit?.outdated ?? null,
|
|
1008
|
+
bkitAdvisory: bkit?.advisory ?? null,
|
|
971
1009
|
changed: before !== after,
|
|
972
1010
|
});
|
|
973
1011
|
return EXIT.OK;
|
|
@@ -985,7 +1023,7 @@ function anchorReadVerb(ctx) {
|
|
|
985
1023
|
ctx.emit({ ...fields, value: null, skip: reason, landed: null });
|
|
986
1024
|
return EXIT_ANCHOR_SKIP;
|
|
987
1025
|
};
|
|
988
|
-
const none =
|
|
1026
|
+
const none = Object.fromEntries(ANCHOR_FIELDS.map((f) => [f, null]));
|
|
989
1027
|
if (!fs.statSync(file, { throwIfNoEntry: false })?.isFile()) {
|
|
990
1028
|
if (against !== undefined)
|
|
991
1029
|
return skip("no-file", `no ${rel} — nothing to check`, none);
|
|
@@ -1208,7 +1246,7 @@ export const branchesCommand = {
|
|
|
1208
1246
|
run: landVerb,
|
|
1209
1247
|
},
|
|
1210
1248
|
"anchor-stamp": {
|
|
1211
|
-
summary: "Put a <!-- bkit:anchor --> block recording the base commit on top of a design/plan doc or audit report (idempotent).",
|
|
1249
|
+
summary: "Put a <!-- bkit:anchor --> block recording the base commit and bkit release on top of a design/plan doc or audit report (idempotent).",
|
|
1212
1250
|
flags: [
|
|
1213
1251
|
{ name: "file", type: "string", required: true, help: "doc to stamp (must exist)" },
|
|
1214
1252
|
{
|
|
@@ -1234,6 +1272,10 @@ export const branchesCommand = {
|
|
|
1234
1272
|
baseRef: "ref stamped",
|
|
1235
1273
|
designPath: "design path stamped (null when none)",
|
|
1236
1274
|
designBaseSha: "the design doc's baseSha stamped (null when none; empty when it had no anchor)",
|
|
1275
|
+
bkitVersion: "the .bkit/version pin stamped (null when unpinned: no bkit fields are stamped then)",
|
|
1276
|
+
bkitLatest: "newest published bkit stamped (null when unknown: stamped empty)",
|
|
1277
|
+
bkitOutdated: "true when bkitVersion is older than bkitLatest: a visible warning line is stamped under the block (null when unknown)",
|
|
1278
|
+
bkitAdvisory: "one warning line when bkitOutdated, else null",
|
|
1237
1279
|
changed: "false when the doc already carried exactly this block",
|
|
1238
1280
|
},
|
|
1239
1281
|
exitCodes: { [EXIT_NO_FILE]: "--file is missing or not a file" },
|
|
@@ -1259,6 +1301,8 @@ export const branchesCommand = {
|
|
|
1259
1301
|
baseRef: "anchor baseRef (null when absent)",
|
|
1260
1302
|
designPath: "anchor designPath (null when absent)",
|
|
1261
1303
|
designBaseSha: "anchor designBaseSha (null when absent)",
|
|
1304
|
+
bkitVersion: "anchor bkitVersion (null when absent)",
|
|
1305
|
+
bkitLatest: "anchor bkitLatest (null when absent)",
|
|
1262
1306
|
value: "the --field value (null when absent or no --field)",
|
|
1263
1307
|
skip: "with --against: no-file | no-anchor | unreachable | nothing-landed (null = run the check)",
|
|
1264
1308
|
landed: "with --against: paths changed between baseSha and the ref",
|
|
@@ -38,16 +38,26 @@ const nonNegativeInt = (v, flag) => {
|
|
|
38
38
|
}
|
|
39
39
|
return Number(s);
|
|
40
40
|
};
|
|
41
|
-
/**
|
|
41
|
+
/**
|
|
42
|
+
* `--of=<step>:<position>` over `--file` / `--workflow`: the counter at that position.
|
|
43
|
+
* `--of=<step>,<step>...:count` sums the DONE rows of every listed step.
|
|
44
|
+
*/
|
|
42
45
|
function derivedOf(ctx) {
|
|
43
|
-
const [
|
|
44
|
-
|
|
45
|
-
|
|
46
|
+
const [list, position] = String(ctx.flags.of).split(":");
|
|
47
|
+
const steps = (list ?? "").split(",");
|
|
48
|
+
if (steps.some((s) => s === "") || !["next", "current", "count"].includes(position ?? ""))
|
|
49
|
+
throw new CommandError(EXIT.USAGE, "--of must be <step>[,<step>...]:<next|current|count>");
|
|
50
|
+
if (steps.length > 1 && (position !== "count" || new Set(steps).size !== steps.length))
|
|
51
|
+
throw new CommandError(EXIT.USAGE, "--of with several steps takes distinct steps and :count");
|
|
46
52
|
if (ctx.flags.file === undefined || ctx.flags.workflow === undefined)
|
|
47
53
|
throw new CommandError(EXIT.USAGE, "--of needs --file and --workflow");
|
|
48
|
-
const
|
|
54
|
+
const runs = readRuns(statusFile(ctx));
|
|
55
|
+
const subPlan = positiveInt(ctx.flags.subPlan, "sub-plan");
|
|
56
|
+
const count = steps.reduce((n, step) => n +
|
|
57
|
+
activeDoneSteps(runs, String(ctx.flags.workflow), { step, subPlan }, str(ctx.flags.since))
|
|
58
|
+
.length, 0);
|
|
49
59
|
if (position === "current" && count === 0)
|
|
50
|
-
throw new CommandError(EXIT_NO_OWN_ROW, `${
|
|
60
|
+
throw new CommandError(EXIT_NO_OWN_ROW, `${steps[0]}: no DONE row in the active run — the step's own row is missing`);
|
|
51
61
|
return position === "next" ? count + 1 : count;
|
|
52
62
|
}
|
|
53
63
|
function threshold(name) {
|
|
@@ -121,7 +131,7 @@ export const countersCommand = {
|
|
|
121
131
|
{
|
|
122
132
|
name: "of",
|
|
123
133
|
type: "string",
|
|
124
|
-
help: "<step>:<next|current|count> — derive the value from --file (active run)",
|
|
134
|
+
help: "<step>:<next|current|count> — derive the value from --file (active run); <step>,<step>...:count sums the listed steps",
|
|
125
135
|
},
|
|
126
136
|
{ ...FILE_FLAG, required: false, help: "status.jsonl, with --of" },
|
|
127
137
|
{ ...WORKFLOW_FLAG, required: false, help: "workflow, with --of" },
|
|
@@ -47,6 +47,23 @@ export function logged(root, issue) {
|
|
|
47
47
|
}
|
|
48
48
|
return [...found].sort();
|
|
49
49
|
}
|
|
50
|
+
/**
|
|
51
|
+
* The canonical design doc for a feature, `docs/plans/{YYYYMM}/{fid}-design.md`: the
|
|
52
|
+
* `month` bucket first, else the newest bucket holding one. null when none exists.
|
|
53
|
+
*/
|
|
54
|
+
export function designDoc(root, fid, month) {
|
|
55
|
+
const plans = path.join(root, "docs", "plans");
|
|
56
|
+
if (!fs.existsSync(plans))
|
|
57
|
+
return null;
|
|
58
|
+
const at = (m) => fs.existsSync(path.join(plans, m, `${fid}-design.md`));
|
|
59
|
+
const months = fs
|
|
60
|
+
.readdirSync(plans)
|
|
61
|
+
.filter((m) => /^[0-9]{6}$/.test(m))
|
|
62
|
+
.sort()
|
|
63
|
+
.reverse();
|
|
64
|
+
const hit = month !== undefined && months.includes(month) && at(month) ? month : months.find(at);
|
|
65
|
+
return hit === undefined ? null : { month: hit, path: `docs/plans/${hit}/${fid}-design.md` };
|
|
66
|
+
}
|
|
50
67
|
/** `package.json` `bkit.issueTracker` at the main checkout (cwd outside git); default `none`. */
|
|
51
68
|
export function readIssueTracker(cwd) {
|
|
52
69
|
const common = git(cwd, ["rev-parse", "--path-format=absolute", "--git-common-dir"]);
|
|
@@ -195,6 +212,28 @@ export const fidsCommand = {
|
|
|
195
212
|
return EXIT.OK;
|
|
196
213
|
},
|
|
197
214
|
},
|
|
215
|
+
design: {
|
|
216
|
+
summary: "The feature's own design doc, docs/plans/{YYYYMM}/{FID}-design.md: exit 0 found, exit 1 none.",
|
|
217
|
+
flags: [
|
|
218
|
+
{ name: "fid", type: "string", required: true, help: "feature id" },
|
|
219
|
+
{
|
|
220
|
+
name: "month",
|
|
221
|
+
type: "string",
|
|
222
|
+
help: "YYYYMM bucket checked first; else the newest bucket holding the doc",
|
|
223
|
+
},
|
|
224
|
+
],
|
|
225
|
+
output: {
|
|
226
|
+
fid: "the FID when its design doc exists, else null",
|
|
227
|
+
month: "the bucket holding it, else null",
|
|
228
|
+
path: "repo-relative path, else null",
|
|
229
|
+
},
|
|
230
|
+
run: (ctx) => {
|
|
231
|
+
const fid = String(ctx.flags.fid);
|
|
232
|
+
const hit = designDoc(repoRoot(ctx.cwd), fid, str(ctx.flags.month));
|
|
233
|
+
ctx.emit(hit ? { fid, month: hit.month, path: hit.path } : { fid: null, month: null, path: null });
|
|
234
|
+
return hit ? EXIT.OK : EXIT.NO;
|
|
235
|
+
},
|
|
236
|
+
},
|
|
198
237
|
find: {
|
|
199
238
|
summary: "The feature already logged for an issue: exit 0 one, exit 1 none, exit 4 several.",
|
|
200
239
|
flags: [
|
|
@@ -68,7 +68,9 @@ function gitRaw(cwd, args) {
|
|
|
68
68
|
env: gitEnv(),
|
|
69
69
|
maxBuffer: 1 << 28,
|
|
70
70
|
});
|
|
71
|
-
|
|
71
|
+
// A spawn error is never a success: the child can exit 0 before ENOBUFS kills it.
|
|
72
|
+
const status = res.error && res.status === 0 ? 1 : res.status;
|
|
73
|
+
return { status, stdout: res.stdout ?? "", stderr: (res.stderr ?? "").trim() };
|
|
72
74
|
}
|
|
73
75
|
const nulList = (out) => out.split("\0").filter((p) => p !== "");
|
|
74
76
|
function requireRepo(root) {
|
|
@@ -10,7 +10,7 @@ import * as fs from "node:fs";
|
|
|
10
10
|
import * as path from "node:path";
|
|
11
11
|
import { readBkitConfig } from "../../shared/settings.js";
|
|
12
12
|
import { appendLine, statusTimestamp } from "../../ledgers/status.js";
|
|
13
|
-
import { bodySkipToken, CommandError, EXIT, ghUnavailable, git, parseJson, repoRoot, runGh, runGit, SKIP_CI_TOKEN, } from "../lib.js";
|
|
13
|
+
import { bodySkipToken, CommandError, DEV, EXIT, ghUnavailable, git, isSharedBranch, parseJson, repoRoot, runGh, runGit, SKIP_CI_TOKEN, } from "../lib.js";
|
|
14
14
|
import { AUTO_LABEL, AUTO_ROUTE_SUFFIX } from "./issues.js";
|
|
15
15
|
import { EXIT_NO_STATUS, FILE_FLAG, readStatusRows, statusFile, str } from "./status.js";
|
|
16
16
|
// ---------------------------------------------------------------------------
|
|
@@ -161,9 +161,9 @@ export function openPrFor(cwd, o, log) {
|
|
|
161
161
|
log(`refusing: PR title carries the CI-suppressing token ${token[0]} — CI would never run`);
|
|
162
162
|
return { code: EXIT_SKIP_CI_TITLE, out: null };
|
|
163
163
|
}
|
|
164
|
-
const base = refFlag(o.base ??
|
|
164
|
+
const base = refFlag(o.base ?? DEV, "base");
|
|
165
165
|
const head = o.head === undefined ? currentBranch(cwd) : refFlag(o.head, "head");
|
|
166
|
-
if (head === base || head
|
|
166
|
+
if (head === base || isSharedBranch(head)) {
|
|
167
167
|
throw new CommandError(EXIT.USAGE, `refusing to open a PR from "${head}" into "${base}"`);
|
|
168
168
|
}
|
|
169
169
|
let plan = o.plan;
|
|
@@ -4,12 +4,13 @@
|
|
|
4
4
|
// `owner/repo` comes from `gh repo view`; when gh is missing, unauthed, or
|
|
5
5
|
// answers nothing, from the `origin` remote URL instead (the MCP fallback the
|
|
6
6
|
// workflows already describe: "parse git remote"). The current branch, how far it
|
|
7
|
-
// trails `origin/dev`, the main checkout,
|
|
8
|
-
//
|
|
7
|
+
// trails `origin/dev`, the main checkout, the bkit binary every later block calls,
|
|
8
|
+
// and whether that bkit is behind the newest release ride along so Step 1 is one call.
|
|
9
9
|
import * as fs from "node:fs";
|
|
10
10
|
import * as path from "node:path";
|
|
11
11
|
import { parseRemoteUrlToSlug } from "../../ledgers/telemetry.js";
|
|
12
|
-
import { EXIT, git, repoRoot, runGit, runTool } from "../lib.js";
|
|
12
|
+
import { DEV, EXIT, git, repoRoot, runGit, runTool } from "../lib.js";
|
|
13
|
+
import { bkitVersionStatus } from "../../shared/bkit-latest.js";
|
|
13
14
|
/** Exit code: neither gh nor the origin remote named an owner/repo. */
|
|
14
15
|
export const EXIT_NO_REPO = 3;
|
|
15
16
|
/** Exit code: HEAD is detached, so there is no current branch (and --allow-detached was not given). */
|
|
@@ -107,6 +108,10 @@ export const repoCommand = {
|
|
|
107
108
|
repoRoot: "the main checkout (the same from any worktree)",
|
|
108
109
|
bkit: "the bkit binary the workflow blocks call: <repoRoot>/node_modules/.bin/bkit, else `bkit` on PATH",
|
|
109
110
|
outboxRoot: "<git common dir>/bkit-outbox: per-run scratch files, never committed",
|
|
111
|
+
bkitVersion: ".bkit/version pinnedVersion: the release this repo's bkit files came from (null when unpinned)",
|
|
112
|
+
bkitLatest: "newest published @cbartens/bkit, asked at most once a day (null when offline, opted out via BKIT_NO_UPDATE_CHECK, or unpinned)",
|
|
113
|
+
bkitOutdated: "true when bkitVersion is older than bkitLatest (null when either is unknown)",
|
|
114
|
+
bkitAdvisory: "one line to show the user when bkitOutdated, else null",
|
|
110
115
|
},
|
|
111
116
|
exitCodes: {
|
|
112
117
|
[EXIT_NO_REPO]: "neither gh nor the origin remote named an owner/repo",
|
|
@@ -114,7 +119,7 @@ export const repoCommand = {
|
|
|
114
119
|
},
|
|
115
120
|
run: (ctx) => {
|
|
116
121
|
if (ctx.flags.fetch === true) {
|
|
117
|
-
const res = runGit(ctx.cwd, ["fetch", "origin",
|
|
122
|
+
const res = runGit(ctx.cwd, ["fetch", "origin", DEV]);
|
|
118
123
|
if (!res.ok)
|
|
119
124
|
ctx.log(`git fetch origin dev failed — behindDev is as of the last fetch: ${res.stderr}`);
|
|
120
125
|
}
|
|
@@ -136,6 +141,9 @@ export const repoCommand = {
|
|
|
136
141
|
}
|
|
137
142
|
const root = repoRoot(ctx.cwd);
|
|
138
143
|
const common = git(ctx.cwd, ["rev-parse", "--path-format=absolute", "--git-common-dir"]);
|
|
144
|
+
const latest = bkitVersionStatus(root, common);
|
|
145
|
+
if (latest.advisory !== null)
|
|
146
|
+
ctx.log(latest.advisory);
|
|
139
147
|
ctx.emit({
|
|
140
148
|
...resolved,
|
|
141
149
|
owner,
|
|
@@ -145,6 +153,10 @@ export const repoCommand = {
|
|
|
145
153
|
repoRoot: root,
|
|
146
154
|
bkit: resolveBkitBinary(root),
|
|
147
155
|
outboxRoot: path.join(common ?? path.join(root, ".git"), "bkit-outbox"),
|
|
156
|
+
bkitVersion: latest.version,
|
|
157
|
+
bkitLatest: latest.latest,
|
|
158
|
+
bkitOutdated: latest.outdated,
|
|
159
|
+
bkitAdvisory: latest.advisory,
|
|
148
160
|
});
|
|
149
161
|
if (branch === null && ctx.flags.allowDetached !== true) {
|
|
150
162
|
ctx.log("HEAD is detached — no current branch");
|
|
@@ -18,7 +18,7 @@ import * as fs from "node:fs";
|
|
|
18
18
|
import * as path from "node:path";
|
|
19
19
|
import { compareTs, parse, resolveRepoSlug, validate } from "../../ledgers/telemetry.js";
|
|
20
20
|
import { readBkitVersion } from "../../install/version-file.js";
|
|
21
|
-
import { CommandError, EXIT, git, parseJson, repoRoot, runGit, } from "../lib.js";
|
|
21
|
+
import { CommandError, DEV, EXIT, git, parseJson, repoRoot, runGit, } from "../lib.js";
|
|
22
22
|
import { acquireDevLock, releaseLock } from "./locks.js";
|
|
23
23
|
import { str } from "./status.js";
|
|
24
24
|
/** Roadmap status each workflow's close moves the feature to. */
|
|
@@ -374,8 +374,8 @@ async function mirror(ctx) {
|
|
|
374
374
|
}
|
|
375
375
|
try {
|
|
376
376
|
const prior = git(root, ["branch", "--show-current"]) ?? "";
|
|
377
|
-
if (!runGit(root, ["checkout",
|
|
378
|
-
!runGit(root, ["pull", "--ff-only", "origin",
|
|
377
|
+
if (!runGit(root, ["checkout", DEV]).ok ||
|
|
378
|
+
!runGit(root, ["pull", "--ff-only", "origin", DEV]).ok) {
|
|
379
379
|
if (prior)
|
|
380
380
|
runGit(root, ["checkout", prior]);
|
|
381
381
|
return done(false, "dev checkout / pull failed");
|
|
@@ -392,7 +392,7 @@ async function mirror(ctx) {
|
|
|
392
392
|
"--",
|
|
393
393
|
...ROADMAP_FILES,
|
|
394
394
|
]);
|
|
395
|
-
const pushed = runGit(root, ["push", "origin",
|
|
395
|
+
const pushed = runGit(root, ["push", "origin", DEV]).ok;
|
|
396
396
|
if (!pushed)
|
|
397
397
|
ctx.log("dev push failed — feat-side row already written");
|
|
398
398
|
if (prior)
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
import * as fs from "node:fs";
|
|
23
23
|
import * as path from "node:path";
|
|
24
24
|
import { statusTimestamp } from "../../ledgers/status.js";
|
|
25
|
-
import { bodySkipToken, commitMessage, CommandError, EXIT, git, parseJson, runGh, runGit, SKIP_CI_TOKEN, } from "../lib.js";
|
|
25
|
+
import { bodySkipToken, commitMessage, CommandError, DEV, EXIT, git, isSharedBranch, parseJson, runGh, runGit, SKIP_CI_TOKEN, } from "../lib.js";
|
|
26
26
|
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";
|
|
@@ -171,7 +171,7 @@ function currentPr(cwd, gh) {
|
|
|
171
171
|
const branch = git(cwd, ["branch", "--show-current"]);
|
|
172
172
|
if (!branch)
|
|
173
173
|
return { pr: null, missing: false };
|
|
174
|
-
const res = gh(["pr", "list", "--head", branch, "--base",
|
|
174
|
+
const res = gh(["pr", "list", "--head", branch, "--base", DEV, "--json", "number"]);
|
|
175
175
|
if (res.missing)
|
|
176
176
|
return { pr: null, missing: true };
|
|
177
177
|
const n = obj(arr(res.ok ? jsonOrUndefined(res.stdout) : undefined)[0]).number;
|
|
@@ -184,7 +184,7 @@ function pushCurrentBranch(cwd) {
|
|
|
184
184
|
if (!branch)
|
|
185
185
|
return false;
|
|
186
186
|
// Shared branches never force; a feature branch is rewritten only by this run.
|
|
187
|
-
const args = branch
|
|
187
|
+
const args = isSharedBranch(branch)
|
|
188
188
|
? ["push", "origin", branch]
|
|
189
189
|
: ["push", "--force-with-lease", "origin", branch];
|
|
190
190
|
return runGit(cwd, args).ok;
|
|
@@ -1324,7 +1324,7 @@ async function runContext(ctx) {
|
|
|
1324
1324
|
mode: "CI_DEV",
|
|
1325
1325
|
fid: arg,
|
|
1326
1326
|
issueId: tracker === "none" ? null : issueIdOf(arg, "any"),
|
|
1327
|
-
branch:
|
|
1327
|
+
branch: DEV,
|
|
1328
1328
|
headSha: git(ctx.cwd, ["rev-parse", "origin/dev"]) ?? "",
|
|
1329
1329
|
});
|
|
1330
1330
|
return EXIT.OK;
|
|
@@ -1395,7 +1395,7 @@ async function runContext(ctx) {
|
|
|
1395
1395
|
async function runMirror(ctx) {
|
|
1396
1396
|
const f = ctx.flags;
|
|
1397
1397
|
const head = String(f.head);
|
|
1398
|
-
const branch = str(f.branch) ??
|
|
1398
|
+
const branch = str(f.branch) ?? DEV;
|
|
1399
1399
|
if (!branch)
|
|
1400
1400
|
throw new CommandError(EXIT.USAGE, "--branch must not be empty");
|
|
1401
1401
|
const o = {
|
|
@@ -242,6 +242,7 @@ export const ROW_FIELDS = {
|
|
|
242
242
|
"build/build-summary": ["attempt"],
|
|
243
243
|
"debug/debug-run-tests": ["attempt", "scope"],
|
|
244
244
|
"debug/context-fetch": ["attempt"],
|
|
245
|
+
"debug/debug-failure-reproduce": ["attempt"],
|
|
245
246
|
"debug/debug-failure-diagnose": ["attempt", "strategy"],
|
|
246
247
|
"debug/debug-failure-remediate": ["attempt", "strategy"],
|
|
247
248
|
"debug/debug-failure-soak": ["attempt"],
|
|
@@ -491,6 +491,11 @@ export const testsCommand = {
|
|
|
491
491
|
repeatable: true,
|
|
492
492
|
help: "candidate plan file; the first that exists is audited",
|
|
493
493
|
},
|
|
494
|
+
{
|
|
495
|
+
name: "brief",
|
|
496
|
+
type: "string",
|
|
497
|
+
help: "the build input, audited when no plan file exists and it carries `**Task N:**` lines with `Test first:`",
|
|
498
|
+
},
|
|
494
499
|
{
|
|
495
500
|
name: "log",
|
|
496
501
|
type: "string",
|
|
@@ -501,7 +506,7 @@ export const testsCommand = {
|
|
|
501
506
|
output: {
|
|
502
507
|
enforced: "false when there is nothing to audit (reason says why)",
|
|
503
508
|
reason: "why test-first is not enforced",
|
|
504
|
-
plan: "the plan file audited",
|
|
509
|
+
plan: "the plan file audited (the brief when no plan file exists and it carries Test first lines)",
|
|
505
510
|
gaps: "[{task, kind, detail}]: no-test-first | test-first-malformed | no-red | red-mismatch | red-evidence-missing | test-changed | not-green",
|
|
506
511
|
log: "where the report was written (as given)",
|
|
507
512
|
},
|
|
@@ -516,14 +521,22 @@ export const testsCommand = {
|
|
|
516
521
|
throw new CommandError(EXIT.USAGE, "--log must be non-empty");
|
|
517
522
|
const log = path.resolve(ctx.cwd, logArg);
|
|
518
523
|
const top = toplevel(ctx.cwd);
|
|
519
|
-
const
|
|
524
|
+
const exists = (p) => fs.existsSync(path.resolve(ctx.cwd, p));
|
|
525
|
+
const planFile = ctx.flags.plan.find(exists);
|
|
526
|
+
const briefArg = str(ctx.flags.brief);
|
|
527
|
+
const brief = planFile === undefined && briefArg !== undefined && exists(briefArg)
|
|
528
|
+
? briefArg
|
|
529
|
+
: undefined;
|
|
530
|
+
const plan = planFile ?? brief;
|
|
520
531
|
const specs = plan
|
|
521
532
|
? readTestFirst(fs.readFileSync(path.resolve(ctx.cwd, plan), "utf-8"))
|
|
522
533
|
: [];
|
|
523
534
|
const reason = plan === undefined
|
|
524
535
|
? "no plan file — the build runs from its brief"
|
|
525
536
|
: !specs.some((s) => s.kind !== "missing")
|
|
526
|
-
?
|
|
537
|
+
? brief !== undefined
|
|
538
|
+
? "no plan file, and the brief has no `**Task N:**` lines with `Test first:`"
|
|
539
|
+
: "the plan has no `Test first:` lines"
|
|
527
540
|
: resolveGate(top, [BKIT_TEST_FILE_SCRIPT]) === null
|
|
528
541
|
? `\`${BKIT_TEST_FILE_SCRIPT}\` is not declared in package.json`
|
|
529
542
|
: undefined;
|
|
@@ -24,8 +24,8 @@ import { appendLine as telemetryLine, foldFrom, resolveRepoSlug, validate, workf
|
|
|
24
24
|
import { readBkitVersion } from "../../install/version-file.js";
|
|
25
25
|
import { TIMEOUTS } from "../../shared/timeouts.js";
|
|
26
26
|
import { gradeCompliance } from "../comply.js";
|
|
27
|
-
import { CommandError, EXIT, git, parseJson, repoRoot, runGh, runGit, statusLocation, statusRelPath, } from "../lib.js";
|
|
28
|
-
import { pushBranch, readAnchor, stampAnchor } from "./branches.js";
|
|
27
|
+
import { CommandError, DEV, EXIT, git, parseJson, repoRoot, runGh, runGit, statusLocation, statusRelPath, } from "../lib.js";
|
|
28
|
+
import { anchorBkitStatus, pushBranch, readAnchor, stampAnchor } from "./branches.js";
|
|
29
29
|
import { AUTO_LABEL, AUTO_ROUTE_SUFFIX, buildComment, linearState, transitionLabels, } from "./issues.js";
|
|
30
30
|
import { EXIT_EMPTY, commitBookkeeping, unionLedgers } from "./ledgers.js";
|
|
31
31
|
import { EXIT_REMOVE_FAILED, EXIT_SPLIT_BUCKET, acquireDevLock, acquireWorkflowLock, lockRoot, owns, readHolder, releaseLock, resolveMonth, workflowLockPath, } from "./locks.js";
|
|
@@ -261,15 +261,15 @@ async function shipFlush(ctx, o) {
|
|
|
261
261
|
return { code: EXIT.OK, pushed: false, ref: null, skipped: "dev-lock-busy" };
|
|
262
262
|
}
|
|
263
263
|
release = () => releaseLock(lock.path, { workflow: "ship", fid: o.fid, token: lock.token });
|
|
264
|
-
runGit(root, ["checkout",
|
|
265
|
-
if (git(root, ["branch", "--show-current"]) !==
|
|
264
|
+
runGit(root, ["checkout", DEV]);
|
|
265
|
+
if (git(root, ["branch", "--show-current"]) !== DEV) {
|
|
266
266
|
release();
|
|
267
267
|
ctx.log(`not on dev after checkout — FAILED bookkeeping left uncommitted in ${bookRoot}`);
|
|
268
268
|
return { code: EXIT_FLUSH_FAILED, pushed: false, ref: null, skipped: null };
|
|
269
269
|
}
|
|
270
|
-
runGit(root, ["pull", "--ff-only", "origin",
|
|
270
|
+
runGit(root, ["pull", "--ff-only", "origin", DEV]);
|
|
271
271
|
wt = root;
|
|
272
|
-
target =
|
|
272
|
+
target = DEV;
|
|
273
273
|
}
|
|
274
274
|
else {
|
|
275
275
|
ctx.log("RUNTIME_DEVPUSHES=false — the FAILED record commits on the current branch");
|
|
@@ -615,7 +615,7 @@ export function closeWorkflow(cwd, o, log) {
|
|
|
615
615
|
: ["[bkit-telemetry] stats.jsonl not found — no telemetry rows yet"];
|
|
616
616
|
const ref = o.ref ??
|
|
617
617
|
(["design", "plan", "ship"].includes(workflow)
|
|
618
|
-
?
|
|
618
|
+
? DEV
|
|
619
619
|
: (git(cwd, ["branch", "--show-current"]) ?? "HEAD"));
|
|
620
620
|
const artifacts = artifactLinks(where.root, ref, where.month, o.fid, workflow, o.ownerRepo ?? repo);
|
|
621
621
|
let comment = null;
|
|
@@ -698,8 +698,8 @@ async function shipClose(ctx, o, token) {
|
|
|
698
698
|
try {
|
|
699
699
|
let wt;
|
|
700
700
|
if (o.devPushes) {
|
|
701
|
-
runGit(root, ["checkout",
|
|
702
|
-
if (git(root, ["branch", "--show-current"]) !==
|
|
701
|
+
runGit(root, ["checkout", DEV]);
|
|
702
|
+
if (git(root, ["branch", "--show-current"]) !== DEV)
|
|
703
703
|
return fail("not on dev after checkout — aborting dev ops");
|
|
704
704
|
wt = root;
|
|
705
705
|
}
|
|
@@ -712,7 +712,7 @@ async function shipClose(ctx, o, token) {
|
|
|
712
712
|
closeRoot = wt;
|
|
713
713
|
}
|
|
714
714
|
else {
|
|
715
|
-
if (!runGit(wt, ["fetch", "origin",
|
|
715
|
+
if (!runGit(wt, ["fetch", "origin", DEV]).ok)
|
|
716
716
|
return fail(`fetch origin dev failed — close bookkeeping left uncommitted in ${wt}`);
|
|
717
717
|
closeRoot = path.join(outbox, "close");
|
|
718
718
|
if (fs.existsSync(closeRoot))
|
|
@@ -734,11 +734,11 @@ async function shipClose(ctx, o, token) {
|
|
|
734
734
|
if (released.removeFailed)
|
|
735
735
|
return fail("Lock removal failed");
|
|
736
736
|
if (o.devPushes) {
|
|
737
|
-
if (!runGit(closeRoot, ["push", "origin",
|
|
737
|
+
if (!runGit(closeRoot, ["push", "origin", DEV]).ok) {
|
|
738
738
|
ctx.log("dev push failed");
|
|
739
739
|
return { code: EXIT_PUSH_FAILED, out };
|
|
740
740
|
}
|
|
741
|
-
landed = { ref:
|
|
741
|
+
landed = { ref: DEV, via: "dev-push" };
|
|
742
742
|
}
|
|
743
743
|
}
|
|
744
744
|
finally {
|
|
@@ -746,7 +746,7 @@ async function shipClose(ctx, o, token) {
|
|
|
746
746
|
}
|
|
747
747
|
if (!o.devPushes) {
|
|
748
748
|
if (runGit(closeRoot, ["push", "origin", "HEAD:dev"]).ok) {
|
|
749
|
-
landed = { ref:
|
|
749
|
+
landed = { ref: DEV, via: "head-push" };
|
|
750
750
|
}
|
|
751
751
|
else {
|
|
752
752
|
// dev refused the push: publish the close commit through its own PR.
|
|
@@ -758,7 +758,7 @@ async function shipClose(ctx, o, token) {
|
|
|
758
758
|
"pr",
|
|
759
759
|
"create",
|
|
760
760
|
"--base",
|
|
761
|
-
|
|
761
|
+
DEV,
|
|
762
762
|
"--head",
|
|
763
763
|
branch,
|
|
764
764
|
"--title",
|
|
@@ -768,7 +768,7 @@ async function shipClose(ctx, o, token) {
|
|
|
768
768
|
]);
|
|
769
769
|
if (!created.ok)
|
|
770
770
|
return fail(`gh pr create failed: ${created.stderr}`);
|
|
771
|
-
const pr = probePr(closeRoot, { head: branch, base:
|
|
771
|
+
const pr = probePr(closeRoot, { head: branch, base: DEV, state: "open" });
|
|
772
772
|
const number = pr.kind === "ok" ? pr.pr?.number : undefined;
|
|
773
773
|
if (number === undefined)
|
|
774
774
|
return fail(`close PR not found for ${branch}`);
|
|
@@ -807,7 +807,7 @@ export function highestVersion(dir, workflow) {
|
|
|
807
807
|
}
|
|
808
808
|
return best;
|
|
809
809
|
}
|
|
810
|
-
/** Stamp `file`'s anchor when a base commit is known (plan: with its design's own anchor). */
|
|
810
|
+
/** Stamp `file`'s anchor when a base commit is known (plan: with its design's own anchor; both: the bkit release). */
|
|
811
811
|
function stamp(cwd, file, baseSha, design) {
|
|
812
812
|
if (baseSha === "")
|
|
813
813
|
return;
|
|
@@ -817,7 +817,8 @@ function stamp(cwd, file, baseSha, design) {
|
|
|
817
817
|
? { path: design, baseSha: readAnchor(fs.readFileSync(designAbs, "utf-8")).baseSha ?? "" }
|
|
818
818
|
: undefined;
|
|
819
819
|
const tmp = `${abs}.bkit-anchor.tmp`;
|
|
820
|
-
|
|
820
|
+
const text = fs.readFileSync(abs, "utf-8");
|
|
821
|
+
fs.writeFileSync(tmp, stampAnchor(text, baseSha, d, undefined, anchorBkitStatus(cwd)));
|
|
821
822
|
fs.renameSync(tmp, abs);
|
|
822
823
|
}
|
|
823
824
|
function promoteVerb(ctx) {
|
|
@@ -1316,7 +1317,7 @@ export const workflowsCommand = {
|
|
|
1316
1317
|
const fid = String(ctx.flags.fid);
|
|
1317
1318
|
const root = repoRoot(ctx.cwd);
|
|
1318
1319
|
const month = resolveMonth(root, fid, str(ctx.flags.month));
|
|
1319
|
-
const artifacts = artifactLinks(root, str(ctx.flags.ref) ??
|
|
1320
|
+
const artifacts = artifactLinks(root, str(ctx.flags.ref) ?? DEV, month, fid, workflow, str(ctx.flags.ownerRepo) ?? (resolveRepoSlug(root) || "unknown/repo"));
|
|
1320
1321
|
let comment = null;
|
|
1321
1322
|
const outbox = str(ctx.flags.outbox);
|
|
1322
1323
|
if (outbox !== undefined) {
|
|
@@ -70,7 +70,7 @@ export function parseWorkstreams(md) {
|
|
|
70
70
|
}
|
|
71
71
|
/** `[]` or `[WS-1, WS-2]`. */
|
|
72
72
|
export const requiresList = (w) => `[${w.requires.join(", ")}]`;
|
|
73
|
-
/** The Step 11 comment: one line per workstream, then the design doc link. */
|
|
73
|
+
/** The Step 11 comment: one line per workstream, the issue-body line, then the design doc link. */
|
|
74
74
|
export function commentBody(ws, opts) {
|
|
75
75
|
const doc = `docs/plans/${opts.month}/${opts.fid}-design.md`;
|
|
76
76
|
return [
|
|
@@ -78,6 +78,7 @@ export function commentBody(ws, opts) {
|
|
|
78
78
|
"### Step 11 — Suggested Workstreams",
|
|
79
79
|
"Advisory only. NEVER auto-trigger.",
|
|
80
80
|
...ws.map((w) => `- ${w.id}: ${w.name}. Requires: ${requiresList(w)}`),
|
|
81
|
+
`Filing one issue per workstream: put \`**Parent design:** [${opts.fid}-design.md](${doc})\` in its body, and list the issues it requires in a blocked-by block (.bkit/trackers.md § Issue shapes).`,
|
|
81
82
|
`[${doc}](https://github.com/${opts.ownerRepo}/blob/dev/${doc})`,
|
|
82
83
|
].join("\n");
|
|
83
84
|
}
|