@cbartens/bkit 5.2.3 → 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 +29 -12
- 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 +28 -11
- package/.bkit/core/.bkit/cloud.md +9 -8
- package/.bkit/core/.bkit/comparison.md +68 -345
- package/.bkit/core/.bkit/install.md +15 -9
- 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 +125 -18
- package/.bkit/core/.bkit/trackers.md +47 -1
- package/.bkit/core/.bkit/workflows.md +51 -45
- 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 +9 -1
- package/.bkit/core/docs/templates/bkit-audit-adoption.md +10 -2
- package/.bkit/core/docs/templates/bkit-audit-agents.md +9 -1
- package/.bkit/core/docs/templates/bkit-audit-aio-seo.md +9 -1
- package/.bkit/core/docs/templates/bkit-audit-analytics.md +9 -1
- package/.bkit/core/docs/templates/bkit-audit-annotations.md +10 -2
- package/.bkit/core/docs/templates/bkit-audit-app-performance.md +9 -1
- package/.bkit/core/docs/templates/bkit-audit-app-store.md +9 -1
- package/.bkit/core/docs/templates/bkit-audit-architecture.md +9 -1
- package/.bkit/core/docs/templates/bkit-audit-ci-performance.md +9 -1
- package/.bkit/core/docs/templates/bkit-audit-config.md +9 -1
- package/.bkit/core/docs/templates/bkit-audit-cost.md +10 -2
- package/.bkit/core/docs/templates/bkit-audit-coverage.md +9 -1
- package/.bkit/core/docs/templates/bkit-audit-database.md +9 -1
- package/.bkit/core/docs/templates/bkit-audit-dead-code.md +9 -1
- package/.bkit/core/docs/templates/bkit-audit-deferrals.md +9 -1
- package/.bkit/core/docs/templates/bkit-audit-dependencies.md +22 -10
- package/.bkit/core/docs/templates/bkit-audit-documentation.md +9 -1
- package/.bkit/core/docs/templates/bkit-audit-duplication.md +9 -1
- package/.bkit/core/docs/templates/bkit-audit-failures.md +9 -1
- package/.bkit/core/docs/templates/bkit-audit-flakes.md +10 -2
- package/.bkit/core/docs/templates/bkit-audit-gates.md +9 -1
- package/.bkit/core/docs/templates/bkit-audit-issues.md +9 -1
- package/.bkit/core/docs/templates/bkit-audit-llm.md +29 -15
- package/.bkit/core/docs/templates/bkit-audit-logs.md +10 -2
- package/.bkit/core/docs/templates/bkit-audit-models.md +9 -1
- package/.bkit/core/docs/templates/bkit-audit-privacy.md +9 -1
- package/.bkit/core/docs/templates/bkit-audit-prompts.md +11 -3
- package/.bkit/core/docs/templates/bkit-audit-red-team.md +19 -9
- package/.bkit/core/docs/templates/bkit-audit-reliability.md +9 -1
- package/.bkit/core/docs/templates/bkit-audit-repo.md +10 -2
- package/.bkit/core/docs/templates/bkit-audit-security.md +13 -5
- package/.bkit/core/docs/templates/bkit-audit-slop.md +9 -1
- package/.bkit/core/docs/templates/bkit-audit-testing.md +14 -5
- package/.bkit/core/docs/templates/bkit-audit-usability.md +9 -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 -5
- package/.bkit/core/engine/checks/tips/catalogue.ts +70 -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 +58 -53
- 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 +65 -11
- 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 +18 -4
- 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 +19 -17
- 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/bkit-latest.ts +164 -0
- 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/engine/shared/timeouts.ts +6 -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 +65 -10
- 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 +4 -4
- package/.bkit/core/workflows/bkit-debug.md +70 -34
- package/.bkit/core/workflows/bkit-design.md +3 -3
- package/.bkit/core/workflows/bkit-plan.md +12 -5
- package/.bkit/core/workflows/bkit-ship.md +6 -6
- 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 +15 -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/cleanup/bkit-tmp-prune.mjs +115 -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 +67 -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 +60 -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 +55 -49
- package/dist/commands/lib.js +32 -10
- package/dist/commands/tips.js +6 -3
- package/dist/commands/workflow/branches.js +57 -13
- 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 +16 -4
- 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 +19 -18
- 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/bkit-latest.js +150 -0
- 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/dist/shared/timeouts.js +6 -0
- package/package.json +21 -17
- package/.bkit/core/.agents/shortcuts.md +0 -73
|
@@ -21,16 +21,22 @@
|
|
|
21
21
|
import * as fs from "node:fs";
|
|
22
22
|
import * as path from "node:path";
|
|
23
23
|
import * as readline from "node:readline";
|
|
24
|
+
import { isJsonObject } from "../../install/write.js";
|
|
24
25
|
import { stripManagedBlock, detectMarkerStyle } from "../../install/managed-block.js";
|
|
25
26
|
import { readTemplate } from "../../render/parts.js";
|
|
26
27
|
import { getInstallManifest, ISSUE_TRACKERS, } from "../../install/manifest.js";
|
|
27
28
|
import { OPENCODE_PROVIDERS } from "../../shared/egress.js";
|
|
28
|
-
import {
|
|
29
|
-
import {
|
|
29
|
+
import { parseJson } from "../../shared/json.js";
|
|
30
|
+
import { hashFile, isConsumerModified, mergeCanonicalHashes, readBkitVersion, writeBkitVersion, } from "../../install/version-file.js";
|
|
31
|
+
import { getBkitDocsRoot, getPkgRoot, getSharedRoot, findTemplateSource, TEMPLATE_COPIES_DIR, } from "../../shared/package-roots.js";
|
|
30
32
|
import { PAYLOAD_LINKS } from "../../install/payload-links.js";
|
|
31
|
-
import { removeOpencodeProviderBlock, renderOpencodeJson } from "../../install/modules/opencode.js";
|
|
33
|
+
import { removeOpencodeProviderBlock, renderOpencodeAgentsCommands, renderOpencodeJson, } from "../../install/modules/opencode.js";
|
|
34
|
+
import { applyModelOverrides, buildOpencodeModelLookup, parseEffortMap, } from "../../render/models.js";
|
|
35
|
+
import { readInstallingVersion } from "../../shared/package-json.js";
|
|
36
|
+
import { readBkitConfig } from "../../shared/settings.js";
|
|
32
37
|
import { CLAUDE_CLOUD_RELPATH, CURSOR_CLOUD_RELPATH, resolveClaudeDerivedAllows, } from "../../install/cloud-env.js";
|
|
33
38
|
import { LOG_PREFIX, setLogPrefix } from "../../shared/log-prefix.js";
|
|
39
|
+
import { unusedTrackerMcpServers } from "../../checks/before/mcp.js";
|
|
34
40
|
// ---------------------------------------------------------------------------
|
|
35
41
|
// stripTier2JsonScope — remove bkit-owned JSON scope from consumer doc (BAR-167 Phase 1)
|
|
36
42
|
//
|
|
@@ -57,13 +63,8 @@ import { LOG_PREFIX, setLogPrefix } from "../../shared/log-prefix.js";
|
|
|
57
63
|
* leaf like any Tier-2 JSON file. Reads only the template.
|
|
58
64
|
*/
|
|
59
65
|
export function stripOpencodeJsonScope(consumer, templatePath, cwd) {
|
|
60
|
-
const render = (tracker, provider) =>
|
|
61
|
-
const ownedMcp =
|
|
62
|
-
for (const tracker of ISSUE_TRACKERS) {
|
|
63
|
-
const { mcp } = render(tracker, OPENCODE_PROVIDERS[0]);
|
|
64
|
-
if (isJsonObject(mcp))
|
|
65
|
-
Object.assign(ownedMcp, mcp);
|
|
66
|
-
}
|
|
66
|
+
const render = (tracker, provider) => renderOpencodeDoc(templatePath, tracker, provider, cwd);
|
|
67
|
+
const ownedMcp = ownedOpencodeMcpEntries(templatePath, cwd);
|
|
67
68
|
const ownedProviders = {};
|
|
68
69
|
for (const provider of OPENCODE_PROVIDERS) {
|
|
69
70
|
const rendered = render("none", provider).provider;
|
|
@@ -78,6 +79,19 @@ export function stripOpencodeJsonScope(consumer, templatePath, cwd) {
|
|
|
78
79
|
removeOwnedEntries(out, "provider", ownedProviders);
|
|
79
80
|
return stripTier2JsonScope(out, rest);
|
|
80
81
|
}
|
|
82
|
+
function renderOpencodeDoc(templatePath, tracker, provider, cwd) {
|
|
83
|
+
return JSON.parse(renderOpencodeJson(templatePath, tracker, provider, cwd));
|
|
84
|
+
}
|
|
85
|
+
/** Every tracker's `mcp` entry exactly as bkit renders it into `.opencode/opencode.json`. */
|
|
86
|
+
function ownedOpencodeMcpEntries(templatePath, cwd) {
|
|
87
|
+
const owned = {};
|
|
88
|
+
for (const tracker of ISSUE_TRACKERS) {
|
|
89
|
+
const { mcp } = renderOpencodeDoc(templatePath, tracker, OPENCODE_PROVIDERS[0], cwd);
|
|
90
|
+
if (isJsonObject(mcp))
|
|
91
|
+
Object.assign(owned, mcp);
|
|
92
|
+
}
|
|
93
|
+
return owned;
|
|
94
|
+
}
|
|
81
95
|
export function stripTier2JsonScope(consumerDoc, templateDoc) {
|
|
82
96
|
const out = JSON.parse(JSON.stringify(consumerDoc));
|
|
83
97
|
_stripScope(out, templateDoc);
|
|
@@ -144,21 +158,87 @@ export function stripMcpTrackerEntries(consumer, template) {
|
|
|
144
158
|
}
|
|
145
159
|
/**
|
|
146
160
|
* Delete each entry of `doc[key]` identical to the same-named entry in `owned`, then drop
|
|
147
|
-
* `doc[key]` once empty. Entries that differ, and names `owned`
|
|
161
|
+
* `doc[key]` once empty (unless `dropEmpty` is false). Entries that differ, and names `owned`
|
|
162
|
+
* lacks, stay. Mutates `doc`; returns the names deleted.
|
|
148
163
|
*/
|
|
149
|
-
function removeOwnedEntries(doc, key, owned) {
|
|
164
|
+
function removeOwnedEntries(doc, key, owned, dropEmpty = true) {
|
|
150
165
|
const entries = doc[key];
|
|
151
166
|
if (!isJsonObject(entries))
|
|
152
|
-
return;
|
|
167
|
+
return [];
|
|
168
|
+
const removed = [];
|
|
153
169
|
for (const [name, entry] of Object.entries(owned)) {
|
|
154
|
-
if (JSON.stringify(entries[name]) === JSON.stringify(entry))
|
|
170
|
+
if (name in entries && JSON.stringify(entries[name]) === JSON.stringify(entry)) {
|
|
155
171
|
delete entries[name];
|
|
172
|
+
removed.push(name);
|
|
173
|
+
}
|
|
156
174
|
}
|
|
157
|
-
if (Object.keys(entries).length === 0)
|
|
175
|
+
if (dropEmpty && Object.keys(entries).length === 0)
|
|
158
176
|
delete doc[key];
|
|
177
|
+
return removed;
|
|
159
178
|
}
|
|
160
|
-
|
|
161
|
-
|
|
179
|
+
/** The files bkit writes a tracker MCP entry into, and the key of each one's server map. */
|
|
180
|
+
const TRACKER_MCP_FILES = [
|
|
181
|
+
{ relPath: ".mcp.json", mapKey: "mcpServers" },
|
|
182
|
+
{ relPath: path.join(".cursor", "mcp.json"), mapKey: "mcpServers" },
|
|
183
|
+
{ relPath: path.join(".opencode", "opencode.json"), mapKey: "mcp" },
|
|
184
|
+
];
|
|
185
|
+
/**
|
|
186
|
+
* Tracker switch: remove each `unusedTrackerMcpServers(tracker)` entry from `.mcp.json`,
|
|
187
|
+
* `.cursor/mcp.json` and `.opencode/opencode.json` while it still equals bkit's template entry
|
|
188
|
+
* — the rule uninstall applies (`removeOwnedEntries`). An entry the consumer edited stays and
|
|
189
|
+
* is named in a warning. `.mcp.json` / `.cursor/mcp.json` keep an emptied `mcpServers` (the
|
|
190
|
+
* tracker-`none` render); `.opencode/opencode.json` drops an emptied `mcp`, as its render does.
|
|
191
|
+
* Absent and malformed files are skipped (the host module reports malformed JSON). Pushes each
|
|
192
|
+
* rewritten file onto `ws` and returns its path.
|
|
193
|
+
*/
|
|
194
|
+
export function removeUnusedTrackerMcpEntries(cwd, tracker, dryRun, ws, logPrefix) {
|
|
195
|
+
const unused = unusedTrackerMcpServers(tracker);
|
|
196
|
+
const written = [];
|
|
197
|
+
for (const { relPath, mapKey } of TRACKER_MCP_FILES) {
|
|
198
|
+
const absPath = path.join(cwd, relPath);
|
|
199
|
+
const templatePath = findTemplateSource(relPath);
|
|
200
|
+
if (unused.length === 0 || templatePath === null || !fs.existsSync(absPath))
|
|
201
|
+
continue;
|
|
202
|
+
const parsed = parseJson(fs.readFileSync(absPath, "utf-8"));
|
|
203
|
+
const doc = parsed.ok ? parsed.value : null;
|
|
204
|
+
if (!isJsonObject(doc))
|
|
205
|
+
continue;
|
|
206
|
+
const servers = doc[mapKey];
|
|
207
|
+
if (!isJsonObject(servers))
|
|
208
|
+
continue;
|
|
209
|
+
let templateEntries;
|
|
210
|
+
if (mapKey === "mcp") {
|
|
211
|
+
templateEntries = ownedOpencodeMcpEntries(templatePath, cwd);
|
|
212
|
+
}
|
|
213
|
+
else {
|
|
214
|
+
const template = parseJson(fs.readFileSync(templatePath, "utf-8"));
|
|
215
|
+
const templateDoc = template.ok ? template.value : null;
|
|
216
|
+
templateEntries = isJsonObject(templateDoc) ? templateDoc[mapKey] : undefined;
|
|
217
|
+
}
|
|
218
|
+
if (!isJsonObject(templateEntries))
|
|
219
|
+
continue;
|
|
220
|
+
const owned = {};
|
|
221
|
+
for (const name of unused) {
|
|
222
|
+
if (name in servers && name in templateEntries)
|
|
223
|
+
owned[name] = templateEntries[name];
|
|
224
|
+
}
|
|
225
|
+
const removed = removeOwnedEntries(doc, mapKey, owned, mapKey === "mcp");
|
|
226
|
+
for (const name of Object.keys(owned).filter((n) => !removed.includes(n))) {
|
|
227
|
+
console.warn(`${logPrefix} kept ${relPath} ${mapKey}.${name}: edited since bkit wrote it, and the ` +
|
|
228
|
+
`${tracker} tracker does not use it — remove it by hand if unneeded.`);
|
|
229
|
+
}
|
|
230
|
+
if (removed.length === 0)
|
|
231
|
+
continue;
|
|
232
|
+
if (!dryRun)
|
|
233
|
+
fs.writeFileSync(absPath, JSON.stringify(doc, null, 2) + "\n", "utf-8");
|
|
234
|
+
ws.writes.push({ path: absPath, action: "update" });
|
|
235
|
+
written.push(absPath);
|
|
236
|
+
for (const name of removed) {
|
|
237
|
+
console.log(`${logPrefix} ${dryRun ? "[dry-run] " : ""}removed ${relPath} ${mapKey}.${name} ` +
|
|
238
|
+
`(the ${tracker} tracker does not use it)`);
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
return written;
|
|
162
242
|
}
|
|
163
243
|
// ---------------------------------------------------------------------------
|
|
164
244
|
// Decision table builder (for --dry-run output and UninstallResult)
|
|
@@ -176,8 +256,9 @@ const CORE_TEMPLATE_DOCTRINE = [
|
|
|
176
256
|
{ path: ".agents/context.md", format: "markered-text", module: "core" },
|
|
177
257
|
{ path: ".agents/docs.md", format: "markered-text", module: "core" },
|
|
178
258
|
{ path: ".agents/rules.md", format: "markered-text", module: "core" },
|
|
179
|
-
{ path: ".agents/shortcuts.md", format: "markered-text", module: "core" },
|
|
180
259
|
{ path: ".agents/skills.md", format: "markered-text", module: "core" },
|
|
260
|
+
// Retired path of `.bkit/lite.md` (5.1.0 – 5.2.4), for an install never upgraded since.
|
|
261
|
+
{ path: ".agents/shortcuts.md", format: "markered-text", module: "core" },
|
|
181
262
|
];
|
|
182
263
|
/**
|
|
183
264
|
* The top-level `docs/*.md` the core payload pass installs: each carries bkit's managed
|
|
@@ -466,12 +547,18 @@ export async function runUninstall(modules, ctx) {
|
|
|
466
547
|
break;
|
|
467
548
|
}
|
|
468
549
|
const raw = fs.readFileSync(absPath, "utf-8");
|
|
469
|
-
const
|
|
550
|
+
const consumerParsed = parseJson(raw);
|
|
551
|
+
if (!consumerParsed.ok)
|
|
552
|
+
throw new Error(`${summary.file} is not valid JSON`);
|
|
553
|
+
const consumerDoc = consumerParsed.value;
|
|
470
554
|
const templateRaw = fs.readFileSync(templatePath, "utf-8");
|
|
471
555
|
// opencode.json ships `@@OPENCODE_*@@` sentinel KEYS; stripOpencodeJsonScope
|
|
472
556
|
// renders them for every tracker and provider bkit can have written.
|
|
473
557
|
const isOpencodeJson = templateRaw.includes("@@OPENCODE_TRACKER_MCP@@");
|
|
474
|
-
const
|
|
558
|
+
const templateParsed = parseJson(templateRaw);
|
|
559
|
+
if (!templateParsed.ok)
|
|
560
|
+
throw new Error(`${templatePath} is not valid JSON`);
|
|
561
|
+
const templateDoc = templateParsed.value;
|
|
475
562
|
// `.claude/settings.json` is not written verbatim: after rendering the
|
|
476
563
|
// template, install appends one `WebFetch(domain:<d>)` grant per entry in
|
|
477
564
|
// the resolved network allowlist and `mcp__…` grants per declared MCP
|
|
@@ -801,14 +888,8 @@ export async function runSurgicalOpencodeUninstall(providerKey, dryRun, cwd) {
|
|
|
801
888
|
let newActive = null;
|
|
802
889
|
if (fs.existsSync(pkgPath)) {
|
|
803
890
|
const raw = fs.readFileSync(pkgPath, "utf-8");
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
try {
|
|
807
|
-
pkg = JSON.parse(raw);
|
|
808
|
-
}
|
|
809
|
-
catch {
|
|
810
|
-
pkg = null;
|
|
811
|
-
}
|
|
891
|
+
const parsed = parseJson(raw);
|
|
892
|
+
const pkg = parsed.ok ? parsed.value : null;
|
|
812
893
|
if (pkg === null) {
|
|
813
894
|
console.warn(`${LOG_PREFIX} package.json is malformed — skipping bkit section update`);
|
|
814
895
|
return;
|
|
@@ -853,11 +934,64 @@ export async function runSurgicalOpencodeUninstall(providerKey, dryRun, cwd) {
|
|
|
853
934
|
});
|
|
854
935
|
return;
|
|
855
936
|
}
|
|
856
|
-
// 4. If was active →
|
|
937
|
+
// 4. If was active → re-render the agent pins for the new active provider, so `bkit check`
|
|
938
|
+
// finds the mirrors in sync right after.
|
|
857
939
|
if (wasActive && newActive !== null) {
|
|
858
|
-
|
|
859
|
-
|
|
940
|
+
if (dryRun) {
|
|
941
|
+
console.log(`${LOG_PREFIX}${tag} active provider would switch to "${newActive}" — .opencode/agents/ ` +
|
|
942
|
+
`would be re-rendered to its model pins.`);
|
|
943
|
+
return;
|
|
944
|
+
}
|
|
945
|
+
const previousCwd = process.cwd();
|
|
946
|
+
process.chdir(cwd);
|
|
947
|
+
try {
|
|
948
|
+
const written = rerenderOpencodeMirrors(newActive, LOG_PREFIX);
|
|
949
|
+
console.log(`${LOG_PREFIX} active provider switched to "${newActive}" — re-rendered ` +
|
|
950
|
+
`${written.length} .opencode/ agent/command file(s) to its model pins.`);
|
|
951
|
+
}
|
|
952
|
+
finally {
|
|
953
|
+
process.chdir(previousCwd);
|
|
954
|
+
}
|
|
955
|
+
}
|
|
956
|
+
}
|
|
957
|
+
/**
|
|
958
|
+
* Re-render `.opencode/agents/` + `.opencode/commands/` for `provider` — the per-agent model
|
|
959
|
+
* pins `bkit check` expects once `provider` is the active one, consumer `.bkit/prompts.md`
|
|
960
|
+
* § Model Overrides applied — and refresh their `.bkit/version` hashes. Renders into
|
|
961
|
+
* process.cwd(), as the host renderers resolve consumer paths from it. Returns the paths written.
|
|
962
|
+
*/
|
|
963
|
+
function rerenderOpencodeMirrors(provider, logPrefix) {
|
|
964
|
+
const cwd = process.cwd();
|
|
965
|
+
const promptsMd = path.join(getBkitDocsRoot(), "prompts.md");
|
|
966
|
+
const opencodeModelLookup = buildOpencodeModelLookup(promptsMd, provider);
|
|
967
|
+
applyModelOverrides(opencodeModelLookup, provider, path.join(cwd, ".bkit", "prompts.md"));
|
|
968
|
+
const written = renderOpencodeAgentsCommands({
|
|
969
|
+
dryRun: false,
|
|
970
|
+
tokens: { DEFAULT_BRANCH: "", PROJECT_NAME: "", REPO_SLUG: "" },
|
|
971
|
+
modelLookup: new Map(),
|
|
972
|
+
opencodeModelLookup,
|
|
973
|
+
effortMap: parseEffortMap(promptsMd),
|
|
974
|
+
opencodeProvider: provider,
|
|
975
|
+
advisories: [],
|
|
976
|
+
ws: { writes: [] },
|
|
977
|
+
logPrefix,
|
|
978
|
+
postDispatch: [],
|
|
979
|
+
issueTracker: readBkitConfig(cwd).issueTracker,
|
|
980
|
+
version: readInstallingVersion(),
|
|
981
|
+
});
|
|
982
|
+
const versionFile = path.join(cwd, ".bkit", "version");
|
|
983
|
+
const existing = readBkitVersion(versionFile);
|
|
984
|
+
if (existing && written.length > 0) {
|
|
985
|
+
const fresh = {};
|
|
986
|
+
for (const rel of written) {
|
|
987
|
+
const hash = hashFile(path.join(cwd, rel));
|
|
988
|
+
if (hash)
|
|
989
|
+
fresh[rel] = hash;
|
|
990
|
+
}
|
|
991
|
+
const { canonicalHashes } = mergeCanonicalHashes(cwd, existing.canonicalHashes, fresh);
|
|
992
|
+
writeBkitVersion(versionFile, { ...existing, canonicalHashes });
|
|
860
993
|
}
|
|
994
|
+
return written;
|
|
861
995
|
}
|
|
862
996
|
export async function runUninstallCommand(modules, opencodeProvider, uninstallFlags) {
|
|
863
997
|
setLogPrefix("[bkit-uninstall]");
|
|
@@ -25,15 +25,19 @@ import { writeTier2, writeTier2JsonContained } from "../../install/write.js";
|
|
|
25
25
|
import { detectMarkerStyle } from "../../install/managed-block.js";
|
|
26
26
|
import { applyTokens, resolveTokens } from "../../install/placeholders.js";
|
|
27
27
|
import { readTemplate } from "../../render/parts.js";
|
|
28
|
-
import { TEMPLATE_COPIES_DIR, getCoreRoot, getSharedRoot, getBkitDocsRoot,
|
|
29
|
-
import {
|
|
28
|
+
import { TEMPLATE_COPIES_DIR, getCoreRoot, getSharedRoot, getBkitDocsRoot, } from "../../shared/package-roots.js";
|
|
29
|
+
import { readDependencySpec, readInstallingVersion } from "../../shared/package-json.js";
|
|
30
|
+
import { requireOpencodeProvider, detectOpencodeProviders, runUpgradeAdvisories, } from "./install.js";
|
|
30
31
|
import { setLogPrefix } from "../../shared/log-prefix.js";
|
|
31
|
-
import {
|
|
32
|
+
import { BKIT_PACKAGE, lookupLatestPublished } from "../../shared/bkit-latest.js";
|
|
33
|
+
import { PACKAGE_RUNNER } from "../../shared/package-manager.js";
|
|
34
|
+
import { getInstallManifest, getModuleManifest, } from "../../install/manifest.js";
|
|
32
35
|
import { OPTIN_MODULES } from "../../install/manifest.js";
|
|
36
|
+
import { readBkitConfig } from "../../shared/settings.js";
|
|
33
37
|
import { detectInstalledHostModules } from "../../install/hosts.js";
|
|
34
38
|
import { detectInstalledModules } from "./check.js";
|
|
35
39
|
import { remapTemplateDest } from "../../install/template-copies.js";
|
|
36
|
-
import { CLAUDE_CLOUD_RELPATH, CURSOR_CLOUD_RELPATH, writeClaudeCloudDoc, writeCursorCloudDoc,
|
|
40
|
+
import { CLAUDE_CLOUD_RELPATH, CURSOR_CLOUD_RELPATH, writeClaudeCloudDoc, writeCursorCloudDoc, writeCursorCliPermissionsArtifact, } from "../../install/cloud-env.js";
|
|
37
41
|
import { syncTemplateCopies, formatTemplateChanges } from "../../install/template-copies.js";
|
|
38
42
|
import { formatPayloadLinkChanges, syncPayloadLinks } from "../../install/payload-links.js";
|
|
39
43
|
import { renderOpencodeJson, reconcileOpencodeJson } from "../../install/modules/opencode.js";
|
|
@@ -57,12 +61,25 @@ const EMPTY_TOKENS = {
|
|
|
57
61
|
// ---------------------------------------------------------------------------
|
|
58
62
|
/** Accepts X.Y.Z with an optional prerelease tag (e.g. 4.1.5, 4.2.0-rc.1). */
|
|
59
63
|
const SELF_BUMP_SEMVER_RE = /^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?$/;
|
|
64
|
+
/**
|
|
65
|
+
* True when a `package.json` dependency spec resolves from the registry: a version, range or
|
|
66
|
+
* dist-tag. `file:` / `link:` / `workspace:` / `npm:` alias / git / URL / path specs are not.
|
|
67
|
+
*/
|
|
68
|
+
export function isRegistrySpec(spec) {
|
|
69
|
+
const s = spec.trim();
|
|
70
|
+
return !/[:/\\]/.test(s) && !s.startsWith(".");
|
|
71
|
+
}
|
|
60
72
|
/**
|
|
61
73
|
* Resolve the self-bump target and decide the action. `resolveLatest` is only
|
|
62
74
|
* invoked for `--latest` (it shells out to the registry in production); injected
|
|
63
75
|
* so tests stay offline. A leading `v` is tolerated on either source.
|
|
76
|
+
*
|
|
77
|
+
* `installedSpec` is the consumer `package.json` spec for @cbartens/bkit (`null` when
|
|
78
|
+
* undeclared). A matching version string is a no-op only when that spec resolves from the
|
|
79
|
+
* registry: a `file:` tarball or other non-registry install at the same version still bumps,
|
|
80
|
+
* so `pnpm add` replaces it with the published package.
|
|
64
81
|
*/
|
|
65
|
-
export function planSelfBump(installed, flags, resolveLatest) {
|
|
82
|
+
export function planSelfBump(installed, flags, resolveLatest, installedSpec = null) {
|
|
66
83
|
let target;
|
|
67
84
|
if (flags.toVersion !== null) {
|
|
68
85
|
target = flags.toVersion.trim().replace(/^v/, "");
|
|
@@ -82,9 +99,11 @@ export function planSelfBump(installed, flags, resolveLatest) {
|
|
|
82
99
|
};
|
|
83
100
|
}
|
|
84
101
|
}
|
|
85
|
-
if (target
|
|
102
|
+
if (target !== installed.trim().replace(/^v/, ""))
|
|
103
|
+
return { kind: "bump", target };
|
|
104
|
+
if (installedSpec === null || isRegistrySpec(installedSpec))
|
|
86
105
|
return { kind: "noop", target };
|
|
87
|
-
return { kind: "bump", target };
|
|
106
|
+
return { kind: "bump", target, fromSpec: installedSpec };
|
|
88
107
|
}
|
|
89
108
|
export const LOG_PREFIX = "[bkit-upgrade]";
|
|
90
109
|
export function diffFile(relPath, absolutePath, templateContent, canonicalHashes) {
|
|
@@ -294,7 +313,7 @@ export function updateCanonicalHashesAfterUpgrade(result, options) {
|
|
|
294
313
|
const seedablePaths = new Set([...result.updated, ...result.skippedSeedable]);
|
|
295
314
|
const fresh = {};
|
|
296
315
|
for (const relPath of seedablePaths) {
|
|
297
|
-
// Exclude .agents/ internal files (docs.md,
|
|
316
|
+
// Exclude .agents/ internal files (docs.md, rules.md,
|
|
298
317
|
// skills.md, .env.example etc.) from canonicalHashes — they are not consumer-facing files
|
|
299
318
|
// whose hashes bkit uses for drift detection. Mirrors the same filter applied
|
|
300
319
|
// in the install path (install/modules/index.ts postDispatch). Template copies carry no
|
|
@@ -339,16 +358,15 @@ export function updateCanonicalHashesAfterUpgrade(result, options) {
|
|
|
339
358
|
* registry auth). Hard-exits with guidance on failure — the caller has nothing
|
|
340
359
|
* to fall back to.
|
|
341
360
|
*/
|
|
342
|
-
|
|
343
|
-
const
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
`(pnpm view exit ${r.status ?? "null"}). Check your network / registry access, ` +
|
|
361
|
+
function resolveLatestPublishedVersion(cwd) {
|
|
362
|
+
const latest = lookupLatestPublished(cwd, null);
|
|
363
|
+
if (latest === null) {
|
|
364
|
+
console.error(`${LOG_PREFIX} could not resolve the latest ${BKIT_PACKAGE} version from the registry ` +
|
|
365
|
+
`(pnpm view failed). Check your network / registry access, ` +
|
|
348
366
|
`or pin a version with --to=<version>.`);
|
|
349
367
|
process.exit(1);
|
|
350
368
|
}
|
|
351
|
-
return
|
|
369
|
+
return latest;
|
|
352
370
|
}
|
|
353
371
|
/**
|
|
354
372
|
* Atomic self-bump for `bkit upgrade --to=<v>` / `--latest`: install the target
|
|
@@ -361,11 +379,10 @@ async function resolveLatestPublishedVersion(cwd) {
|
|
|
361
379
|
* caller falls through to a normal in-place re-render.
|
|
362
380
|
*/
|
|
363
381
|
export async function runSelfBump(flags, cwd) {
|
|
364
|
-
const installed =
|
|
365
|
-
//
|
|
366
|
-
|
|
367
|
-
const
|
|
368
|
-
const resolvedPlan = planSelfBump(installed, { toVersion: flags.toVersion, latest: flags.latest }, () => latestVersion);
|
|
382
|
+
const installed = readInstallingVersion();
|
|
383
|
+
// Resolve the latest first (only when asked), then feed planSelfBump a constant.
|
|
384
|
+
const latestVersion = flags.latest ? resolveLatestPublishedVersion(cwd) : "";
|
|
385
|
+
const resolvedPlan = planSelfBump(installed, { toVersion: flags.toVersion, latest: flags.latest }, () => latestVersion, readDependencySpec(cwd, BKIT_PACKAGE));
|
|
369
386
|
if (resolvedPlan.kind === "invalid") {
|
|
370
387
|
console.error(`${LOG_PREFIX} ${resolvedPlan.message}`);
|
|
371
388
|
process.exit(1);
|
|
@@ -389,16 +406,17 @@ export async function runSelfBump(flags, cwd) {
|
|
|
389
406
|
...(inWorkspaceRoot ? ["-w"] : []),
|
|
390
407
|
`@cbartens/bkit@${resolvedPlan.target}`,
|
|
391
408
|
];
|
|
392
|
-
const addCmd =
|
|
409
|
+
const addCmd = [PACKAGE_RUNNER, ...addArgs].join(" ");
|
|
410
|
+
const from = resolvedPlan.fromSpec ? `${installed} (${resolvedPlan.fromSpec})` : installed;
|
|
393
411
|
if (flags.dryRun) {
|
|
394
|
-
console.log(`${LOG_PREFIX} [dry-run] would bump @cbartens/bkit ${
|
|
412
|
+
console.log(`${LOG_PREFIX} [dry-run] would bump @cbartens/bkit ${from} -> ${resolvedPlan.target} ` +
|
|
395
413
|
`(${addCmd}), then re-render + re-pin via the ` +
|
|
396
414
|
`freshly-installed binary. No changes made.`);
|
|
397
415
|
return true;
|
|
398
416
|
}
|
|
399
417
|
const { spawnSync } = await import("node:child_process");
|
|
400
|
-
console.log(`${LOG_PREFIX} bumping @cbartens/bkit ${
|
|
401
|
-
const add = spawnSync(
|
|
418
|
+
console.log(`${LOG_PREFIX} bumping @cbartens/bkit ${from} -> ${resolvedPlan.target} ...`);
|
|
419
|
+
const add = spawnSync(PACKAGE_RUNNER, addArgs, {
|
|
402
420
|
cwd,
|
|
403
421
|
stdio: "inherit",
|
|
404
422
|
});
|
|
@@ -412,7 +430,7 @@ export async function runSelfBump(flags, cwd) {
|
|
|
412
430
|
const reArgs = ["exec", "bkit", "upgrade"];
|
|
413
431
|
if (flags.nonInteractive)
|
|
414
432
|
reArgs.push("--auto-apply");
|
|
415
|
-
const re = spawnSync(
|
|
433
|
+
const re = spawnSync(PACKAGE_RUNNER, reArgs, { cwd, stdio: "inherit" });
|
|
416
434
|
process.exit(re.status ?? 1);
|
|
417
435
|
}
|
|
418
436
|
export async function runUpgradeCommand(upgradeFlags) {
|
|
@@ -427,6 +445,8 @@ export async function runUpgradeCommand(upgradeFlags) {
|
|
|
427
445
|
if (handled)
|
|
428
446
|
return;
|
|
429
447
|
}
|
|
448
|
+
// Read before any write: a damaged bkit package stops the run with nothing changed.
|
|
449
|
+
const installingVersion = readInstallingVersion();
|
|
430
450
|
console.log(`${LOG_PREFIX} Running upgrade${upgradeFlags.dryRun ? " (dry-run)" : ""}${upgradeFlags.nonInteractive ? " (non-interactive)" : ""}`);
|
|
431
451
|
// Collect bkit-managed payload candidates from the package: `shared/` and
|
|
432
452
|
// `core/` hold every file install writes. `templates/` is excluded — it is
|
|
@@ -465,16 +485,7 @@ export async function runUpgradeCommand(upgradeFlags) {
|
|
|
465
485
|
const installedModules = detectInstalledModules(process.cwd());
|
|
466
486
|
// Resolve the consumer's tracker so upgrade renders tracker-conditional files
|
|
467
487
|
// (opencode.json, the mcp.json files) the same way install does.
|
|
468
|
-
|
|
469
|
-
try {
|
|
470
|
-
const pkg = JSON.parse(fs.readFileSync(path.join(process.cwd(), "package.json"), "utf-8"));
|
|
471
|
-
const stored = parseIssueTracker(pkg.bkit?.issueTracker);
|
|
472
|
-
if (stored !== null)
|
|
473
|
-
upgradeTracker = stored;
|
|
474
|
-
}
|
|
475
|
-
catch {
|
|
476
|
-
// package.json absent/unparseable — default tracker
|
|
477
|
-
}
|
|
488
|
+
const upgradeTracker = readBkitConfig(process.cwd()).issueTracker;
|
|
478
489
|
// opencode.json is provider/tracker-templated on install (renderOpencodeJson resolves the
|
|
479
490
|
// `@@OPENCODE_*@@` sentinels). Upgrade renders it the same way, with the installed
|
|
480
491
|
// provider, so no raw sentinel key reaches the consumer's config.
|
|
@@ -678,7 +689,7 @@ export async function runUpgradeCommand(upgradeFlags) {
|
|
|
678
689
|
cloudVariant: null,
|
|
679
690
|
// Re-stamp every rendered agent + command at the version we are upgrading TO,
|
|
680
691
|
// so a clean upgrade refreshes the managed-version marker and `bkit check` stays green.
|
|
681
|
-
version:
|
|
692
|
+
version: installingVersion,
|
|
682
693
|
// The detected host set — read by the Antigravity module for the Codex-overlap advisory.
|
|
683
694
|
installedModules: renderModules,
|
|
684
695
|
};
|
|
@@ -723,20 +734,17 @@ export async function runUpgradeCommand(upgradeFlags) {
|
|
|
723
734
|
}
|
|
724
735
|
}
|
|
725
736
|
// Network allowlist + MCP allows — OpenCode from renderOpencodeJson; Claude enrich
|
|
726
|
-
// below;
|
|
727
|
-
// module installed. Written artifacts get their
|
|
737
|
+
// below; `.bkit/allowlist.json` in renderManagedOutputs above; Cursor
|
|
738
|
+
// `.cursor/cli.json` only when cursor module installed. Written artifacts get their
|
|
739
|
+
// canonicalHashes refreshed below.
|
|
728
740
|
const artifactWrites = [];
|
|
729
741
|
{
|
|
730
742
|
const cwd = process.cwd();
|
|
731
743
|
if (renderModules.has("cursor")) {
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
if (art.wrote) {
|
|
737
|
-
artifactWrites.push(art.path);
|
|
738
|
-
console.log(`${LOG_PREFIX}${upgradeFlags.dryRun ? " [dry-run]" : ""} upgrade: ${art.path}`);
|
|
739
|
-
}
|
|
744
|
+
const art = writeCursorCliPermissionsArtifact(cwd, upgradeFlags.dryRun);
|
|
745
|
+
if (art.wrote) {
|
|
746
|
+
artifactWrites.push(art.path);
|
|
747
|
+
console.log(`${LOG_PREFIX}${upgradeFlags.dryRun ? " [dry-run]" : ""} upgrade: ${art.path}`);
|
|
740
748
|
}
|
|
741
749
|
}
|
|
742
750
|
if (renderModules.has("claude") && fs.existsSync(path.join(cwd, ".claude", "settings.json"))) {
|
|
@@ -755,8 +763,6 @@ export async function runUpgradeCommand(upgradeFlags) {
|
|
|
755
763
|
// exit), so feed those writes into canonicalHashes — keeping install/upgrade `.bkit/version`
|
|
756
764
|
// parity.
|
|
757
765
|
if (!upgradeFlags.dryRun) {
|
|
758
|
-
const pkgVersion = JSON.parse(fs.readFileSync(path.join(getPkgRoot(), "package.json"), "utf-8"))
|
|
759
|
-
.version;
|
|
760
766
|
const renderedDocPaths = renderWs.writes.map((w) => path.relative(process.cwd(), path.isAbsolute(w.path) ? w.path : path.resolve(process.cwd(), w.path)));
|
|
761
767
|
updateCanonicalHashesAfterUpgrade({
|
|
762
768
|
updated: [
|
|
@@ -771,7 +777,7 @@ export async function runUpgradeCommand(upgradeFlags) {
|
|
|
771
777
|
}, {
|
|
772
778
|
dryRun: false,
|
|
773
779
|
cwd: process.cwd(),
|
|
774
|
-
pinnedVersion:
|
|
780
|
+
pinnedVersion: installingVersion,
|
|
775
781
|
claudeAllowDerived: upgradeClaudeAllowDerived,
|
|
776
782
|
});
|
|
777
783
|
}
|
package/dist/commands/lib.js
CHANGED
|
@@ -3,9 +3,9 @@
|
|
|
3
3
|
// Flag parsing, one JSON object on stdout, `[bkit-<noun>]`-tagged logs on stderr,
|
|
4
4
|
// the exit-code table, `--help` rendering, and the repo facts several workflow
|
|
5
5
|
// steps each re-derived by hand: repo root, UTC month, where `status.jsonl` lives,
|
|
6
|
-
//
|
|
7
|
-
// in its spec; `--help` and the convention test both read
|
|
8
|
-
// text cannot drift from what the command accepts.
|
|
6
|
+
// the skip-CI tokens, and which branches are shared. A command declares its flags,
|
|
7
|
+
// output keys and exit codes in its spec; `--help` and the convention test both read
|
|
8
|
+
// that spec, so the help text cannot drift from what the command accepts.
|
|
9
9
|
import { spawnSync } from "node:child_process";
|
|
10
10
|
import * as fs from "node:fs";
|
|
11
11
|
import * as os from "node:os";
|
|
@@ -253,13 +253,29 @@ export async function runCommand(argv, commands, options) {
|
|
|
253
253
|
// ---------------------------------------------------------------------------
|
|
254
254
|
// Repo facts
|
|
255
255
|
// ---------------------------------------------------------------------------
|
|
256
|
+
/** Captured stdout / stderr cap for `runGit` / `runTool`; hook output (pre-push) counts. */
|
|
257
|
+
const OUTPUT_LIMIT = 1 << 26;
|
|
258
|
+
/** Spawn error as a stderr lead line: ENOBUFS names the limit, anything else Node's message. */
|
|
259
|
+
function spawnErrorText(cmd, args, err) {
|
|
260
|
+
return err.code === "ENOBUFS"
|
|
261
|
+
? `${cmd} ${args[0] ?? ""}: output passed the ${OUTPUT_LIMIT / (1 << 20)} MiB limit (ENOBUFS)`
|
|
262
|
+
: err.message;
|
|
263
|
+
}
|
|
256
264
|
/** `git <args>` in `cwd`, never throwing: exit status plus trimmed stdout / stderr. */
|
|
257
265
|
export function runGit(cwd, args) {
|
|
258
|
-
const res = spawnSync("git", args, {
|
|
266
|
+
const res = spawnSync("git", args, {
|
|
267
|
+
cwd,
|
|
268
|
+
encoding: "utf-8",
|
|
269
|
+
env: gitEnv(),
|
|
270
|
+
maxBuffer: OUTPUT_LIMIT,
|
|
271
|
+
});
|
|
272
|
+
const stderr = (res.stderr ?? "").trim();
|
|
259
273
|
return {
|
|
260
|
-
ok: res.status === 0,
|
|
274
|
+
ok: !res.error && res.status === 0,
|
|
261
275
|
stdout: (res.stdout ?? "").trim(),
|
|
262
|
-
stderr:
|
|
276
|
+
stderr: res.error
|
|
277
|
+
? [spawnErrorText("git", args, res.error), stderr].filter(Boolean).join("\n")
|
|
278
|
+
: stderr,
|
|
263
279
|
};
|
|
264
280
|
}
|
|
265
281
|
/** `git <args>` in `cwd`; stdout trimmed, or null on a non-zero exit. */
|
|
@@ -271,6 +287,8 @@ export function git(cwd, args) {
|
|
|
271
287
|
// Shared with the files that are not commands (checks, install): re-exported here
|
|
272
288
|
// for the command modules that already import it from this module.
|
|
273
289
|
export { parseJson } from "../shared/json.js";
|
|
290
|
+
// The shared-branch rule (`dev`, `main`) lives in shared/ so checks can read it too.
|
|
291
|
+
export { DEV, isSharedBranch } from "../shared/branches.js";
|
|
274
292
|
/**
|
|
275
293
|
* Run a tool other than git, never throwing. Hook-exported GIT_* vars are scrubbed
|
|
276
294
|
* so gh and friends answer for `cwd`; `input` goes to stdin.
|
|
@@ -281,16 +299,20 @@ export function runTool(cmd, args, cwd, opts = {}) {
|
|
|
281
299
|
encoding: "utf-8",
|
|
282
300
|
env: gitEnv(),
|
|
283
301
|
input: opts.input,
|
|
284
|
-
maxBuffer:
|
|
302
|
+
maxBuffer: OUTPUT_LIMIT,
|
|
285
303
|
});
|
|
286
|
-
if (res.error) {
|
|
304
|
+
if (res.error && res.pid === 0) {
|
|
287
305
|
return { found: false, status: 127, stdout: "", stderr: `${cmd} not found on PATH` };
|
|
288
306
|
}
|
|
307
|
+
const status = res.status ?? 128 + signalNumber(res.signal);
|
|
289
308
|
return {
|
|
290
309
|
found: true,
|
|
291
|
-
|
|
310
|
+
// A spawn error is never a success: the child can exit 0 before ENOBUFS kills it.
|
|
311
|
+
status: res.error && status === 0 ? 1 : status,
|
|
292
312
|
stdout: res.stdout ?? "",
|
|
293
|
-
stderr: res.
|
|
313
|
+
stderr: res.error
|
|
314
|
+
? [spawnErrorText(cmd, args, res.error), res.stderr ?? ""].filter(Boolean).join("\n")
|
|
315
|
+
: (res.stderr ?? ""),
|
|
294
316
|
};
|
|
295
317
|
}
|
|
296
318
|
const signalNumber = (signal) => (signal ? os.constants.signals[signal] : undefined) ?? 1;
|
package/dist/commands/tips.js
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
// commands/tips.ts — `bkit tips [--workflow=<name>] [--all]`: print the setup tips that
|
|
2
2
|
// apply to this repo. Each workflow passes its name at its close and gets the one tip that
|
|
3
|
-
// matters most there
|
|
4
|
-
//
|
|
3
|
+
// matters most there (`audit` / `utility` for the audit agent and the ledger / roadmap
|
|
4
|
+
// updaters); bare `bkit tips` prints the top three. The star line closes bare and phase
|
|
5
|
+
// output unless `star` is in `bkit.ignoreAdvisories`. Local checks only, no network; prints
|
|
6
|
+
// nothing when no tip fires and no star line shows; exits 0.
|
|
5
7
|
import { collectTips, formatTips } from "../checks/tips/index.js";
|
|
6
8
|
export function runTipsCommand(all, workflow, cwd = process.cwd()) {
|
|
7
|
-
const
|
|
9
|
+
const { tips, star } = collectTips(cwd);
|
|
10
|
+
const output = formatTips(tips, { all, workflow, star });
|
|
8
11
|
if (output)
|
|
9
12
|
console.log(output);
|
|
10
13
|
}
|