@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.
@@ -1,6 +1,6 @@
1
1
  import { homedir } from 'os';
2
2
  import { join } from 'path';
3
- import { existsSync } from 'fs';
3
+ import { existsSync, readFileSync, readdirSync } from 'fs';
4
4
  import { xdgConfig } from 'xdg-basedir';
5
5
  import type { AgentConfig, AgentType } from './types.ts';
6
6
 
@@ -21,6 +21,20 @@ const autohandHome = process.env.AUTOHAND_HOME?.trim() || join(home, '.autohand'
21
21
  const zedAppDataHome = process.env.APPDATA?.trim();
22
22
  const zedFlatpakConfigHome = process.env.FLATPAK_XDG_CONFIG_HOME?.trim();
23
23
 
24
+ function packageJsonHasDependency(packageJsonPath: string, dependencyName: string): boolean {
25
+ try {
26
+ const packageJson = JSON.parse(readFileSync(packageJsonPath, 'utf-8')) as {
27
+ dependencies?: Record<string, unknown>;
28
+ devDependencies?: Record<string, unknown>;
29
+ };
30
+ return !!(
31
+ packageJson.dependencies?.[dependencyName] || packageJson.devDependencies?.[dependencyName]
32
+ );
33
+ } catch {
34
+ return false;
35
+ }
36
+ }
37
+
24
38
  export function getOpenClawGlobalSkillsDir(
25
39
  homeDir = home,
26
40
  pathExists: (path: string) => boolean = existsSync
@@ -268,6 +282,18 @@ export const agents: Record<AgentType, AgentConfig> = {
268
282
  return existsSync(join(home, '.factory'));
269
283
  },
270
284
  },
285
+ eve: {
286
+ name: 'eve',
287
+ displayName: 'Eve',
288
+ skillsDir: 'agent/skills',
289
+ globalSkillsDir: undefined,
290
+ detectInstalled: async () => {
291
+ const cwd = process.cwd();
292
+ return (
293
+ existsSync(join(cwd, 'agent')) && packageJsonHasDependency(join(cwd, 'package.json'), 'eve')
294
+ );
295
+ },
296
+ },
271
297
  firebender: {
272
298
  name: 'firebender',
273
299
  displayName: 'Firebender',
@@ -709,6 +735,36 @@ export function getAgentConfig(type: AgentType): AgentConfig {
709
735
  return agents[type];
710
736
  }
711
737
 
738
+ /**
739
+ * Directory (relative to an Eve project root) that holds subagents.
740
+ * Each subagent owns its own skills at `agent/subagents/<name>/skills`,
741
+ * mirroring the root agent's `agent/skills`.
742
+ */
743
+ export const EVE_SUBAGENTS_DIR = join('agent', 'subagents');
744
+
745
+ /**
746
+ * Discover the names of Eve subagents in a project.
747
+ *
748
+ * Eve supports subagents that each have their own skills directory at
749
+ * `agent/subagents/<name>/skills`. This returns the `<name>` of every
750
+ * subagent directory found under `agent/subagents/`, sorted alphabetically.
751
+ * Returns an empty list when the directory doesn't exist or can't be read.
752
+ */
753
+ export function getEveSubagents(cwd: string = process.cwd()): string[] {
754
+ const dir = join(cwd, EVE_SUBAGENTS_DIR);
755
+ if (!existsSync(dir)) {
756
+ return [];
757
+ }
758
+ try {
759
+ return readdirSync(dir, { withFileTypes: true })
760
+ .filter((entry) => entry.isDirectory())
761
+ .map((entry) => entry.name)
762
+ .sort();
763
+ } catch {
764
+ return [];
765
+ }
766
+ }
767
+
712
768
  /**
713
769
  * Returns agents that use the universal .agents/skills directory.
714
770
  * These agents share a common skill location and don't need symlinks.
@@ -10,6 +10,7 @@
10
10
  * 3. skills.sh/api/download → fetch full file contents from cached blob
11
11
  */
12
12
 
13
+ import { createHash } from 'node:crypto';
13
14
  import { parseFrontmatter } from './frontmatter.ts';
14
15
  import { sanitizeMetadata } from './sanitize.ts';
15
16
  import type { Skill } from './types.ts';
@@ -420,6 +421,15 @@ export interface BlobInstallResult {
420
421
  tree: RepoTree;
421
422
  }
422
423
 
424
+ function computeSnapshotHash(files: SkillSnapshotFile[]): string {
425
+ const hash = createHash('sha256');
426
+ for (const file of [...files].sort((a, b) => a.path.localeCompare(b.path))) {
427
+ hash.update(file.path);
428
+ hash.update(file.contents);
429
+ }
430
+ return hash.digest('hex');
431
+ }
432
+
423
433
  /**
424
434
  * Attempt to resolve skills from blob storage instead of cloning.
425
435
  *
@@ -549,6 +559,16 @@ export async function tryBlobInstall(
549
559
  ? ''
550
560
  : skill.mdPath.slice(0, -(1 + 'SKILL.md'.length));
551
561
 
562
+ // A root-level SKILL.md means the repository root is a skill entrypoint,
563
+ // not that the entire repository is installable skill payload. Some cached
564
+ // snapshots for root skills contain every repo file; installing those can
565
+ // dump thousands of unrelated files into .agents/skills/<name>. Keep root
566
+ // skills to their SKILL.md unless/until the skill spec gains an explicit
567
+ // include list for supporting files.
568
+ const files = folderPath
569
+ ? download!.files
570
+ : download!.files.filter((file) => file.path.toLowerCase() === 'skill.md');
571
+
552
572
  return {
553
573
  name: skill.name,
554
574
  description: skill.description,
@@ -557,8 +577,9 @@ export async function tryBlobInstall(
557
577
  path: '',
558
578
  rawContent: skill.content,
559
579
  metadata: skill.metadata,
560
- files: download!.files,
561
- snapshotHash: download!.hash,
580
+ files,
581
+ snapshotHash:
582
+ files.length === download!.files.length ? download!.hash : computeSnapshotHash(files),
562
583
  repoPath: skill.mdPath,
563
584
  };
564
585
  });
@@ -3,7 +3,7 @@
3
3
  import { writeFileSync, readFileSync, existsSync, mkdirSync } from 'fs';
4
4
  import { basename, join, dirname } from 'path';
5
5
  import { fileURLToPath } from 'url';
6
- import { runAdd, parseAddOptions, initTelemetry } from './add.ts';
6
+ import { runAdd, parseAddOptions } from './add.ts';
7
7
  import { runFind } from './find.ts';
8
8
  import { runInstallFromLock } from './install.ts';
9
9
  import { runList } from './list.ts';
@@ -27,7 +27,6 @@ function getVersion(): string {
27
27
  }
28
28
 
29
29
  const VERSION = getVersion();
30
- initTelemetry(VERSION);
31
30
 
32
31
  const RESET = '\x1b[0m';
33
32
  const BOLD = '\x1b[1m';
@@ -116,6 +115,9 @@ ${BOLD}Manage Skills:${RESET}
116
115
  list, ls List installed skills
117
116
  find [query] Search for skills interactively
118
117
 
118
+ ${BOLD}Find Options:${RESET}
119
+ --owner <owner> Search only repositories from a GitHub owner
120
+
119
121
  ${BOLD}Updates:${RESET}
120
122
  update [skills...] Update skills to latest versions (alias: upgrade)
121
123
 
@@ -136,6 +138,7 @@ ${BOLD}Add Options:${RESET}
136
138
  -l, --list List available skills in the repository without installing
137
139
  -y, --yes Skip confirmation prompts
138
140
  --copy Copy files instead of symlinking to agent directories
141
+ --subagent <names> Install to Eve subagents (use 'root' for the root agent)
139
142
  --all Shorthand for --skill '*' --agent '*' -y
140
143
  --full-depth Search all subdirectories even when a root SKILL.md exists
141
144
 
@@ -182,6 +185,7 @@ ${BOLD}Examples:${RESET}
182
185
  ${DIM}$${RESET} skills ls --json ${DIM}# JSON output${RESET}
183
186
  ${DIM}$${RESET} skills find ${DIM}# interactive search${RESET}
184
187
  ${DIM}$${RESET} skills find typescript ${DIM}# search by keyword${RESET}
188
+ ${DIM}$${RESET} skills find react --owner vercel ${DIM}# search within an owner${RESET}
185
189
  ${DIM}$${RESET} skills update
186
190
  ${DIM}$${RESET} skills update my-skill ${DIM}# update a single skill${RESET}
187
191
  ${DIM}$${RESET} skills update -g ${DIM}# update global skills only${RESET}
@@ -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 url = `${SEARCH_API_BASE}/api/search?q=${encodeURIComponent(query)}&limit=10`;
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.join(' ');
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
- console.log(`${DIM}No skills found for "${query}"${RESET}`);
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>${RESET}`);
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, options);
404
+ const { source, options: addOptions } = parseAddOptions([pkg, '--skill', skillName]);
405
+ await runAdd(source, addOptions);
344
406
 
345
407
  console.log();
346
408
 
@@ -22,7 +22,7 @@ export async function runInstallFromLock(args: string[]): Promise<void> {
22
22
  if (skillEntries.length === 0) {
23
23
  p.log.warn('No project skills found in skills-lock.json');
24
24
  p.log.info(
25
- `Add project-level skills with ${pc.cyan('npx skills add <package>')} (without ${pc.cyan('-g')})`
25
+ `Add project-level skills with ${pc.cyan('adg skills add <package>')} (without ${pc.cyan('-g')})`
26
26
  );
27
27
  return;
28
28
  }