@rbbtsn0w/adg 0.10.1-dev.pr151.b79dccc → 0.10.1-dev.pr152.b8c43a6

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.
@@ -17,6 +17,7 @@ const vibeHome = process.env.VIBE_HOME?.trim() || join(home, '.vibe');
17
17
  const hermesHome = process.env.HERMES_HOME?.trim() || join(home, '.hermes');
18
18
  const autohandHome = process.env.AUTOHAND_HOME?.trim() || join(home, '.autohand');
19
19
  const grokHome = process.env.GROK_HOME?.trim() || join(home, '.grok');
20
+ const sarvamHome = process.env.SARVAM_HOME?.trim() || join(home, '.sarvam');
20
21
  const zedAppDataHome = process.env.APPDATA?.trim();
21
22
  const zedFlatpakConfigHome = process.env.FLATPAK_XDG_CONFIG_HOME?.trim();
22
23
  function packageJsonHasDependency(packageJsonPath, dependencyName) {
@@ -78,6 +79,7 @@ export const agents = {
78
79
  displayName: 'Antigravity',
79
80
  skillsDir: '.agents/skills',
80
81
  globalSkillsDir: join(home, '.gemini/antigravity/skills'),
82
+ showInUniversalPrompt: false,
81
83
  detectInstalled: async () => {
82
84
  return existsSync(join(home, '.gemini/antigravity'));
83
85
  },
@@ -87,6 +89,7 @@ export const agents = {
87
89
  displayName: 'Antigravity CLI',
88
90
  skillsDir: '.agents/skills',
89
91
  globalSkillsDir: join(home, '.gemini/antigravity-cli/skills'),
92
+ showInUniversalPrompt: false,
90
93
  detectInstalled: async () => {
91
94
  return existsSync(join(home, '.gemini/antigravity-cli'));
92
95
  },
@@ -132,6 +135,8 @@ export const agents = {
132
135
  displayName: 'Claude Code',
133
136
  skillsDir: '.claude/skills',
134
137
  globalSkillsDir: join(claudeHome, 'skills'),
138
+ // Preserve the established project-install behavior from #1138 and #1607.
139
+ createProjectSkillsDirByDefault: true,
135
140
  detectInstalled: async () => {
136
141
  return existsSync(claudeHome);
137
142
  },
@@ -196,7 +201,7 @@ export const agents = {
196
201
  name: 'codex',
197
202
  displayName: 'Codex',
198
203
  skillsDir: '.agents/skills',
199
- globalSkillsDir: join(codexHome, 'skills'),
204
+ globalSkillsDir: join(home, '.agents', 'skills'),
200
205
  detectInstalled: async () => {
201
206
  return existsSync(codexHome) || existsSync('/etc/codex');
202
207
  },
@@ -251,6 +256,7 @@ export const agents = {
251
256
  displayName: 'Deep Agents',
252
257
  skillsDir: '.agents/skills',
253
258
  globalSkillsDir: join(home, '.deepagents/agent/skills'),
259
+ showInUniversalPrompt: false,
254
260
  detectInstalled: async () => {
255
261
  return existsSync(join(home, '.deepagents'));
256
262
  },
@@ -277,7 +283,11 @@ export const agents = {
277
283
  droid: {
278
284
  name: 'droid',
279
285
  displayName: 'Droid',
280
- skillsDir: '.factory/skills',
286
+ // Droid reads .agents/skills and ~/.agents/skills as compatibility
287
+ // locations, so installing there avoids defining the same skill twice.
288
+ // globalSkillsDir stays on ~/.factory/skills so `remove` still cleans up
289
+ // skills placed there by earlier versions.
290
+ skillsDir: '.agents/skills',
281
291
  globalSkillsDir: join(home, '.factory/skills'),
282
292
  detectInstalled: async () => {
283
293
  return existsSync(join(home, '.factory'));
@@ -312,6 +322,16 @@ export const agents = {
312
322
  return existsSync(join(home, '.forge'));
313
323
  },
314
324
  },
325
+ fx: {
326
+ name: 'fx',
327
+ displayName: 'fx',
328
+ // fx discovers these shared roots natively alongside its own .fx/skills roots.
329
+ skillsDir: '.agents/skills',
330
+ globalSkillsDir: join(home, '.agents/skills'),
331
+ detectInstalled: async () => {
332
+ return existsSync(join(home, '.fx'));
333
+ },
334
+ },
315
335
  'gemini-cli': {
316
336
  name: 'gemini-cli',
317
337
  displayName: 'Gemini CLI',
@@ -396,10 +416,12 @@ export const agents = {
396
416
  kilo: {
397
417
  name: 'kilo',
398
418
  displayName: 'Kilo Code',
399
- skillsDir: '.kilocode/skills',
400
- globalSkillsDir: join(home, '.kilocode/skills'),
419
+ skillsDir: '.agents/skills',
420
+ globalSkillsDir: join(home, '.kilo/skills'),
401
421
  detectInstalled: async () => {
402
- return existsSync(join(home, '.kilocode'));
422
+ // `.kilocode` is the legacy config directory, kept here so existing
423
+ // installs are still detected.
424
+ return existsSync(join(home, '.kilo')) || existsSync(join(home, '.kilocode'));
403
425
  },
404
426
  },
405
427
  kimchi: {
@@ -532,8 +554,11 @@ export const agents = {
532
554
  pi: {
533
555
  name: 'pi',
534
556
  displayName: 'Pi',
535
- skillsDir: '.pi/skills',
536
- globalSkillsDir: join(home, '.pi/agent/skills'),
557
+ // Pi natively reads the Agent Skills locations: `.agents/skills/` from the working
558
+ // directory up through its ancestors, and `~/.agents/skills/` globally.
559
+ // See https://github.com/badlogic/pi-mono/blob/main/packages/coding-agent/docs/skills.md
560
+ skillsDir: '.agents/skills',
561
+ globalSkillsDir: join(home, '.agents/skills'),
537
562
  detectInstalled: async () => {
538
563
  return existsSync(join(home, '.pi/agent'));
539
564
  },
@@ -611,6 +636,16 @@ export const agents = {
611
636
  return existsSync(join(home, '.roo'));
612
637
  },
613
638
  },
639
+ 'sarvam-code': {
640
+ name: 'sarvam-code',
641
+ displayName: 'Sarvam Code',
642
+ skillsDir: '.agents/skills',
643
+ globalSkillsDir: join(home, '.agents/skills'),
644
+ showInUniversalPrompt: false,
645
+ detectInstalled: async () => {
646
+ return existsSync(sarvamHome);
647
+ },
648
+ },
614
649
  'tabnine-cli': {
615
650
  name: 'tabnine-cli',
616
651
  displayName: 'Tabnine CLI',
@@ -75,11 +75,10 @@ async function fetchTreeBranch(ownerRepo, branch, token) {
75
75
  }
76
76
  // GitHub signals rate-limit with 403 + X-RateLimit-Remaining: 0.
77
77
  const rateLimited = response.status === 403 && response.headers.get('x-ratelimit-remaining') === '0';
78
- // ADG patch: a 401/403/404 from an UNauthenticated request may just mean the
79
- // repo is private — retry with a token before giving up. GitHub returns 404
80
- // (not 403) for private repos to anonymous callers to avoid leaking existence.
81
- const authMayHelp = !rateLimited &&
82
- (response.status === 401 || response.status === 403 || response.status === 404);
78
+ // A private repo answers 401/404 to an anonymous request (GitHub hides its
79
+ // existence); a token may turn that into a 200. See issue #1318.
80
+ // ADG patch: permission-denied responses can also require authentication.
81
+ const authMayHelp = response.status === 401 || response.status === 403 || response.status === 404;
83
82
  return { tree: null, rateLimited, authMayHelp };
84
83
  }
85
84
  catch {
@@ -108,7 +107,12 @@ async function fetchTreeWithGitHubCli(ownerRepo, branches) {
108
107
  maxBuffer: GH_API_MAX_BUFFER,
109
108
  windowsHide: true,
110
109
  env: { ...process.env, GH_PROMPT_DISABLED: '1' },
111
- }, (error, output) => (error ? reject(error) : resolve(output)));
110
+ }, (error, output) => {
111
+ if (error)
112
+ reject(error);
113
+ else
114
+ resolve(output);
115
+ });
112
116
  });
113
117
  const data = JSON.parse(stdout);
114
118
  if (typeof data.sha !== 'string' || !Array.isArray(data.tree))
@@ -116,7 +120,7 @@ async function fetchTreeWithGitHubCli(ownerRepo, branches) {
116
120
  return { sha: data.sha, branch, tree: data.tree };
117
121
  }
118
122
  catch {
119
- // Try the next branch, then let the caller fall back to git clone.
123
+ // Try the next candidate branch, then let the caller fall back to clone.
120
124
  }
121
125
  }
122
126
  return null;
@@ -135,11 +139,13 @@ async function fetchTreeWithAvailableAuth(ownerRepo, branches, getToken) {
135
139
  * Tries branches in order: ref (if specified), then main, then master.
136
140
  *
137
141
  * Authentication is lazy: by default the call goes out unauthenticated,
138
- * which is enough for the vast majority of users (60 req/hr per IP).
139
- * Only if GitHub responds with a rate-limit 403 do we ask the optional
140
- * `getToken` callback for a token and retry. This avoids invoking
141
- * `gh auth token` on every install, which corporate endpoint security
142
- * tools flag as suspicious credential extraction. See issue #523.
142
+ * which is enough for the vast majority of users (60 req/hr per IP). We only
143
+ * retry with available authentication when the unauthenticated attempt fails
144
+ * in a way credentials can fix: a rate-limit 403, or the 401/404 a private repo
145
+ * returns to anonymous requests. Explicit environment tokens are tried first;
146
+ * then `gh api` uses GitHub CLI authentication without exporting its stored
147
+ * credential. ADG also retries a permission-denied 403 when an auth resolver
148
+ * is supplied. See issues #523 and #1318.
143
149
  */
144
150
  export async function fetchRepoTree(ownerRepo, ref, getToken) {
145
151
  const branches = ref ? [ref] : ['HEAD', 'main', 'master'];
@@ -161,20 +167,15 @@ export async function fetchRepoTree(ownerRepo, ref, getToken) {
161
167
  rateLimited = true;
162
168
  break;
163
169
  }
164
- // ADG patch: remember a possible-private signal, but keep trying the other
165
- // candidate branches unauthenticated first (the repo may just lack `main`).
166
170
  if (result.authMayHelp) {
171
+ // ADG patch: exhaust anonymous branch candidates before requesting a token.
167
172
  authMayHelp = true;
168
- break;
169
173
  }
170
174
  }
171
- // ADG patch: fall back to an authenticated retry on EITHER a rate limit or a
172
- // private/forbidden response. Upstream only retried on rate limit, so private
173
- // repos never used the token and always failed.
174
- if ((!rateLimited && !authMayHelp) || (!getToken && getGitHubHost() === 'github.com')) {
175
+ if (!(rateLimited || authMayHelp) || (!getToken && getGitHubHost() === 'github.com'))
175
176
  return null;
176
- }
177
- // Only a rate limit is a process-wide condition worth short-circuiting later.
177
+ // Remember an IP-level rate limit so later calls skip the unauth pass.
178
+ // A private-repo 404 is per-repo, not per-IP, so it must not set this flag.
178
179
  if (rateLimited)
179
180
  _rateLimitedThisSession = true;
180
181
  return fetchTreeWithAvailableAuth(ownerRepo, branches, getToken);
@@ -217,21 +218,28 @@ const PRIORITY_PREFIXES = [
217
218
  '.codex/skills/',
218
219
  '.commandcode/skills/',
219
220
  '.continue/skills/',
221
+ '.factory/skills/',
220
222
  '.github/skills/',
221
223
  '.goose/skills/',
224
+ '.grok/skills/',
222
225
  '.iflow/skills/',
223
226
  '.junie/skills/',
227
+ '.kilo/skills/',
224
228
  '.kilocode/skills/',
229
+ '.kimchi/skills/',
225
230
  '.kiro/skills/',
231
+ '.minimax/skills/',
226
232
  '.mux/skills/',
227
233
  '.neovate/skills/',
228
234
  '.opencode/skills/',
229
235
  '.openhands/skills/',
230
236
  '.pi/skills/',
237
+ '.posit/assistant/skills/',
231
238
  '.qoder/skills/',
232
239
  '.roo/skills/',
233
240
  '.trae/skills/',
234
241
  '.windsurf/skills/',
242
+ '.zcode/skills/',
235
243
  '.zencoder/skills/',
236
244
  ];
237
245
  /**
@@ -252,7 +260,7 @@ export function findSkillMdPaths(tree, subpath) {
252
260
  if (filtered.length === 0)
253
261
  return [];
254
262
  // Check priority directories first (same order as discoverSkills).
255
- // Non-root prefixes also accept depth-2 paths so the blob fast path stays
263
+ // Non-root prefixes also accept paths up to depth 3 so the blob fast path stays
256
264
  // in sync with the on-disk walk's catalog-layout discovery.
257
265
  const priorityResults = [];
258
266
  const seen = new Set();
@@ -285,17 +293,22 @@ export function findSkillMdPaths(tree, subpath) {
285
293
  }
286
294
  continue;
287
295
  }
288
- // SKILL.md two levels deep under a known container prefix
289
- // (e.g., "skills/<category>/<skill>/SKILL.md"). Skip if the parent
290
- // child dir already has its own SKILL.md (no descent past), or if
296
+ // SKILL.md two or three levels deep under a known container prefix
297
+ // (e.g., "skills/<category>/<category>/<skill>/SKILL.md"). Skip if an
298
+ // ancestor dir already has its own SKILL.md (no descent past), or if
291
299
  // any path segment is an ignored directory.
300
+ const skillDirs = parts.slice(0, -1);
301
+ const hasAncestorSkill = skillDirs.slice(0, -1).some((_, index) => {
302
+ const ancestorPath = skillDirs.slice(0, index + 1).join('/');
303
+ return lowerSkillMdSet.has(`${fullPrefix}${ancestorPath}/SKILL.md`.toLowerCase());
304
+ });
292
305
  if (isContainer &&
293
- parts.length === 3 &&
294
- parts[2].toLowerCase() === 'skill.md' &&
295
- !SKIP_DIRS.has(parts[0]) &&
296
- !SKIP_DIRS.has(parts[1])) {
297
- const parentSkillMd = `${fullPrefix}${parts[0]}/SKILL.md`.toLowerCase();
298
- if (!lowerSkillMdSet.has(parentSkillMd) && !seen.has(skillMd)) {
306
+ parts.length >= 3 &&
307
+ parts.length <= DEFAULT_SKILL_CONTAINER_DEPTH + 1 &&
308
+ parts.at(-1).toLowerCase() === 'skill.md' &&
309
+ skillDirs.every((part) => !SKIP_DIRS.has(part)) &&
310
+ !hasAncestorSkill) {
311
+ if (!seen.has(skillMd)) {
299
312
  priorityResults.push(skillMd);
300
313
  seen.add(skillMd);
301
314
  }
@@ -360,6 +373,39 @@ function computeSnapshotHash(files) {
360
373
  }
361
374
  return hash.digest('hex');
362
375
  }
376
+ function getSkillFolderPath(skillMdPath) {
377
+ const pathLower = skillMdPath.toLowerCase();
378
+ if (pathLower.endsWith('/skill.md'))
379
+ return skillMdPath.slice(0, -9);
380
+ if (pathLower === 'skill.md')
381
+ return '';
382
+ return skillMdPath.slice(0, -(1 + 'SKILL.md'.length));
383
+ }
384
+ // Keep these exclusions aligned with copyDirectory() in installer.ts. Cached
385
+ // snapshots do not need files that the normal clone installer intentionally
386
+ // omits, but every other repository blob in a nested skill must be present.
387
+ const SNAPSHOT_EXCLUDED_FILES = new Set(['metadata.json']);
388
+ const SNAPSHOT_EXCLUDED_DIRS = new Set(['.git', '__pycache__', '__pypackages__']);
389
+ function isInstallableSnapshotPath(path) {
390
+ const parts = path.split('/');
391
+ const fileName = parts.at(-1);
392
+ if (!fileName || SNAPSHOT_EXCLUDED_FILES.has(fileName))
393
+ return false;
394
+ return parts.slice(0, -1).every((part) => !SNAPSHOT_EXCLUDED_DIRS.has(part));
395
+ }
396
+ function hasCompleteNestedSnapshot(tree, skillMdPath, files) {
397
+ const folderPath = getSkillFolderPath(skillMdPath);
398
+ if (!folderPath)
399
+ return true;
400
+ const folderPrefix = `${folderPath}/`;
401
+ const snapshotPaths = new Set(files.map((file) => file.path));
402
+ return tree.tree.every((entry) => {
403
+ if (entry.type !== 'blob' || !entry.path.startsWith(folderPrefix))
404
+ return true;
405
+ const relativePath = entry.path.slice(folderPrefix.length);
406
+ return !isInstallableSnapshotPath(relativePath) || snapshotPaths.has(relativePath);
407
+ });
408
+ }
363
409
  /**
364
410
  * Attempt to resolve skills from blob storage instead of cloning.
365
411
  *
@@ -373,9 +419,16 @@ function computeSnapshotHash(files) {
373
419
  * (the caller should fall back to git clone).
374
420
  *
375
421
  * @param ownerRepo - e.g., "vercel-labs/agent-skills"
376
- * @param options - subpath, skillFilter, ref, token
422
+ * @param options - subpath, skillFilter, ref, token. An explicit ref bypasses
423
+ * this ref-agnostic snapshot path and returns null for the caller's git fallback.
377
424
  */
378
425
  export async function tryBlobInstall(ownerRepo, options = {}) {
426
+ // Snapshot downloads are keyed only by owner, repository, and skill slug. They
427
+ // are not bound to the requested ref, so using this path for an explicit ref
428
+ // could install different bytes than the tree and frontmatter resolved below.
429
+ // Return null to use the caller's existing git clone fallback instead.
430
+ if (options.ref !== undefined)
431
+ return null;
379
432
  // 1. Fetch the full repo tree
380
433
  const tree = await fetchRepoTree(ownerRepo, options.ref, options.getToken);
381
434
  if (!tree)
@@ -455,15 +508,16 @@ export async function tryBlobInstall(ownerRepo, options = {}) {
455
508
  const allSucceeded = downloads.every((d) => d.download !== null);
456
509
  if (!allSucceeded)
457
510
  return null;
511
+ // A successful response can still be incomplete (for example, when the
512
+ // snapshot service cannot represent a binary supporting file). In that case
513
+ // use the existing clone path instead of silently installing a partial skill.
514
+ const allComplete = downloads.every(({ skill, download }) => hasCompleteNestedSnapshot(tree, skill.mdPath, download.files));
515
+ if (!allComplete)
516
+ return null;
458
517
  // 6. Convert to BlobSkill objects
459
518
  const blobSkills = downloads.map(({ skill, download }) => {
460
519
  // Compute the folder path from the SKILL.md path (e.g., "skills/react-best-practices")
461
- const mdPathLower = skill.mdPath.toLowerCase();
462
- const folderPath = mdPathLower.endsWith('/skill.md')
463
- ? skill.mdPath.slice(0, -9)
464
- : mdPathLower === 'skill.md'
465
- ? ''
466
- : skill.mdPath.slice(0, -(1 + 'SKILL.md'.length));
520
+ const folderPath = getSkillFolderPath(skill.mdPath);
467
521
  // A root-level SKILL.md means the repository root is a skill entrypoint,
468
522
  // not that the entire repository is installable skill payload. Some cached
469
523
  // snapshots for root skills contain every repo file; installing those can
@@ -75,12 +75,49 @@ function showBanner() {
75
75
  console.log();
76
76
  }
77
77
  function showHelp() {
78
+ const examples = [
79
+ ['skills add vercel-labs/agent-skills'],
80
+ ['skills use vercel-labs/agent-skills@vercel-optimize | claude'],
81
+ ['skills use vercel-labs/agent-skills --skill vercel-optimize --agent claude-code'],
82
+ ['skills add vercel-labs/agent-skills -g'],
83
+ ['skills add vercel-labs/agent-skills --agent claude-code cursor'],
84
+ ['skills add vercel-labs/agent-skills --skill pr-review commit'],
85
+ ['skills add vercel-labs/agent-skills --json -y', 'JSON output'],
86
+ ['skills remove', 'interactive remove'],
87
+ ['skills remove web-design', 'remove by name'],
88
+ ['skills rm --global frontend-design'],
89
+ ['skills list', 'list project skills'],
90
+ ['skills ls -g', 'list global skills'],
91
+ ['skills ls -a claude-code', 'filter by agent'],
92
+ ['skills ls --json', 'JSON output'],
93
+ ['skills find', 'interactive search'],
94
+ ['skills find typescript', 'search by keyword'],
95
+ ['skills find react --owner vercel', 'search within an owner'],
96
+ ['skills update'],
97
+ ['skills update my-skill', 'update a single skill'],
98
+ ['skills update -g', 'update global skills only'],
99
+ ['skills experimental_install', 'restore from skills-lock.json'],
100
+ ['skills init my-skill'],
101
+ ['skills experimental_sync', 'sync from node_modules (experimental)'],
102
+ ['skills experimental_sync -y', 'sync without prompts'],
103
+ ];
104
+ const exampleWidth = Math.max(...examples.filter(([, description]) => description).map(([command]) => command.length));
105
+ const formattedExamples = examples
106
+ .map(([command, description]) => {
107
+ const comment = description
108
+ ? `${' '.repeat(exampleWidth - command.length + 2)}${DIM}# ${description}${RESET}`
109
+ : '';
110
+ return ` ${DIM}$${RESET} ${command}${comment}`;
111
+ })
112
+ .join('\n');
78
113
  console.log(`
79
114
  ${BOLD}Usage:${RESET} skills <command> [options]
80
115
 
81
116
  ${BOLD}Manage Skills:${RESET}
82
117
  add <package> Add a skill package (alias: a)
83
118
  e.g. vercel-labs/agent-skills
119
+ notion
120
+ https://notion.so/<skill-page>
84
121
  https://github.com/vercel-labs/agent-skills
85
122
  use <package>@<skill>
86
123
  Generate a prompt for using one skill without installing it
@@ -102,7 +139,7 @@ ${BOLD}Update Options:${RESET}
102
139
  ${BOLD}Project:${RESET}
103
140
  experimental_install Restore skills from skills-lock.json
104
141
  init [name] Initialize a skill (creates <name>/SKILL.md or ./SKILL.md)
105
- experimental_sync Sync skills from node_modules into agent directories
142
+ experimental_sync Sync skills from node_modules into agent directories (alias: sync)
106
143
 
107
144
  ${BOLD}Add Options:${RESET}
108
145
  -g, --global Install skill globally (user-level) instead of project-level
@@ -114,6 +151,7 @@ ${BOLD}Add Options:${RESET}
114
151
  --subagent <names> Install to Eve subagents (use 'root' for the root agent)
115
152
  --all Shorthand for --skill '*' --agent '*' -y
116
153
  --full-depth Search all subdirectories even when a root SKILL.md exists
154
+ --json Output results as JSON (machine-readable, no ANSI codes)
117
155
 
118
156
  ${BOLD}Use Options:${RESET}
119
157
  -s, --skill <skill> Specify the skill to use
@@ -132,6 +170,13 @@ ${BOLD}Remove Options:${RESET}
132
170
  ${BOLD}Experimental Sync Options:${RESET}
133
171
  -a, --agent <agents> Specify agents to install to (use '*' for all agents)
134
172
  -y, --yes Skip confirmation prompts
173
+ --copy Copy skills instead of linking them to node_modules
174
+ --dry-run Show what would change without changing anything
175
+ --no-cleanup Keep skills whose package no longer ships them
176
+ --no-remote Skip git sources listed in package.json skills fields
177
+ -r, --recursive Also sync the dependencies of each workspace package
178
+ --include <patterns> Only sync matching packages (<pkg>) or skills (<pkg>#<skill>)
179
+ --exclude <patterns> Skip matching packages (<pkg>) or skills (<pkg>#<skill>)
135
180
 
136
181
  ${BOLD}List Options:${RESET}
137
182
  -g, --global List global skills (default: project)
@@ -143,29 +188,7 @@ ${BOLD}Options:${RESET}
143
188
  --version, -v Show version number
144
189
 
145
190
  ${BOLD}Examples:${RESET}
146
- ${DIM}$${RESET} skills add vercel-labs/agent-skills
147
- ${DIM}$${RESET} skills use vercel-labs/agent-skills@vercel-optimize | claude
148
- ${DIM}$${RESET} skills use vercel-labs/agent-skills --skill vercel-optimize --agent claude-code
149
- ${DIM}$${RESET} skills add vercel-labs/agent-skills -g
150
- ${DIM}$${RESET} skills add vercel-labs/agent-skills --agent claude-code cursor
151
- ${DIM}$${RESET} skills add vercel-labs/agent-skills --skill pr-review commit
152
- ${DIM}$${RESET} skills remove ${DIM}# interactive remove${RESET}
153
- ${DIM}$${RESET} skills remove web-design ${DIM}# remove by name${RESET}
154
- ${DIM}$${RESET} skills rm --global frontend-design
155
- ${DIM}$${RESET} skills list ${DIM}# list project skills${RESET}
156
- ${DIM}$${RESET} skills ls -g ${DIM}# list global skills${RESET}
157
- ${DIM}$${RESET} skills ls -a claude-code ${DIM}# filter by agent${RESET}
158
- ${DIM}$${RESET} skills ls --json ${DIM}# JSON output${RESET}
159
- ${DIM}$${RESET} skills find ${DIM}# interactive search${RESET}
160
- ${DIM}$${RESET} skills find typescript ${DIM}# search by keyword${RESET}
161
- ${DIM}$${RESET} skills find react --owner vercel ${DIM}# search within an owner${RESET}
162
- ${DIM}$${RESET} skills update
163
- ${DIM}$${RESET} skills update my-skill ${DIM}# update a single skill${RESET}
164
- ${DIM}$${RESET} skills update -g ${DIM}# update global skills only${RESET}
165
- ${DIM}$${RESET} skills experimental_install ${DIM}# restore from skills-lock.json${RESET}
166
- ${DIM}$${RESET} skills init my-skill
167
- ${DIM}$${RESET} skills experimental_sync ${DIM}# sync from node_modules${RESET}
168
- ${DIM}$${RESET} skills experimental_sync -y ${DIM}# sync without prompts${RESET}
191
+ ${formattedExamples}
169
192
 
170
193
  Discover more skills at ${TEXT}https://skills.sh/${RESET}
171
194
  `);
@@ -303,12 +326,16 @@ async function main() {
303
326
  case 'install':
304
327
  case 'a':
305
328
  case 'add': {
306
- if (!inAgent)
307
- showLogo();
308
329
  const { source: addSource, options: addOpts, errors } = parseAddOptions(restArgs);
330
+ // JSON mode must keep stdout parseable — no logo
331
+ if (!inAgent && !addOpts.json)
332
+ showLogo();
309
333
  if (errors.length > 0) {
310
334
  for (const error of errors)
311
335
  console.error(`Error: ${error}`);
336
+ // JSON mode promises exactly one JSON value on stdout, even here
337
+ if (addOpts.json)
338
+ console.log('[]');
312
339
  process.exitCode = 1;
313
340
  break;
314
341
  }
@@ -331,6 +358,7 @@ async function main() {
331
358
  const { skills, options: removeOptions } = parseRemoveOptions(restArgs);
332
359
  await removeCommand(skills, removeOptions);
333
360
  break;
361
+ case 'sync':
334
362
  case 'experimental_sync': {
335
363
  if (!inAgent)
336
364
  showLogo();
@@ -10,6 +10,9 @@ const DEFAULT_DOWNLOAD_MAX_BYTES = 10 * 1024 * 1024;
10
10
  const DEFAULT_EXTRACT_MAX_BYTES = 25 * 1024 * 1024;
11
11
  const DEFAULT_EXTRACT_MAX_FILES = 1000;
12
12
  const FETCH_TIMEOUT_MS = 30_000;
13
+ function positiveIntegerOr(value, fallback) {
14
+ return typeof value === 'number' && Number.isInteger(value) && value > 0 ? value : fallback;
15
+ }
13
16
  function getPositiveIntegerEnv(name, fallback) {
14
17
  const raw = process.env[name];
15
18
  if (!raw)
@@ -17,11 +20,11 @@ function getPositiveIntegerEnv(name, fallback) {
17
20
  const parsed = Number.parseInt(raw, 10);
18
21
  return Number.isFinite(parsed) && parsed > 0 ? parsed : fallback;
19
22
  }
20
- function getDownloadLimits() {
23
+ function getDownloadLimits(options) {
21
24
  return {
22
- downloadMaxBytes: getPositiveIntegerEnv('SKILLS_DOWNLOAD_MAX_BYTES', DEFAULT_DOWNLOAD_MAX_BYTES),
23
- extractMaxBytes: getPositiveIntegerEnv('SKILLS_EXTRACT_MAX_BYTES', DEFAULT_EXTRACT_MAX_BYTES),
24
- extractMaxFiles: getPositiveIntegerEnv('SKILLS_EXTRACT_MAX_FILES', DEFAULT_EXTRACT_MAX_FILES),
25
+ downloadMaxBytes: getPositiveIntegerEnv('SKILLS_DOWNLOAD_MAX_BYTES', positiveIntegerOr(options.downloadMaxBytes, DEFAULT_DOWNLOAD_MAX_BYTES)),
26
+ extractMaxBytes: getPositiveIntegerEnv('SKILLS_EXTRACT_MAX_BYTES', positiveIntegerOr(options.extractMaxBytes, DEFAULT_EXTRACT_MAX_BYTES)),
27
+ extractMaxFiles: getPositiveIntegerEnv('SKILLS_EXTRACT_MAX_FILES', positiveIntegerOr(options.extractMaxFiles, DEFAULT_EXTRACT_MAX_FILES)),
25
28
  };
26
29
  }
27
30
  function isPathSafe(basePath, targetPath) {
@@ -190,8 +193,8 @@ async function getSingleTopLevelDirectory(dir) {
190
193
  return null;
191
194
  return join(dir, visibleEntries[0].name);
192
195
  }
193
- export async function downloadSource(url) {
194
- const limits = getDownloadLimits();
196
+ export async function downloadSource(url, options = {}) {
197
+ const limits = getDownloadLimits(options);
195
198
  const tempDir = await mkdtemp(join(tmpdir(), 'skills-download-'));
196
199
  const downloadedFile = join(tempDir, 'source.download');
197
200
  const extractDir = join(tempDir, 'extract');
@@ -5,7 +5,7 @@ import { parse as parseYaml } from 'yaml';
5
5
  * that exists in gray-matter's built-in JS engine.
6
6
  */
7
7
  export function parseFrontmatter(raw) {
8
- const match = raw.match(/^---\r?\n([\s\S]*?)\r?\n---\r?\n?([\s\S]*)$/);
8
+ const match = raw.match(/^\uFEFF?---\r?\n([\s\S]*?)\r?\n---\r?\n?([\s\S]*)$/);
9
9
  if (!match)
10
10
  return { data: {}, content: raw };
11
11
  const data = parseYaml(match[1]) ?? {};
@@ -40,6 +40,56 @@ const UNSAFE_INHERITED_GIT_ENV_KEYS = [
40
40
  'SSH_ASKPASS',
41
41
  ];
42
42
  const UNSAFE_INHERITED_GIT_ENV_KEY_SET = new Set(UNSAFE_INHERITED_GIT_ENV_KEYS.map((key) => key.toUpperCase()));
43
+ /**
44
+ * Whether a ref is a full 40-character Git commit SHA.
45
+ *
46
+ * Used only to decide whether the commit-SHA fetch fallback is worth attempting
47
+ * after a `--branch` clone fails. The fetch-by-SHA protocol requires the full
48
+ * 40-char SHA; abbreviated SHAs are rejected by the server, so they are not
49
+ * matched here. Branch and tag detection is never inferred from the string:
50
+ * `--branch` is always tried first, so any real branch or tag (including a
51
+ * hex-looking name like "deadbeef" or a 40-char-hex name) resolves correctly
52
+ * before the SHA fallback is ever considered.
53
+ */
54
+ export function isCommitSha(ref) {
55
+ return /^[0-9a-f]{40}$/i.test(ref);
56
+ }
57
+ /**
58
+ * Whether a clone or fetch error means the requested ref does not exist as a
59
+ * branch or tag. `git clone --branch <sha>` fails this way because `--branch`
60
+ * only accepts branch or tag names, never a bare commit SHA.
61
+ *
62
+ * These messages come from the git client and the server `upload-pack`, not from
63
+ * the host, so they are identical across GitHub, GitLab, self-hosted git, and
64
+ * `gh` (which wraps git). Verified on git 2.53. The variants cover the different
65
+ * code paths a missing ref can surface through:
66
+ * - `clone --branch <ref>` -> "Remote branch <ref> not found in upstream origin"
67
+ * - GitHub shorthand fetch path -> "couldn't find remote ref <ref>"
68
+ * - server-side fetch by SHA rejected -> "upload-pack: not our ref <ref>"
69
+ */
70
+ export function isMissingRefError(message) {
71
+ return (/Remote branch .* not found in upstream origin/i.test(message) ||
72
+ /couldn't find remote ref/i.test(message) ||
73
+ /upload-pack: not our ref/i.test(message));
74
+ }
75
+ /**
76
+ * Clone a repository pinned to a specific commit SHA.
77
+ *
78
+ * `git clone --branch` cannot target a bare SHA, and a `--depth 1` clone does
79
+ * not contain arbitrary commits. Instead, init an empty repo and fetch only the
80
+ * requested commit, then check it out. This requires the server to allow
81
+ * fetching reachable commits by SHA (`uploadpack.allowReachableSHA1InWant`),
82
+ * which GitHub and GitLab.com both enable. If the server rejects it, the caller
83
+ * falls back to the standard error handling.
84
+ */
85
+ async function cloneAtSha(url, sha, tempDir, extraEnv) {
86
+ const git = createGitClient(extraEnv);
87
+ await git.cwd(tempDir);
88
+ await git.init();
89
+ await git.addRemote('origin', url);
90
+ await git.fetch(['--depth', '1', 'origin', sha]);
91
+ await git.checkout('FETCH_HEAD');
92
+ }
43
93
  export class GitCloneError extends Error {
44
94
  url;
45
95
  isTimeout;
@@ -250,8 +300,12 @@ export async function getGitTreeHash(repoDir, skillPath) {
250
300
  }
251
301
  }
252
302
  export async function cloneRepo(url, ref) {
303
+ if (/^ext::/i.test(url)) {
304
+ throw new GitCloneError('Unsupported Git transport: ext', url);
305
+ }
253
306
  const tempDir = await mkdtemp(join(tmpdir(), 'skills-'));
254
307
  const cloneOptions = ref ? ['--depth', '1', '--branch', ref] : ['--depth', '1'];
308
+ const refCanBeSha = !!ref && isCommitSha(ref);
255
309
  const repo = parseGitHubRepoUrl(url);
256
310
  try {
257
311
  await createGitClient().clone(url, tempDir, cloneOptions);
@@ -259,6 +313,20 @@ export async function cloneRepo(url, ref) {
259
313
  }
260
314
  catch (error) {
261
315
  const errorMessage = error instanceof Error ? error.message : String(error);
316
+ // `--branch` cannot target a bare commit SHA. If the ref is a full SHA and
317
+ // the clone failed because the ref was not a branch or tag, retry by
318
+ // fetching the commit directly. This runs only after `--branch` fails, so a
319
+ // real branch or tag (any name) is always resolved first.
320
+ if (refCanBeSha && isMissingRefError(errorMessage)) {
321
+ try {
322
+ await resetTempDir(tempDir);
323
+ await cloneAtSha(url, ref, tempDir);
324
+ return tempDir;
325
+ }
326
+ catch {
327
+ // Fall through to the standard error handling below.
328
+ }
329
+ }
262
330
  const isTimeout = errorMessage.includes('block timeout') || errorMessage.includes('timed out');
263
331
  const isAuthError = isAuthFailure(errorMessage);
264
332
  if (isTimeout) {
@@ -283,9 +351,22 @@ export async function cloneRepo(url, ref) {
283
351
  }
284
352
  try {
285
353
  await resetTempDir(tempDir);
286
- await createGitClient({
354
+ const sshEnv = {
287
355
  GIT_SSH_COMMAND: 'ssh -o BatchMode=yes',
288
- }).clone(repo.sshUrl, tempDir, cloneOptions);
356
+ };
357
+ try {
358
+ await createGitClient(sshEnv).clone(repo.sshUrl, tempDir, cloneOptions);
359
+ }
360
+ catch (sshError) {
361
+ const sshMessage = sshError instanceof Error ? sshError.message : String(sshError);
362
+ if (refCanBeSha && isMissingRefError(sshMessage)) {
363
+ await resetTempDir(tempDir);
364
+ await cloneAtSha(repo.sshUrl, ref, tempDir, sshEnv);
365
+ }
366
+ else {
367
+ throw sshError;
368
+ }
369
+ }
289
370
  return tempDir;
290
371
  }
291
372
  catch {