sumulige-claude 1.0.7 → 1.0.8

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/cli.js CHANGED
@@ -13,6 +13,7 @@
13
13
  */
14
14
 
15
15
  const { runCommand } = require('./lib/commands');
16
+ const { marketplaceCommands } = require('./lib/marketplace');
16
17
 
17
18
  // ============================================================================
18
19
  // Command Registry (data-driven, no if-else chains)
@@ -58,6 +59,30 @@ const COMMANDS = {
58
59
  'skill:install': {
59
60
  help: 'Install a skill',
60
61
  args: '<source>'
62
+ },
63
+ 'marketplace:list': {
64
+ help: 'List all available skills',
65
+ args: ''
66
+ },
67
+ 'marketplace:install': {
68
+ help: 'Install a skill from marketplace',
69
+ args: '<name>'
70
+ },
71
+ 'marketplace:sync': {
72
+ help: 'Sync external skills',
73
+ args: ''
74
+ },
75
+ 'marketplace:add': {
76
+ help: 'Add external skill source',
77
+ args: '<owner/repo>'
78
+ },
79
+ 'marketplace:remove': {
80
+ help: 'Remove skill from sources',
81
+ args: '<name>'
82
+ },
83
+ 'marketplace:status': {
84
+ help: 'Show marketplace status',
85
+ args: ''
61
86
  }
62
87
  };
63
88
 
@@ -93,6 +118,9 @@ function showHelp() {
93
118
  console.log(' smc skill:create api-tester');
94
119
  console.log(' smc skill:check manus-kickoff');
95
120
  console.log(' smc skill:install anthropics/skills');
121
+ console.log(' smc marketplace:list');
122
+ console.log(' smc marketplace:install dev-browser');
123
+ console.log(' smc marketplace:sync');
96
124
  }
97
125
 
98
126
  // ============================================================================
@@ -110,7 +138,12 @@ function main() {
110
138
  const handler = COMMANDS[cmd];
111
139
 
112
140
  if (handler) {
113
- runCommand(cmd, args);
141
+ // Check if it's a marketplace command
142
+ if (cmd.startsWith('marketplace:')) {
143
+ marketplaceCommands[cmd](...args);
144
+ } else {
145
+ runCommand(cmd, args);
146
+ }
114
147
  } else {
115
148
  console.log(`Unknown command: ${cmd}`);
116
149
  console.log('');
@@ -0,0 +1,40 @@
1
+ {
2
+ "version": "1.0.0",
3
+ "categories": {
4
+ "tools": {
5
+ "name": "CLI 工具",
6
+ "description": "命令行工具和实用程序",
7
+ "icon": "🔧"
8
+ },
9
+ "development": {
10
+ "name": "开发辅助",
11
+ "description": "语言特定的开发辅助工具",
12
+ "icon": "💻"
13
+ },
14
+ "productivity": {
15
+ "name": "效率工具",
16
+ "description": "工作流自动化和效率提升",
17
+ "icon": "⚡"
18
+ },
19
+ "automation": {
20
+ "name": "自动化",
21
+ "description": "浏览器、CI/CD、系统自动化",
22
+ "icon": "🤖"
23
+ },
24
+ "data": {
25
+ "name": "数据处理",
26
+ "description": "数据库、数据处理和分析",
27
+ "icon": "📊"
28
+ },
29
+ "documentation": {
30
+ "name": "文档",
31
+ "description": "文档、图表、规范生成",
32
+ "icon": "📚"
33
+ },
34
+ "workflow": {
35
+ "name": "工作流编排",
36
+ "description": "多代理编排和协调",
37
+ "icon": "🎼"
38
+ }
39
+ }
40
+ }
@@ -0,0 +1,423 @@
1
+ # Development Guide - SMC Marketplace
2
+
3
+ 本文档详细说明了 SMC 技能市场和自动同步系统的开发细节。
4
+
5
+ ## 目录
6
+
7
+ - [架构概述](#架构概述)
8
+ - [项目结构](#项目结构)
9
+ - [添加新技能](#添加新技能)
10
+ - [同步机制原理](#同步机制原理)
11
+ - [命令开发](#命令开发)
12
+ - [调试指南](#调试指南)
13
+
14
+ ---
15
+
16
+ ## 架构概述
17
+
18
+ ### 核心组件
19
+
20
+ ```
21
+ ┌─────────────────────────────────────────────────────────────┐
22
+ │ SMC CLI │
23
+ │ ┌──────────────┐ ┌──────────────┐ ┌──────────────────┐ │
24
+ │ │ Commands │ │ Marketplace │ │ Config │ │
25
+ │ │ │ │ Commands │ │ │ │
26
+ │ └──────────────┘ └──────────────┘ └──────────────────┘ │
27
+ └─────────────────────────────────────────────────────────────┘
28
+ │ │ │
29
+ ▼ ▼ ▼
30
+ ┌──────────────────┐ ┌──────────────────┐ ┌──────────────────┐
31
+ │ sources.yaml │ │ sync-external.mjs│ │ update-registry │
32
+ │ │ │ │ │ .mjs │
33
+ └──────────────────┘ └──────────────────┘ └──────────────────┘
34
+ │ │ │
35
+ ▼ ▼ ▼
36
+ ┌──────────────────┐ ┌──────────────────┐ ┌──────────────────┐
37
+ │ External Repos │ │ Template Skills │ │ marketplace.json │
38
+ │ (GitHub) │ │ │ │ │
39
+ └──────────────────┘ └──────────────────┘ └──────────────────┘
40
+ ```
41
+
42
+ ### 数据流
43
+
44
+ ```
45
+ sources.yaml ──► sync-external.mjs ──► template/.claude/skills/
46
+ │ │
47
+ │ ▼
48
+ └──────────────────► update-registry.mjs ──► marketplace.json
49
+ ```
50
+
51
+ ---
52
+
53
+ ## 项目结构
54
+
55
+ ```
56
+ sumulige-claude/
57
+ ├── .claude-plugin/
58
+ │ └── marketplace.json # Claude Code 插件注册表
59
+ ├── .github/workflows/
60
+ │ └── sync-skills.yml # 自动同步工作流
61
+ ├── scripts/
62
+ │ ├── sync-external.mjs # 同步引擎 (ES Module)
63
+ │ └── update-registry.mjs # 注册表生成器 (ES Module)
64
+ ├── config/
65
+ │ └── skill-categories.json # 技能分类配置
66
+ ├── lib/
67
+ │ ├── commands.js # 基础命令 (CommonJS)
68
+ │ ├── config.js # 配置管理
69
+ │ ├── marketplace.js # 市场命令 (CommonJS)
70
+ │ └── utils.js # 工具函数
71
+ ├── template/.claude/skills/
72
+ │ ├── manus-kickoff/ # 本地技能
73
+ │ └── ...
74
+ ├── sources.yaml # 外部技能清单
75
+ ├── cli.js # 入口文件
76
+ └── package.json # 项目配置
77
+ ```
78
+
79
+ ---
80
+
81
+ ## 添加新技能
82
+
83
+ ### 1. 本地技能 (Native Skill)
84
+
85
+ 直接在 `template/.claude/skills/` 下创建目录:
86
+
87
+ ```bash
88
+ mkdir -p template/.claude/skills/my-skill
89
+ cd template/.claude/skills/my-skill
90
+
91
+ # 创建 SKILL.md
92
+ cat > SKILL.md << 'EOF'
93
+ # My Skill
94
+
95
+ > A brief description of what this skill does
96
+
97
+ ## Usage
98
+
99
+ When to use this skill...
100
+
101
+ EOF
102
+
103
+ # 创建 metadata.yaml
104
+ cat > metadata.yaml << 'EOF'
105
+ name: my-skill
106
+ description: A brief description
107
+ version: 1.0.0
108
+ category: tools
109
+ keywords:
110
+ - my-skill
111
+ - example
112
+ dependencies: []
113
+ author:
114
+ name: Your Name
115
+ github: yourusername
116
+ license: MIT
117
+ EOF
118
+ ```
119
+
120
+ 在 `sources.yaml` 中声明为 native:
121
+
122
+ ```yaml
123
+ - name: my-skill
124
+ description: "A brief description"
125
+ native: true
126
+ target:
127
+ category: tools
128
+ path: template/.claude/skills/my-skill
129
+ author:
130
+ name: Your Name
131
+ github: yourusername
132
+ license: MIT
133
+ homepage: https://github.com/yourusername/your-repo
134
+ ```
135
+
136
+ ### 2. 外部技能 (External Skill)
137
+
138
+ 编辑 `sources.yaml` 添加外部技能:
139
+
140
+ ```yaml
141
+ - name: external-skill
142
+ description: "Skill from external repository"
143
+ source:
144
+ repo: owner/repo
145
+ path: skills/external-skill
146
+ ref: main
147
+ target:
148
+ category: automation
149
+ path: template/.claude/skills/automation/external-skill
150
+ author:
151
+ name: Owner Name
152
+ github: owner
153
+ license: MIT
154
+ homepage: https://github.com/owner/repo
155
+ verified: false
156
+ sync:
157
+ include:
158
+ - SKILL.md
159
+ - src/
160
+ exclude:
161
+ - node_modules/
162
+ - "*.lock"
163
+ ```
164
+
165
+ ### 3. 更新注册表
166
+
167
+ ```bash
168
+ # 同步外部技能
169
+ npm run sync
170
+
171
+ # 更新市场注册表
172
+ npm run update-registry
173
+
174
+ # 或一次性执行
175
+ npm run sync:all
176
+ ```
177
+
178
+ ---
179
+
180
+ ## 同步机制原理
181
+
182
+ ### sync-external.mjs 工作流程
183
+
184
+ ```
185
+ ┌─────────────────────────────────────────────────────────────┐
186
+ │ 1. 解析 sources.yaml │
187
+ │ - 读取技能清单 │
188
+ │ - 区分 native 和 external 技能 │
189
+ └─────────────────────────────────────────────────────────────┘
190
+
191
+
192
+ ┌─────────────────────────────────────────────────────────────┐
193
+ │ 2. 遍历每个技能 │
194
+ │ - 跳过 native 技能 │
195
+ │ - 验证 external 技能配置 │
196
+ └─────────────────────────────────────────────────────────────┘
197
+
198
+
199
+ ┌─────────────────────────────────────────────────────────────┐
200
+ │ 3. 克隆外部仓库 │
201
+ │ - git clone --depth 1 │
202
+ │ - 使用指定的 ref (branch/tag) │
203
+ └─────────────────────────────────────────────────────────────┘
204
+
205
+
206
+ ┌─────────────────────────────────────────────────────────────┐
207
+ │ 4. 复制文件到目标目录 │
208
+ │ - 根据 sync.include 过滤文件 │
209
+ │ - 根据 sync.exclude 排除文件 │
210
+ └─────────────────────────────────────────────────────────────┘
211
+
212
+
213
+ ┌─────────────────────────────────────────────────────────────┐
214
+ │ 5. 生成源信息文件 │
215
+ │ - 写入 .source.json │
216
+ │ - 记录同步时间和来源 │
217
+ └─────────────────────────────────────────────────────────────┘
218
+
219
+
220
+ ┌─────────────────────────────────────────────────────────────┐
221
+ │ 6. 清理临时文件 │
222
+ │ - 删除克隆的临时目录 │
223
+ └─────────────────────────────────────────────────────────────┘
224
+ ```
225
+
226
+ ### update-registry.mjs 工作流程
227
+
228
+ ```
229
+ ┌─────────────────────────────────────────────────────────────┐
230
+ │ 1. 扫描技能目录 │
231
+ │ - 递归查找所有包含 SKILL.md 或 .source.json 的目录 │
232
+ └─────────────────────────────────────────────────────────────┘
233
+
234
+
235
+ ┌─────────────────────────────────────────────────────────────┐
236
+ │ 2. 提取技能元数据 │
237
+ │ - 读取 metadata.yaml │
238
+ │ - 读取 .source.json │
239
+ │ - 从 SKILL.md 提取描述 │
240
+ └─────────────────────────────────────────────────────────────┘
241
+
242
+
243
+ ┌─────────────────────────────────────────────────────────────┐
244
+ │ 3. 确定技能分类 │
245
+ │ - 根据 metadata.category │
246
+ │ - 或根据路径推断 │
247
+ └─────────────────────────────────────────────────────────────┘
248
+
249
+
250
+ ┌─────────────────────────────────────────────────────────────┐
251
+ │ 4. 构建插件注册表 │
252
+ │ - 按分类组织技能 │
253
+ │ - 添加元数据 (版本、时间戳、数量) │
254
+ └─────────────────────────────────────────────────────────────┘
255
+
256
+
257
+ ┌─────────────────────────────────────────────────────────────┐
258
+ │ 5. 写入 marketplace.json │
259
+ │ - 格式化为 JSON │
260
+ │ - 符合 Claude Code 插件规范 │
261
+ └─────────────────────────────────────────────────────────────┘
262
+ ```
263
+
264
+ ---
265
+
266
+ ## 命令开发
267
+
268
+ ### 添加新命令
269
+
270
+ #### 1. 在 `lib/commands.js` 或 `lib/marketplace.js` 添加处理函数
271
+
272
+ ```javascript
273
+ const commands = {
274
+ // ...existing commands...
275
+
276
+ // 新命令
277
+ 'my:command': (arg1, arg2) => {
278
+ console.log('Executing my:command with:', arg1, arg2);
279
+ // 命令逻辑
280
+ }
281
+ };
282
+ ```
283
+
284
+ #### 2. 在 `cli.js` 的 COMMANDS 注册表添加
285
+
286
+ ```javascript
287
+ const COMMANDS = {
288
+ // ...existing commands...
289
+
290
+ 'my:command': {
291
+ help: 'Command description',
292
+ args: '<arg1> <arg2>'
293
+ }
294
+ };
295
+ ```
296
+
297
+ #### 3. 添加帮助示例
298
+
299
+ ```javascript
300
+ // 在 showHelp() 函数的 Examples 部分
301
+ console.log(' smc my:command value1 value2');
302
+ ```
303
+
304
+ ### 命令分类
305
+
306
+ - **核心命令**: 直接在 `lib/commands.js` 实现
307
+ - **市场命令**: 在 `lib/marketplace.js` 实现
308
+ - **技能命令**: 在 `lib/commands.js` 的 `skill:*` 组
309
+
310
+ ---
311
+
312
+ ## 调试指南
313
+
314
+ ### 启用详细输出
315
+
316
+ ```bash
317
+ # 运行同步脚本并查看完整输出
318
+ node --trace-warnings scripts/sync-external.mjs
319
+ ```
320
+
321
+ ### 检查配置
322
+
323
+ ```bash
324
+ # 查看市场状态
325
+ smc marketplace:status
326
+
327
+ # 列出所有技能
328
+ smc marketplace:list
329
+ ```
330
+
331
+ ### 常见问题
332
+
333
+ #### 1. YAML 解析错误
334
+
335
+ ```bash
336
+ # 验证 YAML 语法
337
+ node -e "const yaml = require('yaml'); console.log(yaml.parse(require('fs').readFileSync('sources.yaml', 'utf8')))"
338
+ ```
339
+
340
+ #### 2. Git 克隆失败
341
+
342
+ ```bash
343
+ # 手动测试克隆
344
+ git clone --depth 1 https://github.com/owner/repo /tmp/test-repo
345
+ ```
346
+
347
+ #### 3. 权限问题
348
+
349
+ ```bash
350
+ # 检查目录权限
351
+ ls -la template/.claude/skills/
352
+
353
+ # 修复权限
354
+ chmod -R u+rwX template/.claude/skills/
355
+ ```
356
+
357
+ ### 调试日志
358
+
359
+ 同步脚本会在 `.tmp/` 目录存储临时克隆的仓库。如果同步失败,检查此目录:
360
+
361
+ ```bash
362
+ ls -la .tmp/
363
+ ```
364
+
365
+ ---
366
+
367
+ ## 测试
368
+
369
+ ### 手动测试
370
+
371
+ ```bash
372
+ # 测试同步
373
+ npm run sync
374
+
375
+ # 测试注册表生成
376
+ npm run update-registry
377
+
378
+ # 测试完整流程
379
+ npm run sync:all
380
+ ```
381
+
382
+ ### CI/CD 测试
383
+
384
+ 推送更改到 GitHub,自动触发工作流:
385
+
386
+ ```bash
387
+ git add .
388
+ git commit -m "test: update sources.yaml"
389
+ git push
390
+ ```
391
+
392
+ 手动触发工作流:
393
+ 1. 进入 GitHub 仓库页面
394
+ 2. 点击 "Actions" 标签
395
+ 3. 选择 "Sync External Skills" 工作流
396
+ 4. 点击 "Run workflow"
397
+
398
+ ---
399
+
400
+ ## 发布
401
+
402
+ ### 更新版本号
403
+
404
+ ```bash
405
+ # 更新 package.json
406
+ npm version patch # 或 minor, major
407
+
408
+ # 更新 marketplace.json 中的版本
409
+ npm run update-registry
410
+ ```
411
+
412
+ ### 发布到 npm
413
+
414
+ ```bash
415
+ npm publish
416
+ ```
417
+
418
+ ### 创建 Git 标签
419
+
420
+ ```bash
421
+ git tag v$(node -p "require('./package.json').version")
422
+ git push --tags
423
+ ```