@rbbtsn0w/adg 0.4.0 → 0.5.0-beta.2
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/dist/bin/adg.js +80 -21
- package/dist/src/adapters/antigravity-hooks.js +18 -9
- package/dist/src/agents/base.js +44 -12
- package/dist/src/sources.js +28 -1
- package/dist/src/telemetry.js +76 -0
- package/dist/vendor/skills/src/add.js +6 -12
- package/dist/vendor/skills/src/cli.js +1 -2
- package/dist/vendor/skills/src/install.js +1 -1
- package/dist/vendor/skills/src/telemetry.js +83 -48
- package/dist/vendor/skills/src/update.js +83 -14
- package/docs/agents/antigravity.md +148 -0
- package/docs/agents/claude.md +113 -0
- package/docs/agents/codex.md +89 -0
- package/docs/agents-spec.md +172 -0
- package/package.json +7 -1
- package/vendor/skills/PROVENANCE.md +3 -2
- package/vendor/skills/src/add.ts +5 -13
- package/vendor/skills/src/cli.ts +1 -2
- package/vendor/skills/src/install.ts +1 -1
- package/vendor/skills/src/telemetry.ts +100 -65
- package/vendor/skills/src/update.ts +89 -22
- package/dist/vendor/skills/package.json +0 -143
package/dist/bin/adg.js
CHANGED
|
@@ -7,6 +7,8 @@ import { checkForUpdate, formatUpdateNotice } from "../src/update-check.js";
|
|
|
7
7
|
import { ui } from "../src/render/ui.js";
|
|
8
8
|
import { TOP_USAGE, fail } from "../src/cli/index.js";
|
|
9
9
|
import { runPlugins } from "../src/cli/handlers.js";
|
|
10
|
+
import { getTracer, shutdownTelemetry, sanitizeArgs } from "../src/telemetry.js";
|
|
11
|
+
import { SpanKind, SpanStatusCode, propagation, context } from "@opentelemetry/api";
|
|
10
12
|
// ---------------------------------------------------------------------------
|
|
11
13
|
// `adg` entry point: thin wire-up only.
|
|
12
14
|
//
|
|
@@ -41,8 +43,17 @@ function runSkills(verb, rest) {
|
|
|
41
43
|
const ext = self.endsWith(".ts") ? ".ts" : ".js";
|
|
42
44
|
const entry = join(here, "..", "vendor", "skills", "src", `cli${ext}`);
|
|
43
45
|
const args = [verb, ...rest].filter((x) => x !== undefined);
|
|
44
|
-
|
|
45
|
-
|
|
46
|
+
// Inject current active OpenTelemetry context into environment variables
|
|
47
|
+
const envCarrier = {};
|
|
48
|
+
propagation.inject(context.active(), envCarrier);
|
|
49
|
+
const r = spawnSync(process.execPath, skillsChildArgv(entry, args), {
|
|
50
|
+
stdio: "inherit",
|
|
51
|
+
env: {
|
|
52
|
+
...process.env,
|
|
53
|
+
...envCarrier,
|
|
54
|
+
},
|
|
55
|
+
});
|
|
56
|
+
return r.status ?? 1;
|
|
46
57
|
}
|
|
47
58
|
/**
|
|
48
59
|
* Read the package version from package.json.
|
|
@@ -73,24 +84,66 @@ async function main(argv) {
|
|
|
73
84
|
console.log(TOP_USAGE);
|
|
74
85
|
return;
|
|
75
86
|
}
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
87
|
+
const tracer = getTracer();
|
|
88
|
+
return await tracer.startActiveSpan("adg", { kind: SpanKind.INTERNAL }, async (span) => {
|
|
89
|
+
let status = 0;
|
|
90
|
+
try {
|
|
91
|
+
span.setAttribute("process.executable.name", "adg");
|
|
92
|
+
span.setAttribute("process.executable.path", process.argv[1] || process.execPath);
|
|
93
|
+
span.setAttribute("process.pid", process.pid);
|
|
94
|
+
span.setAttribute("process.command_args", sanitizeArgs(["adg", ...argv]));
|
|
95
|
+
// Check for an available update (reads local cache; schedules a background
|
|
96
|
+
// network refresh when the cache is stale — the refresh uses an unreffed
|
|
97
|
+
// socket so it cannot delay process exit).
|
|
98
|
+
const currentVersion = getVersion();
|
|
99
|
+
span.setAttribute("cli.version", currentVersion);
|
|
100
|
+
const latestVersion = checkForUpdate(currentVersion);
|
|
101
|
+
if (latestVersion) {
|
|
102
|
+
process.stderr.write(formatUpdateNotice(currentVersion, latestVersion));
|
|
103
|
+
}
|
|
104
|
+
switch (domain) {
|
|
105
|
+
case "plugins":
|
|
106
|
+
case "plugin": // tolerated alias
|
|
107
|
+
span.setAttribute("domain", "plugins");
|
|
108
|
+
if (verb)
|
|
109
|
+
span.setAttribute("verb", verb);
|
|
110
|
+
await runPlugins(verb, rest);
|
|
111
|
+
break;
|
|
112
|
+
case "skills":
|
|
113
|
+
case "skill":
|
|
114
|
+
span.setAttribute("domain", "skills");
|
|
115
|
+
if (verb)
|
|
116
|
+
span.setAttribute("verb", verb);
|
|
117
|
+
status = runSkills(verb, rest);
|
|
118
|
+
break;
|
|
119
|
+
default:
|
|
120
|
+
fail(`unknown domain: ${domain} (expected \`plugins\` or \`skills\`)`);
|
|
121
|
+
}
|
|
122
|
+
span.setAttribute("process.exit.code", status);
|
|
123
|
+
if (status !== 0) {
|
|
124
|
+
span.setAttribute("error.type", `EXIT_CODE_${status}`);
|
|
125
|
+
span.setStatus({
|
|
126
|
+
code: SpanStatusCode.ERROR,
|
|
127
|
+
message: `CLI exited with non-zero status ${status}`,
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
return status;
|
|
131
|
+
}
|
|
132
|
+
catch (error) {
|
|
133
|
+
status = 1;
|
|
134
|
+
span.setAttribute("process.exit.code", status);
|
|
135
|
+
span.setAttribute("error.type", error instanceof Error ? error.name : typeof error);
|
|
136
|
+
span.recordException(error);
|
|
137
|
+
span.setStatus({
|
|
138
|
+
code: SpanStatusCode.ERROR,
|
|
139
|
+
message: error instanceof Error ? error.message : String(error),
|
|
140
|
+
});
|
|
141
|
+
throw error;
|
|
142
|
+
}
|
|
143
|
+
finally {
|
|
144
|
+
span.end();
|
|
145
|
+
}
|
|
146
|
+
});
|
|
94
147
|
}
|
|
95
148
|
// Only run the CLI when executed directly, so the module can be imported by tests.
|
|
96
149
|
// `import.meta.url` is already realpath-resolved by Node, but `process.argv[1]`
|
|
@@ -112,8 +165,14 @@ function isInvokedDirectly() {
|
|
|
112
165
|
return fileURLToPath(import.meta.url) === resolved;
|
|
113
166
|
}
|
|
114
167
|
if (isInvokedDirectly()) {
|
|
115
|
-
main(process.argv.slice(2))
|
|
168
|
+
main(process.argv.slice(2))
|
|
169
|
+
.then(async (status) => {
|
|
170
|
+
await shutdownTelemetry();
|
|
171
|
+
process.exit(typeof status === "number" ? status : 0);
|
|
172
|
+
})
|
|
173
|
+
.catch(async (err) => {
|
|
116
174
|
console.error(`${ui.err("error:")} ${err instanceof Error ? err.message : String(err)}`);
|
|
175
|
+
await shutdownTelemetry();
|
|
117
176
|
process.exit(1);
|
|
118
177
|
});
|
|
119
178
|
}
|
|
@@ -174,17 +174,26 @@ function translateToolMatcher(matcher) {
|
|
|
174
174
|
if (typeof matcher !== "string")
|
|
175
175
|
return undefined;
|
|
176
176
|
const tokens = matcher.split("|");
|
|
177
|
-
if (tokens.some((token) => !/^[A-Za-z0-9_]+$/.test(token)))
|
|
178
|
-
return undefined;
|
|
179
177
|
const translated = [];
|
|
180
178
|
for (const token of tokens) {
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
translated.push(
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
179
|
+
if (token.startsWith("mcp__")) {
|
|
180
|
+
const mapped = "mcp_" + token.slice(5).replaceAll("__", "_");
|
|
181
|
+
translated.push(mapped);
|
|
182
|
+
}
|
|
183
|
+
else {
|
|
184
|
+
if (!/^[A-Za-z0-9_]+$/.test(token))
|
|
185
|
+
return undefined;
|
|
186
|
+
const alias = TOOL_ALIASES[token];
|
|
187
|
+
if (alias) {
|
|
188
|
+
translated.push(alias);
|
|
189
|
+
}
|
|
190
|
+
else if (ANTIGRAVITY_TOOL_NAMES.has(token)) {
|
|
191
|
+
translated.push(token);
|
|
192
|
+
}
|
|
193
|
+
else {
|
|
194
|
+
return undefined;
|
|
195
|
+
}
|
|
196
|
+
}
|
|
188
197
|
}
|
|
189
198
|
return translated.join("|");
|
|
190
199
|
}
|
package/dist/src/agents/base.js
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { spawnSync } from "node:child_process";
|
|
2
|
+
import { SpanKind, SpanStatusCode } from "@opentelemetry/api";
|
|
3
|
+
import { getTracer, sanitizeArgs } from "../telemetry.js";
|
|
2
4
|
/**
|
|
3
5
|
* The canonical "CLI absent, so nothing was touched" lifecycle result. Every
|
|
4
6
|
* agent's activate/deactivate guard returns this shape; centralizing it keeps
|
|
@@ -24,18 +26,48 @@ export function makeCli(bin, opts) {
|
|
|
24
26
|
return {
|
|
25
27
|
available: () => (probed ??= spawnSync(bin, opts.probeArgs, { stdio: "ignore" }).status === 0),
|
|
26
28
|
run: (args) => {
|
|
27
|
-
const
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
29
|
+
const tracer = getTracer();
|
|
30
|
+
return tracer.startActiveSpan(bin, { kind: SpanKind.CLIENT }, (span) => {
|
|
31
|
+
try {
|
|
32
|
+
span.setAttribute("process.executable.name", bin);
|
|
33
|
+
span.setAttribute("process.command_args", sanitizeArgs([bin, ...args]));
|
|
34
|
+
const r = spawnSync(bin, args, { encoding: "utf8" });
|
|
35
|
+
if (r.pid !== undefined) {
|
|
36
|
+
span.setAttribute("process.pid", r.pid);
|
|
37
|
+
}
|
|
38
|
+
if (r.status !== null) {
|
|
39
|
+
span.setAttribute("process.exit.code", r.status);
|
|
40
|
+
if (r.status !== 0) {
|
|
41
|
+
span.setAttribute("error.type", `EXIT_CODE_${r.status}`);
|
|
42
|
+
span.setStatus({
|
|
43
|
+
code: SpanStatusCode.ERROR,
|
|
44
|
+
message: `Command exited with non-zero status ${r.status}`,
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
else if (r.error) {
|
|
49
|
+
span.setAttribute("process.exit.code", -1);
|
|
50
|
+
const errCode = r.error.code;
|
|
51
|
+
span.setAttribute("error.type", (typeof errCode === "string" || typeof errCode === "number" ? String(errCode) : null) || r.error.name || "SpawnError");
|
|
52
|
+
span.recordException(r.error);
|
|
53
|
+
span.setStatus({
|
|
54
|
+
code: SpanStatusCode.ERROR,
|
|
55
|
+
message: r.error.message,
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
const ok = r.status === 0 && !r.error;
|
|
59
|
+
if (!ok && opts.echoStderr) {
|
|
60
|
+
if (r.error)
|
|
61
|
+
console.error(r.error.message);
|
|
62
|
+
else if (r.stderr)
|
|
63
|
+
console.error(r.stderr.trim());
|
|
64
|
+
}
|
|
65
|
+
return { ok, out: `${r.stdout ?? ""}${r.stderr ?? ""}${r.error ? r.error.message : ""}` };
|
|
66
|
+
}
|
|
67
|
+
finally {
|
|
68
|
+
span.end();
|
|
69
|
+
}
|
|
70
|
+
});
|
|
39
71
|
},
|
|
40
72
|
};
|
|
41
73
|
}
|
package/dist/src/sources.js
CHANGED
|
@@ -2,6 +2,8 @@ import { execFileSync } from "node:child_process";
|
|
|
2
2
|
import { existsSync, readdirSync } from "node:fs";
|
|
3
3
|
import { join } from "node:path";
|
|
4
4
|
import { readManifest, findManifestFile } from "./manifest.js";
|
|
5
|
+
import { SpanKind, SpanStatusCode } from "@opentelemetry/api";
|
|
6
|
+
import { getTracer, sanitizeArgs } from "./telemetry.js";
|
|
5
7
|
const GH_SHORTHAND = /^([\w.-]+)\/([\w.-]+?)(?:@(.+))?$/;
|
|
6
8
|
const GH_URL = /^(?:https?:\/\/github\.com\/|git@github\.com:)([\w.-]+)\/([\w.-]+?)(?:\.git)?(?:@(.+))?$/;
|
|
7
9
|
/**
|
|
@@ -56,7 +58,32 @@ export function cloneGitHub(src, dest, opts = {}) {
|
|
|
56
58
|
return dest;
|
|
57
59
|
}
|
|
58
60
|
const defaultGitRunner = (args) => {
|
|
59
|
-
|
|
61
|
+
const tracer = getTracer();
|
|
62
|
+
return tracer.startActiveSpan("git", { kind: SpanKind.CLIENT }, (span) => {
|
|
63
|
+
try {
|
|
64
|
+
span.setAttribute("process.executable.name", "git");
|
|
65
|
+
span.setAttribute("process.command_args", sanitizeArgs(["git", ...args]));
|
|
66
|
+
execFileSync("git", args, { stdio: "pipe" });
|
|
67
|
+
span.setAttribute("process.exit.code", 0);
|
|
68
|
+
}
|
|
69
|
+
catch (error) {
|
|
70
|
+
const exitCode = typeof error.status === "number" ? error.status : 1;
|
|
71
|
+
span.setAttribute("process.exit.code", exitCode);
|
|
72
|
+
if (typeof error.pid === "number") {
|
|
73
|
+
span.setAttribute("process.pid", error.pid);
|
|
74
|
+
}
|
|
75
|
+
span.setAttribute("error.type", error.code || error.name || `EXIT_CODE_${exitCode}`);
|
|
76
|
+
span.recordException(error);
|
|
77
|
+
span.setStatus({
|
|
78
|
+
code: SpanStatusCode.ERROR,
|
|
79
|
+
message: error.message,
|
|
80
|
+
});
|
|
81
|
+
throw error;
|
|
82
|
+
}
|
|
83
|
+
finally {
|
|
84
|
+
span.end();
|
|
85
|
+
}
|
|
86
|
+
});
|
|
60
87
|
};
|
|
61
88
|
/**
|
|
62
89
|
* Recursively find ADG plugins under `root` (directories containing
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { SimpleSpanProcessor } from "@opentelemetry/sdk-trace-base";
|
|
2
|
+
import { NodeTracerProvider } from "@opentelemetry/sdk-trace-node";
|
|
3
|
+
import { OTLPTraceExporter } from "@opentelemetry/exporter-trace-otlp-http";
|
|
4
|
+
import { resourceFromAttributes } from "@opentelemetry/resources";
|
|
5
|
+
import { SemanticResourceAttributes } from "@opentelemetry/semantic-conventions";
|
|
6
|
+
import * as opentelemetry from "@opentelemetry/api";
|
|
7
|
+
import {} from "@opentelemetry/api";
|
|
8
|
+
const baseEndpoint = process.env.OTEL_EXPORTER_OTLP_ENDPOINT;
|
|
9
|
+
const TELEMETRY_URL = process.env.OTEL_EXPORTER_OTLP_TRACES_ENDPOINT ||
|
|
10
|
+
(baseEndpoint
|
|
11
|
+
? `${baseEndpoint.replace(/\/$/, "")}/v1/traces`
|
|
12
|
+
: "https://telemetry-gateway.hamiltonsnow.workers.dev/v1/traces");
|
|
13
|
+
function isEnabled() {
|
|
14
|
+
return (!process.env.DISABLE_TELEMETRY &&
|
|
15
|
+
!process.env.DO_NOT_TRACK &&
|
|
16
|
+
!process.env.NODE_TEST_CONTEXT);
|
|
17
|
+
}
|
|
18
|
+
let provider = null;
|
|
19
|
+
let activeTracer = null;
|
|
20
|
+
export function getTracer() {
|
|
21
|
+
if (!isEnabled()) {
|
|
22
|
+
return opentelemetry.trace.getTracer("adg-noop");
|
|
23
|
+
}
|
|
24
|
+
if (!activeTracer) {
|
|
25
|
+
const exporter = new OTLPTraceExporter({
|
|
26
|
+
url: TELEMETRY_URL,
|
|
27
|
+
});
|
|
28
|
+
provider = new NodeTracerProvider({
|
|
29
|
+
resource: resourceFromAttributes({
|
|
30
|
+
[SemanticResourceAttributes.SERVICE_NAME]: "adg",
|
|
31
|
+
}),
|
|
32
|
+
spanProcessors: [new SimpleSpanProcessor(exporter)],
|
|
33
|
+
});
|
|
34
|
+
provider.register();
|
|
35
|
+
activeTracer = opentelemetry.trace.getTracer("adg");
|
|
36
|
+
}
|
|
37
|
+
return activeTracer;
|
|
38
|
+
}
|
|
39
|
+
export async function shutdownTelemetry() {
|
|
40
|
+
if (provider) {
|
|
41
|
+
try {
|
|
42
|
+
await provider.shutdown();
|
|
43
|
+
}
|
|
44
|
+
catch {
|
|
45
|
+
// Silently fail - telemetry should never break CLI exit
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
export function sanitizeArgs(args) {
|
|
50
|
+
return args.map((arg) => {
|
|
51
|
+
if (arg.startsWith("ghp_") ||
|
|
52
|
+
arg.startsWith("gho_") ||
|
|
53
|
+
arg.startsWith("ghu_") ||
|
|
54
|
+
arg.startsWith("ghs_") ||
|
|
55
|
+
arg.startsWith("ghr_") ||
|
|
56
|
+
arg.startsWith("github_pat_")) {
|
|
57
|
+
return "[REDACTED_TOKEN]";
|
|
58
|
+
}
|
|
59
|
+
if (arg.includes("@") && (arg.startsWith("http://") || arg.startsWith("https://"))) {
|
|
60
|
+
try {
|
|
61
|
+
const url = new URL(arg);
|
|
62
|
+
if (url.username) {
|
|
63
|
+
url.username = "[REDACTED]";
|
|
64
|
+
}
|
|
65
|
+
if (url.password) {
|
|
66
|
+
url.password = "[REDACTED]";
|
|
67
|
+
}
|
|
68
|
+
return url.toString();
|
|
69
|
+
}
|
|
70
|
+
catch {
|
|
71
|
+
return "[REDACTED_URL]";
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
return arg;
|
|
75
|
+
});
|
|
76
|
+
}
|
|
@@ -32,16 +32,12 @@ import { gitTreeShaForFolder } from "./git-tree.js";
|
|
|
32
32
|
import { discoverSkills, getSkillDisplayName, filterSkills } from "./skills.js";
|
|
33
33
|
import { installSkillForAgent, installBlobSkillForAgent, isSkillInstalled, getCanonicalPath, installWellKnownSkillForAgent, } from "./installer.js";
|
|
34
34
|
import { detectInstalledAgents, agents, getUniversalAgents, getVisibleUniversalAgents, getNonUniversalAgents, isUniversalAgent, } from "./agents.js";
|
|
35
|
-
import { track,
|
|
35
|
+
import { track, fetchAuditData, } from "./telemetry.js";
|
|
36
36
|
import { detectAgent, getAgentType } from "./detect-agent.js";
|
|
37
37
|
import { wellKnownProvider } from "./providers/index.js";
|
|
38
38
|
import { addSkillToLock, fetchSkillFolderHash, getGitHubToken, isPromptDismissed, dismissPrompt, getLastSelectedAgents, saveSelectedAgents, } from "./skill-lock.js";
|
|
39
39
|
import { addSkillToLocalLock, computeSkillFolderHash } from "./local-lock.js";
|
|
40
40
|
import { tryBlobInstall, BLOB_ALLOWED_REPOS, getSkillFolderHashFromTree, fetchRepoTree, } from "./blob.js";
|
|
41
|
-
import packageJson from '../package.json' with { type: 'json' };
|
|
42
|
-
export function initTelemetry(version) {
|
|
43
|
-
setVersion(version);
|
|
44
|
-
}
|
|
45
41
|
// ─── Security Advisory ───
|
|
46
42
|
function riskLabel(risk) {
|
|
47
43
|
switch (risk) {
|
|
@@ -322,8 +318,6 @@ async function selectAgentsInteractive(options) {
|
|
|
322
318
|
}
|
|
323
319
|
return selected;
|
|
324
320
|
}
|
|
325
|
-
const version = packageJson.version;
|
|
326
|
-
setVersion(version);
|
|
327
321
|
/**
|
|
328
322
|
* Handle skills from a well-known endpoint (RFC 8615).
|
|
329
323
|
* Discovers skills from /.well-known/agent-skills/index.json (preferred)
|
|
@@ -714,10 +708,10 @@ export async function runAdd(args, options = {}) {
|
|
|
714
708
|
console.log(pc.bgRed(pc.white(pc.bold(' ERROR '))) + ' ' + pc.red('Missing required argument: source'));
|
|
715
709
|
console.log();
|
|
716
710
|
console.log(pc.dim(' Usage:'));
|
|
717
|
-
console.log(` ${pc.cyan('
|
|
711
|
+
console.log(` ${pc.cyan('adg skills add')} ${pc.yellow('<source>')} ${pc.dim('[options]')}`);
|
|
718
712
|
console.log();
|
|
719
713
|
console.log(pc.dim(' Example:'));
|
|
720
|
-
console.log(` ${pc.cyan('
|
|
714
|
+
console.log(` ${pc.cyan('adg skills add')} ${pc.yellow('vercel-labs/agent-skills')}`);
|
|
721
715
|
console.log();
|
|
722
716
|
process.exit(1);
|
|
723
717
|
}
|
|
@@ -777,7 +771,7 @@ export async function runAdd(args, options = {}) {
|
|
|
777
771
|
p.log.message(pc.yellow('This source contains user-submitted skills that have not been reviewed for safety or quality.'));
|
|
778
772
|
p.log.message(pc.yellow('Skills run with full agent permissions and could be malicious.'));
|
|
779
773
|
console.log();
|
|
780
|
-
p.log.message(`If you understand the risks, re-run with:\n\n ${pc.cyan(`
|
|
774
|
+
p.log.message(`If you understand the risks, re-run with:\n\n ${pc.cyan(`adg skills add ${source} --dangerously-accept-openclaw-risks`)}\n`);
|
|
781
775
|
p.outro(pc.red('Installation blocked'));
|
|
782
776
|
process.exit(1);
|
|
783
777
|
}
|
|
@@ -1593,13 +1587,13 @@ async function promptForFindSkills(options, targetAgents) {
|
|
|
1593
1587
|
}
|
|
1594
1588
|
catch {
|
|
1595
1589
|
p.log.warn('Failed to install find-skills. You can try again with:');
|
|
1596
|
-
p.log.message(pc.dim('
|
|
1590
|
+
p.log.message(pc.dim(' adg skills add vercel-labs/skills@find-skills -g -y --all'));
|
|
1597
1591
|
}
|
|
1598
1592
|
}
|
|
1599
1593
|
else {
|
|
1600
1594
|
// User declined - dismiss the prompt
|
|
1601
1595
|
await dismissPrompt('findSkillsPrompt');
|
|
1602
|
-
p.log.message(pc.dim('You can install it later with:
|
|
1596
|
+
p.log.message(pc.dim('You can install it later with: adg skills add vercel-labs/skills@find-skills'));
|
|
1603
1597
|
}
|
|
1604
1598
|
}
|
|
1605
1599
|
catch {
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { writeFileSync, readFileSync, existsSync, mkdirSync } from 'fs';
|
|
3
3
|
import { basename, join, dirname } from 'path';
|
|
4
4
|
import { fileURLToPath } from 'url';
|
|
5
|
-
import { runAdd, parseAddOptions
|
|
5
|
+
import { runAdd, parseAddOptions } from "./add.js";
|
|
6
6
|
import { runFind } from "./find.js";
|
|
7
7
|
import { runInstallFromLock } from "./install.js";
|
|
8
8
|
import { runList } from "./list.js";
|
|
@@ -24,7 +24,6 @@ function getVersion() {
|
|
|
24
24
|
}
|
|
25
25
|
}
|
|
26
26
|
const VERSION = getVersion();
|
|
27
|
-
initTelemetry(VERSION);
|
|
28
27
|
const RESET = '\x1b[0m';
|
|
29
28
|
const BOLD = '\x1b[1m';
|
|
30
29
|
// 256-color grays - visible on both light and dark backgrounds
|
|
@@ -19,7 +19,7 @@ export async function runInstallFromLock(args) {
|
|
|
19
19
|
const skillEntries = Object.entries(lock.skills);
|
|
20
20
|
if (skillEntries.length === 0) {
|
|
21
21
|
p.log.warn('No project skills found in skills-lock.json');
|
|
22
|
-
p.log.info(`Add project-level skills with ${pc.cyan('
|
|
22
|
+
p.log.info(`Add project-level skills with ${pc.cyan('adg skills add <package>')} (without ${pc.cyan('-g')})`);
|
|
23
23
|
return;
|
|
24
24
|
}
|
|
25
25
|
// Only install to .agents/skills/ (universal agents)
|
|
@@ -1,30 +1,58 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import { SimpleSpanProcessor } from "@opentelemetry/sdk-trace-base";
|
|
2
|
+
import { NodeTracerProvider } from "@opentelemetry/sdk-trace-node";
|
|
3
|
+
import { OTLPTraceExporter } from "@opentelemetry/exporter-trace-otlp-http";
|
|
4
|
+
import { resourceFromAttributes } from "@opentelemetry/resources";
|
|
5
|
+
import { SemanticResourceAttributes } from "@opentelemetry/semantic-conventions";
|
|
6
|
+
import * as opentelemetry from "@opentelemetry/api";
|
|
7
|
+
import { propagation, ROOT_CONTEXT } from "@opentelemetry/api";
|
|
8
|
+
import { readFileSync, existsSync } from "node:fs";
|
|
9
|
+
import { dirname, join } from "node:path";
|
|
10
|
+
import { fileURLToPath } from "node:url";
|
|
11
|
+
const baseEndpoint = process.env.OTEL_EXPORTER_OTLP_ENDPOINT;
|
|
12
|
+
const TELEMETRY_URL = process.env.OTEL_EXPORTER_OTLP_TRACES_ENDPOINT ||
|
|
13
|
+
(baseEndpoint
|
|
14
|
+
? `${baseEndpoint.replace(/\/$/, "")}/v1/traces`
|
|
15
|
+
: "https://telemetry-gateway.hamiltonsnow.workers.dev/v1/traces");
|
|
16
|
+
const AUDIT_URL = "https://add-skill.vercel.sh/audit";
|
|
17
|
+
let provider = null;
|
|
18
|
+
let activeTracer = null;
|
|
4
19
|
let detectedAgentName = null;
|
|
5
|
-
/**
|
|
6
|
-
* Set the detected AI agent name for telemetry tracking.
|
|
7
|
-
* Called once during agent detection, then included in all telemetry events.
|
|
8
|
-
*/
|
|
9
20
|
export function setDetectedAgent(agentName) {
|
|
10
21
|
detectedAgentName = agentName;
|
|
11
22
|
}
|
|
12
|
-
function isCI() {
|
|
13
|
-
return !!(process.env.CI ||
|
|
14
|
-
process.env.GITHUB_ACTIONS ||
|
|
15
|
-
process.env.GITLAB_CI ||
|
|
16
|
-
process.env.CIRCLECI ||
|
|
17
|
-
process.env.TRAVIS ||
|
|
18
|
-
process.env.BUILDKITE ||
|
|
19
|
-
process.env.JENKINS_URL ||
|
|
20
|
-
process.env.TEAMCITY_VERSION);
|
|
21
|
-
}
|
|
22
23
|
function isEnabled() {
|
|
23
|
-
return !process.env.DISABLE_TELEMETRY &&
|
|
24
|
+
return (!process.env.DISABLE_TELEMETRY &&
|
|
25
|
+
!process.env.DO_NOT_TRACK &&
|
|
26
|
+
!process.env.NODE_TEST_CONTEXT);
|
|
24
27
|
}
|
|
25
|
-
|
|
26
|
-
|
|
28
|
+
function isCI() {
|
|
29
|
+
return (process.env.CI === "true" ||
|
|
30
|
+
process.env.CI === "1" ||
|
|
31
|
+
process.env.GITHUB_ACTIONS === "true" ||
|
|
32
|
+
process.env.VERCEL === "1");
|
|
27
33
|
}
|
|
34
|
+
function getCliVersion() {
|
|
35
|
+
try {
|
|
36
|
+
const self = fileURLToPath(import.meta.url);
|
|
37
|
+
const here = dirname(self);
|
|
38
|
+
// Resolve adg's top-level package.json (name "@rbbtsn0w/adg"), not the
|
|
39
|
+
// vendored skills-cli package.json. This module lives at
|
|
40
|
+
// vendor/skills/src/telemetry.ts (dev) or dist/vendor/skills/src/
|
|
41
|
+
// telemetry.js (built), so the adg root is 3 levels up for .ts, 4 for .js.
|
|
42
|
+
const up = self.endsWith(".ts")
|
|
43
|
+
? join("..", "..", "..")
|
|
44
|
+
: join("..", "..", "..", "..");
|
|
45
|
+
const pkgPath = join(here, up, "package.json");
|
|
46
|
+
if (!existsSync(pkgPath))
|
|
47
|
+
return null;
|
|
48
|
+
const pkg = JSON.parse(readFileSync(pkgPath, "utf-8"));
|
|
49
|
+
return pkg.version;
|
|
50
|
+
}
|
|
51
|
+
catch {
|
|
52
|
+
return null;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
const cliVersion = getCliVersion();
|
|
28
56
|
/**
|
|
29
57
|
* Fetch security audit results for skills from the audit API.
|
|
30
58
|
* Returns null on any error or timeout — never blocks installation.
|
|
@@ -35,7 +63,7 @@ export async function fetchAuditData(source, skillSlugs, timeoutMs = 3000) {
|
|
|
35
63
|
try {
|
|
36
64
|
const params = new URLSearchParams({
|
|
37
65
|
source,
|
|
38
|
-
skills: skillSlugs.join(
|
|
66
|
+
skills: skillSlugs.join(","),
|
|
39
67
|
});
|
|
40
68
|
const controller = new AbortController();
|
|
41
69
|
const timeout = setTimeout(() => controller.abort(), timeoutMs);
|
|
@@ -51,51 +79,58 @@ export async function fetchAuditData(source, skillSlugs, timeoutMs = 3000) {
|
|
|
51
79
|
return null;
|
|
52
80
|
}
|
|
53
81
|
}
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
82
|
+
export function getTracer() {
|
|
83
|
+
if (!isEnabled()) {
|
|
84
|
+
return opentelemetry.trace.getTracer("adg-noop");
|
|
85
|
+
}
|
|
86
|
+
if (!activeTracer) {
|
|
87
|
+
const exporter = new OTLPTraceExporter({
|
|
88
|
+
url: TELEMETRY_URL,
|
|
89
|
+
});
|
|
90
|
+
provider = new NodeTracerProvider({
|
|
91
|
+
resource: resourceFromAttributes({
|
|
92
|
+
[SemanticResourceAttributes.SERVICE_NAME]: "adg",
|
|
93
|
+
}),
|
|
94
|
+
spanProcessors: [new SimpleSpanProcessor(exporter)],
|
|
95
|
+
});
|
|
96
|
+
provider.register();
|
|
97
|
+
activeTracer = opentelemetry.trace.getTracer("adg");
|
|
98
|
+
}
|
|
99
|
+
return activeTracer;
|
|
100
|
+
}
|
|
57
101
|
export function track(data) {
|
|
58
102
|
if (!isEnabled())
|
|
59
103
|
return;
|
|
60
104
|
try {
|
|
61
|
-
const
|
|
62
|
-
|
|
105
|
+
const tracer = getTracer();
|
|
106
|
+
const parentContext = propagation.extract(ROOT_CONTEXT, process.env);
|
|
107
|
+
const span = tracer.startSpan(`skills-${data.event}`, {}, parentContext);
|
|
108
|
+
// Set common attributes
|
|
109
|
+
span.setAttribute("domain", "skills");
|
|
63
110
|
if (cliVersion) {
|
|
64
|
-
|
|
111
|
+
span.setAttribute("cli.version", cliVersion);
|
|
65
112
|
}
|
|
66
|
-
// Add CI flag if running in CI
|
|
67
113
|
if (isCI()) {
|
|
68
|
-
|
|
114
|
+
span.setAttribute("ci", true);
|
|
69
115
|
}
|
|
70
|
-
// Add detected AI agent name
|
|
71
116
|
if (detectedAgentName) {
|
|
72
|
-
|
|
117
|
+
span.setAttribute("agent", detectedAgentName);
|
|
73
118
|
}
|
|
74
|
-
//
|
|
119
|
+
// Set event attributes
|
|
75
120
|
for (const [key, value] of Object.entries(data)) {
|
|
76
121
|
if (value !== undefined && value !== null) {
|
|
77
|
-
|
|
122
|
+
span.setAttribute(key, String(value));
|
|
78
123
|
}
|
|
79
124
|
}
|
|
80
|
-
|
|
81
|
-
// flushTelemetry() can await it before the process exits.
|
|
82
|
-
const p = fetch(`${TELEMETRY_URL}?${params.toString()}`)
|
|
83
|
-
.catch(() => { })
|
|
84
|
-
.then(() => { });
|
|
85
|
-
pendingTelemetry.push(p);
|
|
125
|
+
span.end();
|
|
86
126
|
}
|
|
87
127
|
catch {
|
|
88
128
|
// Silently fail - telemetry should never break the CLI
|
|
89
129
|
}
|
|
90
130
|
}
|
|
91
|
-
/**
|
|
92
|
-
* Wait for all in-flight telemetry requests to settle.
|
|
93
|
-
* Called once at CLI exit so the process doesn't hang on open sockets
|
|
94
|
-
* but also doesn't drop data by exiting too early.
|
|
95
|
-
*/
|
|
96
131
|
export async function flushTelemetry(timeoutMs = 5000) {
|
|
97
|
-
if (
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
132
|
+
if (provider) {
|
|
133
|
+
const timeout = new Promise((resolve) => setTimeout(resolve, timeoutMs));
|
|
134
|
+
await Promise.race([provider.shutdown(), timeout]);
|
|
135
|
+
}
|
|
101
136
|
}
|