@rbbtsn0w/adg 0.4.0-beta.4 → 0.4.0-beta.6

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/README.md CHANGED
@@ -152,7 +152,7 @@ asc/
152
152
  ├── .claude-plugin/plugin.json generated by `adg plugins adapt`
153
153
  ├── .codex-plugin/plugin.json generated by `adg plugins adapt`
154
154
  ├── skills/<kebab-name>/SKILL.md
155
- ├── agents/ commands/ hooks/ mcp/ apps/
155
+ ├── agents/ commands/ hooks/ apps/ .mcp.json
156
156
  └── README.md
157
157
  ```
158
158
 
@@ -2,6 +2,7 @@ import { existsSync, readdirSync, statSync } from "node:fs";
2
2
  import { join } from "node:path";
3
3
  import { resolveProjectedSkills } from "../skills.js";
4
4
  import { isExposed } from "../components.js";
5
+ import { mcpConfigPath } from "../mcp.js";
5
6
  /**
6
7
  * Claude auto-loads this plugin-relative path; declaring it in `manifest.hooks`
7
8
  * duplicates the load and fails ("Duplicate hooks file detected").
@@ -78,8 +79,9 @@ export function toAnthropicManifest(pluginDir, manifest, selection) {
78
79
  if (hooksFile)
79
80
  out.hooks = hooksFile;
80
81
  }
81
- if (manifest.mcp && isExposed(selection, "mcp"))
82
- out.mcp = manifest.mcp;
82
+ const mcp = mcpConfigPath(manifest);
83
+ if (mcp && isExposed(selection, "mcp"))
84
+ out.mcpServers = mcp;
83
85
  if (manifest.apps && isExposed(selection, "apps"))
84
86
  out.apps = manifest.apps;
85
87
  // Claude's array form is already `./skills/<id>` paths, so a strict array is
@@ -1,18 +1,20 @@
1
1
  import { join } from "node:path";
2
+ import { isExposed } from "../components.js";
3
+ import { mcpConfigPath } from "../mcp.js";
2
4
  /** Projection subdirectory that holds the self-contained agy plugin root. */
3
5
  export const ANTIGRAVITY_PROJECTION_DIR = ".antigravity-plugin";
4
6
  /**
5
7
  * Generate an Antigravity (`agy`) plugin.json from an ADG manifest.
6
8
  *
7
- * Antigravity's manifest is minimal: it reads only `name` from a `plugin.json`
8
- * and discovers components by convention (sibling `skills/`, `agents/`,
9
- * `commands/`, `hooks/` directories plus a `mcp_config.json`) — all resolved
10
- * relative to the directory handed to `agy plugin install`, with no manifest
11
- * path indirection. We therefore project a self-contained agy plugin root under
12
- * `.antigravity-plugin/`: this pure transform emits its `plugin.json`, while the
13
- * agent materializes the rest (mcp_config.json + symlinked component dirs), so a
14
- * partial-install `selection` is not expressible for this target.
9
+ * Antigravity reads the same plugin.json MCP pointer shape as the other plugin
10
+ * runtimes (`mcpServers`). The agent-side projection still materializes a
11
+ * self-contained root for partial installs by copying the referenced file next
12
+ * to plugin.json and linking selected component dirs.
15
13
  */
16
- export function toAntigravityManifest(_pluginDir, manifest, _selection) {
17
- return { defaultPath: join(ANTIGRAVITY_PROJECTION_DIR, "plugin.json"), manifest: { name: manifest.name } };
14
+ export function toAntigravityManifest(_pluginDir, manifest, selection) {
15
+ const out = { name: manifest.name };
16
+ const mcp = mcpConfigPath(manifest);
17
+ if (mcp && isExposed(selection, "mcp"))
18
+ out.mcpServers = mcp;
19
+ return { defaultPath: join(ANTIGRAVITY_PROJECTION_DIR, "plugin.json"), manifest: out };
18
20
  }
@@ -2,6 +2,7 @@ import { existsSync, readdirSync, statSync } from "node:fs";
2
2
  import { join } from "node:path";
3
3
  import { resolveProjectedSkills } from "../skills.js";
4
4
  import { isExposed } from "../components.js";
5
+ import { mcpConfigPath } from "../mcp.js";
5
6
  /**
6
7
  * Resolve the hooks config *file* Codex should reference. ADG declares `hooks` as
7
8
  * a directory, but Codex (unlike Claude) has no auto-load — it needs an explicit
@@ -37,7 +38,9 @@ export function resolveCodexHooksFile(pluginDir, hooks) {
37
38
  * declared as *paths* (`./skills/foo`), so they are resolved to identifiers
38
39
  * rather than passed through. Beyond skills, Codex also consumes `hooks` — but as
39
40
  * an explicit config *file* (no auto-load), so a declared hooks directory is
40
- * resolved to its Codex-variant file via `resolveCodexHooksFile`.
41
+ * resolved to its Codex-variant file via `resolveCodexHooksFile`. ADG uses
42
+ * Codex's `mcpServers` key as the canonical MCP config pointer, so that field
43
+ * passes through under the same runtime key.
41
44
  */
42
45
  export function toCodexManifest(pluginDir, manifest, selection) {
43
46
  // Codex's array form is bare ids, so a strict skills *array* is resolved to
@@ -60,5 +63,8 @@ export function toCodexManifest(pluginDir, manifest, selection) {
60
63
  if (hooksFile)
61
64
  out.hooks = hooksFile;
62
65
  }
66
+ const mcp = mcpConfigPath(manifest);
67
+ if (mcp && isExposed(selection, "mcp"))
68
+ out.mcpServers = mcp;
63
69
  return { defaultPath: join(".codex-plugin", "plugin.json"), manifest: out };
64
70
  }
@@ -16,15 +16,15 @@ export const ADAPTER_TARGETS = ["claude", "codex", "antigravity"];
16
16
  /**
17
17
  * Component categories each adapter target can actually express, mirroring what
18
18
  * the adapters emit: the Claude manifest carries skills/agents/commands/hooks/mcp
19
- * plus apps (`toAnthropicManifest`), while Codex consumes skills and hooks
19
+ * plus apps (`toAnthropicManifest`), while Codex consumes skills/hooks/mcp
20
20
  * (`toCodexManifest`). Antigravity (`agy`) discovers components by convention
21
- * (skills/agents/commands/hooks dirs + mcp_config.json) and does not surface
21
+ * (skills/agents/commands/hooks dirs + plugin.json pointers) and does not surface
22
22
  * apps, so apps maps only to the Claude target. Used to derive which agents a
23
23
  * plugin is adaptable to from its exposed component types.
24
24
  */
25
25
  export const ADAPTER_COMPONENTS = {
26
26
  claude: ["skills", "agents", "commands", "hooks", "mcp", "apps"],
27
- codex: ["skills", "hooks"],
27
+ codex: ["skills", "hooks", "mcp"],
28
28
  antigravity: ["skills", "agents", "commands", "hooks", "mcp"],
29
29
  };
30
30
  export { toAnthropicManifest, toCodexManifest, toAntigravityManifest };
@@ -35,7 +35,7 @@ export function fromNativeManifest(raw, kind) {
35
35
  copyIfString(n, out, "commands");
36
36
  copyIfString(n, out, "agents");
37
37
  copyIfString(n, out, "hooks");
38
- copyIfString(n, out, "mcp");
38
+ copyIfString(n, out, "mcpServers");
39
39
  copyIfString(n, out, "apps");
40
40
  if (typeof n.author === "object" && n.author !== null) {
41
41
  manifest.author = n.author;
@@ -8,16 +8,16 @@ import { isExposed } from "../components.js";
8
8
  import { installedPluginDir, lockPath } from "../paths.js";
9
9
  import { readLock } from "../lock.js";
10
10
  import { ANTIGRAVITY_PROJECTION_DIR } from "../adapters/antigravity.js";
11
+ import { mcpConfigPath } from "../mcp.js";
11
12
  import { makeCli, skippedResult } from "./base.js";
12
13
  /**
13
14
  * Antigravity (`agy`) agent.
14
15
  *
15
16
  * Antigravity discovers a plugin by convention relative to the directory handed
16
17
  * to `agy plugin install` — `plugin.json` plus sibling `skills/`, `agents/`,
17
- * `commands/`, `hooks/` dirs and a `mcp_config.json`, with no manifest path
18
- * indirection. We therefore project a self-contained agy plugin root under
19
- * `<store>/.antigravity-plugin/`: generated `plugin.json` + `mcp_config.json`
20
- * (the ADG `mcp/.mcp.json` shape is exactly agy's, so it passes through) and
18
+ * `commands/`, `hooks/` dirs plus plugin.json path pointers. We therefore
19
+ * project a self-contained agy plugin root under `<store>/.antigravity-plugin/`:
20
+ * generated `plugin.json` + copied MCP config (when selected) and
21
21
  * *symlinks* to the real component dirs one level up, so nothing is duplicated
22
22
  * on disk. agy follows these symlinks; where the platform forbids them (e.g.
23
23
  * Windows without privilege) we fall back to a copy. We then drive
@@ -76,11 +76,23 @@ function linkOrCopy(linkPath, absTarget) {
76
76
  cpSync(absTarget, linkPath, { recursive: true });
77
77
  }
78
78
  }
79
+ /** Link a file with a relative symlink, copying instead when symlinks fail. */
80
+ function linkFileOrCopy(linkPath, absTarget) {
81
+ rmSync(linkPath, { force: true });
82
+ ensureDir(dirname(linkPath));
83
+ try {
84
+ symlinkSync(relative(dirname(linkPath), absTarget), linkPath, "file");
85
+ }
86
+ catch {
87
+ cpSync(absTarget, linkPath);
88
+ }
89
+ }
79
90
  /**
80
91
  * Build the agy-native projection under `<dir>/.antigravity-plugin/`: a
81
- * `plugin.json` (name only), a `mcp_config.json` copied verbatim from the
82
- * manifest's mcp file when present, and relative symlinks (copy fallback) to the
83
- * declared component dirs named for agy's convention.
92
+ * `plugin.json`, an MCP config file copied verbatim from the manifest's
93
+ * `mcpServers` pointer when present, an agy-conventional `mcp_config.json` link
94
+ * to that file, and relative symlinks (copy fallback) to the declared component
95
+ * dirs named for agy's convention.
84
96
  *
85
97
  * An optional `selection` (the plugin's partial install) narrows what is
86
98
  * projected: component categories outside it are dropped, and `skills` is pinned
@@ -92,16 +104,25 @@ export function writeAntigravityProjection(dir, selection) {
92
104
  const manifest = readManifest(dir);
93
105
  const stage = join(dir, ANTIGRAVITY_PROJECTION_DIR);
94
106
  ensureDir(stage);
95
- writeJson(join(stage, "plugin.json"), { name: manifest.name });
96
- const mcpConfig = join(stage, "mcp_config.json");
97
- rmSync(mcpConfig, { force: true });
98
- if (manifest.mcp && isExposed(selection, "mcp")) {
99
- const mcpFile = join(dir, manifest.mcp);
100
- // The ADG mcp file shape is exactly agy's `mcp_config.json`, so copy it
101
- // verbatim — preserving formatting and avoiding a parse/re-serialize round-trip.
102
- if (existsSync(mcpFile))
103
- cpSync(mcpFile, mcpConfig);
107
+ rmSync(join(stage, "mcp_config.json"), { force: true });
108
+ const mcp = mcpConfigPath(manifest);
109
+ const pluginJson = { name: manifest.name };
110
+ if (mcp && isExposed(selection, "mcp")) {
111
+ pluginJson.mcpServers = mcp;
112
+ const mcpFile = join(dir, mcp);
113
+ const projectedMcp = join(stage, mcp);
114
+ rmSync(projectedMcp, { force: true });
115
+ ensureDir(dirname(projectedMcp));
116
+ // Copy verbatim — preserving formatting and avoiding a parse/re-serialize round-trip.
117
+ if (existsSync(mcpFile)) {
118
+ cpSync(mcpFile, projectedMcp);
119
+ linkFileOrCopy(join(stage, "mcp_config.json"), projectedMcp);
120
+ }
121
+ }
122
+ else {
123
+ rmSync(join(stage, mcp || ".mcp.json"), { force: true });
104
124
  }
125
+ writeJson(join(stage, "plugin.json"), pluginJson);
105
126
  const skillsDir = join(stage, "skills");
106
127
  rmSync(skillsDir, { recursive: true, force: true });
107
128
  if (manifest.skills !== undefined && isExposed(selection, "skills")) {
@@ -1,7 +1,6 @@
1
1
  import { existsSync } from "node:fs";
2
2
  import { resolve } from "node:path";
3
3
  import { adaptPlugin } from "../commands/adapt.js";
4
- import { liftHooksFromDisk } from "../hooks.js";
5
4
  import { addPlugins } from "../commands/install.js";
6
5
  import { validatePlugin } from "../commands/validate.js";
7
6
  import { listPlugins } from "../commands/list.js";
@@ -185,19 +184,6 @@ async function runPluginsVerb(verb, rest, cmd) {
185
184
  }
186
185
  return;
187
186
  }
188
- case "lift-hooks": {
189
- const { positionals } = parseVerb(verb, cmd.flags, rest);
190
- const pluginDir = resolve(positionals[0] ?? process.cwd());
191
- const res = liftHooksFromDisk(pluginDir);
192
- if (!res) {
193
- console.log(ui.meta(`no native hooks found in ${pluginDir} (looked for hooks/hooks.json, hooks/hooks-codex.json)`));
194
- return;
195
- }
196
- console.log(`${ui.ok("lifted")} ${ui.name(res.sources.join(" + "))} ${ui.meta(`-> ${res.file}`)}`);
197
- for (const w of res.warnings)
198
- console.error(ui.warn(` ${w}`));
199
- return;
200
- }
201
187
  case "validate": {
202
188
  const { positionals } = parseVerb(verb, cmd.flags, rest);
203
189
  const pluginDir = resolve(positionals[0] ?? process.cwd());
@@ -111,17 +111,6 @@ export const PLUGIN_COMMANDS = {
111
111
  positional: "<dir> plugin directory (default: current directory)",
112
112
  flags: [],
113
113
  },
114
- "lift-hooks": {
115
- summary: "unify native hook files into a universal .agents/hooks.json",
116
- synopsis: "adg plugins lift-hooks [<dir>]",
117
- positional: "<dir> plugin directory (default: current directory)",
118
- blurb: "The inverse of the hooks DSL compile: read a plugin's native hooks\n" +
119
- "(hooks/hooks.json, hooks/hooks-codex.json), canonicalize the env token, and\n" +
120
- "fold the per-agent differences (matcher/command) into one .agents/hooks.json\n" +
121
- "(adg.hooks/v1) so you maintain a single source. The native files are left in\n" +
122
- "place; a later `adapt` regenerates them from the DSL.",
123
- flags: [],
124
- },
125
114
  "import-skills": {
126
115
  summary: "wrap an existing skills/ dir as a plugin",
127
116
  synopsis: "adg plugins import-skills <skills-dir> --as <name>",
@@ -2,7 +2,7 @@ import { join } from "node:path";
2
2
  import { ADAPTERS } from "../adapters/index.js";
3
3
  import { readManifest } from "../manifest.js";
4
4
  import { writeJson } from "../fsutil.js";
5
- import { compileHooksToDisk } from "../hooks.js";
5
+ import { checkHookEvents } from "../hooks.js";
6
6
  /**
7
7
  * Generate runtime-specific manifests for the given targets from a plugin's
8
8
  * .agents/.plugin.json. The output path honors the manifest's `adapters`
@@ -12,13 +12,11 @@ import { compileHooksToDisk } from "../hooks.js";
12
12
  export function adaptPlugin(pluginDir, targets, selection) {
13
13
  const manifest = readManifest(pluginDir);
14
14
  const results = [];
15
- // Compile the universal hooks DSL (if any) to each target's native hook file
16
- // first, so the adapters' hooks resolvers see the generated files. A no-op for
17
- // plugins that ship hand-authored hooks. Warnings surface but never block.
18
- for (const compiled of compileHooksToDisk(pluginDir, targets)) {
19
- for (const w of compiled.warnings)
20
- console.error(`hooks: ${w}`);
21
- }
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}`);
22
20
  for (const target of targets) {
23
21
  const adapter = ADAPTERS[target];
24
22
  if (!adapter)
@@ -6,7 +6,6 @@ import { fromNativeManifest } from "../adapters/reverse.js";
6
6
  import { adaptPlugin } from "./adapt.js";
7
7
  import { copyPluginDir, toPosix, writeJson } from "../fsutil.js";
8
8
  import { folderHash } from "../hash.js";
9
- import { ADG_HOOKS_PATH, GENERATED_HOOK_FILES } from "../hooks.js";
10
9
  import { packageFilter, PROJECTION_DIRS } from "../package.js";
11
10
  import { lockPath, marketplacePath, marketplaceSourcePath, pluginDir } from "../paths.js";
12
11
  import { readLock, upsertEntry, writeLock } from "../lock.js";
@@ -20,22 +19,9 @@ import { skillDescriptionLoader } from "../skills.js";
20
19
  import { resolveAgents } from "../agents/index.js";
21
20
  // Generated runtime projections never count toward a plugin's content hash.
22
21
  const HASH_IGNORE = PROJECTION_DIRS;
23
- /**
24
- * Content hash over a plugin's packaged payload. Mirrors the projection rule for
25
- * the hooks DSL: when a plugin opts in (`.agents/hooks.json` present), the
26
- * compiled `hooks/*.json` outputs are generated, so they are excluded from the
27
- * hash — letting an authoring source (no compiled files) and an installed copy
28
- * (with them) hash identically, and keeping a compiler change from bumping the
29
- * content hash.
30
- */
22
+ /** Content hash over a plugin's packaged payload (hooks files are authored content, not generated). */
31
23
  function contentHash(dir, manifest) {
32
- const base = packageFilter(manifest, { includeProjections: false });
33
- // `GENERATED_HOOK_FILES` keys are POSIX; normalize so a backslash path (Windows)
34
- // still matches and the generated files are excluded from the hash there too.
35
- const include = existsSync(join(dir, ADG_HOOKS_PATH))
36
- ? (rel) => base(rel) && !GENERATED_HOOK_FILES.has(toPosix(rel))
37
- : base;
38
- return folderHash(dir, HASH_IGNORE, include);
24
+ return folderHash(dir, HASH_IGNORE, packageFilter(manifest, { includeProjections: false }));
39
25
  }
40
26
  /**
41
27
  * Install a single local plugin directory into a plugins directory: copy the
@@ -298,15 +284,18 @@ export async function addPlugins(opts) {
298
284
  const resolved = opts.agents ?? resolveAgents(targets);
299
285
  const scope = opts.scope ?? "project";
300
286
  const ctxFor = (names) => ({ pluginsDir: opts.pluginsDir, plugins: names, scope });
301
- // A "changed" plugin is either brand new (no prior lock entry) or an update
302
- // to an already-installed one. Only updates go through refresh — agents that
303
- // cache a copy (Claude) must drop the stale one and re-pull. Brand-new
304
- // plugins must use activate: refresh would issue an uninstall for something
305
- // never installed, which warns/errors in those agents. On the add path
306
- // (skipUnchanged off) everything is a fresh activate.
307
- const activateNames = (opts.skipUnchanged ? toActivate.filter((r) => !existingPlugins.has(r.name)) : toActivate).map((r) => r.name);
308
- const refreshNames = opts.skipUnchanged ? toActivate.filter((r) => existingPlugins.has(r.name)).map((r) => r.name) : [];
309
287
  agents = resolved.map((a) => {
288
+ const agentInstalled = a.listInstalled?.(ctxFor([]));
289
+ const alreadyInstalled = (name) => agentInstalled !== undefined
290
+ ? agentInstalled.includes(name)
291
+ : existingPlugins.has(name);
292
+ // Existing plugins must go through refresh even on an explicit `add`:
293
+ // agents like Claude cache an installed copy, and their plain install
294
+ // command is a no-op when the plugin already exists. If the agent can
295
+ // enumerate live installs, trust that state; otherwise fall back to the
296
+ // ADG lock to preserve clean-update behavior.
297
+ const activateNames = toActivate.filter((r) => !alreadyInstalled(r.name)).map((r) => r.name);
298
+ const refreshNames = toActivate.filter((r) => alreadyInstalled(r.name)).map((r) => r.name);
310
299
  // An agent may run both lifecycles (new installs + updates) in one pass;
311
300
  // merge into the existing affected/skipped contract so downstream report
312
301
  // and consolidation (renderAgentReport, mergeAgentResults) stay unchanged.
@@ -27,7 +27,7 @@ export function validatePlugin(pluginDir) {
27
27
  ["commands", m.commands],
28
28
  ["apps", m.apps],
29
29
  ["hooks", m.hooks],
30
- ["mcp", m.mcp],
30
+ ["mcpServers", m.mcpServers],
31
31
  ];
32
32
  for (const [field, value] of pathFields) {
33
33
  if (typeof value === "string" && !existsSync(join(pluginDir, value))) {
@@ -2,6 +2,7 @@ import { existsSync, readFileSync, readdirSync } from "node:fs";
2
2
  import { basename, join } from "node:path";
3
3
  import { resolveSkills } from "./skills.js";
4
4
  import { COMPONENT_TYPES } from "./types.js";
5
+ import { mcpConfigPath } from "./mcp.js";
5
6
  export { COMPONENT_TYPES };
6
7
  /** Recursively collect regular (non-dotfile) file basenames, without extension. */
7
8
  function collectFiles(dir) {
@@ -53,13 +54,14 @@ function mcpServers(file) {
53
54
  }
54
55
  /** Enumerate what a plugin contains, by reading its manifest's component paths. */
55
56
  export function pluginContents(dir, manifest) {
57
+ const mcp = mcpConfigPath(manifest);
56
58
  return {
57
59
  skills: resolveSkills(dir, manifest),
58
60
  agents: membersOf(dir, manifest.agents),
59
61
  commands: membersOf(dir, manifest.commands),
60
62
  apps: membersOf(dir, manifest.apps),
61
63
  hooks: membersOf(dir, manifest.hooks),
62
- mcp: manifest.mcp ? mcpServers(join(dir, manifest.mcp)) : [],
64
+ mcp: mcp ? mcpServers(join(dir, mcp)) : [],
63
65
  };
64
66
  }
65
67
  /** Component types this plugin actually has (non-empty). */
package/dist/src/hooks.js CHANGED
@@ -1,262 +1,69 @@
1
1
  import { existsSync, readFileSync } from "node:fs";
2
2
  import { join } from "node:path";
3
- import { writeJson } from "./fsutil.js";
3
+ import { resolveCodexHooksFile } from "./adapters/codex.js";
4
4
  /**
5
- * ADG universal hooks DSL (`adg.hooks/v1`) and its per-agent compiler.
6
- *
7
- * Agents do not share a hook format: Claude auto-loads `hooks/hooks.json` and
8
- * uses `${CLAUDE_PLUGIN_ROOT}`; Codex references an explicit file and uses
9
- * `${PLUGIN_ROOT}`; and real plugins (e.g. superpowers) genuinely diverge per
10
- * agent — different matcher vocabularies (`clear|compact` vs `resume|clear`) and
11
- * even different scripts. So the DSL is authored once with a canonical
12
- * `${PLUGIN_ROOT}` token, and carries *optional* per-target overrides for the
13
- * parts that truly differ. The compiler resolves overrides, translates the env
14
- * token, and warns (never silently drops) on events a target may not support.
15
- *
16
- * The universal source lives at `.agents/hooks.json` and is opt-in: plugins that
17
- * still ship hand-authored `hooks/*.json` keep working unchanged.
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.
18
9
  */
19
- export const ADG_HOOKS_SCHEMA_VERSION = "adg.hooks/v1";
20
- /** Canonical location of the universal hooks document inside a plugin. */
21
- export const ADG_HOOKS_PATH = ".agents/hooks.json";
22
- /**
23
- * Where each target's compiled hook file lands (plugin-relative, POSIX). Claude
24
- * auto-loads `hooks/hooks.json`; Codex references `hooks/hooks-codex.json` from
25
- * its manifest. These are generated outputs — shipped, but excluded from the
26
- * content hash (see `GENERATED_HOOK_FILES`).
27
- */
28
- export const HOOK_OUTPUT = {
29
- claude: "hooks/hooks.json",
30
- codex: "hooks/hooks-codex.json",
31
- };
32
- /** The set of generated hook files, treated like adapter projections (not hashed). */
33
- export const GENERATED_HOOK_FILES = new Set(Object.values(HOOK_OUTPUT));
34
- /** The plugin-root env variable each target expands. */
35
- const ENV_TOKEN = {
36
- claude: "CLAUDE_PLUGIN_ROOT",
37
- codex: "PLUGIN_ROOT",
10
+ const SUPPORTED_EVENTS = {
11
+ claude: new Set([
12
+ "SessionStart", "Setup", "SessionEnd",
13
+ "UserPromptSubmit", "UserPromptExpansion", "Stop", "StopFailure",
14
+ "PreToolUse", "PostToolUse", "PostToolUseFailure", "PostToolBatch",
15
+ "PermissionRequest", "PermissionDenied",
16
+ "SubagentStart", "SubagentStop", "TeammateIdle",
17
+ "TaskCreated", "TaskCompleted",
18
+ "InstructionsLoaded", "ConfigChange", "FileChanged", "CwdChanged",
19
+ "WorktreeCreate", "WorktreeRemove",
20
+ "PreCompact", "PostCompact",
21
+ "Elicitation", "ElicitationResult", "Notification", "MessageDisplay",
22
+ ]),
23
+ codex: new Set([
24
+ "SessionStart", "SubagentStart", "PreToolUse", "PermissionRequest",
25
+ "PostToolUse", "PreCompact", "PostCompact", "UserPromptSubmit",
26
+ "SubagentStop", "Stop",
27
+ ]),
38
28
  };
39
- /**
40
- * Documented hook events. Used only to *warn* on an unfamiliar event — the
41
- * compiler still emits it, so an event this list hasn't caught up with is never
42
- * silently dropped. (Codex's vocabulary is not fully published; this is Claude's
43
- * set, treated as the canonical baseline.)
44
- */
45
- const KNOWN_EVENTS = new Set([
46
- "PreToolUse",
47
- "PostToolUse",
48
- "UserPromptSubmit",
49
- "Notification",
50
- "Stop",
51
- "SubagentStop",
52
- "PreCompact",
53
- "SessionStart",
54
- "SessionEnd",
55
- ]);
56
- /** Reserved object keys that must never be used as event names (prototype-pollution guard). */
57
- const UNSAFE_KEYS = new Set(["__proto__", "constructor", "prototype"]);
58
- const isUnsafeKey = (key) => UNSAFE_KEYS.has(key);
59
- /** Replace the canonical `${PLUGIN_ROOT}` token with the target's env variable. */
60
- function translateEnv(value, target) {
61
- // Function replacement so `$` in the substitution is never treated specially.
62
- return value.replaceAll("${PLUGIN_ROOT}", () => `\${${ENV_TOKEN[target]}}`);
29
+ /** The hooks file `target` will actually load (plugin-relative), or undefined. */
30
+ function hooksFileForTarget(pluginDir, target) {
31
+ // Codex references a file from its manifest (its own variant if shipped, else
32
+ // the shared file) — reuse the adapter's resolution so the lint matches reality.
33
+ if (target === "codex")
34
+ return resolveCodexHooksFile(pluginDir, "./hooks/");
35
+ // Claude auto-loads only the standard hooks/hooks.json.
36
+ return existsSync(join(pluginDir, "hooks", "hooks.json")) ? "hooks/hooks.json" : undefined;
63
37
  }
64
- /**
65
- * Compile the universal hooks document into one target's native `hooks.json`
66
- * object, resolving per-target overrides and translating the env token. Returns
67
- * the native object plus any non-fatal warnings (unknown events).
68
- */
69
- export function compileHooks(src, target) {
70
- const warnings = [];
71
- const out = { hooks: {} };
72
- for (const [event, entries] of Object.entries(src.hooks)) {
73
- if (isUnsafeKey(event)) {
74
- // Defensive: a reserved name (e.g. "__proto__") would mutate the map's
75
- // prototype rather than add an event. parseAdgHooks rejects these at the
76
- // authoring boundary; skip-with-warning covers direct callers.
77
- warnings.push(`skipped reserved hook event name "${event}"`);
78
- continue;
79
- }
80
- if (!KNOWN_EVENTS.has(event)) {
81
- warnings.push(`unknown hook event "${event}" — emitted for ${target} but it may not fire`);
82
- }
83
- out.hooks[event] = entries.map((entry) => {
84
- const matcher = entry.matcherByTarget?.[target] ?? entry.matcher;
85
- const actions = entry.actions.map((a) => {
86
- const command = translateEnv(a.commandByTarget?.[target] ?? a.command, target);
87
- return { type: a.type, command, ...(a.async !== undefined ? { async: a.async } : {}) };
88
- });
89
- return { ...(matcher !== undefined ? { matcher } : {}), hooks: actions };
90
- });
38
+ /** Event names declared in a Claude-format hooks file; tolerant (the agents validate). */
39
+ function hookEventsOf(file) {
40
+ try {
41
+ const doc = JSON.parse(readFileSync(file, "utf8"));
42
+ const map = doc?.hooks;
43
+ return typeof map === "object" && map !== null ? Object.keys(map) : [];
91
44
  }
92
- return { hooks: out, warnings };
93
- }
94
- /** Rewrite any agent's plugin-root token back to the canonical `${PLUGIN_ROOT}`. */
95
- function canonicalizeEnv(value) {
96
- return value.replaceAll("${CLAUDE_PLUGIN_ROOT}", () => "${PLUGIN_ROOT}");
97
- }
98
- /**
99
- * Lift native hook files into one universal document — the inverse of
100
- * `compileHooks`. Where the targets agree, a single canonical value is emitted;
101
- * where they genuinely diverge (matcher or command), the difference is captured
102
- * as a per-target override, so recompiling reproduces each native file. Targets
103
- * are aligned positionally per event; a shape mismatch is reported (not dropped)
104
- * and the primary (Claude when present) is used as the structural base.
105
- */
106
- export function liftHooks(natives) {
107
- const warnings = [];
108
- const present = Object.keys(natives).filter((t) => natives[t]);
109
- const events = new Set(present.flatMap((t) => Object.keys(natives[t].hooks)));
110
- const out = { schemaVersion: ADG_HOOKS_SCHEMA_VERSION, hooks: {} };
111
- for (const event of events) {
112
- if (isUnsafeKey(event)) {
113
- warnings.push(`skipped reserved hook event name "${event}"`);
114
- continue;
115
- }
116
- // An event only some targets define becomes a *shared* entry after compile —
117
- // so it would start firing on agents that never had it. Surface that.
118
- const definedIn = present.filter((t) => natives[t].hooks[event]);
119
- if (present.length > 1 && definedIn.length < present.length) {
120
- warnings.push(`hook event "${event}" is only defined for ${definedIn.join(", ")}; it will apply to every agent after compile`);
121
- }
122
- const primary = natives.claude?.hooks[event] ? "claude" : "codex";
123
- const other = present.find((t) => t !== primary && natives[t].hooks[event]);
124
- const baseEntries = natives[primary].hooks[event];
125
- const otherEntries = other ? natives[other].hooks[event] : undefined;
126
- if (other && otherEntries && otherEntries.length !== baseEntries.length) {
127
- warnings.push(`hook event "${event}" has a different shape per target; lifted from ${primary}`);
128
- }
129
- out.hooks[event] = baseEntries.map((entry, i) => {
130
- const oEntry = otherEntries?.[i];
131
- const adg = { actions: [] };
132
- if (entry.matcher !== undefined)
133
- adg.matcher = entry.matcher;
134
- if (other && oEntry && oEntry.matcher !== undefined && oEntry.matcher !== entry.matcher) {
135
- adg.matcherByTarget = { [other]: oEntry.matcher };
136
- }
137
- adg.actions = entry.hooks.map((act, j) => {
138
- const a = { type: "command", command: canonicalizeEnv(act.command) };
139
- if (act.async !== undefined)
140
- a.async = act.async;
141
- const oAct = oEntry?.hooks[j];
142
- if (other && oAct) {
143
- const oCmd = canonicalizeEnv(oAct.command);
144
- if (oCmd !== a.command)
145
- a.commandByTarget = { [other]: oCmd };
146
- }
147
- return a;
148
- });
149
- return adg;
150
- });
45
+ catch {
46
+ return [];
151
47
  }
152
- return { hooks: out, warnings };
153
48
  }
154
49
  /**
155
- * Read a plugin's native hook files (`hooks/hooks.json`, `hooks/hooks-codex.json`)
156
- * and lift them into one universal `.agents/hooks.json`, the inverse of the
157
- * compile step. Returns undefined when the plugin ships no native hooks (nothing
158
- * to convert). The native files are left in place — a later adapt regenerates
159
- * them from the DSL. Throws on a malformed native file rather than guessing.
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.
160
53
  */
161
- export function liftHooksFromDisk(pluginDir) {
162
- const natives = {};
163
- const sources = [];
164
- for (const target of Object.keys(HOOK_OUTPUT)) {
165
- const file = join(pluginDir, HOOK_OUTPUT[target]);
166
- if (!existsSync(file))
54
+ export function checkHookEvents(pluginDir, targets) {
55
+ const warnings = [];
56
+ for (const t of targets) {
57
+ if (t !== "claude" && t !== "codex")
167
58
  continue;
168
- const parsed = JSON.parse(readFileSync(file, "utf8"));
169
- const hooksMap = parsed?.hooks;
170
- // `typeof null === "object"`, so guard the `hooks` map against null explicitly.
171
- if (typeof parsed !== "object" || parsed === null || typeof hooksMap !== "object" || hooksMap === null) {
172
- throw new Error(`${HOOK_OUTPUT[target]} is not a valid hooks file (missing \`hooks\` map)`);
173
- }
174
- natives[target] = parsed;
175
- sources.push(target);
176
- }
177
- if (sources.length === 0)
178
- return undefined;
179
- const { hooks, warnings } = liftHooks(natives);
180
- writeJson(join(pluginDir, ADG_HOOKS_PATH), hooks);
181
- return { file: ADG_HOOKS_PATH, sources, warnings };
182
- }
183
- /**
184
- * If `pluginDir` opts into the DSL (has `.agents/hooks.json`), compile it to each
185
- * requested target's native hook file and write them under `hooks/`. A no-op
186
- * (returns []) when the DSL source is absent — plugins shipping hand-authored
187
- * `hooks/*.json` are left untouched. Only claude/codex are compiled today;
188
- * targets without a `HOOK_OUTPUT` mapping (e.g. antigravity) are skipped.
189
- */
190
- export function compileHooksToDisk(pluginDir, targets) {
191
- const src = join(pluginDir, ADG_HOOKS_PATH);
192
- if (!existsSync(src))
193
- return [];
194
- const doc = parseAdgHooks(JSON.parse(readFileSync(src, "utf8")));
195
- const written = [];
196
- for (const target of targets) {
197
- if (!(target in HOOK_OUTPUT))
59
+ const rel = hooksFileForTarget(pluginDir, t);
60
+ if (!rel)
198
61
  continue;
199
- const t = target;
200
- const { hooks, warnings } = compileHooks(doc, t);
201
- const rel = HOOK_OUTPUT[t];
202
- writeJson(join(pluginDir, rel), hooks);
203
- written.push({ file: rel, warnings });
204
- }
205
- return written;
206
- }
207
- const VALID_TARGETS = new Set(["claude", "codex"]);
208
- /** Reject an unknown target key in an override map — it would be silently ignored at compile time. */
209
- function checkTargetKeys(value, where) {
210
- if (value === undefined)
211
- return;
212
- if (typeof value !== "object" || value === null || Array.isArray(value)) {
213
- throw new Error(`${where} must be an object keyed by target`);
214
- }
215
- for (const [key, val] of Object.entries(value)) {
216
- if (!VALID_TARGETS.has(key))
217
- throw new Error(`${where} has unknown target "${key}" (expected claude|codex)`);
218
- // A non-string override would crash translateEnv (`.replaceAll` on a non-string).
219
- if (typeof val !== "string")
220
- throw new Error(`${where} value for target "${key}" must be a string`);
221
- }
222
- }
223
- /**
224
- * Parse and shallowly validate a raw `.agents/hooks.json` payload. Throws with a
225
- * pointed message rather than letting a malformed document surface as a deep
226
- * runtime error during compilation.
227
- */
228
- export function parseAdgHooks(raw) {
229
- if (typeof raw !== "object" || raw === null)
230
- throw new Error("hooks document must be a JSON object");
231
- const d = raw;
232
- if (d.schemaVersion !== ADG_HOOKS_SCHEMA_VERSION) {
233
- throw new Error(`hooks document must declare schemaVersion "${ADG_HOOKS_SCHEMA_VERSION}"`);
234
- }
235
- if (typeof d.hooks !== "object" || d.hooks === null)
236
- throw new Error("hooks document missing `hooks` map");
237
- for (const [event, entries] of Object.entries(d.hooks)) {
238
- if (isUnsafeKey(event))
239
- throw new Error(`hook event name "${event}" is reserved and not allowed`);
240
- if (!Array.isArray(entries))
241
- throw new Error(`hook event "${event}" must be an array of entries`);
242
- for (const entry of entries) {
243
- if (typeof entry !== "object" || entry === null)
244
- throw new Error(`hook event "${event}" entry must be an object`);
245
- const e = entry;
246
- if (!Array.isArray(e.actions))
247
- throw new Error(`hook event "${event}" entry missing \`actions\` array`);
248
- checkTargetKeys(e.matcherByTarget, `hook event "${event}" matcherByTarget`);
249
- for (const action of e.actions) {
250
- if (typeof action !== "object" || action === null)
251
- throw new Error(`hook action in "${event}" must be an object`);
252
- const a = action;
253
- if (a.type !== "command")
254
- throw new Error(`hook action in "${event}" must have type "command"`);
255
- if (typeof a.command !== "string")
256
- throw new Error(`hook action in "${event}" missing string \`command\``);
257
- checkTargetKeys(a.commandByTarget, `hook action in "${event}" commandByTarget`);
62
+ for (const event of hookEventsOf(join(pluginDir, rel))) {
63
+ if (!SUPPORTED_EVENTS[t].has(event)) {
64
+ warnings.push(`hook event "${event}" is not a known ${t} hook event — ${t} will not fire it`);
258
65
  }
259
66
  }
260
67
  }
261
- return raw;
68
+ return warnings;
262
69
  }
@@ -75,7 +75,10 @@ export function collectIssues(raw) {
75
75
  if (m.skills !== undefined && typeof m.skills !== "string" && !isStringArray(m.skills)) {
76
76
  issues.push("skills must be a string or an array of strings");
77
77
  }
78
- for (const key of ["agents", "commands", "apps", "hooks", "mcp", "homepage", "changelog", "license", "category"]) {
78
+ if (m.mcp !== undefined) {
79
+ issues.push("mcp is not supported; use mcpServers");
80
+ }
81
+ for (const key of ["agents", "commands", "apps", "hooks", "mcpServers", "homepage", "changelog", "license", "category"]) {
79
82
  if (m[key] !== undefined && typeof m[key] !== "string") {
80
83
  issues.push(`${key} must be a string`);
81
84
  }
@@ -0,0 +1,4 @@
1
+ /** ADG's canonical MCP config pointer. */
2
+ export function mcpConfigPath(manifest) {
3
+ return manifest.mcpServers;
4
+ }
@@ -1,3 +1,4 @@
1
+ import { mcpConfigPath } from "./mcp.js";
1
2
  /**
2
3
  * Manifest-driven packaging allowlist.
3
4
  *
@@ -29,7 +30,7 @@ export function packagedRoots(manifest) {
29
30
  manifest.skills,
30
31
  manifest.agents,
31
32
  manifest.commands,
32
- manifest.mcp,
33
+ mcpConfigPath(manifest),
33
34
  manifest.hooks,
34
35
  manifest.apps,
35
36
  ];
@@ -19,7 +19,7 @@ asc/ # a plugin (authoring source)
19
19
  ├── .agents/
20
20
  │ └── .plugin.json # canonical source manifest (source of truth)
21
21
  ├── skills/<name>/SKILL.md # declared payload
22
- ├── commands/ agents/ mcp/ # declared payload
22
+ ├── commands/ agents/ .mcp.json # declared payload
23
23
  └── README.md LICENSE CHANGELOG # canonical metadata
24
24
  # .claude-plugin/ , .codex-plugin/ are NOT authored here — they are runtime
25
25
  # projections, generated at install time (or committed only when publishing to a
@@ -69,7 +69,7 @@ every projection. See the schema for the full field set; the load-bearing fields
69
69
  "skills": "./skills/", // string (dir) | array (explicit)
70
70
  "commands": "./commands/",
71
71
  "agents": "./agents/",
72
- "mcp": "./mcp/.mcp.json",
72
+ "mcpServers": "./.mcp.json",
73
73
  "dependencies": [{ "name": "github-cr", "version": "^0.2.0" }],
74
74
  "strict": true
75
75
  }
@@ -90,8 +90,8 @@ consistent with the content hash.
90
90
  The packaged file set (`src/package.ts:packagedRoots` / `packageFilter`) is:
91
91
 
92
92
  - the `.agents/` manifest home (and legacy `.adg-plugin/` during deprecation);
93
- - the top-level directory of every declared component
94
- (`skills`/`commands`/`agents`/`mcp`/`hooks`/`apps`);
93
+ - the top-level path segment of every declared component pointer
94
+ (`skills`/`commands`/`agents`/`mcpServers`/`hooks`/`apps`);
95
95
  - canonical metadata at the root: `README*`, `LICENSE*`, `CHANGELOG*`, `NOTICE*`;
96
96
  - the runtime projections `.claude-plugin/`, `.codex-plugin/` when present (copy
97
97
  only) — at install they are regenerated into the destination regardless.
@@ -112,7 +112,7 @@ native `.gitattributes export-ignore` rather than a bespoke ignore format.
112
112
  a human or generated by an agent. Beyond JSON-schema validity it SHOULD enforce:
113
113
 
114
114
  - **Pointer integrity** — every path pointer (`skills`/`commands`/`agents`/
115
- `mcp`/`hooks`/`apps`) resolves; every referenced `SKILL.md` has a non-empty
115
+ `mcpServers`/`hooks`/`apps`) resolves; every referenced `SKILL.md` has a non-empty
116
116
  `name` and `description`.
117
117
  - **Projection sync** — *if* a source repo commits projections (to publish to a
118
118
  native registry), they must match a fresh projection of the current
package/docs/authoring.md CHANGED
@@ -35,7 +35,7 @@ A finished plugin on disk — **`.agents/` only**:
35
35
  my-plugin/
36
36
  ├── .agents/.plugin.json # ← source of truth (you edit this)
37
37
  ├── skills/<name>/SKILL.md # payload
38
- ├── commands/ agents/ mcp/ # payload (only if declared!)
38
+ ├── commands/ agents/ .mcp.json # payload (only if declared!)
39
39
  └── README.md LICENSE CHANGELOG
40
40
  ```
41
41
 
@@ -82,7 +82,7 @@ authoring artifact:
82
82
  "agents": "./agents/", // string (dir)
83
83
  "hooks": "./hooks/", // string (dir)
84
84
  "apps": "./apps/", // string (dir)
85
- "mcp": "./mcp/.mcp.json", // string (file)
85
+ "mcpServers": "./.mcp.json", // string (file)
86
86
 
87
87
  "dependencies": [{ "name": "github-cr", "version": "^0.2.0" }],
88
88
  "strict": true, // default true (see Skills)
@@ -114,7 +114,7 @@ authoring artifact:
114
114
  | `agents` | string | | Directory of sub-agent `.md` files. |
115
115
  | `hooks` | string | | Directory of lifecycle hooks. |
116
116
  | `apps` | string | | Directory of third-party app integration config. |
117
- | `mcp` | string | | Path to an MCP config file (e.g. `./mcp/.mcp.json`). |
117
+ | `mcpServers` | string | | Path to an MCP config file (e.g. `./.mcp.json`). |
118
118
  | `dependencies` | `[{ name, version }]` | | Other plugins required; `version` is a semver range. |
119
119
  | `strict` | boolean | | Default `true`. See **Skills**. |
120
120
  | `homepage`, `changelog` | string | | |
@@ -152,7 +152,7 @@ Two ways to declare them:
152
152
 
153
153
  - **commands** — `"./commands/"`, a dir of slash-command markdown files.
154
154
  - **agents** — `"./agents/"`, a dir of sub-agent definition `.md` files.
155
- - **mcp** — `"./mcp/.mcp.json"`, an MCP server config file (points at a *file*,
155
+ - **mcpServers** — `"./.mcp.json"`, an MCP server config file (points at a *file*,
156
156
  not a dir).
157
157
  - **hooks**, **apps** — directories, same pattern. For hooks, see **Hooks**
158
158
  below — agents differ on the hook config format, so ADG can compile a single
@@ -165,56 +165,40 @@ the runtime projections and the installed package.
165
165
 
166
166
  ## Hooks
167
167
 
168
- Agents do not share a hook format. Claude **auto-loads** `hooks/hooks.json` and
169
- expands `${CLAUDE_PLUGIN_ROOT}`; Codex references an explicit
170
- `hooks/hooks-codex.json` from its manifest and expands `${PLUGIN_ROOT}`; and the
171
- matcher vocabularies differ (e.g. `startup|clear|compact` vs
172
- `startup|resume|clear`). Two ways to author:
173
-
174
- - **Hand-authored (passthrough)** — ship the native files yourself under
175
- `hooks/`. ADG carries them as-is: Claude auto-loads `hooks/hooks.json`, and the
176
- Codex projection references `hooks/hooks-codex.json` (falling back to
177
- `hooks/hooks.json`). Nothing is rewritten.
178
-
179
- - **Universal DSL (recommended, author once)** — add `.agents/hooks.json`
180
- (`adg.hooks/v1`). Write the canonical command with the **braced** `${PLUGIN_ROOT}`
181
- token (only `${PLUGIN_ROOT}` is translated — a bare `$PLUGIN_ROOT` is left
182
- as-is); capture the parts that genuinely differ per agent as `matcherByTarget` /
183
- `commandByTarget` overrides (keyed by `claude`/`codex`). On `adapt`/install ADG
184
- compiles it to each target's native file (`hooks/hooks.json`,
185
- `hooks/hooks-codex.json`), translating the env token and applying overrides. The
186
- compiled files ship but do not count toward the content hash. An event ADG
187
- doesn't recognize is still emitted, with a warning.
188
-
189
- ```json
190
- {
191
- "schemaVersion": "adg.hooks/v1",
192
- "hooks": {
193
- "SessionStart": [
194
- {
195
- "matcher": "startup|clear|compact",
196
- "matcherByTarget": { "codex": "startup|resume|clear" },
197
- "actions": [
198
- {
199
- "type": "command",
200
- "command": "\"${PLUGIN_ROOT}/hooks/run-hook.cmd\" session-start",
201
- "commandByTarget": { "codex": "\"${PLUGIN_ROOT}/hooks/run-hook.cmd\" session-start-codex" },
202
- "async": false
203
- }
204
- ]
205
- }
206
- ]
207
- }
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:
173
+ [docs/hooks-strategy.md](hooks-strategy.md).)
174
+
175
+ - **Author** `hooks/hooks.json` in Claude's hook format (see the
176
+ [Claude hooks reference](https://code.claude.com/docs/en/hooks)), using
177
+ `${CLAUDE_PLUGIN_ROOT}` for the plugin root.
178
+ - **Claude** auto-loads `hooks/hooks.json`; ADG omits the manifest `hooks` field so
179
+ the load isn't duplicated.
180
+ - **Codex** consumes the same file: ADG references it from `.codex-plugin/plugin.json`.
181
+ Need genuinely different Codex behavior? Ship a `hooks/hooks-codex.json` and ADG
182
+ references that for Codex instead (per-agent override; Claude still uses
183
+ `hooks/hooks.json`).
184
+ - **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.
187
+
188
+ ```json
189
+ {
190
+ "hooks": {
191
+ "SessionStart": [
192
+ {
193
+ "matcher": "startup|clear|compact",
194
+ "hooks": [
195
+ { "type": "command", "command": "\"${CLAUDE_PLUGIN_ROOT}/hooks/run-hook.cmd\" session-start" }
196
+ ]
197
+ }
198
+ ]
208
199
  }
209
- ```
210
-
211
- Schema: [adg-hooks.schema.json](../schemas/adg-hooks.schema.json).
212
-
213
- **Migrating an existing plugin** — already maintain native `hooks/hooks.json` +
214
- `hooks/hooks-codex.json` by hand? Run `adg plugins lift-hooks [<dir>]` to fold
215
- both into one `.agents/hooks.json` (canonicalizing the env token and capturing
216
- per-agent differences as overrides). The native files stay put; a later `adapt`
217
- regenerates them from the DSL.
200
+ }
201
+ ```
218
202
 
219
203
  ---
220
204
 
@@ -361,8 +345,9 @@ files.
361
345
 
362
346
  1. `.agents/.plugin.json` exists and is valid JSON;
363
347
  2. structural validity (required fields, kebab `name`, semver `version`, types);
364
- 3. **every declared path exists** (`agents`/`commands`/`apps`/`hooks`/`mcp` dirs
365
- or files; the `skills` root, or each explicit skill path).
348
+ 3. **every declared path exists** (`agents`/`commands`/`apps`/`hooks` dirs
349
+ or files; the `mcpServers` file; the `skills` root, or each explicit skill
350
+ path).
366
351
 
367
352
  Typical failures:
368
353
 
@@ -0,0 +1,82 @@
1
+ # Design note: hooks strategy & the unify-vs-adopt principle
2
+
3
+ **Status:** Accepted · **Date:** 2026-06-26 · **Context:** issue #32, the retired `adg.hooks/v1` DSL
4
+
5
+ This note records *why* ADG does not own a hooks DSL, and the decision rule that produced that outcome —
6
+ so the same wheel isn't reinvented.
7
+
8
+ ## The principle
9
+
10
+ When a feature spans multiple runtimes, **build a unifying ADG layer only when both hold:**
11
+ 1. the runtimes **genuinely diverge** (not just cosmetically), **and**
12
+ 2. there is **no de-facto standard or convergence** to adopt instead.
13
+
14
+ Otherwise, **adopt the de-facto standard** and keep ADG's role to routing/linting. And within any unifying
15
+ layer, draw a hard line:
16
+
17
+ - **Mechanical translation — ADG may do it.** Deterministic, behavior-preserving rewrites: env-token
18
+ substitution, event-name aliasing, file location/discovery. Same behavior, different spelling.
19
+ - **Behavioral synthesis — ADG must not do it.** Which matcher to fire on, which script/command to run.
20
+ That is the author's intent and cannot be invented; it can only be authored.
21
+
22
+ ## Worked example: hooks
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.
28
+
29
+ `superpowers` ships three hook files (`hooks.json`, `hooks-codex.json`, `hooks-cursor.json`) — but that is
30
+ **behavioral divergence, not format divergence**: the author chose different matchers and *different scripts*
31
+ per agent. A DSL with `commandByTarget`/`matcherByTarget` does not make that "author once" — the author still
32
+ 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);
34
+ - divergent plugin → DSL only relocates the N behaviors into override syntax (DSL adds syntax, not leverage).
35
+
36
+ ### What ADG does instead (router + linter)
37
+ - **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".
39
+ - **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.
41
+ - **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.
43
+
44
+ ## Conditional plan: thin mechanical translation (build only when a target needs it)
45
+
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
+
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):
52
+
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.
64
+
65
+ ## The manifest is the same *pattern*, not the same *conclusion*
66
+
67
+ `adg.plugin/v1` (`.agents/.plugin.json`) uses the same canonical-plus-adapters shape, but it stays justified:
68
+ 1. manifests **genuinely diverge** (per-vendor locations, `skills` encoded as bare-id array vs path array,
69
+ different metadata; superpowers ships 5 manifests) and there is **no adopted manifest standard**
70
+ (`AGENTS.md` standardizes *instructions*, not packaging) — so criteria (1) and (2) both hold; and
71
+ 2. the manifest is also **ADG's own control plane** — `dependencies`, `strict`, partial-install selection,
72
+ and `.plugin-lock.json` integrity all key off it. Hooks carried no such ADG-internal role.
73
+
74
+ Its **projection mapping** (skills/commands/agents/hooks/mcpServers → per-agent) shares the hooks risk and would
75
+ lose value if vendors converge; its **control-plane core** does not.
76
+
77
+ ## Revisit triggers
78
+ - `AGENTS.md` (Linux Foundation / Agentic AI Foundation) expands to cover plugin packaging/manifests.
79
+ - Vendors converge on component field encodings (e.g. a single `skills` form).
80
+ - A formal cross-vendor **hooks** protocol emerges.
81
+
82
+ If any fires, shrink the relevant ADG layer toward routing + control-plane only — the move made here for hooks.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rbbtsn0w/adg",
3
- "version": "0.4.0-beta.4",
3
+ "version": "0.4.0-beta.6",
4
4
  "description": "Agent Directory Group (ADG) toolkit — two domains: plugins and skills.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -53,7 +53,7 @@
53
53
  "commands": { "type": "string", "description": "Slash command directory." },
54
54
  "apps": { "type": "string", "description": "Third-party app integration config." },
55
55
  "hooks": { "type": "string", "description": "Lifecycle hooks directory." },
56
- "mcp": { "type": "string", "description": "MCP config file path." },
56
+ "mcpServers": { "type": "string", "description": "MCP config file path." },
57
57
  "dependencies": {
58
58
  "type": "array",
59
59
  "items": {
@@ -1,70 +0,0 @@
1
- {
2
- "$schema": "http://json-schema.org/draft-07/schema#",
3
- "$id": "https://RbBtSn0w.dev/schemas/adg-hooks.schema.json",
4
- "title": "ADG Universal Hooks",
5
- "description": "Universal hooks document stored at .agents/hooks.json. Authored once with the canonical ${PLUGIN_ROOT} token and optional per-target overrides; compiled to each agent's native hook file (Claude hooks/hooks.json, Codex hooks/hooks-codex.json).",
6
- "type": "object",
7
- "required": ["schemaVersion", "hooks"],
8
- "additionalProperties": false,
9
- "properties": {
10
- "schemaVersion": {
11
- "type": "string",
12
- "description": "Hooks schema version.",
13
- "const": "adg.hooks/v1"
14
- },
15
- "hooks": {
16
- "type": "object",
17
- "description": "Map of event name (e.g. SessionStart) to its matcher/action groups.",
18
- "additionalProperties": {
19
- "type": "array",
20
- "items": { "$ref": "#/definitions/entry" }
21
- }
22
- }
23
- },
24
- "definitions": {
25
- "target": {
26
- "type": "string",
27
- "enum": ["claude", "codex"]
28
- },
29
- "entry": {
30
- "type": "object",
31
- "required": ["actions"],
32
- "additionalProperties": false,
33
- "properties": {
34
- "matcher": {
35
- "type": "string",
36
- "description": "Default matcher for this group."
37
- },
38
- "matcherByTarget": {
39
- "type": "object",
40
- "description": "Per-target matcher override (agents use different matcher vocabularies).",
41
- "additionalProperties": { "type": "string" },
42
- "propertyNames": { "$ref": "#/definitions/target" }
43
- },
44
- "actions": {
45
- "type": "array",
46
- "items": { "$ref": "#/definitions/action" }
47
- }
48
- }
49
- },
50
- "action": {
51
- "type": "object",
52
- "required": ["type", "command"],
53
- "additionalProperties": false,
54
- "properties": {
55
- "type": { "type": "string", "const": "command" },
56
- "command": {
57
- "type": "string",
58
- "description": "Canonical command line; reference the plugin root as ${PLUGIN_ROOT}."
59
- },
60
- "async": { "type": "boolean" },
61
- "commandByTarget": {
62
- "type": "object",
63
- "description": "Per-target command override for genuine behavioral divergence (still using ${PLUGIN_ROOT}).",
64
- "additionalProperties": { "type": "string" },
65
- "propertyNames": { "$ref": "#/definitions/target" }
66
- }
67
- }
68
- }
69
- }
70
- }