itismyskillmarket 1.2.8 → 1.2.9
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 +45 -0
- package/package.json +1 -1
- package/src/cli.ts +24 -1
- package/src/commands/ls.ts +53 -0
package/dist/index.js
CHANGED
|
@@ -223,6 +223,46 @@ function filterInstalledSkills(skills, keyword) {
|
|
|
223
223
|
(s) => s.id.toLowerCase().includes(lower) || s.displayName && s.displayName.toLowerCase().includes(lower) || s.description && s.description.toLowerCase().includes(lower)
|
|
224
224
|
);
|
|
225
225
|
}
|
|
226
|
+
async function searchSkills(keyword, limit = 20) {
|
|
227
|
+
console.log(`Searching npm for "${keyword}"...
|
|
228
|
+
`);
|
|
229
|
+
try {
|
|
230
|
+
const { packages, total } = await searchSkillmarketPackages({
|
|
231
|
+
from: 0,
|
|
232
|
+
size: limit,
|
|
233
|
+
keyword
|
|
234
|
+
});
|
|
235
|
+
if (packages.length === 0) {
|
|
236
|
+
console.log(`No skills found matching "${keyword}".`);
|
|
237
|
+
return;
|
|
238
|
+
}
|
|
239
|
+
console.log(`Found ${total} match(es) for "${keyword}":
|
|
240
|
+
`);
|
|
241
|
+
for (const pkgName of packages) {
|
|
242
|
+
try {
|
|
243
|
+
const info = await fetchNpmPackage(pkgName);
|
|
244
|
+
if (!info) {
|
|
245
|
+
console.log(`\u{1F4E6} ${pkgName} (\u4FE1\u606F\u83B7\u53D6\u5931\u8D25)`);
|
|
246
|
+
console.log();
|
|
247
|
+
continue;
|
|
248
|
+
}
|
|
249
|
+
const latestVersion = info["dist-tags"]?.latest || "unknown";
|
|
250
|
+
const pkg = info.versions?.[latestVersion];
|
|
251
|
+
const skillMeta = pkg?.skillmarket;
|
|
252
|
+
console.log(`\u{1F4E6} ${info.name}@${latestVersion}`);
|
|
253
|
+
console.log(` \u540D\u79F0: ${skillMeta?.displayName || info.name}`);
|
|
254
|
+
console.log(` \u63CF\u8FF0: ${pkg?.description || "N/A"}`);
|
|
255
|
+
console.log(` \u5E73\u53F0: ${(skillMeta?.platforms || []).join(", ") || "N/A"}`);
|
|
256
|
+
console.log();
|
|
257
|
+
} catch (e) {
|
|
258
|
+
console.log(`\u{1F4E6} ${pkgName} (\u83B7\u53D6\u5931\u8D25: ${e})`);
|
|
259
|
+
console.log();
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
} catch (error) {
|
|
263
|
+
console.log(`Error searching skills: ${error}`);
|
|
264
|
+
}
|
|
265
|
+
}
|
|
226
266
|
async function listSkills(options) {
|
|
227
267
|
const { installed, updates, page = 1, limit = 20, search } = options;
|
|
228
268
|
if (installed) {
|
|
@@ -853,6 +893,11 @@ lsCmd.option("--installed", "Show only installed skills").option("--updates", "C
|
|
|
853
893
|
};
|
|
854
894
|
listSkills(options);
|
|
855
895
|
});
|
|
896
|
+
var searchCmd = program.command("search").description("Search skills from npm registry");
|
|
897
|
+
searchCmd.argument("<keyword>", "Keyword to search").option("-l, --limit <number>", "Max results to show (default: 20)", parseInt).action(async (keyword, opts) => {
|
|
898
|
+
const limit = opts.limit ?? 20;
|
|
899
|
+
await searchSkills(keyword, limit);
|
|
900
|
+
});
|
|
856
901
|
var infoCmd = program.command("info").description("Display skill information");
|
|
857
902
|
infoCmd.argument("<skill-id>", "Skill ID to show info").action((skillId) => {
|
|
858
903
|
showSkillInfo(skillId);
|
package/package.json
CHANGED
package/src/cli.ts
CHANGED
|
@@ -41,7 +41,7 @@ const VERSION = packageJson.version;
|
|
|
41
41
|
|
|
42
42
|
// 内部模块导入
|
|
43
43
|
import { PLATFORMS } from './constants.js'; // 平台常量
|
|
44
|
-
import { listSkills } from './commands/ls.js'; // 列表命令
|
|
44
|
+
import { listSkills, searchSkills } from './commands/ls.js'; // 列表命令
|
|
45
45
|
import { showSkillInfo } from './commands/info.js'; // 信息命令
|
|
46
46
|
import { installSkill } from './commands/install.js'; // 安装命令
|
|
47
47
|
import { syncPlatformLinks } from './commands/sync.js'; // 同步命令
|
|
@@ -164,6 +164,29 @@ lsCmd
|
|
|
164
164
|
listSkills(options);
|
|
165
165
|
});
|
|
166
166
|
|
|
167
|
+
// -----------------------------------------------------------------------------
|
|
168
|
+
// 搜索命令 (skm search)
|
|
169
|
+
// -----------------------------------------------------------------------------
|
|
170
|
+
|
|
171
|
+
/**
|
|
172
|
+
* 搜索命令
|
|
173
|
+
*
|
|
174
|
+
* 独立搜索 npm 上的 skills
|
|
175
|
+
*
|
|
176
|
+
* 用法: skm search <keyword>
|
|
177
|
+
*
|
|
178
|
+
* @example
|
|
179
|
+
* skm search brain
|
|
180
|
+
*/
|
|
181
|
+
const searchCmd = program.command('search').description('Search skills from npm registry');
|
|
182
|
+
searchCmd
|
|
183
|
+
.argument('<keyword>', 'Keyword to search')
|
|
184
|
+
.option('-l, --limit <number>', 'Max results to show (default: 20)', parseInt)
|
|
185
|
+
.action(async (keyword, opts) => {
|
|
186
|
+
const limit = opts.limit ?? 20;
|
|
187
|
+
await searchSkills(keyword, limit);
|
|
188
|
+
});
|
|
189
|
+
|
|
167
190
|
// -----------------------------------------------------------------------------
|
|
168
191
|
// 信息命令 (skm info)
|
|
169
192
|
// -----------------------------------------------------------------------------
|
package/src/commands/ls.ts
CHANGED
|
@@ -94,6 +94,59 @@ function filterInstalledSkills(skills: any[], keyword: string): any[] {
|
|
|
94
94
|
// 命令实现
|
|
95
95
|
// -----------------------------------------------------------------------------
|
|
96
96
|
|
|
97
|
+
/**
|
|
98
|
+
* 独立搜索 skills(不依赖 ls 命令选项)
|
|
99
|
+
*
|
|
100
|
+
* @param keyword - 搜索关键字
|
|
101
|
+
* @param limit - 返回结果数量限制
|
|
102
|
+
* @returns 搜索结果列表
|
|
103
|
+
*/
|
|
104
|
+
export async function searchSkills(keyword: string, limit: number = 20): Promise<void> {
|
|
105
|
+
console.log(`Searching npm for "${keyword}"...\n`);
|
|
106
|
+
|
|
107
|
+
try {
|
|
108
|
+
const { packages, total } = await searchSkillmarketPackages({
|
|
109
|
+
from: 0,
|
|
110
|
+
size: limit,
|
|
111
|
+
keyword
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
if (packages.length === 0) {
|
|
115
|
+
console.log(`No skills found matching "${keyword}".`);
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
console.log(`Found ${total} match(es) for "${keyword}":\n`);
|
|
120
|
+
|
|
121
|
+
for (const pkgName of packages) {
|
|
122
|
+
try {
|
|
123
|
+
const info = await fetchNpmPackage(pkgName);
|
|
124
|
+
|
|
125
|
+
if (!info) {
|
|
126
|
+
console.log(`📦 ${pkgName} (信息获取失败)`);
|
|
127
|
+
console.log();
|
|
128
|
+
continue;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
const latestVersion = info['dist-tags']?.latest || 'unknown';
|
|
132
|
+
const pkg = info.versions?.[latestVersion];
|
|
133
|
+
const skillMeta = pkg?.skillmarket;
|
|
134
|
+
|
|
135
|
+
console.log(`📦 ${info.name}@${latestVersion}`);
|
|
136
|
+
console.log(` 名称: ${skillMeta?.displayName || info.name}`);
|
|
137
|
+
console.log(` 描述: ${pkg?.description || 'N/A'}`);
|
|
138
|
+
console.log(` 平台: ${(skillMeta?.platforms || []).join(', ') || 'N/A'}`);
|
|
139
|
+
console.log();
|
|
140
|
+
} catch (e) {
|
|
141
|
+
console.log(`📦 ${pkgName} (获取失败: ${e})`);
|
|
142
|
+
console.log();
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
} catch (error) {
|
|
146
|
+
console.log(`Error searching skills: ${error}`);
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
|
|
97
150
|
export async function listSkills(options: LsOptions): Promise<void> {
|
|
98
151
|
const { installed, updates, page = 1, limit = 20, search } = options;
|
|
99
152
|
|