@cbartens/bkit 5.2.4 → 5.4.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 +27 -11
- 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 +18 -1
- package/.bkit/core/.bkit/README.md +26 -10
- package/.bkit/core/.bkit/cloud.md +40 -39
- package/.bkit/core/.bkit/comparison.md +68 -345
- package/.bkit/core/.bkit/install.md +16 -9
- package/.bkit/core/.bkit/lite.md +73 -0
- package/.bkit/core/.bkit/pipeline.md +346 -0
- package/.bkit/core/.bkit/prompts.md +90 -74
- package/.bkit/core/.bkit/providers.md +42 -23
- package/.bkit/core/.bkit/templates.md +138 -19
- package/.bkit/core/.bkit/trackers.md +49 -4
- package/.bkit/core/.bkit/workflows.md +144 -123
- 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 +3 -2
- package/.bkit/core/docs/templates/bkit-audit-adoption.md +2 -2
- 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 +4 -2
- package/.bkit/core/docs/templates/bkit-audit-config.md +3 -2
- package/.bkit/core/docs/templates/bkit-audit-cost.md +3 -2
- package/.bkit/core/docs/templates/bkit-audit-coverage.md +1 -1
- package/.bkit/core/docs/templates/bkit-audit-database.md +3 -2
- package/.bkit/core/docs/templates/bkit-audit-dead-code.md +5 -5
- package/.bkit/core/docs/templates/bkit-audit-deferrals.md +1 -1
- package/.bkit/core/docs/templates/bkit-audit-dependencies.md +26 -21
- package/.bkit/core/docs/templates/bkit-audit-documentation.md +1 -1
- package/.bkit/core/docs/templates/bkit-audit-duplication.md +2 -2
- package/.bkit/core/docs/templates/bkit-audit-failures.md +1 -1
- package/.bkit/core/docs/templates/bkit-audit-flakes.md +3 -2
- package/.bkit/core/docs/templates/bkit-audit-gates.md +5 -2
- package/.bkit/core/docs/templates/bkit-audit-issues.md +3 -2
- package/.bkit/core/docs/templates/bkit-audit-llm.md +22 -15
- package/.bkit/core/docs/templates/bkit-audit-logs.md +10 -6
- package/.bkit/core/docs/templates/bkit-audit-models.md +1 -1
- package/.bkit/core/docs/templates/bkit-audit-privacy.md +1 -1
- package/.bkit/core/docs/templates/bkit-audit-prompts.md +7 -7
- package/.bkit/core/docs/templates/bkit-audit-red-team.md +12 -9
- 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 +14 -12
- package/.bkit/core/docs/templates/bkit-audit-slop.md +1 -1
- package/.bkit/core/docs/templates/bkit-audit-testing.md +10 -8
- package/.bkit/core/docs/templates/bkit-audit-usability.md +1 -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 -6
- package/.bkit/core/engine/checks/tips/catalogue.ts +76 -24
- package/.bkit/core/engine/checks/tips/detect.ts +45 -2
- package/.bkit/core/engine/checks/tips/index.ts +77 -26
- package/.bkit/core/engine/cli.ts +57 -27
- package/.bkit/core/engine/commands/analysis.ts +36 -26
- package/.bkit/core/engine/commands/comply.ts +42 -32
- 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 +73 -130
- package/.bkit/core/engine/commands/install/uninstall.ts +191 -33
- package/.bkit/core/engine/commands/install/upgrade.ts +49 -43
- package/.bkit/core/engine/commands/land.ts +156 -0
- package/.bkit/core/engine/commands/lib.ts +45 -18
- package/.bkit/core/engine/commands/registry.ts +2 -0
- package/.bkit/core/engine/commands/tips.ts +12 -5
- package/.bkit/core/engine/commands/workflow/branches.ts +386 -286
- package/.bkit/core/engine/commands/workflow/counters.ts +21 -12
- package/.bkit/core/engine/commands/workflow/disk.ts +556 -0
- package/.bkit/core/engine/commands/workflow/fids.ts +46 -0
- package/.bkit/core/engine/commands/workflow/issues.ts +73 -28
- package/.bkit/core/engine/commands/workflow/ledgers.ts +3 -1
- package/.bkit/core/engine/commands/workflow/locks.ts +38 -152
- package/.bkit/core/engine/commands/workflow/prs.ts +15 -4
- package/.bkit/core/engine/commands/workflow/repo.ts +2 -2
- package/.bkit/core/engine/commands/workflow/roadmap.ts +49 -53
- package/.bkit/core/engine/commands/workflow/runs.ts +8 -7
- package/.bkit/core/engine/commands/workflow/runtime.ts +3 -2
- package/.bkit/core/engine/commands/workflow/status.ts +33 -11
- package/.bkit/core/engine/commands/workflow/steps.ts +25 -15
- package/.bkit/core/engine/commands/workflow/tests.ts +17 -5
- package/.bkit/core/engine/commands/workflow/workflows.ts +436 -267
- package/.bkit/core/engine/commands/workflow/workstreams.ts +4 -2
- package/.bkit/core/engine/commands/workflow/worktrees.ts +24 -6
- 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 +106 -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 +16 -35
- 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/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 +44 -0
- package/.bkit/core/engine/shared/timeouts.ts +8 -7
- 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 +103 -7
- 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-auto.md +2 -2
- package/.bkit/core/workflows/bkit-build.md +10 -10
- package/.bkit/core/workflows/bkit-debug.md +80 -44
- package/.bkit/core/workflows/bkit-design.md +22 -13
- package/.bkit/core/workflows/bkit-plan.md +33 -16
- package/.bkit/core/workflows/bkit-ship.md +87 -98
- package/.bkit/shared/.claude/bkit-cloud.md +58 -25
- package/.bkit/shared/.claude/settings.json +19 -0
- package/.bkit/shared/.cursor/mcp.json +2 -1
- package/.bkit/shared/.opencode/opencode.json +19 -1
- package/.bkit/shared/docs/deployments.md +49 -29
- package/.bkit/shared/docs/security.md +8 -6
- package/.bkit/shared/docs/testing.md +9 -5
- package/.bkit/shared/gitignore +1 -2
- 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 +73 -55
- 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-commit +6 -0
- package/.bkit/templates/.husky/pre-push +15 -3
- package/.bkit/templates/.lintstagedrc.json +5 -1
- 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-disk-prune.machine.mjs +197 -0
- package/.bkit/templates/scripts/cleanup/bkit-disk-prune.mjs +164 -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 +98 -3
- package/README.md +252 -122
- 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 -7
- package/dist/checks/tips/catalogue.js +65 -18
- package/dist/checks/tips/detect.js +41 -2
- package/dist/checks/tips/index.js +61 -25
- package/dist/cli.js +52 -26
- package/dist/commands/analysis.js +21 -5
- package/dist/commands/comply.js +40 -31
- package/dist/commands/harvest.js +12 -13
- package/dist/commands/install/doctor.js +55 -23
- package/dist/commands/install/install.js +72 -122
- package/dist/commands/install/uninstall.js +165 -31
- package/dist/commands/install/upgrade.js +46 -39
- package/dist/commands/land.js +129 -0
- package/dist/commands/lib.js +41 -16
- package/dist/commands/registry.js +2 -0
- package/dist/commands/tips.js +10 -3
- package/dist/commands/workflow/branches.js +303 -248
- package/dist/commands/workflow/counters.js +17 -7
- package/dist/commands/workflow/disk.js +452 -0
- package/dist/commands/workflow/fids.js +39 -0
- package/dist/commands/workflow/issues.js +63 -27
- package/dist/commands/workflow/ledgers.js +3 -1
- package/dist/commands/workflow/locks.js +35 -130
- package/dist/commands/workflow/prs.js +8 -5
- package/dist/commands/workflow/repo.js +2 -2
- package/dist/commands/workflow/roadmap.js +50 -57
- package/dist/commands/workflow/runs.js +5 -5
- package/dist/commands/workflow/runtime.js +3 -2
- package/dist/commands/workflow/status.js +32 -12
- package/dist/commands/workflow/steps.js +19 -11
- package/dist/commands/workflow/tests.js +16 -3
- package/dist/commands/workflow/workflows.js +390 -249
- package/dist/commands/workflow/workstreams.js +4 -2
- package/dist/commands/workflow/worktrees.js +15 -6
- 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 +95 -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 +16 -35
- 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/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 +23 -1
- package/dist/shared/timeouts.js +8 -7
- package/package.json +21 -17
- package/.bkit/core/.agents/shortcuts.md +0 -73
|
@@ -125,7 +125,16 @@ function textVerb(ctx) {
|
|
|
125
125
|
// labels
|
|
126
126
|
// ---------------------------------------------------------------------------
|
|
127
127
|
/** Mutually exclusive: setting one drops the others. */
|
|
128
|
-
export const PHASE_LABELS = [
|
|
128
|
+
export const PHASE_LABELS = [
|
|
129
|
+
"bkit:design",
|
|
130
|
+
"bkit:plan",
|
|
131
|
+
"bkit:build",
|
|
132
|
+
"bkit:debug",
|
|
133
|
+
"bkit:ship",
|
|
134
|
+
"bkit:merged",
|
|
135
|
+
];
|
|
136
|
+
/** Prefix of the labels naming an issue's next best workflow; setting a phase drops them. */
|
|
137
|
+
export const NEXT_LABEL_PREFIX = "next:";
|
|
129
138
|
/** The issue label that opts a feature into CI auto-routing. */
|
|
130
139
|
export const AUTO_LABEL = "bkit:auto";
|
|
131
140
|
/** Commit-subject suffix the CI auto-route gate matches; carried only while the issue has `AUTO_LABEL`. */
|
|
@@ -145,12 +154,15 @@ export function transitionLabels(current, t) {
|
|
|
145
154
|
for (const l of have)
|
|
146
155
|
if (PHASE_LABELS.includes(l) && l !== label)
|
|
147
156
|
remove.add(l);
|
|
157
|
+
for (const l of have)
|
|
158
|
+
if (l.startsWith(NEXT_LABEL_PREFIX))
|
|
159
|
+
remove.add(l);
|
|
148
160
|
want(label, true);
|
|
149
161
|
}
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
if (
|
|
153
|
-
want("bkit:
|
|
162
|
+
// A phase starting supersedes any earlier Failure Path.
|
|
163
|
+
const failed = t.failed ?? (t.phase !== undefined ? false : undefined);
|
|
164
|
+
if (failed !== undefined)
|
|
165
|
+
want("bkit:failed", failed);
|
|
154
166
|
return {
|
|
155
167
|
add,
|
|
156
168
|
remove: [...remove],
|
|
@@ -159,11 +171,11 @@ export function transitionLabels(current, t) {
|
|
|
159
171
|
}
|
|
160
172
|
/**
|
|
161
173
|
* Linear's issue state for the same transition, as the workflows set it: a
|
|
162
|
-
* shipped
|
|
174
|
+
* shipped or failed issue waits on a human ("In Review"); a phase
|
|
163
175
|
* starting is "In Progress". Null when the transition sets no state.
|
|
164
176
|
*/
|
|
165
177
|
export function linearState(t, board) {
|
|
166
|
-
if (t.phase === "merged" || t.failed === true
|
|
178
|
+
if (t.phase === "merged" || t.failed === true)
|
|
167
179
|
return "In Review";
|
|
168
180
|
if (t.phase !== undefined)
|
|
169
181
|
return "In Progress";
|
|
@@ -253,21 +265,16 @@ function boardPayload(ctx, status) {
|
|
|
253
265
|
function labelsVerb(ctx) {
|
|
254
266
|
const phase = str(ctx.flags.phase);
|
|
255
267
|
if (phase !== undefined && !PHASE_LABELS.includes(`bkit:${phase}`)) {
|
|
256
|
-
throw new CommandError(EXIT.USAGE, "--phase must be design, plan, build, ship, or merged");
|
|
257
|
-
}
|
|
258
|
-
let failed = onOff(ctx.flags.failed, "failed");
|
|
259
|
-
const debug = onOff(ctx.flags.debug, "debug");
|
|
260
|
-
// A merged issue must not keep a stale Failure Path marker.
|
|
261
|
-
if (phase === "merged") {
|
|
262
|
-
if (failed === true)
|
|
263
|
-
throw new CommandError(EXIT.USAGE, "--phase=merged clears bkit:failed; drop --failed=on");
|
|
264
|
-
failed = false;
|
|
268
|
+
throw new CommandError(EXIT.USAGE, "--phase must be design, plan, build, debug, ship, or merged");
|
|
265
269
|
}
|
|
270
|
+
const failed = onOff(ctx.flags.failed, "failed");
|
|
271
|
+
if (phase !== undefined && failed === true)
|
|
272
|
+
throw new CommandError(EXIT.USAGE, "--phase clears bkit:failed; drop --failed=on");
|
|
266
273
|
const board = str(ctx.flags.board);
|
|
267
274
|
if (board !== undefined && BOARD_OPTION[board] === undefined) {
|
|
268
275
|
throw new CommandError(EXIT.USAGE, "--board must be progress or review");
|
|
269
276
|
}
|
|
270
|
-
const t = { phase, failed
|
|
277
|
+
const t = { phase, failed };
|
|
271
278
|
const { add, remove, labels } = transitionLabels(ctx.flags.label ?? [], t);
|
|
272
279
|
const { board: payload, boardSkipped } = board === undefined ? { board: null, boardSkipped: null } : boardPayload(ctx, board);
|
|
273
280
|
ctx.emit({
|
|
@@ -360,12 +367,33 @@ function links(o) {
|
|
|
360
367
|
const ref = o.ref ?? o.tree;
|
|
361
368
|
if (ref === undefined)
|
|
362
369
|
throw new CommandError(EXIT.USAGE, "--artifact needs --ref (or --tree)");
|
|
363
|
-
for (const a of artifacts)
|
|
364
|
-
|
|
370
|
+
for (const a of artifacts) {
|
|
371
|
+
const hash = a.indexOf("#");
|
|
372
|
+
const file = (hash < 0 ? a : a.slice(0, hash)).replace(/^\/+/, "");
|
|
373
|
+
const heading = hash < 0 ? undefined : a.slice(hash + 1).trim();
|
|
374
|
+
if (heading === "")
|
|
375
|
+
throw new CommandError(EXIT.USAGE, `--artifact "${a}" has an empty #Heading`);
|
|
376
|
+
const url = `${gh}/blob/${ref}/${file}`;
|
|
377
|
+
out.push(heading === undefined
|
|
378
|
+
? `[${path.basename(file)}](${url})`
|
|
379
|
+
: `[${path.basename(file)} § ${heading}](${url}#${headingAnchor(heading)})`);
|
|
380
|
+
}
|
|
365
381
|
}
|
|
366
382
|
return out;
|
|
367
383
|
}
|
|
368
|
-
|
|
384
|
+
/**
|
|
385
|
+
* GitHub's anchor for a markdown heading: lowercased, punctuation dropped,
|
|
386
|
+
* spaces to hyphens. A repeated heading's later copies take `-1`, `-2`; this
|
|
387
|
+
* names the first.
|
|
388
|
+
*/
|
|
389
|
+
export function headingAnchor(heading) {
|
|
390
|
+
return heading
|
|
391
|
+
.trim()
|
|
392
|
+
.toLowerCase()
|
|
393
|
+
.replace(/[^\p{L}\p{M}\p{N}\p{Pc} -]/gu, "")
|
|
394
|
+
.replace(/ /g, "-");
|
|
395
|
+
}
|
|
396
|
+
const KINDS = ["step", "failure", "handover", "audit"];
|
|
369
397
|
/** The exact comment body; files (`bodyFile`, `sections`, `stderrFile`, `errorFile`) resolve against `cwd`. */
|
|
370
398
|
export function buildComment(cwd, o) {
|
|
371
399
|
const kind = o.kind ?? "step";
|
|
@@ -406,6 +434,13 @@ export function buildComment(cwd, o) {
|
|
|
406
434
|
lines.push("Stderr:", fenced(captured));
|
|
407
435
|
}
|
|
408
436
|
}
|
|
437
|
+
else if (kind === "audit") {
|
|
438
|
+
const slug = o.auditSlug;
|
|
439
|
+
if (slug === undefined || !/^[a-z0-9-]+$/.test(slug)) {
|
|
440
|
+
throw new CommandError(EXIT.USAGE, "--kind=audit needs --audit-slug=<template slug>");
|
|
441
|
+
}
|
|
442
|
+
lines.push([`### Audit Summary: ${slug}`, ...(o.fields ?? []).map(([k, v]) => `${k}: ${v}`)].join(" - "));
|
|
443
|
+
}
|
|
409
444
|
else {
|
|
410
445
|
lines.push("### Workflow Handover");
|
|
411
446
|
}
|
|
@@ -436,11 +471,12 @@ export function commentBody(ctx) {
|
|
|
436
471
|
}
|
|
437
472
|
return buildComment(ctx.cwd, {
|
|
438
473
|
kind: kind,
|
|
474
|
+
auditSlug: str(ctx.flags.auditSlug),
|
|
439
475
|
workflow: str(ctx.flags.workflow),
|
|
440
476
|
workflowHeading: ctx.flags.workflowHeading === true,
|
|
441
477
|
stepNumber: str(ctx.flags.stepNumber),
|
|
442
478
|
stepTitle: str(ctx.flags.stepTitle),
|
|
443
|
-
fields: kind === "step" ? headerFields(ctx) : [],
|
|
479
|
+
fields: kind === "step" || kind === "audit" ? headerFields(ctx) : [],
|
|
444
480
|
subStep: str(ctx.flags.subStep),
|
|
445
481
|
error: str(ctx.flags.error),
|
|
446
482
|
errorFile: str(ctx.flags.errorFile),
|
|
@@ -490,10 +526,9 @@ export const issuesCommand = {
|
|
|
490
526
|
{
|
|
491
527
|
name: "phase",
|
|
492
528
|
type: "string",
|
|
493
|
-
help: "set this phase: design | plan | build | ship | merged",
|
|
529
|
+
help: "set this phase: design | plan | build | debug | ship | merged (drops next:* and bkit:failed)",
|
|
494
530
|
},
|
|
495
|
-
{ name: "failed", type: "string", help: "bkit:failed on | off (
|
|
496
|
-
{ name: "debug", type: "string", help: "bkit:debug on | off" },
|
|
531
|
+
{ name: "failed", type: "string", help: "bkit:failed on | off (a phase implies off)" },
|
|
497
532
|
{
|
|
498
533
|
name: "board",
|
|
499
534
|
type: "string",
|
|
@@ -515,9 +550,10 @@ export const issuesCommand = {
|
|
|
515
550
|
run: labelsVerb,
|
|
516
551
|
},
|
|
517
552
|
comment: {
|
|
518
|
-
summary: "The exact body of a ###### bkit:generated step, failure, or
|
|
553
|
+
summary: "The exact body of a ###### bkit:generated step, failure, handover, or audit comment.",
|
|
519
554
|
flags: [
|
|
520
|
-
{ name: "kind", type: "string", help: "step (default) | failure | handover" },
|
|
555
|
+
{ name: "kind", type: "string", help: "step (default) | failure | handover | audit" },
|
|
556
|
+
{ name: "audit-slug", type: "string", help: "audit: template slug, e.g. security" },
|
|
521
557
|
{ name: "step-number", type: "string", help: "step number in the heading" },
|
|
522
558
|
{ name: "step-title", type: "string", help: "step title in the heading, e.g. Plan Verify" },
|
|
523
559
|
{ name: "workflow", type: "string", help: "design | plan | build | debug | ship | auto" },
|
|
@@ -548,7 +584,7 @@ export const issuesCommand = {
|
|
|
548
584
|
name: "artifact",
|
|
549
585
|
type: "string",
|
|
550
586
|
repeatable: true,
|
|
551
|
-
help: "link this repo path at --ref",
|
|
587
|
+
help: "link this repo path at --ref; path#Heading links that section",
|
|
552
588
|
},
|
|
553
589
|
{ name: "ref", type: "string", help: "ref the --artifact links point at (default --tree)" },
|
|
554
590
|
{ name: "line", type: "string", repeatable: true, help: "a raw line after the links" },
|
|
@@ -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) {
|
|
@@ -1,34 +1,28 @@
|
|
|
1
|
-
// bkit locks acquire|release — the per-feature workflow lock
|
|
1
|
+
// bkit locks acquire|release — the per-feature workflow lock.
|
|
2
2
|
//
|
|
3
|
-
//
|
|
4
|
-
//
|
|
5
|
-
//
|
|
6
|
-
//
|
|
7
|
-
// dev `.bkit/.dev.lock` in the main checkout: held across every checkout /
|
|
8
|
-
// commit / push of `dev` there. Acquire waits a bounded time; the shell
|
|
9
|
-
// releases it from `trap ... EXIT`.
|
|
3
|
+
// `docs/plans/{month}/logs/{fid}/.lock` in the main checkout: one phase workflow
|
|
4
|
+
// per feature at a time. A lock left behind is reclaimed as soon as its holder is
|
|
5
|
+
// idle: its run is not IN_PROGRESS, or stepped no sooner than 30 minutes ago. The
|
|
6
|
+
// lock file's own age is not checked.
|
|
10
7
|
//
|
|
11
|
-
//
|
|
12
|
-
// this caller owns (same token, else same workflow and feature), so a Failure
|
|
13
|
-
// that never got the lock cannot delete the holder's.
|
|
8
|
+
// The lock holds one line, `{at} {workflow} {fid} {token}`. Release removes only a
|
|
9
|
+
// lock this caller owns (same token, else same workflow and feature), so a Failure
|
|
10
|
+
// Path that never got the lock cannot delete the holder's.
|
|
14
11
|
import { randomBytes } from "node:crypto";
|
|
15
12
|
import * as fs from "node:fs";
|
|
16
13
|
import * as path from "node:path";
|
|
17
14
|
import { fold, lastRun, statusTimestamp, } from "../../ledgers/status.js";
|
|
18
|
-
import { CommandError, EXIT,
|
|
19
|
-
import { TIMEOUTS } from "../../shared/timeouts.js";
|
|
15
|
+
import { CommandError, EXIT, parseJson, repoRoot, statusRelPath, utcMonth, } from "../lib.js";
|
|
20
16
|
import { str } from "./status.js";
|
|
21
17
|
/** A workflow lock whose holder shows no sign of life for this long is stale. */
|
|
22
18
|
export const WORKFLOW_LOCK_IDLE_S = 1800;
|
|
23
|
-
/** Seconds between dev-lock attempts while it is busy. */
|
|
24
|
-
export const DEV_LOCK_POLL_S = 5;
|
|
25
19
|
/** Exit code: the feature has logs in more than one month bucket. */
|
|
26
20
|
export const EXIT_SPLIT_BUCKET = 7;
|
|
27
21
|
/** Exit code: the lock belongs to another owner and was left in place. */
|
|
28
22
|
export const EXIT_NOT_OWNER = 4;
|
|
29
23
|
/** Exit code: the lock file is still there after removing it. */
|
|
30
24
|
export const EXIT_REMOVE_FAILED = 5;
|
|
31
|
-
const KINDS = ["workflow"
|
|
25
|
+
const KINDS = ["workflow"];
|
|
32
26
|
// ---------------------------------------------------------------------------
|
|
33
27
|
// Paths
|
|
34
28
|
// ---------------------------------------------------------------------------
|
|
@@ -60,18 +54,8 @@ export function resolveMonth(root, fid, month) {
|
|
|
60
54
|
}
|
|
61
55
|
return buckets[0] ?? utcMonth();
|
|
62
56
|
}
|
|
63
|
-
/**
|
|
64
|
-
|
|
65
|
-
* runtime that does not push to dev, which books on the branch being shipped.
|
|
66
|
-
*/
|
|
67
|
-
export function lockRoot(cwd, workflow, devPushes) {
|
|
68
|
-
const root = repoRoot(cwd);
|
|
69
|
-
if (workflow !== "ship" || devPushes)
|
|
70
|
-
return root;
|
|
71
|
-
return git(cwd, ["rev-parse", "--show-toplevel"]) ?? root;
|
|
72
|
-
}
|
|
73
|
-
export const workflowLockPath = (bookRoot, month, fid) => path.join(bookRoot, "docs", "plans", month, "logs", fid, ".lock");
|
|
74
|
-
export const devLockPath = (root) => path.join(root, ".bkit", ".dev.lock");
|
|
57
|
+
/** The feature's workflow lock, in the main checkout `root` (gitignored). */
|
|
58
|
+
export const workflowLockPath = (root, month, fid) => path.join(root, "docs", "plans", month, "logs", fid, ".lock");
|
|
75
59
|
export function readHolder(file) {
|
|
76
60
|
if (!fs.existsSync(file))
|
|
77
61
|
return undefined;
|
|
@@ -80,7 +64,7 @@ export function readHolder(file) {
|
|
|
80
64
|
return { line, at, workflow, fid, token };
|
|
81
65
|
}
|
|
82
66
|
/** Create `file` only if absent (`set -C`); false when someone else holds it. */
|
|
83
|
-
function tryCreate(file, line) {
|
|
67
|
+
export function tryCreate(file, line) {
|
|
84
68
|
fs.mkdirSync(path.dirname(file), { recursive: true });
|
|
85
69
|
const fd = openExclusive(file);
|
|
86
70
|
if (fd === undefined)
|
|
@@ -100,10 +84,6 @@ function openExclusive(file) {
|
|
|
100
84
|
throw err;
|
|
101
85
|
}
|
|
102
86
|
}
|
|
103
|
-
const ageSeconds = (file, now) => {
|
|
104
|
-
const st = fs.statSync(file, { throwIfNoEntry: false });
|
|
105
|
-
return st === undefined ? undefined : Math.floor((now - st.mtimeMs) / 1000);
|
|
106
|
-
};
|
|
107
87
|
const newToken = () => randomBytes(4).toString("hex");
|
|
108
88
|
const lockLine = (workflow, fid, token) => `${statusTimestamp()} ${workflow} ${fid} ${token}`;
|
|
109
89
|
/** The caller owns the lock: same token when it gave one, else same workflow and feature. */
|
|
@@ -113,10 +93,10 @@ export function owns(holder, who) {
|
|
|
113
93
|
return holder.workflow === who.workflow && (holder.fid === undefined || holder.fid === who.fid);
|
|
114
94
|
}
|
|
115
95
|
/** Why a held workflow lock is still live, or why it may be reclaimed. */
|
|
116
|
-
function liveReason(root,
|
|
96
|
+
function liveReason(root, month, fid, holder, now) {
|
|
117
97
|
const rel = statusRelPath(month, fid);
|
|
118
98
|
const worktreeCopy = path.join(root, ".worktrees", fid, rel);
|
|
119
|
-
const own = fs.existsSync(worktreeCopy) ? worktreeCopy : path.join(
|
|
99
|
+
const own = fs.existsSync(worktreeCopy) ? worktreeCopy : path.join(root, rel);
|
|
120
100
|
const run = holder.workflow === undefined ? undefined : lastRun(readRunsLenient(own), holder.workflow);
|
|
121
101
|
const lastAt = run?.steps.at(-1)?.at;
|
|
122
102
|
if (run?.status === "IN_PROGRESS" && lastAt) {
|
|
@@ -150,14 +130,13 @@ function readRunsLenient(file) {
|
|
|
150
130
|
export function acquireWorkflowLock(opts) {
|
|
151
131
|
const root = repoRoot(opts.cwd);
|
|
152
132
|
const month = resolveMonth(root, opts.fid, opts.month);
|
|
153
|
-
const
|
|
154
|
-
const file = workflowLockPath(bookRoot, month, opts.fid);
|
|
133
|
+
const file = workflowLockPath(root, month, opts.fid);
|
|
155
134
|
const token = newToken();
|
|
156
135
|
const line = lockLine(opts.workflow, opts.fid, token);
|
|
157
136
|
if (tryCreate(file, line))
|
|
158
137
|
return { path: file, month, token, reclaimed: null };
|
|
159
138
|
const holder = readHolder(file) ?? { line: "" };
|
|
160
|
-
const verdict = liveReason(root,
|
|
139
|
+
const verdict = liveReason(root, month, opts.fid, holder, Date.now());
|
|
161
140
|
if ("live" in verdict) {
|
|
162
141
|
throw new CommandError(EXIT.NO, `workflow already running for ${opts.fid} (workflow=${holder.workflow ?? "?"}, ${verdict.live})`);
|
|
163
142
|
}
|
|
@@ -167,36 +146,6 @@ export function acquireWorkflowLock(opts) {
|
|
|
167
146
|
throw new CommandError(EXIT.NO, `lock contended for ${opts.fid}`);
|
|
168
147
|
return { path: file, month, token, reclaimed: { holder: holder.line, reason: verdict.reason } };
|
|
169
148
|
}
|
|
170
|
-
// ---------------------------------------------------------------------------
|
|
171
|
-
// Dev lock
|
|
172
|
-
// ---------------------------------------------------------------------------
|
|
173
|
-
const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
|
174
|
-
export async function acquireDevLock(opts) {
|
|
175
|
-
const file = devLockPath(repoRoot(opts.cwd));
|
|
176
|
-
const token = newToken();
|
|
177
|
-
const start = Date.now();
|
|
178
|
-
const deadline = start + opts.deadlineS * 1000;
|
|
179
|
-
let reclaimed = null;
|
|
180
|
-
for (;;) {
|
|
181
|
-
if (tryCreate(file, lockLine(opts.workflow, opts.fid, token))) {
|
|
182
|
-
return { path: file, token, reclaimed, waitedS: Math.round((Date.now() - start) / 1000) };
|
|
183
|
-
}
|
|
184
|
-
const now = Date.now();
|
|
185
|
-
const age = ageSeconds(file, now);
|
|
186
|
-
if (age === undefined)
|
|
187
|
-
continue; // released between the attempt and the stat
|
|
188
|
-
if (age >= TIMEOUTS.SHIP_DEV_LOCK_STALE_S) {
|
|
189
|
-
reclaimed = readHolder(file)?.line ?? "";
|
|
190
|
-
opts.log(`reclaiming stale dev lock (${age}s old): ${reclaimed}`);
|
|
191
|
-
fs.rmSync(file, { force: true });
|
|
192
|
-
continue;
|
|
193
|
-
}
|
|
194
|
-
if (now >= deadline) {
|
|
195
|
-
throw new CommandError(EXIT.NO, `dev lock held by: ${readHolder(file)?.line ?? "?"} — serialise this run or use a separate clone`);
|
|
196
|
-
}
|
|
197
|
-
await sleep(Math.min(DEV_LOCK_POLL_S * 1000, deadline - now));
|
|
198
|
-
}
|
|
199
|
-
}
|
|
200
149
|
/**
|
|
201
150
|
* Remove a lock this caller owns. Missing is fine (already released); another
|
|
202
151
|
* owner's lock is left in place and reported.
|
|
@@ -219,7 +168,7 @@ const KIND_FLAG = {
|
|
|
219
168
|
name: "kind",
|
|
220
169
|
type: "string",
|
|
221
170
|
required: true,
|
|
222
|
-
help: "workflow (per-feature .lock)
|
|
171
|
+
help: "workflow (the per-feature .lock)",
|
|
223
172
|
};
|
|
224
173
|
const LOCK_WORKFLOW_FLAG = {
|
|
225
174
|
name: "workflow",
|
|
@@ -233,80 +182,39 @@ const MONTH_FLAG = {
|
|
|
233
182
|
type: "string",
|
|
234
183
|
help: "workflow kind: month bucket YYYYMM (default: the feature's bucket, else this UTC month)",
|
|
235
184
|
};
|
|
236
|
-
const DEV_PUSHES_FLAG = {
|
|
237
|
-
name: "dev-pushes",
|
|
238
|
-
type: "boolean",
|
|
239
|
-
help: "ship only: this runtime pushes to dev (lock lives in the main checkout)",
|
|
240
|
-
};
|
|
241
185
|
function kindOf(ctx) {
|
|
242
186
|
const kind = String(ctx.flags.kind);
|
|
243
187
|
if (!KINDS.includes(kind))
|
|
244
|
-
throw new CommandError(EXIT.USAGE, "--kind must be workflow
|
|
188
|
+
throw new CommandError(EXIT.USAGE, "--kind must be workflow");
|
|
245
189
|
return kind;
|
|
246
190
|
}
|
|
247
|
-
function deadlineOf(ctx) {
|
|
248
|
-
const raw = str(ctx.flags.deadline);
|
|
249
|
-
if (raw === undefined)
|
|
250
|
-
return TIMEOUTS.SHIP_DEV_LOCK_ACQUIRE_DEADLINE_S;
|
|
251
|
-
if (!/^[0-9]+$/.test(raw))
|
|
252
|
-
throw new CommandError(EXIT.USAGE, `--deadline must be whole seconds, got "${raw}"`);
|
|
253
|
-
return Number(raw);
|
|
254
|
-
}
|
|
255
191
|
export const locksCommand = {
|
|
256
192
|
noun: "locks",
|
|
257
|
-
summary: "Acquire and release the per-feature workflow lock
|
|
193
|
+
summary: "Acquire and release the per-feature workflow lock.",
|
|
258
194
|
verbs: {
|
|
259
195
|
acquire: {
|
|
260
|
-
summary: "Take
|
|
261
|
-
flags: [
|
|
262
|
-
KIND_FLAG,
|
|
263
|
-
LOCK_WORKFLOW_FLAG,
|
|
264
|
-
FID_FLAG,
|
|
265
|
-
MONTH_FLAG,
|
|
266
|
-
DEV_PUSHES_FLAG,
|
|
267
|
-
{
|
|
268
|
-
name: "deadline",
|
|
269
|
-
type: "string",
|
|
270
|
-
help: `dev kind: seconds to wait for a busy lock (default ${TIMEOUTS.SHIP_DEV_LOCK_ACQUIRE_DEADLINE_S})`,
|
|
271
|
-
},
|
|
272
|
-
],
|
|
196
|
+
summary: "Take the workflow lock, reclaiming a dead holder's.",
|
|
197
|
+
flags: [KIND_FLAG, LOCK_WORKFLOW_FLAG, FID_FLAG, MONTH_FLAG],
|
|
273
198
|
output: {
|
|
274
|
-
kind: "workflow
|
|
199
|
+
kind: "workflow",
|
|
275
200
|
path: "absolute path of the lock file",
|
|
276
201
|
token: "this holder's token; pass it to release",
|
|
277
|
-
month: "
|
|
278
|
-
reclaimed: "
|
|
279
|
-
waitedS: "dev kind: seconds spent waiting (null for workflow)",
|
|
202
|
+
month: "the month bucket",
|
|
203
|
+
reclaimed: "{holder, reason: finished|stale|orphaned}; null when none",
|
|
280
204
|
},
|
|
281
205
|
exitCodes: {
|
|
282
|
-
[EXIT_SPLIT_BUCKET]: "
|
|
206
|
+
[EXIT_SPLIT_BUCKET]: "the feature has logs in more than one month bucket",
|
|
283
207
|
},
|
|
284
|
-
run:
|
|
208
|
+
run: (ctx) => {
|
|
285
209
|
const kind = kindOf(ctx);
|
|
286
|
-
const
|
|
287
|
-
const fid = String(ctx.flags.fid);
|
|
288
|
-
if (kind === "workflow") {
|
|
289
|
-
if (ctx.flags.deadline !== undefined)
|
|
290
|
-
throw new CommandError(EXIT.USAGE, "--deadline applies to --kind=dev only");
|
|
291
|
-
const lock = acquireWorkflowLock({
|
|
292
|
-
cwd: ctx.cwd,
|
|
293
|
-
workflow,
|
|
294
|
-
fid,
|
|
295
|
-
month: str(ctx.flags.month),
|
|
296
|
-
devPushes: ctx.flags.devPushes === true,
|
|
297
|
-
log: ctx.log,
|
|
298
|
-
});
|
|
299
|
-
ctx.emit({ kind, ...lock, waitedS: null });
|
|
300
|
-
return EXIT.OK;
|
|
301
|
-
}
|
|
302
|
-
const lock = await acquireDevLock({
|
|
210
|
+
const lock = acquireWorkflowLock({
|
|
303
211
|
cwd: ctx.cwd,
|
|
304
|
-
workflow,
|
|
305
|
-
fid,
|
|
306
|
-
|
|
212
|
+
workflow: String(ctx.flags.workflow),
|
|
213
|
+
fid: String(ctx.flags.fid),
|
|
214
|
+
month: str(ctx.flags.month),
|
|
307
215
|
log: ctx.log,
|
|
308
216
|
});
|
|
309
|
-
ctx.emit({ kind, ...lock
|
|
217
|
+
ctx.emit({ kind, ...lock });
|
|
310
218
|
return EXIT.OK;
|
|
311
219
|
},
|
|
312
220
|
},
|
|
@@ -317,7 +225,6 @@ export const locksCommand = {
|
|
|
317
225
|
LOCK_WORKFLOW_FLAG,
|
|
318
226
|
FID_FLAG,
|
|
319
227
|
MONTH_FLAG,
|
|
320
|
-
DEV_PUSHES_FLAG,
|
|
321
228
|
{
|
|
322
229
|
name: "token",
|
|
323
230
|
type: "string",
|
|
@@ -325,14 +232,14 @@ export const locksCommand = {
|
|
|
325
232
|
},
|
|
326
233
|
],
|
|
327
234
|
output: {
|
|
328
|
-
kind: "workflow
|
|
235
|
+
kind: "workflow",
|
|
329
236
|
path: "absolute path of the lock file",
|
|
330
237
|
existed: "a lock file was there",
|
|
331
238
|
released: "this call removed it",
|
|
332
239
|
heldBy: "the other owner's lock line when it was left in place, else null",
|
|
333
240
|
},
|
|
334
241
|
exitCodes: {
|
|
335
|
-
[EXIT_SPLIT_BUCKET]: "
|
|
242
|
+
[EXIT_SPLIT_BUCKET]: "no --month and the feature has logs in more than one month bucket",
|
|
336
243
|
[EXIT_NOT_OWNER]: "the lock belongs to another owner and was left in place",
|
|
337
244
|
[EXIT_REMOVE_FAILED]: "the lock file is still there after removing it",
|
|
338
245
|
},
|
|
@@ -344,9 +251,7 @@ export const locksCommand = {
|
|
|
344
251
|
token: str(ctx.flags.token),
|
|
345
252
|
};
|
|
346
253
|
const root = repoRoot(ctx.cwd);
|
|
347
|
-
const file =
|
|
348
|
-
? devLockPath(root)
|
|
349
|
-
: workflowLockPath(lockRoot(ctx.cwd, who.workflow, ctx.flags.devPushes === true), resolveMonth(root, who.fid, str(ctx.flags.month)), who.fid);
|
|
254
|
+
const file = workflowLockPath(root, resolveMonth(root, who.fid, str(ctx.flags.month)), who.fid);
|
|
350
255
|
const { removeFailed, ...result } = releaseLock(file, who);
|
|
351
256
|
ctx.emit({ kind, ...result });
|
|
352
257
|
if (removeFailed) {
|
|
@@ -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;
|
|
@@ -450,15 +450,18 @@ const TRANSPORTS = ["git", "gh", "mcp"];
|
|
|
450
450
|
* a `git` close needs no `gh`, so a laptop that never ran `gh auth login` closes fine.
|
|
451
451
|
*/
|
|
452
452
|
export function crossCheckFile(file, transport, log) {
|
|
453
|
+
return crossCheckRows(readStatusRows(file), file, transport, log);
|
|
454
|
+
}
|
|
455
|
+
/** crossCheckFile over rows already read; `label` names where they came from. */
|
|
456
|
+
export function crossCheckRows(rows, label, transport, log) {
|
|
453
457
|
if (!TRANSPORTS.includes(transport)) {
|
|
454
458
|
throw new CommandError(EXIT.USAGE, `--transport must be ${TRANSPORTS.join(", ")}`);
|
|
455
459
|
}
|
|
456
|
-
const rows = readStatusRows(file);
|
|
457
460
|
const runtimeGithubCli = capability(lastRow(rows, "runtime-resolved")?.runtimeGithubCli);
|
|
458
461
|
const fallbackRows = rows.filter((r) => r.type === "transport-fallback").length;
|
|
459
462
|
const violated = runtimeGithubCli === false && transport === "mcp" && fallbackRows === 0;
|
|
460
463
|
if (violated) {
|
|
461
|
-
log(`runtime-resolved logged runtimeGithubCli=false and this close used transport mcp, but no transport-fallback row exists in ${
|
|
464
|
+
log(`runtime-resolved logged runtimeGithubCli=false and this close used transport mcp, but no transport-fallback row exists in ${label}`);
|
|
462
465
|
}
|
|
463
466
|
return { ok: !violated, runtimeGithubCli, transport, fallbackRows };
|
|
464
467
|
}
|
|
@@ -9,7 +9,7 @@
|
|
|
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
13
|
import { bkitVersionStatus } from "../../shared/bkit-latest.js";
|
|
14
14
|
/** Exit code: neither gh nor the origin remote named an owner/repo. */
|
|
15
15
|
export const EXIT_NO_REPO = 3;
|
|
@@ -119,7 +119,7 @@ export const repoCommand = {
|
|
|
119
119
|
},
|
|
120
120
|
run: (ctx) => {
|
|
121
121
|
if (ctx.flags.fetch === true) {
|
|
122
|
-
const res = runGit(ctx.cwd, ["fetch", "origin",
|
|
122
|
+
const res = runGit(ctx.cwd, ["fetch", "origin", DEV]);
|
|
123
123
|
if (!res.ok)
|
|
124
124
|
ctx.log(`git fetch origin dev failed — behindDev is as of the last fetch: ${res.stderr}`);
|
|
125
125
|
}
|