@rbbtsn0w/adg 0.5.0-beta.1 → 0.5.0-beta.3
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 +1 -0
- package/dist/src/adapters/antigravity-hooks.js +24 -9
- package/dist/vendor/skills/src/add.js +205 -36
- package/dist/vendor/skills/src/agents.js +49 -1
- package/dist/vendor/skills/src/blob.js +20 -2
- package/dist/vendor/skills/src/cli.js +6 -2
- package/dist/vendor/skills/src/find.js +62 -12
- package/dist/vendor/skills/src/install.js +1 -1
- package/dist/vendor/skills/src/installer.js +173 -30
- package/dist/vendor/skills/src/remove.js +12 -2
- package/dist/vendor/skills/src/telemetry.js +25 -14
- package/dist/vendor/skills/src/update.js +10 -5
- package/package.json +1 -1
- package/vendor/skills/PROVENANCE.md +25 -3
- package/vendor/skills/package.json +2 -1
- package/vendor/skills/src/add.ts +252 -38
- package/vendor/skills/src/agents.ts +57 -1
- package/vendor/skills/src/blob.ts +23 -2
- package/vendor/skills/src/cli.ts +6 -2
- package/vendor/skills/src/find.ts +74 -12
- package/vendor/skills/src/install.ts +1 -1
- package/vendor/skills/src/installer.ts +247 -37
- package/vendor/skills/src/local-lock.ts +7 -0
- package/vendor/skills/src/remove.ts +12 -1
- package/vendor/skills/src/telemetry.ts +76 -25
- package/vendor/skills/src/types.ts +1 -0
- package/vendor/skills/src/update.ts +12 -7
- package/dist/vendor/skills/package.json +0 -143
|
@@ -22,10 +22,52 @@ function formatInstalls(count) {
|
|
|
22
22
|
return `${(count / 1_000).toFixed(1).replace(/\.0$/, '')}K installs`;
|
|
23
23
|
return `${count} install${count === 1 ? '' : 's'}`;
|
|
24
24
|
}
|
|
25
|
+
const GITHUB_OWNER_PATTERN = /^[a-z0-9](?:[a-z0-9-]{0,38})$/i;
|
|
26
|
+
export function parseFindOptions(args) {
|
|
27
|
+
const queryParts = [];
|
|
28
|
+
const options = {};
|
|
29
|
+
const errors = [];
|
|
30
|
+
for (let i = 0; i < args.length; i++) {
|
|
31
|
+
const arg = args[i];
|
|
32
|
+
if (!arg)
|
|
33
|
+
continue;
|
|
34
|
+
let ownerValue;
|
|
35
|
+
if (arg === '--owner') {
|
|
36
|
+
const value = args[i + 1];
|
|
37
|
+
if (!value || value.startsWith('-')) {
|
|
38
|
+
errors.push('--owner requires a GitHub owner');
|
|
39
|
+
continue;
|
|
40
|
+
}
|
|
41
|
+
ownerValue = value;
|
|
42
|
+
i++;
|
|
43
|
+
}
|
|
44
|
+
else if (arg.startsWith('--owner=')) {
|
|
45
|
+
ownerValue = arg.slice('--owner='.length);
|
|
46
|
+
if (!ownerValue) {
|
|
47
|
+
errors.push('--owner requires a GitHub owner');
|
|
48
|
+
continue;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
else {
|
|
52
|
+
queryParts.push(arg);
|
|
53
|
+
continue;
|
|
54
|
+
}
|
|
55
|
+
const owner = ownerValue.trim().toLowerCase();
|
|
56
|
+
if (!GITHUB_OWNER_PATTERN.test(owner)) {
|
|
57
|
+
errors.push('--owner must be a valid GitHub owner');
|
|
58
|
+
continue;
|
|
59
|
+
}
|
|
60
|
+
options.owner = owner;
|
|
61
|
+
}
|
|
62
|
+
return { query: queryParts.join(' '), options, errors };
|
|
63
|
+
}
|
|
25
64
|
// Search via API
|
|
26
|
-
export async function searchSkillsAPI(query) {
|
|
65
|
+
export async function searchSkillsAPI(query, owner) {
|
|
27
66
|
try {
|
|
28
|
-
const
|
|
67
|
+
const params = new URLSearchParams({ q: query, limit: '10' });
|
|
68
|
+
if (owner)
|
|
69
|
+
params.set('owner', owner);
|
|
70
|
+
const url = `${SEARCH_API_BASE}/api/search?${params.toString()}`;
|
|
29
71
|
const res = await fetch(url);
|
|
30
72
|
if (!res.ok)
|
|
31
73
|
return [];
|
|
@@ -50,7 +92,7 @@ const CLEAR_DOWN = '\x1b[J';
|
|
|
50
92
|
const MOVE_UP = (n) => `\x1b[${n}A`;
|
|
51
93
|
const MOVE_TO_COL = (n) => `\x1b[${n}G`;
|
|
52
94
|
// Custom fzf-style search prompt using raw readline
|
|
53
|
-
async function runSearchPrompt(initialQuery = '') {
|
|
95
|
+
async function runSearchPrompt(initialQuery = '', owner) {
|
|
54
96
|
let results = [];
|
|
55
97
|
let selectedIndex = 0;
|
|
56
98
|
let query = initialQuery;
|
|
@@ -134,7 +176,7 @@ async function runSearchPrompt(initialQuery = '') {
|
|
|
134
176
|
const debounceMs = Math.max(150, 350 - q.length * 50);
|
|
135
177
|
debounceTimer = setTimeout(async () => {
|
|
136
178
|
try {
|
|
137
|
-
results = await searchSkillsAPI(q);
|
|
179
|
+
results = await searchSkillsAPI(q, owner);
|
|
138
180
|
selectedIndex = 0;
|
|
139
181
|
}
|
|
140
182
|
catch {
|
|
@@ -224,14 +266,21 @@ async function isRepoPublic(owner, repo) {
|
|
|
224
266
|
return isPrivate === false;
|
|
225
267
|
}
|
|
226
268
|
export async function runFind(args) {
|
|
227
|
-
const query = args
|
|
269
|
+
const { query, options: findOptions, errors } = parseFindOptions(args);
|
|
270
|
+
const owner = findOptions.owner;
|
|
228
271
|
const isNonInteractive = !process.stdin.isTTY;
|
|
229
272
|
const agentTip = `${DIM}Tip: if running in a coding agent, follow these steps:${RESET}
|
|
230
|
-
${DIM} 1) npx skills find [query]${RESET}
|
|
273
|
+
${DIM} 1) npx skills find [query] [--owner <owner>]${RESET}
|
|
231
274
|
${DIM} 2) npx skills add <owner/repo@skill>${RESET}`;
|
|
275
|
+
if (errors.length > 0) {
|
|
276
|
+
for (const error of errors)
|
|
277
|
+
console.error(error);
|
|
278
|
+
console.error('Usage: npx skills find <query> [--owner <owner>]');
|
|
279
|
+
return;
|
|
280
|
+
}
|
|
232
281
|
// Non-interactive mode: just print results and exit
|
|
233
282
|
if (query) {
|
|
234
|
-
const results = await searchSkillsAPI(query);
|
|
283
|
+
const results = await searchSkillsAPI(query, owner);
|
|
235
284
|
// Track telemetry for non-interactive search
|
|
236
285
|
track({
|
|
237
286
|
event: 'find',
|
|
@@ -239,7 +288,8 @@ ${DIM} 2) npx skills add <owner/repo@skill>${RESET}`;
|
|
|
239
288
|
resultCount: String(results.length),
|
|
240
289
|
});
|
|
241
290
|
if (results.length === 0) {
|
|
242
|
-
|
|
291
|
+
const ownerSuffix = owner ? ` from owner "${owner}"` : '';
|
|
292
|
+
console.log(`${DIM}No skills found for "${query}"${ownerSuffix}${RESET}`);
|
|
243
293
|
return;
|
|
244
294
|
}
|
|
245
295
|
console.log(`${DIM}Install with${RESET} npx skills add <owner/repo@skill>`);
|
|
@@ -257,10 +307,10 @@ ${DIM} 2) npx skills add <owner/repo@skill>${RESET}`;
|
|
|
257
307
|
if (isNonInteractive || (await isRunningInAgent())) {
|
|
258
308
|
console.log(agentTip);
|
|
259
309
|
console.log();
|
|
260
|
-
console.log(`${DIM}Usage: npx skills find <query
|
|
310
|
+
console.log(`${DIM}Usage: npx skills find <query> [--owner <owner>]${RESET}`);
|
|
261
311
|
return;
|
|
262
312
|
}
|
|
263
|
-
const selected = await runSearchPrompt();
|
|
313
|
+
const selected = await runSearchPrompt('', owner);
|
|
264
314
|
// Track telemetry for interactive search
|
|
265
315
|
track({
|
|
266
316
|
event: 'find',
|
|
@@ -280,8 +330,8 @@ ${DIM} 2) npx skills add <owner/repo@skill>${RESET}`;
|
|
|
280
330
|
console.log(`${TEXT}Installing ${BOLD}${skillName}${RESET} from ${DIM}${pkg}${RESET}...`);
|
|
281
331
|
console.log();
|
|
282
332
|
// Run add directly since we're in the same CLI
|
|
283
|
-
const { source, options } = parseAddOptions([pkg, '--skill', skillName]);
|
|
284
|
-
await runAdd(source,
|
|
333
|
+
const { source, options: addOptions } = parseAddOptions([pkg, '--skill', skillName]);
|
|
334
|
+
await runAdd(source, addOptions);
|
|
285
335
|
console.log();
|
|
286
336
|
const info = getOwnerRepoFromString(pkg);
|
|
287
337
|
if (info && (await isRepoPublic(info.owner, info.repo))) {
|
|
@@ -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,9 +1,10 @@
|
|
|
1
|
-
import { mkdir, cp, access, readdir, symlink, lstat, rm, readlink, writeFile, stat, realpath, } from 'fs/promises';
|
|
1
|
+
import { mkdir, cp, access, readdir, symlink, lstat, rm, readlink, readFile, writeFile, stat, realpath, } from 'fs/promises';
|
|
2
2
|
import { existsSync } from 'fs';
|
|
3
|
-
import { join, basename, normalize, resolve, sep, relative, dirname } from 'path';
|
|
3
|
+
import { join, basename, normalize, resolve, sep, relative, dirname, extname } from 'path';
|
|
4
4
|
import { homedir, platform } from 'os';
|
|
5
|
-
import { agents, detectInstalledAgents, isUniversalAgent } from "./agents.js";
|
|
5
|
+
import { agents, detectInstalledAgents, isUniversalAgent, getEveSubagents, EVE_SUBAGENTS_DIR, } from "./agents.js";
|
|
6
6
|
import { AGENTS_DIR, SKILLS_SUBDIR } from "./constants.js";
|
|
7
|
+
import { parseFrontmatter } from "./frontmatter.js";
|
|
7
8
|
import { parseSkillMd } from "./skills.js";
|
|
8
9
|
/**
|
|
9
10
|
* Sanitizes a filename/directory name to prevent path traversal attacks
|
|
@@ -37,6 +38,9 @@ function isPathSafe(basePath, targetPath) {
|
|
|
37
38
|
const normalizedTarget = normalize(resolve(targetPath));
|
|
38
39
|
return normalizedTarget.startsWith(normalizedBase + sep) || normalizedTarget === normalizedBase;
|
|
39
40
|
}
|
|
41
|
+
function pathsOverlap(pathA, pathB) {
|
|
42
|
+
return isPathSafe(pathA, pathB) || isPathSafe(pathB, pathA);
|
|
43
|
+
}
|
|
40
44
|
// Dirent.isDirectory() is false for symlinks; follow and verify the target is a directory.
|
|
41
45
|
async function isDirEntryOrSymlinkToDir(entry, entryPath) {
|
|
42
46
|
if (entry.isDirectory())
|
|
@@ -54,15 +58,32 @@ export function getCanonicalSkillsDir(global, cwd) {
|
|
|
54
58
|
const baseDir = global ? homedir() : cwd || process.cwd();
|
|
55
59
|
return join(baseDir, AGENTS_DIR, SKILLS_SUBDIR);
|
|
56
60
|
}
|
|
61
|
+
/**
|
|
62
|
+
* Resolve the skills directory for a specific Eve subagent, relative to the
|
|
63
|
+
* project root: `agent/subagents/<name>/skills`. The subagent name is
|
|
64
|
+
* sanitized to prevent directory traversal when it originates from user input.
|
|
65
|
+
*/
|
|
66
|
+
export function getEveSubagentSkillsDir(subagent, cwd) {
|
|
67
|
+
const baseDir = cwd || process.cwd();
|
|
68
|
+
return join(baseDir, EVE_SUBAGENTS_DIR, sanitizeName(subagent), 'skills');
|
|
69
|
+
}
|
|
57
70
|
/**
|
|
58
71
|
* Gets the base directory for an agent's skills, respecting universal agents.
|
|
59
72
|
* Universal agents always use the canonical directory, which prevents
|
|
60
73
|
* redundant symlinks and double-listing of skills.
|
|
74
|
+
*
|
|
75
|
+
* For Eve, an optional `eveSubagent` targets a subagent's skills directory
|
|
76
|
+
* (`agent/subagents/<name>/skills`) instead of the root agent's `agent/skills`.
|
|
61
77
|
*/
|
|
62
|
-
export function getAgentBaseDir(agentType, global, cwd) {
|
|
78
|
+
export function getAgentBaseDir(agentType, global, cwd, eveSubagent) {
|
|
63
79
|
if (isUniversalAgent(agentType)) {
|
|
64
80
|
return getCanonicalSkillsDir(global, cwd);
|
|
65
81
|
}
|
|
82
|
+
// Eve subagents are inherently project-scoped — they live under the project's
|
|
83
|
+
// agent/ directory, so the `global` flag does not apply here.
|
|
84
|
+
if (agentType === 'eve' && eveSubagent) {
|
|
85
|
+
return getEveSubagentSkillsDir(eveSubagent, cwd);
|
|
86
|
+
}
|
|
66
87
|
const agent = agents[agentType];
|
|
67
88
|
const baseDir = global ? homedir() : cwd || process.cwd();
|
|
68
89
|
if (global) {
|
|
@@ -174,7 +195,8 @@ async function createSymlink(target, linkPath) {
|
|
|
174
195
|
const realLinkDir = await resolveParentSymlinks(linkDir);
|
|
175
196
|
const relativePath = relative(realLinkDir, target);
|
|
176
197
|
const symlinkType = platform() === 'win32' ? 'junction' : undefined;
|
|
177
|
-
|
|
198
|
+
const symlinkTarget = symlinkType === 'junction' ? resolvedTarget : relativePath;
|
|
199
|
+
await symlink(symlinkTarget, linkPath, symlinkType);
|
|
178
200
|
return true;
|
|
179
201
|
}
|
|
180
202
|
catch {
|
|
@@ -185,6 +207,7 @@ export async function installSkillForAgent(skill, agentType, options = {}) {
|
|
|
185
207
|
const agent = agents[agentType];
|
|
186
208
|
const isGlobal = options.global ?? false;
|
|
187
209
|
const cwd = options.cwd || process.cwd();
|
|
210
|
+
const eveSubagent = options.eveSubagent;
|
|
188
211
|
// Check if agent supports global installation
|
|
189
212
|
if (isGlobal && agent.globalSkillsDir === undefined) {
|
|
190
213
|
return {
|
|
@@ -197,13 +220,15 @@ export async function installSkillForAgent(skill, agentType, options = {}) {
|
|
|
197
220
|
// Sanitize skill name to prevent directory traversal
|
|
198
221
|
const rawSkillName = skill.name || basename(skill.path);
|
|
199
222
|
const skillName = sanitizeName(rawSkillName);
|
|
223
|
+
const installMode = options.mode ?? 'symlink';
|
|
200
224
|
// Canonical location: .agents/skills/<skill-name>
|
|
201
|
-
const canonicalBase =
|
|
225
|
+
const canonicalBase = agentType === 'eve' && installMode === 'symlink'
|
|
226
|
+
? getAgentBaseDir(agentType, isGlobal, cwd, eveSubagent)
|
|
227
|
+
: getCanonicalSkillsDir(isGlobal, cwd);
|
|
202
228
|
const canonicalDir = join(canonicalBase, skillName);
|
|
203
229
|
// Agent-specific location (for symlink)
|
|
204
|
-
const agentBase = getAgentBaseDir(agentType, isGlobal, cwd);
|
|
230
|
+
const agentBase = getAgentBaseDir(agentType, isGlobal, cwd, eveSubagent);
|
|
205
231
|
const agentDir = join(agentBase, skillName);
|
|
206
|
-
const installMode = options.mode ?? 'symlink';
|
|
207
232
|
// Validate paths
|
|
208
233
|
if (!isPathSafe(canonicalBase, canonicalDir)) {
|
|
209
234
|
return {
|
|
@@ -222,19 +247,41 @@ export async function installSkillForAgent(skill, agentType, options = {}) {
|
|
|
222
247
|
};
|
|
223
248
|
}
|
|
224
249
|
try {
|
|
250
|
+
// Never install onto (or inside) the source directory. This can happen with
|
|
251
|
+
// agent-specific project directories like OpenClaw's "skills" when users run
|
|
252
|
+
// `skills add ./skills --all`: the source `./skills/<name>` and destination
|
|
253
|
+
// `./skills/<name>` are the same path. Cleaning the destination would delete
|
|
254
|
+
// the user's source skill before we can link or copy it.
|
|
255
|
+
if (pathsOverlap(skill.path, agentDir)) {
|
|
256
|
+
return {
|
|
257
|
+
success: true,
|
|
258
|
+
path: agentDir,
|
|
259
|
+
mode: installMode,
|
|
260
|
+
skipped: true,
|
|
261
|
+
};
|
|
262
|
+
}
|
|
225
263
|
// For copy mode, skip canonical directory and copy directly to agent location
|
|
226
264
|
if (installMode === 'copy') {
|
|
227
265
|
await cleanAndCreateDirectory(agentDir);
|
|
228
|
-
await copyDirectory(skill.path, agentDir);
|
|
266
|
+
await copyDirectory(skill.path, agentDir, agentType);
|
|
229
267
|
return {
|
|
230
268
|
success: true,
|
|
231
269
|
path: agentDir,
|
|
232
270
|
mode: 'copy',
|
|
233
271
|
};
|
|
234
272
|
}
|
|
273
|
+
if (pathsOverlap(skill.path, canonicalDir)) {
|
|
274
|
+
return {
|
|
275
|
+
success: true,
|
|
276
|
+
path: canonicalDir,
|
|
277
|
+
canonicalPath: canonicalDir,
|
|
278
|
+
mode: 'symlink',
|
|
279
|
+
skipped: true,
|
|
280
|
+
};
|
|
281
|
+
}
|
|
235
282
|
// Symlink mode: copy to canonical location and symlink to agent location
|
|
236
283
|
await cleanAndCreateDirectory(canonicalDir);
|
|
237
|
-
await copyDirectory(skill.path, canonicalDir);
|
|
284
|
+
await copyDirectory(skill.path, canonicalDir, agentType);
|
|
238
285
|
// For universal agents with global install, the skill is already in the canonical
|
|
239
286
|
// ~/.agents/skills directory. Skip creating a symlink to the agent-specific global dir
|
|
240
287
|
// (e.g. ~/.copilot/skills) to avoid duplicates.
|
|
@@ -266,7 +313,7 @@ export async function installSkillForAgent(skill, agentType, options = {}) {
|
|
|
266
313
|
if (!symlinkCreated) {
|
|
267
314
|
// Symlink failed, fall back to copy
|
|
268
315
|
await cleanAndCreateDirectory(agentDir);
|
|
269
|
-
await copyDirectory(skill.path, agentDir);
|
|
316
|
+
await copyDirectory(skill.path, agentDir, agentType);
|
|
270
317
|
return {
|
|
271
318
|
success: true,
|
|
272
319
|
path: agentDir,
|
|
@@ -300,7 +347,29 @@ const isExcluded = (name, isDirectory = false) => {
|
|
|
300
347
|
return true;
|
|
301
348
|
return false;
|
|
302
349
|
};
|
|
303
|
-
|
|
350
|
+
function stripIgnoredEveFrontmatter(raw) {
|
|
351
|
+
const { data, content } = parseFrontmatter(raw);
|
|
352
|
+
const eveData = {};
|
|
353
|
+
if (typeof data.description === 'string') {
|
|
354
|
+
eveData.description = data.description;
|
|
355
|
+
}
|
|
356
|
+
if (typeof data.license === 'string') {
|
|
357
|
+
eveData.license = data.license;
|
|
358
|
+
}
|
|
359
|
+
if (data.metadata && typeof data.metadata === 'object' && !Array.isArray(data.metadata)) {
|
|
360
|
+
const metadata = Object.fromEntries(Object.entries(data.metadata).filter((entry) => typeof entry[1] === 'string'));
|
|
361
|
+
if (Object.keys(metadata).length > 0) {
|
|
362
|
+
eveData.metadata = metadata;
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
const keys = Object.keys(eveData);
|
|
366
|
+
if (keys.length === 0) {
|
|
367
|
+
return content.replace(/^\r?\n/u, '');
|
|
368
|
+
}
|
|
369
|
+
const frontmatter = keys.map((key) => `${key}: ${JSON.stringify(eveData[key])}`).join('\n');
|
|
370
|
+
return `---\n${frontmatter}\n---\n${content.replace(/^\r?\n/u, '')}`;
|
|
371
|
+
}
|
|
372
|
+
async function copyDirectory(src, dest, agentType) {
|
|
304
373
|
await mkdir(dest, { recursive: true });
|
|
305
374
|
const entries = await readdir(src, { withFileTypes: true });
|
|
306
375
|
// Copy files and directories in parallel
|
|
@@ -310,10 +379,14 @@ async function copyDirectory(src, dest) {
|
|
|
310
379
|
const srcPath = join(src, entry.name);
|
|
311
380
|
const destPath = join(dest, entry.name);
|
|
312
381
|
if (entry.isDirectory()) {
|
|
313
|
-
await copyDirectory(srcPath, destPath);
|
|
382
|
+
await copyDirectory(srcPath, destPath, agentType);
|
|
314
383
|
}
|
|
315
384
|
else {
|
|
316
385
|
try {
|
|
386
|
+
if (agentType === 'eve' && entry.name.toLowerCase() === 'skill.md') {
|
|
387
|
+
await writeFile(destPath, stripIgnoredEveFrontmatter(await readFile(srcPath, 'utf-8')));
|
|
388
|
+
return;
|
|
389
|
+
}
|
|
317
390
|
await cp(srcPath, destPath, {
|
|
318
391
|
// If the file is a symlink to elsewhere in a remote skill, it may not
|
|
319
392
|
// resolve correctly once it has been copied to the local location.
|
|
@@ -339,6 +412,19 @@ async function copyDirectory(src, dest) {
|
|
|
339
412
|
}
|
|
340
413
|
}));
|
|
341
414
|
}
|
|
415
|
+
function isEvePackagedSkill(files) {
|
|
416
|
+
return files.some((file) => basename(file.path).toLowerCase() === 'skill.md');
|
|
417
|
+
}
|
|
418
|
+
function toEveFlatSkillFileName(installName) {
|
|
419
|
+
return `${sanitizeName(installName)}.md`;
|
|
420
|
+
}
|
|
421
|
+
function getEveFlatSkillMarkdown(files) {
|
|
422
|
+
const skillFile = files.find((file) => basename(file.path).toLowerCase() === 'skill.md');
|
|
423
|
+
if (skillFile)
|
|
424
|
+
return stripIgnoredEveFrontmatter(skillFile.contents);
|
|
425
|
+
const markdownFile = files.find((file) => extname(file.path).toLowerCase() === '.md');
|
|
426
|
+
return markdownFile ? stripIgnoredEveFrontmatter(markdownFile.contents) : '';
|
|
427
|
+
}
|
|
342
428
|
export async function isSkillInstalled(skillName, agentType, options = {}) {
|
|
343
429
|
const agent = agents[agentType];
|
|
344
430
|
const sanitized = sanitizeName(skillName);
|
|
@@ -348,7 +434,9 @@ export async function isSkillInstalled(skillName, agentType, options = {}) {
|
|
|
348
434
|
}
|
|
349
435
|
const targetBase = options.global
|
|
350
436
|
? agent.globalSkillsDir
|
|
351
|
-
:
|
|
437
|
+
: agentType === 'eve' && options.eveSubagent
|
|
438
|
+
? getEveSubagentSkillsDir(options.eveSubagent, options.cwd)
|
|
439
|
+
: join(options.cwd || process.cwd(), agent.skillsDir);
|
|
352
440
|
const skillDir = join(targetBase, sanitized);
|
|
353
441
|
if (!isPathSafe(targetBase, skillDir)) {
|
|
354
442
|
return false;
|
|
@@ -365,7 +453,7 @@ export function getInstallPath(skillName, agentType, options = {}) {
|
|
|
365
453
|
const agent = agents[agentType];
|
|
366
454
|
const cwd = options.cwd || process.cwd();
|
|
367
455
|
const sanitized = sanitizeName(skillName);
|
|
368
|
-
const targetBase = getAgentBaseDir(agentType, options.global ?? false, options.cwd);
|
|
456
|
+
const targetBase = getAgentBaseDir(agentType, options.global ?? false, options.cwd, options.eveSubagent);
|
|
369
457
|
const installPath = join(targetBase, sanitized);
|
|
370
458
|
if (!isPathSafe(targetBase, installPath)) {
|
|
371
459
|
throw new Error('Invalid skill name: potential path traversal detected');
|
|
@@ -377,7 +465,9 @@ export function getInstallPath(skillName, agentType, options = {}) {
|
|
|
377
465
|
*/
|
|
378
466
|
export function getCanonicalPath(skillName, options = {}) {
|
|
379
467
|
const sanitized = sanitizeName(skillName);
|
|
380
|
-
const canonicalBase =
|
|
468
|
+
const canonicalBase = options.agent === 'eve'
|
|
469
|
+
? getAgentBaseDir('eve', options.global ?? false, options.cwd, options.eveSubagent)
|
|
470
|
+
: getCanonicalSkillsDir(options.global ?? false, options.cwd);
|
|
381
471
|
const canonicalPath = join(canonicalBase, sanitized);
|
|
382
472
|
if (!isPathSafe(canonicalBase, canonicalPath)) {
|
|
383
473
|
throw new Error('Invalid skill name: potential path traversal detected');
|
|
@@ -395,6 +485,7 @@ export async function installRemoteSkillForAgent(skill, agentType, options = {})
|
|
|
395
485
|
const isGlobal = options.global ?? false;
|
|
396
486
|
const cwd = options.cwd || process.cwd();
|
|
397
487
|
const installMode = options.mode ?? 'symlink';
|
|
488
|
+
const eveSubagent = options.eveSubagent;
|
|
398
489
|
// Check if agent supports global installation
|
|
399
490
|
if (isGlobal && agent.globalSkillsDir === undefined) {
|
|
400
491
|
return {
|
|
@@ -407,10 +498,12 @@ export async function installRemoteSkillForAgent(skill, agentType, options = {})
|
|
|
407
498
|
// Use installName as the skill directory name
|
|
408
499
|
const skillName = sanitizeName(skill.installName);
|
|
409
500
|
// Canonical location: .agents/skills/<skill-name>
|
|
410
|
-
const canonicalBase =
|
|
501
|
+
const canonicalBase = agentType === 'eve' && installMode === 'symlink'
|
|
502
|
+
? getAgentBaseDir(agentType, isGlobal, cwd, eveSubagent)
|
|
503
|
+
: getCanonicalSkillsDir(isGlobal, cwd);
|
|
411
504
|
const canonicalDir = join(canonicalBase, skillName);
|
|
412
505
|
// Agent-specific location (for symlink)
|
|
413
|
-
const agentBase = getAgentBaseDir(agentType, isGlobal, cwd);
|
|
506
|
+
const agentBase = getAgentBaseDir(agentType, isGlobal, cwd, eveSubagent);
|
|
414
507
|
const agentDir = join(agentBase, skillName);
|
|
415
508
|
// Validate paths
|
|
416
509
|
if (!isPathSafe(canonicalBase, canonicalDir)) {
|
|
@@ -433,8 +526,9 @@ export async function installRemoteSkillForAgent(skill, agentType, options = {})
|
|
|
433
526
|
// For copy mode, write directly to agent location
|
|
434
527
|
if (installMode === 'copy') {
|
|
435
528
|
await cleanAndCreateDirectory(agentDir);
|
|
436
|
-
const
|
|
437
|
-
|
|
529
|
+
const skillFileName = agentType === 'eve' ? toEveFlatSkillFileName(skill.installName) : 'SKILL.md';
|
|
530
|
+
const skillMdPath = join(agentDir, skillFileName);
|
|
531
|
+
await writeFile(skillMdPath, agentType === 'eve' ? stripIgnoredEveFrontmatter(skill.content) : skill.content, 'utf-8');
|
|
438
532
|
return {
|
|
439
533
|
success: true,
|
|
440
534
|
path: agentDir,
|
|
@@ -443,8 +537,9 @@ export async function installRemoteSkillForAgent(skill, agentType, options = {})
|
|
|
443
537
|
}
|
|
444
538
|
// Symlink mode: write to canonical location and symlink to agent location
|
|
445
539
|
await cleanAndCreateDirectory(canonicalDir);
|
|
446
|
-
const
|
|
447
|
-
|
|
540
|
+
const skillFileName = agentType === 'eve' ? toEveFlatSkillFileName(skill.installName) : 'SKILL.md';
|
|
541
|
+
const skillMdPath = join(canonicalDir, skillFileName);
|
|
542
|
+
await writeFile(skillMdPath, agentType === 'eve' ? stripIgnoredEveFrontmatter(skill.content) : skill.content, 'utf-8');
|
|
448
543
|
// For universal agents with global install, skip creating agent-specific symlink
|
|
449
544
|
if (isGlobal && isUniversalAgent(agentType)) {
|
|
450
545
|
return {
|
|
@@ -458,8 +553,9 @@ export async function installRemoteSkillForAgent(skill, agentType, options = {})
|
|
|
458
553
|
if (!symlinkCreated) {
|
|
459
554
|
// Symlink failed, fall back to copy
|
|
460
555
|
await cleanAndCreateDirectory(agentDir);
|
|
461
|
-
const
|
|
462
|
-
|
|
556
|
+
const agentSkillFileName = agentType === 'eve' ? toEveFlatSkillFileName(skill.installName) : 'SKILL.md';
|
|
557
|
+
const agentSkillMdPath = join(agentDir, agentSkillFileName);
|
|
558
|
+
await writeFile(agentSkillMdPath, agentType === 'eve' ? stripIgnoredEveFrontmatter(skill.content) : skill.content, 'utf-8');
|
|
463
559
|
return {
|
|
464
560
|
success: true,
|
|
465
561
|
path: agentDir,
|
|
@@ -496,6 +592,7 @@ export async function installWellKnownSkillForAgent(skill, agentType, options =
|
|
|
496
592
|
const isGlobal = options.global ?? false;
|
|
497
593
|
const cwd = options.cwd || process.cwd();
|
|
498
594
|
const installMode = options.mode ?? 'symlink';
|
|
595
|
+
const eveSubagent = options.eveSubagent;
|
|
499
596
|
// Check if agent supports global installation
|
|
500
597
|
if (isGlobal && agent.globalSkillsDir === undefined) {
|
|
501
598
|
return {
|
|
@@ -508,10 +605,12 @@ export async function installWellKnownSkillForAgent(skill, agentType, options =
|
|
|
508
605
|
// Use installName as the skill directory name
|
|
509
606
|
const skillName = sanitizeName(skill.installName);
|
|
510
607
|
// Canonical location: .agents/skills/<skill-name>
|
|
511
|
-
const canonicalBase =
|
|
608
|
+
const canonicalBase = agentType === 'eve' && installMode === 'symlink'
|
|
609
|
+
? getAgentBaseDir(agentType, isGlobal, cwd, eveSubagent)
|
|
610
|
+
: getCanonicalSkillsDir(isGlobal, cwd);
|
|
512
611
|
const canonicalDir = join(canonicalBase, skillName);
|
|
513
612
|
// Agent-specific location (for symlink)
|
|
514
|
-
const agentBase = getAgentBaseDir(agentType, isGlobal, cwd);
|
|
613
|
+
const agentBase = getAgentBaseDir(agentType, isGlobal, cwd, eveSubagent);
|
|
515
614
|
const agentDir = join(agentBase, skillName);
|
|
516
615
|
// Validate paths
|
|
517
616
|
if (!isPathSafe(canonicalBase, canonicalDir)) {
|
|
@@ -545,7 +644,11 @@ export async function installWellKnownSkillForAgent(skill, agentType, options =
|
|
|
545
644
|
if (parentDir !== targetDir) {
|
|
546
645
|
await mkdir(parentDir, { recursive: true });
|
|
547
646
|
}
|
|
548
|
-
await writeFile(fullPath,
|
|
647
|
+
await writeFile(fullPath, agentType === 'eve' &&
|
|
648
|
+
basename(filePath).toLowerCase() === 'skill.md' &&
|
|
649
|
+
typeof content === 'string'
|
|
650
|
+
? stripIgnoredEveFrontmatter(content)
|
|
651
|
+
: content);
|
|
549
652
|
}
|
|
550
653
|
}
|
|
551
654
|
try {
|
|
@@ -610,6 +713,7 @@ export async function installBlobSkillForAgent(skill, agentType, options = {}) {
|
|
|
610
713
|
const isGlobal = options.global ?? false;
|
|
611
714
|
const cwd = options.cwd || process.cwd();
|
|
612
715
|
const installMode = options.mode ?? 'symlink';
|
|
716
|
+
const eveSubagent = options.eveSubagent;
|
|
613
717
|
if (isGlobal && agent.globalSkillsDir === undefined) {
|
|
614
718
|
return {
|
|
615
719
|
success: false,
|
|
@@ -619,9 +723,36 @@ export async function installBlobSkillForAgent(skill, agentType, options = {}) {
|
|
|
619
723
|
};
|
|
620
724
|
}
|
|
621
725
|
const skillName = sanitizeName(skill.installName);
|
|
622
|
-
const
|
|
726
|
+
const agentBase = getAgentBaseDir(agentType, isGlobal, cwd, eveSubagent);
|
|
727
|
+
if (agentType === 'eve' && !isEvePackagedSkill(skill.files)) {
|
|
728
|
+
const flatSkillPath = join(agentBase, toEveFlatSkillFileName(skill.installName));
|
|
729
|
+
if (!isPathSafe(agentBase, flatSkillPath)) {
|
|
730
|
+
return {
|
|
731
|
+
success: false,
|
|
732
|
+
path: flatSkillPath,
|
|
733
|
+
mode: installMode,
|
|
734
|
+
error: 'Invalid skill name: potential path traversal detected',
|
|
735
|
+
};
|
|
736
|
+
}
|
|
737
|
+
try {
|
|
738
|
+
await mkdir(agentBase, { recursive: true });
|
|
739
|
+
await rm(flatSkillPath, { recursive: true, force: true });
|
|
740
|
+
await writeFile(flatSkillPath, getEveFlatSkillMarkdown(skill.files), 'utf-8');
|
|
741
|
+
return { success: true, path: flatSkillPath, mode: 'copy' };
|
|
742
|
+
}
|
|
743
|
+
catch (error) {
|
|
744
|
+
return {
|
|
745
|
+
success: false,
|
|
746
|
+
path: flatSkillPath,
|
|
747
|
+
mode: installMode,
|
|
748
|
+
error: error instanceof Error ? error.message : 'Unknown error',
|
|
749
|
+
};
|
|
750
|
+
}
|
|
751
|
+
}
|
|
752
|
+
const canonicalBase = agentType === 'eve' && installMode === 'symlink'
|
|
753
|
+
? getAgentBaseDir(agentType, isGlobal, cwd, eveSubagent)
|
|
754
|
+
: getCanonicalSkillsDir(isGlobal, cwd);
|
|
623
755
|
const canonicalDir = join(canonicalBase, skillName);
|
|
624
|
-
const agentBase = getAgentBaseDir(agentType, isGlobal, cwd);
|
|
625
756
|
const agentDir = join(agentBase, skillName);
|
|
626
757
|
if (!isPathSafe(canonicalBase, canonicalDir)) {
|
|
627
758
|
return {
|
|
@@ -648,7 +779,9 @@ export async function installBlobSkillForAgent(skill, agentType, options = {}) {
|
|
|
648
779
|
if (parentDir !== targetDir) {
|
|
649
780
|
await mkdir(parentDir, { recursive: true });
|
|
650
781
|
}
|
|
651
|
-
await writeFile(fullPath, file.
|
|
782
|
+
await writeFile(fullPath, agentType === 'eve' && basename(file.path).toLowerCase() === 'skill.md'
|
|
783
|
+
? stripIgnoredEveFrontmatter(file.contents)
|
|
784
|
+
: file.contents, 'utf-8');
|
|
652
785
|
}
|
|
653
786
|
}
|
|
654
787
|
try {
|
|
@@ -767,6 +900,16 @@ export async function listInstalledSkills(options = {}) {
|
|
|
767
900
|
if (!scopes.some((s) => s.path === agentDir && s.global === isGlobal)) {
|
|
768
901
|
scopes.push({ global: isGlobal, path: agentDir, agentType });
|
|
769
902
|
}
|
|
903
|
+
// Eve subagents keep their skills under agent/subagents/<name>/skills.
|
|
904
|
+
// These are project-scoped, so only scan them for the project scope.
|
|
905
|
+
if (agentType === 'eve' && !isGlobal) {
|
|
906
|
+
for (const subagent of getEveSubagents(cwd)) {
|
|
907
|
+
const subagentDir = getEveSubagentSkillsDir(subagent, cwd);
|
|
908
|
+
if (!scopes.some((s) => s.path === subagentDir && s.global === isGlobal)) {
|
|
909
|
+
scopes.push({ global: isGlobal, path: subagentDir, agentType });
|
|
910
|
+
}
|
|
911
|
+
}
|
|
912
|
+
}
|
|
770
913
|
}
|
|
771
914
|
// Also scan skill directories for agents NOT in agentsToCheck, in case
|
|
772
915
|
// skills were installed with `--agent <name>` but the agent is no longer
|
|
@@ -2,11 +2,11 @@ import * as p from '@clack/prompts';
|
|
|
2
2
|
import pc from 'picocolors';
|
|
3
3
|
import { readdir, rm, lstat } from 'fs/promises';
|
|
4
4
|
import { join } from 'path';
|
|
5
|
-
import { agents, detectInstalledAgents } from "./agents.js";
|
|
5
|
+
import { agents, detectInstalledAgents, getEveSubagents } from "./agents.js";
|
|
6
6
|
import { track } from "./telemetry.js";
|
|
7
7
|
import { detectAgent } from "./detect-agent.js";
|
|
8
8
|
import { removeSkillFromLock, getSkillFromLock } from "./skill-lock.js";
|
|
9
|
-
import { getInstallPath, getCanonicalPath, getCanonicalSkillsDir, sanitizeName, } from "./installer.js";
|
|
9
|
+
import { getInstallPath, getCanonicalPath, getCanonicalSkillsDir, getEveSubagentSkillsDir, sanitizeName, } from "./installer.js";
|
|
10
10
|
export async function removeCommand(skillNames, options) {
|
|
11
11
|
// Auto-enable non-interactive mode when running inside an AI agent
|
|
12
12
|
const agentResult = await detectAgent();
|
|
@@ -49,6 +49,10 @@ export async function removeCommand(skillNames, options) {
|
|
|
49
49
|
for (const agent of Object.values(agents)) {
|
|
50
50
|
await scanDir(join(cwd, agent.skillsDir));
|
|
51
51
|
}
|
|
52
|
+
// Eve subagents keep their skills under agent/subagents/<name>/skills.
|
|
53
|
+
for (const subagent of getEveSubagents(cwd)) {
|
|
54
|
+
await scanDir(getEveSubagentSkillsDir(subagent, cwd));
|
|
55
|
+
}
|
|
52
56
|
}
|
|
53
57
|
const installedSkills = Array.from(skillNamesSet).sort();
|
|
54
58
|
spinner.stop(`Found ${installedSkills.length} unique installed skill(s)`);
|
|
@@ -136,6 +140,12 @@ export async function removeCommand(skillNames, options) {
|
|
|
136
140
|
}
|
|
137
141
|
else {
|
|
138
142
|
pathsToCleanup.add(join(cwd, agent.skillsDir, sanitizedName));
|
|
143
|
+
// Eve skills may also live in subagent directories.
|
|
144
|
+
if (agentKey === 'eve') {
|
|
145
|
+
for (const subagent of getEveSubagents(cwd)) {
|
|
146
|
+
pathsToCleanup.add(join(getEveSubagentSkillsDir(subagent, cwd), sanitizedName));
|
|
147
|
+
}
|
|
148
|
+
}
|
|
139
149
|
}
|
|
140
150
|
for (const pathToCleanup of pathsToCleanup) {
|
|
141
151
|
// Skip if this is the canonical path - we'll handle that after checking all agents
|
|
@@ -13,6 +13,7 @@ const TELEMETRY_URL = process.env.OTEL_EXPORTER_OTLP_TRACES_ENDPOINT ||
|
|
|
13
13
|
(baseEndpoint
|
|
14
14
|
? `${baseEndpoint.replace(/\/$/, "")}/v1/traces`
|
|
15
15
|
: "https://telemetry-gateway.hamiltonsnow.workers.dev/v1/traces");
|
|
16
|
+
const AUDIT_URL = "https://add-skill.vercel.sh/audit";
|
|
16
17
|
let provider = null;
|
|
17
18
|
let activeTracer = null;
|
|
18
19
|
let detectedAgentName = null;
|
|
@@ -34,7 +35,13 @@ function getCliVersion() {
|
|
|
34
35
|
try {
|
|
35
36
|
const self = fileURLToPath(import.meta.url);
|
|
36
37
|
const here = dirname(self);
|
|
37
|
-
|
|
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("..", "..", "..", "..");
|
|
38
45
|
const pkgPath = join(here, up, "package.json");
|
|
39
46
|
if (!existsSync(pkgPath))
|
|
40
47
|
return null;
|
|
@@ -46,23 +53,27 @@ function getCliVersion() {
|
|
|
46
53
|
}
|
|
47
54
|
}
|
|
48
55
|
const cliVersion = getCliVersion();
|
|
49
|
-
|
|
50
|
-
|
|
56
|
+
/**
|
|
57
|
+
* Fetch security audit results for skills from the audit API.
|
|
58
|
+
* Returns null on any error or timeout — never blocks installation.
|
|
59
|
+
*/
|
|
60
|
+
export async function fetchAuditData(source, skillSlugs, timeoutMs = 3000) {
|
|
61
|
+
if (skillSlugs.length === 0)
|
|
51
62
|
return null;
|
|
52
63
|
try {
|
|
53
|
-
const
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
64
|
+
const params = new URLSearchParams({
|
|
65
|
+
source,
|
|
66
|
+
skills: skillSlugs.join(","),
|
|
67
|
+
});
|
|
68
|
+
const controller = new AbortController();
|
|
69
|
+
const timeout = setTimeout(() => controller.abort(), timeoutMs);
|
|
70
|
+
const response = await fetch(`${AUDIT_URL}?${params.toString()}`, {
|
|
71
|
+
signal: controller.signal,
|
|
60
72
|
});
|
|
61
|
-
|
|
73
|
+
clearTimeout(timeout);
|
|
74
|
+
if (!response.ok)
|
|
62
75
|
return null;
|
|
63
|
-
|
|
64
|
-
const data = (await res.json());
|
|
65
|
-
return data.warning || null;
|
|
76
|
+
return (await response.json());
|
|
66
77
|
}
|
|
67
78
|
catch {
|
|
68
79
|
return null;
|