@cbartens/bkit 5.3.0 → 5.5.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 +20 -7
- package/.bkit/core/.agents/docs.md +1 -1
- package/.bkit/core/.agents/rules.md +14 -9
- package/.bkit/core/.bkit/README.md +19 -6
- package/.bkit/core/.bkit/cloud.md +77 -46
- package/.bkit/core/.bkit/comparison.md +3 -3
- package/.bkit/core/.bkit/install.md +21 -18
- package/.bkit/core/.bkit/lite.md +6 -6
- package/.bkit/core/.bkit/pipeline.md +6 -3
- package/.bkit/core/.bkit/prompts.md +14 -10
- package/.bkit/core/.bkit/providers.md +7 -7
- package/.bkit/core/.bkit/templates.md +46 -10
- package/.bkit/core/.bkit/trackers.md +92 -38
- package/.bkit/core/.bkit/workflows.md +140 -116
- package/.bkit/core/AGENTS.md +2 -2
- package/.bkit/core/docs/templates/bkit-audit-accessibility.md +3 -2
- package/.bkit/core/docs/templates/bkit-audit-adoption.md +1 -1
- 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 +2 -2
- 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 +14 -13
- 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 +25 -8
- package/.bkit/core/docs/templates/bkit-audit-llm.md +3 -2
- 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 +5 -5
- package/.bkit/core/docs/templates/bkit-audit-red-team.md +3 -2
- package/.bkit/core/docs/templates/bkit-audit-reliability.md +3 -2
- package/.bkit/core/docs/templates/bkit-audit-repo.md +1 -1
- package/.bkit/core/docs/templates/bkit-audit-security.md +11 -9
- package/.bkit/core/docs/templates/bkit-audit-slop.md +1 -1
- package/.bkit/core/docs/templates/bkit-audit-testing.md +6 -5
- package/.bkit/core/docs/templates/bkit-audit-usability.md +1 -1
- package/.bkit/core/engine/checks/after/auth.ts +88 -45
- package/.bkit/core/engine/checks/after/github.ts +18 -5
- package/.bkit/core/engine/checks/after/index.ts +1 -1
- 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/status-holes.ts +0 -1
- package/.bkit/core/engine/checks/tips/catalogue.ts +31 -2
- package/.bkit/core/engine/checks/tips/index.ts +49 -27
- package/.bkit/core/engine/cli.ts +27 -18
- package/.bkit/core/engine/commands/ci/ci.ts +107 -0
- package/.bkit/core/engine/commands/comply.ts +25 -16
- package/.bkit/core/engine/commands/install/install.ts +11 -4
- package/.bkit/core/engine/commands/install/uninstall.ts +46 -0
- package/.bkit/core/engine/commands/land.ts +156 -0
- package/.bkit/core/engine/commands/lib.ts +10 -8
- package/.bkit/core/engine/commands/registry.ts +2 -0
- package/.bkit/core/engine/commands/tips.ts +7 -3
- package/.bkit/core/engine/commands/workflow/branches.ts +382 -282
- package/.bkit/core/engine/commands/workflow/disk.ts +556 -0
- package/.bkit/core/engine/commands/workflow/fids.ts +23 -15
- package/.bkit/core/engine/commands/workflow/issues.ts +106 -42
- package/.bkit/core/engine/commands/workflow/ledgers.ts +28 -11
- package/.bkit/core/engine/commands/workflow/locks.ts +38 -152
- package/.bkit/core/engine/commands/workflow/prs.ts +14 -3
- package/.bkit/core/engine/commands/workflow/repo.ts +6 -0
- package/.bkit/core/engine/commands/workflow/roadmap.ts +53 -54
- 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 +26 -17
- package/.bkit/core/engine/commands/workflow/workflows.ts +442 -269
- package/.bkit/core/engine/commands/workflow/workstreams.ts +3 -2
- package/.bkit/core/engine/commands/workflow/worktrees.ts +11 -1
- 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 +97 -4
- package/.bkit/core/engine/install/modules/opencode.ts +5 -0
- package/.bkit/core/engine/install/placeholders.ts +13 -17
- 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 +96 -1
- package/.bkit/core/engine/shared/timeouts.ts +8 -7
- package/.bkit/core/hooks/guardrails-tiers.js +1 -1
- package/.bkit/core/prompts/bkit-audit-generate.md +80 -7
- 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-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 +2 -1
- package/.bkit/core/prompts/bkit-ship-conflict-resolve.md +1 -1
- package/.bkit/core/prompts/bkit-utility-update-decisions.md +4 -2
- package/.bkit/core/prompts/bkit-utility-update-deferrals.md +4 -2
- package/.bkit/core/prompts/bkit-utility-update-documentation.md +12 -2
- package/.bkit/core/prompts/bkit-utility-update-failures.md +4 -2
- package/.bkit/core/prompts/bkit-utility-update-knowledge.md +4 -2
- package/.bkit/core/prompts/bkit-utility-update-roadmap.md +12 -5
- 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 +64 -22
- package/.bkit/core/workflows/bkit-debug.md +72 -28
- package/.bkit/core/workflows/bkit-design.md +101 -37
- package/.bkit/core/workflows/bkit-plan.md +82 -31
- package/.bkit/core/workflows/bkit-ship.md +127 -108
- package/.bkit/shared/.bkit/.env.example +8 -0
- package/.bkit/shared/.claude/bkit-cloud.md +12 -12
- package/.bkit/shared/.claude/settings.json +4 -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 +44 -29
- package/.bkit/shared/docs/security.md +1 -1
- package/.bkit/shared/docs/testing.md +3 -3
- package/.bkit/shared/gitignore +1 -2
- package/.bkit/templates/.github/ISSUE_TEMPLATE/bkit-change.yml +2 -2
- package/.bkit/templates/.github/renovate.json5 +1 -1
- package/.bkit/templates/.github/workflows/bkit-ci.yml +29 -56
- package/.bkit/templates/.github/workflows/bkit-cloud.yml +40 -12
- package/.bkit/templates/.husky/pre-commit +10 -4
- package/.bkit/templates/.husky/pre-push +69 -12
- package/.bkit/templates/.lintstagedrc.json +5 -1
- package/.bkit/templates/scripts/ci/lanes/check-tree-cache.mjs +138 -0
- package/.bkit/templates/scripts/ci/lanes/check-tree-cache.test.mjs +181 -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-graphify.sh +1 -1
- package/CHANGELOG.md +85 -1
- package/README.md +102 -100
- package/dist/checks/after/auth.js +81 -45
- package/dist/checks/after/github.js +17 -5
- package/dist/checks/after/index.js +1 -1
- 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/status-holes.js +0 -1
- package/dist/checks/tips/catalogue.js +28 -2
- package/dist/checks/tips/index.js +44 -28
- package/dist/cli.js +27 -19
- package/dist/commands/ci/ci.js +100 -0
- package/dist/commands/comply.js +20 -13
- package/dist/commands/install/install.js +10 -4
- package/dist/commands/install/uninstall.js +42 -0
- package/dist/commands/land.js +129 -0
- package/dist/commands/lib.js +9 -6
- package/dist/commands/registry.js +2 -0
- package/dist/commands/tips.js +7 -3
- package/dist/commands/workflow/branches.js +300 -243
- package/dist/commands/workflow/disk.js +452 -0
- package/dist/commands/workflow/fids.js +22 -15
- package/dist/commands/workflow/issues.js +90 -41
- package/dist/commands/workflow/ledgers.js +26 -11
- package/dist/commands/workflow/locks.js +35 -130
- package/dist/commands/workflow/prs.js +8 -3
- package/dist/commands/workflow/repo.js +5 -0
- package/dist/commands/workflow/roadmap.js +52 -57
- package/dist/commands/workflow/runtime.js +3 -2
- package/dist/commands/workflow/status.js +32 -12
- package/dist/commands/workflow/steps.js +20 -13
- package/dist/commands/workflow/workflows.js +397 -251
- package/dist/commands/workflow/workstreams.js +3 -2
- package/dist/commands/workflow/worktrees.js +11 -1
- package/dist/install/manifest.js +30 -10
- package/dist/install/modules/cloud.js +3 -1
- package/dist/install/modules/core.js +95 -5
- package/dist/install/modules/opencode.js +6 -0
- package/dist/install/placeholders.js +13 -19
- 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 +44 -0
- package/dist/shared/timeouts.js +8 -7
- package/package.json +11 -2
|
@@ -90,13 +90,14 @@ export function commentBody(
|
|
|
90
90
|
opts: { ownerRepo: string; month: string; fid: string },
|
|
91
91
|
): string {
|
|
92
92
|
const doc = `docs/plans/${opts.month}/${opts.fid}-design.md`;
|
|
93
|
+
const url = `https://github.com/${opts.ownerRepo}/blob/dev/${doc}`;
|
|
93
94
|
return [
|
|
94
95
|
"###### bkit:generated",
|
|
95
96
|
"### Step 11 — Suggested Workstreams",
|
|
96
97
|
"Advisory only. NEVER auto-trigger.",
|
|
97
98
|
...ws.map((w) => `- ${w.id}: ${w.name}. Requires: ${requiresList(w)}`),
|
|
98
|
-
`Filing one issue per workstream: put \`**Parent design:** [${opts.fid}-design.md](${
|
|
99
|
-
`[${doc}](
|
|
99
|
+
`Filing one issue per workstream: put \`**Parent design:** [${opts.fid}-design.md](${url})\` in its body, and list the issues it requires in a blocked-by block (.bkit/trackers.md § Issue shapes).`,
|
|
100
|
+
`[${doc}](${url})`,
|
|
100
101
|
].join("\n");
|
|
101
102
|
}
|
|
102
103
|
|
|
@@ -27,6 +27,7 @@ import {
|
|
|
27
27
|
runGit,
|
|
28
28
|
type CommandSpec,
|
|
29
29
|
} from "../lib.js";
|
|
30
|
+
import { ensureDiskSpace } from "./disk.js";
|
|
30
31
|
import { detect } from "./runtime.js";
|
|
31
32
|
import { WORKFLOW_FLAG } from "./status.js";
|
|
32
33
|
|
|
@@ -42,6 +43,7 @@ export const EXIT_WORKTREE_ADD = 8;
|
|
|
42
43
|
export const EXIT_REBASE_NOT_STARTED = 9;
|
|
43
44
|
export const EXIT_NOT_A_WORKTREE = 10;
|
|
44
45
|
export const EXIT_REMOVE = 11;
|
|
46
|
+
export const EXIT_DISK_FULL = 12;
|
|
45
47
|
|
|
46
48
|
const FID_FLAG = { name: "fid", type: "string", required: true, help: "feature id" } as const;
|
|
47
49
|
|
|
@@ -348,8 +350,10 @@ export const worktreesCommand: CommandSpec = {
|
|
|
348
350
|
[EXIT_WORKTREE_ADD]: "git worktree add failed",
|
|
349
351
|
[EXIT_REBASE_NOT_STARTED]: "resume rebase could not start (e.g. uncommitted changes)",
|
|
350
352
|
[EXIT_NOT_A_WORKTREE]: ".worktrees/{fid} exists but is not a registered git worktree",
|
|
353
|
+
[EXIT_DISK_FULL]:
|
|
354
|
+
"free disk under bkit.disk.minFreeGb even after your max cleanup steps (`bkit disk prune`); nothing created",
|
|
351
355
|
},
|
|
352
|
-
run: (ctx) => {
|
|
356
|
+
run: async (ctx) => {
|
|
353
357
|
const f = ctx.flags;
|
|
354
358
|
const workflow = String(f.workflow);
|
|
355
359
|
if (!WORKFLOWS.includes(workflow)) {
|
|
@@ -392,6 +396,12 @@ export const worktreesCommand: CommandSpec = {
|
|
|
392
396
|
const wtDir = worktreeDir(root, fid);
|
|
393
397
|
let mode: "created" | "resumed" | "adopted" = "adopted";
|
|
394
398
|
if (mint) {
|
|
399
|
+
const full = await ensureDiskSpace({
|
|
400
|
+
cwd: root,
|
|
401
|
+
minFreeGb: config.diskMinFreeGb,
|
|
402
|
+
log: ctx.log,
|
|
403
|
+
});
|
|
404
|
+
if (full !== null) throw new CommandError(EXIT_DISK_FULL, full);
|
|
395
405
|
runGit(root, ["worktree", "prune"]);
|
|
396
406
|
if (fs.existsSync(wtDir)) {
|
|
397
407
|
// A plain directory there would resolve to the main checkout's repo,
|
|
@@ -53,14 +53,16 @@ export type ModuleName =
|
|
|
53
53
|
|
|
54
54
|
/**
|
|
55
55
|
* Issue-tracker providers supported by `bkit install --tracker=<name>`.
|
|
56
|
-
* - `github` — GitHub Issues + Projects v2
|
|
57
|
-
* - `linear` — Linear
|
|
58
|
-
* - `
|
|
56
|
+
* - `github` — GitHub Issues + Projects v2.
|
|
57
|
+
* - `linear` — Linear.
|
|
58
|
+
* - `jira` — Jira Cloud through the Atlassian Rovo MCP server.
|
|
59
|
+
* - `none` — no tracker wired; workflows skip tracker calls with one-line log (default).
|
|
59
60
|
*
|
|
60
|
-
*
|
|
61
|
-
*
|
|
61
|
+
* A new value needs its block in every tracker group of the workflow and prompt
|
|
62
|
+
* sources (`.bkit/trackers.md` § Marker contract) and a branch in
|
|
63
|
+
* `render/trackers.ts`.
|
|
62
64
|
*/
|
|
63
|
-
export const ISSUE_TRACKERS = ["github", "linear", "none"] as const;
|
|
65
|
+
export const ISSUE_TRACKERS = ["github", "linear", "jira", "none"] as const;
|
|
64
66
|
export type IssueTracker = (typeof ISSUE_TRACKERS)[number];
|
|
65
67
|
|
|
66
68
|
/** Default tracker when consumer manifest has no `bkit.issueTracker` field. */
|
|
@@ -204,7 +206,9 @@ const CLAUDE_MANIFEST: ManifestEntry[] = [
|
|
|
204
206
|
// ONE CHAIN. Each gate is the previous gate plus its own tier; the NAME and the
|
|
205
207
|
// VALUE describe the same sequence. Tier vocabulary is the `bkit-ci.yml` job ids
|
|
206
208
|
// (bkit-tests-static / -unit / -integration / -e2e / -live). Where a step is not a
|
|
207
|
-
// tier (`format`, the ship gate) the name spells out the actual steps.
|
|
209
|
+
// tier (`format`, the ship gate) the name spells out the actual steps. One exception:
|
|
210
|
+
// `min` sits off the chain: the least a push runs, on a push that changes no code
|
|
211
|
+
// (`bkit.minPushPaths`); its steps are whatever that push can still break.
|
|
208
212
|
//
|
|
209
213
|
// The consumer owns every value: a turbo monorepo writes `turbo run … --filter`,
|
|
210
214
|
// a Python repo writes `ruff check && pytest`. bkit never reads a value — only
|
|
@@ -228,18 +232,24 @@ const CLAUDE_MANIFEST: ManifestEntry[] = [
|
|
|
228
232
|
// …-integration-e2e-live) are absent unless the consumer writes them. Each is one line
|
|
229
233
|
// chaining its parent, e.g.
|
|
230
234
|
// "bkit:gate:static-unit-integration": "pnpm bkit:gate:static-unit && pnpm test:integration"
|
|
231
|
-
// `/bkit-build` and `/bkit-debug` run the DEEPEST gate that exists and record its name
|
|
235
|
+
// `/bkit-build` and `/bkit-debug` run the DEEPEST gate that exists and record its name;
|
|
236
|
+
// `.husky/pre-push` runs `…-integration` when it exists (BKIT_PUSH_GATES).
|
|
232
237
|
export const BKIT_GATE_SCRIPTS: Readonly<Record<string, string>> = {
|
|
233
238
|
// `.husky/pre-commit`: prettier --write over staged files, and nothing else —
|
|
234
239
|
// seconds, not minutes. Prose is a whole-repo scan, so it gates at pre-push.
|
|
235
240
|
"bkit:gate:format": "pnpm lint-staged",
|
|
241
|
+
// `.husky/pre-push` on a min push (every file matches `bkit.minPushPaths`): no code, so
|
|
242
|
+
// no typecheck, lint or tests. Off the chain. Add any test that reads a min-push file.
|
|
243
|
+
"bkit:gate:min": "pnpm format:check && pnpm lint:prose && pnpm slop:delta",
|
|
236
244
|
// Everything that needs no test runner. Every part has a matching step in the
|
|
237
245
|
// bkit-tests-static CI job; audits/templates/template-ci-yml.test.ts fails when one is missing.
|
|
238
246
|
// Callers: build's plan-execute loop between tasks, and the `.husky/pre-push` revert
|
|
239
247
|
// path.
|
|
240
248
|
"bkit:gate:static":
|
|
241
249
|
"pnpm typecheck && pnpm lint && pnpm format:check && pnpm lint:prose && pnpm slop:delta",
|
|
242
|
-
// The default local gate: `.husky/pre-push
|
|
250
|
+
// The default local gate: `.husky/pre-push` (when no `…-integration` gate is declared),
|
|
251
|
+
// build Step 14, the remediates. `pnpm test` is the unit tier only: a test file the
|
|
252
|
+
// integration gate also runs must not match it.
|
|
243
253
|
"bkit:gate:static-unit": "pnpm bkit:gate:static && pnpm test",
|
|
244
254
|
// Ship's conflict-resolve, the only caller whose dependency graph may have just
|
|
245
255
|
// been hand-merged (lockfile conflict) and whose tree no one has ever compiled.
|
|
@@ -276,13 +286,24 @@ export const BKIT_DEBUG_GATES: readonly string[] = [
|
|
|
276
286
|
* Build stops at integration; E2E and live are not in this list.
|
|
277
287
|
*
|
|
278
288
|
* Neither entry is seeded: declaring `bkit:gate:static-unit-integration` opts the build
|
|
279
|
-
* loop into the integration tier.
|
|
289
|
+
* loop and the pre-push hook into the integration tier.
|
|
280
290
|
*/
|
|
281
291
|
export const BKIT_BUILD_GATES: readonly string[] = [
|
|
282
292
|
"bkit:gate:static-unit-integration",
|
|
283
293
|
"bkit:gate:static-unit",
|
|
284
294
|
];
|
|
285
295
|
|
|
296
|
+
/**
|
|
297
|
+
* What `.husky/pre-push` runs on a full push, in DESCENDING order — first one declared wins.
|
|
298
|
+
*
|
|
299
|
+
* Integration runs on push, never on commit; E2E and live stay in CI. The template hook
|
|
300
|
+
* reads package.json for the first entry itself (it cannot import this list).
|
|
301
|
+
*/
|
|
302
|
+
export const BKIT_PUSH_GATES: readonly string[] = [
|
|
303
|
+
"bkit:gate:static-unit-integration",
|
|
304
|
+
"bkit:gate:static-unit",
|
|
305
|
+
];
|
|
306
|
+
|
|
286
307
|
/**
|
|
287
308
|
* Runs ONE test file — `pnpm bkit:test:file <repo-relative path>` — and writes a JUnit
|
|
288
309
|
* report to `$BKIT_TEST_REPORT`. `/bkit-build` records each task's red and audits its
|
|
@@ -86,7 +86,9 @@ export function runCloudModule(ctx: ModuleContext): void {
|
|
|
86
86
|
CLOUD_WORKFLOW_ADOPT_STEP +
|
|
87
87
|
" - 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" +
|
|
88
88
|
" - 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" +
|
|
89
|
-
" -
|
|
89
|
+
" - Give `claude-code-action@v1` ONE claude credential (Settings → Secrets and variables → Actions):\n" +
|
|
90
|
+
" - the `ANTHROPIC_API_KEY` repo secret (job env keeps this vendor name; local `.bkit/.env` stores it as `BKIT_ANTHROPIC_API_KEY`), or\n" +
|
|
91
|
+
" - 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" +
|
|
90
92
|
" - Label the issue `bkit:auto` before pushing the build commit — without the label the CI auto-route exits no-op.\n\n" +
|
|
91
93
|
"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" +
|
|
92
94
|
"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`).",
|
|
@@ -17,7 +17,7 @@ import { listFilesRecursive, syncTemplateCopies } from "../template-copies.js";
|
|
|
17
17
|
import { PAYLOAD_LINK_RELPATHS, syncPayloadLinks } from "../payload-links.js";
|
|
18
18
|
import { writeNetworkAllowlist } from "../network-allowlist.js";
|
|
19
19
|
import type { PreflightFinding } from "../../checks/before/index.js";
|
|
20
|
-
import { readJsonFile } from "../../shared/json.js";
|
|
20
|
+
import { parseJson, readJsonFile } from "../../shared/json.js";
|
|
21
21
|
import { readInstallingVersion } from "../../shared/package-json.js";
|
|
22
22
|
import {
|
|
23
23
|
getCoreRoot,
|
|
@@ -29,6 +29,7 @@ import {
|
|
|
29
29
|
getInstallManifest,
|
|
30
30
|
BKIT_GATE_SCRIPTS,
|
|
31
31
|
BKIT_OPTIONAL_GATES,
|
|
32
|
+
BKIT_PUSH_GATES,
|
|
32
33
|
BKIT_TEST_FILE_SCRIPT,
|
|
33
34
|
} from "../manifest.js";
|
|
34
35
|
import type { ModuleContext } from "./index.js";
|
|
@@ -299,6 +300,7 @@ export function runBkitDocs(
|
|
|
299
300
|
}
|
|
300
301
|
}
|
|
301
302
|
migrateShortcutsToLite(dryRun, ws, logPrefix);
|
|
303
|
+
migrateRetiredDevLock(dryRun, ws, logPrefix);
|
|
302
304
|
}
|
|
303
305
|
|
|
304
306
|
// Migration (5.1.0 – 5.2.4 installs, `docs/migrations.md`): the lite workflows lived at
|
|
@@ -338,6 +340,20 @@ export function migrateShortcutsToLite(dryRun: boolean, ws: WriteSet, logPrefix:
|
|
|
338
340
|
console.log(`${logPrefix} ${tag}core: moved ${RETIRED_SHORTCUTS} → ${dst}`);
|
|
339
341
|
}
|
|
340
342
|
|
|
343
|
+
// Migration (installs up to 5.3.x, `docs/migrations.md`): `.bkit/.dev.lock` was the
|
|
344
|
+
// repo-wide dev lock. Nothing reads it now, so one a crashed run left behind is deleted.
|
|
345
|
+
// bkit owned the name whole. Recorded in ws so `bkit check` fails until upgrade runs.
|
|
346
|
+
const RETIRED_DEV_LOCK = path.join(".bkit", ".dev.lock");
|
|
347
|
+
|
|
348
|
+
export function migrateRetiredDevLock(dryRun: boolean, ws: WriteSet, logPrefix: string): void {
|
|
349
|
+
if (!fs.lstatSync(RETIRED_DEV_LOCK, { throwIfNoEntry: false })?.isFile()) return;
|
|
350
|
+
if (!dryRun) fs.rmSync(RETIRED_DEV_LOCK);
|
|
351
|
+
ws.writes.push({ path: RETIRED_DEV_LOCK, action: "write" });
|
|
352
|
+
console.log(
|
|
353
|
+
`${logPrefix} ${dryRun ? "[dry-run] " : ""}core: removed ${RETIRED_DEV_LOCK} (the dev lock is gone)`,
|
|
354
|
+
);
|
|
355
|
+
}
|
|
356
|
+
|
|
341
357
|
// ---------------------------------------------------------------------------
|
|
342
358
|
// Source-rendered host outputs — agents (.agents/prompts source) and commands
|
|
343
359
|
// (.bkit/workflows source). Extracted from the host module functions so BOTH
|
|
@@ -377,9 +393,47 @@ export function seedCorePackageJsonScripts(
|
|
|
377
393
|
written.push("package.json");
|
|
378
394
|
console.log(`${logPrefix} ${tag}core: package.json scripts added [${gates.added.join(", ")}]`);
|
|
379
395
|
}
|
|
396
|
+
if (migrateLinearTeamKey(dryRun, ws, logPrefix) && !written.includes("package.json")) {
|
|
397
|
+
written.push("package.json");
|
|
398
|
+
}
|
|
380
399
|
return written;
|
|
381
400
|
}
|
|
382
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: boolean, ws: WriteSet, logPrefix: string): boolean {
|
|
406
|
+
const pkgPath = "package.json";
|
|
407
|
+
if (!fs.existsSync(pkgPath)) return false;
|
|
408
|
+
const raw = fs.readFileSync(pkgPath, "utf-8");
|
|
409
|
+
const parsed = parseJson(raw);
|
|
410
|
+
if (!parsed.ok) return false;
|
|
411
|
+
const pkg = parsed.value as Record<string, unknown>;
|
|
412
|
+
const bkit = pkg.bkit;
|
|
413
|
+
if (bkit === null || typeof bkit !== "object" || Array.isArray(bkit)) return false;
|
|
414
|
+
const cfg = bkit as Record<string, unknown>;
|
|
415
|
+
if (!Object.prototype.hasOwnProperty.call(cfg, "linearTeam")) return false;
|
|
416
|
+
const old = cfg.linearTeam;
|
|
417
|
+
const linear =
|
|
418
|
+
cfg.linear !== null && typeof cfg.linear === "object" && !Array.isArray(cfg.linear)
|
|
419
|
+
? (cfg.linear as Record<string, unknown>)
|
|
420
|
+
: {};
|
|
421
|
+
if (linear.team === undefined && typeof old === "string" && old.trim() !== "") linear.team = old;
|
|
422
|
+
delete cfg.linearTeam;
|
|
423
|
+
if (Object.keys(linear).length > 0) cfg.linear = linear;
|
|
424
|
+
ws.writes.push({ path: pkgPath, action: "update" });
|
|
425
|
+
if (!dryRun) {
|
|
426
|
+
const indentMatch = raw.match(/\n([ \t]+)"/);
|
|
427
|
+
const indent = indentMatch ? indentMatch[1] : " ";
|
|
428
|
+
const trailingNewline = raw.endsWith("\n") ? "\n" : "";
|
|
429
|
+
fs.writeFileSync(pkgPath, JSON.stringify(pkg, null, indent) + trailingNewline, "utf-8");
|
|
430
|
+
}
|
|
431
|
+
console.log(
|
|
432
|
+
`${logPrefix} ${dryRun ? "[dry-run] " : ""}core: moved bkit.linearTeam to bkit.linear.team in package.json`,
|
|
433
|
+
);
|
|
434
|
+
return true;
|
|
435
|
+
}
|
|
436
|
+
|
|
383
437
|
// Tokens that follow `pnpm` in a gate value but are not package.json scripts: the
|
|
384
438
|
// package manager's own subcommands (`install` in bkit:gate:install-static-unit-build,
|
|
385
439
|
// `audit` / `outdated` in the bkit:deps:* pair) and node_modules binaries pnpm resolves
|
|
@@ -394,10 +448,33 @@ const PNPM_NOT_A_SCRIPT = new Set([
|
|
|
394
448
|
"lint-staged",
|
|
395
449
|
]);
|
|
396
450
|
|
|
451
|
+
/**
|
|
452
|
+
* The scripts a gate ends up running: each `pnpm <script>` / `pnpm run <script>` it calls,
|
|
453
|
+
* with every `bkit:gate:*` it chains expanded in place. pnpm's own subcommands and
|
|
454
|
+
* binaries are left out.
|
|
455
|
+
*/
|
|
456
|
+
export function gateLeafScripts(
|
|
457
|
+
gate: string,
|
|
458
|
+
declared: Readonly<Record<string, string>>,
|
|
459
|
+
seen: Set<string> = new Set(),
|
|
460
|
+
): string[] {
|
|
461
|
+
const value = declared[gate];
|
|
462
|
+
if (typeof value !== "string" || seen.has(gate)) return [];
|
|
463
|
+
seen.add(gate);
|
|
464
|
+
const leaves: string[] = [];
|
|
465
|
+
for (const [, called] of value.matchAll(/\bpnpm (?:run )?([\w:-]+)/g)) {
|
|
466
|
+
if (PNPM_NOT_A_SCRIPT.has(called)) continue;
|
|
467
|
+
if (called.startsWith("bkit:gate:")) leaves.push(...gateLeafScripts(called, declared, seen));
|
|
468
|
+
else leaves.push(called);
|
|
469
|
+
}
|
|
470
|
+
return leaves;
|
|
471
|
+
}
|
|
472
|
+
|
|
397
473
|
/**
|
|
398
474
|
* Advisories for the `bkit:gate:*` scripts: the scripts a still-default gate
|
|
399
475
|
* chains that package.json does not declare, the deeper test tiers the repo has
|
|
400
|
-
* but no gate runs,
|
|
476
|
+
* but no gate runs, a commit gate that repeats the push gate, and a missing
|
|
477
|
+
* `bkit:test:file`. Judges the scripts as install
|
|
401
478
|
* leaves them (missing gate names at their seeded defaults), so install, `bkit check`
|
|
402
479
|
* and `bkit upgrade` report the same set. Read-only; an absent or unparseable
|
|
403
480
|
* package.json yields none.
|
|
@@ -446,14 +523,30 @@ export function detectGateAdvisories(cwd: string): PreflightFinding[] {
|
|
|
446
523
|
id: "gate-tier-not-wired",
|
|
447
524
|
severity: "advisory",
|
|
448
525
|
detect:
|
|
449
|
-
"package.json declares deeper test tiers than any `bkit:gate*` script runs, so `/bkit-build
|
|
526
|
+
"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.",
|
|
450
527
|
action:
|
|
451
|
-
"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" +
|
|
528
|
+
"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" +
|
|
452
529
|
unwired.join("\n") +
|
|
453
530
|
"\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.",
|
|
454
531
|
});
|
|
455
532
|
}
|
|
456
533
|
|
|
534
|
+
// The commit gate is the fast one: a script it shares with the push gate runs on every
|
|
535
|
+
// commit and again on the push that carries it.
|
|
536
|
+
const pushGate = BKIT_PUSH_GATES.find((g) => g in declared);
|
|
537
|
+
const commitCalls = pushGate === undefined ? [] : gateLeafScripts("bkit:gate:format", declared);
|
|
538
|
+
const pushCalls = new Set(pushGate === undefined ? [] : gateLeafScripts(pushGate, declared));
|
|
539
|
+
const repeated = [...new Set(commitCalls.filter((s) => pushCalls.has(s)))].sort();
|
|
540
|
+
if (repeated.length > 0) {
|
|
541
|
+
const names = repeated.map((n) => `\`${n}\``).join(", ");
|
|
542
|
+
findings.push({
|
|
543
|
+
id: "gate-commit-repeats-push",
|
|
544
|
+
severity: "advisory",
|
|
545
|
+
detect: `\`bkit:gate:format\` (pre-commit) runs ${names}, which \`${pushGate}\` (pre-push) runs again.`,
|
|
546
|
+
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.`,
|
|
547
|
+
});
|
|
548
|
+
}
|
|
549
|
+
|
|
457
550
|
// /bkit-build records each task's red through this script; without it test-first is
|
|
458
551
|
// reported as not enforced. bkit cannot seed it: what runs one file is the stack's.
|
|
459
552
|
if (!(BKIT_TEST_FILE_SCRIPT in declared)) {
|
|
@@ -263,6 +263,11 @@ export function renderOpencodeJson(
|
|
|
263
263
|
'"github": { "type": "remote", "url": "https://api.githubcopilot.com/mcp/", "oauth": false, "headers": { "Authorization": "Bearer {env:BKIT_GH_TOKEN}", "X-MCP-Toolsets": "context,issues,pull_requests,repos,users,projects,actions" } }';
|
|
264
264
|
} else if (tracker === "linear") {
|
|
265
265
|
mcpEntry = '"linear": { "type": "remote", "url": "https://mcp.linear.app/mcp" }';
|
|
266
|
+
} else if (tracker === "jira") {
|
|
267
|
+
// Same "oauth": false reason as github: the API token in the header is the only auth
|
|
268
|
+
// bkit wires, so a bad one fails as a 401, not as an OAuth sign-in prompt.
|
|
269
|
+
mcpEntry =
|
|
270
|
+
'"jira": { "type": "remote", "url": "https://mcp.atlassian.com/v2/mcp", "oauth": false, "headers": { "Authorization": "Bearer {env:BKIT_JIRA_API_TOKEN}" } }';
|
|
266
271
|
} else {
|
|
267
272
|
mcpEntry = "";
|
|
268
273
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as fs from "node:fs";
|
|
2
2
|
import * as path from "node:path";
|
|
3
|
-
import {
|
|
3
|
+
import { spawnSync } from "node:child_process";
|
|
4
4
|
import { readInstallingVersion } from "../shared/package-json.js";
|
|
5
5
|
import { managedVersionMarker } from "./version-file.js";
|
|
6
6
|
import { gitEnv, resolveRepoSlug } from "../ledgers/telemetry.js";
|
|
@@ -18,23 +18,19 @@ export interface TokenMap {
|
|
|
18
18
|
BKIT_VERSION?: string;
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
-
// Resolve DEFAULT_BRANCH
|
|
21
|
+
// Resolve DEFAULT_BRANCH, the production branch: refs/remotes/origin/HEAD, else "main".
|
|
22
|
+
// `dev` is bkit's integration branch, never production, so a remote whose default is `dev`
|
|
23
|
+
// also gets "main" — and renders the same bytes as a checkout with no origin/HEAD.
|
|
22
24
|
function resolveDefaultBranch(cwd: string): string {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
const branch = parts[parts.length - 1];
|
|
33
|
-
if (branch) return branch;
|
|
34
|
-
} catch {
|
|
35
|
-
// not a git repo or no remote HEAD configured — fall back
|
|
36
|
-
}
|
|
37
|
-
return "main";
|
|
25
|
+
const res = spawnSync("git", ["symbolic-ref", "refs/remotes/origin/HEAD"], {
|
|
26
|
+
cwd,
|
|
27
|
+
encoding: "utf-8",
|
|
28
|
+
stdio: ["ignore", "pipe", "ignore"],
|
|
29
|
+
env: gitEnv(),
|
|
30
|
+
});
|
|
31
|
+
// stdout is like "refs/remotes/origin/main"; empty when not a git repo or no remote HEAD.
|
|
32
|
+
const branch = res.status === 0 ? res.stdout.trim().replace(/^refs\/remotes\/origin\//, "") : "";
|
|
33
|
+
return branch === "" || branch === "dev" ? "main" : branch;
|
|
38
34
|
}
|
|
39
35
|
|
|
40
36
|
// Read and parse package.json from cwd. Throws if absent.
|
|
@@ -319,6 +319,27 @@ export function ensureDir(dir: string): void {
|
|
|
319
319
|
fs.mkdirSync(dir, { recursive: true });
|
|
320
320
|
}
|
|
321
321
|
|
|
322
|
+
/**
|
|
323
|
+
* Give an existing `dstPath` the executable bits `srcPath` carries. Hosts run some hooks
|
|
324
|
+
* directly (Cursor's `bkit-preflight.sh`), so a lost bit is drift: recorded in `ws` (a dry
|
|
325
|
+
* run included, so `bkit check` fails) and restored on a real run. No-op on Windows.
|
|
326
|
+
*/
|
|
327
|
+
export function restoreExecBits(
|
|
328
|
+
srcPath: string,
|
|
329
|
+
dstPath: string,
|
|
330
|
+
dryRun: boolean,
|
|
331
|
+
ws: WriteSet,
|
|
332
|
+
): void {
|
|
333
|
+
if (process.platform === "win32" || !fs.existsSync(dstPath)) return;
|
|
334
|
+
const execBits = fs.statSync(srcPath).mode & 0o111;
|
|
335
|
+
const dstMode = fs.statSync(dstPath).mode;
|
|
336
|
+
if ((dstMode & execBits) === execBits) return;
|
|
337
|
+
if (!dryRun) fs.chmodSync(dstPath, (dstMode | execBits) & 0o7777);
|
|
338
|
+
if (!ws.writes.some((w) => w.path === dstPath)) {
|
|
339
|
+
ws.writes.push({ path: dstPath, action: "update" });
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
|
|
322
343
|
// ---------------------------------------------------------------------------
|
|
323
344
|
// fully-managed format — idempotent rewrite of whole file after token substitution
|
|
324
345
|
//
|
|
@@ -338,7 +359,10 @@ export function writeTier1(
|
|
|
338
359
|
|
|
339
360
|
if (fs.existsSync(dstPath)) {
|
|
340
361
|
const existing = fs.readFileSync(dstPath, "utf-8");
|
|
341
|
-
if (existing === srcContent)
|
|
362
|
+
if (existing === srcContent) {
|
|
363
|
+
restoreExecBits(srcPath, dstPath, dryRun, ws);
|
|
364
|
+
return;
|
|
365
|
+
}
|
|
342
366
|
}
|
|
343
367
|
|
|
344
368
|
ensureDir(path.dirname(dstPath));
|
|
@@ -418,6 +442,18 @@ export function writeTier2(
|
|
|
418
442
|
markerStyle: MarkerStyle,
|
|
419
443
|
dryRun: boolean,
|
|
420
444
|
ws: WriteSet,
|
|
445
|
+
): void {
|
|
446
|
+
writeTier2Content(srcPath, dstPath, tokens, markerStyle, dryRun, ws);
|
|
447
|
+
restoreExecBits(srcPath, dstPath, dryRun, ws);
|
|
448
|
+
}
|
|
449
|
+
|
|
450
|
+
function writeTier2Content(
|
|
451
|
+
srcPath: string,
|
|
452
|
+
dstPath: string,
|
|
453
|
+
tokens: TokenMap,
|
|
454
|
+
markerStyle: MarkerStyle,
|
|
455
|
+
dryRun: boolean,
|
|
456
|
+
ws: WriteSet,
|
|
421
457
|
): void {
|
|
422
458
|
const srcRaw = readTemplate(srcPath);
|
|
423
459
|
|
|
@@ -3,15 +3,16 @@
|
|
|
3
3
|
// `.bkit/workflows/bkit-*.md` to host commands and `.bkit/prompts/bkit-*.md` to
|
|
4
4
|
// host agents.
|
|
5
5
|
//
|
|
6
|
-
// Inline model (no trackers.md substitution): every tracker call site carries
|
|
7
|
-
//
|
|
8
|
-
// the block matching the chosen tracker and
|
|
6
|
+
// Inline model (no trackers.md substitution): every tracker call site carries one
|
|
7
|
+
// variant per tracker inline as a consecutive group, in the fixed order `github`,
|
|
8
|
+
// `linear`, `jira`. The installer keeps the block matching the chosen tracker and
|
|
9
|
+
// drops the others. Two boolean
|
|
9
10
|
// conditional dialects gate tracker-agnostic content:
|
|
10
11
|
//
|
|
11
12
|
// <!-- bkit:tracker true start/end --> kept when a tracker IS connected; removed under none
|
|
12
13
|
// <!-- bkit:tracker false start/end --> kept ONLY under none; removed when wired
|
|
13
14
|
//
|
|
14
|
-
// Under `none` a
|
|
15
|
+
// Under `none` a group collapses to its trailing `false` block if present (the
|
|
15
16
|
// substantive no-tracker behaviour — e.g. `issue-id-extraction`, `fid-format`,
|
|
16
17
|
// `pr-body-marker`), otherwise to one generic skip message. There is no separate
|
|
17
18
|
// `none` marker — no-tracker content is always `false`.
|
|
@@ -27,7 +28,7 @@ import type { IssueTracker } from "../install/manifest.js";
|
|
|
27
28
|
export interface SubstituteResult {
|
|
28
29
|
/** Workflow content with tracker blocks resolved for the chosen tracker. */
|
|
29
30
|
output: string;
|
|
30
|
-
/** Number of
|
|
31
|
+
/** Number of tracker groups resolved (to a body or the none stub). */
|
|
31
32
|
pairs: number;
|
|
32
33
|
/** Number of `true`/`false` conditional blocks resolved (kept or removed). */
|
|
33
34
|
conditionals: number;
|
|
@@ -39,7 +40,7 @@ export interface SubstituteResult {
|
|
|
39
40
|
// Markers
|
|
40
41
|
// ---------------------------------------------------------------------------
|
|
41
42
|
|
|
42
|
-
/** Generic message rendered in place of a
|
|
43
|
+
/** Generic message rendered in place of a tracker group when no tracker is wired. */
|
|
43
44
|
const NONE_STUB = "_No tracker connected, skip step._";
|
|
44
45
|
|
|
45
46
|
/**
|
|
@@ -57,12 +58,14 @@ function block(name: string): string {
|
|
|
57
58
|
}
|
|
58
59
|
|
|
59
60
|
/**
|
|
60
|
-
* Per-tracker group:
|
|
61
|
+
* Per-tracker group: consecutive `github` → `linear` → `jira` blocks, each
|
|
61
62
|
* `<!-- bkit:tracker {name} start -->` … `<!-- bkit:tracker {name} end -->`,
|
|
62
|
-
* with an OPTIONAL trailing `false` block. The
|
|
63
|
-
*
|
|
64
|
-
*
|
|
65
|
-
*
|
|
63
|
+
* with an OPTIONAL trailing `false` block. The `jira` block is optional to the
|
|
64
|
+
* match: a group without one resolves for github, linear and none, and is left
|
|
65
|
+
* whole under jira so its markers surface as orphans. The whitespace BEFORE each
|
|
66
|
+
* optional block lives INSIDE its optional group (`(?:\s*<false>)?`), so when no
|
|
67
|
+
* block follows, the trailing newline + indent are left untouched — otherwise
|
|
68
|
+
* content immediately after the group would jam onto the kept body. A
|
|
66
69
|
* list-number prefix (`3. `) precedes the first marker and is left untouched, so
|
|
67
70
|
* the kept body / none stub attaches to it cleanly.
|
|
68
71
|
*
|
|
@@ -71,8 +74,15 @@ function block(name: string): string {
|
|
|
71
74
|
* `pr-body-marker`), use its body; otherwise emit the generic skip message.
|
|
72
75
|
* (Standalone `false` blocks not attached to a pair are handled in pass 2.)
|
|
73
76
|
*/
|
|
74
|
-
const
|
|
75
|
-
block("github") +
|
|
77
|
+
const GROUP_RE = new RegExp(
|
|
78
|
+
block("github") +
|
|
79
|
+
"\\s*" +
|
|
80
|
+
block("linear") +
|
|
81
|
+
"(?:\\s*" +
|
|
82
|
+
block("jira") +
|
|
83
|
+
")?(?:\\s*" +
|
|
84
|
+
block("false") +
|
|
85
|
+
")?",
|
|
76
86
|
"g",
|
|
77
87
|
);
|
|
78
88
|
|
|
@@ -85,9 +95,9 @@ function condDropRe(name: "true" | "false"): RegExp {
|
|
|
85
95
|
return new RegExp(`\\n?[ \\t]*${block(name)}`, "g");
|
|
86
96
|
}
|
|
87
97
|
|
|
88
|
-
// Any tracker marker surviving resolution is an orphan (
|
|
98
|
+
// Any tracker marker surviving resolution is an orphan (an incomplete group, or
|
|
89
99
|
// unbalanced true/false).
|
|
90
|
-
const ORPHAN_RE = new RegExp(marker("(github|linear|true|false)", "(?:start|end)"), "g");
|
|
100
|
+
const ORPHAN_RE = new RegExp(marker("(github|linear|jira|true|false)", "(?:start|end)"), "g");
|
|
91
101
|
|
|
92
102
|
/**
|
|
93
103
|
* When keeping in-place content, drop the newline (and its indentation)
|
|
@@ -107,10 +117,10 @@ function trimKeptContent(s: string): string {
|
|
|
107
117
|
/**
|
|
108
118
|
* Resolve tracker blocks in a workflow source file for the chosen tracker.
|
|
109
119
|
*
|
|
110
|
-
* Pass 1 collapses each
|
|
120
|
+
* Pass 1 collapses each tracker group to the chosen tracker's body, or — for
|
|
111
121
|
* `none` — to the generic skip message. Pass 2 resolves the `true`/`false`
|
|
112
122
|
* conditional blocks (kept when their condition matches the chosen tracker,
|
|
113
|
-
* removed otherwise) — run AFTER pass 1 so
|
|
123
|
+
* removed otherwise) — run AFTER pass 1 so groups nested inside a kept conditional
|
|
114
124
|
* are resolved first. Mirror output is clean — no markers remain.
|
|
115
125
|
*
|
|
116
126
|
* Always operates on workflow SOURCE (which has markers). Mirror output is
|
|
@@ -122,21 +132,23 @@ export function substituteWorkflow(
|
|
|
122
132
|
): SubstituteResult {
|
|
123
133
|
const wired = tracker !== "none";
|
|
124
134
|
|
|
125
|
-
// Pass 1:
|
|
126
|
-
//
|
|
135
|
+
// Pass 1: tracker groups → chosen tracker's body; none → the group's trailing
|
|
136
|
+
// `false` block if present, else the generic skip message.
|
|
127
137
|
let pairs = 0;
|
|
128
138
|
let output = workflowContent.replace(
|
|
129
|
-
|
|
130
|
-
(
|
|
139
|
+
GROUP_RE,
|
|
140
|
+
(match, gh: string, ln: string, jira: string | undefined, falseBody: string | undefined) => {
|
|
141
|
+
if (tracker === "jira" && jira === undefined) return match;
|
|
131
142
|
pairs++;
|
|
132
143
|
if (tracker === "github") return trimKeptContent(gh);
|
|
133
144
|
if (tracker === "linear") return trimKeptContent(ln);
|
|
145
|
+
if (tracker === "jira") return trimKeptContent(jira!);
|
|
134
146
|
return falseBody !== undefined ? trimKeptContent(falseBody) : NONE_STUB;
|
|
135
147
|
},
|
|
136
148
|
);
|
|
137
149
|
|
|
138
150
|
// Pass 2: standalone conditional `true`/`false` blocks (any `false` attached to
|
|
139
|
-
// a
|
|
151
|
+
// a group was already consumed in pass 1).
|
|
140
152
|
let conditionals = 0;
|
|
141
153
|
for (const name of ["true", "false"] as const) {
|
|
142
154
|
const active = name === "true" ? wired : !wired;
|
|
@@ -158,7 +170,7 @@ export function substituteWorkflow(
|
|
|
158
170
|
|
|
159
171
|
/**
|
|
160
172
|
* Find tracker markers that didn't participate in a successful resolution — a
|
|
161
|
-
*
|
|
173
|
+
* block outside a complete group, a group lacking the chosen tracker, or an unbalanced
|
|
162
174
|
* true/false pair.
|
|
163
175
|
*/
|
|
164
176
|
function findOrphanMarkers(content: string): string[] {
|
|
@@ -154,6 +154,12 @@ export const BKIT_EGRESS_SOURCES: readonly EgressSource[] = [
|
|
|
154
154
|
hosts: ["mcp.linear.app", "api.linear.app"],
|
|
155
155
|
bases: ["linear.app"],
|
|
156
156
|
},
|
|
157
|
+
{
|
|
158
|
+
id: "mcp-jira",
|
|
159
|
+
kind: "tracker-mcp",
|
|
160
|
+
hosts: ["mcp.atlassian.com"],
|
|
161
|
+
bases: ["atlassian.com"],
|
|
162
|
+
},
|
|
157
163
|
{
|
|
158
164
|
id: "agent-claude",
|
|
159
165
|
kind: "agent-host",
|