@cbartens/bkit 5.2.1 → 5.2.3

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.
Files changed (90) hide show
  1. package/.bkit/README.md +1 -1
  2. package/.bkit/core/.agents/context.md +2 -2
  3. package/.bkit/core/.agents/plugins/bkit/hooks/bkit-guardrails.cjs +7 -1
  4. package/.bkit/core/.bkit/comparison.md +114 -45
  5. package/.bkit/core/.bkit/install.md +8 -5
  6. package/.bkit/core/.bkit/jsonl.md +3 -3
  7. package/.bkit/core/.bkit/prompts.md +6 -5
  8. package/.bkit/core/.bkit/providers.md +5 -4
  9. package/.bkit/core/.bkit/templates.md +11 -10
  10. package/.bkit/core/.bkit/workflows.md +8 -6
  11. package/.bkit/core/.codex/hooks/bkit-guardrails.cjs +5 -1
  12. package/.bkit/core/.cursor/hooks/bkit-guardrails.cjs +8 -2
  13. package/.bkit/core/docs/templates/bkit-audit-accessibility.md +5 -2
  14. package/.bkit/core/docs/templates/bkit-audit-adoption.md +5 -2
  15. package/.bkit/core/docs/templates/bkit-audit-agents.md +5 -2
  16. package/.bkit/core/docs/templates/bkit-audit-aio-seo.md +5 -2
  17. package/.bkit/core/docs/templates/bkit-audit-analytics.md +5 -2
  18. package/.bkit/core/docs/templates/bkit-audit-annotations.md +6 -3
  19. package/.bkit/core/docs/templates/bkit-audit-app-performance.md +5 -2
  20. package/.bkit/core/docs/templates/bkit-audit-app-store.md +5 -2
  21. package/.bkit/core/docs/templates/bkit-audit-architecture.md +5 -2
  22. package/.bkit/core/docs/templates/bkit-audit-ci-performance.md +5 -2
  23. package/.bkit/core/docs/templates/bkit-audit-config.md +5 -2
  24. package/.bkit/core/docs/templates/bkit-audit-cost.md +5 -2
  25. package/.bkit/core/docs/templates/bkit-audit-coverage.md +5 -2
  26. package/.bkit/core/docs/templates/bkit-audit-database.md +5 -2
  27. package/.bkit/core/docs/templates/bkit-audit-dead-code.md +5 -2
  28. package/.bkit/core/docs/templates/bkit-audit-deferrals.md +5 -2
  29. package/.bkit/core/docs/templates/bkit-audit-dependencies.md +5 -2
  30. package/.bkit/core/docs/templates/bkit-audit-documentation.md +5 -2
  31. package/.bkit/core/docs/templates/bkit-audit-duplication.md +5 -2
  32. package/.bkit/core/docs/templates/bkit-audit-failures.md +6 -3
  33. package/.bkit/core/docs/templates/bkit-audit-flakes.md +6 -3
  34. package/.bkit/core/docs/templates/bkit-audit-gates.md +5 -2
  35. package/.bkit/core/docs/templates/bkit-audit-issues.md +5 -2
  36. package/.bkit/core/docs/templates/bkit-audit-llm.md +5 -2
  37. package/.bkit/core/docs/templates/bkit-audit-logs.md +16 -12
  38. package/.bkit/core/docs/templates/bkit-audit-models.md +5 -2
  39. package/.bkit/core/docs/templates/bkit-audit-privacy.md +5 -2
  40. package/.bkit/core/docs/templates/bkit-audit-prompts.md +5 -2
  41. package/.bkit/core/docs/templates/bkit-audit-red-team.md +5 -2
  42. package/.bkit/core/docs/templates/bkit-audit-reliability.md +6 -3
  43. package/.bkit/core/docs/templates/bkit-audit-repo.md +5 -2
  44. package/.bkit/core/docs/templates/bkit-audit-security.md +6 -3
  45. package/.bkit/core/docs/templates/bkit-audit-slop.md +5 -2
  46. package/.bkit/core/docs/templates/bkit-audit-testing.md +5 -2
  47. package/.bkit/core/docs/templates/bkit-audit-usability.md +5 -2
  48. package/.bkit/core/docs/templates/bkit-plan.md +1 -1
  49. package/.bkit/core/engine/checks/after/index.ts +2 -2
  50. package/.bkit/core/engine/commands/install/check.ts +3 -11
  51. package/.bkit/core/engine/commands/install/doctor.ts +2 -3
  52. package/.bkit/core/engine/commands/install/install.ts +44 -11
  53. package/.bkit/core/engine/commands/install/uninstall.ts +60 -44
  54. package/.bkit/core/engine/commands/install/upgrade.ts +8 -1
  55. package/.bkit/core/engine/commands/workflow/branches.ts +13 -4
  56. package/.bkit/core/engine/install/hosts.ts +14 -4
  57. package/.bkit/core/engine/install/manifest.ts +2 -2
  58. package/.bkit/core/engine/install/modules/core.ts +9 -6
  59. package/.bkit/core/engine/ledgers/telemetry.ts +3 -4
  60. package/.bkit/core/hooks/guardrails-read.js +4 -9
  61. package/.bkit/core/hooks/guardrails-tiers.js +312 -28
  62. package/.bkit/core/prompts/bkit-audit-generate.md +19 -5
  63. package/.bkit/shared/.claude/settings.json +19 -0
  64. package/.bkit/shared/.opencode/opencode.json +21 -1
  65. package/.bkit/shared/docs/deployments.md +14 -0
  66. package/.bkit/templates/.github/workflows/bkit-ci.yml +9 -0
  67. package/.bkit/templates/context/bkit-cloudrun.md +28 -19
  68. package/.bkit/templates/context/bkit-expo.md +30 -13
  69. package/.bkit/templates/context/bkit-inngest.md +54 -17
  70. package/.bkit/templates/context/bkit-resend.md +36 -8
  71. package/.bkit/templates/context/bkit-sentry.md +11 -4
  72. package/.bkit/templates/context/bkit-stripe.md +39 -22
  73. package/.bkit/templates/context/bkit-supabase.md +45 -20
  74. package/.bkit/templates/context/bkit-vercel.md +45 -16
  75. package/.bkit/templates/scripts/ci/accepted-advisories.json +7 -0
  76. package/.bkit/templates/scripts/ci/check-dependency-audit.mjs +200 -0
  77. package/.bkit/templates/scripts/ci/check-dependency-audit.test.mjs +127 -0
  78. package/CHANGELOG.md +45 -0
  79. package/README.md +76 -20
  80. package/dist/checks/after/index.js +1 -1
  81. package/dist/commands/install/check.js +3 -15
  82. package/dist/commands/install/doctor.js +2 -1
  83. package/dist/commands/install/install.js +42 -8
  84. package/dist/commands/install/uninstall.js +52 -45
  85. package/dist/commands/install/upgrade.js +8 -2
  86. package/dist/commands/workflow/branches.js +13 -5
  87. package/dist/install/hosts.js +11 -4
  88. package/dist/install/manifest.js +2 -2
  89. package/dist/install/modules/core.js +9 -7
  90. package/package.json +1 -1
@@ -30,7 +30,9 @@ import {
30
30
  type ManifestEntry,
31
31
  type ModuleName,
32
32
  type IssueTracker,
33
+ ISSUE_TRACKERS,
33
34
  } from "../../install/manifest.js";
35
+ import { OPENCODE_PROVIDERS } from "../../shared/egress.js";
34
36
  import {
35
37
  isConsumerModified,
36
38
  mergeCanonicalHashes,
@@ -120,33 +122,42 @@ export interface UninstallResult {
120
122
  // ---------------------------------------------------------------------------
121
123
 
122
124
  /**
123
- * Detect the tracker bkit seeded into opencode.json from its mcp keys. The template ships an
124
- * `@@OPENCODE_TRACKER_MCP@@` sentinel KEY that renders to `github` / `linear` at install, so a
125
- * strip-scope keyed on the raw template never matches — these detectors let uninstall render the
126
- * template the same way the install did before stripping. Keyed on bkit's known tracker names so
127
- * a consumer-added mcp server is never mistaken for bkit's.
125
+ * Strip bkit's scope from `.opencode/opencode.json`. The template ships `@@OPENCODE_*@@`
126
+ * sentinel KEYS that render to the consumer's tracker and provider, and install keeps every
127
+ * earlier provider block and tracker entry (install is additive), so one file can hold several.
128
+ * Render the template once per known tracker and once per supported provider, then remove each
129
+ * `mcp` entry and `provider` block identical to a rendered one; an entry the consumer added or
130
+ * edited stays whole. The rest of the template (permission sandbox, plugin list) strips leaf by
131
+ * leaf like any Tier-2 JSON file. Reads only the template.
128
132
  */
129
- function detectOpencodeTracker(doc: Record<string, JsonValue>): IssueTracker {
130
- const mcp = doc.mcp;
131
- if (mcp !== null && typeof mcp === "object" && !Array.isArray(mcp)) {
132
- if ("github" in mcp) return "github";
133
- if ("linear" in mcp) return "linear";
133
+ export function stripOpencodeJsonScope(
134
+ consumer: Record<string, JsonValue>,
135
+ templatePath: string,
136
+ cwd: string,
137
+ ): Record<string, JsonValue> {
138
+ const render = (tracker: IssueTracker, provider: string): Record<string, JsonValue> =>
139
+ JSON.parse(renderOpencodeJson(templatePath, tracker, provider, cwd)) as Record<
140
+ string,
141
+ JsonValue
142
+ >;
143
+ const ownedMcp: Record<string, JsonValue> = {};
144
+ for (const tracker of ISSUE_TRACKERS) {
145
+ const { mcp } = render(tracker, OPENCODE_PROVIDERS[0]);
146
+ if (isJsonObject(mcp)) Object.assign(ownedMcp, mcp);
134
147
  }
135
- return "none";
136
- }
137
-
138
- /** Detect the opencode provider key bkit seeded (the first `provider` block key). */
139
- function detectOpencodeProvider(doc: Record<string, JsonValue>): string {
140
- const provider = doc.provider;
141
- if (provider !== null && typeof provider === "object" && !Array.isArray(provider)) {
142
- const keys = Object.keys(provider);
143
- if (keys.length > 0) {
144
- const first = keys[0];
145
- // Zen block is keyed `opencode` (built-in id); map back to the bkit CLI key.
146
- return first === "opencode" ? "opencode-zen" : first;
147
- }
148
+ const ownedProviders: Record<string, JsonValue> = {};
149
+ for (const provider of OPENCODE_PROVIDERS) {
150
+ const rendered = render("none", provider).provider;
151
+ if (isJsonObject(rendered)) Object.assign(ownedProviders, rendered);
148
152
  }
149
- return "opencode-zen";
153
+ const rest = render("none", OPENCODE_PROVIDERS[0]);
154
+ delete rest.mcp;
155
+ delete rest.provider;
156
+
157
+ const out = JSON.parse(JSON.stringify(consumer)) as Record<string, JsonValue>;
158
+ removeOwnedEntries(out, "mcp", ownedMcp);
159
+ removeOwnedEntries(out, "provider", ownedProviders);
160
+ return stripTier2JsonScope(out, rest);
150
161
  }
151
162
 
152
163
  export function stripTier2JsonScope(
@@ -219,16 +230,28 @@ export function stripMcpTrackerEntries(
219
230
  template: Record<string, JsonValue>,
220
231
  ): Record<string, JsonValue> {
221
232
  const out = JSON.parse(JSON.stringify(consumer)) as Record<string, JsonValue>;
222
- const servers = out.mcpServers;
223
233
  const owned = template.mcpServers;
224
- if (!isJsonObject(servers) || !isJsonObject(owned)) return out;
225
- for (const [key, entry] of Object.entries(owned)) {
226
- if (JSON.stringify(servers[key]) === JSON.stringify(entry)) delete servers[key];
227
- }
228
- if (Object.keys(servers).length === 0) delete out.mcpServers;
234
+ if (isJsonObject(owned)) removeOwnedEntries(out, "mcpServers", owned);
229
235
  return out;
230
236
  }
231
237
 
238
+ /**
239
+ * Delete each entry of `doc[key]` identical to the same-named entry in `owned`, then drop
240
+ * `doc[key]` once empty. Entries that differ, and names `owned` lacks, stay. Mutates `doc`.
241
+ */
242
+ function removeOwnedEntries(
243
+ doc: Record<string, JsonValue>,
244
+ key: string,
245
+ owned: Record<string, JsonValue>,
246
+ ): void {
247
+ const entries = doc[key];
248
+ if (!isJsonObject(entries)) return;
249
+ for (const [name, entry] of Object.entries(owned)) {
250
+ if (JSON.stringify(entries[name]) === JSON.stringify(entry)) delete entries[name];
251
+ }
252
+ if (Object.keys(entries).length === 0) delete doc[key];
253
+ }
254
+
232
255
  function isJsonObject(v: JsonValue | undefined): v is Record<string, JsonValue> {
233
256
  return v !== null && typeof v === "object" && !Array.isArray(v);
234
257
  }
@@ -582,19 +605,10 @@ export async function runUninstall(
582
605
  }
583
606
  const raw = fs.readFileSync(absPath, "utf-8");
584
607
  const consumerDoc = JSON.parse(raw) as Record<string, JsonValue>;
585
- let templateRaw = fs.readFileSync(templatePath, "utf-8");
586
- // opencode.json ships `@@OPENCODE_*@@` sentinel KEYS that render to the consumer's
587
- // tracker / provider at install; strip-scope keyed on the RAW template never matches
588
- // the rendered keys, so bkit's mcp + provider blocks (a token-referencing config)
589
- // survive a full uninstall. Render the template with the consumer's OWN tracker +
590
- // provider first so the keys line up and the bkit-owned scope strips cleanly.
591
- if (templateRaw.includes("@@OPENCODE_TRACKER_MCP@@")) {
592
- templateRaw = renderOpencodeJson(
593
- templatePath,
594
- detectOpencodeTracker(consumerDoc),
595
- detectOpencodeProvider(consumerDoc),
596
- );
597
- }
608
+ const templateRaw = fs.readFileSync(templatePath, "utf-8");
609
+ // opencode.json ships `@@OPENCODE_*@@` sentinel KEYS; stripOpencodeJsonScope
610
+ // renders them for every tracker and provider bkit can have written.
611
+ const isOpencodeJson = templateRaw.includes("@@OPENCODE_TRACKER_MCP@@");
598
612
  const templateDoc = JSON.parse(templateRaw) as Record<string, JsonValue>;
599
613
  // `.claude/settings.json` is not written verbatim: after rendering the
600
614
  // template, install appends one `WebFetch(domain:<d>)` grant per entry in
@@ -620,7 +634,9 @@ export async function runUninstall(
620
634
  }
621
635
  const stripped = MCP_JSON_RELPATHS.has(summary.file)
622
636
  ? stripMcpTrackerEntries(consumerDoc, templateDoc)
623
- : stripTier2JsonScope(consumerDoc, templateDoc);
637
+ : isOpencodeJson
638
+ ? stripOpencodeJsonScope(consumerDoc, templatePath, ctx.cwd)
639
+ : stripTier2JsonScope(consumerDoc, templateDoc);
624
640
  const strippedJson = JSON.stringify(stripped, null, 2) + "\n";
625
641
  if (Object.keys(stripped).length === 0) {
626
642
  // All keys were bkit-owned → delete file
@@ -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 {
@@ -961,7 +962,8 @@ export async function runUpgradeCommand(upgradeFlags: UpgradeFlags): Promise<voi
961
962
 
962
963
  // Network allowlist + MCP allows — OpenCode from renderOpencodeJson; Claude enrich
963
964
  // below; Cursor `.cursor/allowlist.json` + `.cursor/cli.json` only when cursor
964
- // module installed.
965
+ // module installed. Written artifacts get their canonicalHashes refreshed below.
966
+ const artifactWrites: string[] = [];
965
967
  {
966
968
  const cwd = process.cwd();
967
969
  if (renderModules.has("cursor")) {
@@ -970,6 +972,7 @@ export async function runUpgradeCommand(upgradeFlags: UpgradeFlags): Promise<voi
970
972
  writeCursorCliPermissionsArtifact(cwd, upgradeFlags.dryRun),
971
973
  ]) {
972
974
  if (art.wrote) {
975
+ artifactWrites.push(art.path);
973
976
  console.log(
974
977
  `${LOG_PREFIX}${upgradeFlags.dryRun ? " [dry-run]" : ""} upgrade: ${art.path}`,
975
978
  );
@@ -1014,6 +1017,7 @@ export async function runUpgradeCommand(upgradeFlags: UpgradeFlags): Promise<voi
1014
1017
  ...result.updated,
1015
1018
  ...renderedDocPaths,
1016
1019
  ...mcpWs.writes.map((w) => path.relative(process.cwd(), w.path)),
1020
+ ...artifactWrites,
1017
1021
  ],
1018
1022
  skipped: result.skipped,
1019
1023
  skippedSeedable: result.skippedSeedable,
@@ -1032,6 +1036,9 @@ export async function runUpgradeCommand(upgradeFlags: UpgradeFlags): Promise<voi
1032
1036
  `${LOG_PREFIX} Done. updated: ${result.updated.length}, skipped: ${result.skipped.length}, conflicts: ${result.conflicts.length}, re-rendered: ${rendered.length}`,
1033
1037
  );
1034
1038
 
1039
+ // `.bkit/advisories.md` describes the upgraded repo, not the last install or check.
1040
+ if (!upgradeFlags.dryRun) await runUpgradeAdvisories();
1041
+
1035
1042
  // Non-interactive mode: exit non-zero on conflicts
1036
1043
  if (upgradeFlags.nonInteractive && result.conflicts.length > 0) {
1037
1044
  process.exit(1);
@@ -395,8 +395,9 @@ export function stampAnchor(
395
395
  text: string,
396
396
  baseSha: string,
397
397
  design?: { path: string; baseSha: string },
398
+ baseRef: string = UPSTREAM,
398
399
  ): string {
399
- const header = [ANCHOR_OPEN, `baseSha: ${baseSha}`, `baseRef: ${UPSTREAM}`];
400
+ const header = [ANCHOR_OPEN, `baseSha: ${baseSha}`, `baseRef: ${baseRef}`];
400
401
  if (design) header.push(`designPath: ${design.path}`, `designBaseSha: ${design.baseSha}`);
401
402
  header.push(ANCHOR_CLOSE);
402
403
  const body = anchorLines(text)
@@ -1180,6 +1181,7 @@ function anchorStampVerb(ctx: RunContext): number {
1180
1181
  return EXIT_NO_FILE;
1181
1182
  }
1182
1183
  if (baseSha === "") throw new CommandError(EXIT.USAGE, "--base-sha must be non-empty");
1184
+ const baseRef = str(ctx.flags.baseRef) ?? UPSTREAM;
1183
1185
  const designFlag = str(ctx.flags.design);
1184
1186
  const designFile = designFlag === undefined ? undefined : path.resolve(ctx.cwd, designFlag);
1185
1187
  const design =
@@ -1190,7 +1192,7 @@ function anchorStampVerb(ctx: RunContext): number {
1190
1192
  }
1191
1193
  : undefined;
1192
1194
  const before = fs.readFileSync(file, "utf-8");
1193
- const after = stampAnchor(before, baseSha, design);
1195
+ const after = stampAnchor(before, baseSha, design, baseRef);
1194
1196
  // Temp file + rename: a crash mid-write never leaves a half-stamped doc.
1195
1197
  const tmp = `${file}.bkit-anchor.tmp`;
1196
1198
  fs.writeFileSync(tmp, after);
@@ -1198,6 +1200,7 @@ function anchorStampVerb(ctx: RunContext): number {
1198
1200
  ctx.emit({
1199
1201
  file: rel,
1200
1202
  baseSha,
1203
+ baseRef,
1201
1204
  designPath: design?.path ?? null,
1202
1205
  designBaseSha: design?.baseSha ?? null,
1203
1206
  changed: before !== after,
@@ -1452,7 +1455,7 @@ export const branchesCommand: CommandSpec = {
1452
1455
  },
1453
1456
  "anchor-stamp": {
1454
1457
  summary:
1455
- "Put a <!-- bkit:anchor --> block recording the base commit on top of a design/plan doc (idempotent).",
1458
+ "Put a <!-- bkit:anchor --> block recording the base commit on top of a design/plan doc or audit report (idempotent).",
1456
1459
  flags: [
1457
1460
  { name: "file", type: "string", required: true, help: "doc to stamp (must exist)" },
1458
1461
  {
@@ -1461,6 +1464,11 @@ export const branchesCommand: CommandSpec = {
1461
1464
  required: true,
1462
1465
  help: "base commit the doc was written against (non-empty)",
1463
1466
  },
1467
+ {
1468
+ name: "base-ref",
1469
+ type: "string",
1470
+ help: `ref baseSha was taken from (default ${UPSTREAM}; audit reports pass the audited branch)`,
1471
+ },
1464
1472
  {
1465
1473
  name: "design",
1466
1474
  type: "string",
@@ -1470,6 +1478,7 @@ export const branchesCommand: CommandSpec = {
1470
1478
  output: {
1471
1479
  file: "doc stamped",
1472
1480
  baseSha: "base commit stamped",
1481
+ baseRef: "ref stamped",
1473
1482
  designPath: "design path stamped (null when none)",
1474
1483
  designBaseSha:
1475
1484
  "the design doc's baseSha stamped (null when none; empty when it had no anchor)",
@@ -1482,7 +1491,7 @@ export const branchesCommand: CommandSpec = {
1482
1491
  summary:
1483
1492
  "Read a doc's anchor fields; with --against, decide whether anything landed since its baseSha.",
1484
1493
  flags: [
1485
- { name: "file", type: "string", required: true, help: "design/plan doc" },
1494
+ { name: "file", type: "string", required: true, help: "design/plan doc or audit report" },
1486
1495
  {
1487
1496
  name: "field",
1488
1497
  type: "string",
@@ -5,9 +5,19 @@ import * as path from "node:path";
5
5
  import type { ModuleFlag } from "../cli.js";
6
6
 
7
7
  /**
8
- * Detect which host modules a consumer has installed, by the presence of each host's
9
- * source-rendered agents directory. `bkit upgrade` re-renders only these hosts — never
10
- * force-creating an opencode/cursor tree — and setup tips key host-specific advice on them.
8
+ * The Antigravity plugin's bkit-written paths (install/modules/antigravity.ts). Any one
9
+ * present marks the host installed, so deleting a single file (the manifest included) still
10
+ * leaves the host detected and its missing files reported as drift.
11
+ */
12
+ const ANTIGRAVITY_SENTINELS = ["plugin.json", "hooks.json", "agents", "skills", "hooks"].map((p) =>
13
+ path.join(".agents", "plugins", "bkit", p),
14
+ );
15
+
16
+ /**
17
+ * Detect which host modules a consumer has installed: each host's source-rendered agents
18
+ * directory, or for Antigravity any of its plugin files. `bkit upgrade` re-renders only these
19
+ * hosts — never force-creating an opencode/cursor tree — and setup tips key host-specific
20
+ * advice on them.
11
21
  */
12
22
  export function detectInstalledHostModules(cwd: string): Set<ModuleFlag> {
13
23
  const mods = new Set<ModuleFlag>();
@@ -15,7 +25,7 @@ export function detectInstalledHostModules(cwd: string): Set<ModuleFlag> {
15
25
  if (fs.existsSync(path.join(cwd, ".cursor", "agents"))) mods.add("cursor");
16
26
  if (fs.existsSync(path.join(cwd, ".opencode", "agents"))) mods.add("opencode");
17
27
  if (fs.existsSync(path.join(cwd, ".codex", "agents"))) mods.add("codex");
18
- if (fs.existsSync(path.join(cwd, ".agents", "plugins", "bkit", "plugin.json")))
28
+ if (ANTIGRAVITY_SENTINELS.some((rel) => fs.existsSync(path.join(cwd, rel))))
19
29
  mods.add("antigravity");
20
30
  return mods;
21
31
  }
@@ -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.
@@ -118,7 +118,7 @@ export interface TelemetryEnvelope {
118
118
  repo: string;
119
119
  /** bkit version stamped on every row for regression attribution. */
120
120
  bkitVersion: string;
121
- /** Emitting workflow: design | plan | build | debug | ship */
121
+ /** Emitting workflow: design | plan | build | debug | ship | audit */
122
122
  workflow: string;
123
123
  /**
124
124
  * The WORKFLOW STEP the row was emitted at, e.g. `build-close-workflow`,
@@ -218,9 +218,8 @@ export const SEVERITY_KINDS: Set<string> = new Set(["friction", "deferral", "fai
218
218
  * `OPEN` raised, cause unknown -> `TRIAGED` analysed, disposition known, not yet
219
219
  * fixed -> `CLOSED` dealt with (fixed, refuted, or established as not ours).
220
220
  *
221
- * `TRIAGED` IS STILL OPEN WORK. Readers counting open entries — a CI gate on open
222
- * CRITICAL failures, an audit debt lens, an age report — MUST count it. Only
223
- * `CLOSED` is done.
221
+ * `TRIAGED` IS STILL OPEN WORK. Readers counting open entries — an audit debt
222
+ * lens, an age report — MUST count it. Only `CLOSED` is done.
224
223
  *
225
224
  * NOT on knowledge or decision. Both use the `ACTIVE` / `SUPERSEDED`
226
225
  * lifecycle, a different axis entirely. Absent `status` = `ACTIVE`.
@@ -1,7 +1,7 @@
1
1
  // --- Secret-file read tier: identical in the Cursor and Google Antigravity guardrails hooks
2
2
  // (bkit renders it from one source). Same policy as Claude's settings.json `Read(...)` deny /
3
3
  // ask rows and opencode's `permission.read` map; each host maps a tier to its own output
4
- // shape and wording.
4
+ // shape and wording. Needs `secretFileKind` from `guardrails-tiers.js` above it.
5
5
 
6
6
  /**
7
7
  * The read tier for a file path (`/` or `\` separated), first match wins:
@@ -11,13 +11,8 @@
11
11
  */
12
12
  function classifyRead(filePath) {
13
13
  const p = String(filePath || "").replace(/\\/g, "/");
14
- if (!p) return null;
15
- if (/\.pem$/i.test(p) || /\.p12$/i.test(p) || /(^|\/)id_rsa$/i.test(p)) {
16
- return { tier: "deny", path: p };
17
- }
18
- const base = p.split("/").pop() || p;
19
- if (base === ".env" || (/^\.env\./.test(base) && base !== ".env.example")) {
20
- return { tier: "ask", path: p };
21
- }
14
+ const kind = secretFileKind(p);
15
+ if (kind === "key") return { tier: "deny", path: p };
16
+ if (kind === "env") return { tier: "ask", path: p };
22
17
  return null;
23
18
  }