@cbartens/bkit 5.2.4 → 5.3.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 +26 -11
- package/.bkit/core/.agents/context.md +1 -1
- package/.bkit/core/.agents/docs.md +1 -1
- package/.bkit/core/.agents/plugins/bkit/hooks/bkit-guardrails.cjs +1 -1
- package/.bkit/core/.agents/rules.md +11 -0
- package/.bkit/core/.bkit/README.md +25 -10
- package/.bkit/core/.bkit/cloud.md +9 -8
- package/.bkit/core/.bkit/comparison.md +68 -345
- package/.bkit/core/.bkit/install.md +12 -6
- package/.bkit/core/.bkit/lite.md +73 -0
- package/.bkit/core/.bkit/pipeline.md +345 -0
- package/.bkit/core/.bkit/prompts.md +88 -73
- package/.bkit/core/.bkit/providers.md +41 -22
- package/.bkit/core/.bkit/templates.md +106 -17
- package/.bkit/core/.bkit/trackers.md +47 -1
- package/.bkit/core/.bkit/workflows.md +44 -43
- package/.bkit/core/.claude/hooks/bkit-guardrails.cjs +1 -1
- package/.bkit/core/.codex/hooks/bkit-guardrails.cjs +7 -4
- package/.bkit/core/.cursor/hooks/bkit-guardrails.cjs +8 -5
- package/.bkit/core/docs/templates/bkit-audit-adoption.md +1 -1
- package/.bkit/core/docs/templates/bkit-audit-dependencies.md +14 -10
- package/.bkit/core/docs/templates/bkit-audit-llm.md +20 -14
- package/.bkit/core/docs/templates/bkit-audit-prompts.md +2 -2
- package/.bkit/core/docs/templates/bkit-audit-red-team.md +10 -8
- package/.bkit/core/docs/templates/bkit-audit-security.md +3 -3
- package/.bkit/core/docs/templates/bkit-audit-testing.md +4 -3
- package/.bkit/core/docs/templates/bkit-plan.md +8 -6
- package/.bkit/core/engine/checks/after/auth.ts +9 -9
- package/.bkit/core/engine/checks/after/ci-yml.ts +14 -12
- package/.bkit/core/engine/checks/after/github.ts +29 -120
- package/.bkit/core/engine/checks/after/index.ts +2 -2
- package/.bkit/core/engine/checks/after/managed.ts +8 -28
- package/.bkit/core/engine/checks/after/tools.ts +3 -15
- package/.bkit/core/engine/checks/before/context-fetch.ts +1 -21
- package/.bkit/core/engine/checks/before/index.ts +7 -43
- package/.bkit/core/engine/checks/before/mcp.ts +17 -8
- package/.bkit/core/engine/checks/before/repo.ts +9 -12
- package/.bkit/core/engine/checks/status-holes.ts +4 -5
- package/.bkit/core/engine/checks/tips/catalogue.ts +60 -24
- package/.bkit/core/engine/checks/tips/detect.ts +45 -2
- package/.bkit/core/engine/checks/tips/index.ts +37 -8
- package/.bkit/core/engine/cli.ts +39 -16
- package/.bkit/core/engine/commands/analysis.ts +36 -26
- package/.bkit/core/engine/commands/comply.ts +17 -16
- package/.bkit/core/engine/commands/harvest.ts +12 -12
- package/.bkit/core/engine/commands/install/doctor.ts +57 -28
- package/.bkit/core/engine/commands/install/install.ts +62 -126
- package/.bkit/core/engine/commands/install/uninstall.ts +191 -33
- package/.bkit/core/engine/commands/install/upgrade.ts +49 -43
- package/.bkit/core/engine/commands/lib.ts +35 -10
- package/.bkit/core/engine/commands/tips.ts +8 -5
- package/.bkit/core/engine/commands/workflow/branches.ts +4 -4
- package/.bkit/core/engine/commands/workflow/counters.ts +21 -12
- package/.bkit/core/engine/commands/workflow/fids.ts +46 -0
- package/.bkit/core/engine/commands/workflow/ledgers.ts +3 -1
- package/.bkit/core/engine/commands/workflow/prs.ts +4 -2
- package/.bkit/core/engine/commands/workflow/repo.ts +2 -2
- package/.bkit/core/engine/commands/workflow/roadmap.ts +4 -3
- package/.bkit/core/engine/commands/workflow/runs.ts +8 -7
- package/.bkit/core/engine/commands/workflow/steps.ts +1 -0
- package/.bkit/core/engine/commands/workflow/tests.ts +17 -5
- package/.bkit/core/engine/commands/workflow/workflows.ts +15 -14
- package/.bkit/core/engine/commands/workflow/workstreams.ts +2 -1
- package/.bkit/core/engine/commands/workflow/worktrees.ts +13 -5
- package/.bkit/core/engine/install/cloud-env.ts +10 -31
- package/.bkit/core/engine/install/manifest.ts +14 -7
- package/.bkit/core/engine/install/modules/antigravity.ts +15 -26
- package/.bkit/core/engine/install/modules/claude.ts +20 -28
- package/.bkit/core/engine/install/modules/cloud.ts +5 -2
- package/.bkit/core/engine/install/modules/codex.ts +15 -29
- package/.bkit/core/engine/install/modules/core.ts +91 -70
- package/.bkit/core/engine/install/modules/cursor.ts +6 -20
- package/.bkit/core/engine/install/modules/index.ts +7 -1
- package/.bkit/core/engine/install/modules/opencode.ts +48 -70
- package/.bkit/core/engine/install/network-allowlist.ts +73 -0
- package/.bkit/core/engine/install/placeholders.ts +3 -18
- package/.bkit/core/engine/install/write.ts +59 -12
- package/.bkit/core/engine/ledgers/telemetry.ts +6 -4
- package/.bkit/core/engine/render/hosts.ts +47 -67
- package/.bkit/core/engine/render/models.ts +29 -11
- package/.bkit/core/engine/shared/branches.ts +13 -0
- package/.bkit/core/engine/shared/egress.ts +3 -3
- package/.bkit/core/engine/shared/json.ts +18 -1
- package/.bkit/core/engine/shared/package-json.ts +63 -0
- package/.bkit/core/engine/shared/package-roots.ts +0 -10
- package/.bkit/core/engine/shared/protected-paths.ts +5 -130
- package/.bkit/core/engine/shared/settings.ts +36 -0
- package/.bkit/core/hooks/antigravity-hook.js +1 -0
- package/.bkit/core/hooks/guardrails-shell.js +186 -40
- package/.bkit/core/hooks/guardrails-tiers.js +5 -78
- package/.bkit/core/prompts/bkit-audit-generate.md +60 -7
- package/.bkit/core/prompts/bkit-build-challenge-1.md +1 -1
- package/.bkit/core/prompts/bkit-build-challenge-2.md +1 -1
- package/.bkit/core/prompts/bkit-build-challenge-reconcile.md +1 -1
- package/.bkit/core/prompts/bkit-build-challenge-remediate.md +1 -1
- package/.bkit/core/prompts/bkit-build-challenge-tests.md +1 -1
- package/.bkit/core/prompts/bkit-build-install-skills.md +1 -1
- package/.bkit/core/prompts/bkit-build-plan-current.md +1 -1
- package/.bkit/core/prompts/bkit-build-plan-execute.md +4 -4
- package/.bkit/core/prompts/bkit-build-plan-gaps-remediate.md +1 -1
- package/.bkit/core/prompts/bkit-build-plan-verify.md +2 -2
- package/.bkit/core/prompts/bkit-debug-abort-handover.md +1 -1
- package/.bkit/core/prompts/bkit-debug-failure-diagnose.md +1 -1
- package/.bkit/core/prompts/bkit-debug-failure-remediate.md +1 -1
- package/.bkit/core/prompts/bkit-debug-failure-reproduce.md +78 -0
- package/.bkit/core/prompts/bkit-debug-failure-soak.md +1 -1
- package/.bkit/core/prompts/bkit-debug-summary.md +3 -3
- package/.bkit/core/prompts/bkit-design-spike.md +1 -1
- package/.bkit/core/prompts/bkit-design-summary.md +2 -2
- package/.bkit/core/prompts/bkit-design-update.md +1 -1
- package/.bkit/core/prompts/bkit-plan-complexity-check.md +1 -1
- package/.bkit/core/prompts/bkit-plan-generate.md +1 -1
- package/.bkit/core/prompts/bkit-plan-scope-check-1.md +1 -1
- package/.bkit/core/prompts/bkit-plan-scope-check-2.md +1 -1
- package/.bkit/core/prompts/bkit-plan-summary.md +1 -1
- package/.bkit/core/prompts/bkit-plan-update.md +1 -1
- package/.bkit/core/prompts/bkit-ship-conflict-resolve.md +1 -1
- package/.bkit/core/prompts/bkit-ship-deferred-sweep.md +1 -1
- package/.bkit/core/prompts/bkit-ship-update-docs.md +1 -1
- package/.bkit/core/prompts/bkit-utility-update-decisions.md +9 -2
- package/.bkit/core/prompts/bkit-utility-update-deferrals.md +9 -2
- package/.bkit/core/prompts/bkit-utility-update-documentation.md +2 -1
- package/.bkit/core/prompts/bkit-utility-update-failures.md +9 -2
- package/.bkit/core/prompts/bkit-utility-update-knowledge.md +9 -2
- package/.bkit/core/prompts/bkit-utility-update-roadmap.md +11 -4
- package/.bkit/core/workflows/bkit-build.md +3 -3
- package/.bkit/core/workflows/bkit-debug.md +69 -33
- package/.bkit/core/workflows/bkit-design.md +2 -2
- package/.bkit/core/workflows/bkit-plan.md +11 -4
- package/.bkit/core/workflows/bkit-ship.md +5 -5
- package/.bkit/shared/.claude/bkit-cloud.md +46 -13
- package/.bkit/shared/.claude/settings.json +18 -0
- package/.bkit/shared/.cursor/mcp.json +2 -1
- package/.bkit/shared/.opencode/opencode.json +19 -1
- package/.bkit/shared/docs/deployments.md +20 -4
- package/.bkit/shared/docs/security.md +8 -6
- package/.bkit/shared/docs/testing.md +9 -5
- package/.bkit/templates/.cursor/Dockerfile +30 -16
- package/.bkit/templates/.github/ISSUE_TEMPLATE/bkit-bug.yml +78 -0
- package/.bkit/templates/.github/ISSUE_TEMPLATE/bkit-change.yml +91 -0
- package/.bkit/templates/.github/ISSUE_TEMPLATE/bkit-idea.yml +56 -0
- package/.bkit/templates/.github/renovate.json5 +91 -12
- package/.bkit/templates/.github/workflows/bkit-ci.yml +66 -53
- package/.bkit/templates/.github/workflows/bkit-cloud.yml +3 -1
- package/.bkit/templates/.github/workflows/bkit-renovate.yml +8 -1
- package/.bkit/templates/.github/workflows/bkit-trivy.yml +67 -0
- package/.bkit/templates/.husky/pre-push +8 -3
- package/.bkit/templates/.oxlintrc.json +21 -0
- package/.bkit/templates/docs/capabilities.md +1 -1
- package/.bkit/templates/scripts/ci/check-capstone.mjs +176 -0
- package/.bkit/templates/scripts/ci/check-capstone.test.mjs +311 -0
- package/.bkit/templates/scripts/graphify/bkit-graph-eager.py +2 -2
- package/.bkit/templates/scripts/graphify/bkit-graph-imports.py +43 -20
- package/.bkit/templates/scripts/graphify/bkit-graph-pre-push.sh +33 -11
- package/.bkit/templates/scripts/graphify/bkit-graph-repair.py +3 -2
- package/.bkit/templates/scripts/graphify/bkit-graphify-rollup.py +5 -5
- package/.bkit/templates/scripts/graphify/bkit-graphify.sh +79 -19
- package/CHANGELOG.md +50 -3
- package/README.md +258 -129
- package/dist/checks/after/auth.js +10 -11
- package/dist/checks/after/ci-yml.js +11 -14
- package/dist/checks/after/github.js +32 -125
- package/dist/checks/after/index.js +3 -2
- package/dist/checks/after/managed.js +8 -24
- package/dist/checks/after/tools.js +3 -16
- package/dist/checks/before/context-fetch.js +1 -21
- package/dist/checks/before/index.js +6 -42
- package/dist/checks/before/mcp.js +14 -9
- package/dist/checks/before/repo.js +8 -11
- package/dist/checks/status-holes.js +5 -6
- package/dist/checks/tips/catalogue.js +51 -18
- package/dist/checks/tips/detect.js +41 -2
- package/dist/checks/tips/index.js +25 -5
- package/dist/cli.js +34 -14
- package/dist/commands/analysis.js +21 -5
- package/dist/commands/comply.js +20 -18
- package/dist/commands/harvest.js +12 -13
- package/dist/commands/install/doctor.js +55 -23
- package/dist/commands/install/install.js +62 -118
- package/dist/commands/install/uninstall.js +165 -31
- package/dist/commands/install/upgrade.js +46 -39
- package/dist/commands/lib.js +32 -10
- package/dist/commands/tips.js +6 -3
- package/dist/commands/workflow/branches.js +3 -5
- package/dist/commands/workflow/counters.js +17 -7
- package/dist/commands/workflow/fids.js +39 -0
- package/dist/commands/workflow/ledgers.js +3 -1
- package/dist/commands/workflow/prs.js +3 -3
- package/dist/commands/workflow/repo.js +2 -2
- package/dist/commands/workflow/roadmap.js +4 -4
- package/dist/commands/workflow/runs.js +5 -5
- package/dist/commands/workflow/steps.js +1 -0
- package/dist/commands/workflow/tests.js +16 -3
- package/dist/commands/workflow/workflows.js +15 -15
- package/dist/commands/workflow/workstreams.js +2 -1
- package/dist/commands/workflow/worktrees.js +4 -5
- package/dist/install/cloud-env.js +10 -23
- package/dist/install/manifest.js +14 -7
- package/dist/install/modules/antigravity.js +15 -26
- package/dist/install/modules/claude.js +17 -21
- package/dist/install/modules/cloud.js +6 -2
- package/dist/install/modules/codex.js +15 -29
- package/dist/install/modules/core.js +82 -63
- package/dist/install/modules/cursor.js +6 -9
- package/dist/install/modules/index.js +6 -1
- package/dist/install/modules/opencode.js +41 -72
- package/dist/install/network-allowlist.js +62 -0
- package/dist/install/placeholders.js +3 -16
- package/dist/install/write.js +55 -15
- package/dist/ledgers/telemetry.js +5 -4
- package/dist/render/hosts.js +30 -55
- package/dist/render/models.js +20 -9
- package/dist/shared/branches.js +11 -0
- package/dist/shared/egress.js +0 -2
- package/dist/shared/json.js +14 -0
- package/dist/shared/package-json.js +61 -0
- package/dist/shared/package-roots.js +0 -8
- package/dist/shared/protected-paths.js +5 -122
- package/dist/shared/settings.js +18 -1
- package/package.json +21 -17
- package/.bkit/core/.agents/shortcuts.md +0 -73
|
@@ -125,10 +125,17 @@ const CORE_MANIFEST: ManifestEntry[] = [
|
|
|
125
125
|
// their own attributes outside the block, so this is markered-text (not whole-file).
|
|
126
126
|
{ path: ".gitattributes", format: "markered-text", module: "core" },
|
|
127
127
|
{ path: ".bkit/version", format: "byte-equal-text", module: "core" },
|
|
128
|
+
// Curl/wget host allowlist read at runtime by every host's bkit-guardrails.cjs (Claude,
|
|
129
|
+
// Cursor, Codex, Antigravity). No template backs it — `writeNetworkAllowlist`
|
|
130
|
+
// (install/network-allowlist.ts) computes the domain set from the consumer's own config,
|
|
131
|
+
// so it is `generated` and its hash is in `canonicalHashes`. Core-owned: it stays until
|
|
132
|
+
// the last host goes (full/core uninstall).
|
|
133
|
+
{ path: ".bkit/allowlist.json", format: "byte-equal-text", module: "core", generated: true },
|
|
128
134
|
// Canonical bkit-authored reference docs. They live package-side under
|
|
129
135
|
// `.bkit/core/.bkit/` and are read from there at runtime (getBkitDocsRoot); these
|
|
130
136
|
// consumer copies are force-overwritten mirrors (writeTier1) so a consumer can read
|
|
131
|
-
// them in-repo. Whole file is bkit-owned → byte-equal-text (refreshed every install)
|
|
137
|
+
// them in-repo. Whole file is bkit-owned → byte-equal-text (refreshed every install);
|
|
138
|
+
// prompts.md and lite.md are markered-text, keeping the consumer section below `bkit:end`.
|
|
132
139
|
{ path: ".bkit/cloud.md", format: "byte-equal-text", module: "core" },
|
|
133
140
|
{ path: ".bkit/comparison.md", format: "byte-equal-text", module: "core" },
|
|
134
141
|
{ path: ".bkit/install.md", format: "byte-equal-text", module: "core" },
|
|
@@ -136,6 +143,8 @@ const CORE_MANIFEST: ManifestEntry[] = [
|
|
|
136
143
|
// The MIT notice that travels with the files bkit writes: the full text and copyright
|
|
137
144
|
// notice. Sourced from `.bkit/core/.bkit/LICENSE.md`.
|
|
138
145
|
{ path: ".bkit/LICENSE.md", format: "byte-equal-text", module: "core" },
|
|
146
|
+
{ path: ".bkit/lite.md", format: "markered-text", module: "core" },
|
|
147
|
+
{ path: ".bkit/pipeline.md", format: "byte-equal-text", module: "core" },
|
|
139
148
|
{ path: ".bkit/providers.md", format: "byte-equal-text", module: "core" },
|
|
140
149
|
{ path: ".bkit/prompts.md", format: "markered-text", module: "core" },
|
|
141
150
|
{ path: ".bkit/templates.md", format: "byte-equal-text", module: "core" },
|
|
@@ -209,7 +218,8 @@ const CLAUDE_MANIFEST: ManifestEntry[] = [
|
|
|
209
218
|
// `gate-missing-called-scripts` advisory names any that are missing.
|
|
210
219
|
//
|
|
211
220
|
// The SAME names are what the git hook templates run (`.husky/pre-commit`,
|
|
212
|
-
// `.husky/pre-push`). `bkit-ci.yml` does NOT call the gates; it calls the scripts
|
|
221
|
+
// `.husky/pre-push`). `bkit-ci.yml` does NOT call the gates; it calls the same scripts
|
|
222
|
+
// directly, one step each.
|
|
213
223
|
//
|
|
214
224
|
// `lint:slop` is in no gate: `slop-scan scan` is report-only and never fails. The gate
|
|
215
225
|
// that fails on new findings is `slop:delta`.
|
|
@@ -223,7 +233,8 @@ export const BKIT_GATE_SCRIPTS: Readonly<Record<string, string>> = {
|
|
|
223
233
|
// `.husky/pre-commit`: prettier --write over staged files, and nothing else —
|
|
224
234
|
// seconds, not minutes. Prose is a whole-repo scan, so it gates at pre-push.
|
|
225
235
|
"bkit:gate:format": "pnpm lint-staged",
|
|
226
|
-
// Everything that needs no test runner.
|
|
236
|
+
// Everything that needs no test runner. Every part has a matching step in the
|
|
237
|
+
// bkit-tests-static CI job; audits/templates/template-ci-yml.test.ts fails when one is missing.
|
|
227
238
|
// Callers: build's plan-execute loop between tasks, and the `.husky/pre-push` revert
|
|
228
239
|
// path.
|
|
229
240
|
"bkit:gate:static":
|
|
@@ -339,10 +350,6 @@ const CURSOR_MANIFEST: ManifestEntry[] = [
|
|
|
339
350
|
format: "markered-text",
|
|
340
351
|
module: "cursor",
|
|
341
352
|
},
|
|
342
|
-
// Curl/wget host allowlist read at runtime by bkit-guardrails.cjs. No template backs it —
|
|
343
|
-
// `writeNetworkAllowlistArtifact` (install/cloud-env.ts) computes the domain set from the
|
|
344
|
-
// consumer's own config, so it is `generated` and its hash is in `canonicalHashes`.
|
|
345
|
-
{ path: ".cursor/allowlist.json", format: "byte-equal-text", module: "cursor", generated: true },
|
|
346
353
|
// Cursor CLI / cloud-agent MCP allows — `writeCursorCliPermissionsArtifact`
|
|
347
354
|
// (install/cloud-env.ts) renders it from the consumer's `mcp-servers` block; same contract.
|
|
348
355
|
{ path: ".cursor/cli.json", format: "byte-equal-text", module: "cursor", generated: true },
|
|
@@ -19,14 +19,9 @@ import {
|
|
|
19
19
|
} from "../../shared/package-roots.js";
|
|
20
20
|
import { type IssueTracker, DEFAULT_ISSUE_TRACKER } from "../manifest.js";
|
|
21
21
|
import { substituteWorkflow } from "../../render/trackers.js";
|
|
22
|
+
import { readInstallingVersion } from "../../shared/package-json.js";
|
|
22
23
|
import type { ModuleContext } from "./index.js";
|
|
23
|
-
import {
|
|
24
|
-
BKIT_PREFIX,
|
|
25
|
-
installFile,
|
|
26
|
-
listMdFiles,
|
|
27
|
-
readInstallingVersion,
|
|
28
|
-
trackMirrorWrite,
|
|
29
|
-
} from "./core.js";
|
|
24
|
+
import { BKIT_PREFIX, installFile, listMdFiles, removeOrphans, trackMirrorWrite } from "./core.js";
|
|
30
25
|
|
|
31
26
|
// ---------------------------------------------------------------------------
|
|
32
27
|
// runAntigravityModule — Google Antigravity IDE host (opt-in via --antigravity)
|
|
@@ -115,16 +110,12 @@ export function renderAntigravityAgentsSkills(ctx: ModuleContext): string[] {
|
|
|
115
110
|
}
|
|
116
111
|
}
|
|
117
112
|
|
|
118
|
-
// Orphan sweep is bkit-prefix scoped — the plugin's agents/ is bkit-owned
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
if (!dryRun) fs.rmSync(rel, { force: true });
|
|
125
|
-
console.log(`${logPrefix} ${tag}delete orphan: ${rel}`);
|
|
126
|
-
trackMirrorWrite(ctx, rel, written);
|
|
127
|
-
}
|
|
113
|
+
// Orphan sweep is bkit-prefix scoped — the plugin's agents/ is bkit-owned, so every
|
|
114
|
+
// bkit-* entry counts, whatever its extension.
|
|
115
|
+
for (const f of removeOrphans(dest, sourceSet, dryRun, BKIT_PREFIX, { extension: "" })) {
|
|
116
|
+
const rel = path.join(dest, f);
|
|
117
|
+
console.log(`${logPrefix} ${tag}delete orphan: ${rel}`);
|
|
118
|
+
trackMirrorWrite(ctx, rel, written);
|
|
128
119
|
}
|
|
129
120
|
}
|
|
130
121
|
|
|
@@ -148,15 +139,13 @@ export function renderAntigravityAgentsSkills(ctx: ModuleContext): string[] {
|
|
|
148
139
|
}
|
|
149
140
|
|
|
150
141
|
// Prefix-scoped sweep inside the bkit plugin's skills/.
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
trackMirrorWrite(ctx, rel, written);
|
|
159
|
-
}
|
|
142
|
+
const orphans = removeOrphans(ANTIGRAVITY_SKILLS_DIR, sourceStems, dryRun, BKIT_PREFIX, {
|
|
143
|
+
wholeFolders: true,
|
|
144
|
+
});
|
|
145
|
+
for (const d of orphans) {
|
|
146
|
+
const rel = path.join(ANTIGRAVITY_SKILLS_DIR, d);
|
|
147
|
+
console.log(`${logPrefix} ${tag}delete orphan: ${rel}`);
|
|
148
|
+
trackMirrorWrite(ctx, rel, written);
|
|
160
149
|
}
|
|
161
150
|
}
|
|
162
151
|
|
|
@@ -8,10 +8,13 @@ import {
|
|
|
8
8
|
writeTier2,
|
|
9
9
|
writeTier2JsonContained,
|
|
10
10
|
ensureDir,
|
|
11
|
+
mergeTrackerEntry,
|
|
12
|
+
trackerEntryInSync,
|
|
11
13
|
type WriteSet,
|
|
12
14
|
type JsonValue,
|
|
13
15
|
} from "../write.js";
|
|
14
16
|
import { readBkitVersion, stampManagedVersion } from "../version-file.js";
|
|
17
|
+
import { readJsonFile } from "../../shared/json.js";
|
|
15
18
|
import { applyEffortRemap } from "../../render/hosts.js";
|
|
16
19
|
import type { PreflightFinding } from "../../checks/before/index.js";
|
|
17
20
|
import {
|
|
@@ -23,15 +26,9 @@ import {
|
|
|
23
26
|
import { type IssueTracker, DEFAULT_ISSUE_TRACKER } from "../manifest.js";
|
|
24
27
|
import { substituteWorkflow } from "../../render/trackers.js";
|
|
25
28
|
import { writeClaudeCloudDoc, resolveClaudeDerivedAllows } from "../cloud-env.js";
|
|
29
|
+
import { readInstallingVersion } from "../../shared/package-json.js";
|
|
26
30
|
import type { ModuleContext } from "./index.js";
|
|
27
|
-
import {
|
|
28
|
-
BKIT_PREFIX,
|
|
29
|
-
installFile,
|
|
30
|
-
listMdFiles,
|
|
31
|
-
readInstallingVersion,
|
|
32
|
-
removeOrphans,
|
|
33
|
-
trackMirrorWrite,
|
|
34
|
-
} from "./core.js";
|
|
31
|
+
import { BKIT_PREFIX, installFile, listMdFiles, removeOrphans, trackMirrorWrite } from "./core.js";
|
|
35
32
|
|
|
36
33
|
export function renderClaudeAgentsCommands(ctx: ModuleContext): string[] {
|
|
37
34
|
const { dryRun, logPrefix, effortMap } = ctx;
|
|
@@ -247,14 +244,11 @@ export function enrichClaudeSettingsAllows(
|
|
|
247
244
|
advisories?: PreflightFinding[],
|
|
248
245
|
): readonly string[] | null {
|
|
249
246
|
if (!fs.existsSync(settingsDst)) return null;
|
|
250
|
-
|
|
247
|
+
const settings = readJsonFile(settingsDst);
|
|
248
|
+
if (!settings.ok) return null;
|
|
249
|
+
const doc = settings.value as {
|
|
251
250
|
permissions?: { allow?: string[] };
|
|
252
251
|
};
|
|
253
|
-
try {
|
|
254
|
-
doc = JSON.parse(fs.readFileSync(settingsDst, "utf-8")) as typeof doc;
|
|
255
|
-
} catch {
|
|
256
|
-
return null;
|
|
257
|
-
}
|
|
258
252
|
const allow = doc.permissions?.allow;
|
|
259
253
|
if (!Array.isArray(allow)) return null;
|
|
260
254
|
|
|
@@ -310,12 +304,14 @@ export function buildMcpJson(templatePath: string, tracker: IssueTracker): strin
|
|
|
310
304
|
|
|
311
305
|
/**
|
|
312
306
|
* Reconcile bkit's tracker entry into a consumer's `.mcp.json` / `.cursor/mcp.json`. bkit
|
|
313
|
-
* owns exactly one key, `mcpServers[<tracker>]`, and
|
|
307
|
+
* owns exactly one key, `mcpServers[<tracker>]`, and within it only what the template sets
|
|
308
|
+
* (`mergeTrackerEntry`: extra keys, headers and toolsets stay the consumer's); every
|
|
314
309
|
* other key and the existing key order stay the consumer's. Absent file → write the
|
|
315
310
|
* `buildMcpJson` render. Malformed JSON → throw (refuse to merge; the consumer fixes it).
|
|
316
311
|
* Tracker `none` owns no entry, so a present file is left alone. Writes only on change, so
|
|
317
|
-
* dry-run and live compute the identical WriteSet. Another tracker's entry
|
|
318
|
-
*
|
|
312
|
+
* dry-run and live compute the identical WriteSet. Another tracker's entry is not touched
|
|
313
|
+
* here: a `--tracker` switch removes an unedited one first (`removeUnusedTrackerMcpEntries`),
|
|
314
|
+
* and `detectExtraMcpServers` advises on an edited one.
|
|
319
315
|
*/
|
|
320
316
|
export function reconcileMcpJson(
|
|
321
317
|
templatePath: string,
|
|
@@ -334,13 +330,8 @@ export function reconcileMcpJson(
|
|
|
334
330
|
return;
|
|
335
331
|
}
|
|
336
332
|
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
try {
|
|
340
|
-
existing = JSON.parse(fs.readFileSync(relDst, "utf-8")) as JsonValue;
|
|
341
|
-
} catch {
|
|
342
|
-
existing = null;
|
|
343
|
-
}
|
|
333
|
+
const read = readJsonFile(relDst);
|
|
334
|
+
const existing = read.ok ? (read.value as JsonValue) : null;
|
|
344
335
|
if (existing === null || typeof existing !== "object" || Array.isArray(existing)) {
|
|
345
336
|
throw new Error(
|
|
346
337
|
`[bkit] ${relDst} is malformed JSON — fix manually before running bkit install`,
|
|
@@ -351,12 +342,13 @@ export function reconcileMcpJson(
|
|
|
351
342
|
const servers = existing.mcpServers;
|
|
352
343
|
const serversObj =
|
|
353
344
|
servers !== null && typeof servers === "object" && !Array.isArray(servers) ? servers : {};
|
|
354
|
-
const inSync = Object.entries(owned).every(
|
|
355
|
-
([k, v]) => JSON.stringify(serversObj[k]) === JSON.stringify(v),
|
|
356
|
-
);
|
|
345
|
+
const inSync = Object.entries(owned).every(([k, v]) => trackerEntryInSync(serversObj[k], v));
|
|
357
346
|
if (inSync) return;
|
|
358
347
|
|
|
359
|
-
const
|
|
348
|
+
const merged = Object.fromEntries(
|
|
349
|
+
Object.entries(owned).map(([k, v]) => [k, mergeTrackerEntry(serversObj[k], v)]),
|
|
350
|
+
);
|
|
351
|
+
const next = { ...existing, mcpServers: { ...serversObj, ...merged } };
|
|
360
352
|
if (!dryRun) fs.writeFileSync(relDst, JSON.stringify(next, null, 2) + "\n", "utf-8");
|
|
361
353
|
ws.writes.push({ path: relDst, action: "update" });
|
|
362
354
|
}
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
|
|
6
6
|
import * as fs from "node:fs";
|
|
7
7
|
import * as path from "node:path";
|
|
8
|
+
import { parseJson } from "../../shared/json.js";
|
|
8
9
|
import type { CloudAgents } from "../manifest.js";
|
|
9
10
|
import type { ModuleContext } from "./index.js";
|
|
10
11
|
|
|
@@ -26,7 +27,9 @@ function setConsumerBkitField(field: string, value: string, dryRun: boolean): vo
|
|
|
26
27
|
if (!fs.existsSync(pkgPath)) return;
|
|
27
28
|
try {
|
|
28
29
|
const raw = fs.readFileSync(pkgPath, "utf-8");
|
|
29
|
-
const
|
|
30
|
+
const parsed = parseJson(raw);
|
|
31
|
+
if (!parsed.ok) return;
|
|
32
|
+
const pkg = parsed.value as Record<string, unknown>;
|
|
30
33
|
const bkit = (pkg.bkit ?? {}) as Record<string, unknown>;
|
|
31
34
|
if (bkit[field] === value) return; // already set — avoid a no-op rewrite
|
|
32
35
|
bkit[field] = value;
|
|
@@ -101,7 +104,7 @@ export function runCloudModule(ctx: ModuleContext): void {
|
|
|
101
104
|
" - Adopt `.bkit/templates/.claude/hooks/bkit-cloud-bootstrap.sh` as `.claude/hooks/bkit-cloud-bootstrap.sh` and edit it freely — the baseline runs `pnpm install` / `vale sync` and the gh login on each cloud session; add your own repo-specific steps (Supabase start, turbo prebuild, etc. — examples inlined). The `.claude/settings.json` SessionStart entry runs it only when present (`test -f … || true`).\n\n" +
|
|
102
105
|
"IN CLAUDE APP (claude.ai/code → environment selector → + Add environment):\n" +
|
|
103
106
|
" - Name: the repo name (e.g. `acme-web`) — one environment per repo, since secrets are per-repo.\n" +
|
|
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" +
|
|
107
|
+
" - Setup script: paste from bkit's `cloud.md` § Setup script (installs Node 24 + vale + gh + jq + corepack-pinned pnpm — exact versions live in cloud.md, not duplicated here).\n" +
|
|
105
108
|
" - Environment variables: `BKIT_GH_TOKEN` (fine-grained for one owner, classic across owners — GitHub MCP).\n" +
|
|
106
109
|
" - 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
110
|
" - 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.",
|
|
@@ -13,14 +13,9 @@ import {
|
|
|
13
13
|
} from "../../shared/package-roots.js";
|
|
14
14
|
import { type IssueTracker, DEFAULT_ISSUE_TRACKER } from "../manifest.js";
|
|
15
15
|
import { substituteWorkflow } from "../../render/trackers.js";
|
|
16
|
+
import { readInstallingVersion } from "../../shared/package-json.js";
|
|
16
17
|
import type { ModuleContext } from "./index.js";
|
|
17
|
-
import {
|
|
18
|
-
BKIT_PREFIX,
|
|
19
|
-
installFile,
|
|
20
|
-
listMdFiles,
|
|
21
|
-
readInstallingVersion,
|
|
22
|
-
trackMirrorWrite,
|
|
23
|
-
} from "./core.js";
|
|
18
|
+
import { BKIT_PREFIX, installFile, listMdFiles, removeOrphans, trackMirrorWrite } from "./core.js";
|
|
24
19
|
|
|
25
20
|
/**
|
|
26
21
|
* Convert a workflow orchestrator (`.bkit/core/workflows/*.md`) into a Codex SKILL.md.
|
|
@@ -93,8 +88,8 @@ export function renderCodexAgentsSkills(ctx: ModuleContext): string[] {
|
|
|
93
88
|
const dest = ".codex/agents";
|
|
94
89
|
if (!dryRun) ensureDir(dest);
|
|
95
90
|
const files = listMdFiles(src, BKIT_PREFIX);
|
|
96
|
-
// Destination basenames are .toml, so the orphan sweep
|
|
97
|
-
const
|
|
91
|
+
// Destination basenames are .toml, so the orphan sweep compares on the .toml names.
|
|
92
|
+
const sourceNames = new Set(files.map((f) => f.replace(/\.md$/, ".toml")));
|
|
98
93
|
|
|
99
94
|
for (const f of files) {
|
|
100
95
|
const stem = f.replace(/\.md$/, "");
|
|
@@ -108,17 +103,10 @@ export function renderCodexAgentsSkills(ctx: ModuleContext): string[] {
|
|
|
108
103
|
}
|
|
109
104
|
}
|
|
110
105
|
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
if (!sourceStems.has(f.replace(/\.toml$/, ""))) {
|
|
116
|
-
const rel = path.join(dest, f);
|
|
117
|
-
if (!dryRun) fs.rmSync(path.join(dest, f));
|
|
118
|
-
console.log(`${logPrefix} ${tag}delete orphan: ${rel}`);
|
|
119
|
-
trackMirrorWrite(ctx, rel, written);
|
|
120
|
-
}
|
|
121
|
-
}
|
|
106
|
+
for (const f of removeOrphans(dest, sourceNames, dryRun, BKIT_PREFIX, { extension: ".toml" })) {
|
|
107
|
+
const rel = path.join(dest, f);
|
|
108
|
+
console.log(`${logPrefix} ${tag}delete orphan: ${rel}`);
|
|
109
|
+
trackMirrorWrite(ctx, rel, written);
|
|
122
110
|
}
|
|
123
111
|
}
|
|
124
112
|
|
|
@@ -146,15 +134,13 @@ export function renderCodexAgentsSkills(ctx: ModuleContext): string[] {
|
|
|
146
134
|
|
|
147
135
|
// Orphan sweep is bkit-prefix scoped: `.agents/skills/` is SHARED with third-party
|
|
148
136
|
// skills installed via skills.sh, so anything not named bkit-* is off limits here.
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
trackMirrorWrite(ctx, rel, written);
|
|
157
|
-
}
|
|
137
|
+
const orphans = removeOrphans(CODEX_SKILLS_DIR, sourceStems, dryRun, BKIT_PREFIX, {
|
|
138
|
+
wholeFolders: true,
|
|
139
|
+
});
|
|
140
|
+
for (const d of orphans) {
|
|
141
|
+
const rel = path.join(CODEX_SKILLS_DIR, d);
|
|
142
|
+
console.log(`${logPrefix} ${tag}delete orphan: ${rel}`);
|
|
143
|
+
trackMirrorWrite(ctx, rel, written);
|
|
158
144
|
}
|
|
159
145
|
}
|
|
160
146
|
|
|
@@ -11,12 +11,15 @@ import {
|
|
|
11
11
|
hashFile,
|
|
12
12
|
mergeCanonicalHashes,
|
|
13
13
|
} from "../version-file.js";
|
|
14
|
+
import { extractManagedBlock, stripManagedBlock } from "../managed-block.js";
|
|
14
15
|
import type { TokenMap } from "../placeholders.js";
|
|
15
16
|
import { listFilesRecursive, syncTemplateCopies } from "../template-copies.js";
|
|
16
17
|
import { PAYLOAD_LINK_RELPATHS, syncPayloadLinks } from "../payload-links.js";
|
|
18
|
+
import { writeNetworkAllowlist } from "../network-allowlist.js";
|
|
17
19
|
import type { PreflightFinding } from "../../checks/before/index.js";
|
|
20
|
+
import { readJsonFile } from "../../shared/json.js";
|
|
21
|
+
import { readInstallingVersion } from "../../shared/package-json.js";
|
|
18
22
|
import {
|
|
19
|
-
getPkgRoot,
|
|
20
23
|
getCoreRoot,
|
|
21
24
|
getSharedRoot,
|
|
22
25
|
getBkitDocsRoot,
|
|
@@ -71,25 +74,46 @@ const ORPHAN_PRUNE_DIRS = [
|
|
|
71
74
|
".claude/commands",
|
|
72
75
|
".cursor/agents",
|
|
73
76
|
".cursor/commands",
|
|
77
|
+
".opencode/agents",
|
|
78
|
+
".opencode/commands",
|
|
79
|
+
".codex/agents",
|
|
80
|
+
".agents/skills",
|
|
81
|
+
".agents/plugins/bkit/agents",
|
|
82
|
+
".agents/plugins/bkit/skills",
|
|
74
83
|
] as const;
|
|
75
84
|
|
|
85
|
+
export interface RemoveOrphansOptions {
|
|
86
|
+
/** Entry-name suffix an orphan must carry. Default `.md`; `""` matches every name. */
|
|
87
|
+
extension?: string;
|
|
88
|
+
/** Orphans are whole folders (skill dirs) removed recursively; `extension` is ignored. */
|
|
89
|
+
wholeFolders?: boolean;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* Removes entries of `destDir` that start with `prefix` and are absent from `sourceNames`
|
|
94
|
+
* (entry names as they appear in `destDir`). Returns the removed names; with `dryRun` it
|
|
95
|
+
* reports them without deleting. Throws for any `destDir` outside `ORPHAN_PRUNE_DIRS`.
|
|
96
|
+
*/
|
|
76
97
|
export function removeOrphans(
|
|
77
98
|
destDir: string,
|
|
78
|
-
|
|
99
|
+
sourceNames: Set<string>,
|
|
79
100
|
dryRun: boolean,
|
|
80
101
|
prefix?: string,
|
|
102
|
+
options: RemoveOrphansOptions = {},
|
|
81
103
|
): string[] {
|
|
82
104
|
const resolved = path.resolve(destDir);
|
|
83
105
|
if (!ORPHAN_PRUNE_DIRS.some((d) => path.resolve(d) === resolved)) {
|
|
84
106
|
throw new Error(`removeOrphans: refusing orphan removal outside allowlist: ${destDir}`);
|
|
85
107
|
}
|
|
86
108
|
if (!fs.existsSync(destDir)) return [];
|
|
109
|
+
const { extension = ".md", wholeFolders = false } = options;
|
|
87
110
|
const removed: string[] = [];
|
|
88
111
|
for (const f of fs.readdirSync(destDir)) {
|
|
89
|
-
if (!f.endsWith(
|
|
112
|
+
if (!wholeFolders && !f.endsWith(extension)) continue;
|
|
90
113
|
if (prefix && !f.startsWith(prefix)) continue;
|
|
91
|
-
if (!
|
|
92
|
-
|
|
114
|
+
if (!sourceNames.has(f)) {
|
|
115
|
+
const target = path.join(destDir, f);
|
|
116
|
+
if (!dryRun) fs.rmSync(target, { recursive: wholeFolders, force: wholeFolders });
|
|
93
117
|
removed.push(f);
|
|
94
118
|
}
|
|
95
119
|
}
|
|
@@ -117,13 +141,7 @@ interface CoreTemplateFile {
|
|
|
117
141
|
}
|
|
118
142
|
|
|
119
143
|
/** The markered-text `.agents/*.md` blocks core owns. */
|
|
120
|
-
const CORE_AGENT_FILES = [
|
|
121
|
-
"context.md",
|
|
122
|
-
"docs.md",
|
|
123
|
-
"rules.md",
|
|
124
|
-
"shortcuts.md",
|
|
125
|
-
"skills.md",
|
|
126
|
-
] as const;
|
|
144
|
+
const CORE_AGENT_FILES = ["context.md", "docs.md", "rules.md", "skills.md"] as const;
|
|
127
145
|
|
|
128
146
|
// The two shared-root files core writes: stored in `shared/`, owned by the core
|
|
129
147
|
// manifest, written as html-comment managed blocks.
|
|
@@ -228,16 +246,18 @@ function runCoreTemplates(
|
|
|
228
246
|
// mirrored into the consumer's `.bkit/` on every install so a consumer can read them
|
|
229
247
|
// in-repo without spelunking node_modules. Force-overwritten (Tier 1) — bkit owns
|
|
230
248
|
// them, so a consumer edit is replaced. Source of truth is the package's own
|
|
231
|
-
// `.bkit/core/.bkit/<name>`. (`advisories.md` is a regenerated runtime artifact
|
|
232
|
-
// `wording.md` is repo-only tooling
|
|
233
|
-
//
|
|
234
|
-
//
|
|
249
|
+
// `.bkit/core/.bkit/<name>`. (`advisories.md` is a regenerated runtime artifact and
|
|
250
|
+
// `wording.md` is repo-only tooling — neither belongs here. `LICENSE.md` is the MIT
|
|
251
|
+
// notice that travels with the files bkit writes: MIT requires the copyright and
|
|
252
|
+
// permission notice in every copy.)
|
|
235
253
|
export const BKIT_CANONICAL_DOCS = [
|
|
236
254
|
"cloud.md",
|
|
237
255
|
"comparison.md",
|
|
238
256
|
"install.md",
|
|
239
257
|
"jsonl.md",
|
|
240
258
|
"LICENSE.md",
|
|
259
|
+
"lite.md",
|
|
260
|
+
"pipeline.md",
|
|
241
261
|
"providers.md",
|
|
242
262
|
"prompts.md",
|
|
243
263
|
"templates.md",
|
|
@@ -278,6 +298,44 @@ export function runBkitDocs(
|
|
|
278
298
|
console.log(`${logPrefix} ${tag}core: ${dstPath}`);
|
|
279
299
|
}
|
|
280
300
|
}
|
|
301
|
+
migrateShortcutsToLite(dryRun, ws, logPrefix);
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
// Migration (5.1.0 – 5.2.4 installs, `docs/migrations.md`): the lite workflows lived at
|
|
305
|
+
// `.agents/shortcuts.md`. The consumer's own lines below `bkit:end` (minus the seeded
|
|
306
|
+
// heading) move under `.bkit/lite.md`'s consumer section; the old file is deleted. Runs
|
|
307
|
+
// after the docs loop, so `.bkit/lite.md` is already written. The delete is recorded in
|
|
308
|
+
// ws (as orphan-mirror deletes are) so `bkit check` fails until upgrade runs.
|
|
309
|
+
const RETIRED_SHORTCUTS = path.join(".agents", "shortcuts.md");
|
|
310
|
+
const RETIRED_SHORTCUTS_HEADING = "## Project Shortcuts";
|
|
311
|
+
|
|
312
|
+
export function migrateShortcutsToLite(dryRun: boolean, ws: WriteSet, logPrefix: string): void {
|
|
313
|
+
if (!fs.existsSync(RETIRED_SHORTCUTS)) return;
|
|
314
|
+
if (!fs.existsSync(path.join(getBkitDocsRoot(), "lite.md"))) return;
|
|
315
|
+
const tag = dryRun ? "[dry-run] " : "";
|
|
316
|
+
const dst = path.join(".bkit", "lite.md");
|
|
317
|
+
const old = fs.readFileSync(RETIRED_SHORTCUTS, "utf-8");
|
|
318
|
+
if (extractManagedBlock(old, "html-comment") === null) {
|
|
319
|
+
console.warn(
|
|
320
|
+
`${logPrefix} ${RETIRED_SHORTCUTS} has no single bkit managed block — left in place. Move your own lines into ${dst} below \`<!-- bkit:end -->\`, then delete it.`,
|
|
321
|
+
);
|
|
322
|
+
return;
|
|
323
|
+
}
|
|
324
|
+
const own = stripManagedBlock(old, "html-comment")
|
|
325
|
+
.split("\n")
|
|
326
|
+
.filter((line) => line.trim() !== RETIRED_SHORTCUTS_HEADING)
|
|
327
|
+
.join("\n")
|
|
328
|
+
.trim();
|
|
329
|
+
if (own.length > 0) {
|
|
330
|
+
if (!dryRun) {
|
|
331
|
+
const current = fs.readFileSync(dst, "utf-8");
|
|
332
|
+
fs.writeFileSync(dst, `${current.replace(/\n*$/, "\n\n")}${own}\n`, "utf-8");
|
|
333
|
+
}
|
|
334
|
+
ws.writes.push({ path: dst, action: "update" });
|
|
335
|
+
}
|
|
336
|
+
if (!dryRun) fs.rmSync(RETIRED_SHORTCUTS);
|
|
337
|
+
ws.writes.push({ path: RETIRED_SHORTCUTS, action: "write" });
|
|
338
|
+
console.log(`${logPrefix} ${tag}core: moved ${RETIRED_SHORTCUTS} → ${dst}`);
|
|
281
339
|
}
|
|
282
340
|
|
|
283
341
|
// ---------------------------------------------------------------------------
|
|
@@ -292,29 +350,6 @@ export function runBkitDocs(
|
|
|
292
350
|
// the consumer-relative dest paths it wrote (for the upgrade summary).
|
|
293
351
|
// ---------------------------------------------------------------------------
|
|
294
352
|
|
|
295
|
-
// ---------------------------------------------------------------------------
|
|
296
|
-
// Managed-version stamping. The marker shape (stampManagedVersion + regexes) lives
|
|
297
|
-
// in install/version-file.ts, shared by the renderer and the `bkit check` detector. Here we
|
|
298
|
-
// only resolve WHICH version to stamp: ctx.version (set by install/upgrade) with a
|
|
299
|
-
// package-root fallback.
|
|
300
|
-
// ---------------------------------------------------------------------------
|
|
301
|
-
|
|
302
|
-
/**
|
|
303
|
-
* Best-effort read of the installing bkit version from the package root's
|
|
304
|
-
* package.json. Mirrors getInstallingVersion in commands/install/install.ts; duplicated here
|
|
305
|
-
* (not imported) to avoid a modules → install dependency cycle. Returns "0.0.0"
|
|
306
|
-
* when unreadable — the same non-fatal fallback the install side uses.
|
|
307
|
-
*/
|
|
308
|
-
export function readInstallingVersion(): string {
|
|
309
|
-
try {
|
|
310
|
-
const pkgPath = path.join(getPkgRoot(), "package.json");
|
|
311
|
-
const pkg = JSON.parse(fs.readFileSync(pkgPath, "utf-8")) as { version?: string };
|
|
312
|
-
return pkg.version ?? "0.0.0";
|
|
313
|
-
} catch {
|
|
314
|
-
return "0.0.0";
|
|
315
|
-
}
|
|
316
|
-
}
|
|
317
|
-
|
|
318
353
|
/** Record a host mirror would-write so `bkit check` exits 1 on content drift. */
|
|
319
354
|
export function trackMirrorWrite(ctx: ModuleContext, relPath: string, written: string[]): void {
|
|
320
355
|
written.push(relPath);
|
|
@@ -368,17 +403,12 @@ const PNPM_NOT_A_SCRIPT = new Set([
|
|
|
368
403
|
* package.json yields none.
|
|
369
404
|
*/
|
|
370
405
|
export function detectGateAdvisories(cwd: string): PreflightFinding[] {
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
} catch {
|
|
378
|
-
// Absent or malformed package.json — preflight's no-package-json /
|
|
379
|
-
// malformed-package-json blockers already report it.
|
|
380
|
-
return [];
|
|
381
|
-
}
|
|
406
|
+
const read = readJsonFile(path.join(cwd, "package.json"));
|
|
407
|
+
// Absent or malformed package.json — preflight's no-package-json /
|
|
408
|
+
// malformed-package-json blockers already report it.
|
|
409
|
+
if (!read.ok || read.value === null) return [];
|
|
410
|
+
const pkg = read.value as { scripts?: Record<string, string> };
|
|
411
|
+
const declared: Record<string, string> = { ...BKIT_GATE_SCRIPTS, ...pkg.scripts };
|
|
382
412
|
const findings: PreflightFinding[] = [];
|
|
383
413
|
|
|
384
414
|
// Every script a seeded gate default chains MUST exist, or the gate dies on the first
|
|
@@ -454,16 +484,11 @@ export function isNoopScript(value: string): boolean {
|
|
|
454
484
|
* every branch. Read-only; an absent or unparseable package.json yields none.
|
|
455
485
|
*/
|
|
456
486
|
export function detectNoopGates(cwd: string): PreflightFinding[] {
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
declared = pkg.scripts ?? {};
|
|
463
|
-
} catch {
|
|
464
|
-
// Absent or malformed package.json — preflight's blockers already report it.
|
|
465
|
-
return [];
|
|
466
|
-
}
|
|
487
|
+
const read = readJsonFile(path.join(cwd, "package.json"));
|
|
488
|
+
// Absent or malformed package.json — preflight's blockers already report it.
|
|
489
|
+
if (!read.ok || read.value === null) return [];
|
|
490
|
+
const pkg = read.value as { scripts?: Record<string, unknown> };
|
|
491
|
+
const declared: Record<string, unknown> = pkg.scripts ?? {};
|
|
467
492
|
const noop = Object.entries(declared)
|
|
468
493
|
.filter(([name, value]) => name.startsWith("bkit:gate:") && typeof value === "string")
|
|
469
494
|
.filter(([, value]) => isNoopScript(value as string))
|
|
@@ -485,15 +510,7 @@ export function runCoreModule(ctx: ModuleContext): void {
|
|
|
485
510
|
const { dryRun, ws, advisories, logPrefix, postDispatch } = ctx;
|
|
486
511
|
const tag = dryRun ? "[dry-run] " : "";
|
|
487
512
|
const cwd = process.cwd();
|
|
488
|
-
const
|
|
489
|
-
const PKG_PACKAGE_JSON = path.join(PKG_ROOT, "package.json");
|
|
490
|
-
|
|
491
|
-
if (!fs.existsSync(PKG_PACKAGE_JSON)) {
|
|
492
|
-
console.error(`${logPrefix} package.json not found at ${PKG_PACKAGE_JSON} — package corrupt?`);
|
|
493
|
-
process.exit(1);
|
|
494
|
-
}
|
|
495
|
-
|
|
496
|
-
const pkgVersion = JSON.parse(fs.readFileSync(PKG_PACKAGE_JSON, "utf-8")).version as string;
|
|
513
|
+
const pkgVersion = readInstallingVersion();
|
|
497
514
|
|
|
498
515
|
// Capture first-install signal NOW (before any writes) — used for the post-install banner.
|
|
499
516
|
// The .bkit/version write happens in postDispatch, so a mid-install crash in a later
|
|
@@ -507,7 +524,7 @@ export function runCoreModule(ctx: ModuleContext): void {
|
|
|
507
524
|
runCoreTemplates(dryRun, ctx.tokens, ws, logPrefix);
|
|
508
525
|
|
|
509
526
|
// 3b. bkit canonical docs pass — mirror the package's reference docs
|
|
510
|
-
// (cloud/IDEs/prompts/trackers/workflows/README/install/comparison) into the
|
|
527
|
+
// (cloud/IDEs/prompts/trackers/workflows/README/install/comparison/pipeline) into the
|
|
511
528
|
// consumer's `.bkit/` so they are readable in-repo. Force-overwrite (Tier 1).
|
|
512
529
|
console.log(`${logPrefix} ${tag}Running bkit docs pass`);
|
|
513
530
|
runBkitDocs(dryRun, ctx.tokens, ws, logPrefix);
|
|
@@ -550,6 +567,10 @@ export function runCoreModule(ctx: ModuleContext): void {
|
|
|
550
567
|
});
|
|
551
568
|
}
|
|
552
569
|
|
|
570
|
+
// 3b4. `.bkit/allowlist.json` — the network allowlist every host's guardrails hook
|
|
571
|
+
// reads (writeNetworkAllowlist), plus the move off the retired `.cursor/` copy.
|
|
572
|
+
writeNetworkAllowlist(cwd, dryRun, ws, logPrefix);
|
|
573
|
+
|
|
553
574
|
// 3c. The bkit:gate:* / bkit:deps:* package.json scripts (add-if-missing). The
|
|
554
575
|
// advisories read the result.
|
|
555
576
|
seedCorePackageJsonScripts(ctx);
|
|
@@ -13,20 +13,10 @@ import {
|
|
|
13
13
|
} from "../../shared/package-roots.js";
|
|
14
14
|
import { DEFAULT_ISSUE_TRACKER } from "../manifest.js";
|
|
15
15
|
import { substituteWorkflow } from "../../render/trackers.js";
|
|
16
|
-
import {
|
|
17
|
-
|
|
18
|
-
writeNetworkAllowlistArtifact,
|
|
19
|
-
writeCursorCliPermissionsArtifact,
|
|
20
|
-
} from "../cloud-env.js";
|
|
16
|
+
import { writeCursorCloudDoc, writeCursorCliPermissionsArtifact } from "../cloud-env.js";
|
|
17
|
+
import { readInstallingVersion } from "../../shared/package-json.js";
|
|
21
18
|
import type { ModuleContext } from "./index.js";
|
|
22
|
-
import {
|
|
23
|
-
BKIT_PREFIX,
|
|
24
|
-
installFile,
|
|
25
|
-
listMdFiles,
|
|
26
|
-
readInstallingVersion,
|
|
27
|
-
removeOrphans,
|
|
28
|
-
trackMirrorWrite,
|
|
29
|
-
} from "./core.js";
|
|
19
|
+
import { BKIT_PREFIX, installFile, listMdFiles, removeOrphans, trackMirrorWrite } from "./core.js";
|
|
30
20
|
import { reconcileMcpJson } from "./claude.js";
|
|
31
21
|
|
|
32
22
|
export function renderCursorAgentsCommands(ctx: ModuleContext): string[] {
|
|
@@ -182,15 +172,11 @@ export function runCursorModule(ctx: ModuleContext): void {
|
|
|
182
172
|
}
|
|
183
173
|
}
|
|
184
174
|
|
|
185
|
-
// Cursor-only runtime curl/wget allowlist (bkit-guardrails.cjs reads `.cursor/allowlist.json`).
|
|
186
|
-
// Same domain set as Claude WebFetch / OpenCode bash allows — sourced from tooling
|
|
187
|
-
// defaults ∪ consumer `allowed-domains`. Not under `.bkit/` (IDE-scoped artifact).
|
|
188
175
|
// Cursor CLI / cloud-agent MCP allows (`.cursor/cli.json`) from consumer `mcp-servers` —
|
|
189
176
|
// same server set as Claude `mcp__…` allows / OpenCode `<server>_*` permission rows.
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
writeCursorCliPermissionsArtifact(process.cwd(), dryRun)
|
|
193
|
-
]) {
|
|
177
|
+
// The curl/wget allowlist the guardrails hook reads is core's `.bkit/allowlist.json`.
|
|
178
|
+
{
|
|
179
|
+
const art = writeCursorCliPermissionsArtifact(process.cwd(), dryRun);
|
|
194
180
|
if (art.wrote) {
|
|
195
181
|
ws.writes.push({ path: art.path, action: "write" });
|
|
196
182
|
console.log(`${logPrefix} ${tag}cursor: ${art.path}`);
|