@rbbtsn0w/adg 0.5.0-beta.5 → 0.5.0-beta.7
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 +2 -2
- package/dist/src/agents/antigravity.js +4 -1
- package/dist/src/agents/base.js +7 -2
- package/dist/src/cli/handlers.js +45 -3
- package/dist/src/cli/index.js +17 -1
- package/dist/src/commands/cache.js +54 -0
- package/dist/src/commands/install.js +74 -52
- package/dist/src/commands/link.js +13 -9
- package/dist/src/commands/list.js +4 -1
- package/dist/src/commands/marketplace.js +8 -1
- package/dist/src/commands/migrate.js +73 -6
- package/dist/src/commands/projection.js +6 -0
- package/dist/src/commands/remove.js +11 -2
- package/dist/src/commands/select-components.js +2 -1
- package/dist/src/commands/state.js +18 -12
- package/dist/src/commands/sync.js +13 -9
- package/dist/src/commands/update.js +34 -36
- package/dist/src/fsutil.js +15 -2
- package/dist/src/lock.js +10 -6
- package/dist/src/manifest.js +52 -3
- package/dist/src/materialize.js +176 -0
- package/dist/src/paths.js +27 -1
- package/dist/src/render/json.js +2 -1
- package/dist/src/render/plugins.js +1 -1
- package/dist/src/telemetry.js +14 -1
- package/dist/src/types.js +51 -1
- package/dist/vendor/skills/src/remove.js +2 -1
- package/dist/vendor/skills/src/telemetry.js +5 -1
- package/docs/agents-spec.md +23 -12
- package/docs/cli-json.md +2 -1
- package/package.json +1 -1
- package/schemas/adg-plugin.schema.json +23 -0
- package/schemas/plugin-lock.schema.json +10 -5
- package/vendor/skills/src/remove.ts +2 -1
- package/vendor/skills/src/telemetry.ts +6 -1
package/README.md
CHANGED
|
@@ -165,7 +165,7 @@ asc/
|
|
|
165
165
|
| File | Schema | Role |
|
|
166
166
|
|------|--------|------|
|
|
167
167
|
| `.agents/.plugin.json` | [adg-plugin.schema.json](schemas/adg-plugin.schema.json) (`adg.plugin/v1`) | Universal manifest — source of truth |
|
|
168
|
-
| `.plugin-lock.json` | [plugin-lock.schema.json](schemas/plugin-lock.schema.json) (`version:
|
|
168
|
+
| `.plugin-lock.json` | [plugin-lock.schema.json](schemas/plugin-lock.schema.json) (`version: 3`) | **Control plane** — ADG's authoritative state |
|
|
169
169
|
| `marketplace.json` | [marketplace.schema.json](schemas/marketplace.schema.json) | **Export** — de-facto catalog for Codex |
|
|
170
170
|
|
|
171
171
|
The split is deliberate:
|
|
@@ -243,7 +243,7 @@ adg plugins marketplace sync owner/repo --target all # same, scoped to a who
|
|
|
243
243
|
adg plugins status --target antigravity # live-diff store vs agent (isolates global plugins if project is uninitialized)
|
|
244
244
|
adg plugins update --dir plugins # re-fetch remote sources; rescan local ones in place
|
|
245
245
|
adg plugins list --dir plugins # list locked plugins
|
|
246
|
-
adg plugins migrate --dir plugins # move flat installs
|
|
246
|
+
adg plugins migrate --dir plugins # upgrade legacy locks and move flat installs
|
|
247
247
|
|
|
248
248
|
```
|
|
249
249
|
|
|
@@ -9,6 +9,7 @@ import { readLock } from "../lock.js";
|
|
|
9
9
|
import { toAntigravityManifest, writeAntigravityMcpConfig } from "../adapters/antigravity.js";
|
|
10
10
|
import { writeAntigravityHooks } from "../adapters/antigravity-hooks.js";
|
|
11
11
|
import { skippedResult } from "./base.js";
|
|
12
|
+
import { resolveSelectionDependencies } from "../types.js";
|
|
12
13
|
/**
|
|
13
14
|
* Antigravity (`agy`) agent — physical-directory model, no CLI.
|
|
14
15
|
*
|
|
@@ -212,7 +213,9 @@ function pluginRealDir(pluginsDir, name) {
|
|
|
212
213
|
if (!entry)
|
|
213
214
|
return undefined;
|
|
214
215
|
const dir = installedPluginDir(pluginsDir, name, entry.origin);
|
|
215
|
-
|
|
216
|
+
if (!existsSync(dir))
|
|
217
|
+
return undefined;
|
|
218
|
+
return { dir, selection: resolveSelectionDependencies(readManifest(dir), entry.selection) };
|
|
216
219
|
}
|
|
217
220
|
export const antigravityAgent = {
|
|
218
221
|
id: ID,
|
package/dist/src/agents/base.js
CHANGED
|
@@ -13,13 +13,18 @@ export function skippedResult(agent) {
|
|
|
13
13
|
function clipText(value, max = 512) {
|
|
14
14
|
return value.length <= max ? value : `${value.slice(0, max - 1)}…`;
|
|
15
15
|
}
|
|
16
|
+
function redactFailureText(value) {
|
|
17
|
+
return value
|
|
18
|
+
.replace(/\b(?:github_pat_[A-Za-z0-9_]+|gh[pousr]_[A-Za-z0-9]+)\b/gu, "[REDACTED_TOKEN]")
|
|
19
|
+
.replace(/\b(Authorization\s*:\s*Bearer\s+)[^\s,;]+/giu, "$1[REDACTED_TOKEN]");
|
|
20
|
+
}
|
|
16
21
|
function summarizeFailure(r) {
|
|
17
22
|
const stderr = r.stderr?.trim();
|
|
18
23
|
if (stderr)
|
|
19
|
-
return { stream: "stderr", text: clipText(stderr) };
|
|
24
|
+
return { stream: "stderr", text: clipText(redactFailureText(stderr)) };
|
|
20
25
|
const stdout = r.stdout?.trim();
|
|
21
26
|
if (stdout)
|
|
22
|
-
return { stream: "stdout", text: clipText(stdout) };
|
|
27
|
+
return { stream: "stdout", text: clipText(redactFailureText(stdout)) };
|
|
23
28
|
return undefined;
|
|
24
29
|
}
|
|
25
30
|
function recordFailureExcerpt(span, summary) {
|
package/dist/src/cli/handlers.js
CHANGED
|
@@ -12,6 +12,7 @@ import { removePlugin } from "../commands/remove.js";
|
|
|
12
12
|
import { disablePlugins, enablePlugins } from "../commands/state.js";
|
|
13
13
|
import { migrateLayout } from "../commands/migrate.js";
|
|
14
14
|
import { pluginStatus } from "../commands/status.js";
|
|
15
|
+
import { cleanPluginCache, pluginCacheStatus, prunePluginCache } from "../commands/cache.js";
|
|
15
16
|
import { marketplaceList, marketplaceRemove, marketplaceSync, updatePlugins } from "../commands/marketplace.js";
|
|
16
17
|
import { initScaffold } from "../commands/init.js";
|
|
17
18
|
import { confirmFullInstall, selectComponentsInteractive } from "../commands/select-components.js";
|
|
@@ -23,7 +24,7 @@ import { getAgent } from "../agents/index.js";
|
|
|
23
24
|
import { ui } from "../render/ui.js";
|
|
24
25
|
import { renderAgentReport, renderMarketplaceList, renderPluginList, renderStatus, renderUpdateReport, } from "../render/plugins.js";
|
|
25
26
|
import { pluginsListJson, pluginsStatusJson, printJson } from "../render/json.js";
|
|
26
|
-
import { MARKETPLACE_USAGE, PLUGIN_ALIASES, PLUGIN_COMMANDS, SCOPE, fail, parseVerb, renderPluginsHelp, renderVerbHelp, requireSingleTarget, resolveComponents, resolveScopeDir, resolveTargets, scopeOf, wantsHelp, } from "./index.js";
|
|
27
|
+
import { CACHE_USAGE, MARKETPLACE_USAGE, PLUGIN_ALIASES, PLUGIN_COMMANDS, SCOPE, fail, parseVerb, renderPluginsHelp, renderVerbHelp, requireSingleTarget, resolveComponents, resolveScopeDir, resolveTargets, scopeOf, wantsHelp, } from "./index.js";
|
|
27
28
|
/**
|
|
28
29
|
* Resolve which scope(s) `plugins update` should refresh, mirroring
|
|
29
30
|
* `adg skills update`: an explicit --dir is a single ad-hoc location; otherwise
|
|
@@ -158,6 +159,8 @@ export async function runPlugins(rawVerb, rest) {
|
|
|
158
159
|
}
|
|
159
160
|
if (verb === "marketplace")
|
|
160
161
|
return runMarketplace(rest);
|
|
162
|
+
if (verb === "cache")
|
|
163
|
+
return runCache(rest);
|
|
161
164
|
return runPluginsVerb(verb, rest, cmd);
|
|
162
165
|
}
|
|
163
166
|
async function runPluginsVerb(verb, rest, cmd) {
|
|
@@ -258,7 +261,8 @@ async function runPluginsVerb(verb, rest, cmd) {
|
|
|
258
261
|
console.log(ui.meta(`install order: ${order.join(" -> ")}`));
|
|
259
262
|
for (const res of installed) {
|
|
260
263
|
console.log(`${ui.ok("added")} ${ui.name(res.name)} ${ui.meta(`-> ${res.installedTo}`)}`);
|
|
261
|
-
console.log(ui.meta(`
|
|
264
|
+
console.log(ui.meta(` sourceHash: ${res.sourceHash}`));
|
|
265
|
+
console.log(ui.meta(` installedHash: ${res.installedHash}`));
|
|
262
266
|
for (const f of res.adapted)
|
|
263
267
|
console.log(ui.meta(` adapted: ${f}`));
|
|
264
268
|
}
|
|
@@ -455,11 +459,13 @@ async function runPluginsVerb(verb, rest, cmd) {
|
|
|
455
459
|
const { values } = parseVerb(verb, cmd.flags, rest);
|
|
456
460
|
const sc = await resolveActionScope(values, "migrate");
|
|
457
461
|
const res = migrateLayout(sc.pluginsDir);
|
|
462
|
+
if (res.lockUpgraded)
|
|
463
|
+
console.log(`${ui.ok("upgraded")} plugin lock to version 3`);
|
|
458
464
|
for (const m of res.moved)
|
|
459
465
|
console.log(`${ui.ok("moved")} ${ui.name(m.name)}: ${ui.meta(`${m.from} -> ${m.to}`)}`);
|
|
460
466
|
for (const m of res.missing)
|
|
461
467
|
console.error(ui.warn(` ! missing directory for locked plugin: ${m}`));
|
|
462
|
-
if (res.moved.length === 0)
|
|
468
|
+
if (!res.lockUpgraded && res.moved.length === 0)
|
|
463
469
|
console.log(ui.meta(`nothing to migrate (${res.unchanged.length} already in place)`));
|
|
464
470
|
return;
|
|
465
471
|
}
|
|
@@ -578,3 +584,39 @@ async function runMarketplace(args) {
|
|
|
578
584
|
}
|
|
579
585
|
}
|
|
580
586
|
}
|
|
587
|
+
async function runCache(args) {
|
|
588
|
+
const [sub, ...rest] = args;
|
|
589
|
+
if (sub === undefined || sub === "-h" || sub === "--help" || sub === "help" || wantsHelp(rest)) {
|
|
590
|
+
console.log(CACHE_USAGE);
|
|
591
|
+
return;
|
|
592
|
+
}
|
|
593
|
+
if (sub === "status") {
|
|
594
|
+
const { values } = parseVerb("cache", [...SCOPE], rest);
|
|
595
|
+
const status = pluginCacheStatus(resolveScopeDir(values));
|
|
596
|
+
console.log(ui.meta(status.root));
|
|
597
|
+
if (status.entries.length === 0)
|
|
598
|
+
console.log(ui.meta("cache is empty"));
|
|
599
|
+
for (const entry of status.entries) {
|
|
600
|
+
console.log(`${entry.orphan ? ui.warn("orphan") : ui.ok("cached")} ${ui.name(entry.name)} ${ui.meta(`${entry.bytes} bytes`)}`);
|
|
601
|
+
}
|
|
602
|
+
console.log(ui.meta(`total: ${status.totalBytes} bytes`));
|
|
603
|
+
return;
|
|
604
|
+
}
|
|
605
|
+
if (sub === "prune") {
|
|
606
|
+
const { values } = parseVerb("cache", [...SCOPE], rest);
|
|
607
|
+
const scope = await resolveActionScope(values, "cache prune");
|
|
608
|
+
const removed = prunePluginCache(scope.pluginsDir);
|
|
609
|
+
console.log(removed.length > 0 ? `${ui.ok("pruned")} ${removed.join(", ")}` : ui.meta("no orphan cache snapshots"));
|
|
610
|
+
return;
|
|
611
|
+
}
|
|
612
|
+
if (sub === "clean") {
|
|
613
|
+
const { values } = parseVerb("cache", ["force", ...SCOPE], rest);
|
|
614
|
+
if (!values.force)
|
|
615
|
+
fail("cache clean requires --force");
|
|
616
|
+
const scope = await resolveActionScope(values, "cache clean");
|
|
617
|
+
cleanPluginCache(scope.pluginsDir);
|
|
618
|
+
console.log(ui.ok("cache cleaned"));
|
|
619
|
+
return;
|
|
620
|
+
}
|
|
621
|
+
fail(`unknown cache subcommand: ${sub}`);
|
|
622
|
+
}
|
package/dist/src/cli/index.js
CHANGED
|
@@ -162,7 +162,7 @@ export const PLUGIN_COMMANDS = {
|
|
|
162
162
|
],
|
|
163
163
|
},
|
|
164
164
|
migrate: {
|
|
165
|
-
summary: "move flat installs
|
|
165
|
+
summary: "upgrade legacy locks and move flat installs",
|
|
166
166
|
synopsis: "adg plugins migrate",
|
|
167
167
|
flags: [...SCOPE],
|
|
168
168
|
},
|
|
@@ -172,6 +172,12 @@ export const PLUGIN_COMMANDS = {
|
|
|
172
172
|
flags: [],
|
|
173
173
|
delegated: true,
|
|
174
174
|
},
|
|
175
|
+
cache: {
|
|
176
|
+
summary: "inspect and garbage-collect source snapshots",
|
|
177
|
+
synopsis: "adg plugins cache <status|prune|clean>",
|
|
178
|
+
flags: [],
|
|
179
|
+
delegated: true,
|
|
180
|
+
},
|
|
175
181
|
};
|
|
176
182
|
// Aliases tolerated for plugin verbs.
|
|
177
183
|
export const PLUGIN_ALIASES = { rm: "remove", mp: "marketplace" };
|
|
@@ -212,6 +218,16 @@ Commands:
|
|
|
212
218
|
Kept as an alias. To pull upstream changes, prefer \`adg plugins update\`.
|
|
213
219
|
|
|
214
220
|
<source> is a key from \`marketplace list\` (e.g. owner/repo).`;
|
|
221
|
+
export const CACHE_USAGE = `adg plugins cache — inspect and garbage-collect complete source snapshots
|
|
222
|
+
|
|
223
|
+
Commands:
|
|
224
|
+
adg plugins cache status [--global | --project | --dir <dir>]
|
|
225
|
+
Show cached snapshots, byte sizes, and orphan state.
|
|
226
|
+
adg plugins cache prune [--global | --project | --dir <dir>]
|
|
227
|
+
Delete snapshots that have no corresponding lock entry.
|
|
228
|
+
adg plugins cache clean --force [--global | --project | --dir <dir>]
|
|
229
|
+
Delete every source snapshot for the selected store. A later update or
|
|
230
|
+
add may be required before link/sync can rebuild remote plugins.`;
|
|
215
231
|
export function flagLabel(name) {
|
|
216
232
|
const f = FLAGS[name];
|
|
217
233
|
const lead = f.short ? `-${f.short}, --${name}` : ` --${name}`;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { existsSync, readdirSync, rmSync, statSync } from "node:fs";
|
|
2
|
+
import { join } from "node:path";
|
|
3
|
+
import { readLock } from "../lock.js";
|
|
4
|
+
import { lockPath, pluginCacheRoot } from "../paths.js";
|
|
5
|
+
export function directoryBytes(dir) {
|
|
6
|
+
let total = 0;
|
|
7
|
+
try {
|
|
8
|
+
for (const entry of readdirSync(dir, { withFileTypes: true })) {
|
|
9
|
+
const path = join(dir, entry.name);
|
|
10
|
+
if (entry.isDirectory())
|
|
11
|
+
total += directoryBytes(path);
|
|
12
|
+
else if (entry.isFile()) {
|
|
13
|
+
try {
|
|
14
|
+
total += statSync(path).size;
|
|
15
|
+
}
|
|
16
|
+
catch {
|
|
17
|
+
// A concurrent cache mutation must not make status fail.
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
catch {
|
|
23
|
+
// Treat an unreadable or concurrently removed directory as empty.
|
|
24
|
+
}
|
|
25
|
+
return total;
|
|
26
|
+
}
|
|
27
|
+
export function pluginCacheStatus(pluginsDir) {
|
|
28
|
+
const root = pluginCacheRoot(pluginsDir);
|
|
29
|
+
const installed = new Set(Object.keys(readLock(lockPath(pluginsDir)).plugins));
|
|
30
|
+
const entries = existsSync(root)
|
|
31
|
+
? readdirSync(root, { withFileTypes: true })
|
|
32
|
+
.filter((entry) => entry.isDirectory() && !entry.name.startsWith("."))
|
|
33
|
+
.map((entry) => {
|
|
34
|
+
const path = join(root, entry.name);
|
|
35
|
+
return { name: entry.name, path, bytes: directoryBytes(path), orphan: !installed.has(entry.name) };
|
|
36
|
+
})
|
|
37
|
+
.sort((a, b) => a.name.localeCompare(b.name))
|
|
38
|
+
: [];
|
|
39
|
+
return { root, entries, totalBytes: entries.reduce((sum, entry) => sum + entry.bytes, 0) };
|
|
40
|
+
}
|
|
41
|
+
/** Delete cache snapshots that have no corresponding lock entry. */
|
|
42
|
+
export function prunePluginCache(pluginsDir) {
|
|
43
|
+
const status = pluginCacheStatus(pluginsDir);
|
|
44
|
+
const removed = status.entries.filter((entry) => entry.orphan);
|
|
45
|
+
for (const entry of removed)
|
|
46
|
+
rmSync(entry.path, { recursive: true, force: true });
|
|
47
|
+
if (existsSync(status.root) && readdirSync(status.root).length === 0)
|
|
48
|
+
rmSync(status.root, { recursive: true, force: true });
|
|
49
|
+
return removed.map((entry) => entry.name);
|
|
50
|
+
}
|
|
51
|
+
/** Delete every rebuildable source snapshot for this store. */
|
|
52
|
+
export function cleanPluginCache(pluginsDir) {
|
|
53
|
+
rmSync(pluginCacheRoot(pluginsDir), { recursive: true, force: true });
|
|
54
|
+
}
|
|
@@ -1,23 +1,25 @@
|
|
|
1
1
|
import { existsSync, mkdtempSync, readFileSync, rmSync, statSync } from "node:fs";
|
|
2
2
|
import { tmpdir } from "node:os";
|
|
3
3
|
import { basename, join, relative, resolve } from "node:path";
|
|
4
|
+
import { isDeepStrictEqual } from "node:util";
|
|
4
5
|
import { ADAPTER_TARGETS } from "../adapters/index.js";
|
|
5
6
|
import { fromNativeManifest } from "../adapters/reverse.js";
|
|
6
7
|
import { adaptPlugin } from "./adapt.js";
|
|
7
8
|
import { removePlugin } from "./remove.js";
|
|
8
|
-
import {
|
|
9
|
+
import { toPosix, writeJson } from "../fsutil.js";
|
|
9
10
|
import { folderHash } from "../hash.js";
|
|
10
11
|
import { packageFilter, PROJECTION_DIRS } from "../package.js";
|
|
11
|
-
import { lockPath, marketplacePath, marketplaceSourcePath, pluginDir } from "../paths.js";
|
|
12
|
+
import { lockPath, marketplacePath, marketplaceSourcePath, pluginDir, pluginSourceCacheDir } from "../paths.js";
|
|
12
13
|
import { readLock, upsertEntry, writeLock } from "../lock.js";
|
|
13
14
|
import { ADG_MANIFEST_PATH, readManifest } from "../manifest.js";
|
|
14
15
|
import { readMarketplace, upsertMarketplacePlugin, writeMarketplace } from "../marketplace.js";
|
|
15
16
|
import { resolveInstallOrder } from "../deps.js";
|
|
16
17
|
import { cloneGitHub, parseSource, scanNativePlugins, scanPlugins } from "../sources.js";
|
|
17
|
-
import { pluginState, sameSource, COMPONENT_TYPES } from "../types.js";
|
|
18
|
+
import { normalizePluginSelection, pluginState, resolveSelectionDependencies, sameSource, COMPONENT_TYPES } from "../types.js";
|
|
18
19
|
import { pluginContents, presentComponents } from "../components.js";
|
|
19
20
|
import { skillDescriptionLoader } from "../skills.js";
|
|
20
21
|
import { resolveAgents } from "../agents/index.js";
|
|
22
|
+
import { effectivePackageFilter, materializePlugin, withPluginSourceCache } from "../materialize.js";
|
|
21
23
|
// Generated runtime projections never count toward a plugin's content hash.
|
|
22
24
|
const HASH_IGNORE = PROJECTION_DIRS;
|
|
23
25
|
/** Content hash over a plugin's packaged payload (hooks files are authored content, not generated). */
|
|
@@ -40,7 +42,7 @@ export function installPlugin(opts) {
|
|
|
40
42
|
const name = manifest.name;
|
|
41
43
|
// Local installs stay flat; remote sources derive a per-marketplace dir from
|
|
42
44
|
// their origin. The default (no origin) is a flat local copy-in.
|
|
43
|
-
const origin = opts.origin ?? { type: "local", path:
|
|
45
|
+
const origin = opts.origin ?? { type: "local", path: source };
|
|
44
46
|
const dest = pluginDir(opts.pluginsDir, name, origin);
|
|
45
47
|
const lockFile = lockPath(opts.pluginsDir);
|
|
46
48
|
const lock = readLock(lockFile);
|
|
@@ -49,56 +51,76 @@ export function installPlugin(opts) {
|
|
|
49
51
|
throw new Error(`name collision: "${name}" is already installed from a different source ` +
|
|
50
52
|
`(${describe(prev.origin)} vs ${describe(origin)}). Rename one to avoid the conflict.`);
|
|
51
53
|
}
|
|
52
|
-
// Detect-then-update: compute the source's content hash up front (cheap, no
|
|
53
|
-
// copy) and, when asked, short-circuit if it matches what's already recorded —
|
|
54
|
-
// so an unchanged upstream source is never re-copied, re-adapted, or re-locked.
|
|
55
|
-
if (opts.skipUnchanged && prev) {
|
|
56
|
-
const sourceHash = contentHash(source, manifest);
|
|
57
|
-
if (prev.folderHash === sourceHash && prev.version === manifest.version) {
|
|
58
|
-
return { name, installedTo: dest, folderHash: sourceHash, adapted: [], changed: false };
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
// When the source already lives at the destination (e.g. adapting an
|
|
62
|
-
// in-repo reference plugin) skip the copy to avoid copying onto itself.
|
|
63
|
-
// Only the manifest-declared payload is copied (projections included) — dev
|
|
64
|
-
// cruft like src/ or test/ never ships.
|
|
65
|
-
if (resolve(dest) !== source) {
|
|
66
|
-
copyPluginDir(source, dest, packageFilter(manifest, { includeProjections: true }));
|
|
67
|
-
}
|
|
68
54
|
// A new selection wins; otherwise keep whatever a prior install recorded so
|
|
69
55
|
// partial installs survive re-install / `marketplace upgrade`.
|
|
70
|
-
const
|
|
71
|
-
const
|
|
72
|
-
const
|
|
73
|
-
const
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
56
|
+
const desiredSelection = normalizePluginSelection(opts.selection ?? prev?.selection);
|
|
57
|
+
const selection = resolveSelectionDependencies(manifest, desiredSelection);
|
|
58
|
+
const sourceHash = contentHash(source, manifest);
|
|
59
|
+
const cacheDir = pluginSourceCacheDir(opts.pluginsDir, name);
|
|
60
|
+
return withPluginSourceCache(source, cacheDir, manifest, (snapshot) => {
|
|
61
|
+
// Detect-then-update compares the complete source snapshot, never the
|
|
62
|
+
// selection-pruned runtime installation.
|
|
63
|
+
if (!opts.forceMaterialize && opts.skipUnchanged && prev
|
|
64
|
+
&& prev.sourceHash === sourceHash && prev.version === manifest.version) {
|
|
65
|
+
const installedIntact = existsSync(dest)
|
|
66
|
+
&& folderHash(dest, PROJECTION_DIRS, effectivePackageFilter(manifest, selection)) === prev.installedHash;
|
|
67
|
+
if (installedIntact) {
|
|
68
|
+
return {
|
|
69
|
+
name,
|
|
70
|
+
version: manifest.version,
|
|
71
|
+
installedTo: dest,
|
|
72
|
+
sourceHash,
|
|
73
|
+
installedHash: prev.installedHash,
|
|
74
|
+
adapted: [],
|
|
75
|
+
changed: false,
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
const targets = opts.targets ?? [...ADAPTER_TARGETS];
|
|
80
|
+
const adapted = [];
|
|
81
|
+
let installedHash = "";
|
|
82
|
+
materializePlugin({
|
|
83
|
+
source: snapshot,
|
|
84
|
+
destination: dest,
|
|
85
|
+
manifest,
|
|
86
|
+
selection,
|
|
87
|
+
build: (staging) => {
|
|
88
|
+
adapted.push(...adaptPlugin(staging, targets, selection).map((r) => relative(staging, r.file)));
|
|
89
|
+
installedHash = folderHash(staging, PROJECTION_DIRS, effectivePackageFilter(manifest, selection));
|
|
90
|
+
},
|
|
91
|
+
});
|
|
92
|
+
const adaptedFiles = adapted.map((file) => join(dest, file));
|
|
93
|
+
const entry = {
|
|
94
|
+
origin,
|
|
95
|
+
version: manifest.version,
|
|
96
|
+
sourceHash,
|
|
97
|
+
installedHash,
|
|
98
|
+
};
|
|
99
|
+
if (manifest.dependencies?.length) {
|
|
100
|
+
entry.dependencies = Object.fromEntries(manifest.dependencies.map((d) => [d.name, d.version]));
|
|
101
|
+
}
|
|
102
|
+
if (desiredSelection)
|
|
103
|
+
entry.selection = desiredSelection;
|
|
104
|
+
if (prev?.state)
|
|
105
|
+
entry.state = prev.state;
|
|
106
|
+
const previousEntry = prev && Object.fromEntries(Object.entries(prev).filter(([key]) => key !== "installedAt" && key !== "updatedAt"));
|
|
107
|
+
const changed = !prev || !isDeepStrictEqual(previousEntry, entry);
|
|
108
|
+
if (changed) {
|
|
109
|
+
upsertEntry(lock, name, entry, opts.now);
|
|
110
|
+
writeLock(lockFile, lock);
|
|
111
|
+
}
|
|
112
|
+
const marketFile = marketplacePath(opts.pluginsDir);
|
|
113
|
+
const fallbackName = opts.marketplaceName ?? basename(opts.pluginsDir);
|
|
114
|
+
const market = readMarketplace(marketFile, fallbackName);
|
|
115
|
+
upsertMarketplacePlugin(market, {
|
|
116
|
+
name,
|
|
117
|
+
source: { source: "local", path: marketplaceSourcePath(opts.pluginsDir, dest) },
|
|
118
|
+
policy: { installation: "AVAILABLE", authentication: "ON_INSTALL" },
|
|
119
|
+
...(manifest.category ? { category: manifest.category } : {}),
|
|
120
|
+
});
|
|
121
|
+
writeMarketplace(marketFile, market);
|
|
122
|
+
return { name, version: manifest.version, installedTo: dest, sourceHash, installedHash, adapted: adaptedFiles, changed };
|
|
99
123
|
});
|
|
100
|
-
writeMarketplace(marketFile, market);
|
|
101
|
-
return { name, installedTo: dest, folderHash: hash, adapted, changed };
|
|
102
124
|
}
|
|
103
125
|
function describe(s) {
|
|
104
126
|
switch (s.type) {
|
|
@@ -262,7 +284,7 @@ export async function addPlugins(opts) {
|
|
|
262
284
|
let cleanup;
|
|
263
285
|
if (parsed.kind === "local") {
|
|
264
286
|
workRoot = resolve(parsed.dir);
|
|
265
|
-
buildOrigin = (dir) => ({ type: "local", path:
|
|
287
|
+
buildOrigin = (dir) => ({ type: "local", path: resolve(dir) });
|
|
266
288
|
}
|
|
267
289
|
else {
|
|
268
290
|
const tmp = mkdtempSync(join(tmpdir(), "adg-clone-"));
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { selectInstalled } from "./projection.js";
|
|
4
|
-
import { installedPluginDir } from "../paths.js";
|
|
1
|
+
import { adaptedFilesForTarget, selectInstalled } from "./projection.js";
|
|
2
|
+
import { pluginRematerializationSource } from "../paths.js";
|
|
5
3
|
import { getAgent } from "../agents/index.js";
|
|
4
|
+
import { ADAPTER_TARGETS } from "../adapters/index.js";
|
|
6
5
|
import { pluginState } from "../types.js";
|
|
6
|
+
import { installPlugin } from "./install.js";
|
|
7
7
|
/**
|
|
8
8
|
* Project installed plugins into an agent: (re)generate that agent's manifest
|
|
9
9
|
* from each plugin (honoring its partial-install selection), then enable the
|
|
@@ -22,11 +22,15 @@ export function linkPlugins(opts) {
|
|
|
22
22
|
const enabled = selected.filter((p) => pluginState(p) === "enabled");
|
|
23
23
|
const actions = [];
|
|
24
24
|
for (const p of enabled) {
|
|
25
|
-
const
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
25
|
+
const result = installPlugin({
|
|
26
|
+
source: pluginRematerializationSource(opts.pluginsDir, p.name, p.origin),
|
|
27
|
+
pluginsDir: opts.pluginsDir,
|
|
28
|
+
origin: p.origin,
|
|
29
|
+
selection: p.selection,
|
|
30
|
+
targets: [...ADAPTER_TARGETS],
|
|
31
|
+
forceMaterialize: true,
|
|
32
|
+
});
|
|
33
|
+
actions.push({ name: p.name, adapted: adaptedFilesForTarget(result.installedTo, result.adapted, adaptTarget) });
|
|
30
34
|
}
|
|
31
35
|
if (!agent)
|
|
32
36
|
return { target: opts.target, actions };
|
|
@@ -2,6 +2,7 @@ import { installedPluginDir, lockPath } from "../paths.js";
|
|
|
2
2
|
import { readLock } from "../lock.js";
|
|
3
3
|
import { readManifest } from "../manifest.js";
|
|
4
4
|
import { exposedContents, pluginContents } from "../components.js";
|
|
5
|
+
import { resolveSelectionDependencies } from "../types.js";
|
|
5
6
|
/** List plugins recorded in a plugins directory's .plugin-lock.json. */
|
|
6
7
|
export function listPlugins(pluginsDir) {
|
|
7
8
|
const lock = readLock(lockPath(pluginsDir));
|
|
@@ -9,7 +10,9 @@ export function listPlugins(pluginsDir) {
|
|
|
9
10
|
const dir = installedPluginDir(pluginsDir, name, entry.origin);
|
|
10
11
|
let contents;
|
|
11
12
|
try {
|
|
12
|
-
|
|
13
|
+
const manifest = readManifest(dir);
|
|
14
|
+
const effectiveSelection = resolveSelectionDependencies(manifest, entry.selection);
|
|
15
|
+
contents = exposedContents(pluginContents(dir, manifest), effectiveSelection);
|
|
13
16
|
}
|
|
14
17
|
catch {
|
|
15
18
|
contents = undefined; // no/invalid manifest on disk — show provenance only
|
|
@@ -60,7 +60,14 @@ function requireGroup(pluginsDir, source, scope) {
|
|
|
60
60
|
const where = scope?.label ? `${scope.label}: ${pluginsDir}` : pluginsDir;
|
|
61
61
|
let msg = `no installed source "${source}" in ${where}. Known sources: ${keys}`;
|
|
62
62
|
if (scope?.globalDir && scope.globalDir !== pluginsDir) {
|
|
63
|
-
|
|
63
|
+
let inGlobal = false;
|
|
64
|
+
try {
|
|
65
|
+
inGlobal = marketplaceList({ pluginsDir: scope.globalDir }).some((g) => g.source === source);
|
|
66
|
+
}
|
|
67
|
+
catch {
|
|
68
|
+
// The global store is only an optional suggestion source. A malformed or
|
|
69
|
+
// unsupported global lock must not mask the active scope's real error.
|
|
70
|
+
}
|
|
64
71
|
if (inGlobal)
|
|
65
72
|
msg += ` — found in global; did you mean \`-g\`?`;
|
|
66
73
|
}
|
|
@@ -1,8 +1,16 @@
|
|
|
1
|
-
import { existsSync, mkdirSync, renameSync } from "node:fs";
|
|
1
|
+
import { existsSync, mkdirSync, readFileSync, renameSync } from "node:fs";
|
|
2
2
|
import { dirname, join } from "node:path";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
3
|
+
import { ADAPTER_TARGETS } from "../adapters/index.js";
|
|
4
|
+
import { folderHash } from "../hash.js";
|
|
5
|
+
import { readManifest } from "../manifest.js";
|
|
6
|
+
import { effectivePackageFilter, materializePlugin, withPluginSourceCache } from "../materialize.js";
|
|
7
|
+
import { packageFilter, PROJECTION_DIRS } from "../package.js";
|
|
8
|
+
import { installedPluginDir, lockPath, marketplacePath, marketplaceSourcePath, pluginDir, pluginSourceCacheDir } from "../paths.js";
|
|
9
|
+
import { readLock, writeLock } from "../lock.js";
|
|
5
10
|
import { readMarketplace, upsertMarketplacePlugin, writeMarketplace } from "../marketplace.js";
|
|
11
|
+
import { adaptPlugin } from "./adapt.js";
|
|
12
|
+
import { recordTelemetryEvent } from "../telemetry.js";
|
|
13
|
+
import { LOCK_VERSION, normalizePluginSelection, resolveSelectionDependencies } from "../types.js";
|
|
6
14
|
/**
|
|
7
15
|
* Migrate a flat plugins directory to the per-marketplace nested layout.
|
|
8
16
|
*
|
|
@@ -11,8 +19,9 @@ import { readMarketplace, upsertMarketplacePlugin, writeMarketplace } from "../m
|
|
|
11
19
|
* flat) and rewrite its marketplace.json `source.path` to match. Idempotent:
|
|
12
20
|
* plugins already at their target path are reported as unchanged.
|
|
13
21
|
*/
|
|
14
|
-
export function migrateLayout(pluginsDir) {
|
|
15
|
-
const
|
|
22
|
+
export function migrateLayout(pluginsDir, telemetrySpan) {
|
|
23
|
+
const lockUpgraded = migrateLockV2(pluginsDir, telemetrySpan);
|
|
24
|
+
const lock = readLock(lockPath(pluginsDir), telemetrySpan);
|
|
16
25
|
const moved = [];
|
|
17
26
|
const unchanged = [];
|
|
18
27
|
const missing = [];
|
|
@@ -45,7 +54,65 @@ export function migrateLayout(pluginsDir) {
|
|
|
45
54
|
}
|
|
46
55
|
if (marketDirty)
|
|
47
56
|
writeMarketplace(marketFile, market);
|
|
48
|
-
return { moved, unchanged, missing };
|
|
57
|
+
return { lockUpgraded, moved, unchanged, missing };
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Explicitly upgrade a v2 store. The old full installation is cached before
|
|
61
|
+
* selection-aware materialization, so unselected payload remains recoverable.
|
|
62
|
+
* The v3 lock is written only after every plugin has been converted.
|
|
63
|
+
*/
|
|
64
|
+
function migrateLockV2(pluginsDir, telemetrySpan) {
|
|
65
|
+
const file = lockPath(pluginsDir);
|
|
66
|
+
if (!existsSync(file))
|
|
67
|
+
return false;
|
|
68
|
+
const raw = JSON.parse(readFileSync(file, "utf8"));
|
|
69
|
+
if (raw.version === LOCK_VERSION)
|
|
70
|
+
return false;
|
|
71
|
+
if (typeof raw?.version === "number") {
|
|
72
|
+
recordTelemetryEvent("adg.lock.read", { "format.version": raw.version === 2 ? 2 : -1 }, telemetrySpan);
|
|
73
|
+
}
|
|
74
|
+
if (raw.version !== 2 || typeof raw.plugins !== "object" || raw.plugins === null) {
|
|
75
|
+
throw new Error(`${file} uses unsupported lock version ${raw.version}; expected ${LOCK_VERSION}`);
|
|
76
|
+
}
|
|
77
|
+
const plugins = {};
|
|
78
|
+
for (const [name, oldEntry] of Object.entries(raw.plugins)) {
|
|
79
|
+
const installed = installedPluginDir(pluginsDir, name, oldEntry.origin);
|
|
80
|
+
const cache = pluginSourceCacheDir(pluginsDir, name);
|
|
81
|
+
const source = existsSync(cache) ? cache : installed;
|
|
82
|
+
if (!existsSync(source))
|
|
83
|
+
throw new Error(`cannot migrate "${name}": installed directory and source cache are missing`);
|
|
84
|
+
const manifest = readManifest(source, telemetrySpan);
|
|
85
|
+
const desiredSelection = normalizePluginSelection(oldEntry.selection);
|
|
86
|
+
const selection = resolveSelectionDependencies(manifest, desiredSelection);
|
|
87
|
+
withPluginSourceCache(source, cache, manifest, (snapshot) => {
|
|
88
|
+
const sourceHash = folderHash(snapshot, PROJECTION_DIRS, packageFilter(manifest, { includeProjections: false }));
|
|
89
|
+
let installedHash = "";
|
|
90
|
+
materializePlugin({
|
|
91
|
+
source: snapshot,
|
|
92
|
+
destination: installed,
|
|
93
|
+
manifest,
|
|
94
|
+
selection,
|
|
95
|
+
build: (staging) => {
|
|
96
|
+
adaptPlugin(staging, [...ADAPTER_TARGETS], selection);
|
|
97
|
+
installedHash = folderHash(staging, PROJECTION_DIRS, effectivePackageFilter(manifest, selection));
|
|
98
|
+
},
|
|
99
|
+
});
|
|
100
|
+
plugins[name] = {
|
|
101
|
+
origin: oldEntry.origin,
|
|
102
|
+
version: oldEntry.version,
|
|
103
|
+
sourceHash,
|
|
104
|
+
installedHash,
|
|
105
|
+
installedAt: oldEntry.installedAt,
|
|
106
|
+
updatedAt: oldEntry.updatedAt,
|
|
107
|
+
...(oldEntry.dependencies ? { dependencies: oldEntry.dependencies } : {}),
|
|
108
|
+
...(desiredSelection ? { selection: desiredSelection } : {}),
|
|
109
|
+
...(oldEntry.state ? { state: oldEntry.state } : {}),
|
|
110
|
+
};
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
writeLock(file, { version: LOCK_VERSION, plugins, ...(raw.lastSelected ? { lastSelected: raw.lastSelected } : {}) });
|
|
114
|
+
recordTelemetryEvent("adg.lock.migrate", { "from.version": 2, "to.version": LOCK_VERSION }, telemetrySpan);
|
|
115
|
+
return true;
|
|
49
116
|
}
|
|
50
117
|
/** Point a marketplace entry's `source.path` at the plugin's on-disk dir. */
|
|
51
118
|
function rewriteMarketplacePath(market, name, pluginsDir, dir) {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { listPlugins } from "./list.js";
|
|
2
|
+
import { relative } from "node:path";
|
|
2
3
|
/**
|
|
3
4
|
* Shared selection for the projection verbs (link / unlink / sync). Resolve which
|
|
4
5
|
* installed plugins to act on: the named subset (validated against the store), or
|
|
@@ -26,3 +27,8 @@ export function selectInstalled(pluginsDir, names) {
|
|
|
26
27
|
}
|
|
27
28
|
return picked;
|
|
28
29
|
}
|
|
30
|
+
/** Keep only the generated manifest reported for one runtime target. */
|
|
31
|
+
export function adaptedFilesForTarget(installedTo, files, target) {
|
|
32
|
+
const expected = target === "antigravity" ? "plugin.json" : `.${target}-plugin/plugin.json`;
|
|
33
|
+
return files.filter((file) => relative(installedTo, file).split("\\").join("/") === expected);
|
|
34
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { existsSync, lstatSync, readdirSync, readlinkSync, rmdirSync, rmSync } from "node:fs";
|
|
2
2
|
import { basename, dirname, join, resolve } from "node:path";
|
|
3
|
-
import { claudeSkillsDir, lockPath, marketplacePath, pluginDir } from "../paths.js";
|
|
3
|
+
import { claudeSkillsDir, lockPath, marketplacePath, pluginCacheRoot, pluginDir, pluginSourceCacheDir } from "../paths.js";
|
|
4
4
|
import { readLock, removeEntry, writeLock } from "../lock.js";
|
|
5
5
|
import { readMarketplace, removeMarketplacePlugin, writeMarketplace } from "../marketplace.js";
|
|
6
6
|
import { resolveAgents } from "../agents/index.js";
|
|
@@ -55,6 +55,15 @@ export function removePlugin(opts) {
|
|
|
55
55
|
// Drop the per-marketplace bucket if it became empty (nested remote layout).
|
|
56
56
|
pruneEmptyParent(dirname(dir), opts.pluginsDir);
|
|
57
57
|
}
|
|
58
|
+
const cacheDir = pluginSourceCacheDir(opts.pluginsDir, name);
|
|
59
|
+
let removedCacheDir;
|
|
60
|
+
if (existsSync(cacheDir)) {
|
|
61
|
+
rmSync(cacheDir, { recursive: true, force: true });
|
|
62
|
+
removedCacheDir = cacheDir;
|
|
63
|
+
const cacheRoot = pluginCacheRoot(opts.pluginsDir);
|
|
64
|
+
if (existsSync(cacheRoot) && readdirSync(cacheRoot).length === 0)
|
|
65
|
+
rmSync(cacheRoot, { recursive: true, force: true });
|
|
66
|
+
}
|
|
58
67
|
const removedFromLock = removeEntry(lock, name);
|
|
59
68
|
if (removedFromLock)
|
|
60
69
|
writeLock(lockFile, lock);
|
|
@@ -70,7 +79,7 @@ export function removePlugin(opts) {
|
|
|
70
79
|
const ctx = { pluginsDir: opts.pluginsDir, plugins: [name], scope: opts.scope ?? "project" };
|
|
71
80
|
agents = (opts.agents ?? resolveAgents()).map((a) => a.deactivate(ctx));
|
|
72
81
|
}
|
|
73
|
-
return { name, removedDir, unlinked, removedFromLock, removedFromMarketplace, agents };
|
|
82
|
+
return { name, removedDir, removedCacheDir, unlinked, removedFromLock, removedFromMarketplace, agents };
|
|
74
83
|
}
|
|
75
84
|
/**
|
|
76
85
|
* Remove `parent` if it is an empty per-marketplace bucket below `pluginsDir`.
|
|
@@ -30,7 +30,8 @@ export async function confirmFullInstall(plugins) {
|
|
|
30
30
|
/**
|
|
31
31
|
* Per-plugin component picker (①). Choose which categories to expose; if skills
|
|
32
32
|
* is kept and the plugin has several, drill in to pick individual skills. Files
|
|
33
|
-
* are
|
|
33
|
+
* are materialized into the effective installation; unselected payload stays
|
|
34
|
+
* only in ADG's internal source cache.
|
|
34
35
|
*/
|
|
35
36
|
export async function selectComponentsInteractive(req) {
|
|
36
37
|
const components = await p.multiselect({
|