@cbartens/bkit 5.0.3 → 5.1.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 (112) hide show
  1. package/.bkit/README.md +4 -4
  2. package/.bkit/core/.agents/docs.md +1 -0
  3. package/.bkit/core/.agents/plugins/bkit/hooks/bkit-gateguard.cjs +104 -0
  4. package/.bkit/core/.agents/plugins/bkit/hooks/bkit-guardrails.cjs +119 -0
  5. package/.bkit/core/.agents/rules.md +2 -2
  6. package/.bkit/core/.agents/shortcuts.md +73 -0
  7. package/.bkit/core/.agents/skills.md +5 -3
  8. package/.bkit/core/.bkit/README.md +3 -3
  9. package/.bkit/core/.bkit/comparison.md +2 -2
  10. package/.bkit/core/.bkit/install.md +5 -3
  11. package/.bkit/core/.bkit/prompts.md +69 -68
  12. package/.bkit/core/.bkit/providers.md +28 -10
  13. package/.bkit/core/.bkit/templates.md +4 -2
  14. package/.bkit/core/.bkit/workflows.md +6 -6
  15. package/.bkit/core/AGENTS.md +11 -0
  16. package/.bkit/core/engine/checks/after/managed.ts +4 -1
  17. package/.bkit/core/engine/cli.ts +25 -9
  18. package/.bkit/core/engine/commands/install/check.ts +2 -0
  19. package/.bkit/core/engine/commands/install/doctor.ts +9 -0
  20. package/.bkit/core/engine/commands/install/install.ts +20 -0
  21. package/.bkit/core/engine/commands/install/uninstall.ts +30 -19
  22. package/.bkit/core/engine/commands/install/upgrade.ts +17 -2
  23. package/.bkit/core/engine/commands/workflow/prs.ts +20 -2
  24. package/.bkit/core/engine/commands/workflow/runs.ts +26 -3
  25. package/.bkit/core/engine/install/manifest.ts +38 -2
  26. package/.bkit/core/engine/install/modules/antigravity.ts +265 -0
  27. package/.bkit/core/engine/install/modules/codex.ts +3 -0
  28. package/.bkit/core/engine/install/modules/core.ts +7 -1
  29. package/.bkit/core/engine/install/modules/index.ts +33 -6
  30. package/.bkit/core/engine/render/hosts.ts +174 -1
  31. package/.bkit/core/engine/render/models.ts +10 -0
  32. package/.bkit/core/prompts/bkit-audit-generate.md +1 -1
  33. package/.bkit/core/prompts/bkit-build-challenge-1.md +1 -1
  34. package/.bkit/core/prompts/bkit-build-challenge-2.md +1 -1
  35. package/.bkit/core/prompts/bkit-build-challenge-reconcile.md +1 -1
  36. package/.bkit/core/prompts/bkit-build-challenge-remediate.md +1 -1
  37. package/.bkit/core/prompts/bkit-build-challenge-tests.md +1 -1
  38. package/.bkit/core/prompts/bkit-build-install-skills.md +6 -5
  39. package/.bkit/core/prompts/bkit-build-plan-current.md +1 -1
  40. package/.bkit/core/prompts/bkit-build-plan-execute.md +1 -1
  41. package/.bkit/core/prompts/bkit-build-plan-gaps-remediate.md +1 -1
  42. package/.bkit/core/prompts/bkit-build-plan-verify.md +1 -1
  43. package/.bkit/core/prompts/bkit-build-summary.md +1 -1
  44. package/.bkit/core/prompts/bkit-debug-abort-handover.md +1 -1
  45. package/.bkit/core/prompts/bkit-debug-failure-diagnose.md +1 -1
  46. package/.bkit/core/prompts/bkit-debug-failure-remediate.md +1 -1
  47. package/.bkit/core/prompts/bkit-debug-failure-soak.md +1 -1
  48. package/.bkit/core/prompts/bkit-debug-summary.md +1 -1
  49. package/.bkit/core/prompts/bkit-design-brainstorm-ideate-1.md +1 -1
  50. package/.bkit/core/prompts/bkit-design-brainstorm-ideate-2.md +1 -1
  51. package/.bkit/core/prompts/bkit-design-brainstorm-ideate-3.md +1 -1
  52. package/.bkit/core/prompts/bkit-design-generate.md +1 -1
  53. package/.bkit/core/prompts/bkit-design-organise.md +1 -1
  54. package/.bkit/core/prompts/bkit-design-review-1.md +1 -1
  55. package/.bkit/core/prompts/bkit-design-review-2.md +1 -1
  56. package/.bkit/core/prompts/bkit-design-spike.md +1 -1
  57. package/.bkit/core/prompts/bkit-design-summary.md +1 -1
  58. package/.bkit/core/prompts/bkit-design-update.md +1 -1
  59. package/.bkit/core/prompts/bkit-plan-complexity-check.md +1 -1
  60. package/.bkit/core/prompts/bkit-plan-complexity-split.md +1 -1
  61. package/.bkit/core/prompts/bkit-plan-generate.md +1 -1
  62. package/.bkit/core/prompts/bkit-plan-review-1.md +1 -1
  63. package/.bkit/core/prompts/bkit-plan-review-2.md +1 -1
  64. package/.bkit/core/prompts/bkit-plan-review-3.md +1 -1
  65. package/.bkit/core/prompts/bkit-plan-scope-check-1.md +1 -1
  66. package/.bkit/core/prompts/bkit-plan-scope-check-2.md +1 -1
  67. package/.bkit/core/prompts/bkit-plan-summary.md +1 -1
  68. package/.bkit/core/prompts/bkit-plan-update.md +1 -1
  69. package/.bkit/core/prompts/bkit-ship-conflict-resolve.md +1 -1
  70. package/.bkit/core/prompts/bkit-ship-deferred-sweep.md +1 -1
  71. package/.bkit/core/prompts/bkit-ship-summary.md +1 -1
  72. package/.bkit/core/prompts/bkit-ship-update-docs.md +1 -1
  73. package/.bkit/core/prompts/bkit-utility-compress-markdown.md +1 -1
  74. package/.bkit/core/prompts/bkit-utility-update-decisions.md +1 -1
  75. package/.bkit/core/prompts/bkit-utility-update-deferrals.md +1 -1
  76. package/.bkit/core/prompts/bkit-utility-update-documentation.md +1 -1
  77. package/.bkit/core/prompts/bkit-utility-update-failures.md +1 -1
  78. package/.bkit/core/prompts/bkit-utility-update-knowledge.md +1 -1
  79. package/.bkit/core/prompts/bkit-utility-update-roadmap.md +3 -3
  80. package/.bkit/core/workflows/bkit-auto.md +1 -1
  81. package/.bkit/core/workflows/bkit-build.md +3 -1
  82. package/.bkit/core/workflows/bkit-debug.md +3 -1
  83. package/.bkit/core/workflows/bkit-design.md +3 -1
  84. package/.bkit/core/workflows/bkit-plan.md +3 -1
  85. package/.bkit/core/workflows/bkit-ship.md +3 -1
  86. package/.bkit/shared/.agents/plugins/bkit/hooks.json +26 -0
  87. package/.bkit/shared/.agents/plugins/bkit/plugin.json +5 -0
  88. package/.bkit/shared/GEMINI.md +11 -0
  89. package/.bkit/shared/docs/security.md +3 -3
  90. package/.bkit/templates/.github/workflows/bkit-ci.yml +24 -0
  91. package/.bkit/templates/.prettierignore +3 -0
  92. package/.bkit/templates/scripts/graphify/bkit-graph-pre-push.sh +2 -2
  93. package/.bkit/templates/slop-scan.config.json +3 -1
  94. package/CHANGELOG.md +20 -0
  95. package/README.md +9 -8
  96. package/dist/checks/after/managed.js +1 -0
  97. package/dist/cli.js +21 -8
  98. package/dist/commands/install/check.js +2 -0
  99. package/dist/commands/install/doctor.js +4 -0
  100. package/dist/commands/install/install.js +22 -1
  101. package/dist/commands/install/uninstall.js +34 -22
  102. package/dist/commands/install/upgrade.js +18 -3
  103. package/dist/commands/workflow/prs.js +13 -1
  104. package/dist/commands/workflow/runs.js +23 -3
  105. package/dist/install/manifest.js +35 -1
  106. package/dist/install/modules/antigravity.js +224 -0
  107. package/dist/install/modules/codex.js +3 -0
  108. package/dist/install/modules/core.js +7 -1
  109. package/dist/install/modules/index.js +17 -6
  110. package/dist/render/hosts.js +149 -1
  111. package/dist/render/models.js +9 -0
  112. package/package.json +5 -3
@@ -17,6 +17,13 @@ import { EXIT_NO_STATUS, FILE_FLAG, readStatusRows, statusFile, str } from "./st
17
17
  // gh
18
18
  // ---------------------------------------------------------------------------
19
19
  const PR_FIELDS = "number,url,state,baseRefName,headRefName,headRefOid,title,mergeCommit";
20
+ /**
21
+ * The `owner/repo` a PR URL points at, or undefined when it is not a recognizable
22
+ * GitHub PR URL. Lets a caller compare the repo a PR resolved in against `--repo`.
23
+ */
24
+ export function prRepoSlug(url) {
25
+ return /^https?:\/\/[^/]+\/([^/]+\/[^/]+)\/pull\//.exec(url ?? "")?.[1];
26
+ }
20
27
  function ghFailure(res, what) {
21
28
  const detail = res.stderr.split("\n").at(-1) || `exit ${String(res.status)}`;
22
29
  return ghUnavailable(res)
@@ -30,7 +37,10 @@ function ghFailure(res, what) {
30
37
  */
31
38
  export function probePr(cwd, opts) {
32
39
  if (opts.number !== undefined) {
33
- const res = runGh(cwd, ["pr", "view", opts.number, "--json", `${PR_FIELDS},mergeable`]);
40
+ const args = ["pr", "view", opts.number, "--json", `${PR_FIELDS},mergeable`];
41
+ if (opts.repo !== undefined)
42
+ args.push("--repo", opts.repo);
43
+ const res = runGh(cwd, args);
34
44
  if (!res.ok)
35
45
  return ghFailure(res, `gh pr view ${opts.number}`);
36
46
  const parsed = parseJson(res.stdout);
@@ -41,6 +51,8 @@ export function probePr(cwd, opts) {
41
51
  const args = ["pr", "list", "--head", opts.head, "--state", opts.state, "--json", PR_FIELDS];
42
52
  if (opts.base !== undefined)
43
53
  args.push("--base", opts.base);
54
+ if (opts.repo !== undefined)
55
+ args.push("--repo", opts.repo);
44
56
  const res = runGh(cwd, args);
45
57
  if (!res.ok)
46
58
  return ghFailure(res, `gh pr list --head ${opts.head}`);
@@ -28,7 +28,7 @@ import { TIMEOUTS } from "../../shared/timeouts.js";
28
28
  import { FID_PATTERNS, fromBranch, fromMarker, issueIdOf, readIssueTracker } from "./fids.js";
29
29
  import { AUTO_LABEL, AUTO_ROUTE_SUFFIX } from "./issues.js";
30
30
  import { checkOnlyBookkeeping } from "./ledgers.js";
31
- import { closeTransportRow, crossCheckFile, probePr } from "./prs.js";
31
+ import { closeTransportRow, crossCheckFile, prRepoSlug, probePr } from "./prs.js";
32
32
  import { resolveOwnerRepo, splitSlug } from "./repo.js";
33
33
  import { extraField, str } from "./status.js";
34
34
  import { writeStepRow } from "./steps.js";
@@ -977,6 +977,24 @@ function auditRow(file, type, fields) {
977
977
  throw new CommandError(EXIT.USAGE, `${file} does not exist`);
978
978
  fs.appendFileSync(file, `${JSON.stringify({ type, workflow: "ship", at: statusTimestamp(), ...fields })}\n`);
979
979
  }
980
+ /**
981
+ * Log where a `--pr` resolved so a `--repo` naming a repo other than the checkout
982
+ * is visible; the PR URL names the repo `gh` actually read from.
983
+ */
984
+ function logResolvedPrRepo(repoFlag, prNumber, pr, log) {
985
+ if (repoFlag === undefined)
986
+ return;
987
+ const resolved = prRepoSlug(pr?.url);
988
+ if (resolved === undefined) {
989
+ log(`PR ${prNumber}: could not read the resolved repo from its URL (--repo ${repoFlag})`);
990
+ }
991
+ else if (resolved !== repoFlag) {
992
+ log(`PR ${prNumber} resolved in ${resolved} — --repo names ${repoFlag}`);
993
+ }
994
+ else {
995
+ log(`PR ${prNumber} resolved in ${repoFlag}`);
996
+ }
997
+ }
980
998
  function runGate(ctx) {
981
999
  const f = ctx.flags;
982
1000
  const given = [f.head, f.pr, f.squashOf].filter((v) => v !== undefined).length;
@@ -993,12 +1011,13 @@ function runGate(ctx) {
993
1011
  if (prNumber !== undefined) {
994
1012
  if (!/^[1-9][0-9]*$/.test(prNumber))
995
1013
  throw new CommandError(EXIT.USAGE, "--pr / --squash-of take a PR number");
996
- pr = probePr(ctx.cwd, { number: prNumber, state: "open" });
1014
+ pr = probePr(ctx.cwd, { number: prNumber, state: "open", repo: str(f.repo) });
997
1015
  if (pr.kind === "unavailable") {
998
1016
  ctx.log(pr.message);
999
1017
  return EXIT.USE_MCP;
1000
1018
  }
1001
1019
  const info = pr.kind === "ok" ? pr.pr : undefined;
1020
+ logResolvedPrRepo(str(f.repo), prNumber, info, ctx.log);
1002
1021
  head = (f.squashOf !== undefined ? info?.mergeCommit?.oid : info?.headRefOid) ?? "";
1003
1022
  if (head === "") {
1004
1023
  ctx.log(`cannot read the ${f.squashOf !== undefined ? "squash commit" : "head"} of PR ${prNumber}`);
@@ -1122,11 +1141,12 @@ async function runRevalidate(ctx) {
1122
1141
  throw new CommandError(EXIT.USAGE, "--reason must be head-move or gate-refusal");
1123
1142
  const status = path.resolve(ctx.cwd, String(f.file));
1124
1143
  runGit(ctx.cwd, ["fetch", "origin", branch]);
1125
- const pr = probePr(ctx.cwd, { number: String(f.pr), state: "open" });
1144
+ const pr = probePr(ctx.cwd, { number: String(f.pr), state: "open", repo: str(f.repo) });
1126
1145
  if (pr.kind === "unavailable") {
1127
1146
  ctx.log(pr.message);
1128
1147
  return EXIT.USE_MCP;
1129
1148
  }
1149
+ logResolvedPrRepo(str(f.repo), String(f.pr), pr.kind === "ok" ? pr.pr : undefined, ctx.log);
1130
1150
  const current = pr.kind === "ok" ? (pr.pr?.headRefOid ?? "") : "";
1131
1151
  if (current === "") {
1132
1152
  ctx.log("cannot read the PR head — query failed (403 = PAT scope)");
@@ -9,7 +9,7 @@
9
9
  * (`--auto=`, `--opencode=`). A bare/full `uninstall` DOES remove them (zero footprint).
10
10
  * Dependency-updater files are not modules — bkit never writes or removes them.
11
11
  */
12
- export const OPTIN_MODULES = new Set(["cloud", "opencode", "codex"]);
12
+ export const OPTIN_MODULES = new Set(["cloud", "opencode", "codex", "antigravity"]);
13
13
  // ---------------------------------------------------------------------------
14
14
  // Issue tracker
15
15
  // ---------------------------------------------------------------------------
@@ -325,6 +325,39 @@ export const CODEX_MANIFEST = [
325
325
  // Agent mirrors (.codex/agents/*.toml) and workflow skills (.agents/skills/bkit-*/) are
326
326
  // managed dynamically — the set follows the bkit-prefix prompt/workflow files at install.
327
327
  ];
328
+ // --antigravity: Google Antigravity IDE host. Installs as a workspace PLUGIN at
329
+ // `.agents/plugins/bkit/` (Antigravity's own packaging surface), so `.agents/` root stays
330
+ // the dedicated Codex install. Root `GEMINI.md` is the redirect mirror of `CLAUDE.md`
331
+ // (Antigravity loads `GEMINI.md` as a workspace rule file).
332
+ export const ANTIGRAVITY_MANIFEST = [
333
+ // plugin.json — the required plugin manifest. Tier-2 json (deep-contained): bkit owns
334
+ // the schema/name/description keys (the schema is `additionalProperties: false`).
335
+ { path: ".agents/plugins/bkit/plugin.json", format: "json", module: "antigravity" },
336
+ // hooks.json — Tier-2 json (deep-contained): bkit owns the PreToolUse GateGuard and
337
+ // guardrails entries, consumers may add their own event groups alongside them.
338
+ { path: ".agents/plugins/bkit/hooks.json", format: "json", module: "antigravity" },
339
+ // bkit-gateguard.cjs — Tier-2 markered-text, twin of the Claude/Codex hook (same
340
+ // stdin/stdout contract); differs in the tool names (`write_to_file` /
341
+ // `replace_file_content`) and the payload path field.
342
+ {
343
+ path: ".agents/plugins/bkit/hooks/bkit-gateguard.cjs",
344
+ format: "markered-text",
345
+ module: "antigravity",
346
+ },
347
+ // bkit-guardrails.cjs — Tier-2 markered-text, twin of the Cursor/Codex hook. Registered
348
+ // on matcher `run_command`, Antigravity's shell tool name.
349
+ {
350
+ path: ".agents/plugins/bkit/hooks/bkit-guardrails.cjs",
351
+ format: "markered-text",
352
+ module: "antigravity",
353
+ },
354
+ // Root GEMINI.md — Antigravity workspace-rule redirect to .agents/rules.md, owned by the
355
+ // antigravity module: `uninstall --antigravity` removes it; other installs leave it.
356
+ { path: "GEMINI.md", format: "markered-text", module: "antigravity" },
357
+ // Subagent prompts (.agents/plugins/bkit/agents/bkit-*.md) and workflow skills
358
+ // (.agents/plugins/bkit/skills/bkit-*/) are managed dynamically — the set follows the
359
+ // bkit-prefix prompt/workflow files at install.
360
+ ];
328
361
  // Cloud agent integration is opt-in — NOT in a default install, so a default install
329
362
  // ships ZERO cloud footprint. Every variant writes no files: the cloud workflow
330
363
  // (bkit-cloud.yml), bkit-cloud-bootstrap.sh and the Cursor Background Agent files
@@ -351,6 +384,7 @@ const MODULE_MANIFESTS = {
351
384
  cursor: CURSOR_MANIFEST,
352
385
  opencode: OPENCODE_MANIFEST,
353
386
  codex: CODEX_MANIFEST,
387
+ antigravity: ANTIGRAVITY_MANIFEST,
354
388
  cloud: CLOUD_MANIFEST,
355
389
  };
356
390
  // ---------------------------------------------------------------------------
@@ -0,0 +1,224 @@
1
+ // install/modules/antigravity.ts — the Google Antigravity host module. The whole host
2
+ // installs into a workspace PLUGIN at `.agents/plugins/bkit/`, so `.agents/` root stays
3
+ // the dedicated Codex install.
4
+ import * as fs from "node:fs";
5
+ import * as path from "node:path";
6
+ import { writeTier2, writeTier2JsonContained, ensureDir } from "../write.js";
7
+ import { stampManagedVersion } from "../version-file.js";
8
+ import { ANTIGRAVITY_AGENTS_DIR, applyAntigravityPrompt, applyAntigravitySkill, } from "../../render/hosts.js";
9
+ import { getCoreRoot, getSharedRoot, getWorkflowsRoot, getPromptsRoot, } from "../../shared/package-roots.js";
10
+ import { DEFAULT_ISSUE_TRACKER } from "../manifest.js";
11
+ import { substituteWorkflow } from "../../render/trackers.js";
12
+ import { BKIT_PREFIX, installFile, listMdFiles, readInstallingVersion, trackMirrorWrite, } from "./core.js";
13
+ // ---------------------------------------------------------------------------
14
+ // runAntigravityModule — Google Antigravity IDE host (opt-in via --antigravity)
15
+ //
16
+ // Nullary flag, like --codex: Antigravity runs on one pinned gateway (`google`).
17
+ //
18
+ // The host installs as a workspace PLUGIN (`.agents/plugins/bkit/`) — Antigravity's own
19
+ // packaging surface (antigravity.google/docs/plugins). The plugin activates per project:
20
+ // .agents/plugins/bkit/plugin.json — plugin manifest (required)
21
+ // .agents/plugins/bkit/skills/bkit-<wf>/SKILL.md — workflow entry points (skills)
22
+ // .agents/plugins/bkit/agents/<name>.md — subagent prompt definitions
23
+ // .agents/plugins/bkit/hooks.json + hooks/ — GateGuard registration (PreToolUse)
24
+ //
25
+ // `.agents/` ROOT stays the dedicated Codex install: Codex workflow skills live at
26
+ // `.agents/skills/bkit-<wf>/SKILL.md` and this module never writes there.
27
+ //
28
+ // There is no native subagent tool on Antigravity: the orchestrator loads a prompt with
29
+ // `view_file` and executes its step contract in-session, which is why the workflow skills
30
+ // respell `**Subagent:** @name` to the plugin's `agents/<name>.md` path.
31
+ //
32
+ // `.agents/plugins/` may hold consumer plugins, so every sweep here is scoped to the
33
+ // `bkit` plugin directory (and, within it, to `bkit-` prefixed entries).
34
+ // ---------------------------------------------------------------------------
35
+ /** The bkit Antigravity workspace plugin root. */
36
+ export const ANTIGRAVITY_PLUGIN_DIR = ".agents/plugins/bkit";
37
+ /** Workflow skills, one directory per workflow, each holding SKILL.md. */
38
+ export const ANTIGRAVITY_SKILLS_DIR = ".agents/plugins/bkit/skills";
39
+ /** Subagent prompt definitions. Sourced from the renderer's shared constant. */
40
+ export { ANTIGRAVITY_AGENTS_DIR };
41
+ /** Hook scripts referenced by the plugin's hooks.json. */
42
+ export const ANTIGRAVITY_HOOKS_DIR = ".agents/plugins/bkit/hooks";
43
+ /**
44
+ * Convert a workflow orchestrator into an Antigravity SKILL.md. Tracker-conditional
45
+ * blocks are resolved first, exactly as for the other hosts' command mirrors.
46
+ */
47
+ export function applyAntigravityWorkflowSkill(content, skillName, issueTracker) {
48
+ return applyAntigravitySkill(substituteWorkflow(content, issueTracker).output, skillName);
49
+ }
50
+ /**
51
+ * Render the plugin's subagent prompts and workflow skills. Extracted so `bkit upgrade`
52
+ * re-renders them identically — bkit-owned output, force-overwritten.
53
+ */
54
+ export function renderAntigravityAgentsSkills(ctx) {
55
+ const { dryRun, effortMap, logPrefix } = ctx;
56
+ const tag = dryRun ? "[dry-run] " : "";
57
+ const issueTracker = ctx.issueTracker ?? DEFAULT_ISSUE_TRACKER;
58
+ const version = ctx.version ?? readInstallingVersion();
59
+ const written = [];
60
+ const modelLookup = ctx.antigravityModelLookup;
61
+ if (!modelLookup) {
62
+ throw new Error("renderAntigravityAgentsSkills: ctx.antigravityModelLookup is required");
63
+ }
64
+ // --- Prompts: markdown+frontmatter -> .agents/plugins/bkit/agents/<name>.md ---
65
+ {
66
+ const src = getPromptsRoot();
67
+ const dest = ANTIGRAVITY_AGENTS_DIR;
68
+ if (!dryRun)
69
+ ensureDir(dest);
70
+ const files = listMdFiles(src, BKIT_PREFIX);
71
+ const sourceSet = new Set(files);
72
+ for (const f of files) {
73
+ const transform = (c) => stampManagedVersion(applyAntigravityPrompt(substituteWorkflow(c, issueTracker).output, modelLookup, effortMap), version);
74
+ if (installFile(path.join(src, f), path.join(dest, f), transform, dryRun)) {
75
+ const rel = path.join(dest, f);
76
+ console.log(`${logPrefix} ${tag}write: ${rel}`);
77
+ trackMirrorWrite(ctx, rel, written);
78
+ }
79
+ }
80
+ // Orphan sweep is bkit-prefix scoped — the plugin's agents/ is bkit-owned.
81
+ if (fs.existsSync(dest)) {
82
+ for (const f of fs.readdirSync(dest)) {
83
+ if (!f.startsWith(BKIT_PREFIX))
84
+ continue;
85
+ if (sourceSet.has(f))
86
+ continue;
87
+ const rel = path.join(dest, f);
88
+ if (!dryRun)
89
+ fs.rmSync(rel, { force: true });
90
+ console.log(`${logPrefix} ${tag}delete orphan: ${rel}`);
91
+ trackMirrorWrite(ctx, rel, written);
92
+ }
93
+ }
94
+ }
95
+ // --- Workflow skills: one directory per workflow, each holding SKILL.md ---
96
+ {
97
+ const src = getWorkflowsRoot();
98
+ const files = listMdFiles(src, BKIT_PREFIX);
99
+ const sourceStems = new Set(files.map((f) => f.replace(/\.md$/, "")));
100
+ if (!dryRun && files.length > 0)
101
+ ensureDir(ANTIGRAVITY_SKILLS_DIR);
102
+ for (const f of files) {
103
+ const stem = f.replace(/\.md$/, "");
104
+ const dest = path.join(ANTIGRAVITY_SKILLS_DIR, stem, "SKILL.md");
105
+ if (!dryRun)
106
+ ensureDir(path.dirname(dest));
107
+ const transform = (c) => stampManagedVersion(applyAntigravityWorkflowSkill(c, stem, issueTracker), version);
108
+ if (installFile(path.join(src, f), dest, transform, dryRun)) {
109
+ console.log(`${logPrefix} ${tag}write: ${dest}`);
110
+ trackMirrorWrite(ctx, dest, written);
111
+ }
112
+ }
113
+ // Prefix-scoped sweep inside the bkit plugin's skills/.
114
+ if (fs.existsSync(ANTIGRAVITY_SKILLS_DIR)) {
115
+ for (const d of fs.readdirSync(ANTIGRAVITY_SKILLS_DIR)) {
116
+ if (!d.startsWith(BKIT_PREFIX))
117
+ continue;
118
+ if (sourceStems.has(d))
119
+ continue;
120
+ const rel = path.join(ANTIGRAVITY_SKILLS_DIR, d);
121
+ if (!dryRun)
122
+ fs.rmSync(rel, { recursive: true, force: true });
123
+ console.log(`${logPrefix} ${tag}delete orphan: ${rel}`);
124
+ trackMirrorWrite(ctx, rel, written);
125
+ }
126
+ }
127
+ }
128
+ return written;
129
+ }
130
+ export function runAntigravityModule(ctx) {
131
+ const { dryRun, advisories, ws, logPrefix } = ctx;
132
+ const tag = dryRun ? "[dry-run] " : "";
133
+ renderAntigravityAgentsSkills(ctx);
134
+ const pluginShared = path.join(getSharedRoot(), ".agents", "plugins", "bkit");
135
+ const pluginHooksSrc = path.join(getCoreRoot(), ".agents", "plugins", "bkit", "hooks");
136
+ // --- plugin.json — Tier-2 json (deep-contained), the required plugin manifest ---
137
+ {
138
+ const jsonSrc = path.join(pluginShared, "plugin.json");
139
+ const jsonDst = path.join(ANTIGRAVITY_PLUGIN_DIR, "plugin.json");
140
+ if (fs.existsSync(jsonSrc)) {
141
+ if (!dryRun)
142
+ ensureDir(path.dirname(jsonDst));
143
+ const prevLen = ws.writes.length;
144
+ writeTier2JsonContained(jsonSrc, jsonDst, dryRun, ws);
145
+ if (ws.writes.length > prevLen)
146
+ console.log(`${logPrefix} ${tag}antigravity: ${jsonDst}`);
147
+ }
148
+ }
149
+ // Root GEMINI.md — Antigravity workspace-rule redirect to .agents/rules.md. A ROOT file
150
+ // (not under .agents/), so the plugin walk does not cover it. Tier-2 markered-text
151
+ // (writeTier2 html-comment), exact twin of the claude module's CLAUDE.md.
152
+ {
153
+ const src = path.join(getSharedRoot(), "GEMINI.md");
154
+ const dst = "GEMINI.md";
155
+ if (fs.existsSync(src)) {
156
+ const prevLen = ws.writes.length;
157
+ writeTier2(src, dst, ctx.tokens, "html-comment", dryRun, ws);
158
+ if (ws.writes.length > prevLen)
159
+ console.log(`${logPrefix} ${tag}antigravity: ${dst}`);
160
+ }
161
+ }
162
+ // --- plugin hooks.json — Tier-2 deep-contained (consumers may add their own groups) ---
163
+ {
164
+ const jsonSrc = path.join(pluginShared, "hooks.json");
165
+ const jsonDst = path.join(ANTIGRAVITY_PLUGIN_DIR, "hooks.json");
166
+ if (fs.existsSync(jsonSrc)) {
167
+ if (!dryRun)
168
+ ensureDir(path.dirname(jsonDst));
169
+ const prevLen = ws.writes.length;
170
+ writeTier2JsonContained(jsonSrc, jsonDst, dryRun, ws);
171
+ if (ws.writes.length > prevLen)
172
+ console.log(`${logPrefix} ${tag}antigravity: ${jsonDst}`);
173
+ }
174
+ }
175
+ // --- bkit-gateguard.cjs — Tier-2 markered-text, twin of the Claude/Codex hook ---
176
+ {
177
+ const hookSrc = path.join(pluginHooksSrc, "bkit-gateguard.cjs");
178
+ const hookDst = path.join(ANTIGRAVITY_HOOKS_DIR, "bkit-gateguard.cjs");
179
+ if (fs.existsSync(hookSrc)) {
180
+ if (!dryRun)
181
+ ensureDir(path.dirname(hookDst));
182
+ const prevLen = ws.writes.length;
183
+ writeTier2(hookSrc, hookDst, ctx.tokens, "slash-comment", dryRun, ws);
184
+ if (ws.writes.length > prevLen)
185
+ console.log(`${logPrefix} ${tag}antigravity: ${hookDst}`);
186
+ }
187
+ }
188
+ // --- bkit-guardrails.cjs — Tier-2 markered-text, twin of the Cursor/Codex hook ---
189
+ // Registered on matcher `run_command` in hooks.json above. Same decision engine as the
190
+ // other hosts; the deny tier blocks for real.
191
+ {
192
+ const railSrc = path.join(pluginHooksSrc, "bkit-guardrails.cjs");
193
+ const railDst = path.join(ANTIGRAVITY_HOOKS_DIR, "bkit-guardrails.cjs");
194
+ if (fs.existsSync(railSrc)) {
195
+ if (!dryRun)
196
+ ensureDir(path.dirname(railDst));
197
+ const prevLen = ws.writes.length;
198
+ writeTier2(railSrc, railDst, ctx.tokens, "slash-comment", dryRun, ws);
199
+ if (ws.writes.length > prevLen)
200
+ console.log(`${logPrefix} ${tag}antigravity: ${railDst}`);
201
+ }
202
+ }
203
+ advisories.push({
204
+ id: "antigravity-setup",
205
+ severity: "advisory",
206
+ detect: "antigravity host installed as a workspace plugin (.agents/plugins/bkit/: plugin.json + skills/bkit-* + agents/ + hooks.json).",
207
+ action: "Three things that differ from the other hosts:\n" +
208
+ "1. Workflows are SKILLS here, not slash commands: Antigravity discovers them under `.agents/plugins/bkit/skills/bkit-<wf>/SKILL.md` (the plugin activates per project — no toggle).\n" +
209
+ "2. There is no native subagent tool. The orchestrator loads each subagent prompt from `.agents/plugins/bkit/agents/` with `view_file` and executes it in-session; isolated runs use `run_command` (`agy`).\n" +
210
+ "3. GateGuard and guardrails are wired from `.agents/plugins/bkit/hooks.json` (PreToolUse on `write_to_file` / `replace_file_content` / `run_command`). See .bkit/providers.md.",
211
+ });
212
+ // Both hosts installed: Antigravity's skill selector lists TWO sets of bkit-* skills.
213
+ // Codex does not merge same-named skills; Antigravity lists both. Warn which to pick.
214
+ const codexPresent = ctx.installedModules?.has("codex") ??
215
+ fs.existsSync(path.join(process.cwd(), ".codex", "agents"));
216
+ if (codexPresent) {
217
+ advisories.push({
218
+ id: "antigravity-codex-skill-overlap",
219
+ severity: "advisory",
220
+ detect: "Codex and Antigravity are both installed — Antigravity's skill selector now lists BOTH the Codex workflow skills (`.agents/skills/bkit-<wf>/SKILL.md`) and the Antigravity plugin skills (`.agents/plugins/bkit/skills/bkit-<wf>/SKILL.md`).",
221
+ action: "In Antigravity, invoke the WORKFLOW skills from the plugin under `.agents/plugins/bkit/skills/bkit-<wf>/SKILL.md` — they carry Antigravity's tool vocabulary (`view_file`, plugin subagent paths). The `.agents/skills/bkit-*` copies are Codex's install and name Claude/Codex tools Antigravity does not have. If you only use one host, the other's skills are harmless but may appear in the picker.",
222
+ });
223
+ }
224
+ }
@@ -98,6 +98,9 @@ export function renderCodexAgentsSkills(ctx) {
98
98
  }
99
99
  }
100
100
  // --- Workflow skills: one directory per workflow, each holding SKILL.md ---
101
+ // `.agents/skills/` is Codex's. The Antigravity host installs its own workflow skills
102
+ // into a workspace plugin (`.agents/plugins/bkit/skills/`) instead, so this directory
103
+ // has a single writer and the two hosts never fight over one file.
101
104
  {
102
105
  const src = getWorkflowsRoot();
103
106
  const files = listMdFiles(src, BKIT_PREFIX);
@@ -70,7 +70,13 @@ export function removeOrphans(destDir, sourceFiles, dryRun, prefix) {
70
70
  return removed;
71
71
  }
72
72
  /** The markered-text `.agents/*.md` blocks core owns. */
73
- const CORE_AGENT_FILES = ["context.md", "docs.md", "rules.md", "skills.md"];
73
+ const CORE_AGENT_FILES = [
74
+ "context.md",
75
+ "docs.md",
76
+ "rules.md",
77
+ "shortcuts.md",
78
+ "skills.md",
79
+ ];
74
80
  // The two shared-root files core writes: stored in `shared/`, owned by the core
75
81
  // manifest, written as html-comment managed blocks.
76
82
  const CORE_SHARED_FILES = [
@@ -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
  /**
@@ -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
+ }