@rbbtsn0w/adg 0.6.0 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (83) hide show
  1. package/README.md +41 -9
  2. package/dist/bin/adg.js +4 -4
  3. package/dist/src/adapters/codex.js +12 -0
  4. package/dist/src/adapters/reverse.js +22 -1
  5. package/dist/src/agents/base.js +2 -1
  6. package/dist/src/agents/claude.js +52 -6
  7. package/dist/src/agents/codex.js +94 -14
  8. package/dist/src/cli/core-plugin-handlers.js +97 -0
  9. package/dist/src/cli/handlers.js +155 -210
  10. package/dist/src/cli/index.js +14 -4
  11. package/dist/src/codex-marketplace-migration.js +139 -0
  12. package/dist/src/commands/cache.js +92 -15
  13. package/dist/src/commands/inspect.js +41 -0
  14. package/dist/src/commands/install.js +140 -73
  15. package/dist/src/commands/link.js +4 -16
  16. package/dist/src/commands/marketplace.js +74 -20
  17. package/dist/src/commands/migrate.js +15 -3
  18. package/dist/src/commands/projection.js +15 -0
  19. package/dist/src/commands/select-components.js +12 -0
  20. package/dist/src/commands/state.js +4 -2
  21. package/dist/src/commands/sync.js +9 -15
  22. package/dist/src/commands/update.js +51 -10
  23. package/dist/src/commands/validate.js +9 -2
  24. package/dist/src/components.js +3 -0
  25. package/dist/src/default-dsl.js +142 -0
  26. package/dist/src/lock.js +25 -7
  27. package/dist/src/manifest.js +85 -4
  28. package/dist/src/materialize.js +5 -1
  29. package/dist/src/mcp.js +59 -0
  30. package/dist/src/paths.js +31 -4
  31. package/dist/src/render/plugins.js +7 -1
  32. package/dist/src/source-cache.js +140 -0
  33. package/dist/src/sources.js +76 -5
  34. package/dist/src/subprocess.js +53 -0
  35. package/dist/src/telemetry.js +28 -21
  36. package/dist/src/types.js +5 -1
  37. package/dist/vendor/skills/src/add.js +0 -15
  38. package/dist/vendor/skills/src/cli.js +6 -1
  39. package/dist/vendor/skills/src/git-tree.js +4 -4
  40. package/dist/vendor/skills/src/skill-lock.js +4 -3
  41. package/dist/vendor/skills/src/update.js +38 -77
  42. package/dist/vendor/skills/src/use.js +28 -4
  43. package/docs/agents-spec.md +27 -4
  44. package/docs/authoring.md +19 -2
  45. package/docs/branching-and-release.md +52 -0
  46. package/package.json +14 -3
  47. package/schemas/adg-plugin.schema.json +2 -0
  48. package/schemas/plugin-lock.schema.json +23 -1
  49. package/vendor/skills/PROVENANCE.md +2 -0
  50. package/vendor/skills/package.json +0 -144
  51. package/vendor/skills/src/add.ts +0 -2213
  52. package/vendor/skills/src/agents.ts +0 -811
  53. package/vendor/skills/src/blob.ts +0 -588
  54. package/vendor/skills/src/cli.ts +0 -391
  55. package/vendor/skills/src/constants.ts +0 -3
  56. package/vendor/skills/src/detect-agent.ts +0 -62
  57. package/vendor/skills/src/find.ts +0 -419
  58. package/vendor/skills/src/frontmatter.ts +0 -16
  59. package/vendor/skills/src/git-tree.ts +0 -36
  60. package/vendor/skills/src/git.ts +0 -277
  61. package/vendor/skills/src/install.ts +0 -91
  62. package/vendor/skills/src/installer.ts +0 -1307
  63. package/vendor/skills/src/list.ts +0 -231
  64. package/vendor/skills/src/local-lock.ts +0 -189
  65. package/vendor/skills/src/plugin-manifest.ts +0 -183
  66. package/vendor/skills/src/prompts/search-multiselect.ts +0 -387
  67. package/vendor/skills/src/providers/index.ts +0 -14
  68. package/vendor/skills/src/providers/registry.ts +0 -51
  69. package/vendor/skills/src/providers/types.ts +0 -97
  70. package/vendor/skills/src/providers/wellknown.ts +0 -812
  71. package/vendor/skills/src/remove.ts +0 -335
  72. package/vendor/skills/src/sanitize.ts +0 -65
  73. package/vendor/skills/src/self-cli.ts +0 -20
  74. package/vendor/skills/src/skill-lock.ts +0 -329
  75. package/vendor/skills/src/skills.ts +0 -316
  76. package/vendor/skills/src/source-parser.ts +0 -449
  77. package/vendor/skills/src/sync.ts +0 -478
  78. package/vendor/skills/src/telemetry.ts +0 -226
  79. package/vendor/skills/src/test-utils.ts +0 -73
  80. package/vendor/skills/src/types.ts +0 -129
  81. package/vendor/skills/src/update-source.ts +0 -90
  82. package/vendor/skills/src/update.ts +0 -821
  83. package/vendor/skills/src/use.ts +0 -682
@@ -1,8 +1,6 @@
1
1
  import { existsSync } from "node:fs";
2
2
  import { resolve } from "node:path";
3
- import { adaptPlugin } from "../commands/adapt.js";
4
3
  import { addPlugins } from "../commands/install.js";
5
- import { validatePlugin } from "../commands/validate.js";
6
4
  import { listPlugins } from "../commands/list.js";
7
5
  import { importSkills } from "../commands/import.js";
8
6
  import { linkPlugins } from "../commands/link.js";
@@ -11,10 +9,8 @@ import { syncPlugins } from "../commands/sync.js";
11
9
  import { removePlugin } from "../commands/remove.js";
12
10
  import { disablePlugins, enablePlugins } from "../commands/state.js";
13
11
  import { migrateLayout } from "../commands/migrate.js";
14
- import { pluginStatus } from "../commands/status.js";
15
- import { cleanPluginCache, pluginCacheStatus, prunePluginCache } from "../commands/cache.js";
12
+ import { cleanPluginCache, pluginCacheStatus, prunePluginCache, restorePluginCache } from "../commands/cache.js";
16
13
  import { marketplaceList, marketplaceRemove, marketplaceSync, updatePlugins } from "../commands/marketplace.js";
17
- import { initScaffold } from "../commands/init.js";
18
14
  import { confirmFullInstall, selectComponentsInteractive } from "../commands/select-components.js";
19
15
  import { selectPluginsInteractive } from "../commands/select-plugins.js";
20
16
  import { selectTargetsInteractive } from "../commands/select-agents.js";
@@ -22,9 +18,9 @@ import { selectScopeInteractive, selectUpdateScopeInteractive } from "../command
22
18
  import { globalPluginsDir, projectPluginsDir, lockPath } from "../paths.js";
23
19
  import { getAgent } from "../agents/index.js";
24
20
  import { ui } from "../render/ui.js";
25
- import { renderAgentReport, renderMarketplaceList, renderPluginList, renderStatus, renderUpdateReport, } from "../render/plugins.js";
26
- import { pluginsListJson, pluginsStatusJson, printJson } from "../render/json.js";
21
+ import { renderAgentReport, renderMarketplaceList, renderUpdateReport, } from "../render/plugins.js";
27
22
  import { CACHE_USAGE, MARKETPLACE_USAGE, PLUGIN_ALIASES, PLUGIN_COMMANDS, SCOPE, fail, parseVerb, renderPluginsHelp, renderVerbHelp, requireSingleTarget, resolveComponents, resolveScopeDir, resolveTargets, scopeOf, wantsHelp, } from "./index.js";
23
+ import { handleCorePluginVerb } from "./core-plugin-handlers.js";
28
24
  /**
29
25
  * Resolve which scope(s) `plugins update` should refresh, mirroring
30
26
  * `adg skills update`: an explicit --dir is a single ad-hoc location; otherwise
@@ -132,6 +128,14 @@ async function resolveActionScope(values, verb) {
132
128
  info: { label: global ? "global" : "project", globalDir },
133
129
  };
134
130
  }
131
+ function resolveVerbTargets(values, verb) {
132
+ return values.target === "all"
133
+ ? resolveTargets("all")
134
+ : [requireSingleTarget(values.target, verb)];
135
+ }
136
+ function printCliUnavailableNote(target, message) {
137
+ console.log(ui.warn(`note: \`${target}\` CLI not found — ${message}`));
138
+ }
135
139
  /**
136
140
  * Top-level dispatcher for `adg plugins <verb>`: render help, resolve aliases,
137
141
  * look the verb up in the command table, then hand off to the per-verb handler
@@ -163,111 +167,141 @@ export async function runPlugins(rawVerb, rest) {
163
167
  return runCache(rest);
164
168
  return runPluginsVerb(verb, rest, cmd);
165
169
  }
166
- async function runPluginsVerb(verb, rest, cmd) {
167
- switch (verb) {
168
- case "init": {
169
- const { values, positionals } = parseVerb(verb, cmd.flags, rest);
170
- const name = positionals[0];
171
- if (!name)
172
- fail("plugins init requires a <name>");
173
- const dir = values.dir ? resolve(values.dir) : resolve(process.cwd(), "plugins");
174
- const type = (values.type ?? "plugin");
175
- if (type !== "plugin" && type !== "marketplace" && type !== "all") {
176
- fail(`invalid --type "${values.type}" (expected plugin|marketplace|all)`);
177
- }
178
- const res = initScaffold({ name, dir, type, description: values.description, author: values.author, skill: values.skill?.[0] });
179
- console.log(`${ui.ok(`created ${type}`)} at ${ui.name(res.pluginDir)}`);
180
- for (const f of res.created)
181
- console.log(ui.meta(` + ${f}`));
182
- return;
170
+ async function handleAdd(rest, cmd) {
171
+ const { values, positionals } = parseVerb("add", cmd.flags, rest);
172
+ const spec = positionals[0];
173
+ if (!spec)
174
+ fail("plugins add requires a <plugin-dir | owner/repo[@ref] | github-url>");
175
+ const tty = process.stdin.isTTY;
176
+ let global = Boolean(values.global);
177
+ if (!values.dir && values.global === undefined && values.project === undefined && tty) {
178
+ global = await selectScopeInteractive();
179
+ }
180
+ if (!values.dir)
181
+ global = promoteGlobalTrap(global);
182
+ const pluginsDir = values.dir
183
+ ? resolve(values.dir)
184
+ : global
185
+ ? globalPluginsDir()
186
+ : projectPluginsDir();
187
+ const only = resolveComponents(values.only);
188
+ const skillsSubset = values.skill && values.skill.length > 0 ? values.skill : undefined;
189
+ const mcpSubset = values.mcp && values.mcp.length > 0 ? values.mcp : undefined;
190
+ const narrowed = only !== undefined || skillsSubset !== undefined || mcpSubset !== undefined;
191
+ const { order, installed, removed, converted, agents } = await addPlugins({
192
+ spec,
193
+ pluginsDir,
194
+ ref: values.ref,
195
+ sparse: values.sparse,
196
+ all: values.all,
197
+ plugins: values.plugin,
198
+ only,
199
+ skillsSubset,
200
+ mcpSubset,
201
+ withDeps: !values["no-deps"],
202
+ marketplaceName: values["marketplace-name"],
203
+ as: values.as,
204
+ targets: values.target !== undefined ? resolveTargets(values.target) : undefined,
205
+ selectPlugins: tty ? selectPluginsInteractive : undefined,
206
+ selectTargets: tty && values.target === undefined ? selectTargetsInteractive : undefined,
207
+ confirmFull: tty && !narrowed ? confirmFullInstall : undefined,
208
+ selectComponents: tty && !narrowed ? selectComponentsInteractive : undefined,
209
+ activate: true,
210
+ nonInteractive: !tty,
211
+ scope: global ? "user" : "project",
212
+ });
213
+ for (const name of converted)
214
+ console.log(ui.meta(`converted native manifest -> .agents/.plugin.json: ${name}`));
215
+ for (const name of removed)
216
+ console.log(`${ui.warn("removed")} ${ui.name(name)}`);
217
+ if (order.length > 1)
218
+ console.log(ui.meta(`install order: ${order.join(" -> ")}`));
219
+ for (const res of installed) {
220
+ console.log(`${ui.ok("added")} ${ui.name(res.name)} ${ui.meta(`-> ${res.installedTo}`)}`);
221
+ console.log(ui.meta(` sourceHash: ${res.sourceHash}`));
222
+ console.log(ui.meta(` installedHash: ${res.installedHash}`));
223
+ for (const f of res.adapted)
224
+ console.log(ui.meta(` adapted: ${f}`));
225
+ }
226
+ for (const line of renderAgentReport(agents, "enabled"))
227
+ console.log(line);
228
+ }
229
+ async function handleLink(rest, cmd) {
230
+ const { values, positionals } = parseVerb("link", cmd.flags, rest);
231
+ const targets = resolveVerbTargets(values, "link");
232
+ const sc = await resolveActionScope(values, "link");
233
+ const names = positionals.length > 0 ? positionals : undefined;
234
+ for (const target of targets) {
235
+ const res = linkPlugins({ pluginsDir: sc.pluginsDir, target, global: sc.global, names });
236
+ for (const action of res.actions) {
237
+ console.log(`${ui.ok("linked")} ${ui.name(action.name)} ${ui.meta(`[${res.target}]`)}${action.linkedTo ? ui.meta(` -> ${action.linkedTo}`) : ""}`);
238
+ for (const file of action.adapted)
239
+ console.log(ui.meta(` adapted: ${file}`));
183
240
  }
184
- case "adapt": {
185
- const { values, positionals } = parseVerb(verb, cmd.flags, rest);
186
- const pluginDir = resolve(positionals[0] ?? process.cwd());
187
- for (const r of adaptPlugin(pluginDir, resolveTargets(values.target))) {
188
- console.log(`${ui.ok("adapted")} ${ui.name(r.target)} ${ui.meta(`-> ${r.file}`)}`);
189
- }
190
- return;
241
+ if (res.cliSkipped)
242
+ printCliUnavailableNote(target, `manifests were generated, but nothing was enabled in ${target}.`);
243
+ }
244
+ }
245
+ async function handleUnlink(rest, cmd) {
246
+ const { values, positionals } = parseVerb("unlink", cmd.flags, rest);
247
+ const targets = resolveVerbTargets(values, "unlink");
248
+ const sc = await resolveActionScope(values, "unlink");
249
+ const names = positionals.length > 0 ? positionals : undefined;
250
+ for (const target of targets) {
251
+ const res = unlinkPlugins({ pluginsDir: sc.pluginsDir, target, global: sc.global, names });
252
+ for (const name of res.unlinked)
253
+ console.log(`${ui.ok("unlinked")} ${ui.name(name)} ${ui.meta(`[${res.target}]`)}`);
254
+ if (res.cliSkipped) {
255
+ printCliUnavailableNote(target, `nothing was unlinked from ${target}.`);
191
256
  }
192
- case "validate": {
193
- const { positionals } = parseVerb(verb, cmd.flags, rest);
194
- const pluginDir = resolve(positionals[0] ?? process.cwd());
195
- const res = validatePlugin(pluginDir);
196
- if (res.ok) {
197
- console.log(`${ui.ok("ok:")} ${ui.name(pluginDir)} is a valid ADG plugin`);
198
- }
199
- else {
200
- console.error(`${ui.err("invalid:")} ${ui.name(pluginDir)}`);
201
- for (const i of res.issues)
202
- console.error(ui.warn(` - ${i}`));
203
- process.exit(1);
204
- }
205
- return;
257
+ else if (res.unlinked.length === 0 && targets.length === 1) {
258
+ console.log(ui.meta(`nothing to unlink from ${target}`));
206
259
  }
207
- case "add": {
208
- const { values, positionals } = parseVerb(verb, cmd.flags, rest);
209
- const spec = positionals[0];
210
- if (!spec)
211
- fail("plugins add requires a <plugin-dir | owner/repo[@ref] | github-url>");
212
- const tty = process.stdin.isTTY;
213
- // Scope: honor an explicit --dir/--global/--project, else ask in a terminal
214
- // (defaulting to project non-interactively).
215
- let global = Boolean(values.global);
216
- if (!values.dir && values.global === undefined && values.project === undefined && tty) {
217
- global = await selectScopeInteractive();
218
- }
219
- // Guard the home==global trap: installing global plugins at project scope
220
- // would pin them to the cwd. Skip for an explicit --dir store.
221
- if (!values.dir)
222
- global = promoteGlobalTrap(global);
223
- const pluginsDir = values.dir
224
- ? resolve(values.dir)
225
- : global
226
- ? globalPluginsDir()
227
- : projectPluginsDir();
228
- // A source may hold one plugin or a whole marketplace. addPlugins discovers
229
- // all of them; in a terminal the user picks scope, then plugins, then agents,
230
- // then (unless --only/--skill narrow it) chooses what to install per plugin.
231
- // --all / --plugin / --path / --only / --skill narrow non-interactively.
232
- const only = resolveComponents(values.only);
233
- const skillsSubset = values.skill && values.skill.length > 0 ? values.skill : undefined;
234
- const narrowed = only !== undefined || skillsSubset !== undefined;
235
- const { order, installed, removed, converted, agents } = await addPlugins({
236
- spec,
237
- pluginsDir,
238
- ref: values.ref,
239
- sparse: values.sparse,
240
- path: values.path,
260
+ }
261
+ }
262
+ async function handleSync(rest, cmd) {
263
+ const { values, positionals } = parseVerb("sync", cmd.flags, rest);
264
+ const targets = resolveVerbTargets(values, "sync");
265
+ const sc = await resolveActionScope(values, "sync");
266
+ const names = positionals.length > 0 ? positionals : undefined;
267
+ for (const target of targets) {
268
+ const res = syncPlugins({ pluginsDir: sc.pluginsDir, target, global: sc.global, names });
269
+ for (const action of res.actions) {
270
+ const tail = action.synced ? ui.meta(` -> ${res.target}`) : "";
271
+ console.log(`${ui.ok("synced")} ${ui.name(action.name)} ${ui.meta(`[${res.target}]`)}${tail}`);
272
+ }
273
+ if (res.cliSkipped)
274
+ printCliUnavailableNote(target, `manifests were regenerated, but nothing was re-synced in ${target}.`);
275
+ }
276
+ }
277
+ async function handleUpdate(rest, cmd) {
278
+ const { values, positionals } = parseVerb("update", cmd.flags, rest);
279
+ const source = positionals[0];
280
+ for (const sc of await resolveUpdateScopes(values)) {
281
+ if (sc.heading)
282
+ console.log(`${ui.name(sc.heading)}`);
283
+ try {
284
+ const result = await updatePlugins({
285
+ pluginsDir: sc.dir,
286
+ source,
241
287
  all: values.all,
242
- plugins: values.plugin,
243
- only,
244
- skillsSubset,
245
- withDeps: !values["no-deps"],
246
- marketplaceName: values["marketplace-name"],
247
- targets: values.target !== undefined ? resolveTargets(values.target) : undefined,
248
- selectPlugins: tty ? selectPluginsInteractive : undefined,
249
- selectTargets: tty && values.target === undefined ? selectTargetsInteractive : undefined,
250
- confirmFull: tty && !narrowed ? confirmFullInstall : undefined,
251
- selectComponents: tty && !narrowed ? selectComponentsInteractive : undefined,
252
- // Make the install actually usable in the chosen agents, not just stored.
253
288
  activate: true,
254
- scope: global ? "user" : "project",
289
+ agentScope: sc.agentScope,
290
+ scope: { label: sc.label, globalDir: globalPluginsDir() },
255
291
  });
256
- for (const name of converted)
257
- console.log(ui.meta(`converted native manifest -> .agents/.plugin.json: ${name}`));
258
- for (const name of removed)
259
- console.log(`${ui.warn("removed")} ${ui.name(name)}`);
260
- if (order.length > 1)
261
- console.log(ui.meta(`install order: ${order.join(" -> ")}`));
262
- for (const res of installed) {
263
- console.log(`${ui.ok("added")} ${ui.name(res.name)} ${ui.meta(`-> ${res.installedTo}`)}`);
264
- console.log(ui.meta(` sourceHash: ${res.sourceHash}`));
265
- console.log(ui.meta(` installedHash: ${res.installedHash}`));
266
- for (const f of res.adapted)
267
- console.log(ui.meta(` adapted: ${f}`));
268
- }
269
- for (const line of renderAgentReport(agents, "enabled"))
270
- console.log(line);
292
+ printUpdateReport(result);
293
+ }
294
+ catch (err) {
295
+ console.error(`${ui.err("error:")} ${err instanceof Error ? err.message : String(err)}`);
296
+ }
297
+ }
298
+ }
299
+ async function runPluginsVerb(verb, rest, cmd) {
300
+ if (await handleCorePluginVerb(verb, rest, cmd))
301
+ return;
302
+ switch (verb) {
303
+ case "add": {
304
+ await handleAdd(rest, cmd);
271
305
  return;
272
306
  }
273
307
  case "import-skills": {
@@ -289,23 +323,7 @@ async function runPluginsVerb(verb, rest, cmd) {
289
323
  return;
290
324
  }
291
325
  case "link": {
292
- const { values, positionals } = parseVerb(verb, cmd.flags, rest);
293
- const targets = values.target === "all"
294
- ? resolveTargets("all")
295
- : [requireSingleTarget(values.target, "link")];
296
- const sc = await resolveActionScope(values, "link");
297
- const names = positionals.length > 0 ? positionals : undefined;
298
- for (const target of targets) {
299
- const res = linkPlugins({ pluginsDir: sc.pluginsDir, target, global: sc.global, names });
300
- for (const a of res.actions) {
301
- console.log(`${ui.ok("linked")} ${ui.name(a.name)} ${ui.meta(`[${res.target}]`)}${a.linkedTo ? ui.meta(` -> ${a.linkedTo}`) : ""}`);
302
- for (const f of a.adapted)
303
- console.log(ui.meta(` adapted: ${f}`));
304
- }
305
- if (res.cliSkipped) {
306
- console.log(ui.warn(`note: \`${target}\` CLI not found — manifests were generated, but nothing was enabled in ${target}.`));
307
- }
308
- }
326
+ await handleLink(rest, cmd);
309
327
  return;
310
328
  }
311
329
  case "disable":
@@ -331,67 +349,15 @@ async function runPluginsVerb(verb, rest, cmd) {
331
349
  return;
332
350
  }
333
351
  case "unlink": {
334
- const { values, positionals } = parseVerb(verb, cmd.flags, rest);
335
- const targets = values.target === "all"
336
- ? resolveTargets("all")
337
- : [requireSingleTarget(values.target, "unlink")];
338
- const sc = await resolveActionScope(values, "unlink");
339
- const names = positionals.length > 0 ? positionals : undefined;
340
- for (const target of targets) {
341
- const res = unlinkPlugins({ pluginsDir: sc.pluginsDir, target, global: sc.global, names });
342
- for (const name of res.unlinked)
343
- console.log(`${ui.ok("unlinked")} ${ui.name(name)} ${ui.meta(`[${res.target}]`)}`);
344
- if (res.cliSkipped) {
345
- console.log(ui.warn(`note: \`${target}\` CLI not found — nothing was unlinked from ${target}.`));
346
- }
347
- else if (res.unlinked.length === 0) {
348
- if (targets.length === 1) {
349
- console.log(ui.meta(`nothing to unlink from ${target}`));
350
- }
351
- }
352
- }
352
+ await handleUnlink(rest, cmd);
353
353
  return;
354
354
  }
355
355
  case "sync": {
356
- const { values, positionals } = parseVerb(verb, cmd.flags, rest);
357
- const targets = values.target === "all"
358
- ? resolveTargets("all")
359
- : [requireSingleTarget(values.target, "sync")];
360
- const sc = await resolveActionScope(values, "sync");
361
- const names = positionals.length > 0 ? positionals : undefined;
362
- for (const target of targets) {
363
- const res = syncPlugins({ pluginsDir: sc.pluginsDir, target, global: sc.global, names });
364
- for (const a of res.actions) {
365
- const tail = a.synced ? ui.meta(` -> ${res.target}`) : "";
366
- console.log(`${ui.ok("synced")} ${ui.name(a.name)} ${ui.meta(`[${res.target}]`)}${tail}`);
367
- }
368
- if (res.cliSkipped) {
369
- console.log(ui.warn(`note: \`${target}\` CLI not found — manifests were regenerated, but nothing was re-synced in ${target}.`));
370
- }
371
- }
356
+ await handleSync(rest, cmd);
372
357
  return;
373
358
  }
374
359
  case "update": {
375
- const { values, positionals } = parseVerb(verb, cmd.flags, rest);
376
- const source = positionals[0];
377
- for (const sc of await resolveUpdateScopes(values)) {
378
- if (sc.heading)
379
- console.log(`${ui.name(sc.heading)}`);
380
- try {
381
- const result = await updatePlugins({
382
- pluginsDir: sc.dir,
383
- source,
384
- all: values.all,
385
- activate: true,
386
- agentScope: sc.agentScope,
387
- scope: { label: sc.label, globalDir: globalPluginsDir() },
388
- });
389
- printUpdateReport(result);
390
- }
391
- catch (err) {
392
- console.error(`${ui.err("error:")} ${err instanceof Error ? err.message : String(err)}`);
393
- }
394
- }
360
+ await handleUpdate(rest, cmd);
395
361
  return;
396
362
  }
397
363
  case "remove": {
@@ -428,33 +394,6 @@ async function runPluginsVerb(verb, rest, cmd) {
428
394
  }
429
395
  return;
430
396
  }
431
- case "list": {
432
- const { values } = parseVerb(verb, cmd.flags, rest);
433
- const pluginsDir = resolveScopeDir(values);
434
- const plugins = listPlugins(pluginsDir);
435
- if (values.json) {
436
- printJson(pluginsListJson(plugins, pluginsDir));
437
- return;
438
- }
439
- for (const line of renderPluginList(plugins, pluginsDir, { verbose: values.verbose })) {
440
- console.log(line);
441
- }
442
- return;
443
- }
444
- case "status": {
445
- const { values } = parseVerb(verb, cmd.flags, rest);
446
- const targets = resolveTargets(values.target);
447
- const pluginsDir = resolveScopeDir(values);
448
- const scope = scopeOf(values);
449
- const statuses = pluginStatus({ pluginsDir, scope, targets });
450
- if (values.json) {
451
- printJson(pluginsStatusJson(statuses, pluginsDir, scope, targets));
452
- return;
453
- }
454
- for (const line of renderStatus(statuses))
455
- console.log(line);
456
- return;
457
- }
458
397
  case "migrate": {
459
398
  const { values } = parseVerb(verb, cmd.flags, rest);
460
399
  const sc = await resolveActionScope(values, "migrate");
@@ -556,9 +495,7 @@ async function runMarketplace(args) {
556
495
  const source = positionals[0];
557
496
  if (!source)
558
497
  fail("marketplace sync requires a <source>");
559
- const targets = values.target === "all"
560
- ? resolveTargets("all")
561
- : [requireSingleTarget(values.target, "marketplace sync")];
498
+ const targets = resolveVerbTargets(values, "marketplace sync");
562
499
  const sc = await resolveActionScope(values, "marketplace sync");
563
500
  for (const target of targets) {
564
501
  const res = marketplaceSync({
@@ -572,7 +509,7 @@ async function runMarketplace(args) {
572
509
  console.log(`${ui.ok("synced")} ${ui.name(a.name)} ${ui.meta(`[${res.target}]`)}${a.synced ? ui.meta(` -> ${res.target}`) : ""}`);
573
510
  }
574
511
  if (res.cliSkipped) {
575
- console.log(ui.warn(`note: \`${target}\` CLI not found — manifests were regenerated, but nothing was re-synced in ${target}.`));
512
+ printCliUnavailableNote(target, `manifests were regenerated, but nothing was re-synced in ${target}.`);
576
513
  }
577
514
  }
578
515
  return;
@@ -597,7 +534,8 @@ async function runCache(args) {
597
534
  if (status.entries.length === 0)
598
535
  console.log(ui.meta("cache is empty"));
599
536
  for (const entry of status.entries) {
600
- console.log(`${entry.orphan ? ui.warn("orphan") : ui.ok("cached")} ${ui.name(entry.name)} ${ui.meta(`${entry.bytes} bytes`)}`);
537
+ const label = entry.orphan ? ui.warn("orphan") : entry.recovery === "present" ? ui.ok("cached") : ui.warn(entry.recovery ?? "cached");
538
+ console.log(`${label} ${ui.name(entry.name)} ${ui.meta(`${entry.bytes} bytes`)}`);
601
539
  }
602
540
  console.log(ui.meta(`total: ${status.totalBytes} bytes`));
603
541
  return;
@@ -618,5 +556,12 @@ async function runCache(args) {
618
556
  console.log(ui.ok("cache cleaned"));
619
557
  return;
620
558
  }
559
+ if (sub === "restore") {
560
+ const { values, positionals } = parseVerb("cache", [...SCOPE], rest);
561
+ const scope = await resolveActionScope(values, "cache restore");
562
+ const restored = restorePluginCache(scope.pluginsDir, positionals);
563
+ console.log(restored.length > 0 ? `${ui.ok("restored")} ${restored.join(", ")}` : ui.meta("no source snapshots to restore"));
564
+ return;
565
+ }
621
566
  fail(`unknown cache subcommand: ${sub}`);
622
567
  }
@@ -8,7 +8,7 @@ export const FLAGS = {
8
8
  // Short flags are first-letter aliases. Where several long flags share a
9
9
  // first letter, the highest-frequency one wins the short and the rest stay
10
10
  // long-only: d → dir (not description) a → all (not author/as)
11
- // s → skill (not sparse) p → plugin (not path/project/prefix)
11
+ // s → skill (not sparse) p → plugin (not project/prefix)
12
12
  dir: { type: "string", short: "d", hint: "<dir>", help: "install into an explicit directory" },
13
13
  global: { type: "boolean", short: "g", help: "use ~/.agents/plugins (across all projects)" },
14
14
  project: { type: "boolean", help: "use <repo>/.agents/plugins (default)" },
@@ -16,7 +16,6 @@ export const FLAGS = {
16
16
  all: { type: "boolean", short: "a", help: "select all available plugins" },
17
17
  plugin: { type: "string", short: "p", multiple: true, hint: "<name>", help: "select a specific plugin (repeatable)" },
18
18
  "no-deps": { type: "boolean", short: "n", help: "don't install dependencies" },
19
- path: { type: "string", hint: "<subdir>", help: "install only this subdir of the source" },
20
19
  ref: { type: "string", short: "r", hint: "<ref>", help: "pin a git ref (branch/tag/sha)" },
21
20
  sparse: { type: "string", multiple: true, hint: "<path>", help: "sparse-checkout path (repeatable)" },
22
21
  "marketplace-name": { type: "string", hint: "<name>", help: "override the marketplace key" },
@@ -25,8 +24,9 @@ export const FLAGS = {
25
24
  author: { type: "string", hint: "<name>", help: "plugin author" },
26
25
  type: { type: "string", hint: "plugin|marketplace|all", help: "init: which .agents/ artifact to scaffold (default plugin)" },
27
26
  skill: { type: "string", short: "s", multiple: true, hint: "<name>", help: "skill name (init: seed one · add: limit to these)" },
27
+ mcp: { type: "string", short: "m", multiple: true, hint: "<name>", help: "MCP server name (add: limit to these)" },
28
28
  only: { type: "string", hint: "<types>", help: "limit to these component types (skills,agents,commands,mcp,hooks,apps)" },
29
- as: { type: "string", hint: "<name>", help: "plugin name to wrap the skills as" },
29
+ as: { type: "string", hint: "<name>", help: "installed identity for a manifest-free structural source" },
30
30
  prefix: { type: "string", hint: "<p>", help: "prefix imported skill names" },
31
31
  verbose: { type: "boolean", short: "v", help: "expand each component to its member names" },
32
32
  json: { type: "boolean", help: "print stable machine-readable JSON" },
@@ -49,12 +49,13 @@ export const PLUGIN_COMMANDS = {
49
49
  blurb: "In a terminal, add guides you through: scope → plugins → agents → what to install.\n" +
50
50
  "By default it installs everything; choose 'No, let me choose' to pick components,\n" +
51
51
  "or pass the flags below to skip any prompt (e.g. for scripts/CI).",
52
- flags: ["all", "plugin", "only", "skill", "target", "no-deps", "path", "ref", "sparse", "marketplace-name", ...SCOPE],
52
+ flags: ["all", "plugin", "only", "skill", "mcp", "target", "no-deps", "ref", "sparse", "marketplace-name", "as", ...SCOPE],
53
53
  examples: [
54
54
  "adg plugins add owner/repo # guided",
55
55
  "adg plugins add owner/repo --all --global # all plugins, global, non-interactive",
56
56
  "adg plugins add owner/repo --only skills # expose only the skills",
57
57
  "adg plugins add owner/repo --skill brainstorming --skill writing-plans",
58
+ "adg plugins add owner/repo --mcp server-name",
58
59
  ],
59
60
  start: true,
60
61
  },
@@ -126,6 +127,12 @@ export const PLUGIN_COMMANDS = {
126
127
  positional: "<dir> plugin directory (default: current directory)",
127
128
  flags: [],
128
129
  },
130
+ inspect: {
131
+ summary: "inspect a plugin source without installing it",
132
+ synopsis: "adg plugins inspect [<source>] [--ref <ref>]",
133
+ positional: "<source> local directory or owner/repo[@ref] (default: current directory)",
134
+ flags: ["json", "ref"],
135
+ },
129
136
  "import-skills": {
130
137
  summary: "wrap an existing skills/ dir as a plugin",
131
138
  synopsis: "adg plugins import-skills <skills-dir> --as <name>",
@@ -225,6 +232,9 @@ Commands:
225
232
  Show cached snapshots, byte sizes, and orphan state.
226
233
  adg plugins cache prune [--global | --project | --dir <dir>]
227
234
  Delete snapshots that have no corresponding lock entry.
235
+ adg plugins cache restore [name...] [--global | --project | --dir <dir>]
236
+ Restore missing snapshots from a verified legacy cache, local source, or
237
+ the exact remote revision recorded in the lock.
228
238
  adg plugins cache clean --force [--global | --project | --dir <dir>]
229
239
  Delete every source snapshot for the selected store. A later update or
230
240
  add may be required before link/sync can rebuild remote plugins.`;