@rbbtsn0w/adg 0.11.1-beta.1 → 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 (56) hide show
  1. package/README.md +131 -73
  2. package/dist/src/agents/antigravity.js +218 -45
  3. package/dist/src/agents/claude.js +98 -38
  4. package/dist/src/agents/codex.js +1 -0
  5. package/dist/src/cli/core-plugin-handlers.js +3 -3
  6. package/dist/src/cli/handlers.js +171 -39
  7. package/dist/src/cli/index.js +23 -14
  8. package/dist/src/cli/review-update.js +80 -0
  9. package/dist/src/commands/install/default-dsl.js +1 -1
  10. package/dist/src/commands/install/discovery.js +3 -1
  11. package/dist/src/commands/install/install-one.js +41 -31
  12. package/dist/src/commands/install.js +59 -24
  13. package/dist/src/commands/marketplace.js +171 -115
  14. package/dist/src/commands/migrate.js +2 -2
  15. package/dist/src/commands/projection.js +3 -1
  16. package/dist/src/commands/remove.js +10 -0
  17. package/dist/src/commands/review-executables.js +106 -0
  18. package/dist/src/commands/select-agents.js +2 -2
  19. package/dist/src/commands/select-components.js +2 -2
  20. package/dist/src/commands/select-plugins.js +15 -2
  21. package/dist/src/commands/select-scope.js +3 -4
  22. package/dist/src/commands/source-upgrade.js +552 -0
  23. package/dist/src/commands/state.js +3 -1
  24. package/dist/src/commands/update.js +3 -1
  25. package/dist/src/lock.js +13 -5
  26. package/dist/src/migration-transaction.js +1011 -0
  27. package/dist/src/native-retry.js +329 -0
  28. package/dist/src/process-identity.js +88 -0
  29. package/dist/src/render/plugins.js +149 -27
  30. package/dist/src/render/ui.js +4 -4
  31. package/dist/src/source-history.js +194 -0
  32. package/dist/src/source-intent.js +7 -0
  33. package/dist/src/store-mutex.js +179 -0
  34. package/dist/src/types.js +1 -1
  35. package/dist/src/update-executables.js +193 -0
  36. package/dist/src/upgrade-plan.js +378 -0
  37. package/docs/agents/antigravity.md +5 -0
  38. package/docs/agents-spec.md +10 -0
  39. package/docs/branching-and-release.md +369 -55
  40. package/docs/marketing/README.md +211 -0
  41. package/docs/marketing/assets.json +228 -0
  42. package/docs/marketing/capture.json +130 -0
  43. package/docs/marketing/live-readiness.json +353 -0
  44. package/docs/marketing/posts.en.md +94 -0
  45. package/docs/marketing/posts.zh-CN.md +67 -0
  46. package/docs/marketing/production.md +210 -0
  47. package/docs/marketing/source/timeline.json +29 -0
  48. package/docs/marketing/source/workflow-01.svg +16 -0
  49. package/docs/marketing/source/workflow-02.svg +14 -0
  50. package/docs/marketing/source/workflow-03.svg +19 -0
  51. package/docs/marketing/source/workflow-poster.svg +32 -0
  52. package/docs/marketing/transcript.md +48 -0
  53. package/docs/plugin-update-semantics.md +53 -10
  54. package/docs/plugin-upgrade-migrations.md +349 -0
  55. package/package.json +14 -10
  56. package/schemas/plugin-lock.schema.json +78 -1
@@ -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.
@@ -21,6 +21,40 @@ const HASH_IGNORE = PROJECTION_DIRS;
21
21
  export function contentHash(dir, manifest) {
22
22
  return folderHash(dir, HASH_IGNORE, packageFilter(manifest, { includeProjections: false }));
23
23
  }
24
+ /** Verify managed payload and every generated runtime projection using the same materialization rules. */
25
+ export function verifyInstallation(dir, expectedHash, selection, targets) {
26
+ let projectionsIntact = false;
27
+ let installationIntact = false;
28
+ try {
29
+ const installedManifest = readManifest(dir);
30
+ const previousSelection = resolveSelectionDependencies(installedManifest, selection);
31
+ installationIntact = Boolean(expectedHash && folderHash(dir, PROJECTION_DIRS, effectivePackageFilter(installedManifest, previousSelection)) === expectedHash);
32
+ // Generate the complete expected installation, including auxiliary MCP,
33
+ // hooks and runner files that are outside native manifest directories.
34
+ const work = mkdtempSync(join(tmpdir(), "adg-projection-check-"));
35
+ try {
36
+ const expected = join(work, "expected");
37
+ materializePlugin({ source: dir, destination: expected, manifest: installedManifest, selection: previousSelection,
38
+ build: (staging) => { adaptPlugin(staging, targets, previousSelection, dir); } });
39
+ const paths = new Set();
40
+ const collect = (dir, prefix = "") => {
41
+ for (const entry of readdirSync(dir, { withFileTypes: true })) {
42
+ const path = prefix ? `${prefix}/${entry.name}` : entry.name;
43
+ paths.add(path);
44
+ if (entry.isDirectory())
45
+ collect(join(dir, entry.name), path);
46
+ }
47
+ };
48
+ collect(expected);
49
+ projectionsIntact = folderHash(expected) === folderHash(dir, [], (path) => paths.has(path));
50
+ }
51
+ finally {
52
+ rmSync(work, { recursive: true, force: true });
53
+ }
54
+ }
55
+ catch { /* Missing or damaged projections must be regenerated. */ }
56
+ return { installationIntact, projectionsIntact };
57
+ }
24
58
  function describe(s) {
25
59
  switch (s.type) {
26
60
  case "local": return `local:${s.path}`;
@@ -56,6 +90,7 @@ export function installPlugin(opts) {
56
90
  // A new selection wins; otherwise keep whatever a prior install recorded so
57
91
  // partial installs survive re-install / `marketplace upgrade`.
58
92
  const desiredSelection = normalizePluginSelection(opts.selection ?? prev?.selection);
93
+ const selectionKnown = opts.selectionKnown ?? true;
59
94
  const selection = resolveSelectionDependencies(manifest, desiredSelection);
60
95
  if (selection) {
61
96
  const contents = pluginContents(source, manifest);
@@ -104,36 +139,7 @@ export function installPlugin(opts) {
104
139
  }
105
140
  catch { /* Missing/invalid comparison evidence requires a conservative update. */ }
106
141
  }
107
- let projectionsIntact = false;
108
- let installationIntact = false;
109
- try {
110
- const installedManifest = readManifest(dest);
111
- const previousSelection = resolveSelectionDependencies(installedManifest, prev?.selection);
112
- installationIntact = Boolean(prev && folderHash(dest, PROJECTION_DIRS, effectivePackageFilter(installedManifest, previousSelection)) === prev.installedHash);
113
- // Generate the complete expected installation, including auxiliary MCP,
114
- // hooks and runner files that are outside native manifest directories.
115
- const work = mkdtempSync(join(tmpdir(), "adg-projection-check-"));
116
- try {
117
- const expected = join(work, "expected");
118
- materializePlugin({ source: dest, destination: expected, manifest: installedManifest, selection: previousSelection,
119
- build: (staging) => { adaptPlugin(staging, targets, previousSelection, dest); } });
120
- const paths = new Set();
121
- const collect = (dir, prefix = "") => {
122
- for (const entry of readdirSync(dir, { withFileTypes: true })) {
123
- const path = prefix ? `${prefix}/${entry.name}` : entry.name;
124
- paths.add(path);
125
- if (entry.isDirectory())
126
- collect(join(dir, entry.name), path);
127
- }
128
- };
129
- collect(expected);
130
- projectionsIntact = folderHash(expected) === folderHash(dest, [], (path) => paths.has(path));
131
- }
132
- finally {
133
- rmSync(work, { recursive: true, force: true });
134
- }
135
- }
136
- catch { /* Missing or damaged projections must be regenerated. */ }
142
+ const { installationIntact, projectionsIntact } = verifyInstallation(dest, prev?.installedHash, prev?.selection, targets);
137
143
  return withPluginSourceCache(source, cacheDir, manifest, (snapshot) => {
138
144
  // Detect-then-update compares the complete source snapshot, never the
139
145
  // selection-pruned runtime installation.
@@ -143,10 +149,11 @@ export function installPlugin(opts) {
143
149
  const installedIntact = existsSync(dest)
144
150
  && folderHash(dest, PROJECTION_DIRS, effectivePackageFilter(manifest, selection)) === prev.installedHash;
145
151
  if (installedIntact) {
146
- if (changes.source || changes.selection) {
152
+ if (changes.source || changes.selection || prev.selectionKnown !== selectionKnown) {
147
153
  // Exact bytes are verified at this revision; this is not an install.
148
154
  lock.plugins[name] = {
149
155
  ...prev,
156
+ selectionKnown,
150
157
  ...(changes.source ? { resolvedRevision: opts.resolvedRevision } : {}),
151
158
  ...(desiredSelection ? { selection: desiredSelection } : {}),
152
159
  };
@@ -184,6 +191,7 @@ export function installPlugin(opts) {
184
191
  version: manifest.version,
185
192
  sourceHash,
186
193
  installedHash,
194
+ selectionKnown,
187
195
  ...(opts.resolvedRevision ? { resolvedRevision: opts.resolvedRevision } : {}),
188
196
  };
189
197
  if (manifest.dependencies?.length) {
@@ -193,6 +201,8 @@ export function installPlugin(opts) {
193
201
  entry.selection = desiredSelection;
194
202
  if (prev?.state)
195
203
  entry.state = prev.state;
204
+ if (prev?.runtimeStates)
205
+ entry.runtimeStates = prev.runtimeStates;
196
206
  if (opts.definition)
197
207
  entry.definition = opts.definition;
198
208
  const previousEntry = prev && Object.fromEntries(Object.entries(prev).filter(([key]) => key !== "installedAt" && key !== "updatedAt"));
@@ -3,7 +3,10 @@ import { tmpdir } from "node:os";
3
3
  import { join, relative, resolve } from "node:path";
4
4
  import { toPosix } from "../fsutil.js";
5
5
  import { lockPath } from "../paths.js";
6
- import { readLock } from "../lock.js";
6
+ import { syncNativeBatchWithRetry } from "../native-retry.js";
7
+ import { installedHistory } from "../source-history.js";
8
+ import { sourceIntent, setSourceIntent } from "../source-intent.js";
9
+ import { readLock, writeLock } from "../lock.js";
7
10
  import { resolveInstallOrder } from "../deps.js";
8
11
  import { cloneGitHub, gitRevision, parseGitHubSource, parseSource } from "../sources.js";
9
12
  import { materializeSource } from "../remote/index.js";
@@ -67,7 +70,7 @@ async function prepareSource(opts, parsed, sourceRef) {
67
70
  throw error;
68
71
  }
69
72
  }
70
- function activateInstalled(opts, targets, installed, existingPlugins) {
73
+ async function activateInstalled(opts, targets, installed, existingPlugins) {
71
74
  const updatedLock = readLock(lockPath(opts.pluginsDir));
72
75
  const eligible = installed.filter((result) => pluginState(updatedLock.plugins[result.name]) === "enabled");
73
76
  const toActivate = opts.skipUnchanged ? eligible.filter((result) => result.runtimeRefreshRequired ?? result.changed) : eligible;
@@ -76,30 +79,23 @@ function activateInstalled(opts, targets, installed, existingPlugins) {
76
79
  const resolved = opts.agents ?? resolveAgents(targets);
77
80
  const scope = opts.scope ?? "project";
78
81
  const ctxFor = (names) => ({ pluginsDir: opts.pluginsDir, plugins: names, scope });
79
- return resolved.map((agent) => {
82
+ const requests = [];
83
+ for (const agent of resolved) {
80
84
  opts.onProgress?.({ kind: "activate", agent: agent.id, count: toActivate.length });
81
85
  const queryResult = agent.listInstalled?.(ctxFor([]));
82
86
  const agentInstalled = Array.isArray(queryResult) ? queryResult : undefined;
83
87
  const alreadyInstalled = (name) => agentInstalled !== undefined
84
- ? agentInstalled.includes(name)
85
- : existingPlugins.has(name);
86
- const activateNames = toActivate.filter((result) => !alreadyInstalled(result.name)).map((result) => result.name);
87
- const refreshNames = toActivate.filter((result) => alreadyInstalled(result.name)).map((result) => result.name);
88
- const parts = [];
89
- if (activateNames.length > 0)
90
- parts.push(agent.activate(ctxFor(activateNames)));
91
- if (refreshNames.length > 0)
92
- parts.push(agent.refresh(ctxFor(refreshNames)));
93
- return parts.reduce((acc, result) => ({
94
- agent: result.agent,
95
- affected: [...acc.affected, ...result.affected],
96
- skipped: acc.skipped && result.skipped,
97
- ...((acc.failures?.length || result.failures?.length) ? { failures: [...(acc.failures ?? []), ...(result.failures ?? [])] } : {}),
98
- ...Object.fromEntries(["verified", "unverified", "preservedDisabled"]
99
- .filter((field) => acc[field] !== undefined || result[field] !== undefined)
100
- .map((field) => [field, [...new Set([...(acc[field] ?? []), ...(result[field] ?? [])])]])),
101
- }), { agent: agent.id, affected: [], skipped: true });
102
- });
88
+ ? agentInstalled.includes(name) : existingPlugins.has(name);
89
+ const activateNames = toActivate.filter(result => !alreadyInstalled(result.name)).map(result => result.name);
90
+ const refreshNames = toActivate.filter(result => alreadyInstalled(result.name)).map(result => result.name);
91
+ requests.push({
92
+ agent,
93
+ activate: activateNames,
94
+ refresh: refreshNames,
95
+ preserveRuntimeDisabled: Boolean(opts.skipUnchanged || opts.preserveExisting),
96
+ });
97
+ }
98
+ return syncNativeBatchWithRetry({ pluginsDir: opts.pluginsDir, scope, requests });
103
99
  }
104
100
  /**
105
101
  * The unified install entrypoint. Treats any source as a marketplace: clone or
@@ -133,6 +129,12 @@ export async function addPlugins(opts) {
133
129
  }
134
130
  }
135
131
  if (candidates.size === 0) {
132
+ // Ordinary plugin updates cannot authorize a new structural identity
133
+ // after all explicit manifests disappear. Existing DSL profiles replay
134
+ // separately with their persisted identity and authorization.
135
+ if (opts.preserveExisting && !opts.structuralIdentity) {
136
+ return { order: [], installed: [], removed: [], converted, available: [] };
137
+ }
136
138
  const synthesized = await synthesizeDefaultDslPlugin(opts, parsed, workRoot, resolvedRevision);
137
139
  candidates = synthesized.candidates;
138
140
  converted = synthesized.converted;
@@ -149,7 +151,15 @@ export async function addPlugins(opts) {
149
151
  }
150
152
  };
151
153
  }
152
- const selected = structuralName ? [structuralName] : await selectPluginNames(opts, candidates, converted);
154
+ const installedAtAnotherRef = (name) => {
155
+ const origin = existingLock.plugins[name]?.origin;
156
+ return parsed.kind === "github" && origin?.type === "github"
157
+ && origin.repo === parsed.source && origin.ref !== sourceRef;
158
+ };
159
+ const chosen = structuralName ? [structuralName] : await selectPluginNames(opts, candidates, converted);
160
+ // --all permits additions, but an existing sibling still belongs to its
161
+ // own ref. Explicit add remains the operation that can change that pin.
162
+ const selected = opts.preserveExisting ? chosen.filter((name) => !installedAtAnotherRef(name)) : chosen;
153
163
  // Resolve adapter targets after the plugin choice (lets a CLI agent picker
154
164
  // run once we know what's being installed). undefined → installPlugin's all.
155
165
  const targets = opts.targets ?? (opts.selectTargets ? await opts.selectTargets() : undefined);
@@ -184,6 +194,12 @@ export async function addPlugins(opts) {
184
194
  }
185
195
  }
186
196
  }
197
+ if (opts.preserveExisting) {
198
+ const conflicts = order.filter(installedAtAnotherRef);
199
+ if (conflicts.length > 0) {
200
+ throw new Error(`dependency plugin(s) installed at a different source ref: ${conflicts.join(", ")}; re-add or migrate explicitly`);
201
+ }
202
+ }
187
203
  // A generated Default DSL replay retains its definition profile. Only an
188
204
  // explicit manifest discovered from the source may replace that profile.
189
205
  const definitionSwitches = definition
@@ -221,7 +237,26 @@ export async function addPlugins(opts) {
221
237
  // undefined targets = all registered agents. Under skipUnchanged (the update
222
238
  // path) only re-activate plugins that actually changed — re-running an agent
223
239
  // CLI for an untouched plugin is wasted work.
224
- const agents = activateInstalled(opts, targets, installed, existingPlugins);
240
+ if (!opts.preserveExisting && parsed.kind === "github") {
241
+ const file = lockPath(opts.pluginsDir);
242
+ const lock = readLock(file);
243
+ const previous = sourceIntent(existingLock, parsed.source, sourceRef);
244
+ const followAll = Boolean((opts.all || opts.followAllSelected) && !opts.plugins?.length && !opts.sparse?.length && !structuralName);
245
+ setSourceIntent(lock, {
246
+ source: parsed.source, ref: sourceRef, mode: followAll ? "all" : "selected",
247
+ roots: selected, excluded: followAll ? [] : (previous?.excluded ?? []).filter((name) => !order.includes(name)),
248
+ appliedMigrations: [],
249
+ history: installedHistory(opts.pluginsDir, lock, parsed.source, sourceRef),
250
+ deferredRecovery: previous?.deferredRecovery,
251
+ executableDecisions: previous?.executableDecisions,
252
+ ...(targets ? { targets } : {}),
253
+ withDeps: opts.withDeps !== false,
254
+ ...(opts.sparse ? { sparse: opts.sparse } : {}),
255
+ ...(opts.only || opts.skillsSubset || opts.mcpSubset ? { selection: selections.get(selected[0]) } : {}),
256
+ });
257
+ writeLock(file, lock);
258
+ }
259
+ const agents = await activateInstalled(opts, targets, installed, existingPlugins);
225
260
  return { order, installed, removed, converted, available, agents };
226
261
  }
227
262
  finally {