@rbbtsn0w/adg 0.6.0-beta.1 → 0.6.0-beta.10
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 +31 -2
- package/dist/bin/adg.js +0 -1
- package/dist/src/adapters/codex.js +12 -0
- package/dist/src/adapters/reverse.js +22 -1
- package/dist/src/agents/claude.js +52 -6
- package/dist/src/agents/codex.js +94 -14
- package/dist/src/cli/handlers.js +164 -141
- package/dist/src/cli/index.js +14 -4
- package/dist/src/codex-marketplace-migration.js +139 -0
- package/dist/src/commands/cache.js +92 -15
- package/dist/src/commands/inspect.js +41 -0
- package/dist/src/commands/install.js +140 -73
- package/dist/src/commands/link.js +4 -16
- package/dist/src/commands/marketplace.js +74 -20
- package/dist/src/commands/migrate.js +15 -3
- package/dist/src/commands/projection.js +15 -0
- package/dist/src/commands/select-components.js +12 -0
- package/dist/src/commands/state.js +4 -2
- package/dist/src/commands/sync.js +9 -15
- package/dist/src/commands/update.js +51 -10
- package/dist/src/commands/validate.js +9 -2
- package/dist/src/components.js +3 -0
- package/dist/src/default-dsl.js +142 -0
- package/dist/src/lock.js +25 -7
- package/dist/src/manifest.js +29 -1
- package/dist/src/materialize.js +5 -1
- package/dist/src/mcp.js +59 -0
- package/dist/src/paths.js +31 -4
- package/dist/src/render/plugins.js +7 -1
- package/dist/src/source-cache.js +140 -0
- package/dist/src/sources.js +76 -5
- package/dist/src/telemetry.js +28 -21
- package/dist/src/types.js +5 -1
- package/dist/vendor/skills/src/cli.js +6 -1
- package/dist/vendor/skills/src/update.js +29 -4
- package/docs/agents-spec.md +27 -4
- package/docs/authoring.md +19 -2
- package/package.json +8 -2
- package/schemas/adg-plugin.schema.json +1 -0
- package/schemas/plugin-lock.schema.json +23 -1
- package/vendor/skills/src/cli.ts +6 -1
- package/vendor/skills/src/update.ts +32 -4
package/dist/src/cli/handlers.js
CHANGED
|
@@ -5,6 +5,7 @@ import { addPlugins } from "../commands/install.js";
|
|
|
5
5
|
import { validatePlugin } from "../commands/validate.js";
|
|
6
6
|
import { listPlugins } from "../commands/list.js";
|
|
7
7
|
import { importSkills } from "../commands/import.js";
|
|
8
|
+
import { inspectSource } from "../commands/inspect.js";
|
|
8
9
|
import { linkPlugins } from "../commands/link.js";
|
|
9
10
|
import { unlinkPlugins } from "../commands/unlink.js";
|
|
10
11
|
import { syncPlugins } from "../commands/sync.js";
|
|
@@ -12,7 +13,7 @@ import { removePlugin } from "../commands/remove.js";
|
|
|
12
13
|
import { disablePlugins, enablePlugins } from "../commands/state.js";
|
|
13
14
|
import { migrateLayout } from "../commands/migrate.js";
|
|
14
15
|
import { pluginStatus } from "../commands/status.js";
|
|
15
|
-
import { cleanPluginCache, pluginCacheStatus, prunePluginCache } from "../commands/cache.js";
|
|
16
|
+
import { cleanPluginCache, pluginCacheStatus, prunePluginCache, restorePluginCache } from "../commands/cache.js";
|
|
16
17
|
import { marketplaceList, marketplaceRemove, marketplaceSync, updatePlugins } from "../commands/marketplace.js";
|
|
17
18
|
import { initScaffold } from "../commands/init.js";
|
|
18
19
|
import { confirmFullInstall, selectComponentsInteractive } from "../commands/select-components.js";
|
|
@@ -132,6 +133,14 @@ async function resolveActionScope(values, verb) {
|
|
|
132
133
|
info: { label: global ? "global" : "project", globalDir },
|
|
133
134
|
};
|
|
134
135
|
}
|
|
136
|
+
function resolveVerbTargets(values, verb) {
|
|
137
|
+
return values.target === "all"
|
|
138
|
+
? resolveTargets("all")
|
|
139
|
+
: [requireSingleTarget(values.target, verb)];
|
|
140
|
+
}
|
|
141
|
+
function printCliUnavailableNote(target, message) {
|
|
142
|
+
console.log(ui.warn(`note: \`${target}\` CLI not found — ${message}`));
|
|
143
|
+
}
|
|
135
144
|
/**
|
|
136
145
|
* Top-level dispatcher for `adg plugins <verb>`: render help, resolve aliases,
|
|
137
146
|
* look the verb up in the command table, then hand off to the per-verb handler
|
|
@@ -163,6 +172,135 @@ export async function runPlugins(rawVerb, rest) {
|
|
|
163
172
|
return runCache(rest);
|
|
164
173
|
return runPluginsVerb(verb, rest, cmd);
|
|
165
174
|
}
|
|
175
|
+
async function handleAdd(rest, cmd) {
|
|
176
|
+
const { values, positionals } = parseVerb("add", cmd.flags, rest);
|
|
177
|
+
const spec = positionals[0];
|
|
178
|
+
if (!spec)
|
|
179
|
+
fail("plugins add requires a <plugin-dir | owner/repo[@ref] | github-url>");
|
|
180
|
+
const tty = process.stdin.isTTY;
|
|
181
|
+
let global = Boolean(values.global);
|
|
182
|
+
if (!values.dir && values.global === undefined && values.project === undefined && tty) {
|
|
183
|
+
global = await selectScopeInteractive();
|
|
184
|
+
}
|
|
185
|
+
if (!values.dir)
|
|
186
|
+
global = promoteGlobalTrap(global);
|
|
187
|
+
const pluginsDir = values.dir
|
|
188
|
+
? resolve(values.dir)
|
|
189
|
+
: global
|
|
190
|
+
? globalPluginsDir()
|
|
191
|
+
: projectPluginsDir();
|
|
192
|
+
const only = resolveComponents(values.only);
|
|
193
|
+
const skillsSubset = values.skill && values.skill.length > 0 ? values.skill : undefined;
|
|
194
|
+
const mcpSubset = values.mcp && values.mcp.length > 0 ? values.mcp : undefined;
|
|
195
|
+
const narrowed = only !== undefined || skillsSubset !== undefined || mcpSubset !== undefined;
|
|
196
|
+
const { order, installed, removed, converted, agents } = await addPlugins({
|
|
197
|
+
spec,
|
|
198
|
+
pluginsDir,
|
|
199
|
+
ref: values.ref,
|
|
200
|
+
sparse: values.sparse,
|
|
201
|
+
all: values.all,
|
|
202
|
+
plugins: values.plugin,
|
|
203
|
+
only,
|
|
204
|
+
skillsSubset,
|
|
205
|
+
mcpSubset,
|
|
206
|
+
withDeps: !values["no-deps"],
|
|
207
|
+
marketplaceName: values["marketplace-name"],
|
|
208
|
+
as: values.as,
|
|
209
|
+
targets: values.target !== undefined ? resolveTargets(values.target) : undefined,
|
|
210
|
+
selectPlugins: tty ? selectPluginsInteractive : undefined,
|
|
211
|
+
selectTargets: tty && values.target === undefined ? selectTargetsInteractive : undefined,
|
|
212
|
+
confirmFull: tty && !narrowed ? confirmFullInstall : undefined,
|
|
213
|
+
selectComponents: tty && !narrowed ? selectComponentsInteractive : undefined,
|
|
214
|
+
activate: true,
|
|
215
|
+
nonInteractive: !tty,
|
|
216
|
+
scope: global ? "user" : "project",
|
|
217
|
+
});
|
|
218
|
+
for (const name of converted)
|
|
219
|
+
console.log(ui.meta(`converted native manifest -> .agents/.plugin.json: ${name}`));
|
|
220
|
+
for (const name of removed)
|
|
221
|
+
console.log(`${ui.warn("removed")} ${ui.name(name)}`);
|
|
222
|
+
if (order.length > 1)
|
|
223
|
+
console.log(ui.meta(`install order: ${order.join(" -> ")}`));
|
|
224
|
+
for (const res of installed) {
|
|
225
|
+
console.log(`${ui.ok("added")} ${ui.name(res.name)} ${ui.meta(`-> ${res.installedTo}`)}`);
|
|
226
|
+
console.log(ui.meta(` sourceHash: ${res.sourceHash}`));
|
|
227
|
+
console.log(ui.meta(` installedHash: ${res.installedHash}`));
|
|
228
|
+
for (const f of res.adapted)
|
|
229
|
+
console.log(ui.meta(` adapted: ${f}`));
|
|
230
|
+
}
|
|
231
|
+
for (const line of renderAgentReport(agents, "enabled"))
|
|
232
|
+
console.log(line);
|
|
233
|
+
}
|
|
234
|
+
async function handleLink(rest, cmd) {
|
|
235
|
+
const { values, positionals } = parseVerb("link", cmd.flags, rest);
|
|
236
|
+
const targets = resolveVerbTargets(values, "link");
|
|
237
|
+
const sc = await resolveActionScope(values, "link");
|
|
238
|
+
const names = positionals.length > 0 ? positionals : undefined;
|
|
239
|
+
for (const target of targets) {
|
|
240
|
+
const res = linkPlugins({ pluginsDir: sc.pluginsDir, target, global: sc.global, names });
|
|
241
|
+
for (const action of res.actions) {
|
|
242
|
+
console.log(`${ui.ok("linked")} ${ui.name(action.name)} ${ui.meta(`[${res.target}]`)}${action.linkedTo ? ui.meta(` -> ${action.linkedTo}`) : ""}`);
|
|
243
|
+
for (const file of action.adapted)
|
|
244
|
+
console.log(ui.meta(` adapted: ${file}`));
|
|
245
|
+
}
|
|
246
|
+
if (res.cliSkipped)
|
|
247
|
+
printCliUnavailableNote(target, `manifests were generated, but nothing was enabled in ${target}.`);
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
async function handleUnlink(rest, cmd) {
|
|
251
|
+
const { values, positionals } = parseVerb("unlink", cmd.flags, rest);
|
|
252
|
+
const targets = resolveVerbTargets(values, "unlink");
|
|
253
|
+
const sc = await resolveActionScope(values, "unlink");
|
|
254
|
+
const names = positionals.length > 0 ? positionals : undefined;
|
|
255
|
+
for (const target of targets) {
|
|
256
|
+
const res = unlinkPlugins({ pluginsDir: sc.pluginsDir, target, global: sc.global, names });
|
|
257
|
+
for (const name of res.unlinked)
|
|
258
|
+
console.log(`${ui.ok("unlinked")} ${ui.name(name)} ${ui.meta(`[${res.target}]`)}`);
|
|
259
|
+
if (res.cliSkipped) {
|
|
260
|
+
printCliUnavailableNote(target, `nothing was unlinked from ${target}.`);
|
|
261
|
+
}
|
|
262
|
+
else if (res.unlinked.length === 0 && targets.length === 1) {
|
|
263
|
+
console.log(ui.meta(`nothing to unlink from ${target}`));
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
async function handleSync(rest, cmd) {
|
|
268
|
+
const { values, positionals } = parseVerb("sync", cmd.flags, rest);
|
|
269
|
+
const targets = resolveVerbTargets(values, "sync");
|
|
270
|
+
const sc = await resolveActionScope(values, "sync");
|
|
271
|
+
const names = positionals.length > 0 ? positionals : undefined;
|
|
272
|
+
for (const target of targets) {
|
|
273
|
+
const res = syncPlugins({ pluginsDir: sc.pluginsDir, target, global: sc.global, names });
|
|
274
|
+
for (const action of res.actions) {
|
|
275
|
+
const tail = action.synced ? ui.meta(` -> ${res.target}`) : "";
|
|
276
|
+
console.log(`${ui.ok("synced")} ${ui.name(action.name)} ${ui.meta(`[${res.target}]`)}${tail}`);
|
|
277
|
+
}
|
|
278
|
+
if (res.cliSkipped)
|
|
279
|
+
printCliUnavailableNote(target, `manifests were regenerated, but nothing was re-synced in ${target}.`);
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
async function handleUpdate(rest, cmd) {
|
|
283
|
+
const { values, positionals } = parseVerb("update", cmd.flags, rest);
|
|
284
|
+
const source = positionals[0];
|
|
285
|
+
for (const sc of await resolveUpdateScopes(values)) {
|
|
286
|
+
if (sc.heading)
|
|
287
|
+
console.log(`${ui.name(sc.heading)}`);
|
|
288
|
+
try {
|
|
289
|
+
const result = await updatePlugins({
|
|
290
|
+
pluginsDir: sc.dir,
|
|
291
|
+
source,
|
|
292
|
+
all: values.all,
|
|
293
|
+
activate: true,
|
|
294
|
+
agentScope: sc.agentScope,
|
|
295
|
+
scope: { label: sc.label, globalDir: globalPluginsDir() },
|
|
296
|
+
});
|
|
297
|
+
printUpdateReport(result);
|
|
298
|
+
}
|
|
299
|
+
catch (err) {
|
|
300
|
+
console.error(`${ui.err("error:")} ${err instanceof Error ? err.message : String(err)}`);
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
}
|
|
166
304
|
async function runPluginsVerb(verb, rest, cmd) {
|
|
167
305
|
switch (verb) {
|
|
168
306
|
case "init": {
|
|
@@ -204,70 +342,17 @@ async function runPluginsVerb(verb, rest, cmd) {
|
|
|
204
342
|
}
|
|
205
343
|
return;
|
|
206
344
|
}
|
|
207
|
-
case "
|
|
345
|
+
case "inspect": {
|
|
208
346
|
const { values, positionals } = parseVerb(verb, cmd.flags, rest);
|
|
209
|
-
const
|
|
210
|
-
if (
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
}
|
|
219
|
-
// Guard the home==global trap: installing global plugins at project scope
|
|
220
|
-
// would pin them to the cwd. Skip for an explicit --dir store.
|
|
221
|
-
if (!values.dir)
|
|
222
|
-
global = promoteGlobalTrap(global);
|
|
223
|
-
const pluginsDir = values.dir
|
|
224
|
-
? resolve(values.dir)
|
|
225
|
-
: global
|
|
226
|
-
? globalPluginsDir()
|
|
227
|
-
: projectPluginsDir();
|
|
228
|
-
// A source may hold one plugin or a whole marketplace. addPlugins discovers
|
|
229
|
-
// all of them; in a terminal the user picks scope, then plugins, then agents,
|
|
230
|
-
// then (unless --only/--skill narrow it) chooses what to install per plugin.
|
|
231
|
-
// --all / --plugin / --path / --only / --skill narrow non-interactively.
|
|
232
|
-
const only = resolveComponents(values.only);
|
|
233
|
-
const skillsSubset = values.skill && values.skill.length > 0 ? values.skill : undefined;
|
|
234
|
-
const narrowed = only !== undefined || skillsSubset !== undefined;
|
|
235
|
-
const { order, installed, removed, converted, agents } = await addPlugins({
|
|
236
|
-
spec,
|
|
237
|
-
pluginsDir,
|
|
238
|
-
ref: values.ref,
|
|
239
|
-
sparse: values.sparse,
|
|
240
|
-
path: values.path,
|
|
241
|
-
all: values.all,
|
|
242
|
-
plugins: values.plugin,
|
|
243
|
-
only,
|
|
244
|
-
skillsSubset,
|
|
245
|
-
withDeps: !values["no-deps"],
|
|
246
|
-
marketplaceName: values["marketplace-name"],
|
|
247
|
-
targets: values.target !== undefined ? resolveTargets(values.target) : undefined,
|
|
248
|
-
selectPlugins: tty ? selectPluginsInteractive : undefined,
|
|
249
|
-
selectTargets: tty && values.target === undefined ? selectTargetsInteractive : undefined,
|
|
250
|
-
confirmFull: tty && !narrowed ? confirmFullInstall : undefined,
|
|
251
|
-
selectComponents: tty && !narrowed ? selectComponentsInteractive : undefined,
|
|
252
|
-
// Make the install actually usable in the chosen agents, not just stored.
|
|
253
|
-
activate: true,
|
|
254
|
-
scope: global ? "user" : "project",
|
|
255
|
-
});
|
|
256
|
-
for (const name of converted)
|
|
257
|
-
console.log(ui.meta(`converted native manifest -> .agents/.plugin.json: ${name}`));
|
|
258
|
-
for (const name of removed)
|
|
259
|
-
console.log(`${ui.warn("removed")} ${ui.name(name)}`);
|
|
260
|
-
if (order.length > 1)
|
|
261
|
-
console.log(ui.meta(`install order: ${order.join(" -> ")}`));
|
|
262
|
-
for (const res of installed) {
|
|
263
|
-
console.log(`${ui.ok("added")} ${ui.name(res.name)} ${ui.meta(`-> ${res.installedTo}`)}`);
|
|
264
|
-
console.log(ui.meta(` sourceHash: ${res.sourceHash}`));
|
|
265
|
-
console.log(ui.meta(` installedHash: ${res.installedHash}`));
|
|
266
|
-
for (const f of res.adapted)
|
|
267
|
-
console.log(ui.meta(` adapted: ${f}`));
|
|
268
|
-
}
|
|
269
|
-
for (const line of renderAgentReport(agents, "enabled"))
|
|
270
|
-
console.log(line);
|
|
347
|
+
const result = await inspectSource({ spec: positionals[0] ?? process.cwd(), ref: values.ref });
|
|
348
|
+
if (values.json)
|
|
349
|
+
console.log(JSON.stringify(result, null, 2));
|
|
350
|
+
else
|
|
351
|
+
console.log(`${ui.ok("inspected")} ${ui.name(result.manifest.name)} ${ui.meta(`[${result.kind}] ${result.components.join(", ") || "no components"}`)}`);
|
|
352
|
+
return;
|
|
353
|
+
}
|
|
354
|
+
case "add": {
|
|
355
|
+
await handleAdd(rest, cmd);
|
|
271
356
|
return;
|
|
272
357
|
}
|
|
273
358
|
case "import-skills": {
|
|
@@ -289,23 +374,7 @@ async function runPluginsVerb(verb, rest, cmd) {
|
|
|
289
374
|
return;
|
|
290
375
|
}
|
|
291
376
|
case "link": {
|
|
292
|
-
|
|
293
|
-
const targets = values.target === "all"
|
|
294
|
-
? resolveTargets("all")
|
|
295
|
-
: [requireSingleTarget(values.target, "link")];
|
|
296
|
-
const sc = await resolveActionScope(values, "link");
|
|
297
|
-
const names = positionals.length > 0 ? positionals : undefined;
|
|
298
|
-
for (const target of targets) {
|
|
299
|
-
const res = linkPlugins({ pluginsDir: sc.pluginsDir, target, global: sc.global, names });
|
|
300
|
-
for (const a of res.actions) {
|
|
301
|
-
console.log(`${ui.ok("linked")} ${ui.name(a.name)} ${ui.meta(`[${res.target}]`)}${a.linkedTo ? ui.meta(` -> ${a.linkedTo}`) : ""}`);
|
|
302
|
-
for (const f of a.adapted)
|
|
303
|
-
console.log(ui.meta(` adapted: ${f}`));
|
|
304
|
-
}
|
|
305
|
-
if (res.cliSkipped) {
|
|
306
|
-
console.log(ui.warn(`note: \`${target}\` CLI not found — manifests were generated, but nothing was enabled in ${target}.`));
|
|
307
|
-
}
|
|
308
|
-
}
|
|
377
|
+
await handleLink(rest, cmd);
|
|
309
378
|
return;
|
|
310
379
|
}
|
|
311
380
|
case "disable":
|
|
@@ -331,67 +400,15 @@ async function runPluginsVerb(verb, rest, cmd) {
|
|
|
331
400
|
return;
|
|
332
401
|
}
|
|
333
402
|
case "unlink": {
|
|
334
|
-
|
|
335
|
-
const targets = values.target === "all"
|
|
336
|
-
? resolveTargets("all")
|
|
337
|
-
: [requireSingleTarget(values.target, "unlink")];
|
|
338
|
-
const sc = await resolveActionScope(values, "unlink");
|
|
339
|
-
const names = positionals.length > 0 ? positionals : undefined;
|
|
340
|
-
for (const target of targets) {
|
|
341
|
-
const res = unlinkPlugins({ pluginsDir: sc.pluginsDir, target, global: sc.global, names });
|
|
342
|
-
for (const name of res.unlinked)
|
|
343
|
-
console.log(`${ui.ok("unlinked")} ${ui.name(name)} ${ui.meta(`[${res.target}]`)}`);
|
|
344
|
-
if (res.cliSkipped) {
|
|
345
|
-
console.log(ui.warn(`note: \`${target}\` CLI not found — nothing was unlinked from ${target}.`));
|
|
346
|
-
}
|
|
347
|
-
else if (res.unlinked.length === 0) {
|
|
348
|
-
if (targets.length === 1) {
|
|
349
|
-
console.log(ui.meta(`nothing to unlink from ${target}`));
|
|
350
|
-
}
|
|
351
|
-
}
|
|
352
|
-
}
|
|
403
|
+
await handleUnlink(rest, cmd);
|
|
353
404
|
return;
|
|
354
405
|
}
|
|
355
406
|
case "sync": {
|
|
356
|
-
|
|
357
|
-
const targets = values.target === "all"
|
|
358
|
-
? resolveTargets("all")
|
|
359
|
-
: [requireSingleTarget(values.target, "sync")];
|
|
360
|
-
const sc = await resolveActionScope(values, "sync");
|
|
361
|
-
const names = positionals.length > 0 ? positionals : undefined;
|
|
362
|
-
for (const target of targets) {
|
|
363
|
-
const res = syncPlugins({ pluginsDir: sc.pluginsDir, target, global: sc.global, names });
|
|
364
|
-
for (const a of res.actions) {
|
|
365
|
-
const tail = a.synced ? ui.meta(` -> ${res.target}`) : "";
|
|
366
|
-
console.log(`${ui.ok("synced")} ${ui.name(a.name)} ${ui.meta(`[${res.target}]`)}${tail}`);
|
|
367
|
-
}
|
|
368
|
-
if (res.cliSkipped) {
|
|
369
|
-
console.log(ui.warn(`note: \`${target}\` CLI not found — manifests were regenerated, but nothing was re-synced in ${target}.`));
|
|
370
|
-
}
|
|
371
|
-
}
|
|
407
|
+
await handleSync(rest, cmd);
|
|
372
408
|
return;
|
|
373
409
|
}
|
|
374
410
|
case "update": {
|
|
375
|
-
|
|
376
|
-
const source = positionals[0];
|
|
377
|
-
for (const sc of await resolveUpdateScopes(values)) {
|
|
378
|
-
if (sc.heading)
|
|
379
|
-
console.log(`${ui.name(sc.heading)}`);
|
|
380
|
-
try {
|
|
381
|
-
const result = await updatePlugins({
|
|
382
|
-
pluginsDir: sc.dir,
|
|
383
|
-
source,
|
|
384
|
-
all: values.all,
|
|
385
|
-
activate: true,
|
|
386
|
-
agentScope: sc.agentScope,
|
|
387
|
-
scope: { label: sc.label, globalDir: globalPluginsDir() },
|
|
388
|
-
});
|
|
389
|
-
printUpdateReport(result);
|
|
390
|
-
}
|
|
391
|
-
catch (err) {
|
|
392
|
-
console.error(`${ui.err("error:")} ${err instanceof Error ? err.message : String(err)}`);
|
|
393
|
-
}
|
|
394
|
-
}
|
|
411
|
+
await handleUpdate(rest, cmd);
|
|
395
412
|
return;
|
|
396
413
|
}
|
|
397
414
|
case "remove": {
|
|
@@ -556,9 +573,7 @@ async function runMarketplace(args) {
|
|
|
556
573
|
const source = positionals[0];
|
|
557
574
|
if (!source)
|
|
558
575
|
fail("marketplace sync requires a <source>");
|
|
559
|
-
const targets = values
|
|
560
|
-
? resolveTargets("all")
|
|
561
|
-
: [requireSingleTarget(values.target, "marketplace sync")];
|
|
576
|
+
const targets = resolveVerbTargets(values, "marketplace sync");
|
|
562
577
|
const sc = await resolveActionScope(values, "marketplace sync");
|
|
563
578
|
for (const target of targets) {
|
|
564
579
|
const res = marketplaceSync({
|
|
@@ -572,7 +587,7 @@ async function runMarketplace(args) {
|
|
|
572
587
|
console.log(`${ui.ok("synced")} ${ui.name(a.name)} ${ui.meta(`[${res.target}]`)}${a.synced ? ui.meta(` -> ${res.target}`) : ""}`);
|
|
573
588
|
}
|
|
574
589
|
if (res.cliSkipped) {
|
|
575
|
-
|
|
590
|
+
printCliUnavailableNote(target, `manifests were regenerated, but nothing was re-synced in ${target}.`);
|
|
576
591
|
}
|
|
577
592
|
}
|
|
578
593
|
return;
|
|
@@ -597,7 +612,8 @@ async function runCache(args) {
|
|
|
597
612
|
if (status.entries.length === 0)
|
|
598
613
|
console.log(ui.meta("cache is empty"));
|
|
599
614
|
for (const entry of status.entries) {
|
|
600
|
-
|
|
615
|
+
const label = entry.orphan ? ui.warn("orphan") : entry.recovery === "present" ? ui.ok("cached") : ui.warn(entry.recovery ?? "cached");
|
|
616
|
+
console.log(`${label} ${ui.name(entry.name)} ${ui.meta(`${entry.bytes} bytes`)}`);
|
|
601
617
|
}
|
|
602
618
|
console.log(ui.meta(`total: ${status.totalBytes} bytes`));
|
|
603
619
|
return;
|
|
@@ -618,5 +634,12 @@ async function runCache(args) {
|
|
|
618
634
|
console.log(ui.ok("cache cleaned"));
|
|
619
635
|
return;
|
|
620
636
|
}
|
|
637
|
+
if (sub === "restore") {
|
|
638
|
+
const { values, positionals } = parseVerb("cache", [...SCOPE], rest);
|
|
639
|
+
const scope = await resolveActionScope(values, "cache restore");
|
|
640
|
+
const restored = restorePluginCache(scope.pluginsDir, positionals);
|
|
641
|
+
console.log(restored.length > 0 ? `${ui.ok("restored")} ${restored.join(", ")}` : ui.meta("no source snapshots to restore"));
|
|
642
|
+
return;
|
|
643
|
+
}
|
|
621
644
|
fail(`unknown cache subcommand: ${sub}`);
|
|
622
645
|
}
|
package/dist/src/cli/index.js
CHANGED
|
@@ -8,7 +8,7 @@ export const FLAGS = {
|
|
|
8
8
|
// Short flags are first-letter aliases. Where several long flags share a
|
|
9
9
|
// first letter, the highest-frequency one wins the short and the rest stay
|
|
10
10
|
// long-only: d → dir (not description) a → all (not author/as)
|
|
11
|
-
// s → skill (not sparse) p → plugin (not
|
|
11
|
+
// s → skill (not sparse) p → plugin (not project/prefix)
|
|
12
12
|
dir: { type: "string", short: "d", hint: "<dir>", help: "install into an explicit directory" },
|
|
13
13
|
global: { type: "boolean", short: "g", help: "use ~/.agents/plugins (across all projects)" },
|
|
14
14
|
project: { type: "boolean", help: "use <repo>/.agents/plugins (default)" },
|
|
@@ -16,7 +16,6 @@ export const FLAGS = {
|
|
|
16
16
|
all: { type: "boolean", short: "a", help: "select all available plugins" },
|
|
17
17
|
plugin: { type: "string", short: "p", multiple: true, hint: "<name>", help: "select a specific plugin (repeatable)" },
|
|
18
18
|
"no-deps": { type: "boolean", short: "n", help: "don't install dependencies" },
|
|
19
|
-
path: { type: "string", hint: "<subdir>", help: "install only this subdir of the source" },
|
|
20
19
|
ref: { type: "string", short: "r", hint: "<ref>", help: "pin a git ref (branch/tag/sha)" },
|
|
21
20
|
sparse: { type: "string", multiple: true, hint: "<path>", help: "sparse-checkout path (repeatable)" },
|
|
22
21
|
"marketplace-name": { type: "string", hint: "<name>", help: "override the marketplace key" },
|
|
@@ -25,8 +24,9 @@ export const FLAGS = {
|
|
|
25
24
|
author: { type: "string", hint: "<name>", help: "plugin author" },
|
|
26
25
|
type: { type: "string", hint: "plugin|marketplace|all", help: "init: which .agents/ artifact to scaffold (default plugin)" },
|
|
27
26
|
skill: { type: "string", short: "s", multiple: true, hint: "<name>", help: "skill name (init: seed one · add: limit to these)" },
|
|
27
|
+
mcp: { type: "string", short: "m", multiple: true, hint: "<name>", help: "MCP server name (add: limit to these)" },
|
|
28
28
|
only: { type: "string", hint: "<types>", help: "limit to these component types (skills,agents,commands,mcp,hooks,apps)" },
|
|
29
|
-
as: { type: "string", hint: "<name>", help: "
|
|
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
31
|
verbose: { type: "boolean", short: "v", help: "expand each component to its member names" },
|
|
32
32
|
json: { type: "boolean", help: "print stable machine-readable JSON" },
|
|
@@ -49,12 +49,13 @@ export const PLUGIN_COMMANDS = {
|
|
|
49
49
|
blurb: "In a terminal, add guides you through: scope → plugins → agents → what to install.\n" +
|
|
50
50
|
"By default it installs everything; choose 'No, let me choose' to pick components,\n" +
|
|
51
51
|
"or pass the flags below to skip any prompt (e.g. for scripts/CI).",
|
|
52
|
-
flags: ["all", "plugin", "only", "skill", "target", "no-deps", "
|
|
52
|
+
flags: ["all", "plugin", "only", "skill", "mcp", "target", "no-deps", "ref", "sparse", "marketplace-name", "as", ...SCOPE],
|
|
53
53
|
examples: [
|
|
54
54
|
"adg plugins add owner/repo # guided",
|
|
55
55
|
"adg plugins add owner/repo --all --global # all plugins, global, non-interactive",
|
|
56
56
|
"adg plugins add owner/repo --only skills # expose only the skills",
|
|
57
57
|
"adg plugins add owner/repo --skill brainstorming --skill writing-plans",
|
|
58
|
+
"adg plugins add owner/repo --mcp server-name",
|
|
58
59
|
],
|
|
59
60
|
start: true,
|
|
60
61
|
},
|
|
@@ -126,6 +127,12 @@ export const PLUGIN_COMMANDS = {
|
|
|
126
127
|
positional: "<dir> plugin directory (default: current directory)",
|
|
127
128
|
flags: [],
|
|
128
129
|
},
|
|
130
|
+
inspect: {
|
|
131
|
+
summary: "inspect a plugin source without installing it",
|
|
132
|
+
synopsis: "adg plugins inspect [<source>] [--ref <ref>]",
|
|
133
|
+
positional: "<source> local directory or owner/repo[@ref] (default: current directory)",
|
|
134
|
+
flags: ["json", "ref"],
|
|
135
|
+
},
|
|
129
136
|
"import-skills": {
|
|
130
137
|
summary: "wrap an existing skills/ dir as a plugin",
|
|
131
138
|
synopsis: "adg plugins import-skills <skills-dir> --as <name>",
|
|
@@ -225,6 +232,9 @@ Commands:
|
|
|
225
232
|
Show cached snapshots, byte sizes, and orphan state.
|
|
226
233
|
adg plugins cache prune [--global | --project | --dir <dir>]
|
|
227
234
|
Delete snapshots that have no corresponding lock entry.
|
|
235
|
+
adg plugins cache restore [name...] [--global | --project | --dir <dir>]
|
|
236
|
+
Restore missing snapshots from a verified legacy cache, local source, or
|
|
237
|
+
the exact remote revision recorded in the lock.
|
|
228
238
|
adg plugins cache clean --force [--global | --project | --dir <dir>]
|
|
229
239
|
Delete every source snapshot for the selected store. A later update or
|
|
230
240
|
add may be required before link/sync can rebuild remote plugins.`;
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import { resolve } from "node:path";
|
|
2
|
+
import { codexMarketplaceRoot } from "./paths.js";
|
|
3
|
+
/**
|
|
4
|
+
* Read only the marketplace/plugin tables that this migrator owns. Codex keeps
|
|
5
|
+
* these values as simple TOML scalars, so a narrow parser avoids adding a TOML
|
|
6
|
+
* dependency to ADG's runtime just for a one-shot cleanup utility.
|
|
7
|
+
*/
|
|
8
|
+
export function parseCodexPluginConfig(toml) {
|
|
9
|
+
const marketplaces = new Map();
|
|
10
|
+
const plugins = [];
|
|
11
|
+
let marketplace;
|
|
12
|
+
let plugin;
|
|
13
|
+
const flushPlugin = () => {
|
|
14
|
+
if (plugin)
|
|
15
|
+
plugins.push(plugin);
|
|
16
|
+
plugin = undefined;
|
|
17
|
+
};
|
|
18
|
+
for (const line of toml.split("\n")) {
|
|
19
|
+
const marketplaceHeader = line.match(/^\s*\[marketplaces\.([A-Za-z0-9_-]+)\]\s*$/u);
|
|
20
|
+
const pluginHeader = line.match(/^\s*\[plugins\."([^"@]+)@([^"@]+)"\]\s*$/u);
|
|
21
|
+
if (marketplaceHeader || pluginHeader || /^\s*\[/u.test(line)) {
|
|
22
|
+
flushPlugin();
|
|
23
|
+
marketplace = marketplaceHeader?.[1];
|
|
24
|
+
if (pluginHeader)
|
|
25
|
+
plugin = { name: pluginHeader[1], marketplace: pluginHeader[2], enabled: false };
|
|
26
|
+
continue;
|
|
27
|
+
}
|
|
28
|
+
if (marketplace) {
|
|
29
|
+
const source = line.match(/^\s*source\s*=\s*"([^"]+)"\s*$/u);
|
|
30
|
+
if (source)
|
|
31
|
+
marketplaces.set(marketplace, source[1]);
|
|
32
|
+
}
|
|
33
|
+
if (plugin && /^\s*enabled\s*=\s*true\s*$/u.test(line))
|
|
34
|
+
plugin.enabled = true;
|
|
35
|
+
}
|
|
36
|
+
flushPlugin();
|
|
37
|
+
return { marketplaces, plugins };
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Build an idempotent cleanup sequence for plugins whose canonical identity was
|
|
41
|
+
* successfully installed during this link/sync pass.
|
|
42
|
+
*/
|
|
43
|
+
export function planCodexMarketplaceCleanup(config, canonicalRoot, canonicalMarketplace, pluginNames) {
|
|
44
|
+
const root = resolve(canonicalRoot);
|
|
45
|
+
const legacyMarketplaces = [...config.marketplaces]
|
|
46
|
+
.filter(([name, source]) => name !== canonicalMarketplace && resolve(root, source) === root)
|
|
47
|
+
.map(([name]) => name)
|
|
48
|
+
.sort();
|
|
49
|
+
const legacySet = new Set(legacyMarketplaces);
|
|
50
|
+
const selected = new Set(pluginNames);
|
|
51
|
+
const legacyPlugins = config.plugins.filter((plugin) => legacySet.has(plugin.marketplace));
|
|
52
|
+
const commands = [];
|
|
53
|
+
for (const plugin of legacyPlugins) {
|
|
54
|
+
if (!selected.has(plugin.name))
|
|
55
|
+
continue;
|
|
56
|
+
commands.push(["plugin", "remove", `${plugin.name}@${plugin.marketplace}`]);
|
|
57
|
+
}
|
|
58
|
+
for (const marketplace of legacyMarketplaces) {
|
|
59
|
+
const residual = legacyPlugins.some((plugin) => plugin.marketplace === marketplace && !selected.has(plugin.name));
|
|
60
|
+
if (!residual)
|
|
61
|
+
commands.push(["plugin", "marketplace", "remove", marketplace]);
|
|
62
|
+
}
|
|
63
|
+
// Old Codex versions can leave plugin entries behind after their marketplace
|
|
64
|
+
// registration was removed. Delete only an orphan selected by this successful
|
|
65
|
+
// pass; a different live marketplace is intentionally left alone even if it
|
|
66
|
+
// happens to use the same plugin name.
|
|
67
|
+
const configuredMarketplaces = new Set(config.marketplaces.keys());
|
|
68
|
+
const orphaned = config.plugins
|
|
69
|
+
.filter((plugin) => plugin.marketplace !== canonicalMarketplace)
|
|
70
|
+
.filter((plugin) => !configuredMarketplaces.has(plugin.marketplace))
|
|
71
|
+
.filter((plugin) => selected.has(plugin.name))
|
|
72
|
+
.sort((a, b) => `${a.name}@${a.marketplace}`.localeCompare(`${b.name}@${b.marketplace}`));
|
|
73
|
+
for (const plugin of orphaned) {
|
|
74
|
+
commands.push(["plugin", "remove", `${plugin.name}@${plugin.marketplace}`]);
|
|
75
|
+
}
|
|
76
|
+
return { legacyMarketplaces, legacyPluginCount: legacyPlugins.length, orphanPluginCount: orphaned.length, commands };
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Remove legacy Codex plugin identities only after this run has successfully
|
|
80
|
+
* installed their canonical replacements. A failed deletion leaves the legacy
|
|
81
|
+
* marketplace in place, so cleanup cannot make the remaining identities
|
|
82
|
+
* undiscoverable.
|
|
83
|
+
*/
|
|
84
|
+
export function reconcileCodexMarketplaceAliases(opts) {
|
|
85
|
+
let config;
|
|
86
|
+
try {
|
|
87
|
+
config = parseCodexPluginConfig(opts.readConfig());
|
|
88
|
+
}
|
|
89
|
+
catch {
|
|
90
|
+
const result = { outcome: "config_unavailable", removedPluginCount: 0, removedMarketplaceCount: 0 };
|
|
91
|
+
opts.report({
|
|
92
|
+
"legacy.marketplace_count": 0,
|
|
93
|
+
"legacy.plugin_count": 0,
|
|
94
|
+
"legacy.orphan_plugin_count": 0,
|
|
95
|
+
"migration.removed_plugin_count": 0,
|
|
96
|
+
"migration.removed_marketplace_count": 0,
|
|
97
|
+
"migration.outcome": result.outcome,
|
|
98
|
+
});
|
|
99
|
+
return result;
|
|
100
|
+
}
|
|
101
|
+
const plan = planCodexMarketplaceCleanup(config, codexMarketplaceRoot(opts.pluginsDir), opts.marketplace, opts.plugins);
|
|
102
|
+
const pluginCommands = plan.commands.filter((command) => command[1] !== "marketplace");
|
|
103
|
+
const marketplaceCommands = plan.commands.filter((command) => command[1] === "marketplace");
|
|
104
|
+
let removedPluginCount = 0;
|
|
105
|
+
let removedMarketplaceCount = 0;
|
|
106
|
+
let failed = false;
|
|
107
|
+
for (const command of pluginCommands) {
|
|
108
|
+
if (opts.run(command).ok)
|
|
109
|
+
removedPluginCount += 1;
|
|
110
|
+
else
|
|
111
|
+
failed = true;
|
|
112
|
+
}
|
|
113
|
+
if (!failed) {
|
|
114
|
+
for (const command of marketplaceCommands) {
|
|
115
|
+
if (opts.run(command).ok)
|
|
116
|
+
removedMarketplaceCount += 1;
|
|
117
|
+
else
|
|
118
|
+
failed = true;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
const hasLegacy = plan.legacyMarketplaces.length > 0 || plan.legacyPluginCount > 0 || plan.orphanPluginCount > 0;
|
|
122
|
+
const hasDeferredLegacy = plan.legacyMarketplaces.some((marketplace) => !marketplaceCommands.some((command) => command[3] === marketplace));
|
|
123
|
+
const outcome = failed
|
|
124
|
+
? "partial"
|
|
125
|
+
: !hasLegacy
|
|
126
|
+
? "none"
|
|
127
|
+
: hasDeferredLegacy
|
|
128
|
+
? "deferred"
|
|
129
|
+
: "completed";
|
|
130
|
+
opts.report({
|
|
131
|
+
"legacy.marketplace_count": plan.legacyMarketplaces.length,
|
|
132
|
+
"legacy.plugin_count": plan.legacyPluginCount,
|
|
133
|
+
"legacy.orphan_plugin_count": plan.orphanPluginCount,
|
|
134
|
+
"migration.removed_plugin_count": removedPluginCount,
|
|
135
|
+
"migration.removed_marketplace_count": removedMarketplaceCount,
|
|
136
|
+
"migration.outcome": outcome,
|
|
137
|
+
});
|
|
138
|
+
return { outcome, removedPluginCount, removedMarketplaceCount };
|
|
139
|
+
}
|