@rbbtsn0w/adg 0.6.0 → 0.7.0
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
|
@@ -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
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { spawnSync, } from "node:child_process";
|
|
2
|
+
import { basename } from "node:path";
|
|
3
|
+
import { SpanKind, SpanStatusCode, } from "@opentelemetry/api";
|
|
4
|
+
import { getTracer, sanitizeArgs } from "./telemetry.js";
|
|
5
|
+
/** Apply the OTel CLI semantic convention without collecting process output. */
|
|
6
|
+
export function annotateSubprocess(span, executableName, args, result) {
|
|
7
|
+
span.setAttribute("process.executable.name", executableName);
|
|
8
|
+
span.setAttribute("process.command_args", sanitizeArgs([executableName, ...args]));
|
|
9
|
+
if (result.pid !== undefined)
|
|
10
|
+
span.setAttribute("process.pid", result.pid);
|
|
11
|
+
if (result.status !== null) {
|
|
12
|
+
span.setAttribute("process.exit.code", result.status);
|
|
13
|
+
if (result.status !== 0) {
|
|
14
|
+
const errorType = `EXIT_CODE_${result.status}`;
|
|
15
|
+
const error = new Error(`${executableName} exited with status ${result.status}`);
|
|
16
|
+
span.setAttribute("error.type", errorType);
|
|
17
|
+
span.recordException(error);
|
|
18
|
+
span.setStatus({ code: SpanStatusCode.ERROR, message: error.message });
|
|
19
|
+
}
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
span.setAttribute("process.exit.code", -1);
|
|
23
|
+
if (result.signal) {
|
|
24
|
+
const errorType = `SIGNAL_${result.signal}`;
|
|
25
|
+
const error = new Error(`${executableName} terminated by signal ${result.signal}`);
|
|
26
|
+
span.setAttribute("error.type", errorType);
|
|
27
|
+
span.setAttribute("process.exit.signal", result.signal);
|
|
28
|
+
span.recordException(error);
|
|
29
|
+
span.setStatus({ code: SpanStatusCode.ERROR, message: error.message });
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
if (result.error) {
|
|
33
|
+
const code = result.error.code;
|
|
34
|
+
span.setAttribute("error.type", code ?? result.error.name ?? "SpawnError");
|
|
35
|
+
span.recordException(result.error);
|
|
36
|
+
span.setStatus({ code: SpanStatusCode.ERROR, message: result.error.message });
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
export function runSubprocessSync(command, args, options = {}) {
|
|
40
|
+
const executableName = basename(command);
|
|
41
|
+
return getTracer().startActiveSpan(executableName, { kind: SpanKind.CLIENT }, (span) => {
|
|
42
|
+
try {
|
|
43
|
+
const result = (options.encoding
|
|
44
|
+
? spawnSync(command, args, options)
|
|
45
|
+
: spawnSync(command, args, options));
|
|
46
|
+
annotateSubprocess(span, executableName, args, result);
|
|
47
|
+
return result;
|
|
48
|
+
}
|
|
49
|
+
finally {
|
|
50
|
+
span.end();
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
}
|
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) {
|
|
@@ -833,18 +833,6 @@ export async function runAdd(args, options = {}) {
|
|
|
833
833
|
return Promise.resolve(null);
|
|
834
834
|
return isRepoPrivate(ownerRepo.owner, ownerRepo.repo).catch(() => null);
|
|
835
835
|
})();
|
|
836
|
-
// Block openclaw sources unless explicitly opted in
|
|
837
|
-
const sourceOwner = ownerRepoRaw?.split('/')[0]?.toLowerCase();
|
|
838
|
-
if (sourceOwner === 'openclaw' && !options.dangerouslyAcceptOpenclawRisks) {
|
|
839
|
-
console.log();
|
|
840
|
-
p.log.warn(pc.yellow(pc.bold('⚠ OpenClaw skills are unverified community submissions.')));
|
|
841
|
-
p.log.message(pc.yellow('This source contains user-submitted skills that have not been reviewed for safety or quality.'));
|
|
842
|
-
p.log.message(pc.yellow('Skills run with full agent permissions and could be malicious.'));
|
|
843
|
-
console.log();
|
|
844
|
-
p.log.message(`If you understand the risks, re-run with:\n\n ${pc.cyan(`adg skills add ${source} --dangerously-accept-openclaw-risks`)}\n`);
|
|
845
|
-
p.outro(pc.red('Installation blocked'));
|
|
846
|
-
process.exit(1);
|
|
847
|
-
}
|
|
848
836
|
// Handle well-known skills from arbitrary URLs
|
|
849
837
|
if (parsed.type === 'well-known') {
|
|
850
838
|
await handleWellKnownSkills(source, parsed.url, options, spinner);
|
|
@@ -1810,9 +1798,6 @@ export function parseAddOptions(args) {
|
|
|
1810
1798
|
else if (arg === '--copy') {
|
|
1811
1799
|
options.copy = true;
|
|
1812
1800
|
}
|
|
1813
|
-
else if (arg === '--dangerously-accept-openclaw-risks') {
|
|
1814
|
-
options.dangerouslyAcceptOpenclawRisks = true;
|
|
1815
|
-
}
|
|
1816
1801
|
else if (arg === '--subagent') {
|
|
1817
1802
|
options.subagent = options.subagent || [];
|
|
1818
1803
|
i++;
|
|
@@ -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)));
|
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { promisify } from 'node:util';
|
|
3
|
-
const execFileAsync = promisify(execFile);
|
|
1
|
+
import { runSubprocessSync } from "../../../src/subprocess.js";
|
|
4
2
|
/**
|
|
5
3
|
* ADG-added file (see vendor/skills/PROVENANCE.md → Local patches).
|
|
6
4
|
*
|
|
@@ -22,7 +20,9 @@ const execFileAsync = promisify(execFile);
|
|
|
22
20
|
export async function gitTreeShaForFolder(repoDir, folder) {
|
|
23
21
|
const spec = folder ? `HEAD:${folder}` : 'HEAD^{tree}';
|
|
24
22
|
try {
|
|
25
|
-
const { stdout } =
|
|
23
|
+
const { stdout, status } = runSubprocessSync('git', ['-C', repoDir, 'rev-parse', spec], { encoding: 'utf8' });
|
|
24
|
+
if (status !== 0)
|
|
25
|
+
return null;
|
|
26
26
|
const sha = stdout.trim();
|
|
27
27
|
return /^[0-9a-f]{40}$/.test(sha) ? sha : null;
|
|
28
28
|
}
|
|
@@ -2,8 +2,8 @@ import { readFile, writeFile, mkdir } from 'fs/promises';
|
|
|
2
2
|
import { join, dirname } from 'path';
|
|
3
3
|
import { homedir } from 'os';
|
|
4
4
|
import { createHash } from 'crypto';
|
|
5
|
-
import { execSync } from 'child_process';
|
|
6
5
|
import pc from 'picocolors';
|
|
6
|
+
import { runSubprocessSync } from "../../../src/subprocess.js";
|
|
7
7
|
const AGENTS_DIR = '.agents';
|
|
8
8
|
const LOCK_FILE = '.skill-lock.json';
|
|
9
9
|
const CURRENT_VERSION = 3; // Bumped from 2 to 3 for folder hash support (GitHub tree SHA)
|
|
@@ -103,10 +103,11 @@ export function getGitHubToken() {
|
|
|
103
103
|
_ghWarningShown = true;
|
|
104
104
|
}
|
|
105
105
|
try {
|
|
106
|
-
const
|
|
106
|
+
const result = runSubprocessSync('gh', ['auth', 'token'], {
|
|
107
107
|
encoding: 'utf-8',
|
|
108
108
|
stdio: ['pipe', 'pipe', 'pipe'],
|
|
109
|
-
})
|
|
109
|
+
});
|
|
110
|
+
const token = result.status === 0 ? result.stdout.trim() : '';
|
|
110
111
|
if (token) {
|
|
111
112
|
return token;
|
|
112
113
|
}
|