@rbbtsn0w/adg 0.10.1 → 0.11.0-beta.1
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/README.md +9 -0
- package/dist/src/adapters/antigravity-hooks.js +4 -2
- package/dist/src/commands/adapt.js +2 -2
- package/dist/src/commands/install/install-one.js +76 -5
- package/dist/src/commands/install.js +10 -2
- package/dist/src/commands/marketplace.js +6 -1
- package/dist/src/commands/update.js +4 -1
- package/dist/src/materialize.js +1 -1
- package/dist/src/plugin-changes.js +22 -0
- package/dist/src/render/plugins.js +21 -3
- package/dist/src/sources.js +3 -1
- package/dist/vendor/skills/src/add.js +597 -281
- package/dist/vendor/skills/src/agents.js +42 -7
- package/dist/vendor/skills/src/blob.js +96 -42
- package/dist/vendor/skills/src/cli.js +64 -36
- package/dist/vendor/skills/src/detect-agent.js +1 -1
- package/dist/vendor/skills/src/download-source.js +11 -8
- package/dist/vendor/skills/src/find.js +5 -5
- package/dist/vendor/skills/src/frontmatter.js +1 -1
- package/dist/vendor/skills/src/git-tree.js +1 -1
- package/dist/vendor/skills/src/git.js +84 -3
- package/dist/vendor/skills/src/install.js +27 -16
- package/dist/vendor/skills/src/installer.js +68 -42
- package/dist/vendor/skills/src/list.js +5 -5
- package/dist/vendor/skills/src/local-lock.js +18 -7
- package/dist/vendor/skills/src/notion-test.js +440 -0
- package/dist/vendor/skills/src/prompts/search-multiselect.js +22 -0
- package/dist/vendor/skills/src/providers/index.js +2 -2
- package/dist/vendor/skills/src/providers/wellknown.js +4 -4
- package/dist/vendor/skills/src/remove.js +37 -16
- package/dist/vendor/skills/src/skill-lock.js +2 -2
- package/dist/vendor/skills/src/skill-relocation.js +56 -0
- package/dist/vendor/skills/src/skills-field.js +50 -0
- package/dist/vendor/skills/src/skills.js +78 -58
- package/dist/vendor/skills/src/source-parser.js +76 -2
- package/dist/vendor/skills/src/sync.js +610 -190
- package/dist/vendor/skills/src/telemetry.js +1 -1
- package/dist/vendor/skills/src/test-utils.js +6 -9
- package/dist/vendor/skills/src/update.js +147 -62
- package/dist/vendor/skills/src/use.js +13 -12
- package/docs/agents-spec.md +5 -0
- package/docs/plugin-update-semantics.md +152 -0
- package/package.json +7 -7
- package/vendor/skills/PROVENANCE.md +130 -10
- package/vendor/skills/ThirdPartyNoticeText.txt +4 -4
|
@@ -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(
|
|
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
|
-
|
|
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: '.
|
|
400
|
-
globalSkillsDir: join(home, '.
|
|
419
|
+
skillsDir: '.agents/skills',
|
|
420
|
+
globalSkillsDir: join(home, '.kilo/skills'),
|
|
401
421
|
detectInstalled: async () => {
|
|
402
|
-
|
|
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
|
-
|
|
536
|
-
|
|
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',
|
|
@@ -11,10 +11,10 @@
|
|
|
11
11
|
*/
|
|
12
12
|
import { createHash } from 'node:crypto';
|
|
13
13
|
import { execFile } from 'node:child_process';
|
|
14
|
-
import { parseFrontmatter } from
|
|
15
|
-
import { sanitizeMetadata } from
|
|
16
|
-
import { getGitHubHost } from
|
|
17
|
-
import { DEFAULT_SKILL_CONTAINER_DEPTH } from
|
|
14
|
+
import { parseFrontmatter } from './frontmatter.js';
|
|
15
|
+
import { sanitizeMetadata } from './sanitize.js';
|
|
16
|
+
import { getGitHubHost } from './github-host.js';
|
|
17
|
+
import { DEFAULT_SKILL_CONTAINER_DEPTH } from './constants.js';
|
|
18
18
|
// ─── Constants ───
|
|
19
19
|
const DOWNLOAD_BASE_URL = process.env.SKILLS_DOWNLOAD_URL || 'https://skills.sh';
|
|
20
20
|
// Repos that self-host their downloads on the blob fast-path
|
|
@@ -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
|
-
//
|
|
79
|
-
//
|
|
80
|
-
//
|
|
81
|
-
const authMayHelp =
|
|
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) =>
|
|
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
|
|
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
|
-
*
|
|
140
|
-
*
|
|
141
|
-
*
|
|
142
|
-
*
|
|
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
|
-
|
|
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
|
-
//
|
|
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
|
|
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
|
|
290
|
-
//
|
|
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
|
|
294
|
-
parts
|
|
295
|
-
|
|
296
|
-
!SKIP_DIRS.has(
|
|
297
|
-
|
|
298
|
-
if (!
|
|
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
|
|
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
|
|
@@ -2,16 +2,16 @@
|
|
|
2
2
|
import { writeFileSync, readFileSync, existsSync, mkdirSync } from 'fs';
|
|
3
3
|
import { basename, join, dirname } from 'path';
|
|
4
4
|
import { fileURLToPath } from 'url';
|
|
5
|
-
import { runAdd, parseAddOptions } from
|
|
6
|
-
import { runFind } from
|
|
7
|
-
import { runInstallFromLock } from
|
|
8
|
-
import { runList } from
|
|
9
|
-
import { removeCommand, parseRemoveOptions } from
|
|
10
|
-
import { runSync, parseSyncOptions } from
|
|
11
|
-
import { flushTelemetry } from
|
|
12
|
-
import { isRunningInAgent } from
|
|
13
|
-
import { runUpdate } from
|
|
14
|
-
import { runUse, parseUseOptions } from
|
|
5
|
+
import { runAdd, parseAddOptions } from './add.js';
|
|
6
|
+
import { runFind } from './find.js';
|
|
7
|
+
import { runInstallFromLock } from './install.js';
|
|
8
|
+
import { runList } from './list.js';
|
|
9
|
+
import { removeCommand, parseRemoveOptions } from './remove.js';
|
|
10
|
+
import { runSync, parseSyncOptions } from './sync.js';
|
|
11
|
+
import { flushTelemetry } from './telemetry.js';
|
|
12
|
+
import { isRunningInAgent } from './detect-agent.js';
|
|
13
|
+
import { runUpdate } from './update.js';
|
|
14
|
+
import { runUse, parseUseOptions } from './use.js';
|
|
15
15
|
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
16
16
|
function getVersion() {
|
|
17
17
|
try {
|
|
@@ -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
|
-
|
|
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();
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { determineAgent } from '@vercel/detect-agent';
|
|
2
|
-
import { setDetectedAgent } from
|
|
2
|
+
import { setDetectedAgent } from './telemetry.js';
|
|
3
3
|
let cachedResult = null;
|
|
4
4
|
/**
|
|
5
5
|
* @vercel/detect-agent treats any CURSOR_TRACE_ID as a Cursor agent, but that
|
|
@@ -4,12 +4,15 @@ import { tmpdir } from 'node:os';
|
|
|
4
4
|
import { dirname, join, normalize, resolve, sep } from 'node:path';
|
|
5
5
|
import { pipeline } from 'node:stream/promises';
|
|
6
6
|
import * as tar from 'tar';
|
|
7
|
-
import { ArchiveValidationError, readZipArchive } from
|
|
8
|
-
import { parseFrontmatter } from
|
|
7
|
+
import { ArchiveValidationError, readZipArchive } from './archive.js';
|
|
8
|
+
import { parseFrontmatter } from './frontmatter.js';
|
|
9
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');
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import * as readline from 'readline';
|
|
2
|
-
import { runAdd, parseAddOptions } from
|
|
3
|
-
import { sanitizeMetadata } from
|
|
4
|
-
import { track } from
|
|
5
|
-
import { isRepoPrivate } from
|
|
6
|
-
import { isRunningInAgent } from
|
|
2
|
+
import { runAdd, parseAddOptions } from './add.js';
|
|
3
|
+
import { sanitizeMetadata } from './sanitize.js';
|
|
4
|
+
import { track } from './telemetry.js';
|
|
5
|
+
import { isRepoPrivate } from './source-parser.js';
|
|
6
|
+
import { isRunningInAgent } from './detect-agent.js';
|
|
7
7
|
const RESET = '\x1b[0m';
|
|
8
8
|
const BOLD = '\x1b[1m';
|
|
9
9
|
const DIM = '\x1b[38;5;102m';
|
|
@@ -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(
|
|
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]) ?? {};
|