@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.
- package/README.md +131 -73
- package/dist/src/agents/antigravity.js +218 -45
- package/dist/src/agents/claude.js +98 -38
- package/dist/src/agents/codex.js +1 -0
- package/dist/src/cli/core-plugin-handlers.js +3 -3
- package/dist/src/cli/handlers.js +171 -39
- package/dist/src/cli/index.js +23 -14
- package/dist/src/cli/review-update.js +80 -0
- package/dist/src/commands/install/default-dsl.js +1 -1
- package/dist/src/commands/install/discovery.js +3 -1
- package/dist/src/commands/install/install-one.js +41 -31
- package/dist/src/commands/install.js +59 -24
- package/dist/src/commands/marketplace.js +171 -115
- package/dist/src/commands/migrate.js +2 -2
- package/dist/src/commands/projection.js +3 -1
- package/dist/src/commands/remove.js +10 -0
- package/dist/src/commands/review-executables.js +106 -0
- package/dist/src/commands/select-agents.js +2 -2
- package/dist/src/commands/select-components.js +2 -2
- package/dist/src/commands/select-plugins.js +15 -2
- package/dist/src/commands/select-scope.js +3 -4
- package/dist/src/commands/source-upgrade.js +552 -0
- package/dist/src/commands/state.js +3 -1
- package/dist/src/commands/update.js +3 -1
- package/dist/src/lock.js +13 -5
- package/dist/src/migration-transaction.js +1011 -0
- package/dist/src/native-retry.js +329 -0
- package/dist/src/process-identity.js +88 -0
- package/dist/src/render/plugins.js +149 -27
- package/dist/src/render/ui.js +4 -4
- package/dist/src/source-history.js +194 -0
- package/dist/src/source-intent.js +7 -0
- package/dist/src/store-mutex.js +179 -0
- package/dist/src/types.js +1 -1
- package/dist/src/update-executables.js +193 -0
- package/dist/src/upgrade-plan.js +378 -0
- package/docs/agents/antigravity.md +5 -0
- package/docs/agents-spec.md +10 -0
- package/docs/branching-and-release.md +369 -55
- package/docs/marketing/README.md +211 -0
- package/docs/marketing/assets.json +228 -0
- package/docs/marketing/capture.json +130 -0
- package/docs/marketing/live-readiness.json +353 -0
- package/docs/marketing/posts.en.md +94 -0
- package/docs/marketing/posts.zh-CN.md +67 -0
- package/docs/marketing/production.md +210 -0
- package/docs/marketing/source/timeline.json +29 -0
- package/docs/marketing/source/workflow-01.svg +16 -0
- package/docs/marketing/source/workflow-02.svg +14 -0
- package/docs/marketing/source/workflow-03.svg +19 -0
- package/docs/marketing/source/workflow-poster.svg +32 -0
- package/docs/marketing/transcript.md +48 -0
- package/docs/plugin-update-semantics.md +53 -10
- package/docs/plugin-upgrade-migrations.md +349 -0
- package/package.json +14 -10
- package/schemas/plugin-lock.schema.json +78 -1
|
@@ -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
|
-
|
|
106
|
-
|
|
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
|
-
|
|
172
|
-
|
|
173
|
-
|
|
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
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
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 {
|
package/dist/src/agents/codex.js
CHANGED
|
@@ -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",
|
|
@@ -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
|
-
|
|
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
|
-
|
|
112
|
+
throw new CliUsageError("Native registry cleanup is incomplete");
|
|
113
113
|
return true;
|
|
114
114
|
}
|
|
115
115
|
}
|
package/dist/src/cli/handlers.js
CHANGED
|
@@ -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
|
-
//
|
|
29
|
-
const
|
|
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
|
|
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
|
|
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 ?
|
|
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
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
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
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
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
|
-
|
|
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 (
|
|
447
|
+
catch (error) {
|
|
350
448
|
progress.stop();
|
|
351
|
-
|
|
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
|
-
|
|
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
|
-
|
|
494
|
-
const
|
|
495
|
-
|
|
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
|
}
|
package/dist/src/cli/index.js
CHANGED
|
@@ -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: "
|
|
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
|
-
|
|
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
|
|
92
|
-
"newly available (
|
|
93
|
-
"rescanned in place.
|
|
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
|
-
"
|
|
96
|
-
|
|
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 #
|
|
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
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
385
|
+
throw new CliUsageError(err instanceof Error ? err.message : String(err));
|
|
377
386
|
}
|
|
378
387
|
}
|