skillhub 0.1.12 → 0.1.14
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/LICENSE +21 -0
- package/dist/index.js +119 -27
- package/package.json +59 -59
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 SkillHub Contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/dist/index.js
CHANGED
|
@@ -26,11 +26,13 @@ import https from "https";
|
|
|
26
26
|
import http from "http";
|
|
27
27
|
var API_BASE_URL = process.env.SKILLHUB_API_URL || "https://skills.palebluedot.live/api";
|
|
28
28
|
var API_TIMEOUT = parseInt(process.env.SKILLHUB_API_TIMEOUT || "10000");
|
|
29
|
+
var API_FILES_TIMEOUT = parseInt(process.env.SKILLHUB_API_FILES_TIMEOUT || "45000");
|
|
29
30
|
function httpsRequest(url, options = {}) {
|
|
30
31
|
return new Promise((resolve, reject) => {
|
|
31
32
|
const parsedUrl = new URL(url);
|
|
32
33
|
const isHttps = parsedUrl.protocol === "https:";
|
|
33
34
|
const lib = isHttps ? https : http;
|
|
35
|
+
const requestTimeout = options.timeout || API_TIMEOUT;
|
|
34
36
|
const reqOptions = {
|
|
35
37
|
hostname: parsedUrl.hostname,
|
|
36
38
|
port: parsedUrl.port || (isHttps ? 443 : 80),
|
|
@@ -41,7 +43,7 @@ function httpsRequest(url, options = {}) {
|
|
|
41
43
|
"Accept": "application/json",
|
|
42
44
|
...options.headers
|
|
43
45
|
},
|
|
44
|
-
timeout:
|
|
46
|
+
timeout: requestTimeout
|
|
45
47
|
};
|
|
46
48
|
const req = lib.request(reqOptions, (res) => {
|
|
47
49
|
const chunks = [];
|
|
@@ -74,10 +76,10 @@ function httpsRequest(url, options = {}) {
|
|
|
74
76
|
});
|
|
75
77
|
}
|
|
76
78
|
});
|
|
77
|
-
res.setTimeout(
|
|
79
|
+
res.setTimeout(requestTimeout, () => {
|
|
78
80
|
if (!resolved) {
|
|
79
81
|
res.destroy();
|
|
80
|
-
reject(new Error(`Response timeout after ${
|
|
82
|
+
reject(new Error(`Response timeout after ${requestTimeout / 1e3}s`));
|
|
81
83
|
}
|
|
82
84
|
});
|
|
83
85
|
});
|
|
@@ -87,7 +89,7 @@ function httpsRequest(url, options = {}) {
|
|
|
87
89
|
});
|
|
88
90
|
req.on("timeout", () => {
|
|
89
91
|
req.destroy();
|
|
90
|
-
reject(new Error(`Request timeout after ${
|
|
92
|
+
reject(new Error(`Request timeout after ${requestTimeout / 1e3}s`));
|
|
91
93
|
});
|
|
92
94
|
if (options.body) {
|
|
93
95
|
req.write(options.body);
|
|
@@ -99,7 +101,8 @@ async function searchSkills(query, options = {}) {
|
|
|
99
101
|
const params = new URLSearchParams({
|
|
100
102
|
q: query,
|
|
101
103
|
limit: String(options.limit || 10),
|
|
102
|
-
page: String(options.page || 1)
|
|
104
|
+
page: String(options.page || 1),
|
|
105
|
+
sort: options.sort || "downloads"
|
|
103
106
|
});
|
|
104
107
|
if (options.platform) {
|
|
105
108
|
params.set("platform", options.platform);
|
|
@@ -131,6 +134,23 @@ async function trackInstall(skillId, platform, method = "cli") {
|
|
|
131
134
|
} catch {
|
|
132
135
|
}
|
|
133
136
|
}
|
|
137
|
+
async function getSkillFiles(id) {
|
|
138
|
+
try {
|
|
139
|
+
const response = await httpsRequest(
|
|
140
|
+
`${API_BASE_URL}/skill-files?id=${encodeURIComponent(id)}`,
|
|
141
|
+
{ timeout: API_FILES_TIMEOUT }
|
|
142
|
+
);
|
|
143
|
+
if (response.statusCode === 404) {
|
|
144
|
+
return null;
|
|
145
|
+
}
|
|
146
|
+
if (response.statusCode !== 200) {
|
|
147
|
+
return null;
|
|
148
|
+
}
|
|
149
|
+
return JSON.parse(response.data);
|
|
150
|
+
} catch {
|
|
151
|
+
return null;
|
|
152
|
+
}
|
|
153
|
+
}
|
|
134
154
|
|
|
135
155
|
// src/utils/github.ts
|
|
136
156
|
import { Octokit } from "@octokit/rest";
|
|
@@ -343,20 +363,49 @@ async function install(skillId, options) {
|
|
|
343
363
|
process.exit(1);
|
|
344
364
|
}
|
|
345
365
|
await ensureSkillsDir(options.platform, options.project);
|
|
346
|
-
spinner.text = `Downloading
|
|
366
|
+
spinner.text = `Downloading ${skillInfo?.name || skillId}...`;
|
|
347
367
|
let content;
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
368
|
+
let apiWasReachable = false;
|
|
369
|
+
if (!options.noApi && skillInfo) {
|
|
370
|
+
apiWasReachable = true;
|
|
371
|
+
try {
|
|
372
|
+
spinner.text = "Downloading skill files...";
|
|
373
|
+
const cachedFiles = await getSkillFiles(skillInfo.id);
|
|
374
|
+
if (cachedFiles && cachedFiles.files.length > 0) {
|
|
375
|
+
content = convertCachedFilesToSkillContent(cachedFiles);
|
|
376
|
+
spinner.text = cachedFiles.fromCache ? `Using cached files (${cachedFiles.files.length} files)` : `Downloaded ${cachedFiles.files.length} files via API`;
|
|
377
|
+
}
|
|
378
|
+
} catch {
|
|
379
|
+
spinner.text = "API file fetch failed, falling back to GitHub...";
|
|
380
|
+
}
|
|
381
|
+
}
|
|
382
|
+
if (!content) {
|
|
383
|
+
if (apiWasReachable) {
|
|
384
|
+
spinner.text = `Falling back to GitHub: ${owner}/${repo}/${skillPath || ""}...`;
|
|
385
|
+
} else {
|
|
386
|
+
spinner.text = `Downloading from GitHub: ${owner}/${repo}/${skillPath || ""}...`;
|
|
387
|
+
}
|
|
388
|
+
try {
|
|
389
|
+
content = await fetchSkillContent(owner, repo, skillPath, branch);
|
|
390
|
+
spinner.text = `Downloaded ${content.scripts.length} scripts, ${content.references.length} references`;
|
|
391
|
+
} catch (error) {
|
|
392
|
+
spinner.fail("Failed to download skill files");
|
|
393
|
+
console.error(chalk.red(error.message));
|
|
394
|
+
console.log();
|
|
395
|
+
console.log(chalk.yellow("Troubleshooting tips:"));
|
|
396
|
+
console.log(chalk.dim(" 1. Check your internet connection"));
|
|
397
|
+
if (apiWasReachable) {
|
|
398
|
+
console.log(chalk.dim(" 2. The API server could not fetch files either - try again in a minute"));
|
|
399
|
+
console.log(chalk.dim(" 3. The server may be caching the files now - retry shortly"));
|
|
400
|
+
} else {
|
|
401
|
+
console.log(chalk.dim(" 2. If behind a proxy, configure HTTP_PROXY/HTTPS_PROXY environment variables"));
|
|
402
|
+
}
|
|
403
|
+
console.log(chalk.dim(` ${apiWasReachable ? "4" : "3"}. Set GITHUB_TOKEN environment variable for higher rate limits`));
|
|
404
|
+
process.exit(1);
|
|
405
|
+
}
|
|
406
|
+
}
|
|
407
|
+
if (!content) {
|
|
408
|
+
spinner.fail("Failed to download skill content");
|
|
360
409
|
process.exit(1);
|
|
361
410
|
}
|
|
362
411
|
const parsed = parseSkillMd(content.skillMd);
|
|
@@ -453,6 +502,37 @@ function getPlatformName(platform) {
|
|
|
453
502
|
};
|
|
454
503
|
return names[platform];
|
|
455
504
|
}
|
|
505
|
+
function convertCachedFilesToSkillContent(response) {
|
|
506
|
+
let skillMd = "";
|
|
507
|
+
const scripts = [];
|
|
508
|
+
const references = [];
|
|
509
|
+
for (const file of response.files) {
|
|
510
|
+
if (!file.content) continue;
|
|
511
|
+
if (file.name === "SKILL.md" && (file.path === "SKILL.md" || file.path === file.name)) {
|
|
512
|
+
skillMd = file.content;
|
|
513
|
+
continue;
|
|
514
|
+
}
|
|
515
|
+
if (file.path.startsWith("scripts/")) {
|
|
516
|
+
scripts.push({
|
|
517
|
+
name: file.name,
|
|
518
|
+
content: file.content
|
|
519
|
+
});
|
|
520
|
+
continue;
|
|
521
|
+
}
|
|
522
|
+
if (file.path.startsWith("references/")) {
|
|
523
|
+
references.push({
|
|
524
|
+
name: file.name,
|
|
525
|
+
content: file.content
|
|
526
|
+
});
|
|
527
|
+
}
|
|
528
|
+
}
|
|
529
|
+
return {
|
|
530
|
+
skillMd,
|
|
531
|
+
scripts,
|
|
532
|
+
references,
|
|
533
|
+
assets: []
|
|
534
|
+
};
|
|
535
|
+
}
|
|
456
536
|
|
|
457
537
|
// src/commands/search.ts
|
|
458
538
|
import chalk2 from "chalk";
|
|
@@ -461,9 +541,13 @@ async function search(query, options) {
|
|
|
461
541
|
const spinner = ora2("Searching skills...").start();
|
|
462
542
|
try {
|
|
463
543
|
const limit = parseInt(options.limit || "10");
|
|
544
|
+
const page = parseInt(options.page || "1");
|
|
545
|
+
const sort = options.sort || "downloads";
|
|
464
546
|
const result = await searchSkills(query, {
|
|
465
547
|
platform: options.platform,
|
|
466
|
-
limit
|
|
548
|
+
limit,
|
|
549
|
+
page,
|
|
550
|
+
sort
|
|
467
551
|
});
|
|
468
552
|
spinner.stop();
|
|
469
553
|
if (result.skills.length === 0) {
|
|
@@ -471,35 +555,43 @@ async function search(query, options) {
|
|
|
471
555
|
console.log(chalk2.dim("Try a different search term or check the spelling."));
|
|
472
556
|
return;
|
|
473
557
|
}
|
|
474
|
-
|
|
558
|
+
const sortLabel = { downloads: "downloads", stars: "GitHub stars", rating: "rating", recent: "recently updated" }[sort] || sort;
|
|
559
|
+
console.log(chalk2.bold(`Found ${result.pagination.total} skills (sorted by ${sortLabel}):
|
|
475
560
|
`));
|
|
476
561
|
console.log(
|
|
477
562
|
chalk2.dim("\u2500".repeat(80))
|
|
478
563
|
);
|
|
479
|
-
|
|
564
|
+
const startIndex = (page - 1) * limit;
|
|
565
|
+
for (let i = 0; i < result.skills.length; i++) {
|
|
566
|
+
const skill = result.skills[i];
|
|
567
|
+
const num = chalk2.dim(`[${startIndex + i + 1}]`);
|
|
480
568
|
const verified = skill.isVerified ? chalk2.green("\u2713") : " ";
|
|
481
569
|
const security = skill.securityStatus ? getSecurityStatusBadge(skill.securityStatus) : getSecurityBadge(skill.securityScore);
|
|
482
570
|
console.log(
|
|
483
|
-
`${verified} ${chalk2.cyan(skill.id.padEnd(
|
|
571
|
+
`${num} ${verified} ${chalk2.cyan(skill.id.padEnd(38))} ${security}`
|
|
484
572
|
);
|
|
485
573
|
console.log(
|
|
486
|
-
` ${chalk2.dim(skill.description.slice(0,
|
|
574
|
+
` \u2B07 ${formatNumber(skill.downloadCount).padStart(6)} \u2B50 ${formatNumber(skill.githubStars).padStart(6)} ${chalk2.dim(skill.description.slice(0, 55))}${skill.description.length > 55 ? "..." : ""}`
|
|
487
575
|
);
|
|
488
576
|
const showRating = (skill.ratingCount ?? 0) >= 3;
|
|
489
577
|
if (showRating && skill.rating) {
|
|
490
578
|
console.log(
|
|
491
|
-
`
|
|
579
|
+
` ${chalk2.yellow("\u2605")} ${skill.rating.toFixed(1)} ${chalk2.dim(`(${skill.ratingCount} ratings)`)}`
|
|
492
580
|
);
|
|
493
581
|
}
|
|
494
582
|
console.log(chalk2.dim("\u2500".repeat(80)));
|
|
495
583
|
}
|
|
496
584
|
console.log();
|
|
497
585
|
console.log(chalk2.dim(`Install with: ${chalk2.white("npx skillhub install <skill-id>")}`));
|
|
498
|
-
|
|
586
|
+
const totalPages = result.pagination.totalPages;
|
|
587
|
+
if (totalPages > 1) {
|
|
499
588
|
console.log(
|
|
500
|
-
chalk2.dim(`
|
|
589
|
+
chalk2.dim(`Page ${page} of ${totalPages}. Use ${chalk2.white(`--page ${page + 1}`)} for next page.`)
|
|
501
590
|
);
|
|
502
591
|
}
|
|
592
|
+
if (sort === "downloads") {
|
|
593
|
+
console.log(chalk2.dim(`Sort options: ${chalk2.white("--sort stars|rating|recent")}`));
|
|
594
|
+
}
|
|
503
595
|
} catch (error) {
|
|
504
596
|
spinner.fail("Search failed");
|
|
505
597
|
const err = error;
|
|
@@ -720,7 +812,7 @@ program.command("install <skill-id>").description("Install a skill from the regi
|
|
|
720
812
|
// Commander converts --no-api to api: false
|
|
721
813
|
});
|
|
722
814
|
});
|
|
723
|
-
program.command("search <query>").description("Search for skills in the registry").option("-p, --platform <platform>", "Filter by platform").option("-l, --limit <number>", "Number of results", "10").action(async (query, options) => {
|
|
815
|
+
program.command("search <query>").description("Search for skills in the registry").option("-p, --platform <platform>", "Filter by platform").option("-s, --sort <sort>", "Sort by: downloads, stars, rating, recent", "downloads").option("-l, --limit <number>", "Number of results", "10").option("--page <number>", "Page number", "1").action(async (query, options) => {
|
|
724
816
|
await search(query, options);
|
|
725
817
|
});
|
|
726
818
|
program.command("list").description("List installed skills").option("-p, --platform <platform>", "Filter by platform").option("--project", "List skills in the current project").option("--all", "List both global and project skills").action(async (options) => {
|
package/package.json
CHANGED
|
@@ -1,59 +1,59 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "skillhub",
|
|
3
|
-
"version": "0.1.
|
|
4
|
-
"description": "CLI tool for managing AI Agent skills - search, install, and update skills for Claude, Codex, Copilot, and more",
|
|
5
|
-
"author": "SkillHub Contributors",
|
|
6
|
-
"license": "MIT",
|
|
7
|
-
"repository": {
|
|
8
|
-
"type": "git",
|
|
9
|
-
"url": "https://github.com/anthropics/skillhub.git",
|
|
10
|
-
"directory": "apps/cli"
|
|
11
|
-
},
|
|
12
|
-
"homepage": "https://skills.palebluedot.live",
|
|
13
|
-
"type": "module",
|
|
14
|
-
"bin": {
|
|
15
|
-
"skillhub": "./dist/index.js"
|
|
16
|
-
},
|
|
17
|
-
"files": [
|
|
18
|
-
"dist"
|
|
19
|
-
],
|
|
20
|
-
"
|
|
21
|
-
"
|
|
22
|
-
"
|
|
23
|
-
"
|
|
24
|
-
"
|
|
25
|
-
"
|
|
26
|
-
"
|
|
27
|
-
"
|
|
28
|
-
},
|
|
29
|
-
"
|
|
30
|
-
"
|
|
31
|
-
"@
|
|
32
|
-
"
|
|
33
|
-
"
|
|
34
|
-
"
|
|
35
|
-
"
|
|
36
|
-
"
|
|
37
|
-
},
|
|
38
|
-
"
|
|
39
|
-
"
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
"
|
|
43
|
-
"
|
|
44
|
-
"
|
|
45
|
-
"
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
"
|
|
49
|
-
|
|
50
|
-
"
|
|
51
|
-
"
|
|
52
|
-
"
|
|
53
|
-
"
|
|
54
|
-
"
|
|
55
|
-
"
|
|
56
|
-
"
|
|
57
|
-
"
|
|
58
|
-
|
|
59
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "skillhub",
|
|
3
|
+
"version": "0.1.14",
|
|
4
|
+
"description": "CLI tool for managing AI Agent skills - search, install, and update skills for Claude, Codex, Copilot, and more",
|
|
5
|
+
"author": "SkillHub Contributors",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "https://github.com/anthropics/skillhub.git",
|
|
10
|
+
"directory": "apps/cli"
|
|
11
|
+
},
|
|
12
|
+
"homepage": "https://skills.palebluedot.live",
|
|
13
|
+
"type": "module",
|
|
14
|
+
"bin": {
|
|
15
|
+
"skillhub": "./dist/index.js"
|
|
16
|
+
},
|
|
17
|
+
"files": [
|
|
18
|
+
"dist"
|
|
19
|
+
],
|
|
20
|
+
"dependencies": {
|
|
21
|
+
"skillhub-core": "^0.1.0",
|
|
22
|
+
"@octokit/rest": "^20.0.2",
|
|
23
|
+
"chalk": "^5.3.0",
|
|
24
|
+
"commander": "^11.1.0",
|
|
25
|
+
"fs-extra": "^11.2.0",
|
|
26
|
+
"ora": "^8.0.1",
|
|
27
|
+
"prompts": "^2.4.2"
|
|
28
|
+
},
|
|
29
|
+
"devDependencies": {
|
|
30
|
+
"@types/fs-extra": "^11.0.4",
|
|
31
|
+
"@types/node": "^20.10.0",
|
|
32
|
+
"@types/prompts": "^2.4.9",
|
|
33
|
+
"tsup": "^8.0.1",
|
|
34
|
+
"tsx": "^4.7.0",
|
|
35
|
+
"typescript": "^5.3.0",
|
|
36
|
+
"vitest": "^1.2.0"
|
|
37
|
+
},
|
|
38
|
+
"engines": {
|
|
39
|
+
"node": ">=18.0.0"
|
|
40
|
+
},
|
|
41
|
+
"keywords": [
|
|
42
|
+
"ai",
|
|
43
|
+
"agent",
|
|
44
|
+
"skills",
|
|
45
|
+
"cli",
|
|
46
|
+
"claude",
|
|
47
|
+
"codex",
|
|
48
|
+
"copilot"
|
|
49
|
+
],
|
|
50
|
+
"scripts": {
|
|
51
|
+
"build": "tsup src/index.ts --format esm --target node20 --clean",
|
|
52
|
+
"dev": "tsx src/index.ts",
|
|
53
|
+
"start": "node dist/index.js",
|
|
54
|
+
"lint": "eslint src/",
|
|
55
|
+
"typecheck": "tsc --noEmit",
|
|
56
|
+
"test": "vitest",
|
|
57
|
+
"test:run": "vitest run"
|
|
58
|
+
}
|
|
59
|
+
}
|