@cbartens/bkit 5.1.0 → 5.2.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 +11 -7
- package/.bkit/core/.agents/plugins/bkit/hooks/bkit-gateguard.cjs +39 -50
- package/.bkit/core/.agents/plugins/bkit/hooks/bkit-guardrails.cjs +74 -56
- package/.bkit/core/.agents/plugins/bkit/hooks/bkit-readguard.cjs +72 -0
- package/.bkit/core/.agents/rules.md +8 -4
- package/.bkit/core/.agents/shortcuts.md +1 -1
- package/.bkit/core/.bkit/LICENSE.md +18 -140
- package/.bkit/core/.bkit/README.md +10 -6
- package/.bkit/core/.bkit/cloud.md +12 -15
- package/.bkit/core/.bkit/comparison.md +66 -14
- package/.bkit/core/.bkit/install.md +31 -8
- package/.bkit/core/.bkit/jsonl.md +0 -1
- package/.bkit/core/.bkit/prompts.md +14 -13
- package/.bkit/core/.bkit/providers.md +92 -26
- package/.bkit/core/.bkit/templates.md +38 -11
- package/.bkit/core/.bkit/workflows.md +63 -41
- package/.bkit/core/.claude/hooks/bkit-gateguard.cjs +4 -3
- package/.bkit/core/.claude/hooks/bkit-readguard.cjs +60 -0
- package/.bkit/core/.codex/hooks/bkit-gateguard.cjs +8 -6
- package/.bkit/core/.codex/hooks/bkit-readguard.cjs +58 -0
- package/.bkit/core/.cursor/hooks/bkit-guardrails.cjs +12 -19
- package/.bkit/core/.cursor/hooks/bkit-readguard.cjs +59 -0
- package/.bkit/core/.opencode/plugin/bkit-gateguard.js +73 -22
- package/.bkit/core/.opencode/plugin/bkit-readguard.js +126 -0
- package/.bkit/core/docs/templates/bkit-audit-adoption.md +2 -2
- package/.bkit/core/docs/templates/bkit-plan.md +6 -3
- package/.bkit/core/engine/checks/after/auth.ts +32 -0
- package/.bkit/core/engine/checks/after/github.ts +4 -4
- package/.bkit/core/engine/checks/after/index.ts +36 -50
- package/.bkit/core/engine/checks/after/managed.ts +40 -0
- package/.bkit/core/engine/checks/before/index.ts +5 -4
- package/.bkit/core/engine/checks/before/mcp.ts +60 -54
- package/.bkit/core/engine/checks/status-holes.ts +1 -1
- package/.bkit/core/engine/checks/tips/catalogue.ts +356 -0
- package/.bkit/core/engine/checks/tips/detect.ts +144 -0
- package/.bkit/core/engine/checks/tips/index.ts +174 -0
- package/.bkit/core/engine/cli.ts +57 -9
- package/.bkit/core/engine/commands/install/doctor.ts +5 -1
- package/.bkit/core/engine/commands/install/install.ts +39 -9
- package/.bkit/core/engine/commands/install/uninstall.ts +32 -18
- package/.bkit/core/engine/commands/install/upgrade.ts +15 -28
- package/.bkit/core/engine/commands/launch.ts +33 -11
- package/.bkit/core/engine/commands/tips.ts +16 -0
- package/.bkit/core/engine/commands/workflow/runs.ts +57 -16
- package/.bkit/core/engine/commands/workflow/runtime.ts +10 -0
- package/.bkit/core/engine/commands/workflow/steps.ts +1 -0
- package/.bkit/core/engine/commands/workflow/tests.ts +647 -4
- package/.bkit/core/engine/commands/workflow/workstreams.ts +4 -4
- package/.bkit/core/engine/install/cloud-env.ts +7 -21
- package/.bkit/core/engine/install/hosts.ts +21 -0
- package/.bkit/core/engine/install/managed-block.ts +36 -0
- package/.bkit/core/engine/install/manifest.ts +46 -4
- package/.bkit/core/engine/install/modules/antigravity.ts +8 -7
- package/.bkit/core/engine/install/modules/claude.ts +6 -6
- package/.bkit/core/engine/install/modules/cloud.ts +2 -2
- package/.bkit/core/engine/install/modules/codex.ts +5 -5
- package/.bkit/core/engine/install/modules/core.ts +23 -9
- package/.bkit/core/engine/install/modules/cursor.ts +6 -6
- package/.bkit/core/engine/install/modules/opencode.ts +4 -4
- package/.bkit/core/engine/install/payload-links.ts +6 -10
- package/.bkit/core/engine/install/placeholders.ts +1 -1
- package/.bkit/core/engine/install/version-file.ts +17 -9
- package/.bkit/core/engine/install/write.ts +68 -1
- package/.bkit/core/engine/ledgers/telemetry.ts +0 -2
- package/.bkit/core/engine/shared/package-roots.ts +8 -10
- package/.bkit/core/hooks/antigravity-hook.js +67 -0
- package/.bkit/core/hooks/gateguard-edit-payload.js +4 -4
- package/.bkit/core/hooks/gateguard-engine.js +16 -6
- package/.bkit/core/hooks/guardrails-read.js +23 -0
- package/.bkit/core/hooks/readguard-engine.js +259 -0
- package/.bkit/core/hooks/readguard-payload.js +67 -0
- package/.bkit/core/prompts/bkit-audit-generate.md +1 -0
- package/.bkit/core/prompts/bkit-build-challenge-1.md +1 -0
- package/.bkit/core/prompts/bkit-build-challenge-2.md +1 -0
- package/.bkit/core/prompts/bkit-build-challenge-reconcile.md +1 -0
- package/.bkit/core/prompts/bkit-build-challenge-remediate.md +1 -0
- package/.bkit/core/prompts/bkit-build-challenge-tests.md +1 -0
- package/.bkit/core/prompts/bkit-build-install-skills.md +1 -0
- package/.bkit/core/prompts/bkit-build-plan-current.md +1 -0
- package/.bkit/core/prompts/bkit-build-plan-execute.md +5 -1
- package/.bkit/core/prompts/bkit-build-plan-gaps-remediate.md +1 -0
- package/.bkit/core/prompts/bkit-build-plan-verify.md +11 -3
- package/.bkit/core/prompts/bkit-build-summary.md +1 -0
- package/.bkit/core/prompts/bkit-debug-abort-handover.md +1 -0
- package/.bkit/core/prompts/bkit-debug-failure-diagnose.md +1 -0
- package/.bkit/core/prompts/bkit-debug-failure-remediate.md +1 -0
- package/.bkit/core/prompts/bkit-debug-failure-soak.md +1 -0
- package/.bkit/core/prompts/bkit-debug-summary.md +1 -0
- package/.bkit/core/prompts/bkit-design-brainstorm-ideate-1.md +1 -0
- package/.bkit/core/prompts/bkit-design-brainstorm-ideate-2.md +1 -0
- package/.bkit/core/prompts/bkit-design-brainstorm-ideate-3.md +1 -0
- package/.bkit/core/prompts/bkit-design-generate.md +9 -4
- package/.bkit/core/prompts/bkit-design-organise.md +1 -0
- package/.bkit/core/prompts/bkit-design-review-1.md +1 -0
- package/.bkit/core/prompts/bkit-design-review-2.md +1 -0
- package/.bkit/core/prompts/bkit-design-spike.md +1 -0
- package/.bkit/core/prompts/bkit-design-summary.md +1 -0
- package/.bkit/core/prompts/bkit-design-update.md +1 -0
- package/.bkit/core/prompts/bkit-plan-complexity-check.md +1 -0
- package/.bkit/core/prompts/bkit-plan-complexity-split.md +3 -2
- package/.bkit/core/prompts/bkit-plan-generate.md +1 -0
- package/.bkit/core/prompts/bkit-plan-review-1.md +1 -0
- package/.bkit/core/prompts/bkit-plan-review-2.md +1 -0
- package/.bkit/core/prompts/bkit-plan-review-3.md +1 -0
- package/.bkit/core/prompts/bkit-plan-scope-check-1.md +2 -1
- package/.bkit/core/prompts/bkit-plan-scope-check-2.md +2 -1
- package/.bkit/core/prompts/bkit-plan-summary.md +1 -0
- package/.bkit/core/prompts/bkit-plan-update.md +2 -1
- package/.bkit/core/prompts/bkit-ship-conflict-resolve.md +1 -0
- package/.bkit/core/prompts/bkit-ship-deferred-sweep.md +1 -0
- package/.bkit/core/prompts/bkit-ship-summary.md +1 -0
- package/.bkit/core/prompts/bkit-ship-update-docs.md +1 -0
- package/.bkit/core/prompts/bkit-utility-compress-markdown.md +1 -0
- package/.bkit/core/prompts/bkit-utility-update-decisions.md +1 -0
- package/.bkit/core/prompts/bkit-utility-update-deferrals.md +1 -0
- package/.bkit/core/prompts/bkit-utility-update-documentation.md +1 -0
- package/.bkit/core/prompts/bkit-utility-update-failures.md +1 -0
- package/.bkit/core/prompts/bkit-utility-update-knowledge.md +1 -0
- package/.bkit/core/prompts/bkit-utility-update-roadmap.md +1 -0
- package/.bkit/core/workflows/bkit-build.md +33 -21
- package/.bkit/core/workflows/bkit-debug.md +29 -22
- package/.bkit/core/workflows/bkit-design.md +81 -38
- package/.bkit/core/workflows/bkit-plan.md +8 -2
- package/.bkit/core/workflows/bkit-ship.md +8 -2
- package/.bkit/shared/.agents/plugins/bkit/hooks.json +13 -3
- package/.bkit/shared/.claude/settings.json +19 -0
- package/.bkit/shared/.codex/hooks.json +21 -0
- package/.bkit/shared/.cursor/hooks.json +6 -1
- package/.bkit/shared/.opencode/opencode.json +1 -1
- package/.bkit/shared/docs/deployments.md +1 -1
- package/.bkit/shared/docs/testing.md +12 -1
- package/.bkit/templates/.github/dependabot.yml +6 -0
- package/.bkit/templates/.github/renovate.json5 +3 -3
- package/.bkit/templates/.github/workflows/bkit-ci.yml +0 -13
- package/.bkit/templates/.prettierignore +1 -1
- package/.bkit/templates/context/bkit-expo.md +22 -13
- package/.bkit/templates/context/bkit-github.md +20 -6
- package/.bkit/templates/context/bkit-inngest.md +10 -4
- package/.bkit/templates/context/bkit-maestro.md +5 -5
- package/.bkit/templates/context/bkit-playwright.md +3 -3
- package/.bkit/templates/context/bkit-sentry.md +6 -5
- package/.bkit/templates/context/bkit-stripe.md +31 -8
- package/.bkit/templates/scripts/ci/check-accepted-divergences.mjs +65 -19
- package/.bkit/templates/scripts/ci/check-accepted-divergences.test.mjs +34 -0
- package/.bkit/templates/scripts/ci/lanes/resolve-push-base.mjs +33 -12
- package/.bkit/templates/scripts/ci/lanes/resolve-push-base.test.mjs +54 -0
- package/.bkit/templates/scripts/launchd/bkit-launchd-env.sh +76 -6
- package/.bkit/templates/slop-scan.config.json +7 -2
- package/CHANGELOG.md +50 -0
- package/LICENSE.md +21 -161
- package/README.md +61 -28
- package/dist/checks/after/auth.js +28 -0
- package/dist/checks/after/github.js +4 -4
- package/dist/checks/after/index.js +29 -45
- package/dist/checks/after/managed.js +40 -1
- package/dist/checks/before/index.js +5 -4
- package/dist/checks/before/mcp.js +53 -53
- package/dist/checks/status-holes.js +1 -1
- package/dist/checks/tips/catalogue.js +297 -0
- package/dist/checks/tips/detect.js +130 -0
- package/dist/checks/tips/index.js +146 -0
- package/dist/cli.js +47 -9
- package/dist/commands/install/doctor.js +5 -1
- package/dist/commands/install/install.js +27 -7
- package/dist/commands/install/uninstall.js +31 -16
- package/dist/commands/install/upgrade.js +15 -32
- package/dist/commands/launch.js +27 -11
- package/dist/commands/tips.js +10 -0
- package/dist/commands/workflow/runs.js +52 -16
- package/dist/commands/workflow/runtime.js +8 -0
- package/dist/commands/workflow/steps.js +1 -0
- package/dist/commands/workflow/tests.js +541 -4
- package/dist/commands/workflow/workstreams.js +4 -4
- package/dist/install/cloud-env.js +3 -14
- package/dist/install/hosts.js +22 -0
- package/dist/install/managed-block.js +36 -0
- package/dist/install/manifest.js +45 -4
- package/dist/install/modules/antigravity.js +8 -7
- package/dist/install/modules/claude.js +6 -6
- package/dist/install/modules/cloud.js +2 -2
- package/dist/install/modules/codex.js +5 -5
- package/dist/install/modules/core.js +14 -5
- package/dist/install/modules/cursor.js +6 -6
- package/dist/install/modules/opencode.js +4 -4
- package/dist/install/payload-links.js +5 -5
- package/dist/install/placeholders.js +1 -1
- package/dist/install/version-file.js +12 -3
- package/dist/install/write.js +61 -2
- package/dist/shared/package-roots.js +8 -11
- package/package.json +4 -6
- package/.bkit/core/LICENSE.md +0 -149
- package/.bkit/shared/LICENSE.md +0 -22
- package/.bkit/templates/LICENSE.md +0 -22
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// bkit workstreams parse|comment — design Step
|
|
1
|
+
// bkit workstreams parse|comment — design Step 11: read the organised design's
|
|
2
2
|
// `## Suggested Workstreams` and build the advisory comment for the feature's
|
|
3
3
|
// own issue.
|
|
4
4
|
//
|
|
@@ -84,7 +84,7 @@ export function parseWorkstreams(md: string): Workstream[] {
|
|
|
84
84
|
/** `[]` or `[WS-1, WS-2]`. */
|
|
85
85
|
export const requiresList = (w: Workstream) => `[${w.requires.join(", ")}]`;
|
|
86
86
|
|
|
87
|
-
/** The Step
|
|
87
|
+
/** The Step 11 comment: one line per workstream, then the design doc link. */
|
|
88
88
|
export function commentBody(
|
|
89
89
|
ws: Workstream[],
|
|
90
90
|
opts: { ownerRepo: string; month: string; fid: string },
|
|
@@ -92,7 +92,7 @@ export function commentBody(
|
|
|
92
92
|
const doc = `docs/plans/${opts.month}/${opts.fid}-design.md`;
|
|
93
93
|
return [
|
|
94
94
|
"###### bkit:generated",
|
|
95
|
-
"### Step
|
|
95
|
+
"### Step 11 — Suggested Workstreams",
|
|
96
96
|
"Advisory only. NEVER auto-trigger.",
|
|
97
97
|
...ws.map((w) => `- ${w.id}: ${w.name}. Requires: ${requiresList(w)}`),
|
|
98
98
|
`[${doc}](https://github.com/${opts.ownerRepo}/blob/dev/${doc})`,
|
|
@@ -135,7 +135,7 @@ export const workstreamsCommand: CommandSpec = {
|
|
|
135
135
|
},
|
|
136
136
|
comment: {
|
|
137
137
|
summary:
|
|
138
|
-
"The Step
|
|
138
|
+
"The Step 11 comment body for the feature's own issue (posted via MCP by the workflow).",
|
|
139
139
|
flags: [
|
|
140
140
|
ARTIFACT_FLAG,
|
|
141
141
|
{ name: "fid", type: "string", required: true, help: "feature id" },
|
|
@@ -45,36 +45,26 @@ const BASELINE_TOKEN_PLACEHOLDERS: ReadonlyArray<readonly [string, string]> = [
|
|
|
45
45
|
],
|
|
46
46
|
];
|
|
47
47
|
|
|
48
|
-
// Earlier-compaction override — a bkit constant, not a secret. Appended to the
|
|
49
|
-
// block when not already resolved from a source file. Claude-harness-only knob —
|
|
50
|
-
// Cursor has no equivalent, so it is NOT in the Cursor policy's constants.
|
|
51
|
-
const AUTOCOMPACT_KEY = "CLAUDE_AUTOCOMPACT_PCT_OVERRIDE";
|
|
52
|
-
const AUTOCOMPACT_VALUE = "70";
|
|
53
|
-
|
|
54
48
|
// Per-cloud env-var policy. The `.envrc`-following resolver core is identical for
|
|
55
49
|
// both clouds (same dotenv sources, same unset/hijack/empty drops) — only the
|
|
56
|
-
// baseline placeholder set
|
|
57
|
-
//
|
|
58
|
-
//
|
|
59
|
-
//
|
|
60
|
-
// SAME cloud environment — just different mechanics (pasted setup vs. Dockerfile).
|
|
50
|
+
// baseline placeholder set differs. Claude pairs with the GitHub tracker; Cursor pairs
|
|
51
|
+
// with Linear (and so also needs `BKIT_LINEAR_API_KEY`). Keeping one resolver with a
|
|
52
|
+
// small policy object is what guarantees the two generated docs describe the SAME
|
|
53
|
+
// cloud environment — just different mechanics (pasted setup vs. Dockerfile).
|
|
61
54
|
export interface CloudEnvPolicy {
|
|
62
55
|
/** Baseline env-var NAMES this cloud always needs; emitted as `NAME=<placeholder>`
|
|
63
56
|
* when absent from the resolved `.envrc` set. */
|
|
64
57
|
baseline: ReadonlyArray<readonly [string, string]>;
|
|
65
|
-
/** Constant KEY/value pairs appended when not already resolved from a source. */
|
|
66
|
-
constants: ReadonlyArray<readonly [string, string]>;
|
|
67
58
|
}
|
|
68
59
|
|
|
69
|
-
// Claude Code on the web: GitHub tracker
|
|
60
|
+
// Claude Code on the web: GitHub tracker.
|
|
70
61
|
export const CLAUDE_CLOUD_POLICY: CloudEnvPolicy = {
|
|
71
62
|
baseline: BASELINE_TOKEN_PLACEHOLDERS,
|
|
72
|
-
constants: [[AUTOCOMPACT_KEY, AUTOCOMPACT_VALUE]],
|
|
73
63
|
};
|
|
74
64
|
|
|
75
65
|
// Cursor Background Agents: `BKIT_LINEAR_API_KEY` prepended for the Linear tracker
|
|
76
66
|
// (bkit-preflight.sh calls the Linear GraphQL API and hard-fails without it); GitHub
|
|
77
|
-
// tracker uses the same GH baseline as Claude
|
|
67
|
+
// tracker uses the same GH baseline as Claude.
|
|
78
68
|
const CURSOR_LINEAR_PLACEHOLDER: readonly [string, string] = [
|
|
79
69
|
"BKIT_LINEAR_API_KEY",
|
|
80
70
|
"<Linear personal API key — https://linear.app/settings/api>",
|
|
@@ -85,7 +75,6 @@ export function cursorCloudPolicy(tracker: IssueTracker): CloudEnvPolicy {
|
|
|
85
75
|
tracker === "linear"
|
|
86
76
|
? [CURSOR_LINEAR_PLACEHOLDER, ...BASELINE_TOKEN_PLACEHOLDERS]
|
|
87
77
|
: BASELINE_TOKEN_PLACEHOLDERS,
|
|
88
|
-
constants: [],
|
|
89
78
|
};
|
|
90
79
|
}
|
|
91
80
|
|
|
@@ -234,7 +223,7 @@ export function resolveCloudEnvVars(
|
|
|
234
223
|
|
|
235
224
|
/**
|
|
236
225
|
* Render the `.env`-format paste block: resolved KEY=value lines, then placeholder
|
|
237
|
-
* lines for any absent baseline token
|
|
226
|
+
* lines for any absent baseline token.
|
|
238
227
|
*/
|
|
239
228
|
export function renderCloudEnvBlock(
|
|
240
229
|
res: CloudEnvResolution,
|
|
@@ -245,9 +234,6 @@ export function renderCloudEnvBlock(
|
|
|
245
234
|
for (const [name, placeholder] of policy.baseline) {
|
|
246
235
|
if (res.placeholders.includes(name)) lines.push(`${name}=${placeholder}`);
|
|
247
236
|
}
|
|
248
|
-
for (const [key, value] of policy.constants) {
|
|
249
|
-
if (!res.included.some(([k]) => k === key)) lines.push(`${key}=${value}`);
|
|
250
|
-
}
|
|
251
237
|
return lines.join("\n");
|
|
252
238
|
}
|
|
253
239
|
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
// install/hosts.ts — which host modules a consumer has installed.
|
|
2
|
+
|
|
3
|
+
import * as fs from "node:fs";
|
|
4
|
+
import * as path from "node:path";
|
|
5
|
+
import type { ModuleFlag } from "../cli.js";
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Detect which host modules a consumer has installed, by the presence of each host's
|
|
9
|
+
* source-rendered agents directory. `bkit upgrade` re-renders only these hosts — never
|
|
10
|
+
* force-creating an opencode/cursor tree — and setup tips key host-specific advice on them.
|
|
11
|
+
*/
|
|
12
|
+
export function detectInstalledHostModules(cwd: string): Set<ModuleFlag> {
|
|
13
|
+
const mods = new Set<ModuleFlag>();
|
|
14
|
+
if (fs.existsSync(path.join(cwd, ".claude", "agents"))) mods.add("claude");
|
|
15
|
+
if (fs.existsSync(path.join(cwd, ".cursor", "agents"))) mods.add("cursor");
|
|
16
|
+
if (fs.existsSync(path.join(cwd, ".opencode", "agents"))) mods.add("opencode");
|
|
17
|
+
if (fs.existsSync(path.join(cwd, ".codex", "agents"))) mods.add("codex");
|
|
18
|
+
if (fs.existsSync(path.join(cwd, ".agents", "plugins", "bkit", "plugin.json")))
|
|
19
|
+
mods.add("antigravity");
|
|
20
|
+
return mods;
|
|
21
|
+
}
|
|
@@ -139,6 +139,42 @@ export function detectMarkerStyle(content: string): MarkerStyle | null {
|
|
|
139
139
|
return null;
|
|
140
140
|
}
|
|
141
141
|
|
|
142
|
+
// Verbatim long lines a text must share with a block, beside its title, to count as a copy.
|
|
143
|
+
const COPY_MIN_SHARED_LINES = 10;
|
|
144
|
+
// Shortest trimmed line counted as shared; shorter lines (rules, `>`, table dividers) recur by chance.
|
|
145
|
+
const COPY_MIN_LINE_LENGTH = 40;
|
|
146
|
+
|
|
147
|
+
// Lines outside fenced code blocks; a shell comment in a fence (`# Vercel errors`) is no heading.
|
|
148
|
+
function proseLines(text: string): string[] {
|
|
149
|
+
const out: string[] = [];
|
|
150
|
+
let inFence = false;
|
|
151
|
+
for (const line of text.split("\n")) {
|
|
152
|
+
if (line.trimStart().startsWith("```")) {
|
|
153
|
+
inFence = !inFence;
|
|
154
|
+
continue;
|
|
155
|
+
}
|
|
156
|
+
if (!inFence) out.push(line);
|
|
157
|
+
}
|
|
158
|
+
return out;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
// The block's `# ` title when `text` holds an older unmarked copy of the same markdown block:
|
|
162
|
+
// the title line plus COPY_MIN_SHARED_LINES long lines verbatim, all outside fenced code.
|
|
163
|
+
// Null otherwise, including for a block with no title.
|
|
164
|
+
export function findUnmarkedCopy(text: string, block: string): string | null {
|
|
165
|
+
const blockLines = proseLines(block);
|
|
166
|
+
const title = blockLines.find((l) => /^# \S/.test(l));
|
|
167
|
+
if (title === undefined) return null;
|
|
168
|
+
const textLines = proseLines(text);
|
|
169
|
+
if (!textLines.includes(title)) return null;
|
|
170
|
+
const long = new Set(
|
|
171
|
+
blockLines.map((l) => l.trim()).filter((l) => l.length >= COPY_MIN_LINE_LENGTH),
|
|
172
|
+
);
|
|
173
|
+
let shared = 0;
|
|
174
|
+
for (const l of new Set(textLines.map((t) => t.trim()))) if (long.has(l)) shared++;
|
|
175
|
+
return shared >= COPY_MIN_SHARED_LINES ? title : null;
|
|
176
|
+
}
|
|
177
|
+
|
|
142
178
|
// Remove the bkit-managed block (including marker lines) from a string,
|
|
143
179
|
// preserving all consumer-owned content outside the block.
|
|
144
180
|
//
|
|
@@ -133,9 +133,8 @@ const CORE_MANIFEST: ManifestEntry[] = [
|
|
|
133
133
|
{ path: ".bkit/comparison.md", format: "byte-equal-text", module: "core" },
|
|
134
134
|
{ path: ".bkit/install.md", format: "byte-equal-text", module: "core" },
|
|
135
135
|
{ path: ".bkit/jsonl.md", format: "byte-equal-text", module: "core" },
|
|
136
|
-
// The
|
|
137
|
-
//
|
|
138
|
-
// Required Notice). Sourced from `.bkit/core/.bkit/LICENSE.md`.
|
|
136
|
+
// The MIT notice that travels with the files bkit writes: the full text and copyright
|
|
137
|
+
// notice. Sourced from `.bkit/core/.bkit/LICENSE.md`.
|
|
139
138
|
{ path: ".bkit/LICENSE.md", format: "byte-equal-text", module: "core" },
|
|
140
139
|
{ path: ".bkit/providers.md", format: "byte-equal-text", module: "core" },
|
|
141
140
|
{ path: ".bkit/prompts.md", format: "markered-text", module: "core" },
|
|
@@ -162,6 +161,13 @@ const CLAUDE_MANIFEST: ManifestEntry[] = [
|
|
|
162
161
|
format: "markered-text",
|
|
163
162
|
module: "claude",
|
|
164
163
|
},
|
|
164
|
+
// ReadGuard advisory repeat-read hook — same ownership split as GateGuard. Wired in
|
|
165
|
+
// .claude/settings.json → PreToolUse (matcher `Read|Bash`) and PreCompact.
|
|
166
|
+
{
|
|
167
|
+
path: ".claude/hooks/bkit-readguard.cjs",
|
|
168
|
+
format: "markered-text",
|
|
169
|
+
module: "claude",
|
|
170
|
+
},
|
|
165
171
|
// bkit-guardrails.cjs — Tier-2 markered-text, twin of the Cursor/Codex hooks.
|
|
166
172
|
// PreToolUse matcher `Bash`. ADVISORY ONLY: covers URL hosts and shell-as-edit-channel;
|
|
167
173
|
// never denies or asks.
|
|
@@ -266,6 +272,14 @@ export const BKIT_BUILD_GATES: readonly string[] = [
|
|
|
266
272
|
"bkit:gate:static-unit",
|
|
267
273
|
];
|
|
268
274
|
|
|
275
|
+
/**
|
|
276
|
+
* Runs ONE test file — `pnpm bkit:test:file <repo-relative path>` — and writes a JUnit
|
|
277
|
+
* report to `$BKIT_TEST_REPORT`. `/bkit-build` records each task's red and audits its
|
|
278
|
+
* green through it. Never seeded: no default works on every stack; install advises
|
|
279
|
+
* when it is missing (detectGateAdvisories).
|
|
280
|
+
*/
|
|
281
|
+
export const BKIT_TEST_FILE_SCRIPT = "bkit:test:file";
|
|
282
|
+
|
|
269
283
|
/**
|
|
270
284
|
* The deeper gates, shallowest first, with what declaring each one costs.
|
|
271
285
|
*
|
|
@@ -317,6 +331,14 @@ const CURSOR_MANIFEST: ManifestEntry[] = [
|
|
|
317
331
|
format: "markered-text",
|
|
318
332
|
module: "cursor",
|
|
319
333
|
},
|
|
334
|
+
// ReadGuard for Cursor — same managed block as the Claude twin. Wired in
|
|
335
|
+
// .cursor/hooks.json → preToolUse (matcher "Read|Shell") and preCompact, without
|
|
336
|
+
// failClosed.
|
|
337
|
+
{
|
|
338
|
+
path: ".cursor/hooks/bkit-readguard.cjs",
|
|
339
|
+
format: "markered-text",
|
|
340
|
+
module: "cursor",
|
|
341
|
+
},
|
|
320
342
|
// Curl/wget host allowlist read at runtime by bkit-guardrails.cjs. No template backs it —
|
|
321
343
|
// `writeNetworkAllowlistArtifact` (install/cloud-env.ts) computes the domain set from the
|
|
322
344
|
// consumer's own config, so it is `generated` and its hash is in `canonicalHashes`.
|
|
@@ -354,6 +376,12 @@ export const OPENCODE_MANIFEST: ManifestEntry[] = [
|
|
|
354
376
|
format: "markered-text",
|
|
355
377
|
module: "opencode",
|
|
356
378
|
},
|
|
379
|
+
// bkit-readguard.js — same split as bkit-gateguard.js.
|
|
380
|
+
{
|
|
381
|
+
path: ".opencode/plugin/bkit-readguard.js",
|
|
382
|
+
format: "markered-text",
|
|
383
|
+
module: "opencode",
|
|
384
|
+
},
|
|
357
385
|
// Agent and command mirrors are managed dynamically (not listed individually here —
|
|
358
386
|
// the exact set depends on the bkit-prefix prompt/workflow files at install time).
|
|
359
387
|
// Uninstall uses the BKIT_PREFIX filter for .opencode/agents/ and .opencode/commands/.
|
|
@@ -374,6 +402,13 @@ export const CODEX_MANIFEST: ManifestEntry[] = [
|
|
|
374
402
|
format: "markered-text",
|
|
375
403
|
module: "codex",
|
|
376
404
|
},
|
|
405
|
+
// bkit-readguard.cjs — Tier-2 markered-text, twin of the Claude hook. Registered on
|
|
406
|
+
// PreToolUse matcher `Bash` (Codex has no read tool) and PreCompact.
|
|
407
|
+
{
|
|
408
|
+
path: ".codex/hooks/bkit-readguard.cjs",
|
|
409
|
+
format: "markered-text",
|
|
410
|
+
module: "codex",
|
|
411
|
+
},
|
|
377
412
|
// bkit-guardrails.cjs — Tier-2 markered-text, twin of the Cursor hook (same decision
|
|
378
413
|
// engine). Registered on matcher `Bash`, Codex's shell tool name. Codex parses but
|
|
379
414
|
// does not implement `permissionDecision: "ask"`, so the deny tier blocks for real
|
|
@@ -407,8 +442,15 @@ export const ANTIGRAVITY_MANIFEST: ManifestEntry[] = [
|
|
|
407
442
|
format: "markered-text",
|
|
408
443
|
module: "antigravity",
|
|
409
444
|
},
|
|
445
|
+
// bkit-readguard.cjs — Tier-2 markered-text, twin of the Claude hook. Registered on
|
|
446
|
+
// matcher `view_file|run_command`.
|
|
447
|
+
{
|
|
448
|
+
path: ".agents/plugins/bkit/hooks/bkit-readguard.cjs",
|
|
449
|
+
format: "markered-text",
|
|
450
|
+
module: "antigravity",
|
|
451
|
+
},
|
|
410
452
|
// bkit-guardrails.cjs — Tier-2 markered-text, twin of the Cursor/Codex hook. Registered
|
|
411
|
-
// on matcher `run_command`, Antigravity's shell tool
|
|
453
|
+
// on matcher `view_file|run_command`, Antigravity's file-read and shell tool names.
|
|
412
454
|
{
|
|
413
455
|
path: ".agents/plugins/bkit/hooks/bkit-guardrails.cjs",
|
|
414
456
|
format: "markered-text",
|
|
@@ -209,10 +209,10 @@ export function runAntigravityModule(ctx: ModuleContext): void {
|
|
|
209
209
|
}
|
|
210
210
|
}
|
|
211
211
|
|
|
212
|
-
// --- bkit-gateguard.cjs — Tier-2 markered-text,
|
|
213
|
-
{
|
|
214
|
-
const hookSrc = path.join(pluginHooksSrc,
|
|
215
|
-
const hookDst = path.join(ANTIGRAVITY_HOOKS_DIR,
|
|
212
|
+
// --- bkit-gateguard.cjs / bkit-readguard.cjs — Tier-2 markered-text, twins of the Claude/Codex hooks ---
|
|
213
|
+
for (const hook of ["bkit-gateguard.cjs", "bkit-readguard.cjs"]) {
|
|
214
|
+
const hookSrc = path.join(pluginHooksSrc, hook);
|
|
215
|
+
const hookDst = path.join(ANTIGRAVITY_HOOKS_DIR, hook);
|
|
216
216
|
if (fs.existsSync(hookSrc)) {
|
|
217
217
|
if (!dryRun) ensureDir(path.dirname(hookDst));
|
|
218
218
|
const prevLen = ws.writes.length;
|
|
@@ -222,8 +222,9 @@ export function runAntigravityModule(ctx: ModuleContext): void {
|
|
|
222
222
|
}
|
|
223
223
|
|
|
224
224
|
// --- bkit-guardrails.cjs — Tier-2 markered-text, twin of the Cursor/Codex hook ---
|
|
225
|
-
// Registered on matcher `run_command` in hooks.json above. Same decision engine
|
|
226
|
-
// other hosts; the deny tier blocks
|
|
225
|
+
// Registered on matcher `view_file|run_command` in hooks.json above. Same decision engine
|
|
226
|
+
// as the other hosts (shell tiers; read tiers shared with Cursor); the deny tier blocks
|
|
227
|
+
// for real.
|
|
227
228
|
{
|
|
228
229
|
const railSrc = path.join(pluginHooksSrc, "bkit-guardrails.cjs");
|
|
229
230
|
const railDst = path.join(ANTIGRAVITY_HOOKS_DIR, "bkit-guardrails.cjs");
|
|
@@ -244,7 +245,7 @@ export function runAntigravityModule(ctx: ModuleContext): void {
|
|
|
244
245
|
"Three things that differ from the other hosts:\n" +
|
|
245
246
|
"1. Workflows are SKILLS here, not slash commands: Antigravity discovers them under `.agents/plugins/bkit/skills/bkit-<wf>/SKILL.md` (the plugin activates per project — no toggle).\n" +
|
|
246
247
|
"2. There is no native subagent tool. The orchestrator loads each subagent prompt from `.agents/plugins/bkit/agents/` with `view_file` and executes it in-session; isolated runs use `run_command` (`agy`).\n" +
|
|
247
|
-
"3. GateGuard and guardrails are wired from `.agents/plugins/bkit/hooks.json` (PreToolUse on `write_to_file` / `replace_file_content` / `run_command`). See .bkit/providers.md.",
|
|
248
|
+
"3. GateGuard, ReadGuard and guardrails are wired from `.agents/plugins/bkit/hooks.json` (PreToolUse on `write_to_file` / `replace_file_content` / `view_file` / `run_command`). See .bkit/providers.md.",
|
|
248
249
|
});
|
|
249
250
|
|
|
250
251
|
// Both hosts installed: Antigravity's skill selector lists TWO sets of bkit-* skills.
|
|
@@ -140,13 +140,13 @@ export function runClaudeModule(ctx: ModuleContext): void {
|
|
|
140
140
|
}
|
|
141
141
|
}
|
|
142
142
|
|
|
143
|
-
// markered-text (slash-comment) — GateGuard advisory
|
|
143
|
+
// markered-text (slash-comment) — GateGuard and ReadGuard advisory hooks. bkit owns
|
|
144
144
|
// only the advisory engine between the markers; consumers own the stdin/stdout
|
|
145
|
-
// driver from first install onward (env vars BKIT_GATEGUARD / BKIT_ALLOW_CONFIG_EDIT
|
|
146
|
-
// still tune behaviour
|
|
147
|
-
{
|
|
148
|
-
const src = path.join(claudeHooks,
|
|
149
|
-
const dst =
|
|
145
|
+
// driver from first install onward (env vars BKIT_GATEGUARD / BKIT_ALLOW_CONFIG_EDIT /
|
|
146
|
+
// BKIT_READGUARD still tune behaviour).
|
|
147
|
+
for (const hook of ["bkit-gateguard.cjs", "bkit-readguard.cjs"]) {
|
|
148
|
+
const src = path.join(claudeHooks, hook);
|
|
149
|
+
const dst = `.claude/hooks/${hook}`;
|
|
150
150
|
if (fs.existsSync(src)) {
|
|
151
151
|
const prevLen = ws.writes.length;
|
|
152
152
|
writeTier2(src, dst, tokens, "slash-comment", dryRun, ws);
|
|
@@ -102,8 +102,8 @@ export function runCloudModule(ctx: ModuleContext): void {
|
|
|
102
102
|
"IN CLAUDE APP (claude.ai/code → environment selector → + Add environment):\n" +
|
|
103
103
|
" - Name: the repo name (e.g. `acme-web`) — one environment per repo, since secrets are per-repo.\n" +
|
|
104
104
|
" - Setup script: paste from bkit's `cloud.md` § Setup script (installs vale + gh + corepack-pinned pnpm — exact versions live in cloud.md, not duplicated here).\n" +
|
|
105
|
-
" - Environment variables: `BKIT_GH_TOKEN` (fine-grained for one owner, classic across owners — GitHub MCP)
|
|
106
|
-
" - Tracker env vars (GitHub):
|
|
105
|
+
" - Environment variables: `BKIT_GH_TOKEN` (fine-grained for one owner, classic across owners — GitHub MCP).\n" +
|
|
106
|
+
" - Tracker env vars (GitHub): `BKIT_GH_TOKEN` above is the only tracker credential — the GitHub MCP server sends it on every call, and the bootstrap hook signs `gh` in with it.\n" +
|
|
107
107
|
" - Network access: `Trusted` (default). One environment per repo (secrets differ per repo); the setup script + variable *names* are identical across repos, only the values change. See cloud.md § Sharing across repos → Claude.",
|
|
108
108
|
});
|
|
109
109
|
} else if (variant === "opencode") {
|
|
@@ -182,10 +182,10 @@ export function runCodexModule(ctx: ModuleContext): void {
|
|
|
182
182
|
}
|
|
183
183
|
}
|
|
184
184
|
|
|
185
|
-
// --- bkit-gateguard.cjs — Tier-2 markered-text,
|
|
186
|
-
{
|
|
187
|
-
const hookSrc = path.join(codexHooks,
|
|
188
|
-
const hookDst =
|
|
185
|
+
// --- bkit-gateguard.cjs / bkit-readguard.cjs — Tier-2 markered-text, twins of the Claude hooks ---
|
|
186
|
+
for (const hook of ["bkit-gateguard.cjs", "bkit-readguard.cjs"]) {
|
|
187
|
+
const hookSrc = path.join(codexHooks, hook);
|
|
188
|
+
const hookDst = `.codex/hooks/${hook}`;
|
|
189
189
|
if (fs.existsSync(hookSrc)) {
|
|
190
190
|
if (!dryRun) ensureDir(path.dirname(hookDst));
|
|
191
191
|
const prevLen = ws.writes.length;
|
|
@@ -215,7 +215,7 @@ export function runCodexModule(ctx: ModuleContext): void {
|
|
|
215
215
|
detect: "codex host installed (.codex/agents + .agents/skills/bkit-*).",
|
|
216
216
|
action:
|
|
217
217
|
"Three things that differ from the other hosts:\n" +
|
|
218
|
-
"1. TRUST THE LAYER. Codex loads project-local hooks only once the `.codex/` layer is trusted. Until then GateGuard
|
|
218
|
+
"1. TRUST THE LAYER. Codex loads project-local hooks only once the `.codex/` layer is trusted. Until then GateGuard and ReadGuard are installed and never fire.\n" +
|
|
219
219
|
"2. Workflows are SKILLS here, not slash commands: invoke `$bkit-design`, not `/bkit-design`.\n" +
|
|
220
220
|
"3. Per-agent `tools:` is NOT enforced. Codex has no tool allowlist, so every agent gets the full built-in tool set. See .bkit/providers.md.",
|
|
221
221
|
});
|
|
@@ -22,7 +22,12 @@ import {
|
|
|
22
22
|
getBkitDocsRoot,
|
|
23
23
|
TEMPLATE_COPIES_DIR,
|
|
24
24
|
} from "../../shared/package-roots.js";
|
|
25
|
-
import {
|
|
25
|
+
import {
|
|
26
|
+
getInstallManifest,
|
|
27
|
+
BKIT_GATE_SCRIPTS,
|
|
28
|
+
BKIT_OPTIONAL_GATES,
|
|
29
|
+
BKIT_TEST_FILE_SCRIPT,
|
|
30
|
+
} from "../manifest.js";
|
|
26
31
|
import type { ModuleContext } from "./index.js";
|
|
27
32
|
|
|
28
33
|
export function listMdFiles(dir: string, prefix?: string): string[] {
|
|
@@ -94,10 +99,9 @@ export function removeOrphans(
|
|
|
94
99
|
// ---------------------------------------------------------------------------
|
|
95
100
|
// Core payload — the files install writes from `core/`, at their
|
|
96
101
|
// folder-relative dest paths. The package-only subtrees (engine/, workflows/,
|
|
97
|
-
// prompts/, .bkit/, hooks/)
|
|
98
|
-
//
|
|
99
|
-
//
|
|
100
|
-
// reference docs.
|
|
102
|
+
// prompts/, .bkit/, hooks/) and the shared/ and templates/ payloads are NOT
|
|
103
|
+
// part of this walk: the host modules write their own hook files (sourced from
|
|
104
|
+
// `core/`), and `runBkitDocs` mirrors the reference docs.
|
|
101
105
|
// ---------------------------------------------------------------------------
|
|
102
106
|
|
|
103
107
|
/** A core-owned payload file and how install writes it. */
|
|
@@ -226,9 +230,8 @@ function runCoreTemplates(
|
|
|
226
230
|
// them, so a consumer edit is replaced. Source of truth is the package's own
|
|
227
231
|
// `.bkit/core/.bkit/<name>`. (`advisories.md` is a regenerated runtime artifact,
|
|
228
232
|
// `wording.md` is repo-only tooling and `friction.md` is a consumer-owned seed —
|
|
229
|
-
// none belongs here. `LICENSE.md` is the
|
|
230
|
-
//
|
|
231
|
-
// the terms or their URL and the Required Notice line.)
|
|
233
|
+
// none belongs here. `LICENSE.md` is the MIT notice that travels with the files bkit
|
|
234
|
+
// writes: MIT requires the copyright and permission notice in every copy.)
|
|
232
235
|
export const BKIT_CANONICAL_DOCS = [
|
|
233
236
|
"cloud.md",
|
|
234
237
|
"comparison.md",
|
|
@@ -417,6 +420,17 @@ export function detectGateAdvisories(cwd: string): PreflightFinding[] {
|
|
|
417
420
|
"\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.",
|
|
418
421
|
});
|
|
419
422
|
}
|
|
423
|
+
|
|
424
|
+
// /bkit-build records each task's red through this script; without it test-first is
|
|
425
|
+
// reported as not enforced. bkit cannot seed it: what runs one file is the stack's.
|
|
426
|
+
if (!(BKIT_TEST_FILE_SCRIPT in declared)) {
|
|
427
|
+
findings.push({
|
|
428
|
+
id: "test-file-script-missing",
|
|
429
|
+
severity: "advisory",
|
|
430
|
+
detect: `package.json does not declare \`${BKIT_TEST_FILE_SCRIPT}\`, so \`/bkit-build\` cannot check that each task's tests fail before its code is written.`,
|
|
431
|
+
action: `Add \`${BKIT_TEST_FILE_SCRIPT}\` to package.json: it runs the ONE test file bkit appends as its argument (repo-relative path) and writes a JUnit report to the path in \`$BKIT_TEST_REPORT\`. Vitest example:\n\n "${BKIT_TEST_FILE_SCRIPT}": "vitest run --reporter=default --reporter=junit --outputFile.junit=\\"$BKIT_TEST_REPORT\\""\n\nCall the runner directly, not through a task runner that caches results or runs dependent packages first. A monorepo routes the path to the package and config that own it.`,
|
|
432
|
+
});
|
|
433
|
+
}
|
|
420
434
|
return findings;
|
|
421
435
|
}
|
|
422
436
|
|
|
@@ -509,7 +523,7 @@ export function runCoreModule(ctx: ModuleContext): void {
|
|
|
509
523
|
// installed package (browse-only, gitignored; no-op in dogfood). A real
|
|
510
524
|
// directory or file at either path is never clobbered (advisory); a platform
|
|
511
525
|
// refusal is an advisory, never a failure.
|
|
512
|
-
const linkChanges = syncPayloadLinks(cwd, { dryRun
|
|
526
|
+
const linkChanges = syncPayloadLinks(cwd, { dryRun });
|
|
513
527
|
for (const rel of linkChanges.created) {
|
|
514
528
|
console.log(`${logPrefix} ${tag}payload link: ${rel}`);
|
|
515
529
|
}
|
|
@@ -154,12 +154,12 @@ export function runCursorModule(ctx: ModuleContext): void {
|
|
|
154
154
|
}
|
|
155
155
|
}
|
|
156
156
|
|
|
157
|
-
// markered-text (slash-comment) — GateGuard advisory
|
|
158
|
-
// Same managed
|
|
159
|
-
// payload (relative file_path, no subagent marker) and
|
|
160
|
-
{
|
|
161
|
-
const src = path.join(cursorHooks,
|
|
162
|
-
const dst =
|
|
157
|
+
// markered-text (slash-comment) — GateGuard and ReadGuard advisory hooks for Cursor.
|
|
158
|
+
// Same managed blocks as the Claude twins; the drivers outside them adapt Cursor's
|
|
159
|
+
// payload (relative file_path, no subagent marker) and emit Cursor's shape.
|
|
160
|
+
for (const hook of ["bkit-gateguard.cjs", "bkit-readguard.cjs"]) {
|
|
161
|
+
const src = path.join(cursorHooks, hook);
|
|
162
|
+
const dst = `.cursor/hooks/${hook}`;
|
|
163
163
|
if (fs.existsSync(src)) {
|
|
164
164
|
const prevLen = ws.writes.length;
|
|
165
165
|
writeTier2(src, dst, tokens, "slash-comment", dryRun, ws);
|
|
@@ -533,11 +533,11 @@ export function runOpencodeModule(ctx: ModuleContext): void {
|
|
|
533
533
|
}
|
|
534
534
|
}
|
|
535
535
|
|
|
536
|
-
// --- bkit-gateguard.js — Tier-2 markered-text (slash-comment); see install/manifest.ts ---
|
|
537
|
-
{
|
|
536
|
+
// --- bkit-gateguard.js / bkit-readguard.js — Tier-2 markered-text (slash-comment); see install/manifest.ts ---
|
|
537
|
+
for (const plugin of ["bkit-gateguard.js", "bkit-readguard.js"]) {
|
|
538
538
|
const opencodeCore = path.join(getCoreRoot(), ".opencode", "plugin");
|
|
539
|
-
const pluginSrc = path.join(opencodeCore,
|
|
540
|
-
const pluginDst =
|
|
539
|
+
const pluginSrc = path.join(opencodeCore, plugin);
|
|
540
|
+
const pluginDst = `.opencode/plugin/${plugin}`;
|
|
541
541
|
if (fs.existsSync(pluginSrc)) {
|
|
542
542
|
// dryRun-gated — writeTier2 honours dryRun, so the dir is only needed for a real
|
|
543
543
|
// write; `bkit check` stays read-only when gateguard's parent dir is absent.
|
|
@@ -6,7 +6,6 @@
|
|
|
6
6
|
import * as fs from "node:fs";
|
|
7
7
|
import * as path from "node:path";
|
|
8
8
|
import { getCoreRoot, getPkgRoot, getSharedRoot } from "../shared/package-roots.js";
|
|
9
|
-
import type { WriteSet } from "./write.js";
|
|
10
9
|
|
|
11
10
|
// The two view links: a symlink at the consumer-relative `relPath` pointing at the
|
|
12
11
|
// package payload dir `target()` resolves to. Relative targets, so the link keeps
|
|
@@ -58,14 +57,12 @@ export function createPayloadLink(
|
|
|
58
57
|
// Create or refresh the consumer's `.bkit/core` + `.bkit/shared` view links into
|
|
59
58
|
// the package payload. Idempotent: a correct link is kept, a dangling or
|
|
60
59
|
// mis-pointed symlink is re-pointed, a real directory or file is NEVER clobbered
|
|
61
|
-
// (skippedRealDir) and a platform refusal is only recorded (failed).
|
|
62
|
-
//
|
|
63
|
-
// missing or broken link
|
|
64
|
-
//
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
opts: { dryRun: boolean; ws: WriteSet },
|
|
68
|
-
): PayloadLinkChanges {
|
|
60
|
+
// (skippedRealDir) and a platform refusal is only recorded (failed). Links are
|
|
61
|
+
// convenience views, not managed content: they never join the install WriteSet, so
|
|
62
|
+
// a missing or broken link is never `bkit check` drift (a fresh clone or worktree
|
|
63
|
+
// has none). Dry-run reports what a live run would do and touches nothing. No-op
|
|
64
|
+
// in dogfood: there `.bkit/core` IS the package source, never a view onto it.
|
|
65
|
+
export function syncPayloadLinks(cwd: string, opts: { dryRun: boolean }): PayloadLinkChanges {
|
|
69
66
|
const changes: PayloadLinkChanges = {
|
|
70
67
|
created: [],
|
|
71
68
|
repaired: [],
|
|
@@ -122,7 +119,6 @@ export function syncPayloadLinks(
|
|
|
122
119
|
}
|
|
123
120
|
}
|
|
124
121
|
(st !== null ? changes.repaired : changes.created).push(relPath);
|
|
125
|
-
opts.ws.writes.push({ path: relPath, action: "write" });
|
|
126
122
|
}
|
|
127
123
|
return changes;
|
|
128
124
|
}
|
|
@@ -102,7 +102,7 @@ export function applyTokens(content: string, tokens: TokenMap): string {
|
|
|
102
102
|
const version = tokens.BKIT_VERSION ?? readInstallingBkitVersion();
|
|
103
103
|
out = out
|
|
104
104
|
.replace(/^\/\/ \{\{BKIT_MANAGED_MARKER\}\}/gm, () => managedVersionMarker(version, "slash"))
|
|
105
|
-
.replace(/\{\{BKIT_MANAGED_MARKER\}\}/g, () => managedVersionMarker(version));
|
|
105
|
+
.replace(/\{\{BKIT_MANAGED_MARKER\}\}/g, () => managedVersionMarker(version, "html"));
|
|
106
106
|
}
|
|
107
107
|
return out;
|
|
108
108
|
}
|
|
@@ -161,6 +161,9 @@ export function isConsumerModified(
|
|
|
161
161
|
* cases; the latter survive the absent-path prune because the adopted copy stays on
|
|
162
162
|
* disk).
|
|
163
163
|
*
|
|
164
|
+
* `removing` lists paths (or directories) a dry run would delete: they count as absent, so a
|
|
165
|
+
* dry run prunes the same entries the real run does.
|
|
166
|
+
*
|
|
164
167
|
* `pruned` counts the dropped entries so callers can treat a prune-only merge as a
|
|
165
168
|
* change that is still worth writing.
|
|
166
169
|
*/
|
|
@@ -168,11 +171,21 @@ export function mergeCanonicalHashes(
|
|
|
168
171
|
cwd: string,
|
|
169
172
|
existing: Record<string, string>,
|
|
170
173
|
fresh: Record<string, string>,
|
|
174
|
+
removing: readonly string[] = [],
|
|
171
175
|
): { canonicalHashes: Record<string, string>; pruned: number } {
|
|
172
176
|
const canonicalHashes: Record<string, string> = {};
|
|
177
|
+
const isRemoving = (relPath: string): boolean =>
|
|
178
|
+
removing.some((r) => {
|
|
179
|
+
const dir = r.replace(/[\\/]+$/, "");
|
|
180
|
+
return relPath === dir || relPath.startsWith(`${dir}/`);
|
|
181
|
+
});
|
|
173
182
|
let pruned = 0;
|
|
174
183
|
for (const [relPath, hash] of Object.entries(existing)) {
|
|
175
|
-
if (
|
|
184
|
+
if (
|
|
185
|
+
!fs.existsSync(path.join(cwd, relPath)) ||
|
|
186
|
+
isRemoving(relPath) ||
|
|
187
|
+
isTemplateSetPath(relPath)
|
|
188
|
+
) {
|
|
176
189
|
pruned++;
|
|
177
190
|
continue;
|
|
178
191
|
}
|
|
@@ -216,15 +229,10 @@ export function hashFile(filePath: string): string | null {
|
|
|
216
229
|
// hash `# <!-- bkit:managed vX.Y.Z — … -->` shell, `.gitignore`, `.env.example`, TOML
|
|
217
230
|
// slash `// bkit:managed vX.Y.Z — …` JS (`.cjs` / `.js` / `.mjs`)
|
|
218
231
|
//
|
|
219
|
-
// The marker names the licence the bkit-written files are under (PolyForm Noncommercial
|
|
220
|
-
// or Small Business, the pair `.bkit/LICENSE.md` carries in full) and the licences-index
|
|
221
|
-
// URL, so a copy passed on in a public repo carries the terms URL with it (PolyForm's
|
|
222
|
-
// Notices section). `.bkit/LICENSE.md` is written by runBkitDocs (install/modules/core.ts).
|
|
223
|
-
//
|
|
224
232
|
// Rendered agents / commands / skills are stamped at render (stampManagedVersion);
|
|
225
233
|
// every other file carries the `{{BKIT_MANAGED_MARKER}}` token in its source, which
|
|
226
|
-
// applyTokens (install/placeholders.ts) resolves to the form its comment prefix selects.
|
|
227
|
-
// `bkit check` gate (detectManagedStale, checks/after/index.ts) reads the stamp back
|
|
234
|
+
// applyTokens (install/placeholders.ts) resolves to the form its comment prefix selects.
|
|
235
|
+
// The `bkit check` gate (detectManagedStale, checks/after/index.ts) reads the stamp back
|
|
228
236
|
// with readManagedVersion.
|
|
229
237
|
// ---------------------------------------------------------------------------
|
|
230
238
|
|
|
@@ -240,7 +248,7 @@ export const MANAGED_MARKER_VERSION_RE = /bkit:managed v(\S+)/;
|
|
|
240
248
|
|
|
241
249
|
/** Build the managed-version marker for a given version, in the given comment syntax. */
|
|
242
250
|
export function managedVersionMarker(version: string, form: ManagedMarkerForm = "html"): string {
|
|
243
|
-
const text = `bkit:managed v${version} —
|
|
251
|
+
const text = `bkit:managed v${version} — do not edit; run \`bkit upgrade\` to refresh`;
|
|
244
252
|
if (form === "slash") return `// ${text}`;
|
|
245
253
|
return form === "hash" ? `# <!-- ${text} -->` : `<!-- ${text} -->`;
|
|
246
254
|
}
|