@rbbtsn0w/adg 0.5.0-beta.2 → 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/src/adapters/antigravity-hooks.js +6 -0
- package/dist/vendor/skills/src/add.js +199 -24
- 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 +5 -0
- package/dist/vendor/skills/src/find.js +62 -12
- package/dist/vendor/skills/src/installer.js +173 -30
- package/dist/vendor/skills/src/remove.js +12 -2
- package/dist/vendor/skills/src/update.js +6 -1
- 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 +247 -25
- package/vendor/skills/src/agents.ts +57 -1
- package/vendor/skills/src/blob.ts +23 -2
- package/vendor/skills/src/cli.ts +5 -0
- package/vendor/skills/src/find.ts +74 -12
- 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/types.ts +1 -0
- package/vendor/skills/src/update.ts +6 -1
|
@@ -30,10 +30,64 @@ export interface SearchSkill {
|
|
|
30
30
|
installs: number;
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
+
export interface FindOptions {
|
|
34
|
+
owner?: string;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export interface ParseFindOptionsResult {
|
|
38
|
+
query: string;
|
|
39
|
+
options: FindOptions;
|
|
40
|
+
errors: string[];
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
const GITHUB_OWNER_PATTERN = /^[a-z0-9](?:[a-z0-9-]{0,38})$/i;
|
|
44
|
+
|
|
45
|
+
export function parseFindOptions(args: string[]): ParseFindOptionsResult {
|
|
46
|
+
const queryParts: string[] = [];
|
|
47
|
+
const options: FindOptions = {};
|
|
48
|
+
const errors: string[] = [];
|
|
49
|
+
|
|
50
|
+
for (let i = 0; i < args.length; i++) {
|
|
51
|
+
const arg = args[i];
|
|
52
|
+
if (!arg) continue;
|
|
53
|
+
|
|
54
|
+
let ownerValue: string | undefined;
|
|
55
|
+
if (arg === '--owner') {
|
|
56
|
+
const value = args[i + 1];
|
|
57
|
+
if (!value || value.startsWith('-')) {
|
|
58
|
+
errors.push('--owner requires a GitHub owner');
|
|
59
|
+
continue;
|
|
60
|
+
}
|
|
61
|
+
ownerValue = value;
|
|
62
|
+
i++;
|
|
63
|
+
} else if (arg.startsWith('--owner=')) {
|
|
64
|
+
ownerValue = arg.slice('--owner='.length);
|
|
65
|
+
if (!ownerValue) {
|
|
66
|
+
errors.push('--owner requires a GitHub owner');
|
|
67
|
+
continue;
|
|
68
|
+
}
|
|
69
|
+
} else {
|
|
70
|
+
queryParts.push(arg);
|
|
71
|
+
continue;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
const owner = ownerValue.trim().toLowerCase();
|
|
75
|
+
if (!GITHUB_OWNER_PATTERN.test(owner)) {
|
|
76
|
+
errors.push('--owner must be a valid GitHub owner');
|
|
77
|
+
continue;
|
|
78
|
+
}
|
|
79
|
+
options.owner = owner;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
return { query: queryParts.join(' '), options, errors };
|
|
83
|
+
}
|
|
84
|
+
|
|
33
85
|
// Search via API
|
|
34
|
-
export async function searchSkillsAPI(query: string): Promise<SearchSkill[]> {
|
|
86
|
+
export async function searchSkillsAPI(query: string, owner?: string): Promise<SearchSkill[]> {
|
|
35
87
|
try {
|
|
36
|
-
const
|
|
88
|
+
const params = new URLSearchParams({ q: query, limit: '10' });
|
|
89
|
+
if (owner) params.set('owner', owner);
|
|
90
|
+
const url = `${SEARCH_API_BASE}/api/search?${params.toString()}`;
|
|
37
91
|
const res = await fetch(url);
|
|
38
92
|
|
|
39
93
|
if (!res.ok) return [];
|
|
@@ -68,7 +122,7 @@ const MOVE_UP = (n: number) => `\x1b[${n}A`;
|
|
|
68
122
|
const MOVE_TO_COL = (n: number) => `\x1b[${n}G`;
|
|
69
123
|
|
|
70
124
|
// Custom fzf-style search prompt using raw readline
|
|
71
|
-
async function runSearchPrompt(initialQuery = ''): Promise<SearchSkill | null> {
|
|
125
|
+
async function runSearchPrompt(initialQuery = '', owner?: string): Promise<SearchSkill | null> {
|
|
72
126
|
let results: SearchSkill[] = [];
|
|
73
127
|
let selectedIndex = 0;
|
|
74
128
|
let query = initialQuery;
|
|
@@ -169,7 +223,7 @@ async function runSearchPrompt(initialQuery = ''): Promise<SearchSkill | null> {
|
|
|
169
223
|
|
|
170
224
|
debounceTimer = setTimeout(async () => {
|
|
171
225
|
try {
|
|
172
|
-
results = await searchSkillsAPI(q);
|
|
226
|
+
results = await searchSkillsAPI(q, owner);
|
|
173
227
|
selectedIndex = 0;
|
|
174
228
|
} catch {
|
|
175
229
|
results = [];
|
|
@@ -269,15 +323,22 @@ async function isRepoPublic(owner: string, repo: string): Promise<boolean> {
|
|
|
269
323
|
}
|
|
270
324
|
|
|
271
325
|
export async function runFind(args: string[]): Promise<void> {
|
|
272
|
-
const query = args
|
|
326
|
+
const { query, options: findOptions, errors } = parseFindOptions(args);
|
|
327
|
+
const owner = findOptions.owner;
|
|
273
328
|
const isNonInteractive = !process.stdin.isTTY;
|
|
274
329
|
const agentTip = `${DIM}Tip: if running in a coding agent, follow these steps:${RESET}
|
|
275
|
-
${DIM} 1) npx skills find [query]${RESET}
|
|
330
|
+
${DIM} 1) npx skills find [query] [--owner <owner>]${RESET}
|
|
276
331
|
${DIM} 2) npx skills add <owner/repo@skill>${RESET}`;
|
|
277
332
|
|
|
333
|
+
if (errors.length > 0) {
|
|
334
|
+
for (const error of errors) console.error(error);
|
|
335
|
+
console.error('Usage: npx skills find <query> [--owner <owner>]');
|
|
336
|
+
return;
|
|
337
|
+
}
|
|
338
|
+
|
|
278
339
|
// Non-interactive mode: just print results and exit
|
|
279
340
|
if (query) {
|
|
280
|
-
const results = await searchSkillsAPI(query);
|
|
341
|
+
const results = await searchSkillsAPI(query, owner);
|
|
281
342
|
|
|
282
343
|
// Track telemetry for non-interactive search
|
|
283
344
|
track({
|
|
@@ -287,7 +348,8 @@ ${DIM} 2) npx skills add <owner/repo@skill>${RESET}`;
|
|
|
287
348
|
});
|
|
288
349
|
|
|
289
350
|
if (results.length === 0) {
|
|
290
|
-
|
|
351
|
+
const ownerSuffix = owner ? ` from owner "${owner}"` : '';
|
|
352
|
+
console.log(`${DIM}No skills found for "${query}"${ownerSuffix}${RESET}`);
|
|
291
353
|
return;
|
|
292
354
|
}
|
|
293
355
|
|
|
@@ -310,11 +372,11 @@ ${DIM} 2) npx skills add <owner/repo@skill>${RESET}`;
|
|
|
310
372
|
if (isNonInteractive || (await isRunningInAgent())) {
|
|
311
373
|
console.log(agentTip);
|
|
312
374
|
console.log();
|
|
313
|
-
console.log(`${DIM}Usage: npx skills find <query
|
|
375
|
+
console.log(`${DIM}Usage: npx skills find <query> [--owner <owner>]${RESET}`);
|
|
314
376
|
return;
|
|
315
377
|
}
|
|
316
378
|
|
|
317
|
-
const selected = await runSearchPrompt();
|
|
379
|
+
const selected = await runSearchPrompt('', owner);
|
|
318
380
|
|
|
319
381
|
// Track telemetry for interactive search
|
|
320
382
|
track({
|
|
@@ -339,8 +401,8 @@ ${DIM} 2) npx skills add <owner/repo@skill>${RESET}`;
|
|
|
339
401
|
console.log();
|
|
340
402
|
|
|
341
403
|
// Run add directly since we're in the same CLI
|
|
342
|
-
const { source, options } = parseAddOptions([pkg, '--skill', skillName]);
|
|
343
|
-
await runAdd(source,
|
|
404
|
+
const { source, options: addOptions } = parseAddOptions([pkg, '--skill', skillName]);
|
|
405
|
+
await runAdd(source, addOptions);
|
|
344
406
|
|
|
345
407
|
console.log();
|
|
346
408
|
|
|
@@ -7,17 +7,25 @@ import {
|
|
|
7
7
|
lstat,
|
|
8
8
|
rm,
|
|
9
9
|
readlink,
|
|
10
|
+
readFile,
|
|
10
11
|
writeFile,
|
|
11
12
|
stat,
|
|
12
13
|
realpath,
|
|
13
14
|
} from 'fs/promises';
|
|
14
15
|
import { existsSync } from 'fs';
|
|
15
|
-
import { join, basename, normalize, resolve, sep, relative, dirname } from 'path';
|
|
16
|
+
import { join, basename, normalize, resolve, sep, relative, dirname, extname } from 'path';
|
|
16
17
|
import { homedir, platform } from 'os';
|
|
17
18
|
import type { Skill, AgentType, RemoteSkill } from './types.ts';
|
|
18
19
|
import type { WellKnownSkill } from './providers/wellknown.ts';
|
|
19
|
-
import {
|
|
20
|
+
import {
|
|
21
|
+
agents,
|
|
22
|
+
detectInstalledAgents,
|
|
23
|
+
isUniversalAgent,
|
|
24
|
+
getEveSubagents,
|
|
25
|
+
EVE_SUBAGENTS_DIR,
|
|
26
|
+
} from './agents.ts';
|
|
20
27
|
import { AGENTS_DIR, SKILLS_SUBDIR } from './constants.ts';
|
|
28
|
+
import { parseFrontmatter } from './frontmatter.ts';
|
|
21
29
|
import { parseSkillMd } from './skills.ts';
|
|
22
30
|
|
|
23
31
|
export type InstallMode = 'symlink' | 'copy';
|
|
@@ -68,6 +76,10 @@ function isPathSafe(basePath: string, targetPath: string): boolean {
|
|
|
68
76
|
return normalizedTarget.startsWith(normalizedBase + sep) || normalizedTarget === normalizedBase;
|
|
69
77
|
}
|
|
70
78
|
|
|
79
|
+
function pathsOverlap(pathA: string, pathB: string): boolean {
|
|
80
|
+
return isPathSafe(pathA, pathB) || isPathSafe(pathB, pathA);
|
|
81
|
+
}
|
|
82
|
+
|
|
71
83
|
// Dirent.isDirectory() is false for symlinks; follow and verify the target is a directory.
|
|
72
84
|
async function isDirEntryOrSymlinkToDir(
|
|
73
85
|
entry: { isDirectory(): boolean; isSymbolicLink(): boolean },
|
|
@@ -87,16 +99,40 @@ export function getCanonicalSkillsDir(global: boolean, cwd?: string): string {
|
|
|
87
99
|
return join(baseDir, AGENTS_DIR, SKILLS_SUBDIR);
|
|
88
100
|
}
|
|
89
101
|
|
|
102
|
+
/**
|
|
103
|
+
* Resolve the skills directory for a specific Eve subagent, relative to the
|
|
104
|
+
* project root: `agent/subagents/<name>/skills`. The subagent name is
|
|
105
|
+
* sanitized to prevent directory traversal when it originates from user input.
|
|
106
|
+
*/
|
|
107
|
+
export function getEveSubagentSkillsDir(subagent: string, cwd?: string): string {
|
|
108
|
+
const baseDir = cwd || process.cwd();
|
|
109
|
+
return join(baseDir, EVE_SUBAGENTS_DIR, sanitizeName(subagent), 'skills');
|
|
110
|
+
}
|
|
111
|
+
|
|
90
112
|
/**
|
|
91
113
|
* Gets the base directory for an agent's skills, respecting universal agents.
|
|
92
114
|
* Universal agents always use the canonical directory, which prevents
|
|
93
115
|
* redundant symlinks and double-listing of skills.
|
|
116
|
+
*
|
|
117
|
+
* For Eve, an optional `eveSubagent` targets a subagent's skills directory
|
|
118
|
+
* (`agent/subagents/<name>/skills`) instead of the root agent's `agent/skills`.
|
|
94
119
|
*/
|
|
95
|
-
export function getAgentBaseDir(
|
|
120
|
+
export function getAgentBaseDir(
|
|
121
|
+
agentType: AgentType,
|
|
122
|
+
global: boolean,
|
|
123
|
+
cwd?: string,
|
|
124
|
+
eveSubagent?: string
|
|
125
|
+
): string {
|
|
96
126
|
if (isUniversalAgent(agentType)) {
|
|
97
127
|
return getCanonicalSkillsDir(global, cwd);
|
|
98
128
|
}
|
|
99
129
|
|
|
130
|
+
// Eve subagents are inherently project-scoped — they live under the project's
|
|
131
|
+
// agent/ directory, so the `global` flag does not apply here.
|
|
132
|
+
if (agentType === 'eve' && eveSubagent) {
|
|
133
|
+
return getEveSubagentSkillsDir(eveSubagent, cwd);
|
|
134
|
+
}
|
|
135
|
+
|
|
100
136
|
const agent = agents[agentType];
|
|
101
137
|
const baseDir = global ? homedir() : cwd || process.cwd();
|
|
102
138
|
|
|
@@ -216,8 +252,9 @@ async function createSymlink(target: string, linkPath: string): Promise<boolean>
|
|
|
216
252
|
const realLinkDir = await resolveParentSymlinks(linkDir);
|
|
217
253
|
const relativePath = relative(realLinkDir, target);
|
|
218
254
|
const symlinkType = platform() === 'win32' ? 'junction' : undefined;
|
|
255
|
+
const symlinkTarget = symlinkType === 'junction' ? resolvedTarget : relativePath;
|
|
219
256
|
|
|
220
|
-
await symlink(
|
|
257
|
+
await symlink(symlinkTarget, linkPath, symlinkType);
|
|
221
258
|
return true;
|
|
222
259
|
} catch {
|
|
223
260
|
return false;
|
|
@@ -227,11 +264,12 @@ async function createSymlink(target: string, linkPath: string): Promise<boolean>
|
|
|
227
264
|
export async function installSkillForAgent(
|
|
228
265
|
skill: Skill,
|
|
229
266
|
agentType: AgentType,
|
|
230
|
-
options: { global?: boolean; cwd?: string; mode?: InstallMode } = {}
|
|
267
|
+
options: { global?: boolean; cwd?: string; mode?: InstallMode; eveSubagent?: string } = {}
|
|
231
268
|
): Promise<InstallResult> {
|
|
232
269
|
const agent = agents[agentType];
|
|
233
270
|
const isGlobal = options.global ?? false;
|
|
234
271
|
const cwd = options.cwd || process.cwd();
|
|
272
|
+
const eveSubagent = options.eveSubagent;
|
|
235
273
|
|
|
236
274
|
// Check if agent supports global installation
|
|
237
275
|
if (isGlobal && agent.globalSkillsDir === undefined) {
|
|
@@ -247,16 +285,19 @@ export async function installSkillForAgent(
|
|
|
247
285
|
const rawSkillName = skill.name || basename(skill.path);
|
|
248
286
|
const skillName = sanitizeName(rawSkillName);
|
|
249
287
|
|
|
288
|
+
const installMode = options.mode ?? 'symlink';
|
|
289
|
+
|
|
250
290
|
// Canonical location: .agents/skills/<skill-name>
|
|
251
|
-
const canonicalBase =
|
|
291
|
+
const canonicalBase =
|
|
292
|
+
agentType === 'eve' && installMode === 'symlink'
|
|
293
|
+
? getAgentBaseDir(agentType, isGlobal, cwd, eveSubagent)
|
|
294
|
+
: getCanonicalSkillsDir(isGlobal, cwd);
|
|
252
295
|
const canonicalDir = join(canonicalBase, skillName);
|
|
253
296
|
|
|
254
297
|
// Agent-specific location (for symlink)
|
|
255
|
-
const agentBase = getAgentBaseDir(agentType, isGlobal, cwd);
|
|
298
|
+
const agentBase = getAgentBaseDir(agentType, isGlobal, cwd, eveSubagent);
|
|
256
299
|
const agentDir = join(agentBase, skillName);
|
|
257
300
|
|
|
258
|
-
const installMode = options.mode ?? 'symlink';
|
|
259
|
-
|
|
260
301
|
// Validate paths
|
|
261
302
|
if (!isPathSafe(canonicalBase, canonicalDir)) {
|
|
262
303
|
return {
|
|
@@ -277,10 +318,24 @@ export async function installSkillForAgent(
|
|
|
277
318
|
}
|
|
278
319
|
|
|
279
320
|
try {
|
|
321
|
+
// Never install onto (or inside) the source directory. This can happen with
|
|
322
|
+
// agent-specific project directories like OpenClaw's "skills" when users run
|
|
323
|
+
// `skills add ./skills --all`: the source `./skills/<name>` and destination
|
|
324
|
+
// `./skills/<name>` are the same path. Cleaning the destination would delete
|
|
325
|
+
// the user's source skill before we can link or copy it.
|
|
326
|
+
if (pathsOverlap(skill.path, agentDir)) {
|
|
327
|
+
return {
|
|
328
|
+
success: true,
|
|
329
|
+
path: agentDir,
|
|
330
|
+
mode: installMode,
|
|
331
|
+
skipped: true,
|
|
332
|
+
};
|
|
333
|
+
}
|
|
334
|
+
|
|
280
335
|
// For copy mode, skip canonical directory and copy directly to agent location
|
|
281
336
|
if (installMode === 'copy') {
|
|
282
337
|
await cleanAndCreateDirectory(agentDir);
|
|
283
|
-
await copyDirectory(skill.path, agentDir);
|
|
338
|
+
await copyDirectory(skill.path, agentDir, agentType);
|
|
284
339
|
|
|
285
340
|
return {
|
|
286
341
|
success: true,
|
|
@@ -289,9 +344,19 @@ export async function installSkillForAgent(
|
|
|
289
344
|
};
|
|
290
345
|
}
|
|
291
346
|
|
|
347
|
+
if (pathsOverlap(skill.path, canonicalDir)) {
|
|
348
|
+
return {
|
|
349
|
+
success: true,
|
|
350
|
+
path: canonicalDir,
|
|
351
|
+
canonicalPath: canonicalDir,
|
|
352
|
+
mode: 'symlink',
|
|
353
|
+
skipped: true,
|
|
354
|
+
};
|
|
355
|
+
}
|
|
356
|
+
|
|
292
357
|
// Symlink mode: copy to canonical location and symlink to agent location
|
|
293
358
|
await cleanAndCreateDirectory(canonicalDir);
|
|
294
|
-
await copyDirectory(skill.path, canonicalDir);
|
|
359
|
+
await copyDirectory(skill.path, canonicalDir, agentType);
|
|
295
360
|
|
|
296
361
|
// For universal agents with global install, the skill is already in the canonical
|
|
297
362
|
// ~/.agents/skills directory. Skip creating a symlink to the agent-specific global dir
|
|
@@ -327,7 +392,7 @@ export async function installSkillForAgent(
|
|
|
327
392
|
if (!symlinkCreated) {
|
|
328
393
|
// Symlink failed, fall back to copy
|
|
329
394
|
await cleanAndCreateDirectory(agentDir);
|
|
330
|
-
await copyDirectory(skill.path, agentDir);
|
|
395
|
+
await copyDirectory(skill.path, agentDir, agentType);
|
|
331
396
|
|
|
332
397
|
return {
|
|
333
398
|
success: true,
|
|
@@ -363,7 +428,37 @@ const isExcluded = (name: string, isDirectory: boolean = false): boolean => {
|
|
|
363
428
|
return false;
|
|
364
429
|
};
|
|
365
430
|
|
|
366
|
-
|
|
431
|
+
function stripIgnoredEveFrontmatter(raw: string): string {
|
|
432
|
+
const { data, content } = parseFrontmatter(raw);
|
|
433
|
+
const eveData: Record<string, unknown> = {};
|
|
434
|
+
|
|
435
|
+
if (typeof data.description === 'string') {
|
|
436
|
+
eveData.description = data.description;
|
|
437
|
+
}
|
|
438
|
+
if (typeof data.license === 'string') {
|
|
439
|
+
eveData.license = data.license;
|
|
440
|
+
}
|
|
441
|
+
if (data.metadata && typeof data.metadata === 'object' && !Array.isArray(data.metadata)) {
|
|
442
|
+
const metadata = Object.fromEntries(
|
|
443
|
+
Object.entries(data.metadata).filter(
|
|
444
|
+
(entry): entry is [string, string] => typeof entry[1] === 'string'
|
|
445
|
+
)
|
|
446
|
+
);
|
|
447
|
+
if (Object.keys(metadata).length > 0) {
|
|
448
|
+
eveData.metadata = metadata;
|
|
449
|
+
}
|
|
450
|
+
}
|
|
451
|
+
|
|
452
|
+
const keys = Object.keys(eveData);
|
|
453
|
+
if (keys.length === 0) {
|
|
454
|
+
return content.replace(/^\r?\n/u, '');
|
|
455
|
+
}
|
|
456
|
+
|
|
457
|
+
const frontmatter = keys.map((key) => `${key}: ${JSON.stringify(eveData[key])}`).join('\n');
|
|
458
|
+
return `---\n${frontmatter}\n---\n${content.replace(/^\r?\n/u, '')}`;
|
|
459
|
+
}
|
|
460
|
+
|
|
461
|
+
async function copyDirectory(src: string, dest: string, agentType?: AgentType): Promise<void> {
|
|
367
462
|
await mkdir(dest, { recursive: true });
|
|
368
463
|
|
|
369
464
|
const entries = await readdir(src, { withFileTypes: true });
|
|
@@ -377,9 +472,17 @@ async function copyDirectory(src: string, dest: string): Promise<void> {
|
|
|
377
472
|
const destPath = join(dest, entry.name);
|
|
378
473
|
|
|
379
474
|
if (entry.isDirectory()) {
|
|
380
|
-
await copyDirectory(srcPath, destPath);
|
|
475
|
+
await copyDirectory(srcPath, destPath, agentType);
|
|
381
476
|
} else {
|
|
382
477
|
try {
|
|
478
|
+
if (agentType === 'eve' && entry.name.toLowerCase() === 'skill.md') {
|
|
479
|
+
await writeFile(
|
|
480
|
+
destPath,
|
|
481
|
+
stripIgnoredEveFrontmatter(await readFile(srcPath, 'utf-8'))
|
|
482
|
+
);
|
|
483
|
+
return;
|
|
484
|
+
}
|
|
485
|
+
|
|
383
486
|
await cp(srcPath, destPath, {
|
|
384
487
|
// If the file is a symlink to elsewhere in a remote skill, it may not
|
|
385
488
|
// resolve correctly once it has been copied to the local location.
|
|
@@ -407,10 +510,26 @@ async function copyDirectory(src: string, dest: string): Promise<void> {
|
|
|
407
510
|
);
|
|
408
511
|
}
|
|
409
512
|
|
|
513
|
+
function isEvePackagedSkill(files: Array<{ path: string; contents?: string }>): boolean {
|
|
514
|
+
return files.some((file) => basename(file.path).toLowerCase() === 'skill.md');
|
|
515
|
+
}
|
|
516
|
+
|
|
517
|
+
function toEveFlatSkillFileName(installName: string): string {
|
|
518
|
+
return `${sanitizeName(installName)}.md`;
|
|
519
|
+
}
|
|
520
|
+
|
|
521
|
+
function getEveFlatSkillMarkdown(files: Array<{ path: string; contents: string }>): string {
|
|
522
|
+
const skillFile = files.find((file) => basename(file.path).toLowerCase() === 'skill.md');
|
|
523
|
+
if (skillFile) return stripIgnoredEveFrontmatter(skillFile.contents);
|
|
524
|
+
|
|
525
|
+
const markdownFile = files.find((file) => extname(file.path).toLowerCase() === '.md');
|
|
526
|
+
return markdownFile ? stripIgnoredEveFrontmatter(markdownFile.contents) : '';
|
|
527
|
+
}
|
|
528
|
+
|
|
410
529
|
export async function isSkillInstalled(
|
|
411
530
|
skillName: string,
|
|
412
531
|
agentType: AgentType,
|
|
413
|
-
options: { global?: boolean; cwd?: string } = {}
|
|
532
|
+
options: { global?: boolean; cwd?: string; eveSubagent?: string } = {}
|
|
414
533
|
): Promise<boolean> {
|
|
415
534
|
const agent = agents[agentType];
|
|
416
535
|
const sanitized = sanitizeName(skillName);
|
|
@@ -422,7 +541,9 @@ export async function isSkillInstalled(
|
|
|
422
541
|
|
|
423
542
|
const targetBase = options.global
|
|
424
543
|
? agent.globalSkillsDir!
|
|
425
|
-
:
|
|
544
|
+
: agentType === 'eve' && options.eveSubagent
|
|
545
|
+
? getEveSubagentSkillsDir(options.eveSubagent, options.cwd)
|
|
546
|
+
: join(options.cwd || process.cwd(), agent.skillsDir);
|
|
426
547
|
|
|
427
548
|
const skillDir = join(targetBase, sanitized);
|
|
428
549
|
|
|
@@ -441,13 +562,18 @@ export async function isSkillInstalled(
|
|
|
441
562
|
export function getInstallPath(
|
|
442
563
|
skillName: string,
|
|
443
564
|
agentType: AgentType,
|
|
444
|
-
options: { global?: boolean; cwd?: string } = {}
|
|
565
|
+
options: { global?: boolean; cwd?: string; eveSubagent?: string } = {}
|
|
445
566
|
): string {
|
|
446
567
|
const agent = agents[agentType];
|
|
447
568
|
const cwd = options.cwd || process.cwd();
|
|
448
569
|
const sanitized = sanitizeName(skillName);
|
|
449
570
|
|
|
450
|
-
const targetBase = getAgentBaseDir(
|
|
571
|
+
const targetBase = getAgentBaseDir(
|
|
572
|
+
agentType,
|
|
573
|
+
options.global ?? false,
|
|
574
|
+
options.cwd,
|
|
575
|
+
options.eveSubagent
|
|
576
|
+
);
|
|
451
577
|
const installPath = join(targetBase, sanitized);
|
|
452
578
|
|
|
453
579
|
if (!isPathSafe(targetBase, installPath)) {
|
|
@@ -462,10 +588,13 @@ export function getInstallPath(
|
|
|
462
588
|
*/
|
|
463
589
|
export function getCanonicalPath(
|
|
464
590
|
skillName: string,
|
|
465
|
-
options: { global?: boolean; cwd?: string } = {}
|
|
591
|
+
options: { global?: boolean; cwd?: string; agent?: AgentType; eveSubagent?: string } = {}
|
|
466
592
|
): string {
|
|
467
593
|
const sanitized = sanitizeName(skillName);
|
|
468
|
-
const canonicalBase =
|
|
594
|
+
const canonicalBase =
|
|
595
|
+
options.agent === 'eve'
|
|
596
|
+
? getAgentBaseDir('eve', options.global ?? false, options.cwd, options.eveSubagent)
|
|
597
|
+
: getCanonicalSkillsDir(options.global ?? false, options.cwd);
|
|
469
598
|
const canonicalPath = join(canonicalBase, sanitized);
|
|
470
599
|
|
|
471
600
|
if (!isPathSafe(canonicalBase, canonicalPath)) {
|
|
@@ -484,12 +613,13 @@ export function getCanonicalPath(
|
|
|
484
613
|
export async function installRemoteSkillForAgent(
|
|
485
614
|
skill: RemoteSkill,
|
|
486
615
|
agentType: AgentType,
|
|
487
|
-
options: { global?: boolean; cwd?: string; mode?: InstallMode } = {}
|
|
616
|
+
options: { global?: boolean; cwd?: string; mode?: InstallMode; eveSubagent?: string } = {}
|
|
488
617
|
): Promise<InstallResult> {
|
|
489
618
|
const agent = agents[agentType];
|
|
490
619
|
const isGlobal = options.global ?? false;
|
|
491
620
|
const cwd = options.cwd || process.cwd();
|
|
492
621
|
const installMode = options.mode ?? 'symlink';
|
|
622
|
+
const eveSubagent = options.eveSubagent;
|
|
493
623
|
|
|
494
624
|
// Check if agent supports global installation
|
|
495
625
|
if (isGlobal && agent.globalSkillsDir === undefined) {
|
|
@@ -505,11 +635,14 @@ export async function installRemoteSkillForAgent(
|
|
|
505
635
|
const skillName = sanitizeName(skill.installName);
|
|
506
636
|
|
|
507
637
|
// Canonical location: .agents/skills/<skill-name>
|
|
508
|
-
const canonicalBase =
|
|
638
|
+
const canonicalBase =
|
|
639
|
+
agentType === 'eve' && installMode === 'symlink'
|
|
640
|
+
? getAgentBaseDir(agentType, isGlobal, cwd, eveSubagent)
|
|
641
|
+
: getCanonicalSkillsDir(isGlobal, cwd);
|
|
509
642
|
const canonicalDir = join(canonicalBase, skillName);
|
|
510
643
|
|
|
511
644
|
// Agent-specific location (for symlink)
|
|
512
|
-
const agentBase = getAgentBaseDir(agentType, isGlobal, cwd);
|
|
645
|
+
const agentBase = getAgentBaseDir(agentType, isGlobal, cwd, eveSubagent);
|
|
513
646
|
const agentDir = join(agentBase, skillName);
|
|
514
647
|
|
|
515
648
|
// Validate paths
|
|
@@ -535,8 +668,14 @@ export async function installRemoteSkillForAgent(
|
|
|
535
668
|
// For copy mode, write directly to agent location
|
|
536
669
|
if (installMode === 'copy') {
|
|
537
670
|
await cleanAndCreateDirectory(agentDir);
|
|
538
|
-
const
|
|
539
|
-
|
|
671
|
+
const skillFileName =
|
|
672
|
+
agentType === 'eve' ? toEveFlatSkillFileName(skill.installName) : 'SKILL.md';
|
|
673
|
+
const skillMdPath = join(agentDir, skillFileName);
|
|
674
|
+
await writeFile(
|
|
675
|
+
skillMdPath,
|
|
676
|
+
agentType === 'eve' ? stripIgnoredEveFrontmatter(skill.content) : skill.content,
|
|
677
|
+
'utf-8'
|
|
678
|
+
);
|
|
540
679
|
|
|
541
680
|
return {
|
|
542
681
|
success: true,
|
|
@@ -547,8 +686,14 @@ export async function installRemoteSkillForAgent(
|
|
|
547
686
|
|
|
548
687
|
// Symlink mode: write to canonical location and symlink to agent location
|
|
549
688
|
await cleanAndCreateDirectory(canonicalDir);
|
|
550
|
-
const
|
|
551
|
-
|
|
689
|
+
const skillFileName =
|
|
690
|
+
agentType === 'eve' ? toEveFlatSkillFileName(skill.installName) : 'SKILL.md';
|
|
691
|
+
const skillMdPath = join(canonicalDir, skillFileName);
|
|
692
|
+
await writeFile(
|
|
693
|
+
skillMdPath,
|
|
694
|
+
agentType === 'eve' ? stripIgnoredEveFrontmatter(skill.content) : skill.content,
|
|
695
|
+
'utf-8'
|
|
696
|
+
);
|
|
552
697
|
|
|
553
698
|
// For universal agents with global install, skip creating agent-specific symlink
|
|
554
699
|
if (isGlobal && isUniversalAgent(agentType)) {
|
|
@@ -565,8 +710,14 @@ export async function installRemoteSkillForAgent(
|
|
|
565
710
|
if (!symlinkCreated) {
|
|
566
711
|
// Symlink failed, fall back to copy
|
|
567
712
|
await cleanAndCreateDirectory(agentDir);
|
|
568
|
-
const
|
|
569
|
-
|
|
713
|
+
const agentSkillFileName =
|
|
714
|
+
agentType === 'eve' ? toEveFlatSkillFileName(skill.installName) : 'SKILL.md';
|
|
715
|
+
const agentSkillMdPath = join(agentDir, agentSkillFileName);
|
|
716
|
+
await writeFile(
|
|
717
|
+
agentSkillMdPath,
|
|
718
|
+
agentType === 'eve' ? stripIgnoredEveFrontmatter(skill.content) : skill.content,
|
|
719
|
+
'utf-8'
|
|
720
|
+
);
|
|
570
721
|
|
|
571
722
|
return {
|
|
572
723
|
success: true,
|
|
@@ -603,12 +754,13 @@ export async function installRemoteSkillForAgent(
|
|
|
603
754
|
export async function installWellKnownSkillForAgent(
|
|
604
755
|
skill: WellKnownSkill,
|
|
605
756
|
agentType: AgentType,
|
|
606
|
-
options: { global?: boolean; cwd?: string; mode?: InstallMode } = {}
|
|
757
|
+
options: { global?: boolean; cwd?: string; mode?: InstallMode; eveSubagent?: string } = {}
|
|
607
758
|
): Promise<InstallResult> {
|
|
608
759
|
const agent = agents[agentType];
|
|
609
760
|
const isGlobal = options.global ?? false;
|
|
610
761
|
const cwd = options.cwd || process.cwd();
|
|
611
762
|
const installMode = options.mode ?? 'symlink';
|
|
763
|
+
const eveSubagent = options.eveSubagent;
|
|
612
764
|
|
|
613
765
|
// Check if agent supports global installation
|
|
614
766
|
if (isGlobal && agent.globalSkillsDir === undefined) {
|
|
@@ -624,11 +776,14 @@ export async function installWellKnownSkillForAgent(
|
|
|
624
776
|
const skillName = sanitizeName(skill.installName);
|
|
625
777
|
|
|
626
778
|
// Canonical location: .agents/skills/<skill-name>
|
|
627
|
-
const canonicalBase =
|
|
779
|
+
const canonicalBase =
|
|
780
|
+
agentType === 'eve' && installMode === 'symlink'
|
|
781
|
+
? getAgentBaseDir(agentType, isGlobal, cwd, eveSubagent)
|
|
782
|
+
: getCanonicalSkillsDir(isGlobal, cwd);
|
|
628
783
|
const canonicalDir = join(canonicalBase, skillName);
|
|
629
784
|
|
|
630
785
|
// Agent-specific location (for symlink)
|
|
631
|
-
const agentBase = getAgentBaseDir(agentType, isGlobal, cwd);
|
|
786
|
+
const agentBase = getAgentBaseDir(agentType, isGlobal, cwd, eveSubagent);
|
|
632
787
|
const agentDir = join(agentBase, skillName);
|
|
633
788
|
|
|
634
789
|
// Validate paths
|
|
@@ -667,7 +822,14 @@ export async function installWellKnownSkillForAgent(
|
|
|
667
822
|
await mkdir(parentDir, { recursive: true });
|
|
668
823
|
}
|
|
669
824
|
|
|
670
|
-
await writeFile(
|
|
825
|
+
await writeFile(
|
|
826
|
+
fullPath,
|
|
827
|
+
agentType === 'eve' &&
|
|
828
|
+
basename(filePath).toLowerCase() === 'skill.md' &&
|
|
829
|
+
typeof content === 'string'
|
|
830
|
+
? stripIgnoredEveFrontmatter(content)
|
|
831
|
+
: content
|
|
832
|
+
);
|
|
671
833
|
}
|
|
672
834
|
}
|
|
673
835
|
|
|
@@ -738,12 +900,13 @@ export async function installWellKnownSkillForAgent(
|
|
|
738
900
|
export async function installBlobSkillForAgent(
|
|
739
901
|
skill: { installName: string; files: Array<{ path: string; contents: string }> },
|
|
740
902
|
agentType: AgentType,
|
|
741
|
-
options: { global?: boolean; cwd?: string; mode?: InstallMode } = {}
|
|
903
|
+
options: { global?: boolean; cwd?: string; mode?: InstallMode; eveSubagent?: string } = {}
|
|
742
904
|
): Promise<InstallResult> {
|
|
743
905
|
const agent = agents[agentType];
|
|
744
906
|
const isGlobal = options.global ?? false;
|
|
745
907
|
const cwd = options.cwd || process.cwd();
|
|
746
908
|
const installMode = options.mode ?? 'symlink';
|
|
909
|
+
const eveSubagent = options.eveSubagent;
|
|
747
910
|
|
|
748
911
|
if (isGlobal && agent.globalSkillsDir === undefined) {
|
|
749
912
|
return {
|
|
@@ -755,9 +918,39 @@ export async function installBlobSkillForAgent(
|
|
|
755
918
|
}
|
|
756
919
|
|
|
757
920
|
const skillName = sanitizeName(skill.installName);
|
|
758
|
-
const
|
|
921
|
+
const agentBase = getAgentBaseDir(agentType, isGlobal, cwd, eveSubagent);
|
|
922
|
+
|
|
923
|
+
if (agentType === 'eve' && !isEvePackagedSkill(skill.files)) {
|
|
924
|
+
const flatSkillPath = join(agentBase, toEveFlatSkillFileName(skill.installName));
|
|
925
|
+
if (!isPathSafe(agentBase, flatSkillPath)) {
|
|
926
|
+
return {
|
|
927
|
+
success: false,
|
|
928
|
+
path: flatSkillPath,
|
|
929
|
+
mode: installMode,
|
|
930
|
+
error: 'Invalid skill name: potential path traversal detected',
|
|
931
|
+
};
|
|
932
|
+
}
|
|
933
|
+
|
|
934
|
+
try {
|
|
935
|
+
await mkdir(agentBase, { recursive: true });
|
|
936
|
+
await rm(flatSkillPath, { recursive: true, force: true });
|
|
937
|
+
await writeFile(flatSkillPath, getEveFlatSkillMarkdown(skill.files), 'utf-8');
|
|
938
|
+
return { success: true, path: flatSkillPath, mode: 'copy' };
|
|
939
|
+
} catch (error) {
|
|
940
|
+
return {
|
|
941
|
+
success: false,
|
|
942
|
+
path: flatSkillPath,
|
|
943
|
+
mode: installMode,
|
|
944
|
+
error: error instanceof Error ? error.message : 'Unknown error',
|
|
945
|
+
};
|
|
946
|
+
}
|
|
947
|
+
}
|
|
948
|
+
|
|
949
|
+
const canonicalBase =
|
|
950
|
+
agentType === 'eve' && installMode === 'symlink'
|
|
951
|
+
? getAgentBaseDir(agentType, isGlobal, cwd, eveSubagent)
|
|
952
|
+
: getCanonicalSkillsDir(isGlobal, cwd);
|
|
759
953
|
const canonicalDir = join(canonicalBase, skillName);
|
|
760
|
-
const agentBase = getAgentBaseDir(agentType, isGlobal, cwd);
|
|
761
954
|
const agentDir = join(agentBase, skillName);
|
|
762
955
|
|
|
763
956
|
if (!isPathSafe(canonicalBase, canonicalDir)) {
|
|
@@ -788,7 +981,13 @@ export async function installBlobSkillForAgent(
|
|
|
788
981
|
await mkdir(parentDir, { recursive: true });
|
|
789
982
|
}
|
|
790
983
|
|
|
791
|
-
await writeFile(
|
|
984
|
+
await writeFile(
|
|
985
|
+
fullPath,
|
|
986
|
+
agentType === 'eve' && basename(file.path).toLowerCase() === 'skill.md'
|
|
987
|
+
? stripIgnoredEveFrontmatter(file.contents)
|
|
988
|
+
: file.contents,
|
|
989
|
+
'utf-8'
|
|
990
|
+
);
|
|
792
991
|
}
|
|
793
992
|
}
|
|
794
993
|
|
|
@@ -932,6 +1131,17 @@ export async function listInstalledSkills(
|
|
|
932
1131
|
if (!scopes.some((s) => s.path === agentDir && s.global === isGlobal)) {
|
|
933
1132
|
scopes.push({ global: isGlobal, path: agentDir, agentType });
|
|
934
1133
|
}
|
|
1134
|
+
|
|
1135
|
+
// Eve subagents keep their skills under agent/subagents/<name>/skills.
|
|
1136
|
+
// These are project-scoped, so only scan them for the project scope.
|
|
1137
|
+
if (agentType === 'eve' && !isGlobal) {
|
|
1138
|
+
for (const subagent of getEveSubagents(cwd)) {
|
|
1139
|
+
const subagentDir = getEveSubagentSkillsDir(subagent, cwd);
|
|
1140
|
+
if (!scopes.some((s) => s.path === subagentDir && s.global === isGlobal)) {
|
|
1141
|
+
scopes.push({ global: isGlobal, path: subagentDir, agentType });
|
|
1142
|
+
}
|
|
1143
|
+
}
|
|
1144
|
+
}
|
|
935
1145
|
}
|
|
936
1146
|
|
|
937
1147
|
// Also scan skill directories for agents NOT in agentsToCheck, in case
|
|
@@ -33,6 +33,13 @@ export interface LocalSkillLockEntry {
|
|
|
33
33
|
* computes the hash from actual file contents on disk.
|
|
34
34
|
*/
|
|
35
35
|
computedHash: string;
|
|
36
|
+
/**
|
|
37
|
+
* Eve subagent targets this skill was installed into, so `update` can
|
|
38
|
+
* restore the same placement. Each entry is an Eve subagent directory name;
|
|
39
|
+
* the empty string `''` denotes the root agent (`agent/skills`). Omitted for
|
|
40
|
+
* non-Eve installs and for plain Eve root installs (treated as `['']`).
|
|
41
|
+
*/
|
|
42
|
+
subagents?: string[];
|
|
36
43
|
}
|
|
37
44
|
|
|
38
45
|
/**
|