@rbbtsn0w/adg 0.9.0-dev.pr110.9b0a3ec → 0.9.0-dev.pr111.8698552
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/dist/src/agents/base.js +23 -0
- package/dist/src/agents/claude.js +53 -1
- package/dist/src/agents/codex.js +148 -2
- package/dist/src/cli/core-plugin-handlers.js +22 -3
- package/dist/src/cli/index.js +11 -0
- package/dist/src/commands/multiselect-skills.js +10 -3
- package/dist/src/commands/prune.js +22 -0
- package/dist/src/render/json.js +4 -0
- package/dist/src/render/plugins.js +35 -0
- package/dist/src/telemetry.js +1 -0
- package/docs/cli-json.md +37 -0
- package/package.json +2 -1
package/dist/src/agents/base.js
CHANGED
|
@@ -2,6 +2,29 @@ import { spawnSync } from "node:child_process";
|
|
|
2
2
|
import { SpanKind, SpanStatusCode } from "@opentelemetry/api";
|
|
3
3
|
import { getTracer, sanitizeArgs } from "../telemetry.js";
|
|
4
4
|
import { runSubprocessSync } from "../subprocess.js";
|
|
5
|
+
/**
|
|
6
|
+
* Matches the marketplace names `claudeMarketplaceName`/`codexMarketplaceName`
|
|
7
|
+
* generate: the historical global `adg`, or a store-scoped `adg-<8-hex-hash>`.
|
|
8
|
+
* `pruneStale()` implementations use this to recognize an ADG-owned
|
|
9
|
+
* registration before ever removing it — never a user's own marketplace that
|
|
10
|
+
* merely happens to be named "adg" (that would need the hash suffix to collide,
|
|
11
|
+
* which SHA-1 truncated to 8 hex chars makes negligible, but the check still
|
|
12
|
+
* exists so intent is explicit rather than implied by never checking).
|
|
13
|
+
*/
|
|
14
|
+
export function isAdgOwnedName(name) {
|
|
15
|
+
return /^adg(-[0-9a-f]{8})?$/.test(name);
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Stricter than `isAdgOwnedName`: a *hash-suffixed* ADG marketplace name only,
|
|
19
|
+
* excluding the bare "adg" global. Used when deleting a filesystem cache
|
|
20
|
+
* directory by name match with no CLI-level undo — the extra caution against
|
|
21
|
+
* ever touching the real global cache directory is worth the asymmetry with
|
|
22
|
+
* the CLI-level removal above (which is safely reversible via `adg plugins
|
|
23
|
+
* marketplace sync`).
|
|
24
|
+
*/
|
|
25
|
+
export function isAdgSandboxCacheDirName(name) {
|
|
26
|
+
return /^adg-[0-9a-f]{8}$/.test(name);
|
|
27
|
+
}
|
|
5
28
|
/**
|
|
6
29
|
* The canonical "CLI absent, so nothing was touched" lifecycle result. Every
|
|
7
30
|
* agent's activate/deactivate guard returns this shape; centralizing it keeps
|
|
@@ -6,7 +6,7 @@ import { toPosix, writeJson } from "../fsutil.js";
|
|
|
6
6
|
import { readManifest } from "../manifest.js";
|
|
7
7
|
import { globalPluginsDir, installedPluginDir, lockPath } from "../paths.js";
|
|
8
8
|
import { readLock } from "../lock.js";
|
|
9
|
-
import { makeCli, skippedResult } from "./base.js";
|
|
9
|
+
import { isAdgOwnedName, makeCli, skippedResult } from "./base.js";
|
|
10
10
|
/**
|
|
11
11
|
* Claude Code agent.
|
|
12
12
|
*
|
|
@@ -110,6 +110,57 @@ export function syncMarketplace(pluginsDir, name, runner = run, warn = console.w
|
|
|
110
110
|
warn(`failed to sync Claude marketplace (${name}): ${added.out.trim() || "claude plugin marketplace add failed without an error message"}`);
|
|
111
111
|
}
|
|
112
112
|
}
|
|
113
|
+
/**
|
|
114
|
+
* Parse `claude plugin marketplace list --json` into every directory-backed
|
|
115
|
+
* marketplace with a resolvable path — the shape `pruneStale` needs to decide
|
|
116
|
+
* which registrations are stale. `parseClaudeMarketplaceList` (above) only
|
|
117
|
+
* extracts `name` because that's all drift-listing needs; this extracts `path`
|
|
118
|
+
* too, since a URL/GitHub-sourced marketplace has none and can never go stale
|
|
119
|
+
* this way (its source isn't a local directory that can vanish).
|
|
120
|
+
*/
|
|
121
|
+
export function parseClaudeMarketplaceDirectories(out) {
|
|
122
|
+
try {
|
|
123
|
+
const parsed = JSON.parse(out);
|
|
124
|
+
if (!Array.isArray(parsed))
|
|
125
|
+
return [];
|
|
126
|
+
const entries = [];
|
|
127
|
+
for (const entry of parsed) {
|
|
128
|
+
if (typeof entry !== "object" || entry === null)
|
|
129
|
+
continue;
|
|
130
|
+
const { name, source, path } = entry;
|
|
131
|
+
if (typeof name === "string" && source === "directory" && typeof path === "string")
|
|
132
|
+
entries.push({ name, path });
|
|
133
|
+
}
|
|
134
|
+
return entries;
|
|
135
|
+
}
|
|
136
|
+
catch {
|
|
137
|
+
return [];
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* Remove every ADG-owned Claude marketplace whose source directory no longer
|
|
142
|
+
* exists — e.g. a deleted project, or a test sandbox that leaked into the real
|
|
143
|
+
* `~/.claude` config (see `adg plugins prune`). Never touches a marketplace ADG
|
|
144
|
+
* didn't create (`isAdgOwnedName`), and never one whose directory is still there.
|
|
145
|
+
*/
|
|
146
|
+
export function pruneStaleClaudeMarketplaces(runner = run, exists = existsSync) {
|
|
147
|
+
const listed = runner(["plugin", "marketplace", "list", "--json"]);
|
|
148
|
+
if (!listed.ok) {
|
|
149
|
+
return { agent: "claude", skipped: false, removed: [], errors: [listed.out.trim() || "claude plugin marketplace list failed without an error message"] };
|
|
150
|
+
}
|
|
151
|
+
const removed = [];
|
|
152
|
+
const errors = [];
|
|
153
|
+
for (const { name, path } of parseClaudeMarketplaceDirectories(listed.out)) {
|
|
154
|
+
if (!isAdgOwnedName(name) || exists(path))
|
|
155
|
+
continue;
|
|
156
|
+
const result = runner(["plugin", "marketplace", "remove", name]);
|
|
157
|
+
if (result.ok)
|
|
158
|
+
removed.push({ name, path });
|
|
159
|
+
else
|
|
160
|
+
errors.push(`failed to remove stale Claude marketplace "${name}": ${result.out.trim() || "no error message"}`);
|
|
161
|
+
}
|
|
162
|
+
return { agent: "claude", skipped: false, removed, errors };
|
|
163
|
+
}
|
|
113
164
|
export const claudeAgent = {
|
|
114
165
|
id: "claude",
|
|
115
166
|
displayName: "Claude Code",
|
|
@@ -176,6 +227,7 @@ export const claudeAgent = {
|
|
|
176
227
|
return fallback;
|
|
177
228
|
return claudeListFailure(textRes.out);
|
|
178
229
|
},
|
|
230
|
+
pruneStale: () => (available() ? pruneStaleClaudeMarketplaces() : { agent: "claude", skipped: true, removed: [], errors: [] }),
|
|
179
231
|
};
|
|
180
232
|
export function claudeListFailure(out) {
|
|
181
233
|
const detail = out.trim() || "claude plugin list failed without an error message";
|
package/dist/src/agents/codex.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { createHash } from "node:crypto";
|
|
2
|
-
import { existsSync, readFileSync } from "node:fs";
|
|
2
|
+
import { existsSync, readdirSync, readFileSync, rmSync } from "node:fs";
|
|
3
3
|
import { homedir } from "node:os";
|
|
4
4
|
import { join, resolve } from "node:path";
|
|
5
5
|
import { SpanKind } from "@opentelemetry/api";
|
|
6
6
|
import { codexMarketplaceRoot, globalPluginsDir, marketplacePath } from "../paths.js";
|
|
7
7
|
import { readMarketplace, writeMarketplace } from "../marketplace.js";
|
|
8
|
-
import { makeCli, skippedResult } from "./base.js";
|
|
8
|
+
import { isAdgOwnedName, isAdgSandboxCacheDirName, makeCli, skippedResult } from "./base.js";
|
|
9
9
|
import { reconcileCodexMarketplaceAliases } from "../codex-marketplace-migration.js";
|
|
10
10
|
import { getTracer, recordTelemetryEvent } from "../telemetry.js";
|
|
11
11
|
const UNRECOGNIZED_PLUGIN_LIST = "codex plugin list returned unrecognized output";
|
|
@@ -81,6 +81,151 @@ function reconcileLegacyAliases(pluginsDir, marketplace, plugins) {
|
|
|
81
81
|
}
|
|
82
82
|
});
|
|
83
83
|
}
|
|
84
|
+
/**
|
|
85
|
+
* Parse `codex plugin marketplace list --json` into every locally-sourced
|
|
86
|
+
* marketplace with its root directory — the shape `pruneStale` needs to decide
|
|
87
|
+
* which registrations are stale. A Git-sourced marketplace has no local root
|
|
88
|
+
* that can vanish this way, so only `sourceType: "local"` entries qualify.
|
|
89
|
+
*/
|
|
90
|
+
export function parseCodexMarketplaceLocalSources(out) {
|
|
91
|
+
try {
|
|
92
|
+
const parsed = JSON.parse(out);
|
|
93
|
+
if (typeof parsed !== "object" || parsed === null)
|
|
94
|
+
return [];
|
|
95
|
+
const marketplaces = parsed.marketplaces;
|
|
96
|
+
if (!Array.isArray(marketplaces))
|
|
97
|
+
return [];
|
|
98
|
+
const entries = [];
|
|
99
|
+
for (const entry of marketplaces) {
|
|
100
|
+
if (typeof entry !== "object" || entry === null)
|
|
101
|
+
continue;
|
|
102
|
+
const { name, marketplaceSource } = entry;
|
|
103
|
+
if (typeof name !== "string" || typeof marketplaceSource !== "object" || marketplaceSource === null)
|
|
104
|
+
continue;
|
|
105
|
+
const { sourceType, source } = marketplaceSource;
|
|
106
|
+
if (sourceType === "local" && typeof source === "string")
|
|
107
|
+
entries.push({ name, path: source });
|
|
108
|
+
}
|
|
109
|
+
return entries;
|
|
110
|
+
}
|
|
111
|
+
catch {
|
|
112
|
+
return [];
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
/** Directory names under `<CODEX_HOME>/plugins/cache` (best-effort; a missing/unreadable root is just empty). */
|
|
116
|
+
function codexCacheDirNames(dir) {
|
|
117
|
+
try {
|
|
118
|
+
return readdirSync(dir, { withFileTypes: true }).filter((entry) => entry.isDirectory()).map((entry) => entry.name);
|
|
119
|
+
}
|
|
120
|
+
catch {
|
|
121
|
+
return [];
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Parse every stale-marketplace bullet out of a `codex plugin marketplace
|
|
126
|
+
* list` failure: `- \`name\` at path: marketplace root does not contain a
|
|
127
|
+
* supported manifest`. Codex fails the WHOLE `list` call (JSON or not) the
|
|
128
|
+
* moment ANY registered marketplace's root lacks a manifest — verified live
|
|
129
|
+
* against codex-cli 0.154.0 — bulleting every offender it found in one
|
|
130
|
+
* message, so this recovers all of them in a single pass rather than just one.
|
|
131
|
+
*/
|
|
132
|
+
export function parseCodexStaleMarketplaceErrors(out) {
|
|
133
|
+
const entries = [];
|
|
134
|
+
for (const m of out.matchAll(/- `([^`]+)` at (.+?): marketplace root does not contain a supported manifest/g)) {
|
|
135
|
+
entries.push({ name: m[1], path: m[2] });
|
|
136
|
+
}
|
|
137
|
+
return entries;
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* Whether a Codex marketplace's registered root (`source`) still resolves to
|
|
141
|
+
* a live ADG marketplace manifest. Checking `existsSync(source)` alone isn't
|
|
142
|
+
* enough: for a canonical `<root>/.agents/plugins` store, Codex is registered
|
|
143
|
+
* against `<root>` (see `codexMarketplaceRoot`), not the plugins directory
|
|
144
|
+
* itself — so after a project's `.agents/` is deleted but its root survives,
|
|
145
|
+
* `source` still exists even though the marketplace is exactly what Codex
|
|
146
|
+
* calls stale. An explicit `--dir` store has no such project root: `source`
|
|
147
|
+
* IS the plugins directory, with `marketplace.json` directly under it.
|
|
148
|
+
*/
|
|
149
|
+
function codexMarketplaceIsLive(source, exists) {
|
|
150
|
+
return exists(join(source, ".agents", "plugins", "marketplace.json")) || exists(join(source, "marketplace.json"));
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* List Codex's registered marketplaces, recovering from the failure mode
|
|
154
|
+
* `parseCodexStaleMarketplaceErrors` targets: one broken ADG-owned
|
|
155
|
+
* registration otherwise fails the whole `list` call and blocks pruning every
|
|
156
|
+
* other, unrelated, genuinely-stale entry. Removes every ADG-owned offender
|
|
157
|
+
* the error names and retries once; a non-ADG-owned offender (not ours to
|
|
158
|
+
* touch) or a `remove` that itself fails is left in `errors` for the caller.
|
|
159
|
+
*/
|
|
160
|
+
function listCodexMarketplaces(runner) {
|
|
161
|
+
const removed = [];
|
|
162
|
+
const errors = [];
|
|
163
|
+
for (let attempt = 0; attempt < 2; attempt++) {
|
|
164
|
+
const listed = runner(["plugin", "marketplace", "list", "--json"]);
|
|
165
|
+
if (listed.ok)
|
|
166
|
+
return { ok: true, sources: parseCodexMarketplaceLocalSources(listed.out), removed, errors };
|
|
167
|
+
const detail = listed.out.trim() || "codex plugin marketplace list failed without an error message";
|
|
168
|
+
const ownedStale = parseCodexStaleMarketplaceErrors(listed.out).filter((e) => isAdgOwnedName(e.name));
|
|
169
|
+
if (attempt === 1 || ownedStale.length === 0)
|
|
170
|
+
return { ok: false, error: detail, removed, errors };
|
|
171
|
+
for (const { name, path } of ownedStale) {
|
|
172
|
+
const result = runner(["plugin", "marketplace", "remove", name]);
|
|
173
|
+
if (result.ok)
|
|
174
|
+
removed.push({ name, path });
|
|
175
|
+
else
|
|
176
|
+
errors.push(`failed to remove stale Codex marketplace "${name}": ${result.out.trim() || "no error message"}`);
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
/* c8 ignore next */
|
|
180
|
+
return { ok: false, error: "codex plugin marketplace list failed without an error message", removed, errors };
|
|
181
|
+
}
|
|
182
|
+
/**
|
|
183
|
+
* Remove every ADG-owned Codex marketplace whose plugins directory no longer
|
|
184
|
+
* exists — e.g. a deleted project, or a test sandbox that leaked into the real
|
|
185
|
+
* `~/.codex` config (see `adg plugins prune`) — then sweep
|
|
186
|
+
* `plugins/cache/adg-<hash>` directories that outlived their registry entry
|
|
187
|
+
* (observed in practice: `codex plugin marketplace remove` doesn't reliably
|
|
188
|
+
* clear the cache snapshot it staged). Never touches a marketplace ADG didn't
|
|
189
|
+
* create (`isAdgOwnedName`), never one whose directory is still there, and the
|
|
190
|
+
* cache sweep never touches the bare global `adg` cache dir (`isAdgSandboxCacheDirName`
|
|
191
|
+
* requires the hash suffix) since that deletion has no CLI-level undo.
|
|
192
|
+
*/
|
|
193
|
+
export function pruneStaleCodexMarketplaces(runner = run, env = process.env, exists = existsSync, listCacheDirNames = codexCacheDirNames, removeCacheDir = (path) => rmSync(path, { recursive: true, force: true })) {
|
|
194
|
+
const listing = listCodexMarketplaces(runner);
|
|
195
|
+
const removed = [...listing.removed];
|
|
196
|
+
const errors = [...listing.errors];
|
|
197
|
+
if (!listing.ok) {
|
|
198
|
+
errors.push(listing.error);
|
|
199
|
+
return { agent: "codex", skipped: false, removed, errors };
|
|
200
|
+
}
|
|
201
|
+
const survivingNames = new Set(listing.sources.map((s) => s.name));
|
|
202
|
+
for (const { name, path } of listing.sources) {
|
|
203
|
+
if (!isAdgOwnedName(name) || codexMarketplaceIsLive(path, exists))
|
|
204
|
+
continue;
|
|
205
|
+
const result = runner(["plugin", "marketplace", "remove", name]);
|
|
206
|
+
if (result.ok) {
|
|
207
|
+
removed.push({ name, path });
|
|
208
|
+
survivingNames.delete(name);
|
|
209
|
+
}
|
|
210
|
+
else {
|
|
211
|
+
errors.push(`failed to remove stale Codex marketplace "${name}": ${result.out.trim() || "no error message"}`);
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
const cacheRoot = join(codexHome(env), "plugins", "cache");
|
|
215
|
+
for (const dirName of listCacheDirNames(cacheRoot)) {
|
|
216
|
+
if (!isAdgSandboxCacheDirName(dirName) || survivingNames.has(dirName))
|
|
217
|
+
continue;
|
|
218
|
+
const path = join(cacheRoot, dirName);
|
|
219
|
+
try {
|
|
220
|
+
removeCacheDir(path);
|
|
221
|
+
removed.push({ name: dirName, path });
|
|
222
|
+
}
|
|
223
|
+
catch (err) {
|
|
224
|
+
errors.push(`failed to remove orphaned Codex cache dir "${dirName}": ${err instanceof Error ? err.message : String(err)}`);
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
return { agent: "codex", skipped: false, removed, errors };
|
|
228
|
+
}
|
|
84
229
|
export const codexAgent = {
|
|
85
230
|
id: "codex",
|
|
86
231
|
displayName: "Codex",
|
|
@@ -143,6 +288,7 @@ export const codexAgent = {
|
|
|
143
288
|
return fallback;
|
|
144
289
|
return codexUnrecognizedListFailure(textRes.out);
|
|
145
290
|
},
|
|
291
|
+
pruneStale: () => (available() ? pruneStaleCodexMarketplaces() : { agent: "codex", skipped: true, removed: [], errors: [] }),
|
|
146
292
|
};
|
|
147
293
|
/** Preserve Codex's diagnostic and offer cleanup for a stale ADG project marketplace. */
|
|
148
294
|
export function codexListFailure(out) {
|
|
@@ -4,12 +4,13 @@ import { initScaffold } from "../commands/init.js";
|
|
|
4
4
|
import { inspectSource } from "../commands/inspect.js";
|
|
5
5
|
import { listPlugins } from "../commands/list.js";
|
|
6
6
|
import { pluginStatus } from "../commands/status.js";
|
|
7
|
+
import { pruneAgents, pruneHasErrors } from "../commands/prune.js";
|
|
7
8
|
import { validatePlugin } from "../commands/validate.js";
|
|
8
9
|
import { ui } from "../render/ui.js";
|
|
9
|
-
import { pluginsListJson, pluginsStatusJson, printJson } from "../render/json.js";
|
|
10
|
-
import { renderPluginList, renderStatus } from "../render/plugins.js";
|
|
10
|
+
import { pluginsListJson, pluginsPruneJson, pluginsStatusJson, printJson } from "../render/json.js";
|
|
11
|
+
import { renderPluginList, renderPrune, renderStatus } from "../render/plugins.js";
|
|
11
12
|
import { fail, parseVerb, resolveScopeDir, resolveTargets, scopeOf, } from "./index.js";
|
|
12
|
-
const CORE_PLUGIN_VERBS = new Set(["init", "adapt", "validate", "inspect", "list", "status"]);
|
|
13
|
+
const CORE_PLUGIN_VERBS = new Set(["init", "adapt", "validate", "inspect", "list", "status", "prune"]);
|
|
13
14
|
export async function handleCorePluginVerb(verb, rest, cmd) {
|
|
14
15
|
if (!CORE_PLUGIN_VERBS.has(verb))
|
|
15
16
|
return false;
|
|
@@ -93,5 +94,23 @@ export async function handleCorePluginVerb(verb, rest, cmd) {
|
|
|
93
94
|
console.log(line);
|
|
94
95
|
return true;
|
|
95
96
|
}
|
|
97
|
+
case "prune": {
|
|
98
|
+
const { values } = parseVerb(verb, cmd.flags, rest);
|
|
99
|
+
const targets = resolveTargets(values.target);
|
|
100
|
+
const results = pruneAgents({ targets });
|
|
101
|
+
if (values.json)
|
|
102
|
+
printJson(pluginsPruneJson(results, targets));
|
|
103
|
+
else
|
|
104
|
+
for (const line of renderPrune(results))
|
|
105
|
+
console.log(line);
|
|
106
|
+
// A per-agent error means a stale registration was found but ADG
|
|
107
|
+
// couldn't clean it up (the agent's CLI rejected the removal, etc) — a
|
|
108
|
+
// real failure of this mutating command, not the read-only "found
|
|
109
|
+
// drift" outcome `status` reports at exit 0. See docs/cli-json.md's
|
|
110
|
+
// exit-code contract for `adg plugins prune --json`.
|
|
111
|
+
if (pruneHasErrors(results))
|
|
112
|
+
process.exit(1);
|
|
113
|
+
return true;
|
|
114
|
+
}
|
|
96
115
|
}
|
|
97
116
|
}
|
package/dist/src/cli/index.js
CHANGED
|
@@ -71,6 +71,17 @@ export const PLUGIN_COMMANDS = {
|
|
|
71
71
|
blurb: "Query each agent's CLI live and diff it against the store: what's in\nsync, missing (needs `link`/`sync`), or present in the agent only. Each drift\nrow carries the command that repairs it. Inspects the active scope (--global →\nuser, else project). Name-level only — run `sync` if unsure.",
|
|
72
72
|
flags: ["target", "json", ...SCOPE],
|
|
73
73
|
},
|
|
74
|
+
prune: {
|
|
75
|
+
summary: "remove stale agent-side registrations for deleted plugin directories",
|
|
76
|
+
synopsis: "adg plugins prune [--target claude|codex|antigravity]",
|
|
77
|
+
blurb: "Scans each agent's own marketplace/cache registry for ADG-owned entries\n" +
|
|
78
|
+
"(`adg` / `adg-<hash>`) whose plugin directory no longer exists on disk —\n" +
|
|
79
|
+
"a deleted project, or a test sandbox that leaked into the real agent config —\n" +
|
|
80
|
+
"and removes them via that agent's own CLI. Never touches a marketplace ADG\n" +
|
|
81
|
+
"didn't create, and never one whose directory still exists. Unscoped: checks\n" +
|
|
82
|
+
"every registration the agent knows about, not just the active project/global store.",
|
|
83
|
+
flags: ["target", "json"],
|
|
84
|
+
},
|
|
74
85
|
update: {
|
|
75
86
|
summary: "pull upstream changes for installed plugins",
|
|
76
87
|
synopsis: "adg plugins update [<source>]",
|
|
@@ -20,6 +20,7 @@ const S_BAR_END = g("└", "—");
|
|
|
20
20
|
const S_STEP_ACTIVE = g("◆", "*");
|
|
21
21
|
const S_STEP_SUBMIT = g("◇", "o");
|
|
22
22
|
const S_STEP_CANCEL = g("■", "x");
|
|
23
|
+
const S_STEP_ERROR = g("▲", "!");
|
|
23
24
|
const S_CHECK_ACTIVE = g("◻", "[•]");
|
|
24
25
|
const S_CHECK_SELECTED = g("◼", "[+]");
|
|
25
26
|
const S_CHECK_INACTIVE = g("◻", "[ ]");
|
|
@@ -59,17 +60,20 @@ export function multiselectSkills(opts) {
|
|
|
59
60
|
return pc.green(S_STEP_SUBMIT);
|
|
60
61
|
if (state === "cancel")
|
|
61
62
|
return pc.red(S_STEP_CANCEL);
|
|
63
|
+
if (state === "error")
|
|
64
|
+
return pc.yellow(S_STEP_ERROR);
|
|
62
65
|
return pc.cyan(S_STEP_ACTIVE);
|
|
63
66
|
};
|
|
64
67
|
const footer = () => pc.dim(`space ${pc.gray("toggle")} · a ${pc.gray("all")} · d ${pc.gray(showDesc ? "hide" : "show")} descriptions`);
|
|
68
|
+
const required = opts.required ?? true;
|
|
65
69
|
const prompt = new MultiSelectPrompt({
|
|
66
70
|
input: opts.input,
|
|
67
71
|
output: opts.output,
|
|
68
72
|
options: opts.options,
|
|
69
73
|
initialValues: opts.initialValues,
|
|
70
|
-
required
|
|
74
|
+
required,
|
|
71
75
|
validate(value) {
|
|
72
|
-
if (
|
|
76
|
+
if (required && Array.isArray(value) && value.length === 0) {
|
|
73
77
|
return "Please select at least one option.";
|
|
74
78
|
}
|
|
75
79
|
return undefined;
|
|
@@ -90,7 +94,10 @@ export function multiselectSkills(opts) {
|
|
|
90
94
|
showDesc,
|
|
91
95
|
loadDescription: opts.loadDescription,
|
|
92
96
|
}).join(`\n${pc.cyan(S_BAR)} `);
|
|
93
|
-
|
|
97
|
+
const errorBar = this.state === "error" && this.error
|
|
98
|
+
? `${pc.yellow(S_BAR_END)} ${pc.yellow(this.error)}\n`
|
|
99
|
+
: `${pc.cyan(S_BAR_END)}\n`;
|
|
100
|
+
return `${head}${pc.cyan(S_BAR)} ${rows}\n${pc.cyan(S_BAR)} ${footer()}\n${errorBar}`;
|
|
94
101
|
},
|
|
95
102
|
});
|
|
96
103
|
// `a` (toggle-all) is bound by MultiSelectPrompt itself; `d` is free for us.
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { allAgents, resolveAgents } from "../agents/index.js";
|
|
2
|
+
/**
|
|
3
|
+
* `adg plugins prune` — ask every resolved agent to remove its own ADG-owned
|
|
4
|
+
* registrations (marketplaces, cached snapshots, …) that still point at a
|
|
5
|
+
* plugin directory ADG no longer has on disk. Read-only for agents that don't
|
|
6
|
+
* implement `pruneStale` (e.g. Antigravity's file-projection model has nothing
|
|
7
|
+
* analogous to prune), which report back `skipped: true`.
|
|
8
|
+
*/
|
|
9
|
+
export function pruneAgents(opts = {}) {
|
|
10
|
+
const agents = opts.agents ?? (opts.targets ? resolveAgents(opts.targets) : allAgents());
|
|
11
|
+
return agents.map((agent) => agent.pruneStale?.() ?? { agent: agent.id, skipped: true, removed: [], errors: [] });
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Whether `adg plugins prune` should exit non-zero: a stale registration was
|
|
15
|
+
* found but ADG couldn't clean it up (the agent's CLI rejected the removal,
|
|
16
|
+
* etc). This is a real failure of this mutating command — unlike `status`,
|
|
17
|
+
* which reports drift at exit 0 because finding it IS the successful outcome
|
|
18
|
+
* of a read-only diagnostic.
|
|
19
|
+
*/
|
|
20
|
+
export function pruneHasErrors(results) {
|
|
21
|
+
return results.some((r) => r.errors.length > 0);
|
|
22
|
+
}
|
package/dist/src/render/json.js
CHANGED
|
@@ -38,6 +38,10 @@ export function pluginsListJson(plugins, pluginsDir) {
|
|
|
38
38
|
export function pluginsStatusJson(statuses, pluginsDir, scope, targets) {
|
|
39
39
|
return { pluginsDir, scope, targets, statuses };
|
|
40
40
|
}
|
|
41
|
+
/** Stable machine-readable shape for `adg plugins prune --json`. */
|
|
42
|
+
export function pluginsPruneJson(results, targets) {
|
|
43
|
+
return { targets, results };
|
|
44
|
+
}
|
|
41
45
|
export function printJson(value) {
|
|
42
46
|
console.log(JSON.stringify(value, null, 2));
|
|
43
47
|
}
|
|
@@ -167,6 +167,41 @@ export function renderStatus(statuses) {
|
|
|
167
167
|
out.push(ui.meta("note: name-level only; content drift isn't shown — run `adg plugins sync` if unsure."));
|
|
168
168
|
return out;
|
|
169
169
|
}
|
|
170
|
+
/**
|
|
171
|
+
* `adg plugins prune` — per-agent report of ADG-owned registrations removed
|
|
172
|
+
* because their plugin directory no longer exists on disk.
|
|
173
|
+
*/
|
|
174
|
+
export function renderPrune(results) {
|
|
175
|
+
if (results.length === 0)
|
|
176
|
+
return [ui.meta("no agents detected — nothing to prune.")];
|
|
177
|
+
const out = [];
|
|
178
|
+
let totalRemoved = 0;
|
|
179
|
+
for (const r of results) {
|
|
180
|
+
const display = getAgent(r.agent)?.displayName ?? r.agent;
|
|
181
|
+
out.push(ui.name(display));
|
|
182
|
+
if (r.skipped) {
|
|
183
|
+
out.push(ui.meta(" skipped — nothing was scanned (agent CLI unavailable or no registry to prune)"));
|
|
184
|
+
continue;
|
|
185
|
+
}
|
|
186
|
+
if (r.removed.length === 0 && r.errors.length === 0) {
|
|
187
|
+
out.push(ui.meta(" nothing stale"));
|
|
188
|
+
}
|
|
189
|
+
for (const entry of r.removed) {
|
|
190
|
+
totalRemoved += 1;
|
|
191
|
+
out.push(` ${ui.ok("removed")} ${ui.name(entry.name)} ${ui.meta(`(missing: ${entry.path})`)}`);
|
|
192
|
+
}
|
|
193
|
+
for (const error of r.errors)
|
|
194
|
+
out.push(ui.warn(` ${error}`));
|
|
195
|
+
}
|
|
196
|
+
// Only claim "found nothing stale" when something was actually checked —
|
|
197
|
+
// an all-skipped run (no agent CLI available) didn't check anything, so
|
|
198
|
+
// saying so would misrepresent "not checked" as "checked and clean".
|
|
199
|
+
const anyChecked = results.some((r) => !r.skipped);
|
|
200
|
+
if (anyChecked && totalRemoved === 0 && results.every((r) => r.errors.length === 0)) {
|
|
201
|
+
out.push(ui.meta("no stale registrations found"));
|
|
202
|
+
}
|
|
203
|
+
return out;
|
|
204
|
+
}
|
|
170
205
|
/**
|
|
171
206
|
* `adg plugins marketplace list` — installed plugins grouped by source.
|
|
172
207
|
* `details` (name → ListedPlugin) enables the verbose per-plugin component drill;
|
package/dist/src/telemetry.js
CHANGED
package/docs/cli-json.md
CHANGED
|
@@ -8,6 +8,7 @@ can integrate over the CLI boundary without scraping human-formatted text.
|
|
|
8
8
|
- Supported commands in this contract:
|
|
9
9
|
- `adg plugins list --json`
|
|
10
10
|
- `adg plugins status --json`
|
|
11
|
+
- `adg plugins prune --json`
|
|
11
12
|
- On success, stdout contains exactly one valid JSON document and no human
|
|
12
13
|
formatting, ANSI color, notes, or tips.
|
|
13
14
|
- On failure, diagnostics are written to stderr and the process exits non-zero.
|
|
@@ -119,3 +120,39 @@ Field notes:
|
|
|
119
120
|
`agentOnly` remains reserved for runtime plugins absent from the store.
|
|
120
121
|
Content drift is not represented; use `adg plugins sync` when a full runtime
|
|
121
122
|
refresh is required.
|
|
123
|
+
|
|
124
|
+
## `adg plugins prune --json`
|
|
125
|
+
|
|
126
|
+
Shape:
|
|
127
|
+
|
|
128
|
+
```json
|
|
129
|
+
{
|
|
130
|
+
"targets": ["claude", "codex", "antigravity"],
|
|
131
|
+
"results": [
|
|
132
|
+
{
|
|
133
|
+
"agent": "claude",
|
|
134
|
+
"skipped": false,
|
|
135
|
+
"removed": [
|
|
136
|
+
{ "name": "adg-deadbeef", "path": "/var/folders/.../T/adg-cache-sandbox-xyz/state/plugins" }
|
|
137
|
+
],
|
|
138
|
+
"errors": []
|
|
139
|
+
},
|
|
140
|
+
{ "agent": "codex", "skipped": false, "removed": [], "errors": [] },
|
|
141
|
+
{ "agent": "antigravity", "skipped": true, "removed": [], "errors": [] }
|
|
142
|
+
]
|
|
143
|
+
}
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
Field notes:
|
|
147
|
+
|
|
148
|
+
- `targets` contains the resolved target ids requested by `--target`; omitted
|
|
149
|
+
`--target` resolves to all registered targets.
|
|
150
|
+
- `skipped: true` means either the agent's CLI wasn't available, or the agent
|
|
151
|
+
has no persistent external registry to prune (e.g. Antigravity's
|
|
152
|
+
file-projection model — it has nothing analogous).
|
|
153
|
+
- `removed` lists every ADG-owned registration (`adg` / `adg-<hash>`) actually
|
|
154
|
+
deleted because its `path` no longer exists on disk. A registration ADG
|
|
155
|
+
didn't create, or whose directory is still there, is never listed or touched.
|
|
156
|
+
- `errors` carries diagnostics for entries recognized as stale that could not
|
|
157
|
+
be removed (the agent's CLI rejected the removal, etc) — these are not
|
|
158
|
+
fatal; other agents/entries are still processed.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rbbtsn0w/adg",
|
|
3
|
-
"version": "0.9.0-dev.
|
|
3
|
+
"version": "0.9.0-dev.pr111.8698552",
|
|
4
4
|
"description": "Agent Directory Group (ADG) toolkit — two domains: plugins and skills.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -28,6 +28,7 @@
|
|
|
28
28
|
"test:codex-sandbox": "node --test test/codex-sandbox.test.mjs",
|
|
29
29
|
"test:cache-sandbox": "node --test test/cache-sandbox.test.mjs",
|
|
30
30
|
"check:docs": "node scripts/check-doc-links.mjs",
|
|
31
|
+
"check:test-isolation": "node scripts/check-test-cli-isolation.mjs",
|
|
31
32
|
"check:package-smoke": "node scripts/check-package-smoke.mjs",
|
|
32
33
|
"check:vendor-deps": "node scripts/check-vendor-deps.mjs",
|
|
33
34
|
"check:vendor-upstream": "node scripts/check-vendor-upstream.mjs",
|