@cbartens/bkit 5.4.0 → 5.5.1
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 +19 -7
- package/.bkit/core/.agents/rules.md +24 -9
- package/.bkit/core/.bkit/README.md +18 -6
- package/.bkit/core/.bkit/cloud.md +46 -15
- package/.bkit/core/.bkit/comparison.md +2 -2
- package/.bkit/core/.bkit/install.md +19 -18
- package/.bkit/core/.bkit/pipeline.md +3 -1
- package/.bkit/core/.bkit/prompts.md +38 -20
- package/.bkit/core/.bkit/providers.md +6 -6
- package/.bkit/core/.bkit/templates.md +44 -13
- package/.bkit/core/.bkit/trackers.md +99 -35
- package/.bkit/core/.bkit/workflows.md +50 -45
- package/.bkit/core/AGENTS.md +2 -2
- package/.bkit/core/docs/templates/bkit-audit-app-performance.md +1 -1
- package/.bkit/core/docs/templates/bkit-audit-issues.md +22 -6
- package/.bkit/core/engine/checks/after/auth.ts +88 -45
- package/.bkit/core/engine/checks/after/ci-yml.ts +0 -1
- package/.bkit/core/engine/checks/after/github.ts +42 -78
- package/.bkit/core/engine/checks/after/index.ts +1 -6
- package/.bkit/core/engine/checks/after/tools.ts +1 -1
- package/.bkit/core/engine/checks/before/env.ts +28 -18
- package/.bkit/core/engine/checks/before/mcp.ts +4 -2
- package/.bkit/core/engine/checks/tips/catalogue.ts +15 -2
- package/.bkit/core/engine/checks/tips/index.ts +5 -2
- package/.bkit/core/engine/cli.ts +7 -5
- package/.bkit/core/engine/commands/ci/ci.ts +107 -0
- package/.bkit/core/engine/commands/install/uninstall.ts +46 -0
- package/.bkit/core/engine/commands/workflow/fids.ts +23 -15
- package/.bkit/core/engine/commands/workflow/issues.ts +61 -63
- package/.bkit/core/engine/commands/workflow/ledgers.ts +28 -11
- package/.bkit/core/engine/commands/workflow/prs.ts +3 -1
- package/.bkit/core/engine/commands/workflow/repo.ts +8 -0
- package/.bkit/core/engine/commands/workflow/roadmap.ts +5 -1
- package/.bkit/core/engine/commands/workflow/steps.ts +2 -2
- package/.bkit/core/engine/commands/workflow/workflows.ts +9 -4
- package/.bkit/core/engine/commands/workflow/worktrees.ts +91 -14
- package/.bkit/core/engine/install/manifest.ts +31 -10
- package/.bkit/core/engine/install/modules/cloud.ts +3 -1
- package/.bkit/core/engine/install/modules/core.ts +153 -4
- package/.bkit/core/engine/install/modules/opencode.ts +5 -0
- package/.bkit/core/engine/install/write.ts +37 -1
- package/.bkit/core/engine/render/trackers.ts +35 -23
- package/.bkit/core/engine/shared/egress.ts +6 -0
- package/.bkit/core/engine/shared/settings.ts +130 -11
- package/.bkit/core/hooks/guardrails-tiers.js +1 -1
- package/.bkit/core/prompts/bkit-audit-generate.md +42 -12
- 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-plan-execute.md +1 -1
- package/.bkit/core/prompts/bkit-build-plan-gaps-remediate.md +1 -1
- package/.bkit/core/prompts/bkit-debug-abort-handover.md +2 -0
- package/.bkit/core/prompts/bkit-debug-failure-remediate.md +1 -1
- package/.bkit/core/prompts/bkit-debug-failure-reproduce.md +1 -1
- package/.bkit/core/prompts/bkit-debug-failure-soak.md +1 -1
- package/.bkit/core/prompts/bkit-design-generate.md +4 -1
- package/.bkit/core/prompts/bkit-plan-generate.md +5 -3
- package/.bkit/core/prompts/bkit-ship-conflict-resolve.md +1 -1
- package/.bkit/core/prompts/bkit-ship-update-docs.md +1 -1
- package/.bkit/core/prompts/bkit-utility-update-decisions.md +3 -1
- package/.bkit/core/prompts/bkit-utility-update-deferrals.md +3 -1
- package/.bkit/core/prompts/bkit-utility-update-documentation.md +12 -2
- package/.bkit/core/prompts/bkit-utility-update-failures.md +3 -1
- package/.bkit/core/prompts/bkit-utility-update-knowledge.md +3 -1
- package/.bkit/core/prompts/bkit-utility-update-roadmap.md +9 -2
- package/.bkit/core/prompts/bkit-utility-update-tracker.md +159 -0
- package/.bkit/core/workflows/bkit-auto.md +19 -6
- package/.bkit/core/workflows/bkit-build.md +59 -17
- package/.bkit/core/workflows/bkit-debug.md +64 -20
- package/.bkit/core/workflows/bkit-design.md +83 -28
- package/.bkit/core/workflows/bkit-plan.md +61 -20
- package/.bkit/core/workflows/bkit-ship.md +48 -18
- package/.bkit/shared/.bkit/.env.example +8 -0
- package/.bkit/shared/.claude/settings.json +3 -1
- package/.bkit/shared/.cursor/bkit-cloud.md +2 -2
- package/.bkit/shared/.cursor/mcp.json +11 -4
- package/.bkit/shared/.mcp.json +11 -4
- package/.bkit/shared/.opencode/opencode.json +2 -0
- package/.bkit/shared/docs/deployments.md +6 -7
- package/.bkit/shared/docs/security.md +1 -1
- package/.bkit/shared/docs/testing.md +13 -5
- package/.bkit/templates/.github/renovate.json5 +1 -1
- package/.bkit/templates/.github/workflows/bkit-ci.yml +21 -115
- package/.bkit/templates/.github/workflows/bkit-cloud.yml +40 -12
- package/.bkit/templates/.husky/pre-commit +4 -4
- package/.bkit/templates/.husky/pre-push +107 -18
- package/.bkit/templates/scripts/ci/bkit-local-stack-lock.sh +194 -0
- package/.bkit/templates/scripts/ci/check-capstone.mjs +2 -4
- package/.bkit/templates/scripts/ci/check-capstone.test.mjs +4 -23
- package/.bkit/templates/scripts/ci/lanes/resolve-push-base.mjs +104 -23
- package/.bkit/templates/scripts/ci/lanes/resolve-push-base.test.mjs +103 -6
- package/.bkit/templates/scripts/graphify/bkit-graph-pre-push.sh +3 -1
- package/.bkit/templates/scripts/graphify/bkit-graphify.sh +1 -1
- package/.bkit/templates/scripts/prettier/bkit-insert-ignore.mjs +49 -29
- package/CHANGELOG.md +67 -1
- package/README.md +16 -6
- package/dist/checks/after/auth.js +81 -45
- package/dist/checks/after/ci-yml.js +0 -1
- package/dist/checks/after/github.js +41 -76
- package/dist/checks/after/index.js +2 -7
- package/dist/checks/after/tools.js +1 -1
- package/dist/checks/before/env.js +24 -17
- package/dist/checks/before/mcp.js +4 -2
- package/dist/checks/tips/catalogue.js +14 -2
- package/dist/checks/tips/index.js +4 -2
- package/dist/cli.js +7 -5
- package/dist/commands/ci/ci.js +100 -0
- package/dist/commands/install/uninstall.js +42 -0
- package/dist/commands/workflow/fids.js +22 -15
- package/dist/commands/workflow/issues.js +53 -61
- package/dist/commands/workflow/ledgers.js +26 -11
- package/dist/commands/workflow/prs.js +3 -1
- package/dist/commands/workflow/repo.js +6 -0
- package/dist/commands/workflow/roadmap.js +3 -1
- package/dist/commands/workflow/steps.js +2 -2
- package/dist/commands/workflow/workflows.js +9 -4
- package/dist/commands/workflow/worktrees.js +74 -13
- package/dist/install/manifest.js +30 -10
- package/dist/install/modules/cloud.js +3 -1
- package/dist/install/modules/core.js +157 -5
- package/dist/install/modules/opencode.js +6 -0
- package/dist/install/write.js +26 -2
- package/dist/render/trackers.js +34 -20
- package/dist/shared/egress.js +6 -0
- package/dist/shared/settings.js +59 -7
- package/package.json +14 -3
|
@@ -43,6 +43,8 @@ const ANALYSIS_PLACEHOLDER = "_(no analysis yet; run @bkit-utility-update-roadma
|
|
|
43
43
|
const NOTES_PRE_PLACEHOLDER = "## Notes\n\n_(above the bkit list — yours, never overwritten)_";
|
|
44
44
|
const NOTES_POST_PLACEHOLDER = "## Notes\n\n_(end of the board — yours, never overwritten)_";
|
|
45
45
|
const BANNER = "> Generated tables — do not hand-edit the `bkit` tables; append to `.bkit/issues.jsonl` instead (an `ABANDONED` row hides a FID from every section). `## Notes` blocks are yours and are never overwritten. Everything above the first marker is also yours. notes-post is last. Analysis list length: `package.json` key `bkit.roadmapNext` (positive integer; absent or invalid → 25).";
|
|
46
|
+
/** Fixed related-utilities line; `@bkit-audit-generate` ends every run with the same text. */
|
|
47
|
+
export const RELATED_UTILITIES = "> Related utilities, run on demand: `@bkit-utility-update-roadmap` ranks the next best items in `docs/roadmap.md`; `@bkit-utility-update-tracker` brings tracker issues in line with the tracker rules; `@bkit-utility-update-deferrals` and `@bkit-utility-update-failures` close ledger rows the code already resolved; `@bkit-utility-update-decisions`, `@bkit-utility-update-knowledge` and `@bkit-utility-update-documentation` correct ledgers and docs the code has since contradicted.";
|
|
46
48
|
/** Newest SHIPPED rows on the board; older ones stay in the ledger. */
|
|
47
49
|
export const SHIPPED_ON_BOARD = 10;
|
|
48
50
|
const SECTIONS = [
|
|
@@ -100,7 +102,7 @@ function table(rows) {
|
|
|
100
102
|
];
|
|
101
103
|
}
|
|
102
104
|
export function statusBlock(p, now) {
|
|
103
|
-
const out = [BANNER, "", "## bkit", "", `_(refreshed ${now})_`];
|
|
105
|
+
const out = [BANNER, "", RELATED_UTILITIES, "", "## bkit", "", `_(refreshed ${now})_`];
|
|
104
106
|
for (const [bucket, , heading] of SECTIONS)
|
|
105
107
|
out.push("", heading, "", ...table(p[bucket]));
|
|
106
108
|
return out.join("\n");
|
|
@@ -16,7 +16,7 @@ import { clampLogPath, readRecords } from "../../ledgers/clamp-log.js";
|
|
|
16
16
|
import { resolveRepoSlug } from "../../ledgers/telemetry.js";
|
|
17
17
|
import { getPromptsRoot } from "../../shared/package-roots.js";
|
|
18
18
|
import { CommandError, EXIT, repoRoot, runGit, } from "../lib.js";
|
|
19
|
-
import { FID_PATTERNS, readIssueTracker } from "./fids.js";
|
|
19
|
+
import { FID_PATTERNS, normaliseFid, readIssueTracker } from "./fids.js";
|
|
20
20
|
import { buildComment } from "./issues.js";
|
|
21
21
|
import { readHolder, resolveMonth, workflowLockPath } from "./locks.js";
|
|
22
22
|
import { EXIT_NO_STATUS, FILE_FLAG, STEP_FLAG, SUB_PLAN_FLAG, WORKFLOW_FLAG, extraField, nonNegativeInt, positiveInt, readRuns, readRunsAt, statusFile, str, } from "./status.js";
|
|
@@ -324,7 +324,7 @@ function gateChecks(cwd, o) {
|
|
|
324
324
|
}
|
|
325
325
|
if (o.fid !== undefined) {
|
|
326
326
|
const tracker = readIssueTracker(cwd);
|
|
327
|
-
const fid =
|
|
327
|
+
const fid = normaliseFid(o.fid, tracker);
|
|
328
328
|
add(`fid ${fid}`, FID_PATTERNS[tracker].test(fid)
|
|
329
329
|
? undefined
|
|
330
330
|
: `does not match the ${tracker} shape ${FID_PATTERNS[tracker].source}`, `${tracker} shape`);
|
|
@@ -22,11 +22,12 @@ import * as path from "node:path";
|
|
|
22
22
|
import { appendLine, fold, runNumber, runOrStepField, statusTimestamp, } from "../../ledgers/status.js";
|
|
23
23
|
import { appendLine as telemetryLine, foldFrom, resolveRepoSlug, validate, workflowTelemetry, } from "../../ledgers/telemetry.js";
|
|
24
24
|
import { readBkitVersion } from "../../install/version-file.js";
|
|
25
|
+
import { readBkitConfig } from "../../shared/settings.js";
|
|
25
26
|
import { gradeCompliance } from "../comply.js";
|
|
26
27
|
import { landDir, pushToDev } from "../land.js";
|
|
27
28
|
import { CommandError, DEV, EXIT, git, isSharedBranch, parseJson, repoRoot, runGh, runGit, statusLocation, statusRelPath, } from "../lib.js";
|
|
28
29
|
import { anchorBkitStatus, pushBranch, readAnchor, stampAnchor } from "./branches.js";
|
|
29
|
-
import { AUTO_LABEL, AUTO_ROUTE_SUFFIX, buildComment,
|
|
30
|
+
import { AUTO_LABEL, AUTO_ROUTE_SUFFIX, buildComment, trackerState, transitionLabels, } from "./issues.js";
|
|
30
31
|
import { EXIT_EMPTY, commitBookkeeping, unionLedgers } from "./ledgers.js";
|
|
31
32
|
import { EXIT_REMOVE_FAILED, EXIT_SPLIT_BUCKET, acquireWorkflowLock, owns, readHolder, releaseLock, resolveMonth, workflowLockPath, } from "./locks.js";
|
|
32
33
|
import { mergePr, probePr } from "./prs.js";
|
|
@@ -172,9 +173,11 @@ function failVerb(ctx) {
|
|
|
172
173
|
}
|
|
173
174
|
const merged = prState === "MERGED";
|
|
174
175
|
const transition = merged ? { phase: "merged" } : { failed: true };
|
|
175
|
-
const
|
|
176
|
+
const current = list(ctx.flags.label);
|
|
177
|
+
const labels = transitionLabels(current, transition).labels;
|
|
176
178
|
if (merged && !labels.includes("bkit:failed"))
|
|
177
179
|
labels.push("bkit:failed");
|
|
180
|
+
const add = labels.filter((l) => !current.includes(l));
|
|
178
181
|
// The failure comment, when the step is named.
|
|
179
182
|
let comment = null;
|
|
180
183
|
const stepNumber = str(ctx.flags.stepNumber);
|
|
@@ -197,8 +200,9 @@ function failVerb(ctx) {
|
|
|
197
200
|
sentinels: state.sentinels,
|
|
198
201
|
handoverNeeded: token !== undefined &&
|
|
199
202
|
(ctx.flags.maxExceeded === true || state.sentinels.length > 0 || state.soak),
|
|
203
|
+
add,
|
|
200
204
|
labels,
|
|
201
|
-
|
|
205
|
+
trackerState: trackerState(transition, undefined, readBkitConfig(repoRoot(ctx.cwd))),
|
|
202
206
|
prState,
|
|
203
207
|
comment,
|
|
204
208
|
});
|
|
@@ -1223,8 +1227,9 @@ export const workflowsCommand = {
|
|
|
1223
1227
|
lock: "{path, existed, released, heldBy}: heldBy is another owner's lock line, left in place; null without --token",
|
|
1224
1228
|
sentinels: "[{name, path}] sentinels that existed before this call removed them",
|
|
1225
1229
|
handoverNeeded: "--max-exceeded, a sentinel existed, or a debug run in SOAK mode: write the abort handover",
|
|
1230
|
+
add: "labels in the set that the issue does not carry yet",
|
|
1226
1231
|
labels: "the label set to write: the current labels plus bkit:failed (and bkit:merged for a merged ship PR)",
|
|
1227
|
-
|
|
1232
|
+
trackerState: "the Linear or Jira state for the failed issue (null under github, none)",
|
|
1228
1233
|
prState: "the --pr PR's state, or null",
|
|
1229
1234
|
comment: "the failure comment body (with --step-number), else null",
|
|
1230
1235
|
},
|
|
@@ -8,7 +8,10 @@
|
|
|
8
8
|
// reports it. `remove` is the close / cleanup half: it removes only a worktree a
|
|
9
9
|
// workflow created, marked in the git common dir's outbox so the marker outlives
|
|
10
10
|
// the worktree it describes, and with `--branch` deletes the feature branch
|
|
11
|
-
// unless another worktree still holds it.
|
|
11
|
+
// unless another worktree still holds it. A new branch, and a resume rebase,
|
|
12
|
+
// use local `dev` when it is a fast-forward of `origin/dev`: dev pushes wait for
|
|
13
|
+
// a human, so local dev is routinely ahead, and a worktree without those commits
|
|
14
|
+
// builds against superseded work.
|
|
12
15
|
import { spawnSync } from "node:child_process";
|
|
13
16
|
import * as fs from "node:fs";
|
|
14
17
|
import * as path from "node:path";
|
|
@@ -93,12 +96,32 @@ function shipBranch(root, fid, named, session) {
|
|
|
93
96
|
return feat;
|
|
94
97
|
return isSharedBranch(session) || session === "" ? feat : session;
|
|
95
98
|
}
|
|
99
|
+
/**
|
|
100
|
+
* The ref a feature branch starts from and rebases onto: local `dev` when it is
|
|
101
|
+
* strictly ahead of `origin/dev` (a fast-forward of it), else `origin/dev`. With
|
|
102
|
+
* `log`, says why when the two differ. Fetch first for a current answer.
|
|
103
|
+
*/
|
|
104
|
+
export function devBase(cwd, log) {
|
|
105
|
+
const local = git(cwd, ["rev-parse", "-q", "--verify", `refs/heads/${DEV}`]);
|
|
106
|
+
const remote = git(cwd, ["rev-parse", "-q", "--verify", `refs/remotes/${ORIGIN_DEV}`]);
|
|
107
|
+
if (local === null || remote === null || local === remote)
|
|
108
|
+
return ORIGIN_DEV;
|
|
109
|
+
const count = (range) => git(cwd, ["rev-list", "--count", range]) ?? "?";
|
|
110
|
+
if (runGit(cwd, ["merge-base", "--is-ancestor", remote, local]).ok) {
|
|
111
|
+
log?.(`local ${DEV} is ${count(`${remote}..${local}`)} commit(s) ahead of ${ORIGIN_DEV} — basing on local ${DEV}; push ${DEV} before the feature PR`);
|
|
112
|
+
return DEV;
|
|
113
|
+
}
|
|
114
|
+
if (!runGit(cwd, ["merge-base", "--is-ancestor", local, remote]).ok) {
|
|
115
|
+
log?.(`local ${DEV} and ${ORIGIN_DEV} have diverged — basing on ${ORIGIN_DEV}; local ${DEV}'s ${count(`${remote}..${local}`)} commit(s) are not in this worktree`);
|
|
116
|
+
}
|
|
117
|
+
return ORIGIN_DEV;
|
|
118
|
+
}
|
|
96
119
|
/**
|
|
97
120
|
* `git worktree add` for `branch`: the local branch, else a tracking branch off
|
|
98
|
-
* `origin`, else (when `mayCreate`) a new branch off a
|
|
99
|
-
*
|
|
121
|
+
* `origin`, else (when `mayCreate`) a new branch off `devBase` after a fresh
|
|
122
|
+
* fetch. Returns false when there was nothing to add and `mayCreate` is off.
|
|
100
123
|
*/
|
|
101
|
-
function addWorktree(root, wt, branch, mayCreate) {
|
|
124
|
+
function addWorktree(root, wt, branch, mayCreate, log) {
|
|
102
125
|
let args;
|
|
103
126
|
if (hasLocal(root, branch)) {
|
|
104
127
|
args = [wt, branch];
|
|
@@ -114,7 +137,7 @@ function addWorktree(root, wt, branch, mayCreate) {
|
|
|
114
137
|
}
|
|
115
138
|
else if (mayCreate) {
|
|
116
139
|
fetchBranch(root, DEV);
|
|
117
|
-
args = [wt, "-b", branch,
|
|
140
|
+
args = [wt, "-b", branch, devBase(root, log)];
|
|
118
141
|
}
|
|
119
142
|
else {
|
|
120
143
|
return false;
|
|
@@ -157,6 +180,32 @@ function copyListed(root, wt, entries, log) {
|
|
|
157
180
|
}
|
|
158
181
|
return { copied, copyMissing };
|
|
159
182
|
}
|
|
183
|
+
/**
|
|
184
|
+
* `direnv allow` the worktree's `.envrc` when it matches the main checkout's
|
|
185
|
+
* byte for byte, so the worktree inherits the trust given there and nothing
|
|
186
|
+
* more; a differing file is left for a human to read. No `.envrc`, direnv
|
|
187
|
+
* missing or failing → false, narrated, never fatal.
|
|
188
|
+
*/
|
|
189
|
+
function allowDirenv(root, wt, log) {
|
|
190
|
+
const envrc = path.join(wt, ".envrc");
|
|
191
|
+
if (!fs.existsSync(envrc))
|
|
192
|
+
return false;
|
|
193
|
+
const main = path.join(root, ".envrc");
|
|
194
|
+
if (!fs.existsSync(main) || !fs.readFileSync(main).equals(fs.readFileSync(envrc))) {
|
|
195
|
+
log(`direnv: ${envrc} differs from the main checkout's — not allowed; read it, then run direnv allow`);
|
|
196
|
+
return false;
|
|
197
|
+
}
|
|
198
|
+
const res = spawnSync("direnv", ["allow", wt], { cwd: wt, encoding: "utf-8" });
|
|
199
|
+
if (res.error || res.status === 127) {
|
|
200
|
+
log("direnv: not installed — run direnv allow in the worktree once it is");
|
|
201
|
+
return false;
|
|
202
|
+
}
|
|
203
|
+
if (res.status !== 0) {
|
|
204
|
+
log(`direnv allow failed (exit ${res.status}): ${(res.stderr ?? "").trim()}`);
|
|
205
|
+
return false;
|
|
206
|
+
}
|
|
207
|
+
return true;
|
|
208
|
+
}
|
|
160
209
|
/** Run the frozen install in `wt`; the exit status, with a spawn failure read as "could not run". */
|
|
161
210
|
function install(wt, log) {
|
|
162
211
|
const [cmd, ...args] = installCommand({ frozen: true });
|
|
@@ -287,12 +336,14 @@ export const worktreesCommand = {
|
|
|
287
336
|
branch: "branch checked out at worktreePath",
|
|
288
337
|
mode: "created | resumed | adopted",
|
|
289
338
|
owned: "the .worktree-owned marker is present (a workflow created this worktree)",
|
|
290
|
-
rebaseConflict: "a resume rebase onto
|
|
339
|
+
rebaseConflict: "a resume rebase onto baseRef stopped on a conflict and is left in progress",
|
|
291
340
|
sentinel: "the .rebase-failed sentinel written on a failed rebase, else null",
|
|
292
341
|
logDir: "docs/plans/{month}/logs/{fid} under worktreePath (created)",
|
|
293
|
-
|
|
342
|
+
baseRef: "dev when local dev is a fast-forward of origin/dev (unpushed commits), else origin/dev",
|
|
343
|
+
baseSha: "git merge-base baseRef HEAD at worktreePath, or null",
|
|
294
344
|
copied: "worktree copy entries copied from the main checkout",
|
|
295
345
|
copyMissing: "worktree copy entries absent from the main checkout",
|
|
346
|
+
direnvAllowed: "direnv allow ran on the worktree's .envrc (present and identical to the main checkout's)",
|
|
296
347
|
installed: "dependencies were installed",
|
|
297
348
|
},
|
|
298
349
|
exitCodes: {
|
|
@@ -362,7 +413,7 @@ export const worktreesCommand = {
|
|
|
362
413
|
}
|
|
363
414
|
else if (workflow !== "debug" || session !== target) {
|
|
364
415
|
// Debug adopts an existing feat/{fid}; it never mints a branch of its own.
|
|
365
|
-
if (addWorktree(root, wtDir, target, workflow !== "debug"))
|
|
416
|
+
if (addWorktree(root, wtDir, target, workflow !== "debug", ctx.log))
|
|
366
417
|
mode = "created";
|
|
367
418
|
}
|
|
368
419
|
}
|
|
@@ -393,23 +444,29 @@ export const worktreesCommand = {
|
|
|
393
444
|
fs.rmSync(sentinelPath, { force: true });
|
|
394
445
|
let failure;
|
|
395
446
|
if (rebaseInProgress(wt)) {
|
|
396
|
-
failure = {
|
|
447
|
+
failure = {
|
|
448
|
+
conflict: true,
|
|
449
|
+
detail: "a rebase is already in progress",
|
|
450
|
+
onto: devBase(wt),
|
|
451
|
+
};
|
|
397
452
|
}
|
|
398
453
|
else {
|
|
399
454
|
fetchBranch(wt, DEV);
|
|
400
|
-
const
|
|
455
|
+
const onto = devBase(wt, ctx.log);
|
|
456
|
+
const rb = runGit(wt, ["rebase", "--rebase-merges", onto]);
|
|
401
457
|
if (!rb.ok) {
|
|
402
458
|
failure = {
|
|
403
459
|
conflict: rebaseInProgress(wt),
|
|
404
460
|
detail: [rb.stdout, rb.stderr].filter(Boolean).join("\n"),
|
|
461
|
+
onto,
|
|
405
462
|
};
|
|
406
463
|
}
|
|
407
464
|
}
|
|
408
465
|
if (failure) {
|
|
409
466
|
fs.mkdirSync(logDir, { recursive: true });
|
|
410
|
-
fs.appendFileSync(path.join(logDir, "rebase-resolve-log.md"), `[bkit-worktrees] ${new Date().toISOString()} rebase onto ${
|
|
467
|
+
fs.appendFileSync(path.join(logDir, "rebase-resolve-log.md"), `[bkit-worktrees] ${new Date().toISOString()} rebase onto ${failure.onto} stopped\n${failure.detail}\n`);
|
|
411
468
|
fs.writeFileSync(sentinelPath, "");
|
|
412
|
-
ctx.log(`rebase onto ${
|
|
469
|
+
ctx.log(`rebase onto ${failure.onto} failed in ${wt}: ${failure.detail.split("\n")[0]}`);
|
|
413
470
|
rebaseConflict = failure.conflict;
|
|
414
471
|
sentinel = sentinelPath;
|
|
415
472
|
}
|
|
@@ -423,8 +480,10 @@ export const worktreesCommand = {
|
|
|
423
480
|
const { copied, copyMissing } = done
|
|
424
481
|
? copyListed(root, wt, config.worktreeCopy, ctx.log)
|
|
425
482
|
: { copied: [], copyMissing: [] };
|
|
483
|
+
const direnvAllowed = done && allowDirenv(root, wt, ctx.log);
|
|
426
484
|
const wantInstall = done && config.worktreeInstall;
|
|
427
485
|
const installStatus = wantInstall ? install(wt, ctx.log) : 0;
|
|
486
|
+
const baseRef = devBase(wt);
|
|
428
487
|
ctx.emit({
|
|
429
488
|
worktreePath: wt,
|
|
430
489
|
repoRoot: root,
|
|
@@ -434,9 +493,11 @@ export const worktreesCommand = {
|
|
|
434
493
|
rebaseConflict,
|
|
435
494
|
sentinel,
|
|
436
495
|
logDir,
|
|
437
|
-
|
|
496
|
+
baseRef,
|
|
497
|
+
baseSha: git(wt, ["merge-base", baseRef, "HEAD"]),
|
|
438
498
|
copied,
|
|
439
499
|
copyMissing,
|
|
500
|
+
direnvAllowed,
|
|
440
501
|
installed: wantInstall && installStatus === 0,
|
|
441
502
|
});
|
|
442
503
|
if (sentinel !== null)
|
package/dist/install/manifest.js
CHANGED
|
@@ -15,14 +15,16 @@ export const OPTIN_MODULES = new Set(["cloud", "opencode", "codex", "antigravity
|
|
|
15
15
|
// ---------------------------------------------------------------------------
|
|
16
16
|
/**
|
|
17
17
|
* Issue-tracker providers supported by `bkit install --tracker=<name>`.
|
|
18
|
-
* - `github` — GitHub Issues + Projects v2
|
|
19
|
-
* - `linear` — Linear
|
|
20
|
-
* - `
|
|
18
|
+
* - `github` — GitHub Issues + Projects v2.
|
|
19
|
+
* - `linear` — Linear.
|
|
20
|
+
* - `jira` — Jira Cloud through the Atlassian Rovo MCP server.
|
|
21
|
+
* - `none` — no tracker wired; workflows skip tracker calls with one-line log (default).
|
|
21
22
|
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
23
|
+
* A new value needs its block in every tracker group of the workflow and prompt
|
|
24
|
+
* sources (`.bkit/trackers.md` § Marker contract) and a branch in
|
|
25
|
+
* `render/trackers.ts`.
|
|
24
26
|
*/
|
|
25
|
-
export const ISSUE_TRACKERS = ["github", "linear", "none"];
|
|
27
|
+
export const ISSUE_TRACKERS = ["github", "linear", "jira", "none"];
|
|
26
28
|
/** Default tracker when consumer manifest has no `bkit.issueTracker` field. */
|
|
27
29
|
export const DEFAULT_ISSUE_TRACKER = "none";
|
|
28
30
|
/**
|
|
@@ -154,7 +156,9 @@ const CLAUDE_MANIFEST = [
|
|
|
154
156
|
// ONE CHAIN. Each gate is the previous gate plus its own tier; the NAME and the
|
|
155
157
|
// VALUE describe the same sequence. Tier vocabulary is the `bkit-ci.yml` job ids
|
|
156
158
|
// (bkit-tests-static / -unit / -integration / -e2e / -live). Where a step is not a
|
|
157
|
-
// tier (`format`, the ship gate) the name spells out the actual steps.
|
|
159
|
+
// tier (`format`, the ship gate) the name spells out the actual steps. One exception:
|
|
160
|
+
// `min` sits off the chain: the least a push runs, on a push that changes no code
|
|
161
|
+
// (`bkit.minPushPaths`); its steps are whatever that push can still break.
|
|
158
162
|
//
|
|
159
163
|
// The consumer owns every value: a turbo monorepo writes `turbo run … --filter`,
|
|
160
164
|
// a Python repo writes `ruff check && pytest`. bkit never reads a value — only
|
|
@@ -178,17 +182,23 @@ const CLAUDE_MANIFEST = [
|
|
|
178
182
|
// …-integration-e2e-live) are absent unless the consumer writes them. Each is one line
|
|
179
183
|
// chaining its parent, e.g.
|
|
180
184
|
// "bkit:gate:static-unit-integration": "pnpm bkit:gate:static-unit && pnpm test:integration"
|
|
181
|
-
// `/bkit-build` and `/bkit-debug` run the DEEPEST gate that exists and record its name
|
|
185
|
+
// `/bkit-build` and `/bkit-debug` run the DEEPEST gate that exists and record its name;
|
|
186
|
+
// `.husky/pre-push` runs `…-integration` when it exists (BKIT_PUSH_GATES).
|
|
182
187
|
export const BKIT_GATE_SCRIPTS = {
|
|
183
188
|
// `.husky/pre-commit`: prettier --write over staged files, and nothing else —
|
|
184
189
|
// seconds, not minutes. Prose is a whole-repo scan, so it gates at pre-push.
|
|
185
190
|
"bkit:gate:format": "pnpm lint-staged",
|
|
191
|
+
// `.husky/pre-push` on a min push (every file matches `bkit.minPushPaths`): no code, so
|
|
192
|
+
// no typecheck, lint or tests. Off the chain. Add any test that reads a min-push file.
|
|
193
|
+
"bkit:gate:min": "pnpm format:check && pnpm lint:prose && pnpm slop:delta",
|
|
186
194
|
// Everything that needs no test runner. Every part has a matching step in the
|
|
187
195
|
// bkit-tests-static CI job; audits/templates/template-ci-yml.test.ts fails when one is missing.
|
|
188
196
|
// Callers: build's plan-execute loop between tasks, and the `.husky/pre-push` revert
|
|
189
197
|
// path.
|
|
190
198
|
"bkit:gate:static": "pnpm typecheck && pnpm lint && pnpm format:check && pnpm lint:prose && pnpm slop:delta",
|
|
191
|
-
// The default local gate: `.husky/pre-push
|
|
199
|
+
// The default local gate: `.husky/pre-push` (when no `…-integration` gate is declared),
|
|
200
|
+
// build Step 14, the remediates. `pnpm test` is the unit tier only: a test file the
|
|
201
|
+
// integration gate also runs must not match it.
|
|
192
202
|
"bkit:gate:static-unit": "pnpm bkit:gate:static && pnpm test",
|
|
193
203
|
// Ship's conflict-resolve, the only caller whose dependency graph may have just
|
|
194
204
|
// been hand-merged (lockfile conflict) and whose tree no one has ever compiled.
|
|
@@ -222,12 +232,22 @@ export const BKIT_DEBUG_GATES = [
|
|
|
222
232
|
* Build stops at integration; E2E and live are not in this list.
|
|
223
233
|
*
|
|
224
234
|
* Neither entry is seeded: declaring `bkit:gate:static-unit-integration` opts the build
|
|
225
|
-
* loop into the integration tier.
|
|
235
|
+
* loop and the pre-push hook into the integration tier.
|
|
226
236
|
*/
|
|
227
237
|
export const BKIT_BUILD_GATES = [
|
|
228
238
|
"bkit:gate:static-unit-integration",
|
|
229
239
|
"bkit:gate:static-unit",
|
|
230
240
|
];
|
|
241
|
+
/**
|
|
242
|
+
* What `.husky/pre-push` runs on a full push, in DESCENDING order — first one declared wins.
|
|
243
|
+
*
|
|
244
|
+
* Integration runs on push, never on commit; E2E and live stay in CI. The template hook
|
|
245
|
+
* reads package.json for the first entry itself (it cannot import this list).
|
|
246
|
+
*/
|
|
247
|
+
export const BKIT_PUSH_GATES = [
|
|
248
|
+
"bkit:gate:static-unit-integration",
|
|
249
|
+
"bkit:gate:static-unit",
|
|
250
|
+
];
|
|
231
251
|
/**
|
|
232
252
|
* Runs ONE test file — `pnpm bkit:test:file <repo-relative path>` — and writes a JUnit
|
|
233
253
|
* report to `$BKIT_TEST_REPORT`. `/bkit-build` records each task's red and audits its
|
|
@@ -77,7 +77,9 @@ export function runCloudModule(ctx) {
|
|
|
77
77
|
CLOUD_WORKFLOW_ADOPT_STEP +
|
|
78
78
|
" - Run `/install-github-app` (Claude Code CLI) to install the Claude GitHub App on your repo. This is required — `claude-code-action@v1` authenticates as the App via OIDC (`id-token: write`); without the App it fails at boot with an OIDC error.\n" +
|
|
79
79
|
" - GitHub Actions permissions — flip BOTH org AND repo: Settings → Actions → General → Workflow permissions = **Read and write permissions** + tick **Allow GitHub Actions to create and approve pull requests**.\n" +
|
|
80
|
-
" -
|
|
80
|
+
" - Give `claude-code-action@v1` ONE claude credential (Settings → Secrets and variables → Actions):\n" +
|
|
81
|
+
" - the `ANTHROPIC_API_KEY` repo secret (job env keeps this vendor name; local `.bkit/.env` stores it as `BKIT_ANTHROPIC_API_KEY`), or\n" +
|
|
82
|
+
" - keyless workload identity federation: Claude Console → Settings → Workload identity → Connect workload → GitHub Actions creates the issuer, service account and federation rule; then set the `ANTHROPIC_FEDERATION_RULE_ID` + `ANTHROPIC_ORGANIZATION_ID` repo variables (optional `ANTHROPIC_SERVICE_ACCOUNT_ID` / `ANTHROPIC_WORKSPACE_ID`). Leave `ANTHROPIC_API_KEY` unset — a set key wins over federation.\n" +
|
|
81
83
|
" - Label the issue `bkit:auto` before pushing the build commit — without the label the CI auto-route exits no-op.\n\n" +
|
|
82
84
|
"OPTIONAL (manual phase launch): after `/install-github-app`, comment `@claude /bkit-plan` (or any phase) on a GitHub issue/PR to launch it from the tracker UI. The App's generated `claude.yml` triggers on mention events; `bkit-cloud.yml` triggers on CI completion + `workflow_dispatch` — the two coexist.\n\n" +
|
|
83
85
|
"Both the CI-driven path and the `@claude` mention path invoke the same `/bkit-auto` orchestrator (mirrored to `.claude/commands/bkit-auto.md` on each `pnpm bkit install`).",
|
|
@@ -9,10 +9,11 @@ import { extractManagedBlock, stripManagedBlock } from "../managed-block.js";
|
|
|
9
9
|
import { listFilesRecursive, syncTemplateCopies } from "../template-copies.js";
|
|
10
10
|
import { PAYLOAD_LINK_RELPATHS, syncPayloadLinks } from "../payload-links.js";
|
|
11
11
|
import { writeNetworkAllowlist } from "../network-allowlist.js";
|
|
12
|
-
import { readJsonFile } from "../../shared/json.js";
|
|
12
|
+
import { parseJson, readJsonFile } from "../../shared/json.js";
|
|
13
13
|
import { readInstallingVersion } from "../../shared/package-json.js";
|
|
14
|
+
import { CONFIG_DEFAULTS } from "../../shared/settings.js";
|
|
14
15
|
import { getCoreRoot, getSharedRoot, getBkitDocsRoot, TEMPLATE_COPIES_DIR, } from "../../shared/package-roots.js";
|
|
15
|
-
import { getInstallManifest, BKIT_GATE_SCRIPTS, BKIT_OPTIONAL_GATES, BKIT_TEST_FILE_SCRIPT, } from "../manifest.js";
|
|
16
|
+
import { getInstallManifest, BKIT_GATE_SCRIPTS, BKIT_OPTIONAL_GATES, BKIT_PUSH_GATES, BKIT_TEST_FILE_SCRIPT, } from "../manifest.js";
|
|
16
17
|
export function listMdFiles(dir, prefix) {
|
|
17
18
|
if (!fs.existsSync(dir))
|
|
18
19
|
return [];
|
|
@@ -315,8 +316,122 @@ export function seedCorePackageJsonScripts(ctx) {
|
|
|
315
316
|
written.push("package.json");
|
|
316
317
|
console.log(`${logPrefix} ${tag}core: package.json scripts added [${gates.added.join(", ")}]`);
|
|
317
318
|
}
|
|
319
|
+
if (migrateLinearTeamKey(dryRun, ws, logPrefix) && !written.includes("package.json")) {
|
|
320
|
+
written.push("package.json");
|
|
321
|
+
}
|
|
322
|
+
if (migrateGithubProjectKey(dryRun, ws, logPrefix) && !written.includes("package.json")) {
|
|
323
|
+
written.push("package.json");
|
|
324
|
+
}
|
|
318
325
|
return written;
|
|
319
326
|
}
|
|
327
|
+
/** Rewrite package.json with `pkg`, keeping the file's indent and trailing newline. */
|
|
328
|
+
function writePackageJsonLike(raw, pkg) {
|
|
329
|
+
const indentMatch = raw.match(/\n([ \t]+)"/);
|
|
330
|
+
const indent = indentMatch ? indentMatch[1] : " ";
|
|
331
|
+
const trailingNewline = raw.endsWith("\n") ? "\n" : "";
|
|
332
|
+
fs.writeFileSync("package.json", JSON.stringify(pkg, null, indent) + trailingNewline, "utf-8");
|
|
333
|
+
}
|
|
334
|
+
// Status option ids of GitHub's Kanban and Team planning board templates; every board
|
|
335
|
+
// made from one carries the same ids.
|
|
336
|
+
const TEMPLATE_STATUS_OPTIONS = {
|
|
337
|
+
"47fc9ee4": "In progress",
|
|
338
|
+
df73e18b: "In review",
|
|
339
|
+
};
|
|
340
|
+
// Migration (up to 5.4.x installs, `docs/migrations.md`): the board lived at
|
|
341
|
+
// `bkit.githubProject` as `{owner, number, statusFieldId, *OptionId}`, org boards only; it
|
|
342
|
+
// is `bkit.github.project`, the board URL, with Status set by option name from
|
|
343
|
+
// `bkit.github.progress` / `review`. An existing `bkit.github.project` wins over the old
|
|
344
|
+
// key. Returns true when package.json changed.
|
|
345
|
+
export function migrateGithubProjectKey(dryRun, ws, logPrefix) {
|
|
346
|
+
const pkgPath = "package.json";
|
|
347
|
+
if (!fs.existsSync(pkgPath))
|
|
348
|
+
return false;
|
|
349
|
+
const raw = fs.readFileSync(pkgPath, "utf-8");
|
|
350
|
+
const parsed = parseJson(raw);
|
|
351
|
+
if (!parsed.ok)
|
|
352
|
+
return false;
|
|
353
|
+
const pkg = parsed.value;
|
|
354
|
+
const bkit = pkg.bkit;
|
|
355
|
+
if (bkit === null || typeof bkit !== "object" || Array.isArray(bkit))
|
|
356
|
+
return false;
|
|
357
|
+
const cfg = bkit;
|
|
358
|
+
if (!Object.prototype.hasOwnProperty.call(cfg, "githubProject"))
|
|
359
|
+
return false;
|
|
360
|
+
const old = cfg.githubProject;
|
|
361
|
+
const github = cfg.github !== null && typeof cfg.github === "object" && !Array.isArray(cfg.github)
|
|
362
|
+
? cfg.github
|
|
363
|
+
: {};
|
|
364
|
+
const unnamed = [];
|
|
365
|
+
if (github.project === undefined) {
|
|
366
|
+
if (old === false)
|
|
367
|
+
github.project = false;
|
|
368
|
+
else if (old !== null && typeof old === "object" && !Array.isArray(old)) {
|
|
369
|
+
const board = old;
|
|
370
|
+
const owner = typeof board.owner === "string" ? board.owner.trim() : "";
|
|
371
|
+
const number = Number(board.number);
|
|
372
|
+
if (owner !== "" && Number.isInteger(number) && number > 0) {
|
|
373
|
+
github.project = `https://github.com/orgs/${owner}/projects/${number}`;
|
|
374
|
+
for (const [moment, key] of [
|
|
375
|
+
["progress", "progressOptionId"],
|
|
376
|
+
["review", "reviewOptionId"],
|
|
377
|
+
]) {
|
|
378
|
+
const id = board[key];
|
|
379
|
+
if (typeof id !== "string" || id.trim() === "")
|
|
380
|
+
continue;
|
|
381
|
+
const name = TEMPLATE_STATUS_OPTIONS[id.trim()];
|
|
382
|
+
if (name === undefined)
|
|
383
|
+
unnamed.push(moment);
|
|
384
|
+
else if (github[moment] === undefined && name !== CONFIG_DEFAULTS.github[moment])
|
|
385
|
+
github[moment] = name;
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
delete cfg.githubProject;
|
|
391
|
+
if (Object.keys(github).length > 0)
|
|
392
|
+
cfg.github = github;
|
|
393
|
+
ws.writes.push({ path: pkgPath, action: "update" });
|
|
394
|
+
if (!dryRun)
|
|
395
|
+
writePackageJsonLike(raw, pkg);
|
|
396
|
+
const tag = dryRun ? "[dry-run] " : "";
|
|
397
|
+
console.log(`${logPrefix} ${tag}core: moved bkit.githubProject to bkit.github in package.json`);
|
|
398
|
+
for (const moment of unnamed)
|
|
399
|
+
console.log(`${logPrefix} ${tag}core: bkit.githubProject named its ${moment} Status option by id; set bkit.github.${moment} to that option's name (default "${CONFIG_DEFAULTS.github[moment]}")`);
|
|
400
|
+
return true;
|
|
401
|
+
}
|
|
402
|
+
// Migration (up to 5.4.x installs, `docs/migrations.md`): the Linear team lived at
|
|
403
|
+
// `bkit.linearTeam`; it is `bkit.linear.team`, beside the project and state names. An
|
|
404
|
+
// existing `bkit.linear.team` wins over the old key. Returns true when package.json changed.
|
|
405
|
+
export function migrateLinearTeamKey(dryRun, ws, logPrefix) {
|
|
406
|
+
const pkgPath = "package.json";
|
|
407
|
+
if (!fs.existsSync(pkgPath))
|
|
408
|
+
return false;
|
|
409
|
+
const raw = fs.readFileSync(pkgPath, "utf-8");
|
|
410
|
+
const parsed = parseJson(raw);
|
|
411
|
+
if (!parsed.ok)
|
|
412
|
+
return false;
|
|
413
|
+
const pkg = parsed.value;
|
|
414
|
+
const bkit = pkg.bkit;
|
|
415
|
+
if (bkit === null || typeof bkit !== "object" || Array.isArray(bkit))
|
|
416
|
+
return false;
|
|
417
|
+
const cfg = bkit;
|
|
418
|
+
if (!Object.prototype.hasOwnProperty.call(cfg, "linearTeam"))
|
|
419
|
+
return false;
|
|
420
|
+
const old = cfg.linearTeam;
|
|
421
|
+
const linear = cfg.linear !== null && typeof cfg.linear === "object" && !Array.isArray(cfg.linear)
|
|
422
|
+
? cfg.linear
|
|
423
|
+
: {};
|
|
424
|
+
if (linear.team === undefined && typeof old === "string" && old.trim() !== "")
|
|
425
|
+
linear.team = old;
|
|
426
|
+
delete cfg.linearTeam;
|
|
427
|
+
if (Object.keys(linear).length > 0)
|
|
428
|
+
cfg.linear = linear;
|
|
429
|
+
ws.writes.push({ path: pkgPath, action: "update" });
|
|
430
|
+
if (!dryRun)
|
|
431
|
+
writePackageJsonLike(raw, pkg);
|
|
432
|
+
console.log(`${logPrefix} ${dryRun ? "[dry-run] " : ""}core: moved bkit.linearTeam to bkit.linear.team in package.json`);
|
|
433
|
+
return true;
|
|
434
|
+
}
|
|
320
435
|
// Tokens that follow `pnpm` in a gate value but are not package.json scripts: the
|
|
321
436
|
// package manager's own subcommands (`install` in bkit:gate:install-static-unit-build,
|
|
322
437
|
// `audit` / `outdated` in the bkit:deps:* pair) and node_modules binaries pnpm resolves
|
|
@@ -330,10 +445,32 @@ const PNPM_NOT_A_SCRIPT = new Set([
|
|
|
330
445
|
"outdated",
|
|
331
446
|
"lint-staged",
|
|
332
447
|
]);
|
|
448
|
+
/**
|
|
449
|
+
* The scripts a gate ends up running: each `pnpm <script>` / `pnpm run <script>` it calls,
|
|
450
|
+
* with every `bkit:gate:*` it chains expanded in place. pnpm's own subcommands and
|
|
451
|
+
* binaries are left out.
|
|
452
|
+
*/
|
|
453
|
+
export function gateLeafScripts(gate, declared, seen = new Set()) {
|
|
454
|
+
const value = declared[gate];
|
|
455
|
+
if (typeof value !== "string" || seen.has(gate))
|
|
456
|
+
return [];
|
|
457
|
+
seen.add(gate);
|
|
458
|
+
const leaves = [];
|
|
459
|
+
for (const [, called] of value.matchAll(/\bpnpm (?:run )?([\w:-]+)/g)) {
|
|
460
|
+
if (PNPM_NOT_A_SCRIPT.has(called))
|
|
461
|
+
continue;
|
|
462
|
+
if (called.startsWith("bkit:gate:"))
|
|
463
|
+
leaves.push(...gateLeafScripts(called, declared, seen));
|
|
464
|
+
else
|
|
465
|
+
leaves.push(called);
|
|
466
|
+
}
|
|
467
|
+
return leaves;
|
|
468
|
+
}
|
|
333
469
|
/**
|
|
334
470
|
* Advisories for the `bkit:gate:*` scripts: the scripts a still-default gate
|
|
335
471
|
* chains that package.json does not declare, the deeper test tiers the repo has
|
|
336
|
-
* but no gate runs,
|
|
472
|
+
* but no gate runs, a commit gate that repeats the push gate, and a missing
|
|
473
|
+
* `bkit:test:file`. Judges the scripts as install
|
|
337
474
|
* leaves them (missing gate names at their seeded defaults), so install, `bkit check`
|
|
338
475
|
* and `bkit upgrade` report the same set. Read-only; an absent or unparseable
|
|
339
476
|
* package.json yields none.
|
|
@@ -384,12 +521,27 @@ export function detectGateAdvisories(cwd) {
|
|
|
384
521
|
findings.push({
|
|
385
522
|
id: "gate-tier-not-wired",
|
|
386
523
|
severity: "advisory",
|
|
387
|
-
detect: "package.json declares deeper test tiers than any `bkit:gate*` script runs, so `/bkit-build
|
|
388
|
-
action: "Each workflow runs the DEEPEST gate you declare; an undeclared one is skipped, never guessed. Add the gates you want the agent loop to run:\n\n" +
|
|
524
|
+
detect: "package.json declares deeper test tiers than any `bkit:gate*` script runs, so `/bkit-build`, `/bkit-debug` and the pre-push hook gate at `bkit:gate:static-unit` and never execute them.",
|
|
525
|
+
action: "Each workflow runs the DEEPEST gate you declare, and `.husky/pre-push` runs `bkit:gate:static-unit-integration` when it is declared; an undeclared one is skipped, never guessed. Add the gates you want the agent loop to run:\n\n" +
|
|
389
526
|
unwired.join("\n") +
|
|
390
527
|
"\n\nOrder matters — each chains the one above it. Omit a level deliberately to keep it CI-only (E2E in the build loop costs a production build on every remediation attempt). `.bkit/templates.md` lists the tool scripts the gates chain.",
|
|
391
528
|
});
|
|
392
529
|
}
|
|
530
|
+
// The commit gate is the fast one: a script it shares with the push gate runs on every
|
|
531
|
+
// commit and again on the push that carries it.
|
|
532
|
+
const pushGate = BKIT_PUSH_GATES.find((g) => g in declared);
|
|
533
|
+
const commitCalls = pushGate === undefined ? [] : gateLeafScripts("bkit:gate:format", declared);
|
|
534
|
+
const pushCalls = new Set(pushGate === undefined ? [] : gateLeafScripts(pushGate, declared));
|
|
535
|
+
const repeated = [...new Set(commitCalls.filter((s) => pushCalls.has(s)))].sort();
|
|
536
|
+
if (repeated.length > 0) {
|
|
537
|
+
const names = repeated.map((n) => `\`${n}\``).join(", ");
|
|
538
|
+
findings.push({
|
|
539
|
+
id: "gate-commit-repeats-push",
|
|
540
|
+
severity: "advisory",
|
|
541
|
+
detect: `\`bkit:gate:format\` (pre-commit) runs ${names}, which \`${pushGate}\` (pre-push) runs again.`,
|
|
542
|
+
action: `Drop ${names} from \`bkit:gate:format\`. The commit gate formats staged files and nothing else; every whole-repo check runs once, at pre-push.`,
|
|
543
|
+
});
|
|
544
|
+
}
|
|
393
545
|
// /bkit-build records each task's red through this script; without it test-first is
|
|
394
546
|
// reported as not enforced. bkit cannot seed it: what runs one file is the stack's.
|
|
395
547
|
if (!(BKIT_TEST_FILE_SCRIPT in declared)) {
|
|
@@ -212,6 +212,12 @@ export function renderOpencodeJson(templatePath, tracker, provider, cwd = proces
|
|
|
212
212
|
else if (tracker === "linear") {
|
|
213
213
|
mcpEntry = '"linear": { "type": "remote", "url": "https://mcp.linear.app/mcp" }';
|
|
214
214
|
}
|
|
215
|
+
else if (tracker === "jira") {
|
|
216
|
+
// Same "oauth": false reason as github: the API token in the header is the only auth
|
|
217
|
+
// bkit wires, so a bad one fails as a 401, not as an OAuth sign-in prompt.
|
|
218
|
+
mcpEntry =
|
|
219
|
+
'"jira": { "type": "remote", "url": "https://mcp.atlassian.com/v2/mcp", "oauth": false, "headers": { "Authorization": "Bearer {env:BKIT_JIRA_API_TOKEN}" } }';
|
|
220
|
+
}
|
|
215
221
|
else {
|
|
216
222
|
mcpEntry = "";
|
|
217
223
|
}
|
package/dist/install/write.js
CHANGED
|
@@ -238,6 +238,24 @@ export function writeTier2JsonContained(srcPath, dstPath, dryRun, ws) {
|
|
|
238
238
|
export function ensureDir(dir) {
|
|
239
239
|
fs.mkdirSync(dir, { recursive: true });
|
|
240
240
|
}
|
|
241
|
+
/**
|
|
242
|
+
* Give an existing `dstPath` the executable bits `srcPath` carries. Hosts run some hooks
|
|
243
|
+
* directly (Cursor's `bkit-preflight.sh`), so a lost bit is drift: recorded in `ws` (a dry
|
|
244
|
+
* run included, so `bkit check` fails) and restored on a real run. No-op on Windows.
|
|
245
|
+
*/
|
|
246
|
+
export function restoreExecBits(srcPath, dstPath, dryRun, ws) {
|
|
247
|
+
if (process.platform === "win32" || !fs.existsSync(dstPath))
|
|
248
|
+
return;
|
|
249
|
+
const execBits = fs.statSync(srcPath).mode & 0o111;
|
|
250
|
+
const dstMode = fs.statSync(dstPath).mode;
|
|
251
|
+
if ((dstMode & execBits) === execBits)
|
|
252
|
+
return;
|
|
253
|
+
if (!dryRun)
|
|
254
|
+
fs.chmodSync(dstPath, (dstMode | execBits) & 0o7777);
|
|
255
|
+
if (!ws.writes.some((w) => w.path === dstPath)) {
|
|
256
|
+
ws.writes.push({ path: dstPath, action: "update" });
|
|
257
|
+
}
|
|
258
|
+
}
|
|
241
259
|
// ---------------------------------------------------------------------------
|
|
242
260
|
// fully-managed format — idempotent rewrite of whole file after token substitution
|
|
243
261
|
//
|
|
@@ -249,8 +267,10 @@ export function writeTier1(srcPath, dstPath, tokens, dryRun, ws) {
|
|
|
249
267
|
const srcContent = applyTokens(srcRaw, tokens);
|
|
250
268
|
if (fs.existsSync(dstPath)) {
|
|
251
269
|
const existing = fs.readFileSync(dstPath, "utf-8");
|
|
252
|
-
if (existing === srcContent)
|
|
253
|
-
|
|
270
|
+
if (existing === srcContent) {
|
|
271
|
+
restoreExecBits(srcPath, dstPath, dryRun, ws);
|
|
272
|
+
return;
|
|
273
|
+
}
|
|
254
274
|
}
|
|
255
275
|
ensureDir(path.dirname(dstPath));
|
|
256
276
|
if (!dryRun) {
|
|
@@ -317,6 +337,10 @@ function hasRetiredDriver(dstPath, content, markerStyle) {
|
|
|
317
337
|
return false;
|
|
318
338
|
}
|
|
319
339
|
export function writeTier2(srcPath, dstPath, tokens, markerStyle, dryRun, ws) {
|
|
340
|
+
writeTier2Content(srcPath, dstPath, tokens, markerStyle, dryRun, ws);
|
|
341
|
+
restoreExecBits(srcPath, dstPath, dryRun, ws);
|
|
342
|
+
}
|
|
343
|
+
function writeTier2Content(srcPath, dstPath, tokens, markerStyle, dryRun, ws) {
|
|
320
344
|
const srcRaw = readTemplate(srcPath);
|
|
321
345
|
// A retired, unedited bkit driver is bkit's code, not the consumer's: replace the
|
|
322
346
|
// whole file so the new driver ships with the new block.
|