@rbbtsn0w/adg 0.11.0 → 0.11.1-dev.pr200.c6ce45e

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 (59) hide show
  1. package/README.md +131 -73
  2. package/dist/src/agents/antigravity.js +218 -45
  3. package/dist/src/agents/base.js +1 -1
  4. package/dist/src/agents/claude.js +98 -38
  5. package/dist/src/agents/codex.js +32 -42
  6. package/dist/src/cli/core-plugin-handlers.js +3 -3
  7. package/dist/src/cli/handlers.js +171 -39
  8. package/dist/src/cli/index.js +23 -14
  9. package/dist/src/cli/review-update.js +80 -0
  10. package/dist/src/commands/install/default-dsl.js +1 -1
  11. package/dist/src/commands/install/discovery.js +3 -1
  12. package/dist/src/commands/install/install-one.js +41 -31
  13. package/dist/src/commands/install.js +59 -24
  14. package/dist/src/commands/marketplace.js +171 -115
  15. package/dist/src/commands/migrate.js +2 -2
  16. package/dist/src/commands/projection.js +3 -1
  17. package/dist/src/commands/remove.js +10 -0
  18. package/dist/src/commands/review-executables.js +106 -0
  19. package/dist/src/commands/select-agents.js +2 -2
  20. package/dist/src/commands/select-components.js +2 -2
  21. package/dist/src/commands/select-plugins.js +15 -2
  22. package/dist/src/commands/select-scope.js +3 -4
  23. package/dist/src/commands/source-upgrade.js +552 -0
  24. package/dist/src/commands/state.js +3 -1
  25. package/dist/src/commands/status.js +1 -0
  26. package/dist/src/commands/update.js +3 -1
  27. package/dist/src/lock.js +13 -5
  28. package/dist/src/migration-transaction.js +1011 -0
  29. package/dist/src/native-retry.js +329 -0
  30. package/dist/src/process-identity.js +88 -0
  31. package/dist/src/render/plugins.js +149 -27
  32. package/dist/src/render/ui.js +4 -4
  33. package/dist/src/source-history.js +194 -0
  34. package/dist/src/source-intent.js +7 -0
  35. package/dist/src/store-mutex.js +179 -0
  36. package/dist/src/types.js +1 -1
  37. package/dist/src/update-executables.js +193 -0
  38. package/dist/src/upgrade-plan.js +378 -0
  39. package/docs/agents/antigravity.md +5 -0
  40. package/docs/agents-spec.md +10 -0
  41. package/docs/branching-and-release.md +369 -55
  42. package/docs/cli-json.md +9 -0
  43. package/docs/marketing/README.md +211 -0
  44. package/docs/marketing/assets.json +228 -0
  45. package/docs/marketing/capture.json +130 -0
  46. package/docs/marketing/live-readiness.json +353 -0
  47. package/docs/marketing/posts.en.md +94 -0
  48. package/docs/marketing/posts.zh-CN.md +67 -0
  49. package/docs/marketing/production.md +210 -0
  50. package/docs/marketing/source/timeline.json +29 -0
  51. package/docs/marketing/source/workflow-01.svg +16 -0
  52. package/docs/marketing/source/workflow-02.svg +14 -0
  53. package/docs/marketing/source/workflow-03.svg +19 -0
  54. package/docs/marketing/source/workflow-poster.svg +32 -0
  55. package/docs/marketing/transcript.md +48 -0
  56. package/docs/plugin-update-semantics.md +53 -10
  57. package/docs/plugin-upgrade-migrations.md +349 -0
  58. package/package.json +14 -10
  59. package/schemas/plugin-lock.schema.json +78 -1
@@ -1,5 +1,5 @@
1
1
  import { existsSync } from "node:fs";
2
- import { resolve } from "node:path";
2
+ import { dirname, resolve } from "node:path";
3
3
  import { addPlugins } from "../commands/install.js";
4
4
  import { listPlugins } from "../commands/list.js";
5
5
  import { importSkills } from "../commands/import.js";
@@ -12,21 +12,47 @@ import { migrateLayout } from "../commands/migrate.js";
12
12
  import { cleanPluginCache, pluginCacheStatus, prunePluginCache, restorePluginCache } from "../commands/cache.js";
13
13
  import { marketplaceList, marketplaceRemove, marketplaceSync, updatePlugins } from "../commands/marketplace.js";
14
14
  import { confirmFullInstall, selectComponentsInteractive } from "../commands/select-components.js";
15
- import { selectPluginsInteractive } from "../commands/select-plugins.js";
15
+ import { FOLLOW_ALL_PLUGINS, selectPluginsInteractive } from "../commands/select-plugins.js";
16
16
  import { selectTargetsInteractive } from "../commands/select-agents.js";
17
17
  import { selectScopeInteractive, selectUpdateScopeInteractive } from "../commands/select-scope.js";
18
18
  import { globalPluginsDir, projectPluginsDir, lockPath } from "../paths.js";
19
19
  import { getAgent } from "../agents/index.js";
20
20
  import { ui } from "../render/ui.js";
21
21
  import { createProgress, formatUpdateSummary } from "../render/progress.js";
22
- import { renderAgentReport, renderMarketplaceList, renderUpdateReport, } from "../render/plugins.js";
23
- import { CACHE_USAGE, MARKETPLACE_USAGE, PLUGIN_ALIASES, PLUGIN_COMMANDS, SCOPE, fail, parseVerb, renderPluginsHelp, renderVerbHelp, requireSingleTarget, resolveComponents, resolveScopeDir, resolveTargets, scopeOf, wantsHelp, } from "./index.js";
22
+ import { marketplaceListCounts, renderAgentReport, renderMarketplaceList, renderUpdateReport, renderUpdateAgentReport, } from "../render/plugins.js";
23
+ import { CACHE_USAGE, MARKETPLACE_USAGE, PLUGIN_ALIASES, PLUGIN_COMMANDS, SCOPE, fail, parseVerb, renderPluginsHelp, renderVerbHelp, requireSingleTarget, resolveComponents, resolveScopeDir, resolveTargets, scopeOf, wantsHelp, CliUsageError, } from "./index.js";
24
24
  import { handleCorePluginVerb } from "./core-plugin-handlers.js";
25
25
  import { commandOutcome, mergeCommandOutcomes, agentCommandOutcome } from "../command-outcome.js";
26
+ import { recordTelemetryEvent } from "../telemetry.js";
27
+ import { withStoreMutex } from "../store-mutex.js";
28
+ import { discoverPendingMigrations } from "../migration-transaction.js";
29
+ import { UpdateCancelled } from "../commands/source-upgrade.js";
30
+ import { reviewUpdate } from "./review-update.js";
31
+ /** Pending transactions own the selected store until update resumes them. */
32
+ function assertNoPendingMigration(pluginsDir) {
33
+ if (discoverPendingMigrations(pluginsDir).length) {
34
+ throw new Error("A plugin migration is pending. Run `adg plugins update` with the same scope to resume it before making other changes.");
35
+ }
36
+ }
26
37
  export function updateResultCounts(result) {
27
- const failedRemote = result.remote.filter((source) => source.failed !== undefined).length;
28
- // A failed plugin remains one unit even if several stages report diagnostics.
29
- const runtimeFailures = new Set(result.agents.flatMap((agent) => (agent.failures ?? []).map((failure) => JSON.stringify([agent.agent, failure.plugin ?? null, failure.plugin ? null : failure.stage]))));
38
+ const failedRemote = result.remote.filter((source) => source.failed !== undefined || Boolean(source.missingUpstream?.length || source.actionRequired?.length || source.pendingRuntime?.length)).length;
39
+ // Replayed source diagnostics already account for their native failures.
40
+ const sourceMessages = new Set(result.remote.flatMap(source => source.pendingRuntime ?? []));
41
+ const runtimeFailures = new Set(result.agents.flatMap(agent => (agent.failures ?? [])
42
+ .filter(failure => !sourceMessages.has(failure.message))
43
+ .map(failure => JSON.stringify([agent.agent, failure.plugin ?? null, failure.plugin ? null : failure.stage]))));
44
+ const sourceReportedPlugins = new Set(result.agents.flatMap(agent => (agent.failures ?? [])
45
+ .filter(failure => failure.plugin && sourceMessages.has(failure.message))
46
+ .map(failure => JSON.stringify([agent.agent, failure.plugin, null]))));
47
+ for (const agent of result.agents) {
48
+ if (agent.skipped)
49
+ continue;
50
+ for (const plugin of agent.unverified ?? []) {
51
+ const key = JSON.stringify([agent.agent, plugin, null]);
52
+ if (!sourceReportedPlugins.has(key))
53
+ runtimeFailures.add(key);
54
+ }
55
+ }
30
56
  return {
31
57
  succeeded: result.remote.length - failedRemote +
32
58
  result.local.results.length,
@@ -53,7 +79,7 @@ async function resolveUpdateScopes(values) {
53
79
  choice = "global";
54
80
  else if (values.project)
55
81
  choice = "project";
56
- else if (process.stdin.isTTY)
82
+ else if (process.stdin.isTTY && !values.json)
57
83
  choice = await selectUpdateScopeInteractive();
58
84
  else
59
85
  choice = existsSync(lockPath(projectPluginsDir())) ? "project" : "global";
@@ -70,10 +96,14 @@ async function resolveUpdateScopes(values) {
70
96
  return [choice === "global" ? global : project];
71
97
  }
72
98
  /** Render an update/upgrade result: per-source changes, then per-agent re-sync. */
73
- function printUpdateReport(result) {
74
- for (const line of renderUpdateReport(result))
99
+ function printUpdateReport(result, verbose = false, retryCommand) {
100
+ for (const line of renderUpdateReport(result, { verbose, retryCommand }))
75
101
  console.log(line);
76
- for (const line of renderAgentReport(result.agents, "re-synced"))
102
+ for (const line of renderUpdateAgentReport(result.agents, {
103
+ verbose,
104
+ retryCommand,
105
+ reportedFailures: result.remote.flatMap(source => source.pendingRuntime ?? []),
106
+ }))
77
107
  console.log(line);
78
108
  }
79
109
  /**
@@ -110,6 +140,11 @@ export function promoteGlobalTrap(global, projectDir = projectPluginsDir(), glob
110
140
  * - promotes the home==global trap to global with a warning.
111
141
  */
112
142
  async function resolveActionScope(values, verb) {
143
+ const scope = await resolveActionScopeUnchecked(values, verb);
144
+ assertNoPendingMigration(scope.pluginsDir);
145
+ return scope;
146
+ }
147
+ async function resolveActionScopeUnchecked(values, verb) {
113
148
  if (typeof values.dir === "string") {
114
149
  // --dir is an explicit ad-hoc store; --global still selects the user agent
115
150
  // scope (matching the old scopeOf behavior), the trap guard doesn't apply.
@@ -124,7 +159,7 @@ async function resolveActionScope(values, verb) {
124
159
  global = true;
125
160
  else if (values.project)
126
161
  global = false;
127
- else if (process.stdin.isTTY)
162
+ else if (process.stdin.isTTY && !values.json)
128
163
  global = await selectScopeInteractive();
129
164
  else
130
165
  fail(`plugins ${verb} needs an explicit scope in a non-interactive run: pass --global or --project`);
@@ -155,6 +190,33 @@ function printCliUnavailableNote(target, message) {
155
190
  * dispatch surface is unit-testable.
156
191
  */
157
192
  export async function runPlugins(rawVerb, rest) {
193
+ const verb = rawVerb ? PLUGIN_ALIASES[rawVerb] ?? rawVerb : undefined;
194
+ const readOnly = !verb || ["help", "-h", "--help", "list", "status", "validate", "inspect"].includes(verb)
195
+ || wantsHelp(rest)
196
+ || (verb === "marketplace" && (!rest[0] || ["help", "list"].includes(rest[0])))
197
+ || (verb === "cache" && (!rest[0] || ["help", "status"].includes(rest[0])));
198
+ try {
199
+ if (readOnly)
200
+ return await dispatchPlugins(rawVerb, rest);
201
+ return await withStoreMutex(projectPluginsDir(), async () => {
202
+ // Prune operates across native registries rather than one chosen store.
203
+ if (verb === "prune") {
204
+ assertNoPendingMigration(projectPluginsDir());
205
+ assertNoPendingMigration(globalPluginsDir());
206
+ }
207
+ return await dispatchPlugins(rawVerb, rest);
208
+ });
209
+ }
210
+ catch (error) {
211
+ if (error instanceof CliUsageError)
212
+ return commandOutcome("failure", "user");
213
+ if (!(error instanceof UpdateCancelled))
214
+ throw error;
215
+ console.error(ui.warn("Cancelled; no further changes were made."));
216
+ return commandOutcome("cancelled");
217
+ }
218
+ }
219
+ async function dispatchPlugins(rawVerb, rest) {
158
220
  // `adg plugins` (no verb) or an explicit help request → the L1 overview.
159
221
  if (rawVerb === undefined || rawVerb === "-h" || rawVerb === "--help" || rawVerb === "help") {
160
222
  console.log(renderPluginsHelp());
@@ -192,7 +254,7 @@ async function handleAdd(rest, cmd) {
192
254
  const spec = positionals[0];
193
255
  if (!spec)
194
256
  fail("plugins add requires a <plugin-dir | owner/repo[@ref] | github-url>");
195
- const tty = process.stdin.isTTY;
257
+ const tty = process.stdin.isTTY && !values.json;
196
258
  let global = Boolean(values.global);
197
259
  if (!values.dir && values.global === undefined && values.project === undefined && tty) {
198
260
  global = await selectScopeInteractive();
@@ -204,11 +266,13 @@ async function handleAdd(rest, cmd) {
204
266
  : global
205
267
  ? globalPluginsDir()
206
268
  : projectPluginsDir();
269
+ assertNoPendingMigration(pluginsDir);
270
+ let followExplicit = false;
207
271
  const only = resolveComponents(values.only);
208
272
  const skillsSubset = values.skill && values.skill.length > 0 ? values.skill : undefined;
209
273
  const mcpSubset = values.mcp && values.mcp.length > 0 ? values.mcp : undefined;
210
274
  const narrowed = only !== undefined || skillsSubset !== undefined || mcpSubset !== undefined;
211
- const { order, installed, removed, converted, agents } = await addPlugins({
275
+ const result = await addPlugins({
212
276
  spec,
213
277
  pluginsDir,
214
278
  ref: values.ref,
@@ -222,7 +286,15 @@ async function handleAdd(rest, cmd) {
222
286
  marketplaceName: values["marketplace-name"],
223
287
  as: values.as,
224
288
  targets: values.target !== undefined ? resolveTargets(values.target) : undefined,
225
- selectPlugins: tty ? selectPluginsInteractive : undefined,
289
+ selectPlugins: tty ? async (choices) => {
290
+ const selected = await selectPluginsInteractive(choices);
291
+ if (selected.includes(FOLLOW_ALL_PLUGINS)) {
292
+ followExplicit = true;
293
+ return choices.map(choice => choice.name);
294
+ }
295
+ return selected;
296
+ } : undefined,
297
+ get followAllSelected() { return followExplicit; },
226
298
  selectTargets: tty && values.target === undefined ? selectTargetsInteractive : undefined,
227
299
  confirmFull: tty && !narrowed ? confirmFullInstall : undefined,
228
300
  selectComponents: tty && !narrowed ? selectComponentsInteractive : undefined,
@@ -230,18 +302,25 @@ async function handleAdd(rest, cmd) {
230
302
  nonInteractive: !tty,
231
303
  scope: global ? "user" : "project",
232
304
  });
305
+ const { order, installed, removed, converted, agents } = result;
306
+ if (values.json) {
307
+ console.log(JSON.stringify({ schemaVersion: "adg.plugins.add/v1", ...result }));
308
+ return runtimeOutcome(agents);
309
+ }
233
310
  for (const name of converted)
234
311
  console.log(ui.meta(`converted native manifest -> .agents/.plugin.json: ${name}`));
235
312
  for (const name of removed)
236
313
  console.log(`${ui.warn("removed")} ${ui.name(name)}`);
237
- if (order.length > 1)
314
+ if (values.verbose && order.length > 1)
238
315
  console.log(ui.meta(`install order: ${order.join(" -> ")}`));
239
316
  for (const res of installed) {
240
317
  console.log(`${ui.ok("added")} ${ui.name(res.name)} ${ui.meta(`-> ${res.installedTo}`)}`);
241
- console.log(ui.meta(` sourceHash: ${res.sourceHash}`));
242
- console.log(ui.meta(` installedHash: ${res.installedHash}`));
243
- for (const f of res.adapted)
244
- console.log(ui.meta(` adapted: ${f}`));
318
+ if (values.verbose) {
319
+ console.log(ui.meta(` sourceHash: ${res.sourceHash}`));
320
+ console.log(ui.meta(` installedHash: ${res.installedHash}`));
321
+ for (const file of res.adapted)
322
+ console.log(ui.meta(` adapted: ${file}`));
323
+ }
245
324
  }
246
325
  for (const line of renderAgentReport(agents, "enabled"))
247
326
  console.log(line);
@@ -321,12 +400,33 @@ async function handleSync(rest, cmd) {
321
400
  async function runUpdateAcrossScopes(values, opts) {
322
401
  let succeeded = 0;
323
402
  let failed = 0;
403
+ let cancelled = false;
404
+ const scopes = [];
324
405
  for (const sc of await resolveUpdateScopes(values)) {
325
- if (sc.heading)
406
+ if (sc.heading && !values.json)
326
407
  console.log(`${ui.name(sc.heading)}`);
327
- const progress = createProgress();
408
+ const progress = createProgress(values.json ? { stream: { write() { } }, isTTY: false } : {});
409
+ const reportResult = (result, interrupted = false) => {
410
+ scopes.push({ scope: sc.label, result, ...(interrupted ? { cancelled: true } : {}) });
411
+ const quote = (value) => `'${value.replaceAll("'", "'\\''")}'`;
412
+ const scopeFlag = typeof values.dir === "string" ? `--dir ${quote(sc.dir)}` : sc.agentScope === "user" ? "--global" : "--project";
413
+ const target = typeof values.target === "string" ? values.target : undefined;
414
+ const retryVerb = target ? "marketplace upgrade" : "update";
415
+ const retryCommand = `adg plugins ${retryVerb}${opts.source ? ` ${quote(opts.source)}` : ""} ${scopeFlag}${values.all ? " --all" : ""}${values.repair ? " --repair" : ""}${target ? ` --target ${quote(target)}` : ""}`;
416
+ const hasCompletedWork = result.remote.length || result.local.results.length || result.local.missing.length || result.agents.length;
417
+ if (!values.json && (!interrupted || hasCompletedWork))
418
+ printUpdateReport(result, values.verbose, retryCommand);
419
+ const counts = updateResultCounts(result);
420
+ if (!values.json && (!interrupted || hasCompletedWork)) {
421
+ const awaitingReview = result.remote.filter(source => source.actionRequired?.length).length;
422
+ const summary = formatUpdateSummary({ succeeded: counts.succeeded, failed: counts.failed - awaitingReview }, progress.elapsedMs());
423
+ console.log(`${summary}${awaitingReview ? ui.warn(` · ${awaitingReview} awaiting review`) : ""}`);
424
+ }
425
+ succeeded += counts.succeeded;
426
+ failed += counts.failed;
427
+ };
328
428
  try {
329
- const result = await updatePlugins({
429
+ const result = await withStoreMutex(sc.dir, () => updatePlugins({
330
430
  pluginsDir: sc.dir,
331
431
  source: opts.source,
332
432
  all: values.all,
@@ -335,23 +435,36 @@ async function runUpdateAcrossScopes(values, opts) {
335
435
  agentScope: sc.agentScope,
336
436
  scope: { label: sc.label, globalDir: globalPluginsDir() },
337
437
  targets: opts.targets,
338
- onProgress: (phase) => progress.update(phase),
339
- });
340
- // Clear the animated line before the report goes to stdout, so the two
341
- // streams don't interleave mid-line.
438
+ review: process.stdin.isTTY && !values.json ? async (review) => {
439
+ progress.stop();
440
+ return reviewUpdate(review);
441
+ } : undefined,
442
+ onProgress: values.json ? undefined : phase => progress.update(phase),
443
+ }));
342
444
  progress.stop();
343
- printUpdateReport(result);
344
- const counts = updateResultCounts(result);
345
- console.log(formatUpdateSummary(counts, progress.elapsedMs()));
346
- succeeded += counts.succeeded;
347
- failed += counts.failed;
445
+ reportResult(result);
348
446
  }
349
- catch (err) {
447
+ catch (error) {
350
448
  progress.stop();
351
- console.error(`${ui.err("error:")} ${err instanceof Error ? err.message : String(err)}`);
449
+ if (error instanceof UpdateCancelled) {
450
+ cancelled = true;
451
+ if (error.partial)
452
+ reportResult(error.partial, true);
453
+ if (!values.json)
454
+ console.error(ui.warn("Update cancelled; completed changes are kept. Remaining updates were not run."));
455
+ break;
456
+ }
457
+ const message = error instanceof Error ? error.message : String(error);
458
+ scopes.push({ scope: sc.label, error: message });
459
+ if (!values.json)
460
+ console.error(`${ui.err("error:")} ${message}`);
352
461
  failed += 1;
353
462
  }
354
463
  }
464
+ if (values.json)
465
+ console.log(JSON.stringify({ schemaVersion: "adg.plugins.update/v1", scopes, summary: { succeeded, failed }, cancelled }));
466
+ if (cancelled)
467
+ return commandOutcome("cancelled");
355
468
  if (failed === 0)
356
469
  return commandOutcome("success");
357
470
  return commandOutcome(succeeded > 0 ? "partial" : "failure", "dependency");
@@ -360,10 +473,22 @@ async function handleUpdate(rest, cmd) {
360
473
  const { values, positionals } = parseVerb("update", cmd.flags, rest);
361
474
  // First paint, before the scope prompt and before any lock read, so the run
362
475
  // never opens on a blank screen. stderr keeps stdout to the report alone.
363
- process.stderr.write(`${ui.title("adg plugins update")}\n`);
476
+ if (!values.json)
477
+ process.stderr.write(`${ui.title("adg plugins update")}\n`);
364
478
  return runUpdateAcrossScopes(values, { source: positionals[0] });
365
479
  }
366
480
  async function runPluginsVerb(verb, rest, cmd) {
481
+ if (verb === "adapt" || verb === "init") {
482
+ const { values, positionals } = parseVerb(verb, cmd.flags, rest);
483
+ let target = verb === "adapt" ? resolve(positionals[0] ?? process.cwd()) : resolve(values.dir ?? "plugins");
484
+ for (;;) {
485
+ assertNoPendingMigration(target);
486
+ const parent = dirname(target);
487
+ if (parent === target)
488
+ break;
489
+ target = parent;
490
+ }
491
+ }
367
492
  if (await handleCorePluginVerb(verb, rest, cmd))
368
493
  return;
369
494
  switch (verb) {
@@ -490,10 +615,17 @@ async function runMarketplace(args) {
490
615
  const { values } = parseVerb("marketplace", ["verbose", ...SCOPE], rest);
491
616
  const dir = resolveScopeDir(values);
492
617
  const groups = marketplaceList({ pluginsDir: dir });
493
- // Verbose: drill each plugin down to its components (reuses `plugins list -v`).
494
- const byName = values.verbose ? new Map(listPlugins(dir).map((p) => [p.name, p])) : undefined;
495
- for (const line of renderMarketplaceList(groups, byName))
618
+ const scope = typeof values.dir === "string" ? "directory" : values.global ? "global" : "project";
619
+ const scopeLabel = scope === "directory" ? `Directory ${dir}` : scope === "global" ? "Global" : "Project";
620
+ const verbose = Boolean(values.verbose);
621
+ const details = verbose ? new Map(listPlugins(dir).map((p) => [p.name, p])) : undefined;
622
+ for (const line of renderMarketplaceList(groups, { scope: scopeLabel, details }))
496
623
  console.log(line);
624
+ const { sources, installed, enabled, disabled } = marketplaceListCounts(groups);
625
+ recordTelemetryEvent("adg.plugins.marketplace.list", {
626
+ scope, verbose, "source.count": sources, "plugin.installed.count": installed,
627
+ "plugin.enabled.count": enabled, "plugin.disabled.count": disabled,
628
+ });
497
629
  return commandOutcome("success");
498
630
  }
499
631
  case "upgrade": {
@@ -502,7 +634,7 @@ async function runMarketplace(args) {
502
634
  // and error handling) so the alias can't drift from the verb it aliases.
503
635
  // `--target` narrows the runtimes.
504
636
  console.error(ui.warn("note: `marketplace upgrade` is a deprecated alias for `adg plugins update`."));
505
- const { values, positionals } = parseVerb("marketplace", ["all", "target", ...SCOPE], rest);
637
+ const { values, positionals } = parseVerb("marketplace", ["all", "repair", "target", "verbose", "json", ...SCOPE], rest);
506
638
  const targets = values.target !== undefined ? resolveTargets(values.target) : undefined;
507
639
  return runUpdateAcrossScopes(values, { source: positionals[0], targets });
508
640
  }
@@ -28,7 +28,7 @@ export const FLAGS = {
28
28
  only: { type: "string", hint: "<types>", help: "limit to these component types (skills,agents,commands,mcp,hooks,apps)" },
29
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
- verbose: { type: "boolean", short: "v", help: "expand each component to its member names" },
31
+ verbose: { type: "boolean", short: "v", help: "show detailed component and update information" },
32
32
  repair: { type: "boolean", help: "repair missing Codex registrations after updating; preserve runtime-disabled plugins" },
33
33
  json: { type: "boolean", help: "print stable machine-readable JSON" },
34
34
  };
@@ -49,8 +49,10 @@ export const PLUGIN_COMMANDS = {
49
49
  positional: "<source> = <local-dir> | <owner/repo[@ref]> | <github-url>",
50
50
  blurb: "In a terminal, add guides you through: scope → plugins → agents → what to install.\n" +
51
51
  "By default it installs everything; choose 'No, let me choose' to pick components,\n" +
52
- "or pass the flags below to skip any prompt (e.g. for scripts/CI).",
53
- flags: ["all", "plugin", "only", "skill", "mcp", "target", "no-deps", "ref", "sparse", "marketplace-name", "as", ...SCOPE],
52
+ "or pass the flags below to skip any prompt (e.g. for scripts/CI).\n" +
53
+ "Choose 'Follow all plugins' or pass --all to subscribe to future additions.\n" +
54
+ "Selecting every plugin manually keeps a selected-plugin subscription.",
55
+ flags: ["all", "plugin", "only", "skill", "mcp", "target", "no-deps", "ref", "sparse", "marketplace-name", "as", "verbose", "json", ...SCOPE],
54
56
  examples: [
55
57
  "adg plugins add owner/repo # guided",
56
58
  "adg plugins add owner/repo --all --global # all plugins, global, non-interactive",
@@ -88,18 +90,23 @@ export const PLUGIN_COMMANDS = {
88
90
  synopsis: "adg plugins update [<source>]",
89
91
  positional: "<source> limit to one source key from `adg plugins marketplace list` (default: all)",
90
92
  blurb: "Re-fetches every remote source and refreshes the plugins installed from it,\n" +
91
- "reporting what changed, what's unchanged, what was deleted upstream, and what's\n" +
92
- "newly available (install those too with --all). Local-source plugins are\n" +
93
- "rescanned in place. In a terminal, it asks whether to update project, global,\n" +
93
+ "reporting what changed, what's unchanged, what's missing upstream, and what's\n" +
94
+ "newly available (--all includes these once). Local-source plugins are\n" +
95
+ "rescanned in place. ADG follows verified skill relocations and existing\n" +
96
+ "marketplace renames. Missing upstream plugins are retained and can be\n" +
97
+ "reviewed in this update. Skill choices and disabled state are preserved\n" +
98
+ "before old owners are retired.\n" +
99
+ "In a terminal, it asks whether to update project, global,\n" +
94
100
  "or both; pass a scope flag to skip the prompt.\n\n" +
95
- "This is the plugins-domain twin of `adg skills update`.",
96
- flags: ["all", "repair", ...SCOPE],
101
+ "Historical skill restoration is separate from following future plugins.\n" +
102
+ "Use --verbose for details; --json is non-interactive machine output.",
103
+ flags: ["all", "repair", "verbose", "json", ...SCOPE],
97
104
  examples: [
98
105
  "adg plugins update --global --repair # explicitly restore missing Codex registrations",
99
106
  "adg plugins update # guided: project / global / both",
100
107
  "adg plugins update --global # every global source",
101
108
  "adg plugins update owner/repo # just one source",
102
- "adg plugins update owner/repo --all # also install newly-added plugins",
109
+ "adg plugins update owner/repo --all # include current additions once",
103
110
  ],
104
111
  },
105
112
  remove: {
@@ -227,8 +234,8 @@ look back over what you installed.
227
234
 
228
235
  Commands:
229
236
  adg plugins marketplace list [--verbose] [--global | --project | --dir <dir>]
230
- Group installed plugins by source. --verbose expands each plugin to its
231
- components (skills, agents, commands, …).
237
+ Group local installation records by source and show their ADG state.
238
+ --verbose expands each plugin to its components (skills, agents, commands, …).
232
239
  adg plugins marketplace remove <source> [--force] [--global | --project | --dir <dir>]
233
240
  Uninstall every plugin that came from <source>.
234
241
  adg plugins marketplace sync <source> --target <agent> [--global | --project | --dir <dir>]
@@ -308,11 +315,13 @@ export function renderVerbHelp(name) {
308
315
  export function wantsHelp(args) {
309
316
  return args.includes("-h") || args.includes("--help");
310
317
  }
311
- /** Print a top-level usage error and exit non-zero. */
318
+ export class CliUsageError extends Error {
319
+ }
320
+ /** Report invalid usage; the dispatcher returns failure after releasing resources. */
312
321
  export function fail(msg) {
313
322
  console.error(`${ui.err("error:")} ${msg}\n`);
314
323
  console.error(TOP_USAGE);
315
- process.exit(1);
324
+ throw new CliUsageError(msg);
316
325
  }
317
326
  export function resolveScopeDir(values) {
318
327
  if (typeof values.dir === "string")
@@ -373,6 +382,6 @@ export function parseVerb(name, flags, rest) {
373
382
  catch (err) {
374
383
  console.error(`${ui.err("error:")} ${err instanceof Error ? err.message : String(err)}\n`);
375
384
  console.error(renderVerbHelp(name));
376
- process.exit(1);
385
+ throw new CliUsageError(err instanceof Error ? err.message : String(err));
377
386
  }
378
387
  }
@@ -0,0 +1,80 @@
1
+ import * as prompts from "@clack/prompts";
2
+ const labels = {
3
+ restore: { label: "Restore all candidates", hint: "explicitly restore every listed candidate; future plugin subscriptions stay unchanged" },
4
+ keep: { label: "Skip historical restoration", hint: "leave these historical skills unrestored and continue the remaining updates" },
5
+ select: { label: "Choose individual skills", hint: "restore only the skills you select" },
6
+ enabled: { label: "Enable the merged plugin", hint: "enable the combined selection in agent runtimes" },
7
+ disabled: { label: "Keep the merged plugin disabled (Recommended)", hint: "preserve it in the store without activating its contents" },
8
+ drop: { label: "Remove this skill permanently", hint: "no replacement is declared; the old skill will be removed" },
9
+ };
10
+ /** Returns undefined on cancellation; authorization is never implied by a prompt. */
11
+ export async function reviewUpdate(review, ui = {
12
+ select: options => prompts.select(options),
13
+ multiselect: options => prompts.multiselect(options),
14
+ confirm: options => prompts.confirm(options),
15
+ isCancel: prompts.isCancel,
16
+ }) {
17
+ const answer = { history: {}, allow: [] };
18
+ for (const item of review.history) {
19
+ const uncertainSelection = item.uncertain || item.choices.includes("restore");
20
+ const ordered = uncertainSelection
21
+ ? ["keep", "select", "restore", "drop"].filter(action => item.choices.includes(action))
22
+ : item.choices.includes("disabled") ? ["disabled", "enabled"] : item.choices;
23
+ const message = item.id.startsWith("state:")
24
+ ? `${review.source}: resolve enabled and disabled selections for ${item.id.slice(6)}`
25
+ : item.id.startsWith("unmapped:")
26
+ ? `${review.source}: no declared replacement for old plugin ${item.skills.join(", ")}`
27
+ : item.id.startsWith("drop:")
28
+ ? `${review.source}: no replacement for ${item.skills.join(", ")}`
29
+ : item.id.startsWith("ownership:") && !uncertainSelection
30
+ ? `${review.source}: choose a current owner for ${item.skills.join(", ")}`
31
+ : `${review.source}: prior selection of these ${item.skills.length} skill candidates is unknown.\n${item.skills.join(", ")}`;
32
+ const selected = await ui.select({
33
+ message,
34
+ options: ordered.map(action => ({
35
+ value: action,
36
+ ...(item.id.startsWith("unmapped:")
37
+ ? action === "keep"
38
+ ? { label: "Keep the old plugin (Recommended)", hint: "preserve its installed contents and runtime state" }
39
+ : { label: "Remove the old plugin", hint: "explicitly retire this plugin without a declared replacement" }
40
+ : uncertainSelection && action === "keep"
41
+ ? { label: "Keep current selection (Recommended)", hint: "defer these candidates and continue the remaining updates" }
42
+ : labels[action]),
43
+ })),
44
+ initialValue: ordered[0],
45
+ });
46
+ if (ui.isCancel(selected))
47
+ return undefined;
48
+ const action = selected;
49
+ if (!item.choices.includes(action))
50
+ throw new Error(`Invalid migration decision: ${item.id}`);
51
+ let skills;
52
+ if (action === "select") {
53
+ const ownerSelection = item.id.startsWith("ownership:");
54
+ const chosen = await (ownerSelection ? ui.select({
55
+ message: "Choose the current plugin that should own this skill",
56
+ options: item.skills.map(address => ({ value: address, label: address })),
57
+ initialValue: item.skills[0],
58
+ }) : ui.multiselect({
59
+ message: "Choose candidates to restore; their prior selection is unknown (space to toggle)",
60
+ options: item.skills.map(skill => ({ value: skill, label: skill })),
61
+ initialValues: [],
62
+ required: false,
63
+ }));
64
+ if (ui.isCancel(chosen))
65
+ return undefined;
66
+ skills = ownerSelection ? [chosen] : chosen;
67
+ if (!Array.isArray(skills) || skills.some(skill => !item.skills.includes(skill)))
68
+ throw new Error("Invalid historical skill selection");
69
+ }
70
+ answer.history[item.id] = { action, ...(skills ? { skills } : {}) };
71
+ }
72
+ for (const executable of review.executable) {
73
+ const allowed = await ui.confirm({ message: `Allow ${executable.label}?`, initialValue: false });
74
+ if (ui.isCancel(allowed))
75
+ return undefined;
76
+ if (allowed === true)
77
+ answer.allow.push(executable.key);
78
+ }
79
+ return answer;
80
+ }
@@ -23,7 +23,7 @@ export async function synthesizeDefaultDslPlugin(opts, parsed, workRoot, resolve
23
23
  });
24
24
  const authorized = opts.authorizedComponents;
25
25
  const unauthorizedRisk = generated.components.some((c) => (c === "hooks" || c === "mcp") && !authorized?.includes(c));
26
- if (opts.nonInteractive && unauthorizedRisk && opts.only === undefined) {
26
+ if (opts.nonInteractive && unauthorizedRisk && opts.only === undefined && !opts.replaySelection) {
27
27
  throw new Error("default source exposes hooks or MCP; pass --only to explicitly authorize selected components");
28
28
  }
29
29
  const staging = mkdtempSync(join(tmpdir(), "adg-default-plugin-"));
@@ -98,7 +98,9 @@ export function sameRemoteSource(entry, parsed, ref) {
98
98
  * runtime exports behind.
99
99
  */
100
100
  export function reconcileRemotePlugins(opts, parsed, ref, desired) {
101
- if (parsed.kind === "local")
101
+ // Updating a source is not a new desired-set selection. Upstream renames or
102
+ // removals must not uninstall the last usable payload or erase its origin.
103
+ if (opts.preserveExisting || parsed.kind === "local")
102
104
  return [];
103
105
  // A sparse checkout does not prove the full source shape, so it must not
104
106
  // prune sibling plugins from the same repo that were intentionally excluded.