@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
|
@@ -1,12 +1,24 @@
|
|
|
1
|
-
import { createHash } from 'node:crypto';
|
|
2
1
|
import * as p from '@clack/prompts';
|
|
3
2
|
import pc from 'picocolors';
|
|
4
3
|
import { existsSync } from 'fs';
|
|
5
4
|
import { homedir } from 'os';
|
|
6
5
|
import { sep, join, dirname } from 'path';
|
|
7
|
-
import { parseSource, getOwnerRepo, parseOwnerRepo, isRepoPrivate } from
|
|
8
|
-
import { stripTerminalEscapes } from
|
|
9
|
-
import { searchMultiselect } from
|
|
6
|
+
import { parseSource, getOwnerRepo, parseOwnerRepo, isRepoPrivate } from './source-parser.js';
|
|
7
|
+
import { stripTerminalEscapes } from './sanitize.js';
|
|
8
|
+
import { searchMultiselect } from './prompts/search-multiselect.js';
|
|
9
|
+
import { cloneRepo, cleanupTempDir, GitCloneError } from './git.js';
|
|
10
|
+
import { gitTreeShaForFolder } from './git-tree.js';
|
|
11
|
+
import { discoverSkills, getSkillDisplayName, filterSkills } from './skills.js';
|
|
12
|
+
import { installSkillForAgent, installBlobSkillForAgent, isSkillInstalled, getCanonicalPath, installWellKnownSkillForAgent, } from './installer.js';
|
|
13
|
+
import { detectInstalledAgents, agents, getUniversalAgents, getVisibleUniversalAgents, getNonUniversalAgents, isUniversalAgent, getEveSubagents, } from './agents.js';
|
|
14
|
+
import { track, fetchAuditData, } from './telemetry.js';
|
|
15
|
+
import { detectAgent, getAgentType } from './detect-agent.js';
|
|
16
|
+
import { wellKnownProvider, computeWellKnownSkillDigest, WellKnownScopeNotFoundError, } from './providers/index.js';
|
|
17
|
+
import { downloadSource } from './download-source.js';
|
|
18
|
+
import { addSkillToLock, getGitHubToken, isPromptDismissed, dismissPrompt, getLastSelectedAgents, saveSelectedAgents, } from './skill-lock.js';
|
|
19
|
+
import { addSkillToLocalLock, computeSkillFolderHash, computeSingleFileSkillHash, } from './local-lock.js';
|
|
20
|
+
import { tryBlobInstall, BLOB_ALLOWED_REPOS, getSkillFolderHashFromTree, fetchRepoTree, } from './blob.js';
|
|
21
|
+
import { isNotionSource, parseNotionSkillUrl, prepareNotionPackSource, prepareNotionSkillSource, } from './notion-test.js';
|
|
10
22
|
// Helper to check if a value is a cancel symbol (works with both clack and our custom prompts)
|
|
11
23
|
const isCancelled = (value) => typeof value === 'symbol';
|
|
12
24
|
const EVE_AGENT_LABEL = 'eve agent';
|
|
@@ -27,12 +39,14 @@ export function getLockSource(parsedUrl, normalizedSource) {
|
|
|
27
39
|
// When normalizedSource is used, parseSource() later resolves it to HTTPS,
|
|
28
40
|
// breaking restore for private repos that require SSH authentication.
|
|
29
41
|
const isSSH = parsedUrl.startsWith('git@') || parsedUrl.startsWith('ssh://');
|
|
30
|
-
if (isSSH)
|
|
42
|
+
if (isSSH) {
|
|
31
43
|
return parsedUrl;
|
|
44
|
+
}
|
|
32
45
|
if (parsedUrl.startsWith('http://') || parsedUrl.startsWith('https://')) {
|
|
33
46
|
try {
|
|
34
|
-
if (new URL(parsedUrl).hostname !== 'github.com')
|
|
47
|
+
if (new URL(parsedUrl).hostname !== 'github.com') {
|
|
35
48
|
return parsedUrl;
|
|
49
|
+
}
|
|
36
50
|
}
|
|
37
51
|
catch {
|
|
38
52
|
return normalizedSource;
|
|
@@ -43,18 +57,6 @@ export function getLockSource(parsedUrl, normalizedSource) {
|
|
|
43
57
|
export function getProjectLockSourceUrl(sourceType, sourceUrl) {
|
|
44
58
|
return sourceType === 'git' || sourceType === 'gitlab' ? sourceUrl : undefined;
|
|
45
59
|
}
|
|
46
|
-
import { cloneRepo, cleanupTempDir, GitCloneError } from "./git.js";
|
|
47
|
-
import { gitTreeShaForFolder } from "./git-tree.js";
|
|
48
|
-
import { discoverSkills, getSkillDisplayName, filterSkills } from "./skills.js";
|
|
49
|
-
import { installSkillForAgent, installBlobSkillForAgent, isSkillInstalled, getCanonicalPath, installWellKnownSkillForAgent, } from "./installer.js";
|
|
50
|
-
import { detectInstalledAgents, agents, getUniversalAgents, getVisibleUniversalAgents, getNonUniversalAgents, isUniversalAgent, getEveSubagents, } from "./agents.js";
|
|
51
|
-
import { track, fetchAuditData, } from "./telemetry.js";
|
|
52
|
-
import { detectAgent, getAgentType } from "./detect-agent.js";
|
|
53
|
-
import { wellKnownProvider, computeWellKnownSkillDigest, WellKnownScopeNotFoundError, } from "./providers/index.js";
|
|
54
|
-
import { downloadSource } from "./download-source.js";
|
|
55
|
-
import { addSkillToLock, fetchSkillFolderHash, getGitHubToken, isPromptDismissed, dismissPrompt, getLastSelectedAgents, saveSelectedAgents, } from "./skill-lock.js";
|
|
56
|
-
import { addSkillToLocalLock, computeSkillFolderHash } from "./local-lock.js";
|
|
57
|
-
import { tryBlobInstall, BLOB_ALLOWED_REPOS, getSkillFolderHashFromTree, fetchRepoTree, } from "./blob.js";
|
|
58
60
|
// ─── Security Advisory ───
|
|
59
61
|
function riskLabel(risk) {
|
|
60
62
|
switch (risk) {
|
|
@@ -139,12 +141,6 @@ function shortenPath(fullPath, cwd) {
|
|
|
139
141
|
}
|
|
140
142
|
return fullPath;
|
|
141
143
|
}
|
|
142
|
-
function computeSingleFileSkillHash(contents) {
|
|
143
|
-
const hash = createHash('sha256');
|
|
144
|
-
hash.update('SKILL.md');
|
|
145
|
-
hash.update(contents);
|
|
146
|
-
return hash.digest('hex');
|
|
147
|
-
}
|
|
148
144
|
/**
|
|
149
145
|
* Formats a list of items, truncating if too many
|
|
150
146
|
*/
|
|
@@ -283,6 +279,11 @@ function buildResultLines(results, targetAgents) {
|
|
|
283
279
|
.filter((r) => !r.symlinkFailed && !r.skipped && !universal.includes(r.agent))
|
|
284
280
|
.map((r) => r.agent);
|
|
285
281
|
const failedSymlinks = results.filter((r) => r.symlinkFailed && !r.skipped).map((r) => r.agent);
|
|
282
|
+
const skippedSymlinks = results
|
|
283
|
+
.filter((r) => r.skipped &&
|
|
284
|
+
r.skipReason === 'missing-agent-project-directory' &&
|
|
285
|
+
symlinkAgents.includes(r.agent))
|
|
286
|
+
.map((r) => r.agent);
|
|
286
287
|
if (universal.length > 0) {
|
|
287
288
|
lines.push(` ${pc.green('universal:')} ${formatList(universal)}`);
|
|
288
289
|
}
|
|
@@ -292,6 +293,9 @@ function buildResultLines(results, targetAgents) {
|
|
|
292
293
|
if (failedSymlinks.length > 0) {
|
|
293
294
|
lines.push(` ${pc.yellow('copied:')} ${formatList(failedSymlinks)}`);
|
|
294
295
|
}
|
|
296
|
+
if (skippedSymlinks.length > 0) {
|
|
297
|
+
lines.push(` ${pc.yellow('skipped:')} ${formatList(skippedSymlinks)} ${pc.dim('(project directory not found)')}`);
|
|
298
|
+
}
|
|
295
299
|
return lines;
|
|
296
300
|
}
|
|
297
301
|
/**
|
|
@@ -306,6 +310,23 @@ function multiselect(opts) {
|
|
|
306
310
|
message: `${opts.message} ${pc.dim('(space to toggle)')}`,
|
|
307
311
|
});
|
|
308
312
|
}
|
|
313
|
+
/**
|
|
314
|
+
* Exit after an installation prompt was cancelled before anything was installed.
|
|
315
|
+
*
|
|
316
|
+
* Without a TTY the prompt cannot collect input at all: stdin EOF cancels it
|
|
317
|
+
* immediately. Exiting 0 there reports success to scripts and CI even though
|
|
318
|
+
* nothing was installed, so exit non-zero and point at the non-interactive
|
|
319
|
+
* flags instead. A deliberate interactive cancel still exits 0.
|
|
320
|
+
*/
|
|
321
|
+
function exitInstallationCancelled() {
|
|
322
|
+
p.cancel('Installation cancelled');
|
|
323
|
+
if (!process.stdin.isTTY) {
|
|
324
|
+
console.error('Interactive prompt required but stdin is not a TTY. Nothing was installed. ' +
|
|
325
|
+
`Use --agent <name> (or --agent '*') and -y to run non-interactively.`);
|
|
326
|
+
process.exit(1);
|
|
327
|
+
}
|
|
328
|
+
process.exit(0);
|
|
329
|
+
}
|
|
309
330
|
/**
|
|
310
331
|
* Prompts the user to select agents using interactive search.
|
|
311
332
|
* Pre-selects the last used agents if available.
|
|
@@ -322,7 +343,7 @@ export async function promptForAgents(message, choices) {
|
|
|
322
343
|
}
|
|
323
344
|
const validAgents = choices.map((c) => c.value);
|
|
324
345
|
// Default agents to pre-select when no valid history exists
|
|
325
|
-
const defaultAgents = ['claude-code', 'opencode', 'codex'];
|
|
346
|
+
const defaultAgents = ['claude-code', 'opencode', 'codex', 'grok'];
|
|
326
347
|
const defaultValues = defaultAgents.filter((a) => validAgents.includes(a));
|
|
327
348
|
let initialValues = [];
|
|
328
349
|
if (lastSelected && lastSelected.length > 0) {
|
|
@@ -403,15 +424,47 @@ async function selectAgentsInteractive(options) {
|
|
|
403
424
|
}
|
|
404
425
|
return selected;
|
|
405
426
|
}
|
|
427
|
+
/** Build the `security` field for a JSON entry from partner audit data. */
|
|
428
|
+
function buildJsonSecurity(auditData, skillName, source) {
|
|
429
|
+
const data = auditData?.[skillName];
|
|
430
|
+
if (!data || Object.keys(data).length === 0)
|
|
431
|
+
return null;
|
|
432
|
+
const socketAlerts = data.socket?.alerts ?? 0;
|
|
433
|
+
return {
|
|
434
|
+
...(data.ath && { gen: data.ath.risk }),
|
|
435
|
+
...(data.socket && { socket: `${socketAlerts} alert${socketAlerts !== 1 ? 's' : ''}` }),
|
|
436
|
+
...(data.snyk && { snyk: data.snyk.risk }),
|
|
437
|
+
...(source && { details: `https://skills.sh/${source}` }),
|
|
438
|
+
};
|
|
439
|
+
}
|
|
406
440
|
/**
|
|
407
441
|
* Handle skills from a well-known endpoint (RFC 8615).
|
|
408
442
|
* Discovers skills from /.well-known/agent-skills/index.json (preferred)
|
|
409
443
|
* or /.well-known/skills/index.json (legacy fallback).
|
|
410
444
|
*/
|
|
445
|
+
function isSkillsShPackUrl(url) {
|
|
446
|
+
try {
|
|
447
|
+
const parsed = new URL(url);
|
|
448
|
+
const hostname = parsed.hostname.replace(/^www\./, '');
|
|
449
|
+
return hostname === 'skills.sh' && /^\/p\/[^/]+/.test(parsed.pathname);
|
|
450
|
+
}
|
|
451
|
+
catch {
|
|
452
|
+
return false;
|
|
453
|
+
}
|
|
454
|
+
}
|
|
455
|
+
function logAutoSelectedSkills(entries) {
|
|
456
|
+
const only = entries.length === 1 ? entries[0] : null;
|
|
457
|
+
if (!only) {
|
|
458
|
+
p.log.info(`Installing all ${entries.length} skills`);
|
|
459
|
+
return;
|
|
460
|
+
}
|
|
461
|
+
p.log.info(`Skill: ${pc.cyan(only.label)}`);
|
|
462
|
+
if (only.description)
|
|
463
|
+
p.log.message(pc.dim(only.description));
|
|
464
|
+
}
|
|
411
465
|
async function handleWellKnownSkills(source, url, options, spinner) {
|
|
412
466
|
spinner.start('Discovering skills from well-known endpoint...');
|
|
413
|
-
// Fetch all skills from the well-known endpoint
|
|
414
|
-
// is the documented escape hatch for internal skills; wildcard is not.
|
|
467
|
+
// Fetch all skills from the well-known endpoint
|
|
415
468
|
let skills = [];
|
|
416
469
|
try {
|
|
417
470
|
skills = await wellKnownProvider.fetchAllSkills(url, {
|
|
@@ -454,10 +507,11 @@ async function handleWellKnownSkills(source, url, options, spinner) {
|
|
|
454
507
|
}
|
|
455
508
|
// Filter skills if --skill option is provided
|
|
456
509
|
let selectedSkills;
|
|
510
|
+
const logWellKnown = (chosen) => logAutoSelectedSkills(chosen.map((s) => ({ label: s.installName, description: s.description })));
|
|
457
511
|
if (options.skill?.includes('*')) {
|
|
458
512
|
// --skill '*' selects all skills
|
|
459
513
|
selectedSkills = skills;
|
|
460
|
-
|
|
514
|
+
logWellKnown(selectedSkills);
|
|
461
515
|
}
|
|
462
516
|
else if (options.skill && options.skill.length > 0) {
|
|
463
517
|
selectedSkills = skills.filter((s) => options.skill.some((name) => s.installName.toLowerCase() === name.toLowerCase() ||
|
|
@@ -471,30 +525,24 @@ async function handleWellKnownSkills(source, url, options, spinner) {
|
|
|
471
525
|
process.exit(1);
|
|
472
526
|
}
|
|
473
527
|
}
|
|
474
|
-
else if (skills.length === 1) {
|
|
475
|
-
selectedSkills = skills;
|
|
476
|
-
const firstSkill = skills[0];
|
|
477
|
-
p.log.info(`Skill: ${pc.cyan(firstSkill.installName)}`);
|
|
478
|
-
}
|
|
479
|
-
else if (options.yes) {
|
|
528
|
+
else if (skills.length === 1 || options.yes) {
|
|
480
529
|
selectedSkills = skills;
|
|
481
|
-
|
|
530
|
+
logWellKnown(selectedSkills);
|
|
482
531
|
}
|
|
483
532
|
else {
|
|
484
533
|
// Prompt user to select skills
|
|
485
534
|
const skillChoices = skills.map((s) => ({
|
|
486
535
|
value: s,
|
|
487
536
|
label: s.installName,
|
|
488
|
-
hint: s.description.length > 60 ? s.description.slice(0, 57) + '
|
|
537
|
+
hint: s.description.length > 60 ? s.description.slice(0, 57) + '…' : s.description,
|
|
489
538
|
}));
|
|
490
539
|
const selected = await multiselect({
|
|
491
540
|
message: 'Select skills to install',
|
|
492
541
|
options: skillChoices,
|
|
493
542
|
required: true,
|
|
494
543
|
});
|
|
495
|
-
if (
|
|
496
|
-
|
|
497
|
-
process.exit(0);
|
|
544
|
+
if (isCancelled(selected)) {
|
|
545
|
+
exitInstallationCancelled();
|
|
498
546
|
}
|
|
499
547
|
selectedSkills = selected;
|
|
500
548
|
}
|
|
@@ -516,7 +564,7 @@ async function handleWellKnownSkills(source, url, options, spinner) {
|
|
|
516
564
|
targetAgents = options.agent;
|
|
517
565
|
}
|
|
518
566
|
else {
|
|
519
|
-
spinner.start('Loading agents
|
|
567
|
+
spinner.start('Loading agents…');
|
|
520
568
|
const installedAgents = await detectInstalledAgents();
|
|
521
569
|
const totalAgents = Object.keys(agents).length;
|
|
522
570
|
spinner.stop(`${totalAgents} agents`);
|
|
@@ -533,9 +581,8 @@ async function handleWellKnownSkills(source, url, options, spinner) {
|
|
|
533
581
|
}));
|
|
534
582
|
// Use helper to prompt with search
|
|
535
583
|
const selected = await promptForAgents('Which agents do you want to install to?', allAgentChoices);
|
|
536
|
-
if (
|
|
537
|
-
|
|
538
|
-
process.exit(0);
|
|
584
|
+
if (isCancelled(selected)) {
|
|
585
|
+
exitInstallationCancelled();
|
|
539
586
|
}
|
|
540
587
|
targetAgents = selected;
|
|
541
588
|
}
|
|
@@ -553,9 +600,8 @@ async function handleWellKnownSkills(source, url, options, spinner) {
|
|
|
553
600
|
}
|
|
554
601
|
else {
|
|
555
602
|
const selected = await selectAgentsInteractive({ global: options.global });
|
|
556
|
-
if (
|
|
557
|
-
|
|
558
|
-
process.exit(0);
|
|
603
|
+
if (isCancelled(selected)) {
|
|
604
|
+
exitInstallationCancelled();
|
|
559
605
|
}
|
|
560
606
|
targetAgents = selected;
|
|
561
607
|
}
|
|
@@ -580,8 +626,7 @@ async function handleWellKnownSkills(source, url, options, spinner) {
|
|
|
580
626
|
],
|
|
581
627
|
});
|
|
582
628
|
if (p.isCancel(scope)) {
|
|
583
|
-
|
|
584
|
-
process.exit(0);
|
|
629
|
+
exitInstallationCancelled();
|
|
585
630
|
}
|
|
586
631
|
installGlobally = scope;
|
|
587
632
|
}
|
|
@@ -603,8 +648,7 @@ async function handleWellKnownSkills(source, url, options, spinner) {
|
|
|
603
648
|
],
|
|
604
649
|
});
|
|
605
650
|
if (p.isCancel(modeChoice)) {
|
|
606
|
-
|
|
607
|
-
process.exit(0);
|
|
651
|
+
exitInstallationCancelled();
|
|
608
652
|
}
|
|
609
653
|
installMode = modeChoice;
|
|
610
654
|
}
|
|
@@ -652,14 +696,13 @@ async function handleWellKnownSkills(source, url, options, spinner) {
|
|
|
652
696
|
if (!options.yes) {
|
|
653
697
|
const confirmed = await p.confirm({ message: 'Proceed with installation?' });
|
|
654
698
|
if (p.isCancel(confirmed) || !confirmed) {
|
|
655
|
-
|
|
656
|
-
process.exit(0);
|
|
699
|
+
exitInstallationCancelled();
|
|
657
700
|
}
|
|
658
701
|
}
|
|
659
702
|
// Kick off privacy check early so it runs in parallel with installation
|
|
660
703
|
const sourceIdentifier = wellKnownProvider.getSourceIdentifier(url);
|
|
661
704
|
const wellKnownPrivacyPromise = isSourcePrivate(sourceIdentifier).catch(() => null);
|
|
662
|
-
spinner.start('Installing skills
|
|
705
|
+
spinner.start('Installing skills…');
|
|
663
706
|
const results = [];
|
|
664
707
|
for (const skill of selectedSkills) {
|
|
665
708
|
for (const agent of targetAgents) {
|
|
@@ -678,6 +721,7 @@ async function handleWellKnownSkills(source, url, options, spinner) {
|
|
|
678
721
|
console.log();
|
|
679
722
|
const successful = results.filter((r) => r.success);
|
|
680
723
|
const failed = results.filter((r) => !r.success);
|
|
724
|
+
const successfulSkillNames = new Set(successful.map((r) => r.skill));
|
|
681
725
|
// Build skillFiles map: { skillName: sourceUrl }
|
|
682
726
|
const skillFiles = {};
|
|
683
727
|
for (const skill of selectedSkills) {
|
|
@@ -699,7 +743,6 @@ async function handleWellKnownSkills(source, url, options, spinner) {
|
|
|
699
743
|
}
|
|
700
744
|
// Add to skill lock file for update tracking (only for global installs)
|
|
701
745
|
if (successful.length > 0 && installGlobally) {
|
|
702
|
-
const successfulSkillNames = new Set(successful.map((r) => r.skill));
|
|
703
746
|
for (const skill of selectedSkills) {
|
|
704
747
|
if (successfulSkillNames.has(skill.installName)) {
|
|
705
748
|
try {
|
|
@@ -707,7 +750,7 @@ async function handleWellKnownSkills(source, url, options, spinner) {
|
|
|
707
750
|
source: sourceIdentifier,
|
|
708
751
|
sourceType: 'well-known',
|
|
709
752
|
sourceUrl: skill.sourceUrl,
|
|
710
|
-
skillFolderHash: '',
|
|
753
|
+
skillFolderHash: '',
|
|
711
754
|
sourceBaseUrl: url,
|
|
712
755
|
wellKnownDigest: computeWellKnownSkillDigest(skill),
|
|
713
756
|
});
|
|
@@ -720,7 +763,6 @@ async function handleWellKnownSkills(source, url, options, spinner) {
|
|
|
720
763
|
}
|
|
721
764
|
// Add to local lock file for project-scoped installs
|
|
722
765
|
if (successful.length > 0 && !installGlobally) {
|
|
723
|
-
const successfulSkillNames = new Set(successful.map((r) => r.skill));
|
|
724
766
|
for (const skill of selectedSkills) {
|
|
725
767
|
if (successfulSkillNames.has(skill.installName)) {
|
|
726
768
|
try {
|
|
@@ -759,9 +801,13 @@ async function handleWellKnownSkills(source, url, options, spinner) {
|
|
|
759
801
|
if (firstResult.mode === 'copy') {
|
|
760
802
|
// Copy mode: show skill name and list all agent paths
|
|
761
803
|
resultLines.push(`${pc.green('✓')} ${skillName} ${pc.dim('(copied)')}`);
|
|
804
|
+
const shortPathsSet = new Set();
|
|
762
805
|
for (const r of skillResults) {
|
|
763
806
|
const shortPath = shortenPath(r.path, cwd);
|
|
764
|
-
|
|
807
|
+
if (!shortPathsSet.has(shortPath)) {
|
|
808
|
+
shortPathsSet.add(shortPath);
|
|
809
|
+
resultLines.push(` ${pc.dim('→')} ${shortPath}`);
|
|
810
|
+
}
|
|
765
811
|
}
|
|
766
812
|
}
|
|
767
813
|
else {
|
|
@@ -797,9 +843,277 @@ async function handleWellKnownSkills(source, url, options, spinner) {
|
|
|
797
843
|
await promptForFindSkills(options, targetAgents);
|
|
798
844
|
return true;
|
|
799
845
|
}
|
|
846
|
+
/**
|
|
847
|
+
* Fetch `parsed` (blob snapshot, clone, or download) and discover its skills.
|
|
848
|
+
* Throws instead of exiting; removes its own temp dir when it throws.
|
|
849
|
+
*/
|
|
850
|
+
async function resolveSkills(parsed, options, spinner) {
|
|
851
|
+
const { includeInternal } = options;
|
|
852
|
+
let skills;
|
|
853
|
+
let blobResult = null;
|
|
854
|
+
let tempDir = null;
|
|
855
|
+
try {
|
|
856
|
+
if (parsed.type === 'local') {
|
|
857
|
+
spinner.start('Discovering skills…');
|
|
858
|
+
skills = await discoverSkills(parsed.localPath, parsed.subpath, {
|
|
859
|
+
includeInternal,
|
|
860
|
+
fullDepth: options.fullDepth,
|
|
861
|
+
});
|
|
862
|
+
}
|
|
863
|
+
else if (parsed.type === 'well-known' || parsed.type === 'download') {
|
|
864
|
+
spinner.start('Downloading source...');
|
|
865
|
+
const downloaded = await downloadSource(parsed.url);
|
|
866
|
+
tempDir = downloaded.tempDir;
|
|
867
|
+
spinner.stop(`Downloaded ${downloaded.kind === 'skill-md' ? 'SKILL.md file' : 'archive'}`);
|
|
868
|
+
spinner.start('Discovering skills...');
|
|
869
|
+
skills = await discoverSkills(downloaded.rootDir, parsed.subpath, {
|
|
870
|
+
includeInternal,
|
|
871
|
+
fullDepth: options.fullDepth,
|
|
872
|
+
});
|
|
873
|
+
}
|
|
874
|
+
else if (parsed.type === 'github' && !options.fullDepth) {
|
|
875
|
+
// Try the blob-based fast install for GitHub sources; skip for --full-depth.
|
|
876
|
+
// Eligible per repo (a BLOB_ALLOWED_REPOS entry = self-hosted download URL) or
|
|
877
|
+
// per owner (BLOB_ALLOWED_OWNERS = all their repos, skills.sh-hosted).
|
|
878
|
+
let attemptedBlobInstall = false;
|
|
879
|
+
const BLOB_ALLOWED_OWNERS = ['vercel', 'vercel-labs', 'heygen-com', 'remotion-dev'];
|
|
880
|
+
const ownerRepo = getOwnerRepo(parsed);
|
|
881
|
+
const owner = ownerRepo?.split('/')[0]?.toLowerCase();
|
|
882
|
+
const isSelfHostedRepo = !!ownerRepo && Object.hasOwn(BLOB_ALLOWED_REPOS, ownerRepo.toLowerCase());
|
|
883
|
+
if (ownerRepo && owner && (isSelfHostedRepo || BLOB_ALLOWED_OWNERS.includes(owner))) {
|
|
884
|
+
attemptedBlobInstall = true;
|
|
885
|
+
spinner.start('Fetching skills…');
|
|
886
|
+
blobResult = await tryBlobInstall(ownerRepo, {
|
|
887
|
+
subpath: parsed.subpath,
|
|
888
|
+
skillFilter: parsed.skillFilter,
|
|
889
|
+
ref: parsed.ref,
|
|
890
|
+
getToken: getGitHubToken,
|
|
891
|
+
includeInternal,
|
|
892
|
+
});
|
|
893
|
+
}
|
|
894
|
+
if (blobResult) {
|
|
895
|
+
skills = blobResult.skills;
|
|
896
|
+
spinner.stop(`Found ${pc.green(skills.length)} skill${skills.length > 1 ? 's' : ''}`);
|
|
897
|
+
}
|
|
898
|
+
else {
|
|
899
|
+
// Blob failed — fall back to git clone
|
|
900
|
+
if (attemptedBlobInstall) {
|
|
901
|
+
spinner.message('Cloning repository…');
|
|
902
|
+
}
|
|
903
|
+
else {
|
|
904
|
+
spinner.start('Cloning repository…');
|
|
905
|
+
}
|
|
906
|
+
tempDir = await cloneRepo(parsed.url, parsed.ref);
|
|
907
|
+
spinner.stop('Repository cloned');
|
|
908
|
+
spinner.start('Discovering skills…');
|
|
909
|
+
skills = await discoverSkills(tempDir, parsed.subpath, {
|
|
910
|
+
includeInternal,
|
|
911
|
+
fullDepth: options.fullDepth,
|
|
912
|
+
});
|
|
913
|
+
}
|
|
914
|
+
}
|
|
915
|
+
else {
|
|
916
|
+
// GitLab, git URL, or --full-depth: always clone
|
|
917
|
+
spinner.start('Cloning repository…');
|
|
918
|
+
tempDir = await cloneRepo(parsed.url, parsed.ref);
|
|
919
|
+
spinner.stop('Repository cloned');
|
|
920
|
+
spinner.start('Discovering skills…');
|
|
921
|
+
skills = await discoverSkills(tempDir, parsed.subpath, {
|
|
922
|
+
includeInternal,
|
|
923
|
+
fullDepth: options.fullDepth,
|
|
924
|
+
});
|
|
925
|
+
}
|
|
926
|
+
}
|
|
927
|
+
catch (error) {
|
|
928
|
+
await cleanup(tempDir);
|
|
929
|
+
throw error;
|
|
930
|
+
}
|
|
931
|
+
return { skills, tempDir, blobResult };
|
|
932
|
+
}
|
|
933
|
+
/** Install every skill into every target. Failures are returned per skill × target. */
|
|
934
|
+
async function installToTargets(resolved, skills, targets, options) {
|
|
935
|
+
const results = [];
|
|
936
|
+
for (const skill of skills) {
|
|
937
|
+
for (const target of targets) {
|
|
938
|
+
const { agent, subagent } = target;
|
|
939
|
+
const installOptions = {
|
|
940
|
+
global: options.global,
|
|
941
|
+
mode: options.mode,
|
|
942
|
+
eveSubagent: subagent,
|
|
943
|
+
createMissingAgentRoot: options.createMissingAgentRoot(agent),
|
|
944
|
+
};
|
|
945
|
+
let result;
|
|
946
|
+
if (resolved.blobResult && 'files' in skill) {
|
|
947
|
+
// Blob-based install: write files from snapshot
|
|
948
|
+
const blobSkill = skill;
|
|
949
|
+
result = await installBlobSkillForAgent({ installName: blobSkill.name, files: blobSkill.files }, agent, installOptions);
|
|
950
|
+
}
|
|
951
|
+
else if (resolved.tempDir && skill.path === resolved.tempDir && skill.rawContent) {
|
|
952
|
+
// ADG patch: remote root skills install only SKILL.md, not the whole repository.
|
|
953
|
+
result = await installBlobSkillForAgent({ installName: skill.name, files: [{ path: 'SKILL.md', contents: skill.rawContent }] }, agent, installOptions);
|
|
954
|
+
}
|
|
955
|
+
else {
|
|
956
|
+
// Disk-based install: copy from cloned/local directory.
|
|
957
|
+
result = await installSkillForAgent(skill, agent, installOptions);
|
|
958
|
+
}
|
|
959
|
+
results.push({
|
|
960
|
+
skill: getSkillDisplayName(skill),
|
|
961
|
+
agent: targetDisplayName(target),
|
|
962
|
+
pluginName: skill.pluginName,
|
|
963
|
+
...result,
|
|
964
|
+
});
|
|
965
|
+
}
|
|
966
|
+
}
|
|
967
|
+
return results;
|
|
968
|
+
}
|
|
969
|
+
/** Repo-relative SKILL.md path per skill name; local skills have none. */
|
|
970
|
+
function getSkillRepoPaths(resolved, skills) {
|
|
971
|
+
const { tempDir, blobResult } = resolved;
|
|
972
|
+
const skillFiles = {};
|
|
973
|
+
for (const skill of skills) {
|
|
974
|
+
if (blobResult && 'repoPath' in skill) {
|
|
975
|
+
// Blob-based: repoPath is already the repo-relative path (e.g., "skills/react/SKILL.md")
|
|
976
|
+
skillFiles[skill.name] = skill.repoPath;
|
|
977
|
+
}
|
|
978
|
+
else if (tempDir && skill.path === tempDir) {
|
|
979
|
+
// Skill is at root level of repo
|
|
980
|
+
skillFiles[skill.name] = 'SKILL.md';
|
|
981
|
+
}
|
|
982
|
+
else if (tempDir && skill.path.startsWith(tempDir + sep)) {
|
|
983
|
+
// Compute path relative to repo root (tempDir), not search path
|
|
984
|
+
// Use forward slashes for telemetry (URL-style paths)
|
|
985
|
+
skillFiles[skill.name] =
|
|
986
|
+
skill.path
|
|
987
|
+
.slice(tempDir.length + 1)
|
|
988
|
+
.split(sep)
|
|
989
|
+
.join('/') + '/SKILL.md';
|
|
990
|
+
}
|
|
991
|
+
}
|
|
992
|
+
return skillFiles;
|
|
993
|
+
}
|
|
994
|
+
/** The `source` a project lock entry records for `parsed`. */
|
|
995
|
+
export function getProjectLockSource(parsed) {
|
|
996
|
+
return getLockSource(parsed.url, getOwnerRepo(parsed)) || parsed.url;
|
|
997
|
+
}
|
|
998
|
+
function projectLockEntry(parsed, skillPath, computedHash) {
|
|
999
|
+
const sourceUrl = getProjectLockSourceUrl(parsed.type, parsed.url);
|
|
1000
|
+
return {
|
|
1001
|
+
source: getProjectLockSource(parsed),
|
|
1002
|
+
...(sourceUrl && { sourceUrl }),
|
|
1003
|
+
ref: parsed.ref,
|
|
1004
|
+
sourceType: parsed.type,
|
|
1005
|
+
...(skillPath && { skillPath }),
|
|
1006
|
+
computedHash,
|
|
1007
|
+
};
|
|
1008
|
+
}
|
|
1009
|
+
/**
|
|
1010
|
+
* Install skills from `parsed` at project scope without prompting or exiting:
|
|
1011
|
+
* keep `skills` (all when empty), let `select` drop any, install into
|
|
1012
|
+
* `agents`, and record the project lock (with `via` when given).
|
|
1013
|
+
*/
|
|
1014
|
+
export async function installFromSource(parsed, options) {
|
|
1015
|
+
const spinner = p.spinner();
|
|
1016
|
+
let resolved = null;
|
|
1017
|
+
try {
|
|
1018
|
+
resolved = await resolveSkills(parsed, { includeInternal: options.skills.length > 0 }, spinner);
|
|
1019
|
+
let selected = options.skills.length > 0 ? filterSkills(resolved.skills, options.skills) : resolved.skills;
|
|
1020
|
+
if (selected.length === 0) {
|
|
1021
|
+
spinner.stop(pc.red('No matching skills found'));
|
|
1022
|
+
return { installed: [], failed: [], error: 'No matching skills found' };
|
|
1023
|
+
}
|
|
1024
|
+
spinner.stop(`Found ${pc.green(selected.length)} skill${selected.length > 1 ? 's' : ''}`);
|
|
1025
|
+
if (options.select)
|
|
1026
|
+
selected = await options.select(selected);
|
|
1027
|
+
const results = await installToTargets(resolved, selected, options.agents.map((agent) => ({ agent })), { global: false, mode: 'symlink', createMissingAgentRoot: () => true });
|
|
1028
|
+
const installed = new Set(results.filter((r) => r.success).map((r) => r.skill));
|
|
1029
|
+
const repoPaths = getSkillRepoPaths(resolved, selected);
|
|
1030
|
+
for (const skill of selected) {
|
|
1031
|
+
if (!installed.has(getSkillDisplayName(skill)))
|
|
1032
|
+
continue;
|
|
1033
|
+
const entry = projectLockEntry(parsed, repoPaths[skill.name], await sourceSkillHash(skill, resolved));
|
|
1034
|
+
await addSkillToLocalLock(skill.name, { ...entry, ...(options.via && { via: options.via }) });
|
|
1035
|
+
}
|
|
1036
|
+
return {
|
|
1037
|
+
installed: [...installed],
|
|
1038
|
+
failed: results.filter((r) => !r.success).map((r) => `${r.skill} → ${r.agent}: ${r.error}`),
|
|
1039
|
+
};
|
|
1040
|
+
}
|
|
1041
|
+
catch (error) {
|
|
1042
|
+
spinner.stop(pc.red('Installation failed'));
|
|
1043
|
+
return {
|
|
1044
|
+
installed: [],
|
|
1045
|
+
failed: [],
|
|
1046
|
+
error: error instanceof Error ? error.message : String(error),
|
|
1047
|
+
};
|
|
1048
|
+
}
|
|
1049
|
+
finally {
|
|
1050
|
+
await cleanup(resolved?.tempDir ?? null);
|
|
1051
|
+
}
|
|
1052
|
+
}
|
|
1053
|
+
/** Content hash of a skill at its source: the blob snapshot, or the folder on disk. */
|
|
1054
|
+
function sourceSkillHash(skill, resolved) {
|
|
1055
|
+
if (resolved.tempDir && skill.path === resolved.tempDir && skill.rawContent) {
|
|
1056
|
+
return Promise.resolve(computeSingleFileSkillHash(skill.rawContent));
|
|
1057
|
+
}
|
|
1058
|
+
// snapshotHash is only present on BlobSkill
|
|
1059
|
+
return 'snapshotHash' in skill
|
|
1060
|
+
? Promise.resolve(skill.snapshotHash)
|
|
1061
|
+
: computeSkillFolderHash(skill.path);
|
|
1062
|
+
}
|
|
800
1063
|
export async function runAdd(args, options = {}) {
|
|
801
1064
|
const source = args[0];
|
|
802
1065
|
let installTipShown = false;
|
|
1066
|
+
// ─── JSON output mode ───
|
|
1067
|
+
// Suppress all decorated stdout (clack banners, spinners, notes) and emit a
|
|
1068
|
+
// single JSON array on stdout instead. Human error text goes to stderr.
|
|
1069
|
+
const jsonMode = options.json === true;
|
|
1070
|
+
const jsonResults = [];
|
|
1071
|
+
const originalStdoutWrite = process.stdout.write;
|
|
1072
|
+
let stdoutSuppressed = false;
|
|
1073
|
+
if (jsonMode) {
|
|
1074
|
+
// Keep stdout reserved for the JSON value while preserving human-facing
|
|
1075
|
+
// progress and diagnostics on stderr, as promised by the command contract.
|
|
1076
|
+
process.stdout.write = process.stderr.write.bind(process.stderr);
|
|
1077
|
+
stdoutSuppressed = true;
|
|
1078
|
+
}
|
|
1079
|
+
const restoreStdout = () => {
|
|
1080
|
+
if (stdoutSuppressed) {
|
|
1081
|
+
process.stdout.write = originalStdoutWrite;
|
|
1082
|
+
stdoutSuppressed = false;
|
|
1083
|
+
}
|
|
1084
|
+
};
|
|
1085
|
+
let jsonEmitted = false;
|
|
1086
|
+
const emitJson = () => {
|
|
1087
|
+
if (!jsonMode || jsonEmitted)
|
|
1088
|
+
return;
|
|
1089
|
+
jsonEmitted = true;
|
|
1090
|
+
restoreStdout();
|
|
1091
|
+
console.log(JSON.stringify(jsonResults, null, 2));
|
|
1092
|
+
};
|
|
1093
|
+
/**
|
|
1094
|
+
* Every exit path must emit exactly one JSON array in json mode.
|
|
1095
|
+
* In non-json mode this is a plain process.exit(code).
|
|
1096
|
+
*
|
|
1097
|
+
* The explicit type annotation (not just a return annotation) is what lets
|
|
1098
|
+
* TypeScript narrow control flow after calls, like `process.exit` does.
|
|
1099
|
+
*/
|
|
1100
|
+
const emitJsonAndExit = (code, errorMessage) => {
|
|
1101
|
+
if (jsonMode) {
|
|
1102
|
+
if (errorMessage !== undefined)
|
|
1103
|
+
console.error(errorMessage);
|
|
1104
|
+
if (code !== 0 && jsonResults.length === 0) {
|
|
1105
|
+
jsonResults.push({ status: 'failed', error: errorMessage ?? 'Installation failed' });
|
|
1106
|
+
}
|
|
1107
|
+
emitJson();
|
|
1108
|
+
}
|
|
1109
|
+
process.exit(code);
|
|
1110
|
+
};
|
|
1111
|
+
const emitJsonOnExit = () => emitJson();
|
|
1112
|
+
if (jsonMode) {
|
|
1113
|
+
// Safety net for exit paths outside this function (e.g. nested helpers):
|
|
1114
|
+
// guarantee stdout carries one parseable array even then.
|
|
1115
|
+
process.once('exit', emitJsonOnExit);
|
|
1116
|
+
}
|
|
803
1117
|
const showInstallTip = () => {
|
|
804
1118
|
if (installTipShown)
|
|
805
1119
|
return;
|
|
@@ -816,8 +1130,11 @@ export async function runAdd(args, options = {}) {
|
|
|
816
1130
|
console.log(pc.dim(' Example:'));
|
|
817
1131
|
console.log(` ${pc.cyan('adg skills add')} ${pc.yellow('vercel-labs/agent-skills')}`);
|
|
818
1132
|
console.log();
|
|
819
|
-
|
|
1133
|
+
emitJsonAndExit(1, 'Missing required argument: source');
|
|
820
1134
|
}
|
|
1135
|
+
// Capture command-line intent before agent-context detection populates
|
|
1136
|
+
// options.agent with automatic defaults.
|
|
1137
|
+
const explicitlySelectedAgents = new Set(options.agent?.includes('*') ? [] : (options.agent ?? []));
|
|
821
1138
|
// --all implies --skill '*' and --agent '*' and -y
|
|
822
1139
|
if (options.all) {
|
|
823
1140
|
options.skill = ['*'];
|
|
@@ -836,6 +1153,14 @@ export async function runAdd(args, options = {}) {
|
|
|
836
1153
|
}
|
|
837
1154
|
}
|
|
838
1155
|
}
|
|
1156
|
+
// --json is machine-oriented: never prompt. Require an explicit
|
|
1157
|
+
// non-interactive mode instead of hanging on (or cancelling) a prompt.
|
|
1158
|
+
if (jsonMode && !options.yes) {
|
|
1159
|
+
emitJsonAndExit(1, 'The --json flag requires --yes (or --all) to run non-interactively.');
|
|
1160
|
+
}
|
|
1161
|
+
if (jsonMode && options.list) {
|
|
1162
|
+
emitJsonAndExit(1, 'The --json flag cannot be combined with --list.');
|
|
1163
|
+
}
|
|
839
1164
|
console.log();
|
|
840
1165
|
if (!agentResult.isAgent) {
|
|
841
1166
|
p.intro(pc.bgCyan(pc.black(' skills ')));
|
|
@@ -850,15 +1175,48 @@ export async function runAdd(args, options = {}) {
|
|
|
850
1175
|
}
|
|
851
1176
|
let tempDir = null;
|
|
852
1177
|
try {
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
const
|
|
856
|
-
|
|
1178
|
+
let effectiveSource = source;
|
|
1179
|
+
let notionSourceLabel = null;
|
|
1180
|
+
const notionSkillPageId = parseNotionSkillUrl(source);
|
|
1181
|
+
if (isNotionSource(source) || notionSkillPageId) {
|
|
1182
|
+
const prepared = notionSkillPageId
|
|
1183
|
+
? await prepareNotionSkillSource(notionSkillPageId)
|
|
1184
|
+
: await prepareNotionPackSource(options);
|
|
1185
|
+
if (!prepared)
|
|
1186
|
+
return;
|
|
1187
|
+
effectiveSource = prepared.rootDir;
|
|
1188
|
+
tempDir = prepared.tempDir;
|
|
1189
|
+
notionSourceLabel =
|
|
1190
|
+
'packCount' in prepared
|
|
1191
|
+
? `${prepared.packCount} selected Notion pack${prepared.packCount === 1 ? '' : 's'}`
|
|
1192
|
+
: 'Notion page';
|
|
1193
|
+
// The pack selection or page URL already chose the skills to install.
|
|
1194
|
+
options.skill = ['*'];
|
|
1195
|
+
}
|
|
1196
|
+
// In json mode, use an inert spinner: clack spinners poll the terminal and
|
|
1197
|
+
// write frames/cursor sequences that must never reach stdout.
|
|
1198
|
+
const spinner = jsonMode
|
|
1199
|
+
? {
|
|
1200
|
+
start: () => { },
|
|
1201
|
+
stop: () => { },
|
|
1202
|
+
message: () => { },
|
|
1203
|
+
}
|
|
1204
|
+
: p.spinner();
|
|
1205
|
+
spinner.start('Parsing source…');
|
|
1206
|
+
const parsed = parseSource(effectiveSource);
|
|
1207
|
+
let directDownload = parsed.type === 'download' || notionSourceLabel !== null;
|
|
1208
|
+
spinner.stop(notionSourceLabel !== null
|
|
1209
|
+
? `Source: ${notionSourceLabel}`
|
|
1210
|
+
: `Source: ${parsed.type === 'local' ? parsed.localPath : parsed.url}${parsed.ref ? ` @ ${pc.yellow(parsed.ref)}` : ''}${parsed.subpath ? ` (${parsed.subpath})` : ''}${parsed.skillFilter ? ` ${pc.dim('@')}${pc.cyan(parsed.skillFilter)}` : ''}`);
|
|
857
1211
|
// Kick off the repo privacy check early so it runs in parallel with
|
|
858
1212
|
// cloning/discovering/installing. The result is only needed later for
|
|
859
1213
|
// telemetry gating — it should never block user-visible output.
|
|
860
|
-
const ownerRepoRaw = getOwnerRepo(parsed);
|
|
1214
|
+
const ownerRepoRaw = parsed.type === 'well-known' || parsed.type === 'download' ? null : getOwnerRepo(parsed);
|
|
861
1215
|
const repoPrivacyPromise = (() => {
|
|
1216
|
+
// The privacy endpoint below is GitHub.com-specific. In particular, do
|
|
1217
|
+
// not send GitHub Enterprise repository names to the public API.
|
|
1218
|
+
if (parsed.type !== 'github')
|
|
1219
|
+
return Promise.resolve(null);
|
|
862
1220
|
if (!ownerRepoRaw)
|
|
863
1221
|
return Promise.resolve(null);
|
|
864
1222
|
const ownerRepo = parseOwnerRepo(ownerRepoRaw);
|
|
@@ -866,10 +1224,14 @@ export async function runAdd(args, options = {}) {
|
|
|
866
1224
|
return Promise.resolve(null);
|
|
867
1225
|
return isRepoPrivate(ownerRepo.owner, ownerRepo.repo).catch(() => null);
|
|
868
1226
|
})();
|
|
869
|
-
|
|
870
|
-
//
|
|
871
|
-
// yield skills, the same URL may still be a raw SKILL.md or archive.
|
|
1227
|
+
// Handle arbitrary URLs by trying well-known discovery first, then
|
|
1228
|
+
// falling back to a direct SKILL.md/archive download.
|
|
872
1229
|
if (parsed.type === 'well-known') {
|
|
1230
|
+
if (jsonMode) {
|
|
1231
|
+
// The well-known flow has its own prompts and exit paths that do not
|
|
1232
|
+
// feed the JSON accumulator yet.
|
|
1233
|
+
emitJsonAndExit(1, '--json is not yet supported for well-known skill sources.');
|
|
1234
|
+
}
|
|
873
1235
|
const handled = await handleWellKnownSkills(source, parsed.url, options, spinner);
|
|
874
1236
|
if (handled)
|
|
875
1237
|
return;
|
|
@@ -884,89 +1246,30 @@ export async function runAdd(args, options = {}) {
|
|
|
884
1246
|
}
|
|
885
1247
|
}
|
|
886
1248
|
// Include internal skills when a specific skill is explicitly requested
|
|
887
|
-
// (via --skill or @skill syntax)
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
1249
|
+
// (via --skill or @skill syntax). The '*' wildcard is a bulk request, not
|
|
1250
|
+
// an explicit one, so internal skills stay hidden from it unless
|
|
1251
|
+
// INSTALL_INTERNAL_SKILLS is set.
|
|
1252
|
+
const includeInternal = !!(options.skill &&
|
|
1253
|
+
options.skill.length > 0 &&
|
|
1254
|
+
!options.skill.includes('*'));
|
|
891
1255
|
if (parsed.type === 'local') {
|
|
892
|
-
|
|
893
|
-
spinner.start('Validating local path...');
|
|
1256
|
+
spinner.start('Validating local path…');
|
|
894
1257
|
if (!existsSync(parsed.localPath)) {
|
|
895
1258
|
spinner.stop(pc.red('Path not found'));
|
|
896
1259
|
p.outro(pc.red(`Local path does not exist: ${parsed.localPath}`));
|
|
897
|
-
|
|
1260
|
+
emitJsonAndExit(1, `Local path does not exist: ${parsed.localPath}`);
|
|
898
1261
|
}
|
|
899
1262
|
spinner.stop('Local path validated');
|
|
900
|
-
spinner.start('Discovering skills...');
|
|
901
|
-
skills = await discoverSkills(parsed.localPath, parsed.subpath, {
|
|
902
|
-
includeInternal,
|
|
903
|
-
fullDepth: options.fullDepth,
|
|
904
|
-
});
|
|
905
|
-
}
|
|
906
|
-
else if (parsed.type === 'well-known' || parsed.type === 'download') {
|
|
907
|
-
spinner.start('Downloading source...');
|
|
908
|
-
const downloaded = await downloadSource(parsed.url);
|
|
909
|
-
tempDir = downloaded.tempDir;
|
|
910
|
-
spinner.stop(`Downloaded ${downloaded.kind === 'skill-md' ? 'SKILL.md file' : 'archive'}`);
|
|
911
|
-
spinner.start('Discovering skills...');
|
|
912
|
-
skills = await discoverSkills(downloaded.rootDir, parsed.subpath, {
|
|
913
|
-
includeInternal,
|
|
914
|
-
fullDepth: options.fullDepth,
|
|
915
|
-
});
|
|
916
|
-
}
|
|
917
|
-
else if (parsed.type === 'github' && !options.fullDepth) {
|
|
918
|
-
// Try the blob-based fast install for GitHub sources; skip for --full-depth.
|
|
919
|
-
// Eligible per repo (a BLOB_ALLOWED_REPOS entry = self-hosted download URL) or
|
|
920
|
-
// per owner (BLOB_ALLOWED_OWNERS = all their repos, skills.sh-hosted).
|
|
921
|
-
const BLOB_ALLOWED_OWNERS = ['vercel', 'vercel-labs', 'heygen-com'];
|
|
922
|
-
const ownerRepo = getOwnerRepo(parsed);
|
|
923
|
-
const owner = ownerRepo?.split('/')[0]?.toLowerCase();
|
|
924
|
-
const isSelfHostedRepo = !!ownerRepo && Object.hasOwn(BLOB_ALLOWED_REPOS, ownerRepo.toLowerCase());
|
|
925
|
-
if (ownerRepo && owner && (isSelfHostedRepo || BLOB_ALLOWED_OWNERS.includes(owner))) {
|
|
926
|
-
spinner.start('Fetching skills...');
|
|
927
|
-
blobResult = await tryBlobInstall(ownerRepo, {
|
|
928
|
-
subpath: parsed.subpath,
|
|
929
|
-
skillFilter: parsed.skillFilter,
|
|
930
|
-
ref: parsed.ref,
|
|
931
|
-
getToken: getGitHubToken,
|
|
932
|
-
includeInternal,
|
|
933
|
-
});
|
|
934
|
-
if (!blobResult) {
|
|
935
|
-
spinner.stop(pc.dim('Falling back to clone...'));
|
|
936
|
-
}
|
|
937
|
-
}
|
|
938
|
-
if (blobResult) {
|
|
939
|
-
skills = blobResult.skills;
|
|
940
|
-
spinner.stop(`Found ${pc.green(skills.length)} skill${skills.length > 1 ? 's' : ''}`);
|
|
941
|
-
}
|
|
942
|
-
else {
|
|
943
|
-
// Blob failed — fall back to git clone
|
|
944
|
-
spinner.start('Cloning repository...');
|
|
945
|
-
tempDir = await cloneRepo(parsed.url, parsed.ref);
|
|
946
|
-
spinner.stop('Repository cloned');
|
|
947
|
-
spinner.start('Discovering skills...');
|
|
948
|
-
skills = await discoverSkills(tempDir, parsed.subpath, {
|
|
949
|
-
includeInternal,
|
|
950
|
-
fullDepth: options.fullDepth,
|
|
951
|
-
});
|
|
952
|
-
}
|
|
953
|
-
}
|
|
954
|
-
else {
|
|
955
|
-
// GitLab, git URL, or --full-depth: always clone
|
|
956
|
-
spinner.start('Cloning repository...');
|
|
957
|
-
tempDir = await cloneRepo(parsed.url, parsed.ref);
|
|
958
|
-
spinner.stop('Repository cloned');
|
|
959
|
-
spinner.start('Discovering skills...');
|
|
960
|
-
skills = await discoverSkills(tempDir, parsed.subpath, {
|
|
961
|
-
includeInternal,
|
|
962
|
-
fullDepth: options.fullDepth,
|
|
963
|
-
});
|
|
964
1263
|
}
|
|
1264
|
+
const resolved = await resolveSkills(parsed, { includeInternal, fullDepth: options.fullDepth }, spinner);
|
|
1265
|
+
const { skills, blobResult } = resolved;
|
|
1266
|
+
// a Notion source already owns tempDir; a local resolve has none of its own
|
|
1267
|
+
tempDir = resolved.tempDir ?? tempDir;
|
|
965
1268
|
if (skills.length === 0) {
|
|
966
1269
|
spinner.stop(pc.red('No skills found'));
|
|
967
1270
|
p.outro(pc.red('No valid skills found. Skills require a SKILL.md with name and description.'));
|
|
968
1271
|
await cleanup(tempDir);
|
|
969
|
-
|
|
1272
|
+
emitJsonAndExit(1, 'No valid skills found. Skills require a SKILL.md with name and description.');
|
|
970
1273
|
}
|
|
971
1274
|
if (!blobResult) {
|
|
972
1275
|
spinner.stop(`Found ${pc.green(skills.length)} skill${skills.length > 1 ? 's' : ''}`);
|
|
@@ -1015,16 +1318,29 @@ export async function runAdd(args, options = {}) {
|
|
|
1015
1318
|
console.log();
|
|
1016
1319
|
p.outro('Use --skill <name> to install specific skills');
|
|
1017
1320
|
await cleanup(tempDir);
|
|
1018
|
-
|
|
1321
|
+
emitJsonAndExit(0);
|
|
1019
1322
|
}
|
|
1020
1323
|
let selectedSkills;
|
|
1324
|
+
const logChosen = (chosen) => logAutoSelectedSkills(chosen.map((s) => ({ label: getSkillDisplayName(s), description: s.description })));
|
|
1021
1325
|
if (options.skill?.includes('*')) {
|
|
1022
1326
|
// --skill '*' selects all skills
|
|
1023
1327
|
selectedSkills = skills;
|
|
1024
|
-
|
|
1328
|
+
logChosen(selectedSkills);
|
|
1025
1329
|
}
|
|
1026
1330
|
else if (options.skill && options.skill.length > 0) {
|
|
1027
1331
|
selectedSkills = filterSkills(skills, options.skill);
|
|
1332
|
+
// Requested names that matched nothing are reported as skipped entries.
|
|
1333
|
+
if (jsonMode) {
|
|
1334
|
+
for (const requested of options.skill) {
|
|
1335
|
+
if (filterSkills(skills, [requested]).length === 0) {
|
|
1336
|
+
jsonResults.push({
|
|
1337
|
+
name: requested,
|
|
1338
|
+
status: 'skipped',
|
|
1339
|
+
reason: 'No matching skill found in source',
|
|
1340
|
+
});
|
|
1341
|
+
}
|
|
1342
|
+
}
|
|
1343
|
+
}
|
|
1028
1344
|
if (selectedSkills.length === 0) {
|
|
1029
1345
|
p.log.error(`No matching skills found for: ${options.skill.join(', ')}`);
|
|
1030
1346
|
p.log.info('Available skills:');
|
|
@@ -1032,19 +1348,13 @@ export async function runAdd(args, options = {}) {
|
|
|
1032
1348
|
p.log.message(` - ${getSkillDisplayName(s)}`);
|
|
1033
1349
|
}
|
|
1034
1350
|
await cleanup(tempDir);
|
|
1035
|
-
|
|
1351
|
+
emitJsonAndExit(1, `No matching skills found for: ${options.skill.join(', ')}`);
|
|
1036
1352
|
}
|
|
1037
1353
|
p.log.info(`Selected ${selectedSkills.length} skill${selectedSkills.length !== 1 ? 's' : ''}: ${selectedSkills.map((s) => pc.cyan(getSkillDisplayName(s))).join(', ')}`);
|
|
1038
1354
|
}
|
|
1039
|
-
else if (skills.length === 1) {
|
|
1040
|
-
selectedSkills = skills;
|
|
1041
|
-
const firstSkill = skills[0];
|
|
1042
|
-
p.log.info(`Skill: ${pc.cyan(getSkillDisplayName(firstSkill))}`);
|
|
1043
|
-
p.log.message(pc.dim(firstSkill.description));
|
|
1044
|
-
}
|
|
1045
|
-
else if (options.yes) {
|
|
1355
|
+
else if (skills.length === 1 || options.yes) {
|
|
1046
1356
|
selectedSkills = skills;
|
|
1047
|
-
|
|
1357
|
+
logChosen(selectedSkills);
|
|
1048
1358
|
}
|
|
1049
1359
|
else {
|
|
1050
1360
|
// Sort skills by plugin name first, then by skill name
|
|
@@ -1118,18 +1428,20 @@ export async function runAdd(args, options = {}) {
|
|
|
1118
1428
|
required: true,
|
|
1119
1429
|
});
|
|
1120
1430
|
}
|
|
1121
|
-
if (
|
|
1122
|
-
p.cancel('Installation cancelled');
|
|
1431
|
+
if (isCancelled(selected)) {
|
|
1123
1432
|
await cleanup(tempDir);
|
|
1124
|
-
|
|
1433
|
+
exitInstallationCancelled();
|
|
1125
1434
|
}
|
|
1126
1435
|
selectedSkills = selected;
|
|
1127
1436
|
}
|
|
1128
|
-
// Kick off security audit
|
|
1129
|
-
//
|
|
1437
|
+
// Kick off the security audit only after GitHub has positively confirmed
|
|
1438
|
+
// that this is a public repository. Private and unknown repositories must
|
|
1439
|
+
// not send their names or skill names to the audit service.
|
|
1130
1440
|
const ownerRepoForAudit = getOwnerRepo(parsed);
|
|
1131
1441
|
const auditPromise = ownerRepoForAudit
|
|
1132
|
-
?
|
|
1442
|
+
? repoPrivacyPromise.then((isPrivate) => isPrivate === false
|
|
1443
|
+
? fetchAuditData(ownerRepoForAudit, selectedSkills.map((s) => getSkillDisplayName(s)))
|
|
1444
|
+
: null)
|
|
1133
1445
|
: Promise.resolve(null);
|
|
1134
1446
|
let targetAgents;
|
|
1135
1447
|
const validAgents = Object.keys(agents);
|
|
@@ -1144,12 +1456,12 @@ export async function runAdd(args, options = {}) {
|
|
|
1144
1456
|
p.log.error(`Invalid agents: ${invalidAgents.join(', ')}`);
|
|
1145
1457
|
p.log.info(`Valid agents: ${validAgents.join(', ')}`);
|
|
1146
1458
|
await cleanup(tempDir);
|
|
1147
|
-
|
|
1459
|
+
emitJsonAndExit(1, `Invalid agents: ${invalidAgents.join(', ')}`);
|
|
1148
1460
|
}
|
|
1149
1461
|
targetAgents = options.agent;
|
|
1150
1462
|
}
|
|
1151
1463
|
else {
|
|
1152
|
-
spinner.start('Loading agents
|
|
1464
|
+
spinner.start('Loading agents…');
|
|
1153
1465
|
const installedAgents = await detectInstalledAgents();
|
|
1154
1466
|
const totalAgents = Object.keys(agents).length;
|
|
1155
1467
|
spinner.stop(`${totalAgents} agents`);
|
|
@@ -1161,22 +1473,24 @@ export async function runAdd(args, options = {}) {
|
|
|
1161
1473
|
initialValue: true,
|
|
1162
1474
|
});
|
|
1163
1475
|
if (p.isCancel(useEve)) {
|
|
1164
|
-
p.cancel('Installation cancelled');
|
|
1165
1476
|
await cleanup(tempDir);
|
|
1166
|
-
|
|
1477
|
+
exitInstallationCancelled();
|
|
1167
1478
|
}
|
|
1168
1479
|
if (useEve) {
|
|
1169
1480
|
targetAgents = ['eve'];
|
|
1481
|
+
if (!options.yes)
|
|
1482
|
+
explicitlySelectedAgents.add('eve');
|
|
1170
1483
|
p.log.info(`Installing to: ${pc.cyan(EVE_AGENT_LABEL)}`);
|
|
1171
1484
|
}
|
|
1172
1485
|
else {
|
|
1173
1486
|
const selected = await selectAgentsInteractive({ global: options.global });
|
|
1174
|
-
if (
|
|
1175
|
-
p.cancel('Installation cancelled');
|
|
1487
|
+
if (isCancelled(selected)) {
|
|
1176
1488
|
await cleanup(tempDir);
|
|
1177
|
-
|
|
1489
|
+
exitInstallationCancelled();
|
|
1178
1490
|
}
|
|
1179
1491
|
targetAgents = selected;
|
|
1492
|
+
for (const agent of targetAgents)
|
|
1493
|
+
explicitlySelectedAgents.add(agent);
|
|
1180
1494
|
}
|
|
1181
1495
|
}
|
|
1182
1496
|
else if (installedAgents.length === 0) {
|
|
@@ -1194,12 +1508,13 @@ export async function runAdd(args, options = {}) {
|
|
|
1194
1508
|
}));
|
|
1195
1509
|
// Use helper to prompt with search
|
|
1196
1510
|
const selected = await promptForAgents('Which agents do you want to install to?', allAgentChoices);
|
|
1197
|
-
if (
|
|
1198
|
-
p.cancel('Installation cancelled');
|
|
1511
|
+
if (isCancelled(selected)) {
|
|
1199
1512
|
await cleanup(tempDir);
|
|
1200
|
-
|
|
1513
|
+
exitInstallationCancelled();
|
|
1201
1514
|
}
|
|
1202
1515
|
targetAgents = selected;
|
|
1516
|
+
for (const agent of targetAgents)
|
|
1517
|
+
explicitlySelectedAgents.add(agent);
|
|
1203
1518
|
}
|
|
1204
1519
|
}
|
|
1205
1520
|
else if (installedAgents.length === 1 || options.yes) {
|
|
@@ -1215,17 +1530,20 @@ export async function runAdd(args, options = {}) {
|
|
|
1215
1530
|
}
|
|
1216
1531
|
else {
|
|
1217
1532
|
const selected = await selectAgentsInteractive({ global: options.global });
|
|
1218
|
-
if (
|
|
1219
|
-
p.cancel('Installation cancelled');
|
|
1533
|
+
if (isCancelled(selected)) {
|
|
1220
1534
|
await cleanup(tempDir);
|
|
1221
|
-
|
|
1535
|
+
exitInstallationCancelled();
|
|
1222
1536
|
}
|
|
1223
1537
|
targetAgents = selected;
|
|
1538
|
+
for (const agent of targetAgents)
|
|
1539
|
+
explicitlySelectedAgents.add(agent);
|
|
1224
1540
|
}
|
|
1225
1541
|
}
|
|
1226
1542
|
// An explicit --subagent flag implies the user wants to target Eve.
|
|
1227
|
-
if (options.subagent && options.subagent.length > 0
|
|
1228
|
-
|
|
1543
|
+
if (options.subagent && options.subagent.length > 0) {
|
|
1544
|
+
explicitlySelectedAgents.add('eve');
|
|
1545
|
+
if (!targetAgents.includes('eve'))
|
|
1546
|
+
targetAgents = [...targetAgents, 'eve'];
|
|
1229
1547
|
}
|
|
1230
1548
|
// Eve supports subagents, each with their own skills directory at
|
|
1231
1549
|
// agent/subagents/<name>/skills in addition to the root agent/skills.
|
|
@@ -1253,9 +1571,8 @@ export async function runAdd(args, options = {}) {
|
|
|
1253
1571
|
required: true,
|
|
1254
1572
|
});
|
|
1255
1573
|
if (p.isCancel(selectedSubagents)) {
|
|
1256
|
-
p.cancel('Installation cancelled');
|
|
1257
1574
|
await cleanup(tempDir);
|
|
1258
|
-
|
|
1575
|
+
exitInstallationCancelled();
|
|
1259
1576
|
}
|
|
1260
1577
|
eveSubagentTargets = selectedSubagents.map((s) => (s === '' ? undefined : s));
|
|
1261
1578
|
}
|
|
@@ -1281,9 +1598,8 @@ export async function runAdd(args, options = {}) {
|
|
|
1281
1598
|
],
|
|
1282
1599
|
});
|
|
1283
1600
|
if (p.isCancel(scope)) {
|
|
1284
|
-
p.cancel('Installation cancelled');
|
|
1285
1601
|
await cleanup(tempDir);
|
|
1286
|
-
|
|
1602
|
+
exitInstallationCancelled();
|
|
1287
1603
|
}
|
|
1288
1604
|
installGlobally = scope;
|
|
1289
1605
|
}
|
|
@@ -1308,9 +1624,8 @@ export async function runAdd(args, options = {}) {
|
|
|
1308
1624
|
],
|
|
1309
1625
|
});
|
|
1310
1626
|
if (p.isCancel(modeChoice)) {
|
|
1311
|
-
p.cancel('Installation cancelled');
|
|
1312
1627
|
await cleanup(tempDir);
|
|
1313
|
-
|
|
1628
|
+
exitInstallationCancelled();
|
|
1314
1629
|
}
|
|
1315
1630
|
installMode = modeChoice;
|
|
1316
1631
|
}
|
|
@@ -1398,8 +1713,10 @@ export async function runAdd(args, options = {}) {
|
|
|
1398
1713
|
p.note(summaryLines.join('\n'), 'Installation Summary');
|
|
1399
1714
|
// Await and display security audit results (started earlier in parallel)
|
|
1400
1715
|
// Wrapped in try/catch so a failed audit fetch never blocks installation.
|
|
1716
|
+
let auditDataForJson = null;
|
|
1401
1717
|
try {
|
|
1402
1718
|
const auditData = await auditPromise;
|
|
1719
|
+
auditDataForJson = auditData;
|
|
1403
1720
|
if (auditData && ownerRepoForAudit) {
|
|
1404
1721
|
const securityLines = buildSecurityLines(auditData, selectedSkills.map((s) => ({
|
|
1405
1722
|
slug: getSkillDisplayName(s),
|
|
@@ -1416,78 +1733,27 @@ export async function runAdd(args, options = {}) {
|
|
|
1416
1733
|
if (!options.yes) {
|
|
1417
1734
|
const confirmed = await p.confirm({ message: 'Proceed with installation?' });
|
|
1418
1735
|
if (p.isCancel(confirmed) || !confirmed) {
|
|
1419
|
-
p.cancel('Installation cancelled');
|
|
1420
1736
|
await cleanup(tempDir);
|
|
1421
|
-
|
|
1422
|
-
}
|
|
1423
|
-
}
|
|
1424
|
-
spinner.start('Installing skills...');
|
|
1425
|
-
const results = [];
|
|
1426
|
-
for (const skill of selectedSkills) {
|
|
1427
|
-
for (const target of installTargets) {
|
|
1428
|
-
const { agent, subagent } = target;
|
|
1429
|
-
let result;
|
|
1430
|
-
if (blobResult && 'files' in skill) {
|
|
1431
|
-
// Blob-based install: write files from snapshot
|
|
1432
|
-
const blobSkill = skill;
|
|
1433
|
-
result = await installBlobSkillForAgent({ installName: blobSkill.name, files: blobSkill.files }, agent, { global: installGlobally, mode: installMode, eveSubagent: subagent });
|
|
1434
|
-
}
|
|
1435
|
-
else if (tempDir && skill.path === tempDir && skill.rawContent) {
|
|
1436
|
-
// Remote root-level SKILL.md: install the skill file, not the whole repository.
|
|
1437
|
-
result = await installBlobSkillForAgent({ installName: skill.name, files: [{ path: 'SKILL.md', contents: skill.rawContent }] }, agent, { global: installGlobally, mode: installMode });
|
|
1438
|
-
}
|
|
1439
|
-
else {
|
|
1440
|
-
// Disk-based install: copy from cloned/local directory
|
|
1441
|
-
result = await installSkillForAgent(skill, agent, {
|
|
1442
|
-
global: installGlobally,
|
|
1443
|
-
mode: installMode,
|
|
1444
|
-
eveSubagent: subagent,
|
|
1445
|
-
});
|
|
1446
|
-
}
|
|
1447
|
-
results.push({
|
|
1448
|
-
skill: getSkillDisplayName(skill),
|
|
1449
|
-
agent: targetDisplayName(target),
|
|
1450
|
-
pluginName: skill.pluginName,
|
|
1451
|
-
...result,
|
|
1452
|
-
});
|
|
1737
|
+
exitInstallationCancelled();
|
|
1453
1738
|
}
|
|
1454
1739
|
}
|
|
1740
|
+
spinner.start('Installing skills…');
|
|
1741
|
+
const results = await installToTargets(resolved, selectedSkills, installTargets, {
|
|
1742
|
+
global: installGlobally,
|
|
1743
|
+
mode: installMode,
|
|
1744
|
+
createMissingAgentRoot: (agent) => explicitlySelectedAgents.has(agent),
|
|
1745
|
+
});
|
|
1455
1746
|
spinner.stop('Installation complete');
|
|
1456
1747
|
console.log();
|
|
1457
1748
|
const successful = results.filter((r) => r.success);
|
|
1458
1749
|
const failed = results.filter((r) => !r.success);
|
|
1750
|
+
const successfulSkillNames = new Set(successful.map((r) => r.skill));
|
|
1459
1751
|
// Track installation result
|
|
1460
1752
|
// Build skillFiles map: { skillName: relative path to SKILL.md from repo root }
|
|
1461
|
-
const skillFiles =
|
|
1462
|
-
for (const skill of selectedSkills) {
|
|
1463
|
-
if (blobResult && 'repoPath' in skill) {
|
|
1464
|
-
// Blob-based: repoPath is already the repo-relative path (e.g., "skills/react/SKILL.md")
|
|
1465
|
-
skillFiles[skill.name] = skill.repoPath;
|
|
1466
|
-
}
|
|
1467
|
-
else if (tempDir && skill.path === tempDir) {
|
|
1468
|
-
// Skill is at root level of repo
|
|
1469
|
-
skillFiles[skill.name] = 'SKILL.md';
|
|
1470
|
-
}
|
|
1471
|
-
else if (tempDir && skill.path.startsWith(tempDir + sep)) {
|
|
1472
|
-
// Compute path relative to repo root (tempDir), not search path
|
|
1473
|
-
// Use forward slashes for telemetry (URL-style paths)
|
|
1474
|
-
skillFiles[skill.name] =
|
|
1475
|
-
skill.path
|
|
1476
|
-
.slice(tempDir.length + 1)
|
|
1477
|
-
.split(sep)
|
|
1478
|
-
.join('/') + '/SKILL.md';
|
|
1479
|
-
}
|
|
1480
|
-
else {
|
|
1481
|
-
// Local path - skip telemetry for local installs
|
|
1482
|
-
continue;
|
|
1483
|
-
}
|
|
1484
|
-
}
|
|
1753
|
+
const skillFiles = getSkillRepoPaths(resolved, selectedSkills);
|
|
1485
1754
|
// Normalize source to owner/repo format for telemetry
|
|
1486
1755
|
const normalizedSource = directDownload ? null : getOwnerRepo(parsed);
|
|
1487
1756
|
const lockSource = directDownload ? null : getLockSource(parsed.url, normalizedSource);
|
|
1488
|
-
const projectLockSourceUrl = directDownload
|
|
1489
|
-
? undefined
|
|
1490
|
-
: getProjectLockSourceUrl(parsed.type, parsed.url);
|
|
1491
1757
|
// Only track if we have a valid remote source and it's not a private repo.
|
|
1492
1758
|
// repoPrivacyPromise was started early (right after parsing) so it has
|
|
1493
1759
|
// already been running in parallel with the entire install — no stall here.
|
|
@@ -1520,13 +1786,33 @@ export async function runAdd(args, options = {}) {
|
|
|
1520
1786
|
});
|
|
1521
1787
|
}
|
|
1522
1788
|
}
|
|
1789
|
+
// Content hash per installed skill (blob snapshot or folder hash), for the
|
|
1790
|
+
// project lock below and --json. The global lock derives its own from the
|
|
1791
|
+
// repo tree, so skip the walk when neither consumer needs it.
|
|
1792
|
+
const installedSkillHashes = new Map();
|
|
1793
|
+
if (successful.length > 0 && (jsonMode || !installGlobally)) {
|
|
1794
|
+
for (const skill of selectedSkills) {
|
|
1795
|
+
const skillDisplayName = getSkillDisplayName(skill);
|
|
1796
|
+
if (!successfulSkillNames.has(skillDisplayName))
|
|
1797
|
+
continue;
|
|
1798
|
+
try {
|
|
1799
|
+
installedSkillHashes.set(skillDisplayName, await sourceSkillHash(skill, resolved));
|
|
1800
|
+
}
|
|
1801
|
+
catch {
|
|
1802
|
+
// Hash is informational; lock writing skips skills without one.
|
|
1803
|
+
}
|
|
1804
|
+
}
|
|
1805
|
+
}
|
|
1523
1806
|
// Add to skill lock file for update tracking (only for global installs)
|
|
1524
|
-
|
|
1525
|
-
|
|
1807
|
+
// Notion installs are downloaded to a temp dir that parses as `local` and is deleted in the
|
|
1808
|
+
// finally block below, so only a real local path is recorded (same guard as the project lock).
|
|
1809
|
+
if (successful.length > 0 &&
|
|
1810
|
+
installGlobally &&
|
|
1811
|
+
(normalizedSource || (parsed.type === 'local' && !directDownload))) {
|
|
1526
1812
|
// For GitHub clone installs, fetch the repo tree once and reuse it
|
|
1527
1813
|
// for all skills — avoids N sequential API calls that take ~400ms each.
|
|
1528
1814
|
let cachedTree;
|
|
1529
|
-
if (parsed.type === 'github' && !blobResult) {
|
|
1815
|
+
if (parsed.type === 'github' && !blobResult && normalizedSource) {
|
|
1530
1816
|
cachedTree = await fetchRepoTree(normalizedSource, parsed.ref, getGitHubToken);
|
|
1531
1817
|
}
|
|
1532
1818
|
for (const skill of selectedSkills) {
|
|
@@ -1547,25 +1833,22 @@ export async function runAdd(args, options = {}) {
|
|
|
1547
1833
|
}
|
|
1548
1834
|
else if (skillPathValue && tempDir) {
|
|
1549
1835
|
const folder = dirname(skillPathValue);
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
if (hash)
|
|
1564
|
-
skillFolderHash = hash;
|
|
1565
|
-
}
|
|
1836
|
+
// ADG patch: GitHub update checks compare tree SHAs, including clone fallback.
|
|
1837
|
+
const hash = parsed.type === 'github'
|
|
1838
|
+
? await gitTreeShaForFolder(tempDir, folder === '.' ? '' : folder)
|
|
1839
|
+
: await computeSkillFolderHash(join(tempDir, folder));
|
|
1840
|
+
if (hash)
|
|
1841
|
+
skillFolderHash = hash;
|
|
1842
|
+
}
|
|
1843
|
+
else if (parsed.type === 'local') {
|
|
1844
|
+
// Local sources aren't cloned into tempDir, so hash the skill's
|
|
1845
|
+
// own directory directly (same approach as the project-scope lock below).
|
|
1846
|
+
const hash = await computeSkillFolderHash(skill.path);
|
|
1847
|
+
if (hash)
|
|
1848
|
+
skillFolderHash = hash;
|
|
1566
1849
|
}
|
|
1567
1850
|
await addSkillToLock(skill.name, {
|
|
1568
|
-
source: lockSource || normalizedSource,
|
|
1851
|
+
source: lockSource || normalizedSource || parsed.url,
|
|
1569
1852
|
sourceType: parsed.type,
|
|
1570
1853
|
sourceUrl: parsed.url,
|
|
1571
1854
|
ref: parsed.ref,
|
|
@@ -1582,7 +1865,6 @@ export async function runAdd(args, options = {}) {
|
|
|
1582
1865
|
}
|
|
1583
1866
|
// Add to local lock file for project-scoped installs
|
|
1584
1867
|
if (successful.length > 0 && !installGlobally && !directDownload) {
|
|
1585
|
-
const successfulSkillNames = new Set(successful.map((r) => r.skill));
|
|
1586
1868
|
// Record Eve subagent placement (root = '') so `update` can restore it.
|
|
1587
1869
|
// Only meaningful when Eve is among the targets and a non-root subagent
|
|
1588
1870
|
// was selected; otherwise omit for a clean, minimal lock entry.
|
|
@@ -1594,20 +1876,13 @@ export async function runAdd(args, options = {}) {
|
|
|
1594
1876
|
const skillDisplayName = getSkillDisplayName(skill);
|
|
1595
1877
|
if (successfulSkillNames.has(skillDisplayName)) {
|
|
1596
1878
|
try {
|
|
1597
|
-
//
|
|
1598
|
-
const computedHash =
|
|
1599
|
-
|
|
1600
|
-
|
|
1601
|
-
? computeSingleFileSkillHash(skill.rawContent)
|
|
1602
|
-
: await computeSkillFolderHash(skill.path);
|
|
1879
|
+
// Reuse the hash computed above (blob snapshot or folder hash)
|
|
1880
|
+
const computedHash = installedSkillHashes.get(skillDisplayName);
|
|
1881
|
+
if (computedHash === undefined)
|
|
1882
|
+
continue;
|
|
1603
1883
|
const skillPathValue = skillFiles[skill.name];
|
|
1604
1884
|
await addSkillToLocalLock(skill.name, {
|
|
1605
|
-
|
|
1606
|
-
...(projectLockSourceUrl && { sourceUrl: projectLockSourceUrl }),
|
|
1607
|
-
ref: parsed.ref,
|
|
1608
|
-
sourceType: parsed.type,
|
|
1609
|
-
...(skillPathValue && { skillPath: skillPathValue }),
|
|
1610
|
-
computedHash,
|
|
1885
|
+
...projectLockEntry(parsed, skillPathValue, computedHash),
|
|
1611
1886
|
...(recordSubagents && { subagents: eveSubagents }),
|
|
1612
1887
|
}, cwd);
|
|
1613
1888
|
}
|
|
@@ -1617,6 +1892,41 @@ export async function runAdd(args, options = {}) {
|
|
|
1617
1892
|
}
|
|
1618
1893
|
}
|
|
1619
1894
|
}
|
|
1895
|
+
// JSON output: one entry per skill, collapsing per-skill×agent results.
|
|
1896
|
+
// A skill is failed if any target failed, otherwise installed.
|
|
1897
|
+
if (jsonMode) {
|
|
1898
|
+
const jsonSource = normalizedSource ?? (parsed.type === 'local' ? parsed.localPath : parsed.url);
|
|
1899
|
+
for (const skill of selectedSkills) {
|
|
1900
|
+
const name = getSkillDisplayName(skill);
|
|
1901
|
+
const skillResults = results.filter((r) => r.skill === name);
|
|
1902
|
+
const failures = skillResults.filter((r) => !r.success);
|
|
1903
|
+
if (failures.length > 0) {
|
|
1904
|
+
jsonResults.push({
|
|
1905
|
+
name,
|
|
1906
|
+
status: 'failed',
|
|
1907
|
+
error: failures[0].error ?? 'Installation failed',
|
|
1908
|
+
});
|
|
1909
|
+
continue;
|
|
1910
|
+
}
|
|
1911
|
+
jsonResults.push({
|
|
1912
|
+
name,
|
|
1913
|
+
status: 'installed',
|
|
1914
|
+
source: jsonSource,
|
|
1915
|
+
ref: parsed.ref ?? null,
|
|
1916
|
+
hash: installedSkillHashes.get(name) ?? null,
|
|
1917
|
+
path: skillResults[0]?.canonicalPath ?? skillResults[0]?.path,
|
|
1918
|
+
scope: installGlobally ? 'global' : 'project',
|
|
1919
|
+
agents: skillResults.filter((r) => !r.skipped).map((r) => r.agent),
|
|
1920
|
+
mode: skillResults[0]?.mode ?? installMode,
|
|
1921
|
+
security: buildJsonSecurity(auditDataForJson, name, ownerRepoForAudit),
|
|
1922
|
+
});
|
|
1923
|
+
}
|
|
1924
|
+
emitJson();
|
|
1925
|
+
if (failed.length > 0 || jsonResults.some((result) => result.status === 'skipped')) {
|
|
1926
|
+
process.exitCode = 1;
|
|
1927
|
+
}
|
|
1928
|
+
return; // the finally block handles tempDir cleanup
|
|
1929
|
+
}
|
|
1620
1930
|
if (successful.length > 0) {
|
|
1621
1931
|
const bySkill = new Map();
|
|
1622
1932
|
// Group results by plugin name
|
|
@@ -1651,9 +1961,13 @@ export async function runAdd(args, options = {}) {
|
|
|
1651
1961
|
if (firstResult.mode === 'copy') {
|
|
1652
1962
|
// Copy mode: show skill name and list all agent paths
|
|
1653
1963
|
resultLines.push(`${pc.green('✓')} ${entry.skill} ${pc.dim('(copied)')}`);
|
|
1964
|
+
const shortPathsSet = new Set();
|
|
1654
1965
|
for (const r of skillResults) {
|
|
1655
1966
|
const shortPath = shortenPath(r.path, cwd);
|
|
1656
|
-
|
|
1967
|
+
if (!shortPathsSet.has(shortPath)) {
|
|
1968
|
+
shortPathsSet.add(shortPath);
|
|
1969
|
+
resultLines.push(` ${pc.dim('→')} ${shortPath}`);
|
|
1970
|
+
}
|
|
1657
1971
|
}
|
|
1658
1972
|
}
|
|
1659
1973
|
else {
|
|
@@ -1721,9 +2035,17 @@ export async function runAdd(args, options = {}) {
|
|
|
1721
2035
|
}
|
|
1722
2036
|
showInstallTip();
|
|
1723
2037
|
p.outro(pc.red('Installation failed'));
|
|
1724
|
-
|
|
2038
|
+
const errorMessage = error instanceof GitCloneError
|
|
2039
|
+
? `Failed to clone repository\n${error.message}`
|
|
2040
|
+
: error instanceof Error
|
|
2041
|
+
? error.message
|
|
2042
|
+
: 'Unknown error occurred';
|
|
2043
|
+
emitJsonAndExit(1, errorMessage);
|
|
1725
2044
|
}
|
|
1726
2045
|
finally {
|
|
2046
|
+
if (jsonMode)
|
|
2047
|
+
process.removeListener('exit', emitJsonOnExit);
|
|
2048
|
+
restoreStdout();
|
|
1727
2049
|
await cleanup(tempDir);
|
|
1728
2050
|
}
|
|
1729
2051
|
}
|
|
@@ -1779,7 +2101,7 @@ async function promptForFindSkills(options, targetAgents) {
|
|
|
1779
2101
|
return;
|
|
1780
2102
|
}
|
|
1781
2103
|
console.log();
|
|
1782
|
-
p.log.step('Installing find-skills skill
|
|
2104
|
+
p.log.step('Installing find-skills skill…');
|
|
1783
2105
|
try {
|
|
1784
2106
|
// Call runAdd directly
|
|
1785
2107
|
await runAdd(['vercel-labs/skills'], {
|
|
@@ -1826,8 +2148,6 @@ export function parseAddOptions(args) {
|
|
|
1826
2148
|
else if (arg === '-a' || arg === '--agent') {
|
|
1827
2149
|
options.agent = options.agent || [];
|
|
1828
2150
|
i++;
|
|
1829
|
-
if (!args[i] || args[i].startsWith('-'))
|
|
1830
|
-
errors.push(`${arg} requires an agent name`);
|
|
1831
2151
|
let nextArg = args[i];
|
|
1832
2152
|
while (i < args.length && nextArg && !nextArg.startsWith('-')) {
|
|
1833
2153
|
options.agent.push(nextArg);
|
|
@@ -1839,8 +2159,6 @@ export function parseAddOptions(args) {
|
|
|
1839
2159
|
else if (arg === '-s' || arg === '--skill') {
|
|
1840
2160
|
options.skill = options.skill || [];
|
|
1841
2161
|
i++;
|
|
1842
|
-
if (!args[i] || args[i].startsWith('-'))
|
|
1843
|
-
errors.push(`${arg} requires a skill name`);
|
|
1844
2162
|
let nextArg = args[i];
|
|
1845
2163
|
while (i < args.length && nextArg && !nextArg.startsWith('-')) {
|
|
1846
2164
|
options.skill.push(nextArg);
|
|
@@ -1867,14 +2185,15 @@ export function parseAddOptions(args) {
|
|
|
1867
2185
|
else if (arg === '--full-depth') {
|
|
1868
2186
|
options.fullDepth = true;
|
|
1869
2187
|
}
|
|
2188
|
+
else if (arg === '--json') {
|
|
2189
|
+
options.json = true;
|
|
2190
|
+
}
|
|
1870
2191
|
else if (arg === '--copy') {
|
|
1871
2192
|
options.copy = true;
|
|
1872
2193
|
}
|
|
1873
2194
|
else if (arg === '--subagent') {
|
|
1874
2195
|
options.subagent = options.subagent || [];
|
|
1875
2196
|
i++;
|
|
1876
|
-
if (!args[i] || args[i].startsWith('-'))
|
|
1877
|
-
errors.push('--subagent requires a name');
|
|
1878
2197
|
let nextArg = args[i];
|
|
1879
2198
|
while (i < args.length && nextArg && !nextArg.startsWith('-')) {
|
|
1880
2199
|
options.subagent.push(nextArg);
|
|
@@ -1886,9 +2205,6 @@ export function parseAddOptions(args) {
|
|
|
1886
2205
|
else if (arg && !arg.startsWith('-')) {
|
|
1887
2206
|
source.push(arg);
|
|
1888
2207
|
}
|
|
1889
|
-
else if (arg) {
|
|
1890
|
-
errors.push(`Unknown option: ${arg}`);
|
|
1891
|
-
}
|
|
1892
2208
|
}
|
|
1893
2209
|
return { source, options, errors };
|
|
1894
2210
|
}
|