@rbbtsn0w/adg 0.5.0 → 0.6.0-beta.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +67 -2
- package/dist/bin/adg.js +0 -1
- package/dist/src/adapters/codex.js +12 -0
- package/dist/src/adapters/reverse.js +22 -1
- package/dist/src/agents/claude.js +52 -6
- package/dist/src/agents/codex.js +94 -14
- package/dist/src/cli/handlers.js +164 -141
- package/dist/src/cli/index.js +14 -4
- package/dist/src/codex-marketplace-migration.js +139 -0
- package/dist/src/commands/cache.js +92 -15
- package/dist/src/commands/inspect.js +41 -0
- package/dist/src/commands/install.js +140 -73
- package/dist/src/commands/link.js +4 -16
- package/dist/src/commands/marketplace.js +74 -20
- package/dist/src/commands/migrate.js +15 -3
- package/dist/src/commands/projection.js +15 -0
- package/dist/src/commands/select-components.js +12 -0
- package/dist/src/commands/state.js +4 -2
- package/dist/src/commands/sync.js +9 -15
- package/dist/src/commands/update.js +51 -10
- package/dist/src/commands/validate.js +9 -2
- package/dist/src/components.js +3 -0
- package/dist/src/default-dsl.js +142 -0
- package/dist/src/lock.js +25 -7
- package/dist/src/manifest.js +29 -1
- package/dist/src/materialize.js +5 -1
- package/dist/src/mcp.js +59 -0
- package/dist/src/paths.js +31 -4
- package/dist/src/render/plugins.js +7 -1
- package/dist/src/source-cache.js +140 -0
- package/dist/src/sources.js +76 -5
- package/dist/src/telemetry.js +28 -21
- package/dist/src/types.js +5 -1
- package/dist/vendor/skills/src/cli.js +6 -1
- package/dist/vendor/skills/src/update.js +29 -4
- package/docs/agents-spec.md +27 -4
- package/docs/authoring.md +19 -2
- package/package.json +8 -2
- package/schemas/adg-plugin.schema.json +1 -0
- package/schemas/plugin-lock.schema.json +23 -1
- package/vendor/skills/src/cli.ts +6 -1
- package/vendor/skills/src/update.ts +32 -4
package/dist/src/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))
|
|
@@ -34,6 +34,12 @@ export function renderAgentReport(agents, verb) {
|
|
|
34
34
|
return out;
|
|
35
35
|
}
|
|
36
36
|
const PATH_MAX = 44;
|
|
37
|
+
function pluginLabel(plugin) {
|
|
38
|
+
if (plugin.definition?.kind === "default-dsl/v1" && plugin.resolvedRevision) {
|
|
39
|
+
return `${plugin.name}@0.0.0-git-${plugin.resolvedRevision.slice(0, 6)}`;
|
|
40
|
+
}
|
|
41
|
+
return `${plugin.name}@${plugin.version}`;
|
|
42
|
+
}
|
|
37
43
|
/** `adg plugins list` — aligned name/path/agents rows, with optional verbose contents. */
|
|
38
44
|
export function renderPluginList(plugins, pluginsDir, opts = {}) {
|
|
39
45
|
if (plugins.length === 0)
|
|
@@ -47,7 +53,7 @@ export function renderPluginList(plugins, pluginsDir, opts = {}) {
|
|
|
47
53
|
const agents = agentsForComponents(types).map((a) => a.displayName);
|
|
48
54
|
return {
|
|
49
55
|
p,
|
|
50
|
-
label:
|
|
56
|
+
label: pluginLabel(p),
|
|
51
57
|
path: abbrevHome(installedPluginDir(pluginsDir, p.name, p.origin)),
|
|
52
58
|
agents: agents.length > 0 ? agents.join(", ") : "—",
|
|
53
59
|
counts: exposed.map(([type, names]) => `${type}: ${names.length}`),
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
import { existsSync, mkdtempSync, rmSync } from "node:fs";
|
|
2
|
+
import { tmpdir } from "node:os";
|
|
3
|
+
import { isAbsolute, join, relative, resolve, sep } from "node:path";
|
|
4
|
+
import { folderHash } from "./hash.js";
|
|
5
|
+
import { readManifest } from "./manifest.js";
|
|
6
|
+
import { withPluginSourceCache } from "./materialize.js";
|
|
7
|
+
import { PROJECTION_DIRS, packageFilter } from "./package.js";
|
|
8
|
+
import { legacyPluginSourceCacheDir, pluginSourceCacheDir } from "./paths.js";
|
|
9
|
+
import { recordTelemetryEvent } from "./telemetry.js";
|
|
10
|
+
import { runGit } from "./sources.js";
|
|
11
|
+
class SourceCacheIntegrityError extends Error {
|
|
12
|
+
}
|
|
13
|
+
function sourceHash(dir) {
|
|
14
|
+
const manifest = readManifest(dir);
|
|
15
|
+
return folderHash(dir, PROJECTION_DIRS, packageFilter(manifest, { includeProjections: false }));
|
|
16
|
+
}
|
|
17
|
+
function assertSourceHash(dir, name, expected) {
|
|
18
|
+
if (sourceHash(dir) !== expected) {
|
|
19
|
+
recordTelemetryEvent("adg.cache.recovery", { outcome: "hash_mismatch" });
|
|
20
|
+
throw new SourceCacheIntegrityError(`source cache integrity mismatch for "${name}"; run \`adg plugins update\` or re-add the plugin`);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
function recordRecoveryFailure(error) {
|
|
24
|
+
if (!(error instanceof SourceCacheIntegrityError)) {
|
|
25
|
+
recordTelemetryEvent("adg.cache.recovery", { outcome: "missing_unrecoverable" });
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
function remoteUrl(entry) {
|
|
29
|
+
if (entry.origin.type === "github")
|
|
30
|
+
return `https://github.com/${entry.origin.repo}.git`;
|
|
31
|
+
if (entry.origin.type === "git")
|
|
32
|
+
return entry.origin.url;
|
|
33
|
+
return undefined;
|
|
34
|
+
}
|
|
35
|
+
function restoreExactRemoteSnapshot(pluginsDir, name, entry) {
|
|
36
|
+
const url = remoteUrl(entry);
|
|
37
|
+
if (!url || !entry.resolvedRevision)
|
|
38
|
+
return undefined;
|
|
39
|
+
const temp = mkdtempSync(join(tmpdir(), "adg-cache-restore-"));
|
|
40
|
+
try {
|
|
41
|
+
// Do not check out origin/ref: it is user update intent and can move. Fetch
|
|
42
|
+
// only the exact commit persisted by the v4 lock instead.
|
|
43
|
+
runGit(["-C", temp, "init"]);
|
|
44
|
+
runGit(["-C", temp, "remote", "add", "origin", url]);
|
|
45
|
+
runGit(["-C", temp, "fetch", "--depth", "1", "origin", entry.resolvedRevision]);
|
|
46
|
+
runGit(["-C", temp, "checkout", "--detach", "FETCH_HEAD"]);
|
|
47
|
+
const source = resolve(temp, entry.origin.path || ".");
|
|
48
|
+
const rel = relative(temp, source);
|
|
49
|
+
if (isAbsolute(rel) || rel === ".." || rel.startsWith(`..${sep}`)) {
|
|
50
|
+
throw new Error(`locked source path escapes the repository for "${name}"`);
|
|
51
|
+
}
|
|
52
|
+
if (!existsSync(source))
|
|
53
|
+
throw new Error(`locked source path is missing for "${name}"`);
|
|
54
|
+
assertSourceHash(source, name, entry.sourceHash);
|
|
55
|
+
const manifest = readManifest(source);
|
|
56
|
+
return withPluginSourceCache(source, pluginSourceCacheDir(pluginsDir, name), manifest, (snapshot) => {
|
|
57
|
+
assertSourceHash(snapshot, name, entry.sourceHash);
|
|
58
|
+
return snapshot;
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
catch (error) {
|
|
62
|
+
recordRecoveryFailure(error);
|
|
63
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
64
|
+
throw new Error(`cannot restore "${name}" at locked revision ${entry.resolvedRevision}: ${message}`);
|
|
65
|
+
}
|
|
66
|
+
finally {
|
|
67
|
+
rmSync(temp, { recursive: true, force: true });
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Return a complete source payload for rematerialization. The modern cache is
|
|
72
|
+
* authoritative; a legacy snapshot is adopted only after proving it matches
|
|
73
|
+
* the lock hash. Local origins are likewise accepted only when they still
|
|
74
|
+
* reproduce the locked source hash. Remote entries intentionally never fall
|
|
75
|
+
* back to their moving ref: a missing immutable snapshot is a hard recovery
|
|
76
|
+
* failure until an explicit update/add records a new revision.
|
|
77
|
+
*/
|
|
78
|
+
export function resolvePluginSourceSnapshot(pluginsDir, name, entry) {
|
|
79
|
+
if (!entry || typeof entry !== "object" || !entry.origin || typeof entry.origin !== "object") {
|
|
80
|
+
throw new Error(`Invalid or missing lock entry for "${name}"`);
|
|
81
|
+
}
|
|
82
|
+
const cache = pluginSourceCacheDir(pluginsDir, name);
|
|
83
|
+
if (existsSync(cache)) {
|
|
84
|
+
try {
|
|
85
|
+
assertSourceHash(cache, name, entry.sourceHash);
|
|
86
|
+
recordTelemetryEvent("adg.cache.recovery", { outcome: "hit" });
|
|
87
|
+
return cache;
|
|
88
|
+
}
|
|
89
|
+
catch (error) {
|
|
90
|
+
recordRecoveryFailure(error);
|
|
91
|
+
throw error;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
const legacy = legacyPluginSourceCacheDir(pluginsDir, name);
|
|
95
|
+
if (existsSync(legacy)) {
|
|
96
|
+
try {
|
|
97
|
+
assertSourceHash(legacy, name, entry.sourceHash);
|
|
98
|
+
const manifest = readManifest(legacy);
|
|
99
|
+
const adopted = withPluginSourceCache(legacy, cache, manifest, (snapshot) => {
|
|
100
|
+
assertSourceHash(snapshot, name, entry.sourceHash);
|
|
101
|
+
return snapshot;
|
|
102
|
+
});
|
|
103
|
+
recordTelemetryEvent("adg.cache.recovery", { outcome: "adopted_legacy" });
|
|
104
|
+
return adopted;
|
|
105
|
+
}
|
|
106
|
+
catch (error) {
|
|
107
|
+
recordRecoveryFailure(error);
|
|
108
|
+
throw error;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
if (entry.origin.type === "local") {
|
|
112
|
+
const local = resolve(pluginsDir, entry.origin.path);
|
|
113
|
+
if (existsSync(local)) {
|
|
114
|
+
try {
|
|
115
|
+
assertSourceHash(local, name, entry.sourceHash);
|
|
116
|
+
const manifest = readManifest(local);
|
|
117
|
+
const restored = withPluginSourceCache(local, cache, manifest, (snapshot) => {
|
|
118
|
+
assertSourceHash(snapshot, name, entry.sourceHash);
|
|
119
|
+
return snapshot;
|
|
120
|
+
});
|
|
121
|
+
recordTelemetryEvent("adg.cache.recovery", { outcome: "restored_local" });
|
|
122
|
+
return restored;
|
|
123
|
+
}
|
|
124
|
+
catch (error) {
|
|
125
|
+
recordRecoveryFailure(error);
|
|
126
|
+
throw error;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
const restored = restoreExactRemoteSnapshot(pluginsDir, name, entry);
|
|
131
|
+
if (restored) {
|
|
132
|
+
recordTelemetryEvent("adg.cache.recovery", { outcome: "restored_remote" });
|
|
133
|
+
return restored;
|
|
134
|
+
}
|
|
135
|
+
recordTelemetryEvent("adg.cache.recovery", { outcome: "missing_unrecoverable" });
|
|
136
|
+
const legacyHint = entry.origin.type === "github" || entry.origin.type === "git"
|
|
137
|
+
? "Remote source recovery requires an immutable revision; run `adg plugins update` or re-add the plugin."
|
|
138
|
+
: "Run `adg plugins update` or re-add the plugin.";
|
|
139
|
+
throw new Error(`source cache missing for "${name}". ${legacyHint}`);
|
|
140
|
+
}
|
package/dist/src/sources.js
CHANGED
|
@@ -4,6 +4,22 @@ import { join } from "node:path";
|
|
|
4
4
|
import { readManifest, findManifestFile } from "./manifest.js";
|
|
5
5
|
import { SpanKind, SpanStatusCode } from "@opentelemetry/api";
|
|
6
6
|
import { getTracer, sanitizeArgs } from "./telemetry.js";
|
|
7
|
+
/** Best-effort repository About lookup. Callers must retain their deterministic fallback on failure. */
|
|
8
|
+
export async function githubRepositoryDescription(repo) {
|
|
9
|
+
try {
|
|
10
|
+
const response = await fetch(`https://api.github.com/repos/${repo.split("/").map(encodeURIComponent).join("/")}`, {
|
|
11
|
+
headers: { Accept: "application/vnd.github+json", "User-Agent": "adg-cli" },
|
|
12
|
+
signal: AbortSignal.timeout(3000),
|
|
13
|
+
});
|
|
14
|
+
if (!response.ok)
|
|
15
|
+
return undefined;
|
|
16
|
+
const body = await response.json();
|
|
17
|
+
return typeof body.description === "string" && body.description.trim() ? body.description.trim() : undefined;
|
|
18
|
+
}
|
|
19
|
+
catch {
|
|
20
|
+
return undefined;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
7
23
|
const GH_SHORTHAND = /^([\w.-]+)\/([\w.-]+?)(?:@(.+))?$/;
|
|
8
24
|
const GH_URL = /^(?:https?:\/\/github\.com\/|git@github\.com:)([\w.-]+)\/([\w.-]+?)(?:\.git)?(?:@(.+))?$/;
|
|
9
25
|
const GH_BLOB_URL = /^(?:https?:\/\/github\.com\/)([\w.-]+)\/([\w.-]+?)(?:\.git)?\/(?:blob|tree)\/([^/]+)\/(.+)$/;
|
|
@@ -40,6 +56,15 @@ function decodeGitHubUrlPart(value) {
|
|
|
40
56
|
export function parseSource(spec) {
|
|
41
57
|
if (existsSync(spec))
|
|
42
58
|
return { kind: "local", dir: spec };
|
|
59
|
+
try {
|
|
60
|
+
return parseGitHubSource(spec);
|
|
61
|
+
}
|
|
62
|
+
catch {
|
|
63
|
+
throw new Error(`cannot parse install source: "${spec}" (expected a local path, owner/repo[@ref], or a github.com URL)`);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
/** Parse a GitHub source without allowing an existing CWD path to override it. */
|
|
67
|
+
export function parseGitHubSource(spec) {
|
|
43
68
|
const clean = spec.replace(/[?#].*$/, "");
|
|
44
69
|
const blob = clean.match(GH_BLOB_URL);
|
|
45
70
|
if (blob) {
|
|
@@ -58,7 +83,7 @@ export function parseSource(spec) {
|
|
|
58
83
|
const [, owner, repo, ref] = short;
|
|
59
84
|
return gh(owner, repo, ref);
|
|
60
85
|
}
|
|
61
|
-
throw new Error(`cannot parse
|
|
86
|
+
throw new Error(`cannot parse GitHub source: "${spec}" (expected owner/repo[@ref] or a github.com URL)`);
|
|
62
87
|
}
|
|
63
88
|
function gh(owner, repo, ref) {
|
|
64
89
|
return {
|
|
@@ -90,14 +115,26 @@ export function cloneGitHub(src, dest, opts = {}) {
|
|
|
90
115
|
}
|
|
91
116
|
return dest;
|
|
92
117
|
}
|
|
93
|
-
const defaultGitRunner = (args) => {
|
|
118
|
+
export const defaultGitRunner = (args) => {
|
|
119
|
+
runGit(args);
|
|
120
|
+
};
|
|
121
|
+
/** Return a low-cardinality, string-safe error type for Git subprocess spans. */
|
|
122
|
+
export function gitErrorType(error, exitCode) {
|
|
123
|
+
const code = error && typeof error === "object" ? error.code : undefined;
|
|
124
|
+
return code === undefined || code === null ? `EXIT_CODE_${exitCode}` : String(code);
|
|
125
|
+
}
|
|
126
|
+
/** Run git under the shared CLI semantic-convention instrumentation. */
|
|
127
|
+
export function runGit(args, captureOutput = false) {
|
|
94
128
|
const tracer = getTracer();
|
|
95
129
|
return tracer.startActiveSpan("git", { kind: SpanKind.CLIENT }, (span) => {
|
|
96
130
|
try {
|
|
97
131
|
span.setAttribute("process.executable.name", "git");
|
|
98
132
|
span.setAttribute("process.command_args", sanitizeArgs(["git", ...args]));
|
|
99
|
-
execFileSync("git", args,
|
|
133
|
+
const output = execFileSync("git", args, captureOutput
|
|
134
|
+
? { stdio: "pipe", encoding: "utf8" }
|
|
135
|
+
: { stdio: "ignore" });
|
|
100
136
|
span.setAttribute("process.exit.code", 0);
|
|
137
|
+
return captureOutput ? String(output).trimEnd() : undefined;
|
|
101
138
|
}
|
|
102
139
|
catch (error) {
|
|
103
140
|
const exitCode = typeof error.status === "number" ? error.status : 1;
|
|
@@ -105,7 +142,7 @@ const defaultGitRunner = (args) => {
|
|
|
105
142
|
if (typeof error.pid === "number") {
|
|
106
143
|
span.setAttribute("process.pid", error.pid);
|
|
107
144
|
}
|
|
108
|
-
span.setAttribute("error.type", error
|
|
145
|
+
span.setAttribute("error.type", gitErrorType(error, exitCode));
|
|
109
146
|
span.recordException(error);
|
|
110
147
|
span.setStatus({
|
|
111
148
|
code: SpanStatusCode.ERROR,
|
|
@@ -117,7 +154,41 @@ const defaultGitRunner = (args) => {
|
|
|
117
154
|
span.end();
|
|
118
155
|
}
|
|
119
156
|
});
|
|
120
|
-
}
|
|
157
|
+
}
|
|
158
|
+
;
|
|
159
|
+
/** Resolve the immutable commit checked out in a cloned worktree. */
|
|
160
|
+
export function gitRevision(dir) {
|
|
161
|
+
try {
|
|
162
|
+
return runGit(["-C", dir, "rev-parse", "HEAD"], true) || undefined;
|
|
163
|
+
}
|
|
164
|
+
catch {
|
|
165
|
+
// Injected/offline clone runners in tests may materialize a plain directory.
|
|
166
|
+
// Such entries remain legacy until a real update records an immutable commit.
|
|
167
|
+
return undefined;
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
const GIT_SHA_RE = /^[0-9a-f]{40}$/i;
|
|
171
|
+
/** Extract the commit SHA from `git ls-remote`, preferring an annotated tag's peeled ref. */
|
|
172
|
+
export function parseRemoteRevision(output, ref) {
|
|
173
|
+
if (!output)
|
|
174
|
+
return undefined;
|
|
175
|
+
const rows = output.split(/\r?\n/).map((line) => line.trim().split(/\s+/)).filter(([sha, name]) => GIT_SHA_RE.test(sha ?? "") && name);
|
|
176
|
+
const peeled = ref ? rows.find(([, name]) => name === `refs/tags/${ref}^{}`)?.[0] : undefined;
|
|
177
|
+
return peeled ?? rows[0]?.[0];
|
|
178
|
+
}
|
|
179
|
+
/** Lightweight remote commit probe used to avoid cloning an unchanged source. */
|
|
180
|
+
export function gitRemoteRevision(repo, ref) {
|
|
181
|
+
if (ref && GIT_SHA_RE.test(ref))
|
|
182
|
+
return ref.toLowerCase();
|
|
183
|
+
try {
|
|
184
|
+
const pattern = ref || "HEAD";
|
|
185
|
+
const output = runGit(["ls-remote", `https://github.com/${repo}.git`, pattern, `${pattern}^{}`], true);
|
|
186
|
+
return parseRemoteRevision(output, ref);
|
|
187
|
+
}
|
|
188
|
+
catch {
|
|
189
|
+
return undefined;
|
|
190
|
+
}
|
|
191
|
+
}
|
|
121
192
|
/**
|
|
122
193
|
* Recursively find ADG plugins under `root` (directories containing
|
|
123
194
|
* `.agents/.plugin.json`, or the legacy `.adg-plugin/plugin.json`), keyed by
|
package/dist/src/telemetry.js
CHANGED
|
@@ -50,32 +50,39 @@ export async function shutdownTelemetry() {
|
|
|
50
50
|
}
|
|
51
51
|
}
|
|
52
52
|
}
|
|
53
|
+
/**
|
|
54
|
+
* Unconditionally redact any non-empty string passed to it.
|
|
55
|
+
* Telemetry consumers need the command skeleton (subcommands + flags),
|
|
56
|
+
* not path details. Returning a fixed placeholder eliminates all
|
|
57
|
+
* path-related privacy edge cases.
|
|
58
|
+
*/
|
|
59
|
+
export function sanitizePath(path) {
|
|
60
|
+
if (!path)
|
|
61
|
+
return "";
|
|
62
|
+
return "[PATH]";
|
|
63
|
+
}
|
|
53
64
|
export function sanitizeArgs(args) {
|
|
54
65
|
return args.map((arg) => {
|
|
55
|
-
if (arg.startsWith("
|
|
56
|
-
arg.
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
arg.startsWith("
|
|
61
|
-
|
|
62
|
-
}
|
|
63
|
-
if (arg.includes("@") && (arg.startsWith("http://") || arg.startsWith("https://"))) {
|
|
64
|
-
try {
|
|
65
|
-
const url = new URL(arg);
|
|
66
|
-
if (url.username) {
|
|
67
|
-
url.username = "[REDACTED]";
|
|
68
|
-
}
|
|
69
|
-
if (url.password) {
|
|
70
|
-
url.password = "[REDACTED]";
|
|
71
|
-
}
|
|
72
|
-
return url.toString();
|
|
66
|
+
if (arg.startsWith("-")) {
|
|
67
|
+
const eqIndex = arg.indexOf("=");
|
|
68
|
+
if (eqIndex !== -1) {
|
|
69
|
+
return `${arg.slice(0, eqIndex)}=[VALUE]`;
|
|
70
|
+
}
|
|
71
|
+
if (arg.startsWith("--") && /^--[a-zA-Z0-9-]+$/.test(arg)) {
|
|
72
|
+
return arg;
|
|
73
73
|
}
|
|
74
|
-
|
|
75
|
-
return
|
|
74
|
+
if (/^-[a-zA-Z0-9]$/.test(arg)) {
|
|
75
|
+
return arg;
|
|
76
76
|
}
|
|
77
|
+
if (/^-[a-zA-Z0-9]/.test(arg)) {
|
|
78
|
+
return `${arg.slice(0, 2)}[VALUE]`;
|
|
79
|
+
}
|
|
80
|
+
return "[VALUE]";
|
|
81
|
+
}
|
|
82
|
+
if (/^[a-z]+(-[a-z]+)*$/.test(arg) || /^[0-9]+$/.test(arg)) {
|
|
83
|
+
return arg;
|
|
77
84
|
}
|
|
78
|
-
return
|
|
85
|
+
return "[VALUE]";
|
|
79
86
|
});
|
|
80
87
|
}
|
|
81
88
|
/** Record a privacy-safe event without allowing telemetry to affect CLI behavior. */
|
package/dist/src/types.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* ADG type definitions mirroring the JSON Schemas under ../schemas.
|
|
3
3
|
*/
|
|
4
4
|
export const ADG_SCHEMA_VERSION = "adg.plugin/v1";
|
|
5
|
-
export const LOCK_VERSION =
|
|
5
|
+
export const LOCK_VERSION = 5;
|
|
6
6
|
/** The component categories a plugin can expose. */
|
|
7
7
|
export const COMPONENT_TYPES = ["skills", "agents", "commands", "mcp", "hooks", "apps"];
|
|
8
8
|
/** Canonicalize user intent without adding derived component dependencies. */
|
|
@@ -12,9 +12,12 @@ export function normalizePluginSelection(selection) {
|
|
|
12
12
|
const components = new Set(selection.components);
|
|
13
13
|
if (selection.skills !== undefined)
|
|
14
14
|
components.add("skills");
|
|
15
|
+
if (selection.mcp !== undefined)
|
|
16
|
+
components.add("mcp");
|
|
15
17
|
return {
|
|
16
18
|
components: COMPONENT_TYPES.filter((component) => components.has(component)),
|
|
17
19
|
...(selection.skills !== undefined ? { skills: [...new Set(selection.skills)].sort() } : {}),
|
|
20
|
+
...(selection.mcp !== undefined ? { mcp: [...new Set(selection.mcp)].sort() } : {}),
|
|
18
21
|
};
|
|
19
22
|
}
|
|
20
23
|
/** Expand mandatory component/skill requirements to a stable closure. */
|
|
@@ -53,6 +56,7 @@ export function resolveSelectionDependencies(manifest, selection) {
|
|
|
53
56
|
return {
|
|
54
57
|
components: COMPONENT_TYPES.filter((component) => components.has(component)),
|
|
55
58
|
...(skills ? { skills: [...skills].sort() } : {}),
|
|
59
|
+
...(normalized.mcp !== undefined ? { mcp: [...new Set(normalized.mcp)].sort() } : {}),
|
|
56
60
|
};
|
|
57
61
|
}
|
|
58
62
|
export function pluginState(entry) {
|
|
@@ -341,4 +341,9 @@ async function main() {
|
|
|
341
341
|
console.log(`Run ${BOLD}skills --help${RESET} for usage.`);
|
|
342
342
|
}
|
|
343
343
|
}
|
|
344
|
-
main()
|
|
344
|
+
main()
|
|
345
|
+
.catch((error) => {
|
|
346
|
+
console.error(error instanceof Error ? error.message : String(error));
|
|
347
|
+
process.exitCode = 1;
|
|
348
|
+
})
|
|
349
|
+
.finally(() => flushTelemetry().then(() => process.exit(process.exitCode ?? 0)));
|
|
@@ -24,9 +24,31 @@ const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
|
24
24
|
* our actual TS entry, run via Node's type-stripping (Node >= 22.6), exactly how
|
|
25
25
|
* `adg skills` launches the CLI. See vendor/skills/PROVENANCE.md.
|
|
26
26
|
*/
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
27
|
+
export function resolveSelfCliEntry(moduleDir = __dirname, exists = existsSync) {
|
|
28
|
+
const sourceEntry = join(moduleDir, '../../../bin/adg.ts');
|
|
29
|
+
if (exists(sourceEntry))
|
|
30
|
+
return sourceEntry;
|
|
31
|
+
return join(moduleDir, '../../../bin/adg.js');
|
|
32
|
+
}
|
|
33
|
+
const SELF_CLI_ENTRY = resolveSelfCliEntry();
|
|
34
|
+
function recordSelfCliEntrypointMissing() {
|
|
35
|
+
const tracer = getTracer();
|
|
36
|
+
const span = tracer.startSpan("adg", { kind: SpanKind.CLIENT });
|
|
37
|
+
try {
|
|
38
|
+
span.setAttribute("process.executable.name", "adg");
|
|
39
|
+
span.setAttribute("process.command_args", ["adg", "skills", "add"]);
|
|
40
|
+
span.setAttribute("process.exit.code", -1);
|
|
41
|
+
span.setAttribute("error.type", "CLI_ENTRYPOINT_NOT_FOUND");
|
|
42
|
+
span.recordException(new Error("CLI entrypoint not found"));
|
|
43
|
+
span.setStatus({
|
|
44
|
+
code: SpanStatusCode.ERROR,
|
|
45
|
+
message: "CLI entrypoint not found",
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
finally {
|
|
49
|
+
span.end();
|
|
50
|
+
}
|
|
51
|
+
}
|
|
30
52
|
const RESET = '\x1b[0m';
|
|
31
53
|
const BOLD = '\x1b[1m';
|
|
32
54
|
const DIM = '\x1b[38;5;102m';
|
|
@@ -400,13 +422,14 @@ export async function updateGlobalSkills(options = {}) {
|
|
|
400
422
|
console.log(`${TEXT}Updating ${safeName}...${RESET}`);
|
|
401
423
|
const installUrl = buildUpdateInstallSource(update.entry);
|
|
402
424
|
const cliEntry = SELF_CLI_ENTRY;
|
|
425
|
+
const args = ['skills', 'add', installUrl, '-g', '-y'];
|
|
403
426
|
if (!existsSync(cliEntry)) {
|
|
404
427
|
failCount++;
|
|
428
|
+
recordSelfCliEntrypointMissing();
|
|
405
429
|
console.log(` ${DIM}✗ Failed to update ${safeName}: CLI entrypoint not found at ${cliEntry}${RESET}`);
|
|
406
430
|
continue;
|
|
407
431
|
}
|
|
408
432
|
const tracer = getTracer();
|
|
409
|
-
const args = ['skills', 'add', installUrl, '-g', '-y'];
|
|
410
433
|
const result = tracer.startActiveSpan("adg", { kind: SpanKind.CLIENT }, (span) => {
|
|
411
434
|
try {
|
|
412
435
|
span.setAttribute("process.executable.name", "adg");
|
|
@@ -508,6 +531,7 @@ export async function updateProjectSkills(options = {}) {
|
|
|
508
531
|
const localLock = await readLocalLock();
|
|
509
532
|
const cliEntry = SELF_CLI_ENTRY;
|
|
510
533
|
if (!existsSync(cliEntry)) {
|
|
534
|
+
recordSelfCliEntrypointMissing();
|
|
511
535
|
console.log(`${DIM}✗ CLI entrypoint not found at ${cliEntry}${RESET}`);
|
|
512
536
|
return { successCount, failCount: updatable.length, foundCount: projectSkills.length };
|
|
513
537
|
}
|
|
@@ -652,6 +676,7 @@ export async function runUpdate(args = []) {
|
|
|
652
676
|
}
|
|
653
677
|
if (totalFail > 0) {
|
|
654
678
|
console.log(`${DIM}Failed to update ${totalFail} skill(s)${RESET}`);
|
|
679
|
+
process.exitCode = 1;
|
|
655
680
|
}
|
|
656
681
|
track({
|
|
657
682
|
event: 'update',
|
package/docs/agents-spec.md
CHANGED
|
@@ -80,7 +80,28 @@ are ADG-internal conventions, not declared in the manifest.
|
|
|
80
80
|
|
|
81
81
|
---
|
|
82
82
|
|
|
83
|
-
## 3.
|
|
83
|
+
## 3. Default directory DSL
|
|
84
|
+
|
|
85
|
+
When `.agents/.plugin.json` is absent, ADG recognizes only these fixed source
|
|
86
|
+
slots: `skills/<name>/SKILL.md`, `hooks/hooks.json`, and `.mcp.json`. At least
|
|
87
|
+
one valid slot is required. A skill needs non-empty frontmatter `description`;
|
|
88
|
+
hooks and MCP files must be valid JSON (MCP must contain an object of servers).
|
|
89
|
+
|
|
90
|
+
An explicit source manifest remains the only customization mechanism. Its
|
|
91
|
+
`skills`, `hooks`, and `mcpServers` fields replace the corresponding default
|
|
92
|
+
slot; omitted fields inherit valid defaults. A malformed inherited default slot
|
|
93
|
+
is an error, while an explicitly overridden slot is not interpreted. `--as` is
|
|
94
|
+
available only for structural sources. `--only` controls both copied payload and
|
|
95
|
+
runtime projection; non-interactive hooks/MCP discovery requires explicit
|
|
96
|
+
`--only`. Default DSL is source-root only.
|
|
97
|
+
|
|
98
|
+
Default DSL is deliberately **not** a monorepo discovery convention. A source
|
|
99
|
+
repository containing multiple plugins must declare every member with its own
|
|
100
|
+
`.agents/.plugin.json` (and may use `.agents/.marketplace.json` as its catalog).
|
|
101
|
+
Consumers select declared members with `--plugin` or `--all`; a source
|
|
102
|
+
subdirectory is never an install/inspect selector.
|
|
103
|
+
|
|
104
|
+
## 4. Packaging — manifest-driven allowlist
|
|
84
105
|
|
|
85
106
|
ADG first stores the complete declared payload in an internal source cache, then
|
|
86
107
|
materializes an **effective installation** into the runtime-facing plugins
|
|
@@ -102,9 +123,11 @@ The lock records two hashes: `sourceHash` covers the complete cached payload and
|
|
|
102
123
|
`installedHash` covers the effective selection. Runtime projections are excluded
|
|
103
124
|
from both hashes so re-adapting does not churn content identity.
|
|
104
125
|
|
|
105
|
-
The cache is scoped by a stable store id under the
|
|
106
|
-
|
|
107
|
-
|
|
126
|
+
The cache is scoped by a stable store id under the OS-managed
|
|
127
|
+
system cache tree (`~/Library/Caches/adg/plugins/` on macOS,
|
|
128
|
+
`$XDG_CACHE_HOME/adg/plugins/` on Linux). `adg plugins cache status` reports
|
|
129
|
+
its contents, `cache restore` recreates missing snapshots from the exact lock
|
|
130
|
+
revision, `cache prune` removes orphan snapshots, and `cache clean --force` removes all
|
|
108
131
|
snapshots. A missing remote snapshot must be restored with `plugins update` or
|
|
109
132
|
`plugins add`; a still-available local source is used directly as fallback.
|
|
110
133
|
|
package/docs/authoring.md
CHANGED
|
@@ -62,6 +62,23 @@ authoring artifact:
|
|
|
62
62
|
|
|
63
63
|
---
|
|
64
64
|
|
|
65
|
+
## Conventional skills repositories
|
|
66
|
+
|
|
67
|
+
A repository may omit `.agents/.plugin.json` when it follows the fixed Default
|
|
68
|
+
DSL: `skills/<name>/SKILL.md`, `hooks/hooks.json`, and/or `.mcp.json`. ADG
|
|
69
|
+
derives one plugin only from the source root; it does not recursively guess
|
|
70
|
+
other directories.
|
|
71
|
+
|
|
72
|
+
Default DSL is not available to a member directory of a multi-plugin repository.
|
|
73
|
+
For a marketplace, give every member its own `.agents/.plugin.json`; consumers
|
|
74
|
+
select that explicit member with `--plugin` rather than by source subdirectory.
|
|
75
|
+
|
|
76
|
+
Add `.agents/.plugin.json` for non-standard paths or metadata. Its `skills`,
|
|
77
|
+
`hooks`, and `mcpServers` fields replace their respective defaults; omitted
|
|
78
|
+
fields inherit valid conventional locations. In automation, explicitly use
|
|
79
|
+
`--only` before enabling discovered hooks or MCP. Consumers may use `--as` only
|
|
80
|
+
when installing a manifest-free structural source.
|
|
81
|
+
|
|
65
82
|
## The `.agents/.plugin.json` DSL
|
|
66
83
|
|
|
67
84
|
```jsonc
|
|
@@ -74,7 +91,7 @@ authoring artifact:
|
|
|
74
91
|
"author": { "name": "You", "url": "…", "email": "…" },
|
|
75
92
|
"license": "MIT",
|
|
76
93
|
"category": "Developer Tools",
|
|
77
|
-
"interface": { "displayName": "ASC", "icon": "asc.png" },
|
|
94
|
+
"interface": { "displayName": "ASC", "shortDescription": "Ship App Store releases with asc.", "icon": "asc.png" },
|
|
78
95
|
|
|
79
96
|
// ── Components: path pointers, never inlined content ──
|
|
80
97
|
"skills": "./skills/", // string (root dir) | string[] (explicit paths)
|
|
@@ -108,7 +125,7 @@ authoring artifact:
|
|
|
108
125
|
| `author` | `{ name, url?, email? }` | | |
|
|
109
126
|
| `license` | string | | SPDX id, e.g. `MIT`. |
|
|
110
127
|
| `category` | string | | Free-form, e.g. `Developer Tools`. |
|
|
111
|
-
| `interface` | `{ displayName?, icon? }` | | Presentation
|
|
128
|
+
| `interface` | `{ displayName?, shortDescription?, icon? }` | | Presentation metadata. Codex uses `shortDescription` in its plugin picker; when omitted, ADG uses the manifest `description`. |
|
|
112
129
|
| `skills` | string \| string[] | | Root dir (auto-scan) or explicit skill paths. |
|
|
113
130
|
| `commands` | string | | Directory of slash-command `.md` files. |
|
|
114
131
|
| `agents` | string | | Directory of sub-agent `.md` files. |
|