@cbartens/bkit 5.2.4 → 5.4.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 +27 -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 +18 -1
- package/.bkit/core/.bkit/README.md +26 -10
- package/.bkit/core/.bkit/cloud.md +40 -39
- package/.bkit/core/.bkit/comparison.md +68 -345
- package/.bkit/core/.bkit/install.md +16 -9
- package/.bkit/core/.bkit/lite.md +73 -0
- package/.bkit/core/.bkit/pipeline.md +346 -0
- package/.bkit/core/.bkit/prompts.md +90 -74
- package/.bkit/core/.bkit/providers.md +42 -23
- package/.bkit/core/.bkit/templates.md +138 -19
- package/.bkit/core/.bkit/trackers.md +49 -4
- package/.bkit/core/.bkit/workflows.md +144 -123
- 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-accessibility.md +3 -2
- package/.bkit/core/docs/templates/bkit-audit-adoption.md +2 -2
- 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 +1 -1
- 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 +26 -21
- 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 +3 -2
- package/.bkit/core/docs/templates/bkit-audit-llm.md +22 -15
- 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 +7 -7
- package/.bkit/core/docs/templates/bkit-audit-red-team.md +12 -9
- 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 +14 -12
- package/.bkit/core/docs/templates/bkit-audit-slop.md +1 -1
- package/.bkit/core/docs/templates/bkit-audit-testing.md +10 -8
- package/.bkit/core/docs/templates/bkit-audit-usability.md +1 -1
- 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 -6
- package/.bkit/core/engine/checks/tips/catalogue.ts +76 -24
- package/.bkit/core/engine/checks/tips/detect.ts +45 -2
- package/.bkit/core/engine/checks/tips/index.ts +77 -26
- package/.bkit/core/engine/cli.ts +57 -27
- package/.bkit/core/engine/commands/analysis.ts +36 -26
- package/.bkit/core/engine/commands/comply.ts +42 -32
- 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 +73 -130
- 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/land.ts +156 -0
- package/.bkit/core/engine/commands/lib.ts +45 -18
- package/.bkit/core/engine/commands/registry.ts +2 -0
- package/.bkit/core/engine/commands/tips.ts +12 -5
- package/.bkit/core/engine/commands/workflow/branches.ts +386 -286
- package/.bkit/core/engine/commands/workflow/counters.ts +21 -12
- package/.bkit/core/engine/commands/workflow/disk.ts +556 -0
- package/.bkit/core/engine/commands/workflow/fids.ts +46 -0
- package/.bkit/core/engine/commands/workflow/issues.ts +73 -28
- package/.bkit/core/engine/commands/workflow/ledgers.ts +3 -1
- package/.bkit/core/engine/commands/workflow/locks.ts +38 -152
- package/.bkit/core/engine/commands/workflow/prs.ts +15 -4
- package/.bkit/core/engine/commands/workflow/repo.ts +2 -2
- package/.bkit/core/engine/commands/workflow/roadmap.ts +49 -53
- package/.bkit/core/engine/commands/workflow/runs.ts +8 -7
- 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 +25 -15
- package/.bkit/core/engine/commands/workflow/tests.ts +17 -5
- package/.bkit/core/engine/commands/workflow/workflows.ts +436 -267
- package/.bkit/core/engine/commands/workflow/workstreams.ts +4 -2
- package/.bkit/core/engine/commands/workflow/worktrees.ts +24 -6
- 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 +106 -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 +16 -35
- 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 +44 -0
- package/.bkit/core/engine/shared/timeouts.ts +8 -7
- 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 +103 -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-auto.md +2 -2
- package/.bkit/core/workflows/bkit-build.md +10 -10
- package/.bkit/core/workflows/bkit-debug.md +80 -44
- package/.bkit/core/workflows/bkit-design.md +22 -13
- package/.bkit/core/workflows/bkit-plan.md +33 -16
- package/.bkit/core/workflows/bkit-ship.md +87 -98
- package/.bkit/shared/.claude/bkit-cloud.md +58 -25
- package/.bkit/shared/.claude/settings.json +19 -0
- package/.bkit/shared/.cursor/mcp.json +2 -1
- package/.bkit/shared/.opencode/opencode.json +19 -1
- package/.bkit/shared/docs/deployments.md +49 -29
- package/.bkit/shared/docs/security.md +8 -6
- package/.bkit/shared/docs/testing.md +9 -5
- package/.bkit/shared/gitignore +1 -2
- 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 +73 -55
- 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-commit +6 -0
- package/.bkit/templates/.husky/pre-push +15 -3
- package/.bkit/templates/.lintstagedrc.json +5 -1
- 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/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-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 +98 -3
- package/README.md +252 -122
- 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 -7
- package/dist/checks/tips/catalogue.js +65 -18
- package/dist/checks/tips/detect.js +41 -2
- package/dist/checks/tips/index.js +61 -25
- package/dist/cli.js +52 -26
- package/dist/commands/analysis.js +21 -5
- package/dist/commands/comply.js +40 -31
- package/dist/commands/harvest.js +12 -13
- package/dist/commands/install/doctor.js +55 -23
- package/dist/commands/install/install.js +72 -122
- package/dist/commands/install/uninstall.js +165 -31
- package/dist/commands/install/upgrade.js +46 -39
- package/dist/commands/land.js +129 -0
- package/dist/commands/lib.js +41 -16
- package/dist/commands/registry.js +2 -0
- package/dist/commands/tips.js +10 -3
- package/dist/commands/workflow/branches.js +303 -248
- package/dist/commands/workflow/counters.js +17 -7
- package/dist/commands/workflow/disk.js +452 -0
- package/dist/commands/workflow/fids.js +39 -0
- package/dist/commands/workflow/issues.js +63 -27
- package/dist/commands/workflow/ledgers.js +3 -1
- package/dist/commands/workflow/locks.js +35 -130
- package/dist/commands/workflow/prs.js +8 -5
- package/dist/commands/workflow/repo.js +2 -2
- package/dist/commands/workflow/roadmap.js +50 -57
- package/dist/commands/workflow/runs.js +5 -5
- package/dist/commands/workflow/runtime.js +3 -2
- package/dist/commands/workflow/status.js +32 -12
- package/dist/commands/workflow/steps.js +19 -11
- package/dist/commands/workflow/tests.js +16 -3
- package/dist/commands/workflow/workflows.js +390 -249
- package/dist/commands/workflow/workstreams.js +4 -2
- package/dist/commands/workflow/worktrees.js +15 -6
- 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 +95 -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 +16 -35
- 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 +23 -1
- package/dist/shared/timeouts.js +8 -7
- package/package.json +21 -17
- package/.bkit/core/.agents/shortcuts.md +0 -73
|
@@ -5,9 +5,13 @@ import * as fs from "node:fs";
|
|
|
5
5
|
import * as path from "node:path";
|
|
6
6
|
import { writeTier1, writeTier2, ensurePackageJsonScripts } from "../write.js";
|
|
7
7
|
import { readBkitVersion, writeBkitVersion, hashFile, mergeCanonicalHashes, } from "../version-file.js";
|
|
8
|
+
import { extractManagedBlock, stripManagedBlock } from "../managed-block.js";
|
|
8
9
|
import { listFilesRecursive, syncTemplateCopies } from "../template-copies.js";
|
|
9
10
|
import { PAYLOAD_LINK_RELPATHS, syncPayloadLinks } from "../payload-links.js";
|
|
10
|
-
import {
|
|
11
|
+
import { writeNetworkAllowlist } from "../network-allowlist.js";
|
|
12
|
+
import { readJsonFile } from "../../shared/json.js";
|
|
13
|
+
import { readInstallingVersion } from "../../shared/package-json.js";
|
|
14
|
+
import { getCoreRoot, getSharedRoot, getBkitDocsRoot, TEMPLATE_COPIES_DIR, } from "../../shared/package-roots.js";
|
|
11
15
|
import { getInstallManifest, BKIT_GATE_SCRIPTS, BKIT_OPTIONAL_GATES, BKIT_TEST_FILE_SCRIPT, } from "../manifest.js";
|
|
12
16
|
export function listMdFiles(dir, prefix) {
|
|
13
17
|
if (!fs.existsSync(dir))
|
|
@@ -47,36 +51,43 @@ const ORPHAN_PRUNE_DIRS = [
|
|
|
47
51
|
".claude/commands",
|
|
48
52
|
".cursor/agents",
|
|
49
53
|
".cursor/commands",
|
|
54
|
+
".opencode/agents",
|
|
55
|
+
".opencode/commands",
|
|
56
|
+
".codex/agents",
|
|
57
|
+
".agents/skills",
|
|
58
|
+
".agents/plugins/bkit/agents",
|
|
59
|
+
".agents/plugins/bkit/skills",
|
|
50
60
|
];
|
|
51
|
-
|
|
61
|
+
/**
|
|
62
|
+
* Removes entries of `destDir` that start with `prefix` and are absent from `sourceNames`
|
|
63
|
+
* (entry names as they appear in `destDir`). Returns the removed names; with `dryRun` it
|
|
64
|
+
* reports them without deleting. Throws for any `destDir` outside `ORPHAN_PRUNE_DIRS`.
|
|
65
|
+
*/
|
|
66
|
+
export function removeOrphans(destDir, sourceNames, dryRun, prefix, options = {}) {
|
|
52
67
|
const resolved = path.resolve(destDir);
|
|
53
68
|
if (!ORPHAN_PRUNE_DIRS.some((d) => path.resolve(d) === resolved)) {
|
|
54
69
|
throw new Error(`removeOrphans: refusing orphan removal outside allowlist: ${destDir}`);
|
|
55
70
|
}
|
|
56
71
|
if (!fs.existsSync(destDir))
|
|
57
72
|
return [];
|
|
73
|
+
const { extension = ".md", wholeFolders = false } = options;
|
|
58
74
|
const removed = [];
|
|
59
75
|
for (const f of fs.readdirSync(destDir)) {
|
|
60
|
-
if (!f.endsWith(
|
|
76
|
+
if (!wholeFolders && !f.endsWith(extension))
|
|
61
77
|
continue;
|
|
62
78
|
if (prefix && !f.startsWith(prefix))
|
|
63
79
|
continue;
|
|
64
|
-
if (!
|
|
80
|
+
if (!sourceNames.has(f)) {
|
|
81
|
+
const target = path.join(destDir, f);
|
|
65
82
|
if (!dryRun)
|
|
66
|
-
fs.rmSync(
|
|
83
|
+
fs.rmSync(target, { recursive: wholeFolders, force: wholeFolders });
|
|
67
84
|
removed.push(f);
|
|
68
85
|
}
|
|
69
86
|
}
|
|
70
87
|
return removed;
|
|
71
88
|
}
|
|
72
89
|
/** The markered-text `.agents/*.md` blocks core owns. */
|
|
73
|
-
const CORE_AGENT_FILES = [
|
|
74
|
-
"context.md",
|
|
75
|
-
"docs.md",
|
|
76
|
-
"rules.md",
|
|
77
|
-
"shortcuts.md",
|
|
78
|
-
"skills.md",
|
|
79
|
-
];
|
|
90
|
+
const CORE_AGENT_FILES = ["context.md", "docs.md", "rules.md", "skills.md"];
|
|
80
91
|
// The two shared-root files core writes: stored in `shared/`, owned by the core
|
|
81
92
|
// manifest, written as html-comment managed blocks.
|
|
82
93
|
const CORE_SHARED_FILES = [
|
|
@@ -171,16 +182,18 @@ function runCoreTemplates(dryRun, tokens, ws, logPrefix) {
|
|
|
171
182
|
// mirrored into the consumer's `.bkit/` on every install so a consumer can read them
|
|
172
183
|
// in-repo without spelunking node_modules. Force-overwritten (Tier 1) — bkit owns
|
|
173
184
|
// them, so a consumer edit is replaced. Source of truth is the package's own
|
|
174
|
-
// `.bkit/core/.bkit/<name>`. (`advisories.md` is a regenerated runtime artifact
|
|
175
|
-
// `wording.md` is repo-only tooling
|
|
176
|
-
//
|
|
177
|
-
//
|
|
185
|
+
// `.bkit/core/.bkit/<name>`. (`advisories.md` is a regenerated runtime artifact and
|
|
186
|
+
// `wording.md` is repo-only tooling — neither belongs here. `LICENSE.md` is the MIT
|
|
187
|
+
// notice that travels with the files bkit writes: MIT requires the copyright and
|
|
188
|
+
// permission notice in every copy.)
|
|
178
189
|
export const BKIT_CANONICAL_DOCS = [
|
|
179
190
|
"cloud.md",
|
|
180
191
|
"comparison.md",
|
|
181
192
|
"install.md",
|
|
182
193
|
"jsonl.md",
|
|
183
194
|
"LICENSE.md",
|
|
195
|
+
"lite.md",
|
|
196
|
+
"pipeline.md",
|
|
184
197
|
"providers.md",
|
|
185
198
|
"prompts.md",
|
|
186
199
|
"templates.md",
|
|
@@ -217,6 +230,56 @@ export function runBkitDocs(dryRun, tokens, ws, logPrefix) {
|
|
|
217
230
|
console.log(`${logPrefix} ${tag}core: ${dstPath}`);
|
|
218
231
|
}
|
|
219
232
|
}
|
|
233
|
+
migrateShortcutsToLite(dryRun, ws, logPrefix);
|
|
234
|
+
migrateRetiredDevLock(dryRun, ws, logPrefix);
|
|
235
|
+
}
|
|
236
|
+
// Migration (5.1.0 – 5.2.4 installs, `docs/migrations.md`): the lite workflows lived at
|
|
237
|
+
// `.agents/shortcuts.md`. The consumer's own lines below `bkit:end` (minus the seeded
|
|
238
|
+
// heading) move under `.bkit/lite.md`'s consumer section; the old file is deleted. Runs
|
|
239
|
+
// after the docs loop, so `.bkit/lite.md` is already written. The delete is recorded in
|
|
240
|
+
// ws (as orphan-mirror deletes are) so `bkit check` fails until upgrade runs.
|
|
241
|
+
const RETIRED_SHORTCUTS = path.join(".agents", "shortcuts.md");
|
|
242
|
+
const RETIRED_SHORTCUTS_HEADING = "## Project Shortcuts";
|
|
243
|
+
export function migrateShortcutsToLite(dryRun, ws, logPrefix) {
|
|
244
|
+
if (!fs.existsSync(RETIRED_SHORTCUTS))
|
|
245
|
+
return;
|
|
246
|
+
if (!fs.existsSync(path.join(getBkitDocsRoot(), "lite.md")))
|
|
247
|
+
return;
|
|
248
|
+
const tag = dryRun ? "[dry-run] " : "";
|
|
249
|
+
const dst = path.join(".bkit", "lite.md");
|
|
250
|
+
const old = fs.readFileSync(RETIRED_SHORTCUTS, "utf-8");
|
|
251
|
+
if (extractManagedBlock(old, "html-comment") === null) {
|
|
252
|
+
console.warn(`${logPrefix} ${RETIRED_SHORTCUTS} has no single bkit managed block — left in place. Move your own lines into ${dst} below \`<!-- bkit:end -->\`, then delete it.`);
|
|
253
|
+
return;
|
|
254
|
+
}
|
|
255
|
+
const own = stripManagedBlock(old, "html-comment")
|
|
256
|
+
.split("\n")
|
|
257
|
+
.filter((line) => line.trim() !== RETIRED_SHORTCUTS_HEADING)
|
|
258
|
+
.join("\n")
|
|
259
|
+
.trim();
|
|
260
|
+
if (own.length > 0) {
|
|
261
|
+
if (!dryRun) {
|
|
262
|
+
const current = fs.readFileSync(dst, "utf-8");
|
|
263
|
+
fs.writeFileSync(dst, `${current.replace(/\n*$/, "\n\n")}${own}\n`, "utf-8");
|
|
264
|
+
}
|
|
265
|
+
ws.writes.push({ path: dst, action: "update" });
|
|
266
|
+
}
|
|
267
|
+
if (!dryRun)
|
|
268
|
+
fs.rmSync(RETIRED_SHORTCUTS);
|
|
269
|
+
ws.writes.push({ path: RETIRED_SHORTCUTS, action: "write" });
|
|
270
|
+
console.log(`${logPrefix} ${tag}core: moved ${RETIRED_SHORTCUTS} → ${dst}`);
|
|
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)`);
|
|
220
283
|
}
|
|
221
284
|
// ---------------------------------------------------------------------------
|
|
222
285
|
// Source-rendered host outputs — agents (.agents/prompts source) and commands
|
|
@@ -229,28 +292,6 @@ export function runBkitDocs(dryRun, tokens, ws, logPrefix) {
|
|
|
229
292
|
// (installFile does not touch ws), matching the install path exactly. Each returns
|
|
230
293
|
// the consumer-relative dest paths it wrote (for the upgrade summary).
|
|
231
294
|
// ---------------------------------------------------------------------------
|
|
232
|
-
// ---------------------------------------------------------------------------
|
|
233
|
-
// Managed-version stamping. The marker shape (stampManagedVersion + regexes) lives
|
|
234
|
-
// in install/version-file.ts, shared by the renderer and the `bkit check` detector. Here we
|
|
235
|
-
// only resolve WHICH version to stamp: ctx.version (set by install/upgrade) with a
|
|
236
|
-
// package-root fallback.
|
|
237
|
-
// ---------------------------------------------------------------------------
|
|
238
|
-
/**
|
|
239
|
-
* Best-effort read of the installing bkit version from the package root's
|
|
240
|
-
* package.json. Mirrors getInstallingVersion in commands/install/install.ts; duplicated here
|
|
241
|
-
* (not imported) to avoid a modules → install dependency cycle. Returns "0.0.0"
|
|
242
|
-
* when unreadable — the same non-fatal fallback the install side uses.
|
|
243
|
-
*/
|
|
244
|
-
export function readInstallingVersion() {
|
|
245
|
-
try {
|
|
246
|
-
const pkgPath = path.join(getPkgRoot(), "package.json");
|
|
247
|
-
const pkg = JSON.parse(fs.readFileSync(pkgPath, "utf-8"));
|
|
248
|
-
return pkg.version ?? "0.0.0";
|
|
249
|
-
}
|
|
250
|
-
catch {
|
|
251
|
-
return "0.0.0";
|
|
252
|
-
}
|
|
253
|
-
}
|
|
254
295
|
/** Record a host mirror would-write so `bkit check` exits 1 on content drift. */
|
|
255
296
|
export function trackMirrorWrite(ctx, relPath, written) {
|
|
256
297
|
written.push(relPath);
|
|
@@ -298,16 +339,13 @@ const PNPM_NOT_A_SCRIPT = new Set([
|
|
|
298
339
|
* package.json yields none.
|
|
299
340
|
*/
|
|
300
341
|
export function detectGateAdvisories(cwd) {
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
}
|
|
306
|
-
catch {
|
|
307
|
-
// Absent or malformed package.json — preflight's no-package-json /
|
|
308
|
-
// malformed-package-json blockers already report it.
|
|
342
|
+
const read = readJsonFile(path.join(cwd, "package.json"));
|
|
343
|
+
// Absent or malformed package.json — preflight's no-package-json /
|
|
344
|
+
// malformed-package-json blockers already report it.
|
|
345
|
+
if (!read.ok || read.value === null)
|
|
309
346
|
return [];
|
|
310
|
-
|
|
347
|
+
const pkg = read.value;
|
|
348
|
+
const declared = { ...BKIT_GATE_SCRIPTS, ...pkg.scripts };
|
|
311
349
|
const findings = [];
|
|
312
350
|
// Every script a seeded gate default chains MUST exist, or the gate dies on the first
|
|
313
351
|
// missing one and the workflow reads that as a real failure. Checked only where the
|
|
@@ -379,15 +417,12 @@ export function isNoopScript(value) {
|
|
|
379
417
|
* every branch. Read-only; an absent or unparseable package.json yields none.
|
|
380
418
|
*/
|
|
381
419
|
export function detectNoopGates(cwd) {
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
declared = pkg.scripts ?? {};
|
|
386
|
-
}
|
|
387
|
-
catch {
|
|
388
|
-
// Absent or malformed package.json — preflight's blockers already report it.
|
|
420
|
+
const read = readJsonFile(path.join(cwd, "package.json"));
|
|
421
|
+
// Absent or malformed package.json — preflight's blockers already report it.
|
|
422
|
+
if (!read.ok || read.value === null)
|
|
389
423
|
return [];
|
|
390
|
-
|
|
424
|
+
const pkg = read.value;
|
|
425
|
+
const declared = pkg.scripts ?? {};
|
|
391
426
|
const noop = Object.entries(declared)
|
|
392
427
|
.filter(([name, value]) => name.startsWith("bkit:gate:") && typeof value === "string")
|
|
393
428
|
.filter(([, value]) => isNoopScript(value))
|
|
@@ -408,13 +443,7 @@ export function runCoreModule(ctx) {
|
|
|
408
443
|
const { dryRun, ws, advisories, logPrefix, postDispatch } = ctx;
|
|
409
444
|
const tag = dryRun ? "[dry-run] " : "";
|
|
410
445
|
const cwd = process.cwd();
|
|
411
|
-
const
|
|
412
|
-
const PKG_PACKAGE_JSON = path.join(PKG_ROOT, "package.json");
|
|
413
|
-
if (!fs.existsSync(PKG_PACKAGE_JSON)) {
|
|
414
|
-
console.error(`${logPrefix} package.json not found at ${PKG_PACKAGE_JSON} — package corrupt?`);
|
|
415
|
-
process.exit(1);
|
|
416
|
-
}
|
|
417
|
-
const pkgVersion = JSON.parse(fs.readFileSync(PKG_PACKAGE_JSON, "utf-8")).version;
|
|
446
|
+
const pkgVersion = readInstallingVersion();
|
|
418
447
|
// Capture first-install signal NOW (before any writes) — used for the post-install banner.
|
|
419
448
|
// The .bkit/version write happens in postDispatch, so a mid-install crash in a later
|
|
420
449
|
// module leaves no .bkit/version on disk.
|
|
@@ -425,7 +454,7 @@ export function runCoreModule(ctx) {
|
|
|
425
454
|
console.log(`${logPrefix} ${tag}Running core payload pass`);
|
|
426
455
|
runCoreTemplates(dryRun, ctx.tokens, ws, logPrefix);
|
|
427
456
|
// 3b. bkit canonical docs pass — mirror the package's reference docs
|
|
428
|
-
// (cloud/IDEs/prompts/trackers/workflows/README/install/comparison) into the
|
|
457
|
+
// (cloud/IDEs/prompts/trackers/workflows/README/install/comparison/pipeline) into the
|
|
429
458
|
// consumer's `.bkit/` so they are readable in-repo. Force-overwrite (Tier 1).
|
|
430
459
|
console.log(`${logPrefix} ${tag}Running bkit docs pass`);
|
|
431
460
|
runBkitDocs(dryRun, ctx.tokens, ws, logPrefix);
|
|
@@ -465,6 +494,9 @@ export function runCoreModule(ctx) {
|
|
|
465
494
|
action: `Browse-only — bkit reads its payload from the package regardless. To add the view by hand on POSIX: ln -s ../node_modules/@cbartens/bkit/${rel} ${rel}`,
|
|
466
495
|
});
|
|
467
496
|
}
|
|
497
|
+
// 3b4. `.bkit/allowlist.json` — the network allowlist every host's guardrails hook
|
|
498
|
+
// reads (writeNetworkAllowlist), plus the move off the retired `.cursor/` copy.
|
|
499
|
+
writeNetworkAllowlist(cwd, dryRun, ws, logPrefix);
|
|
468
500
|
// 3c. The bkit:gate:* / bkit:deps:* package.json scripts (add-if-missing). The
|
|
469
501
|
// advisories read the result.
|
|
470
502
|
seedCorePackageJsonScripts(ctx);
|
|
@@ -7,8 +7,9 @@ import { applyT1, applyT2, applyT3 } from "../../render/hosts.js";
|
|
|
7
7
|
import { getCoreRoot, getSharedRoot, getWorkflowsRoot, getPromptsRoot, } from "../../shared/package-roots.js";
|
|
8
8
|
import { DEFAULT_ISSUE_TRACKER } from "../manifest.js";
|
|
9
9
|
import { substituteWorkflow } from "../../render/trackers.js";
|
|
10
|
-
import { writeCursorCloudDoc,
|
|
11
|
-
import {
|
|
10
|
+
import { writeCursorCloudDoc, writeCursorCliPermissionsArtifact } from "../cloud-env.js";
|
|
11
|
+
import { readInstallingVersion } from "../../shared/package-json.js";
|
|
12
|
+
import { BKIT_PREFIX, installFile, listMdFiles, removeOrphans, trackMirrorWrite } from "./core.js";
|
|
12
13
|
import { reconcileMcpJson } from "./claude.js";
|
|
13
14
|
export function renderCursorAgentsCommands(ctx) {
|
|
14
15
|
const { dryRun, modelLookup, effortMap, logPrefix } = ctx;
|
|
@@ -143,15 +144,11 @@ export function runCursorModule(ctx) {
|
|
|
143
144
|
}
|
|
144
145
|
}
|
|
145
146
|
}
|
|
146
|
-
// Cursor-only runtime curl/wget allowlist (bkit-guardrails.cjs reads `.cursor/allowlist.json`).
|
|
147
|
-
// Same domain set as Claude WebFetch / OpenCode bash allows — sourced from tooling
|
|
148
|
-
// defaults ∪ consumer `allowed-domains`. Not under `.bkit/` (IDE-scoped artifact).
|
|
149
147
|
// Cursor CLI / cloud-agent MCP allows (`.cursor/cli.json`) from consumer `mcp-servers` —
|
|
150
148
|
// same server set as Claude `mcp__…` allows / OpenCode `<server>_*` permission rows.
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
writeCursorCliPermissionsArtifact(process.cwd(), dryRun)
|
|
154
|
-
]) {
|
|
149
|
+
// The curl/wget allowlist the guardrails hook reads is core's `.bkit/allowlist.json`.
|
|
150
|
+
{
|
|
151
|
+
const art = writeCursorCliPermissionsArtifact(process.cwd(), dryRun);
|
|
155
152
|
if (art.wrote) {
|
|
156
153
|
ws.writes.push({ path: art.path, action: "write" });
|
|
157
154
|
console.log(`${logPrefix} ${tag}cursor: ${art.path}`);
|
|
@@ -8,6 +8,7 @@ import * as fs from "node:fs";
|
|
|
8
8
|
import * as path from "node:path";
|
|
9
9
|
import { getCoreRoot, getSharedRoot } from "../../shared/package-roots.js";
|
|
10
10
|
import { getInstallManifest } from "../manifest.js";
|
|
11
|
+
import { writeNetworkAllowlist } from "../network-allowlist.js";
|
|
11
12
|
import { BKIT_PREFIX, listCoreTemplateFiles, listSharedTemplateFiles, runBkitDocs, runCoreModule, seedCorePackageJsonScripts, } from "./core.js";
|
|
12
13
|
import { renderClaudeAgentsCommands, runClaudeModule } from "./claude.js";
|
|
13
14
|
import { renderCursorAgentsCommands, runCursorModule } from "./cursor.js";
|
|
@@ -19,7 +20,8 @@ import { runCloudModule } from "./cloud.js";
|
|
|
19
20
|
// renderManagedOutputs — re-render the bkit-managed OUTPUT files that the
|
|
20
21
|
// `bkit upgrade` payload walk does NOT cover:
|
|
21
22
|
// host agents/commands (source-rendered), the `.bkit/*.md` canonical docs
|
|
22
|
-
// (runBkitDocs) and core's
|
|
23
|
+
// (runBkitDocs), `.bkit/allowlist.json` (writeNetworkAllowlist) and core's
|
|
24
|
+
// package.json scripts (seedCorePackageJsonScripts).
|
|
23
25
|
// `.bkit/prompts.md` is markered → runBkitDocs block-merges it (managed block
|
|
24
26
|
// refreshed, consumer `## Model Overrides` below bkit:end preserved).
|
|
25
27
|
//
|
|
@@ -41,6 +43,9 @@ export function renderManagedOutputs(modules, ctx) {
|
|
|
41
43
|
for (let i = docsBefore; i < ctx.ws.writes.length; i++) {
|
|
42
44
|
written.push(String(ctx.ws.writes[i].path));
|
|
43
45
|
}
|
|
46
|
+
// `.bkit/allowlist.json` — the same pass install's core module runs (writeNetworkAllowlist
|
|
47
|
+
// records into ctx.ws, so the caller refreshes its canonicalHashes).
|
|
48
|
+
written.push(...writeNetworkAllowlist(process.cwd(), ctx.dryRun, ctx.ws, ctx.logPrefix));
|
|
44
49
|
// Core package.json scripts — the same pass install runs, so `bkit check` after a
|
|
45
50
|
// clean upgrade finds no missing gate name and no superseded script value.
|
|
46
51
|
written.push(...seedCorePackageJsonScripts(ctx));
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// the provider-templated `opencode.json`.
|
|
3
3
|
import * as fs from "node:fs";
|
|
4
4
|
import * as path from "node:path";
|
|
5
|
-
import { writeTier2, deepMergeJson, ensureDir } from "../write.js";
|
|
5
|
+
import { writeTier2, deepMergeJson, ensureDir, isJsonObject, mergeTrackerEntry, } from "../write.js";
|
|
6
6
|
import { stampManagedVersion } from "../version-file.js";
|
|
7
7
|
import { applyOpencodeAgent, applyOpencodeCommand } from "../../render/hosts.js";
|
|
8
8
|
import { getCoreRoot, getSharedRoot, getWorkflowsRoot, getPromptsRoot, } from "../../shared/package-roots.js";
|
|
@@ -10,8 +10,11 @@ import { DEFAULT_ISSUE_TRACKER } from "../manifest.js";
|
|
|
10
10
|
import { substituteWorkflow } from "../../render/trackers.js";
|
|
11
11
|
import { resolveNetworkAllowlist, extractMcpServers, networkAllowlistBases } from "../cloud-env.js";
|
|
12
12
|
import { OPENCODE_PROVIDER_DEFAULTS } from "../../shared/egress.js";
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
13
|
+
import { parseJson, readJsonFile } from "../../shared/json.js";
|
|
14
|
+
import { readBkitConfig } from "../../shared/settings.js";
|
|
15
|
+
import { readInstallingVersion } from "../../shared/package-json.js";
|
|
16
|
+
import { BKIT_PREFIX, installFile, listMdFiles, removeOrphans, trackMirrorWrite } from "./core.js";
|
|
17
|
+
import { isOpencodeProvider, opencodeProviderId } from "../../render/models.js";
|
|
15
18
|
export function renderOpencodeAgentsCommands(ctx) {
|
|
16
19
|
const { dryRun, opencodeModelLookup, effortMap, opencodeProvider, logPrefix } = ctx;
|
|
17
20
|
const tag = dryRun ? "[dry-run] " : "";
|
|
@@ -42,23 +45,11 @@ export function renderOpencodeAgentsCommands(ctx) {
|
|
|
42
45
|
trackMirrorWrite(ctx, rel, written);
|
|
43
46
|
}
|
|
44
47
|
}
|
|
45
|
-
//
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
if (!f.endsWith(".md"))
|
|
51
|
-
continue;
|
|
52
|
-
if (!f.startsWith(BKIT_PREFIX))
|
|
53
|
-
continue;
|
|
54
|
-
if (!sourceSet.has(f)) {
|
|
55
|
-
const rel = path.join(dest, f);
|
|
56
|
-
if (!dryRun)
|
|
57
|
-
fs.rmSync(path.join(dest, f));
|
|
58
|
-
console.log(`${logPrefix} ${tag}delete orphan: ${rel}`);
|
|
59
|
-
trackMirrorWrite(ctx, rel, written);
|
|
60
|
-
}
|
|
61
|
-
}
|
|
48
|
+
// dryRun still reports would-deletes into ws.writes so `bkit check` fails on stale mirrors.
|
|
49
|
+
for (const f of removeOrphans(dest, sourceSet, dryRun, BKIT_PREFIX)) {
|
|
50
|
+
const rel = path.join(dest, f);
|
|
51
|
+
console.log(`${logPrefix} ${tag}delete orphan: ${rel}`);
|
|
52
|
+
trackMirrorWrite(ctx, rel, written);
|
|
62
53
|
}
|
|
63
54
|
}
|
|
64
55
|
// --- Commands: tracker substitution + applyOpencodeCommand ---
|
|
@@ -78,20 +69,10 @@ export function renderOpencodeAgentsCommands(ctx) {
|
|
|
78
69
|
trackMirrorWrite(ctx, rel, written);
|
|
79
70
|
}
|
|
80
71
|
}
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
if (!f.startsWith(BKIT_PREFIX))
|
|
86
|
-
continue;
|
|
87
|
-
if (!sourceSet.has(f)) {
|
|
88
|
-
const rel = path.join(dest, f);
|
|
89
|
-
if (!dryRun)
|
|
90
|
-
fs.rmSync(path.join(dest, f));
|
|
91
|
-
console.log(`${logPrefix} ${tag}delete orphan: ${rel}`);
|
|
92
|
-
trackMirrorWrite(ctx, rel, written);
|
|
93
|
-
}
|
|
94
|
-
}
|
|
72
|
+
for (const f of removeOrphans(dest, sourceSet, dryRun, BKIT_PREFIX)) {
|
|
73
|
+
const rel = path.join(dest, f);
|
|
74
|
+
console.log(`${logPrefix} ${tag}delete orphan: ${rel}`);
|
|
75
|
+
trackMirrorWrite(ctx, rel, written);
|
|
95
76
|
}
|
|
96
77
|
}
|
|
97
78
|
return written;
|
|
@@ -118,7 +99,7 @@ export function renderOpencodeAgentsCommands(ctx) {
|
|
|
118
99
|
* secret against the installed provider.
|
|
119
100
|
*/
|
|
120
101
|
export function opencodeProviderEnvVar(providerKey) {
|
|
121
|
-
return OPENCODE_PROVIDER_DEFAULTS[providerKey]
|
|
102
|
+
return isOpencodeProvider(providerKey) ? OPENCODE_PROVIDER_DEFAULTS[providerKey].envVar : "";
|
|
122
103
|
}
|
|
123
104
|
/**
|
|
124
105
|
* Detect drift between the self-installed `.github/workflows/opencode.yml` reactive `/oc` handler
|
|
@@ -141,19 +122,8 @@ export function detectOpencodeYmlProviderDrift(cwd) {
|
|
|
141
122
|
if (!fs.existsSync(ymlPath))
|
|
142
123
|
return null;
|
|
143
124
|
// The installed provider — package.json `bkit.opencodeProvider` is the authoritative record
|
|
144
|
-
// written on install. Absent/broken → the null-guard below skips silently.
|
|
145
|
-
|
|
146
|
-
const pkgPath = path.join(cwd, "package.json");
|
|
147
|
-
if (fs.existsSync(pkgPath)) {
|
|
148
|
-
try {
|
|
149
|
-
const pkg = JSON.parse(fs.readFileSync(pkgPath, "utf-8"));
|
|
150
|
-
if (typeof pkg.bkit?.opencodeProvider === "string")
|
|
151
|
-
provider = pkg.bkit.opencodeProvider;
|
|
152
|
-
}
|
|
153
|
-
catch {
|
|
154
|
-
// Malformed package.json — leave provider null; a JSON-drift advisory covers that separately.
|
|
155
|
-
}
|
|
156
|
-
}
|
|
125
|
+
// written on install. Absent/broken/unsupported → the null-guard below skips silently.
|
|
126
|
+
const provider = readBkitConfig(cwd).opencodeProvider;
|
|
157
127
|
if (!provider)
|
|
158
128
|
return null;
|
|
159
129
|
const expectedPrefix = opencodeProviderId(provider); // model id form is `<providerId>/<model>`
|
|
@@ -222,10 +192,10 @@ export function renderOpencodeJson(templatePath, tracker, provider, cwd = proces
|
|
|
222
192
|
const raw = fs.readFileSync(templatePath, "utf-8");
|
|
223
193
|
// Strict allowlist: provider is gated to OPENCODE_PROVIDERS at the CLI, so it is always
|
|
224
194
|
// a known key here. An unknown id throws; no substitute provider.
|
|
225
|
-
|
|
226
|
-
if (!providerDefaults) {
|
|
195
|
+
if (!isOpencodeProvider(provider)) {
|
|
227
196
|
throw new Error(`renderOpencodeJson: unknown opencode provider ${JSON.stringify(provider)}`);
|
|
228
197
|
}
|
|
198
|
+
const providerDefaults = OPENCODE_PROVIDER_DEFAULTS[provider];
|
|
229
199
|
// Resolve tracker MCP entry
|
|
230
200
|
// opencode's MCP schema differs from Claude/Cursor: remote servers use type "remote"
|
|
231
201
|
// (NOT "http" — not in opencode's enum, which makes the whole config invalid) and read
|
|
@@ -237,7 +207,7 @@ export function renderOpencodeJson(templatePath, tracker, provider, cwd = proces
|
|
|
237
207
|
let mcpEntry;
|
|
238
208
|
if (tracker === "github") {
|
|
239
209
|
mcpEntry =
|
|
240
|
-
'"github": { "type": "remote", "url": "https://api.githubcopilot.com/mcp/", "oauth": false, "headers": { "Authorization": "Bearer {env:BKIT_GH_TOKEN}", "X-MCP-Toolsets": "context,issues,pull_requests,repos,users,projects" } }';
|
|
210
|
+
'"github": { "type": "remote", "url": "https://api.githubcopilot.com/mcp/", "oauth": false, "headers": { "Authorization": "Bearer {env:BKIT_GH_TOKEN}", "X-MCP-Toolsets": "context,issues,pull_requests,repos,users,projects,actions" } }';
|
|
241
211
|
}
|
|
242
212
|
else if (tracker === "linear") {
|
|
243
213
|
mcpEntry = '"linear": { "type": "remote", "url": "https://mcp.linear.app/mcp" }';
|
|
@@ -251,7 +221,10 @@ export function renderOpencodeJson(templatePath, tracker, provider, cwd = proces
|
|
|
251
221
|
rendered = rendered.replace(OPENCODE_PROVIDER_BASE_URL_SENTINEL, providerDefaults.baseURL);
|
|
252
222
|
// Parse + re-serialize to normalise JSON (removes empty mcp entry if tracker=none)
|
|
253
223
|
try {
|
|
254
|
-
const
|
|
224
|
+
const renderedDoc = parseJson(rendered);
|
|
225
|
+
if (!renderedDoc.ok)
|
|
226
|
+
return rendered;
|
|
227
|
+
const parsed = renderedDoc.value;
|
|
255
228
|
// Clean up empty mcp object when tracker=none
|
|
256
229
|
const mcp = parsed.mcp;
|
|
257
230
|
if (mcp && Object.keys(mcp).length === 0) {
|
|
@@ -350,20 +323,22 @@ export function reconcileOpencodeJson(renderedTemplate, relDst, dryRun, ws) {
|
|
|
350
323
|
ws.writes.push({ path: relDst, action: "write" });
|
|
351
324
|
return;
|
|
352
325
|
}
|
|
353
|
-
//
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
let existing = null;
|
|
357
|
-
try {
|
|
358
|
-
existing = JSON.parse(fs.readFileSync(relDst, "utf-8"));
|
|
359
|
-
}
|
|
360
|
-
catch {
|
|
361
|
-
existing = null;
|
|
362
|
-
}
|
|
326
|
+
// Malformed consumer JSON is a hard stop: refuse to merge, require a fix.
|
|
327
|
+
const read = readJsonFile(relDst);
|
|
328
|
+
const existing = read.ok ? read.value : null;
|
|
363
329
|
if (existing === null) {
|
|
364
330
|
throw new Error(`[bkit] ${relDst} is malformed JSON — fix manually before running bkit install`);
|
|
365
331
|
}
|
|
366
332
|
const merged = deepMergeJson(existing, template);
|
|
333
|
+
// The tracker `mcp` entry keeps the consumer's extra toolsets (`mergeTrackerEntry`), which
|
|
334
|
+
// the plain merge above would overwrite with the template's list.
|
|
335
|
+
const tmplMcp = template.mcp;
|
|
336
|
+
const existingMcp = existing.mcp;
|
|
337
|
+
if (isJsonObject(tmplMcp) && isJsonObject(existingMcp) && isJsonObject(merged.mcp)) {
|
|
338
|
+
for (const [k, v] of Object.entries(tmplMcp)) {
|
|
339
|
+
merged.mcp[k] = mergeTrackerEntry(existingMcp[k], v);
|
|
340
|
+
}
|
|
341
|
+
}
|
|
367
342
|
// Replace (do not deep-merge) each provider key the template seeds — heals hijacked
|
|
368
343
|
// npm/baseURL/name while keeping other provider keys additive.
|
|
369
344
|
//
|
|
@@ -411,14 +386,8 @@ export function reconcileOpencodeJson(renderedTemplate, relDst, dryRun, ws) {
|
|
|
411
386
|
export function removeOpencodeProviderBlock(dst, providerKey, dryRun, ws) {
|
|
412
387
|
if (!fs.existsSync(dst))
|
|
413
388
|
return;
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
try {
|
|
417
|
-
existing = JSON.parse(fs.readFileSync(dst, "utf-8"));
|
|
418
|
-
}
|
|
419
|
-
catch {
|
|
420
|
-
existing = null;
|
|
421
|
-
}
|
|
389
|
+
const read = readJsonFile(dst);
|
|
390
|
+
const existing = read.ok ? read.value : null;
|
|
422
391
|
if (existing === null) {
|
|
423
392
|
console.warn(`[bkit] ${dst} is malformed — leaving as-is`);
|
|
424
393
|
return;
|
|
@@ -494,7 +463,7 @@ export function runOpencodeModule(ctx) {
|
|
|
494
463
|
detect: `opencode host installed (provider: ${provider}). The opencode CLI and your provider credentials are required before running agents.`,
|
|
495
464
|
action: `opencode setup for provider "${provider}":\n\n` +
|
|
496
465
|
(() => {
|
|
497
|
-
const pd = OPENCODE_PROVIDER_DEFAULTS[provider];
|
|
466
|
+
const pd = isOpencodeProvider(provider) ? OPENCODE_PROVIDER_DEFAULTS[provider] : undefined;
|
|
498
467
|
if (!pd) {
|
|
499
468
|
return (` 1. Set ${provider.toUpperCase()}_API_KEY in your environment / .bkit/.env.\n` +
|
|
500
469
|
` 2. Update .opencode/opencode.json provider.${provider}.options.baseURL for your endpoint.\n`);
|
|
@@ -518,7 +487,7 @@ export function runOpencodeModule(ctx) {
|
|
|
518
487
|
` env — {env:KEY} placeholders in opencode.json resolve empty without this. Quit the\n` +
|
|
519
488
|
` running app first (a running instance ignores the new env).\n` +
|
|
520
489
|
` 4. Model IDs: all four providers (openrouter, ollama, opencode-zen, opencode-go) install ready-to-run curated per-agent pins. ` +
|
|
521
|
-
`Re-pin any agent via .bkit/prompts.md § Model Overrides or by probing the provider's live /v1/models — see .bkit/providers.md § Models. NOTE: ollama
|
|
490
|
+
`Re-pin any agent via .bkit/prompts.md § Model Overrides or by probing the provider's live /v1/models — see .bkit/providers.md § Models. NOTE: every ollama pin (deepseek-v4.1-flash, kimi-k3) needs a paid Ollama plan. opencode-go pins (deepseek-v4.1-flash, kimi-k3) — prefer pins that stay within the Go 5h usage window; opencode-zen pins are existence-validated via models.dev (the /zen/v1/models REST probe cannot see Go-only models — models.dev is the source of truth).\n` +
|
|
522
491
|
` 5. Verify with: \`bkit doctor\` (credentials + tools) and \`bkit status\` (installed hosts + providers).`,
|
|
523
492
|
});
|
|
524
493
|
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
// install/network-allowlist.ts — `.bkit/allowlist.json`, the resolved network allowlist
|
|
2
|
+
// (shipped egress registry ∪ consumer `allowed-domains`) the guardrails hooks of Claude,
|
|
3
|
+
// Cursor, Codex and Antigravity read at runtime to host-check shell curl / wget. Core
|
|
4
|
+
// owns it: install (runCoreModule) and upgrade (renderManagedOutputs) both write it, so
|
|
5
|
+
// it exists for every host that reads it and `bkit check` reports it missing or stale.
|
|
6
|
+
import * as fs from "node:fs";
|
|
7
|
+
import * as path from "node:path";
|
|
8
|
+
import { resolveNetworkAllowlist } from "./cloud-env.js";
|
|
9
|
+
import { readBkitVersion } from "./version-file.js";
|
|
10
|
+
/** Consumer-relative path of the install-written curl/wget allowlist. */
|
|
11
|
+
export const NETWORK_ALLOWLIST_RELPATH = path.join(".bkit", "allowlist.json");
|
|
12
|
+
/** Where the cursor module wrote the allowlist up to 5.2.4 (migrated away). */
|
|
13
|
+
export const RETIRED_NETWORK_ALLOWLIST_RELPATH = path.join(".cursor", "allowlist.json");
|
|
14
|
+
/** The allowlist file body: `{ domains }`, apex + `*.` wildcard per base, sorted. */
|
|
15
|
+
export function renderNetworkAllowlist(cwd) {
|
|
16
|
+
return JSON.stringify({ domains: resolveNetworkAllowlist(cwd) }, null, 2) + "\n";
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Write `.bkit/allowlist.json` whole (hand edits do not survive — `allowed-domains` in
|
|
20
|
+
* `.agents/context.md` is the source), then migrate the retired copy. Every change is
|
|
21
|
+
* recorded in `ws` under dry-run too, so `bkit check` fails until install / upgrade runs.
|
|
22
|
+
* Returns the consumer-relative paths changed.
|
|
23
|
+
*/
|
|
24
|
+
export function writeNetworkAllowlist(cwd, dryRun, ws, logPrefix) {
|
|
25
|
+
const tag = dryRun ? "[dry-run] " : "";
|
|
26
|
+
const changed = [];
|
|
27
|
+
const abs = path.join(cwd, NETWORK_ALLOWLIST_RELPATH);
|
|
28
|
+
const body = renderNetworkAllowlist(cwd);
|
|
29
|
+
const prev = fs.existsSync(abs) ? fs.readFileSync(abs, "utf-8") : null;
|
|
30
|
+
if (prev !== body) {
|
|
31
|
+
if (!dryRun) {
|
|
32
|
+
fs.mkdirSync(path.dirname(abs), { recursive: true });
|
|
33
|
+
fs.writeFileSync(abs, body, "utf-8");
|
|
34
|
+
}
|
|
35
|
+
ws.writes.push({ path: NETWORK_ALLOWLIST_RELPATH, action: prev === null ? "write" : "update" });
|
|
36
|
+
changed.push(NETWORK_ALLOWLIST_RELPATH);
|
|
37
|
+
console.log(`${logPrefix} ${tag}core: ${NETWORK_ALLOWLIST_RELPATH}`);
|
|
38
|
+
}
|
|
39
|
+
if (migrateRetiredNetworkAllowlist(cwd, dryRun)) {
|
|
40
|
+
ws.writes.push({ path: RETIRED_NETWORK_ALLOWLIST_RELPATH, action: "write" });
|
|
41
|
+
changed.push(RETIRED_NETWORK_ALLOWLIST_RELPATH);
|
|
42
|
+
console.log(`${logPrefix} ${tag}core: removed ${RETIRED_NETWORK_ALLOWLIST_RELPATH} (moved to ${NETWORK_ALLOWLIST_RELPATH})`);
|
|
43
|
+
}
|
|
44
|
+
return changed;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Migration (installs up to 5.2.4, `docs/migrations.md`): delete `.cursor/allowlist.json`
|
|
48
|
+
* when `.bkit/version` records its hash — bkit wrote it and owned it whole. A file bkit
|
|
49
|
+
* never recorded is left alone. Returns whether the file is (or, under dry-run, would be)
|
|
50
|
+
* removed. The stale hash entry is pruned by the `.bkit/version` writer.
|
|
51
|
+
*/
|
|
52
|
+
function migrateRetiredNetworkAllowlist(cwd, dryRun) {
|
|
53
|
+
const abs = path.join(cwd, RETIRED_NETWORK_ALLOWLIST_RELPATH);
|
|
54
|
+
if (!fs.existsSync(abs))
|
|
55
|
+
return false;
|
|
56
|
+
const hashes = readBkitVersion(path.join(cwd, ".bkit", "version"))?.canonicalHashes ?? {};
|
|
57
|
+
if (hashes[RETIRED_NETWORK_ALLOWLIST_RELPATH] === undefined)
|
|
58
|
+
return false;
|
|
59
|
+
if (!dryRun)
|
|
60
|
+
fs.rmSync(abs);
|
|
61
|
+
return true;
|
|
62
|
+
}
|