@rbbtsn0w/adg 0.6.0-beta.1 → 0.6.0-beta.11
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
|
@@ -1,9 +1,6 @@
|
|
|
1
|
-
import { adaptedFilesForTarget, selectInstalled } from "./projection.js";
|
|
2
|
-
import { pluginRematerializationSource } from "../paths.js";
|
|
1
|
+
import { adaptedFilesForTarget, rematerializeInstalled, selectInstalled } from "./projection.js";
|
|
3
2
|
import { getAgent } from "../agents/index.js";
|
|
4
|
-
import { ADAPTER_TARGETS } from "../adapters/index.js";
|
|
5
3
|
import { pluginState } from "../types.js";
|
|
6
|
-
import { installPlugin } from "./install.js";
|
|
7
4
|
/** Regenerate manifests for the selected plugins, then refresh them in the agent. */
|
|
8
5
|
export function syncPlugins(opts) {
|
|
9
6
|
const agent = opts.agent ?? getAgent(opts.target);
|
|
@@ -12,23 +9,20 @@ export function syncPlugins(opts) {
|
|
|
12
9
|
const enabled = selected.filter((p) => pluginState(p) === "enabled");
|
|
13
10
|
const disabled = selected.filter((p) => pluginState(p) === "disabled");
|
|
14
11
|
const actions = disabled.map((p) => ({ name: p.name, adapted: [], synced: false }));
|
|
15
|
-
for (const
|
|
16
|
-
|
|
17
|
-
source: pluginRematerializationSource(opts.pluginsDir, p.name, p.origin),
|
|
18
|
-
pluginsDir: opts.pluginsDir,
|
|
19
|
-
origin: p.origin,
|
|
20
|
-
selection: p.selection,
|
|
21
|
-
targets: [...ADAPTER_TARGETS],
|
|
22
|
-
forceMaterialize: true,
|
|
23
|
-
});
|
|
24
|
-
actions.push({ name: p.name, adapted: adaptedFilesForTarget(result.installedTo, result.adapted, adaptTarget), synced: false });
|
|
12
|
+
for (const result of rematerializeInstalled(opts.pluginsDir, enabled)) {
|
|
13
|
+
actions.push({ name: result.name, adapted: adaptedFilesForTarget(result.installedTo, result.adapted, adaptTarget), synced: false });
|
|
25
14
|
}
|
|
26
15
|
if (!agent)
|
|
27
16
|
return { target: opts.target, actions };
|
|
28
17
|
const scope = opts.global ? "user" : "project";
|
|
29
18
|
const parts = [
|
|
30
19
|
...(disabled.length > 0 ? [agent.deactivate({ pluginsDir: opts.pluginsDir, plugins: disabled.map((p) => p.name), scope })] : []),
|
|
31
|
-
...(enabled.length > 0 ? [agent.refresh({
|
|
20
|
+
...(enabled.length > 0 ? [agent.refresh({
|
|
21
|
+
pluginsDir: opts.pluginsDir,
|
|
22
|
+
plugins: enabled.map((p) => p.name),
|
|
23
|
+
scope,
|
|
24
|
+
...(opts.target === "codex" ? { reconcileLegacyAliases: true } : {}),
|
|
25
|
+
})] : []),
|
|
32
26
|
];
|
|
33
27
|
for (const action of actions)
|
|
34
28
|
if (parts.some((part) => part.affected.includes(action.name)))
|
|
@@ -1,9 +1,13 @@
|
|
|
1
|
-
import { existsSync } from "node:fs";
|
|
2
|
-
import {
|
|
1
|
+
import { existsSync, mkdtempSync, rmSync } from "node:fs";
|
|
2
|
+
import { tmpdir } from "node:os";
|
|
3
|
+
import { join, resolve } from "node:path";
|
|
3
4
|
import { resolveAgents } from "../agents/index.js";
|
|
4
5
|
import { installedPluginDir, lockPath, pluginSourceCacheDir } from "../paths.js";
|
|
5
6
|
import { readLock } from "../lock.js";
|
|
6
7
|
import { installPlugin } from "./install.js";
|
|
8
|
+
import { resolveDefaultDsl } from "../default-dsl.js";
|
|
9
|
+
import { ADG_MANIFEST_PATH } from "../manifest.js";
|
|
10
|
+
import { copyPluginDir, writeJson } from "../fsutil.js";
|
|
7
11
|
/**
|
|
8
12
|
* Refresh local sources and repair effective installations from their complete
|
|
9
13
|
* source snapshots. Runtime installations are never treated as upstream input.
|
|
@@ -28,14 +32,51 @@ export function updateLock(pluginsDir, now = new Date().toISOString(), opts = {}
|
|
|
28
32
|
missing.push(name);
|
|
29
33
|
continue;
|
|
30
34
|
}
|
|
31
|
-
|
|
32
|
-
source
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
35
|
+
if (entry.definition && localSource && existsSync(join(localSource, ADG_MANIFEST_PATH))) {
|
|
36
|
+
throw new Error(`source definition changed from default DSL to a manifest for "${name}"; re-add or migrate the plugin explicitly`);
|
|
37
|
+
}
|
|
38
|
+
let installSource = source;
|
|
39
|
+
let staging;
|
|
40
|
+
let definition = entry.definition;
|
|
41
|
+
if (!existsSync(join(source, ADG_MANIFEST_PATH))) {
|
|
42
|
+
try {
|
|
43
|
+
const generated = resolveDefaultDsl(source, { name, description: entry.definition?.description ?? name }, {
|
|
44
|
+
...(entry.origin.type === "github" && entry.resolvedRevision ? { resolvedRevision: entry.resolvedRevision } : {}),
|
|
45
|
+
});
|
|
46
|
+
const authorized = entry.definition?.authorizedComponents;
|
|
47
|
+
const unauthorizedRisk = generated.components.some((component) => (component === "hooks" || component === "mcp") && !authorized?.includes(component));
|
|
48
|
+
if (entry.definition && unauthorizedRisk) {
|
|
49
|
+
throw new Error(`default source exposes an unauthorized hook or MCP component for "${name}"; re-add the plugin with an explicit component selection`);
|
|
50
|
+
}
|
|
51
|
+
if (entry.definition)
|
|
52
|
+
definition = { ...entry.definition, description: generated.manifest.description, fingerprint: generated.fingerprint };
|
|
53
|
+
staging = mkdtempSync(join(tmpdir(), "adg-default-update-"));
|
|
54
|
+
copyPluginDir(source, staging);
|
|
55
|
+
writeJson(join(staging, ADG_MANIFEST_PATH), generated.manifest);
|
|
56
|
+
installSource = staging;
|
|
57
|
+
}
|
|
58
|
+
catch (error) {
|
|
59
|
+
if (!(error instanceof Error) || !error.message.includes("no default plugin component"))
|
|
60
|
+
throw error;
|
|
61
|
+
// Non-plugin local directories continue through the normal manifest path.
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
let result;
|
|
65
|
+
try {
|
|
66
|
+
result = installPlugin({
|
|
67
|
+
source: installSource,
|
|
68
|
+
pluginsDir,
|
|
69
|
+
origin: entry.origin,
|
|
70
|
+
selection: entry.selection ?? (entry.definition?.authorizedComponents ? { components: entry.definition.authorizedComponents } : undefined),
|
|
71
|
+
skipUnchanged: true,
|
|
72
|
+
now,
|
|
73
|
+
definition,
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
finally {
|
|
77
|
+
if (staging)
|
|
78
|
+
rmSync(staging, { recursive: true, force: true });
|
|
79
|
+
}
|
|
39
80
|
if (result.changed)
|
|
40
81
|
changedNames.push(name);
|
|
41
82
|
results.push({
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { existsSync, readFileSync } from "node:fs";
|
|
2
|
-
import { join } from "node:path";
|
|
2
|
+
import { basename, join } from "node:path";
|
|
3
3
|
import { ADG_MANIFEST_PATH, collectIssues } from "../manifest.js";
|
|
4
|
+
import { resolveDefaultDsl } from "../default-dsl.js";
|
|
4
5
|
/**
|
|
5
6
|
* Validate a plugin's manifest against the ADG schema and check that the
|
|
6
7
|
* directories/files it references actually exist.
|
|
@@ -8,7 +9,13 @@ import { ADG_MANIFEST_PATH, collectIssues } from "../manifest.js";
|
|
|
8
9
|
export function validatePlugin(pluginDir) {
|
|
9
10
|
const manifestFile = join(pluginDir, ADG_MANIFEST_PATH);
|
|
10
11
|
if (!existsSync(manifestFile)) {
|
|
11
|
-
|
|
12
|
+
try {
|
|
13
|
+
resolveDefaultDsl(pluginDir, { name: basename(pluginDir), description: basename(pluginDir) });
|
|
14
|
+
return { ok: true, issues: [] };
|
|
15
|
+
}
|
|
16
|
+
catch (error) {
|
|
17
|
+
return { ok: false, issues: [error instanceof Error ? error.message : String(error)] };
|
|
18
|
+
}
|
|
12
19
|
}
|
|
13
20
|
let raw;
|
|
14
21
|
try {
|
package/dist/src/components.js
CHANGED
|
@@ -84,6 +84,9 @@ export function exposedContents(contents, selection) {
|
|
|
84
84
|
else if (c === "skills" && selection.skills) {
|
|
85
85
|
out[c] = contents.skills.filter((s) => selection.skills.includes(s));
|
|
86
86
|
}
|
|
87
|
+
else if (c === "mcp" && selection.mcp) {
|
|
88
|
+
out[c] = contents.mcp.filter((s) => selection.mcp.includes(s));
|
|
89
|
+
}
|
|
87
90
|
else {
|
|
88
91
|
out[c] = contents[c];
|
|
89
92
|
}
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
import { createHash } from "node:crypto";
|
|
2
|
+
import { existsSync, lstatSync, readFileSync, readdirSync } from "node:fs";
|
|
3
|
+
import { join } from "node:path";
|
|
4
|
+
import { ADG_SCHEMA_VERSION } from "./types.js";
|
|
5
|
+
import { readSkillDescription } from "./skills.js";
|
|
6
|
+
import { recordTelemetryEvent } from "./telemetry.js";
|
|
7
|
+
/** Convert a repository directory name into the manifest's stable kebab-case identity. */
|
|
8
|
+
export function defaultPluginName(value) {
|
|
9
|
+
const normalized = value.trim().replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase()
|
|
10
|
+
.replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "");
|
|
11
|
+
if (!normalized)
|
|
12
|
+
throw new Error("default plugin name is empty");
|
|
13
|
+
return normalized;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Resolve the intentionally small structural DSL. It only recognizes the three
|
|
17
|
+
* documented default locations; other directories are never guessed as runtime
|
|
18
|
+
* components.
|
|
19
|
+
*/
|
|
20
|
+
export function resolveDefaultDsl(root, metadata, options = {}) {
|
|
21
|
+
const { components, manifest: componentManifest } = probeDefaultDsl(root, options);
|
|
22
|
+
const hasSkills = components.includes("skills");
|
|
23
|
+
const hasHooks = components.includes("hooks");
|
|
24
|
+
const hasMcp = components.includes("mcp");
|
|
25
|
+
const skillsRoot = join(root, "skills");
|
|
26
|
+
const mcpFile = join(root, ".mcp.json");
|
|
27
|
+
const hasher = createHash("sha256").update(JSON.stringify({ name: defaultPluginName(metadata.name), components }));
|
|
28
|
+
if (hasSkills)
|
|
29
|
+
hashTree(hasher, skillsRoot, "skills");
|
|
30
|
+
if (hasHooks)
|
|
31
|
+
hashTree(hasher, join(root, "hooks"), "hooks");
|
|
32
|
+
if (hasMcp)
|
|
33
|
+
hasher.update(".mcp.json\0").update(readFileSync(mcpFile)).update("\0");
|
|
34
|
+
const fingerprint = hasher.digest("hex");
|
|
35
|
+
if (options.recordTelemetry !== false) {
|
|
36
|
+
recordTelemetryEvent("adg.default_dsl.resolve", {
|
|
37
|
+
"definition.kind": "default-dsl/v1",
|
|
38
|
+
"components.count": components.length,
|
|
39
|
+
outcome: "success",
|
|
40
|
+
}, options.telemetrySpan);
|
|
41
|
+
}
|
|
42
|
+
return {
|
|
43
|
+
components,
|
|
44
|
+
fingerprint,
|
|
45
|
+
manifest: {
|
|
46
|
+
schemaVersion: ADG_SCHEMA_VERSION,
|
|
47
|
+
name: defaultPluginName(metadata.name),
|
|
48
|
+
version: options.resolvedRevision
|
|
49
|
+
? `0.0.0-git.${options.resolvedRevision}`
|
|
50
|
+
: `0.0.0-adg.${fingerprint}`,
|
|
51
|
+
description: metadata.description,
|
|
52
|
+
...componentManifest,
|
|
53
|
+
},
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
/** Discover and validate conventional component locations without hashing payload contents. */
|
|
57
|
+
export function probeDefaultDsl(root, options = {}) {
|
|
58
|
+
const ignore = options.ignore ?? new Set();
|
|
59
|
+
const skillsRoot = join(root, "skills");
|
|
60
|
+
const skillFiles = !ignore.has("skills") && isDirectory(skillsRoot)
|
|
61
|
+
? readdirSync(skillsRoot, { withFileTypes: true }).filter((entry) => entry.isDirectory() && existsSync(join(skillsRoot, entry.name, "SKILL.md"))).map((entry) => join(skillsRoot, entry.name, "SKILL.md"))
|
|
62
|
+
: [];
|
|
63
|
+
const invalidSkillFile = skillFiles.find((file) => !isRegularFile(file));
|
|
64
|
+
if (invalidSkillFile)
|
|
65
|
+
throw new Error(`invalid default skill file (must be a regular file): ${invalidSkillFile}`);
|
|
66
|
+
const invalidSkill = skillFiles.find((file) => !readSkillDescription(file));
|
|
67
|
+
if (invalidSkill)
|
|
68
|
+
throw new Error(`default skill requires SKILL.md frontmatter with a description: ${invalidSkill}`);
|
|
69
|
+
const hasSkills = skillFiles.length > 0;
|
|
70
|
+
const hooksFile = join(root, "hooks", "hooks.json");
|
|
71
|
+
const hasHooks = !ignore.has("hooks") && existsSync(hooksFile) && validJson(hooksFile);
|
|
72
|
+
if (!ignore.has("hooks") && existsSync(hooksFile) && !hasHooks)
|
|
73
|
+
throw new Error(`invalid default hooks configuration: ${hooksFile}`);
|
|
74
|
+
const mcpFile = join(root, ".mcp.json");
|
|
75
|
+
const hasMcp = !ignore.has("mcp") && existsSync(mcpFile) && validMcp(mcpFile);
|
|
76
|
+
if (!ignore.has("mcp") && existsSync(mcpFile) && !hasMcp)
|
|
77
|
+
throw new Error(`invalid default MCP configuration: ${mcpFile}`);
|
|
78
|
+
const components = [
|
|
79
|
+
...(hasSkills ? ["skills"] : []),
|
|
80
|
+
...(hasHooks ? ["hooks"] : []),
|
|
81
|
+
...(hasMcp ? ["mcp"] : []),
|
|
82
|
+
];
|
|
83
|
+
if (components.length === 0)
|
|
84
|
+
throw new Error(`no default plugin component found in ${root}`);
|
|
85
|
+
return {
|
|
86
|
+
components,
|
|
87
|
+
manifest: {
|
|
88
|
+
...(hasSkills ? { skills: "./skills/" } : { skills: [] }),
|
|
89
|
+
...(hasHooks ? { hooks: "./hooks/" } : {}),
|
|
90
|
+
...(hasMcp ? { mcpServers: "./.mcp.json" } : {}),
|
|
91
|
+
},
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
function validJson(file) {
|
|
95
|
+
if (!isRegularFile(file))
|
|
96
|
+
return false;
|
|
97
|
+
try {
|
|
98
|
+
JSON.parse(readFileSync(file, "utf8"));
|
|
99
|
+
return true;
|
|
100
|
+
}
|
|
101
|
+
catch {
|
|
102
|
+
return false;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
function isDirectory(path) {
|
|
106
|
+
try {
|
|
107
|
+
return lstatSync(path).isDirectory();
|
|
108
|
+
}
|
|
109
|
+
catch {
|
|
110
|
+
return false;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
function isRegularFile(path) {
|
|
114
|
+
try {
|
|
115
|
+
return lstatSync(path).isFile();
|
|
116
|
+
}
|
|
117
|
+
catch {
|
|
118
|
+
return false;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
function validMcp(file) {
|
|
122
|
+
if (!validJson(file))
|
|
123
|
+
return false;
|
|
124
|
+
const json = JSON.parse(readFileSync(file, "utf8"));
|
|
125
|
+
if (json === null || typeof json !== "object" || Array.isArray(json))
|
|
126
|
+
return false;
|
|
127
|
+
const servers = json.mcpServers ?? json.servers;
|
|
128
|
+
return typeof servers === "object" && servers !== null && !Array.isArray(servers);
|
|
129
|
+
}
|
|
130
|
+
function hashTree(hasher, dir, rel) {
|
|
131
|
+
for (const entry of readdirSync(dir, { withFileTypes: true }).sort((a, b) => a.name < b.name ? -1 : a.name > b.name ? 1 : 0)) {
|
|
132
|
+
const child = join(dir, entry.name);
|
|
133
|
+
const childRel = `${rel}/${entry.name}`;
|
|
134
|
+
const stat = lstatSync(child);
|
|
135
|
+
if (stat.isSymbolicLink())
|
|
136
|
+
throw new Error(`default plugin component must not contain symlinks: ${child}`);
|
|
137
|
+
if (stat.isDirectory())
|
|
138
|
+
hashTree(hasher, child, childRel);
|
|
139
|
+
else if (stat.isFile())
|
|
140
|
+
hasher.update(childRel).update("\0").update(readFileSync(child)).update("\0");
|
|
141
|
+
}
|
|
142
|
+
}
|
package/dist/src/lock.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { existsSync, readFileSync, writeFileSync } from "node:fs";
|
|
2
2
|
import { recordTelemetryEvent } from "./telemetry.js";
|
|
3
3
|
import { LOCK_VERSION } from "./types.js";
|
|
4
|
+
/** Compatibility reads are upgraded in memory; record the transition on first successful persistence. */
|
|
5
|
+
const pendingLockMigrations = new WeakMap();
|
|
4
6
|
export function emptyLock() {
|
|
5
7
|
return { version: LOCK_VERSION, plugins: {} };
|
|
6
8
|
}
|
|
@@ -8,21 +10,37 @@ export function readLock(file, telemetrySpan) {
|
|
|
8
10
|
if (!existsSync(file))
|
|
9
11
|
return emptyLock();
|
|
10
12
|
const raw = JSON.parse(readFileSync(file, "utf8"));
|
|
11
|
-
if (typeof raw
|
|
12
|
-
|
|
13
|
+
if (raw === null || typeof raw !== "object" || Array.isArray(raw)) {
|
|
14
|
+
throw new Error(`${file} is not a valid .plugin-lock.json`);
|
|
15
|
+
}
|
|
16
|
+
const parsed = raw;
|
|
17
|
+
if (typeof parsed.version === "number") {
|
|
18
|
+
const observed = parsed.version === 2 || parsed.version === 3 || parsed.version === 4 || parsed.version === LOCK_VERSION ? parsed.version : -1;
|
|
13
19
|
recordTelemetryEvent("adg.lock.read", { "format.version": observed }, telemetrySpan);
|
|
14
20
|
}
|
|
15
|
-
if (typeof
|
|
21
|
+
if (typeof parsed.version !== "number" || typeof parsed.plugins !== "object" || parsed.plugins === null || Array.isArray(parsed.plugins)) {
|
|
16
22
|
throw new Error(`${file} is not a valid .plugin-lock.json`);
|
|
17
23
|
}
|
|
18
|
-
if (
|
|
19
|
-
|
|
24
|
+
if (parsed.version === 3 || parsed.version === 4) {
|
|
25
|
+
// Read compatibility for the retained v3 and v4 formats keeps runtime
|
|
26
|
+
// adapters working before the user runs the explicit migration command.
|
|
27
|
+
const upgraded = { ...parsed, version: LOCK_VERSION };
|
|
28
|
+
pendingLockMigrations.set(upgraded, parsed.version);
|
|
29
|
+
return upgraded;
|
|
30
|
+
}
|
|
31
|
+
if (parsed.version !== LOCK_VERSION) {
|
|
32
|
+
throw new Error(`${file} uses unsupported lock version ${parsed.version}; expected ${LOCK_VERSION}. ` +
|
|
20
33
|
"Run `adg plugins migrate` with the same scope flag to upgrade it.");
|
|
21
34
|
}
|
|
22
|
-
return
|
|
35
|
+
return parsed;
|
|
23
36
|
}
|
|
24
|
-
export function writeLock(file, lock) {
|
|
37
|
+
export function writeLock(file, lock, telemetrySpan) {
|
|
25
38
|
writeFileSync(file, JSON.stringify(lock, null, 2) + "\n");
|
|
39
|
+
const fromVersion = pendingLockMigrations.get(lock);
|
|
40
|
+
if (fromVersion !== undefined) {
|
|
41
|
+
pendingLockMigrations.delete(lock);
|
|
42
|
+
recordTelemetryEvent("adg.lock.migrate", { "from.version": fromVersion, "to.version": LOCK_VERSION }, telemetrySpan);
|
|
43
|
+
}
|
|
26
44
|
}
|
|
27
45
|
/**
|
|
28
46
|
* Remove a plugin entry from the lock. Drops it from `lastSelected` too.
|
package/dist/src/manifest.js
CHANGED
|
@@ -2,6 +2,7 @@ import { existsSync, readFileSync } from "node:fs";
|
|
|
2
2
|
import { isAbsolute, join } from "node:path";
|
|
3
3
|
import { ADG_SCHEMA_VERSION, COMPONENT_TYPES } from "./types.js";
|
|
4
4
|
import { recordTelemetryEvent } from "./telemetry.js";
|
|
5
|
+
import { probeDefaultDsl } from "./default-dsl.js";
|
|
5
6
|
/** Canonical, vendor-neutral source manifest location (a plugin). */
|
|
6
7
|
export const ADG_MANIFEST_PATH = join(".agents", ".plugin.json");
|
|
7
8
|
/** Canonical, vendor-neutral source catalog location (a marketplace). */
|
|
@@ -24,6 +25,11 @@ export function findManifestFile(pluginDir) {
|
|
|
24
25
|
}
|
|
25
26
|
const NAME_RE = /^[a-z0-9]+(-[a-z0-9]+)*$/;
|
|
26
27
|
const SEMVER_RE = /^\d+\.\d+\.\d+(?:-[0-9A-Za-z-.]+)?(?:\+[0-9A-Za-z-.]+)?$/;
|
|
28
|
+
const MANIFEST_FIELDS = new Set([
|
|
29
|
+
"schemaVersion", "name", "version", "description", "author", "license", "category",
|
|
30
|
+
"interface", "skills", "agents", "commands", "apps", "hooks", "mcpServers",
|
|
31
|
+
"dependencies", "selectionDependencies", "strict", "homepage", "changelog",
|
|
32
|
+
]);
|
|
27
33
|
export class ManifestError extends Error {
|
|
28
34
|
issues;
|
|
29
35
|
constructor(issues) {
|
|
@@ -46,7 +52,34 @@ export function readManifest(pluginDir, telemetrySpan) {
|
|
|
46
52
|
throw new ManifestError([`${file} is not valid JSON: ${err.message}`]);
|
|
47
53
|
}
|
|
48
54
|
if (typeof raw === "object" && raw !== null && !Array.isArray(raw)) {
|
|
49
|
-
const
|
|
55
|
+
const m = raw;
|
|
56
|
+
// A repository manifest is an explicit mapping only for fields it names.
|
|
57
|
+
// Standard skills/hooks/MCP locations remain the default DSL for omitted
|
|
58
|
+
// component fields, keeping source authors from repeating boilerplate.
|
|
59
|
+
if (typeof m.name === "string" && typeof m.description === "string") {
|
|
60
|
+
try {
|
|
61
|
+
const ignored = new Set();
|
|
62
|
+
if (m.skills !== undefined)
|
|
63
|
+
ignored.add("skills");
|
|
64
|
+
if (m.hooks !== undefined)
|
|
65
|
+
ignored.add("hooks");
|
|
66
|
+
if (m.mcpServers !== undefined)
|
|
67
|
+
ignored.add("mcp");
|
|
68
|
+
const defaults = probeDefaultDsl(pluginDir, { ignore: ignored }).manifest;
|
|
69
|
+
for (const key of ["skills", "hooks", "mcpServers"]) {
|
|
70
|
+
if (m[key] === undefined && defaults[key] !== undefined)
|
|
71
|
+
m[key] = defaults[key];
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
catch (error) {
|
|
75
|
+
// A manifest may use entirely custom locations and therefore have no
|
|
76
|
+
// conventional component. Any malformed conventional component that it
|
|
77
|
+
// *inherits*, however, is a source error and must never be hidden.
|
|
78
|
+
if (!(error instanceof Error) || !error.message.includes("no default plugin component"))
|
|
79
|
+
throw error;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
const schemaVersion = m.schemaVersion;
|
|
50
83
|
if (typeof schemaVersion === "string") {
|
|
51
84
|
recordTelemetryEvent("adg.manifest.read", {
|
|
52
85
|
"schema.version": schemaVersion === ADG_SCHEMA_VERSION ? schemaVersion : "other",
|
|
@@ -70,6 +103,10 @@ export function collectIssues(raw) {
|
|
|
70
103
|
return ["manifest must be a JSON object"];
|
|
71
104
|
}
|
|
72
105
|
const m = raw;
|
|
106
|
+
for (const key of Object.keys(m)) {
|
|
107
|
+
if (!MANIFEST_FIELDS.has(key))
|
|
108
|
+
issues.push(`unsupported manifest field: ${key}`);
|
|
109
|
+
}
|
|
73
110
|
if (m.schemaVersion !== ADG_SCHEMA_VERSION) {
|
|
74
111
|
issues.push(`schemaVersion must be "${ADG_SCHEMA_VERSION}"`);
|
|
75
112
|
}
|
|
@@ -82,6 +119,34 @@ export function collectIssues(raw) {
|
|
|
82
119
|
if (typeof m.description !== "string" || m.description.length === 0) {
|
|
83
120
|
issues.push("description is required and must be a non-empty string");
|
|
84
121
|
}
|
|
122
|
+
if (m.author !== undefined) {
|
|
123
|
+
if (!isRecord(m.author)) {
|
|
124
|
+
issues.push("author must be an object");
|
|
125
|
+
}
|
|
126
|
+
else {
|
|
127
|
+
for (const key of Object.keys(m.author)) {
|
|
128
|
+
if (!["name", "url", "email"].includes(key))
|
|
129
|
+
issues.push(`author contains unsupported field: ${key}`);
|
|
130
|
+
}
|
|
131
|
+
if (typeof m.author.name !== "string")
|
|
132
|
+
issues.push("author.name must be a string");
|
|
133
|
+
for (const key of ["url", "email"]) {
|
|
134
|
+
if (m.author[key] !== undefined && typeof m.author[key] !== "string")
|
|
135
|
+
issues.push(`author.${key} must be a string`);
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
if (m.interface !== undefined) {
|
|
140
|
+
if (!isRecord(m.interface)) {
|
|
141
|
+
issues.push("interface must be an object");
|
|
142
|
+
}
|
|
143
|
+
else {
|
|
144
|
+
for (const key of ["displayName", "shortDescription", "icon"]) {
|
|
145
|
+
if (m.interface[key] !== undefined && typeof m.interface[key] !== "string")
|
|
146
|
+
issues.push(`interface.${key} must be a string`);
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
}
|
|
85
150
|
if (m.skills !== undefined && typeof m.skills !== "string" && !isStringArray(m.skills)) {
|
|
86
151
|
issues.push("skills must be a string or an array of strings");
|
|
87
152
|
}
|
|
@@ -111,11 +176,15 @@ export function collectIssues(raw) {
|
|
|
111
176
|
}
|
|
112
177
|
else {
|
|
113
178
|
m.dependencies.forEach((dep, i) => {
|
|
114
|
-
if (
|
|
179
|
+
if (!isRecord(dep)) {
|
|
115
180
|
issues.push(`dependencies[${i}] must be an object`);
|
|
116
181
|
return;
|
|
117
182
|
}
|
|
118
183
|
const d = dep;
|
|
184
|
+
for (const key of Object.keys(d)) {
|
|
185
|
+
if (!["name", "version"].includes(key))
|
|
186
|
+
issues.push(`dependencies[${i}] contains unsupported field: ${key}`);
|
|
187
|
+
}
|
|
119
188
|
if (typeof d.name !== "string")
|
|
120
189
|
issues.push(`dependencies[${i}].name must be a string`);
|
|
121
190
|
if (typeof d.version !== "string")
|
|
@@ -138,23 +207,35 @@ export function collectIssues(raw) {
|
|
|
138
207
|
continue;
|
|
139
208
|
}
|
|
140
209
|
const requirement = rawRequirement;
|
|
210
|
+
for (const key of Object.keys(requirement)) {
|
|
211
|
+
if (!["components", "skills"].includes(key)) {
|
|
212
|
+
issues.push(`selectionDependencies.${component} contains unsupported field: ${key}`);
|
|
213
|
+
}
|
|
214
|
+
}
|
|
141
215
|
if (requirement.components !== undefined && (!isStringArray(requirement.components)
|
|
142
216
|
|| requirement.components.some((value) => !COMPONENT_TYPES.includes(value)))) {
|
|
143
217
|
issues.push(`selectionDependencies.${component}.components must contain supported component names`);
|
|
144
218
|
}
|
|
219
|
+
else if (isStringArray(requirement.components) && new Set(requirement.components).size !== requirement.components.length) {
|
|
220
|
+
issues.push(`selectionDependencies.${component}.components must not contain duplicates`);
|
|
221
|
+
}
|
|
145
222
|
if (requirement.skills !== undefined && !isStringArray(requirement.skills)) {
|
|
146
223
|
issues.push(`selectionDependencies.${component}.skills must be an array of strings`);
|
|
147
224
|
}
|
|
225
|
+
else if (isStringArray(requirement.skills) && new Set(requirement.skills).size !== requirement.skills.length) {
|
|
226
|
+
issues.push(`selectionDependencies.${component}.skills must not contain duplicates`);
|
|
227
|
+
}
|
|
148
228
|
}
|
|
149
229
|
}
|
|
150
230
|
}
|
|
151
|
-
// `adapters` is no longer part of the DSL. A stray one from an old manifest is
|
|
152
|
-
// tolerated (ignored) rather than rejected — output paths are ADG-internal.
|
|
153
231
|
return issues;
|
|
154
232
|
}
|
|
155
233
|
function isStringArray(v) {
|
|
156
234
|
return Array.isArray(v) && v.every((x) => typeof x === "string");
|
|
157
235
|
}
|
|
236
|
+
function isRecord(value) {
|
|
237
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
238
|
+
}
|
|
158
239
|
function isSafeRelativePointer(value) {
|
|
159
240
|
if (isAbsolute(value) || /^[A-Za-z]:/.test(value) || /^[/\\]{2}/.test(value))
|
|
160
241
|
return false;
|
package/dist/src/materialize.js
CHANGED
|
@@ -3,7 +3,7 @@ import { existsSync, renameSync, rmSync } from "node:fs";
|
|
|
3
3
|
import { basename, dirname, join, resolve } from "node:path";
|
|
4
4
|
import { copyPluginDir, ensureDir, toPosix, writeJson } from "./fsutil.js";
|
|
5
5
|
import { ADG_MANIFEST_PATH } from "./manifest.js";
|
|
6
|
-
import { mcpConfigPath } from "./mcp.js";
|
|
6
|
+
import { filterMcpConfig, mcpConfigPath } from "./mcp.js";
|
|
7
7
|
import { packageFilter } from "./package.js";
|
|
8
8
|
const META_RE = /^(README|LICEN[CS]E|CHANGELOG|NOTICE)(\..+)?$/i;
|
|
9
9
|
function normalizeRelative(path) {
|
|
@@ -106,6 +106,10 @@ export function materializePlugin(opts) {
|
|
|
106
106
|
}
|
|
107
107
|
try {
|
|
108
108
|
copyPluginDir(opts.source, staging, effectivePackageFilter(opts.manifest, opts.selection));
|
|
109
|
+
const mcp = mcpConfigPath(opts.manifest);
|
|
110
|
+
if (mcp && opts.selection?.components.includes("mcp") && opts.selection.mcp) {
|
|
111
|
+
filterMcpConfig(join(staging, mcp), opts.selection.mcp);
|
|
112
|
+
}
|
|
109
113
|
writeJson(join(staging, ADG_MANIFEST_PATH), effectiveManifest);
|
|
110
114
|
opts.build(staging, effectiveManifest);
|
|
111
115
|
if (existsSync(destination))
|
package/dist/src/mcp.js
CHANGED
|
@@ -1,4 +1,63 @@
|
|
|
1
|
+
import { readFileSync, writeFileSync, existsSync } from "node:fs";
|
|
1
2
|
/** ADG's canonical MCP config pointer. */
|
|
2
3
|
export function mcpConfigPath(manifest) {
|
|
3
4
|
return manifest.mcpServers;
|
|
4
5
|
}
|
|
6
|
+
/** Filter the servers defined in the MCP config file. */
|
|
7
|
+
export function filterMcpConfig(file, allowedNames) {
|
|
8
|
+
if (!existsSync(file))
|
|
9
|
+
return;
|
|
10
|
+
try {
|
|
11
|
+
const json = JSON.parse(readFileSync(file, "utf8"));
|
|
12
|
+
if (typeof json !== "object" || json === null) {
|
|
13
|
+
throw new Error("MCP config root must be an object");
|
|
14
|
+
}
|
|
15
|
+
// Find and validate all defined server names
|
|
16
|
+
const definedNames = new Set();
|
|
17
|
+
let hasMcpServersOrServers = false;
|
|
18
|
+
for (const key of ["mcpServers", "servers"]) {
|
|
19
|
+
const servers = json[key];
|
|
20
|
+
if (servers !== undefined) {
|
|
21
|
+
if (typeof servers !== "object" || servers === null || Array.isArray(servers)) {
|
|
22
|
+
throw new Error(`MCP config "${key}" must be an object`);
|
|
23
|
+
}
|
|
24
|
+
hasMcpServersOrServers = true;
|
|
25
|
+
for (const name of Object.keys(servers)) {
|
|
26
|
+
definedNames.add(name);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
if (allowedNames.length > 0 && !hasMcpServersOrServers) {
|
|
31
|
+
throw new Error("MCP config does not define any servers");
|
|
32
|
+
}
|
|
33
|
+
const missing = allowedNames.filter((name) => !definedNames.has(name));
|
|
34
|
+
if (missing.length > 0) {
|
|
35
|
+
throw new Error(`selected mcp server(s) not declared: ${missing.join(", ")}`);
|
|
36
|
+
}
|
|
37
|
+
const allowed = new Set(allowedNames);
|
|
38
|
+
let changed = false;
|
|
39
|
+
for (const key of ["mcpServers", "servers"]) {
|
|
40
|
+
const servers = json[key];
|
|
41
|
+
if (servers && typeof servers === "object" && !Array.isArray(servers)) {
|
|
42
|
+
const obj = servers;
|
|
43
|
+
const newObj = {};
|
|
44
|
+
for (const [name, config] of Object.entries(obj)) {
|
|
45
|
+
if (allowed.has(name)) {
|
|
46
|
+
newObj[name] = config;
|
|
47
|
+
}
|
|
48
|
+
else {
|
|
49
|
+
changed = true;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
json[key] = newObj;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
if (changed) {
|
|
56
|
+
writeFileSync(file, JSON.stringify(json, null, 2), "utf8");
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
catch (err) {
|
|
60
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
61
|
+
throw new Error("Failed to filter MCP config at " + file + ": " + msg);
|
|
62
|
+
}
|
|
63
|
+
}
|
package/dist/src/paths.js
CHANGED
|
@@ -55,21 +55,48 @@ export function marketplacePath(pluginsDir) {
|
|
|
55
55
|
/**
|
|
56
56
|
* Internal full-source cache for a plugin store. The runtime-facing
|
|
57
57
|
* `pluginsDir` contains only effective installations; complete source payloads
|
|
58
|
-
* live in the
|
|
58
|
+
* live in the OS-managed cache tree and are never registered with an agent.
|
|
59
59
|
*/
|
|
60
|
-
export function pluginCacheRoot(pluginsDir) {
|
|
61
|
-
|
|
62
|
-
|
|
60
|
+
export function pluginCacheRoot(pluginsDir, env = process.env, platform = process.platform) {
|
|
61
|
+
return join(systemCacheHome(env, platform), "plugins", pluginStoreId(pluginsDir));
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* OS-managed cache home for ADG. `ADG_CACHE_HOME` is intentionally an escape
|
|
65
|
+
* hatch for hermetic CI and tests; normal installations use the platform cache
|
|
66
|
+
* convention rather than the durable `~/.agents` state tree.
|
|
67
|
+
*/
|
|
68
|
+
export function systemCacheHome(env = process.env, platform = process.platform) {
|
|
69
|
+
if (env.ADG_CACHE_HOME)
|
|
70
|
+
return env.ADG_CACHE_HOME;
|
|
71
|
+
if (platform === "darwin")
|
|
72
|
+
return join(homedir(), "Library", "Caches", "adg");
|
|
73
|
+
if (platform === "win32")
|
|
74
|
+
return join(env.LOCALAPPDATA || join(homedir(), "AppData", "Local"), "adg");
|
|
75
|
+
return join(env.XDG_CACHE_HOME || join(homedir(), ".cache"), "adg");
|
|
76
|
+
}
|
|
77
|
+
function pluginStoreId(pluginsDir) {
|
|
78
|
+
return createHash("sha1").update(resolve(pluginsDir).split("\\").join("/")).digest("hex").slice(0, 12);
|
|
79
|
+
}
|
|
80
|
+
/** Read-only location used by ADG releases before the system-cache migration. */
|
|
81
|
+
export function legacyPluginCacheRoot(pluginsDir) {
|
|
82
|
+
return join(dirname(pluginsDir), "cache", "plugins", pluginStoreId(pluginsDir));
|
|
63
83
|
}
|
|
64
84
|
/** One replaceable full-source snapshot per installed plugin. */
|
|
65
85
|
export function pluginSourceCacheDir(pluginsDir, name) {
|
|
66
86
|
return join(pluginCacheRoot(pluginsDir), name);
|
|
67
87
|
}
|
|
88
|
+
/** One legacy snapshot path, retained as a read-only migration source. */
|
|
89
|
+
export function legacyPluginSourceCacheDir(pluginsDir, name) {
|
|
90
|
+
return join(legacyPluginCacheRoot(pluginsDir), name);
|
|
91
|
+
}
|
|
68
92
|
/** Resolve a complete payload for rebuilding, falling back to a live local source. */
|
|
69
93
|
export function pluginRematerializationSource(pluginsDir, name, origin) {
|
|
70
94
|
const cache = pluginSourceCacheDir(pluginsDir, name);
|
|
71
95
|
if (existsSync(cache))
|
|
72
96
|
return cache;
|
|
97
|
+
const legacyCache = legacyPluginSourceCacheDir(pluginsDir, name);
|
|
98
|
+
if (existsSync(legacyCache))
|
|
99
|
+
return legacyCache;
|
|
73
100
|
if (origin.type === "local") {
|
|
74
101
|
const localPath = resolve(pluginsDir, origin.path);
|
|
75
102
|
if (existsSync(localPath))
|