@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
@@ -105,7 +105,7 @@ export function makeCli(bin, opts) {
105
105
  else if (r.stderr)
106
106
  console.error(r.stderr.trim());
107
107
  }
108
- return { ok, out: `${r.stdout ?? ""}${r.stderr ?? ""}${r.error ? r.error.message : ""}` };
108
+ return { ok, out: `${r.stdout ?? ""}${r.stderr ?? ""}${r.error ? r.error.message : ""}`, stdout: r.stdout ?? "", stderr: r.stderr ?? "" };
109
109
  }
110
110
  finally {
111
111
  span.end();
@@ -102,13 +102,15 @@ export function syncMarketplace(pluginsDir, name, runner = run, warn = console.w
102
102
  // example, merge-conflict-style failures on older CLI builds). When that
103
103
  // happens, fall back to re-adding the marketplace so the refresh remains
104
104
  // best-effort instead of surfacing a hard EXIT_CODE_1 in the ADG timeline.
105
- if (runner(["plugin", "marketplace", "update", name]).ok)
106
- return;
105
+ const updated = runner(["plugin", "marketplace", "update", name]);
106
+ if (updated.ok)
107
+ return updated;
107
108
  }
108
109
  const added = runner(["plugin", "marketplace", "add", pluginsDir]);
109
110
  if (!added.ok) {
110
111
  warn(`failed to sync Claude marketplace (${name}): ${added.out.trim() || "claude plugin marketplace add failed without an error message"}`);
111
112
  }
113
+ return added;
112
114
  }
113
115
  /**
114
116
  * Parse `claude plugin marketplace list --json` into every directory-backed
@@ -161,49 +163,82 @@ export function pruneStaleClaudeMarketplaces(runner = run, exists = existsSync)
161
163
  }
162
164
  return { agent: "claude", skipped: false, removed, errors };
163
165
  }
166
+ /** Run every requested plugin independently and return actionable native failures. */
167
+ export function runClaudeLifecycle(ctx, operation, runner = run, isAvailable = available) {
168
+ if (!isAvailable())
169
+ return skippedResult("claude");
170
+ const result = { agent: "claude", affected: [], skipped: false, failures: [] };
171
+ const marketplace = claudeMarketplaceName(ctx.pluginsDir);
172
+ if (operation !== "deactivate") {
173
+ writeClaudeCatalog(ctx.pluginsDir);
174
+ const synced = syncMarketplace(ctx.pluginsDir, marketplace, runner);
175
+ if (!synced.ok) {
176
+ result.failures.push({ stage: "marketplace", errorType: "native_failure", message: synced.out.trim() || "Claude marketplace synchronization failed" });
177
+ return result;
178
+ }
179
+ }
180
+ let inspection;
181
+ if (operation === "refresh") {
182
+ const listed = runner(["plugin", "list", "--json"]);
183
+ inspection = listed.ok ? parseClaudePluginRecords(listed.stdout ?? listed.out, marketplace, ctx.scope) : undefined;
184
+ if (!inspection) {
185
+ result.failures.push({ stage: "inspect", errorType: "native_failure", message: listed.out.trim() || "Claude state could not be inspected before refresh" });
186
+ return result;
187
+ }
188
+ }
189
+ for (const plugin of ctx.plugins) {
190
+ const native = inspection?.find((p) => p.name === plugin);
191
+ if (operation === "refresh" && native && !native.enabled && !ctx.forceEnable) {
192
+ (result.preservedDisabled ??= []).push(plugin);
193
+ continue;
194
+ }
195
+ if (operation === "deactivate" || (operation === "refresh" && native)) {
196
+ const removed = runner(["plugin", "uninstall", `${plugin}@${marketplace}`, "--scope", ctx.scope, ...(operation === "refresh" || ctx.preserveData ? ["--keep-data"] : [])]);
197
+ const listed = !removed.ok ? runner(["plugin", "list", "--json"]) : undefined;
198
+ const observed = listed?.ok ? parseClaudePluginRecords(listed.stdout ?? listed.out, marketplace, ctx.scope) : undefined;
199
+ if (!removed.ok && !(observed && !observed.some((p) => p.name === plugin))) {
200
+ result.failures.push({ plugin, stage: "remove", errorType: "native_failure", message: removed.out.trim() || "Claude uninstall failed" });
201
+ continue;
202
+ }
203
+ }
204
+ if (operation !== "deactivate") {
205
+ const installed = runner(["plugin", "install", `${plugin}@${marketplace}`, "--scope", ctx.scope]);
206
+ if (!installed.ok) {
207
+ result.failures.push({ plugin, stage: "install", errorType: "native_failure", message: installed.out.trim() || "Claude install failed" });
208
+ continue;
209
+ }
210
+ if (ctx.forceEnable) {
211
+ const enabled = runner(["plugin", "enable", `${plugin}@${marketplace}`, "--scope", ctx.scope]);
212
+ if (!enabled.ok) {
213
+ result.failures.push({ plugin, stage: "install", errorType: "native_failure", message: enabled.out.trim() || "Claude enable failed" });
214
+ continue;
215
+ }
216
+ }
217
+ }
218
+ result.affected.push(plugin);
219
+ }
220
+ if (!result.failures.length)
221
+ delete result.failures;
222
+ return result;
223
+ }
164
224
  export const claudeAgent = {
225
+ retrySafeOperations: ["refresh", "deactivate"],
165
226
  id: "claude",
166
227
  displayName: "Claude Code",
167
228
  adaptTarget: "claude",
168
229
  detect: (env = process.env) => existsSync(claudeHome(env)),
169
230
  available,
170
- activate(ctx) {
171
- if (!available())
172
- return skippedResult("claude");
173
- const { name: marketplace } = writeClaudeCatalog(ctx.pluginsDir);
174
- syncMarketplace(ctx.pluginsDir, marketplace);
175
- const affected = [];
176
- for (const p of ctx.plugins) {
177
- const r = run(["plugin", "install", `${p}@${marketplace}`, "--scope", ctx.scope]);
178
- if (r.ok)
179
- affected.push(p);
180
- // Surface the CLI's reason instead of silently dropping the plugin — a
181
- // rejected manifest (e.g. `hooks: Invalid input`) otherwise looks like a
182
- // no-op "missing" with no diagnostic.
183
- else
184
- console.error(`claude: failed to install ${p}@${marketplace}: ${r.out.trim()}`);
185
- }
186
- return { agent: "claude", affected, skipped: false };
187
- },
188
- deactivate(ctx) {
189
- if (!available())
190
- return skippedResult("claude");
191
- const affected = [];
192
- for (const p of ctx.plugins) {
193
- if (run(["plugin", "uninstall", p, "--scope", ctx.scope]).ok)
194
- affected.push(p);
195
- }
196
- return { agent: "claude", affected, skipped: false };
197
- },
198
- refresh(ctx) {
231
+ activate: (ctx) => runClaudeLifecycle(ctx, "activate"),
232
+ deactivate: (ctx) => runClaudeLifecycle(ctx, "deactivate"),
233
+ refresh: (ctx) => runClaudeLifecycle(ctx, "refresh"),
234
+ inspectPlugins(ctx) {
199
235
  if (!available())
200
- return skippedResult("claude");
201
- // Claude caches a copy on install and won't re-pull from a local marketplace,
202
- // so uninstall (keeping data) then re-install to force a fresh copy.
203
- for (const p of ctx.plugins)
204
- run(["plugin", "uninstall", p, "--scope", ctx.scope, "--keep-data"]);
205
- const act = claudeAgent.activate(ctx);
206
- return { agent: "claude", affected: act.affected, skipped: act.skipped };
236
+ return undefined;
237
+ const result = run(["plugin", "list", "--json"]);
238
+ if (!result.ok)
239
+ return { error: result.out.trim() || "Claude plugin inspection failed" };
240
+ const records = parseClaudePluginRecords(result.stdout ?? result.out, claudeMarketplaceName(ctx.pluginsDir), ctx.scope);
241
+ return records ?? { error: UNRECOGNIZED_PLUGIN_LIST };
207
242
  },
208
243
  // Query Claude's live plugin state for `adg plugins status`, scoped to the
209
244
  // ADG marketplace and the requested install scope. `available()` gates the
@@ -233,6 +268,31 @@ export function claudeListFailure(out) {
233
268
  const detail = out.trim() || "claude plugin list failed without an error message";
234
269
  return { error: `${UNRECOGNIZED_PLUGIN_LIST}: ${detail}` };
235
270
  }
271
+ /** Preserve disabled registrations and versions for transaction verification. */
272
+ export function parseClaudePluginRecords(out, marketplace, scope) {
273
+ try {
274
+ const parsed = JSON.parse(out);
275
+ if (!Array.isArray(parsed))
276
+ return undefined;
277
+ const records = [];
278
+ for (const value of parsed) {
279
+ if (!value || typeof value !== "object")
280
+ return undefined;
281
+ const record = value;
282
+ if (typeof record.id !== "string" || typeof record.scope !== "string" || typeof record.enabled !== "boolean")
283
+ return undefined;
284
+ const identity = record.id.match(/^(\S+?)@([\w.-]+)$/);
285
+ if (!identity || identity[2] !== marketplace || record.scope.toLowerCase() !== scope)
286
+ continue;
287
+ records.push({ id: record.id, name: identity[1], installed: true, enabled: record.enabled,
288
+ ...(typeof record.version === "string" ? { version: record.version } : {}) });
289
+ }
290
+ return records;
291
+ }
292
+ catch {
293
+ return undefined;
294
+ }
295
+ }
236
296
  /** Parse `claude plugin list --json` into enabled plugin names for a marketplace + scope. */
237
297
  export function parseClaudePluginListJson(out, marketplace, scope) {
238
298
  try {
@@ -176,7 +176,7 @@ function listCodexMarketplaces(runner) {
176
176
  for (let attempt = 0; attempt < 2; attempt++) {
177
177
  const listed = runner(["plugin", "marketplace", "list", "--json"]);
178
178
  if (listed.ok)
179
- return { ok: true, sources: parseCodexMarketplaceLocalSources(listed.out), removed, errors };
179
+ return { ok: true, sources: parseCodexMarketplaceLocalSources(listed.stdout ?? listed.out), removed, errors };
180
180
  const detail = listed.out.trim() || "codex plugin marketplace list failed without an error message";
181
181
  const ownedStale = parseCodexStaleMarketplaceErrors(listed.out).filter((e) => isAdgOwnedName(e.name));
182
182
  if (attempt === 1 || ownedStale.length === 0)
@@ -240,6 +240,7 @@ export function pruneStaleCodexMarketplaces(runner = run, env = process.env, exi
240
240
  return { agent: "codex", skipped: false, removed, errors };
241
241
  }
242
242
  export const codexAgent = {
243
+ retrySafeOperations: ["activate", "refresh", "deactivate"],
243
244
  id: "codex",
244
245
  displayName: "Codex",
245
246
  adaptTarget: "codex",
@@ -296,8 +297,13 @@ export const codexAgent = {
296
297
  const result = run(["plugin", "list", "--available", "--marketplace", marketplace, "--json"]);
297
298
  if (!result.ok)
298
299
  return codexListFailure(result.out);
299
- const records = parseCodexInspection(result.out, marketplace);
300
- recordTelemetryEvent("adg.codex.inspect_plugins", { "inspection.valid": records !== undefined, "inspection.record_count": records?.length ?? 0 }, span);
300
+ const records = parseCodexInspection(result.stdout ?? result.out, marketplace);
301
+ recordTelemetryEvent("adg.codex.inspect_plugins", {
302
+ "inspection.valid": records !== undefined,
303
+ "inspection.record_count": records?.length ?? 0,
304
+ "inspection.version_count": records?.filter((record) => record.version !== undefined).length ?? 0,
305
+ "inspection.stderr_present": Boolean(result.stderr),
306
+ }, span);
301
307
  return records ?? codexUnrecognizedListFailure(result.out);
302
308
  }
303
309
  finally {
@@ -316,7 +322,7 @@ export const codexAgent = {
316
322
  return undefined; // no generated marketplace → can't scope the query
317
323
  const jsonRes = run(["plugin", "list", "--json"]);
318
324
  if (jsonRes.ok) {
319
- const parsed = parseCodexPluginListJson(jsonRes.out, mp);
325
+ const parsed = parseCodexPluginListJson(jsonRes.stdout ?? jsonRes.out, mp);
320
326
  if (parsed !== undefined)
321
327
  return parsed;
322
328
  return codexUnrecognizedListFailure(jsonRes.out);
@@ -346,33 +352,7 @@ export function codexUnrecognizedListFailure(out) {
346
352
  }
347
353
  /** Parse `codex plugin list --json` into installed and enabled plugin names for one marketplace. */
348
354
  export function parseCodexPluginListJson(out, marketplace) {
349
- try {
350
- const parsed = JSON.parse(out);
351
- if (typeof parsed !== "object" || parsed === null)
352
- return undefined;
353
- const installed = parsed.installed;
354
- if (!Array.isArray(installed))
355
- return undefined;
356
- const names = [];
357
- const seen = new Set();
358
- for (const entry of installed) {
359
- if (typeof entry !== "object" || entry === null)
360
- continue;
361
- const record = entry;
362
- const name = typeof record.name === "string" ? record.name : undefined;
363
- const mp = typeof record.marketplaceName === "string" ? record.marketplaceName : undefined;
364
- const isInstalled = record.installed === true;
365
- const enabled = record.enabled === true;
366
- if (!name || mp !== marketplace || !isInstalled || !enabled || seen.has(name))
367
- continue;
368
- seen.add(name);
369
- names.push(name);
370
- }
371
- return names;
372
- }
373
- catch {
374
- return undefined;
375
- }
355
+ return parseCodexInspection(out, marketplace)?.filter((record) => record.installed && record.enabled).map((record) => record.name);
376
356
  }
377
357
  /**
378
358
  * Parse `codex plugin list` output into the *installed and enabled* plugin names
@@ -407,19 +387,29 @@ export function parseCodexPluginList(out, marketplace) {
407
387
  export function parseCodexInspection(out, marketplace) {
408
388
  try {
409
389
  const parsed = JSON.parse(out);
410
- if (!Array.isArray(parsed?.installed) || !Array.isArray(parsed?.available))
390
+ if (!parsed || typeof parsed !== "object" || Array.isArray(parsed) || !Array.isArray(parsed.installed))
391
+ return undefined;
392
+ const available = parsed.available === undefined ? [] : parsed.available;
393
+ if (!Array.isArray(available))
411
394
  return undefined;
412
395
  const records = new Map();
413
- for (const record of [...parsed.installed, ...parsed.available]) {
414
- if (!record || typeof record !== "object")
415
- return undefined;
416
- if (record.marketplaceName !== marketplace)
417
- continue;
418
- if (typeof record.name !== "string" || record.pluginId !== `${record.name}@${marketplace}` || typeof record.installed !== "boolean" || typeof record.enabled !== "boolean" || (record.enabled && !record.installed))
419
- return undefined;
420
- if (records.has(record.name))
421
- return undefined;
422
- records.set(record.name, { id: record.pluginId, name: record.name, installed: record.installed, enabled: record.enabled });
396
+ for (const [entries, installed] of [[parsed.installed, true], [available, false]]) {
397
+ for (const record of entries) {
398
+ if (!record || typeof record !== "object" || Array.isArray(record) || typeof record.marketplaceName !== "string")
399
+ return undefined;
400
+ if (record.marketplaceName !== marketplace)
401
+ continue;
402
+ if (record.installed !== installed)
403
+ return undefined;
404
+ if (typeof record.name !== "string" || !record.name.trim() || record.pluginId !== `${record.name}@${marketplace}` || typeof record.installed !== "boolean" || typeof record.enabled !== "boolean" || (record.enabled && !record.installed))
405
+ return undefined;
406
+ if (record.version != null && (typeof record.version !== "string" || !record.version.trim()))
407
+ return undefined;
408
+ if (records.has(record.name))
409
+ return undefined;
410
+ records.set(record.name, { id: record.pluginId, name: record.name, installed: record.installed, enabled: record.enabled,
411
+ ...(typeof record.version === "string" ? { version: record.version } : {}) });
412
+ }
423
413
  }
424
414
  return [...records.values()];
425
415
  }
@@ -9,7 +9,7 @@ import { validatePlugin } from "../commands/validate.js";
9
9
  import { ui } from "../render/ui.js";
10
10
  import { pluginsListJson, pluginsPruneJson, pluginsStatusJson, printJson } from "../render/json.js";
11
11
  import { renderPluginList, renderPrune, renderStatus } from "../render/plugins.js";
12
- import { fail, parseVerb, resolveScopeDir, resolveTargets, scopeOf, } from "./index.js";
12
+ import { fail, CliUsageError, parseVerb, resolveScopeDir, resolveTargets, scopeOf, } from "./index.js";
13
13
  const CORE_PLUGIN_VERBS = new Set(["init", "adapt", "validate", "inspect", "list", "status", "prune"]);
14
14
  export async function handleCorePluginVerb(verb, rest, cmd) {
15
15
  if (!CORE_PLUGIN_VERBS.has(verb))
@@ -57,7 +57,7 @@ export async function handleCorePluginVerb(verb, rest, cmd) {
57
57
  console.error(`${ui.err("invalid:")} ${ui.name(pluginDir)}`);
58
58
  for (const issue of result.issues)
59
59
  console.error(ui.warn(` - ${issue}`));
60
- process.exit(1);
60
+ throw new CliUsageError("Plugin validation failed");
61
61
  }
62
62
  return true;
63
63
  }
@@ -109,7 +109,7 @@ export async function handleCorePluginVerb(verb, rest, cmd) {
109
109
  // drift" outcome `status` reports at exit 0. See docs/cli-json.md's
110
110
  // exit-code contract for `adg plugins prune --json`.
111
111
  if (pruneHasErrors(results))
112
- process.exit(1);
112
+ throw new CliUsageError("Native registry cleanup is incomplete");
113
113
  return true;
114
114
  }
115
115
  }