@optima-chat/dev-skills 0.7.16 → 0.7.18

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.
@@ -0,0 +1,196 @@
1
+ # /restart-ecs - 重启 ECS 服务
2
+
3
+ 快速重启 ECS 集群中的服务,支持 Stage/Prod 两个环境。
4
+
5
+ **版本**: v0.1.0
6
+
7
+ ## 使用场景
8
+
9
+ **后端开发者**: 代码更新后需要重启服务使配置生效
10
+ **DevOps**: 服务异常需要快速恢复
11
+ **排查问题**: 服务状态异常,需要重启清理缓存或连接
12
+
13
+ ## 用法
14
+
15
+ ```
16
+ /restart-ecs <service> [environment]
17
+ ```
18
+
19
+ ## 参数
20
+
21
+ - `service` (必需): 服务简称
22
+ - `user-auth` - 用户认证服务
23
+ - `user-auth-admin` - 用户认证管理后台
24
+ - `commerce-backend` - 电商后端 API
25
+ - `commerce-rq-worker` - RQ 后台任务
26
+ - `commerce-rq-scheduler` - RQ 定时调度
27
+ - `agentic-chat` - AI 聊天服务
28
+ - `session-gateway` - AI Shell 网关
29
+ - `bi-backend` - BI 后端
30
+ - `bi-dashboard` - BI 仪表板
31
+ - `optima-scout` - 产品研究工具
32
+ - `ai-shell-web-ui` - Shell Web UI
33
+ - `optima-store` - 商城前端(仅 Stage)
34
+ - `pgbouncer` - 连接池(仅 Stage)
35
+ - `environment` (可选): 环境,默认 stage
36
+ - `stage` - Stage 预发布环境(默认,更安全)
37
+ - `prod` - 生产环境(需确认)
38
+
39
+ ## 示例
40
+
41
+ ```bash
42
+ /restart-ecs session-gateway # 重启 Stage 环境的 session-gateway(默认)
43
+ /restart-ecs session-gateway prod # 重启 Prod 环境的 session-gateway
44
+ /restart-ecs user-auth stage # 重启 Stage 环境的 user-auth
45
+ /restart-ecs list # 列出 Stage 环境所有可用服务
46
+ /restart-ecs list prod # 列出 Prod 环境所有可用服务
47
+ ```
48
+
49
+ ## 特殊参数处理
50
+
51
+ - 如果用户输入 `/restart-ecs` 或 `/restart-ecs --help` 或 `/restart-ecs help`,显示此帮助文档
52
+ - 如果用户输入 `/restart-ecs list [env]`,列出指定环境的所有服务
53
+
54
+ ## Claude Code 执行步骤
55
+
56
+ ### 0. 列出服务(service = "list")
57
+
58
+ ```bash
59
+ # 列出 Stage 环境服务
60
+ aws ecs list-services --cluster optima-stage-cluster --region ap-southeast-1 --query 'serviceArns[*]' --output text | tr '\t' '\n' | sed 's/.*service\/optima-stage-cluster\///'
61
+
62
+ # 列出 Prod 环境服务
63
+ aws ecs list-services --cluster optima-prod-cluster --region ap-southeast-1 --query 'serviceArns[*]' --output text | tr '\t' '\n' | sed 's/.*service\/optima-prod-cluster\///'
64
+ ```
65
+
66
+ ### 1. Stage 环境重启(environment = "stage" 或默认)
67
+
68
+ **集群名**: `optima-stage-cluster`
69
+ **服务名格式**: `{service}-stage`
70
+
71
+ **步骤**:
72
+ ```bash
73
+ # 重启服务(强制重新部署)
74
+ aws ecs update-service \
75
+ --cluster optima-stage-cluster \
76
+ --service {service}-stage \
77
+ --force-new-deployment \
78
+ --region ap-southeast-1 \
79
+ --query 'service.{serviceName:serviceName,desiredCount:desiredCount,runningCount:runningCount,status:status}' \
80
+ --output table
81
+ ```
82
+
83
+ **可用服务**:
84
+ - `user-auth-stage`
85
+ - `user-auth-admin-stage`
86
+ - `commerce-backend-stage`
87
+ - `commerce-rq-worker-stage`
88
+ - `commerce-rq-scheduler-stage`
89
+ - `agentic-chat-stage`
90
+ - `session-gateway-stage`
91
+ - `bi-backend-stage`
92
+ - `bi-dashboard-stage`
93
+ - `optima-scout-stage`
94
+ - `ai-shell-web-ui-stage`
95
+ - `optima-store-stage`
96
+ - `pgbouncer-stage`
97
+
98
+ ### 2. Prod 环境重启(environment = "prod")
99
+
100
+ **集群名**: `optima-prod-cluster`
101
+ **服务名格式**: `{service}-prod`
102
+
103
+ **⚠️ 安全提醒**: 重启 Prod 服务前,Claude 应主动向用户确认是否继续。
104
+
105
+ **步骤**:
106
+ ```bash
107
+ # 重启服务(强制重新部署)
108
+ aws ecs update-service \
109
+ --cluster optima-prod-cluster \
110
+ --service {service}-prod \
111
+ --force-new-deployment \
112
+ --region ap-southeast-1 \
113
+ --query 'service.{serviceName:serviceName,desiredCount:desiredCount,runningCount:runningCount,status:status}' \
114
+ --output table
115
+ ```
116
+
117
+ **可用服务**:
118
+ - `user-auth-prod`
119
+ - `user-auth-admin-prod`
120
+ - `commerce-backend-prod`
121
+ - `commerce-rq-worker-prod`
122
+ - `commerce-rq-scheduler-prod`
123
+ - `agentic-chat-prod`
124
+ - `session-gateway-prod`
125
+ - `bi-backend-prod`
126
+ - `bi-dashboard-prod`
127
+ - `optima-scout-prod`
128
+ - `ai-shell-web-ui-prod`
129
+
130
+ **注意**: `optima-store` 和 `pgbouncer` 仅在 Stage 环境部署
131
+
132
+ ## 查看重启进度
133
+
134
+ 重启触发后,可以查看部署进度:
135
+
136
+ ```bash
137
+ # 查看服务部署状态
138
+ aws ecs describe-services \
139
+ --cluster optima-{env}-cluster \
140
+ --services {service}-{env} \
141
+ --region ap-southeast-1 \
142
+ --query 'services[0].{serviceName:serviceName,status:status,runningCount:runningCount,desiredCount:desiredCount,deployments:deployments[*].{status:status,runningCount:runningCount,desiredCount:desiredCount}}' \
143
+ --output yaml
144
+
145
+ # 查看服务事件(最近的部署事件)
146
+ aws ecs describe-services \
147
+ --cluster optima-{env}-cluster \
148
+ --services {service}-{env} \
149
+ --region ap-southeast-1 \
150
+ --query 'services[0].events[:5]' \
151
+ --output table
152
+ ```
153
+
154
+ ## 常见错误处理
155
+
156
+ ### 错误:ServiceNotFoundException
157
+
158
+ **原因**: 服务名不存在
159
+
160
+ **解决**:
161
+ ```bash
162
+ # 列出所有服务
163
+ aws ecs list-services --cluster optima-stage-cluster --region ap-southeast-1
164
+ ```
165
+
166
+ ### 错误:ClusterNotFoundException
167
+
168
+ **原因**: 集群名错误
169
+
170
+ **解决**: 确认使用正确的集群名:
171
+ - Stage: `optima-stage-cluster`
172
+ - Prod: `optima-prod-cluster`
173
+
174
+ ### 错误:AccessDeniedException
175
+
176
+ **原因**: AWS 凭证无权限
177
+
178
+ **解决**: 确认 AWS CLI 配置了正确的凭证,且有 ECS 操作权限
179
+
180
+ ## 重启原理
181
+
182
+ `--force-new-deployment` 参数会:
183
+ 1. 使用**当前**的 Task Definition(版本号不变)
184
+ 2. 启动新的 Task 实例
185
+ 3. 新 Task 健康检查通过后注册到 ALB
186
+ 4. 旧 Task 优雅停止
187
+
188
+ 这是一个零停机的滚动更新过程。
189
+
190
+ ## 注意事项
191
+
192
+ 1. **默认 Stage 环境**: 为避免误操作生产环境,默认重启 Stage
193
+ 2. **Prod 需确认**: 重启 Prod 服务时 Claude 会主动确认
194
+ 3. **版本不变**: 重启不会改变 Task Definition 版本号
195
+ 4. **零停机**: ECS 会确保新 Task 健康后才停止旧 Task
196
+ 5. **权限要求**: 需要 AWS CLI 配置了正确的凭证和 ECS 操作权限
@@ -33,7 +33,12 @@
33
33
  "Bash(cat:*)",
34
34
  "Bash(node /Users/verypro/optima-dev-skills/scripts/install.js:*)",
35
35
  "Bash(aws logs tail:*)",
36
- "Bash(grep:*)"
36
+ "Bash(grep:*)",
37
+ "Bash(npm view:*)",
38
+ "Bash(npm version:*)",
39
+ "Bash(git checkout:*)",
40
+ "Bash(git pull:*)",
41
+ "Bash(node scripts/install.js:*)"
37
42
  ],
38
43
  "deny": [],
39
44
  "ask": []
@@ -0,0 +1,160 @@
1
+ ---
2
+ name: "restartEcs"
3
+ description: "当用户请求重启 ECS 服务、重启服务、restart service、重新部署服务、重启 session-gateway、重启 user-auth、重启后端服务时,使用此技能。支持 Stage、Prod 两个环境的 ECS 服务重启。"
4
+ allowed-tools: ["Bash"]
5
+ ---
6
+
7
+ # 重启 ECS 服务
8
+
9
+ 当你需要重启 ECS 集群中的服务时,使用这个场景。
10
+
11
+ ## 适用情况
12
+
13
+ - 代码更新后需要使配置生效
14
+ - 服务异常需要快速恢复
15
+ - 服务状态异常,需要清理缓存或连接
16
+ - 内存泄漏等问题需要重启服务
17
+
18
+ ## 快速操作
19
+
20
+ ### 1. 重启 Stage 环境服务(默认,更安全)
21
+
22
+ ```
23
+ /restart-ecs session-gateway
24
+ /restart-ecs user-auth
25
+ /restart-ecs commerce-backend
26
+ ```
27
+
28
+ **说明**:
29
+ - 默认重启 Stage 环境,避免误操作生产环境
30
+ - 使用 ECS `force-new-deployment` 实现零停机重启
31
+ - Task Definition 版本号不变
32
+
33
+ ### 2. 重启 Prod 环境服务
34
+
35
+ ```
36
+ /restart-ecs session-gateway prod
37
+ /restart-ecs user-auth prod
38
+ ```
39
+
40
+ **说明**:
41
+ - 重启生产环境服务
42
+ - Claude 会主动确认是否继续
43
+ - 同样是零停机滚动更新
44
+
45
+ ### 3. 列出可用服务
46
+
47
+ ```
48
+ /restart-ecs list # 列出 Stage 环境服务
49
+ /restart-ecs list prod # 列出 Prod 环境服务
50
+ ```
51
+
52
+ ## 环境信息
53
+
54
+ ### Stage 环境
55
+
56
+ **集群名**: `optima-stage-cluster`
57
+
58
+ **可用服务**:
59
+ | 服务简称 | 完整服务名 | 说明 |
60
+ |---------|-----------|------|
61
+ | user-auth | user-auth-stage | 用户认证服务 |
62
+ | user-auth-admin | user-auth-admin-stage | 认证管理后台 |
63
+ | commerce-backend | commerce-backend-stage | 电商后端 API |
64
+ | commerce-rq-worker | commerce-rq-worker-stage | RQ 后台任务 |
65
+ | commerce-rq-scheduler | commerce-rq-scheduler-stage | RQ 定时调度 |
66
+ | agentic-chat | agentic-chat-stage | AI 聊天服务 |
67
+ | session-gateway | session-gateway-stage | AI Shell 网关 |
68
+ | bi-backend | bi-backend-stage | BI 后端 |
69
+ | bi-dashboard | bi-dashboard-stage | BI 仪表板 |
70
+ | optima-scout | optima-scout-stage | 产品研究工具 |
71
+ | ai-shell-web-ui | ai-shell-web-ui-stage | Shell Web UI |
72
+ | optima-store | optima-store-stage | 商城前端 |
73
+ | pgbouncer | pgbouncer-stage | 数据库连接池 |
74
+
75
+ ### Prod 环境
76
+
77
+ **集群名**: `optima-prod-cluster`
78
+
79
+ **可用服务**:
80
+ | 服务简称 | 完整服务名 | 说明 |
81
+ |---------|-----------|------|
82
+ | user-auth | user-auth-prod | 用户认证服务 |
83
+ | user-auth-admin | user-auth-admin-prod | 认证管理后台 |
84
+ | commerce-backend | commerce-backend-prod | 电商后端 API |
85
+ | commerce-rq-worker | commerce-rq-worker-prod | RQ 后台任务 |
86
+ | commerce-rq-scheduler | commerce-rq-scheduler-prod | RQ 定时调度 |
87
+ | agentic-chat | agentic-chat-prod | AI 聊天服务 |
88
+ | session-gateway | session-gateway-prod | AI Shell 网关 |
89
+ | bi-backend | bi-backend-prod | BI 后端 |
90
+ | bi-dashboard | bi-dashboard-prod | BI 仪表板 |
91
+ | optima-scout | optima-scout-prod | 产品研究工具 |
92
+ | ai-shell-web-ui | ai-shell-web-ui-prod | Shell Web UI |
93
+
94
+ **注意**: `optima-store` 和 `pgbouncer` 仅在 Stage 环境部署
95
+
96
+ ## 重启原理
97
+
98
+ ECS `--force-new-deployment` 的工作流程:
99
+
100
+ 1. **启动新 Task** - 使用当前 Task Definition 创建新实例
101
+ 2. **健康检查** - 新 Task 通过 ALB 健康检查
102
+ 3. **注册到 ALB** - 新 Task 开始接收流量
103
+ 4. **停止旧 Task** - 旧 Task 优雅停止
104
+
105
+ 这是一个**零停机**的滚动更新过程,用户请求不会中断。
106
+
107
+ ## 常见使用场景
108
+
109
+ ### 场景 1:服务配置更新后重启
110
+
111
+ 当修改了 Infisical 中的环境变量后,需要重启服务使配置生效:
112
+
113
+ ```
114
+ /restart-ecs commerce-backend stage
115
+ ```
116
+
117
+ ### 场景 2:服务异常恢复
118
+
119
+ 服务出现内存泄漏或连接池耗尽等问题:
120
+
121
+ ```
122
+ /restart-ecs session-gateway prod
123
+ ```
124
+
125
+ ### 场景 3:批量重启多个服务
126
+
127
+ 需要重启多个相关服务:
128
+
129
+ ```
130
+ # 依次重启
131
+ /restart-ecs user-auth stage
132
+ /restart-ecs commerce-backend stage
133
+ /restart-ecs agentic-chat stage
134
+ ```
135
+
136
+ ## 查看重启进度
137
+
138
+ 重启触发后,可以查看部署状态:
139
+
140
+ ```bash
141
+ # 查看服务部署状态
142
+ aws ecs describe-services \
143
+ --cluster optima-stage-cluster \
144
+ --services session-gateway-stage \
145
+ --region ap-southeast-1 \
146
+ --query 'services[0].deployments' \
147
+ --output table
148
+ ```
149
+
150
+ ## 安全提醒
151
+
152
+ 1. **Stage 优先**: 默认重启 Stage 环境,降低误操作风险
153
+ 2. **Prod 确认**: 重启 Prod 服务前会主动确认
154
+ 3. **版本不变**: 重启不会改变 Task Definition 版本号
155
+ 4. **可恢复**: 如果新 Task 启动失败,旧 Task 会继续运行
156
+
157
+ ## 相关命令
158
+
159
+ - `/restart-ecs` - 重启 ECS 服务(详细使用方法请查看 `/restart-ecs --help`)
160
+ - `/logs` - 查看服务日志,可用于确认重启后服务状态
package/README.md CHANGED
@@ -23,12 +23,13 @@ Optima Dev Skills 让 Claude Code 能够直接在 **CI、Stage、Prod** 三个
23
23
  - **任务驱动** - 基于具体任务场景(查看日志、调用 API),不是抽象分类
24
24
  - **跨环境协作** - 统一的命令在 CI、Stage、Prod 三个环境中使用
25
25
 
26
- ## 📋 任务场景(5 个)
26
+ ## 📋 任务场景(6 个)
27
27
 
28
28
  当 Claude Code 识别到以下任务时,会自动加载对应的 Skill:
29
29
 
30
30
  - **logs** - 查看 CI/Stage/Prod 的服务器日志
31
31
  - **query-db** - 查询 CI/Stage/Prod 的数据库
32
+ - **show-env** - 查看 Stage/Prod 的服务环境变量(从 Infisical)
32
33
  - **generate-test-token** - 生成测试 Access Token 用于 API 测试
33
34
  - **use-commerce-cli** - 使用 Commerce CLI 管理电商店铺
34
35
  - **read-code** - 阅读 Optima-Chat 组织下任意仓库的代码
@@ -91,10 +92,12 @@ Claude:
91
92
  | 工具 | 说明 | 示例 |
92
93
  |------|------|------|
93
94
  | `optima-query-db` | 数据库查询工具 | `optima-query-db user-auth "SELECT COUNT(*) FROM users" prod` |
95
+ | `optima-show-env` | 查看服务环境变量 | `optima-show-env commerce-backend stage --filter DATABASE` |
94
96
  | `optima-generate-test-token` | 生成测试 token | `optima-generate-test-token --business-name "测试店铺"` |
95
97
 
96
98
  **特点**:
97
99
  - ✅ 支持 CI、Stage、Prod 三个环境(query-db)
100
+ - ✅ 支持 Stage、Prod 环境(show-env)
98
101
  - ✅ 自动管理 SSH 隧道和密钥
99
102
  - ✅ 可在任何终端直接使用
100
103
  - ✅ 自动注册账户、获取 token、设置 merchant profile(generate-test-token)
@@ -114,6 +117,7 @@ optima-dev-skills/
114
117
  │ └── skills/
115
118
  │ ├── logs/ # 日志查看 skill
116
119
  │ ├── query-db/ # 数据库查询 skill
120
+ │ ├── show-env/ # 环境变量查看 skill
117
121
  │ ├── generate-test-token/ # 测试 token 生成 skill
118
122
  │ ├── use-commerce-cli/ # Commerce CLI 使用 skill
119
123
  │ └── read-code/ # 代码阅读 skill
@@ -121,6 +125,7 @@ optima-dev-skills/
121
125
  ├── bin/
122
126
  │ └── helpers/
123
127
  │ ├── query-db.ts # CLI: 数据库查询
128
+ │ ├── show-env.ts # CLI: 查看环境变量
124
129
  │ └── generate-test-token.ts # CLI: 生成测试 token
125
130
 
126
131
  └── docs/
@@ -228,16 +233,16 @@ $ optima-query-db commerce-backend "SELECT id, title FROM products LIMIT 5" stag
228
233
 
229
234
  ## 🛠️ 开发状态
230
235
 
231
- **当前版本**: 0.7.4
236
+ **当前版本**: 0.7.16
232
237
 
233
238
  **已完成**:
234
239
  - ✅ 4 个命令:`/logs`、`/query-db`、`/generate-test-token`、`/read-code`
235
- - ✅ 5 个任务场景:`logs`、`query-db`、`generate-test-token`、`use-commerce-cli`、`read-code`
240
+ - ✅ 6 个任务场景:`logs`、`query-db`、`show-env`、`generate-test-token`、`use-commerce-cli`、`read-code`
236
241
  - ✅ 支持 CI、Stage、Prod 三个环境
237
242
  - ✅ CI 环境通过 SSH + Docker 访问
238
243
  - ✅ Stage/Prod 通过 SSH 隧道访问 RDS
239
- - ✅ TypeScript CLI 工具:`optima-query-db`、`optima-generate-test-token`
240
- - ✅ 通过 Infisical 动态获取密钥
244
+ - ✅ TypeScript CLI 工具:`optima-query-db`、`optima-show-env`、`optima-generate-test-token`
245
+ - ✅ 通过 Infisical 动态获取密钥和环境变量
241
246
  - ✅ 自动生成测试 token 并设置 merchant profile
242
247
  - ✅ `generate-test-token` 支持 development 和 production 环境
243
248
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@optima-chat/dev-skills",
3
- "version": "0.7.16",
3
+ "version": "0.7.18",
4
4
  "description": "Claude Code Skills for Optima development team - cross-environment collaboration tools",
5
5
  "main": "index.js",
6
6
  "bin": {
@@ -7,11 +7,7 @@ const os = require('os');
7
7
  const CLAUDE_DIR = path.join(os.homedir(), '.claude');
8
8
  const SKILLS_SOURCE = path.join(__dirname, '..', '.claude');
9
9
  const COMMANDS_DEST = path.join(CLAUDE_DIR, 'commands');
10
- const LOGS_SKILL_DEST = path.join(CLAUDE_DIR, 'skills', 'logs');
11
- const QUERY_DB_SKILL_DEST = path.join(CLAUDE_DIR, 'skills', 'query-db');
12
- const GENERATE_TOKEN_SKILL_DEST = path.join(CLAUDE_DIR, 'skills', 'generate-test-token');
13
- const USE_COMMERCE_CLI_SKILL_DEST = path.join(CLAUDE_DIR, 'skills', 'use-commerce-cli');
14
- const READ_CODE_SKILL_DEST = path.join(CLAUDE_DIR, 'skills', 'read-code');
10
+ const SKILLS_DEST = path.join(CLAUDE_DIR, 'skills');
15
11
 
16
12
  // 颜色输出
17
13
  const colors = {
@@ -47,95 +43,48 @@ function copyRecursive(src, dest) {
47
43
  function install() {
48
44
  log('\n🚀 Installing Optima Dev Skills...\n', 'blue');
49
45
 
50
- // 确保 .claude 目录存在
46
+ // 确保目录存在
51
47
  if (!fs.existsSync(CLAUDE_DIR)) {
52
48
  fs.mkdirSync(CLAUDE_DIR, { recursive: true });
53
49
  log(`✓ Created ${CLAUDE_DIR}`, 'green');
54
50
  }
55
-
56
- // 安装命令
57
51
  if (!fs.existsSync(COMMANDS_DEST)) {
58
52
  fs.mkdirSync(COMMANDS_DEST, { recursive: true });
59
53
  }
60
-
61
- // 安装 /logs 命令
62
- const logsCommandSource = path.join(SKILLS_SOURCE, 'commands', 'logs.md');
63
- const logsCommandDest = path.join(COMMANDS_DEST, 'logs.md');
64
- if (fs.existsSync(logsCommandSource)) {
65
- fs.copyFileSync(logsCommandSource, logsCommandDest);
66
- log(`✓ Installed /logs command`, 'green');
54
+ if (!fs.existsSync(SKILLS_DEST)) {
55
+ fs.mkdirSync(SKILLS_DEST, { recursive: true });
67
56
  }
68
57
 
69
- // 安装 /query-db 命令
70
- const queryDbCommandSource = path.join(SKILLS_SOURCE, 'commands', 'query-db.md');
71
- const queryDbCommandDest = path.join(COMMANDS_DEST, 'query-db.md');
72
- if (fs.existsSync(queryDbCommandSource)) {
73
- fs.copyFileSync(queryDbCommandSource, queryDbCommandDest);
74
- log(`✓ Installed /query-db command`, 'green');
75
- }
76
-
77
- // 安装 /generate-test-token 命令
78
- const generateTokenCommandSource = path.join(SKILLS_SOURCE, 'commands', 'generate-test-token.md');
79
- const generateTokenCommandDest = path.join(COMMANDS_DEST, 'generate-test-token.md');
80
- if (fs.existsSync(generateTokenCommandSource)) {
81
- fs.copyFileSync(generateTokenCommandSource, generateTokenCommandDest);
82
- log(`✓ Installed /generate-test-token command`, 'green');
83
- }
84
-
85
- // 安装 /read-code 命令
86
- const readCodeCommandSource = path.join(SKILLS_SOURCE, 'commands', 'read-code.md');
87
- const readCodeCommandDest = path.join(COMMANDS_DEST, 'read-code.md');
88
- if (fs.existsSync(readCodeCommandSource)) {
89
- fs.copyFileSync(readCodeCommandSource, readCodeCommandDest);
90
- log(`✓ Installed /read-code command`, 'green');
91
- }
92
-
93
- // 安装 logs skill
94
- const logsSkillSource = path.join(SKILLS_SOURCE, 'skills', 'logs');
95
- if (fs.existsSync(logsSkillSource)) {
96
- copyRecursive(logsSkillSource, LOGS_SKILL_DEST);
97
- log(`✓ Installed logs skill`, 'green');
98
- }
99
-
100
- // 安装 query-db skill
101
- const queryDbSkillSource = path.join(SKILLS_SOURCE, 'skills', 'query-db');
102
- if (fs.existsSync(queryDbSkillSource)) {
103
- copyRecursive(queryDbSkillSource, QUERY_DB_SKILL_DEST);
104
- log(`✓ Installed query-db skill`, 'green');
105
- }
106
-
107
- // 安装 generate-test-token skill
108
- const generateTokenSkillSource = path.join(SKILLS_SOURCE, 'skills', 'generate-test-token');
109
- if (fs.existsSync(generateTokenSkillSource)) {
110
- copyRecursive(generateTokenSkillSource, GENERATE_TOKEN_SKILL_DEST);
111
- log(`✓ Installed generate-test-token skill`, 'green');
112
- }
113
-
114
- // 安装 use-commerce-cli skill
115
- const useCommerceCliSkillSource = path.join(SKILLS_SOURCE, 'skills', 'use-commerce-cli');
116
- if (fs.existsSync(useCommerceCliSkillSource)) {
117
- copyRecursive(useCommerceCliSkillSource, USE_COMMERCE_CLI_SKILL_DEST);
118
- log(`✓ Installed use-commerce-cli skill`, 'green');
58
+ // 动态安装所有 commands
59
+ const commandsSource = path.join(SKILLS_SOURCE, 'commands');
60
+ if (fs.existsSync(commandsSource)) {
61
+ const commands = fs.readdirSync(commandsSource).filter(f => f.endsWith('.md'));
62
+ commands.forEach(cmd => {
63
+ const src = path.join(commandsSource, cmd);
64
+ const dest = path.join(COMMANDS_DEST, cmd);
65
+ fs.copyFileSync(src, dest);
66
+ const cmdName = cmd.replace('.md', '');
67
+ log(`✓ Installed /${cmdName} command`, 'green');
68
+ });
119
69
  }
120
70
 
121
- // 安装 read-code skill
122
- const readCodeSkillSource = path.join(SKILLS_SOURCE, 'skills', 'read-code');
123
- if (fs.existsSync(readCodeSkillSource)) {
124
- copyRecursive(readCodeSkillSource, READ_CODE_SKILL_DEST);
125
- log(`✓ Installed read-code skill`, 'green');
71
+ // 动态安装所有 skills
72
+ const skillsSource = path.join(SKILLS_SOURCE, 'skills');
73
+ if (fs.existsSync(skillsSource)) {
74
+ const skills = fs.readdirSync(skillsSource).filter(f => {
75
+ return fs.statSync(path.join(skillsSource, f)).isDirectory();
76
+ });
77
+ skills.forEach(skill => {
78
+ const src = path.join(skillsSource, skill);
79
+ const dest = path.join(SKILLS_DEST, skill);
80
+ copyRecursive(src, dest);
81
+ log(`✓ Installed ${skill} skill`, 'green');
82
+ });
126
83
  }
127
84
 
128
85
  log('\n✨ Installation complete!\n', 'green');
129
- log('Available commands:', 'blue');
130
- log(' /logs <service> [lines] [environment]', 'yellow');
131
- log(' /query-db <service> <sql> [environment]', 'yellow');
132
- log(' /generate-test-token [options]', 'yellow');
133
- log(' /read-code <repo> [path]', 'yellow');
134
- log('\nExamples:', 'blue');
135
- log(' /logs commerce-backend # CI logs', 'yellow');
136
- log(' /query-db commerce-backend "SELECT COUNT(*) FROM orders" # CI query', 'yellow');
137
- log(' /read-code commerce-backend app/main.py # Read code', 'yellow');
138
- log('\nDocumentation: https://github.com/Optima-Chat/optima-dev-skills\n', 'blue');
86
+ log('Run /help in Claude Code to see available commands.\n', 'blue');
87
+ log('Documentation: https://github.com/Optima-Chat/optima-dev-skills\n', 'blue');
139
88
  }
140
89
 
141
90
  try {