@rbbtsn0w/adg 0.4.0-beta.9 → 0.5.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bin/adg.js +79 -21
- package/dist/src/adapters/antigravity-hooks.js +2 -1
- package/dist/src/agents/antigravity.js +8 -6
- 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/telemetry.js +88 -64
- package/dist/vendor/skills/src/update.js +79 -10
- 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/telemetry.ts +108 -124
- package/vendor/skills/src/update.ts +85 -18
|
@@ -1,186 +1,170 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
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 { type Tracer, 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
|
+
|
|
12
|
+
const baseEndpoint = process.env.OTEL_EXPORTER_OTLP_ENDPOINT;
|
|
13
|
+
const TELEMETRY_URL =
|
|
14
|
+
process.env.OTEL_EXPORTER_OTLP_TRACES_ENDPOINT ||
|
|
15
|
+
(baseEndpoint
|
|
16
|
+
? `${baseEndpoint.replace(/\/$/, "")}/v1/traces`
|
|
17
|
+
: "https://telemetry-gateway.hamiltonsnow.workers.dev/v1/traces");
|
|
3
18
|
|
|
4
19
|
interface InstallTelemetryData {
|
|
5
|
-
event:
|
|
20
|
+
event: "install";
|
|
6
21
|
source: string;
|
|
7
22
|
skills: string;
|
|
8
23
|
agents: string;
|
|
9
|
-
global?:
|
|
10
|
-
skillFiles?: string;
|
|
11
|
-
/**
|
|
12
|
-
* Source type for different hosts:
|
|
13
|
-
* - 'github': GitHub repository (default, uses raw.githubusercontent.com)
|
|
14
|
-
* - 'raw': Direct URL to SKILL.md (generic raw URL)
|
|
15
|
-
* - Provider IDs like 'mintlify', 'huggingface', etc.
|
|
16
|
-
*/
|
|
17
|
-
sourceType?: string;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
interface RemoveTelemetryData {
|
|
21
|
-
event: 'remove';
|
|
22
|
-
source?: string;
|
|
23
|
-
skills: string;
|
|
24
|
-
agents: string;
|
|
25
|
-
global?: '1';
|
|
26
|
-
sourceType?: string;
|
|
24
|
+
global?: "1";
|
|
25
|
+
skillFiles?: string;
|
|
27
26
|
}
|
|
28
27
|
|
|
29
28
|
interface UpdateTelemetryData {
|
|
30
|
-
event:
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
29
|
+
event: "update";
|
|
30
|
+
successCount: number;
|
|
31
|
+
failCount: number;
|
|
32
|
+
checkedCount: number;
|
|
33
|
+
global?: "1";
|
|
35
34
|
}
|
|
36
35
|
|
|
37
|
-
interface
|
|
38
|
-
event:
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
interactive?: '1';
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
interface SyncTelemetryData {
|
|
45
|
-
event: 'experimental_sync';
|
|
46
|
-
skillCount: string;
|
|
47
|
-
successCount: string;
|
|
48
|
-
agents: string;
|
|
36
|
+
interface RemoveTelemetryData {
|
|
37
|
+
event: "remove";
|
|
38
|
+
skill: string;
|
|
39
|
+
global?: "1";
|
|
49
40
|
}
|
|
50
41
|
|
|
51
|
-
type TelemetryData =
|
|
52
|
-
| InstallTelemetryData
|
|
53
|
-
| RemoveTelemetryData
|
|
54
|
-
| UpdateTelemetryData
|
|
55
|
-
| FindTelemetryData
|
|
56
|
-
| SyncTelemetryData;
|
|
42
|
+
type TelemetryData = InstallTelemetryData | UpdateTelemetryData | RemoveTelemetryData;
|
|
57
43
|
|
|
58
|
-
let
|
|
44
|
+
let provider: NodeTracerProvider | null = null;
|
|
45
|
+
let activeTracer: Tracer | null = null;
|
|
59
46
|
let detectedAgentName: string | null = null;
|
|
60
47
|
|
|
61
|
-
/**
|
|
62
|
-
* Set the detected AI agent name for telemetry tracking.
|
|
63
|
-
* Called once during agent detection, then included in all telemetry events.
|
|
64
|
-
*/
|
|
65
48
|
export function setDetectedAgent(agentName: string | null): void {
|
|
66
49
|
detectedAgentName = agentName;
|
|
67
50
|
}
|
|
68
51
|
|
|
69
|
-
function isCI(): boolean {
|
|
70
|
-
return !!(
|
|
71
|
-
process.env.CI ||
|
|
72
|
-
process.env.GITHUB_ACTIONS ||
|
|
73
|
-
process.env.GITLAB_CI ||
|
|
74
|
-
process.env.CIRCLECI ||
|
|
75
|
-
process.env.TRAVIS ||
|
|
76
|
-
process.env.BUILDKITE ||
|
|
77
|
-
process.env.JENKINS_URL ||
|
|
78
|
-
process.env.TEAMCITY_VERSION
|
|
79
|
-
);
|
|
80
|
-
}
|
|
81
|
-
|
|
82
52
|
function isEnabled(): boolean {
|
|
83
|
-
return
|
|
53
|
+
return (
|
|
54
|
+
!process.env.DISABLE_TELEMETRY &&
|
|
55
|
+
!process.env.DO_NOT_TRACK &&
|
|
56
|
+
!process.env.NODE_TEST_CONTEXT
|
|
57
|
+
);
|
|
84
58
|
}
|
|
85
59
|
|
|
86
|
-
|
|
87
|
-
|
|
60
|
+
function isCI(): boolean {
|
|
61
|
+
return (
|
|
62
|
+
process.env.CI === "true" ||
|
|
63
|
+
process.env.CI === "1" ||
|
|
64
|
+
process.env.GITHUB_ACTIONS === "true" ||
|
|
65
|
+
process.env.VERCEL === "1"
|
|
66
|
+
);
|
|
88
67
|
}
|
|
89
68
|
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
69
|
+
function getCliVersion(): string | null {
|
|
70
|
+
try {
|
|
71
|
+
const self = fileURLToPath(import.meta.url);
|
|
72
|
+
const here = dirname(self);
|
|
73
|
+
const up = self.endsWith(".ts") ? ".." : join("..", "..");
|
|
74
|
+
const pkgPath = join(here, up, "package.json");
|
|
75
|
+
if (!existsSync(pkgPath)) return null;
|
|
76
|
+
const pkg = JSON.parse(readFileSync(pkgPath, "utf-8"));
|
|
77
|
+
return pkg.version;
|
|
78
|
+
} catch {
|
|
79
|
+
return null;
|
|
80
|
+
}
|
|
97
81
|
}
|
|
98
82
|
|
|
99
|
-
|
|
100
|
-
export type AuditResponse = Record<string, SkillAuditData>;
|
|
83
|
+
const cliVersion = getCliVersion();
|
|
101
84
|
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
* Returns null on any error or timeout — never blocks installation.
|
|
105
|
-
*/
|
|
106
|
-
export async function fetchAuditData(
|
|
107
|
-
source: string,
|
|
108
|
-
skillSlugs: string[],
|
|
109
|
-
timeoutMs = 3000
|
|
110
|
-
): Promise<AuditResponse | null> {
|
|
111
|
-
if (skillSlugs.length === 0) return null;
|
|
85
|
+
async function auditSkill(url: string, source: string): Promise<string | null> {
|
|
86
|
+
if (!isEnabled()) return null;
|
|
112
87
|
|
|
113
88
|
try {
|
|
114
|
-
const
|
|
115
|
-
|
|
116
|
-
|
|
89
|
+
const res = await fetch(url, {
|
|
90
|
+
method: "POST",
|
|
91
|
+
headers: {
|
|
92
|
+
"Content-Type": "application/json",
|
|
93
|
+
"User-Agent": `skills-cli/${cliVersion || "unknown"}`,
|
|
94
|
+
},
|
|
95
|
+
body: JSON.stringify({ source }),
|
|
117
96
|
});
|
|
118
97
|
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
const response = await fetch(`${AUDIT_URL}?${params.toString()}`, {
|
|
123
|
-
signal: controller.signal,
|
|
124
|
-
});
|
|
125
|
-
clearTimeout(timeout);
|
|
98
|
+
if (!res.ok) {
|
|
99
|
+
return null;
|
|
100
|
+
}
|
|
126
101
|
|
|
127
|
-
|
|
128
|
-
return
|
|
102
|
+
const data = (await res.json()) as { warning?: string };
|
|
103
|
+
return data.warning || null;
|
|
129
104
|
} catch {
|
|
130
105
|
return null;
|
|
131
106
|
}
|
|
132
107
|
}
|
|
133
108
|
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
109
|
+
export function getTracer(): Tracer {
|
|
110
|
+
if (!isEnabled()) {
|
|
111
|
+
return opentelemetry.trace.getTracer("adg-noop");
|
|
112
|
+
}
|
|
113
|
+
if (!activeTracer) {
|
|
114
|
+
const exporter = new OTLPTraceExporter({
|
|
115
|
+
url: TELEMETRY_URL,
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
provider = new NodeTracerProvider({
|
|
119
|
+
resource: resourceFromAttributes({
|
|
120
|
+
[SemanticResourceAttributes.SERVICE_NAME]: "adg",
|
|
121
|
+
}),
|
|
122
|
+
spanProcessors: [new SimpleSpanProcessor(exporter)],
|
|
123
|
+
});
|
|
124
|
+
|
|
125
|
+
provider.register();
|
|
126
|
+
|
|
127
|
+
activeTracer = opentelemetry.trace.getTracer("adg");
|
|
128
|
+
}
|
|
129
|
+
return activeTracer;
|
|
130
|
+
}
|
|
137
131
|
|
|
138
132
|
export function track(data: TelemetryData): void {
|
|
139
133
|
if (!isEnabled()) return;
|
|
140
134
|
|
|
141
135
|
try {
|
|
142
|
-
const
|
|
136
|
+
const tracer = getTracer();
|
|
137
|
+
const parentContext = propagation.extract(ROOT_CONTEXT, process.env);
|
|
138
|
+
const span = tracer.startSpan(`skills-${data.event}`, {}, parentContext);
|
|
143
139
|
|
|
144
|
-
//
|
|
140
|
+
// Set common attributes
|
|
141
|
+
span.setAttribute("domain", "skills");
|
|
145
142
|
if (cliVersion) {
|
|
146
|
-
|
|
143
|
+
span.setAttribute("cli.version", cliVersion);
|
|
147
144
|
}
|
|
148
|
-
|
|
149
|
-
// Add CI flag if running in CI
|
|
150
145
|
if (isCI()) {
|
|
151
|
-
|
|
146
|
+
span.setAttribute("ci", true);
|
|
152
147
|
}
|
|
153
|
-
|
|
154
|
-
// Add detected AI agent name
|
|
155
148
|
if (detectedAgentName) {
|
|
156
|
-
|
|
149
|
+
span.setAttribute("agent", detectedAgentName);
|
|
157
150
|
}
|
|
158
151
|
|
|
159
|
-
//
|
|
152
|
+
// Set event attributes
|
|
160
153
|
for (const [key, value] of Object.entries(data)) {
|
|
161
154
|
if (value !== undefined && value !== null) {
|
|
162
|
-
|
|
155
|
+
span.setAttribute(key, String(value));
|
|
163
156
|
}
|
|
164
157
|
}
|
|
165
158
|
|
|
166
|
-
|
|
167
|
-
// flushTelemetry() can await it before the process exits.
|
|
168
|
-
const p = fetch(`${TELEMETRY_URL}?${params.toString()}`)
|
|
169
|
-
.catch(() => {})
|
|
170
|
-
.then(() => {});
|
|
171
|
-
pendingTelemetry.push(p);
|
|
159
|
+
span.end();
|
|
172
160
|
} catch {
|
|
173
161
|
// Silently fail - telemetry should never break the CLI
|
|
174
162
|
}
|
|
175
163
|
}
|
|
176
164
|
|
|
177
|
-
/**
|
|
178
|
-
* Wait for all in-flight telemetry requests to settle.
|
|
179
|
-
* Called once at CLI exit so the process doesn't hang on open sockets
|
|
180
|
-
* but also doesn't drop data by exiting too early.
|
|
181
|
-
*/
|
|
182
165
|
export async function flushTelemetry(timeoutMs = 5000): Promise<void> {
|
|
183
|
-
if (
|
|
184
|
-
|
|
185
|
-
|
|
166
|
+
if (provider) {
|
|
167
|
+
const timeout = new Promise<void>((resolve) => setTimeout(resolve, timeoutMs));
|
|
168
|
+
await Promise.race([provider.shutdown(), timeout]);
|
|
169
|
+
}
|
|
186
170
|
}
|
|
@@ -17,10 +17,11 @@ import { discoverSkills } from './skills.ts';
|
|
|
17
17
|
import { fetchRepoTree, findSkillMdPaths, getSkillFolderHashFromTree } from './blob.ts';
|
|
18
18
|
import { removeCommand } from './remove.ts';
|
|
19
19
|
import { sanitizeMetadata } from './sanitize.ts';
|
|
20
|
-
import { track } from './telemetry.ts';
|
|
20
|
+
import { track, getTracer } from './telemetry.ts';
|
|
21
21
|
import { agents, isUniversalAgent } from './agents.ts';
|
|
22
22
|
import { selfCliArgv } from './self-cli.ts';
|
|
23
23
|
import type { AgentType } from './types.ts';
|
|
24
|
+
import { SpanKind, SpanStatusCode } from '@opentelemetry/api';
|
|
24
25
|
|
|
25
26
|
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
26
27
|
|
|
@@ -31,7 +32,9 @@ const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
|
31
32
|
* our actual TS entry, run via Node's type-stripping (Node >= 22.6), exactly how
|
|
32
33
|
* `adg skills` launches the CLI. See vendor/skills/PROVENANCE.md.
|
|
33
34
|
*/
|
|
34
|
-
const SELF_CLI_ENTRY = join(__dirname, '
|
|
35
|
+
const SELF_CLI_ENTRY = existsSync(join(__dirname, '../../../bin/adg.ts'))
|
|
36
|
+
? join(__dirname, '../../../bin/adg.ts')
|
|
37
|
+
: join(__dirname, '../../../dist/bin/adg.js');
|
|
35
38
|
|
|
36
39
|
const RESET = '\x1b[0m';
|
|
37
40
|
const BOLD = '\x1b[1m';
|
|
@@ -511,15 +514,47 @@ export async function updateGlobalSkills(
|
|
|
511
514
|
);
|
|
512
515
|
continue;
|
|
513
516
|
}
|
|
514
|
-
const
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
{
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
517
|
+
const tracer = getTracer();
|
|
518
|
+
const args = ['skills', 'add', installUrl, '-g', '-y'];
|
|
519
|
+
const result = tracer.startActiveSpan("adg", { kind: SpanKind.CLIENT }, (span) => {
|
|
520
|
+
try {
|
|
521
|
+
span.setAttribute("process.executable.name", "adg");
|
|
522
|
+
span.setAttribute("process.command_args", ["adg", ...args]);
|
|
523
|
+
|
|
524
|
+
const r = spawnSync(
|
|
525
|
+
process.execPath,
|
|
526
|
+
selfCliArgv(cliEntry, args),
|
|
527
|
+
{
|
|
528
|
+
stdio: ['inherit', 'pipe', 'pipe'],
|
|
529
|
+
encoding: 'utf-8',
|
|
530
|
+
shell: process.platform === 'win32',
|
|
531
|
+
}
|
|
532
|
+
);
|
|
533
|
+
|
|
534
|
+
if (r.pid !== undefined) span.setAttribute("process.pid", r.pid);
|
|
535
|
+
if (r.status !== null) {
|
|
536
|
+
span.setAttribute("process.exit.code", r.status);
|
|
537
|
+
if (r.status !== 0) {
|
|
538
|
+
span.setAttribute("error.type", `EXIT_CODE_${r.status}`);
|
|
539
|
+
span.setStatus({
|
|
540
|
+
code: SpanStatusCode.ERROR,
|
|
541
|
+
message: `Subprocess exited with status ${r.status}`,
|
|
542
|
+
});
|
|
543
|
+
}
|
|
544
|
+
} else if (r.error) {
|
|
545
|
+
span.setAttribute("process.exit.code", -1);
|
|
546
|
+
span.setAttribute("error.type", r.error.code || r.error.name || "SpawnError");
|
|
547
|
+
span.recordException(r.error);
|
|
548
|
+
span.setStatus({
|
|
549
|
+
code: SpanStatusCode.ERROR,
|
|
550
|
+
message: r.error.message,
|
|
551
|
+
});
|
|
552
|
+
}
|
|
553
|
+
return r;
|
|
554
|
+
} finally {
|
|
555
|
+
span.end();
|
|
521
556
|
}
|
|
522
|
-
);
|
|
557
|
+
});
|
|
523
558
|
|
|
524
559
|
if (result.status === 0) {
|
|
525
560
|
successCount++;
|
|
@@ -648,15 +683,47 @@ export async function updateProjectSkills(
|
|
|
648
683
|
console.log(`${TEXT}Updating ${safeName}...${RESET}`);
|
|
649
684
|
const installUrl = formatSourceInput(skill.entry.source, skill.entry.ref);
|
|
650
685
|
|
|
651
|
-
const
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
{
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
686
|
+
const tracer = getTracer();
|
|
687
|
+
const args = ['skills', 'add', installUrl, '--skill', skill.name, '-y'];
|
|
688
|
+
const result = tracer.startActiveSpan("adg", { kind: SpanKind.CLIENT }, (span) => {
|
|
689
|
+
try {
|
|
690
|
+
span.setAttribute("process.executable.name", "adg");
|
|
691
|
+
span.setAttribute("process.command_args", ["adg", ...args]);
|
|
692
|
+
|
|
693
|
+
const r = spawnSync(
|
|
694
|
+
process.execPath,
|
|
695
|
+
selfCliArgv(cliEntry, args),
|
|
696
|
+
{
|
|
697
|
+
stdio: ['inherit', 'pipe', 'pipe'],
|
|
698
|
+
encoding: 'utf-8',
|
|
699
|
+
shell: process.platform === 'win32',
|
|
700
|
+
}
|
|
701
|
+
);
|
|
702
|
+
|
|
703
|
+
if (r.pid !== undefined) span.setAttribute("process.pid", r.pid);
|
|
704
|
+
if (r.status !== null) {
|
|
705
|
+
span.setAttribute("process.exit.code", r.status);
|
|
706
|
+
if (r.status !== 0) {
|
|
707
|
+
span.setAttribute("error.type", `EXIT_CODE_${r.status}`);
|
|
708
|
+
span.setStatus({
|
|
709
|
+
code: SpanStatusCode.ERROR,
|
|
710
|
+
message: `Subprocess exited with status ${r.status}`,
|
|
711
|
+
});
|
|
712
|
+
}
|
|
713
|
+
} else if (r.error) {
|
|
714
|
+
span.setAttribute("process.exit.code", -1);
|
|
715
|
+
span.setAttribute("error.type", r.error.code || r.error.name || "SpawnError");
|
|
716
|
+
span.recordException(r.error);
|
|
717
|
+
span.setStatus({
|
|
718
|
+
code: SpanStatusCode.ERROR,
|
|
719
|
+
message: r.error.message,
|
|
720
|
+
});
|
|
721
|
+
}
|
|
722
|
+
return r;
|
|
723
|
+
} finally {
|
|
724
|
+
span.end();
|
|
658
725
|
}
|
|
659
|
-
);
|
|
726
|
+
});
|
|
660
727
|
|
|
661
728
|
if (result.status === 0) {
|
|
662
729
|
successCount++;
|