@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
@@ -22,7 +22,12 @@ import {
22
22
  getBkitDocsRoot,
23
23
  TEMPLATE_COPIES_DIR,
24
24
  } from "../../shared/package-roots.js";
25
- import { getInstallManifest, BKIT_GATE_SCRIPTS, BKIT_OPTIONAL_GATES } from "../manifest.js";
25
+ import {
26
+ getInstallManifest,
27
+ BKIT_GATE_SCRIPTS,
28
+ BKIT_OPTIONAL_GATES,
29
+ BKIT_TEST_FILE_SCRIPT,
30
+ } from "../manifest.js";
26
31
  import type { ModuleContext } from "./index.js";
27
32
 
28
33
  export function listMdFiles(dir: string, prefix?: string): string[] {
@@ -94,10 +99,9 @@ export function removeOrphans(
94
99
  // ---------------------------------------------------------------------------
95
100
  // Core payload — the files install writes from `core/`, at their
96
101
  // folder-relative dest paths. The package-only subtrees (engine/, workflows/,
97
- // prompts/, .bkit/, hooks/), the root LICENSE.md and the shared/ and
98
- // templates/ payloads are NOT part of this walk: the host modules write their
99
- // own hook files (sourced from `core/`), and `runBkitDocs` mirrors the
100
- // reference docs.
102
+ // prompts/, .bkit/, hooks/) and the shared/ and templates/ payloads are NOT
103
+ // part of this walk: the host modules write their own hook files (sourced from
104
+ // `core/`), and `runBkitDocs` mirrors the reference docs.
101
105
  // ---------------------------------------------------------------------------
102
106
 
103
107
  /** A core-owned payload file and how install writes it. */
@@ -113,7 +117,13 @@ interface CoreTemplateFile {
113
117
  }
114
118
 
115
119
  /** The markered-text `.agents/*.md` blocks core owns. */
116
- const CORE_AGENT_FILES = ["context.md", "docs.md", "rules.md", "skills.md"] as const;
120
+ const CORE_AGENT_FILES = [
121
+ "context.md",
122
+ "docs.md",
123
+ "rules.md",
124
+ "shortcuts.md",
125
+ "skills.md",
126
+ ] as const;
117
127
 
118
128
  // The two shared-root files core writes: stored in `shared/`, owned by the core
119
129
  // manifest, written as html-comment managed blocks.
@@ -220,9 +230,8 @@ function runCoreTemplates(
220
230
  // them, so a consumer edit is replaced. Source of truth is the package's own
221
231
  // `.bkit/core/.bkit/<name>`. (`advisories.md` is a regenerated runtime artifact,
222
232
  // `wording.md` is repo-only tooling and `friction.md` is a consumer-owned seed —
223
- // none belongs here. `LICENSE.md` is the PolyForm notice that travels with every
224
- // file bkit writes: PolyForm's Notices section requires a passed-on copy to carry
225
- // the terms or their URL and the Required Notice line.)
233
+ // none belongs here. `LICENSE.md` is the MIT notice that travels with the files bkit
234
+ // writes: MIT requires the copyright and permission notice in every copy.)
226
235
  export const BKIT_CANONICAL_DOCS = [
227
236
  "cloud.md",
228
237
  "comparison.md",
@@ -411,6 +420,17 @@ export function detectGateAdvisories(cwd: string): PreflightFinding[] {
411
420
  "\n\nOrder matters — each chains the one above it. Omit a level deliberately to keep it CI-only (E2E in the build loop costs a production build on every remediation attempt). `.bkit/templates.md` lists the tool scripts the gates chain.",
412
421
  });
413
422
  }
423
+
424
+ // /bkit-build records each task's red through this script; without it test-first is
425
+ // reported as not enforced. bkit cannot seed it: what runs one file is the stack's.
426
+ if (!(BKIT_TEST_FILE_SCRIPT in declared)) {
427
+ findings.push({
428
+ id: "test-file-script-missing",
429
+ severity: "advisory",
430
+ detect: `package.json does not declare \`${BKIT_TEST_FILE_SCRIPT}\`, so \`/bkit-build\` cannot check that each task's tests fail before its code is written.`,
431
+ action: `Add \`${BKIT_TEST_FILE_SCRIPT}\` to package.json: it runs the ONE test file bkit appends as its argument (repo-relative path) and writes a JUnit report to the path in \`$BKIT_TEST_REPORT\`. Vitest example:\n\n "${BKIT_TEST_FILE_SCRIPT}": "vitest run --reporter=default --reporter=junit --outputFile.junit=\\"$BKIT_TEST_REPORT\\""\n\nCall the runner directly, not through a task runner that caches results or runs dependent packages first. A monorepo routes the path to the package and config that own it.`,
432
+ });
433
+ }
414
434
  return findings;
415
435
  }
416
436
 
@@ -503,7 +523,7 @@ export function runCoreModule(ctx: ModuleContext): void {
503
523
  // installed package (browse-only, gitignored; no-op in dogfood). A real
504
524
  // directory or file at either path is never clobbered (advisory); a platform
505
525
  // refusal is an advisory, never a failure.
506
- const linkChanges = syncPayloadLinks(cwd, { dryRun, ws });
526
+ const linkChanges = syncPayloadLinks(cwd, { dryRun });
507
527
  for (const rel of linkChanges.created) {
508
528
  console.log(`${logPrefix} ${tag}payload link: ${rel}`);
509
529
  }
@@ -154,12 +154,12 @@ export function runCursorModule(ctx: ModuleContext): void {
154
154
  }
155
155
  }
156
156
 
157
- // markered-text (slash-comment) — GateGuard advisory PreToolUse hook for Cursor.
158
- // Same managed block as the Claude twin; the driver outside it adapts Cursor's
159
- // payload (relative file_path, no subagent marker) and emits Cursor's shape.
160
- {
161
- const src = path.join(cursorHooks, "bkit-gateguard.cjs");
162
- const dst = ".cursor/hooks/bkit-gateguard.cjs";
157
+ // markered-text (slash-comment) — GateGuard and ReadGuard advisory hooks for Cursor.
158
+ // Same managed blocks as the Claude twins; the drivers outside them adapt Cursor's
159
+ // payload (relative file_path, no subagent marker) and emit Cursor's shape.
160
+ for (const hook of ["bkit-gateguard.cjs", "bkit-readguard.cjs"]) {
161
+ const src = path.join(cursorHooks, hook);
162
+ const dst = `.cursor/hooks/${hook}`;
163
163
  if (fs.existsSync(src)) {
164
164
  const prevLen = ws.writes.length;
165
165
  writeTier2(src, dst, tokens, "slash-comment", dryRun, ws);
@@ -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
 
8
8
  import * as fs from "node:fs";
@@ -26,6 +26,11 @@ import { renderClaudeAgentsCommands, runClaudeModule } from "./claude.js";
26
26
  import { renderCursorAgentsCommands, runCursorModule } from "./cursor.js";
27
27
  import { renderOpencodeAgentsCommands, runOpencodeModule } from "./opencode.js";
28
28
  import { CODEX_SKILLS_DIR, renderCodexAgentsSkills, runCodexModule } from "./codex.js";
29
+ import {
30
+ ANTIGRAVITY_SKILLS_DIR,
31
+ renderAntigravityAgentsSkills,
32
+ runAntigravityModule,
33
+ } from "./antigravity.js";
29
34
  import { runCloudModule } from "./cloud.js";
30
35
 
31
36
  // ---------------------------------------------------------------------------
@@ -54,6 +59,11 @@ export interface ModuleContext {
54
59
  * opencodeModelLookup because they read different gateway columns.
55
60
  */
56
61
  codexModelLookup?: Map<string, string>;
62
+ /**
63
+ * name -> BARE § Models `Google` cell, for `.agents/plugins/bkit/agents/*.md`. Separate
64
+ * from the other lookups because it reads the Google gateway column.
65
+ */
66
+ antigravityModelLookup?: Map<string, string>;
57
67
  /**
58
68
  * Effort → provider thinking map from prompts.md (Default | Claude | Cursor | …).
59
69
  * Shared by Claude / Cursor / opencode transforms. Empty map when prompts.md absent.
@@ -88,6 +98,15 @@ export interface ModuleContext {
88
98
  * install/upgrade set it explicitly.
89
99
  */
90
100
  version?: string;
101
+ /**
102
+ * The full set of host modules present for this run — the dispatched set UNION the hosts
103
+ * already on disk. Read by the Antigravity module to warn when Codex is also installed
104
+ * (both hosts' `bkit-*` workflow skills then surface in Antigravity's skill selector).
105
+ *
106
+ * Optional: absent in isolated unit tests. Production install
107
+ * (commands/install/install.ts) and upgrade (commands/install/upgrade.ts) set it.
108
+ */
109
+ installedModules?: ReadonlySet<ModuleFlag>;
91
110
  }
92
111
 
93
112
  export type ModuleFn = (ctx: ModuleContext) => void;
@@ -130,6 +149,7 @@ export function renderManagedOutputs(modules: Set<ModuleFlag>, ctx: ModuleContex
130
149
  if (modules.has("cursor")) written.push(...renderCursorAgentsCommands(ctx));
131
150
  if (modules.has("opencode")) written.push(...renderOpencodeAgentsCommands(ctx));
132
151
  if (modules.has("codex")) written.push(...renderCodexAgentsSkills(ctx));
152
+ if (modules.has("antigravity")) written.push(...renderAntigravityAgentsSkills(ctx));
133
153
 
134
154
  return written;
135
155
  }
@@ -155,6 +175,7 @@ const RENDERED_MIRRORS: ReadonlyArray<[dir: string, ext: string]> = [
155
175
  [".opencode/agents", ".md"],
156
176
  [".opencode/commands", ".md"],
157
177
  [".codex/agents", ".toml"],
178
+ [".agents/plugins/bkit/agents", ".md"],
158
179
  ];
159
180
 
160
181
  /**
@@ -187,12 +208,16 @@ export function listStampedFiles(cwd: string): StampedFile[] {
187
208
  if (f.startsWith(BKIT_PREFIX) && f.endsWith(ext)) add(path.join(dir, f), "whole");
188
209
  }
189
210
  }
190
- const skills = path.join(cwd, CODEX_SKILLS_DIR);
191
- if (fs.existsSync(skills)) {
192
- for (const d of fs.readdirSync(skills)) {
211
+ // Codex renders workflow skills into `.agents/skills/bkit-*/SKILL.md`; Antigravity renders
212
+ // its own into the plugin `.agents/plugins/bkit/skills/bkit-*/SKILL.md`. Both stamp a
213
+ // managed-version marker; collect each for the stale detector.
214
+ for (const dir of [CODEX_SKILLS_DIR, ANTIGRAVITY_SKILLS_DIR]) {
215
+ const abs = path.join(cwd, dir);
216
+ if (!fs.existsSync(abs)) continue;
217
+ for (const d of fs.readdirSync(abs)) {
193
218
  if (!d.startsWith(BKIT_PREFIX)) continue;
194
- if (fs.existsSync(path.join(skills, d, "SKILL.md"))) {
195
- add(path.join(CODEX_SKILLS_DIR, d, "SKILL.md"), "whole");
219
+ if (fs.existsSync(path.join(abs, d, "SKILL.md"))) {
220
+ add(path.join(dir, d, "SKILL.md"), "whole");
196
221
  }
197
222
  }
198
223
  }
@@ -209,6 +234,7 @@ export const MODULE_REGISTRY: Partial<Record<ModuleFlag, ModuleFn>> = {
209
234
  cursor: runCursorModule,
210
235
  opencode: runOpencodeModule,
211
236
  codex: runCodexModule,
237
+ antigravity: runAntigravityModule,
212
238
  cloud: runCloudModule,
213
239
  // "full" is never directly in the registry — resolveModules expands it to all modules
214
240
  };
@@ -220,6 +246,7 @@ export const MODULE_DISPATCH_ORDER: ModuleFlag[] = [
220
246
  "cursor",
221
247
  "opencode",
222
248
  "codex",
249
+ "antigravity",
223
250
  "cloud",
224
251
  ];
225
252
 
@@ -533,11 +533,11 @@ export function runOpencodeModule(ctx: ModuleContext): void {
533
533
  }
534
534
  }
535
535
 
536
- // --- bkit-gateguard.js — Tier-2 markered-text (slash-comment); see install/manifest.ts ---
537
- {
536
+ // --- bkit-gateguard.js / bkit-readguard.js — Tier-2 markered-text (slash-comment); see install/manifest.ts ---
537
+ for (const plugin of ["bkit-gateguard.js", "bkit-readguard.js"]) {
538
538
  const opencodeCore = path.join(getCoreRoot(), ".opencode", "plugin");
539
- const pluginSrc = path.join(opencodeCore, "bkit-gateguard.js");
540
- const pluginDst = ".opencode/plugin/bkit-gateguard.js";
539
+ const pluginSrc = path.join(opencodeCore, plugin);
540
+ const pluginDst = `.opencode/plugin/${plugin}`;
541
541
  if (fs.existsSync(pluginSrc)) {
542
542
  // dryRun-gated — writeTier2 honours dryRun, so the dir is only needed for a real
543
543
  // write; `bkit check` stays read-only when gateguard's parent dir is absent.
@@ -6,7 +6,6 @@
6
6
  import * as fs from "node:fs";
7
7
  import * as path from "node:path";
8
8
  import { getCoreRoot, getPkgRoot, getSharedRoot } from "../shared/package-roots.js";
9
- import type { WriteSet } from "./write.js";
10
9
 
11
10
  // The two view links: a symlink at the consumer-relative `relPath` pointing at the
12
11
  // package payload dir `target()` resolves to. Relative targets, so the link keeps
@@ -58,14 +57,12 @@ export function createPayloadLink(
58
57
  // Create or refresh the consumer's `.bkit/core` + `.bkit/shared` view links into
59
58
  // the package payload. Idempotent: a correct link is kept, a dangling or
60
59
  // mis-pointed symlink is re-pointed, a real directory or file is NEVER clobbered
61
- // (skippedRealDir) and a platform refusal is only recorded (failed). Every create
62
- // or repair pushes a ws write in dry-run and live alike, so `bkit check` flags a
63
- // missing or broken link as drift. No-op in dogfood: there `.bkit/core` IS the
64
- // package source, never a view onto it.
65
- export function syncPayloadLinks(
66
- cwd: string,
67
- opts: { dryRun: boolean; ws: WriteSet },
68
- ): PayloadLinkChanges {
60
+ // (skippedRealDir) and a platform refusal is only recorded (failed). Links are
61
+ // convenience views, not managed content: they never join the install WriteSet, so
62
+ // a missing or broken link is never `bkit check` drift (a fresh clone or worktree
63
+ // has none). Dry-run reports what a live run would do and touches nothing. No-op
64
+ // in dogfood: there `.bkit/core` IS the package source, never a view onto it.
65
+ export function syncPayloadLinks(cwd: string, opts: { dryRun: boolean }): PayloadLinkChanges {
69
66
  const changes: PayloadLinkChanges = {
70
67
  created: [],
71
68
  repaired: [],
@@ -122,7 +119,6 @@ export function syncPayloadLinks(
122
119
  }
123
120
  }
124
121
  (st !== null ? changes.repaired : changes.created).push(relPath);
125
- opts.ws.writes.push({ path: relPath, action: "write" });
126
122
  }
127
123
  return changes;
128
124
  }
@@ -102,7 +102,7 @@ export function applyTokens(content: string, tokens: TokenMap): string {
102
102
  const version = tokens.BKIT_VERSION ?? readInstallingBkitVersion();
103
103
  out = out
104
104
  .replace(/^\/\/ \{\{BKIT_MANAGED_MARKER\}\}/gm, () => managedVersionMarker(version, "slash"))
105
- .replace(/\{\{BKIT_MANAGED_MARKER\}\}/g, () => managedVersionMarker(version));
105
+ .replace(/\{\{BKIT_MANAGED_MARKER\}\}/g, () => managedVersionMarker(version, "html"));
106
106
  }
107
107
  return out;
108
108
  }
@@ -161,6 +161,9 @@ export function isConsumerModified(
161
161
  * cases; the latter survive the absent-path prune because the adopted copy stays on
162
162
  * disk).
163
163
  *
164
+ * `removing` lists paths (or directories) a dry run would delete: they count as absent, so a
165
+ * dry run prunes the same entries the real run does.
166
+ *
164
167
  * `pruned` counts the dropped entries so callers can treat a prune-only merge as a
165
168
  * change that is still worth writing.
166
169
  */
@@ -168,11 +171,21 @@ export function mergeCanonicalHashes(
168
171
  cwd: string,
169
172
  existing: Record<string, string>,
170
173
  fresh: Record<string, string>,
174
+ removing: readonly string[] = [],
171
175
  ): { canonicalHashes: Record<string, string>; pruned: number } {
172
176
  const canonicalHashes: Record<string, string> = {};
177
+ const isRemoving = (relPath: string): boolean =>
178
+ removing.some((r) => {
179
+ const dir = r.replace(/[\\/]+$/, "");
180
+ return relPath === dir || relPath.startsWith(`${dir}/`);
181
+ });
173
182
  let pruned = 0;
174
183
  for (const [relPath, hash] of Object.entries(existing)) {
175
- if (!fs.existsSync(path.join(cwd, relPath)) || isTemplateSetPath(relPath)) {
184
+ if (
185
+ !fs.existsSync(path.join(cwd, relPath)) ||
186
+ isRemoving(relPath) ||
187
+ isTemplateSetPath(relPath)
188
+ ) {
176
189
  pruned++;
177
190
  continue;
178
191
  }
@@ -216,15 +229,10 @@ export function hashFile(filePath: string): string | null {
216
229
  // hash `# <!-- bkit:managed vX.Y.Z — … -->` shell, `.gitignore`, `.env.example`, TOML
217
230
  // slash `// bkit:managed vX.Y.Z — …` JS (`.cjs` / `.js` / `.mjs`)
218
231
  //
219
- // The marker names the licence the bkit-written files are under (PolyForm Noncommercial
220
- // or Small Business, the pair `.bkit/LICENSE.md` carries in full) and the licences-index
221
- // URL, so a copy passed on in a public repo carries the terms URL with it (PolyForm's
222
- // Notices section). `.bkit/LICENSE.md` is written by runBkitDocs (install/modules/core.ts).
223
- //
224
232
  // Rendered agents / commands / skills are stamped at render (stampManagedVersion);
225
233
  // every other file carries the `{{BKIT_MANAGED_MARKER}}` token in its source, which
226
- // applyTokens (install/placeholders.ts) resolves to the form its comment prefix selects. The
227
- // `bkit check` gate (detectManagedStale, checks/after/index.ts) reads the stamp back
234
+ // applyTokens (install/placeholders.ts) resolves to the form its comment prefix selects.
235
+ // The `bkit check` gate (detectManagedStale, checks/after/index.ts) reads the stamp back
228
236
  // with readManagedVersion.
229
237
  // ---------------------------------------------------------------------------
230
238
 
@@ -240,7 +248,7 @@ export const MANAGED_MARKER_VERSION_RE = /bkit:managed v(\S+)/;
240
248
 
241
249
  /** Build the managed-version marker for a given version, in the given comment syntax. */
242
250
  export function managedVersionMarker(version: string, form: ManagedMarkerForm = "html"): string {
243
- 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`;
251
+ const text = `bkit:managed v${version} — do not edit; run \`bkit upgrade\` to refresh`;
244
252
  if (form === "slash") return `// ${text}`;
245
253
  return form === "hash" ? `# <!-- ${text} -->` : `<!-- ${text} -->`;
246
254
  }
@@ -5,11 +5,13 @@ import {
5
5
  extractFullManagedBlock,
6
6
  extractManagedBlock,
7
7
  findLineAnchoredMarkers,
8
+ findUnmarkedCopy,
8
9
  selectMarkers,
9
10
  type MarkerStyle,
10
11
  } from "./managed-block.js";
11
12
  import { readTemplate } from "../render/parts.js";
12
13
  import { applyTokens, type TokenMap } from "./placeholders.js";
14
+ import { sha256 } from "./version-file.js";
13
15
 
14
16
  // ---------------------------------------------------------------------------
15
17
  // JsonValue — generic JSON type used throughout Tier-2 JSON helpers
@@ -202,7 +204,7 @@ export function deepMergeJson(base: JsonValue, override: JsonValue): JsonValue {
202
204
  // - dest present, valid JSON, template contained → no-op (idempotent)
203
205
  // - dest present, valid JSON, containment fails → deepMergeJson(existing, template)
204
206
  // (template wins on key collisions; consumer-only keys outside template tree preserved)
205
- // - dest present, malformed JSON → overwrite with template
207
+ // - dest present, malformed JSON → throw; the consumer fixes it by hand
206
208
  // - schemaFlipped: true when a path value changed type during deep-merge
207
209
  // ---------------------------------------------------------------------------
208
210
 
@@ -309,11 +311,58 @@ export function writeTier1(
309
311
  // - dest absent → write whole file (with token substitution)
310
312
  // - dest has markers → update only the bkit block (tokens applied to new block content)
311
313
  // - dest present, no marks → append full block at EOF; preserve consumer content above
314
+ // - no marks, markdown dest already holds an unmarked copy of the block (findUnmarkedCopy)
315
+ // → warn + skip; appending would leave a frozen duplicate above it
312
316
  //
313
317
  // markerStyle: "html-comment" for markdown, shell and `.gitignore` (`# ` prefix allowed);
314
318
  // "slash-comment" for JS.
315
319
  // ---------------------------------------------------------------------------
316
320
 
321
+ /**
322
+ * sha256 of the driver (everything outside the managed block) of hook files a bkit
323
+ * release shipped with a host contract the host does not accept, keyed by consumer path.
324
+ * Register: docs/migrations.md.
325
+ */
326
+ export const RETIRED_DRIVER_HASHES: Readonly<Record<string, readonly string[]>> = {
327
+ // 5.1.0: Claude-shaped `hookSpecificOutput`; Antigravity reads `{ decision, reason }`.
328
+ ".agents/plugins/bkit/hooks/bkit-gateguard.cjs": [
329
+ "544dbcc2bab81875789563a2925bb5dc7b5dbbcf185f216fb3281cfa01ec030d",
330
+ ],
331
+ ".agents/plugins/bkit/hooks/bkit-guardrails.cjs": [
332
+ "8e5d75f7e1a4527889dafa6a250ae370e2acf1b5fc7d58929dfc759489746e14",
333
+ ],
334
+ };
335
+
336
+ /** The text outside a file's single managed block, or null without exactly one block. */
337
+ export function driverText(content: string, markerStyle: MarkerStyle): string | null {
338
+ const [startMarker, endMarker] = selectMarkers(markerStyle);
339
+ const starts = findLineAnchoredMarkers(content, startMarker);
340
+ const ends = findLineAnchoredMarkers(content, endMarker);
341
+ if (starts.length !== 1 || ends.length !== 1 || ends[0]! < starts[0]!) return null;
342
+ return content.slice(0, starts[0]) + content.slice(ends[0]);
343
+ }
344
+
345
+ /**
346
+ * True when `dstPath` still carries a retired bkit driver the consumer never edited. An
347
+ * edited driver still on the retired output shape is kept and gets a printed fix.
348
+ */
349
+ function hasRetiredDriver(dstPath: string, content: string, markerStyle: MarkerStyle): boolean {
350
+ const posix = dstPath.replace(/\\/g, "/");
351
+ const key = Object.keys(RETIRED_DRIVER_HASHES).find(
352
+ (rel) => posix === rel || posix.endsWith(`/${rel}`),
353
+ );
354
+ if (key === undefined) return false;
355
+ const driver = driverText(content, markerStyle);
356
+ if (driver === null) return false;
357
+ if (RETIRED_DRIVER_HASHES[key]!.includes(sha256(driver))) return true;
358
+ if (driver.includes("hookSpecificOutput")) {
359
+ console.warn(
360
+ `[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.`,
361
+ );
362
+ }
363
+ return false;
364
+ }
365
+
317
366
  export function writeTier2(
318
367
  srcPath: string,
319
368
  dstPath: string,
@@ -324,6 +373,17 @@ export function writeTier2(
324
373
  ): void {
325
374
  const srcRaw = readTemplate(srcPath);
326
375
 
376
+ // A retired, unedited bkit driver is bkit's code, not the consumer's: replace the
377
+ // whole file so the new driver ships with the new block.
378
+ if (
379
+ fs.existsSync(dstPath) &&
380
+ hasRetiredDriver(dstPath, fs.readFileSync(dstPath, "utf-8"), markerStyle)
381
+ ) {
382
+ if (!dryRun) fs.writeFileSync(dstPath, applyTokens(srcRaw, tokens), "utf-8");
383
+ ws.writes.push({ path: dstPath, action: "write" });
384
+ return;
385
+ }
386
+
327
387
  if (!fs.existsSync(dstPath)) {
328
388
  // dest missing → write whole template (with tokens applied)
329
389
  const content = applyTokens(srcRaw, tokens);
@@ -364,6 +424,13 @@ export function writeTier2(
364
424
 
365
425
  // dest has no markers → append full block at EOF (with tokens applied)
366
426
  const appliedBlock = applyTokens(fullBlock, tokens);
427
+ const copyTitle = dstPath.endsWith(".md") ? findUnmarkedCopy(destContent, appliedBlock) : null;
428
+ if (copyTitle !== null) {
429
+ console.warn(
430
+ `[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 -->\`.`,
431
+ );
432
+ return;
433
+ }
367
434
  const sep =
368
435
  destContent.length === 0
369
436
  ? ""
@@ -391,8 +391,6 @@ export interface OutcomePayload {
391
391
  frictionAdded?: number;
392
392
  deferralsAdded?: number;
393
393
  failuresAdded?: number;
394
- /** Sweep verdict from ship deferred-sweep step. */
395
- sweepVerdict?: string;
396
394
  /**
397
395
  * `"brief"` = the run had no `{FID}-plan*.md` and worked from its input file
398
396
  * (build / ship `workflow-meta` row). Absent = the run had a plan. Brief runs
@@ -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
 
4
4
  import { type EffortMap, formatModelPin, lookupEffort } from "./models.js";
5
5
  import { LOG_PREFIX } from "../shared/log-prefix.js";
@@ -36,6 +36,56 @@ export function opencodeToolsBlock(toolsBlock: string | null): string {
36
36
  return out;
37
37
  }
38
38
 
39
+ /**
40
+ * Antigravity built-in tool names. Antigravity (`.agents/`) uses lower_snake_case tool
41
+ * names that differ from Claude's capitalized set, so the declared `tools:` block must be
42
+ * respelled — an unknown tool name is not guaranteed to resolve on that host. Unknown
43
+ * Claude names are passed through unchanged (best effort); MCP tools keep their
44
+ * `mcp__<server>__<tool>` spelling.
45
+ */
46
+ const ANTIGRAVITY_TOOL_MAP: Record<string, string> = {
47
+ read: "view_file",
48
+ glob: "list_dir",
49
+ grep: "grep_search",
50
+ write: "write_to_file",
51
+ edit: "replace_file_content",
52
+ bash: "run_command",
53
+ websearch: "search_web",
54
+ webfetch: "read_url",
55
+ };
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: string | null): string {
64
+ if (!toolsBlock) return "";
65
+ const names: string[] = [];
66
+ for (const m of toolsBlock.matchAll(/^[ \t]*-[ \t]*([A-Za-z][\w*-]*)/gm)) names.push(m[1]);
67
+ if (names.length === 0) {
68
+ // Fallback: inline array form `tools: [Read, Write]`.
69
+ const inline = toolsBlock.match(/\[([^\]]*)\]/);
70
+ if (inline) {
71
+ for (const t of inline[1].split(",")) {
72
+ const n = t.trim().replace(/['"]/g, "");
73
+ if (n) names.push(n);
74
+ }
75
+ }
76
+ }
77
+ if (names.length === 0) return "";
78
+ let out = "tools:\n";
79
+ for (const n of names) {
80
+ if (n.startsWith("mcp__")) {
81
+ out += ` - ${n}\n`;
82
+ continue;
83
+ }
84
+ out += ` - ${ANTIGRAVITY_TOOL_MAP[n.toLowerCase()] ?? n}\n`;
85
+ }
86
+ return out;
87
+ }
88
+
39
89
  /**
40
90
  * OC1: opencode agent frontmatter rewrite.
41
91
  * Emits: mode, name, description, model, tools (Claude array → opencode object map),
@@ -370,3 +420,126 @@ export function applyT3(
370
420
 
371
421
  return newFm + afterFm;
372
422
  }
423
+
424
+ /**
425
+ * Antigravity subagent-definition directory — the `agents/` folder of the bkit workspace
426
+ * plugin (`.agents/plugins/bkit/`). The host install lives entirely inside the plugin so
427
+ * `.agents/` root stays Codex's.
428
+ */
429
+ export const ANTIGRAVITY_AGENTS_DIR = ".agents/plugins/bkit/agents";
430
+
431
+ /**
432
+ * Antigravity command/skill invocation rewrite. Antigravity has no native subagent tool:
433
+ * the orchestrator loads a subagent prompt in-session with `view_file` and executes its
434
+ * step contract, so both Claude tools (`Agent` / `Skill`) respell to `view_file`. A
435
+ * `**Subagent:** @name` reference resolves to the rendered prompt file it must load
436
+ * (`<agentsDir>/<name>.md`). Does NOT rewrite body prose or gate-checklist `@agent` refs.
437
+ */
438
+ export function applyAntigravityToolRewrites(
439
+ content: string,
440
+ agentsDir: string = ANTIGRAVITY_AGENTS_DIR,
441
+ ): string {
442
+ let result = content.replace(/`Agent` tool/g, "`view_file` tool");
443
+ result = result.replace(/using `Agent` tool/g, "using `view_file` tool");
444
+ result = result.replace(/`Skill` tool/g, "`view_file` tool");
445
+ result = result.replace(/using `Skill` tool/g, "using `view_file` tool");
446
+ // Backticked `@agent` on any **Subagent:** line (numbered, list-indented, or bare).
447
+ result = result.replace(
448
+ /^([^\n]*?\*\*Subagent:\*\*[^\n]*?)`@([a-z][a-z0-9-]*)`/gm,
449
+ `$1\`view_file\` \`${agentsDir}/$2.md\``,
450
+ );
451
+ // Bare `@agent` immediately after **Subagent:** (exact-line form).
452
+ result = result.replace(
453
+ /^([^\n]*?\*\*Subagent:\*\* )@([a-z][a-z0-9-]*)\b/gm,
454
+ `$1\`view_file\` \`${agentsDir}/$2.md\``,
455
+ );
456
+ result = result.replace(
457
+ /Invoke using `@name`/g,
458
+ `Invoke using \`view_file\` \`${agentsDir}/name.md\``,
459
+ );
460
+ return result;
461
+ }
462
+
463
+ /**
464
+ * Convert a Claude-format subagent prompt (`.bkit/core/prompts/*.md`) into an Antigravity
465
+ * prompt (`.agents/plugins/bkit/agents/<name>.md`).
466
+ *
467
+ * Antigravity loads subagent prompts from `.agents/plugins/bkit/agents/` and executes them
468
+ * in-session (the orchestrator loads the file with `view_file`). The frontmatter is rewritten to
469
+ * Antigravity's vocabulary: `name`/`description` preserved, the model pin from the
470
+ * `.bkit/prompts.md` § Models `Google` column (bare `gemini-3.8-*` id), the thinking
471
+ * `effort` remapped through the `Antigravity` column, and the `tools:` block respelled to
472
+ * Antigravity tool names. Claude-only fields (permissionMode, maxTurns, is_background,
473
+ * readonly) are dropped. Hard-fails with non-zero exit if the model lookup is missing.
474
+ */
475
+ export function applyAntigravityPrompt(
476
+ content: string,
477
+ modelLookup: Map<string, string>,
478
+ effortMap?: EffortMap,
479
+ ): string {
480
+ const fmMatch = content.match(/^(---\r?\n)([\s\S]*?)(\r?\n---\r?\n?)/);
481
+ if (!fmMatch) return content;
482
+
483
+ const fmBlock = fmMatch[2];
484
+ const afterFm = content.slice(fmMatch[0].length);
485
+ const parsed = parseFrontmatter(fmBlock);
486
+
487
+ const name = parsed.get("name") ?? "";
488
+ if (!name) {
489
+ console.error(`${LOG_PREFIX} Subagent frontmatter missing 'name' field`);
490
+ process.exit(1);
491
+ }
492
+
493
+ const model = modelLookup.get(name);
494
+ if (!model) {
495
+ console.error(`${LOG_PREFIX} Missing antigravity model lookup for ${name}`);
496
+ process.exit(1);
497
+ }
498
+
499
+ const description = parsed.get("description") ?? "";
500
+ const effort = parsed.get("effort");
501
+ const toolsBlock = extractFrontmatterField(fmBlock, "tools");
502
+
503
+ let newFm = "---\n";
504
+ newFm += `name: ${name}\n`;
505
+ if (description.includes("\n")) {
506
+ const indented = description.split("\n").join("\n ");
507
+ newFm += `description: |\n ${indented}\n`;
508
+ } else {
509
+ newFm += `description: ${description}\n`;
510
+ }
511
+ newFm += `model: ${formatModelPin("antigravity", "google", model)}\n`;
512
+ if (effort && effortMap) {
513
+ newFm += `effort: ${lookupEffort(effortMap, "antigravity", effort)}\n`;
514
+ }
515
+ newFm += antigravityToolsBlock(toolsBlock);
516
+ newFm += "---\n";
517
+
518
+ return newFm + afterFm;
519
+ }
520
+
521
+ /**
522
+ * Convert a workflow orchestrator (`.bkit/core/workflows/*.md`) into an Antigravity
523
+ * SKILL.md (`.agents/plugins/bkit/skills/<name>/SKILL.md`). Antigravity auto-discovers
524
+ * skills under a workspace plugin's `skills/`; `name` and `description` are frontmatter
525
+ * keys, and the body is the workflow steps verbatim with invocations respelled to
526
+ * Antigravity's in-session prompt loading (see applyAntigravityToolRewrites).
527
+ */
528
+ export function applyAntigravitySkill(
529
+ content: string,
530
+ skillName: string,
531
+ agentsDir: string = ANTIGRAVITY_AGENTS_DIR,
532
+ ): string {
533
+ const fmMatch = content.match(/^(---\r?\n)([\s\S]*?)(\r?\n---\r?\n?)/);
534
+ let body: string;
535
+ let description = `bkit ${skillName} workflow`;
536
+ if (fmMatch) {
537
+ const parsed = parseFrontmatter(fmMatch[2]);
538
+ description = (parsed.get("description") ?? description).replace(/^"|"$/g, "");
539
+ body = content.slice(fmMatch[0].length);
540
+ } else {
541
+ body = content;
542
+ }
543
+ const rewritten = applyAntigravityToolRewrites(body, agentsDir);
544
+ return `---\nname: ${skillName}\ndescription: "${description.replace(/"/g, '\\"')}"\n---\n${rewritten}`;
545
+ }