@indigoai-us/hq-cli 5.345.246 → 5.345.247

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -2,6 +2,15 @@
2
2
 
3
3
  ## [Unreleased]
4
4
 
5
+ ## [5.345.247] — 2026-11-23
6
+ - Added (`hq install --global`, `hq doctor`): Google Antigravity is a supported host. When Antigravity is detected (or with `--runtime antigravity`), HQ writes an always-on global rule at `~/.gemini/config/rules/hq.md` that points at the HQ charter and registers the `hq` MCP server in `~/.gemini/config/mcp_config.json`, keeping other servers. An invalid file, or an existing `hq` entry with a different definition, is left unchanged with a warning and the rest of the install continues. Only the core `hq` server is written; pack and integration MCP servers are not registered in Antigravity. `hq doctor` detects the Antigravity app and reports the rule and MCP wiring. Antigravity hooks are not wired yet.
7
+ - Internal: The `hq-hook PR tests` jobs no longer run on GitHub-hosted runners for same-repo pull requests or the daily run. The test shards and the Grok comparison always take the Mac pool and wait in its queue when the Macs are busy; they no longer wait for the route job, which now only reports the pool's queue and load. The Windows Clippy cross-check runs on the Mac pool too. Fork pull requests, `HQ_MAC_RUNNERS=off` and the `ci-hosted-runners` label keep ubuntu-latest. The Mac load limit is now measured against the Docker VM's CPU count (12 and 14) instead of the container's cap (6), and the queue threshold matches the pool's five runners.
8
+ - Fix `conduct_link::tests::a_timeout_ends_the_whole_process_group` on Linux containers without a zombie-reaping PID 1 by treating `/proc/<pid>/stat` zombie/dead states (`Z`/`X`/`x`) as terminated in `alive()`.
9
+ - Fixed: the native hook packages built for a release tag now report that release in `hq-hook --version`, matching the package version.
10
+ - Fixed: `hq reindex` keeps an event on the shell hook when the HQ root's copy of a script the native hook engine rebuilds for that event (the Work Mesh turn-end hook, the policy enforcement gate, the Codex and Grok adapters, the session scope library) is a revision the engine does not rebuild, so a newer or edited core no longer has those events refused after the switch.
11
+ - Internal: the native model of master-hook's own PreToolUse work now follows hq-core v16.0.50 and covers the Codex adapter as well as Claude Code. It skips hqd's policy check (the native scope guard and policy injector already run for the event), refuses with master-hook's own line when the hook registry cannot be read, and refuses Codex payloads it cannot match to what the adapter gave master-hook. The engine now lists every file the native PreToolUse reproduces at pinned versions (master-hook.sh and the files it sources, the vault-write guard and the credential guard), for the hold that will keep an HQ with other versions on the old dispatcher. Nothing is registered and PreToolUse does not switch on any host yet.
12
+ - Internal: on Grok Build, the repository merge-hold check and the write-guard shadow record now run in the native hook engine instead of the shell hooks. One shared helper rebuilds the payload the hq-core v16.0.50 Grok adapter hands its hooks (the command and path it reads, its session id and working folder), the shadow record is written under the adapter's HQ root, and the merge-hold records are read under that root as well as the one the environment names. A merge whose command the adapter would have read differently from the native engine is refused. Claude Code and Codex are unchanged; local bots (`fleet-local`) and hosted agents (`agents-v2`) keep the shell hooks.
13
+
5
14
  ## [5.345.246] — 2026-11-23
6
15
  - Fixed: the agent MCP tool `hq_dm_send` no longer answers "sent to <recipient>" when the server saved a DM but held it back from the recipient (`delivery: "held"`, for example an agent-to-agent DM stopped by the bot loop breaker). It now returns a warning that the DM was not delivered, with the server's explanation and reason, so the sending agent knows to resend later.
7
16
  - Internal: Pushes to `train/**` branches run the same Linux checks as a merge-queue run, on the self-hosted pools only. This is the trigger for the merge lane's batch train, which tests main plus a batch of ready pull requests before any of them merges.
@@ -361,7 +361,7 @@ export declare const COMMAND_CATALOG: readonly [{
361
361
  readonly hidden: false;
362
362
  }, {
363
363
  readonly flags: "--runtime <runtime>";
364
- readonly description: "Runtime for --global (claude | codex | chatgpt | grok)";
364
+ readonly description: "Runtime for --global (claude | codex | chatgpt | grok | antigravity)";
365
365
  readonly hidden: false;
366
366
  readonly defaultValue: "claude";
367
367
  }, {
@@ -763,7 +763,7 @@ export declare const COMMAND_CATALOG: readonly [{
763
763
  readonly hidden: false;
764
764
  }, {
765
765
  readonly flags: "--runtime <runtime>";
766
- readonly description: "Runtime for --global (claude | codex | chatgpt | grok)";
766
+ readonly description: "Runtime for --global (claude | codex | chatgpt | grok | antigravity)";
767
767
  readonly hidden: false;
768
768
  readonly defaultValue: "claude";
769
769
  }, {
@@ -6831,7 +6831,7 @@ export declare const COMMAND_CATALOG: readonly [{
6831
6831
  }];
6832
6832
  }, {
6833
6833
  readonly name: "reindex";
6834
- readonly description: "Surface namespaced skills, materialize legacy knowledge repos, regenerate the workers registry, and trust HQ hooks for Codex, Grok, and Claude Code";
6834
+ readonly description: "Surface namespaced skills, materialize legacy knowledge repos, regenerate the workers registry, and trust HQ hooks for Codex, Grok, and Claude Code (Antigravity: rule and MCP come from hq install --global; hooks pending)";
6835
6835
  readonly aliases: readonly ["master-sync"];
6836
6836
  readonly hidden: false;
6837
6837
  readonly helpOption: true;
@@ -406,7 +406,7 @@ export const COMMAND_CATALOG = [
406
406
  },
407
407
  {
408
408
  "flags": "--runtime <runtime>",
409
- "description": "Runtime for --global (claude | codex | chatgpt | grok)",
409
+ "description": "Runtime for --global (claude | codex | chatgpt | grok | antigravity)",
410
410
  "hidden": false,
411
411
  "defaultValue": "claude"
412
412
  },
@@ -910,7 +910,7 @@ export const COMMAND_CATALOG = [
910
910
  },
911
911
  {
912
912
  "flags": "--runtime <runtime>",
913
- "description": "Runtime for --global (claude | codex | chatgpt | grok)",
913
+ "description": "Runtime for --global (claude | codex | chatgpt | grok | antigravity)",
914
914
  "hidden": false,
915
915
  "defaultValue": "claude"
916
916
  },
@@ -8331,7 +8331,7 @@ export const COMMAND_CATALOG = [
8331
8331
  },
8332
8332
  {
8333
8333
  "name": "reindex",
8334
- "description": "Surface namespaced skills, materialize legacy knowledge repos, regenerate the workers registry, and trust HQ hooks for Codex, Grok, and Claude Code",
8334
+ "description": "Surface namespaced skills, materialize legacy knowledge repos, regenerate the workers registry, and trust HQ hooks for Codex, Grok, and Claude Code (Antigravity: rule and MCP come from hq install --global; hooks pending)",
8335
8335
  "aliases": [
8336
8336
  "master-sync"
8337
8337
  ],
@@ -65,6 +65,19 @@ export declare function uninstallGlobalClaude(opts?: GlobalUninstallOptions): st
65
65
  export declare function installGlobalCodex(opts: GlobalInstallOptions): string[];
66
66
  /** Reverse every Codex install step; non-HQ entries are left untouched. */
67
67
  export declare function uninstallGlobalCodex(opts?: GlobalUninstallOptions): string[];
68
+ export interface AntigravityInstallResult {
69
+ rule: 'written' | 'unchanged' | 'foreign' | 'dry-run';
70
+ mcp: 'registered' | 'unchanged' | 'invalid-json' | 'conflict' | 'dry-run';
71
+ touched: string[];
72
+ }
73
+ /**
74
+ * Wire HQ into Google Antigravity at user scope: the always-on global rule
75
+ * `~/.gemini/config/rules/hq.md` and the `hq` server in
76
+ * `~/.gemini/config/mcp_config.json`. Never clobbers a user-owned rule file and
77
+ * never overwrites an mcp_config.json that is not valid JSON or that already has
78
+ * a different `hq` entry (all reported as warnings). Idempotent. Hooks are not wired yet.
79
+ */
80
+ export declare function installGlobalAntigravity(opts: GlobalInstallOptions): AntigravityInstallResult;
68
81
  export interface GlobalCommandOpts {
69
82
  global?: boolean;
70
83
  runtime?: string;
@@ -87,6 +100,8 @@ export interface GlobalCommandOpts {
87
100
  shimPathCheck?: () => ShimPathCheck | null;
88
101
  /** Test seam: the Windows npm prefix holding hq.cmd. Null off Windows. */
89
102
  ps1ShimDir?: () => string | null;
103
+ /** Test seam: is Google Antigravity installed? Default: {@link detectAntigravity}. */
104
+ antigravityDetected?: () => boolean;
90
105
  }
91
106
  export declare function resolveInstallRoot(explicit: string | undefined, options?: {
92
107
  env?: NodeJS.ProcessEnv;
@@ -13,7 +13,7 @@ import * as fs from 'fs';
13
13
  import * as os from 'node:os';
14
14
  import * as path from 'path';
15
15
  import { spawnSync } from 'node:child_process';
16
- import { buildCodexServerDef, claudeConfigFormat, codexConfigFormat, codexRemovalFormat, isCodexInstalled, jsonFormat, mergeCodexServer, removeCodexServer, registerCodexServer, unregisterCodexServer, mergeClaudeServer, readConfigDoc, realpathOrSelf, registerClaudeServer, resolveEnv, unregisterClaudeServer, writeConfigAtomic, } from './mcp-registration.js';
16
+ import { buildCodexServerDef, claudeConfigFormat, codexConfigFormat, codexRemovalFormat, isCodexInstalled, jsonFormat, mergeCodexServer, removeCodexServer, registerCodexServer, unregisterCodexServer, mergeClaudeServer, readConfigDoc, realpathOrSelf, registerClaudeServer, registerAntigravityServer, ConfigParseError, McpNameCollisionError, resolveEnv, unregisterClaudeServer, writeConfigAtomic, } from './mcp-registration.js';
17
17
  import { seedRegistryFromHqRoot } from './link.js';
18
18
  import { resolveMcpLaunch } from '../utils/mcp-launcher.js';
19
19
  import { resolveHqRoot } from './doctor.js';
@@ -23,6 +23,7 @@ import { linkDirectory, removeLinkOnly, removeSkillEntry, skillCopySource } from
23
23
  import { chatgptConnectorInstructions } from '../lib/install/chatgpt-targets.js';
24
24
  import { anywhereRuntimeAllowed } from '../lib/anywhere-person-setting.js';
25
25
  import { grokConnectorInstructions } from '../lib/install/grok-targets.js';
26
+ import { ANTIGRAVITY_HOOKS_ADVISORY, antigravityTargets, detectAntigravity, planAntigravityRule, } from '../lib/install/antigravity-targets.js';
26
27
  import { readRegistry, registryDir, registryFile, writeRegistry } from '../lib/registry/registry.js';
27
28
  import { readCompaniesManifestMap } from '../lib/work-context/repo-remote.js';
28
29
  import { resolveDefaultHqRoot } from '../utils/hq-root-resolver.js';
@@ -1126,10 +1127,86 @@ export function uninstallGlobalCodex(opts = {}) {
1126
1127
  log(`HQ removed from Codex user scope (${links.length} skill link(s), hooks, MCP server, AGENTS.md block).`);
1127
1128
  return touched;
1128
1129
  }
1130
+ /**
1131
+ * Wire HQ into Google Antigravity at user scope: the always-on global rule
1132
+ * `~/.gemini/config/rules/hq.md` and the `hq` server in
1133
+ * `~/.gemini/config/mcp_config.json`. Never clobbers a user-owned rule file and
1134
+ * never overwrites an mcp_config.json that is not valid JSON or that already has
1135
+ * a different `hq` entry (all reported as warnings). Idempotent. Hooks are not wired yet.
1136
+ */
1137
+ export function installGlobalAntigravity(opts) {
1138
+ const home = resolveEnv({ home: opts.home }).home;
1139
+ const log = opts.log ?? ((l) => console.log(l));
1140
+ const t = antigravityTargets(home);
1141
+ const manifest = mcpManifest(opts);
1142
+ const touched = [];
1143
+ const ruleOld = readOrNull(t.ruleFile);
1144
+ const plan = planAntigravityRule(ruleOld, opts.hqRoot);
1145
+ let rule;
1146
+ if (plan.action === 'foreign') {
1147
+ rule = 'foreign';
1148
+ log(` Antigravity: ${t.ruleFile} exists and is not managed by HQ; left unchanged. Move it away and re-run to install the HQ rule.`);
1149
+ }
1150
+ else if (opts.dryRun) {
1151
+ rule = 'dry-run';
1152
+ if (plan.action === 'write') {
1153
+ touched.push(t.ruleFile);
1154
+ log(`[dry-run] would write ${t.ruleFile}`);
1155
+ }
1156
+ }
1157
+ else if (plan.action === 'write') {
1158
+ writeFileAtomic(t.ruleFile, plan.content);
1159
+ touched.push(t.ruleFile);
1160
+ rule = 'written';
1161
+ }
1162
+ else {
1163
+ rule = 'unchanged';
1164
+ }
1165
+ let mcp;
1166
+ if (opts.dryRun) {
1167
+ mcp = 'dry-run';
1168
+ log(`[dry-run] would register MCP "${HQ_MCP_SERVER_NAME}" in ${t.mcpConfig}`);
1169
+ }
1170
+ else {
1171
+ try {
1172
+ const res = registerAntigravityServer({
1173
+ name: HQ_MCP_SERVER_NAME,
1174
+ manifest,
1175
+ pack: HQ_ANYWHERE_PACK,
1176
+ env: { home },
1177
+ });
1178
+ if ('skipped' in res)
1179
+ throw new Error(res.reason);
1180
+ mcp = res.changed ? 'registered' : 'unchanged';
1181
+ if (res.changed)
1182
+ touched.push(t.mcpConfig);
1183
+ }
1184
+ catch (e) {
1185
+ if (e instanceof ConfigParseError) {
1186
+ mcp = 'invalid-json';
1187
+ log(` Antigravity: WARNING ${t.mcpConfig} is not valid JSON; left unchanged. Fix the file and re-run to register the HQ MCP server.`);
1188
+ }
1189
+ else if (e instanceof McpNameCollisionError) {
1190
+ mcp = 'conflict';
1191
+ log(` Antigravity: WARNING ${t.mcpConfig} already has an MCP server "${HQ_MCP_SERVER_NAME}" with a different definition; left unchanged. Rename or remove that entry and re-run to register the local HQ MCP server.`);
1192
+ }
1193
+ else {
1194
+ throw e;
1195
+ }
1196
+ }
1197
+ }
1198
+ if (!opts.dryRun) {
1199
+ log(`HQ installed for Antigravity from ${opts.hqRoot}.`);
1200
+ log(` rule: ${t.ruleFile} (${rule})`);
1201
+ log(` MCP: "${HQ_MCP_SERVER_NAME}" in ${t.mcpConfig} (${mcp})`);
1202
+ log(` ${ANTIGRAVITY_HOOKS_ADVISORY}.`);
1203
+ }
1204
+ return { rule, mcp, touched };
1205
+ }
1129
1206
  function assertRuntime(runtime) {
1130
1207
  const r = runtime ?? 'claude';
1131
- if (r !== 'claude' && r !== 'codex' && r !== 'chatgpt' && r !== 'grok') {
1132
- throw Object.assign(new Error(`--runtime ${r} is not supported. Use --runtime claude, codex, chatgpt, or grok.`), {
1208
+ if (r !== 'claude' && r !== 'codex' && r !== 'chatgpt' && r !== 'grok' && r !== 'antigravity') {
1209
+ throw Object.assign(new Error(`--runtime ${r} is not supported. Use --runtime claude, codex, chatgpt, grok, or antigravity.`), {
1133
1210
  expected: true,
1134
1211
  });
1135
1212
  }
@@ -1206,8 +1283,12 @@ export async function runInstallGlobal(opts) {
1206
1283
  return;
1207
1284
  }
1208
1285
  }
1209
- const install = runtime === 'codex' ? installGlobalCodex : installGlobalClaude;
1210
1286
  const hqRoot = resolveInstallRoot(opts.hqRoot, { env, cwd: opts.cwd, home: opts.home });
1287
+ if (runtime === 'antigravity') {
1288
+ installGlobalAntigravity({ hqRoot, home: opts.home, dryRun: opts.dryRun, env, log: opts.log });
1289
+ return;
1290
+ }
1291
+ const install = runtime === 'codex' ? installGlobalCodex : installGlobalClaude;
1211
1292
  if (process.platform === 'win32' && !opts.dryRun) {
1212
1293
  try {
1213
1294
  await installWindowsJq({ home: opts.home });
@@ -1230,6 +1311,19 @@ export async function runInstallGlobal(opts) {
1230
1311
  });
1231
1312
  if (runtime === 'codex' && !opts.dryRun)
1232
1313
  await trustInstalledCodexHooks(hqRoot, opts);
1314
+ // Antigravity rides along with a Claude/Codex install when it is present.
1315
+ const antigravityPresent = opts.antigravityDetected
1316
+ ? opts.antigravityDetected()
1317
+ : detectAntigravity({ home: resolveEnv({ home: opts.home }).home, env }).detected;
1318
+ if (antigravityPresent) {
1319
+ try {
1320
+ installGlobalAntigravity({ hqRoot, home: opts.home, dryRun: opts.dryRun, env, log: opts.log });
1321
+ }
1322
+ catch (error) {
1323
+ const message = error instanceof Error ? error.message : String(error);
1324
+ (opts.log ?? console.log)(` Antigravity: not wired (${message}). Re-run \`hq install --global --runtime antigravity\`.`);
1325
+ }
1326
+ }
1233
1327
  if (!opts.dryRun) {
1234
1328
  try {
1235
1329
  ensureShimOnUserPath({ env, entry: process.argv[1] });
@@ -198,6 +198,10 @@ export declare function codexHome(env: SafeWriteEnv): string;
198
198
  export declare function codexConfigPath(env: SafeWriteEnv): string;
199
199
  /** True iff the Codex runtime is installed (`~/.codex` exists). Never creates it. */
200
200
  export declare function isCodexInstalled(env: SafeWriteEnv): boolean;
201
+ /** `~/.gemini/config` — the Antigravity config root. */
202
+ export declare function antigravityConfigDir(env: SafeWriteEnv): string;
203
+ /** `~/.gemini/config/mcp_config.json` — the GLOBAL Antigravity MCP config (App, IDE and CLI share it). */
204
+ export declare function antigravityConfigPath(env: SafeWriteEnv): string;
201
205
  /** `~/.claude.json` — the PINNED single Claude surface (top-level mcpServers). */
202
206
  export declare function claudeConfigPath(env: SafeWriteEnv): string;
203
207
  /** Outcome of {@link readConfigDoc}: a parsed doc plus whether the file pre-existed. */
@@ -622,6 +626,19 @@ export declare function assertValidServerName(name: string): void;
622
626
  * @throws ConfigParseError / ConfigPermissionError / PartialRegistrationError (from the core)
623
627
  */
624
628
  export declare function registerClaudeServer(opts: RegisterServerOptions): RegisterSurfaceResult;
629
+ export declare const antigravityConfigFormat: ConfigFormat<Record<string, unknown>>;
630
+ /** Build the Antigravity server def (same command/args/env as Claude and Codex). */
631
+ export declare function buildAntigravityServerDef(manifest: McpManifest, resolve: SecretResolver, secretSink: Set<string>): Record<string, unknown>;
632
+ /** True iff `entry` is a local stdio server launched as `<cmd> ... mcp serve` (the shape HQ writes). */
633
+ export declare function isHqLocalAntigravityServer(entry: unknown): boolean;
634
+ /** Merge fn for the Antigravity surface. A foreign entry of the same name throws McpNameCollisionError. */
635
+ export declare function mergeAntigravityServer(name: string, def: Record<string, unknown>): (doc: Record<string, unknown>) => Record<string, unknown>;
636
+ /**
637
+ * Emit ONE server into `~/.gemini/config/mcp_config.json`, creating the file if
638
+ * needed. Skips SSE manifests, which Antigravity does not support. Called only by
639
+ * `hq install --global`; registerServer does not fan out to Antigravity.
640
+ */
641
+ export declare function registerAntigravityServer(opts: RegisterServerOptions): RegisterSurfaceResult | RegisterSurfaceSkip;
625
642
  /**
626
643
  * Fan ONE server out across the per-runtime surfaces. US-007 wires the Claude/JSON
627
644
  * arm ({@link registerClaudeServer}); US-008 wires the Codex/TOML arm
@@ -219,6 +219,14 @@ export function isCodexInstalled(env) {
219
219
  return false;
220
220
  }
221
221
  }
222
+ /** `~/.gemini/config` — the Antigravity config root. */
223
+ export function antigravityConfigDir(env) {
224
+ return path.join(env.home, '.gemini', 'config');
225
+ }
226
+ /** `~/.gemini/config/mcp_config.json` — the GLOBAL Antigravity MCP config (App, IDE and CLI share it). */
227
+ export function antigravityConfigPath(env) {
228
+ return path.join(antigravityConfigDir(env), 'mcp_config.json');
229
+ }
222
230
  /** `~/.claude.json` — the PINNED single Claude surface (top-level mcpServers). */
223
231
  export function claudeConfigPath(env) {
224
232
  return path.join(env.home, '.claude.json');
@@ -1315,6 +1323,117 @@ export function registerClaudeServer(opts) {
1315
1323
  throw e;
1316
1324
  }
1317
1325
  }
1326
+ // ---------------------------------------------------------------------------
1327
+ // Antigravity/JSON surface (`~/.gemini/config/mcp_config.json`).
1328
+ //
1329
+ // Shape: {"mcpServers": {"<name>": {command, args, env}}} for stdio, or
1330
+ // {serverUrl, headers} for Streamable HTTP. Antigravity does not support legacy
1331
+ // SSE, so an `sse` manifest is skipped. Every other server and top-level key is
1332
+ // preserved by the merge; the file goes through writeConfigAtomic (lock, backup,
1333
+ // atomic replace, verify). A non-empty file that is not valid JSON aborts with
1334
+ // ConfigParseError and is never overwritten.
1335
+ //
1336
+ // Only `hq install --global` writes here, and only the core `hq` server. Entries
1337
+ // carry no `_hqPack` provenance key: Google documents a fixed set of entry keys,
1338
+ // so HQ adds none. An existing entry counts as HQ's own when it is a local stdio
1339
+ // `... mcp serve` server (see {@link isHqLocalAntigravityServer}).
1340
+ // ---------------------------------------------------------------------------
1341
+ export const antigravityConfigFormat = {
1342
+ parse: jsonFormat.parse,
1343
+ serialize: jsonFormat.serialize,
1344
+ emptyDoc: () => ({}),
1345
+ assertEntry(doc, name) {
1346
+ const servers = doc.mcpServers;
1347
+ if (!servers || typeof servers !== 'object' || Array.isArray(servers) || !(name in servers)) {
1348
+ throw new Error(`mcpServers.${name} not present after write`);
1349
+ }
1350
+ },
1351
+ };
1352
+ /** Build the Antigravity server def (same command/args/env as Claude and Codex). */
1353
+ export function buildAntigravityServerDef(manifest, resolve, secretSink) {
1354
+ const def = {};
1355
+ if (manifest.type === 'http') {
1356
+ if (manifest.url !== undefined)
1357
+ def.serverUrl = manifest.url;
1358
+ if (manifest.headers !== undefined)
1359
+ def.headers = resolveStringMap(manifest.headers, resolve, secretSink);
1360
+ }
1361
+ else {
1362
+ if (manifest.command !== undefined)
1363
+ def.command = manifest.command;
1364
+ if (manifest.args !== undefined)
1365
+ def.args = manifest.args.map((arg) => resolveSecretRefs(arg, resolve, secretSink));
1366
+ if (manifest.env !== undefined)
1367
+ def.env = resolveStringMap(manifest.env, resolve, secretSink);
1368
+ }
1369
+ return def;
1370
+ }
1371
+ /** True iff `entry` is a local stdio server launched as `<cmd> ... mcp serve` (the shape HQ writes). */
1372
+ export function isHqLocalAntigravityServer(entry) {
1373
+ if (!entry || typeof entry !== 'object' || Array.isArray(entry))
1374
+ return false;
1375
+ const e = entry;
1376
+ if (typeof e.command !== 'string' || e.serverUrl !== undefined || e.url !== undefined)
1377
+ return false;
1378
+ if (!Array.isArray(e.args) || e.args.length < 2)
1379
+ return false;
1380
+ return e.args[e.args.length - 2] === 'mcp' && e.args[e.args.length - 1] === 'serve';
1381
+ }
1382
+ /** Merge fn for the Antigravity surface. A foreign entry of the same name throws McpNameCollisionError. */
1383
+ export function mergeAntigravityServer(name, def) {
1384
+ return (doc) => {
1385
+ const current = doc.mcpServers;
1386
+ if (current !== undefined && (current === null || typeof current !== 'object' || Array.isArray(current))) {
1387
+ throw new McpNameCollisionError('mcpServers in ~/.gemini/config/mcp_config.json is not an object; refusing to rewrite it.');
1388
+ }
1389
+ const servers = { ...(current ?? {}) };
1390
+ const existing = servers[name];
1391
+ if (existing !== undefined) {
1392
+ if (serverDefsEqual(existing, def))
1393
+ return doc;
1394
+ if (isHqLocalAntigravityServer(existing) && isHqLocalAntigravityServer(def)) {
1395
+ servers[name] = def;
1396
+ return { ...doc, mcpServers: servers };
1397
+ }
1398
+ throw new McpNameCollisionError(`MCP server "${name}" is already defined in ~/.gemini/config/mcp_config.json with a ` +
1399
+ 'different definition — refusing to overwrite. Remove or rename the existing server, then re-install.');
1400
+ }
1401
+ servers[name] = def;
1402
+ return { ...doc, mcpServers: servers };
1403
+ };
1404
+ }
1405
+ /**
1406
+ * Emit ONE server into `~/.gemini/config/mcp_config.json`, creating the file if
1407
+ * needed. Skips SSE manifests, which Antigravity does not support. Called only by
1408
+ * `hq install --global`; registerServer does not fan out to Antigravity.
1409
+ */
1410
+ export function registerAntigravityServer(opts) {
1411
+ assertValidServerName(opts.name);
1412
+ const env = resolveEnv(opts.env);
1413
+ if (opts.manifest.type === 'sse') {
1414
+ return { skipped: true, reason: 'Antigravity supports stdio and Streamable HTTP MCP servers, not SSE' };
1415
+ }
1416
+ const secretSink = new Set();
1417
+ const def = buildAntigravityServerDef(opts.manifest, opts.resolveSecret ?? noSecretResolver, secretSink);
1418
+ try {
1419
+ const res = writeConfigAtomic({
1420
+ target: antigravityConfigPath(env),
1421
+ pack: opts.pack,
1422
+ format: antigravityConfigFormat,
1423
+ merge: mergeAntigravityServer(opts.name, def),
1424
+ assertName: opts.name,
1425
+ env: opts.env,
1426
+ lock: opts.lock,
1427
+ stamp: opts.stamp,
1428
+ });
1429
+ return { changed: res.changed, realTarget: res.realTarget };
1430
+ }
1431
+ catch (e) {
1432
+ if (secretSink.size > 0 && e instanceof Error)
1433
+ e.message = redactSecrets(e.message, secretSink);
1434
+ throw e;
1435
+ }
1436
+ }
1318
1437
  /**
1319
1438
  * Resolve the Claude target path from a (partial) env, mirroring
1320
1439
  * {@link claudeConfigPath} but tolerating an undefined env (production default).
@@ -47,7 +47,7 @@ export function registerPackageInstallCommand(parent) {
47
47
  .option('--start-bot', "After install, create and start the pack's setup bot (packs with a setup: block); prints `bot: <name>`")
48
48
  .option('--branch', 'Follow a ref instead of SHA-pinning (git content-pack flow)')
49
49
  .option('--global', 'Install HQ into an agent runtime at user scope (requires the hq-anywhere-runtime flag)')
50
- .option('--runtime <runtime>', 'Runtime for --global (claude | codex | chatgpt | grok)', 'claude')
50
+ .option('--runtime <runtime>', 'Runtime for --global (claude | codex | chatgpt | grok | antigravity)', 'claude')
51
51
  .option('--via <mode>', 'With --global Claude: install directly or via plugin (direct | plugin)', 'direct')
52
52
  .option('--marketplace-dir <dir>', 'With --via plugin: local Claude Code marketplace directory (or HQ_CLAUDE_PLUGIN_MARKETPLACE)')
53
53
  .option('--dry-run', 'With --global: print every file and config diff without writing')
@@ -741,7 +741,7 @@ export function registerReindexCommand(program) {
741
741
  program
742
742
  .command('reindex')
743
743
  .alias('master-sync')
744
- .description('Surface namespaced skills, materialize legacy knowledge repos, regenerate the workers registry, and trust HQ hooks for Codex, Grok, and Claude Code')
744
+ .description('Surface namespaced skills, materialize legacy knowledge repos, regenerate the workers registry, and trust HQ hooks for Codex, Grok, and Claude Code (Antigravity: rule and MCP come from hq install --global; hooks pending)')
745
745
  .option('--repo-root <path>', 'HQ root to operate on (defaults to the current directory)')
746
746
  .option('--from-hook', 'Invoked from a Claude/Codex lifecycle hook: never wait on the per-root operation lock — if a sync/rescue holds it, skip this reindex instead of blocking the session (equivalent to --lock-timeout 0)')
747
747
  .option('--lock-timeout <seconds>', 'Bound the wait for the per-root operation lock (seconds). 0 = refuse immediately; omitted = wait indefinitely (the interactive default). --from-hook implies 0; an explicit --lock-timeout wins.')
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Google Antigravity wiring checks.
3
+ *
4
+ * HQ wires Antigravity through two user-scope files under `~/.gemini/config/`:
5
+ * the always-on global rule `rules/hq.md` and the `hq` entry in
6
+ * `mcp_config.json` (both written by `hq install --global`). This tier reports
7
+ * whether each is present. Antigravity hooks are not wired by HQ yet; that is
8
+ * reported as an advisory NA line, never a failure.
9
+ *
10
+ * When Antigravity is not detected the tier reports a single NA line. Home and
11
+ * the app path are injectable so tests never read the developer's real home.
12
+ */
13
+ import type { CheckContext, CheckResult } from "../types.js";
14
+ export declare const ANTIGRAVITY_INSTALL_REMEDIATION = "hq install --global --runtime antigravity";
15
+ export interface AntigravityWiringOptions {
16
+ home?: string;
17
+ env?: NodeJS.ProcessEnv;
18
+ appPath?: string;
19
+ }
20
+ export declare function checkAntigravityWiring(_context: CheckContext, options?: AntigravityWiringOptions): CheckResult[];
21
+ //# sourceMappingURL=antigravity-wiring.d.ts.map
@@ -0,0 +1,75 @@
1
+ /**
2
+ * Google Antigravity wiring checks.
3
+ *
4
+ * HQ wires Antigravity through two user-scope files under `~/.gemini/config/`:
5
+ * the always-on global rule `rules/hq.md` and the `hq` entry in
6
+ * `mcp_config.json` (both written by `hq install --global`). This tier reports
7
+ * whether each is present. Antigravity hooks are not wired by HQ yet; that is
8
+ * reported as an advisory NA line, never a failure.
9
+ *
10
+ * When Antigravity is not detected the tier reports a single NA line. Home and
11
+ * the app path are injectable so tests never read the developer's real home.
12
+ */
13
+ import * as fs from "node:fs";
14
+ import * as os from "node:os";
15
+ import { ANTIGRAVITY_HOOKS_ADVISORY, antigravityTargets, detectAntigravity, isHqAntigravityRule, } from "../../install/antigravity-targets.js";
16
+ import { HQ_MCP_SERVER_NAME } from "../../install/claude-targets.js";
17
+ export const ANTIGRAVITY_INSTALL_REMEDIATION = "hq install --global --runtime antigravity";
18
+ export function checkAntigravityWiring(_context, options = {}) {
19
+ const home = options.home ?? os.homedir();
20
+ const detection = detectAntigravity({ home, env: options.env, appPath: options.appPath });
21
+ if (!detection.detected) {
22
+ return [{
23
+ status: "NA",
24
+ checkId: "antigravity.detected",
25
+ target: "antigravity",
26
+ message: "Google Antigravity not detected (no app, ~/.gemini/config, ~/.gemini/antigravity, or agy on PATH).",
27
+ }];
28
+ }
29
+ const t = antigravityTargets(home);
30
+ return [
31
+ checkRule(t.ruleFile),
32
+ checkMcp(t.mcpConfig),
33
+ { status: "NA", checkId: "antigravity.hooks", target: "antigravity", message: ANTIGRAVITY_HOOKS_ADVISORY },
34
+ ];
35
+ }
36
+ function readOrNull(file) {
37
+ try {
38
+ return fs.readFileSync(file, "utf8");
39
+ }
40
+ catch {
41
+ return null;
42
+ }
43
+ }
44
+ function checkRule(ruleFile) {
45
+ const raw = readOrNull(ruleFile);
46
+ if (raw === null) {
47
+ return { status: "WARN", checkId: "antigravity.rule", target: ruleFile, message: "Antigravity HQ rule is missing; Antigravity sessions will not load the HQ charter.", remediation: ANTIGRAVITY_INSTALL_REMEDIATION };
48
+ }
49
+ if (!isHqAntigravityRule(raw)) {
50
+ return { status: "WARN", checkId: "antigravity.rule", target: ruleFile, message: "Antigravity rules/hq.md exists but is not the HQ-managed always-on rule.", remediation: ANTIGRAVITY_INSTALL_REMEDIATION };
51
+ }
52
+ return { status: "PASS", checkId: "antigravity.rule", target: ruleFile, message: "Antigravity always-on HQ rule is present." };
53
+ }
54
+ function checkMcp(mcpConfig) {
55
+ const raw = readOrNull(mcpConfig);
56
+ if (raw === null) {
57
+ return { status: "WARN", checkId: "antigravity.mcp", target: mcpConfig, message: `Antigravity mcp_config.json is missing; the "${HQ_MCP_SERVER_NAME}" MCP server is not registered.`, remediation: ANTIGRAVITY_INSTALL_REMEDIATION };
58
+ }
59
+ let doc;
60
+ try {
61
+ doc = JSON.parse(raw);
62
+ }
63
+ catch {
64
+ return { status: "FAIL", checkId: "antigravity.mcp", target: mcpConfig, message: "Antigravity mcp_config.json is not valid JSON; Antigravity cannot load any MCP server from it.", remediation: "Fix the JSON, then run hq install --global --runtime antigravity" };
65
+ }
66
+ const servers = doc?.mcpServers;
67
+ const entry = servers && typeof servers === "object" && !Array.isArray(servers)
68
+ ? servers[HQ_MCP_SERVER_NAME]
69
+ : undefined;
70
+ if (!entry || typeof entry !== "object") {
71
+ return { status: "WARN", checkId: "antigravity.mcp", target: mcpConfig, message: `Antigravity mcp_config.json has no "${HQ_MCP_SERVER_NAME}" MCP server.`, remediation: ANTIGRAVITY_INSTALL_REMEDIATION };
72
+ }
73
+ return { status: "PASS", checkId: "antigravity.mcp", target: mcpConfig, message: `Antigravity MCP server "${HQ_MCP_SERVER_NAME}" is registered.` };
74
+ }
75
+ //# sourceMappingURL=antigravity-wiring.js.map
@@ -18,6 +18,7 @@ import { HQ_MCP_SERVER_NAME, SKILL_LINK_PREFIX, claudeTargets } from "../../inst
18
18
  import { codexTargets } from "../../install/codex-targets.js";
19
19
  import { CHATGPT_MODE } from "../../install/chatgpt-targets.js";
20
20
  import { GROK_MODE } from "../../install/grok-targets.js";
21
+ import { antigravityTargets, isHqAntigravityRule } from "../../install/antigravity-targets.js";
21
22
  import { HqdClientError, hqdRequest } from "../../daemon/protocol.js";
22
23
  import { daemonPresenceLabel, heartbeatFile, readHeartbeat } from "../../daemon/heartbeat.js";
23
24
  import { DAEMON_LAUNCHD_LABEL, DAEMON_SYSTEMD_UNIT, LEGACY_DAEMON_WINDOWS_TASK, currentWindowsIdentity, legacyWindowsTask, windowsTaskName, } from "../../daemon/install.js";
@@ -53,6 +54,32 @@ export function createAnywhereFamily(deps = {}) {
53
54
  return { id: ANYWHERE_FAMILY_ID, title: "HQ anywhere runtime", run: (context) => runAnywhereChecks(context, deps) };
54
55
  }
55
56
  export const anywhereFamily = createAnywhereFamily();
57
+ /** One line for Google Antigravity, only when its config root (~/.gemini/config) exists. */
58
+ function antigravityAnywhereCheck(home) {
59
+ const t = antigravityTargets(home);
60
+ if (!fs.existsSync(t.configDir))
61
+ return null;
62
+ let rule = null;
63
+ try {
64
+ rule = fs.readFileSync(t.ruleFile, "utf8");
65
+ }
66
+ catch {
67
+ rule = null;
68
+ }
69
+ let mcp = false;
70
+ try {
71
+ const doc = JSON.parse(fs.readFileSync(t.mcpConfig, "utf8"));
72
+ mcp = Boolean(doc.mcpServers && typeof doc.mcpServers === "object" && doc.mcpServers[HQ_MCP_SERVER_NAME]);
73
+ }
74
+ catch {
75
+ mcp = false;
76
+ }
77
+ const ruleOk = isHqAntigravityRule(rule);
78
+ if (ruleOk && mcp)
79
+ return result("PASS", "antigravity", "Antigravity: always-on HQ rule and hq MCP server are installed (hooks not wired yet)");
80
+ const missing = [ruleOk ? null : "always-on HQ rule", mcp ? null : "hq MCP server"].filter(Boolean).join(" and ");
81
+ return result("WARN", "antigravity", `Antigravity: ${missing} missing`, "hq install --global --runtime antigravity");
82
+ }
56
83
  function result(status, checkId, message, remediation, target) {
57
84
  return { status, checkId: `anywhere.${checkId}`, message, ...(remediation ? { remediation } : {}), ...(target ? { target } : {}) };
58
85
  }
@@ -146,6 +173,9 @@ async function runAnywhereChecks(context, deps = {}) {
146
173
  result("WARN", "grok-mode", `Grok integration mode: ${GROK_MODE}; host connector setup is managed in Grok`, "hq install --global --runtime grok"),
147
174
  ];
148
175
  const out = [healthCheck, settingCheck, ...remoteModes];
176
+ const antigravity = antigravityAnywhereCheck(home);
177
+ if (antigravity)
178
+ out.push(antigravity);
149
179
  if (!installed) {
150
180
  return [...out, result("NA", "installed", "HQ local anywhere runtime is not installed on this machine", REMEDIATION.installClaude)];
151
181
  }
@@ -324,6 +324,19 @@ export function checkRuntimeProbe(context) {
324
324
  },
325
325
  ];
326
326
  }
327
+ // Google Antigravity: HQ does not register hooks there yet, so an empty or
328
+ // present ledger says nothing about this host. Report it as not applicable.
329
+ if (platformId === "antigravity") {
330
+ return [
331
+ {
332
+ status: "NA",
333
+ checkId,
334
+ target,
335
+ message: `Host platform is Google Antigravity. HQ hooks are not wired for Antigravity yet; HQ policies ` +
336
+ `load through the always-on rule and AGENTS.md. The policy-trigger ledger is ${repro.ledgerState}${scope}.`,
337
+ },
338
+ ];
339
+ }
327
340
  // Ledger present ⇒ a hook demonstrably fired this session ⇒ enforcement is live.
328
341
  if (repro.ledgerState === "present") {
329
342
  return [
@@ -51,7 +51,7 @@
51
51
  */
52
52
  import type { DoctorStatus } from "./types.js";
53
53
  /** Every platform the doctor can report, including the `unknown` fallback. */
54
- export declare const PLATFORMS: readonly ["claude-code-cli", "claude-code-app", "claude-code-sdk", "codex", "grok", "unknown"];
54
+ export declare const PLATFORMS: readonly ["claude-code-cli", "claude-code-app", "claude-code-sdk", "codex", "grok", "antigravity", "unknown"];
55
55
  /** A detected host platform. Closed union derived from {@link PLATFORMS}. */
56
56
  export type Platform = (typeof PLATFORMS)[number];
57
57
  /**
@@ -57,6 +57,7 @@ export const PLATFORMS = [
57
57
  "claude-code-sdk",
58
58
  "codex",
59
59
  "grok",
60
+ "antigravity",
60
61
  "unknown",
61
62
  ];
62
63
  // --- environment signal collectors --------------------------------------------
@@ -124,6 +125,9 @@ export function bundleIdEvidence(env) {
124
125
  if (id === "com.openai.codex") {
125
126
  return { key, detail, points: "codex", strength: "strong" };
126
127
  }
128
+ if (id === "com.google.antigravity") {
129
+ return { key, detail, points: "antigravity", strength: "strong" };
130
+ }
127
131
  if (/grok|(?:^|\.)x\.ai(?:\.|$)|com\.xai/i.test(id)) {
128
132
  return { key, detail, points: "grok", strength: "strong" };
129
133
  }
@@ -437,6 +441,7 @@ const PLATFORM_LABELS = {
437
441
  "claude-code-sdk": "Claude Code (SDK)",
438
442
  codex: "Codex",
439
443
  grok: "Grok",
444
+ antigravity: "Google Antigravity",
440
445
  unknown: "unknown",
441
446
  };
442
447
  /** A human-readable label for a platform, for text and report output. */
@@ -18,6 +18,7 @@ import { jqFamily } from './checks/jq.js';
18
18
  import * as path from "node:path";
19
19
  import { checkCodexWiring } from "./checks/codex-wiring.js";
20
20
  import { checkGrokWiring } from "./checks/grok-wiring.js";
21
+ import { checkAntigravityWiring } from "./checks/antigravity-wiring.js";
21
22
  import { checkRuntimeProbe } from "./checks/runtime-probe.js";
22
23
  import { runtimeHealthFamily } from "./checks/runtime-health.js";
23
24
  import { integrationsFamily } from "./checks/integrations.js";
@@ -110,6 +111,8 @@ function runHooksFamily(context) {
110
111
  // doctor run — a thrown tier degrades to an UNKNOWN result instead.
111
112
  results.push(...safeTier("hooks.codex", () => checkCodexWiring(context)));
112
113
  results.push(...safeTier("hooks.grok", () => checkGrokWiring(context)));
114
+ // Antigravity: rule + MCP wiring and a hooks-pending advisory (NA when not detected).
115
+ results.push(...safeTier("antigravity", () => checkAntigravityWiring(context)));
113
116
  // The runtime probe (US-006) is the live tier: it reads the policy-trigger
114
117
  // ledger to report whether hooks actually FIRED on the detected host, catching
115
118
  // an app/SDK runtime that loads hook config correctly and then never dispatches
@@ -220,6 +220,47 @@ export interface PinnedFile {
220
220
  * listed generation (a file skipped as missing matches any).
221
221
  */
222
222
  export declare function pinnedFilesHold(root: string, event: string, files: readonly PinnedFile[], generations?: ReadonlyArray<readonly string[]>): string | null;
223
+ /**
224
+ * The three scripts the native Grok StopCancelled and StopFailure member reads by sha256
225
+ * (crates/hq-hook/src/grok_stop_observe.rs `LEAF_SHA256`, `ASYNC_SHA256`, `ENQUEUE_SHA256`), in the
226
+ * order it reads them. Each is skipped there when it is not a file.
227
+ */
228
+ export declare const GROK_STOP_OBSERVE_PINS: readonly PinnedFile[];
229
+ /**
230
+ * Why a Grok StopCancelled or StopFailure (`event`) must stay on the shell adapter in `root`: the
231
+ * turn-end leaf or one of its two libraries is a revision the native member refuses
232
+ * (grok_stop_observe.rs `plan`). As there, nothing is read in a root with no
233
+ * `.claude/hooks/hook-gate.sh` or no leaf: the member writes nothing and refuses no file. Null
234
+ * when the member accepts the root's files.
235
+ */
236
+ export declare function grokStopObserveHold(root: string, event: string): string | null;
237
+ /**
238
+ * The Grok adapter and its library the native Grok PreToolUse work is modelled on, as one pair:
239
+ * `.grok/hooks/hq-grok-hook-adapter.sh` b9075b2f with `core/scripts/lib/hook-adapter-core.sh`
240
+ * 940bb5a0 (hq-core v16.0.48 to v16.0.50; crates/hq-hook/src/grok_adapter.rs and grok_pretool.rs).
241
+ * The native side rebuilds the payload this adapter hands its registry hooks and its own checks
242
+ * of the call; it does not read the adapter's sha256 at run time, so another revision would be
243
+ * answered with this model. A root without one of the two files has no other revision to answer
244
+ * for, so a missing file is not held; every hq-core release ships both.
245
+ */
246
+ export declare const GROK_PRE_TOOL_USE_ADAPTER_PINS: readonly PinnedFile[];
247
+ /**
248
+ * The merged-write-guard-shadow wrapper and its .cjs the native Grok member models
249
+ * (crates/hq-hook/src/merged_write_guard.rs `SCRIPT_SHA256` 63ddff4a and `CJS_SHA256` 225e5c89; the
250
+ * released 742870a2 and 6f65f2b9, which pretool_merged_write_guard.rs models by the wrapper's
251
+ * sha256). A root without them runs no shadow row, so a missing file is not held.
252
+ */
253
+ export declare const GROK_SHADOW_GUARD_PINS: readonly PinnedFile[];
254
+ /**
255
+ * Why Grok PreToolUse must stay on the shell adapter in `root`: the adapter or its library is not the
256
+ * pair the native work is modelled on, or (when `shadow`, the registry lists the claimed
257
+ * merged-write-guard-shadow row) the wrapper or its .cjs is not a revision the native member
258
+ * models. Unlike the other holds there is no run-time refusal to mirror: on another adapter the
259
+ * native side would answer with the v16.0.50 model, so the hold is the only guard. A missing file is
260
+ * not held: the hold guards against another revision. The merge-hold shim is not pinned:
261
+ * the claimed merge-gates-ready member reads hold records, never the shim.
262
+ */
263
+ export declare function grokPreToolUseHold(root: string, shadow: boolean): string | null;
223
264
  /**
224
265
  * The scripts the native first-prompt company bind rebuilds, each at one revision:
225
266
  * `MENTION_LIBS` in crates/hq-hook/src/prompt_company_mention/bind.rs, then `SCRIPTS`, `ID_LIBS` and
@@ -236,6 +277,56 @@ export declare const PROMPT_COMPANY_BIND_PINS: readonly PinnedFile[];
236
277
  * Whether a prompt reaches the bind is decided per prompt, so the hold does not wait for one.
237
278
  */
238
279
  export declare function promptCompanyBindHold(root: string): string | null;
280
+ /**
281
+ * The policy-enforcement-gate.sh revisions the native gate answers, by the name of
282
+ * `gate::Revision` (crates/hq-hook/src/gate/mod.rs `script_sha256`), each with the
283
+ * core/scripts/hook-lib.sh revisions it accepts beside that gate
284
+ * (crates/hq-hook/src/gate/facts.rs `accepted_hook_lib_sha256`).
285
+ */
286
+ export declare const POLICY_GATE_REVISIONS: ReadonlyArray<{
287
+ revision: string;
288
+ gate: string;
289
+ hookLibs: readonly string[];
290
+ }>;
291
+ /**
292
+ * Why PostToolUse must stay on the shell registration in `root`: the native policy gate
293
+ * (crates/hq-hook/src/post_hooks/mod.rs `run_gate`, reached from the Claude Code, Codex, Grok Build
294
+ * and fleet-local PostToolUse paths) blocks every call it answers beside a gate script that is not
295
+ * a listed revision, or a hook-lib.sh that revision does not accept. As there, a root with no gate
296
+ * script runs no gate (no hold) and a root with no hook-lib.sh is not refused for it.
297
+ */
298
+ export declare function policyGateHold(root: string): string | null;
299
+ /** The (Codex adapter, hook-adapter-core.sh) pairs of crates/hq-hook/src/post_hooks/codex.rs `POST_TOOL_USE_GENERATIONS`. */
300
+ export declare const CODEX_POST_TOOL_USE_GENERATIONS: ReadonlyArray<readonly [string, string]>;
301
+ /** The (Grok adapter, hook-adapter-core.sh) pairs of crates/hq-hook/src/post_hooks/grok.rs `ADAPTER_GENERATIONS`. */
302
+ export declare const GROK_POST_TOOL_USE_GENERATIONS: ReadonlyArray<readonly [string, string]>;
303
+ /** The hook-adapter-core.sh revisions of crates/hq-hook/src/host/fleet/local_pre.rs `RELEASED_CORE_SHA256`. */
304
+ export declare const FLEET_LOCAL_ADAPTER_CORE: readonly string[];
305
+ /**
306
+ * Why PostToolUse must stay on the shell adapter of `host` in `root`: the native adapter work
307
+ * refuses the root's adapter scripts. Null for a host with no adapter pin, and where the native
308
+ * port reads no pin:
309
+ * - Codex (post_hooks/codex.rs `answer`, `pin_generation`): nothing is read without
310
+ * `.claude/hooks/hook-gate.sh`. With it, the adapter and its library must be one listed pair; a
311
+ * missing one is refused.
312
+ * - Grok Build (post_hooks/grok.rs `answer`, `held_flush_modelled`, `pin`): nothing is read with
313
+ * neither hook-gate.sh nor `.claude/hooks/inject-policy-on-trigger.sh` on disk. Otherwise as Codex.
314
+ * - fleet-local (post_hooks/fleet.rs `answer`): nothing is read without hook-gate.sh or without
315
+ * hook-adapter-core.sh; with both, the library must be a listed revision.
316
+ * Which calls reach the check is decided per call (a registry row for the tool, a Bash call, a held
317
+ * reminder), so the hold does not wait for one.
318
+ */
319
+ export declare function postToolUseAdapterHold(root: string, host: CoreNextHost): string | null;
320
+ /** The session-scope-capability.sh master-hook's Task-agent pin is modelled on (crates/hq-hook/src/scope/session.rs `SUBAGENT_PIN_LIB_SHA256`). */
321
+ export declare const SUBAGENT_SCOPE_LIBRARY: PinnedFile;
322
+ /**
323
+ * Why SubagentStart or SubagentStop (`event`) must stay on the shell registration in `root`: the
324
+ * native master work (crates/hq-hook/src/lifecycle_master.rs `begin`) refuses every such event that
325
+ * names a Task agent when the scope library is another revision or not a readable file
326
+ * (scope/session.rs `subagent_pin_library`). As there, a root with nothing at that path is not
327
+ * refused (master-hook bound nothing), so it is not held.
328
+ */
329
+ export declare function subagentScopeLibraryHold(root: string, event: string): string | null;
239
330
  /** Records the environment `target` was resolved under; returns `target`. */
240
331
  export declare function resolvedUnder<T extends CoreNextTarget | null>(target: T, env: NodeJS.ProcessEnv): T;
241
332
  export declare function forHost(target: CoreNextTarget | null, root: string, host: CoreNextHost, env?: NodeJS.ProcessEnv): CoreNextTarget | null;
@@ -1705,12 +1705,37 @@ export function uncoveredHooks(root, host, event, covers, env = process.env) {
1705
1705
  if (hold)
1706
1706
  missing.push(`(native SessionStart compatibility: ${hold})`);
1707
1707
  }
1708
+ if (host === 'grok' && GROK_STOP_OBSERVE.has(event) && covered.includes(`grok-adapter:${event}`)) {
1709
+ const hold = grokStopObserveHold(root, event);
1710
+ if (hold)
1711
+ missing.push(`(native ${event} compatibility: ${hold})`);
1712
+ }
1713
+ if (host === 'grok' && event === 'PreToolUse' && covered.includes('grok-adapter:PreToolUse')) {
1714
+ const shadow = covered.includes('merged-write-guard-shadow') && hooks.includes('merged-write-guard-shadow');
1715
+ const hold = grokPreToolUseHold(root, shadow);
1716
+ if (hold)
1717
+ missing.push(`(native PreToolUse compatibility: ${hold})`);
1718
+ }
1708
1719
  // The native natural-language-router runs where the registry lists it; its claim and master-hook's switch the event.
1709
1720
  if (event === 'UserPromptSubmit' && covered.includes('master-hook:UserPromptSubmit') && covered.includes('natural-language-router') && hooks.includes('natural-language-router')) {
1710
1721
  const hold = promptCompanyBindHold(root);
1711
1722
  if (hold)
1712
1723
  missing.push(`(native UserPromptSubmit compatibility: ${hold})`);
1713
1724
  }
1725
+ if (event === 'PostToolUse' && covered.includes('master-hook:PostToolUse')) {
1726
+ // The native policy gate runs where the registry lists it, on every host master-hook's PostToolUse is claimed for.
1727
+ const gate = covered.includes('policy-enforcement-gate') && hooks.includes('policy-enforcement-gate') ? policyGateHold(root) : null;
1728
+ if (gate)
1729
+ missing.push(`(native PostToolUse compatibility: ${gate})`);
1730
+ const adapter = covered.includes(`${host}-adapter:PostToolUse`) ? postToolUseAdapterHold(root, host) : null;
1731
+ if (adapter)
1732
+ missing.push(`(native PostToolUse compatibility: ${adapter})`);
1733
+ }
1734
+ if (SUBAGENT_SCOPE_HOSTS[event]?.includes(host) && covered.includes(`master-hook:${event}`)) {
1735
+ const hold = subagentScopeLibraryHold(root, event);
1736
+ if (hold)
1737
+ missing.push(`(native ${event} compatibility: ${hold})`);
1738
+ }
1714
1739
  return missing;
1715
1740
  }
1716
1741
  /**
@@ -1833,6 +1858,66 @@ export function pinnedFilesHold(root, event, files, generations = []) {
1833
1858
  }
1834
1859
  return null;
1835
1860
  }
1861
+ /**
1862
+ * The three scripts the native Grok StopCancelled and StopFailure member reads by sha256
1863
+ * (crates/hq-hook/src/grok_stop_observe.rs `LEAF_SHA256`, `ASYNC_SHA256`, `ENQUEUE_SHA256`), in the
1864
+ * order it reads them. Each is skipped there when it is not a file.
1865
+ */
1866
+ export const GROK_STOP_OBSERVE_PINS = [
1867
+ { relative: 'core/hooks/Stop/70-work-mesh-turn-end.sh', accepted: ['1b37183a94a46152c9592d6821f323203438e09ed59956d6239880bb73f896db'], missing: 'allowed' },
1868
+ { relative: 'core/scripts/lib/hook-stop-async.sh', accepted: ['730b008b81b360923f82785467f3a3b6592be6610ee3b909e446b242543ab3bc', 'fe89218c3f92413cff36e82a937eed5e548e712644d8228b34d59c7f459917ad'], missing: 'allowed' },
1869
+ { relative: 'core/scripts/lib/work-mesh-enqueue.sh', accepted: ['db440318b8933b7c436c7b7172adffc9e8fd00c92f0e1745ed5da76871accbe7', 'ac44fc8f68dbe7311811e0e97bba2b1e53b3aa856856db566635a135c6319451'], missing: 'allowed' },
1870
+ ];
1871
+ /**
1872
+ * Why a Grok StopCancelled or StopFailure (`event`) must stay on the shell adapter in `root`: the
1873
+ * turn-end leaf or one of its two libraries is a revision the native member refuses
1874
+ * (grok_stop_observe.rs `plan`). As there, nothing is read in a root with no
1875
+ * `.claude/hooks/hook-gate.sh` or no leaf: the member writes nothing and refuses no file. Null
1876
+ * when the member accepts the root's files.
1877
+ */
1878
+ export function grokStopObserveHold(root, event) {
1879
+ if (!regularFile(path.join(root, '.claude', 'hooks', 'hook-gate.sh')))
1880
+ return null;
1881
+ if (!regularFile(path.join(root, GROK_STOP_OBSERVE_PINS[0].relative)))
1882
+ return null;
1883
+ return pinnedFilesHold(root, event, GROK_STOP_OBSERVE_PINS);
1884
+ }
1885
+ /**
1886
+ * The Grok adapter and its library the native Grok PreToolUse work is modelled on, as one pair:
1887
+ * `.grok/hooks/hq-grok-hook-adapter.sh` b9075b2f with `core/scripts/lib/hook-adapter-core.sh`
1888
+ * 940bb5a0 (hq-core v16.0.48 to v16.0.50; crates/hq-hook/src/grok_adapter.rs and grok_pretool.rs).
1889
+ * The native side rebuilds the payload this adapter hands its registry hooks and its own checks
1890
+ * of the call; it does not read the adapter's sha256 at run time, so another revision would be
1891
+ * answered with this model. A root without one of the two files has no other revision to answer
1892
+ * for, so a missing file is not held; every hq-core release ships both.
1893
+ */
1894
+ export const GROK_PRE_TOOL_USE_ADAPTER_PINS = [
1895
+ { relative: '.grok/hooks/hq-grok-hook-adapter.sh', accepted: ['b9075b2f96a6ef8d2ba9675e32ce5881d50522da4eca02b69e6dc8bcd57efddf'], missing: 'allowed' },
1896
+ { relative: 'core/scripts/lib/hook-adapter-core.sh', accepted: ['940bb5a0a268929a4cd3f88b61a0ce619f0fdf64e5d3f25f7f18da35df466ab5'], missing: 'allowed' },
1897
+ ];
1898
+ /**
1899
+ * The merged-write-guard-shadow wrapper and its .cjs the native Grok member models
1900
+ * (crates/hq-hook/src/merged_write_guard.rs `SCRIPT_SHA256` 63ddff4a and `CJS_SHA256` 225e5c89; the
1901
+ * released 742870a2 and 6f65f2b9, which pretool_merged_write_guard.rs models by the wrapper's
1902
+ * sha256). A root without them runs no shadow row, so a missing file is not held.
1903
+ */
1904
+ export const GROK_SHADOW_GUARD_PINS = [
1905
+ { relative: '.claude/hooks/merged-write-guard-shadow.sh', accepted: ['63ddff4a40e861d8d922b0701863259a3cedbffaf6d44a94d837865e62cca6ac', '742870a2ada4f9357320f7708fca7363be6d81fde374948b59873c327a7d7206'], missing: 'allowed' },
1906
+ { relative: '.claude/hooks/merged-write-guard-shadow.cjs', accepted: ['225e5c89501ab87965db46e6520c0fd8d08ec5e9745068a2e7324e64f7360884', '6f65f2b9425612f9b2ec2590dace82585230210dcd69a124a9cdeb0116ea7f30'], missing: 'allowed' },
1907
+ ];
1908
+ /**
1909
+ * Why Grok PreToolUse must stay on the shell adapter in `root`: the adapter or its library is not the
1910
+ * pair the native work is modelled on, or (when `shadow`, the registry lists the claimed
1911
+ * merged-write-guard-shadow row) the wrapper or its .cjs is not a revision the native member
1912
+ * models. Unlike the other holds there is no run-time refusal to mirror: on another adapter the
1913
+ * native side would answer with the v16.0.50 model, so the hold is the only guard. A missing file is
1914
+ * not held: the hold guards against another revision. The merge-hold shim is not pinned:
1915
+ * the claimed merge-gates-ready member reads hold records, never the shim.
1916
+ */
1917
+ export function grokPreToolUseHold(root, shadow) {
1918
+ return pinnedFilesHold(root, 'PreToolUse', GROK_PRE_TOOL_USE_ADAPTER_PINS)
1919
+ ?? (shadow ? pinnedFilesHold(root, 'PreToolUse', GROK_SHADOW_GUARD_PINS) : null);
1920
+ }
1836
1921
  /**
1837
1922
  * The scripts the native first-prompt company bind rebuilds, each at one revision:
1838
1923
  * `MENTION_LIBS` in crates/hq-hook/src/prompt_company_mention/bind.rs, then `SCRIPTS`, `ID_LIBS` and
@@ -1860,6 +1945,105 @@ export function promptCompanyBindHold(root) {
1860
1945
  }
1861
1946
  return pinnedFilesHold(root, 'UserPromptSubmit', PROMPT_COMPANY_BIND_PINS);
1862
1947
  }
1948
+ /**
1949
+ * The policy-enforcement-gate.sh revisions the native gate answers, by the name of
1950
+ * `gate::Revision` (crates/hq-hook/src/gate/mod.rs `script_sha256`), each with the
1951
+ * core/scripts/hook-lib.sh revisions it accepts beside that gate
1952
+ * (crates/hq-hook/src/gate/facts.rs `accepted_hook_lib_sha256`).
1953
+ */
1954
+ export const POLICY_GATE_REVISIONS = [
1955
+ { revision: 'Staging2018', gate: '1bc4df8eaabded175804d2effba704c93b439df05c0867f85bb27f5dcfbc7914', hookLibs: ['9133295e5ce523bf8355a093bbea5a1c19682ec42b59ab6b626dffbc33544f3f'] },
1956
+ { revision: 'Core16_0_48Beta90', gate: 'a2879dfe692233f5953bac86672947bbd82f3c5247292f3efcb80f16c3d2c6b1', hookLibs: ['9133295e5ce523bf8355a093bbea5a1c19682ec42b59ab6b626dffbc33544f3f', '49c337ceccf0a2d7c2a64f6b1de8c3c4d1da507bc5d7afcd01ed292e1f25abf7', 'be7ca74b2524afba56fefd530bf46cbd1dd39a4c181b6a64c87e124b29bdebe7'] },
1957
+ { revision: 'Core16_0_48Beta68', gate: '6005f2315210c31daf0c870b768303bfd15f58f3416c52b6e02da9bcb430e9bb', hookLibs: ['c3eb950f80aea21d3f8ad2bc0f76656e6c5a39a5197b4d985aa03d13144fc8a7'] },
1958
+ { revision: 'Staging1804', gate: 'b3156dc1173cfc3954da0910d05d7c3fa608ba2a75f80407a3e305c9a5949d26', hookLibs: ['df3d8ddc15a0c179227c9ba7f855c040973fcee249673156d08b2e2ff2c850b8', 'b971dae4a2b82bfa5b31782e54717115abaf052457fb1a546893d04cae43adbb'] },
1959
+ { revision: 'Core16_0_45', gate: 'f692078ab91b20fd6889de57656c08b5572398af3cce044d0c61d06c462a853f', hookLibs: ['c5c8153f1e6cead7a2cbfc9085788f26970efc79752660ff2c308112622a5c8e'] },
1960
+ ];
1961
+ const POLICY_GATE = '.claude/hooks/policy-enforcement-gate.sh';
1962
+ const HOOK_LIB = 'core/scripts/hook-lib.sh';
1963
+ /**
1964
+ * Why PostToolUse must stay on the shell registration in `root`: the native policy gate
1965
+ * (crates/hq-hook/src/post_hooks/mod.rs `run_gate`, reached from the Claude Code, Codex, Grok Build
1966
+ * and fleet-local PostToolUse paths) blocks every call it answers beside a gate script that is not
1967
+ * a listed revision, or a hook-lib.sh that revision does not accept. As there, a root with no gate
1968
+ * script runs no gate (no hold) and a root with no hook-lib.sh is not refused for it.
1969
+ */
1970
+ export function policyGateHold(root) {
1971
+ if (!regularFile(path.join(root, POLICY_GATE)))
1972
+ return null;
1973
+ const files = [
1974
+ { relative: POLICY_GATE, accepted: POLICY_GATE_REVISIONS.map(({ gate }) => gate) },
1975
+ { relative: HOOK_LIB, accepted: POLICY_GATE_REVISIONS.flatMap(({ hookLibs }) => hookLibs), missing: 'allowed' },
1976
+ ];
1977
+ return pinnedFilesHold(root, 'PostToolUse', files, POLICY_GATE_REVISIONS.flatMap(({ gate, hookLibs }) => hookLibs.map((lib) => [gate, lib])));
1978
+ }
1979
+ const CODEX_ADAPTER = '.codex/hooks/hq-codex-hook-adapter.sh';
1980
+ const GROK_ADAPTER = '.grok/hooks/hq-grok-hook-adapter.sh';
1981
+ const ADAPTER_CORE = 'core/scripts/lib/hook-adapter-core.sh';
1982
+ /** The (Codex adapter, hook-adapter-core.sh) pairs of crates/hq-hook/src/post_hooks/codex.rs `POST_TOOL_USE_GENERATIONS`. */
1983
+ export const CODEX_POST_TOOL_USE_GENERATIONS = [
1984
+ ['3c3196254614df7b14dccad507dcee3299fa8cf9c163a6903eac2d86fb2159c5', '98da450068af022eb1eee5420a4eca98867b91690e57316ee565eb7788fb6e7a'],
1985
+ ['a3178b59e633310f3cc39a8c257ff58863169696ffda04dc6ea93a34a5db05ef', '940bb5a0a268929a4cd3f88b61a0ce619f0fdf64e5d3f25f7f18da35df466ab5'],
1986
+ ];
1987
+ /** The (Grok adapter, hook-adapter-core.sh) pairs of crates/hq-hook/src/post_hooks/grok.rs `ADAPTER_GENERATIONS`. */
1988
+ export const GROK_POST_TOOL_USE_GENERATIONS = [
1989
+ ['56d5ce126646589e4ca5b2a2a29f9e11900891d1c791310d23fef757aae02904', '98da450068af022eb1eee5420a4eca98867b91690e57316ee565eb7788fb6e7a'],
1990
+ ['f9664658ba328e2d8107c1e0b58ef797d892811130a21ba7d6fd6f83d17a4a9d', 'e750ab8b96cefcac007088f1fb583ff56af8a1169666656518b862296a149f0c'],
1991
+ ['b9075b2f96a6ef8d2ba9675e32ce5881d50522da4eca02b69e6dc8bcd57efddf', '940bb5a0a268929a4cd3f88b61a0ce619f0fdf64e5d3f25f7f18da35df466ab5'],
1992
+ ];
1993
+ /** The hook-adapter-core.sh revisions of crates/hq-hook/src/host/fleet/local_pre.rs `RELEASED_CORE_SHA256`. */
1994
+ export const FLEET_LOCAL_ADAPTER_CORE = ['940bb5a0a268929a4cd3f88b61a0ce619f0fdf64e5d3f25f7f18da35df466ab5'];
1995
+ /**
1996
+ * Why PostToolUse must stay on the shell adapter of `host` in `root`: the native adapter work
1997
+ * refuses the root's adapter scripts. Null for a host with no adapter pin, and where the native
1998
+ * port reads no pin:
1999
+ * - Codex (post_hooks/codex.rs `answer`, `pin_generation`): nothing is read without
2000
+ * `.claude/hooks/hook-gate.sh`. With it, the adapter and its library must be one listed pair; a
2001
+ * missing one is refused.
2002
+ * - Grok Build (post_hooks/grok.rs `answer`, `held_flush_modelled`, `pin`): nothing is read with
2003
+ * neither hook-gate.sh nor `.claude/hooks/inject-policy-on-trigger.sh` on disk. Otherwise as Codex.
2004
+ * - fleet-local (post_hooks/fleet.rs `answer`): nothing is read without hook-gate.sh or without
2005
+ * hook-adapter-core.sh; with both, the library must be a listed revision.
2006
+ * Which calls reach the check is decided per call (a registry row for the tool, a Bash call, a held
2007
+ * reminder), so the hold does not wait for one.
2008
+ */
2009
+ export function postToolUseAdapterHold(root, host) {
2010
+ const gate = regularFile(path.join(root, '.claude', 'hooks', 'hook-gate.sh'));
2011
+ const pair = (adapter, generations) => pinnedFilesHold(root, 'PostToolUse', [
2012
+ { relative: adapter, accepted: generations.map(([own]) => own) },
2013
+ { relative: ADAPTER_CORE, accepted: generations.map(([, core]) => core) },
2014
+ ], generations);
2015
+ if (host === 'codex')
2016
+ return gate ? pair(CODEX_ADAPTER, CODEX_POST_TOOL_USE_GENERATIONS) : null;
2017
+ if (host === 'grok')
2018
+ return gate || regularFile(path.join(root, '.claude', 'hooks', 'inject-policy-on-trigger.sh')) ? pair(GROK_ADAPTER, GROK_POST_TOOL_USE_GENERATIONS) : null;
2019
+ if (host === 'fleet-local')
2020
+ return gate && regularFile(path.join(root, ADAPTER_CORE)) ? pinnedFilesHold(root, 'PostToolUse', [{ relative: ADAPTER_CORE, accepted: FLEET_LOCAL_ADAPTER_CORE }]) : null;
2021
+ return null;
2022
+ }
2023
+ /** The session-scope-capability.sh master-hook's Task-agent pin is modelled on (crates/hq-hook/src/scope/session.rs `SUBAGENT_PIN_LIB_SHA256`). */
2024
+ export const SUBAGENT_SCOPE_LIBRARY = { relative: 'core/scripts/lib/session-scope-capability.sh', accepted: ['388ffef43cfe05810c38ce377245d0d86f415b4009b21a008bca8897be0c9ead'] };
2025
+ /**
2026
+ * Why SubagentStart or SubagentStop (`event`) must stay on the shell registration in `root`: the
2027
+ * native master work (crates/hq-hook/src/lifecycle_master.rs `begin`) refuses every such event that
2028
+ * names a Task agent when the scope library is another revision or not a readable file
2029
+ * (scope/session.rs `subagent_pin_library`). As there, a root with nothing at that path is not
2030
+ * refused (master-hook bound nothing), so it is not held.
2031
+ */
2032
+ export function subagentScopeLibraryHold(root, event) {
2033
+ try {
2034
+ fs.lstatSync(path.join(root, SUBAGENT_SCOPE_LIBRARY.relative));
2035
+ }
2036
+ catch {
2037
+ return null;
2038
+ }
2039
+ return pinnedFilesHold(root, event, [SUBAGENT_SCOPE_LIBRARY]);
2040
+ }
2041
+ /**
2042
+ * The hosts whose native master work reads the scope library on `event`: SubagentStart on Claude
2043
+ * Code and Grok Build, SubagentStop on Claude Code and Codex (lifecycle_master.rs `begin`,
2044
+ * `task_agent` and `stop_agent`).
2045
+ */
2046
+ const SUBAGENT_SCOPE_HOSTS = { SubagentStart: ['claude', 'grok'], SubagentStop: ['claude', 'codex'] };
1863
2047
  /** Grok events the adapter dispatched as its settings.json `Stop` entries (lifecycle_master.rs `dispatched`). */
1864
2048
  const GROK_STOP_OBSERVE = new Set(['StopCancelled', 'StopFailure']);
1865
2049
  /**
@@ -0,0 +1,39 @@
1
+ export declare const ANTIGRAVITY_BUNDLE_ID = "com.google.antigravity";
2
+ export declare const ANTIGRAVITY_CLI_BINARY = "agy";
3
+ export declare const ANTIGRAVITY_RULE_MARKER = "<!-- hq-anywhere:antigravity (managed by `hq install --global`; edits are overwritten) -->";
4
+ export declare const ANTIGRAVITY_HOOKS_ADVISORY = "Antigravity hooks: not wired yet \u2014 HQ policies load through the always-on rule and AGENTS.md; hook guards arrive in a later release";
5
+ export interface AntigravityTargets {
6
+ configDir: string;
7
+ rulesDir: string;
8
+ ruleFile: string;
9
+ mcpConfig: string;
10
+ stateDir: string;
11
+ cliStateDir: string;
12
+ }
13
+ export declare function antigravityTargets(home: string): AntigravityTargets;
14
+ export interface AntigravityDetectOptions {
15
+ home: string;
16
+ env?: NodeJS.ProcessEnv;
17
+ platform?: NodeJS.Platform;
18
+ /** Override for the macOS app bundle path (env HQ_ANTIGRAVITY_APP_PATH also works). */
19
+ appPath?: string;
20
+ }
21
+ export interface AntigravityDetection {
22
+ detected: boolean;
23
+ signals: string[];
24
+ }
25
+ /** Antigravity is present when any of: the macOS app, a config/state dir, or `agy` on PATH. */
26
+ export declare function detectAntigravity(opts: AntigravityDetectOptions): AntigravityDetection;
27
+ /** The full HQ-owned rule file. Deterministic so a re-run is a byte-for-byte no-op. */
28
+ export declare function antigravityRuleContent(hqRoot: string): string;
29
+ export type RulePlan = {
30
+ action: 'write' | 'noop';
31
+ content: string;
32
+ } | {
33
+ action: 'foreign';
34
+ content: string;
35
+ };
36
+ /** Decide what to do with the rule file: HQ-owned files are replaced, others are left alone. */
37
+ export declare function planAntigravityRule(current: string | null, hqRoot: string): RulePlan;
38
+ export declare function isHqAntigravityRule(current: string | null): boolean;
39
+ //# sourceMappingURL=antigravity-targets.d.ts.map
@@ -0,0 +1,122 @@
1
+ /** Google Antigravity host integration.
2
+ *
3
+ * Antigravity (App, IDE and the `agy` CLI) reads a shared user config root at
4
+ * `~/.gemini/config/`. HQ writes two things there:
5
+ *
6
+ * - `rules/hq.md`: an always-on global rule (frontmatter `trigger: always_on`
7
+ * is required; a rule without valid frontmatter is silently discarded) that
8
+ * points the agent at the HQ charter. The file is whole-file owned by HQ and
9
+ * carries {@link ANTIGRAVITY_RULE_MARKER}; a file without the marker is
10
+ * user content and is never overwritten.
11
+ * - `mcp_config.json`: the HQ MCP server under `mcpServers`, merged through the
12
+ * mcp-registration safe-write path.
13
+ *
14
+ * Antigravity hooks exist but are not wired by HQ yet.
15
+ */
16
+ import * as fs from 'node:fs';
17
+ import * as path from 'node:path';
18
+ import { charterPath } from './claude-targets.js';
19
+ import { matchFrontmatter } from '../../utils/frontmatter.js';
20
+ export const ANTIGRAVITY_BUNDLE_ID = 'com.google.antigravity';
21
+ export const ANTIGRAVITY_CLI_BINARY = 'agy';
22
+ export const ANTIGRAVITY_RULE_MARKER = '<!-- hq-anywhere:antigravity (managed by `hq install --global`; edits are overwritten) -->';
23
+ export const ANTIGRAVITY_HOOKS_ADVISORY = 'Antigravity hooks: not wired yet — HQ policies load through the always-on rule and AGENTS.md; hook guards arrive in a later release';
24
+ export function antigravityTargets(home) {
25
+ const configDir = path.join(home, '.gemini', 'config');
26
+ return {
27
+ configDir,
28
+ rulesDir: path.join(configDir, 'rules'),
29
+ ruleFile: path.join(configDir, 'rules', 'hq.md'),
30
+ mcpConfig: path.join(configDir, 'mcp_config.json'),
31
+ stateDir: path.join(home, '.gemini', 'antigravity'),
32
+ cliStateDir: path.join(home, '.gemini', 'antigravity-cli'),
33
+ };
34
+ }
35
+ function isDir(p) {
36
+ try {
37
+ return fs.statSync(p).isDirectory();
38
+ }
39
+ catch {
40
+ return false;
41
+ }
42
+ }
43
+ function onPath(binary, env, platform) {
44
+ const sep = platform === 'win32' ? ';' : ':';
45
+ const exts = platform === 'win32' ? ['.exe', '.cmd', ''] : [''];
46
+ for (const dir of (env.PATH ?? '').split(sep)) {
47
+ if (!dir)
48
+ continue;
49
+ for (const ext of exts) {
50
+ const candidate = path.join(dir, binary + ext);
51
+ try {
52
+ if (fs.statSync(candidate).isFile())
53
+ return candidate;
54
+ }
55
+ catch {
56
+ // keep looking
57
+ }
58
+ }
59
+ }
60
+ return null;
61
+ }
62
+ /** Antigravity is present when any of: the macOS app, a config/state dir, or `agy` on PATH. */
63
+ export function detectAntigravity(opts) {
64
+ const env = opts.env ?? process.env;
65
+ const platform = opts.platform ?? process.platform;
66
+ const t = antigravityTargets(opts.home);
67
+ const signals = [];
68
+ const appPath = opts.appPath ?? env.HQ_ANTIGRAVITY_APP_PATH ?? (platform === 'darwin' ? '/Applications/Antigravity.app' : '');
69
+ if (appPath && isDir(appPath))
70
+ signals.push(`app: ${appPath}`);
71
+ if (isDir(t.configDir))
72
+ signals.push(`config: ${t.configDir}`);
73
+ if (isDir(t.stateDir))
74
+ signals.push(`state: ${t.stateDir}`);
75
+ const agy = onPath(ANTIGRAVITY_CLI_BINARY, env, platform);
76
+ if (agy)
77
+ signals.push(`cli: ${agy}`);
78
+ return { detected: signals.length > 0, signals };
79
+ }
80
+ /** Rule includes use forward slashes on every OS. */
81
+ function posix(p) {
82
+ return p.split('\\').join('/');
83
+ }
84
+ /** The full HQ-owned rule file. Deterministic so a re-run is a byte-for-byte no-op. */
85
+ export function antigravityRuleContent(hqRoot) {
86
+ const charter = posix(charterPath(hqRoot));
87
+ const agents = posix(path.join(hqRoot, 'AGENTS.md'));
88
+ return [
89
+ '---',
90
+ 'trigger: always_on',
91
+ '---',
92
+ ANTIGRAVITY_RULE_MARKER,
93
+ '',
94
+ '# HQ',
95
+ '',
96
+ `HQ is installed from ${posix(hqRoot)}. Follow the HQ charter in every workspace:`,
97
+ '',
98
+ `@[HQ charter](${charter})`,
99
+ '',
100
+ `If the charter above did not load, read ${charter} and ${agents} before acting.`,
101
+ 'HQ tools are available through the "hq" MCP server.',
102
+ '',
103
+ ].join('\n');
104
+ }
105
+ /** Decide what to do with the rule file: HQ-owned files are replaced, others are left alone. */
106
+ export function planAntigravityRule(current, hqRoot) {
107
+ const content = antigravityRuleContent(hqRoot);
108
+ if (current === null)
109
+ return { action: 'write', content };
110
+ if (current === content)
111
+ return { action: 'noop', content };
112
+ if (current.includes(ANTIGRAVITY_RULE_MARKER))
113
+ return { action: 'write', content };
114
+ return { action: 'foreign', content };
115
+ }
116
+ export function isHqAntigravityRule(current) {
117
+ if (current === null || !current.includes(ANTIGRAVITY_RULE_MARKER))
118
+ return false;
119
+ const fence = matchFrontmatter(current);
120
+ return fence !== null && /^trigger:\s*always_on\s*$/m.test(fence[1] ?? '');
121
+ }
122
+ //# sourceMappingURL=antigravity-targets.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@indigoai-us/hq-cli",
3
- "version": "5.345.246",
3
+ "version": "5.345.247",
4
4
  "description": "HQ by Indigo management CLI — modules and cloud sync",
5
5
  "main": "dist/index.js",
6
6
  "bin": {
@@ -126,11 +126,11 @@
126
126
  "*.{ts,tsx,mts,cts,js,jsx,mjs,cjs}": "eslint --cache --no-error-on-unmatched-pattern"
127
127
  },
128
128
  "optionalDependencies": {
129
- "@indigoai-us/hq-hook-win32-x64": "5.345.246",
130
- "@indigoai-us/hq-hook-win32-arm64": "5.345.246",
131
- "@indigoai-us/hq-hook-darwin-x64": "5.345.246",
132
- "@indigoai-us/hq-hook-darwin-arm64": "5.345.246",
133
- "@indigoai-us/hq-hook-linux-x64": "5.345.246",
134
- "@indigoai-us/hq-hook-linux-arm64": "5.345.246"
129
+ "@indigoai-us/hq-hook-win32-x64": "5.345.247",
130
+ "@indigoai-us/hq-hook-win32-arm64": "5.345.247",
131
+ "@indigoai-us/hq-hook-darwin-x64": "5.345.247",
132
+ "@indigoai-us/hq-hook-darwin-arm64": "5.345.247",
133
+ "@indigoai-us/hq-hook-linux-x64": "5.345.247",
134
+ "@indigoai-us/hq-hook-linux-arm64": "5.345.247"
135
135
  }
136
136
  }