@cbartens/bkit 5.2.1 → 5.2.2

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  # bkit — Agent Workflow System
2
2
 
3
- <!-- bkit:managed v5.2.1 — do not edit; run `bkit upgrade` to refresh -->
3
+ <!-- bkit:managed v5.2.2 — do not edit; run `bkit upgrade` to refresh -->
4
4
 
5
5
  **bkit** wires Claude Code, Cursor, Codex, Google Antigravity and opencode into five-phase tracker-integrated cycle: `/bkit-design` → `/bkit-plan` → `/bkit-build` → `/bkit-debug` → `/bkit-ship`. Hosts additive, one flag each: `--claude`, `--cursor`, `--codex`, `--antigravity`, `--opencode=<provider>` — opencode providers: `openrouter`, `ollama`, `opencode-zen` + `opencode-go` (opencode-native gateways; auth via `BKIT_OPENCODE_API_KEY`). Same harness on every host; state lives in the repo, so a feature moves between hosts mid-run (see `.bkit/providers.md` § Hosts + Providers).
6
6
 
@@ -234,13 +234,16 @@ After writes, bkit re-runs credential and environment checks — some only accur
234
234
  | `opencode-setup` | opencode host installed (`--opencode=<provider>`) — names the provider key to set (e.g. `BKIT_OPENROUTER_API_KEY`; `BKIT_OPENCODE_API_KEY` for `opencode-zen` / `opencode-go`), confirms the pre-seeded base URL, and notes all four providers ship curated per-agent pins (re-pin via `.bkit/prompts.md` § Model Overrides). Verify with `bkit doctor` + `bkit status`. |
235
235
  | `vale-package-not-synced` | vale on PATH but `.vale/styles/write-good/` absent |
236
236
  | `gate-missing-called-scripts` | A `bkit:gate:*` script still at bkit's default chains a script `package.json` does not declare (e.g. `typecheck`, `format:check`, `test`). Add it (`.bkit/templates.md` lists the tool scripts and devDeps) or rewrite the gate. |
237
- | `gate-noop` | A `bkit:gate:*` script is empty or cannot fail (`true`, `:`, `exit 0`, `echo …`), so every agent run and push passes it. Warn-only, at install and `bkit check`, on every branch. Point it at real checks, or delete it and run `bkit upgrade` to restore bkit's default. |
237
+ | `gate-noop` | A `bkit:gate:*` script is empty or cannot fail (`true`, `:`, `exit 0`, `echo …`), so every agent run and push passes it. Warn-only, at install, `bkit check` and `bkit upgrade`, on every branch. Point it at real checks, or delete it and run `bkit upgrade` to restore bkit's default. |
238
238
  | `gate-tier-not-wired` | `package.json` declares a deeper test tier (`test:integration`, `test:e2e`, `test:live`) that no `bkit:gate:*` script runs; the advisory prints the gate line to add. |
239
+ | `test-file-script-missing` | `package.json` does not declare `bkit:test:file`, so `/bkit-build` reports test-first as not enforced. The advisory prints the script contract and a Vitest line. |
239
240
 
240
241
  Phase 1 and Phase 3 findings merged and deduplicated by `id` (Phase 3 wins on conflict — re-detection more accurate post-write). Zero findings → no banner.
241
242
 
242
243
  **`bkit check` (dry-run)** runs Phase 1 and Phase 3 (read-only) — same advisory set as `bkit install` minus writes. Changes no managed file (regenerates `.bkit/advisories.md` artifact) and **exits 1 when any managed-file write would occur** in installed module — Tier-2 JSON deep-containment or markered-block drift, whole-file byte-equal mismatch, **host agent/command mirror content drift** (would-write / orphan delete), or when any file bkit writes (rendered agents / commands / skills, managed blocks, owned whole files) carries a stale managed-version marker (`bkit-managed-stale`). Gate covers the **installed** module set ({core, claude, cursor, codex, antigravity} plus **opencode**, each detected by sentinel files). A missing `bkit:gate:*` name counts as a write. antigravity gated: `.agents/plugins/bkit/**` (plugin manifest, hooks, agents, skills) and root `GEMINI.md`. opencode gated: `.opencode/opencode.json` (provider block + the recorded tracker's `mcp` entry + permission sandbox; another tracker's leftover `mcp` entry is not drift — `mcp-extra-server-linear--opencode-opencode-json` advises removing it) and the `bkit-gateguard.js` / `bkit-readguard.js` plugins drift fail `check` — render inputs fall back to installed provider (`package.json` `bkit.opencodeProvider`, authoritative for `opencode-zen` / `opencode-go`; all installed providers tracked in `bkit.opencodeProviders: string[]`) and recorded tracker, so clean install across providers checks green (no false drift). Remaining **opt-in** module (cloud) is not drift-gated. A missing bkit-owned hook file also fails `check`, one line per file naming it and the `bkit install` flag that restores it: the hook files of every installed host (`.claude/hooks/*`, `.cursor/hooks/*`, `.codex/hooks/*`, `.agents/plugins/bkit/hooks/*`, `.opencode/plugin/bkit-gateguard.js`, `.opencode/plugin/bkit-readguard.js`) — the hook commands skip a missing file (`test -f … || true`), so without this the guard would be off with no signal. Updater configs are not bkit files, so `bkit check` does not report them. Phase 3 stays read-only through read-only detector paths, not by being skipped.
243
244
 
245
+ **`bkit upgrade`** (not `--dry-run`) ends with the same read-only pass as `bkit check`: prints the checklist and rewrites `.bkit/advisories.md` (`Mode: upgrade`). Drift and blockers it finds are reported only — upgrade's exit code is unchanged.
246
+
244
247
  **`PreflightFinding` shape** — stable contract for downstream tooling:
245
248
 
246
249
  ```typescript
@@ -328,7 +331,7 @@ bkit tips --all # every firing tip
328
331
  | Order | One fixed priority list. `--workflow=<name>` moves the tips that matter in that workflow to the front: tracker, GitHub token, `.bkit/.env` and direnv matter in every workflow, so they lead until fixed; then e.g. context-fetch for debug, Husky / slop-scan for build, CI workflow / cloud for ship. |
329
332
  | Detection | Local only — files, settings, environment; no network. A tip clears once its local half exists; dashboard steps live in the tip text. |
330
333
  | Reuse | A tip for a gap an advisory already detects calls that advisory's detector — tip and advisory never disagree. |
331
- | Artifact | `bkit install` / `check` / `doctor` list every firing tip, with its id, in `.bkit/advisories.md` § Setup tips and the console banner: line, why, caution, ask-your-agent sentence, agent steps. |
334
+ | Artifact | `bkit install` / `check` / `upgrade` / `doctor` list every firing tip, with its id, in `.bkit/advisories.md` § Setup tips and the console banner: line, why, caution, ask-your-agent sentence, agent steps. |
332
335
  | Silence | Root `package.json` `bkit.ignoreAdvisories`: a tip id, or an advisory id the tip reuses, silences the tip and those advisories together; both show in the suppressed block. |
333
336
  | Exit | Always 0. Prints nothing when no tip fires. |
334
337
 
@@ -1400,7 +1400,7 @@ Each gate is the previous gate plus its own tier, so the name and the value desc
1400
1400
 
1401
1401
  Dependency inspection is read-only, not a gate: `bkit:deps:outdated` and `bkit:deps:audit` exist so prompts stop hardcoding `pnpm outdated` / `pnpm audit`.
1402
1402
 
1403
- `bkit:test:file` is not a gate either: it runs ONE test file — bkit appends the repo-relative path as its argument — and writes a JUnit report to the path in `$BKIT_TEST_REPORT`. `/bkit-build` reads that report for test-first (§ Test-first). Not seeded (no default runs one file on every stack); install's `test-file-script-missing` advisory hands over the line until it is declared. Call the runner directly: a task runner that caches results or runs dependent packages first breaks the one-file contract.
1403
+ `bkit:test:file` is not a gate either: it runs ONE test file — bkit appends the repo-relative path as its argument — and writes a JUnit report to the path in `$BKIT_TEST_REPORT`. `/bkit-build` reads that report for test-first (§ Test-first). Not seeded (no default runs one file on every stack); the `test-file-script-missing` advisory (install, `bkit check`, `bkit upgrade`) hands over the line until it is declared. Call the runner directly: a task runner that caches results or runs dependent packages first breaks the one-file contract.
1404
1404
 
1405
1405
  Agents and humans run the same scripts, so a green agent gate and a green `git push` mean the same thing. `bkit-ci.yml` deliberately stays off them: it needs per-step reporting, affected-package conditionals, and the heavier tiers the local gate excludes, so it calls `pnpm typecheck` / `pnpm test` / … directly.
1406
1406
 
@@ -154,7 +154,7 @@ export function formatChecklist(
154
154
  // Advisories artifact — `.bkit/advisories.md`
155
155
  // ---------------------------------------------------------------------------
156
156
 
157
- export type AdvisoriesMode = "install" | "check" | "doctor";
157
+ export type AdvisoriesMode = "install" | "check" | "upgrade" | "doctor";
158
158
 
159
159
  /**
160
160
  * Render findings as a markdown artifact suitable for `.bkit/advisories.md`.
@@ -182,7 +182,7 @@ export function renderAdvisoriesMarkdown(
182
182
  lines.push(`_Mode: ${opts.mode}_`);
183
183
  lines.push("");
184
184
  lines.push(
185
- "> Auto-generated by `bkit install` / `bkit check` / `bkit doctor`. Overwritten on each run.",
185
+ "> Auto-generated by `bkit install` / `bkit check` / `bkit upgrade` / `bkit doctor`. Overwritten on each run.",
186
186
  );
187
187
  lines.push("");
188
188
 
@@ -243,18 +243,40 @@ export function refreshPreflightAfterWrites(
243
243
  };
244
244
  }
245
245
 
246
- /** `bkit install`, and `bkit check` (the same pipeline, dry-run). */
246
+ /**
247
+ * The advisory pass that closes a real `bkit upgrade`: `bkit check`'s read-only pipeline
248
+ * under upgrade's log prefix, printing the checklist and rewriting `.bkit/advisories.md`
249
+ * (mode `upgrade`). Never exits — blockers and drift are reported, upgrade keeps its own
250
+ * exit code.
251
+ */
252
+ export function runUpgradeAdvisories(): Promise<void> {
253
+ return runInstall(
254
+ {
255
+ verb: "check",
256
+ modules: new Set(),
257
+ tracker: null,
258
+ cloudVariant: null,
259
+ opencodeProvider: null,
260
+ },
261
+ true,
262
+ );
263
+ }
264
+
265
+ /**
266
+ * `bkit install`, and `bkit check` (the same pipeline, dry-run). `upgradeReport` runs the
267
+ * check pipeline for runUpgradeAdvisories.
268
+ */
247
269
  export async function runInstall(
248
- args: Pick<
249
- ParsedArgs,
250
- "verb" | "modules" | "tracker" | "cloudVariant" | "opencodeProvider" | "uninstallFlags"
251
- >,
270
+ args: Pick<ParsedArgs, "verb" | "modules" | "tracker" | "cloudVariant" | "opencodeProvider"> &
271
+ Partial<Pick<ParsedArgs, "uninstallFlags">>,
272
+ upgradeReport = false,
252
273
  ): Promise<void> {
253
274
  const { verb, modules, tracker, cloudVariant, opencodeProvider, uninstallFlags } = args;
254
275
  const dryRun = verb === "check";
255
- if (dryRun) setLogPrefix("[bkit-check]");
276
+ if (dryRun && !upgradeReport) setLogPrefix("[bkit-check]");
256
277
 
257
- if (dryRun) console.log(`${LOG_PREFIX} Running in check (dry-run) mode`);
278
+ if (upgradeReport) console.log(`${LOG_PREFIX} Checking advisories (read-only)`);
279
+ else if (dryRun) console.log(`${LOG_PREFIX} Running in check (dry-run) mode`);
258
280
 
259
281
  // `bkit check` scopes drift detection to what is INSTALLED (detected by sentinel files),
260
282
  // not to a fixed full set. `install` keeps its explicit resolved set.
@@ -306,14 +328,25 @@ export async function runInstall(
306
328
  console.log(`${LOG_PREFIX} Preflight blockers detected — aborting.`);
307
329
  const blockerBanner = formatChecklist(blockers);
308
330
  if (blockerBanner) console.log(blockerBanner);
331
+ if (upgradeReport) {
332
+ writeAdvisoriesArtifact(blockers, {
333
+ cwd: process.cwd(),
334
+ mode: "upgrade",
335
+ version: getInstallingVersion(),
336
+ logPrefix: LOG_PREFIX,
337
+ });
338
+ return;
339
+ }
309
340
  process.exit(1);
310
341
  }
311
342
 
312
343
  // Resolve tokens once for the whole install
313
344
  const tokens = await resolveTokens(process.cwd()).catch((err: unknown) => {
314
345
  console.error(`${LOG_PREFIX} Token resolution failed: ${(err as Error).message}`);
315
- process.exit(1);
346
+ if (!upgradeReport) process.exit(1);
347
+ return undefined;
316
348
  });
349
+ if (tokens === undefined) return;
317
350
 
318
351
  // Parse model lookup (needed for cursor transforms).
319
352
  // DEFAULTS come from the PACKAGE's .bkit/prompts.md § Models (authoritative, matches the
@@ -555,7 +588,7 @@ export async function runInstall(
555
588
  if (banner) console.log(banner);
556
589
  writeAdvisoriesArtifact(postFindings, {
557
590
  cwd: process.cwd(),
558
- mode: dryRun ? "check" : "install",
591
+ mode: upgradeReport ? "upgrade" : dryRun ? "check" : "install",
559
592
  version: getInstallingVersion(),
560
593
  logPrefix: LOG_PREFIX,
561
594
  suppressed,
@@ -564,7 +597,7 @@ export async function runInstall(
564
597
 
565
598
  // Check mode: exit 1 on drift (see reportCheckDrift).
566
599
  if (dryRun) {
567
- reportCheckDrift(postFindings, totalWrites, missingHooks);
600
+ if (!upgradeReport) reportCheckDrift(postFindings, totalWrites, missingHooks);
568
601
  return;
569
602
  }
570
603
 
@@ -579,7 +612,7 @@ export async function runInstall(
579
612
  `${LOG_PREFIX} ${phase3Blockers.length} Phase 3 blocker(s) detected. Recovery:\n ${recoveryLine}`,
580
613
  );
581
614
  // P2.T10: --auto-revert: run uninstall in-process before exit-1
582
- if (uninstallFlags.autoRevert) {
615
+ if (uninstallFlags?.autoRevert) {
583
616
  console.log(`${LOG_PREFIX} --auto-revert: reverting install...`);
584
617
  const uninstallCtx: UninstallContext = {
585
618
  cwd: process.cwd(),
@@ -46,6 +46,7 @@ import {
46
46
  getInstallingVersion,
47
47
  requireOpencodeProvider,
48
48
  detectOpencodeProviders,
49
+ runUpgradeAdvisories,
49
50
  } from "./install.js";
50
51
  import { setLogPrefix } from "../../shared/log-prefix.js";
51
52
  import {
@@ -1032,6 +1033,9 @@ export async function runUpgradeCommand(upgradeFlags: UpgradeFlags): Promise<voi
1032
1033
  `${LOG_PREFIX} Done. updated: ${result.updated.length}, skipped: ${result.skipped.length}, conflicts: ${result.conflicts.length}, re-rendered: ${rendered.length}`,
1033
1034
  );
1034
1035
 
1036
+ // `.bkit/advisories.md` describes the upgraded repo, not the last install or check.
1037
+ if (!upgradeFlags.dryRun) await runUpgradeAdvisories();
1038
+
1035
1039
  // Non-interactive mode: exit non-zero on conflicts
1036
1040
  if (upgradeFlags.nonInteractive && result.conflicts.length > 0) {
1037
1041
  process.exit(1);
@@ -275,8 +275,8 @@ export const BKIT_BUILD_GATES: readonly string[] = [
275
275
  /**
276
276
  * Runs ONE test file — `pnpm bkit:test:file <repo-relative path>` — and writes a JUnit
277
277
  * report to `$BKIT_TEST_REPORT`. `/bkit-build` records each task's red and audits its
278
- * green through it. Never seeded: no default works on every stack; install advises
279
- * when it is missing (detectGateAdvisories).
278
+ * green through it. Never seeded: no default works on every stack; install, check and
279
+ * upgrade advise when it is missing (detectGateAdvisories).
280
280
  */
281
281
  export const BKIT_TEST_FILE_SCRIPT = "bkit:test:file";
282
282
 
@@ -361,8 +361,11 @@ const PNPM_NOT_A_SCRIPT = new Set([
361
361
 
362
362
  /**
363
363
  * Advisories for the `bkit:gate:*` scripts: the scripts a still-default gate
364
- * chains that package.json does not declare, and the deeper test tiers the repo has
365
- * but no gate runs. Read-only; an absent or unparseable package.json yields none.
364
+ * chains that package.json does not declare, the deeper test tiers the repo has
365
+ * but no gate runs, and a missing `bkit:test:file`. Judges the scripts as install
366
+ * leaves them (missing gate names at their seeded defaults), so install, `bkit check`
367
+ * and `bkit upgrade` report the same set. Read-only; an absent or unparseable
368
+ * package.json yields none.
366
369
  */
367
370
  export function detectGateAdvisories(cwd: string): PreflightFinding[] {
368
371
  let declared: Record<string, string>;
@@ -370,7 +373,7 @@ export function detectGateAdvisories(cwd: string): PreflightFinding[] {
370
373
  const pkg = JSON.parse(fs.readFileSync(path.join(cwd, "package.json"), "utf-8")) as {
371
374
  scripts?: Record<string, string>;
372
375
  };
373
- declared = pkg.scripts ?? {};
376
+ declared = { ...BKIT_GATE_SCRIPTS, ...pkg.scripts };
374
377
  } catch {
375
378
  // Absent or malformed package.json — preflight's no-package-json /
376
379
  // malformed-package-json blockers already report it.
@@ -386,7 +389,7 @@ export function detectGateAdvisories(cwd: string): PreflightFinding[] {
386
389
  if (declared[name] !== seeded) continue;
387
390
  for (const [, called] of seeded.matchAll(/\bpnpm ([\w:-]+)/g)) {
388
391
  if (PNPM_NOT_A_SCRIPT.has(called)) continue;
389
- if (!(called in declared) && !(called in BKIT_GATE_SCRIPTS)) missing.add(called);
392
+ if (!(called in declared)) missing.add(called);
390
393
  }
391
394
  }
392
395
  if (missing.size > 0) {
@@ -447,7 +450,7 @@ export function isNoopScript(value: string): boolean {
447
450
 
448
451
  /**
449
452
  * Advisory for every `bkit:gate:*` script that is empty or a no-op: it checks nothing,
450
- * so every agent run and push passes it. Warn-only, at install and `bkit check`, on
453
+ * so every agent run and push passes it. Warn-only, at install, `bkit check` and `bkit upgrade`, on
451
454
  * every branch. Read-only; an absent or unparseable package.json yields none.
452
455
  */
453
456
  export function detectNoopGates(cwd: string): PreflightFinding[] {
@@ -550,7 +553,7 @@ export function runCoreModule(ctx: ModuleContext): void {
550
553
  // 3c. The bkit:gate:* / bkit:deps:* package.json scripts (add-if-missing). The
551
554
  // advisories read the result.
552
555
  seedCorePackageJsonScripts(ctx);
553
- if (!dryRun) advisories.push(...detectGateAdvisories(cwd));
556
+ advisories.push(...detectGateAdvisories(cwd));
554
557
  advisories.push(...detectNoopGates(cwd));
555
558
 
556
559
  // 4. .bkit/version write — deferred to postDispatch so it only persists when ALL modules succeed.
package/CHANGELOG.md CHANGED
@@ -8,6 +8,12 @@ Format: `## [version] — YYYY-MM-DD`
8
8
 
9
9
  ## [Unreleased]
10
10
 
11
+ ## [5.2.2] — 2026-10-15
12
+
13
+ ### Fixed
14
+
15
+ - **`bkit check` and `bkit upgrade` report the gate advisories install reports** (#524). `test-file-script-missing`, `gate-missing-called-scripts` and `gate-tier-not-wired` ran only on a real install, so an upgraded repo never saw them. They now judge `package.json` as install leaves it and run in every mode. A real `bkit upgrade` ends with `bkit check`'s read-only pass: prints the checklist and rewrites `.bkit/advisories.md` (`Mode: upgrade`), so the upgrade paste block's "read `.bkit/advisories.md`" step reads current findings. Upgrade's exit code is unchanged.
16
+
11
17
  ## [5.2.1] — 2026-10-15
12
18
 
13
19
  ### Changed
@@ -117,7 +117,7 @@ export function renderAdvisoriesMarkdown(findings, opts, suppressed = [], tips =
117
117
  lines.push(`_bkit: ${opts.version}_ `);
118
118
  lines.push(`_Mode: ${opts.mode}_`);
119
119
  lines.push("");
120
- lines.push("> Auto-generated by `bkit install` / `bkit check` / `bkit doctor`. Overwritten on each run.");
120
+ lines.push("> Auto-generated by `bkit install` / `bkit check` / `bkit upgrade` / `bkit doctor`. Overwritten on each run.");
121
121
  lines.push("");
122
122
  if (findings.length === 0 && suppressed.length === 0 && tips.length === 0) {
123
123
  lines.push("**No advisories.** Last run was clean.");
@@ -196,13 +196,33 @@ export function refreshPreflightAfterWrites(modules, cwd, issueTracker, seedCoun
196
196
  blockers: fresh.blockers,
197
197
  };
198
198
  }
199
- /** `bkit install`, and `bkit check` (the same pipeline, dry-run). */
200
- export async function runInstall(args) {
199
+ /**
200
+ * The advisory pass that closes a real `bkit upgrade`: `bkit check`'s read-only pipeline
201
+ * under upgrade's log prefix, printing the checklist and rewriting `.bkit/advisories.md`
202
+ * (mode `upgrade`). Never exits — blockers and drift are reported, upgrade keeps its own
203
+ * exit code.
204
+ */
205
+ export function runUpgradeAdvisories() {
206
+ return runInstall({
207
+ verb: "check",
208
+ modules: new Set(),
209
+ tracker: null,
210
+ cloudVariant: null,
211
+ opencodeProvider: null,
212
+ }, true);
213
+ }
214
+ /**
215
+ * `bkit install`, and `bkit check` (the same pipeline, dry-run). `upgradeReport` runs the
216
+ * check pipeline for runUpgradeAdvisories.
217
+ */
218
+ export async function runInstall(args, upgradeReport = false) {
201
219
  const { verb, modules, tracker, cloudVariant, opencodeProvider, uninstallFlags } = args;
202
220
  const dryRun = verb === "check";
203
- if (dryRun)
221
+ if (dryRun && !upgradeReport)
204
222
  setLogPrefix("[bkit-check]");
205
- if (dryRun)
223
+ if (upgradeReport)
224
+ console.log(`${LOG_PREFIX} Checking advisories (read-only)`);
225
+ else if (dryRun)
206
226
  console.log(`${LOG_PREFIX} Running in check (dry-run) mode`);
207
227
  // `bkit check` scopes drift detection to what is INSTALLED (detected by sentinel files),
208
228
  // not to a fixed full set. `install` keeps its explicit resolved set.
@@ -247,13 +267,26 @@ export async function runInstall(args) {
247
267
  const blockerBanner = formatChecklist(blockers);
248
268
  if (blockerBanner)
249
269
  console.log(blockerBanner);
270
+ if (upgradeReport) {
271
+ writeAdvisoriesArtifact(blockers, {
272
+ cwd: process.cwd(),
273
+ mode: "upgrade",
274
+ version: getInstallingVersion(),
275
+ logPrefix: LOG_PREFIX,
276
+ });
277
+ return;
278
+ }
250
279
  process.exit(1);
251
280
  }
252
281
  // Resolve tokens once for the whole install
253
282
  const tokens = await resolveTokens(process.cwd()).catch((err) => {
254
283
  console.error(`${LOG_PREFIX} Token resolution failed: ${err.message}`);
255
- process.exit(1);
284
+ if (!upgradeReport)
285
+ process.exit(1);
286
+ return undefined;
256
287
  });
288
+ if (tokens === undefined)
289
+ return;
257
290
  // Parse model lookup (needed for cursor transforms).
258
291
  // DEFAULTS come from the PACKAGE's .bkit/prompts.md § Models (authoritative, matches the
259
292
  // prompt files about to be installed).
@@ -475,7 +508,7 @@ export async function runInstall(args) {
475
508
  console.log(banner);
476
509
  writeAdvisoriesArtifact(postFindings, {
477
510
  cwd: process.cwd(),
478
- mode: dryRun ? "check" : "install",
511
+ mode: upgradeReport ? "upgrade" : dryRun ? "check" : "install",
479
512
  version: getInstallingVersion(),
480
513
  logPrefix: LOG_PREFIX,
481
514
  suppressed,
@@ -483,7 +516,8 @@ export async function runInstall(args) {
483
516
  });
484
517
  // Check mode: exit 1 on drift (see reportCheckDrift).
485
518
  if (dryRun) {
486
- reportCheckDrift(postFindings, totalWrites, missingHooks);
519
+ if (!upgradeReport)
520
+ reportCheckDrift(postFindings, totalWrites, missingHooks);
487
521
  return;
488
522
  }
489
523
  // P2.T9: exit-1 on Phase 3 blockers + recovery action text.
@@ -495,7 +529,7 @@ export async function runInstall(args) {
495
529
  const recoveryLine = `pnpm bkit uninstall ${recoveryFlags} && <fix the issue> && pnpm bkit install ${recoveryFlags}`;
496
530
  console.error(`${LOG_PREFIX} ${phase3Blockers.length} Phase 3 blocker(s) detected. Recovery:\n ${recoveryLine}`);
497
531
  // P2.T10: --auto-revert: run uninstall in-process before exit-1
498
- if (uninstallFlags.autoRevert) {
532
+ if (uninstallFlags?.autoRevert) {
499
533
  console.log(`${LOG_PREFIX} --auto-revert: reverting install...`);
500
534
  const uninstallCtx = {
501
535
  cwd: process.cwd(),
@@ -26,7 +26,7 @@ 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
28
  import { TEMPLATE_COPIES_DIR, getCoreRoot, getSharedRoot, getBkitDocsRoot, getPkgRoot, } from "../../shared/package-roots.js";
29
- import { getInstallingVersion, requireOpencodeProvider, detectOpencodeProviders, } from "./install.js";
29
+ import { getInstallingVersion, requireOpencodeProvider, detectOpencodeProviders, runUpgradeAdvisories, } from "./install.js";
30
30
  import { setLogPrefix } from "../../shared/log-prefix.js";
31
31
  import { getInstallManifest, getModuleManifest, DEFAULT_ISSUE_TRACKER, parseIssueTracker, } from "../../install/manifest.js";
32
32
  import { OPTIN_MODULES } from "../../install/manifest.js";
@@ -773,6 +773,9 @@ export async function runUpgradeCommand(upgradeFlags) {
773
773
  });
774
774
  }
775
775
  console.log(`${LOG_PREFIX} Done. updated: ${result.updated.length}, skipped: ${result.skipped.length}, conflicts: ${result.conflicts.length}, re-rendered: ${rendered.length}`);
776
+ // `.bkit/advisories.md` describes the upgraded repo, not the last install or check.
777
+ if (!upgradeFlags.dryRun)
778
+ await runUpgradeAdvisories();
776
779
  // Non-interactive mode: exit non-zero on conflicts
777
780
  if (upgradeFlags.nonInteractive && result.conflicts.length > 0) {
778
781
  process.exit(1);
@@ -220,8 +220,8 @@ export const BKIT_BUILD_GATES = [
220
220
  /**
221
221
  * Runs ONE test file — `pnpm bkit:test:file <repo-relative path>` — and writes a JUnit
222
222
  * report to `$BKIT_TEST_REPORT`. `/bkit-build` records each task's red and audits its
223
- * green through it. Never seeded: no default works on every stack; install advises
224
- * when it is missing (detectGateAdvisories).
223
+ * green through it. Never seeded: no default works on every stack; install, check and
224
+ * upgrade advise when it is missing (detectGateAdvisories).
225
225
  */
226
226
  export const BKIT_TEST_FILE_SCRIPT = "bkit:test:file";
227
227
  /**
@@ -291,14 +291,17 @@ const PNPM_NOT_A_SCRIPT = new Set([
291
291
  ]);
292
292
  /**
293
293
  * Advisories for the `bkit:gate:*` scripts: the scripts a still-default gate
294
- * chains that package.json does not declare, and the deeper test tiers the repo has
295
- * but no gate runs. Read-only; an absent or unparseable package.json yields none.
294
+ * chains that package.json does not declare, the deeper test tiers the repo has
295
+ * but no gate runs, and a missing `bkit:test:file`. Judges the scripts as install
296
+ * leaves them (missing gate names at their seeded defaults), so install, `bkit check`
297
+ * and `bkit upgrade` report the same set. Read-only; an absent or unparseable
298
+ * package.json yields none.
296
299
  */
297
300
  export function detectGateAdvisories(cwd) {
298
301
  let declared;
299
302
  try {
300
303
  const pkg = JSON.parse(fs.readFileSync(path.join(cwd, "package.json"), "utf-8"));
301
- declared = pkg.scripts ?? {};
304
+ declared = { ...BKIT_GATE_SCRIPTS, ...pkg.scripts };
302
305
  }
303
306
  catch {
304
307
  // Absent or malformed package.json — preflight's no-package-json /
@@ -316,7 +319,7 @@ export function detectGateAdvisories(cwd) {
316
319
  for (const [, called] of seeded.matchAll(/\bpnpm ([\w:-]+)/g)) {
317
320
  if (PNPM_NOT_A_SCRIPT.has(called))
318
321
  continue;
319
- if (!(called in declared) && !(called in BKIT_GATE_SCRIPTS))
322
+ if (!(called in declared))
320
323
  missing.add(called);
321
324
  }
322
325
  }
@@ -372,7 +375,7 @@ export function isNoopScript(value) {
372
375
  }
373
376
  /**
374
377
  * Advisory for every `bkit:gate:*` script that is empty or a no-op: it checks nothing,
375
- * so every agent run and push passes it. Warn-only, at install and `bkit check`, on
378
+ * so every agent run and push passes it. Warn-only, at install, `bkit check` and `bkit upgrade`, on
376
379
  * every branch. Read-only; an absent or unparseable package.json yields none.
377
380
  */
378
381
  export function detectNoopGates(cwd) {
@@ -465,8 +468,7 @@ export function runCoreModule(ctx) {
465
468
  // 3c. The bkit:gate:* / bkit:deps:* package.json scripts (add-if-missing). The
466
469
  // advisories read the result.
467
470
  seedCorePackageJsonScripts(ctx);
468
- if (!dryRun)
469
- advisories.push(...detectGateAdvisories(cwd));
471
+ advisories.push(...detectGateAdvisories(cwd));
470
472
  advisories.push(...detectNoopGates(cwd));
471
473
  // 4. .bkit/version write — deferred to postDispatch so it only persists when ALL modules succeed.
472
474
  // This ensures a mid-install crash in a subsequent module does not suppress the first-install
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cbartens/bkit",
3
- "version": "5.2.1",
3
+ "version": "5.2.2",
4
4
  "private": false,
5
5
  "description": "From vibe coding to production code. A senior engineering team's process, ready-made: AI agents design, plan, build, review, fix and ship your features on Claude Code, Cursor, Codex, Google Antigravity and opencode.",
6
6
  "keywords": [