@rbbtsn0w/adg 0.6.0-beta.1 → 0.6.0-beta.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. package/README.md +31 -2
  2. package/dist/bin/adg.js +0 -1
  3. package/dist/src/adapters/codex.js +12 -0
  4. package/dist/src/adapters/reverse.js +22 -1
  5. package/dist/src/agents/claude.js +52 -6
  6. package/dist/src/agents/codex.js +94 -14
  7. package/dist/src/cli/handlers.js +164 -141
  8. package/dist/src/cli/index.js +14 -4
  9. package/dist/src/codex-marketplace-migration.js +139 -0
  10. package/dist/src/commands/cache.js +92 -15
  11. package/dist/src/commands/inspect.js +41 -0
  12. package/dist/src/commands/install.js +140 -73
  13. package/dist/src/commands/link.js +4 -16
  14. package/dist/src/commands/marketplace.js +74 -20
  15. package/dist/src/commands/migrate.js +15 -3
  16. package/dist/src/commands/projection.js +15 -0
  17. package/dist/src/commands/select-components.js +12 -0
  18. package/dist/src/commands/state.js +4 -2
  19. package/dist/src/commands/sync.js +9 -15
  20. package/dist/src/commands/update.js +51 -10
  21. package/dist/src/commands/validate.js +9 -2
  22. package/dist/src/components.js +3 -0
  23. package/dist/src/default-dsl.js +142 -0
  24. package/dist/src/lock.js +25 -7
  25. package/dist/src/manifest.js +29 -1
  26. package/dist/src/materialize.js +5 -1
  27. package/dist/src/mcp.js +59 -0
  28. package/dist/src/paths.js +31 -4
  29. package/dist/src/render/plugins.js +7 -1
  30. package/dist/src/source-cache.js +140 -0
  31. package/dist/src/sources.js +76 -5
  32. package/dist/src/telemetry.js +28 -21
  33. package/dist/src/types.js +5 -1
  34. package/dist/vendor/skills/src/cli.js +6 -1
  35. package/dist/vendor/skills/src/update.js +29 -4
  36. package/docs/agents-spec.md +27 -4
  37. package/docs/authoring.md +19 -2
  38. package/package.json +8 -2
  39. package/schemas/adg-plugin.schema.json +1 -0
  40. package/schemas/plugin-lock.schema.json +23 -1
  41. package/vendor/skills/src/cli.ts +6 -1
  42. package/vendor/skills/src/update.ts +32 -4
package/README.md CHANGED
@@ -31,6 +31,21 @@ See [docs/authoring.md](docs/authoring.md) to author a plugin, and
31
31
  - **Reproducibility** — `.plugin-lock.json` records source, version and a content
32
32
  hash for every installed plugin.
33
33
 
34
+ ## Default plugin layout
35
+
36
+ A repository without a manifest is also installable when it uses the standard
37
+ plugin locations: `skills/<name>/SKILL.md`, `hooks/hooks.json`, or `.mcp.json`.
38
+ ADG derives a default manifest from the locations that exist. Add
39
+ `.agents/.plugin.json` only when a source needs custom component paths or other
40
+ plugin metadata; its `skills`, `hooks`, and `mcpServers` fields override only
41
+ their matching defaults, while omitted fields inherit valid standard locations.
42
+ For structural sources, `--as` sets a stable installed identity and `--only`
43
+ limits both the stored payload and runtime exposure. In non-interactive runs,
44
+ discovered hooks or MCP require explicit `--only`. Default DSL applies only to
45
+ the source root. It is not a monorepo convention: every member of a
46
+ multi-plugin repository must declare its own `.agents/.plugin.json` and be
47
+ selected with `--plugin` or `--all`.
48
+
34
49
  ---
35
50
 
36
51
  # Install and quick start
@@ -156,6 +171,20 @@ adg plugins update --global
156
171
  adg plugins link --target claude --global
157
172
  ```
158
173
 
174
+ ### Example 3 — `cloudflare/skills` (auto-discovery and selective installation)
175
+
176
+ A repository containing skills for the Cloudflare Developer Platform. Although the repository doesn't explicitly declare an MCP configuration in its native `.claude-plugin/plugin.json` manifest, it includes a `.mcp.json` file in its root. ADG auto-discovers this file, allowing you to selectively choose which components, skills, or MCP servers to install:
177
+
178
+ ```bash
179
+ # Add the cloudflare plugin globally (interactive guide asks which skills/MCP servers to install)
180
+ adg plugins add https://github.com/cloudflare/skills --global
181
+
182
+ # Or install it non-interactively, limiting to specific skills and MCP servers:
183
+ adg plugins add https://github.com/cloudflare/skills --global \
184
+ --skill agents-sdk --skill cloudflare --skill durable-objects \
185
+ --mcp wrangler-mcp --mcp d1-mcp
186
+ ```
187
+
159
188
  > Both repos are pulled by `owner/repo` shorthand over a shallow clone (sparse
160
189
  > checkout when `--sparse` is given). Provenance — `{type:"github",repo,ref,path}`
161
190
  > — plus a `sha256` integrity hash land in `.plugin-lock.json`, so the install is
@@ -252,9 +281,9 @@ adg plugins add plugins/my-plugin --project # <repo>/.agents/plugins
252
281
  adg plugins add plugins/my-plugin --global # ~/.agents/plugins
253
282
  adg plugins add plugins/asc --dir plugins # explicit target dir
254
283
 
255
- # add from GitHub (shorthand, @ref, or full URL); --path selects a monorepo subdir
284
+ # add from GitHub (shorthand, @ref, or full URL)
256
285
  adg plugins add owner/repo --dir plugins
257
- adg plugins add owner/repo@v0.1.0 --path plugins/asc --dir plugins
286
+ adg plugins add owner/repo@v0.1.0 --plugin asc --dir plugins
258
287
  adg plugins add https://github.com/owner/repo.git --ref main --dir plugins
259
288
  adg plugins add plugins/asc --dir plugins --no-deps # skip transitive deps
260
289
 
package/dist/bin/adg.js CHANGED
@@ -104,7 +104,6 @@ async function main(argv) {
104
104
  let status = 0;
105
105
  try {
106
106
  span.setAttribute("process.executable.name", "adg");
107
- span.setAttribute("process.executable.path", process.argv[1] || process.execPath);
108
107
  span.setAttribute("process.pid", process.pid);
109
108
  span.setAttribute("process.command_args", sanitizeArgs(["adg", ...argv]));
110
109
  // Check for an available update (reads local cache; schedules a background
@@ -3,6 +3,7 @@ import { join } from "node:path";
3
3
  import { resolveProjectedSkills } from "../skills.js";
4
4
  import { isExposed } from "../components.js";
5
5
  import { mcpConfigPath } from "../mcp.js";
6
+ import { recordTelemetryEvent } from "../telemetry.js";
6
7
  /**
7
8
  * Resolve the hooks config *file* Codex should reference. ADG declares `hooks` as
8
9
  * a directory, but Codex (unlike Claude) has no auto-load — it needs an explicit
@@ -52,6 +53,17 @@ export function toCodexManifest(pluginDir, manifest, selection) {
52
53
  description: manifest.description,
53
54
  skills,
54
55
  };
56
+ const displayName = typeof manifest.interface?.displayName === "string" ? manifest.interface.displayName : undefined;
57
+ const explicitShortDescription = typeof manifest.interface?.shortDescription === "string" && manifest.interface.shortDescription.trim()
58
+ ? manifest.interface.shortDescription.trim()
59
+ : undefined;
60
+ out.interface = {
61
+ ...(displayName ? { displayName } : {}),
62
+ shortDescription: explicitShortDescription ?? manifest.description,
63
+ };
64
+ recordTelemetryEvent("adg.codex.interface", {
65
+ "interface.short_description_source": explicitShortDescription ? "explicit" : "manifest",
66
+ });
55
67
  if (manifest.author)
56
68
  out.author = manifest.author;
57
69
  if (manifest.homepage)
@@ -1,3 +1,5 @@
1
+ import { existsSync, statSync } from "node:fs";
2
+ import { join } from "node:path";
1
3
  import { ADG_SCHEMA_VERSION } from "../types.js";
2
4
  import { validateManifest } from "../manifest.js";
3
5
  import { toPosix } from "../fsutil.js";
@@ -15,7 +17,7 @@ import { toPosix } from "../fsutil.js";
15
17
  * emits valid `./skills/<id>` entries instead of leaking bare ids into a Claude
16
18
  * manifest.
17
19
  */
18
- export function fromNativeManifest(raw, kind) {
20
+ export function fromNativeManifest(raw, kind, pluginDir) {
19
21
  if (typeof raw !== "object" || raw === null) {
20
22
  throw new Error("native manifest must be a JSON object");
21
23
  }
@@ -36,6 +38,14 @@ export function fromNativeManifest(raw, kind) {
36
38
  copyIfString(n, out, "agents");
37
39
  copyIfString(n, out, "hooks");
38
40
  copyIfString(n, out, "mcpServers");
41
+ if (typeof out.mcpServers !== "string") {
42
+ if (typeof n.mcp === "string") {
43
+ out.mcpServers = n.mcp;
44
+ }
45
+ else if (pluginDir && existsSync(join(pluginDir, ".mcp.json"))) {
46
+ out.mcpServers = "./.mcp.json";
47
+ }
48
+ }
39
49
  copyIfString(n, out, "apps");
40
50
  if (typeof n.author === "object" && n.author !== null) {
41
51
  manifest.author = n.author;
@@ -57,6 +67,17 @@ export function fromNativeManifest(raw, kind) {
57
67
  manifest.skills = "./skills/";
58
68
  }
59
69
  manifest.strict = typeof n.strict === "boolean" ? n.strict : true;
70
+ if (!manifest.hooks && pluginDir) {
71
+ const hooksDir = join(pluginDir, "hooks");
72
+ try {
73
+ if (existsSync(hooksDir) && statSync(hooksDir).isDirectory())
74
+ manifest.hooks = "./hooks/";
75
+ }
76
+ catch {
77
+ // hooks inference is best-effort; unreadable or concurrently removed dirs
78
+ // must not abort reverse-adaptation.
79
+ }
80
+ }
60
81
  return validateManifest(manifest);
61
82
  }
62
83
  function copyIfString(src, dst, key) {
@@ -16,6 +16,7 @@ import { makeCli, skippedResult } from "./base.js";
16
16
  * versions) rather than hand-editing Claude's internal state.
17
17
  */
18
18
  const MARKETPLACE = "adg";
19
+ const UNRECOGNIZED_PLUGIN_LIST = "claude plugin list returned unrecognized output";
19
20
  function claudeHome(env) {
20
21
  return env.CLAUDE_CONFIG_DIR?.trim() || join(homedir(), ".claude");
21
22
  }
@@ -94,7 +95,7 @@ export function parseClaudeMarketplaceList(out) {
94
95
  }
95
96
  }
96
97
  /** Register or refresh the ADG store as a Claude marketplace, failing open. */
97
- export function syncMarketplace(pluginsDir, name, runner = run) {
98
+ export function syncMarketplace(pluginsDir, name, runner = run, warn = console.warn) {
98
99
  const listed = runner(["plugin", "marketplace", "list", "--json"]);
99
100
  if (listed.ok && parseClaudeMarketplaceList(listed.out).includes(name)) {
100
101
  // Claude's marketplace update path can fail on existing installs (for
@@ -104,7 +105,10 @@ export function syncMarketplace(pluginsDir, name, runner = run) {
104
105
  if (runner(["plugin", "marketplace", "update", name]).ok)
105
106
  return;
106
107
  }
107
- runner(["plugin", "marketplace", "add", pluginsDir]);
108
+ const added = runner(["plugin", "marketplace", "add", pluginsDir]);
109
+ if (!added.ok) {
110
+ warn(`failed to sync Claude marketplace (${name}): ${added.out.trim() || "claude plugin marketplace add failed without an error message"}`);
111
+ }
108
112
  }
109
113
  export const claudeAgent = {
110
114
  id: "claude",
@@ -156,12 +160,54 @@ export const claudeAgent = {
156
160
  listInstalled(ctx) {
157
161
  if (!available())
158
162
  return undefined;
159
- const res = run(["plugin", "list"]);
160
- if (!res.ok)
161
- return undefined;
162
- return parseClaudePluginList(res.out, claudeMarketplaceName(ctx.pluginsDir), ctx.scope);
163
+ const marketplace = claudeMarketplaceName(ctx.pluginsDir);
164
+ const jsonRes = run(["plugin", "list", "--json"]);
165
+ if (jsonRes.ok) {
166
+ const parsed = parseClaudePluginListJson(jsonRes.out, marketplace, ctx.scope);
167
+ if (parsed !== undefined)
168
+ return parsed;
169
+ return claudeListFailure(jsonRes.out);
170
+ }
171
+ const textRes = run(["plugin", "list"]);
172
+ if (!textRes.ok)
173
+ return { error: textRes.out.trim() || jsonRes.out.trim() || "claude plugin list failed without an error message" };
174
+ const fallback = parseClaudePluginList(textRes.out, marketplace, ctx.scope);
175
+ if (fallback.length > 0 || textRes.out.trim() === "")
176
+ return fallback;
177
+ return claudeListFailure(textRes.out);
163
178
  },
164
179
  };
180
+ export function claudeListFailure(out) {
181
+ const detail = out.trim() || "claude plugin list failed without an error message";
182
+ return { error: `${UNRECOGNIZED_PLUGIN_LIST}: ${detail}` };
183
+ }
184
+ /** Parse `claude plugin list --json` into enabled plugin names for a marketplace + scope. */
185
+ export function parseClaudePluginListJson(out, marketplace, scope) {
186
+ try {
187
+ const parsed = JSON.parse(out);
188
+ if (!Array.isArray(parsed))
189
+ return undefined;
190
+ const names = [];
191
+ const seen = new Set();
192
+ for (const entry of parsed) {
193
+ if (typeof entry !== "object" || entry === null)
194
+ continue;
195
+ const record = entry;
196
+ const id = typeof record.id === "string" ? record.id : undefined;
197
+ const entryScope = typeof record.scope === "string" ? record.scope.toLowerCase() : undefined;
198
+ const enabled = record.enabled === true;
199
+ const head = id?.match(/^(\S+?)@([\w.-]+)$/);
200
+ if (!head || head[2] !== marketplace || entryScope !== scope || !enabled || seen.has(head[1]))
201
+ continue;
202
+ seen.add(head[1]);
203
+ names.push(head[1]);
204
+ }
205
+ return names;
206
+ }
207
+ catch {
208
+ return undefined;
209
+ }
210
+ }
165
211
  /**
166
212
  * Parse `claude plugin list` output into the *enabled* plugin names from a given
167
213
  * marketplace and install scope. The listing groups each plugin as a
@@ -1,10 +1,15 @@
1
1
  import { createHash } from "node:crypto";
2
- import { existsSync } from "node:fs";
2
+ import { existsSync, readFileSync } from "node:fs";
3
3
  import { homedir } from "node:os";
4
4
  import { join, resolve } from "node:path";
5
+ import { SpanKind } from "@opentelemetry/api";
5
6
  import { codexMarketplaceRoot, globalPluginsDir, marketplacePath } from "../paths.js";
6
7
  import { readMarketplace, writeMarketplace } from "../marketplace.js";
7
8
  import { makeCli, skippedResult } from "./base.js";
9
+ import { reconcileCodexMarketplaceAliases } from "../codex-marketplace-migration.js";
10
+ import { getTracer, recordTelemetryEvent } from "../telemetry.js";
11
+ const UNRECOGNIZED_PLUGIN_LIST = "codex plugin list returned unrecognized output";
12
+ const MARKETPLACE = "adg";
8
13
  /**
9
14
  * Codex agent.
10
15
  *
@@ -18,16 +23,16 @@ function codexHome(env) {
18
23
  }
19
24
  const { available, run } = makeCli("codex", { probeArgs: ["plugin", "--help"] });
20
25
  /**
21
- * Codex's default global marketplace is historically named `plugins`. Project
22
- * and explicit stores get a store-scoped name to avoid colliding with a global
23
- * or another project's configured marketplace.
26
+ * Keep Codex's global marketplace identity aligned with the Claude projection.
27
+ * Project and explicit stores get a store-scoped name to avoid colliding with
28
+ * the global store or another project's configured marketplace.
24
29
  */
25
30
  export function codexMarketplaceName(pluginsDir) {
26
31
  const normalized = resolve(pluginsDir);
27
32
  if (normalized === resolve(globalPluginsDir()))
28
- return "plugins";
33
+ return MARKETPLACE;
29
34
  const hash = createHash("sha1").update(normalized.split("\\").join("/")).digest("hex").slice(0, 8);
30
- return `adg-${hash}`;
35
+ return `${MARKETPLACE}-${hash}`;
31
36
  }
32
37
  /** Ensure the generated Codex marketplace export uses this store's scoped name. */
33
38
  export function writeCodexMarketplaceName(pluginsDir) {
@@ -41,11 +46,40 @@ export function writeCodexMarketplaceName(pluginsDir) {
41
46
  return name;
42
47
  }
43
48
  /** Register the local marketplace root Codex expects for this store. */
44
- function syncMarketplace(pluginsDir, marketplace) {
49
+ export function syncMarketplace(pluginsDir, marketplace, runner = run, warn = console.warn) {
45
50
  const root = codexMarketplaceRoot(pluginsDir);
46
- const add = run(["plugin", "marketplace", "add", root]);
47
- if (!add.ok)
48
- run(["plugin", "marketplace", "upgrade", marketplace]);
51
+ const add = runner(["plugin", "marketplace", "add", root]);
52
+ if (add.ok)
53
+ return;
54
+ const upgraded = runner(["plugin", "marketplace", "upgrade", marketplace]);
55
+ if (!upgraded.ok) {
56
+ warn(`failed to sync Codex marketplace (${marketplace}): ${upgraded.out.trim() || add.out.trim() || "codex plugin marketplace sync failed without an error message"}`);
57
+ }
58
+ }
59
+ /**
60
+ * Best-effort retirement of historical aliases after canonical installs succeed.
61
+ * Keep this compatibility path only until telemetry reports no legacy aliases for
62
+ * two release cycles.
63
+ */
64
+ function reconcileLegacyAliases(pluginsDir, marketplace, plugins) {
65
+ getTracer().startActiveSpan("adg.codex.marketplace_alias_migration", { kind: SpanKind.INTERNAL }, (span) => {
66
+ try {
67
+ const result = reconcileCodexMarketplaceAliases({
68
+ pluginsDir,
69
+ marketplace,
70
+ plugins,
71
+ readConfig: () => readFileSync(join(codexHome(process.env), "config.toml"), "utf8"),
72
+ run,
73
+ report: (attributes) => recordTelemetryEvent("adg.codex.marketplace_alias_migration", attributes, span),
74
+ });
75
+ if (result.outcome === "partial") {
76
+ console.warn("Codex legacy marketplace alias cleanup was only partially completed; rerun `adg plugins sync --target codex` to retry.");
77
+ }
78
+ }
79
+ finally {
80
+ span.end();
81
+ }
82
+ });
49
83
  }
50
84
  export const codexAgent = {
51
85
  id: "codex",
@@ -63,6 +97,8 @@ export const codexAgent = {
63
97
  if (run(["plugin", "add", `${p}@${mp}`]).ok)
64
98
  affected.push(p);
65
99
  }
100
+ if (ctx.reconcileLegacyAliases && affected.length > 0)
101
+ reconcileLegacyAliases(ctx.pluginsDir, mp, affected);
66
102
  return { agent: "codex", affected, skipped: false };
67
103
  },
68
104
  deactivate(ctx) {
@@ -92,10 +128,20 @@ export const codexAgent = {
92
128
  const mp = writeCodexMarketplaceName(ctx.pluginsDir);
93
129
  if (!mp)
94
130
  return undefined; // no generated marketplace → can't scope the query
95
- const res = run(["plugin", "list"]);
96
- if (!res.ok)
97
- return codexListFailure(res.out);
98
- return parseCodexPluginList(res.out, mp);
131
+ const jsonRes = run(["plugin", "list", "--json"]);
132
+ if (jsonRes.ok) {
133
+ const parsed = parseCodexPluginListJson(jsonRes.out, mp);
134
+ if (parsed !== undefined)
135
+ return parsed;
136
+ return codexUnrecognizedListFailure(jsonRes.out);
137
+ }
138
+ const textRes = run(["plugin", "list"]);
139
+ if (!textRes.ok)
140
+ return codexListFailure(textRes.out || jsonRes.out);
141
+ const fallback = parseCodexPluginList(textRes.out, mp);
142
+ if (fallback.length > 0 || textRes.out.trim() === "")
143
+ return fallback;
144
+ return codexUnrecognizedListFailure(textRes.out);
99
145
  },
100
146
  };
101
147
  /** Preserve Codex's diagnostic and offer cleanup for a stale ADG project marketplace. */
@@ -107,6 +153,40 @@ export function codexListFailure(out) {
107
153
  ...(staleMarketplace ? { recoveryCommand: `codex plugin marketplace remove ${staleMarketplace[1]}` } : {}),
108
154
  };
109
155
  }
156
+ export function codexUnrecognizedListFailure(out) {
157
+ const detail = out.trim() || "codex plugin list failed without an error message";
158
+ return { error: `${UNRECOGNIZED_PLUGIN_LIST}: ${detail}` };
159
+ }
160
+ /** Parse `codex plugin list --json` into installed and enabled plugin names for one marketplace. */
161
+ export function parseCodexPluginListJson(out, marketplace) {
162
+ try {
163
+ const parsed = JSON.parse(out);
164
+ if (typeof parsed !== "object" || parsed === null)
165
+ return undefined;
166
+ const installed = parsed.installed;
167
+ if (!Array.isArray(installed))
168
+ return undefined;
169
+ const names = [];
170
+ const seen = new Set();
171
+ for (const entry of installed) {
172
+ if (typeof entry !== "object" || entry === null)
173
+ continue;
174
+ const record = entry;
175
+ const name = typeof record.name === "string" ? record.name : undefined;
176
+ const mp = typeof record.marketplaceName === "string" ? record.marketplaceName : undefined;
177
+ const isInstalled = record.installed === true;
178
+ const enabled = record.enabled === true;
179
+ if (!name || mp !== marketplace || !isInstalled || !enabled || seen.has(name))
180
+ continue;
181
+ seen.add(name);
182
+ names.push(name);
183
+ }
184
+ return names;
185
+ }
186
+ catch {
187
+ return undefined;
188
+ }
189
+ }
110
190
  /**
111
191
  * Parse `codex plugin list` output into the *installed and enabled* plugin names
112
192
  * from a given marketplace. The listing is a whitespace-aligned table whose