yunxiao-code 1.0.10 → 1.1.1

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/README.md CHANGED
@@ -9,6 +9,7 @@
9
9
  - 📤 **推送代码** - 自动推送当前分支到远程
10
10
  - 🔀 **合并请求** - 快速创建 MR,支持指定目标分支
11
11
  - 📊 **代码差异** - 查看分支间的代码差异统计
12
+ - 🤖 **Claude Code 集成** - 支持 Claude Code Skills/Commands 自动化工作流
12
13
 
13
14
  ## 安装
14
15
 
@@ -165,7 +166,7 @@ yx-code mr -m "<title>" [flags]
165
166
  yx-code mr -m "添加用户登录功能"
166
167
 
167
168
  # 指定目标分支
168
- yx-code mr -m "添加用户登录功能" -t main
169
+ yx-code mr -m "添加用户登录功能" -t develop
169
170
 
170
171
  # 带描述
171
172
  yx-code mr -m "添加用户登录功能" -d "实现用户登录、注销功能"
@@ -232,6 +233,38 @@ yx-code mr -m "添加用户登录功能"
232
233
  yx-code diff
233
234
  ```
234
235
 
236
+ ## Claude Code 集成
237
+
238
+ 本工具提供 Claude Code Skills/Commands 支持,可在 Claude Code 中通过斜杠命令自动化云效工作流。
239
+
240
+ ### 可用命令
241
+
242
+ | 命令 | 功能 |
243
+ |------|------|
244
+ | `/yx-commands:commit` | 分析代码变更并提交 |
245
+ | `/yx-commands:push` | 推送代码到远程 |
246
+ | `/yx-commands:mr` | 创建合并请求 |
247
+ | `/yx-commands:review` | 查看分支代码差异 |
248
+ | `/yx-commands:commit-push-mr` | 一键完成提交、推送、创建MR |
249
+
250
+ ### 使用示例
251
+
252
+ 在 Claude Code 中直接输入命令:
253
+
254
+ ```
255
+ /yx-commands:commit-push-mr
256
+ ```
257
+
258
+ Claude 会自动:
259
+ 1. 分析代码变更
260
+ 2. 生成 commit message
261
+ 3. 执行 commit、push
262
+ 4. 创建合并请求
263
+
264
+ ### 安装
265
+
266
+ npm 安装后自动部署到 `~/.claude/commands/yx-commands/` 和 `~/.claude/skills/yx-commands/`。
267
+
235
268
  ## 相关链接
236
269
 
237
270
  - [阿里云云效官方文档](https://help.aliyun.com/zh/yunxiao/)
Binary file
Binary file
Binary file
@@ -0,0 +1,38 @@
1
+ ---
2
+ name: commit-push-mr
3
+ description: 一键完成提交、推送、创建合并请求(完整工作流)
4
+ ---
5
+
6
+ 依次执行 commit、push、mr,完成从代码变更到合并请求的完整工作流。
7
+
8
+ **步骤:**
9
+
10
+ 1. 查看当前变更状态:
11
+ ```bash
12
+ git status && git diff --stat HEAD
13
+ ```
14
+
15
+ 2. 查看完整差异内容:
16
+ ```bash
17
+ git diff HEAD
18
+ ```
19
+
20
+ 3. 分析变更后生成 commit message,执行提交:
21
+ ```bash
22
+ yx-code commit -m "<生成的commit-message>"
23
+ ```
24
+
25
+ 4. 推送到远程:
26
+ ```bash
27
+ yx-code push
28
+ ```
29
+
30
+ 5. 创建合并请求:
31
+ ```bash
32
+ yx-code mr -m "<mr-title>"
33
+ ```
34
+
35
+ **注意:**
36
+ - 如果用户提供了特定的 commit message,则使用用户提供的
37
+ - MR 标题默认使用 commit message
38
+ - 目标分支默认为 develop,可通过参数指定
@@ -0,0 +1,34 @@
1
+ ---
2
+ name: commit
3
+ description: 分析代码变更并提交到云效仓库
4
+ ---
5
+
6
+ 分析当前的代码变更并提交。
7
+
8
+ **步骤:**
9
+
10
+ 1. 一次性获取变更状态和差异概览:
11
+ ```bash
12
+ git status && git diff --stat HEAD
13
+ ```
14
+
15
+ 2. 查看完整差异内容用于分析(包含已暂存和未暂存的所有变更):
16
+ ```bash
17
+ git diff HEAD
18
+ ```
19
+
20
+ 3. 分析变更后,根据变更内容生成合适的 commit message,格式遵循 Conventional Commits:
21
+ - `feat:` 新功能
22
+ - `fix:` 修复 bug
23
+ - `refactor:` 重构
24
+ - `docs:` 文档变更
25
+ - `style:` 代码格式
26
+ - `test:` 测试
27
+ - `chore:` 构建/工具
28
+
29
+ 4. 执行提交:
30
+ ```bash
31
+ yx-code commit -m "<生成的commit-message>"
32
+ ```
33
+
34
+ 如果用户提供了特定的 commit message,则使用用户提供的。
@@ -0,0 +1,78 @@
1
+ ---
2
+ name: mr
3
+ description: 创建云效合并请求(Merge Request)
4
+ ---
5
+
6
+ 创建合并请求到目标分支。
7
+
8
+ **重要:默认目标分支为 develop,执行前需用户确认。**
9
+
10
+ ## 前置条件
11
+
12
+ - 当前分支已推送到远程(如未推送,先执行推送)
13
+ - 工作区干净(无未提交变更)
14
+
15
+ > **注意**:认证信息(organization_id、token)由 CLI 自动获取,无需手动配置。
16
+
17
+ ## 步骤
18
+
19
+ 1. **获取分支状态和提交信息**:
20
+ ```bash
21
+ git branch --show-current && git log --oneline -3
22
+ ```
23
+
24
+ 如果分支未推送到远程,先推送:
25
+ ```bash
26
+ git push -u origin HEAD
27
+ ```
28
+
29
+ 2. **确定 MR 信息**:
30
+ - 标题:优先使用用户提供的标题;如果用户未提供,从最近的 commit message 自动推导
31
+ - 目标分支:**默认为 develop**,除非用户明确指定其他分支
32
+
33
+ 3. **询问用户确认**:
34
+ 使用 AskUserQuestion 询问用户:
35
+ - 问题:"即将创建合并请求到分支 `<target_branch>`,是否继续?"
36
+ - 选项:Yes / No
37
+
38
+ 4. **用户选择 Yes 后创建 MR**:
39
+ ```bash
40
+ yx-code mr -m "<title>" [-d "<description>"] [-t "<target>"]
41
+ ```
42
+
43
+ ## 命令参数
44
+
45
+ ```
46
+ yx-code mr [flags]
47
+
48
+ Flags:
49
+ -m, --message string MR 标题(必填)
50
+ -d, --description string MR 描述(可选)
51
+ -t, --target string 目标分支(默认: develop)
52
+ -h, --help 帮助信息
53
+ ```
54
+
55
+ ## 示例
56
+
57
+ 创建 MR 到默认分支(develop):
58
+ ```bash
59
+ yx-code mr -m "feat: 添加用户登录功能"
60
+ ```
61
+
62
+ 指定目标分支:
63
+ ```bash
64
+ yx-code mr -m "feat: 添加用户登录功能" -t main
65
+ ```
66
+
67
+ 带描述创建:
68
+ ```bash
69
+ yx-code mr -m "feat: 添加用户登录功能" -d "实现了登录、登出功能,包含单元测试" -t develop
70
+ ```
71
+
72
+ ## 创建后
73
+
74
+ 创建成功后会返回:
75
+ - 合并请求 ID
76
+ - 合并请求 URL 链接
77
+
78
+ 用户可在浏览器中访问链接进行代码审查和合并操作。
@@ -0,0 +1,30 @@
1
+ ---
2
+ name: push
3
+ description: 推送代码到云效远程仓库
4
+ ---
5
+
6
+ 推送代码到远程仓库。
7
+
8
+ **重要:执行前需用户确认。**
9
+
10
+ ## 步骤
11
+
12
+ 1. **获取当前分支信息**:
13
+ ```bash
14
+ git branch --show-current
15
+ ```
16
+
17
+ 2. **询问用户确认**:
18
+ 使用 AskUserQuestion 询问用户:
19
+ - 问题:"即将推送代码到远程仓库,是否继续?"
20
+ - 选项:Yes / No
21
+
22
+ 3. **用户选择 Yes 后执行推送**:
23
+ ```bash
24
+ yx-code push
25
+ ```
26
+
27
+ 4. **如果推送失败且提示无上游分支**,自动设置上游并重试:
28
+ ```bash
29
+ yx-code push -u origin HEAD
30
+ ```
@@ -0,0 +1,163 @@
1
+ ---
2
+ allowed-tools: Bash(yx-code diff:*), Bash(yx-code --help:*), Bash(git branch:*), Bash(git remote:*), Bash(git log:*), Bash(git show:*), Bash(git blame:*), Read, Grep, Glob
3
+ description: 查看分支代码差异并进行代码审查
4
+ disable-model-invocation: false
5
+ ---
6
+
7
+ ## Context
8
+
9
+ - Current branch: !`git branch --show-current`
10
+ - Remote: !`git remote -v`
11
+ - Recent commits: !`git log --oneline -5`
12
+
13
+ ## Your task
14
+
15
+ 对当前分支与目标分支之间的代码差异进行全面的代码审查。
16
+
17
+ ### 步骤 1: 获取代码差异
18
+
19
+ 首先使用 yx-code 命令获取差异:
20
+
21
+ ```bash
22
+ yx-code diff --target <target> --source <source>
23
+ ```
24
+
25
+ ### 步骤 2: 收集上下文信息
26
+
27
+ 使用 Haiku agent 收集以下信息:
28
+
29
+ 1. **获取 CLAUDE.md 文件列表**:查找项目根目录及变更文件所在目录的 CLAUDE.md 文件
30
+ 2. **获取变更摘要**:分析差异内容,返回变更的简要总结
31
+ 3. **检查审查资格**:确认分支是否需要进行代码审查(排除已关闭、草稿、自动生成等)
32
+
33
+ ### 步骤 3: 并行代码审查
34
+
35
+ 启动 5 个并行的 Sonnet agent 独立进行代码审查:
36
+
37
+ **Agent #1: CLAUDE.md 合规审查**
38
+ - 检查变更是否遵循项目 CLAUDE.md 中的规范
39
+ - 注意 CLAUDE.md 是 Claude 编写代码的指南,审查时不一定所有条款都适用
40
+ - 返回问题列表及原因(CLAUDE.md 合规性)
41
+
42
+ **Agent #2: Bug 浅层扫描**
43
+ - 专注于变更本身,不额外读取上下文
44
+ - 关注明显的 Bug,避免小问题和吹毛求疵
45
+ - 忽略可能的误报
46
+ - 返回问题列表及原因(潜在 Bug)
47
+
48
+ **Agent #3: 历史上下文审查**
49
+ - 读取被修改代码的 git blame 和历史
50
+ - 基于历史上下文识别潜在问题
51
+ - 返回问题列表及原因(历史上下文)
52
+
53
+ **Agent #4: 相关 MR 审查**
54
+ - 查找之前修改过这些文件的 MR
55
+ - 检查之前 MR 的评论是否适用于当前变更
56
+ - 返回问题列表及原因(历史 MR 上下文)
57
+
58
+ **Agent #5: 代码注释合规审查**
59
+ - 读取被修改文件中的代码注释
60
+ - 确保变更遵循注释中的指导
61
+ - 返回问题列表及原因(代码注释合规性)
62
+
63
+ ### 步骤 4: 问题置信度评分
64
+
65
+ 对步骤 3 发现的每个问题,启动并行 Haiku agent 进行置信度评分:
66
+
67
+ **评分标准(0-100 分)**:
68
+
69
+ | 分数 | 含义 |
70
+ |-----|------|
71
+ | 0 | 完全不确信。这是经不起推敲的误报,或是已存在的问题 |
72
+ | 25 | 有些确信。可能是真正的问题,但也可能是误报。如果是风格问题,相关 CLAUDE.md 中未明确指出 |
73
+ | 50 | 中等确信。验证了这是真正的问题,但可能只是小问题或不常发生。相对于整个 MR,不太重要 |
74
+ | 75 | 高度确信。验证了这是很可能在现实中发生的真正问题。当前方案不充分。问题很重要,直接影响功能,或在 CLAUDE.md 中明确提及 |
75
+ | 100 | 绝对确定。验证了这是肯定会在现实中频繁发生的真正问题。证据直接确认 |
76
+
77
+ ### 步骤 5: 过滤并输出结果
78
+
79
+ 1. **过滤问题**:仅保留评分 >= 80 的问题
80
+ 2. **重新检查资格**:确认分支仍符合审查条件
81
+ 3. **输出审查报告**
82
+
83
+ ### 使用方式
84
+
85
+ ```
86
+ /yx-commands:review [-t target] [-s source]
87
+ ```
88
+
89
+ 参数:
90
+ - `-t, --target`: 目标分支(默认: develop)
91
+ - `-s, --source`: 源分支(默认: 当前分支)
92
+
93
+ ### 示例
94
+
95
+ 查看与 develop 的差异:
96
+ ```
97
+ /yx-commands:review
98
+ ```
99
+
100
+ 查看 feature 分支与 main 的差异:
101
+ ```
102
+ /yx-commands:review -t main -s feature-branch
103
+ ```
104
+
105
+ ### 输出格式
106
+
107
+ 如果发现问题:
108
+
109
+ ---
110
+ ### MR Code Review
111
+
112
+ 发现 N 个问题:
113
+
114
+ 1. **<问题简要描述>** (CLAUDE.md 规定: "<相关条款>")
115
+
116
+ <文件链接,包含完整 sha1 和行范围>
117
+
118
+ 2. **<问题简要描述>** (<其他原因>)
119
+
120
+ <文件链接>
121
+
122
+ ---
123
+
124
+ 如果没有发现问题:
125
+
126
+ ---
127
+ ### MR Code Review
128
+
129
+ 未发现问题。已检查 Bug 和 CLAUDE.md 合规性。
130
+
131
+ ---
132
+
133
+ ### 链接格式要求
134
+
135
+ 链接到代码时使用以下格式:
136
+ ```
137
+ https://<云效域名>/<项目路径>/blob/<完整sha1>/<文件路径>#L<起始行>-L<结束行>
138
+ ```
139
+
140
+ 要求:
141
+ - 必须使用完整的 git sha(不能用 HEAD 等引用)
142
+ - 文件名后使用 # 符号
143
+ - 行范围格式: L[起始]-L[结束]
144
+ - 至少包含上下文各 1 行(如评论第 5-6 行,应链接 L4-L7)
145
+
146
+ ### 误报示例(审查时排除)
147
+
148
+ - 已存在的问题(非本次变更引入)
149
+ - 看起来像 Bug 但实际不是
150
+ - 资深工程师不会提出的吹毛求疵
151
+ - Linter/TypeChecker/Compiler 会捕获的问题(导入、类型错误、格式问题)
152
+ - 一般代码质量问题(测试覆盖、一般安全问题、文档)
153
+ - CLAUDE.md 中提及但代码中明确静默的问题(如 lint ignore 注释)
154
+ - 可能是有意的功能性变更
155
+ - 真正的问题但不在用户修改的行上
156
+
157
+ ### 注意事项
158
+
159
+ - 需要在 git 仓库目录中运行
160
+ - 目标分支需要存在于远程
161
+ - 不检查构建信号,不尝试构建或类型检查
162
+ - 大量变更时输出可能较长
163
+ - 对于复杂文件,优先使用 yx-code diff 获取准确差异
@@ -0,0 +1,59 @@
1
+ ---
2
+ name: yx-commands
3
+ description: 阿里云云效(codeup)代码仓库工作流自动化。功能包括:智能提交代码、推送、创建MR(合并请求)、代码审查、分支差异对比。触发场景:用户提到云效、codeup、阿里云代码仓库、yx-code工具;git地址以git@codeup.aliyun.com开头;需要提交代码并创建MR;说"提交合并"触发完整工作流。注意:github相关操作或纯git命令不要使用此技能。
4
+ tools: Bash, Read
5
+ ---
6
+
7
+ # 云效代码仓库工作流
8
+
9
+ 帮助用户在阿里云云效代码仓库平台进行开发工作流自动化。
10
+
11
+ > **认证信息由 CLI 自动获取**,无需手动配置 organization_id 和 token。
12
+
13
+ ## 何时使用
14
+
15
+ 当用户涉及以下场景时,主动使用此 skill:
16
+
17
+ 1. **云效平台相关** - 提到云效、阿里云代码仓库、codeup、阿里云 DevOps、合并请求、MR、代码审查
18
+ 2. **Git 操作** - 提交、推送
19
+ 3. **yx-code 工具** - 提到云效 CLI
20
+ 4. **复合工作流** - 用户说"提交合并"、"提交并合并"、"提交MR"时,按顺序执行:
21
+ - 先执行 `/yx-commands:commit` 提交代码
22
+ - 再执行 `/yx-commands:push` 推送到远程
23
+ - 然后执行 `/yx-commands:mr` 创建合并请求
24
+
25
+ ## 可用命令
26
+
27
+ | 命令 | 功能 | 典型用法 |
28
+ |------|------|----------|
29
+ | `/yx-commands:commit` | 智能提交 | 分析变更生成 commit |
30
+ | `/yx-commands:push` | 推送代码 | 推送到远程 |
31
+ | `/yx-commands:mr` | 创建 MR | 提交合并请求(默认 develop) |
32
+ | `/yx-commands:review` | 代码审查 | 查看分支差异 |
33
+ | `/yx-commands:commit-push-mr` | 完整工作流 | 一键完成提交、推送、创建MR |
34
+
35
+ ## 典型工作流
36
+
37
+ ### 一键完成(推荐)
38
+ ```
39
+ 1. 编写代码...
40
+ 2. /yx-commands:commit-push-mr → 一键完成提交、推送、创建MR
41
+ ```
42
+
43
+ ### 分步执行
44
+ ```
45
+ 1. 编写代码...
46
+ 2. /yx-commands:commit → 智能生成 commit message 并提交
47
+ 3. /yx-commands:push → 推送到远程
48
+ 4. /yx-commands:mr → 创建合并请求
49
+ ```
50
+
51
+ ### 代码审查
52
+ ```
53
+ /yx-commands:review -t develop -s feature-branch
54
+ ```
55
+
56
+ ## 前置条件
57
+
58
+ - 已安装 `yx-code` CLI 工具
59
+ - `yx-code` 在系统 PATH 中可用
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "yunxiao-code",
3
- "version": "1.0.10",
3
+ "version": "1.1.1",
4
4
  "description": "阿里云云效 CLI 工具",
5
5
  "keywords": [
6
6
  "aliyun",
@@ -19,7 +19,8 @@
19
19
  },
20
20
  "files": [
21
21
  "bin",
22
- "scripts"
22
+ "scripts",
23
+ "claude-plugin"
23
24
  ],
24
25
  "license": "MIT",
25
26
  "engines": {
@@ -1,5 +1,67 @@
1
1
  #!/usr/bin/env node
2
2
 
3
+ const fs = require('fs');
4
+ const path = require('path');
5
+ const os = require('os');
6
+
7
+ function removeExisting(target) {
8
+ try {
9
+ const stat = fs.lstatSync(target);
10
+ if (stat.isSymbolicLink()) {
11
+ fs.unlinkSync(target);
12
+ } else if (stat.isDirectory()) {
13
+ fs.rmSync(target, { recursive: true });
14
+ } else {
15
+ fs.unlinkSync(target);
16
+ }
17
+ return true;
18
+ } catch (e) {
19
+ if (e.code === 'ENOENT') return true;
20
+ return false;
21
+ }
22
+ }
23
+
24
+ function deployPlugin() {
25
+ const claudeDir = path.join(os.homedir(), '.claude');
26
+ const commandsDir = path.join(claudeDir, 'commands');
27
+ const skillsDir = path.join(claudeDir, 'skills');
28
+
29
+ // 获取 npm 包路径
30
+ const packageDir = path.dirname(require.main.filename);
31
+ const pluginDir = path.join(packageDir, '..', 'claude-plugin');
32
+
33
+ // 确保目标目录存在
34
+ if (!fs.existsSync(commandsDir)) {
35
+ fs.mkdirSync(commandsDir, { recursive: true });
36
+ }
37
+ if (!fs.existsSync(skillsDir)) {
38
+ fs.mkdirSync(skillsDir, { recursive: true });
39
+ }
40
+
41
+ const commandsTarget = path.join(commandsDir, 'yx-commands');
42
+ const skillsTarget = path.join(skillsDir, 'yx-commands');
43
+ const commandsSource = path.join(pluginDir, 'commands');
44
+ const skillsSource = path.join(pluginDir, 'skills');
45
+
46
+ // 创建/更新 commands 软链接
47
+ if (fs.existsSync(commandsSource)) {
48
+ if (removeExisting(commandsTarget)) {
49
+ fs.symlinkSync(commandsSource, commandsTarget);
50
+ console.log('✅ 已链接 commands 到 ~/.claude/commands/yx-commands/');
51
+ }
52
+ }
53
+
54
+ // 创建/更新 skills 软链接
55
+ if (fs.existsSync(skillsSource)) {
56
+ if (removeExisting(skillsTarget)) {
57
+ fs.symlinkSync(skillsSource, skillsTarget);
58
+ console.log('✅ 已链接 skills 到 ~/.claude/skills/yx-commands/');
59
+ }
60
+ }
61
+
62
+ console.log('\n可用命令: /yx-commands:commit, /yx-commands:push, /yx-commands:mr, /yx-commands:review\n');
63
+ }
64
+
3
65
  console.log('\n✅ yx-code CLI installed successfully!\n');
4
66
  console.log('Usage:');
5
67
  console.log(' yx-code init - 初始化云效配置');
@@ -7,4 +69,10 @@ console.log(' yx-code clone - 克隆仓库');
7
69
  console.log(' yx-code commit - 提交代码');
8
70
  console.log(' yx-code push - 推送代码');
9
71
  console.log(' yx-code mr - 创建合并请求');
10
- console.log(' yx-code review - 代码审查\n');
72
+ console.log(' yx-code diff - 查看代码差异\n');
73
+
74
+ try {
75
+ deployPlugin();
76
+ } catch (err) {
77
+ console.log('⚠️ 部署失败:', err.message, '\n');
78
+ }