yunxiao-code 1.0.0 → 1.0.2

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
@@ -1,4 +1,4 @@
1
- # yunxiao-code
1
+ # yx-code
2
2
 
3
3
  阿里云云效 CLI 工具,支持 Git 提交、推送、克隆及创建合并请求。
4
4
 
@@ -7,16 +7,16 @@
7
7
  ### npm 安装(推荐)
8
8
 
9
9
  ```bash
10
- npm install -g yunxiao-code
10
+ npm install -g yx-code
11
11
  ```
12
12
 
13
13
  ### 从源码编译
14
14
 
15
15
  ```bash
16
16
  git clone <repo-url>
17
- cd yunxiao-code
18
- go build -o yunxiao-code .
19
- sudo mv yunxiao-code /usr/local/bin/
17
+ cd yx-code
18
+ go build -o yx-code .
19
+ sudo mv yx-code /usr/local/bin/
20
20
  ```
21
21
 
22
22
  ## 配置
@@ -26,7 +26,7 @@ sudo mv yunxiao-code /usr/local/bin/
26
26
  在你的项目目录下运行:
27
27
 
28
28
  ```bash
29
- yunxiao-code init
29
+ yx-code init
30
30
  ```
31
31
 
32
32
  会在当前目录生成 `.yunxiao.yaml`:
@@ -71,7 +71,7 @@ export YUNXIAO_TOKEN="your-token"
71
71
  ### 克隆仓库并创建新分支
72
72
 
73
73
  ```bash
74
- yunxiao-code clone <git-url> -b <分支名>
74
+ yx-code clone <git-url> -b <分支名>
75
75
  ```
76
76
 
77
77
  自动检测主分支(main/master),从主分支拉出新分支。
@@ -82,7 +82,7 @@ yunxiao-code clone <git-url> -b <分支名>
82
82
  ### 提交代码
83
83
 
84
84
  ```bash
85
- yunxiao-code commit -m "提交信息"
85
+ yx-code commit -m "提交信息"
86
86
  ```
87
87
 
88
88
  执行 `git add .` 并提交。
@@ -90,7 +90,7 @@ yunxiao-code commit -m "提交信息"
90
90
  ### 推送到远程
91
91
 
92
92
  ```bash
93
- yunxiao-code push
93
+ yx-code push
94
94
  ```
95
95
 
96
96
  推送当前分支到远程仓库。
@@ -98,7 +98,7 @@ yunxiao-code push
98
98
  ### 创建合并请求
99
99
 
100
100
  ```bash
101
- yunxiao-code mr -m "MR 标题"
101
+ yx-code mr -m "MR 标题"
102
102
  ```
103
103
 
104
104
  向云效创建合并请求,目标分支为 `develop`。
@@ -111,5 +111,5 @@ yunxiao-code mr -m "MR 标题"
111
111
  所有子命令支持以下参数,用于覆盖配置文件:
112
112
 
113
113
  ```bash
114
- yunxiao-code <command> --domain <域名> --org <组织ID> --token <令牌>
114
+ yx-code <command> --domain <域名> --org <组织ID> --token <令牌>
115
115
  ```
Binary file
@@ -8,11 +8,11 @@ const arch = os.arch();
8
8
 
9
9
  let binary;
10
10
  if (platform === 'darwin' && arch === 'arm64') {
11
- binary = 'yunxiao-code-darwin-arm64';
11
+ binary = 'yx-code-darwin-arm64';
12
12
  } else if (platform === 'darwin' && arch === 'x64') {
13
- binary = 'yunxiao-code-darwin-amd64';
13
+ binary = 'yx-code-darwin-amd64';
14
14
  } else if (platform === 'linux' && arch === 'x64') {
15
- binary = 'yunxiao-code-linux-amd64';
15
+ binary = 'yx-code-linux-amd64';
16
16
  } else {
17
17
  console.error(`Unsupported platform: ${platform}/${arch}`);
18
18
  process.exit(1);
package/package.json CHANGED
@@ -1,12 +1,17 @@
1
1
  {
2
2
  "name": "yunxiao-code",
3
- "version": "1.0.0",
3
+ "version": "1.0.2",
4
4
  "description": "阿里云云效 CLI 工具",
5
5
  "bin": {
6
- "yunxiao-code": "./bin/yunxiao-code.js"
6
+ "yunxiao-code": "./bin/yx-code.js"
7
+ },
8
+ "scripts": {
9
+ "postinstall": "node scripts/postinstall.js"
7
10
  },
8
11
  "files": [
9
- "bin"
12
+ "bin",
13
+ "scripts",
14
+ "skills"
10
15
  ],
11
16
  "license": "MIT",
12
17
  "engines": {
@@ -0,0 +1,77 @@
1
+ #!/usr/bin/env node
2
+
3
+ const fs = require('fs');
4
+ const path = require('path');
5
+ const os = require('os');
6
+
7
+ const CLAUDE_DIR = path.join(os.homedir(), '.claude');
8
+ const COMMANDS_DIR = path.join(CLAUDE_DIR, 'commands', 'yx-commands');
9
+ const SKILLS_DIR = path.join(CLAUDE_DIR, 'skills', 'yx-workflow');
10
+
11
+ // 获取 npm 包安装目录
12
+ const packageDir = path.resolve(__dirname, '..');
13
+ const skillsSourceDir = path.join(packageDir, 'skills');
14
+
15
+ console.log('\n🔧 Installing yunxiao-code Claude Code integration...\n');
16
+
17
+ // 确保目录存在
18
+ function ensureDir(dir) {
19
+ if (!fs.existsSync(dir)) {
20
+ fs.mkdirSync(dir, { recursive: true });
21
+ console.log(` ✓ Created directory: ${dir}`);
22
+ }
23
+ }
24
+
25
+ // 复制目录
26
+ function copyDir(src, dest) {
27
+ ensureDir(path.dirname(dest));
28
+
29
+ if (fs.existsSync(dest)) {
30
+ fs.rmSync(dest, { recursive: true });
31
+ }
32
+
33
+ fs.cpSync(src, dest, { recursive: true });
34
+ console.log(` ✓ Installed: ${dest}`);
35
+ }
36
+
37
+ // 安装命令
38
+ function installCommands() {
39
+ const commandsSource = path.join(skillsSourceDir, 'yx-commands');
40
+
41
+ if (fs.existsSync(commandsSource)) {
42
+ copyDir(commandsSource, COMMANDS_DIR);
43
+ console.log(` 📦 Commands installed to ~/.claude/commands/yx-commands/`);
44
+ }
45
+ }
46
+
47
+ // 安装 skills
48
+ function installSkills() {
49
+ const skillSource = path.join(skillsSourceDir, 'skills', 'yx-workflow');
50
+
51
+ if (fs.existsSync(skillSource)) {
52
+ copyDir(skillSource, SKILLS_DIR);
53
+ console.log(` 📦 Skill installed to ~/.claude/skills/yx-workflow/`);
54
+ }
55
+ }
56
+
57
+ // 主流程
58
+ try {
59
+ ensureDir(CLAUDE_DIR);
60
+ ensureDir(path.join(CLAUDE_DIR, 'commands'));
61
+ ensureDir(path.join(CLAUDE_DIR, 'skills'));
62
+
63
+ installCommands();
64
+ installSkills();
65
+
66
+ console.log('\n✅ yunxiao-code Claude Code integration installed successfully!\n');
67
+ console.log('Available commands:');
68
+ console.log(' /yx-commands:init - 初始化云效配置');
69
+ console.log(' /yx-commands:clone - 克隆仓库');
70
+ console.log(' /yx-commands:commit - 提交代码');
71
+ console.log(' /yx-commands:push - 推送代码');
72
+ console.log(' /yx-commands:mr - 创建合并请求');
73
+ console.log('\nRun /reload-plugins or restart Claude Code to activate.\n');
74
+ } catch (error) {
75
+ console.error('❌ Installation failed:', error.message);
76
+ process.exit(1);
77
+ }
@@ -0,0 +1,10 @@
1
+ {
2
+ "name": "yunxiao-code",
3
+ "description": "云效代码仓库工作流自动化 - 初始化配置、克隆仓库、提交代码、推送、创建合并请求",
4
+ "author": {
5
+ "name": "yunxiao-code"
6
+ },
7
+ "skills": {
8
+ "yx-workflow": "skills/yx-workflow/SKILL.md"
9
+ }
10
+ }
@@ -0,0 +1,100 @@
1
+ # Yunxiao Code - Claude Code Plugin
2
+
3
+ 云效代码仓库工作流自动化插件,为 Claude Code 提供云效相关命令支持。
4
+
5
+ ## 安装
6
+
7
+ ```bash
8
+ npm install -g yunxiao-code
9
+ ```
10
+
11
+ 安装完成后,会自动:
12
+ 1. 安装 `yunxiao-code` CLI 工具到系统 PATH
13
+ 2. 安装 Claude Code 命令到 `~/.claude/commands/yx-commands/`
14
+ 3. 安装 Claude Code 技能到 `~/.claude/skills/yx-workflow/`
15
+
16
+ 重启 Claude Code 或执行 `/reload-plugins` 后即可使用。
17
+
18
+ ## 可用命令
19
+
20
+ | 命令 | 功能 | 示例 |
21
+ |------|------|------|
22
+ | `/yx-commands:init` | 初始化云效配置 | `/yx-commands:init` |
23
+ | `/yx-commands:clone` | 克隆仓库 | `/yx-commands:clone <git-url>` |
24
+ | `/yx-commands:commit` | 提交代码 | `/yx-commands:commit` |
25
+ | `/yx-commands:push` | 推送代码 | `/yx-commands:push` |
26
+ | `/yx-commands:mr` | 创建合并请求 | `/yx-commands:mr <title>` |
27
+
28
+ ## 使用指南
29
+
30
+ ### 1. 初始化配置
31
+
32
+ 首次使用需要配置云效凭证:
33
+
34
+ ```
35
+ /yx-commands:init
36
+ ```
37
+
38
+ 按提示填写:
39
+ - `organization_id`: 云效组织 ID
40
+ - `token`: 云效个人访问令牌
41
+
42
+ ### 2. 克隆仓库
43
+
44
+ 克隆云效代码仓库:
45
+
46
+ ```
47
+ /yx-commands:clone https://codeup.aliyun.com/your-org/your-repo.git
48
+ ```
49
+
50
+ ### 3. 提交代码
51
+
52
+ 自动分析变更并提交:
53
+
54
+ ```
55
+ /yx-commands:commit
56
+ ```
57
+
58
+ ### 4. 推送代码
59
+
60
+ 推送当前分支到远程:
61
+
62
+ ```
63
+ /yx-commands:push
64
+ ```
65
+
66
+ ### 5. 创建合并请求
67
+
68
+ 创建 MR 到 develop 分支:
69
+
70
+ ```
71
+ /yx-commands:mr "添加用户登录功能"
72
+ ```
73
+
74
+ ## 技能触发
75
+
76
+ 当对话中出现以下关键词时,`yx-workflow` 技能会自动激活:
77
+
78
+ - 云效
79
+ - 合并请求
80
+ - MR
81
+ - yx-code
82
+ - 阿里云代码仓库
83
+
84
+ ## 手动安装(可选)
85
+
86
+ 如果需要手动安装命令和技能:
87
+
88
+ ```bash
89
+ # 安装命令
90
+ mkdir -p ~/.claude/commands/yx-commands
91
+ cp -r skills/yx-commands/*.md ~/.claude/commands/yx-commands/
92
+
93
+ # 安装技能
94
+ mkdir -p ~/.claude/skills/yx-workflow
95
+ cp -r skills/skills/yx-workflow ~/.claude/skills/
96
+ ```
97
+
98
+ ## 许可证
99
+
100
+ MIT License
@@ -0,0 +1,65 @@
1
+ ---
2
+ name: yx-workflow
3
+ description: 云效代码仓库工作流自动化助手
4
+ triggers:
5
+ - 云效
6
+ - 合并请求
7
+ - MR
8
+ - yx-code
9
+ - 阿里云代码仓库
10
+ - 阿里云云效
11
+ ---
12
+
13
+ # 云效代码仓库工作流
14
+
15
+ 我是一个帮助你在云效代码仓库进行开发的助手。我可以帮助你:
16
+
17
+ ## 可用命令
18
+
19
+ | 命令 | 功能 | 用法 |
20
+ |------|------|------|
21
+ | `/yx-init` | 初始化云效配置 | 直接运行,配置 token |
22
+ | `/yx-clone` | 克隆仓库 | `/yx-clone <git-url> [-b branch] [-p path]` |
23
+ | `/yx-commit` | 提交代码 | 自动分析变更生成 commit message |
24
+ | `/yx-push` | 推送代码 | 推送当前分支到远程 |
25
+ | `/yx-mr` | 创建合并请求 | `/yx-mr <title> [-d description]` |
26
+
27
+ ## 典型工作流
28
+
29
+ 1. **初始化配置**
30
+ ```
31
+ /yx-init
32
+ ```
33
+ 首次使用需要配置云效的 organization_id 和 token。
34
+
35
+ 2. **克隆仓库**
36
+ ```
37
+ /yx-clone https://codeup.aliyun.com/xxx/xxx.git
38
+ ```
39
+
40
+ 3. **提交代码**
41
+ ```
42
+ /yx-commit
43
+ ```
44
+ 会自动分析变更并生成合适的 commit message。
45
+
46
+ 4. **推送代码**
47
+ ```
48
+ /yx-push
49
+ ```
50
+
51
+ 5. **创建合并请求**
52
+ ```
53
+ /yx-mr "添加新功能"
54
+ ```
55
+
56
+ ## 注意事项
57
+
58
+ - 确保已安装 `yx-code` CLI 工具
59
+ - 确保 `yx-code` 在系统 PATH 中可用
60
+ - MR 默认合并到 develop 分支
61
+
62
+ ## 相关链接
63
+
64
+ - [云效控制台](https://devops.aliyun.com/)
65
+ - [云效文档](https://help.aliyun.com/product/153293.html)
@@ -0,0 +1,18 @@
1
+ ---
2
+ name: clone
3
+ description: 克隆云效代码仓库
4
+ ---
5
+
6
+ 根据用户提供的参数执行克隆操作。
7
+
8
+ **参数说明:**
9
+ - 第一个参数是云效仓库的 Git URL(必填)
10
+ - `-b` 参数指定分支名(可选)
11
+ - `-p` 参数指定本地路径(可选)
12
+
13
+ 如果用户没有提供 git-url,请询问用户提供仓库地址。
14
+
15
+ 执行命令示例:
16
+ ```bash
17
+ yx-code clone <git-url> [-b <branch>] [-p <path>]
18
+ ```
@@ -0,0 +1,44 @@
1
+ ---
2
+ name: commit
3
+ description: 分析代码变更并提交到云效仓库
4
+ ---
5
+
6
+ 分析当前的代码变更并提交。
7
+
8
+ **步骤:**
9
+
10
+ 1. 首先查看当前变更状态:
11
+ ```bash
12
+ git status
13
+ ```
14
+
15
+ 2. 查看变更统计:
16
+ ```bash
17
+ git diff --stat
18
+ ```
19
+
20
+ 3. 如果有暂存的变更,查看具体内容:
21
+ ```bash
22
+ git diff --cached
23
+ ```
24
+
25
+ 4. 如果没有暂存的变更但有未暂存的变更,查看:
26
+ ```bash
27
+ git diff
28
+ ```
29
+
30
+ 5. 分析变更后,根据变更内容生成合适的 commit message,格式遵循 Conventional Commits:
31
+ - `feat:` 新功能
32
+ - `fix:` 修复 bug
33
+ - `refactor:` 重构
34
+ - `docs:` 文档变更
35
+ - `style:` 代码格式
36
+ - `test:` 测试
37
+ - `chore:` 构建/工具
38
+
39
+ 6. 执行提交:
40
+ ```bash
41
+ yx-code commit -m "<生成的commit-message>"
42
+ ```
43
+
44
+ 如果用户提供了特定的 commit message,则使用用户提供的。
@@ -0,0 +1,20 @@
1
+ ---
2
+ name: init
3
+ description: 初始化云效配置文件
4
+ ---
5
+
6
+ 请执行以下命令初始化云效配置:
7
+
8
+ ```bash
9
+ yx-code init
10
+ ```
11
+
12
+ 执行后,配置文件将创建在 `~/.yunxiao-code/config.json`。
13
+
14
+ 你需要填写以下信息:
15
+ - `organization_id`: 云效组织 ID
16
+ - `token`: 云效个人访问令牌
17
+
18
+ 获取方式:
19
+ 1. organization_id: 在云效控制台 URL 中可以找到,格式如 `https://devops.aliyun.com/organization/{organization_id}/...`
20
+ 2. token: 在云效控制台 -> 个人设置 -> 个人访问令牌 中创建
@@ -0,0 +1,25 @@
1
+ ---
2
+ name: mr
3
+ description: 创建云效合并请求(Merge Request)
4
+ ---
5
+
6
+ 创建合并请求到 develop 分支。
7
+
8
+ **步骤:**
9
+
10
+ 1. 首先显示当前分支和仓库信息:
11
+ ```bash
12
+ git branch --show-current
13
+ git remote -v | head -1
14
+ ```
15
+
16
+ 2. 获取合并请求标题(必填)和描述(可选)
17
+ - 如果用户没有提供标题,请询问用户提供合并请求的标题
18
+ - 描述是可选的,用户可以补充详细说明
19
+
20
+ 3. 执行创建 MR:
21
+ ```bash
22
+ yx-code mr -m "<title>" [-d "<description>"]
23
+ ```
24
+
25
+ 创建成功后,会返回合并请求的 URL 链接,用户可以在浏览器中查看。
@@ -0,0 +1,20 @@
1
+ ---
2
+ name: push
3
+ description: 推送代码到云效远程仓库
4
+ ---
5
+
6
+ 推送代码到远程仓库。
7
+
8
+ **步骤:**
9
+
10
+ 1. 首先显示当前分支信息:
11
+ ```bash
12
+ git branch --show-current
13
+ ```
14
+
15
+ 2. 执行推送:
16
+ ```bash
17
+ yx-code push
18
+ ```
19
+
20
+ 如果推送失败,可能需要先设置上游分支。在这种情况下,提示用户是否需要设置上游分支并重试。