@rbbtsn0w/adg 0.3.0 → 0.4.0-beta.1
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 +15 -5
- package/dist/bin/adg.js +115 -10
- package/dist/src/agents/antigravity.js +52 -1
- package/dist/src/agents/claude.js +53 -0
- package/dist/src/agents/codex.js +47 -2
- package/dist/src/commands/link.js +2 -2
- package/dist/src/commands/marketplace.js +17 -0
- package/dist/src/commands/projection.js +28 -0
- package/dist/src/commands/status.js +26 -0
- package/dist/src/commands/sync.js +29 -0
- package/dist/src/commands/unlink.js +20 -0
- package/dist/src/render/plugins.js +27 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -224,16 +224,26 @@ adg plugins add owner/repo --ref main --sparse .agents/plugins --sparse plugins
|
|
|
224
224
|
adg plugins add ./some/local/repo --dir plugins
|
|
225
225
|
adg plugins import-skills ~/.agents/skills --as asc --prefix asc- --dir plugins
|
|
226
226
|
|
|
227
|
-
# project installed plugins into a runtime's discovery path
|
|
228
|
-
adg plugins link
|
|
229
|
-
adg plugins link
|
|
230
|
-
|
|
231
|
-
#
|
|
227
|
+
# project installed plugins into a runtime's discovery path (store stays the source of truth)
|
|
228
|
+
adg plugins link --target codex --global # enable in one agent (regenerate .codex-plugin)
|
|
229
|
+
adg plugins link --target claude --global # symlink into ~/.claude/skills/
|
|
230
|
+
adg plugins unlink --target antigravity asc # disable in one agent only; store untouched
|
|
231
|
+
adg plugins sync --target antigravity asc # reconcile one agent to the store (clears residual)
|
|
232
|
+
adg plugins marketplace sync owner/repo --target codex # same, scoped to a whole source
|
|
233
|
+
|
|
234
|
+
# diagnose & maintain
|
|
235
|
+
adg plugins status --target antigravity # live-diff the store vs an agent; each drift row shows its fix
|
|
232
236
|
adg plugins update --dir plugins # re-fetch remote sources; rescan local ones in place
|
|
233
237
|
adg plugins list --dir plugins # list locked plugins
|
|
234
238
|
adg plugins migrate --dir plugins # move flat installs into per-marketplace dirs
|
|
235
239
|
```
|
|
236
240
|
|
|
241
|
+
Two layers, two verb pairs. The **store** (`add` / `remove`) is the system of
|
|
242
|
+
record; **agents are projections** of it (`link` / `unlink` toggle one agent;
|
|
243
|
+
`sync` forces an agent to match the store). `remove` deletes from the store and
|
|
244
|
+
every agent at once — for per-agent control use `unlink`. When something looks
|
|
245
|
+
off, `status` shows the drift and `sync` repairs it.
|
|
246
|
+
|
|
237
247
|
#### On-disk layout
|
|
238
248
|
|
|
239
249
|
Plugins are grouped on disk by the source they came from. Remote installs nest
|
package/dist/bin/adg.js
CHANGED
|
@@ -13,9 +13,12 @@ import { validatePlugin } from "../src/commands/validate.js";
|
|
|
13
13
|
import { listPlugins } from "../src/commands/list.js";
|
|
14
14
|
import { importSkills } from "../src/commands/import.js";
|
|
15
15
|
import { linkPlugins } from "../src/commands/link.js";
|
|
16
|
+
import { unlinkPlugins } from "../src/commands/unlink.js";
|
|
17
|
+
import { syncPlugins } from "../src/commands/sync.js";
|
|
16
18
|
import { removePlugin } from "../src/commands/remove.js";
|
|
17
19
|
import { migrateLayout } from "../src/commands/migrate.js";
|
|
18
|
-
import {
|
|
20
|
+
import { pluginStatus } from "../src/commands/status.js";
|
|
21
|
+
import { marketplaceList, marketplaceRemove, marketplaceSync, marketplaceUpgrade, updatePlugins } from "../src/commands/marketplace.js";
|
|
19
22
|
import { selectTargetsInteractive } from "../src/commands/select-agents.js";
|
|
20
23
|
import { selectPluginsInteractive } from "../src/commands/select-plugins.js";
|
|
21
24
|
import { selectScopeInteractive, selectUpdateScopeInteractive } from "../src/commands/select-scope.js";
|
|
@@ -25,7 +28,7 @@ import { globalPluginsDir, projectPluginsDir } from "../src/paths.js";
|
|
|
25
28
|
import { COMPONENT_TYPES } from "../src/types.js";
|
|
26
29
|
import { getAgent } from "../src/agents/index.js";
|
|
27
30
|
import { ui } from "../src/render/ui.js";
|
|
28
|
-
import { renderAgentReport, renderMarketplaceList, renderPluginList, renderUpdateReport, } from "../src/render/plugins.js";
|
|
31
|
+
import { renderAgentReport, renderMarketplaceList, renderPluginList, renderStatus, renderUpdateReport, } from "../src/render/plugins.js";
|
|
29
32
|
const FLAGS = {
|
|
30
33
|
// Short flags are first-letter aliases. Where several long flags share a
|
|
31
34
|
// first letter, the highest-frequency one wins the short and the rest stay
|
|
@@ -85,6 +88,12 @@ const PLUGIN_COMMANDS = {
|
|
|
85
88
|
blurb: "Each plugin shows a one-line summary of what it contains. Add --verbose\nto expand every component (skills, agents, commands, …) to its member names.",
|
|
86
89
|
flags: ["verbose", ...SCOPE],
|
|
87
90
|
},
|
|
91
|
+
status: {
|
|
92
|
+
summary: "show store-vs-agent drift per runtime",
|
|
93
|
+
synopsis: "adg plugins status [--target claude|codex|antigravity]",
|
|
94
|
+
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.",
|
|
95
|
+
flags: ["target", ...SCOPE],
|
|
96
|
+
},
|
|
88
97
|
update: {
|
|
89
98
|
summary: "pull upstream changes for installed plugins",
|
|
90
99
|
synopsis: "adg plugins update [<source>]",
|
|
@@ -135,8 +144,32 @@ const PLUGIN_COMMANDS = {
|
|
|
135
144
|
},
|
|
136
145
|
link: {
|
|
137
146
|
summary: "link installed plugins into a runtime",
|
|
138
|
-
synopsis: "adg plugins link --target claude|codex|antigravity",
|
|
147
|
+
synopsis: "adg plugins link --target claude|codex|antigravity [name...]",
|
|
148
|
+
positional: "[name...] installed plugin names to link (default: all)",
|
|
149
|
+
blurb: "Project the store into one agent: (re)generate its manifests and enable\nthe plugins via that agent's CLI. The store is unchanged. The inverse is\n`adg plugins unlink`; to force an agent to match the store, use `adg plugins sync`.",
|
|
150
|
+
flags: ["target", ...SCOPE],
|
|
151
|
+
},
|
|
152
|
+
unlink: {
|
|
153
|
+
summary: "unlink plugins from a runtime (store kept)",
|
|
154
|
+
synopsis: "adg plugins unlink --target claude|codex|antigravity [name...]",
|
|
155
|
+
positional: "[name...] installed plugin names to unlink (default: all)",
|
|
156
|
+
blurb: "Disable the plugins in one agent without removing them from the store —\nthe per-agent inverse of `link`. To delete from the store and every agent\nat once, use `adg plugins remove`.",
|
|
157
|
+
flags: ["target", ...SCOPE],
|
|
158
|
+
examples: [
|
|
159
|
+
"adg plugins unlink --target antigravity asc # drop asc from agy only",
|
|
160
|
+
"adg plugins unlink --target codex # unlink everything from codex",
|
|
161
|
+
],
|
|
162
|
+
},
|
|
163
|
+
sync: {
|
|
164
|
+
summary: "reconcile a runtime's plugins with the store",
|
|
165
|
+
synopsis: "adg plugins sync --target claude|codex|antigravity [name...]",
|
|
166
|
+
positional: "[name...] installed plugin names to sync (default: all)",
|
|
167
|
+
blurb: "Make one agent's copy match the store: regenerate manifests and re-import,\nclearing components that were dropped since the last sync. Use this to repair\ndrift (e.g. residual skills). Only store-known plugins are touched.",
|
|
139
168
|
flags: ["target", ...SCOPE],
|
|
169
|
+
examples: [
|
|
170
|
+
"adg plugins sync --target antigravity asc # clear agy residual for asc",
|
|
171
|
+
"adg plugins sync --target claude # re-sync every plugin into Claude",
|
|
172
|
+
],
|
|
140
173
|
},
|
|
141
174
|
migrate: {
|
|
142
175
|
summary: "move flat installs into per-marketplace dirs",
|
|
@@ -285,6 +318,13 @@ function resolveTargets(target) {
|
|
|
285
318
|
return [t];
|
|
286
319
|
fail(`invalid --target "${target}" (expected ${[...ADAPTER_TARGETS, "all"].join("|")})`);
|
|
287
320
|
}
|
|
321
|
+
/** A single-agent projection verb (link/unlink/sync) needs exactly one --target. */
|
|
322
|
+
function requireSingleTarget(target, verb) {
|
|
323
|
+
if (target === undefined || target === "all") {
|
|
324
|
+
fail(`plugins ${verb} requires a single --target (${ADAPTER_TARGETS.join("|")})`);
|
|
325
|
+
}
|
|
326
|
+
return resolveTargets(target)[0]; // validates + maps aliases (agy → antigravity); always non-empty
|
|
327
|
+
}
|
|
288
328
|
/** Parse a `--only skills,commands` list into validated component types. */
|
|
289
329
|
function resolveComponents(only) {
|
|
290
330
|
if (only === undefined)
|
|
@@ -447,12 +487,10 @@ async function runPlugins(rawVerb, rest) {
|
|
|
447
487
|
return;
|
|
448
488
|
}
|
|
449
489
|
case "link": {
|
|
450
|
-
const { values } = parseVerb(verb, cmd.flags, rest);
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
}
|
|
454
|
-
const target = resolveTargets(values.target)[0]; // validates + maps aliases (agy → antigravity); always non-empty
|
|
455
|
-
const res = linkPlugins({ pluginsDir: resolveScopeDir(values), target, global: Boolean(values.global) });
|
|
490
|
+
const { values, positionals } = parseVerb(verb, cmd.flags, rest);
|
|
491
|
+
const target = requireSingleTarget(values.target, "link");
|
|
492
|
+
const names = positionals.length > 0 ? positionals : undefined;
|
|
493
|
+
const res = linkPlugins({ pluginsDir: resolveScopeDir(values), target, global: Boolean(values.global), names });
|
|
456
494
|
for (const a of res.actions) {
|
|
457
495
|
console.log(`${ui.ok("linked")} ${ui.name(a.name)} ${ui.meta(`[${res.target}]`)}${a.linkedTo ? ui.meta(` -> ${a.linkedTo}`) : ""}`);
|
|
458
496
|
for (const f of a.adapted)
|
|
@@ -463,6 +501,35 @@ async function runPlugins(rawVerb, rest) {
|
|
|
463
501
|
}
|
|
464
502
|
return;
|
|
465
503
|
}
|
|
504
|
+
case "unlink": {
|
|
505
|
+
const { values, positionals } = parseVerb(verb, cmd.flags, rest);
|
|
506
|
+
const target = requireSingleTarget(values.target, "unlink");
|
|
507
|
+
const names = positionals.length > 0 ? positionals : undefined;
|
|
508
|
+
const res = unlinkPlugins({ pluginsDir: resolveScopeDir(values), target, global: Boolean(values.global), names });
|
|
509
|
+
for (const name of res.unlinked)
|
|
510
|
+
console.log(`${ui.ok("unlinked")} ${ui.name(name)} ${ui.meta(`[${res.target}]`)}`);
|
|
511
|
+
if (res.cliSkipped) {
|
|
512
|
+
console.log(ui.warn(`note: \`${target}\` CLI not found — nothing was unlinked from ${target}.`));
|
|
513
|
+
}
|
|
514
|
+
else if (res.unlinked.length === 0) {
|
|
515
|
+
console.log(ui.meta(`nothing to unlink from ${target}`));
|
|
516
|
+
}
|
|
517
|
+
return;
|
|
518
|
+
}
|
|
519
|
+
case "sync": {
|
|
520
|
+
const { values, positionals } = parseVerb(verb, cmd.flags, rest);
|
|
521
|
+
const target = requireSingleTarget(values.target, "sync");
|
|
522
|
+
const names = positionals.length > 0 ? positionals : undefined;
|
|
523
|
+
const res = syncPlugins({ pluginsDir: resolveScopeDir(values), target, global: Boolean(values.global), names });
|
|
524
|
+
for (const a of res.actions) {
|
|
525
|
+
const tail = a.synced ? ui.meta(` -> ${res.target}`) : "";
|
|
526
|
+
console.log(`${ui.ok("synced")} ${ui.name(a.name)} ${ui.meta(`[${res.target}]`)}${tail}`);
|
|
527
|
+
}
|
|
528
|
+
if (res.cliSkipped) {
|
|
529
|
+
console.log(ui.warn(`note: \`${target}\` CLI not found — manifests were regenerated, but nothing was re-synced in ${target}.`));
|
|
530
|
+
}
|
|
531
|
+
return;
|
|
532
|
+
}
|
|
466
533
|
case "update": {
|
|
467
534
|
const { values, positionals } = parseVerb(verb, cmd.flags, rest);
|
|
468
535
|
const source = positionals[0];
|
|
@@ -508,8 +575,14 @@ async function runPlugins(rawVerb, rest) {
|
|
|
508
575
|
for (const link of res.unlinked)
|
|
509
576
|
console.log(ui.meta(` unlinked: ${link}`));
|
|
510
577
|
for (const r of res.agents ?? []) {
|
|
578
|
+
const display = getAgent(r.agent)?.displayName ?? r.agent;
|
|
511
579
|
if (r.affected.length > 0)
|
|
512
|
-
console.log(ui.meta(` disabled in ${
|
|
580
|
+
console.log(ui.meta(` disabled in ${display}`));
|
|
581
|
+
// CLI absent → the plugin may still be enabled there; surface the precise
|
|
582
|
+
// repair so a store-deleted plugin can't silently linger in that agent.
|
|
583
|
+
else if (r.skipped) {
|
|
584
|
+
console.log(ui.warn(` ${r.agent} CLI not found — if enabled there, run \`adg plugins unlink --target ${r.agent} ${res.name}\``));
|
|
585
|
+
}
|
|
513
586
|
}
|
|
514
587
|
if (!res.removedFromLock && !res.removedDir) {
|
|
515
588
|
console.log(ui.warn(` ${res.name} was not recorded in the lock`));
|
|
@@ -525,6 +598,14 @@ async function runPlugins(rawVerb, rest) {
|
|
|
525
598
|
}
|
|
526
599
|
return;
|
|
527
600
|
}
|
|
601
|
+
case "status": {
|
|
602
|
+
const { values } = parseVerb(verb, cmd.flags, rest);
|
|
603
|
+
const targets = values.target !== undefined ? resolveTargets(values.target) : undefined;
|
|
604
|
+
const statuses = pluginStatus({ pluginsDir: resolveScopeDir(values), scope: scopeOf(values), targets });
|
|
605
|
+
for (const line of renderStatus(statuses))
|
|
606
|
+
console.log(line);
|
|
607
|
+
return;
|
|
608
|
+
}
|
|
528
609
|
case "migrate": {
|
|
529
610
|
const { values } = parseVerb(verb, cmd.flags, rest);
|
|
530
611
|
const res = migrateLayout(resolveScopeDir(values));
|
|
@@ -552,6 +633,9 @@ Commands:
|
|
|
552
633
|
components (skills, agents, commands, …).
|
|
553
634
|
adg plugins marketplace remove <source> [--force] [--global | --project | --dir <dir>]
|
|
554
635
|
Uninstall every plugin that came from <source>.
|
|
636
|
+
adg plugins marketplace sync <source> --target <agent> [--global | --project | --dir <dir>]
|
|
637
|
+
Reconcile one agent's copy of every plugin from <source> with the store
|
|
638
|
+
(the source-scoped twin of \`adg plugins sync\`).
|
|
555
639
|
adg plugins marketplace upgrade … (deprecated → use \`adg plugins update\`)
|
|
556
640
|
Kept as an alias. To pull upstream changes, prefer \`adg plugins update\`.
|
|
557
641
|
|
|
@@ -620,6 +704,27 @@ async function runMarketplace(args) {
|
|
|
620
704
|
console.log(`${ui.ok("removed")} ${res.removed.length} plugin(s) from ${ui.name(res.source)}: ${res.removed.join(", ")}`);
|
|
621
705
|
return;
|
|
622
706
|
}
|
|
707
|
+
case "sync": {
|
|
708
|
+
const { values, positionals } = parseVerb("marketplace", ["target", ...SCOPE], rest);
|
|
709
|
+
const source = positionals[0];
|
|
710
|
+
if (!source)
|
|
711
|
+
fail("marketplace sync requires a <source>");
|
|
712
|
+
const target = requireSingleTarget(values.target, "marketplace sync");
|
|
713
|
+
const res = marketplaceSync({
|
|
714
|
+
pluginsDir: resolveScopeDir(values),
|
|
715
|
+
scope: scopeInfo(values),
|
|
716
|
+
source,
|
|
717
|
+
target,
|
|
718
|
+
global: Boolean(values.global),
|
|
719
|
+
});
|
|
720
|
+
for (const a of res.actions) {
|
|
721
|
+
console.log(`${ui.ok("synced")} ${ui.name(a.name)} ${ui.meta(`[${res.target}]`)}${a.synced ? ui.meta(` -> ${res.target}`) : ""}`);
|
|
722
|
+
}
|
|
723
|
+
if (res.cliSkipped) {
|
|
724
|
+
console.log(ui.warn(`note: \`${target}\` CLI not found — manifests were regenerated, but nothing was re-synced in ${target}.`));
|
|
725
|
+
}
|
|
726
|
+
return;
|
|
727
|
+
}
|
|
623
728
|
default: {
|
|
624
729
|
console.error(`${ui.err("error:")} unknown marketplace subcommand: ${sub}\n`);
|
|
625
730
|
console.error(MARKETPLACE_USAGE);
|
|
@@ -141,6 +141,11 @@ export const antigravityAgent = {
|
|
|
141
141
|
activate(ctx) {
|
|
142
142
|
if (!available())
|
|
143
143
|
return { agent: ID, affected: [], skipped: true };
|
|
144
|
+
// Query agy once up front so the pre-install uninstall below is issued only
|
|
145
|
+
// for plugins that are actually present (a brand-new plugin has no residual
|
|
146
|
+
// to clear). `undefined` (couldn't enumerate) falls back to always
|
|
147
|
+
// uninstalling, preserving the clean-replace guarantee.
|
|
148
|
+
const installed = antigravityInstalled();
|
|
144
149
|
const affected = [];
|
|
145
150
|
for (const p of ctx.plugins) {
|
|
146
151
|
// Isolate each plugin: a malformed manifest or a filesystem error must not
|
|
@@ -150,6 +155,14 @@ export const antigravityAgent = {
|
|
|
150
155
|
if (!store)
|
|
151
156
|
continue;
|
|
152
157
|
writeAntigravityProjection(store.dir, store.selection);
|
|
158
|
+
// `agy plugin install` *merges* into an existing `<store>/plugins/<name>`
|
|
159
|
+
// rather than replacing it, so components dropped since the last sync (a
|
|
160
|
+
// narrowed selection, or a skill removed upstream) would linger as
|
|
161
|
+
// residual data. Uninstall an existing copy first to force a clean
|
|
162
|
+
// re-import; skip it for a not-yet-installed plugin (nothing to clear).
|
|
163
|
+
if (installed === undefined || installed.includes(p)) {
|
|
164
|
+
run(["plugin", "uninstall", p]);
|
|
165
|
+
}
|
|
153
166
|
if (run(["plugin", "install", join(store.dir, ANTIGRAVITY_PROJECTION_DIR)]).ok)
|
|
154
167
|
affected.push(p);
|
|
155
168
|
}
|
|
@@ -169,8 +182,46 @@ export const antigravityAgent = {
|
|
|
169
182
|
}
|
|
170
183
|
return { agent: ID, affected, skipped: false };
|
|
171
184
|
},
|
|
172
|
-
//
|
|
185
|
+
// Re-running activate is the refresh: it uninstalls then re-imports the source
|
|
186
|
+
// dir, so a shrunk component set replaces the stale copy instead of merging.
|
|
173
187
|
refresh(ctx) {
|
|
174
188
|
return antigravityAgent.activate(ctx);
|
|
175
189
|
},
|
|
190
|
+
// `agy plugin list` emits JSON (`{ imports: [{ name }] }`). agy has no
|
|
191
|
+
// marketplace concept, so this returns *every* imported plugin — including
|
|
192
|
+
// ones imported outside ADG; the caller treats agy-only names as "not managed
|
|
193
|
+
// here" rather than asserting they are ADG orphans.
|
|
194
|
+
// `available()` (stdio-ignored probe) gates the query, so an absent CLI is a
|
|
195
|
+
// quiet `undefined` ("unknown") rather than echoing a spawn error to stderr.
|
|
196
|
+
listInstalled: () => antigravityInstalled(),
|
|
176
197
|
};
|
|
198
|
+
/**
|
|
199
|
+
* The plugin names agy currently has imported, or `undefined` when the CLI is
|
|
200
|
+
* absent or its output can't be parsed. Shared by `listInstalled` and by
|
|
201
|
+
* `activate` (to skip the pre-install uninstall for brand-new plugins).
|
|
202
|
+
*/
|
|
203
|
+
function antigravityInstalled() {
|
|
204
|
+
if (!available())
|
|
205
|
+
return undefined;
|
|
206
|
+
const res = run(["plugin", "list"]);
|
|
207
|
+
if (!res.ok)
|
|
208
|
+
return undefined;
|
|
209
|
+
return parseAntigravityPluginList(res.out);
|
|
210
|
+
}
|
|
211
|
+
/**
|
|
212
|
+
* Parse `agy plugin list` JSON (`{ imports: [{ name }] }`) into deduped plugin
|
|
213
|
+
* names, or `undefined` when the output isn't the expected JSON. Pure (no CLI)
|
|
214
|
+
* so it is unit-testable against captured output.
|
|
215
|
+
*/
|
|
216
|
+
export function parseAntigravityPluginList(out) {
|
|
217
|
+
try {
|
|
218
|
+
const parsed = JSON.parse(out);
|
|
219
|
+
const names = (parsed.imports ?? [])
|
|
220
|
+
.map((i) => i.name)
|
|
221
|
+
.filter((n) => typeof n === "string");
|
|
222
|
+
return [...new Set(names)];
|
|
223
|
+
}
|
|
224
|
+
catch {
|
|
225
|
+
return undefined; // unparseable output — report "unknown", don't guess
|
|
226
|
+
}
|
|
227
|
+
}
|
|
@@ -106,4 +106,57 @@ export const claudeAgent = {
|
|
|
106
106
|
const act = claudeAgent.activate(ctx);
|
|
107
107
|
return { agent: "claude", affected: act.affected, skipped: act.skipped };
|
|
108
108
|
},
|
|
109
|
+
// Query Claude's live plugin state for `adg plugins status`, scoped to the
|
|
110
|
+
// ADG marketplace and the requested install scope. `available()` gates the
|
|
111
|
+
// query so an absent CLI is a quiet `undefined` ("unknown").
|
|
112
|
+
listInstalled(ctx) {
|
|
113
|
+
if (!available())
|
|
114
|
+
return undefined;
|
|
115
|
+
const res = run(["plugin", "list"]);
|
|
116
|
+
if (!res.ok)
|
|
117
|
+
return undefined;
|
|
118
|
+
return parseClaudePluginList(res.out, MARKETPLACE, ctx.scope);
|
|
119
|
+
},
|
|
109
120
|
};
|
|
121
|
+
/**
|
|
122
|
+
* Parse `claude plugin list` output into the *enabled* plugin names from a given
|
|
123
|
+
* marketplace and install scope. The listing groups each plugin as a
|
|
124
|
+
* `❯ <name>@<marketplace>` header followed by indented `Scope:` / `Status:`
|
|
125
|
+
* lines; we pair them so a plugin enabled only in another scope, disabled, or
|
|
126
|
+
* from a different marketplace is excluded. Pure (no CLI) so it is unit-testable
|
|
127
|
+
* against captured output.
|
|
128
|
+
*/
|
|
129
|
+
export function parseClaudePluginList(out, marketplace, scope) {
|
|
130
|
+
const names = [];
|
|
131
|
+
const seen = new Set();
|
|
132
|
+
let cur;
|
|
133
|
+
const flush = () => {
|
|
134
|
+
if (cur && cur.mp === marketplace && cur.scope === scope && cur.enabled && !seen.has(cur.name)) {
|
|
135
|
+
seen.add(cur.name);
|
|
136
|
+
names.push(cur.name);
|
|
137
|
+
}
|
|
138
|
+
};
|
|
139
|
+
for (const line of out.split("\n")) {
|
|
140
|
+
const head = line.match(/^\s*❯\s*(\S+?)@([\w.-]+)\s*$/);
|
|
141
|
+
if (head) {
|
|
142
|
+
flush();
|
|
143
|
+
cur = { name: head[1], mp: head[2] };
|
|
144
|
+
continue;
|
|
145
|
+
}
|
|
146
|
+
if (!cur)
|
|
147
|
+
continue;
|
|
148
|
+
const sc = line.match(/^\s*Scope:\s*(\S+)/);
|
|
149
|
+
if (sc) {
|
|
150
|
+
// Normalize case so a future `Scope: Project` still matches "project".
|
|
151
|
+
cur.scope = sc[1].toLowerCase();
|
|
152
|
+
continue;
|
|
153
|
+
}
|
|
154
|
+
const st = line.match(/^\s*Status:\s*(.+)$/);
|
|
155
|
+
// "disabled" does not contain "enabled", so a substring test cleanly
|
|
156
|
+
// distinguishes the two states.
|
|
157
|
+
if (st)
|
|
158
|
+
cur.enabled = /enabled/i.test(st[1]);
|
|
159
|
+
}
|
|
160
|
+
flush();
|
|
161
|
+
return names;
|
|
162
|
+
}
|
package/dist/src/agents/codex.js
CHANGED
|
@@ -47,9 +47,54 @@ export const codexAgent = {
|
|
|
47
47
|
}
|
|
48
48
|
return { agent: "codex", affected, skipped: false };
|
|
49
49
|
},
|
|
50
|
-
// `codex plugin add`
|
|
51
|
-
//
|
|
50
|
+
// `codex plugin add` stages into `.remote-plugin-install-staging` and swaps the
|
|
51
|
+
// cache entry (keeping a `.tmp/plugins-backup-*`), so it *replaces* rather than
|
|
52
|
+
// merges — re-adding is a clean, atomic refresh with no stale-component residue.
|
|
53
|
+
// (Contrast agy, whose `install` merges and so needs an explicit uninstall.)
|
|
52
54
|
refresh(ctx) {
|
|
53
55
|
return codexAgent.activate(ctx);
|
|
54
56
|
},
|
|
57
|
+
// Query Codex's live plugin state for `adg plugins status`, scoped to our
|
|
58
|
+
// generated marketplace. `available()` gates the query so an absent CLI is a
|
|
59
|
+
// quiet `undefined` ("unknown").
|
|
60
|
+
listInstalled(ctx) {
|
|
61
|
+
if (!available())
|
|
62
|
+
return undefined;
|
|
63
|
+
const mp = marketplaceName(ctx.pluginsDir);
|
|
64
|
+
if (!mp)
|
|
65
|
+
return undefined; // no generated marketplace → can't scope the query
|
|
66
|
+
const res = run(["plugin", "list"]);
|
|
67
|
+
if (!res.ok)
|
|
68
|
+
return undefined;
|
|
69
|
+
return parseCodexPluginList(res.out, mp);
|
|
70
|
+
},
|
|
55
71
|
};
|
|
72
|
+
/**
|
|
73
|
+
* Parse `codex plugin list` output into the *installed and enabled* plugin names
|
|
74
|
+
* from a given marketplace. The listing is a whitespace-aligned table whose
|
|
75
|
+
* columns are `<name>@<marketplace>`, `STATUS` (e.g. "installed, enabled"),
|
|
76
|
+
* `VERSION`, `PATH`. We split on 2+ spaces and read the STATUS column so that
|
|
77
|
+
* an available-but-not-added or disabled row isn't miscounted as live, and the
|
|
78
|
+
* header / banner / path lines (no `name@mp` first column) are skipped. Pure
|
|
79
|
+
* (no CLI) so it is unit-testable against captured output.
|
|
80
|
+
*/
|
|
81
|
+
export function parseCodexPluginList(out, marketplace) {
|
|
82
|
+
const names = [];
|
|
83
|
+
const seen = new Set();
|
|
84
|
+
for (const line of out.split("\n")) {
|
|
85
|
+
const cols = line.split(/\s{2,}/);
|
|
86
|
+
const head = cols[0]?.match(/^(\S+?)@(\S+)$/);
|
|
87
|
+
if (!head || head[2] !== marketplace)
|
|
88
|
+
continue;
|
|
89
|
+
const status = (cols[1] ?? "").toLowerCase();
|
|
90
|
+
// Count only plugins actually added and active; "disabled" never contains
|
|
91
|
+
// "enabled", so the substring tests cleanly separate the states.
|
|
92
|
+
if (!status.includes("installed") || status.includes("disabled"))
|
|
93
|
+
continue;
|
|
94
|
+
if (!seen.has(head[1])) {
|
|
95
|
+
seen.add(head[1]);
|
|
96
|
+
names.push(head[1]);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
return names;
|
|
100
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { existsSync } from "node:fs";
|
|
2
2
|
import { adaptPlugin } from "./adapt.js";
|
|
3
|
-
import {
|
|
3
|
+
import { selectInstalled } from "./projection.js";
|
|
4
4
|
import { installedPluginDir } from "../paths.js";
|
|
5
5
|
import { getAgent } from "../agents/index.js";
|
|
6
6
|
/**
|
|
@@ -13,7 +13,7 @@ export function linkPlugins(opts) {
|
|
|
13
13
|
const agent = opts.agent ?? getAgent(opts.target);
|
|
14
14
|
const adaptTarget = agent?.adaptTarget ?? opts.target;
|
|
15
15
|
const actions = [];
|
|
16
|
-
for (const p of
|
|
16
|
+
for (const p of selectInstalled(opts.pluginsDir, opts.names)) {
|
|
17
17
|
const dir = installedPluginDir(opts.pluginsDir, p.name, p.origin);
|
|
18
18
|
if (!existsSync(dir))
|
|
19
19
|
continue;
|
|
@@ -2,6 +2,7 @@ import { lockPath } from "../paths.js";
|
|
|
2
2
|
import { readLock } from "../lock.js";
|
|
3
3
|
import { addPlugins } from "./install.js";
|
|
4
4
|
import { removePlugin } from "./remove.js";
|
|
5
|
+
import { syncPlugins } from "./sync.js";
|
|
5
6
|
import { updateLock } from "./update.js";
|
|
6
7
|
/**
|
|
7
8
|
* A stable key identifying the source a plugin came from. GitHub/git plugins
|
|
@@ -214,3 +215,19 @@ export function marketplaceRemove(opts) {
|
|
|
214
215
|
}
|
|
215
216
|
return { source: opts.source, removed };
|
|
216
217
|
}
|
|
218
|
+
/**
|
|
219
|
+
* Reconcile one agent's copy of every plugin from a given source to the store —
|
|
220
|
+
* the source-scoped twin of `adg plugins sync`. Resolves the source's installed
|
|
221
|
+
* plugins from the lock, then drives `syncPlugins` for just that set, so a whole
|
|
222
|
+
* marketplace can be repaired in one call without naming each plugin.
|
|
223
|
+
*/
|
|
224
|
+
export function marketplaceSync(opts) {
|
|
225
|
+
const group = requireGroup(opts.pluginsDir, opts.source, opts.scope);
|
|
226
|
+
return syncPlugins({
|
|
227
|
+
pluginsDir: opts.pluginsDir,
|
|
228
|
+
target: opts.target,
|
|
229
|
+
global: opts.global,
|
|
230
|
+
names: group.installed,
|
|
231
|
+
agent: opts.agent,
|
|
232
|
+
});
|
|
233
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { listPlugins } from "./list.js";
|
|
2
|
+
/**
|
|
3
|
+
* Shared selection for the projection verbs (link / unlink / sync). Resolve which
|
|
4
|
+
* installed plugins to act on: the named subset (validated against the store), or
|
|
5
|
+
* every installed plugin when no names are given. Throws — naming the unknown
|
|
6
|
+
* plugins — so a typo surfaces rather than silently no-op'ing, and dedupes
|
|
7
|
+
* repeats so `sync foo foo` acts on `foo` once. Centralized here (not in any one
|
|
8
|
+
* verb) so all three select identically.
|
|
9
|
+
*/
|
|
10
|
+
export function selectInstalled(pluginsDir, names) {
|
|
11
|
+
const all = listPlugins(pluginsDir);
|
|
12
|
+
if (!names || names.length === 0)
|
|
13
|
+
return all;
|
|
14
|
+
const byName = new Map(all.map((p) => [p.name, p]));
|
|
15
|
+
const missing = names.filter((n) => !byName.has(n));
|
|
16
|
+
if (missing.length > 0) {
|
|
17
|
+
throw new Error(`not installed: ${missing.join(", ")}. See \`adg plugins list\`.`);
|
|
18
|
+
}
|
|
19
|
+
const seen = new Set();
|
|
20
|
+
const picked = [];
|
|
21
|
+
for (const n of names) {
|
|
22
|
+
if (seen.has(n))
|
|
23
|
+
continue;
|
|
24
|
+
seen.add(n);
|
|
25
|
+
picked.push(byName.get(n));
|
|
26
|
+
}
|
|
27
|
+
return picked;
|
|
28
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { listPlugins } from "./list.js";
|
|
2
|
+
import { allAgents, resolveAgents } from "../agents/index.js";
|
|
3
|
+
/** Diff the store against each agent's live plugin list. Read-only. */
|
|
4
|
+
export function pluginStatus(opts) {
|
|
5
|
+
const store = listPlugins(opts.pluginsDir).map((p) => p.name);
|
|
6
|
+
const storeSet = new Set(store);
|
|
7
|
+
// Query every registered agent (not just `detect`ed ones): `detect` is a
|
|
8
|
+
// config-dir heuristic that can miss an installed CLI, and an agent that
|
|
9
|
+
// can't be queried reports "unknown" anyway — so this never silently drops one.
|
|
10
|
+
const agents = opts.agents ?? (opts.targets ? resolveAgents(opts.targets) : allAgents());
|
|
11
|
+
return agents.map((a) => {
|
|
12
|
+
const installed = a.listInstalled?.({ pluginsDir: opts.pluginsDir, plugins: [], scope: opts.scope });
|
|
13
|
+
if (installed === undefined) {
|
|
14
|
+
return { id: a.id, displayName: a.displayName, queryable: false, inSync: [], missing: [], agentOnly: [] };
|
|
15
|
+
}
|
|
16
|
+
const agentSet = new Set(installed);
|
|
17
|
+
return {
|
|
18
|
+
id: a.id,
|
|
19
|
+
displayName: a.displayName,
|
|
20
|
+
queryable: true,
|
|
21
|
+
inSync: store.filter((n) => agentSet.has(n)),
|
|
22
|
+
missing: store.filter((n) => !agentSet.has(n)),
|
|
23
|
+
agentOnly: installed.filter((n) => !storeSet.has(n)),
|
|
24
|
+
};
|
|
25
|
+
});
|
|
26
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { existsSync } from "node:fs";
|
|
2
|
+
import { adaptPlugin } from "./adapt.js";
|
|
3
|
+
import { selectInstalled } from "./projection.js";
|
|
4
|
+
import { installedPluginDir } from "../paths.js";
|
|
5
|
+
import { getAgent } from "../agents/index.js";
|
|
6
|
+
/** Regenerate manifests for the selected plugins, then refresh them in the agent. */
|
|
7
|
+
export function syncPlugins(opts) {
|
|
8
|
+
const agent = opts.agent ?? getAgent(opts.target);
|
|
9
|
+
const adaptTarget = agent?.adaptTarget ?? opts.target;
|
|
10
|
+
const actions = [];
|
|
11
|
+
for (const p of selectInstalled(opts.pluginsDir, opts.names)) {
|
|
12
|
+
const dir = installedPluginDir(opts.pluginsDir, p.name, p.origin);
|
|
13
|
+
if (!existsSync(dir))
|
|
14
|
+
continue;
|
|
15
|
+
const adapted = adaptPlugin(dir, [adaptTarget], p.selection).map((r) => r.file);
|
|
16
|
+
actions.push({ name: p.name, adapted, synced: false });
|
|
17
|
+
}
|
|
18
|
+
if (!agent)
|
|
19
|
+
return { target: opts.target, actions };
|
|
20
|
+
const res = agent.refresh({
|
|
21
|
+
pluginsDir: opts.pluginsDir,
|
|
22
|
+
plugins: actions.map((a) => a.name),
|
|
23
|
+
scope: opts.global ? "user" : "project",
|
|
24
|
+
});
|
|
25
|
+
for (const a of actions)
|
|
26
|
+
if (res.affected.includes(a.name))
|
|
27
|
+
a.synced = true;
|
|
28
|
+
return { target: opts.target, actions, cliSkipped: res.skipped };
|
|
29
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { selectInstalled } from "./projection.js";
|
|
2
|
+
import { getAgent } from "../agents/index.js";
|
|
3
|
+
/**
|
|
4
|
+
* Deactivate the selected plugins from one agent. Store/lock/marketplace catalog
|
|
5
|
+
* are never touched — only the agent's own enabled state changes.
|
|
6
|
+
*/
|
|
7
|
+
export function unlinkPlugins(opts) {
|
|
8
|
+
const agent = opts.agent ?? getAgent(opts.target);
|
|
9
|
+
// Resolve (and validate) the names against the store even when no agent is
|
|
10
|
+
// registered, so a typo still errors rather than silently no-op'ing.
|
|
11
|
+
const names = selectInstalled(opts.pluginsDir, opts.names).map((p) => p.name);
|
|
12
|
+
if (!agent)
|
|
13
|
+
return { target: opts.target, unlinked: [] };
|
|
14
|
+
const res = agent.deactivate({
|
|
15
|
+
pluginsDir: opts.pluginsDir,
|
|
16
|
+
plugins: names,
|
|
17
|
+
scope: opts.global ? "user" : "project",
|
|
18
|
+
});
|
|
19
|
+
return { target: opts.target, unlinked: res.affected, cliSkipped: res.skipped };
|
|
20
|
+
}
|
|
@@ -105,6 +105,33 @@ export function renderUpdateReport(result) {
|
|
|
105
105
|
out.push(ui.meta("nothing to update (no installed sources)"));
|
|
106
106
|
return out;
|
|
107
107
|
}
|
|
108
|
+
/**
|
|
109
|
+
* `adg plugins status` — per-agent diff of the store against the agent's live
|
|
110
|
+
* plugin list, each drift row tagged with the command that repairs it.
|
|
111
|
+
*/
|
|
112
|
+
export function renderStatus(statuses) {
|
|
113
|
+
if (statuses.length === 0)
|
|
114
|
+
return [ui.meta("no agents detected — install an agent CLI, then `adg plugins link`.")];
|
|
115
|
+
const out = [];
|
|
116
|
+
for (const s of statuses) {
|
|
117
|
+
out.push(ui.name(s.displayName));
|
|
118
|
+
if (!s.queryable) {
|
|
119
|
+
out.push(ui.meta(" live state unknown — agent CLI not available or not queryable"));
|
|
120
|
+
continue;
|
|
121
|
+
}
|
|
122
|
+
out.push(ui.meta(` in sync (${s.inSync.length})${s.inSync.length ? ": " + s.inSync.join(", ") : ""}`));
|
|
123
|
+
if (s.missing.length > 0) {
|
|
124
|
+
out.push(ui.warn(` missing (${s.missing.length}): ${s.missing.join(", ")}`));
|
|
125
|
+
out.push(ui.meta(` → adg plugins sync --target ${s.id} ${s.missing.join(" ")}`));
|
|
126
|
+
}
|
|
127
|
+
if (s.agentOnly.length > 0) {
|
|
128
|
+
out.push(ui.warn(` in agent only (${s.agentOnly.length}): ${s.agentOnly.join(", ")}`));
|
|
129
|
+
out.push(ui.meta(` → if ADG-managed, adg plugins unlink --target ${s.id} <name> (else ignore)`));
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
out.push(ui.meta("note: name-level only; content drift isn't shown — run `adg plugins sync` if unsure."));
|
|
133
|
+
return out;
|
|
134
|
+
}
|
|
108
135
|
/**
|
|
109
136
|
* `adg plugins marketplace list` — installed plugins grouped by source.
|
|
110
137
|
* `details` (name → ListedPlugin) enables the verbose per-plugin component drill;
|