@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.
Files changed (212) hide show
  1. package/.bkit/README.md +14 -10
  2. package/.bkit/core/.agents/docs.md +1 -0
  3. package/.bkit/core/.agents/plugins/bkit/hooks/bkit-gateguard.cjs +93 -0
  4. package/.bkit/core/.agents/plugins/bkit/hooks/bkit-guardrails.cjs +137 -0
  5. package/.bkit/core/.agents/plugins/bkit/hooks/bkit-readguard.cjs +72 -0
  6. package/.bkit/core/.agents/rules.md +10 -6
  7. package/.bkit/core/.agents/shortcuts.md +73 -0
  8. package/.bkit/core/.agents/skills.md +5 -3
  9. package/.bkit/core/.bkit/LICENSE.md +18 -140
  10. package/.bkit/core/.bkit/README.md +13 -9
  11. package/.bkit/core/.bkit/cloud.md +12 -15
  12. package/.bkit/core/.bkit/comparison.md +68 -16
  13. package/.bkit/core/.bkit/install.md +36 -11
  14. package/.bkit/core/.bkit/jsonl.md +0 -1
  15. package/.bkit/core/.bkit/prompts.md +83 -81
  16. package/.bkit/core/.bkit/providers.md +110 -28
  17. package/.bkit/core/.bkit/templates.md +42 -13
  18. package/.bkit/core/.bkit/workflows.md +64 -42
  19. package/.bkit/core/.claude/hooks/bkit-gateguard.cjs +4 -3
  20. package/.bkit/core/.claude/hooks/bkit-readguard.cjs +60 -0
  21. package/.bkit/core/.codex/hooks/bkit-gateguard.cjs +8 -6
  22. package/.bkit/core/.codex/hooks/bkit-readguard.cjs +58 -0
  23. package/.bkit/core/.cursor/hooks/bkit-guardrails.cjs +12 -19
  24. package/.bkit/core/.cursor/hooks/bkit-readguard.cjs +59 -0
  25. package/.bkit/core/.opencode/plugin/bkit-gateguard.js +73 -22
  26. package/.bkit/core/.opencode/plugin/bkit-readguard.js +126 -0
  27. package/.bkit/core/AGENTS.md +11 -0
  28. package/.bkit/core/docs/templates/bkit-audit-adoption.md +2 -2
  29. package/.bkit/core/docs/templates/bkit-plan.md +6 -3
  30. package/.bkit/core/engine/checks/after/auth.ts +32 -0
  31. package/.bkit/core/engine/checks/after/github.ts +4 -4
  32. package/.bkit/core/engine/checks/after/index.ts +36 -50
  33. package/.bkit/core/engine/checks/after/managed.ts +44 -1
  34. package/.bkit/core/engine/checks/before/index.ts +5 -4
  35. package/.bkit/core/engine/checks/before/mcp.ts +60 -54
  36. package/.bkit/core/engine/checks/status-holes.ts +1 -1
  37. package/.bkit/core/engine/checks/tips/catalogue.ts +356 -0
  38. package/.bkit/core/engine/checks/tips/detect.ts +144 -0
  39. package/.bkit/core/engine/checks/tips/index.ts +174 -0
  40. package/.bkit/core/engine/cli.ts +82 -18
  41. package/.bkit/core/engine/commands/install/check.ts +2 -0
  42. package/.bkit/core/engine/commands/install/doctor.ts +14 -1
  43. package/.bkit/core/engine/commands/install/install.ts +59 -9
  44. package/.bkit/core/engine/commands/install/uninstall.ts +59 -34
  45. package/.bkit/core/engine/commands/install/upgrade.ts +30 -28
  46. package/.bkit/core/engine/commands/launch.ts +33 -11
  47. package/.bkit/core/engine/commands/tips.ts +16 -0
  48. package/.bkit/core/engine/commands/workflow/prs.ts +20 -2
  49. package/.bkit/core/engine/commands/workflow/runs.ts +82 -18
  50. package/.bkit/core/engine/commands/workflow/runtime.ts +12 -0
  51. package/.bkit/core/engine/commands/workflow/steps.ts +1 -0
  52. package/.bkit/core/engine/commands/workflow/tests.ts +647 -4
  53. package/.bkit/core/engine/commands/workflow/workstreams.ts +4 -4
  54. package/.bkit/core/engine/install/cloud-env.ts +7 -21
  55. package/.bkit/core/engine/install/hosts.ts +21 -0
  56. package/.bkit/core/engine/install/managed-block.ts +36 -0
  57. package/.bkit/core/engine/install/manifest.ts +83 -5
  58. package/.bkit/core/engine/install/modules/antigravity.ts +266 -0
  59. package/.bkit/core/engine/install/modules/claude.ts +6 -6
  60. package/.bkit/core/engine/install/modules/cloud.ts +2 -2
  61. package/.bkit/core/engine/install/modules/codex.ts +8 -5
  62. package/.bkit/core/engine/install/modules/core.ts +30 -10
  63. package/.bkit/core/engine/install/modules/cursor.ts +6 -6
  64. package/.bkit/core/engine/install/modules/index.ts +33 -6
  65. package/.bkit/core/engine/install/modules/opencode.ts +4 -4
  66. package/.bkit/core/engine/install/payload-links.ts +6 -10
  67. package/.bkit/core/engine/install/placeholders.ts +1 -1
  68. package/.bkit/core/engine/install/version-file.ts +17 -9
  69. package/.bkit/core/engine/install/write.ts +68 -1
  70. package/.bkit/core/engine/ledgers/telemetry.ts +0 -2
  71. package/.bkit/core/engine/render/hosts.ts +174 -1
  72. package/.bkit/core/engine/render/models.ts +10 -0
  73. package/.bkit/core/engine/shared/package-roots.ts +8 -10
  74. package/.bkit/core/hooks/antigravity-hook.js +67 -0
  75. package/.bkit/core/hooks/gateguard-edit-payload.js +4 -4
  76. package/.bkit/core/hooks/gateguard-engine.js +16 -6
  77. package/.bkit/core/hooks/guardrails-read.js +23 -0
  78. package/.bkit/core/hooks/readguard-engine.js +259 -0
  79. package/.bkit/core/hooks/readguard-payload.js +67 -0
  80. package/.bkit/core/prompts/bkit-audit-generate.md +2 -1
  81. package/.bkit/core/prompts/bkit-build-challenge-1.md +2 -1
  82. package/.bkit/core/prompts/bkit-build-challenge-2.md +2 -1
  83. package/.bkit/core/prompts/bkit-build-challenge-reconcile.md +2 -1
  84. package/.bkit/core/prompts/bkit-build-challenge-remediate.md +2 -1
  85. package/.bkit/core/prompts/bkit-build-challenge-tests.md +2 -1
  86. package/.bkit/core/prompts/bkit-build-install-skills.md +7 -5
  87. package/.bkit/core/prompts/bkit-build-plan-current.md +2 -1
  88. package/.bkit/core/prompts/bkit-build-plan-execute.md +6 -2
  89. package/.bkit/core/prompts/bkit-build-plan-gaps-remediate.md +2 -1
  90. package/.bkit/core/prompts/bkit-build-plan-verify.md +12 -4
  91. package/.bkit/core/prompts/bkit-build-summary.md +2 -1
  92. package/.bkit/core/prompts/bkit-debug-abort-handover.md +2 -1
  93. package/.bkit/core/prompts/bkit-debug-failure-diagnose.md +2 -1
  94. package/.bkit/core/prompts/bkit-debug-failure-remediate.md +2 -1
  95. package/.bkit/core/prompts/bkit-debug-failure-soak.md +2 -1
  96. package/.bkit/core/prompts/bkit-debug-summary.md +2 -1
  97. package/.bkit/core/prompts/bkit-design-brainstorm-ideate-1.md +2 -1
  98. package/.bkit/core/prompts/bkit-design-brainstorm-ideate-2.md +2 -1
  99. package/.bkit/core/prompts/bkit-design-brainstorm-ideate-3.md +2 -1
  100. package/.bkit/core/prompts/bkit-design-generate.md +10 -5
  101. package/.bkit/core/prompts/bkit-design-organise.md +2 -1
  102. package/.bkit/core/prompts/bkit-design-review-1.md +2 -1
  103. package/.bkit/core/prompts/bkit-design-review-2.md +2 -1
  104. package/.bkit/core/prompts/bkit-design-spike.md +2 -1
  105. package/.bkit/core/prompts/bkit-design-summary.md +2 -1
  106. package/.bkit/core/prompts/bkit-design-update.md +2 -1
  107. package/.bkit/core/prompts/bkit-plan-complexity-check.md +2 -1
  108. package/.bkit/core/prompts/bkit-plan-complexity-split.md +4 -3
  109. package/.bkit/core/prompts/bkit-plan-generate.md +2 -1
  110. package/.bkit/core/prompts/bkit-plan-review-1.md +2 -1
  111. package/.bkit/core/prompts/bkit-plan-review-2.md +2 -1
  112. package/.bkit/core/prompts/bkit-plan-review-3.md +2 -1
  113. package/.bkit/core/prompts/bkit-plan-scope-check-1.md +3 -2
  114. package/.bkit/core/prompts/bkit-plan-scope-check-2.md +3 -2
  115. package/.bkit/core/prompts/bkit-plan-summary.md +2 -1
  116. package/.bkit/core/prompts/bkit-plan-update.md +3 -2
  117. package/.bkit/core/prompts/bkit-ship-conflict-resolve.md +2 -1
  118. package/.bkit/core/prompts/bkit-ship-deferred-sweep.md +2 -1
  119. package/.bkit/core/prompts/bkit-ship-summary.md +2 -1
  120. package/.bkit/core/prompts/bkit-ship-update-docs.md +2 -1
  121. package/.bkit/core/prompts/bkit-utility-compress-markdown.md +2 -1
  122. package/.bkit/core/prompts/bkit-utility-update-decisions.md +2 -1
  123. package/.bkit/core/prompts/bkit-utility-update-deferrals.md +2 -1
  124. package/.bkit/core/prompts/bkit-utility-update-documentation.md +2 -1
  125. package/.bkit/core/prompts/bkit-utility-update-failures.md +2 -1
  126. package/.bkit/core/prompts/bkit-utility-update-knowledge.md +2 -1
  127. package/.bkit/core/prompts/bkit-utility-update-roadmap.md +4 -3
  128. package/.bkit/core/workflows/bkit-auto.md +1 -1
  129. package/.bkit/core/workflows/bkit-build.md +35 -21
  130. package/.bkit/core/workflows/bkit-debug.md +31 -22
  131. package/.bkit/core/workflows/bkit-design.md +83 -38
  132. package/.bkit/core/workflows/bkit-plan.md +10 -2
  133. package/.bkit/core/workflows/bkit-ship.md +10 -2
  134. package/.bkit/shared/.agents/plugins/bkit/hooks.json +36 -0
  135. package/.bkit/shared/.agents/plugins/bkit/plugin.json +5 -0
  136. package/.bkit/shared/.claude/settings.json +19 -0
  137. package/.bkit/shared/.codex/hooks.json +21 -0
  138. package/.bkit/shared/.cursor/hooks.json +6 -1
  139. package/.bkit/shared/.opencode/opencode.json +1 -1
  140. package/.bkit/shared/GEMINI.md +11 -0
  141. package/.bkit/shared/docs/deployments.md +1 -1
  142. package/.bkit/shared/docs/security.md +3 -3
  143. package/.bkit/shared/docs/testing.md +12 -1
  144. package/.bkit/templates/.github/dependabot.yml +6 -0
  145. package/.bkit/templates/.github/renovate.json5 +3 -3
  146. package/.bkit/templates/.github/workflows/bkit-ci.yml +24 -13
  147. package/.bkit/templates/.github/workflows/bkit-cloud.yml +5 -5
  148. package/.bkit/templates/.prettierignore +4 -1
  149. package/.bkit/templates/context/bkit-expo.md +22 -13
  150. package/.bkit/templates/context/bkit-github.md +20 -6
  151. package/.bkit/templates/context/bkit-inngest.md +10 -4
  152. package/.bkit/templates/context/bkit-maestro.md +5 -5
  153. package/.bkit/templates/context/bkit-playwright.md +3 -3
  154. package/.bkit/templates/context/bkit-sentry.md +6 -5
  155. package/.bkit/templates/context/bkit-stripe.md +31 -8
  156. package/.bkit/templates/scripts/ci/check-accepted-divergences.mjs +65 -19
  157. package/.bkit/templates/scripts/ci/check-accepted-divergences.test.mjs +34 -0
  158. package/.bkit/templates/scripts/ci/lanes/resolve-push-base.mjs +33 -12
  159. package/.bkit/templates/scripts/ci/lanes/resolve-push-base.test.mjs +54 -0
  160. package/.bkit/templates/scripts/graphify/bkit-graph-pre-push.sh +2 -2
  161. package/.bkit/templates/scripts/launchd/bkit-launchd-env.sh +76 -6
  162. package/.bkit/templates/slop-scan.config.json +10 -3
  163. package/CHANGELOG.md +62 -0
  164. package/LICENSE.md +21 -161
  165. package/README.md +66 -35
  166. package/dist/checks/after/auth.js +28 -0
  167. package/dist/checks/after/github.js +4 -4
  168. package/dist/checks/after/index.js +29 -45
  169. package/dist/checks/after/managed.js +41 -1
  170. package/dist/checks/before/index.js +5 -4
  171. package/dist/checks/before/mcp.js +53 -53
  172. package/dist/checks/status-holes.js +1 -1
  173. package/dist/checks/tips/catalogue.js +297 -0
  174. package/dist/checks/tips/detect.js +130 -0
  175. package/dist/checks/tips/index.js +146 -0
  176. package/dist/cli.js +68 -17
  177. package/dist/commands/install/check.js +2 -0
  178. package/dist/commands/install/doctor.js +9 -1
  179. package/dist/commands/install/install.js +49 -8
  180. package/dist/commands/install/uninstall.js +61 -34
  181. package/dist/commands/install/upgrade.js +31 -33
  182. package/dist/commands/launch.js +27 -11
  183. package/dist/commands/tips.js +10 -0
  184. package/dist/commands/workflow/prs.js +13 -1
  185. package/dist/commands/workflow/runs.js +74 -18
  186. package/dist/commands/workflow/runtime.js +8 -0
  187. package/dist/commands/workflow/steps.js +1 -0
  188. package/dist/commands/workflow/tests.js +541 -4
  189. package/dist/commands/workflow/workstreams.js +4 -4
  190. package/dist/install/cloud-env.js +3 -14
  191. package/dist/install/hosts.js +22 -0
  192. package/dist/install/managed-block.js +36 -0
  193. package/dist/install/manifest.js +79 -4
  194. package/dist/install/modules/antigravity.js +225 -0
  195. package/dist/install/modules/claude.js +6 -6
  196. package/dist/install/modules/cloud.js +2 -2
  197. package/dist/install/modules/codex.js +8 -5
  198. package/dist/install/modules/core.js +21 -6
  199. package/dist/install/modules/cursor.js +6 -6
  200. package/dist/install/modules/index.js +17 -6
  201. package/dist/install/modules/opencode.js +4 -4
  202. package/dist/install/payload-links.js +5 -5
  203. package/dist/install/placeholders.js +1 -1
  204. package/dist/install/version-file.js +12 -3
  205. package/dist/install/write.js +61 -2
  206. package/dist/render/hosts.js +149 -1
  207. package/dist/render/models.js +9 -0
  208. package/dist/shared/package-roots.js +8 -11
  209. package/package.json +8 -8
  210. package/.bkit/core/LICENSE.md +0 -149
  211. package/.bkit/shared/LICENSE.md +0 -22
  212. package/.bkit/templates/LICENSE.md +0 -22
@@ -2,7 +2,7 @@
2
2
  // Each module function receives { dryRun, tokens, modelLookup, advisories, ws, … } (ModuleContext)
3
3
  // and emits writes into the shared WriteSet.
4
4
  //
5
- // Dispatch order: core → claude → cursor → opencode → codex → cloud
5
+ // Dispatch order: core → claude → cursor → opencode → codex → antigravity → cloud
6
6
  // .bkit/version is written LAST — in postDispatch after ALL modules complete (MED-4).
7
7
  import * as fs from "node:fs";
8
8
  import * as path from "node:path";
@@ -13,6 +13,7 @@ import { renderClaudeAgentsCommands, runClaudeModule } from "./claude.js";
13
13
  import { renderCursorAgentsCommands, runCursorModule } from "./cursor.js";
14
14
  import { renderOpencodeAgentsCommands, runOpencodeModule } from "./opencode.js";
15
15
  import { CODEX_SKILLS_DIR, renderCodexAgentsSkills, runCodexModule } from "./codex.js";
16
+ import { ANTIGRAVITY_SKILLS_DIR, renderAntigravityAgentsSkills, runAntigravityModule, } from "./antigravity.js";
16
17
  import { runCloudModule } from "./cloud.js";
17
18
  // ---------------------------------------------------------------------------
18
19
  // renderManagedOutputs — re-render the bkit-managed OUTPUT files that the
@@ -52,6 +53,8 @@ export function renderManagedOutputs(modules, ctx) {
52
53
  written.push(...renderOpencodeAgentsCommands(ctx));
53
54
  if (modules.has("codex"))
54
55
  written.push(...renderCodexAgentsSkills(ctx));
56
+ if (modules.has("antigravity"))
57
+ written.push(...renderAntigravityAgentsSkills(ctx));
55
58
  return written;
56
59
  }
57
60
  /** Rendered mirror dirs: every `bkit-*` file of the given extension in each is bkit's. */
@@ -63,6 +66,7 @@ const RENDERED_MIRRORS = [
63
66
  [".opencode/agents", ".md"],
64
67
  [".opencode/commands", ".md"],
65
68
  [".codex/agents", ".toml"],
69
+ [".agents/plugins/bkit/agents", ".md"],
66
70
  ];
67
71
  /**
68
72
  * Every file bkit writes into `cwd` that carries the managed-version marker: the core
@@ -98,13 +102,18 @@ export function listStampedFiles(cwd) {
98
102
  add(path.join(dir, f), "whole");
99
103
  }
100
104
  }
101
- const skills = path.join(cwd, CODEX_SKILLS_DIR);
102
- if (fs.existsSync(skills)) {
103
- for (const d of fs.readdirSync(skills)) {
105
+ // Codex renders workflow skills into `.agents/skills/bkit-*/SKILL.md`; Antigravity renders
106
+ // its own into the plugin `.agents/plugins/bkit/skills/bkit-*/SKILL.md`. Both stamp a
107
+ // managed-version marker; collect each for the stale detector.
108
+ for (const dir of [CODEX_SKILLS_DIR, ANTIGRAVITY_SKILLS_DIR]) {
109
+ const abs = path.join(cwd, dir);
110
+ if (!fs.existsSync(abs))
111
+ continue;
112
+ for (const d of fs.readdirSync(abs)) {
104
113
  if (!d.startsWith(BKIT_PREFIX))
105
114
  continue;
106
- if (fs.existsSync(path.join(skills, d, "SKILL.md"))) {
107
- add(path.join(CODEX_SKILLS_DIR, d, "SKILL.md"), "whole");
115
+ if (fs.existsSync(path.join(abs, d, "SKILL.md"))) {
116
+ add(path.join(dir, d, "SKILL.md"), "whole");
108
117
  }
109
118
  }
110
119
  }
@@ -119,6 +128,7 @@ export const MODULE_REGISTRY = {
119
128
  cursor: runCursorModule,
120
129
  opencode: runOpencodeModule,
121
130
  codex: runCodexModule,
131
+ antigravity: runAntigravityModule,
122
132
  cloud: runCloudModule,
123
133
  // "full" is never directly in the registry — resolveModules expands it to all modules
124
134
  };
@@ -129,6 +139,7 @@ export const MODULE_DISPATCH_ORDER = [
129
139
  "cursor",
130
140
  "opencode",
131
141
  "codex",
142
+ "antigravity",
132
143
  "cloud",
133
144
  ];
134
145
  /**
@@ -470,11 +470,11 @@ export function runOpencodeModule(ctx) {
470
470
  }
471
471
  }
472
472
  }
473
- // --- bkit-gateguard.js — Tier-2 markered-text (slash-comment); see install/manifest.ts ---
474
- {
473
+ // --- bkit-gateguard.js / bkit-readguard.js — Tier-2 markered-text (slash-comment); see install/manifest.ts ---
474
+ for (const plugin of ["bkit-gateguard.js", "bkit-readguard.js"]) {
475
475
  const opencodeCore = path.join(getCoreRoot(), ".opencode", "plugin");
476
- const pluginSrc = path.join(opencodeCore, "bkit-gateguard.js");
477
- const pluginDst = ".opencode/plugin/bkit-gateguard.js";
476
+ const pluginSrc = path.join(opencodeCore, plugin);
477
+ const pluginDst = `.opencode/plugin/${plugin}`;
478
478
  if (fs.existsSync(pluginSrc)) {
479
479
  // dryRun-gated — writeTier2 honours dryRun, so the dir is only needed for a real
480
480
  // write; `bkit check` stays read-only when gateguard's parent dir is absent.
@@ -36,10 +36,11 @@ export function createPayloadLink(targetAbs, linkAbs, symlinkFn = fs.symlinkSync
36
36
  // Create or refresh the consumer's `.bkit/core` + `.bkit/shared` view links into
37
37
  // the package payload. Idempotent: a correct link is kept, a dangling or
38
38
  // mis-pointed symlink is re-pointed, a real directory or file is NEVER clobbered
39
- // (skippedRealDir) and a platform refusal is only recorded (failed). Every create
40
- // or repair pushes a ws write in dry-run and live alike, so `bkit check` flags a
41
- // missing or broken link as drift. No-op in dogfood: there `.bkit/core` IS the
42
- // package source, never a view onto it.
39
+ // (skippedRealDir) and a platform refusal is only recorded (failed). Links are
40
+ // convenience views, not managed content: they never join the install WriteSet, so
41
+ // a missing or broken link is never `bkit check` drift (a fresh clone or worktree
42
+ // has none). Dry-run reports what a live run would do and touches nothing. No-op
43
+ // in dogfood: there `.bkit/core` IS the package source, never a view onto it.
43
44
  export function syncPayloadLinks(cwd, opts) {
44
45
  const changes = {
45
46
  created: [],
@@ -97,7 +98,6 @@ export function syncPayloadLinks(cwd, opts) {
97
98
  }
98
99
  }
99
100
  (st !== null ? changes.repaired : changes.created).push(relPath);
100
- opts.ws.writes.push({ path: relPath, action: "write" });
101
101
  }
102
102
  return changes;
103
103
  }
@@ -81,7 +81,7 @@ export function applyTokens(content, tokens) {
81
81
  const version = tokens.BKIT_VERSION ?? readInstallingBkitVersion();
82
82
  out = out
83
83
  .replace(/^\/\/ \{\{BKIT_MANAGED_MARKER\}\}/gm, () => managedVersionMarker(version, "slash"))
84
- .replace(/\{\{BKIT_MANAGED_MARKER\}\}/g, () => managedVersionMarker(version));
84
+ .replace(/\{\{BKIT_MANAGED_MARKER\}\}/g, () => managedVersionMarker(version, "html"));
85
85
  }
86
86
  return out;
87
87
  }
@@ -115,14 +115,23 @@ export function isConsumerModified(relPath, absolutePath, canonicalHashes) {
115
115
  * cases; the latter survive the absent-path prune because the adopted copy stays on
116
116
  * disk).
117
117
  *
118
+ * `removing` lists paths (or directories) a dry run would delete: they count as absent, so a
119
+ * dry run prunes the same entries the real run does.
120
+ *
118
121
  * `pruned` counts the dropped entries so callers can treat a prune-only merge as a
119
122
  * change that is still worth writing.
120
123
  */
121
- export function mergeCanonicalHashes(cwd, existing, fresh) {
124
+ export function mergeCanonicalHashes(cwd, existing, fresh, removing = []) {
122
125
  const canonicalHashes = {};
126
+ const isRemoving = (relPath) => removing.some((r) => {
127
+ const dir = r.replace(/[\\/]+$/, "");
128
+ return relPath === dir || relPath.startsWith(`${dir}/`);
129
+ });
123
130
  let pruned = 0;
124
131
  for (const [relPath, hash] of Object.entries(existing)) {
125
- if (!fs.existsSync(path.join(cwd, relPath)) || isTemplateSetPath(relPath)) {
132
+ if (!fs.existsSync(path.join(cwd, relPath)) ||
133
+ isRemoving(relPath) ||
134
+ isTemplateSetPath(relPath)) {
126
135
  pruned++;
127
136
  continue;
128
137
  }
@@ -161,7 +170,7 @@ export const MANAGED_MARKER_LINE_RE = /^(?:<!-- |# <!-- |\/\/ )bkit:managed v[^\
161
170
  export const MANAGED_MARKER_VERSION_RE = /bkit:managed v(\S+)/;
162
171
  /** Build the managed-version marker for a given version, in the given comment syntax. */
163
172
  export function managedVersionMarker(version, form = "html") {
164
- const text = `bkit:managed v${version} — PolyForm Noncommercial 1.0.0 / Small Business 1.0.0 (https://polyformproject.org/licenses/) — do not edit; run \`bkit upgrade\` to refresh`;
173
+ const text = `bkit:managed v${version} — do not edit; run \`bkit upgrade\` to refresh`;
165
174
  if (form === "slash")
166
175
  return `// ${text}`;
167
176
  return form === "hash" ? `# <!-- ${text} -->` : `<!-- ${text} -->`;
@@ -1,8 +1,9 @@
1
1
  import * as fs from "node:fs";
2
2
  import * as path from "node:path";
3
- import { updateManagedBlock, extractFullManagedBlock, extractManagedBlock, findLineAnchoredMarkers, selectMarkers, } from "./managed-block.js";
3
+ import { updateManagedBlock, extractFullManagedBlock, extractManagedBlock, findLineAnchoredMarkers, findUnmarkedCopy, selectMarkers, } from "./managed-block.js";
4
4
  import { readTemplate } from "../render/parts.js";
5
5
  import { applyTokens } from "./placeholders.js";
6
+ import { sha256 } from "./version-file.js";
6
7
  export function deepContains(template, consumer, pathPrefix = "") {
7
8
  const missing = [];
8
9
  const mismatched = [];
@@ -141,7 +142,7 @@ export function deepMergeJson(base, override) {
141
142
  // - dest present, valid JSON, template contained → no-op (idempotent)
142
143
  // - dest present, valid JSON, containment fails → deepMergeJson(existing, template)
143
144
  // (template wins on key collisions; consumer-only keys outside template tree preserved)
144
- // - dest present, malformed JSON → overwrite with template
145
+ // - dest present, malformed JSON → throw; the consumer fixes it by hand
145
146
  // - schemaFlipped: true when a path value changed type during deep-merge
146
147
  // ---------------------------------------------------------------------------
147
148
  export function writeTier2JsonContained(srcPath, dstPath, dryRun, ws) {
@@ -225,12 +226,65 @@ export function writeTier1(srcPath, dstPath, tokens, dryRun, ws) {
225
226
  // - dest absent → write whole file (with token substitution)
226
227
  // - dest has markers → update only the bkit block (tokens applied to new block content)
227
228
  // - dest present, no marks → append full block at EOF; preserve consumer content above
229
+ // - no marks, markdown dest already holds an unmarked copy of the block (findUnmarkedCopy)
230
+ // → warn + skip; appending would leave a frozen duplicate above it
228
231
  //
229
232
  // markerStyle: "html-comment" for markdown, shell and `.gitignore` (`# ` prefix allowed);
230
233
  // "slash-comment" for JS.
231
234
  // ---------------------------------------------------------------------------
235
+ /**
236
+ * sha256 of the driver (everything outside the managed block) of hook files a bkit
237
+ * release shipped with a host contract the host does not accept, keyed by consumer path.
238
+ * Register: docs/migrations.md.
239
+ */
240
+ export const RETIRED_DRIVER_HASHES = {
241
+ // 5.1.0: Claude-shaped `hookSpecificOutput`; Antigravity reads `{ decision, reason }`.
242
+ ".agents/plugins/bkit/hooks/bkit-gateguard.cjs": [
243
+ "544dbcc2bab81875789563a2925bb5dc7b5dbbcf185f216fb3281cfa01ec030d",
244
+ ],
245
+ ".agents/plugins/bkit/hooks/bkit-guardrails.cjs": [
246
+ "8e5d75f7e1a4527889dafa6a250ae370e2acf1b5fc7d58929dfc759489746e14",
247
+ ],
248
+ };
249
+ /** The text outside a file's single managed block, or null without exactly one block. */
250
+ export function driverText(content, markerStyle) {
251
+ const [startMarker, endMarker] = selectMarkers(markerStyle);
252
+ const starts = findLineAnchoredMarkers(content, startMarker);
253
+ const ends = findLineAnchoredMarkers(content, endMarker);
254
+ if (starts.length !== 1 || ends.length !== 1 || ends[0] < starts[0])
255
+ return null;
256
+ return content.slice(0, starts[0]) + content.slice(ends[0]);
257
+ }
258
+ /**
259
+ * True when `dstPath` still carries a retired bkit driver the consumer never edited. An
260
+ * edited driver still on the retired output shape is kept and gets a printed fix.
261
+ */
262
+ function hasRetiredDriver(dstPath, content, markerStyle) {
263
+ const posix = dstPath.replace(/\\/g, "/");
264
+ const key = Object.keys(RETIRED_DRIVER_HASHES).find((rel) => posix === rel || posix.endsWith(`/${rel}`));
265
+ if (key === undefined)
266
+ return false;
267
+ const driver = driverText(content, markerStyle);
268
+ if (driver === null)
269
+ return false;
270
+ if (RETIRED_DRIVER_HASHES[key].includes(sha256(driver)))
271
+ return true;
272
+ if (driver.includes("hookSpecificOutput")) {
273
+ console.warn(`[bkit] ${dstPath}: your driver below \`// bkit:end\` writes Claude-shaped \`hookSpecificOutput\`, which Antigravity ignores — the hook never takes effect. Emit the managed block's result as Antigravity's \`{ "decision": "allow" | "deny" | "ask", "reason": "…" }\` (only a deny's reason reaches the model), or delete the file and re-run \`bkit install --antigravity\` to get bkit's driver.`);
274
+ }
275
+ return false;
276
+ }
232
277
  export function writeTier2(srcPath, dstPath, tokens, markerStyle, dryRun, ws) {
233
278
  const srcRaw = readTemplate(srcPath);
279
+ // A retired, unedited bkit driver is bkit's code, not the consumer's: replace the
280
+ // whole file so the new driver ships with the new block.
281
+ if (fs.existsSync(dstPath) &&
282
+ hasRetiredDriver(dstPath, fs.readFileSync(dstPath, "utf-8"), markerStyle)) {
283
+ if (!dryRun)
284
+ fs.writeFileSync(dstPath, applyTokens(srcRaw, tokens), "utf-8");
285
+ ws.writes.push({ path: dstPath, action: "write" });
286
+ return;
287
+ }
234
288
  if (!fs.existsSync(dstPath)) {
235
289
  // dest missing → write whole template (with tokens applied)
236
290
  const content = applyTokens(srcRaw, tokens);
@@ -264,6 +318,11 @@ export function writeTier2(srcPath, dstPath, tokens, markerStyle, dryRun, ws) {
264
318
  }
265
319
  // dest has no markers → append full block at EOF (with tokens applied)
266
320
  const appliedBlock = applyTokens(fullBlock, tokens);
321
+ const copyTitle = dstPath.endsWith(".md") ? findUnmarkedCopy(destContent, appliedBlock) : null;
322
+ if (copyTitle !== null) {
323
+ console.warn(`[bkit] ${dstPath} has no managed-block markers but already holds an older bkit copy (\`${copyTitle}\`) — skipping, so it is not duplicated. Delete the file and re-run install; then re-add any lines you wrote yourself below \`<!-- bkit:end -->\`.`);
324
+ return;
325
+ }
267
326
  const sep = destContent.length === 0
268
327
  ? ""
269
328
  : destContent.endsWith("\n\n")
@@ -1,5 +1,5 @@
1
1
  // render/hosts.ts — workflow and prompt sources → host agent, command and skill copies
2
- // (claude T1/T2, cursor T3, opencode, codex) and the frontmatter parser they share.
2
+ // (claude T1/T2, cursor T3, opencode, codex, antigravity) and the frontmatter parser they share.
3
3
  import { formatModelPin, lookupEffort } from "./models.js";
4
4
  import { LOG_PREFIX } from "../shared/log-prefix.js";
5
5
  /**
@@ -37,6 +37,58 @@ export function opencodeToolsBlock(toolsBlock) {
37
37
  }
38
38
  return out;
39
39
  }
40
+ /**
41
+ * Antigravity built-in tool names. Antigravity (`.agents/`) uses lower_snake_case tool
42
+ * names that differ from Claude's capitalized set, so the declared `tools:` block must be
43
+ * respelled — an unknown tool name is not guaranteed to resolve on that host. Unknown
44
+ * Claude names are passed through unchanged (best effort); MCP tools keep their
45
+ * `mcp__<server>__<tool>` spelling.
46
+ */
47
+ const ANTIGRAVITY_TOOL_MAP = {
48
+ read: "view_file",
49
+ glob: "list_dir",
50
+ grep: "grep_search",
51
+ write: "write_to_file",
52
+ edit: "replace_file_content",
53
+ bash: "run_command",
54
+ websearch: "search_web",
55
+ webfetch: "read_url",
56
+ };
57
+ /**
58
+ * Convert a Claude `tools:` frontmatter block into Antigravity's tool vocabulary
59
+ * (`view_file`, `write_to_file`, `replace_file_content`, `run_command`, `grep_search`,
60
+ * `list_dir`, …). Emits the same YAML list shape as the source so a consumer can read the
61
+ * file. Returns "" when there are no tools (field omitted — also valid).
62
+ */
63
+ export function antigravityToolsBlock(toolsBlock) {
64
+ if (!toolsBlock)
65
+ return "";
66
+ const names = [];
67
+ for (const m of toolsBlock.matchAll(/^[ \t]*-[ \t]*([A-Za-z][\w*-]*)/gm))
68
+ names.push(m[1]);
69
+ if (names.length === 0) {
70
+ // Fallback: inline array form `tools: [Read, Write]`.
71
+ const inline = toolsBlock.match(/\[([^\]]*)\]/);
72
+ if (inline) {
73
+ for (const t of inline[1].split(",")) {
74
+ const n = t.trim().replace(/['"]/g, "");
75
+ if (n)
76
+ names.push(n);
77
+ }
78
+ }
79
+ }
80
+ if (names.length === 0)
81
+ return "";
82
+ let out = "tools:\n";
83
+ for (const n of names) {
84
+ if (n.startsWith("mcp__")) {
85
+ out += ` - ${n}\n`;
86
+ continue;
87
+ }
88
+ out += ` - ${ANTIGRAVITY_TOOL_MAP[n.toLowerCase()] ?? n}\n`;
89
+ }
90
+ return out;
91
+ }
40
92
  /**
41
93
  * OC1: opencode agent frontmatter rewrite.
42
94
  * Emits: mode, name, description, model, tools (Claude array → opencode object map),
@@ -337,3 +389,99 @@ export function applyT3(content, modelLookup, effortMap) {
337
389
  newFm += "---\n";
338
390
  return newFm + afterFm;
339
391
  }
392
+ /**
393
+ * Antigravity subagent-definition directory — the `agents/` folder of the bkit workspace
394
+ * plugin (`.agents/plugins/bkit/`). The host install lives entirely inside the plugin so
395
+ * `.agents/` root stays Codex's.
396
+ */
397
+ export const ANTIGRAVITY_AGENTS_DIR = ".agents/plugins/bkit/agents";
398
+ /**
399
+ * Antigravity command/skill invocation rewrite. Antigravity has no native subagent tool:
400
+ * the orchestrator loads a subagent prompt in-session with `view_file` and executes its
401
+ * step contract, so both Claude tools (`Agent` / `Skill`) respell to `view_file`. A
402
+ * `**Subagent:** @name` reference resolves to the rendered prompt file it must load
403
+ * (`<agentsDir>/<name>.md`). Does NOT rewrite body prose or gate-checklist `@agent` refs.
404
+ */
405
+ export function applyAntigravityToolRewrites(content, agentsDir = ANTIGRAVITY_AGENTS_DIR) {
406
+ let result = content.replace(/`Agent` tool/g, "`view_file` tool");
407
+ result = result.replace(/using `Agent` tool/g, "using `view_file` tool");
408
+ result = result.replace(/`Skill` tool/g, "`view_file` tool");
409
+ result = result.replace(/using `Skill` tool/g, "using `view_file` tool");
410
+ // Backticked `@agent` on any **Subagent:** line (numbered, list-indented, or bare).
411
+ result = result.replace(/^([^\n]*?\*\*Subagent:\*\*[^\n]*?)`@([a-z][a-z0-9-]*)`/gm, `$1\`view_file\` \`${agentsDir}/$2.md\``);
412
+ // Bare `@agent` immediately after **Subagent:** (exact-line form).
413
+ result = result.replace(/^([^\n]*?\*\*Subagent:\*\* )@([a-z][a-z0-9-]*)\b/gm, `$1\`view_file\` \`${agentsDir}/$2.md\``);
414
+ result = result.replace(/Invoke using `@name`/g, `Invoke using \`view_file\` \`${agentsDir}/name.md\``);
415
+ return result;
416
+ }
417
+ /**
418
+ * Convert a Claude-format subagent prompt (`.bkit/core/prompts/*.md`) into an Antigravity
419
+ * prompt (`.agents/plugins/bkit/agents/<name>.md`).
420
+ *
421
+ * Antigravity loads subagent prompts from `.agents/plugins/bkit/agents/` and executes them
422
+ * in-session (the orchestrator loads the file with `view_file`). The frontmatter is rewritten to
423
+ * Antigravity's vocabulary: `name`/`description` preserved, the model pin from the
424
+ * `.bkit/prompts.md` § Models `Google` column (bare `gemini-3.8-*` id), the thinking
425
+ * `effort` remapped through the `Antigravity` column, and the `tools:` block respelled to
426
+ * Antigravity tool names. Claude-only fields (permissionMode, maxTurns, is_background,
427
+ * readonly) are dropped. Hard-fails with non-zero exit if the model lookup is missing.
428
+ */
429
+ export function applyAntigravityPrompt(content, modelLookup, effortMap) {
430
+ const fmMatch = content.match(/^(---\r?\n)([\s\S]*?)(\r?\n---\r?\n?)/);
431
+ if (!fmMatch)
432
+ return content;
433
+ const fmBlock = fmMatch[2];
434
+ const afterFm = content.slice(fmMatch[0].length);
435
+ const parsed = parseFrontmatter(fmBlock);
436
+ const name = parsed.get("name") ?? "";
437
+ if (!name) {
438
+ console.error(`${LOG_PREFIX} Subagent frontmatter missing 'name' field`);
439
+ process.exit(1);
440
+ }
441
+ const model = modelLookup.get(name);
442
+ if (!model) {
443
+ console.error(`${LOG_PREFIX} Missing antigravity model lookup for ${name}`);
444
+ process.exit(1);
445
+ }
446
+ const description = parsed.get("description") ?? "";
447
+ const effort = parsed.get("effort");
448
+ const toolsBlock = extractFrontmatterField(fmBlock, "tools");
449
+ let newFm = "---\n";
450
+ newFm += `name: ${name}\n`;
451
+ if (description.includes("\n")) {
452
+ const indented = description.split("\n").join("\n ");
453
+ newFm += `description: |\n ${indented}\n`;
454
+ }
455
+ else {
456
+ newFm += `description: ${description}\n`;
457
+ }
458
+ newFm += `model: ${formatModelPin("antigravity", "google", model)}\n`;
459
+ if (effort && effortMap) {
460
+ newFm += `effort: ${lookupEffort(effortMap, "antigravity", effort)}\n`;
461
+ }
462
+ newFm += antigravityToolsBlock(toolsBlock);
463
+ newFm += "---\n";
464
+ return newFm + afterFm;
465
+ }
466
+ /**
467
+ * Convert a workflow orchestrator (`.bkit/core/workflows/*.md`) into an Antigravity
468
+ * SKILL.md (`.agents/plugins/bkit/skills/<name>/SKILL.md`). Antigravity auto-discovers
469
+ * skills under a workspace plugin's `skills/`; `name` and `description` are frontmatter
470
+ * keys, and the body is the workflow steps verbatim with invocations respelled to
471
+ * Antigravity's in-session prompt loading (see applyAntigravityToolRewrites).
472
+ */
473
+ export function applyAntigravitySkill(content, skillName, agentsDir = ANTIGRAVITY_AGENTS_DIR) {
474
+ const fmMatch = content.match(/^(---\r?\n)([\s\S]*?)(\r?\n---\r?\n?)/);
475
+ let body;
476
+ let description = `bkit ${skillName} workflow`;
477
+ if (fmMatch) {
478
+ const parsed = parseFrontmatter(fmMatch[2]);
479
+ description = (parsed.get("description") ?? description).replace(/^"|"$/g, "");
480
+ body = content.slice(fmMatch[0].length);
481
+ }
482
+ else {
483
+ body = content;
484
+ }
485
+ const rewritten = applyAntigravityToolRewrites(body, agentsDir);
486
+ return `---\nname: ${skillName}\ndescription: "${description.replace(/"/g, '\\"')}"\n---\n${rewritten}`;
487
+ }
@@ -92,6 +92,7 @@ const GATEWAY_COLUMN = {
92
92
  "opencode-zen": "OpenCode Zen",
93
93
  "opencode-go": "OpenCode Go",
94
94
  openai: "OpenAI",
95
+ google: "Google",
95
96
  };
96
97
  /**
97
98
  * Spell a model pin the way a program's config file expects it.
@@ -121,6 +122,13 @@ export function buildOpencodeModelLookup(subagentsMdPath, provider) {
121
122
  }
122
123
  return parseModelLookupForColumn(subagentsMdPath, header);
123
124
  }
125
+ /**
126
+ * Build the per-agent Antigravity model lookup for Google models.
127
+ * Source of truth = prompts.md § Models, "Google" column.
128
+ */
129
+ export function buildAntigravityModelLookup(subagentsMdPath) {
130
+ return parseModelLookupForColumn(subagentsMdPath, GATEWAY_COLUMN.google);
131
+ }
124
132
  /**
125
133
  * Parse the consumer-owned `## Model Overrides` table (below the `bkit:end` marker)
126
134
  * from an installed prompts.md. Rows are `| Prompt | Provider | Model |`. Best-effort:
@@ -191,6 +199,7 @@ const EFFORT_COLUMN_FOR_PROGRAM = {
191
199
  cursor: "Cursor",
192
200
  opencode: "OpenCode",
193
201
  codex: "Codex",
202
+ antigravity: "Antigravity",
194
203
  };
195
204
  /**
196
205
  * Parse prompts.md effort→provider table (header starts with Default | Claude | …).
@@ -39,16 +39,15 @@ export function getPkgRoot() {
39
39
  : path.resolve(engineDir, "..");
40
40
  }
41
41
  // ---------------------------------------------------------------------------
42
- // The three payload roots. Each folder carries one licence and one install
43
- // behaviour; a file's path inside its folder is where it lands in the consumer
44
- // repo.
42
+ // The three payload roots. Each folder carries one install behaviour; a file's
43
+ // path inside its folder is where it lands in the consumer repo.
45
44
  //
46
- // core/ PolyForm. Written and kept current. engine/, workflows/,
47
- // prompts/, .bkit/, hooks/ and every LICENSE.md are skipped
48
- // by install; the rest is copied at its folder-relative path.
49
- // shared/ MIT-0. Written and kept current: bkit's blocks and keys inside
45
+ // core/ Written and kept current. engine/, workflows/, prompts/,
46
+ // .bkit/ and hooks/ are skipped by install; the rest is copied
47
+ // at its folder-relative path.
48
+ // shared/ Written and kept current: bkit's blocks and keys inside
50
49
  // files the consumer also edits, plus small whole files.
51
- // templates/ MIT-0. Copy-and-own only: never applied to the repo, copied raw
50
+ // templates/ Copy-and-own only: never applied to the repo, copied raw
52
51
  // into the consumer's `.bkit/templates/` by syncTemplateCopies.
53
52
  // ---------------------------------------------------------------------------
54
53
  export function getCoreRoot() {
@@ -96,11 +95,9 @@ export function templateRelPath(dest) {
96
95
  /**
97
96
  * The absolute source path backing a consumer-relative dest, or `null` when no
98
97
  * payload root carries it. Checks `shared/` then `core/`, applying the dotfile
99
- * remap. Root-level `LICENSE.md` files are never install sources.
98
+ * remap.
100
99
  */
101
100
  export function findTemplateSource(relPath) {
102
- if (path.basename(relPath) === "LICENSE.md")
103
- return null;
104
101
  const rel = templateRelPath(relPath);
105
102
  for (const root of [getSharedRoot(), getCoreRoot()]) {
106
103
  const p = path.join(root, rel);
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "@cbartens/bkit",
3
- "version": "5.0.3",
3
+ "version": "5.2.0",
4
4
  "private": false,
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 and opencode.",
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": [
7
7
  "ai-agents",
8
8
  "agentic-coding",
@@ -12,6 +12,8 @@
12
12
  "claude-code",
13
13
  "cursor",
14
14
  "codex",
15
+ "antigravity",
16
+ "gemini",
15
17
  "opencode",
16
18
  "ai-code-review",
17
19
  "code-review",
@@ -35,15 +37,12 @@
35
37
  ".bkit/templates",
36
38
  "dist",
37
39
  "README.md",
38
- "CHANGELOG.md",
39
- "!.bkit/core/engine/**/*.test.ts",
40
- "!.bkit/core/engine/**/*.integration.test.ts",
41
- "!.bkit/core/engine/**/__snapshots__"
40
+ "CHANGELOG.md"
42
41
  ],
43
42
  "engines": {
44
43
  "node": ">=20"
45
44
  },
46
- "packageManager": "pnpm@10.34.4",
45
+ "packageManager": "pnpm@10.34.5",
47
46
  "repository": {
48
47
  "type": "git",
49
48
  "url": "https://github.com/cbartens/bkit.git"
@@ -52,7 +51,7 @@
52
51
  "registry": "https://registry.npmjs.org/",
53
52
  "access": "public"
54
53
  },
55
- "license": "(PolyForm-Noncommercial-1.0.0 OR PolyForm-Small-Business-1.0.0)",
54
+ "license": "MIT",
56
55
  "scripts": {
57
56
  "bkit:gate:format": "pnpm lint-staged",
58
57
  "bkit:gate:static": "pnpm typecheck && pnpm lint && pnpm format:check && pnpm format:tables:check && pnpm lint:prose && pnpm slop:delta",
@@ -60,6 +59,7 @@
60
59
  "bkit:gate:install-static-unit-build": "pnpm install --frozen-lockfile && pnpm bkit:gate:static-unit && pnpm build",
61
60
  "bkit:deps:outdated": "pnpm outdated",
62
61
  "bkit:deps:audit": "pnpm audit",
62
+ "bkit:test:file": "vitest run --reporter=default --reporter=junit --outputFile.junit=\"$BKIT_TEST_REPORT\"",
63
63
  "bkit": "node dist/cli.js",
64
64
  "typecheck": "tsc --noEmit && pnpm bkit:typecheck:tests",
65
65
  "bkit:typecheck:tests": "tsc -p tsconfig.test.json",