agentskillscanner 0.1.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.
Files changed (4) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +121 -0
  3. package/dist/index.js +522 -0
  4. package/package.json +29 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025
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/README.md ADDED
@@ -0,0 +1,121 @@
1
+ # agentskillscanner
2
+
3
+ [繁體中文](#繁體中文) | [English](#english)
4
+
5
+ ---
6
+
7
+ ## English
8
+
9
+ Scan and report all available skills for AI coding assistants (Claude Code).
10
+
11
+ Scans across four levels:
12
+
13
+ 1. **User** — `~/.claude/skills/*/SKILL.md`
14
+ 2. **Project** — `<project>/.claude/skills/*/SKILL.md`
15
+ 3. **Plugin** — `installed_plugins.json` + each plugin directory
16
+ 4. **Enterprise** — `/Library/Application Support/ClaudeCode/`
17
+
18
+ ### Installation & Usage
19
+
20
+ ```bash
21
+ # Option 1: Run directly with npx (no install needed)
22
+ npx agentskillscanner
23
+
24
+ # Option 2: Install globally
25
+ npm install -g agentskillscanner
26
+ agentskillscanner
27
+ ```
28
+
29
+ ### CLI Options
30
+
31
+ ```
32
+ -j, --json Output in JSON format
33
+ -d, --project-dir DIR Project directory (default: current working directory)
34
+ -l, --level LEVELS Filter levels (comma-separated: user,project,plugin,enterprise)
35
+ -v, --verbose Show full descriptions and paths
36
+ -h, --help Show help
37
+ ```
38
+
39
+ ### Examples
40
+
41
+ ```bash
42
+ # Scan all levels (default)
43
+ agentskillscanner
44
+
45
+ # JSON output
46
+ agentskillscanner --json
47
+
48
+ # Only user and project levels
49
+ agentskillscanner --level user,project
50
+
51
+ # Verbose mode
52
+ agentskillscanner --verbose
53
+ ```
54
+
55
+ ### Development
56
+
57
+ ```bash
58
+ pnpm install
59
+ pnpm build
60
+ node dist/index.js
61
+ ```
62
+
63
+ ---
64
+
65
+ ## 繁體中文
66
+
67
+ 掃描並彙整所有可用的 Claude Code skills,涵蓋四個層級:
68
+
69
+ 1. **使用者層級 (User)** — `~/.claude/skills/*/SKILL.md`
70
+ 2. **專案層級 (Project)** — `<project>/.claude/skills/*/SKILL.md`
71
+ 3. **外掛層級 (Plugin)** — `installed_plugins.json` + 各外掛目錄
72
+ 4. **企業層級 (Enterprise)** — `/Library/Application Support/ClaudeCode/`
73
+
74
+ ### 安裝與使用
75
+
76
+ ```bash
77
+ # 方式一:npx 直接執行(免安裝)
78
+ npx agentskillscanner
79
+
80
+ # 方式二:全域安裝
81
+ npm install -g agentskillscanner
82
+ agentskillscanner
83
+ ```
84
+
85
+ ### CLI 選項
86
+
87
+ ```
88
+ -j, --json 以 JSON 格式輸出
89
+ -d, --project-dir DIR 專案目錄(預設:目前工作目錄)
90
+ -l, --level LEVELS 篩選層級(逗號分隔:user,project,plugin,enterprise)
91
+ -v, --verbose 顯示完整描述與路徑
92
+ -h, --help 顯示說明
93
+ ```
94
+
95
+ ### 範例
96
+
97
+ ```bash
98
+ # 預設掃描所有層級
99
+ agentskillscanner
100
+
101
+ # JSON 輸出
102
+ agentskillscanner --json
103
+
104
+ # 只看使用者與專案層級
105
+ agentskillscanner --level user,project
106
+
107
+ # 詳細模式
108
+ agentskillscanner --verbose
109
+ ```
110
+
111
+ ### 開發
112
+
113
+ ```bash
114
+ pnpm install
115
+ pnpm build
116
+ node dist/index.js
117
+ ```
118
+
119
+ ## License
120
+
121
+ MIT
package/dist/index.js ADDED
@@ -0,0 +1,522 @@
1
+ import { cli, define } from "gunshi";
2
+ import { readFileSync, readdirSync, statSync } from "node:fs";
3
+ import { join, resolve } from "node:path";
4
+ import { homedir, platform } from "node:os";
5
+ import pc from "picocolors";
6
+
7
+ //#region src/frontmatter.ts
8
+ function parseFrontmatter(text) {
9
+ const match = text.match(/^---\s*\n([\s\S]*?)\n---/);
10
+ if (!match) return {};
11
+ const block = match[1];
12
+ const result = {};
13
+ let currentKey = null;
14
+ let multilineBuf = [];
15
+ for (const line of block.split("\n")) {
16
+ if (currentKey && (line.startsWith(" ") || line.trim() === "")) {
17
+ multilineBuf.push(line.trim());
18
+ continue;
19
+ }
20
+ if (currentKey && multilineBuf.length > 0) {
21
+ result[currentKey] = multilineBuf.filter((l) => l).join(" ");
22
+ currentKey = null;
23
+ multilineBuf = [];
24
+ }
25
+ const kv = line.match(/^(\w[\w-]*):\s*(.*)/);
26
+ if (kv) {
27
+ const key = kv[1];
28
+ const val = kv[2].trim();
29
+ if (val === "|" || val === ">") {
30
+ currentKey = key;
31
+ multilineBuf = [];
32
+ } else {
33
+ result[key] = val;
34
+ currentKey = null;
35
+ multilineBuf = [];
36
+ }
37
+ }
38
+ }
39
+ if (currentKey && multilineBuf.length > 0) result[currentKey] = multilineBuf.filter((l) => l).join(" ");
40
+ return result;
41
+ }
42
+
43
+ //#endregion
44
+ //#region src/types.ts
45
+ const SkillLevel = {
46
+ USER: "user",
47
+ PROJECT: "project",
48
+ PLUGIN: "plugin",
49
+ ENTERPRISE: "enterprise"
50
+ };
51
+ const SkillType = {
52
+ SKILL: "skill",
53
+ COMMAND: "command",
54
+ AGENT: "agent",
55
+ HOOK: "hook"
56
+ };
57
+ const LEVEL_LABELS = {
58
+ [SkillLevel.USER]: "使用者層級 (User)",
59
+ [SkillLevel.PROJECT]: "專案層級 (Project)",
60
+ [SkillLevel.PLUGIN]: "外掛層級 (Plugin)",
61
+ [SkillLevel.ENTERPRISE]: "企業層級 (Enterprise)"
62
+ };
63
+ const TYPE_LABELS = {
64
+ [SkillType.SKILL]: "技能",
65
+ [SkillType.COMMAND]: "命令",
66
+ [SkillType.AGENT]: "代理",
67
+ [SkillType.HOOK]: "鉤子"
68
+ };
69
+ function byLevel(result, level) {
70
+ return result.skills.filter((s) => s.level === level);
71
+ }
72
+
73
+ //#endregion
74
+ //#region src/scanner.ts
75
+ var Scanner = class {
76
+ projectDir;
77
+ home;
78
+ claudeDir;
79
+ constructor(projectDir) {
80
+ this.projectDir = resolve(projectDir);
81
+ this.home = homedir();
82
+ this.claudeDir = join(this.home, ".claude");
83
+ }
84
+ scan(levels) {
85
+ const targets = levels ?? [
86
+ SkillLevel.USER,
87
+ SkillLevel.PROJECT,
88
+ SkillLevel.PLUGIN,
89
+ SkillLevel.ENTERPRISE
90
+ ];
91
+ const result = {
92
+ skills: [],
93
+ plugins: []
94
+ };
95
+ if (targets.includes(SkillLevel.USER)) result.skills.push(...this.scanUser());
96
+ if (targets.includes(SkillLevel.PROJECT)) result.skills.push(...this.scanProject());
97
+ if (targets.includes(SkillLevel.PLUGIN)) {
98
+ const plugins = this.scanPlugins();
99
+ result.plugins = plugins;
100
+ for (const p of plugins) result.skills.push(...p.items);
101
+ }
102
+ if (targets.includes(SkillLevel.ENTERPRISE)) result.skills.push(...this.scanEnterprise());
103
+ return result;
104
+ }
105
+ scanUser() {
106
+ const skillsDir = join(this.claudeDir, "skills");
107
+ return this.scanSkillDir(skillsDir, SkillLevel.USER);
108
+ }
109
+ scanProject() {
110
+ const skillsDir = join(this.projectDir, ".claude", "skills");
111
+ return this.scanSkillDir(skillsDir, SkillLevel.PROJECT);
112
+ }
113
+ scanSkillDir(skillsDir, level) {
114
+ const items = [];
115
+ if (!isDir(skillsDir)) return items;
116
+ for (const child of sortedDir(skillsDir)) {
117
+ const childPath = join(skillsDir, child);
118
+ if (!isDir(childPath)) continue;
119
+ const skillMd = join(childPath, "SKILL.md");
120
+ if (!isFile(skillMd)) continue;
121
+ const fm = parseFrontmatter(readFileSafe(skillMd));
122
+ const name = fm.name ?? child;
123
+ const desc = fm.description ?? "";
124
+ delete fm.name;
125
+ delete fm.description;
126
+ items.push({
127
+ name,
128
+ skillType: SkillType.SKILL,
129
+ level,
130
+ description: desc,
131
+ path: skillMd,
132
+ pluginName: "",
133
+ marketplace: "",
134
+ enabled: true,
135
+ extra: fm
136
+ });
137
+ }
138
+ return items;
139
+ }
140
+ scanPlugins() {
141
+ const pluginsFile = join(this.claudeDir, "plugins", "installed_plugins.json");
142
+ const settingsFile = join(this.claudeDir, "settings.json");
143
+ if (!isFile(pluginsFile)) return [];
144
+ let data;
145
+ try {
146
+ data = JSON.parse(readFileSafe(pluginsFile));
147
+ } catch {
148
+ return [];
149
+ }
150
+ let enabledMap = {};
151
+ if (isFile(settingsFile)) try {
152
+ enabledMap = JSON.parse(readFileSafe(settingsFile)).enabledPlugins ?? {};
153
+ } catch {}
154
+ const pluginsData = (data.version ?? 1) >= 2 ? data.plugins ?? data : data;
155
+ const result = [];
156
+ for (const [pluginKey, entries] of Object.entries(pluginsData)) {
157
+ if (!Array.isArray(entries) || entries.length === 0) continue;
158
+ const entry = entries[0];
159
+ const installPath = entry.installPath ?? "";
160
+ const ver = entry.version ?? "";
161
+ const atIdx = pluginKey.lastIndexOf("@");
162
+ const pluginName = atIdx > 0 ? pluginKey.slice(0, atIdx) : pluginKey;
163
+ const marketplace = atIdx > 0 ? pluginKey.slice(atIdx + 1) : "";
164
+ const enabled = enabledMap[pluginKey] ?? false;
165
+ let desc = "";
166
+ let author = "";
167
+ const pluginJson = join(installPath, ".claude-plugin", "plugin.json");
168
+ if (isFile(pluginJson)) try {
169
+ const pj = JSON.parse(readFileSafe(pluginJson));
170
+ desc = pj.description ?? "";
171
+ const a = pj.author;
172
+ if (typeof a === "object" && a !== null) author = a.name ?? "";
173
+ else if (typeof a === "string") author = a;
174
+ } catch {}
175
+ const pinfo = {
176
+ name: pluginName,
177
+ marketplace,
178
+ installPath,
179
+ version: ver,
180
+ enabled,
181
+ description: desc,
182
+ author,
183
+ items: []
184
+ };
185
+ pinfo.items.push(...this.scanPluginCommands(installPath, pinfo), ...this.scanPluginAgents(installPath, pinfo), ...this.scanPluginSkills(installPath, pinfo), ...this.scanPluginHooks(installPath, pinfo));
186
+ result.push(pinfo);
187
+ }
188
+ return result;
189
+ }
190
+ makePluginSkill(name, stype, path, pinfo, description = "", extra = {}) {
191
+ return {
192
+ name,
193
+ skillType: stype,
194
+ level: SkillLevel.PLUGIN,
195
+ description,
196
+ path,
197
+ pluginName: pinfo.name,
198
+ marketplace: pinfo.marketplace,
199
+ enabled: pinfo.enabled,
200
+ extra
201
+ };
202
+ }
203
+ scanPluginCommands(root, pinfo) {
204
+ const cmdDir = join(root, "commands");
205
+ const items = [];
206
+ if (!isDir(cmdDir)) return items;
207
+ for (const file of sortedDir(cmdDir)) {
208
+ if (!file.endsWith(".md")) continue;
209
+ const mdPath = join(cmdDir, file);
210
+ const fm = parseFrontmatter(readFileSafe(mdPath));
211
+ const name = fm.name ?? file.replace(/\.md$/, "");
212
+ const desc = fm.description ?? "";
213
+ delete fm.name;
214
+ delete fm.description;
215
+ items.push(this.makePluginSkill(name, SkillType.COMMAND, mdPath, pinfo, desc, fm));
216
+ }
217
+ return items;
218
+ }
219
+ scanPluginAgents(root, pinfo) {
220
+ const agentDir = join(root, "agents");
221
+ const items = [];
222
+ if (!isDir(agentDir)) return items;
223
+ for (const file of sortedDir(agentDir)) {
224
+ if (!file.endsWith(".md")) continue;
225
+ const mdPath = join(agentDir, file);
226
+ const fm = parseFrontmatter(readFileSafe(mdPath));
227
+ const name = fm.name ?? file.replace(/\.md$/, "");
228
+ const desc = fm.description ?? "";
229
+ delete fm.name;
230
+ delete fm.description;
231
+ items.push(this.makePluginSkill(name, SkillType.AGENT, mdPath, pinfo, desc, fm));
232
+ }
233
+ return items;
234
+ }
235
+ scanPluginSkills(root, pinfo) {
236
+ const skillsDir = join(root, "skills");
237
+ const items = [];
238
+ if (!isDir(skillsDir)) return items;
239
+ for (const child of sortedDir(skillsDir)) {
240
+ const childPath = join(skillsDir, child);
241
+ if (!isDir(childPath)) continue;
242
+ const skillMd = join(childPath, "SKILL.md");
243
+ if (!isFile(skillMd)) continue;
244
+ const fm = parseFrontmatter(readFileSafe(skillMd));
245
+ const name = fm.name ?? child;
246
+ const desc = fm.description ?? "";
247
+ delete fm.name;
248
+ delete fm.description;
249
+ items.push(this.makePluginSkill(name, SkillType.SKILL, skillMd, pinfo, desc, fm));
250
+ }
251
+ return items;
252
+ }
253
+ scanPluginHooks(root, pinfo) {
254
+ const hooksDir = join(root, "hooks");
255
+ const items = [];
256
+ if (!isDir(hooksDir)) return items;
257
+ const hooksJson = join(hooksDir, "hooks.json");
258
+ if (!isFile(hooksJson)) return items;
259
+ let data;
260
+ try {
261
+ data = JSON.parse(readFileSafe(hooksJson));
262
+ } catch {
263
+ return items;
264
+ }
265
+ const hookDesc = data.description ?? "";
266
+ const hooksMap = data.hooks ?? {};
267
+ for (const hookName of Object.keys(hooksMap).sort()) items.push(this.makePluginSkill(hookName, SkillType.HOOK, hooksJson, pinfo, hookDesc));
268
+ return items;
269
+ }
270
+ scanEnterprise() {
271
+ if (platform() !== "darwin") return [];
272
+ const entDir = "/Library/Application Support/ClaudeCode";
273
+ if (!isDir(entDir)) return [];
274
+ const items = [];
275
+ const skillsSub = join(entDir, "skills");
276
+ if (isDir(skillsSub)) items.push(...this.scanSkillDir(skillsSub, SkillLevel.ENTERPRISE));
277
+ for (const child of sortedDir(entDir)) {
278
+ const childPath = join(entDir, child);
279
+ if (!isDir(childPath)) continue;
280
+ const skillMd = join(childPath, "SKILL.md");
281
+ if (!isFile(skillMd)) continue;
282
+ const fm = parseFrontmatter(readFileSafe(skillMd));
283
+ const name = fm.name ?? child;
284
+ const desc = fm.description ?? "";
285
+ delete fm.name;
286
+ delete fm.description;
287
+ items.push({
288
+ name,
289
+ skillType: SkillType.SKILL,
290
+ level: SkillLevel.ENTERPRISE,
291
+ description: desc,
292
+ path: skillMd,
293
+ pluginName: "",
294
+ marketplace: "",
295
+ enabled: true,
296
+ extra: fm
297
+ });
298
+ }
299
+ return items;
300
+ }
301
+ };
302
+ function isDir(p) {
303
+ try {
304
+ return statSync(p).isDirectory();
305
+ } catch {
306
+ return false;
307
+ }
308
+ }
309
+ function isFile(p) {
310
+ try {
311
+ return statSync(p).isFile();
312
+ } catch {
313
+ return false;
314
+ }
315
+ }
316
+ function sortedDir(p) {
317
+ try {
318
+ return readdirSync(p).sort();
319
+ } catch {
320
+ return [];
321
+ }
322
+ }
323
+ function readFileSafe(p) {
324
+ try {
325
+ return readFileSync(p, "utf-8");
326
+ } catch {
327
+ return "";
328
+ }
329
+ }
330
+
331
+ //#endregion
332
+ //#region src/formatter.ts
333
+ function truncate(text, maxLen = 72) {
334
+ const clean = text.replace(/\n/g, " ").trim();
335
+ if (clean.length <= maxLen) return clean;
336
+ return clean.slice(0, maxLen - 3) + "...";
337
+ }
338
+ function formatTerminal(result, verbose) {
339
+ const lines = [];
340
+ const title = "Claude Code 技能掃描報告";
341
+ const boxW = 58;
342
+ lines.push(pc.cyan("╔" + "═".repeat(boxW) + "╗"));
343
+ lines.push(pc.cyan("║") + pc.bold(pc.white(" " + title.padEnd(boxW - 2))) + pc.cyan("║"));
344
+ lines.push(pc.cyan("╚" + "═".repeat(boxW) + "╝"));
345
+ lines.push("");
346
+ let anyOutput = false;
347
+ for (const level of [
348
+ SkillLevel.USER,
349
+ SkillLevel.PROJECT,
350
+ SkillLevel.ENTERPRISE
351
+ ]) {
352
+ const items = byLevel(result, level);
353
+ if (items.length === 0) continue;
354
+ anyOutput = true;
355
+ const label = LEVEL_LABELS[level];
356
+ lines.push(pc.bold(`── ${label} ${"─".repeat(55 - label.length)}`));
357
+ for (const sk of items) {
358
+ const badge = `[${TYPE_LABELS[sk.skillType]}]`;
359
+ const desc = sk.description || "(描述未填寫)";
360
+ lines.push(` ${pc.green("●")} ${pc.bold(sk.name.padEnd(44))} ${pc.dim(badge)}`);
361
+ lines.push(` ${pc.dim(truncate(desc))}`);
362
+ if (verbose && sk.path) lines.push(` ${pc.dim("路徑: " + sk.path)}`);
363
+ }
364
+ lines.push("");
365
+ }
366
+ if (byLevel(result, SkillLevel.PLUGIN).length > 0 || result.plugins.length > 0) {
367
+ anyOutput = true;
368
+ const label = LEVEL_LABELS[SkillLevel.PLUGIN];
369
+ lines.push(pc.bold(`── ${label} ${"─".repeat(55 - label.length)}`));
370
+ for (const pinfo of result.plugins) {
371
+ const statusIcon = pinfo.enabled ? pc.green("✓ 已啟用") : pc.red("✗ 已停用");
372
+ lines.push(` ${pc.yellow("▸")} ${pc.bold(pinfo.name)} ${pc.dim("@ " + pinfo.marketplace)} [${statusIcon}]`);
373
+ if (verbose && pinfo.description) lines.push(` ${pc.dim(truncate(pinfo.description, 68))}`);
374
+ if (verbose) lines.push(` ${pc.dim("路徑: " + pinfo.installPath)}`);
375
+ if (pinfo.items.length === 0) lines.push(` ${pc.dim("(無掃描到的項目)")}`);
376
+ else for (let i = 0; i < pinfo.items.length; i++) {
377
+ const item = pinfo.items[i];
378
+ const isLast = i === pinfo.items.length - 1;
379
+ const connector = isLast ? "└─" : "├─";
380
+ const badge = TYPE_LABELS[item.skillType];
381
+ const typeColorFn = {
382
+ [SkillType.COMMAND]: pc.magenta,
383
+ [SkillType.AGENT]: pc.blue,
384
+ [SkillType.SKILL]: pc.green,
385
+ [SkillType.HOOK]: pc.yellow
386
+ }[item.skillType] ?? pc.dim;
387
+ let prefix = item.name;
388
+ if (item.skillType === SkillType.COMMAND) prefix = item.name !== pinfo.name ? `/${pinfo.name}:${item.name}` : `/${item.name}`;
389
+ lines.push(` ${connector} ${typeColorFn(prefix.padEnd(38))} ${pc.dim(`[${badge}]`)}`);
390
+ if (verbose && item.description) {
391
+ const padding = isLast ? " " : "│ ";
392
+ lines.push(` ${padding} ${pc.dim(truncate(item.description, 60))}`);
393
+ }
394
+ }
395
+ lines.push("");
396
+ }
397
+ }
398
+ if (!anyOutput) {
399
+ lines.push(` ${pc.dim("(未掃描到任何技能)")}`);
400
+ lines.push("");
401
+ }
402
+ lines.push(pc.bold(`── 統計摘要 ${"─".repeat(47)}`));
403
+ const userCnt = byLevel(result, SkillLevel.USER).length;
404
+ const projCnt = byLevel(result, SkillLevel.PROJECT).length;
405
+ const entCnt = byLevel(result, SkillLevel.ENTERPRISE).length;
406
+ const pluginAll = byLevel(result, SkillLevel.PLUGIN);
407
+ const pluginCmds = pluginAll.filter((s) => s.skillType === SkillType.COMMAND).length;
408
+ const pluginAgents = pluginAll.filter((s) => s.skillType === SkillType.AGENT).length;
409
+ const pluginSkills = pluginAll.filter((s) => s.skillType === SkillType.SKILL).length;
410
+ const pluginHooks = pluginAll.filter((s) => s.skillType === SkillType.HOOK).length;
411
+ const enabledPlugins = result.plugins.filter((p) => p.enabled).length;
412
+ const totalPlugins = result.plugins.length;
413
+ lines.push(` 使用者: ${pc.bold(String(userCnt))} 專案: ${pc.bold(String(projCnt))} 企業: ${pc.bold(String(entCnt))}`);
414
+ let pluginDetail = `命令 ${pluginCmds} / 代理 ${pluginAgents} / 技能 ${pluginSkills}`;
415
+ if (pluginHooks > 0) pluginDetail += ` / 鉤子 ${pluginHooks}`;
416
+ lines.push(` 外掛: ${pc.bold(String(totalPlugins))} 個 (${pc.green(enabledPlugins + " 已啟用")}) 項目: ${pluginDetail}`);
417
+ lines.push(` ${pc.dim("合計: " + result.skills.length + " 個項目")}`);
418
+ lines.push("");
419
+ return lines.join("\n");
420
+ }
421
+ function formatJson(result) {
422
+ const output = {
423
+ skills: result.skills.map((s) => ({
424
+ name: s.name,
425
+ skill_type: s.skillType,
426
+ level: s.level,
427
+ description: s.description,
428
+ path: s.path,
429
+ plugin_name: s.pluginName,
430
+ marketplace: s.marketplace,
431
+ enabled: s.enabled,
432
+ extra: s.extra
433
+ })),
434
+ plugins: result.plugins.map((p) => ({
435
+ name: p.name,
436
+ marketplace: p.marketplace,
437
+ install_path: p.installPath,
438
+ version: p.version,
439
+ enabled: p.enabled,
440
+ description: p.description,
441
+ author: p.author,
442
+ items: p.items.map((i) => ({
443
+ name: i.name,
444
+ skill_type: i.skillType,
445
+ level: i.level,
446
+ description: i.description,
447
+ path: i.path,
448
+ plugin_name: i.pluginName,
449
+ marketplace: i.marketplace,
450
+ enabled: i.enabled,
451
+ extra: i.extra
452
+ }))
453
+ })),
454
+ summary: {
455
+ user: byLevel(result, SkillLevel.USER).length,
456
+ project: byLevel(result, SkillLevel.PROJECT).length,
457
+ enterprise: byLevel(result, SkillLevel.ENTERPRISE).length,
458
+ plugin_count: result.plugins.length,
459
+ plugin_items: byLevel(result, SkillLevel.PLUGIN).length,
460
+ total: result.skills.length
461
+ }
462
+ };
463
+ return JSON.stringify(output, null, 2);
464
+ }
465
+
466
+ //#endregion
467
+ //#region src/commands/scan.ts
468
+ const LEVEL_MAP = {
469
+ user: SkillLevel.USER,
470
+ project: SkillLevel.PROJECT,
471
+ plugin: SkillLevel.PLUGIN,
472
+ enterprise: SkillLevel.ENTERPRISE
473
+ };
474
+ const scanCommand = define({
475
+ name: "agentskillscanner",
476
+ description: "Scan and report all available skills for AI coding assistants",
477
+ args: {
478
+ json: {
479
+ type: "boolean",
480
+ short: "j",
481
+ description: "以 JSON 格式輸出",
482
+ default: false
483
+ },
484
+ "project-dir": {
485
+ type: "string",
486
+ short: "d",
487
+ description: "專案目錄(預設:目前工作目錄)",
488
+ default: process.cwd()
489
+ },
490
+ level: {
491
+ type: "string",
492
+ short: "l",
493
+ description: "篩選層級:user, project, plugin, enterprise(可用逗號分隔多個)"
494
+ },
495
+ verbose: {
496
+ type: "boolean",
497
+ short: "v",
498
+ description: "顯示完整描述與路徑",
499
+ default: false
500
+ }
501
+ },
502
+ run: (ctx) => {
503
+ const { json, verbose } = ctx.values;
504
+ const projectDir = ctx.values["project-dir"] ?? process.cwd();
505
+ let levelFilter;
506
+ const levelArg = ctx.values.level;
507
+ if (levelArg) {
508
+ levelFilter = levelArg.split(",").map((s) => s.trim().toLowerCase()).map((v) => LEVEL_MAP[v]).filter((v) => v !== void 0);
509
+ if (levelFilter.length === 0) levelFilter = void 0;
510
+ }
511
+ const result = new Scanner(projectDir).scan(levelFilter);
512
+ if (json) console.log(formatJson(result));
513
+ else console.log(formatTerminal(result, verbose ?? false));
514
+ }
515
+ });
516
+
517
+ //#endregion
518
+ //#region src/index.ts
519
+ await cli(process.argv.slice(2), scanCommand);
520
+
521
+ //#endregion
522
+ export { };
package/package.json ADDED
@@ -0,0 +1,29 @@
1
+ {
2
+ "name": "agentskillscanner",
3
+ "version": "0.1.0",
4
+ "type": "module",
5
+ "description": "Scan and report all available skills for AI coding assistants",
6
+ "license": "MIT",
7
+ "bin": {
8
+ "agentskillscanner": "./dist/index.js"
9
+ },
10
+ "files": [
11
+ "dist"
12
+ ],
13
+ "engines": {
14
+ "node": ">=20"
15
+ },
16
+ "scripts": {
17
+ "build": "tsdown",
18
+ "dev": "tsx src/index.ts"
19
+ },
20
+ "dependencies": {
21
+ "gunshi": "^0.26.3",
22
+ "picocolors": "^1.1.1"
23
+ },
24
+ "devDependencies": {
25
+ "tsdown": "^0.12.5",
26
+ "tsx": "^4.19.4",
27
+ "typescript": "^5.8.3"
28
+ }
29
+ }