@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
|
@@ -73,13 +73,14 @@ export const requiresList = (w) => `[${w.requires.join(", ")}]`;
|
|
|
73
73
|
/** The Step 11 comment: one line per workstream, the issue-body line, then the design doc link. */
|
|
74
74
|
export function commentBody(ws, opts) {
|
|
75
75
|
const doc = `docs/plans/${opts.month}/${opts.fid}-design.md`;
|
|
76
|
+
const url = `https://github.com/${opts.ownerRepo}/blob/dev/${doc}`;
|
|
76
77
|
return [
|
|
77
78
|
"###### bkit:generated",
|
|
78
79
|
"### Step 11 — Suggested Workstreams",
|
|
79
80
|
"Advisory only. NEVER auto-trigger.",
|
|
80
81
|
...ws.map((w) => `- ${w.id}: ${w.name}. Requires: ${requiresList(w)}`),
|
|
81
|
-
`Filing one issue per workstream: put \`**Parent design:** [${opts.fid}-design.md](${
|
|
82
|
-
`[${doc}](
|
|
82
|
+
`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).`,
|
|
83
|
+
`[${doc}](${url})`,
|
|
83
84
|
].join("\n");
|
|
84
85
|
}
|
|
85
86
|
const ARTIFACT_FLAG = {
|
|
@@ -16,6 +16,7 @@ import { gitEnv } from "../../ledgers/telemetry.js";
|
|
|
16
16
|
import { readBkitConfig } from "../../shared/settings.js";
|
|
17
17
|
import { COULD_NOT_RUN_EXIT_CODES, installCommand } from "../../shared/package-manager.js";
|
|
18
18
|
import { CommandError, DEV, EXIT, git, isSharedBranch, repoRoot, runGit, } from "../lib.js";
|
|
19
|
+
import { ensureDiskSpace } from "./disk.js";
|
|
19
20
|
import { detect } from "./runtime.js";
|
|
20
21
|
import { WORKFLOW_FLAG } from "./status.js";
|
|
21
22
|
const WORKFLOWS = ["design", "plan", "build", "debug", "ship"];
|
|
@@ -29,6 +30,7 @@ export const EXIT_WORKTREE_ADD = 8;
|
|
|
29
30
|
export const EXIT_REBASE_NOT_STARTED = 9;
|
|
30
31
|
export const EXIT_NOT_A_WORKTREE = 10;
|
|
31
32
|
export const EXIT_REMOVE = 11;
|
|
33
|
+
export const EXIT_DISK_FULL = 12;
|
|
32
34
|
const FID_FLAG = { name: "fid", type: "string", required: true, help: "feature id" };
|
|
33
35
|
function fidOf(value) {
|
|
34
36
|
const fid = String(value);
|
|
@@ -302,8 +304,9 @@ export const worktreesCommand = {
|
|
|
302
304
|
[EXIT_WORKTREE_ADD]: "git worktree add failed",
|
|
303
305
|
[EXIT_REBASE_NOT_STARTED]: "resume rebase could not start (e.g. uncommitted changes)",
|
|
304
306
|
[EXIT_NOT_A_WORKTREE]: ".worktrees/{fid} exists but is not a registered git worktree",
|
|
307
|
+
[EXIT_DISK_FULL]: "free disk under bkit.disk.minFreeGb even after your max cleanup steps (`bkit disk prune`); nothing created",
|
|
305
308
|
},
|
|
306
|
-
run: (ctx) => {
|
|
309
|
+
run: async (ctx) => {
|
|
307
310
|
const f = ctx.flags;
|
|
308
311
|
const workflow = String(f.workflow);
|
|
309
312
|
if (!WORKFLOWS.includes(workflow)) {
|
|
@@ -341,6 +344,13 @@ export const worktreesCommand = {
|
|
|
341
344
|
const wtDir = worktreeDir(root, fid);
|
|
342
345
|
let mode = "adopted";
|
|
343
346
|
if (mint) {
|
|
347
|
+
const full = await ensureDiskSpace({
|
|
348
|
+
cwd: root,
|
|
349
|
+
minFreeGb: config.diskMinFreeGb,
|
|
350
|
+
log: ctx.log,
|
|
351
|
+
});
|
|
352
|
+
if (full !== null)
|
|
353
|
+
throw new CommandError(EXIT_DISK_FULL, full);
|
|
344
354
|
runGit(root, ["worktree", "prune"]);
|
|
345
355
|
if (fs.existsSync(wtDir)) {
|
|
346
356
|
// A plain directory there would resolve to the main checkout's repo,
|
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,10 @@ 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
14
|
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";
|
|
15
|
+
import { getInstallManifest, BKIT_GATE_SCRIPTS, BKIT_OPTIONAL_GATES, BKIT_PUSH_GATES, BKIT_TEST_FILE_SCRIPT, } from "../manifest.js";
|
|
16
16
|
export function listMdFiles(dir, prefix) {
|
|
17
17
|
if (!fs.existsSync(dir))
|
|
18
18
|
return [];
|
|
@@ -231,6 +231,7 @@ export function runBkitDocs(dryRun, tokens, ws, logPrefix) {
|
|
|
231
231
|
}
|
|
232
232
|
}
|
|
233
233
|
migrateShortcutsToLite(dryRun, ws, logPrefix);
|
|
234
|
+
migrateRetiredDevLock(dryRun, ws, logPrefix);
|
|
234
235
|
}
|
|
235
236
|
// Migration (5.1.0 – 5.2.4 installs, `docs/migrations.md`): the lite workflows lived at
|
|
236
237
|
// `.agents/shortcuts.md`. The consumer's own lines below `bkit:end` (minus the seeded
|
|
@@ -268,6 +269,18 @@ export function migrateShortcutsToLite(dryRun, ws, logPrefix) {
|
|
|
268
269
|
ws.writes.push({ path: RETIRED_SHORTCUTS, action: "write" });
|
|
269
270
|
console.log(`${logPrefix} ${tag}core: moved ${RETIRED_SHORTCUTS} → ${dst}`);
|
|
270
271
|
}
|
|
272
|
+
// Migration (installs up to 5.3.x, `docs/migrations.md`): `.bkit/.dev.lock` was the
|
|
273
|
+
// repo-wide dev lock. Nothing reads it now, so one a crashed run left behind is deleted.
|
|
274
|
+
// bkit owned the name whole. Recorded in ws so `bkit check` fails until upgrade runs.
|
|
275
|
+
const RETIRED_DEV_LOCK = path.join(".bkit", ".dev.lock");
|
|
276
|
+
export function migrateRetiredDevLock(dryRun, ws, logPrefix) {
|
|
277
|
+
if (!fs.lstatSync(RETIRED_DEV_LOCK, { throwIfNoEntry: false })?.isFile())
|
|
278
|
+
return;
|
|
279
|
+
if (!dryRun)
|
|
280
|
+
fs.rmSync(RETIRED_DEV_LOCK);
|
|
281
|
+
ws.writes.push({ path: RETIRED_DEV_LOCK, action: "write" });
|
|
282
|
+
console.log(`${logPrefix} ${dryRun ? "[dry-run] " : ""}core: removed ${RETIRED_DEV_LOCK} (the dev lock is gone)`);
|
|
283
|
+
}
|
|
271
284
|
// ---------------------------------------------------------------------------
|
|
272
285
|
// Source-rendered host outputs — agents (.agents/prompts source) and commands
|
|
273
286
|
// (.bkit/workflows source). Extracted from the host module functions so BOTH
|
|
@@ -302,8 +315,48 @@ export function seedCorePackageJsonScripts(ctx) {
|
|
|
302
315
|
written.push("package.json");
|
|
303
316
|
console.log(`${logPrefix} ${tag}core: package.json scripts added [${gates.added.join(", ")}]`);
|
|
304
317
|
}
|
|
318
|
+
if (migrateLinearTeamKey(dryRun, ws, logPrefix) && !written.includes("package.json")) {
|
|
319
|
+
written.push("package.json");
|
|
320
|
+
}
|
|
305
321
|
return written;
|
|
306
322
|
}
|
|
323
|
+
// Migration (up to 5.4.x installs, `docs/migrations.md`): the Linear team lived at
|
|
324
|
+
// `bkit.linearTeam`; it is `bkit.linear.team`, beside the project and state names. An
|
|
325
|
+
// existing `bkit.linear.team` wins over the old key. Returns true when package.json changed.
|
|
326
|
+
export function migrateLinearTeamKey(dryRun, ws, logPrefix) {
|
|
327
|
+
const pkgPath = "package.json";
|
|
328
|
+
if (!fs.existsSync(pkgPath))
|
|
329
|
+
return false;
|
|
330
|
+
const raw = fs.readFileSync(pkgPath, "utf-8");
|
|
331
|
+
const parsed = parseJson(raw);
|
|
332
|
+
if (!parsed.ok)
|
|
333
|
+
return false;
|
|
334
|
+
const pkg = parsed.value;
|
|
335
|
+
const bkit = pkg.bkit;
|
|
336
|
+
if (bkit === null || typeof bkit !== "object" || Array.isArray(bkit))
|
|
337
|
+
return false;
|
|
338
|
+
const cfg = bkit;
|
|
339
|
+
if (!Object.prototype.hasOwnProperty.call(cfg, "linearTeam"))
|
|
340
|
+
return false;
|
|
341
|
+
const old = cfg.linearTeam;
|
|
342
|
+
const linear = cfg.linear !== null && typeof cfg.linear === "object" && !Array.isArray(cfg.linear)
|
|
343
|
+
? cfg.linear
|
|
344
|
+
: {};
|
|
345
|
+
if (linear.team === undefined && typeof old === "string" && old.trim() !== "")
|
|
346
|
+
linear.team = old;
|
|
347
|
+
delete cfg.linearTeam;
|
|
348
|
+
if (Object.keys(linear).length > 0)
|
|
349
|
+
cfg.linear = linear;
|
|
350
|
+
ws.writes.push({ path: pkgPath, action: "update" });
|
|
351
|
+
if (!dryRun) {
|
|
352
|
+
const indentMatch = raw.match(/\n([ \t]+)"/);
|
|
353
|
+
const indent = indentMatch ? indentMatch[1] : " ";
|
|
354
|
+
const trailingNewline = raw.endsWith("\n") ? "\n" : "";
|
|
355
|
+
fs.writeFileSync(pkgPath, JSON.stringify(pkg, null, indent) + trailingNewline, "utf-8");
|
|
356
|
+
}
|
|
357
|
+
console.log(`${logPrefix} ${dryRun ? "[dry-run] " : ""}core: moved bkit.linearTeam to bkit.linear.team in package.json`);
|
|
358
|
+
return true;
|
|
359
|
+
}
|
|
307
360
|
// Tokens that follow `pnpm` in a gate value but are not package.json scripts: the
|
|
308
361
|
// package manager's own subcommands (`install` in bkit:gate:install-static-unit-build,
|
|
309
362
|
// `audit` / `outdated` in the bkit:deps:* pair) and node_modules binaries pnpm resolves
|
|
@@ -317,10 +370,32 @@ const PNPM_NOT_A_SCRIPT = new Set([
|
|
|
317
370
|
"outdated",
|
|
318
371
|
"lint-staged",
|
|
319
372
|
]);
|
|
373
|
+
/**
|
|
374
|
+
* The scripts a gate ends up running: each `pnpm <script>` / `pnpm run <script>` it calls,
|
|
375
|
+
* with every `bkit:gate:*` it chains expanded in place. pnpm's own subcommands and
|
|
376
|
+
* binaries are left out.
|
|
377
|
+
*/
|
|
378
|
+
export function gateLeafScripts(gate, declared, seen = new Set()) {
|
|
379
|
+
const value = declared[gate];
|
|
380
|
+
if (typeof value !== "string" || seen.has(gate))
|
|
381
|
+
return [];
|
|
382
|
+
seen.add(gate);
|
|
383
|
+
const leaves = [];
|
|
384
|
+
for (const [, called] of value.matchAll(/\bpnpm (?:run )?([\w:-]+)/g)) {
|
|
385
|
+
if (PNPM_NOT_A_SCRIPT.has(called))
|
|
386
|
+
continue;
|
|
387
|
+
if (called.startsWith("bkit:gate:"))
|
|
388
|
+
leaves.push(...gateLeafScripts(called, declared, seen));
|
|
389
|
+
else
|
|
390
|
+
leaves.push(called);
|
|
391
|
+
}
|
|
392
|
+
return leaves;
|
|
393
|
+
}
|
|
320
394
|
/**
|
|
321
395
|
* Advisories for the `bkit:gate:*` scripts: the scripts a still-default gate
|
|
322
396
|
* chains that package.json does not declare, the deeper test tiers the repo has
|
|
323
|
-
* but no gate runs,
|
|
397
|
+
* but no gate runs, a commit gate that repeats the push gate, and a missing
|
|
398
|
+
* `bkit:test:file`. Judges the scripts as install
|
|
324
399
|
* leaves them (missing gate names at their seeded defaults), so install, `bkit check`
|
|
325
400
|
* and `bkit upgrade` report the same set. Read-only; an absent or unparseable
|
|
326
401
|
* package.json yields none.
|
|
@@ -371,12 +446,27 @@ export function detectGateAdvisories(cwd) {
|
|
|
371
446
|
findings.push({
|
|
372
447
|
id: "gate-tier-not-wired",
|
|
373
448
|
severity: "advisory",
|
|
374
|
-
detect: "package.json declares deeper test tiers than any `bkit:gate*` script runs, so `/bkit-build
|
|
375
|
-
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" +
|
|
449
|
+
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.",
|
|
450
|
+
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" +
|
|
376
451
|
unwired.join("\n") +
|
|
377
452
|
"\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.",
|
|
378
453
|
});
|
|
379
454
|
}
|
|
455
|
+
// The commit gate is the fast one: a script it shares with the push gate runs on every
|
|
456
|
+
// commit and again on the push that carries it.
|
|
457
|
+
const pushGate = BKIT_PUSH_GATES.find((g) => g in declared);
|
|
458
|
+
const commitCalls = pushGate === undefined ? [] : gateLeafScripts("bkit:gate:format", declared);
|
|
459
|
+
const pushCalls = new Set(pushGate === undefined ? [] : gateLeafScripts(pushGate, declared));
|
|
460
|
+
const repeated = [...new Set(commitCalls.filter((s) => pushCalls.has(s)))].sort();
|
|
461
|
+
if (repeated.length > 0) {
|
|
462
|
+
const names = repeated.map((n) => `\`${n}\``).join(", ");
|
|
463
|
+
findings.push({
|
|
464
|
+
id: "gate-commit-repeats-push",
|
|
465
|
+
severity: "advisory",
|
|
466
|
+
detect: `\`bkit:gate:format\` (pre-commit) runs ${names}, which \`${pushGate}\` (pre-push) runs again.`,
|
|
467
|
+
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.`,
|
|
468
|
+
});
|
|
469
|
+
}
|
|
380
470
|
// /bkit-build records each task's red through this script; without it test-first is
|
|
381
471
|
// reported as not enforced. bkit cannot seed it: what runs one file is the stack's.
|
|
382
472
|
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
|
}
|
|
@@ -1,28 +1,22 @@
|
|
|
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";
|
|
7
|
-
// Resolve DEFAULT_BRANCH
|
|
7
|
+
// Resolve DEFAULT_BRANCH, the production branch: refs/remotes/origin/HEAD, else "main".
|
|
8
|
+
// `dev` is bkit's integration branch, never production, so a remote whose default is `dev`
|
|
9
|
+
// also gets "main" — and renders the same bytes as a checkout with no origin/HEAD.
|
|
8
10
|
function resolveDefaultBranch(cwd) {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
const branch = parts[parts.length - 1];
|
|
19
|
-
if (branch)
|
|
20
|
-
return branch;
|
|
21
|
-
}
|
|
22
|
-
catch {
|
|
23
|
-
// not a git repo or no remote HEAD configured — fall back
|
|
24
|
-
}
|
|
25
|
-
return "main";
|
|
11
|
+
const res = spawnSync("git", ["symbolic-ref", "refs/remotes/origin/HEAD"], {
|
|
12
|
+
cwd,
|
|
13
|
+
encoding: "utf-8",
|
|
14
|
+
stdio: ["ignore", "pipe", "ignore"],
|
|
15
|
+
env: gitEnv(),
|
|
16
|
+
});
|
|
17
|
+
// stdout is like "refs/remotes/origin/main"; empty when not a git repo or no remote HEAD.
|
|
18
|
+
const branch = res.status === 0 ? res.stdout.trim().replace(/^refs\/remotes\/origin\//, "") : "";
|
|
19
|
+
return branch === "" || branch === "dev" ? "main" : branch;
|
|
26
20
|
}
|
|
27
21
|
// Read and parse package.json from cwd. Throws if absent.
|
|
28
22
|
function readPackageJson(cwd) {
|
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.
|
package/dist/render/trackers.js
CHANGED
|
@@ -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`.
|
|
@@ -20,7 +21,7 @@
|
|
|
20
21
|
// ---------------------------------------------------------------------------
|
|
21
22
|
// Markers
|
|
22
23
|
// ---------------------------------------------------------------------------
|
|
23
|
-
/** Generic message rendered in place of a
|
|
24
|
+
/** Generic message rendered in place of a tracker group when no tracker is wired. */
|
|
24
25
|
const NONE_STUB = "_No tracker connected, skip step._";
|
|
25
26
|
/**
|
|
26
27
|
* Marker regex source. An optional `# ` prefix belongs to the marker: inside YAML
|
|
@@ -36,12 +37,14 @@ function block(name) {
|
|
|
36
37
|
return `${marker(name, "start")}([\\s\\S]*?)${marker(name, "end")}`;
|
|
37
38
|
}
|
|
38
39
|
/**
|
|
39
|
-
* Per-tracker group:
|
|
40
|
+
* Per-tracker group: consecutive `github` → `linear` → `jira` blocks, each
|
|
40
41
|
* `<!-- bkit:tracker {name} start -->` … `<!-- bkit:tracker {name} end -->`,
|
|
41
|
-
* with an OPTIONAL trailing `false` block. The
|
|
42
|
-
*
|
|
43
|
-
*
|
|
44
|
-
*
|
|
42
|
+
* with an OPTIONAL trailing `false` block. The `jira` block is optional to the
|
|
43
|
+
* match: a group without one resolves for github, linear and none, and is left
|
|
44
|
+
* whole under jira so its markers surface as orphans. The whitespace BEFORE each
|
|
45
|
+
* optional block lives INSIDE its optional group (`(?:\s*<false>)?`), so when no
|
|
46
|
+
* block follows, the trailing newline + indent are left untouched — otherwise
|
|
47
|
+
* content immediately after the group would jam onto the kept body. A
|
|
45
48
|
* list-number prefix (`3. `) precedes the first marker and is left untouched, so
|
|
46
49
|
* the kept body / none stub attaches to it cleanly.
|
|
47
50
|
*
|
|
@@ -50,7 +53,14 @@ function block(name) {
|
|
|
50
53
|
* `pr-body-marker`), use its body; otherwise emit the generic skip message.
|
|
51
54
|
* (Standalone `false` blocks not attached to a pair are handled in pass 2.)
|
|
52
55
|
*/
|
|
53
|
-
const
|
|
56
|
+
const GROUP_RE = new RegExp(block("github") +
|
|
57
|
+
"\\s*" +
|
|
58
|
+
block("linear") +
|
|
59
|
+
"(?:\\s*" +
|
|
60
|
+
block("jira") +
|
|
61
|
+
")?(?:\\s*" +
|
|
62
|
+
block("false") +
|
|
63
|
+
")?", "g");
|
|
54
64
|
/** Conditional-keep block, KEEP form (markers stripped, content trimmed in place). */
|
|
55
65
|
function condKeepRe(name) {
|
|
56
66
|
return new RegExp(block(name), "g");
|
|
@@ -59,9 +69,9 @@ function condKeepRe(name) {
|
|
|
59
69
|
function condDropRe(name) {
|
|
60
70
|
return new RegExp(`\\n?[ \\t]*${block(name)}`, "g");
|
|
61
71
|
}
|
|
62
|
-
// Any tracker marker surviving resolution is an orphan (
|
|
72
|
+
// Any tracker marker surviving resolution is an orphan (an incomplete group, or
|
|
63
73
|
// unbalanced true/false).
|
|
64
|
-
const ORPHAN_RE = new RegExp(marker("(github|linear|true|false)", "(?:start|end)"), "g");
|
|
74
|
+
const ORPHAN_RE = new RegExp(marker("(github|linear|jira|true|false)", "(?:start|end)"), "g");
|
|
65
75
|
/**
|
|
66
76
|
* When keeping in-place content, drop the newline (and its indentation)
|
|
67
77
|
* immediately after `start -->` and immediately before the `end` marker, so the
|
|
@@ -78,10 +88,10 @@ function trimKeptContent(s) {
|
|
|
78
88
|
/**
|
|
79
89
|
* Resolve tracker blocks in a workflow source file for the chosen tracker.
|
|
80
90
|
*
|
|
81
|
-
* Pass 1 collapses each
|
|
91
|
+
* Pass 1 collapses each tracker group to the chosen tracker's body, or — for
|
|
82
92
|
* `none` — to the generic skip message. Pass 2 resolves the `true`/`false`
|
|
83
93
|
* conditional blocks (kept when their condition matches the chosen tracker,
|
|
84
|
-
* removed otherwise) — run AFTER pass 1 so
|
|
94
|
+
* removed otherwise) — run AFTER pass 1 so groups nested inside a kept conditional
|
|
85
95
|
* are resolved first. Mirror output is clean — no markers remain.
|
|
86
96
|
*
|
|
87
97
|
* Always operates on workflow SOURCE (which has markers). Mirror output is
|
|
@@ -89,19 +99,23 @@ function trimKeptContent(s) {
|
|
|
89
99
|
*/
|
|
90
100
|
export function substituteWorkflow(workflowContent, tracker) {
|
|
91
101
|
const wired = tracker !== "none";
|
|
92
|
-
// Pass 1:
|
|
93
|
-
//
|
|
102
|
+
// Pass 1: tracker groups → chosen tracker's body; none → the group's trailing
|
|
103
|
+
// `false` block if present, else the generic skip message.
|
|
94
104
|
let pairs = 0;
|
|
95
|
-
let output = workflowContent.replace(
|
|
105
|
+
let output = workflowContent.replace(GROUP_RE, (match, gh, ln, jira, falseBody) => {
|
|
106
|
+
if (tracker === "jira" && jira === undefined)
|
|
107
|
+
return match;
|
|
96
108
|
pairs++;
|
|
97
109
|
if (tracker === "github")
|
|
98
110
|
return trimKeptContent(gh);
|
|
99
111
|
if (tracker === "linear")
|
|
100
112
|
return trimKeptContent(ln);
|
|
113
|
+
if (tracker === "jira")
|
|
114
|
+
return trimKeptContent(jira);
|
|
101
115
|
return falseBody !== undefined ? trimKeptContent(falseBody) : NONE_STUB;
|
|
102
116
|
});
|
|
103
117
|
// Pass 2: standalone conditional `true`/`false` blocks (any `false` attached to
|
|
104
|
-
// a
|
|
118
|
+
// a group was already consumed in pass 1).
|
|
105
119
|
let conditionals = 0;
|
|
106
120
|
for (const name of ["true", "false"]) {
|
|
107
121
|
const active = name === "true" ? wired : !wired;
|
|
@@ -122,7 +136,7 @@ export function substituteWorkflow(workflowContent, tracker) {
|
|
|
122
136
|
}
|
|
123
137
|
/**
|
|
124
138
|
* Find tracker markers that didn't participate in a successful resolution — a
|
|
125
|
-
*
|
|
139
|
+
* block outside a complete group, a group lacking the chosen tracker, or an unbalanced
|
|
126
140
|
* true/false pair.
|
|
127
141
|
*/
|
|
128
142
|
function findOrphanMarkers(content) {
|
package/dist/shared/egress.js
CHANGED
|
@@ -109,6 +109,12 @@ export const BKIT_EGRESS_SOURCES = [
|
|
|
109
109
|
hosts: ["mcp.linear.app", "api.linear.app"],
|
|
110
110
|
bases: ["linear.app"],
|
|
111
111
|
},
|
|
112
|
+
{
|
|
113
|
+
id: "mcp-jira",
|
|
114
|
+
kind: "tracker-mcp",
|
|
115
|
+
hosts: ["mcp.atlassian.com"],
|
|
116
|
+
bases: ["atlassian.com"],
|
|
117
|
+
},
|
|
112
118
|
{
|
|
113
119
|
id: "agent-claude",
|
|
114
120
|
kind: "agent-host",
|