@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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rbbtsn0w/adg",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0-beta.2",
|
|
4
4
|
"description": "Agent Directory Group (ADG) toolkit — two domains: plugins and skills.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -40,6 +40,12 @@
|
|
|
40
40
|
"comment:dependencies": "Runtime deps below are required only by the vendored skills CLI (vendor/skills); ADG's own plugins code has zero runtime deps. Root is the single source of truth: each range MUST be >= the floor declared in vendor/skills/package.json, since that is the version the vendored source was authored against. `npm run check:vendor-deps` enforces this and fails on drift.",
|
|
41
41
|
"dependencies": {
|
|
42
42
|
"@clack/prompts": "^0.11.0",
|
|
43
|
+
"@opentelemetry/api": "^1.9.0",
|
|
44
|
+
"@opentelemetry/exporter-trace-otlp-http": "^0.219.0",
|
|
45
|
+
"@opentelemetry/resources": "^2.8.0",
|
|
46
|
+
"@opentelemetry/sdk-trace-base": "^2.8.0",
|
|
47
|
+
"@opentelemetry/sdk-trace-node": "^2.8.0",
|
|
48
|
+
"@opentelemetry/semantic-conventions": "^1.28.0",
|
|
43
49
|
"@vercel/detect-agent": "^1.2.3",
|
|
44
50
|
"picocolors": "^1.1.1",
|
|
45
51
|
"simple-git": "^3.36.0",
|
|
@@ -49,12 +49,13 @@ re-vendoring. Each is marked inline with an `ADG patch:` comment.
|
|
|
49
49
|
| `src/blob.ts` → `fetchRepoTree` / `fetchTreeBranch` (+ `authMayHelp` on `BranchFetchResult`) | Retry authenticated on 401/403/404, not only on a rate-limit 403 | **Private-repo bug**: GitHub returns 404 to anonymous tree requests for private repos. Upstream only fell back to a token on rate limit, so private skills sources never used the token and always "failed to fetch tree". |
|
|
50
50
|
| `src/skill-lock.ts` → `getGitHubToken` warning text | "GitHub rate limit reached" → "GitHub authentication needed" | The resolver is now also used to reach private repos, not just to recover from a rate limit. |
|
|
51
51
|
| `src/update.ts` → `updateGlobalSkills` | Track `failedSources`; stop printing "All global skills are up to date" when a source could not be checked | The swallowed private-repo failure used to be masked by a false "up to date". Now surfaced, with a hint to set `GITHUB_TOKEN` / `gh auth login`, and counted in `failCount`. |
|
|
52
|
-
| `src/update.ts` → `SELF_CLI_ENTRY` (both global + project update paths) | Re-invoke
|
|
52
|
+
| `src/update.ts` → `SELF_CLI_ENTRY` (both global + project update paths) | Re-invoke ADG binary `bin/adg.ts` / `bin/adg.js` instead of `cli.ts` / `cli.js` | Unifies execution under the main ADG product logic (`adg skills add`), keeping telemetry and wrapper context active. |
|
|
53
|
+
| `src/telemetry.ts` → `getTracer` | SERVICE_NAME `"adg-skills"` $\rightarrow$ `"adg"`, plus `domain: "skills"` span attribute and export `getTracer` | Unifies the telemetry tracking under the single complete `adg` product service name while keeping domain categorization, and allows `update.ts` to wrap subprocesses in CLIENT spans. |
|
|
53
54
|
| `src/git.ts` → `createGitClient` | Add `unsafe: { allowUnsafeFilter: true }` to `simpleGit(...)` | simple-git ≥3.36 blocks `filter.*.smudge/clean` configs (RCE vector) and fails **every** clone with "Configuring filter.smudge is not permitted without enabling allowUnsafeFilter". The configs here set the LFS filter to EMPTY (disabling it), so opting in is safe and matches their intent. |
|
|
54
55
|
| `src/git.ts` → `import simpleGit from 'simple-git'` | Default → named import `import { simpleGit } from 'simple-git'` | The default import is not callable under ADG's strict root tsconfig (NodeNext + verbatimModuleSyntax, no esModuleInterop); the named export is. Needed for `git.ts` to typecheck when a test imports it (e.g. via `use.ts`). |
|
|
55
56
|
| `src/git.ts` → `createGitClient` env | Pass env via `.env({...})` instead of as a `simpleGit(...)` constructor option | **Latent runtime bug**: simple-git's factory only reads `baseDir`/`maxConcurrentProcesses`/`config`/`trimmed`/plugins from the options object and silently drops `env`, so `GIT_TERMINAL_PROMPT`/`GIT_LFS_SKIP_SMUDGE`/`GIT_SSH_COMMAND` never reached the spawned git (it inherited the full parent env). `.env(object)` is the documented API and sets the executor env actually used at spawn. |
|
|
56
57
|
| `src/skills.ts` → `parseSkillMd` | Narrow `data.metadata` (frontmatter `unknown`) to `Record<string, unknown> \| undefined` before reading `.internal` / returning it | Behavior-preserving type fix so `skills.ts` typechecks under ADG's strict root tsconfig when reached via `use.ts`/tests. |
|
|
57
|
-
| `src/update.ts` → both `spawnSync` self-CLI re-invokes (+ new `src/self-cli.ts`) | Forward `process.execArgv`
|
|
58
|
+
| `src/update.ts` → both `spawnSync` self-CLI re-invokes (+ new `src/self-cli.ts`) | Forward `process.execArgv`, call `skills add` instead of `add`, and wrap in OpenTelemetry CLIENT spans | The child process runs `adg skills add` inside the spawned Node context, ensuring type-stripping flags inherit properly, and OTel spans capture subprocess execution metadata. |
|
|
58
59
|
| `package.json` → `@vercel/detect-agent` dependency (not a vendored-source change) | `^0.1.0` → `^1.2.3` | `src/detect-agent.ts` (upstream, unpatched) imports `AgentResult` and expects `determineAgent(): Promise<AgentResult>` (object API). The stale `0.1.0` pin only exported `determineAgent(): Promise<string \| false>` and no `AgentResult`, which broke typecheck and left `cachedResult.isAgent` always `undefined` at runtime — agent auto-detection (non-interactive mode in `add`/`sync`/`remove`/`find`/`cli`) silently never fired. The `1.x` line restores the API the fork targets, so `detect-agent.ts` needs **no** local patch. Keep this dependency on `1.x` across re-vendoring. |
|
|
59
60
|
| `src/git-tree.ts` (**new ADG file**) + `src/add.ts` clone-fallback branch | github source that falls back to a `git clone` now records the git **tree SHA** (`git rev-parse HEAD:<folder>`), not a sha256 content hash | Install and update must use ONE hash scheme per source. Update-check always uses the git tree SHA; the old clone fallback stored a sha256 content hash, so those skills were re-flagged on **every** update (a collection repo appeared to "fully update" each run). `git-tree.ts` is standalone (uses `child_process`, no simple-git) so it typechecks under ADG's strict tsconfig when a test imports it. |
|
|
60
61
|
| `src/update.ts` → `updateGlobalSkills` self-heal | A github entry whose stored hash isn't a 40-hex tree SHA (legacy clone-fallback) is normalized to the current tree SHA and NOT flagged; lock rewritten once | Heals locks written before the fix above without a version bump / lock wipe, and stops the perpetual false "update". |
|
package/vendor/skills/src/add.ts
CHANGED
|
@@ -51,7 +51,6 @@ import {
|
|
|
51
51
|
} from './agents.ts';
|
|
52
52
|
import {
|
|
53
53
|
track,
|
|
54
|
-
setVersion,
|
|
55
54
|
fetchAuditData,
|
|
56
55
|
type AuditResponse,
|
|
57
56
|
type PartnerAudit,
|
|
@@ -77,10 +76,6 @@ import {
|
|
|
77
76
|
type BlobSkill,
|
|
78
77
|
type BlobInstallResult,
|
|
79
78
|
} from './blob.ts';
|
|
80
|
-
import packageJson from '../package.json' with { type: 'json' };
|
|
81
|
-
export function initTelemetry(version: string): void {
|
|
82
|
-
setVersion(version);
|
|
83
|
-
}
|
|
84
79
|
|
|
85
80
|
// ─── Security Advisory ───
|
|
86
81
|
|
|
@@ -429,9 +424,6 @@ async function selectAgentsInteractive(options: {
|
|
|
429
424
|
return selected as AgentType[] | symbol;
|
|
430
425
|
}
|
|
431
426
|
|
|
432
|
-
const version = packageJson.version;
|
|
433
|
-
setVersion(version);
|
|
434
|
-
|
|
435
427
|
export interface AddOptions {
|
|
436
428
|
global?: boolean;
|
|
437
429
|
agent?: string[];
|
|
@@ -927,10 +919,10 @@ export async function runAdd(args: string[], options: AddOptions = {}): Promise<
|
|
|
927
919
|
);
|
|
928
920
|
console.log();
|
|
929
921
|
console.log(pc.dim(' Usage:'));
|
|
930
|
-
console.log(` ${pc.cyan('
|
|
922
|
+
console.log(` ${pc.cyan('adg skills add')} ${pc.yellow('<source>')} ${pc.dim('[options]')}`);
|
|
931
923
|
console.log();
|
|
932
924
|
console.log(pc.dim(' Example:'));
|
|
933
|
-
console.log(` ${pc.cyan('
|
|
925
|
+
console.log(` ${pc.cyan('adg skills add')} ${pc.yellow('vercel-labs/agent-skills')}`);
|
|
934
926
|
console.log();
|
|
935
927
|
process.exit(1);
|
|
936
928
|
}
|
|
@@ -1005,7 +997,7 @@ export async function runAdd(args: string[], options: AddOptions = {}): Promise<
|
|
|
1005
997
|
p.log.message(pc.yellow('Skills run with full agent permissions and could be malicious.'));
|
|
1006
998
|
console.log();
|
|
1007
999
|
p.log.message(
|
|
1008
|
-
`If you understand the risks, re-run with:\n\n ${pc.cyan(`
|
|
1000
|
+
`If you understand the risks, re-run with:\n\n ${pc.cyan(`adg skills add ${source} --dangerously-accept-openclaw-risks`)}\n`
|
|
1009
1001
|
);
|
|
1010
1002
|
p.outro(pc.red('Installation blocked'));
|
|
1011
1003
|
process.exit(1);
|
|
@@ -1934,13 +1926,13 @@ async function promptForFindSkills(
|
|
|
1934
1926
|
});
|
|
1935
1927
|
} catch {
|
|
1936
1928
|
p.log.warn('Failed to install find-skills. You can try again with:');
|
|
1937
|
-
p.log.message(pc.dim('
|
|
1929
|
+
p.log.message(pc.dim(' adg skills add vercel-labs/skills@find-skills -g -y --all'));
|
|
1938
1930
|
}
|
|
1939
1931
|
} else {
|
|
1940
1932
|
// User declined - dismiss the prompt
|
|
1941
1933
|
await dismissPrompt('findSkillsPrompt');
|
|
1942
1934
|
p.log.message(
|
|
1943
|
-
pc.dim('You can install it later with:
|
|
1935
|
+
pc.dim('You can install it later with: adg skills add vercel-labs/skills@find-skills')
|
|
1944
1936
|
);
|
|
1945
1937
|
}
|
|
1946
1938
|
} catch {
|
package/vendor/skills/src/cli.ts
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
import { writeFileSync, readFileSync, existsSync, mkdirSync } from 'fs';
|
|
4
4
|
import { basename, join, dirname } from 'path';
|
|
5
5
|
import { fileURLToPath } from 'url';
|
|
6
|
-
import { runAdd, parseAddOptions
|
|
6
|
+
import { runAdd, parseAddOptions } from './add.ts';
|
|
7
7
|
import { runFind } from './find.ts';
|
|
8
8
|
import { runInstallFromLock } from './install.ts';
|
|
9
9
|
import { runList } from './list.ts';
|
|
@@ -27,7 +27,6 @@ function getVersion(): string {
|
|
|
27
27
|
}
|
|
28
28
|
|
|
29
29
|
const VERSION = getVersion();
|
|
30
|
-
initTelemetry(VERSION);
|
|
31
30
|
|
|
32
31
|
const RESET = '\x1b[0m';
|
|
33
32
|
const BOLD = '\x1b[1m';
|
|
@@ -22,7 +22,7 @@ export async function runInstallFromLock(args: string[]): Promise<void> {
|
|
|
22
22
|
if (skillEntries.length === 0) {
|
|
23
23
|
p.log.warn('No project skills found in skills-lock.json');
|
|
24
24
|
p.log.info(
|
|
25
|
-
`Add project-level skills with ${pc.cyan('
|
|
25
|
+
`Add project-level skills with ${pc.cyan('adg skills add <package>')} (without ${pc.cyan('-g')})`
|
|
26
26
|
);
|
|
27
27
|
return;
|
|
28
28
|
}
|
|
@@ -1,33 +1,44 @@
|
|
|
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");
|
|
18
|
+
|
|
19
|
+
const AUDIT_URL = "https://add-skill.vercel.sh/audit";
|
|
3
20
|
|
|
4
21
|
interface InstallTelemetryData {
|
|
5
|
-
event:
|
|
22
|
+
event: "install";
|
|
6
23
|
source: string;
|
|
7
24
|
skills: string;
|
|
8
25
|
agents: string;
|
|
9
|
-
global?:
|
|
26
|
+
global?: "1";
|
|
10
27
|
skillFiles?: string; // JSON stringified { skillName: relativePath }
|
|
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
28
|
sourceType?: string;
|
|
18
29
|
}
|
|
19
30
|
|
|
20
31
|
interface RemoveTelemetryData {
|
|
21
|
-
event:
|
|
32
|
+
event: "remove";
|
|
22
33
|
source?: string;
|
|
23
34
|
skills: string;
|
|
24
35
|
agents: string;
|
|
25
|
-
global?:
|
|
36
|
+
global?: "1";
|
|
26
37
|
sourceType?: string;
|
|
27
38
|
}
|
|
28
39
|
|
|
29
40
|
interface UpdateTelemetryData {
|
|
30
|
-
event:
|
|
41
|
+
event: "update";
|
|
31
42
|
scope?: string;
|
|
32
43
|
skillCount: string;
|
|
33
44
|
successCount: string;
|
|
@@ -35,14 +46,14 @@ interface UpdateTelemetryData {
|
|
|
35
46
|
}
|
|
36
47
|
|
|
37
48
|
interface FindTelemetryData {
|
|
38
|
-
event:
|
|
49
|
+
event: "find";
|
|
39
50
|
query: string;
|
|
40
51
|
resultCount: string;
|
|
41
|
-
interactive?:
|
|
52
|
+
interactive?: "1";
|
|
42
53
|
}
|
|
43
54
|
|
|
44
55
|
interface SyncTelemetryData {
|
|
45
|
-
event:
|
|
56
|
+
event: "experimental_sync";
|
|
46
57
|
skillCount: string;
|
|
47
58
|
successCount: string;
|
|
48
59
|
agents: string;
|
|
@@ -55,42 +66,57 @@ type TelemetryData =
|
|
|
55
66
|
| FindTelemetryData
|
|
56
67
|
| SyncTelemetryData;
|
|
57
68
|
|
|
58
|
-
let
|
|
69
|
+
let provider: NodeTracerProvider | null = null;
|
|
70
|
+
let activeTracer: Tracer | null = null;
|
|
59
71
|
let detectedAgentName: string | null = null;
|
|
60
72
|
|
|
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
73
|
export function setDetectedAgent(agentName: string | null): void {
|
|
66
74
|
detectedAgentName = agentName;
|
|
67
75
|
}
|
|
68
76
|
|
|
69
|
-
function
|
|
70
|
-
return
|
|
71
|
-
process.env.
|
|
72
|
-
process.env.
|
|
73
|
-
process.env.
|
|
74
|
-
process.env.CIRCLECI ||
|
|
75
|
-
process.env.TRAVIS ||
|
|
76
|
-
process.env.BUILDKITE ||
|
|
77
|
-
process.env.JENKINS_URL ||
|
|
78
|
-
process.env.TEAMCITY_VERSION
|
|
77
|
+
function isEnabled(): boolean {
|
|
78
|
+
return (
|
|
79
|
+
!process.env.DISABLE_TELEMETRY &&
|
|
80
|
+
!process.env.DO_NOT_TRACK &&
|
|
81
|
+
!process.env.NODE_TEST_CONTEXT
|
|
79
82
|
);
|
|
80
83
|
}
|
|
81
84
|
|
|
82
|
-
function
|
|
83
|
-
return
|
|
85
|
+
function isCI(): boolean {
|
|
86
|
+
return (
|
|
87
|
+
process.env.CI === "true" ||
|
|
88
|
+
process.env.CI === "1" ||
|
|
89
|
+
process.env.GITHUB_ACTIONS === "true" ||
|
|
90
|
+
process.env.VERCEL === "1"
|
|
91
|
+
);
|
|
84
92
|
}
|
|
85
93
|
|
|
86
|
-
|
|
87
|
-
|
|
94
|
+
function getCliVersion(): string | null {
|
|
95
|
+
try {
|
|
96
|
+
const self = fileURLToPath(import.meta.url);
|
|
97
|
+
const here = dirname(self);
|
|
98
|
+
// Resolve adg's top-level package.json (name "@rbbtsn0w/adg"), not the
|
|
99
|
+
// vendored skills-cli package.json. This module lives at
|
|
100
|
+
// vendor/skills/src/telemetry.ts (dev) or dist/vendor/skills/src/
|
|
101
|
+
// telemetry.js (built), so the adg root is 3 levels up for .ts, 4 for .js.
|
|
102
|
+
const up = self.endsWith(".ts")
|
|
103
|
+
? join("..", "..", "..")
|
|
104
|
+
: join("..", "..", "..", "..");
|
|
105
|
+
const pkgPath = join(here, up, "package.json");
|
|
106
|
+
if (!existsSync(pkgPath)) return null;
|
|
107
|
+
const pkg = JSON.parse(readFileSync(pkgPath, "utf-8"));
|
|
108
|
+
return pkg.version;
|
|
109
|
+
} catch {
|
|
110
|
+
return null;
|
|
111
|
+
}
|
|
88
112
|
}
|
|
89
113
|
|
|
114
|
+
const cliVersion = getCliVersion();
|
|
115
|
+
|
|
90
116
|
// ─── Security audit data ───
|
|
91
117
|
|
|
92
118
|
export interface PartnerAudit {
|
|
93
|
-
risk:
|
|
119
|
+
risk: "safe" | "low" | "medium" | "high" | "critical" | "unknown";
|
|
94
120
|
alerts?: number;
|
|
95
121
|
score?: number;
|
|
96
122
|
analyzedAt: string;
|
|
@@ -113,7 +139,7 @@ export async function fetchAuditData(
|
|
|
113
139
|
try {
|
|
114
140
|
const params = new URLSearchParams({
|
|
115
141
|
source,
|
|
116
|
-
skills: skillSlugs.join(
|
|
142
|
+
skills: skillSlugs.join(","),
|
|
117
143
|
});
|
|
118
144
|
|
|
119
145
|
const controller = new AbortController();
|
|
@@ -131,56 +157,65 @@ export async function fetchAuditData(
|
|
|
131
157
|
}
|
|
132
158
|
}
|
|
133
159
|
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
160
|
+
export function getTracer(): Tracer {
|
|
161
|
+
if (!isEnabled()) {
|
|
162
|
+
return opentelemetry.trace.getTracer("adg-noop");
|
|
163
|
+
}
|
|
164
|
+
if (!activeTracer) {
|
|
165
|
+
const exporter = new OTLPTraceExporter({
|
|
166
|
+
url: TELEMETRY_URL,
|
|
167
|
+
});
|
|
168
|
+
|
|
169
|
+
provider = new NodeTracerProvider({
|
|
170
|
+
resource: resourceFromAttributes({
|
|
171
|
+
[SemanticResourceAttributes.SERVICE_NAME]: "adg",
|
|
172
|
+
}),
|
|
173
|
+
spanProcessors: [new SimpleSpanProcessor(exporter)],
|
|
174
|
+
});
|
|
175
|
+
|
|
176
|
+
provider.register();
|
|
177
|
+
|
|
178
|
+
activeTracer = opentelemetry.trace.getTracer("adg");
|
|
179
|
+
}
|
|
180
|
+
return activeTracer;
|
|
181
|
+
}
|
|
137
182
|
|
|
138
183
|
export function track(data: TelemetryData): void {
|
|
139
184
|
if (!isEnabled()) return;
|
|
140
185
|
|
|
141
186
|
try {
|
|
142
|
-
const
|
|
187
|
+
const tracer = getTracer();
|
|
188
|
+
const parentContext = propagation.extract(ROOT_CONTEXT, process.env);
|
|
189
|
+
const span = tracer.startSpan(`skills-${data.event}`, {}, parentContext);
|
|
143
190
|
|
|
144
|
-
//
|
|
191
|
+
// Set common attributes
|
|
192
|
+
span.setAttribute("domain", "skills");
|
|
145
193
|
if (cliVersion) {
|
|
146
|
-
|
|
194
|
+
span.setAttribute("cli.version", cliVersion);
|
|
147
195
|
}
|
|
148
|
-
|
|
149
|
-
// Add CI flag if running in CI
|
|
150
196
|
if (isCI()) {
|
|
151
|
-
|
|
197
|
+
span.setAttribute("ci", true);
|
|
152
198
|
}
|
|
153
|
-
|
|
154
|
-
// Add detected AI agent name
|
|
155
199
|
if (detectedAgentName) {
|
|
156
|
-
|
|
200
|
+
span.setAttribute("agent", detectedAgentName);
|
|
157
201
|
}
|
|
158
202
|
|
|
159
|
-
//
|
|
203
|
+
// Set event attributes
|
|
160
204
|
for (const [key, value] of Object.entries(data)) {
|
|
161
205
|
if (value !== undefined && value !== null) {
|
|
162
|
-
|
|
206
|
+
span.setAttribute(key, String(value));
|
|
163
207
|
}
|
|
164
208
|
}
|
|
165
209
|
|
|
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);
|
|
210
|
+
span.end();
|
|
172
211
|
} catch {
|
|
173
212
|
// Silently fail - telemetry should never break the CLI
|
|
174
213
|
}
|
|
175
214
|
}
|
|
176
215
|
|
|
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
216
|
export async function flushTelemetry(timeoutMs = 5000): Promise<void> {
|
|
183
|
-
if (
|
|
184
|
-
|
|
185
|
-
|
|
217
|
+
if (provider) {
|
|
218
|
+
const timeout = new Promise<void>((resolve) => setTimeout(resolve, timeoutMs));
|
|
219
|
+
await Promise.race([provider.shutdown(), timeout]);
|
|
220
|
+
}
|
|
186
221
|
}
|
|
@@ -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';
|
|
@@ -227,7 +230,7 @@ export function printSkippedSkills(skipped: SkippedSkill[]): void {
|
|
|
227
230
|
const names = skills.map((s) => sanitizeMetadata(s.name)).join(', ');
|
|
228
231
|
console.log(` ${TEXT}•${RESET} ${names} ${DIM}(${reason})${RESET}`);
|
|
229
232
|
}
|
|
230
|
-
console.log(` ${DIM}To update: ${TEXT}
|
|
233
|
+
console.log(` ${DIM}To update: ${TEXT}adg skills add ${source} -g -y${RESET}`);
|
|
231
234
|
}
|
|
232
235
|
}
|
|
233
236
|
|
|
@@ -302,7 +305,7 @@ export async function updateGlobalSkills(
|
|
|
302
305
|
if (skillNames.length === 0) {
|
|
303
306
|
if (!options.skills) {
|
|
304
307
|
console.log(`${DIM}No global skills tracked in lock file.${RESET}`);
|
|
305
|
-
console.log(`${DIM}Install skills with${RESET} ${TEXT}
|
|
308
|
+
console.log(`${DIM}Install skills with${RESET} ${TEXT}adg skills add <package> -g${RESET}`);
|
|
306
309
|
}
|
|
307
310
|
return { successCount, failCount, checkedCount: 0 };
|
|
308
311
|
}
|
|
@@ -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 as NodeJS.ErrnoException).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++;
|
|
@@ -545,7 +580,7 @@ export async function updateProjectSkills(
|
|
|
545
580
|
if (!options.skills) {
|
|
546
581
|
console.log(`${DIM}No project skills to update.${RESET}`);
|
|
547
582
|
console.log(
|
|
548
|
-
`${DIM}Install project skills with${RESET} ${TEXT}
|
|
583
|
+
`${DIM}Install project skills with${RESET} ${TEXT}adg skills add <package>${RESET}`
|
|
549
584
|
);
|
|
550
585
|
}
|
|
551
586
|
return { successCount, failCount, foundCount: 0 };
|
|
@@ -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 as NodeJS.ErrnoException).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++;
|
|
@@ -683,7 +750,7 @@ export function printLegacyProjectSkills(
|
|
|
683
750
|
for (const skill of legacy) {
|
|
684
751
|
const reinstall = formatSourceInput(skill.entry.source, skill.entry.ref);
|
|
685
752
|
console.log(` ${TEXT}•${RESET} ${sanitizeMetadata(skill.name)}`);
|
|
686
|
-
console.log(` ${DIM}To refresh: ${TEXT}
|
|
753
|
+
console.log(` ${DIM}To refresh: ${TEXT}adg skills add ${reinstall} -y${RESET}`);
|
|
687
754
|
}
|
|
688
755
|
}
|
|
689
756
|
|