@cbartens/bkit 5.0.3 → 5.2.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 +14 -10
- package/.bkit/core/.agents/docs.md +1 -0
- package/.bkit/core/.agents/plugins/bkit/hooks/bkit-gateguard.cjs +93 -0
- package/.bkit/core/.agents/plugins/bkit/hooks/bkit-guardrails.cjs +137 -0
- package/.bkit/core/.agents/plugins/bkit/hooks/bkit-readguard.cjs +72 -0
- package/.bkit/core/.agents/rules.md +10 -6
- package/.bkit/core/.agents/shortcuts.md +73 -0
- package/.bkit/core/.agents/skills.md +5 -3
- package/.bkit/core/.bkit/LICENSE.md +18 -140
- package/.bkit/core/.bkit/README.md +13 -9
- package/.bkit/core/.bkit/cloud.md +12 -15
- package/.bkit/core/.bkit/comparison.md +68 -16
- package/.bkit/core/.bkit/install.md +36 -11
- package/.bkit/core/.bkit/jsonl.md +0 -1
- package/.bkit/core/.bkit/prompts.md +83 -81
- package/.bkit/core/.bkit/providers.md +110 -28
- package/.bkit/core/.bkit/templates.md +42 -13
- package/.bkit/core/.bkit/workflows.md +64 -42
- package/.bkit/core/.claude/hooks/bkit-gateguard.cjs +4 -3
- package/.bkit/core/.claude/hooks/bkit-readguard.cjs +60 -0
- package/.bkit/core/.codex/hooks/bkit-gateguard.cjs +8 -6
- package/.bkit/core/.codex/hooks/bkit-readguard.cjs +58 -0
- package/.bkit/core/.cursor/hooks/bkit-guardrails.cjs +12 -19
- package/.bkit/core/.cursor/hooks/bkit-readguard.cjs +59 -0
- package/.bkit/core/.opencode/plugin/bkit-gateguard.js +73 -22
- package/.bkit/core/.opencode/plugin/bkit-readguard.js +126 -0
- package/.bkit/core/AGENTS.md +11 -0
- package/.bkit/core/docs/templates/bkit-audit-adoption.md +2 -2
- package/.bkit/core/docs/templates/bkit-plan.md +6 -3
- package/.bkit/core/engine/checks/after/auth.ts +32 -0
- package/.bkit/core/engine/checks/after/github.ts +4 -4
- package/.bkit/core/engine/checks/after/index.ts +36 -50
- package/.bkit/core/engine/checks/after/managed.ts +44 -1
- package/.bkit/core/engine/checks/before/index.ts +5 -4
- package/.bkit/core/engine/checks/before/mcp.ts +60 -54
- package/.bkit/core/engine/checks/status-holes.ts +1 -1
- package/.bkit/core/engine/checks/tips/catalogue.ts +356 -0
- package/.bkit/core/engine/checks/tips/detect.ts +144 -0
- package/.bkit/core/engine/checks/tips/index.ts +174 -0
- package/.bkit/core/engine/cli.ts +82 -18
- package/.bkit/core/engine/commands/install/check.ts +2 -0
- package/.bkit/core/engine/commands/install/doctor.ts +14 -1
- package/.bkit/core/engine/commands/install/install.ts +59 -9
- package/.bkit/core/engine/commands/install/uninstall.ts +59 -34
- package/.bkit/core/engine/commands/install/upgrade.ts +30 -28
- package/.bkit/core/engine/commands/launch.ts +33 -11
- package/.bkit/core/engine/commands/tips.ts +16 -0
- package/.bkit/core/engine/commands/workflow/prs.ts +20 -2
- package/.bkit/core/engine/commands/workflow/runs.ts +82 -18
- package/.bkit/core/engine/commands/workflow/runtime.ts +12 -0
- package/.bkit/core/engine/commands/workflow/steps.ts +1 -0
- package/.bkit/core/engine/commands/workflow/tests.ts +647 -4
- package/.bkit/core/engine/commands/workflow/workstreams.ts +4 -4
- package/.bkit/core/engine/install/cloud-env.ts +7 -21
- package/.bkit/core/engine/install/hosts.ts +21 -0
- package/.bkit/core/engine/install/managed-block.ts +36 -0
- package/.bkit/core/engine/install/manifest.ts +83 -5
- package/.bkit/core/engine/install/modules/antigravity.ts +266 -0
- package/.bkit/core/engine/install/modules/claude.ts +6 -6
- package/.bkit/core/engine/install/modules/cloud.ts +2 -2
- package/.bkit/core/engine/install/modules/codex.ts +8 -5
- package/.bkit/core/engine/install/modules/core.ts +30 -10
- package/.bkit/core/engine/install/modules/cursor.ts +6 -6
- package/.bkit/core/engine/install/modules/index.ts +33 -6
- package/.bkit/core/engine/install/modules/opencode.ts +4 -4
- package/.bkit/core/engine/install/payload-links.ts +6 -10
- package/.bkit/core/engine/install/placeholders.ts +1 -1
- package/.bkit/core/engine/install/version-file.ts +17 -9
- package/.bkit/core/engine/install/write.ts +68 -1
- package/.bkit/core/engine/ledgers/telemetry.ts +0 -2
- package/.bkit/core/engine/render/hosts.ts +174 -1
- package/.bkit/core/engine/render/models.ts +10 -0
- package/.bkit/core/engine/shared/package-roots.ts +8 -10
- package/.bkit/core/hooks/antigravity-hook.js +67 -0
- package/.bkit/core/hooks/gateguard-edit-payload.js +4 -4
- package/.bkit/core/hooks/gateguard-engine.js +16 -6
- package/.bkit/core/hooks/guardrails-read.js +23 -0
- package/.bkit/core/hooks/readguard-engine.js +259 -0
- package/.bkit/core/hooks/readguard-payload.js +67 -0
- package/.bkit/core/prompts/bkit-audit-generate.md +2 -1
- package/.bkit/core/prompts/bkit-build-challenge-1.md +2 -1
- package/.bkit/core/prompts/bkit-build-challenge-2.md +2 -1
- package/.bkit/core/prompts/bkit-build-challenge-reconcile.md +2 -1
- package/.bkit/core/prompts/bkit-build-challenge-remediate.md +2 -1
- package/.bkit/core/prompts/bkit-build-challenge-tests.md +2 -1
- package/.bkit/core/prompts/bkit-build-install-skills.md +7 -5
- package/.bkit/core/prompts/bkit-build-plan-current.md +2 -1
- package/.bkit/core/prompts/bkit-build-plan-execute.md +6 -2
- package/.bkit/core/prompts/bkit-build-plan-gaps-remediate.md +2 -1
- package/.bkit/core/prompts/bkit-build-plan-verify.md +12 -4
- package/.bkit/core/prompts/bkit-build-summary.md +2 -1
- package/.bkit/core/prompts/bkit-debug-abort-handover.md +2 -1
- package/.bkit/core/prompts/bkit-debug-failure-diagnose.md +2 -1
- package/.bkit/core/prompts/bkit-debug-failure-remediate.md +2 -1
- package/.bkit/core/prompts/bkit-debug-failure-soak.md +2 -1
- package/.bkit/core/prompts/bkit-debug-summary.md +2 -1
- package/.bkit/core/prompts/bkit-design-brainstorm-ideate-1.md +2 -1
- package/.bkit/core/prompts/bkit-design-brainstorm-ideate-2.md +2 -1
- package/.bkit/core/prompts/bkit-design-brainstorm-ideate-3.md +2 -1
- package/.bkit/core/prompts/bkit-design-generate.md +10 -5
- package/.bkit/core/prompts/bkit-design-organise.md +2 -1
- package/.bkit/core/prompts/bkit-design-review-1.md +2 -1
- package/.bkit/core/prompts/bkit-design-review-2.md +2 -1
- package/.bkit/core/prompts/bkit-design-spike.md +2 -1
- package/.bkit/core/prompts/bkit-design-summary.md +2 -1
- package/.bkit/core/prompts/bkit-design-update.md +2 -1
- package/.bkit/core/prompts/bkit-plan-complexity-check.md +2 -1
- package/.bkit/core/prompts/bkit-plan-complexity-split.md +4 -3
- package/.bkit/core/prompts/bkit-plan-generate.md +2 -1
- package/.bkit/core/prompts/bkit-plan-review-1.md +2 -1
- package/.bkit/core/prompts/bkit-plan-review-2.md +2 -1
- package/.bkit/core/prompts/bkit-plan-review-3.md +2 -1
- package/.bkit/core/prompts/bkit-plan-scope-check-1.md +3 -2
- package/.bkit/core/prompts/bkit-plan-scope-check-2.md +3 -2
- package/.bkit/core/prompts/bkit-plan-summary.md +2 -1
- package/.bkit/core/prompts/bkit-plan-update.md +3 -2
- package/.bkit/core/prompts/bkit-ship-conflict-resolve.md +2 -1
- package/.bkit/core/prompts/bkit-ship-deferred-sweep.md +2 -1
- package/.bkit/core/prompts/bkit-ship-summary.md +2 -1
- package/.bkit/core/prompts/bkit-ship-update-docs.md +2 -1
- package/.bkit/core/prompts/bkit-utility-compress-markdown.md +2 -1
- package/.bkit/core/prompts/bkit-utility-update-decisions.md +2 -1
- package/.bkit/core/prompts/bkit-utility-update-deferrals.md +2 -1
- package/.bkit/core/prompts/bkit-utility-update-documentation.md +2 -1
- package/.bkit/core/prompts/bkit-utility-update-failures.md +2 -1
- package/.bkit/core/prompts/bkit-utility-update-knowledge.md +2 -1
- package/.bkit/core/prompts/bkit-utility-update-roadmap.md +4 -3
- package/.bkit/core/workflows/bkit-auto.md +1 -1
- package/.bkit/core/workflows/bkit-build.md +35 -21
- package/.bkit/core/workflows/bkit-debug.md +31 -22
- package/.bkit/core/workflows/bkit-design.md +83 -38
- package/.bkit/core/workflows/bkit-plan.md +10 -2
- package/.bkit/core/workflows/bkit-ship.md +10 -2
- package/.bkit/shared/.agents/plugins/bkit/hooks.json +36 -0
- package/.bkit/shared/.agents/plugins/bkit/plugin.json +5 -0
- package/.bkit/shared/.claude/settings.json +19 -0
- package/.bkit/shared/.codex/hooks.json +21 -0
- package/.bkit/shared/.cursor/hooks.json +6 -1
- package/.bkit/shared/.opencode/opencode.json +1 -1
- package/.bkit/shared/GEMINI.md +11 -0
- package/.bkit/shared/docs/deployments.md +1 -1
- package/.bkit/shared/docs/security.md +3 -3
- package/.bkit/shared/docs/testing.md +12 -1
- package/.bkit/templates/.github/dependabot.yml +6 -0
- package/.bkit/templates/.github/renovate.json5 +3 -3
- package/.bkit/templates/.github/workflows/bkit-ci.yml +24 -13
- package/.bkit/templates/.github/workflows/bkit-cloud.yml +5 -5
- package/.bkit/templates/.prettierignore +4 -1
- package/.bkit/templates/context/bkit-expo.md +22 -13
- package/.bkit/templates/context/bkit-github.md +20 -6
- package/.bkit/templates/context/bkit-inngest.md +10 -4
- package/.bkit/templates/context/bkit-maestro.md +5 -5
- package/.bkit/templates/context/bkit-playwright.md +3 -3
- package/.bkit/templates/context/bkit-sentry.md +6 -5
- package/.bkit/templates/context/bkit-stripe.md +31 -8
- package/.bkit/templates/scripts/ci/check-accepted-divergences.mjs +65 -19
- package/.bkit/templates/scripts/ci/check-accepted-divergences.test.mjs +34 -0
- package/.bkit/templates/scripts/ci/lanes/resolve-push-base.mjs +33 -12
- package/.bkit/templates/scripts/ci/lanes/resolve-push-base.test.mjs +54 -0
- package/.bkit/templates/scripts/graphify/bkit-graph-pre-push.sh +2 -2
- package/.bkit/templates/scripts/launchd/bkit-launchd-env.sh +76 -6
- package/.bkit/templates/slop-scan.config.json +10 -3
- package/CHANGELOG.md +62 -0
- package/LICENSE.md +21 -161
- package/README.md +66 -35
- package/dist/checks/after/auth.js +28 -0
- package/dist/checks/after/github.js +4 -4
- package/dist/checks/after/index.js +29 -45
- package/dist/checks/after/managed.js +41 -1
- package/dist/checks/before/index.js +5 -4
- package/dist/checks/before/mcp.js +53 -53
- package/dist/checks/status-holes.js +1 -1
- package/dist/checks/tips/catalogue.js +297 -0
- package/dist/checks/tips/detect.js +130 -0
- package/dist/checks/tips/index.js +146 -0
- package/dist/cli.js +68 -17
- package/dist/commands/install/check.js +2 -0
- package/dist/commands/install/doctor.js +9 -1
- package/dist/commands/install/install.js +49 -8
- package/dist/commands/install/uninstall.js +61 -34
- package/dist/commands/install/upgrade.js +31 -33
- package/dist/commands/launch.js +27 -11
- package/dist/commands/tips.js +10 -0
- package/dist/commands/workflow/prs.js +13 -1
- package/dist/commands/workflow/runs.js +74 -18
- package/dist/commands/workflow/runtime.js +8 -0
- package/dist/commands/workflow/steps.js +1 -0
- package/dist/commands/workflow/tests.js +541 -4
- package/dist/commands/workflow/workstreams.js +4 -4
- package/dist/install/cloud-env.js +3 -14
- package/dist/install/hosts.js +22 -0
- package/dist/install/managed-block.js +36 -0
- package/dist/install/manifest.js +79 -4
- package/dist/install/modules/antigravity.js +225 -0
- package/dist/install/modules/claude.js +6 -6
- package/dist/install/modules/cloud.js +2 -2
- package/dist/install/modules/codex.js +8 -5
- package/dist/install/modules/core.js +21 -6
- package/dist/install/modules/cursor.js +6 -6
- package/dist/install/modules/index.js +17 -6
- package/dist/install/modules/opencode.js +4 -4
- package/dist/install/payload-links.js +5 -5
- package/dist/install/placeholders.js +1 -1
- package/dist/install/version-file.js +12 -3
- package/dist/install/write.js +61 -2
- package/dist/render/hosts.js +149 -1
- package/dist/render/models.js +9 -0
- package/dist/shared/package-roots.js +8 -11
- package/package.json +8 -8
- package/.bkit/core/LICENSE.md +0 -149
- package/.bkit/shared/LICENSE.md +0 -22
- package/.bkit/templates/LICENSE.md +0 -22
|
@@ -13,14 +13,8 @@ import {
|
|
|
13
13
|
} from "../before/env.js";
|
|
14
14
|
import { getPkgRoot } from "../../shared/package-roots.js";
|
|
15
15
|
import { detectOpencodeYmlProviderDrift } from "../../install/modules/opencode.js";
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
18
|
-
import {
|
|
19
|
-
buildCloudDashboardsAdvisory,
|
|
20
|
-
detectCiRouterSecrets,
|
|
21
|
-
detectShellGhMcpToken,
|
|
22
|
-
hasGithubMcpServer,
|
|
23
|
-
} from "./auth.js";
|
|
16
|
+
import { detectManagedDuplicate, detectManagedStale } from "./managed.js";
|
|
17
|
+
import { buildCloudDashboardsAdvisory, detectCiRouterSecrets, detectGhMcpToken } from "./auth.js";
|
|
24
18
|
import {
|
|
25
19
|
buildCloudSetupAdvisory,
|
|
26
20
|
buildGithubProjectAdvisory,
|
|
@@ -48,6 +42,12 @@ import {
|
|
|
48
42
|
detectTurboIntegrationInputs,
|
|
49
43
|
} from "./ci-yml.js";
|
|
50
44
|
import { type SuppressionNote, type SuppressionReporter } from "./suppression.js";
|
|
45
|
+
import {
|
|
46
|
+
dropTipSilencedAdvisories,
|
|
47
|
+
setupTipsChecklistLines,
|
|
48
|
+
setupTipsMarkdownLines,
|
|
49
|
+
} from "../tips/index.js";
|
|
50
|
+
import type { SetupTip } from "../tips/catalogue.js";
|
|
51
51
|
|
|
52
52
|
// ---------------------------------------------------------------------------
|
|
53
53
|
// formatChecklist — pure renderer
|
|
@@ -90,26 +90,27 @@ export function suppressedNoteLines(suppressed: SuppressionNote[]): string[] {
|
|
|
90
90
|
|
|
91
91
|
/**
|
|
92
92
|
* Format a list of findings into the post-install console checklist.
|
|
93
|
-
* Returns `""` when findings
|
|
94
|
-
* stay silent. No console.log inside — caller logs.
|
|
93
|
+
* Returns `""` when findings, suppressed and tips are all empty — callers can `if (banner)`
|
|
94
|
+
* to stay silent. No console.log inside — caller logs.
|
|
95
95
|
*
|
|
96
|
-
* Same content as `renderAdvisoriesMarkdown`: title, summary, agent instructions
|
|
97
|
-
*
|
|
98
|
-
* the markdown form.
|
|
96
|
+
* Same content as `renderAdvisoriesMarkdown`: title, summary, agent instructions and
|
|
97
|
+
* setup tips are the shared strings; only the separators differ from the markdown form.
|
|
99
98
|
*
|
|
100
99
|
* Format per finding:
|
|
101
100
|
* --- i/N [severity] id ---
|
|
102
101
|
* Detect: ...
|
|
103
102
|
* Action: ...
|
|
104
103
|
*
|
|
105
|
-
* `
|
|
106
|
-
* advisory stays visible even when
|
|
104
|
+
* `tips` follow the findings as the Setup tips block; `suppressed` is appended as its own
|
|
105
|
+
* block (see `suppressedNoteLines`) — a dismissed advisory or tip stays visible even when
|
|
106
|
+
* nothing else fired.
|
|
107
107
|
*/
|
|
108
108
|
export function formatChecklist(
|
|
109
109
|
findings: PreflightFinding[],
|
|
110
110
|
suppressed: SuppressionNote[] = [],
|
|
111
|
+
tips: readonly SetupTip[] = [],
|
|
111
112
|
): string {
|
|
112
|
-
if (findings.length === 0 && suppressed.length === 0) return "";
|
|
113
|
+
if (findings.length === 0 && suppressed.length === 0 && tips.length === 0) return "";
|
|
113
114
|
|
|
114
115
|
const banner = "=".repeat(58);
|
|
115
116
|
const total = findings.length;
|
|
@@ -125,8 +126,6 @@ export function formatChecklist(
|
|
|
125
126
|
lines.push("");
|
|
126
127
|
lines.push(ADVISORIES_AGENT_INSTRUCTIONS);
|
|
127
128
|
lines.push("");
|
|
128
|
-
lines.push(TEMPLATES_POINTER);
|
|
129
|
-
lines.push("");
|
|
130
129
|
}
|
|
131
130
|
|
|
132
131
|
for (let i = 0; i < findings.length; i++) {
|
|
@@ -137,6 +136,8 @@ export function formatChecklist(
|
|
|
137
136
|
lines.push("");
|
|
138
137
|
}
|
|
139
138
|
|
|
139
|
+
lines.push(...setupTipsChecklistLines(tips));
|
|
140
|
+
|
|
140
141
|
const suppressedLines = suppressedNoteLines(suppressed);
|
|
141
142
|
if (suppressedLines.length > 0) {
|
|
142
143
|
lines.push(...suppressedLines);
|
|
@@ -158,13 +159,14 @@ export type AdvisoriesMode = "install" | "check" | "doctor";
|
|
|
158
159
|
/**
|
|
159
160
|
* Render findings as a markdown artifact suitable for `.bkit/advisories.md`.
|
|
160
161
|
* Renders the SAME content as `formatChecklist` (shared title, summary, agent
|
|
161
|
-
* instructions,
|
|
162
|
+
* instructions, setup tips and suppressed block) in markdown form, so the file can
|
|
162
163
|
* be referenced and revisited between installs. Overwritten on every run.
|
|
163
164
|
*/
|
|
164
165
|
export function renderAdvisoriesMarkdown(
|
|
165
166
|
findings: PreflightFinding[],
|
|
166
167
|
opts: { mode: AdvisoriesMode; version: string },
|
|
167
168
|
suppressed: SuppressionNote[] = [],
|
|
169
|
+
tips: readonly SetupTip[] = [],
|
|
168
170
|
): string {
|
|
169
171
|
const lines: string[] = [];
|
|
170
172
|
// This is a generated, gitignored artifact — not authored prose. Advisory
|
|
@@ -184,7 +186,7 @@ export function renderAdvisoriesMarkdown(
|
|
|
184
186
|
);
|
|
185
187
|
lines.push("");
|
|
186
188
|
|
|
187
|
-
if (findings.length === 0 && suppressed.length === 0) {
|
|
189
|
+
if (findings.length === 0 && suppressed.length === 0 && tips.length === 0) {
|
|
188
190
|
lines.push("**No advisories.** Last run was clean.");
|
|
189
191
|
lines.push("");
|
|
190
192
|
return lines.join("\n");
|
|
@@ -195,8 +197,6 @@ export function renderAdvisoriesMarkdown(
|
|
|
195
197
|
lines.push("");
|
|
196
198
|
lines.push(`> ${ADVISORIES_AGENT_INSTRUCTIONS}`);
|
|
197
199
|
lines.push("");
|
|
198
|
-
lines.push(`> ${TEMPLATES_POINTER}`);
|
|
199
|
-
lines.push("");
|
|
200
200
|
}
|
|
201
201
|
|
|
202
202
|
const total = findings.length;
|
|
@@ -210,6 +210,8 @@ export function renderAdvisoriesMarkdown(
|
|
|
210
210
|
lines.push("");
|
|
211
211
|
}
|
|
212
212
|
|
|
213
|
+
lines.push(...setupTipsMarkdownLines(tips));
|
|
214
|
+
|
|
213
215
|
const suppressedLines = suppressedNoteLines(suppressed);
|
|
214
216
|
if (suppressedLines.length > 0) {
|
|
215
217
|
lines.push(...suppressedLines);
|
|
@@ -232,6 +234,7 @@ export function writeAdvisoriesArtifact(
|
|
|
232
234
|
version: string;
|
|
233
235
|
logPrefix: string;
|
|
234
236
|
suppressed?: SuppressionNote[];
|
|
237
|
+
tips?: readonly SetupTip[];
|
|
235
238
|
},
|
|
236
239
|
): void {
|
|
237
240
|
const dir = path.join(opts.cwd, ".bkit");
|
|
@@ -245,6 +248,7 @@ export function writeAdvisoriesArtifact(
|
|
|
245
248
|
version: opts.version,
|
|
246
249
|
},
|
|
247
250
|
opts.suppressed ?? [],
|
|
251
|
+
opts.tips ?? [],
|
|
248
252
|
);
|
|
249
253
|
fs.writeFileSync(filePath, content);
|
|
250
254
|
const n = findings.length;
|
|
@@ -350,32 +354,13 @@ export function runPostInstallCheck(
|
|
|
350
354
|
const managedStale = detectManagedStale(cwd);
|
|
351
355
|
if (managedStale) phase3.push(managedStale);
|
|
352
356
|
|
|
353
|
-
//
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
phase3.push({
|
|
361
|
-
id: "gh-mcp-token-unset-shell",
|
|
362
|
-
severity: "advisory",
|
|
363
|
-
detect:
|
|
364
|
-
"BKIT_GH_TOKEN is not set in the shell environment (undefined). The GitHub MCP server authenticates with `Authorization: Bearer ${BKIT_GH_TOKEN}` — without it, every tracker, PR, and board MCP call fails to connect.",
|
|
365
|
-
action:
|
|
366
|
-
"Set BKIT_GH_TOKEN in .bkit/.env (canonical local-secrets file, gitignored), then `direnv allow` and restart your editor so MCP servers pick it up:\n\n cp .bkit/.env.example .bkit/.env # if not already done\n # edit .bkit/.env — set BKIT_GH_TOKEN=<PAT>\n direnv allow\n\nUse a fine-grained PAT when every target repo sits under one owner (Contents, Pull requests, Issues, and Actions read & write, plus organization-scoped Projects read & write if you use board sync); use a classic PAT when one token must span owners (scopes repo / workflow / read:org / project / security_events). Generate at: https://github.com/settings/personal-access-tokens (fine-grained) or https://github.com/settings/tokens (classic). In cloud sessions (Claude Code web / Cursor Background Agents) set BKIT_GH_TOKEN in the dashboard env vars instead — repo files are not read for secrets there.",
|
|
367
|
-
});
|
|
368
|
-
} else if (ghMcpTokenStatus === "empty") {
|
|
369
|
-
phase3.push({
|
|
370
|
-
id: "gh-mcp-token-empty-shell",
|
|
371
|
-
severity: "advisory",
|
|
372
|
-
detect:
|
|
373
|
-
'BKIT_GH_TOKEN is set to an empty string (BKIT_GH_TOKEN=""). The GitHub MCP server sends an empty bearer token and fails to authenticate — distinct from unset, same effect.',
|
|
374
|
-
action:
|
|
375
|
-
"Set a non-empty BKIT_GH_TOKEN in .bkit/.env (fine-grained PAT for one owner, or classic across owners; Contents / Pull requests / Issues / Actions read & write), then `direnv allow` and restart your editor so MCP servers reload.",
|
|
376
|
-
});
|
|
377
|
-
}
|
|
378
|
-
}
|
|
357
|
+
// Older unmarked copy of a managed markdown block left outside its markers.
|
|
358
|
+
const managedDuplicate = detectManagedDuplicate(cwd);
|
|
359
|
+
if (managedDuplicate) phase3.push(managedDuplicate);
|
|
360
|
+
|
|
361
|
+
// BKIT_GH_TOKEN shell env — authenticates the GitHub MCP server.
|
|
362
|
+
const ghMcpToken = detectGhMcpToken(cwd);
|
|
363
|
+
if (ghMcpToken) phase3.push(ghMcpToken);
|
|
379
364
|
|
|
380
365
|
// Main branch protection — bkit's PR-base gates (build Step 17, ship Step 2)
|
|
381
366
|
// assert feat/* PRs target dev. Enforcing it at the GitHub layer needs branch
|
|
@@ -525,6 +510,7 @@ export function runPostInstallCheck(
|
|
|
525
510
|
const phase3Ids = new Set(deduped.map((f) => f.id));
|
|
526
511
|
const filteredPreflight = dedupedPreflight.filter((f) => !phase3Ids.has(f.id));
|
|
527
512
|
|
|
528
|
-
// Final order: preflight advisories (that weren't superseded) first, then Phase 3
|
|
529
|
-
|
|
513
|
+
// Final order: preflight advisories (that weren't superseded) first, then Phase 3.
|
|
514
|
+
// An advisory a setup tip reuses goes quiet with that tip (`bkit.ignoreAdvisories`).
|
|
515
|
+
return dropTipSilencedAdvisories([...filteredPreflight, ...deduped], cwd, onSuppressed);
|
|
530
516
|
}
|
|
@@ -11,8 +11,11 @@ import { readManagedVersion } from "../../install/version-file.js";
|
|
|
11
11
|
import { getPkgRoot } from "../../shared/package-roots.js";
|
|
12
12
|
import {
|
|
13
13
|
detectMarkerStyle,
|
|
14
|
+
extractManagedBlock,
|
|
14
15
|
findLineAnchoredMarkers,
|
|
16
|
+
findUnmarkedCopy,
|
|
15
17
|
selectMarkers,
|
|
18
|
+
stripManagedBlock,
|
|
16
19
|
} from "../../install/managed-block.js";
|
|
17
20
|
import { listStampedFiles } from "../../install/modules/index.js";
|
|
18
21
|
|
|
@@ -162,6 +165,43 @@ export function detectManagedStale(
|
|
|
162
165
|
};
|
|
163
166
|
}
|
|
164
167
|
|
|
168
|
+
// ---------------------------------------------------------------------------
|
|
169
|
+
// detectManagedDuplicate — an older unmarked copy kept beside a managed markdown block
|
|
170
|
+
// ---------------------------------------------------------------------------
|
|
171
|
+
|
|
172
|
+
/**
|
|
173
|
+
* Managed markdown blocks whose file also holds an older, unmarked copy of the block outside
|
|
174
|
+
* the markers (findUnmarkedCopy). Install never touches content outside the markers, so that
|
|
175
|
+
* copy stays at the version it was left at while agents read it beside the live block.
|
|
176
|
+
* Advisory: the match is a heuristic. Null when no stamped file has one.
|
|
177
|
+
*/
|
|
178
|
+
export function detectManagedDuplicate(cwd: string): PreflightFinding | null {
|
|
179
|
+
const copies: string[] = [];
|
|
180
|
+
for (const { path: rel, scope } of listStampedFiles(cwd)) {
|
|
181
|
+
if (scope !== "block" || !rel.endsWith(".md")) continue;
|
|
182
|
+
const abs = path.join(cwd, rel);
|
|
183
|
+
if (!fs.existsSync(abs)) continue;
|
|
184
|
+
const content = fs.readFileSync(abs, "utf-8");
|
|
185
|
+
const block = extractManagedBlock(content);
|
|
186
|
+
if (block === null) continue;
|
|
187
|
+
const title = findUnmarkedCopy(stripManagedBlock(content), block);
|
|
188
|
+
if (title === null) continue;
|
|
189
|
+
const lines = content.split("\n");
|
|
190
|
+
const start = lines.indexOf(selectMarkers("html-comment")[0]);
|
|
191
|
+
const end = lines.indexOf(selectMarkers("html-comment")[1]);
|
|
192
|
+
const line = lines.findIndex((l, i) => l === title && (i < start || i > end)) + 1;
|
|
193
|
+
copies.push(`${rel} (\`${title}\` at line ${line})`);
|
|
194
|
+
}
|
|
195
|
+
if (copies.length === 0) return null;
|
|
196
|
+
return {
|
|
197
|
+
id: "bkit-managed-duplicate",
|
|
198
|
+
severity: "advisory",
|
|
199
|
+
detect: `${copies.length} bkit-managed file(s) hold an older bkit copy outside their \`bkit:start\`/\`bkit:end\` block: ${copies.join(", ")}. Install never updates text outside the markers, so agents read that stale copy beside the live block.`,
|
|
200
|
+
action:
|
|
201
|
+
"In each file, delete the old copy: the run of lines starting at the named title line, up to `<!-- bkit:start -->` (or from just after `<!-- bkit:end -->` when the copy sits below). Keep any lines you wrote yourself by moving them below `<!-- bkit:end -->`. Then run `pnpm bkit check` again.",
|
|
202
|
+
};
|
|
203
|
+
}
|
|
204
|
+
|
|
165
205
|
// ---------------------------------------------------------------------------
|
|
166
206
|
// Owned hook files — `bkit check` fails when one is missing
|
|
167
207
|
// ---------------------------------------------------------------------------
|
|
@@ -174,11 +214,14 @@ export interface MissingOwnedHook {
|
|
|
174
214
|
}
|
|
175
215
|
|
|
176
216
|
/** Host modules whose manifest hook files a host config runs, and the flag that installs each. */
|
|
177
|
-
const HOOK_HOST_FLAGS: ReadonlyArray<
|
|
217
|
+
const HOOK_HOST_FLAGS: ReadonlyArray<
|
|
218
|
+
["claude" | "cursor" | "codex" | "opencode" | "antigravity", string]
|
|
219
|
+
> = [
|
|
178
220
|
["claude", "--claude"],
|
|
179
221
|
["cursor", "--cursor"],
|
|
180
222
|
["codex", "--codex"],
|
|
181
223
|
["opencode", "--opencode=<provider>"],
|
|
224
|
+
["antigravity", "--antigravity"],
|
|
182
225
|
];
|
|
183
226
|
|
|
184
227
|
/** Manifest paths a host runs as a hook: `.<host>/hooks/<file>` and `.opencode/plugin/<file>`. */
|
|
@@ -185,15 +185,16 @@ export function runPreflight(
|
|
|
185
185
|
const bkitNotOnPath = detectBkitNotOnPath();
|
|
186
186
|
if (bkitNotOnPath) advisories.push(bkitNotOnPath);
|
|
187
187
|
|
|
188
|
-
// Missing MCP server advisory — one finding per missing required key, per file
|
|
189
|
-
//
|
|
190
|
-
//
|
|
191
|
-
// Extra MCP server advisory — one finding per bkit-managed server that the
|
|
188
|
+
// Missing MCP server advisory — one finding per missing required key, per file: the
|
|
189
|
+
// resolved tracker's own server (none → nothing required), matching what install writes.
|
|
190
|
+
// Extra MCP server advisory — one finding per bkit-written tracker-only server that the
|
|
192
191
|
// resolved tracker does not use (e.g. a stale `linear` entry under `github`).
|
|
192
|
+
// opencode.json is drift-gated, so only the extra check runs there (map key `mcp`).
|
|
193
193
|
for (const relPath of [".mcp.json", ".cursor/mcp.json"]) {
|
|
194
194
|
advisories.push(...detectMissingMcpServers(cwd, relPath, resolvedTracker));
|
|
195
195
|
advisories.push(...detectExtraMcpServers(cwd, relPath, resolvedTracker));
|
|
196
196
|
}
|
|
197
|
+
advisories.push(...detectExtraMcpServers(cwd, ".opencode/opencode.json", resolvedTracker, "mcp"));
|
|
197
198
|
|
|
198
199
|
// [mcp-env] detectors run in Phase 3 (runPostInstallCheck in checks/after/index.ts),
|
|
199
200
|
// not here: the .bkit/.env.example scaffold exists only after writes. Detectors are
|
|
@@ -6,24 +6,47 @@ import { parseJson } from "../../shared/json.js";
|
|
|
6
6
|
import type { IssueTracker } from "../../install/manifest.js";
|
|
7
7
|
import type { PreflightFinding } from "./index.js";
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
// ---------------------------------------------------------------------------
|
|
9
|
+
/** Every MCP server key bkit writes; `requiredMcpServersForTracker` picks the required subset. */
|
|
10
|
+
const BKIT_MCP_SERVERS: readonly string[] = ["linear", "github"];
|
|
12
11
|
|
|
13
|
-
/**
|
|
14
|
-
|
|
12
|
+
/**
|
|
13
|
+
* bkit-written servers a workflow step calls under every tracker, so never flagged as extra:
|
|
14
|
+
* the workflows' gh MCP fallback (PR / CI / merge when `gh` is unavailable) calls `github`.
|
|
15
|
+
*/
|
|
16
|
+
const TRACKER_INDEPENDENT_MCP_SERVERS: readonly string[] = ["github"];
|
|
17
|
+
|
|
18
|
+
/** The key holding the server map: `mcpServers` in `.mcp.json` / `.cursor/mcp.json`, `mcp` in `.opencode/opencode.json`. */
|
|
19
|
+
export type McpServerMapKey = "mcpServers" | "mcp";
|
|
15
20
|
|
|
16
21
|
/**
|
|
17
|
-
* Return the MCP server keys required for a given issue tracker
|
|
18
|
-
*
|
|
19
|
-
* - `github` → only `github` MCP server required (Linear gate is a no-op on GitHub tracker).
|
|
20
|
-
* - `linear` → both `linear` and `github` required (Linear tracker still dispatches via GitHub PR).
|
|
21
|
-
* - `none` → `github` only (tracker calls are no-ops; GitHub surface still needed for PR ops).
|
|
22
|
+
* Return the MCP server keys required for a given issue tracker — exactly the entry the
|
|
23
|
+
* install renderers write: the tracker's own server (`none` → none).
|
|
22
24
|
*/
|
|
23
25
|
export function requiredMcpServersForTracker(tracker: IssueTracker): readonly string[] {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
26
|
+
return tracker === "none" ? [] : [tracker];
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Read the server map under `mapKey` of the JSON file at `relPath`.
|
|
31
|
+
* `undefined` → file absent or malformed (callers skip); `null` → file present, no map.
|
|
32
|
+
*/
|
|
33
|
+
function readMcpServerMap(
|
|
34
|
+
cwd: string,
|
|
35
|
+
relPath: string,
|
|
36
|
+
mapKey: McpServerMapKey,
|
|
37
|
+
): Record<string, unknown> | null | undefined {
|
|
38
|
+
const absPath = path.join(cwd, relPath);
|
|
39
|
+
if (!fs.existsSync(absPath)) return undefined;
|
|
40
|
+
const parsed = parseJson(fs.readFileSync(absPath, "utf-8"));
|
|
41
|
+
if (!parsed.ok || typeof parsed.value !== "object" || parsed.value === null) return undefined;
|
|
42
|
+
const map = (parsed.value as Record<string, unknown>)[mapKey];
|
|
43
|
+
return map !== null && typeof map === "object" && !Array.isArray(map)
|
|
44
|
+
? (map as Record<string, unknown>)
|
|
45
|
+
: null;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
function advisoryPathSlug(relPath: string): string {
|
|
49
|
+
return relPath.replace(/[^a-z0-9]/gi, "-");
|
|
27
50
|
}
|
|
28
51
|
|
|
29
52
|
/**
|
|
@@ -44,22 +67,11 @@ export function detectMissingMcpServers(
|
|
|
44
67
|
relPath: string,
|
|
45
68
|
issueTracker: IssueTracker,
|
|
46
69
|
): PreflightFinding[] {
|
|
47
|
-
const
|
|
48
|
-
if (
|
|
49
|
-
|
|
50
|
-
const parsed = parseJson(fs.readFileSync(absPath, "utf-8"));
|
|
51
|
-
if (!parsed.ok || typeof parsed.value !== "object" || parsed.value === null) return []; // malformed JSON — skip silently
|
|
52
|
-
const doc = parsed.value as Record<string, unknown>;
|
|
53
|
-
|
|
54
|
-
const mcpServers =
|
|
55
|
-
doc.mcpServers !== null && typeof doc.mcpServers === "object" && !Array.isArray(doc.mcpServers)
|
|
56
|
-
? (doc.mcpServers as Record<string, unknown>)
|
|
57
|
-
: null;
|
|
58
|
-
|
|
59
|
-
const requiredServers = requiredMcpServersForTracker(issueTracker);
|
|
70
|
+
const mcpServers = readMcpServerMap(cwd, relPath, "mcpServers");
|
|
71
|
+
if (mcpServers === undefined) return [];
|
|
60
72
|
|
|
61
73
|
const findings: PreflightFinding[] = [];
|
|
62
|
-
for (const key of
|
|
74
|
+
for (const key of requiredMcpServersForTracker(issueTracker)) {
|
|
63
75
|
if (mcpServers && Object.prototype.hasOwnProperty.call(mcpServers, key)) continue;
|
|
64
76
|
const urlHint =
|
|
65
77
|
key === "linear"
|
|
@@ -68,7 +80,7 @@ export function detectMissingMcpServers(
|
|
|
68
80
|
? `"url": "https://api.githubcopilot.com/mcp/"`
|
|
69
81
|
: `"url": "<server-url>"`;
|
|
70
82
|
findings.push({
|
|
71
|
-
id: `mcp-missing-server-${key}-${relPath
|
|
83
|
+
id: `mcp-missing-server-${key}-${advisoryPathSlug(relPath)}`,
|
|
72
84
|
severity: "advisory",
|
|
73
85
|
detect: `${relPath} is missing the ${key} MCP server in mcpServers.`,
|
|
74
86
|
action: `[mcp] ${relPath} is missing the ${key} MCP server. Add it to mcpServers: {"${key}": {${urlHint}}}`,
|
|
@@ -78,17 +90,21 @@ export function detectMissingMcpServers(
|
|
|
78
90
|
}
|
|
79
91
|
|
|
80
92
|
/**
|
|
81
|
-
* Advisory: one finding per bkit-
|
|
82
|
-
*
|
|
83
|
-
*
|
|
84
|
-
*
|
|
93
|
+
* Advisory: one finding per bkit-written MCP server that is present in the file but NOT
|
|
94
|
+
* required by the resolved tracker (the symmetric counterpart to `detectMissingMcpServers`).
|
|
95
|
+
* Catches the stale-leftover case — e.g. a repo switched to `--tracker=github` but still
|
|
96
|
+
* carrying the `linear` entry.
|
|
97
|
+
*
|
|
98
|
+
* Only flags tracker-only servers bkit itself writes (`BKIT_MCP_SERVERS` minus
|
|
99
|
+
* `TRACKER_INDEPENDENT_MCP_SERVERS`). Consumer-added MCP servers (custom tooling, other
|
|
100
|
+
* providers) are never flagged for removal.
|
|
85
101
|
*
|
|
86
|
-
*
|
|
87
|
-
*
|
|
102
|
+
* `mapKey` names the server map: `mcpServers` (`.mcp.json`, `.cursor/mcp.json`) or `mcp`
|
|
103
|
+
* (`.opencode/opencode.json`).
|
|
88
104
|
*
|
|
89
105
|
* Semantics:
|
|
90
|
-
* - File absent / malformed / no
|
|
91
|
-
* -
|
|
106
|
+
* - File absent / malformed / no server map → return []
|
|
107
|
+
* - tracker-only server present but not in `requiredMcpServersForTracker(tracker)` → one advisory
|
|
92
108
|
*
|
|
93
109
|
* Follows `[context] Message` advisory format.
|
|
94
110
|
*/
|
|
@@ -96,31 +112,21 @@ export function detectExtraMcpServers(
|
|
|
96
112
|
cwd: string,
|
|
97
113
|
relPath: string,
|
|
98
114
|
issueTracker: IssueTracker,
|
|
115
|
+
mapKey: McpServerMapKey = "mcpServers",
|
|
99
116
|
): PreflightFinding[] {
|
|
100
|
-
const
|
|
101
|
-
if (!
|
|
102
|
-
|
|
103
|
-
const parsed = parseJson(fs.readFileSync(absPath, "utf-8"));
|
|
104
|
-
if (!parsed.ok || typeof parsed.value !== "object" || parsed.value === null) return []; // malformed JSON — skip silently
|
|
105
|
-
const doc = parsed.value as Record<string, unknown>;
|
|
106
|
-
|
|
107
|
-
const mcpServers =
|
|
108
|
-
doc.mcpServers !== null && typeof doc.mcpServers === "object" && !Array.isArray(doc.mcpServers)
|
|
109
|
-
? (doc.mcpServers as Record<string, unknown>)
|
|
110
|
-
: null;
|
|
111
|
-
if (!mcpServers) return [];
|
|
117
|
+
const servers = readMcpServerMap(cwd, relPath, mapKey);
|
|
118
|
+
if (!servers) return [];
|
|
112
119
|
|
|
113
120
|
const allowed = requiredMcpServersForTracker(issueTracker);
|
|
114
121
|
const findings: PreflightFinding[] = [];
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
if (
|
|
118
|
-
if (!Object.prototype.hasOwnProperty.call(mcpServers, key)) continue;
|
|
122
|
+
for (const key of BKIT_MCP_SERVERS) {
|
|
123
|
+
if (allowed.includes(key) || TRACKER_INDEPENDENT_MCP_SERVERS.includes(key)) continue;
|
|
124
|
+
if (!Object.prototype.hasOwnProperty.call(servers, key)) continue;
|
|
119
125
|
findings.push({
|
|
120
|
-
id: `mcp-extra-server-${key}-${relPath
|
|
126
|
+
id: `mcp-extra-server-${key}-${advisoryPathSlug(relPath)}`,
|
|
121
127
|
severity: "advisory",
|
|
122
128
|
detect: `${relPath} has the ${key} MCP server but the ${issueTracker} tracker does not use it.`,
|
|
123
|
-
action: `[mcp] ${relPath} carries the ${key} MCP server, which is not used by the ${issueTracker} tracker. Remove the "${key}" entry from
|
|
129
|
+
action: `[mcp] ${relPath} carries the ${key} MCP server, which is not used by the ${issueTracker} tracker. Remove the "${key}" entry from ${mapKey}.`,
|
|
124
130
|
});
|
|
125
131
|
}
|
|
126
132
|
return findings;
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
//
|
|
3
3
|
// A fail-open advisory that compares the set of ship steps RECORDED in a
|
|
4
4
|
// status.jsonl against the set of steps the workflow PROSE says should be
|
|
5
|
-
// there. It derives its expected set from .bkit/workflows/bkit-ship.md at
|
|
5
|
+
// there. It derives its expected set from .bkit/core/workflows/bkit-ship.md at
|
|
6
6
|
// runtime (headings + step:"ship-*" literals) — NEVER a hand-maintained table
|
|
7
7
|
// (decision 384-tier3-promotion).
|
|
8
8
|
//
|