runcc 0.1.2 → 0.1.3

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,135 @@
1
+ ---
2
+ name: publish
3
+ description: 自动化 npm 包发布准备工作流。版本升级 → 测试 → 构建 → CHANGELOG → 提交 → 打印发布命令(用户手动执行 npm publish)。触发词:发布新版本/publish to npm/bump version/release。
4
+ ---
5
+
6
+ # NPM 发布工作流
7
+
8
+ 版本升级 → 测试 → 构建 → CHANGELOG → Git 提交 → 可选推送 → 打印发布命令
9
+
10
+ ## 工作流程
11
+
12
+ ### 1. 询问目标版本
13
+
14
+ 使用 `AskUserQuestion` 询问用户要升级到什么版本:
15
+
16
+ | 类型 | 说明 | 示例 |
17
+ |------|------|------|
18
+ | patch | 错误修复、小改动 | 1.0.0 → 1.0.1 |
19
+ | minor | 新功能、向后兼容 | 1.0.0 → 1.1.0 |
20
+ | major | 破坏性更改 | 1.0.0 → 2.0.0 |
21
+ | custom | 指定确切版本号 | 1.0.0 → 1.2.3 |
22
+
23
+ ### 2. 修改 npm 版本
24
+
25
+ ```bash
26
+ npm version <patch|minor|major|x.y.z>
27
+ ```
28
+
29
+ 此命令会:
30
+ - 更新 package.json 和 package-lock.json 版本号
31
+ - 创建 git 提交(消息格式:`v<x.y.z>`)
32
+ - 创建 git 标签(`v<x.y.z>`)
33
+
34
+ ### 3. 运行测试
35
+
36
+ ```bash
37
+ bun run test
38
+ ```
39
+
40
+ - 如果 package.json 有 test 脚本,执行测试
41
+ - 测试失败则中止流程,提示用户修复
42
+ - 无 test 脚本则跳过
43
+
44
+ ### 4. 打包编译
45
+
46
+ ```bash
47
+ bun run build
48
+ ```
49
+
50
+ - 如果 package.json 有 build 脚本,执行构建
51
+ - 构建失败则中止流程,提示用户修复
52
+ - 无 build 脚本则跳过
53
+
54
+ ### 5. 创建 CHANGELOG
55
+
56
+ #### 存在 CHANGELOG.md 时
57
+
58
+ ```bash
59
+ # 查看自上次发布的提交
60
+ git log $(git tag -l | tail -n 1)..HEAD --oneline
61
+ ```
62
+
63
+ **生成条目**:
64
+ - 格式:`## [<版本号>] - YYYY-MM-DD`
65
+ - 按类型分组:新功能、错误修复、破坏性更改
66
+
67
+ **审核流程**:
68
+ 1. 显示生成的变更日志
69
+ 2. 使用 `AskUserQuestion` 确认或修改
70
+ 3. 更新 CHANGELOG.md
71
+
72
+ #### 不存在 CHANGELOG.md 时
73
+
74
+ 询问用户是否创建。
75
+
76
+ ### 6. 提交 git
77
+
78
+ ```bash
79
+ git add CHANGELOG.md
80
+ git commit -m "docs: update CHANGELOG for <版本号>"
81
+ ```
82
+
83
+ ### 7. 询问是否 git push
84
+
85
+ 使用 `AskUserQuestion` 询问是否推送:
86
+
87
+ ```
88
+ 是否推送到远程仓库?
89
+ ```
90
+
91
+ 用户确认后执行:
92
+ ```bash
93
+ git push && git push --tags
94
+ ```
95
+
96
+ ### 8. 打印 npm publish 命令
97
+
98
+ 显示发布命令,要求用户复制手动执行:
99
+
100
+ ```
101
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
102
+ 📦 准备发布: <package-name>@<new-version>
103
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
104
+
105
+ 请复制以下命令并执行:
106
+
107
+ npm publish
108
+
109
+ (如需公共作用域包,使用: npm publish --access public)
110
+
111
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
112
+ ```
113
+
114
+ ### 发布摘要
115
+
116
+ ```
117
+ ✅ 准备工作完成
118
+
119
+ - 包名: <package-name>
120
+ - 新版本: <new-version>
121
+ - Git 标签: v<new-version>
122
+ - CHANGELOG: 已更新
123
+
124
+ 请执行上方 npm publish 命令完成发布。
125
+ ```
126
+
127
+ ## 最佳实践
128
+
129
+ - 发布前运行测试
130
+ - 保持 CHANGELOG.md 最新
131
+ - 遵循语义化版本规范
132
+ - 确认前审查更改
133
+ - 始终先提交再发布
134
+ - 为发布打标签
135
+ - 清楚标注破坏性更改
package/CHANGELOG.md CHANGED
@@ -5,6 +5,13 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [0.1.3] - 2026-01-19
9
+
10
+ ### Changed
11
+ - Renamed `npm-publish` skill to `publish` for consistency
12
+ - Removed deprecated `PLAN.md` file
13
+ - Updated project documentation and test files
14
+
8
15
  ## [0.1.2] - 2026-01-19
9
16
 
10
17
  ### Changed
@@ -23,5 +30,5 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
23
30
  - Support for official Claude API and third-party providers (GLM, DeepSeek, Minimax)
24
31
  - Custom endpoint management (add/remove)
25
32
  - Proxy configuration support
26
- - Configuration persistence in `~/.cc-run/config.json`
33
+ - Configuration persistence in `~/.runcc/config.json`
27
34
  - Integration with Claude CLI settings (`~/.claude/settings.json`)
package/CLAUDE.md CHANGED
@@ -62,7 +62,7 @@ src/
62
62
  ├── config/ # 配置数据层
63
63
  │ ├── types.ts # TypeScript 类型定义
64
64
  │ ├── endpoints.ts # 内置 endpoints (glm/deepseek/minimax)
65
- │ └── storage.ts # ~/.cc-run/config.json 读写
65
+ │ └── storage.ts # ~/.runcc/config.json 读写
66
66
  └── utils/ # 工具层
67
67
  ├── launcher.ts # spawn Claude 进程
68
68
  ├── env.ts # 环境变量构建
@@ -71,7 +71,7 @@ src/
71
71
 
72
72
  ## 双配置文件系统
73
73
 
74
- ### ~/.cc-run/config.json (启动器私有配置)
74
+ ### ~/.runcc/config.json (启动器私有配置)
75
75
 
76
76
  存储自定义 endpoints、API tokens、最后使用的 endpoint、代理配置。
77
77
 
@@ -145,5 +145,5 @@ src/
145
145
  ## 依赖外部条件
146
146
 
147
147
  1. **Claude CLI**: 系统必须已安装 `claude` 命令
148
- 2. **配置目录**: 自动创建 `~/.cc-run/` 和 `~/.claude/`
148
+ 2. **配置目录**: 自动创建 `~/.runcc/` 和 `~/.claude/`
149
149
  3. **Node 版本**: >= 18.0.0
package/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # cc-run
1
+ # runcc
2
2
 
3
3
  Claude CLI 启动器,支持切换不同的 API endpoint。
4
4
 
@@ -24,19 +24,19 @@ npm install -g .
24
24
 
25
25
  ```bash
26
26
  # 查看所有可用的 endpoints
27
- cc-run list
27
+ runcc list
28
28
 
29
29
  # 使用第三方 endpoint
30
- cc-run glm
30
+ runcc glm
31
31
 
32
32
  # 配置原生 claude 命令使用 glm
33
- cc-run glm --claude
33
+ runcc glm --claude
34
34
 
35
35
  # 恢复原生 claude 使用官方 endpoint
36
- cc-run --claude
36
+ runcc --claude
37
37
 
38
38
  # 启动官方 claude
39
- cc-run
39
+ runcc
40
40
  ```
41
41
 
42
42
  ## 命令说明
@@ -45,29 +45,29 @@ cc-run
45
45
 
46
46
  | 命令 | 说明 |
47
47
  |------|------|
48
- | `cc-run` | 启动官方 claude |
49
- | `cc-run glm` | 使用 glm endpoint |
50
- | `cc-run deepseek` | 使用 deepseek endpoint |
51
- | `cc-run minimax` | 使用 minimax endpoint |
52
- | `cc-run list` | 列出所有 endpoints |
53
- | `cc-run add <name> <endpoint> [token]` | 添加自定义 endpoint |
54
- | `cc-run remove <name>` | 删除自定义 endpoint |
48
+ | `runcc` | 启动官方 claude |
49
+ | `runcc glm` | 使用 glm endpoint |
50
+ | `runcc deepseek` | 使用 deepseek endpoint |
51
+ | `runcc minimax` | 使用 minimax endpoint |
52
+ | `runcc list` | 列出所有 endpoints |
53
+ | `runcc add <name> <endpoint> [token]` | 添加自定义 endpoint |
54
+ | `runcc remove <name>` | 删除自定义 endpoint |
55
55
 
56
56
  ### 原生命令配置
57
57
 
58
58
  | 命令 | 说明 |
59
59
  |------|------|
60
- | `cc-run <provider> --claude` | 配置原生 `claude` 命令使用第三方 endpoint |
61
- | `cc-run --claude` | 恢复原生 `claude` 命令使用官方 endpoint |
60
+ | `runcc <provider> --claude` | 配置原生 `claude` 命令使用第三方 endpoint |
61
+ | `runcc --claude` | 恢复原生 `claude` 命令使用官方 endpoint |
62
62
 
63
63
  ### 代理管理
64
64
 
65
65
  | 命令 | 说明 |
66
66
  |------|------|
67
- | `cc-run proxy on` | 开启代理 |
68
- | `cc-run proxy off` | 关闭代理 |
69
- | `cc-run proxy status` | 查看代理状态 |
70
- | `cc-run proxy reset` | 重置代理配置 |
67
+ | `runcc proxy on` | 开启代理 |
68
+ | `runcc proxy off` | 关闭代理 |
69
+ | `runcc proxy status` | 查看代理状态 |
70
+ | `runcc proxy reset` | 重置代理配置 |
71
71
 
72
72
  ## 内置 Endpoints
73
73
 
@@ -79,7 +79,7 @@ cc-run
79
79
 
80
80
  ## 配置文件
81
81
 
82
- ### ~/.cc-run/config.json
82
+ ### ~/.runcc/config.json
83
83
 
84
84
  ```json
85
85
  {
@@ -117,46 +117,46 @@ cc-run
117
117
  ### 添加自定义 endpoint
118
118
 
119
119
  ```bash
120
- cc-run add my-api https://api.my-service.com/v1 sk-my-token
120
+ runcc add my-api https://api.my-service.com/v1 sk-my-token
121
121
  ```
122
122
 
123
123
  ### 切换 endpoint
124
124
 
125
125
  ```bash
126
126
  # 使用 glm
127
- cc-run glm
127
+ runcc glm
128
128
 
129
129
  # 使用 deepseek
130
- cc-run deepseek
130
+ runcc deepseek
131
131
 
132
132
  # 使用自定义 endpoint
133
- cc-run my-api
133
+ runcc my-api
134
134
  ```
135
135
 
136
136
  ### 配置代理
137
137
 
138
138
  ```bash
139
139
  # 开启代理(首次会提示输入代理地址)
140
- cc-run proxy on
140
+ runcc proxy on
141
141
 
142
142
  # 查看代理状态
143
- cc-run proxy status
143
+ runcc proxy status
144
144
 
145
145
  # 关闭代理
146
- cc-run proxy off
146
+ runcc proxy off
147
147
  ```
148
148
 
149
149
  ### 配置原生命令
150
150
 
151
151
  ```bash
152
152
  # 让原生 claude 命令使用 glm
153
- cc-run glm --claude
153
+ runcc glm --claude
154
154
 
155
155
  # 之后直接使用 claude 命令即可
156
156
  claude "你好"
157
157
 
158
158
  # 恢复使用官方 endpoint
159
- cc-run --claude
159
+ runcc --claude
160
160
  ```
161
161
 
162
162
  ## Token 管理
@@ -164,11 +164,11 @@ cc-run --claude
164
164
  首次使用某个 endpoint 时,如果未配置 token,会提示输入:
165
165
 
166
166
  ```bash
167
- $ cc-run glm
167
+ $ runcc glm
168
168
  请输入 glm 的 API Token: [输入框]
169
169
  ```
170
170
 
171
- Token 会被保存到 `~/.cc-run/config.json`,下次使用时无需再次输入。
171
+ Token 会被保存到 `~/.runcc/config.json`,下次使用时无需再次输入。
172
172
 
173
173
  ## 开发
174
174
 
package/dist/index.js CHANGED
@@ -1917,7 +1917,7 @@ import { join } from "node:path";
1917
1917
  import { homedir } from "node:os";
1918
1918
  function getConfigDir() {
1919
1919
  const home = process.env.CC_RUN_TEST_HOME || homedir();
1920
- return join(home, ".cc-run");
1920
+ return join(home, ".runcc");
1921
1921
  }
1922
1922
  function getConfigFilePath() {
1923
1923
  return join(getConfigDir(), "config.json");
@@ -2215,7 +2215,7 @@ function proxyReset() {
2215
2215
  function proxyStatus() {
2216
2216
  const ccRunConfig = getProxyConfig();
2217
2217
  const claudeProxy = getClaudeProxy();
2218
- console.log("CC-Run 代理配置:");
2218
+ console.log("RunCC 代理配置:");
2219
2219
  console.log(` 状态: ${ccRunConfig.enabled ? "开启" : "关闭"}`);
2220
2220
  if (ccRunConfig.url) {
2221
2221
  console.log(` 地址: ${ccRunConfig.url}`);
@@ -2235,16 +2235,16 @@ function proxyHelp() {
2235
2235
  console.log(`
2236
2236
  代理管理命令:
2237
2237
 
2238
- cc-run proxy on 开启代理(首次会提示输入代理地址)
2239
- cc-run proxy off 关闭代理
2240
- cc-run proxy reset 重置代理配置
2241
- cc-run proxy status 查看代理状态
2242
- cc-run proxy help 显示此帮助信息
2238
+ runcc proxy on 开启代理(首次会提示输入代理地址)
2239
+ runcc proxy off 关闭代理
2240
+ runcc proxy reset 重置代理配置
2241
+ runcc proxy status 查看代理状态
2242
+ runcc proxy help 显示此帮助信息
2243
2243
 
2244
2244
  说明:
2245
2245
  - proxy on 会修改 ~/.claude/settings.json,添加 proxy 配置
2246
2246
  - proxy off 会删除 ~/.claude/settings.json 中的 proxy 配置
2247
- - 代理地址保存在 ~/.cc-run/config.json 中
2247
+ - 代理地址保存在 ~/.runcc/config.json 中
2248
2248
  `);
2249
2249
  }
2250
2250
  async function promptProxyUrl() {
@@ -2360,7 +2360,7 @@ async function runProvider(providerName, configureClaude, passthroughArgs = [])
2360
2360
  const endpoint = getEndpointConfig(providerName);
2361
2361
  if (!endpoint) {
2362
2362
  console.error(`错误: 未找到 endpoint "${providerName}"`);
2363
- console.log('使用 "cc-run list" 查看可用的 endpoints');
2363
+ console.log('使用 "runcc list" 查看可用的 endpoints');
2364
2364
  process.exit(1);
2365
2365
  }
2366
2366
  let token = endpoint.token || getToken(providerName);
@@ -2386,7 +2386,7 @@ async function runProvider(providerName, configureClaude, passthroughArgs = [])
2386
2386
  if (configureClaude) {
2387
2387
  setThirdPartyApi(endpoint.endpoint, token);
2388
2388
  console.log(`已配置原生 claude 命令使用 ${providerName}`);
2389
- console.log('使用 "cc-run --claude" 可恢复官方配置');
2389
+ console.log('使用 "runcc --claude" 可恢复官方配置');
2390
2390
  }
2391
2391
  const child = launchClaude({
2392
2392
  apiEndpoint: endpoint.endpoint,
@@ -2482,7 +2482,7 @@ if (isBunCompiled) {
2482
2482
  };
2483
2483
  }
2484
2484
  var program2 = new Command;
2485
- program2.name("cc-run").description("Claude 启动器 - 支持切换不同的 API endpoint").version("0.1.0");
2485
+ program2.name("runcc").description("Claude 启动器 - 支持切换不同的 API endpoint").version("0.1.0");
2486
2486
  program2.command("list").description("列出所有可用的 endpoints").action(list);
2487
2487
  program2.command("add").description("添加自定义 endpoint").argument("<name>", "endpoint 名称").argument("<endpoint>", "API 地址").action(add);
2488
2488
  program2.command("remove").description("删除自定义 endpoint").argument("<name>", "endpoint 名称").action(remove);
@@ -2510,9 +2510,9 @@ program2.argument("[provider]", "provider 名称 (glm, deepseek, minimax 或自
2510
2510
  console.error("❌ 参数位置不正确");
2511
2511
  console.error("");
2512
2512
  console.error("正确的用法示例:");
2513
- console.error(" cc-run glm -- <claude参数> # 使用 glm provider 并透传参数");
2514
- console.error(" cc-run --claude -- <参数> # 恢复官方配置并透传参数");
2515
- console.error(" cc-run glm --claude -- <参数> # 配置原生 claude 命令使用 glm");
2513
+ console.error(" runcc glm -- <claude参数> # 使用 glm provider 并透传参数");
2514
+ console.error(" runcc --claude -- <参数> # 恢复官方配置并透传参数");
2515
+ console.error(" runcc glm --claude -- <参数> # 配置原生 claude 命令使用 glm");
2516
2516
  console.error("");
2517
2517
  console.error("说明: -- 分隔符用于将后续参数透传给 Claude CLI");
2518
2518
  process.exit(1);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "runcc",
3
- "version": "0.1.2",
3
+ "version": "0.1.3",
4
4
  "description": "CC launcher with endpoint switching support",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -1,209 +0,0 @@
1
- ---
2
- name: npm-publish
3
- description: Automate npm package version bumping and publishing with comprehensive safety checks. Use when user requests "发布新版本", "publish to npm", "bump version", "release a new version", or similar package publishing tasks. Supports semantic versioning (patch/minor/major), git tagging, CHANGELOG updates, and pre-publish validation.
4
- ---
5
-
6
- # NPM Publish
7
-
8
- Automate the complete npm package release workflow with safety checks, version management, and changelog updates.
9
-
10
- ## Workflow
11
-
12
- Follow this sequential workflow for publishing npm packages. Each step includes validation and confirmation points to ensure safe releases.
13
-
14
- ### Step 1: Pre-flight Checks
15
-
16
- Before starting the release process, create a todo list with these items and verify the environment:
17
-
18
- 1. **检查 git 工作区状态**
19
- - Run `git status` to ensure working directory is clean
20
- - If there are uncommitted changes, ask user whether to commit them or abort
21
-
22
- 2. **确认当前分支**
23
- - Check current branch with `git branch --show-current`
24
- - Verify it's `main` or `master` (or other release branch)
25
- - If not on release branch, warn user and ask to confirm or switch
26
-
27
- 3. **检查 npm 登录状态**
28
- - Run `npm whoami` to verify npm authentication
29
- - If not logged in, instruct user to run `npm login`
30
-
31
- 4. **拉取最新代码**
32
- - Run `git pull` to ensure working with latest code
33
- - Check for any conflicts
34
-
35
- ### Step 2: Determine Version Bump Type
36
-
37
- Ask the user which type of version bump to perform, unless they've already specified:
38
-
39
- - **patch**: Bug fixes, minor changes (1.0.0 → 1.0.1)
40
- - **minor**: New features, backward compatible (1.0.0 → 1.1.0)
41
- - **major**: Breaking changes (1.0.0 → 2.0.0)
42
- - **custom**: Specify exact version number
43
-
44
- Use the `AskUserQuestion` tool if the version type wasn't specified in the initial request.
45
-
46
- ### Step 3: Run Tests and Build
47
-
48
- Execute the project's quality checks:
49
-
50
- 1. **运行测试**
51
- - Check if `package.json` has a `test` script
52
- - Run `npm test` or equivalent command
53
- - If tests fail, abort the release and report errors
54
-
55
- 2. **运行构建**
56
- - Check if `package.json` has a `build` script
57
- - Run `npm run build` or equivalent command
58
- - If build fails, abort the release and report errors
59
-
60
- ### Step 4: Update CHANGELOG
61
-
62
- If CHANGELOG.md exists in the project:
63
-
64
- 1. **Read recent commits**
65
- - Run `git log` to see commits since last release
66
- - Look for previous version tags with `git tag -l`
67
-
68
- 2. **Generate changelog entry**
69
- - Create a new section for the new version
70
- - List key changes based on commit messages
71
- - Format: `## [Version] - YYYY-MM-DD`
72
- - Group changes by type: Features, Bug Fixes, Breaking Changes, etc.
73
-
74
- 3. **Let user review and edit**
75
- - Show the generated changelog entry
76
- - Use `AskUserQuestion` to confirm or request modifications
77
- - Update CHANGELOG.md with the approved content
78
-
79
- If no CHANGELOG.md exists, ask user if they want to create one.
80
-
81
- ### Step 5: Bump Version
82
-
83
- Use npm's built-in version command:
84
-
85
- ```bash
86
- npm version <patch|minor|major|x.y.z> -m "chore: release v%s"
87
- ```
88
-
89
- This command will:
90
- - Update version in `package.json` and `package-lock.json`
91
- - Create a git commit with the specified message
92
- - Create a git tag with the new version
93
-
94
- ### Step 6: User Confirmation
95
-
96
- Before publishing, display a summary and ask for final confirmation:
97
-
98
- ```
99
- Ready to publish:
100
- - Package: <package-name>
101
- - Current version: <old-version>
102
- - New version: <new-version>
103
- - Branch: <branch-name>
104
- - Changes: <summary from changelog>
105
-
106
- Proceed with publishing? (yes/no)
107
- ```
108
-
109
- Use `AskUserQuestion` for this confirmation.
110
-
111
- ### Step 7: Publish to NPM
112
-
113
- If user confirms, publish the package:
114
-
115
- ```bash
116
- npm publish
117
- ```
118
-
119
- Options to consider:
120
- - `--access public` for scoped public packages
121
- - `--tag <tag>` for pre-release versions (e.g., `beta`, `next`)
122
- - `--dry-run` to test without actually publishing (useful for first-time testing)
123
-
124
- ### Step 8: Push to Git Remote
125
-
126
- After successful npm publish:
127
-
128
- 1. **推送代码和标签**
129
- ```bash
130
- git push && git push --tags
131
- ```
132
-
133
- 2. **验证发布**
134
- - Confirm the new version appears on npmjs.com
135
- - Confirm the git tag appears on the remote repository
136
-
137
- ### Step 9: Summary
138
-
139
- Report the successful release:
140
-
141
- ```
142
- ✅ Successfully published <package-name>@<new-version>
143
-
144
- - NPM: https://www.npmjs.com/package/<package-name>
145
- - Git tag: <tag-name>
146
- - Changelog updated: Yes/No
147
-
148
- Next steps:
149
- - Create GitHub release (if applicable)
150
- - Announce to team
151
- - Update dependent projects
152
- ```
153
-
154
- ## Error Handling
155
-
156
- If any step fails:
157
-
158
- 1. **Clearly state which step failed and why**
159
- 2. **Do not proceed to next steps**
160
- 3. **Provide actionable recovery steps**
161
- 4. **If version was bumped but publish failed:**
162
- - The version commit and tag already exist
163
- - User can either: fix the issue and run `npm publish` manually, or reset with `git reset --hard HEAD~1 && git tag -d v<version>`
164
-
165
- ## Rollback
166
-
167
- If user needs to undo a release:
168
-
169
- 1. **Unpublish from npm** (only within 72 hours):
170
- ```bash
171
- npm unpublish <package-name>@<version>
172
- ```
173
-
174
- 2. **Delete git tag**:
175
- ```bash
176
- git tag -d v<version>
177
- git push origin :refs/tags/v<version>
178
- ```
179
-
180
- 3. **Revert version commit**:
181
- ```bash
182
- git reset --hard HEAD~1
183
- git push --force
184
- ```
185
-
186
- **Warning**: Unpublishing is discouraged by npm. Prefer deprecating instead:
187
- ```bash
188
- npm deprecate <package-name>@<version> "Reason for deprecation"
189
- ```
190
-
191
- ## Customization
192
-
193
- Different projects may need adaptations:
194
-
195
- - **Monorepo**: Use tools like `lerna` or `nx` for versioning multiple packages
196
- - **Pre-release versions**: Use `npm version prerelease --preid=beta`
197
- - **CI/CD**: This workflow is for manual releases; adapt for automated pipelines
198
- - **Private registry**: Use `--registry` flag or `.npmrc` configuration
199
- - **2FA**: npm may require OTP code during publish, prompt user to enter it
200
-
201
- ## Best Practices
202
-
203
- 1. **Always run tests before publishing**
204
- 2. **Keep CHANGELOG.md up to date**
205
- 3. **Use semantic versioning correctly**
206
- 4. **Review changes one final time before confirming**
207
- 5. **Never publish with uncommitted changes**
208
- 6. **Tag releases for easy reference**
209
- 7. **Announce breaking changes clearly**
package/PLAN.md DELETED
@@ -1,236 +0,0 @@
1
- # CC 启动器实现计划
2
-
3
- ## 项目概述
4
-
5
- 使用 TypeScript + bun 创建 CC 启动器,支持切换不同的 API endpoint。
6
-
7
- ## 命令格式
8
-
9
- | 命令 | 功能 |
10
- |------|------|
11
- | `cc-run` | **总是**启动官方 claude(根据配置决定是否临时清除 proxy 和第三方 endpoint) |
12
- | `cc-run --claude` | 恢复原生 `claude` 命令使用官方 endpoint(删除 ~/.claude/settings.json 中的第三方配置) |
13
- | `cc-run glm` | 使用 glm endpoint |
14
- | `cc-run glm --claude` | 使用 glm,并配置原生 `claude` 命令默认使用 glm |
15
- | `cc-run deepseek` | 使用 deepseek endpoint |
16
- | `cc-run deepseek --claude` | 使用 deepseek,并配置原生 `claude` 命令默认使用 deepseek |
17
- | `cc-run minimax` | 使用 minimax endpoint |
18
- | `cc-run add <name> <endpoint> <token>` | 添加自定义 endpoint |
19
- | `cc-run list` | 列出所有 endpoint |
20
- | `cc-run remove <name>` | 删除自定义 endpoint |
21
- | `cc-run proxy on` | 开启代理(修改 ~/.claude/settings.json) |
22
- | `cc-run proxy off` | 关闭代理(修改 ~/.claude/settings.json) |
23
- | `cc-run proxy reset` | 重置代理配置 |
24
- | `cc-run proxy status` | 查看代理状态 |
25
- | `cc-run proxy help` | 代理帮助信息 |
26
-
27
- ## 项目结构
28
-
29
- ```
30
- cc-run/
31
- ├── package.json
32
- ├── tsconfig.json
33
- ├── src/
34
- │ ├── index.ts # CLI 入口
35
- │ ├── commands/
36
- │ │ ├── run.ts # 启动命令
37
- │ │ ├── add.ts # 添加 endpoint
38
- │ │ ├── list.ts # 列出 endpoint
39
- │ │ ├── remove.ts # 删除 endpoint
40
- │ │ └── proxy.ts # 代理管理命令
41
- │ ├── config/
42
- │ │ ├── storage.ts # 配置存储管理
43
- │ │ ├── endpoints.ts # 内置 endpoint 定义
44
- │ │ └── types.ts # 类型定义
45
- │ └── utils/
46
- │ ├── env.ts # 环境变量设置
47
- │ └── launcher.ts # 启动 claude
48
- └── README.md
49
- ```
50
-
51
- ## 内置 Endpoints
52
-
53
- | 名称 | Endpoint |
54
- |------|----------|
55
- | glm | https://open.bigmodel.cn/api/paas/v4/ |
56
- | deepseek | https://api.deepseek.com |
57
- | minimax | https://api.minimax.chat/v1 |
58
-
59
- ## 配置存储
60
-
61
- ### ~/.cc-run/config.json(启动器配置)
62
- `proxy.on/off` 会修改此文件的 proxy 配置,`cc-run <provider>` 会保存 token:
63
- ```json
64
- {
65
- "endpoints": [
66
- {
67
- "name": "my-custom",
68
- "endpoint": "https://api.example.com/v1",
69
- "token": "sk-xxxxxxxx"
70
- }
71
- ],
72
- "tokens": {
73
- "glm": "sk-xxxxxxxx",
74
- "deepseek": "sk-yyyyyyyy",
75
- "minimax": "sk-zzzzzzzz"
76
- },
77
- "lastUsed": "glm",
78
- "proxy": {
79
- "enabled": true,
80
- "url": "http://agent.baidu.com:8891",
81
- "clearForOfficial": false
82
- }
83
- }
84
- ```
85
-
86
- ### ~/.claude/settings.json(Claude 官方配置)
87
- `proxy on/off` 会修改此文件的 proxy 配置:
88
- ```json
89
- {
90
- "proxy": "http://agent.baidu.com:8891"
91
- }
92
- ```
93
-
94
- ## Proxy 处理逻辑
95
-
96
- ### cc-run proxy on
97
- 1. 提示输入代理地址(首次)
98
- 2. 保存到 `~/.cc-run/config.json`
99
- 3. 修改 `~/.claude/settings.json`,添加 proxy 配置
100
-
101
- ### cc-run proxy off
102
- 1. 更新 `~/.cc-run/config.json`(enabled: false)
103
- 2. 修改 `~/.claude/settings.json`,删除 proxy 配置
104
-
105
- ## 运行逻辑
106
-
107
- ### cc-run(无参数)
108
-
109
- 总是启动官方 claude。启动前会检查并清理 `~/.claude/settings.json`:
110
-
111
- 1. 读取当前的 `~/.claude/settings.json`
112
- 2. 检查是否有 `proxy` 配置
113
- 3. 检查是否有 `apiUrl` / `anthropicApiKey` 等第三方 endpoint 配置
114
- 4. 根据清理策略清理:
115
- - **proxy 清理**:由 `~/.cc-run/config.json` 中 `proxy.clearForOfficial` 决定
116
- - **endpoint 清理**:总是清除第三方 endpoint 配置
117
- 5. 启动 claude
118
- 6. claude 退出后恢复被清除的配置
119
-
120
- **proxy 清理策略**(`~/.cc-run/config.json`):
121
- ```json
122
- {
123
- "proxy": {
124
- "clearForOfficial": true // 启动官方 claude 时是否清除 proxy
125
- }
126
- }
127
- ```
128
-
129
- ### cc-run <provider>
130
-
131
- 使用指定 endpoint,通过环境变量启动。
132
-
133
- **Token 获取逻辑**:
134
- 1. 检查 `~/.cc-run/config.json` 中是否已保存该 provider 的 token
135
- 2. 如果没有,提示用户输入:
136
- ```
137
- 请输入 glm 的 API Token: [输入框]
138
- ```
139
- 3. 保存 token 到 `~/.cc-run/config.json`:
140
- ```json
141
- {
142
- "tokens": {
143
- "glm": "sk-xxxxxxxx",
144
- "deepseek": "sk-yyyyyyyy",
145
- "minimax": "sk-zzzzzzzz"
146
- }
147
- }
148
- ```
149
- 4. 使用保存的 token 启动
150
-
151
- ### cc-run <provider> --claude
152
- 使用指定 endpoint,并**配置原生 `claude` 命令**的默认行为:
153
- 1. 使用指定 endpoint 启动 cc-run
154
- 2. 修改 `~/.claude/settings.json`,设置:
155
- - `apiUrl`: 指定 provider 的 endpoint
156
- - `anthropicApiKey`: 指定 provider 的 token
157
- 3. 之后直接运行原生 `claude` 命令时,会使用这个第三方 endpoint
158
- 4. **不影响** `cc-run` 无参数的行为(`cc-run` 仍然总是启动官方 claude)
159
-
160
- ### cc-run --claude(无 provider)
161
- **恢复原生 `claude` 命令使用官方 endpoint**:
162
- 1. 删除 `~/.claude/settings.json` 中的 `apiUrl` 和 `anthropicApiKey`
163
- 2. 之后直接运行原生 `claude` 命令时,会使用官方 endpoint
164
- 3. 不启动 cc-run
165
-
166
- > **注**:`--claude` 只影响原生 `claude` 命令,不影响 `cc-run`
167
-
168
- ## 环境变量
169
-
170
- 启动 CC 时设置:
171
- - `ANTHROPIC_BASE_URL` - API endpoint
172
- - `ANTHROPIC_AUTH_TOKEN` - API token
173
- - `http_proxy` / `https_proxy` - 代理(如果配置)
174
-
175
- ## 关键文件
176
-
177
- | 文件 | 说明 |
178
- |------|------|
179
- | `src/index.ts` | CLI 入口,使用 commander 解析参数 |
180
- | `src/config/storage.ts` | 配置文件读写、token 管理、endpoint 管理 |
181
- | `src/utils/token.ts` | Token 获取和保存逻辑(首次使用时提示输入) |
182
- | `src/commands/run.ts` | 核心启动逻辑,处理官方模式的 proxy 临时清除 |
183
- | `src/commands/proxy.ts` | 代理管理命令(on/off/reset/status/help) |
184
- | `src/utils/launcher.ts` | spawn claude 进程 |
185
- | `src/utils/claude-settings.ts` | 读写 `~/.claude/settings.json` 的 proxy 和 endpoint 配置 |
186
- | `src/config/types.ts` | TypeScript 类型定义 |
187
-
188
- ## 代理命令实现要点
189
-
190
- | 命令 | 说明 |
191
- |------|------|
192
- | `cc-run proxy on` | 首次运行时提示输入代理地址,保存并修改 `~/.claude/settings.json` |
193
- | `cc-run proxy off` | 关闭代理,删除 `~/.claude/settings.json` 中的 proxy 配置 |
194
- | `cc-run proxy reset` | 重置代理配置 |
195
- | `cc-run proxy status` | 显示代理状态(是否启用、地址) |
196
- | `cc-run proxy help` | 显示代理相关帮助 |
197
-
198
- ## 依赖
199
-
200
- ```json
201
- {
202
- "dependencies": {
203
- "commander": "^12.0.0"
204
- },
205
- "devDependencies": {
206
- "@types/node": "^20.0.0",
207
- "bun-types": "latest"
208
- }
209
- }
210
- ```
211
-
212
- ## 验证方式
213
-
214
- ```bash
215
- # 1. 构建
216
- bun run build
217
-
218
- # 2. 测试 list
219
- bun run src/index.ts list
220
-
221
- # 3. 测试 add
222
- bun run src/index.ts add test https://api.test.com sk-test
223
-
224
- # 4. 测试 proxy
225
- bun run src/index.ts proxy status
226
- bun run src/index.ts proxy on
227
- bun run src/index.ts proxy off
228
-
229
- # 5. 测试 run(需要已有 token)
230
- bun run src/index.ts glm
231
-
232
- # 6. 全局安装后测试
233
- bun install -g
234
- cc-run list
235
- cc-run proxy status
236
- ```