@optima-chat/dev-skills 0.6.0 → 0.7.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.
@@ -0,0 +1,128 @@
1
+ # /read-code - 阅读 Optima 代码库
2
+
3
+ 通过 GitHub CLI 查看 Optima-Chat 组织下任意仓库的代码。
4
+
5
+ **版本**: v0.1.0
6
+
7
+ ## 使用场景
8
+
9
+ **开发者**: 查看其他服务的实现细节,了解 API 调用方式
10
+ **新成员**: 快速了解项目结构和代码组织
11
+ **跨团队协作**: 查找特定功能的代码位置
12
+
13
+ ## 用法
14
+
15
+ ```
16
+ /read-code <repo> [path]
17
+ ```
18
+
19
+ ## 参数
20
+
21
+ - `repo` (必需): 仓库名称(不需要 Optima-Chat/ 前缀)
22
+ - `commerce-backend` - 电商后端
23
+ - `user-auth` - 用户认证
24
+ - `mcp-host` - MCP 协调器
25
+ - `agentic-chat` - AI 聊天
26
+ - `commerce-cli` - 电商 CLI
27
+ - `optima-store` - 店铺前端
28
+ - 等等...
29
+ - `path` (可选): 文件或目录路径,默认为根目录
30
+
31
+ ## 示例
32
+
33
+ ```bash
34
+ /read-code commerce-backend # 查看根目录结构
35
+ /read-code commerce-backend app # 查看 app 目录
36
+ /read-code commerce-backend app/main.py # 查看具体文件
37
+ /read-code user-auth CLAUDE.md # 查看项目文档
38
+ ```
39
+
40
+ ## Claude Code 执行步骤
41
+
42
+ ### 1. 查看目录结构
43
+
44
+ ```bash
45
+ # 查看根目录
46
+ gh api repos/Optima-Chat/{repo}/contents | jq -r '.[] | "\(.type)\t\(.name)"'
47
+
48
+ # 查看子目录
49
+ gh api repos/Optima-Chat/{repo}/contents/{path} | jq -r '.[] | "\(.type)\t\(.name)"'
50
+ ```
51
+
52
+ ### 2. 查看文件内容
53
+
54
+ ```bash
55
+ # 查看文件(自动解码 base64)
56
+ gh api repos/Optima-Chat/{repo}/contents/{path} | jq -r '.content' | base64 -d
57
+ ```
58
+
59
+ ### 3. 搜索代码
60
+
61
+ ```bash
62
+ # 在仓库中搜索
63
+ gh search code "{keyword}" --repo Optima-Chat/{repo}
64
+
65
+ # 跨仓库搜索
66
+ gh search code "{keyword}" --owner Optima-Chat
67
+ ```
68
+
69
+ ### 4. 查看完整目录树
70
+
71
+ ```bash
72
+ gh api repos/Optima-Chat/{repo}/git/trees/main?recursive=1 | jq -r '.tree[] | select(.type=="blob") | .path' | head -50
73
+ ```
74
+
75
+ ## 可用仓库列表
76
+
77
+ ### 核心服务
78
+ - `commerce-backend` - 电商后端 API
79
+ - `user-auth` - 用户认证服务
80
+ - `mcp-host` - MCP 协调器
81
+ - `agentic-chat` - AI 聊天应用
82
+
83
+ ### MCP 服务
84
+ - `commerce-mcp` - 电商管理 MCP
85
+ - `shopify-mcp` - Shopify API MCP
86
+ - `google-ads-mcp` - Google Ads MCP
87
+ - `comfy-mcp` - ComfyUI MCP
88
+ - `perplexity-mcp` - Perplexity MCP
89
+ - `fetch-mcp` - 网页抓取 MCP
90
+
91
+ ### 前端 & CLI
92
+ - `optima-store` - 电商店铺前端
93
+ - `commerce-cli` - 电商管理 CLI
94
+ - `optima-ops-cli` - 运维 CLI
95
+
96
+ ### 其他
97
+ - `optima-terraform` - AWS Terraform 配置
98
+ - `optima-workspace` - 多仓库工作区管理
99
+ - `optima-eval` - AI Agent 评测系统
100
+ - `optima-bi` - 商业智能模块
101
+
102
+ ## 实用技巧
103
+
104
+ ### 查看大文件
105
+
106
+ ```bash
107
+ # 获取 raw 内容(避免 base64 截断)
108
+ curl -s "$(gh api repos/Optima-Chat/{repo}/contents/{path} | jq -r '.download_url')"
109
+ ```
110
+
111
+ ### 查看最近修改
112
+
113
+ ```bash
114
+ # 最近 commit 修改的文件
115
+ gh api repos/Optima-Chat/{repo}/commits/main | jq -r '.files[].filename'
116
+ ```
117
+
118
+ ### 查看特定分支
119
+
120
+ ```bash
121
+ gh api repos/Optima-Chat/{repo}/contents/{path}?ref=develop | jq -r '.content' | base64 -d
122
+ ```
123
+
124
+ ## 注意事项
125
+
126
+ 1. 需要 GitHub CLI 已登录且有仓库访问权限
127
+ 2. 大部分仓库是私有的
128
+ 3. 超过 1MB 的文件需要使用 raw URL
@@ -29,7 +29,9 @@
29
29
  "Bash(python3:*)",
30
30
  "Bash(gh api:*)",
31
31
  "Bash(curl -s http://auth.optima.chat/openapi.json)",
32
- "Bash(curl -s https://auth.optima.chat/openapi.json)"
32
+ "Bash(curl -s https://auth.optima.chat/openapi.json)",
33
+ "Bash(cat:*)",
34
+ "Bash(node /Users/verypro/optima-dev-skills/scripts/install.js:*)"
33
35
  ],
34
36
  "deny": [],
35
37
  "ask": []
@@ -0,0 +1,207 @@
1
+ ---
2
+ name: "read-code"
3
+ description: "当用户请求阅读代码、查看源码、看看代码、代码在哪、找代码、查看实现、看看怎么实现的、代码结构、项目结构时,使用此技能。支持查看 Optima-Chat 组织下所有仓库的代码。"
4
+ allowed-tools: ["Bash"]
5
+ ---
6
+
7
+ # 阅读 Optima 代码库
8
+
9
+ 当你需要查看 Optima-Chat 组织下任何仓库的代码时,使用这个技能。
10
+
11
+ ## 🎯 适用情况
12
+
13
+ - 查看某个服务的实现细节
14
+ - 了解项目结构
15
+ - 查找特定功能的代码
16
+ - 学习代码实现方式
17
+ - 跨仓库代码对比
18
+
19
+ ## 🏢 可用仓库
20
+
21
+ ### 核心服务
22
+
23
+ | 仓库 | 说明 |
24
+ |------|------|
25
+ | `commerce-backend` | 电商后端 API |
26
+ | `user-auth` | 用户认证服务 |
27
+ | `mcp-host` | MCP 协调器服务 |
28
+ | `agentic-chat` | AI 聊天应用 |
29
+
30
+ ### MCP 服务
31
+
32
+ | 仓库 | 说明 |
33
+ |------|------|
34
+ | `commerce-mcp` | 电商管理 MCP |
35
+ | `shopify-mcp` | Shopify API MCP |
36
+ | `google-ads-mcp` | Google Ads MCP |
37
+ | `comfy-mcp` | ComfyUI MCP |
38
+ | `perplexity-mcp` | Perplexity MCP |
39
+ | `fetch-mcp` | 网页抓取 MCP |
40
+
41
+ ### 前端 & CLI
42
+
43
+ | 仓库 | 说明 |
44
+ |------|------|
45
+ | `optima-store` | 电商店铺前端 |
46
+ | `commerce-cli` | 电商管理 CLI |
47
+ | `optima-ops-cli` | 运维 CLI |
48
+
49
+ ### 其他
50
+
51
+ | 仓库 | 说明 |
52
+ |------|------|
53
+ | `optima-terraform` | AWS Terraform 配置 |
54
+ | `optima-workspace` | 多仓库工作区管理 |
55
+ | `optima-eval` | AI Agent 评测系统 |
56
+ | `optima-bi` | 商业智能模块 |
57
+ | `optima-scout` | 智能选品助手 |
58
+
59
+ ## 🚀 快速操作
60
+
61
+ ### 1. 查看仓库结构
62
+
63
+ ```bash
64
+ # 查看仓库文件列表
65
+ gh repo view Optima-Chat/commerce-backend --json name,description
66
+
67
+ # 查看根目录结构
68
+ gh api repos/Optima-Chat/commerce-backend/contents | jq -r '.[].name'
69
+
70
+ # 查看特定目录
71
+ gh api repos/Optima-Chat/commerce-backend/contents/app | jq -r '.[].name'
72
+ ```
73
+
74
+ ### 2. 查看文件内容
75
+
76
+ ```bash
77
+ # 查看单个文件(自动解码 base64)
78
+ gh api repos/Optima-Chat/commerce-backend/contents/README.md | jq -r '.content' | base64 -d
79
+
80
+ # 查看 Python 文件
81
+ gh api repos/Optima-Chat/commerce-backend/contents/app/main.py | jq -r '.content' | base64 -d
82
+
83
+ # 查看 CLAUDE.md(如果存在)
84
+ gh api repos/Optima-Chat/commerce-backend/contents/CLAUDE.md | jq -r '.content' | base64 -d
85
+ ```
86
+
87
+ ### 3. 搜索代码
88
+
89
+ ```bash
90
+ # 在仓库中搜索代码
91
+ gh search code "def create_product" --repo Optima-Chat/commerce-backend
92
+
93
+ # 搜索特定文件类型
94
+ gh search code "class Product" --repo Optima-Chat/commerce-backend --filename "*.py"
95
+
96
+ # 跨仓库搜索
97
+ gh search code "MerchantProfile" --owner Optima-Chat
98
+ ```
99
+
100
+ ### 4. 查看特定分支或 commit
101
+
102
+ ```bash
103
+ # 查看特定分支的文件
104
+ gh api repos/Optima-Chat/commerce-backend/contents/app/main.py?ref=develop | jq -r '.content' | base64 -d
105
+
106
+ # 查看最近的 commits
107
+ gh api repos/Optima-Chat/commerce-backend/commits --jq '.[0:5] | .[] | "\(.sha[0:7]) \(.commit.message | split("\n")[0])"'
108
+ ```
109
+
110
+ ## 📋 常见使用场景
111
+
112
+ ### 场景 1:了解服务架构
113
+
114
+ **用户请求**:"帮我看看 commerce-backend 的项目结构"
115
+
116
+ **步骤**:
117
+ ```bash
118
+ # 1. 查看根目录
119
+ gh api repos/Optima-Chat/commerce-backend/contents | jq -r '.[] | "\(.type)\t\(.name)"'
120
+
121
+ # 2. 查看 app 目录结构
122
+ gh api repos/Optima-Chat/commerce-backend/contents/app | jq -r '.[] | "\(.type)\t\(.name)"'
123
+
124
+ # 3. 查看 CLAUDE.md 了解架构
125
+ gh api repos/Optima-Chat/commerce-backend/contents/CLAUDE.md | jq -r '.content' | base64 -d
126
+ ```
127
+
128
+ ### 场景 2:查找功能实现
129
+
130
+ **用户请求**:"商品创建的代码在哪?"
131
+
132
+ **步骤**:
133
+ ```bash
134
+ # 1. 搜索相关代码
135
+ gh search code "create_product" --repo Optima-Chat/commerce-backend
136
+
137
+ # 2. 查看搜索到的文件
138
+ gh api repos/Optima-Chat/commerce-backend/contents/app/services/product_service.py | jq -r '.content' | base64 -d
139
+ ```
140
+
141
+ ### 场景 3:跨仓库对比
142
+
143
+ **用户请求**:"commerce-mcp 和 commerce-cli 有什么区别?"
144
+
145
+ **步骤**:
146
+ ```bash
147
+ # 1. 查看两个仓库的 README
148
+ gh api repos/Optima-Chat/commerce-mcp/contents/README.md | jq -r '.content' | base64 -d
149
+ gh api repos/Optima-Chat/commerce-cli/contents/README.md | jq -r '.content' | base64 -d
150
+
151
+ # 2. 对比项目结构
152
+ gh api repos/Optima-Chat/commerce-mcp/contents | jq -r '.[].name'
153
+ gh api repos/Optima-Chat/commerce-cli/contents | jq -r '.[].name'
154
+ ```
155
+
156
+ ### 场景 4:查看 API 定义
157
+
158
+ **用户请求**:"user-auth 有哪些 API?"
159
+
160
+ **步骤**:
161
+ ```bash
162
+ # 1. 查看路由文件
163
+ gh api repos/Optima-Chat/user-auth/contents/app/api | jq -r '.[].name'
164
+
165
+ # 2. 查看具体路由
166
+ gh api repos/Optima-Chat/user-auth/contents/app/api/routes/auth.py | jq -r '.content' | base64 -d
167
+ ```
168
+
169
+ ## 💡 实用技巧
170
+
171
+ ### 查看大文件
172
+
173
+ 对于大文件,GitHub API 可能返回 truncated 内容,使用 raw URL:
174
+
175
+ ```bash
176
+ # 获取 raw 内容 URL
177
+ gh api repos/Optima-Chat/commerce-backend/contents/app/main.py | jq -r '.download_url'
178
+
179
+ # 直接获取 raw 内容
180
+ curl -s "$(gh api repos/Optima-Chat/commerce-backend/contents/app/main.py | jq -r '.download_url')"
181
+ ```
182
+
183
+ ### 递归查看目录
184
+
185
+ ```bash
186
+ # 获取整个目录树
187
+ gh api repos/Optima-Chat/commerce-backend/git/trees/main?recursive=1 | jq -r '.tree[] | select(.type=="blob") | .path' | head -50
188
+ ```
189
+
190
+ ### 查看最近修改的文件
191
+
192
+ ```bash
193
+ # 查看最近的 commit 修改了哪些文件
194
+ gh api repos/Optima-Chat/commerce-backend/commits/main | jq -r '.files[].filename'
195
+ ```
196
+
197
+ ## ⚠️ 注意事项
198
+
199
+ 1. **权限**:需要 GitHub CLI 已登录且有仓库访问权限
200
+ 2. **私有仓库**:大部分 Optima-Chat 仓库是私有的,确保有访问权限
201
+ 3. **API 限制**:GitHub API 有速率限制,避免频繁请求
202
+ 4. **大文件**:超过 1MB 的文件需要使用 raw URL 获取
203
+
204
+ ## 🔗 相关资源
205
+
206
+ - GitHub CLI 文档:https://cli.github.com/manual/
207
+ - GitHub REST API:https://docs.github.com/en/rest
package/README.md CHANGED
@@ -23,7 +23,7 @@ Optima Dev Skills 让 Claude Code 能够直接在 **CI、Stage、Prod** 三个
23
23
  - **任务驱动** - 基于具体任务场景(查看日志、调用 API),不是抽象分类
24
24
  - **跨环境协作** - 统一的命令在 CI、Stage、Prod 三个环境中使用
25
25
 
26
- ## 📋 任务场景(4 个)
26
+ ## 📋 任务场景(5 个)
27
27
 
28
28
  当 Claude Code 识别到以下任务时,会自动加载对应的 Skill:
29
29
 
@@ -31,6 +31,7 @@ Optima Dev Skills 让 Claude Code 能够直接在 **CI、Stage、Prod** 三个
31
31
  - **query-db** - 查询 CI/Stage/Prod 的数据库
32
32
  - **generate-test-token** - 生成测试 Access Token 用于 API 测试
33
33
  - **use-commerce-cli** - 使用 Commerce CLI 管理电商店铺
34
+ - **read-code** - 阅读 Optima-Chat 组织下任意仓库的代码
34
35
 
35
36
  ## 👤 用户故事
36
37
 
@@ -75,6 +76,7 @@ Claude:
75
76
  | `/logs` | 查看服务日志 | `/logs commerce-backend 100` | ✅ |
76
77
  | `/query-db` | 查询数据库 | `/query-db user-auth "SELECT COUNT(*) FROM users"` | ✅ |
77
78
  | `/generate-test-token` | 生成测试 token | `/generate-test-token` | 🔧 Development |
79
+ | `/read-code` | 阅读代码 | `/read-code commerce-backend app/main.py` | - |
78
80
 
79
81
  **说明**:
80
82
  - 命令支持 CI、Stage、Prod 三个环境
@@ -106,13 +108,15 @@ optima-dev-skills/
106
108
  │ ├── commands/
107
109
  │ │ ├── logs.md # /logs - 查看服务日志
108
110
  │ │ ├── query-db.md # /query-db - 查询数据库
109
- │ │ └── generate-test-token.md # /generate-test-token - 生成测试 token
111
+ │ │ ├── generate-test-token.md # /generate-test-token - 生成测试 token
112
+ │ │ └── read-code.md # /read-code - 阅读代码
110
113
  │ │
111
114
  │ └── skills/
112
115
  │ ├── logs/ # 日志查看 skill
113
116
  │ ├── query-db/ # 数据库查询 skill
114
117
  │ ├── generate-test-token/ # 测试 token 生成 skill
115
- └── use-commerce-cli/ # Commerce CLI 使用 skill
118
+ ├── use-commerce-cli/ # Commerce CLI 使用 skill
119
+ │ └── read-code/ # 代码阅读 skill
116
120
 
117
121
  ├── bin/
118
122
  │ └── helpers/
@@ -142,15 +146,17 @@ Claude:
142
146
  ### 示例 2:生成测试 token 并管理店铺
143
147
 
144
148
  ```bash
145
- # 1. 生成测试 token
146
- $ optima-generate-test-token
149
+ # 1. 生成 production 环境测试 token
150
+ $ optima-generate-test-token --env production
147
151
 
152
+ Environment: production
153
+ Auth API: https://auth.optima.shop
148
154
  ✅ Test token generated successfully!
149
155
  📁 Token File Path: /tmp/optima-test-token-xxx.txt
150
156
 
151
157
  # 2. 使用 token 创建商品
152
158
  $ OPTIMA_TOKEN=$(cat /tmp/optima-test-token-xxx.txt) \
153
- OPTIMA_ENV=development \
159
+ OPTIMA_ENV=production \
154
160
  commerce product create --title "测试商品" --price 99.99 --stock 100
155
161
 
156
162
  {
@@ -222,17 +228,18 @@ $ optima-query-db commerce-backend "SELECT id, title FROM products LIMIT 5" stag
222
228
 
223
229
  ## 🛠️ 开发状态
224
230
 
225
- **当前版本**: 0.5.4
231
+ **当前版本**: 0.7.0
226
232
 
227
233
  **已完成**:
228
- - ✅ 3 个跨环境命令:`/logs`、`/query-db`、`/generate-test-token`
229
- - ✅ 4 个任务场景:`logs`、`query-db`、`generate-test-token`、`use-commerce-cli`
234
+ - ✅ 4 个命令:`/logs`、`/query-db`、`/generate-test-token`、`/read-code`
235
+ - ✅ 5 个任务场景:`logs`、`query-db`、`generate-test-token`、`use-commerce-cli`、`read-code`
230
236
  - ✅ 支持 CI、Stage、Prod 三个环境
231
237
  - ✅ CI 环境通过 SSH + Docker 访问
232
238
  - ✅ Stage/Prod 通过 SSH 隧道访问 RDS
233
239
  - ✅ TypeScript CLI 工具:`optima-query-db`、`optima-generate-test-token`
234
240
  - ✅ 通过 Infisical 动态获取密钥
235
241
  - ✅ 自动生成测试 token 并设置 merchant profile
242
+ - ✅ `generate-test-token` 支持 development 和 production 环境
236
243
 
237
244
  **设计原则**:
238
245
  - 命令提供信息(URL、路径、凭证位置),不实现复杂逻辑
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@optima-chat/dev-skills",
3
- "version": "0.6.0",
3
+ "version": "0.7.0",
4
4
  "description": "Claude Code Skills for Optima development team - cross-environment collaboration tools",
5
5
  "main": "index.js",
6
6
  "bin": {
@@ -9,6 +9,9 @@ const SKILLS_SOURCE = path.join(__dirname, '..', '.claude');
9
9
  const COMMANDS_DEST = path.join(CLAUDE_DIR, 'commands');
10
10
  const LOGS_SKILL_DEST = path.join(CLAUDE_DIR, 'skills', 'logs');
11
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');
12
15
 
13
16
  // 颜色输出
14
17
  const colors = {
@@ -71,6 +74,22 @@ function install() {
71
74
  log(`✓ Installed /query-db command`, 'green');
72
75
  }
73
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
+
74
93
  // 安装 logs skill
75
94
  const logsSkillSource = path.join(SKILLS_SOURCE, 'skills', 'logs');
76
95
  if (fs.existsSync(logsSkillSource)) {
@@ -85,13 +104,37 @@ function install() {
85
104
  log(`✓ Installed query-db skill`, 'green');
86
105
  }
87
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');
119
+ }
120
+
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');
126
+ }
127
+
88
128
  log('\n✨ Installation complete!\n', 'green');
89
129
  log('Available commands:', 'blue');
90
130
  log(' /logs <service> [lines] [environment]', 'yellow');
91
131
  log(' /query-db <service> <sql> [environment]', 'yellow');
132
+ log(' /generate-test-token [options]', 'yellow');
133
+ log(' /read-code <repo> [path]', 'yellow');
92
134
  log('\nExamples:', 'blue');
93
135
  log(' /logs commerce-backend # CI logs', 'yellow');
94
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');
95
138
  log('\nDocumentation: https://github.com/Optima-Chat/optima-dev-skills\n', 'blue');
96
139
  }
97
140