@rbbtsn0w/adg 0.6.0 → 0.7.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 +41 -9
- package/dist/bin/adg.js +4 -4
- package/dist/src/adapters/codex.js +12 -0
- package/dist/src/adapters/reverse.js +22 -1
- package/dist/src/agents/base.js +2 -1
- package/dist/src/agents/claude.js +52 -6
- package/dist/src/agents/codex.js +94 -14
- package/dist/src/cli/core-plugin-handlers.js +97 -0
- package/dist/src/cli/handlers.js +155 -210
- 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 +85 -4
- 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/subprocess.js +53 -0
- package/dist/src/telemetry.js +28 -21
- package/dist/src/types.js +5 -1
- package/dist/vendor/skills/src/add.js +0 -15
- package/dist/vendor/skills/src/cli.js +6 -1
- package/dist/vendor/skills/src/git-tree.js +4 -4
- package/dist/vendor/skills/src/skill-lock.js +4 -3
- package/dist/vendor/skills/src/update.js +38 -77
- package/dist/vendor/skills/src/use.js +28 -4
- package/docs/agents-spec.md +27 -4
- package/docs/authoring.md +19 -2
- package/docs/branching-and-release.md +52 -0
- package/package.json +14 -3
- package/schemas/adg-plugin.schema.json +2 -0
- package/schemas/plugin-lock.schema.json +23 -1
- package/vendor/skills/PROVENANCE.md +2 -0
- package/vendor/skills/package.json +0 -144
- package/vendor/skills/src/add.ts +0 -2213
- package/vendor/skills/src/agents.ts +0 -811
- package/vendor/skills/src/blob.ts +0 -588
- package/vendor/skills/src/cli.ts +0 -391
- package/vendor/skills/src/constants.ts +0 -3
- package/vendor/skills/src/detect-agent.ts +0 -62
- package/vendor/skills/src/find.ts +0 -419
- package/vendor/skills/src/frontmatter.ts +0 -16
- package/vendor/skills/src/git-tree.ts +0 -36
- package/vendor/skills/src/git.ts +0 -277
- package/vendor/skills/src/install.ts +0 -91
- package/vendor/skills/src/installer.ts +0 -1307
- package/vendor/skills/src/list.ts +0 -231
- package/vendor/skills/src/local-lock.ts +0 -189
- package/vendor/skills/src/plugin-manifest.ts +0 -183
- package/vendor/skills/src/prompts/search-multiselect.ts +0 -387
- package/vendor/skills/src/providers/index.ts +0 -14
- package/vendor/skills/src/providers/registry.ts +0 -51
- package/vendor/skills/src/providers/types.ts +0 -97
- package/vendor/skills/src/providers/wellknown.ts +0 -812
- package/vendor/skills/src/remove.ts +0 -335
- package/vendor/skills/src/sanitize.ts +0 -65
- package/vendor/skills/src/self-cli.ts +0 -20
- package/vendor/skills/src/skill-lock.ts +0 -329
- package/vendor/skills/src/skills.ts +0 -316
- package/vendor/skills/src/source-parser.ts +0 -449
- package/vendor/skills/src/sync.ts +0 -478
- package/vendor/skills/src/telemetry.ts +0 -226
- package/vendor/skills/src/test-utils.ts +0 -73
- package/vendor/skills/src/types.ts +0 -129
- package/vendor/skills/src/update-source.ts +0 -90
- package/vendor/skills/src/update.ts +0 -821
- package/vendor/skills/src/use.ts +0 -682
|
@@ -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
|
+
}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { existsSync, readdirSync, rmSync, statSync } from "node:fs";
|
|
2
|
-
import { join } from "node:path";
|
|
2
|
+
import { join, resolve } from "node:path";
|
|
3
3
|
import { readLock } from "../lock.js";
|
|
4
|
-
import { lockPath, pluginCacheRoot } from "../paths.js";
|
|
4
|
+
import { legacyPluginCacheRoot, legacyPluginSourceCacheDir, lockPath, pluginCacheRoot, pluginSourceCacheDir } from "../paths.js";
|
|
5
|
+
import { resolvePluginSourceSnapshot } from "../source-cache.js";
|
|
5
6
|
export function directoryBytes(dir) {
|
|
6
7
|
let total = 0;
|
|
7
8
|
try {
|
|
@@ -24,31 +25,107 @@ export function directoryBytes(dir) {
|
|
|
24
25
|
}
|
|
25
26
|
return total;
|
|
26
27
|
}
|
|
28
|
+
function cacheDirectories(root) {
|
|
29
|
+
try {
|
|
30
|
+
if (!existsSync(root))
|
|
31
|
+
return [];
|
|
32
|
+
return readdirSync(root, { withFileTypes: true })
|
|
33
|
+
.filter((entry) => entry.isDirectory() && !entry.name.startsWith("."))
|
|
34
|
+
.map((entry) => entry.name);
|
|
35
|
+
}
|
|
36
|
+
catch {
|
|
37
|
+
return [];
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
function removeRootIfEmpty(root) {
|
|
41
|
+
try {
|
|
42
|
+
if (existsSync(root) && readdirSync(root).length === 0)
|
|
43
|
+
rmSync(root, { recursive: true, force: true });
|
|
44
|
+
}
|
|
45
|
+
catch {
|
|
46
|
+
// A concurrent cache mutation or unreadable directory must not make prune fail.
|
|
47
|
+
}
|
|
48
|
+
}
|
|
27
49
|
export function pluginCacheStatus(pluginsDir) {
|
|
28
50
|
const root = pluginCacheRoot(pluginsDir);
|
|
29
|
-
const
|
|
30
|
-
const
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
51
|
+
const lock = readLock(lockPath(pluginsDir));
|
|
52
|
+
const installed = new Set(Object.keys(lock.plugins));
|
|
53
|
+
let entries = [];
|
|
54
|
+
try {
|
|
55
|
+
if (existsSync(root)) {
|
|
56
|
+
entries = cacheDirectories(root)
|
|
57
|
+
.map((name) => {
|
|
58
|
+
const path = join(root, name);
|
|
59
|
+
return { name, path, bytes: directoryBytes(path), orphan: !installed.has(name), recovery: "present" };
|
|
60
|
+
})
|
|
61
|
+
.sort((a, b) => a.name.localeCompare(b.name));
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
catch {
|
|
65
|
+
// Treat an unreadable or concurrently removed directory as empty.
|
|
66
|
+
}
|
|
67
|
+
for (const [name, entry] of Object.entries(lock.plugins)) {
|
|
68
|
+
if (entries.some((item) => item.name === name))
|
|
69
|
+
continue;
|
|
70
|
+
const legacy = legacyPluginSourceCacheDir(pluginsDir, name);
|
|
71
|
+
const localRecoverable = entry.origin.type === "local" && existsSync(resolve(pluginsDir, entry.origin.path));
|
|
72
|
+
const remoteRecoverable = (entry.origin.type === "github" || entry.origin.type === "git") && Boolean(entry.resolvedRevision);
|
|
73
|
+
const hasLegacy = existsSync(legacy);
|
|
74
|
+
entries.push({
|
|
75
|
+
name,
|
|
76
|
+
path: hasLegacy ? legacy : pluginSourceCacheDir(pluginsDir, name),
|
|
77
|
+
bytes: hasLegacy ? directoryBytes(legacy) : 0,
|
|
78
|
+
orphan: false,
|
|
79
|
+
recovery: hasLegacy ? "legacy" : (localRecoverable || remoteRecoverable ? "missing-recoverable" : "missing-unrecoverable"),
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
const seen = new Set(entries.map((entry) => entry.name));
|
|
83
|
+
for (const name of cacheDirectories(legacyPluginCacheRoot(pluginsDir))) {
|
|
84
|
+
if (seen.has(name))
|
|
85
|
+
continue;
|
|
86
|
+
if (installed.has(name))
|
|
87
|
+
continue;
|
|
88
|
+
const path = legacyPluginSourceCacheDir(pluginsDir, name);
|
|
89
|
+
entries.push({ name, path, bytes: directoryBytes(path), orphan: true, recovery: "legacy" });
|
|
90
|
+
}
|
|
91
|
+
entries.sort((a, b) => a.name.localeCompare(b.name));
|
|
39
92
|
return { root, entries, totalBytes: entries.reduce((sum, entry) => sum + entry.bytes, 0) };
|
|
40
93
|
}
|
|
94
|
+
/** Restore the selected snapshots with lock-hash verification. */
|
|
95
|
+
export function restorePluginCache(pluginsDir, names) {
|
|
96
|
+
const lock = readLock(lockPath(pluginsDir));
|
|
97
|
+
const selected = names?.length ? [...new Set(names)] : Object.keys(lock.plugins);
|
|
98
|
+
const missing = selected.filter((name) => !lock.plugins[name]);
|
|
99
|
+
if (missing.length > 0)
|
|
100
|
+
throw new Error(`not installed: ${missing.join(", ")}. See \`adg plugins list\`.`);
|
|
101
|
+
const restored = [];
|
|
102
|
+
for (const name of selected) {
|
|
103
|
+
const cache = pluginSourceCacheDir(pluginsDir, name);
|
|
104
|
+
const wasPresent = existsSync(cache);
|
|
105
|
+
resolvePluginSourceSnapshot(pluginsDir, name, lock.plugins[name]);
|
|
106
|
+
if (!wasPresent)
|
|
107
|
+
restored.push(name);
|
|
108
|
+
}
|
|
109
|
+
return restored;
|
|
110
|
+
}
|
|
41
111
|
/** Delete cache snapshots that have no corresponding lock entry. */
|
|
42
112
|
export function prunePluginCache(pluginsDir) {
|
|
43
113
|
const status = pluginCacheStatus(pluginsDir);
|
|
44
114
|
const removed = status.entries.filter((entry) => entry.orphan);
|
|
45
115
|
for (const entry of removed)
|
|
46
116
|
rmSync(entry.path, { recursive: true, force: true });
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
117
|
+
const installed = new Set(Object.keys(readLock(lockPath(pluginsDir)).plugins));
|
|
118
|
+
const legacyRoot = legacyPluginCacheRoot(pluginsDir);
|
|
119
|
+
for (const name of cacheDirectories(legacyRoot)) {
|
|
120
|
+
if (!installed.has(name))
|
|
121
|
+
rmSync(legacyPluginSourceCacheDir(pluginsDir, name), { recursive: true, force: true });
|
|
122
|
+
}
|
|
123
|
+
removeRootIfEmpty(status.root);
|
|
124
|
+
removeRootIfEmpty(legacyRoot);
|
|
125
|
+
return [...new Set(removed.map((entry) => entry.name))];
|
|
50
126
|
}
|
|
51
127
|
/** Delete every rebuildable source snapshot for this store. */
|
|
52
128
|
export function cleanPluginCache(pluginsDir) {
|
|
53
129
|
rmSync(pluginCacheRoot(pluginsDir), { recursive: true, force: true });
|
|
130
|
+
rmSync(legacyPluginCacheRoot(pluginsDir), { recursive: true, force: true });
|
|
54
131
|
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { mkdtempSync, rmSync } from "node:fs";
|
|
2
|
+
import { tmpdir } from "node:os";
|
|
3
|
+
import { basename, join, resolve } from "node:path";
|
|
4
|
+
import { findManifestFile, readManifest } from "../manifest.js";
|
|
5
|
+
import { resolveDefaultDsl } from "../default-dsl.js";
|
|
6
|
+
import { pluginContents } from "../components.js";
|
|
7
|
+
import { cloneGitHub, githubRepositoryDescription, parseSource } from "../sources.js";
|
|
8
|
+
/** Read-only definition resolution for a local plugin root. */
|
|
9
|
+
export function inspectPlugin(root, metadata) {
|
|
10
|
+
const dir = resolve(root);
|
|
11
|
+
const file = findManifestFile(dir);
|
|
12
|
+
const manifest = file
|
|
13
|
+
? readManifest(dir)
|
|
14
|
+
: resolveDefaultDsl(dir, metadata ?? { name: basename(dir), description: basename(dir) }).manifest;
|
|
15
|
+
const contents = pluginContents(dir, manifest);
|
|
16
|
+
return { kind: file ? "manifest" : "default-dsl", root: dir, manifest, components: Object.entries(contents).filter(([, v]) => v.length > 0).map(([k]) => k) };
|
|
17
|
+
}
|
|
18
|
+
/** Resolve a local or GitHub source without creating a store, lock, or projection. */
|
|
19
|
+
export async function inspectSource(opts) {
|
|
20
|
+
const parsed = parseSource(opts.spec);
|
|
21
|
+
if (parsed.kind === "local") {
|
|
22
|
+
return inspectPlugin(parsed.dir);
|
|
23
|
+
}
|
|
24
|
+
if (parsed.path)
|
|
25
|
+
throw new Error("GitHub subdirectory sources are not supported; define a marketplace and select with --plugin or --all");
|
|
26
|
+
const staging = mkdtempSync(join(tmpdir(), "adg-inspect-"));
|
|
27
|
+
try {
|
|
28
|
+
cloneGitHub({ ...parsed, ref: opts.ref ?? parsed.ref }, staging, { runner: opts.gitRunner });
|
|
29
|
+
const manifestFile = findManifestFile(staging);
|
|
30
|
+
const description = manifestFile
|
|
31
|
+
? undefined
|
|
32
|
+
: await (opts.descriptionResolver ?? githubRepositoryDescription)(parsed.source);
|
|
33
|
+
const result = inspectPlugin(staging, manifestFile
|
|
34
|
+
? undefined
|
|
35
|
+
: { name: parsed.source, description: description ?? parsed.source });
|
|
36
|
+
return { ...result, root: "." };
|
|
37
|
+
}
|
|
38
|
+
finally {
|
|
39
|
+
rmSync(staging, { recursive: true, force: true });
|
|
40
|
+
}
|
|
41
|
+
}
|