itismyskillmarket 1.2.7 → 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 +48 -0
- package/package.json +1 -1
- package/src/cli.ts +27 -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) {
|
|
@@ -828,7 +868,10 @@ Examples:
|
|
|
828
868
|
skm ls List all available skills (page 1)
|
|
829
869
|
skm ls --page 2 Go to page 2
|
|
830
870
|
skm ls --limit 10 Show 10 items per page
|
|
871
|
+
skm ls --search brain Search skills by keyword
|
|
872
|
+
skm ls -s brain Search with short form
|
|
831
873
|
skm ls --installed Show installed skills only
|
|
874
|
+
skm ls --installed --search test Search installed skills
|
|
832
875
|
skm ls --installed --page 2
|
|
833
876
|
skm info brainstorming View skill details
|
|
834
877
|
skm install brainstorming Install to all platforms
|
|
@@ -850,6 +893,11 @@ lsCmd.option("--installed", "Show only installed skills").option("--updates", "C
|
|
|
850
893
|
};
|
|
851
894
|
listSkills(options);
|
|
852
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
|
+
});
|
|
853
901
|
var infoCmd = program.command("info").description("Display skill information");
|
|
854
902
|
infoCmd.argument("<skill-id>", "Skill ID to show info").action((skillId) => {
|
|
855
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'; // 同步命令
|
|
@@ -116,7 +116,10 @@ Examples:
|
|
|
116
116
|
skm ls List all available skills (page 1)
|
|
117
117
|
skm ls --page 2 Go to page 2
|
|
118
118
|
skm ls --limit 10 Show 10 items per page
|
|
119
|
+
skm ls --search brain Search skills by keyword
|
|
120
|
+
skm ls -s brain Search with short form
|
|
119
121
|
skm ls --installed Show installed skills only
|
|
122
|
+
skm ls --installed --search test Search installed skills
|
|
120
123
|
skm ls --installed --page 2
|
|
121
124
|
skm info brainstorming View skill details
|
|
122
125
|
skm install brainstorming Install to all platforms
|
|
@@ -161,6 +164,29 @@ lsCmd
|
|
|
161
164
|
listSkills(options);
|
|
162
165
|
});
|
|
163
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
|
+
|
|
164
190
|
// -----------------------------------------------------------------------------
|
|
165
191
|
// 信息命令 (skm info)
|
|
166
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
|
|