@rbbtsn0w/adg 0.4.0-beta.7 → 0.4.0-beta.9

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.
@@ -1 +1,3 @@
1
- export {};
1
+ export function isAgentListFailure(result) {
2
+ return result !== undefined && result !== null && !Array.isArray(result);
3
+ }
@@ -228,7 +228,7 @@ async function runPluginsVerb(verb, rest, cmd) {
228
228
  const only = resolveComponents(values.only);
229
229
  const skillsSubset = values.skill && values.skill.length > 0 ? values.skill : undefined;
230
230
  const narrowed = only !== undefined || skillsSubset !== undefined;
231
- const { order, installed, converted, agents } = await addPlugins({
231
+ const { order, installed, removed, converted, agents } = await addPlugins({
232
232
  spec,
233
233
  pluginsDir,
234
234
  ref: values.ref,
@@ -251,6 +251,8 @@ async function runPluginsVerb(verb, rest, cmd) {
251
251
  });
252
252
  for (const name of converted)
253
253
  console.log(ui.meta(`converted native manifest -> .agents/.plugin.json: ${name}`));
254
+ for (const name of removed)
255
+ console.log(`${ui.warn("removed")} ${ui.name(name)}`);
254
256
  if (order.length > 1)
255
257
  console.log(ui.meta(`install order: ${order.join(" -> ")}`));
256
258
  for (const res of installed) {
@@ -3,6 +3,8 @@ import { ADAPTERS } from "../adapters/index.js";
3
3
  import { readManifest } from "../manifest.js";
4
4
  import { writeJson } from "../fsutil.js";
5
5
  import { checkHookEvents } from "../hooks.js";
6
+ import { writeAntigravityMcpConfig } from "../adapters/antigravity.js";
7
+ import { writeAntigravityHooks } from "../adapters/antigravity-hooks.js";
6
8
  /**
7
9
  * Generate runtime-specific manifests for the given targets from a plugin's
8
10
  * .agents/.plugin.json. The output path honors the manifest's `adapters`
@@ -12,11 +14,9 @@ import { checkHookEvents } from "../hooks.js";
12
14
  export function adaptPlugin(pluginDir, targets, selection) {
13
15
  const manifest = readManifest(pluginDir);
14
16
  const results = [];
15
- // Lint the plugin's hooks against each target's event support: a hook on an
16
- // event a target can't fire (e.g. a Claude-only event projected to Codex) is a
17
- // silent no-op otherwise. Read-only — ADG never transforms hooks.
18
- for (const w of checkHookEvents(pluginDir, targets))
19
- console.error(`hooks: ${w}`);
17
+ // Surface target event gaps before they become silent no-ops. Antigravity's
18
+ // adapter may add more mechanical-translation diagnostics below.
19
+ const hookWarnings = new Set(checkHookEvents(pluginDir, targets));
20
20
  for (const target of targets) {
21
21
  const adapter = ADAPTERS[target];
22
22
  if (!adapter)
@@ -26,7 +26,14 @@ export function adaptPlugin(pluginDir, targets, selection) {
26
26
  // runtime mandates its own (.claude-plugin/ , .codex-plugin/).
27
27
  const file = join(pluginDir, defaultPath);
28
28
  writeJson(file, out);
29
+ if (target === "antigravity") {
30
+ writeAntigravityMcpConfig(pluginDir, manifest, selection);
31
+ for (const warning of writeAntigravityHooks(pluginDir, manifest, selection))
32
+ hookWarnings.add(warning);
33
+ }
29
34
  results.push({ target, file });
30
35
  }
36
+ for (const warning of hookWarnings)
37
+ console.error(`hooks: ${warning}`);
31
38
  return results;
32
39
  }
@@ -4,6 +4,7 @@ import { basename, join, relative, resolve } from "node:path";
4
4
  import { ADAPTER_TARGETS } from "../adapters/index.js";
5
5
  import { fromNativeManifest } from "../adapters/reverse.js";
6
6
  import { adaptPlugin } from "./adapt.js";
7
+ import { removePlugin } from "./remove.js";
7
8
  import { copyPluginDir, toPosix, writeJson } from "../fsutil.js";
8
9
  import { folderHash } from "../hash.js";
9
10
  import { packageFilter, PROJECTION_DIRS } from "../package.js";
@@ -196,6 +197,53 @@ async function resolveSelections(opts, selected, candidates) {
196
197
  }
197
198
  return selections;
198
199
  }
200
+ /** True when a locked plugin belongs to the same remote checkout currently being reconciled. */
201
+ function sameRemoteSource(entry, parsed, ref) {
202
+ if (parsed.kind === "local")
203
+ return false;
204
+ if (entry.type !== "github")
205
+ return false;
206
+ return entry.repo === parsed.source && entry.ref === ref;
207
+ }
208
+ /**
209
+ * Remove plugins from the same remote source that disappeared from the latest
210
+ * desired set. This handles both source layout changes (one plugin splitting
211
+ * into several differently named plugins) and an explicit narrowed reinstall
212
+ * (`--plugin one` after previously installing `--all`) without leaving stale
213
+ * runtime exports behind.
214
+ */
215
+ function reconcileRemotePlugins(opts, parsed, ref, desired) {
216
+ if (parsed.kind === "local")
217
+ return [];
218
+ // A path/sparse install does not prove the full source shape, so it must not
219
+ // prune sibling plugins from the same repo that were intentionally excluded
220
+ // from the checkout/selection window.
221
+ if (opts.path || opts.sparse?.length)
222
+ return [];
223
+ const lock = readLock(lockPath(opts.pluginsDir));
224
+ const stale = Object.entries(lock.plugins)
225
+ .filter(([name, entry]) => sameRemoteSource(entry.origin, parsed, ref) && !desired.has(name))
226
+ .map(([name]) => name)
227
+ .sort();
228
+ if (stale.length === 0)
229
+ return [];
230
+ // Removing from the ADG store is target-agnostic: once a plugin is no longer
231
+ // desired, every agent that may have cached it must be asked to drop it. The
232
+ // install/refresh pass below still honors `targets`; this broader deactivation
233
+ // only applies to removed store entries.
234
+ const agents = opts.activate ? (opts.deactivationAgents ?? resolveAgents()) : undefined;
235
+ for (const name of stale) {
236
+ removePlugin({
237
+ pluginsDir: opts.pluginsDir,
238
+ name,
239
+ force: true,
240
+ deactivate: opts.activate,
241
+ scope: opts.scope,
242
+ agents,
243
+ });
244
+ }
245
+ return stale;
246
+ }
199
247
  /**
200
248
  * The unified install entrypoint. Treats any source as a marketplace: clone or
201
249
  * read it, discover every plugin (ADG plus reverse-adapted native), choose a
@@ -204,6 +252,7 @@ async function resolveSelections(opts, selected, candidates) {
204
252
  */
205
253
  export async function addPlugins(opts) {
206
254
  const parsed = parseSource(opts.spec);
255
+ const sourceRef = parsed.kind === "local" ? undefined : (opts.ref ?? parsed.ref);
207
256
  let workRoot;
208
257
  let buildOrigin;
209
258
  let cleanup;
@@ -212,15 +261,14 @@ export async function addPlugins(opts) {
212
261
  buildOrigin = (dir) => ({ type: "local", path: `./${toPosix(relative(workRoot, dir)) || basename(dir)}` });
213
262
  }
214
263
  else {
215
- const ref = opts.ref ?? parsed.ref;
216
264
  const tmp = mkdtempSync(join(tmpdir(), "adg-clone-"));
217
265
  cleanup = () => rmSync(tmp, { recursive: true, force: true });
218
- cloneGitHub({ ...parsed, ref }, tmp, { sparse: opts.sparse, runner: opts.gitRunner });
266
+ cloneGitHub({ ...parsed, ref: sourceRef }, tmp, { sparse: opts.sparse, runner: opts.gitRunner });
219
267
  workRoot = tmp;
220
268
  buildOrigin = (dir) => ({
221
269
  type: "github",
222
270
  repo: parsed.source,
223
- ...(ref ? { ref } : {}),
271
+ ...(sourceRef ? { ref: sourceRef } : {}),
224
272
  path: toPosix(relative(tmp, dir)) || ".",
225
273
  });
226
274
  }
@@ -230,18 +278,20 @@ export async function addPlugins(opts) {
230
278
  throw new Error(`no plugin found in "${opts.spec}" (no .agents/.plugin.json, .claude-plugin or .codex-plugin manifest).`);
231
279
  }
232
280
  const selected = await selectPluginNames(opts, candidates, workRoot, converted);
281
+ // Resolve adapter targets after the plugin choice (lets a CLI agent picker
282
+ // run once we know what's being installed). undefined → installPlugin's all.
283
+ const targets = opts.targets ?? (opts.selectTargets ? await opts.selectTargets() : undefined);
284
+ const available = [...candidates.keys()];
233
285
  if (selected.length === 0) {
234
286
  // Under "skip" (the update path) every requested plugin was deleted
235
287
  // upstream: don't abort — return what the source still offers so the
236
288
  // caller can report the deletions.
237
289
  if (opts.missingPlugins === "skip") {
238
- return { order: [], installed: [], converted, available: [...candidates.keys()] };
290
+ const removed = reconcileRemotePlugins(opts, parsed, sourceRef, new Set(selected));
291
+ return { order: [], installed: [], removed, converted, available };
239
292
  }
240
293
  throw new Error("no plugins selected");
241
294
  }
242
- // Resolve adapter targets after the plugin choice (lets a CLI agent picker
243
- // run once we know what's being installed). undefined → installPlugin's all.
244
- const targets = opts.targets ?? (opts.selectTargets ? await opts.selectTargets() : undefined);
245
295
  // Partial-install selection per user-chosen plugin (auto-deps install full).
246
296
  const selections = await resolveSelections(opts, selected, candidates);
247
297
  // Dependency-first order across every selected plugin (chains deduped).
@@ -256,6 +306,7 @@ export async function addPlugins(opts) {
256
306
  }
257
307
  }
258
308
  }
309
+ const removed = reconcileRemotePlugins(opts, parsed, sourceRef, new Set(order));
259
310
  // Snapshot which plugins already existed before this call mutates the lock,
260
311
  // so the activation step below can tell brand-new installs from updates.
261
312
  const existingPlugins = new Set(Object.keys(readLock(lockPath(opts.pluginsDir)).plugins));
@@ -285,7 +336,8 @@ export async function addPlugins(opts) {
285
336
  const scope = opts.scope ?? "project";
286
337
  const ctxFor = (names) => ({ pluginsDir: opts.pluginsDir, plugins: names, scope });
287
338
  agents = resolved.map((a) => {
288
- const agentInstalled = a.listInstalled?.(ctxFor([]));
339
+ const queryResult = a.listInstalled?.(ctxFor([]));
340
+ const agentInstalled = Array.isArray(queryResult) ? queryResult : undefined;
289
341
  const alreadyInstalled = (name) => agentInstalled !== undefined
290
342
  ? agentInstalled.includes(name)
291
343
  : existingPlugins.has(name);
@@ -307,7 +359,7 @@ export async function addPlugins(opts) {
307
359
  return parts.reduce((acc, r) => ({ agent: r.agent, affected: [...acc.affected, ...r.affected], skipped: acc.skipped && r.skipped }), { agent: a.id, affected: [], skipped: true });
308
360
  });
309
361
  }
310
- return { order, installed, converted, available: [...candidates.keys()], agents };
362
+ return { order, installed, removed, converted, available, agents };
311
363
  }
312
364
  finally {
313
365
  cleanup?.();
@@ -120,6 +120,7 @@ export async function updatePlugins(opts) {
120
120
  activate: opts.activate,
121
121
  scope: opts.agentScope,
122
122
  agents: opts.agents,
123
+ deactivationAgents: opts.deactivationAgents,
123
124
  now,
124
125
  });
125
126
  if (agents)
@@ -1,6 +1,6 @@
1
1
  import { existsSync } from "node:fs";
2
2
  import { listPlugins } from "./list.js";
3
- import { allAgents, resolveAgents } from "../agents/index.js";
3
+ import { allAgents, isAgentListFailure, resolveAgents } from "../agents/index.js";
4
4
  import { lockPath } from "../paths.js";
5
5
  /** Diff the store against each agent's live plugin list. Read-only. */
6
6
  export function pluginStatus(opts) {
@@ -16,6 +16,18 @@ export function pluginStatus(opts) {
16
16
  if (installed === undefined) {
17
17
  return { id: a.id, displayName: a.displayName, queryable: false, inSync: [], missing: [], agentOnly: [] };
18
18
  }
19
+ if (isAgentListFailure(installed)) {
20
+ return {
21
+ id: a.id,
22
+ displayName: a.displayName,
23
+ queryable: false,
24
+ queryError: installed.error,
25
+ recoveryCommand: installed.recoveryCommand,
26
+ inSync: [],
27
+ missing: [],
28
+ agentOnly: [],
29
+ };
30
+ }
19
31
  const agentSet = new Set(installed);
20
32
  // If we're in project scope and the project doesn't have an ADG lock file,
21
33
  // the project is not initialized with ADG plugins. We should not report global
@@ -9,7 +9,8 @@ export function unlinkPlugins(opts) {
9
9
  if (!agent)
10
10
  return { target: opts.target, unlinked: [] };
11
11
  const scope = opts.global ? "user" : "project";
12
- const installedInAgent = agent.listInstalled?.({ pluginsDir: opts.pluginsDir, plugins: [], scope });
12
+ const queryResult = agent.listInstalled?.({ pluginsDir: opts.pluginsDir, plugins: [], scope });
13
+ const installedInAgent = Array.isArray(queryResult) ? queryResult : undefined;
13
14
  const installedInStore = listPlugins(opts.pluginsDir).map((p) => p.name);
14
15
  // A name is valid if it is installed in either the store OR the agent (if queryable).
15
16
  const validNames = new Set([...installedInStore, ...(installedInAgent ?? [])]);
package/dist/src/hooks.js CHANGED
@@ -2,10 +2,9 @@ import { existsSync, readFileSync } from "node:fs";
2
2
  import { join } from "node:path";
3
3
  import { resolveCodexHooksFile } from "./adapters/codex.js";
4
4
  /**
5
- * Hook events each target fires, from the official docs (Claude
6
- * code.claude.com/docs/en/hooks, Codex developers.openai.com/codex/hooks). Used
7
- * only to warn — never to drop — so an event these lists haven't caught up with
8
- * is reported as unknown rather than hidden. Codex is a subset of Claude's set.
5
+ * Canonical Claude events each target can consume or mechanically map, from the
6
+ * official runtime docs. This table drives diagnostics; target adapters remain
7
+ * responsible for projection.
9
8
  */
10
9
  const SUPPORTED_EVENTS = {
11
10
  claude: new Set([
@@ -25,6 +24,7 @@ const SUPPORTED_EVENTS = {
25
24
  "PostToolUse", "PreCompact", "PostCompact", "UserPromptSubmit",
26
25
  "SubagentStop", "Stop",
27
26
  ]),
27
+ antigravity: new Set(["SessionStart", "PreToolUse", "PostToolUse", "Stop"]),
28
28
  };
29
29
  /** The hooks file `target` will actually load (plugin-relative), or undefined. */
30
30
  function hooksFileForTarget(pluginDir, target) {
@@ -32,6 +32,12 @@ function hooksFileForTarget(pluginDir, target) {
32
32
  // the shared file) — reuse the adapter's resolution so the lint matches reality.
33
33
  if (target === "codex")
34
34
  return resolveCodexHooksFile(pluginDir, "./hooks/");
35
+ if (target === "antigravity") {
36
+ const native = join(pluginDir, "hooks", "hooks-antigravity.json");
37
+ if (existsSync(native))
38
+ return undefined; // Native DSL does not need Claude-event linting.
39
+ return existsSync(join(pluginDir, "hooks", "hooks.json")) ? "hooks/hooks.json" : undefined;
40
+ }
35
41
  // Claude auto-loads only the standard hooks/hooks.json.
36
42
  return existsSync(join(pluginDir, "hooks", "hooks.json")) ? "hooks/hooks.json" : undefined;
37
43
  }
@@ -47,21 +53,22 @@ function hookEventsOf(file) {
47
53
  }
48
54
  }
49
55
  /**
50
- * Warn when a plugin's hooks file declares an event the target agent can't fire,
51
- * so a no-op hook (e.g. a Claude-only `UserPromptExpansion` projected to Codex)
52
- * surfaces instead of silently doing nothing. Pure read-only lint — no transform.
56
+ * Warn when a canonical hook event cannot run on a target. This is read-only;
57
+ * Antigravity's actual translation lives in its target adapter.
53
58
  */
54
59
  export function checkHookEvents(pluginDir, targets) {
55
60
  const warnings = [];
56
61
  for (const t of targets) {
57
- if (t !== "claude" && t !== "codex")
62
+ if (t !== "claude" && t !== "codex" && t !== "antigravity")
58
63
  continue;
59
64
  const rel = hooksFileForTarget(pluginDir, t);
60
65
  if (!rel)
61
66
  continue;
62
67
  for (const event of hookEventsOf(join(pluginDir, rel))) {
63
68
  if (!SUPPORTED_EVENTS[t].has(event)) {
64
- warnings.push(`hook event "${event}" is not a known ${t} hook event — ${t} will not fire it`);
69
+ warnings.push(t === "antigravity"
70
+ ? `hook event "${event}" is not a supported antigravity hook mapping — antigravity will not fire it`
71
+ : `hook event "${event}" is not a known ${t} hook event — ${t} will not fire it`);
65
72
  }
66
73
  }
67
74
  }
@@ -11,7 +11,11 @@ import { mcpConfigPath } from "./mcp.js";
11
11
  */
12
12
  /** Top-level metadata files always shipped with a plugin, matched case-insensitively. */
13
13
  const META_RE = /^(README|LICEN[CS]E|CHANGELOG|NOTICE)(\..+)?$/i;
14
- /** Generated runtime projections — shipped, but excluded from the content hash. */
14
+ /**
15
+ * Generated runtime projections — shipped, but excluded from the content hash.
16
+ * Antigravity projects its manifest and hooks config at the plugin root, while
17
+ * its generated hook protocol runner lives under `.antigravity-plugin`.
18
+ */
15
19
  export const PROJECTION_DIRS = [".claude-plugin", ".codex-plugin", ".antigravity-plugin"];
16
20
  /** Extract the first path segment of a manifest component value (e.g. "./skills/" -> "skills"). */
17
21
  function topSegment(p) {
package/dist/src/paths.js CHANGED
@@ -51,6 +51,19 @@ export function lockPath(pluginsDir) {
51
51
  export function marketplacePath(pluginsDir) {
52
52
  return join(pluginsDir, MARKETPLACE_FILENAME);
53
53
  }
54
+ /** True when `pluginsDir` has the canonical `<root>/.agents/plugins` shape. */
55
+ export function isCanonicalPluginsDir(pluginsDir) {
56
+ return basename(pluginsDir) === "plugins" && basename(dirname(pluginsDir)) === ".agents";
57
+ }
58
+ /**
59
+ * Resolve the marketplace root Codex expects for a local marketplace source.
60
+ * For `<root>/.agents/plugins`, Codex's source root is `<root>`; for explicit
61
+ * `--dir` stores there is no `.agents/` project root, so the store itself is the
62
+ * root and source paths are relative to it.
63
+ */
64
+ export function codexMarketplaceRoot(pluginsDir) {
65
+ return isCanonicalPluginsDir(pluginsDir) ? dirname(dirname(pluginsDir)) : pluginsDir;
66
+ }
54
67
  /**
55
68
  * Make a filesystem-safe single path segment out of a git URL by replacing the
56
69
  * scheme/host/path separators with `__` and dropping a trailing `.git`.
@@ -117,7 +130,6 @@ export function installedPluginDir(pluginsDir, name, origin) {
117
130
  * leaking parent-directory names from a fixed two-levels-up assumption.
118
131
  */
119
132
  export function marketplaceSourcePath(pluginsDir, dest) {
120
- const isCanonical = basename(pluginsDir) === "plugins" && basename(dirname(pluginsDir)) === ".agents";
121
- const root = isCanonical ? dirname(dirname(pluginsDir)) : pluginsDir;
133
+ const root = codexMarketplaceRoot(pluginsDir);
122
134
  return `./${relative(root, dest).split("\\").join("/")}`;
123
135
  }
@@ -90,7 +90,7 @@ export function renderUpdateReport(result) {
90
90
  else
91
91
  out.push(`${head}: ${ui.meta(`up to date (${r.unchanged.length})`)}`);
92
92
  if (r.deleted.length > 0) {
93
- out.push(ui.warn(` deleted upstream: ${r.deleted.join(", ")} — remove with \`adg plugins remove <name>\``));
93
+ out.push(ui.warn(` removed stale upstream entries: ${r.deleted.join(", ")}`));
94
94
  }
95
95
  if (r.available.length > 0) {
96
96
  out.push(ui.meta(` ${r.available.length} more available (use --all): ${r.available.join(", ")}`));
@@ -116,7 +116,16 @@ export function renderStatus(statuses) {
116
116
  for (const s of statuses) {
117
117
  out.push(ui.name(s.displayName));
118
118
  if (!s.queryable) {
119
- out.push(ui.meta(" live state unknown — agent CLI not available or not queryable"));
119
+ if (s.queryError) {
120
+ out.push(ui.meta(" live state unknown — agent CLI query failed"));
121
+ for (const line of s.queryError.split("\n"))
122
+ out.push(ui.warn(` ${line}`));
123
+ if (s.recoveryCommand)
124
+ out.push(ui.meta(` → ${s.recoveryCommand}`));
125
+ }
126
+ else {
127
+ out.push(ui.meta(" live state unknown — agent CLI not available or not queryable"));
128
+ }
120
129
  continue;
121
130
  }
122
131
  out.push(ui.meta(` in sync (${s.inSync.length})${s.inSync.length ? ": " + s.inSync.join(", ") : ""}`));
package/docs/authoring.md CHANGED
@@ -153,7 +153,8 @@ Two ways to declare them:
153
153
  - **commands** — `"./commands/"`, a dir of slash-command markdown files.
154
154
  - **agents** — `"./agents/"`, a dir of sub-agent definition `.md` files.
155
155
  - **mcpServers** — `"./.mcp.json"`, an MCP server config file (points at a *file*,
156
- not a dir).
156
+ not a dir). ADG keeps that pointer for Claude and Codex; Antigravity instead
157
+ materializes the referenced file as the required sibling `mcp_config.json`.
157
158
  - **hooks**, **apps** — directories, same pattern. For hooks, see **Hooks**
158
159
  below — agents differ on the hook config format, so ADG can compile a single
159
160
  universal definition into each agent's native file.
@@ -165,11 +166,11 @@ the runtime projections and the installed package.
165
166
 
166
167
  ## Hooks
167
168
 
168
- Agent hook formats have **converged on Claude's**: Claude Code's hook schema is the
169
- de-facto standard, Codex consumes the same structure (and accepts
170
- `${CLAUDE_PLUGIN_ROOT}`), and Antigravity uses the same shape. So ADG does **not**
171
- define its own hook DSL — you author hooks once in **Claude's native format** and
172
- ADG only routes/lints them. (Rationale and the unify-vs-adopt decision rule:
169
+ ADG adopts Claude's hook schema as its canonical source instead of defining a
170
+ fourth hook DSL. Codex consumes that structure directly, while Antigravity has a
171
+ different root filename, schema, event model, and JSON I/O contract. ADG routes
172
+ Claude/Codex files and mechanically projects the supported subset for
173
+ Antigravity. (Rationale and the unify-vs-adopt decision rule:
173
174
  [docs/hooks-strategy.md](hooks-strategy.md).)
174
175
 
175
176
  - **Author** `hooks/hooks.json` in Claude's hook format (see the
@@ -181,9 +182,23 @@ ADG only routes/lints them. (Rationale and the unify-vs-adopt decision rule:
181
182
  Need genuinely different Codex behavior? Ship a `hooks/hooks-codex.json` and ADG
182
183
  references that for Codex instead (per-agent override; Claude still uses
183
184
  `hooks/hooks.json`).
185
+ - **Antigravity** requires `hooks.json` at the plugin root. ADG generates that
186
+ target file from the canonical Claude definition and bridges supported command
187
+ output into Antigravity's JSON protocol. For behavior that cannot be expressed
188
+ mechanically, ship native Antigravity DSL as `hooks/hooks-antigravity.json`;
189
+ ADG validates it, then copies it to the required root filename without
190
+ rewriting it. Invalid canonical or native input leaves the last-known-good
191
+ generated projection in place.
184
192
  - **Lint** — at `adapt`/install ADG warns when your hooks use an event a target
185
- can't fire (e.g. `UserPromptExpansion` is Claude-only, so it never fires in Codex).
186
- It only warns; it never rewrites your hooks.
193
+ cannot fire or map. Unsupported events/handlers are omitted from the generated
194
+ Antigravity file, but warnings do not abort synchronization.
195
+
196
+ The first Antigravity mapping set covers `SessionStart` (startup only),
197
+ `PreToolUse`, `PostToolUse`, and `Stop`. Tool matcher aliases are translated only
198
+ when they are deterministic; use the native override for target-specific tools,
199
+ asynchronous handlers, or output fields that have no Antigravity equivalent.
200
+ At runtime, an unsupported control output fails explicitly rather than being
201
+ silently weakened.
187
202
 
188
203
  ```json
189
204
  {
package/docs/cli-json.md CHANGED
@@ -101,7 +101,10 @@ Field notes:
101
101
  - `targets` contains the resolved target ids requested by `--target`; omitted
102
102
  `--target` resolves to all registered targets.
103
103
  - `queryable: false` means the agent CLI could not be queried; the arrays are
104
- then empty because live state is unknown.
104
+ then empty because live state is unknown. When the CLI ran but rejected the
105
+ query, `queryError` contains its diagnostic and `recoveryCommand` contains a
106
+ safe repair command when ADG recognizes the failure. Both fields are omitted
107
+ when unavailable.
105
108
  - `inSync`, `missing`, and `agentOnly` are name-level comparisons. Content drift
106
109
  is not represented; use `adg plugins sync` when a full runtime refresh is
107
110
  required.
@@ -1,6 +1,6 @@
1
1
  # Design note: hooks strategy & the unify-vs-adopt principle
2
2
 
3
- **Status:** Accepted · **Date:** 2026-06-26 · **Context:** issue #32, the retired `adg.hooks/v1` DSL
3
+ **Status:** Accepted, amended 2026-06-29 · **Context:** issue #32, the retired `adg.hooks/v1` DSL
4
4
 
5
5
  This note records *why* ADG does not own a hooks DSL, and the decision rule that produced that outcome —
6
6
  so the same wheel isn't reinvented.
@@ -21,46 +21,43 @@ layer, draw a hard line:
21
21
 
22
22
  ## Worked example: hooks
23
23
 
24
- The three agents' hook **formats have converged on Claude's**: same JSON shape
25
- (`{hooks:{Event:[{matcher,hooks:[{type,command}]}]}}`), Codex consumes it and accepts
26
- `${CLAUDE_PLUGIN_ROOT}`, Antigravity is same-shape. So criterion (2) fails → **adopt Claude's format**, don't
27
- invent a 4th.
24
+ Claude's shape (`{hooks:{Event:[{matcher,hooks:[{type,command}]}]}}`) remains the
25
+ canonical authoring format. Codex consumes it and accepts `${CLAUDE_PLUGIN_ROOT}`.
26
+ Antigravity does not: it requires a root `hooks.json`, named hook definitions,
27
+ different lifecycle structure, and camelCase stdin/stdout contracts. The corrected
28
+ decision is still **adopt Claude's format**, but add a thin Antigravity target
29
+ adapter rather than pretending the native formats are identical.
28
30
 
29
31
  `superpowers` ships three hook files (`hooks.json`, `hooks-codex.json`, `hooks-cursor.json`) — but that is
30
32
  **behavioral divergence, not format divergence**: the author chose different matchers and *different scripts*
31
33
  per agent. A DSL with `commandByTarget`/`matcherByTarget` does not make that "author once" — the author still
32
34
  specifies both behaviors, just in one file. So the retired DSL had **no sweet spot**:
33
- - homogeneous plugin → a single native `hooks/hooks.json` already runs on all three (DSL adds nothing);
35
+ - homogeneous Claude/Codex plugin → a single native `hooks/hooks.json` runs on both (DSL adds nothing);
34
36
  - divergent plugin → DSL only relocates the N behaviors into override syntax (DSL adds syntax, not leverage).
35
37
 
36
38
  ### What ADG does instead (router + linter)
37
39
  - **Same behavior across agents → one file.** Author `hooks/hooks.json` in Claude's format; Claude
38
- auto-loads it, Codex references the same file. This is the real "one file, many agents".
40
+ auto-loads it, Codex references the same file, and Antigravity mechanically projects its supported subset.
39
41
  - **Different behavior per agent → N native files + routing.** Author ships `hooks/hooks-codex.json` (etc.);
40
- ADG's adapter resolvers route each agent to its file. ADG does not synthesize variants.
42
+ `hooks/hooks-antigravity.json` is the Antigravity escape hatch. ADG routes each native override.
41
43
  - **Lint** (`checkHookEvents`, `src/hooks.ts`): warn when a hook uses an event a target can't fire (e.g.
42
- Claude-only `UserPromptExpansion` on Codex) — read-only, never a transform.
44
+ Claude-only `UserPromptExpansion` on Codex or Antigravity) rather than silently dropping behavior.
43
45
 
44
- ## Conditional plan: thin mechanical translation (build only when a target needs it)
46
+ ## Thin Antigravity translation
45
47
 
46
- ADG currently supports Claude + Codex hook targets, and **neither needs translation** (Codex accepts Claude's
47
- format + `${CLAUDE_PLUGIN_ROOT}`). So no translation code exists today — deliberately (YAGNI).
48
+ Antigravity triggered the previously conditional translation layer. It remains
49
+ target-local and deterministic; it is not a revived public DSL.
48
50
 
49
- **Trigger to implement:** ADG adds a hook target that diverges *mechanically* — most likely **Antigravity**
50
- or **Cursor**. When that happens, add only these deterministic, behavior-preserving steps to the per-agent
51
- hook handling (a small `HookTranslation` per target, near the adapter resolvers — *not* a revived DSL):
51
+ - **File projection** — write Antigravity's required root `hooks.json` without touching canonical source files.
52
+ - **Schema projection** — convert `SessionStart`, `PreToolUse`, `PostToolUse`, and `Stop` into named native definitions.
53
+ - **Matcher aliases** — translate only exact built-in tool names and simple alternations; warn and omit unsafe regex rewrites.
54
+ - **Protocol bridge** — set canonical plugin-root environment variables and translate the supported stdin/stdout fields.
55
+ - **Native escape hatch** — validate and copy `hooks/hooks-antigravity.json` verbatim when a plugin needs target-specific semantics.
56
+ - **Failure safety** — validate before atomic replacement, retain the last-known-good projection on invalid input, and fail runtime control outputs that cannot be preserved safely.
52
57
 
53
- - **Env-token substitution** — rewrite `${CLAUDE_PLUGIN_ROOT}` → the target's plugin-root var, for targets
54
- that don't accept Claude's. (Claude: none; Codex: none — accepts it; Antigravity: TBD.)
55
- - **Event-name aliases** — a per-target rename table for events that are the same concept under a different
56
- name. Known/suspected (verify against the live agent before shipping):
57
-
58
- | Canonical (Claude) | Antigravity | Codex |
59
- |---|---|---|
60
- | `PostToolUse` | `PostInvocation` (reported) | `PostToolUse` |
61
- | (others) | TBD — verify from the binary/docs | subset, same names |
62
-
63
- **Out of scope even then:** matcher values, command/script selection, async semantics — behavioral, author-owned.
58
+ **Out of scope:** inventing target-specific commands, guessing complex matcher
59
+ semantics, or emulating fields for which Antigravity has no equivalent. These
60
+ produce diagnostics and require a native override.
64
61
 
65
62
  ## The manifest is the same *pattern*, not the same *conclusion*
66
63
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rbbtsn0w/adg",
3
- "version": "0.4.0-beta.7",
3
+ "version": "0.4.0-beta.9",
4
4
  "description": "Agent Directory Group (ADG) toolkit — two domains: plugins and skills.",
5
5
  "type": "module",
6
6
  "license": "MIT",