itismyskillmarket 1.2.10 → 1.3.0
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/dist/index.js +40 -1
- package/package.json +1 -1
- package/src/cli.ts +29 -1
- package/src/commands/search.ts +98 -0
package/dist/index.js
CHANGED
|
@@ -490,9 +490,39 @@ async function uninstallSkill(skillId) {
|
|
|
490
490
|
\u2705 ${skillId} uninstalled successfully!`);
|
|
491
491
|
}
|
|
492
492
|
|
|
493
|
+
// src/commands/search.ts
|
|
494
|
+
async function searchSkills(keyword) {
|
|
495
|
+
console.log(`Searching for "${keyword}"...
|
|
496
|
+
`);
|
|
497
|
+
try {
|
|
498
|
+
const packages = await searchSkillmarketPackages();
|
|
499
|
+
const filtered = packages.filter(
|
|
500
|
+
(pkg) => pkg.toLowerCase().includes(keyword.toLowerCase())
|
|
501
|
+
);
|
|
502
|
+
if (filtered.length === 0) {
|
|
503
|
+
console.log(`No skills found matching "${keyword}".`);
|
|
504
|
+
return;
|
|
505
|
+
}
|
|
506
|
+
console.log(`Found ${filtered.length} skill(s):
|
|
507
|
+
`);
|
|
508
|
+
for (const pkgName of filtered) {
|
|
509
|
+
const info = await fetchNpmPackage(pkgName);
|
|
510
|
+
if (info && info["dist-tags"]?.latest) {
|
|
511
|
+
const latestVersion = info["dist-tags"].latest;
|
|
512
|
+
const pkg = info.versions?.[latestVersion];
|
|
513
|
+
console.log(` ${info.name}@${latestVersion}`);
|
|
514
|
+
console.log(` ${pkg?.description || "No description"}`);
|
|
515
|
+
console.log();
|
|
516
|
+
}
|
|
517
|
+
}
|
|
518
|
+
} catch (error) {
|
|
519
|
+
console.log(`Error searching skills: ${error}`);
|
|
520
|
+
}
|
|
521
|
+
}
|
|
522
|
+
|
|
493
523
|
// src/cli.ts
|
|
494
524
|
var program = new Command();
|
|
495
|
-
program.name("skm").description("SkillMarket - Cross-platform skill manager for AI coding tools").version("1.2.
|
|
525
|
+
program.name("skm").description("SkillMarket - Cross-platform skill manager for AI coding tools").version("1.2.10");
|
|
496
526
|
var helpCmd = program.command("help").description("Display help information");
|
|
497
527
|
helpCmd.action(() => {
|
|
498
528
|
console.log(`
|
|
@@ -576,4 +606,13 @@ var platformCmd = program.command("platform").description("Set target platform")
|
|
|
576
606
|
platformCmd.argument("<name>", "Platform name").action((name) => {
|
|
577
607
|
console.log("Platform command - name:", name);
|
|
578
608
|
});
|
|
609
|
+
var searchCmd = program.command("search").description("Search skills from npm registry");
|
|
610
|
+
searchCmd.argument("<keyword>", "Keyword to search").action(async (keyword) => {
|
|
611
|
+
try {
|
|
612
|
+
await searchSkills(keyword);
|
|
613
|
+
} catch (err) {
|
|
614
|
+
console.error("Search failed:", err);
|
|
615
|
+
process.exit(1);
|
|
616
|
+
}
|
|
617
|
+
});
|
|
579
618
|
program.parse();
|
package/package.json
CHANGED
package/src/cli.ts
CHANGED
|
@@ -37,6 +37,7 @@ import { installSkill } from './commands/install.js'; // 安装命令
|
|
|
37
37
|
import { syncPlatformLinks } from './commands/sync.js'; // 同步命令
|
|
38
38
|
import { updateSkill } from './commands/update.js'; // 更新命令
|
|
39
39
|
import { uninstallSkill } from './commands/uninstall.js'; // 卸载命令
|
|
40
|
+
import { searchSkills } from './commands/search.js'; // 搜索命令
|
|
40
41
|
|
|
41
42
|
// -----------------------------------------------------------------------------
|
|
42
43
|
// 创建命令程序实例
|
|
@@ -63,7 +64,7 @@ const program = new Command();
|
|
|
63
64
|
program
|
|
64
65
|
.name('skm')
|
|
65
66
|
.description('SkillMarket - Cross-platform skill manager for AI coding tools')
|
|
66
|
-
.version('1.2.
|
|
67
|
+
.version('1.2.10');
|
|
67
68
|
|
|
68
69
|
// -----------------------------------------------------------------------------
|
|
69
70
|
// 帮助命令 (-h, --help)
|
|
@@ -285,6 +286,33 @@ platformCmd
|
|
|
285
286
|
console.log('Platform command - name:', name);
|
|
286
287
|
});
|
|
287
288
|
|
|
289
|
+
// -----------------------------------------------------------------------------
|
|
290
|
+
// 搜索命令 (skm search)
|
|
291
|
+
// -----------------------------------------------------------------------------
|
|
292
|
+
|
|
293
|
+
/**
|
|
294
|
+
* 搜索命令
|
|
295
|
+
*
|
|
296
|
+
* 在 npm registry 上搜索匹配的 skills
|
|
297
|
+
* 只返回包名包含关键词的 skill
|
|
298
|
+
*
|
|
299
|
+
* 用法: skm search <keyword>
|
|
300
|
+
*
|
|
301
|
+
* @example
|
|
302
|
+
* skm search test
|
|
303
|
+
*/
|
|
304
|
+
const searchCmd = program.command('search').description('Search skills from npm registry');
|
|
305
|
+
searchCmd
|
|
306
|
+
.argument('<keyword>', 'Keyword to search')
|
|
307
|
+
.action(async (keyword) => {
|
|
308
|
+
try {
|
|
309
|
+
await searchSkills(keyword);
|
|
310
|
+
} catch (err) {
|
|
311
|
+
console.error('Search failed:', err);
|
|
312
|
+
process.exit(1);
|
|
313
|
+
}
|
|
314
|
+
});
|
|
315
|
+
|
|
288
316
|
// -----------------------------------------------------------------------------
|
|
289
317
|
// 解析命令行参数
|
|
290
318
|
// -----------------------------------------------------------------------------
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* =============================================================================
|
|
3
|
+
* SkillMarket 搜索命令模块
|
|
4
|
+
* =============================================================================
|
|
5
|
+
*
|
|
6
|
+
* 本模块实现 `skm search <keyword>` 命令,用于:
|
|
7
|
+
* - 在 npm registry 上搜索匹配的 skills
|
|
8
|
+
* - 只返回包名包含关键词的 skill
|
|
9
|
+
*
|
|
10
|
+
* @module commands/search
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
// -----------------------------------------------------------------------------
|
|
14
|
+
// 导入依赖
|
|
15
|
+
// -----------------------------------------------------------------------------
|
|
16
|
+
|
|
17
|
+
import {
|
|
18
|
+
searchSkillmarketPackages, // 搜索 npm 上的 skill 包
|
|
19
|
+
fetchNpmPackage // 获取单个包的详细信息
|
|
20
|
+
} from './npm.js';
|
|
21
|
+
|
|
22
|
+
// -----------------------------------------------------------------------------
|
|
23
|
+
// 类型定义
|
|
24
|
+
// -----------------------------------------------------------------------------
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* search 命令选项接口
|
|
28
|
+
*/
|
|
29
|
+
interface SearchOptions {
|
|
30
|
+
/** 搜索关键词 */
|
|
31
|
+
keyword?: string;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
// -----------------------------------------------------------------------------
|
|
35
|
+
// 命令实现
|
|
36
|
+
// -----------------------------------------------------------------------------
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* 搜索 skills
|
|
40
|
+
*
|
|
41
|
+
* 根据关键词在 npm registry 上搜索匹配的 skills
|
|
42
|
+
* 只返回包名包含关键词的 skill
|
|
43
|
+
*
|
|
44
|
+
* @param {string} keyword - 搜索关键词
|
|
45
|
+
* @param {SearchOptions} options - 命令选项
|
|
46
|
+
* @returns {Promise<void>}
|
|
47
|
+
*
|
|
48
|
+
* @example
|
|
49
|
+
* // 搜索包含 "test" 的 skills
|
|
50
|
+
* await searchSkills('test', {});
|
|
51
|
+
*/
|
|
52
|
+
export async function searchSkills(keyword: string): Promise<void> {
|
|
53
|
+
// 提示用户正在搜索
|
|
54
|
+
console.log(`Searching for "${keyword}"...\n`);
|
|
55
|
+
|
|
56
|
+
try {
|
|
57
|
+
// 调用 npm search API 搜索 skillmarket 相关包
|
|
58
|
+
const packages = await searchSkillmarketPackages();
|
|
59
|
+
|
|
60
|
+
// 精确匹配:只返回包名包含关键词的 skill
|
|
61
|
+
const filtered = packages.filter(pkg =>
|
|
62
|
+
pkg.toLowerCase().includes(keyword.toLowerCase())
|
|
63
|
+
);
|
|
64
|
+
|
|
65
|
+
// 无搜索结果时
|
|
66
|
+
if (filtered.length === 0) {
|
|
67
|
+
console.log(`No skills found matching "${keyword}".`);
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
// 打印找到的包数量
|
|
72
|
+
console.log(`Found ${filtered.length} skill(s):\n`);
|
|
73
|
+
|
|
74
|
+
// 遍历每个包,获取详细信息并显示
|
|
75
|
+
for (const pkgName of filtered) {
|
|
76
|
+
const info = await fetchNpmPackage(pkgName);
|
|
77
|
+
|
|
78
|
+
if (info && info['dist-tags']?.latest) {
|
|
79
|
+
const latestVersion = info['dist-tags'].latest;
|
|
80
|
+
|
|
81
|
+
// 获取该版本的详细信息
|
|
82
|
+
const pkg = info.versions?.[latestVersion];
|
|
83
|
+
|
|
84
|
+
// 打印包名和版本
|
|
85
|
+
console.log(` ${info.name}@${latestVersion}`);
|
|
86
|
+
|
|
87
|
+
// 打印描述(如果有的话)
|
|
88
|
+
console.log(` ${pkg?.description || 'No description'}`);
|
|
89
|
+
|
|
90
|
+
// 空行分隔
|
|
91
|
+
console.log();
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
} catch (error) {
|
|
95
|
+
// 网络错误处理
|
|
96
|
+
console.log(`Error searching skills: ${error}`);
|
|
97
|
+
}
|
|
98
|
+
}
|