@rbbtsn0w/adg 0.6.0-beta.1 → 0.6.0-beta.11
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
|
@@ -1,478 +0,0 @@
|
|
|
1
|
-
import * as p from '@clack/prompts';
|
|
2
|
-
import pc from 'picocolors';
|
|
3
|
-
import { readdir, stat } from 'fs/promises';
|
|
4
|
-
import { join, sep } from 'path';
|
|
5
|
-
import { homedir } from 'os';
|
|
6
|
-
import { parseSkillMd } from './skills.ts';
|
|
7
|
-
import { installSkillForAgent, getCanonicalPath } from './installer.ts';
|
|
8
|
-
import {
|
|
9
|
-
detectInstalledAgents,
|
|
10
|
-
agents,
|
|
11
|
-
getUniversalAgents,
|
|
12
|
-
getVisibleUniversalAgents,
|
|
13
|
-
getNonUniversalAgents,
|
|
14
|
-
} from './agents.ts';
|
|
15
|
-
import { searchMultiselect } from './prompts/search-multiselect.ts';
|
|
16
|
-
import { addSkillToLocalLock, computeSkillFolderHash, readLocalLock } from './local-lock.ts';
|
|
17
|
-
import type { Skill, AgentType } from './types.ts';
|
|
18
|
-
import { track } from './telemetry.ts';
|
|
19
|
-
import { detectAgent, getAgentType } from './detect-agent.ts';
|
|
20
|
-
|
|
21
|
-
const isCancelled = (value: unknown): value is symbol => typeof value === 'symbol';
|
|
22
|
-
|
|
23
|
-
export interface SyncOptions {
|
|
24
|
-
agent?: string[];
|
|
25
|
-
yes?: boolean;
|
|
26
|
-
force?: boolean;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
* Shortens a path for display: replaces homedir with ~ and cwd with .
|
|
31
|
-
*/
|
|
32
|
-
function shortenPath(fullPath: string, cwd: string): string {
|
|
33
|
-
const home = homedir();
|
|
34
|
-
if (fullPath === home || fullPath.startsWith(home + sep)) {
|
|
35
|
-
return '~' + fullPath.slice(home.length);
|
|
36
|
-
}
|
|
37
|
-
if (fullPath === cwd || fullPath.startsWith(cwd + sep)) {
|
|
38
|
-
return '.' + fullPath.slice(cwd.length);
|
|
39
|
-
}
|
|
40
|
-
return fullPath;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
/**
|
|
44
|
-
* Crawl node_modules for SKILL.md files.
|
|
45
|
-
* Searches both top-level packages and scoped packages (@org/pkg).
|
|
46
|
-
* Returns discovered skills with their source package name.
|
|
47
|
-
*/
|
|
48
|
-
async function discoverNodeModuleSkills(
|
|
49
|
-
cwd: string
|
|
50
|
-
): Promise<Array<Skill & { packageName: string }>> {
|
|
51
|
-
const nodeModulesDir = join(cwd, 'node_modules');
|
|
52
|
-
const skills: Array<Skill & { packageName: string }> = [];
|
|
53
|
-
|
|
54
|
-
let topNames: string[];
|
|
55
|
-
try {
|
|
56
|
-
topNames = await readdir(nodeModulesDir);
|
|
57
|
-
} catch {
|
|
58
|
-
return skills;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
const processPackageDir = async (pkgDir: string, packageName: string) => {
|
|
62
|
-
// Check for SKILL.md at package root
|
|
63
|
-
const rootSkill = await parseSkillMd(join(pkgDir, 'SKILL.md'));
|
|
64
|
-
if (rootSkill) {
|
|
65
|
-
skills.push({ ...rootSkill, packageName });
|
|
66
|
-
return;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
// Check common skill locations within the package
|
|
70
|
-
const searchDirs = [pkgDir, join(pkgDir, 'skills'), join(pkgDir, '.agents', 'skills')];
|
|
71
|
-
|
|
72
|
-
for (const searchDir of searchDirs) {
|
|
73
|
-
try {
|
|
74
|
-
const entries = await readdir(searchDir);
|
|
75
|
-
for (const name of entries) {
|
|
76
|
-
const skillDir = join(searchDir, name);
|
|
77
|
-
try {
|
|
78
|
-
const s = await stat(skillDir);
|
|
79
|
-
if (!s.isDirectory()) continue;
|
|
80
|
-
} catch {
|
|
81
|
-
continue;
|
|
82
|
-
}
|
|
83
|
-
const skill = await parseSkillMd(join(skillDir, 'SKILL.md'));
|
|
84
|
-
if (skill) {
|
|
85
|
-
skills.push({ ...skill, packageName });
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
} catch {
|
|
89
|
-
// Directory doesn't exist
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
};
|
|
93
|
-
|
|
94
|
-
await Promise.all(
|
|
95
|
-
topNames.map(async (name) => {
|
|
96
|
-
if (name.startsWith('.')) return;
|
|
97
|
-
|
|
98
|
-
const fullPath = join(nodeModulesDir, name);
|
|
99
|
-
try {
|
|
100
|
-
const s = await stat(fullPath);
|
|
101
|
-
if (!s.isDirectory()) return;
|
|
102
|
-
} catch {
|
|
103
|
-
return;
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
if (name.startsWith('@')) {
|
|
107
|
-
// Scoped package: read @org/* entries
|
|
108
|
-
try {
|
|
109
|
-
const scopeNames = await readdir(fullPath);
|
|
110
|
-
await Promise.all(
|
|
111
|
-
scopeNames.map(async (scopedName) => {
|
|
112
|
-
const scopedPath = join(fullPath, scopedName);
|
|
113
|
-
try {
|
|
114
|
-
const s = await stat(scopedPath);
|
|
115
|
-
if (!s.isDirectory()) return;
|
|
116
|
-
} catch {
|
|
117
|
-
return;
|
|
118
|
-
}
|
|
119
|
-
await processPackageDir(scopedPath, `${name}/${scopedName}`);
|
|
120
|
-
})
|
|
121
|
-
);
|
|
122
|
-
} catch {
|
|
123
|
-
// Scope directory not readable
|
|
124
|
-
}
|
|
125
|
-
} else {
|
|
126
|
-
await processPackageDir(fullPath, name);
|
|
127
|
-
}
|
|
128
|
-
})
|
|
129
|
-
);
|
|
130
|
-
|
|
131
|
-
return skills;
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
export async function runSync(args: string[], options: SyncOptions = {}): Promise<void> {
|
|
135
|
-
const cwd = process.cwd();
|
|
136
|
-
|
|
137
|
-
// Auto-enable non-interactive mode when running inside an AI agent
|
|
138
|
-
const agentResult = await detectAgent();
|
|
139
|
-
if (agentResult.isAgent) {
|
|
140
|
-
options.yes = true;
|
|
141
|
-
if (!options.agent || options.agent.length === 0) {
|
|
142
|
-
const mappedAgent = getAgentType(agentResult.agent.name);
|
|
143
|
-
if (mappedAgent) {
|
|
144
|
-
const agentList: AgentType[] = [mappedAgent];
|
|
145
|
-
for (const ua of getUniversalAgents()) {
|
|
146
|
-
if (!agentList.includes(ua)) agentList.push(ua);
|
|
147
|
-
}
|
|
148
|
-
options.agent = agentList;
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
console.log();
|
|
154
|
-
if (!agentResult.isAgent) {
|
|
155
|
-
p.intro(pc.bgCyan(pc.black(' skills experimental_sync ')));
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
if (agentResult.isAgent) {
|
|
159
|
-
p.log.info(
|
|
160
|
-
pc.bgCyan(pc.black(pc.bold(` ${agentResult.agent.name} `))) +
|
|
161
|
-
' ' +
|
|
162
|
-
'Agent detected — installing non-interactively'
|
|
163
|
-
);
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
const spinner = p.spinner();
|
|
167
|
-
|
|
168
|
-
// 1. Discover skills from node_modules
|
|
169
|
-
spinner.start('Scanning node_modules for skills...');
|
|
170
|
-
const discoveredSkills = await discoverNodeModuleSkills(cwd);
|
|
171
|
-
|
|
172
|
-
if (discoveredSkills.length === 0) {
|
|
173
|
-
spinner.stop(pc.yellow('No skills found'));
|
|
174
|
-
p.outro(pc.dim('No SKILL.md files found in node_modules.'));
|
|
175
|
-
return;
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
spinner.stop(
|
|
179
|
-
`Found ${pc.green(String(discoveredSkills.length))} skill${discoveredSkills.length > 1 ? 's' : ''} in node_modules`
|
|
180
|
-
);
|
|
181
|
-
|
|
182
|
-
// Show discovered skills
|
|
183
|
-
for (const skill of discoveredSkills) {
|
|
184
|
-
p.log.info(`${pc.cyan(skill.name)} ${pc.dim(`from ${skill.packageName}`)}`);
|
|
185
|
-
if (skill.description) {
|
|
186
|
-
p.log.message(pc.dim(` ${skill.description}`));
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
// 2. Check which skills are already up-to-date via local lock
|
|
191
|
-
const localLock = await readLocalLock(cwd);
|
|
192
|
-
const toInstall: Array<Skill & { packageName: string }> = [];
|
|
193
|
-
const upToDate: string[] = [];
|
|
194
|
-
|
|
195
|
-
if (options.force) {
|
|
196
|
-
toInstall.push(...discoveredSkills);
|
|
197
|
-
p.log.info(pc.dim('Force mode: reinstalling all skills'));
|
|
198
|
-
} else {
|
|
199
|
-
for (const skill of discoveredSkills) {
|
|
200
|
-
const existingEntry = localLock.skills[skill.name];
|
|
201
|
-
if (existingEntry) {
|
|
202
|
-
// Compute current hash and compare
|
|
203
|
-
const currentHash = await computeSkillFolderHash(skill.path);
|
|
204
|
-
if (currentHash === existingEntry.computedHash) {
|
|
205
|
-
upToDate.push(skill.name);
|
|
206
|
-
continue;
|
|
207
|
-
}
|
|
208
|
-
}
|
|
209
|
-
toInstall.push(skill);
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
if (upToDate.length > 0) {
|
|
213
|
-
p.log.info(
|
|
214
|
-
pc.dim(`${upToDate.length} skill${upToDate.length !== 1 ? 's' : ''} already up to date`)
|
|
215
|
-
);
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
if (toInstall.length === 0) {
|
|
219
|
-
console.log();
|
|
220
|
-
p.outro(pc.green('All skills are up to date.'));
|
|
221
|
-
return;
|
|
222
|
-
}
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
p.log.info(`${toInstall.length} skill${toInstall.length !== 1 ? 's' : ''} to install/update`);
|
|
226
|
-
|
|
227
|
-
// 3. Select agents
|
|
228
|
-
let targetAgents: AgentType[];
|
|
229
|
-
const validAgents = Object.keys(agents);
|
|
230
|
-
const universalAgents = getUniversalAgents();
|
|
231
|
-
const visibleUniversalAgents = getVisibleUniversalAgents();
|
|
232
|
-
|
|
233
|
-
if (options.agent?.includes('*')) {
|
|
234
|
-
targetAgents = validAgents as AgentType[];
|
|
235
|
-
p.log.info(`Installing to all ${targetAgents.length} agents`);
|
|
236
|
-
} else if (options.agent && options.agent.length > 0) {
|
|
237
|
-
const invalidAgents = options.agent.filter((a) => !validAgents.includes(a));
|
|
238
|
-
if (invalidAgents.length > 0) {
|
|
239
|
-
p.log.error(`Invalid agents: ${invalidAgents.join(', ')}`);
|
|
240
|
-
p.log.info(`Valid agents: ${validAgents.join(', ')}`);
|
|
241
|
-
process.exit(1);
|
|
242
|
-
}
|
|
243
|
-
targetAgents = options.agent as AgentType[];
|
|
244
|
-
} else {
|
|
245
|
-
spinner.start('Loading agents...');
|
|
246
|
-
const installedAgents = await detectInstalledAgents();
|
|
247
|
-
const totalAgents = Object.keys(agents).length;
|
|
248
|
-
spinner.stop(`${totalAgents} agents`);
|
|
249
|
-
|
|
250
|
-
if (installedAgents.length === 0) {
|
|
251
|
-
if (options.yes) {
|
|
252
|
-
targetAgents = universalAgents;
|
|
253
|
-
p.log.info('Installing to universal agents');
|
|
254
|
-
} else {
|
|
255
|
-
const otherAgents = getNonUniversalAgents();
|
|
256
|
-
|
|
257
|
-
const otherChoices = otherAgents.map((a) => ({
|
|
258
|
-
value: a,
|
|
259
|
-
label: agents[a].displayName,
|
|
260
|
-
hint: agents[a].skillsDir,
|
|
261
|
-
}));
|
|
262
|
-
|
|
263
|
-
const selected = await searchMultiselect({
|
|
264
|
-
message: 'Which agents do you want to install to?',
|
|
265
|
-
items: otherChoices,
|
|
266
|
-
initialSelected: [],
|
|
267
|
-
lockedSection: {
|
|
268
|
-
title: 'Universal (.agents/skills)',
|
|
269
|
-
items: visibleUniversalAgents.map((a) => ({
|
|
270
|
-
value: a,
|
|
271
|
-
label: agents[a].displayName,
|
|
272
|
-
})),
|
|
273
|
-
hiddenCount: universalAgents.length - visibleUniversalAgents.length,
|
|
274
|
-
},
|
|
275
|
-
});
|
|
276
|
-
|
|
277
|
-
if (isCancelled(selected)) {
|
|
278
|
-
p.cancel('Sync cancelled');
|
|
279
|
-
process.exit(0);
|
|
280
|
-
}
|
|
281
|
-
|
|
282
|
-
targetAgents = selected as AgentType[];
|
|
283
|
-
}
|
|
284
|
-
} else if (installedAgents.length === 1 || options.yes) {
|
|
285
|
-
// Ensure universal agents are included
|
|
286
|
-
targetAgents = [...installedAgents];
|
|
287
|
-
for (const ua of universalAgents) {
|
|
288
|
-
if (!targetAgents.includes(ua)) {
|
|
289
|
-
targetAgents.push(ua);
|
|
290
|
-
}
|
|
291
|
-
}
|
|
292
|
-
} else {
|
|
293
|
-
const otherAgents = getNonUniversalAgents().filter((a) => installedAgents.includes(a));
|
|
294
|
-
|
|
295
|
-
const otherChoices = otherAgents.map((a) => ({
|
|
296
|
-
value: a,
|
|
297
|
-
label: agents[a].displayName,
|
|
298
|
-
hint: agents[a].skillsDir,
|
|
299
|
-
}));
|
|
300
|
-
|
|
301
|
-
const selected = await searchMultiselect({
|
|
302
|
-
message: 'Which agents do you want to install to?',
|
|
303
|
-
items: otherChoices,
|
|
304
|
-
initialSelected: installedAgents.filter((a) => !universalAgents.includes(a)),
|
|
305
|
-
lockedSection: {
|
|
306
|
-
title: 'Universal (.agents/skills)',
|
|
307
|
-
items: visibleUniversalAgents.map((a) => ({
|
|
308
|
-
value: a,
|
|
309
|
-
label: agents[a].displayName,
|
|
310
|
-
})),
|
|
311
|
-
hiddenCount: universalAgents.length - visibleUniversalAgents.length,
|
|
312
|
-
},
|
|
313
|
-
});
|
|
314
|
-
|
|
315
|
-
if (isCancelled(selected)) {
|
|
316
|
-
p.cancel('Sync cancelled');
|
|
317
|
-
process.exit(0);
|
|
318
|
-
}
|
|
319
|
-
|
|
320
|
-
targetAgents = selected as AgentType[];
|
|
321
|
-
}
|
|
322
|
-
}
|
|
323
|
-
|
|
324
|
-
// 4. Build summary
|
|
325
|
-
const summaryLines: string[] = [];
|
|
326
|
-
for (const skill of toInstall) {
|
|
327
|
-
const canonicalPath = getCanonicalPath(skill.name, { global: false });
|
|
328
|
-
const shortCanonical = shortenPath(canonicalPath, cwd);
|
|
329
|
-
summaryLines.push(`${pc.cyan(skill.name)} ${pc.dim(`← ${skill.packageName}`)}`);
|
|
330
|
-
summaryLines.push(` ${pc.dim(shortCanonical)}`);
|
|
331
|
-
}
|
|
332
|
-
|
|
333
|
-
console.log();
|
|
334
|
-
p.note(summaryLines.join('\n'), 'Sync Summary');
|
|
335
|
-
|
|
336
|
-
if (!options.yes) {
|
|
337
|
-
const confirmed = await p.confirm({ message: 'Proceed with sync?' });
|
|
338
|
-
|
|
339
|
-
if (p.isCancel(confirmed) || !confirmed) {
|
|
340
|
-
p.cancel('Sync cancelled');
|
|
341
|
-
process.exit(0);
|
|
342
|
-
}
|
|
343
|
-
}
|
|
344
|
-
|
|
345
|
-
// 5. Install skills (always project-scoped, always symlink)
|
|
346
|
-
spinner.start('Syncing skills...');
|
|
347
|
-
|
|
348
|
-
const results: Array<{
|
|
349
|
-
skill: string;
|
|
350
|
-
packageName: string;
|
|
351
|
-
agent: string;
|
|
352
|
-
success: boolean;
|
|
353
|
-
path: string;
|
|
354
|
-
canonicalPath?: string;
|
|
355
|
-
error?: string;
|
|
356
|
-
}> = [];
|
|
357
|
-
|
|
358
|
-
for (const skill of toInstall) {
|
|
359
|
-
for (const agent of targetAgents) {
|
|
360
|
-
const result = await installSkillForAgent(skill, agent, {
|
|
361
|
-
global: false,
|
|
362
|
-
cwd,
|
|
363
|
-
mode: 'symlink',
|
|
364
|
-
});
|
|
365
|
-
results.push({
|
|
366
|
-
skill: skill.name,
|
|
367
|
-
packageName: skill.packageName,
|
|
368
|
-
agent: agents[agent].displayName,
|
|
369
|
-
success: result.success,
|
|
370
|
-
path: result.path,
|
|
371
|
-
canonicalPath: result.canonicalPath,
|
|
372
|
-
error: result.error,
|
|
373
|
-
});
|
|
374
|
-
}
|
|
375
|
-
}
|
|
376
|
-
|
|
377
|
-
spinner.stop('Sync complete');
|
|
378
|
-
|
|
379
|
-
// 6. Update local lock file
|
|
380
|
-
const successful = results.filter((r) => r.success);
|
|
381
|
-
const failed = results.filter((r) => !r.success);
|
|
382
|
-
const successfulSkillNames = new Set(successful.map((r) => r.skill));
|
|
383
|
-
|
|
384
|
-
for (const skill of toInstall) {
|
|
385
|
-
if (successfulSkillNames.has(skill.name)) {
|
|
386
|
-
try {
|
|
387
|
-
const computedHash = await computeSkillFolderHash(skill.path);
|
|
388
|
-
await addSkillToLocalLock(
|
|
389
|
-
skill.name,
|
|
390
|
-
{
|
|
391
|
-
source: skill.packageName,
|
|
392
|
-
sourceType: 'node_modules',
|
|
393
|
-
computedHash,
|
|
394
|
-
},
|
|
395
|
-
cwd
|
|
396
|
-
);
|
|
397
|
-
} catch {
|
|
398
|
-
// Don't fail sync if lock file update fails
|
|
399
|
-
}
|
|
400
|
-
}
|
|
401
|
-
}
|
|
402
|
-
|
|
403
|
-
// 7. Display results
|
|
404
|
-
console.log();
|
|
405
|
-
|
|
406
|
-
if (successful.length > 0) {
|
|
407
|
-
const bySkill = new Map<string, typeof results>();
|
|
408
|
-
for (const r of successful) {
|
|
409
|
-
const skillResults = bySkill.get(r.skill) || [];
|
|
410
|
-
skillResults.push(r);
|
|
411
|
-
bySkill.set(r.skill, skillResults);
|
|
412
|
-
}
|
|
413
|
-
|
|
414
|
-
const resultLines: string[] = [];
|
|
415
|
-
for (const [skillName, skillResults] of bySkill) {
|
|
416
|
-
const firstResult = skillResults[0]!;
|
|
417
|
-
const pkg = toInstall.find((s) => s.name === skillName)?.packageName;
|
|
418
|
-
if (firstResult.canonicalPath) {
|
|
419
|
-
const shortPath = shortenPath(firstResult.canonicalPath, cwd);
|
|
420
|
-
resultLines.push(`${pc.green('✓')} ${skillName} ${pc.dim(`← ${pkg}`)}`);
|
|
421
|
-
resultLines.push(` ${pc.dim(shortPath)}`);
|
|
422
|
-
} else {
|
|
423
|
-
resultLines.push(`${pc.green('✓')} ${skillName} ${pc.dim(`← ${pkg}`)}`);
|
|
424
|
-
}
|
|
425
|
-
}
|
|
426
|
-
|
|
427
|
-
const skillCount = bySkill.size;
|
|
428
|
-
const title = pc.green(`Synced ${skillCount} skill${skillCount !== 1 ? 's' : ''}`);
|
|
429
|
-
p.note(resultLines.join('\n'), title);
|
|
430
|
-
}
|
|
431
|
-
|
|
432
|
-
if (failed.length > 0) {
|
|
433
|
-
console.log();
|
|
434
|
-
p.log.error(pc.red(`Failed to install ${failed.length}`));
|
|
435
|
-
for (const r of failed) {
|
|
436
|
-
p.log.message(` ${pc.red('✗')} ${r.skill} → ${r.agent}: ${pc.dim(r.error)}`);
|
|
437
|
-
}
|
|
438
|
-
}
|
|
439
|
-
|
|
440
|
-
// Track telemetry
|
|
441
|
-
track({
|
|
442
|
-
event: 'experimental_sync',
|
|
443
|
-
skillCount: String(toInstall.length),
|
|
444
|
-
successCount: String(successfulSkillNames.size),
|
|
445
|
-
agents: targetAgents.join(','),
|
|
446
|
-
});
|
|
447
|
-
|
|
448
|
-
console.log();
|
|
449
|
-
p.outro(
|
|
450
|
-
pc.green('Done!') + pc.dim(' Review skills before use; they run with full agent permissions.')
|
|
451
|
-
);
|
|
452
|
-
}
|
|
453
|
-
|
|
454
|
-
export function parseSyncOptions(args: string[]): { options: SyncOptions } {
|
|
455
|
-
const options: SyncOptions = {};
|
|
456
|
-
|
|
457
|
-
for (let i = 0; i < args.length; i++) {
|
|
458
|
-
const arg = args[i];
|
|
459
|
-
|
|
460
|
-
if (arg === '-y' || arg === '--yes') {
|
|
461
|
-
options.yes = true;
|
|
462
|
-
} else if (arg === '-f' || arg === '--force') {
|
|
463
|
-
options.force = true;
|
|
464
|
-
} else if (arg === '-a' || arg === '--agent') {
|
|
465
|
-
options.agent = options.agent || [];
|
|
466
|
-
i++;
|
|
467
|
-
let nextArg = args[i];
|
|
468
|
-
while (i < args.length && nextArg && !nextArg.startsWith('-')) {
|
|
469
|
-
options.agent.push(nextArg);
|
|
470
|
-
i++;
|
|
471
|
-
nextArg = args[i];
|
|
472
|
-
}
|
|
473
|
-
i--;
|
|
474
|
-
}
|
|
475
|
-
}
|
|
476
|
-
|
|
477
|
-
return { options };
|
|
478
|
-
}
|
|
@@ -1,226 +0,0 @@
|
|
|
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
|
-
function normalizeTraceEndpoint(endpoint: string): string {
|
|
14
|
-
const normalized = endpoint.replace(/\/$/, "");
|
|
15
|
-
return normalized.endsWith("/v1/traces") ? normalized : `${normalized}/v1/traces`;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
const TELEMETRY_URL =
|
|
19
|
-
process.env.OTEL_EXPORTER_OTLP_TRACES_ENDPOINT ||
|
|
20
|
-
(baseEndpoint
|
|
21
|
-
? normalizeTraceEndpoint(baseEndpoint)
|
|
22
|
-
: "https://telemetry-gateway.hamiltonsnow.workers.dev/v1/traces");
|
|
23
|
-
|
|
24
|
-
const AUDIT_URL = "https://add-skill.vercel.sh/audit";
|
|
25
|
-
|
|
26
|
-
interface InstallTelemetryData {
|
|
27
|
-
event: "install";
|
|
28
|
-
source: string;
|
|
29
|
-
skills: string;
|
|
30
|
-
agents: string;
|
|
31
|
-
global?: "1";
|
|
32
|
-
skillFiles?: string; // JSON stringified { skillName: relativePath }
|
|
33
|
-
sourceType?: string;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
interface RemoveTelemetryData {
|
|
37
|
-
event: "remove";
|
|
38
|
-
source?: string;
|
|
39
|
-
skills: string;
|
|
40
|
-
agents: string;
|
|
41
|
-
global?: "1";
|
|
42
|
-
sourceType?: string;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
interface UpdateTelemetryData {
|
|
46
|
-
event: "update";
|
|
47
|
-
scope?: string;
|
|
48
|
-
skillCount: string;
|
|
49
|
-
successCount: string;
|
|
50
|
-
failCount: string;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
interface FindTelemetryData {
|
|
54
|
-
event: "find";
|
|
55
|
-
query: string;
|
|
56
|
-
resultCount: string;
|
|
57
|
-
interactive?: "1";
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
interface SyncTelemetryData {
|
|
61
|
-
event: "experimental_sync";
|
|
62
|
-
skillCount: string;
|
|
63
|
-
successCount: string;
|
|
64
|
-
agents: string;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
type TelemetryData =
|
|
68
|
-
| InstallTelemetryData
|
|
69
|
-
| RemoveTelemetryData
|
|
70
|
-
| UpdateTelemetryData
|
|
71
|
-
| FindTelemetryData
|
|
72
|
-
| SyncTelemetryData;
|
|
73
|
-
|
|
74
|
-
let provider: NodeTracerProvider | null = null;
|
|
75
|
-
let activeTracer: Tracer | null = null;
|
|
76
|
-
let detectedAgentName: string | null = null;
|
|
77
|
-
|
|
78
|
-
export function setDetectedAgent(agentName: string | null): void {
|
|
79
|
-
detectedAgentName = agentName;
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
function isEnabled(): boolean {
|
|
83
|
-
return (
|
|
84
|
-
!process.env.DISABLE_TELEMETRY &&
|
|
85
|
-
!process.env.DO_NOT_TRACK &&
|
|
86
|
-
!process.env.NODE_TEST_CONTEXT
|
|
87
|
-
);
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
function isCI(): boolean {
|
|
91
|
-
return (
|
|
92
|
-
process.env.CI === "true" ||
|
|
93
|
-
process.env.CI === "1" ||
|
|
94
|
-
process.env.GITHUB_ACTIONS === "true" ||
|
|
95
|
-
process.env.VERCEL === "1"
|
|
96
|
-
);
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
function getCliVersion(): string | null {
|
|
100
|
-
try {
|
|
101
|
-
const self = fileURLToPath(import.meta.url);
|
|
102
|
-
const here = dirname(self);
|
|
103
|
-
// Resolve adg's top-level package.json (name "@rbbtsn0w/adg"), not the
|
|
104
|
-
// vendored skills-cli package.json. This module lives at
|
|
105
|
-
// vendor/skills/src/telemetry.ts (dev) or dist/vendor/skills/src/
|
|
106
|
-
// telemetry.js (built), so the adg root is 3 levels up for .ts, 4 for .js.
|
|
107
|
-
const up = self.endsWith(".ts")
|
|
108
|
-
? join("..", "..", "..")
|
|
109
|
-
: join("..", "..", "..", "..");
|
|
110
|
-
const pkgPath = join(here, up, "package.json");
|
|
111
|
-
if (!existsSync(pkgPath)) return null;
|
|
112
|
-
const pkg = JSON.parse(readFileSync(pkgPath, "utf-8"));
|
|
113
|
-
return pkg.version;
|
|
114
|
-
} catch {
|
|
115
|
-
return null;
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
const cliVersion = getCliVersion();
|
|
120
|
-
|
|
121
|
-
// ─── Security audit data ───
|
|
122
|
-
|
|
123
|
-
export interface PartnerAudit {
|
|
124
|
-
risk: "safe" | "low" | "medium" | "high" | "critical" | "unknown";
|
|
125
|
-
alerts?: number;
|
|
126
|
-
score?: number;
|
|
127
|
-
analyzedAt: string;
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
export type SkillAuditData = Record<string, PartnerAudit>;
|
|
131
|
-
export type AuditResponse = Record<string, SkillAuditData>;
|
|
132
|
-
|
|
133
|
-
/**
|
|
134
|
-
* Fetch security audit results for skills from the audit API.
|
|
135
|
-
* Returns null on any error or timeout — never blocks installation.
|
|
136
|
-
*/
|
|
137
|
-
export async function fetchAuditData(
|
|
138
|
-
source: string,
|
|
139
|
-
skillSlugs: string[],
|
|
140
|
-
timeoutMs = 3000
|
|
141
|
-
): Promise<AuditResponse | null> {
|
|
142
|
-
if (skillSlugs.length === 0) return null;
|
|
143
|
-
|
|
144
|
-
try {
|
|
145
|
-
const params = new URLSearchParams({
|
|
146
|
-
source,
|
|
147
|
-
skills: skillSlugs.join(","),
|
|
148
|
-
});
|
|
149
|
-
|
|
150
|
-
const controller = new AbortController();
|
|
151
|
-
const timeout = setTimeout(() => controller.abort(), timeoutMs);
|
|
152
|
-
|
|
153
|
-
const response = await fetch(`${AUDIT_URL}?${params.toString()}`, {
|
|
154
|
-
signal: controller.signal,
|
|
155
|
-
});
|
|
156
|
-
clearTimeout(timeout);
|
|
157
|
-
|
|
158
|
-
if (!response.ok) return null;
|
|
159
|
-
return (await response.json()) as AuditResponse;
|
|
160
|
-
} catch {
|
|
161
|
-
return null;
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
export function getTracer(): Tracer {
|
|
166
|
-
if (!isEnabled()) {
|
|
167
|
-
return opentelemetry.trace.getTracer("adg-noop");
|
|
168
|
-
}
|
|
169
|
-
if (!activeTracer) {
|
|
170
|
-
const exporter = new OTLPTraceExporter({
|
|
171
|
-
url: TELEMETRY_URL,
|
|
172
|
-
});
|
|
173
|
-
|
|
174
|
-
provider = new NodeTracerProvider({
|
|
175
|
-
resource: resourceFromAttributes({
|
|
176
|
-
[SemanticResourceAttributes.SERVICE_NAME]: "adg",
|
|
177
|
-
}),
|
|
178
|
-
spanProcessors: [new SimpleSpanProcessor(exporter)],
|
|
179
|
-
});
|
|
180
|
-
|
|
181
|
-
provider.register();
|
|
182
|
-
|
|
183
|
-
activeTracer = opentelemetry.trace.getTracer("adg");
|
|
184
|
-
}
|
|
185
|
-
return activeTracer;
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
export function track(data: TelemetryData): void {
|
|
189
|
-
if (!isEnabled()) return;
|
|
190
|
-
|
|
191
|
-
try {
|
|
192
|
-
const tracer = getTracer();
|
|
193
|
-
const parentContext = propagation.extract(ROOT_CONTEXT, process.env);
|
|
194
|
-
const span = tracer.startSpan(`skills-${data.event}`, {}, parentContext);
|
|
195
|
-
|
|
196
|
-
// Set common attributes
|
|
197
|
-
span.setAttribute("domain", "skills");
|
|
198
|
-
if (cliVersion) {
|
|
199
|
-
span.setAttribute("cli.version", cliVersion);
|
|
200
|
-
}
|
|
201
|
-
if (isCI()) {
|
|
202
|
-
span.setAttribute("ci", true);
|
|
203
|
-
}
|
|
204
|
-
if (detectedAgentName) {
|
|
205
|
-
span.setAttribute("agent", detectedAgentName);
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
// Set event attributes
|
|
209
|
-
for (const [key, value] of Object.entries(data)) {
|
|
210
|
-
if (value !== undefined && value !== null) {
|
|
211
|
-
span.setAttribute(key, String(value));
|
|
212
|
-
}
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
span.end();
|
|
216
|
-
} catch {
|
|
217
|
-
// Silently fail - telemetry should never break the CLI
|
|
218
|
-
}
|
|
219
|
-
}
|
|
220
|
-
|
|
221
|
-
export async function flushTelemetry(timeoutMs = 5000): Promise<void> {
|
|
222
|
-
if (provider) {
|
|
223
|
-
const timeout = new Promise<void>((resolve) => setTimeout(resolve, timeoutMs));
|
|
224
|
-
await Promise.race([provider.shutdown(), timeout]);
|
|
225
|
-
}
|
|
226
|
-
}
|