@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.
@@ -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 { agents, detectInstalledAgents, isUniversalAgent } from './agents.ts';
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(agentType: AgentType, global: boolean, cwd?: string): string {
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(relativePath, linkPath, symlinkType);
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 = getCanonicalSkillsDir(isGlobal, cwd);
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
- async function copyDirectory(src: string, dest: string): Promise<void> {
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
- : join(options.cwd || process.cwd(), agent.skillsDir);
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(agentType, options.global ?? false, options.cwd);
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 = getCanonicalSkillsDir(options.global ?? false, options.cwd);
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 = getCanonicalSkillsDir(isGlobal, cwd);
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 skillMdPath = join(agentDir, 'SKILL.md');
539
- await writeFile(skillMdPath, skill.content, 'utf-8');
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 skillMdPath = join(canonicalDir, 'SKILL.md');
551
- await writeFile(skillMdPath, skill.content, 'utf-8');
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 agentSkillMdPath = join(agentDir, 'SKILL.md');
569
- await writeFile(agentSkillMdPath, skill.content, 'utf-8');
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 = getCanonicalSkillsDir(isGlobal, cwd);
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(fullPath, content);
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 canonicalBase = getCanonicalSkillsDir(isGlobal, cwd);
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(fullPath, file.contents, 'utf-8');
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
  /**
@@ -2,7 +2,7 @@ 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.ts';
5
+ import { agents, detectInstalledAgents, getEveSubagents } from './agents.ts';
6
6
  import { track } from './telemetry.ts';
7
7
  import { detectAgent } from './detect-agent.ts';
8
8
  import { removeSkillFromLock, getSkillFromLock } from './skill-lock.ts';
@@ -11,6 +11,7 @@ import {
11
11
  getInstallPath,
12
12
  getCanonicalPath,
13
13
  getCanonicalSkillsDir,
14
+ getEveSubagentSkillsDir,
14
15
  sanitizeName,
15
16
  } from './installer.ts';
16
17
 
@@ -68,6 +69,10 @@ export async function removeCommand(skillNames: string[], options: RemoveOptions
68
69
  for (const agent of Object.values(agents)) {
69
70
  await scanDir(join(cwd, agent.skillsDir));
70
71
  }
72
+ // Eve subagents keep their skills under agent/subagents/<name>/skills.
73
+ for (const subagent of getEveSubagents(cwd)) {
74
+ await scanDir(getEveSubagentSkillsDir(subagent, cwd));
75
+ }
71
76
  }
72
77
 
73
78
  const installedSkills = Array.from(skillNamesSet).sort();
@@ -178,6 +183,12 @@ export async function removeCommand(skillNames: string[], options: RemoveOptions
178
183
  pathsToCleanup.add(join(agent.globalSkillsDir, sanitizedName));
179
184
  } else {
180
185
  pathsToCleanup.add(join(cwd, agent.skillsDir, sanitizedName));
186
+ // Eve skills may also live in subagent directories.
187
+ if (agentKey === 'eve') {
188
+ for (const subagent of getEveSubagents(cwd)) {
189
+ pathsToCleanup.add(join(getEveSubagentSkillsDir(subagent, cwd), sanitizedName));
190
+ }
191
+ }
181
192
  }
182
193
 
183
194
  for (const pathToCleanup of pathsToCleanup) {