runcc 0.1.1 → 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.
Binary file
@@ -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 ADDED
@@ -0,0 +1,34 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project will be documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
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
+
15
+ ## [0.1.2] - 2026-01-19
16
+
17
+ ### Changed
18
+ - Renamed CLI command from `cc-run` to `runcc` for better naming consistency
19
+ - Improved output formatting with UTF-8 support for better Chinese character display in list command
20
+
21
+ ### Added
22
+ - Added `.npmignore` configuration for cleaner package distribution
23
+ - Added Claude Code skills configuration for enhanced development workflow
24
+ - Added local testing script (`test-install.sh`) for installation verification
25
+
26
+ ## [0.1.1] - 2026-01-19
27
+
28
+ ### Added
29
+ - Initial release with multi-endpoint support
30
+ - Support for official Claude API and third-party providers (GLM, DeepSeek, Minimax)
31
+ - Custom endpoint management (add/remove)
32
+ - Proxy configuration support
33
+ - Configuration persistence in `~/.runcc/config.json`
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
@@ -1,5 +1,4 @@
1
- #!/usr/bin/env bun
2
- // @bun
1
+ #!/usr/bin/env node
3
2
  import { createRequire } from "node:module";
4
3
  var __create = Object.create;
5
4
  var __getProtoOf = Object.getPrototypeOf;
@@ -1918,7 +1917,7 @@ import { join } from "node:path";
1918
1917
  import { homedir } from "node:os";
1919
1918
  function getConfigDir() {
1920
1919
  const home = process.env.CC_RUN_TEST_HOME || homedir();
1921
- return join(home, ".cc-run");
1920
+ return join(home, ".runcc");
1922
1921
  }
1923
1922
  function getConfigFilePath() {
1924
1923
  return join(getConfigDir(), "config.json");
@@ -2020,7 +2019,7 @@ function safeLog(message) {
2020
2019
  const encoder = new TextEncoder;
2021
2020
  const data = encoder.encode(message + `
2022
2021
  `);
2023
- Bun.write(Bun.stdout, data);
2022
+ process.stdout.write(data);
2024
2023
  }
2025
2024
  function formatEndpoint(name, endpoint, hasToken) {
2026
2025
  const tokenStatus = hasToken ? "已配置 token" : "未配置 token";
@@ -2216,7 +2215,7 @@ function proxyReset() {
2216
2215
  function proxyStatus() {
2217
2216
  const ccRunConfig = getProxyConfig();
2218
2217
  const claudeProxy = getClaudeProxy();
2219
- console.log("CC-Run 代理配置:");
2218
+ console.log("RunCC 代理配置:");
2220
2219
  console.log(` 状态: ${ccRunConfig.enabled ? "开启" : "关闭"}`);
2221
2220
  if (ccRunConfig.url) {
2222
2221
  console.log(` 地址: ${ccRunConfig.url}`);
@@ -2236,16 +2235,16 @@ function proxyHelp() {
2236
2235
  console.log(`
2237
2236
  代理管理命令:
2238
2237
 
2239
- cc-run proxy on 开启代理(首次会提示输入代理地址)
2240
- cc-run proxy off 关闭代理
2241
- cc-run proxy reset 重置代理配置
2242
- cc-run proxy status 查看代理状态
2243
- cc-run proxy help 显示此帮助信息
2238
+ runcc proxy on 开启代理(首次会提示输入代理地址)
2239
+ runcc proxy off 关闭代理
2240
+ runcc proxy reset 重置代理配置
2241
+ runcc proxy status 查看代理状态
2242
+ runcc proxy help 显示此帮助信息
2244
2243
 
2245
2244
  说明:
2246
2245
  - proxy on 会修改 ~/.claude/settings.json,添加 proxy 配置
2247
2246
  - proxy off 会删除 ~/.claude/settings.json 中的 proxy 配置
2248
- - 代理地址保存在 ~/.cc-run/config.json 中
2247
+ - 代理地址保存在 ~/.runcc/config.json 中
2249
2248
  `);
2250
2249
  }
2251
2250
  async function promptProxyUrl() {
@@ -2361,7 +2360,7 @@ async function runProvider(providerName, configureClaude, passthroughArgs = [])
2361
2360
  const endpoint = getEndpointConfig(providerName);
2362
2361
  if (!endpoint) {
2363
2362
  console.error(`错误: 未找到 endpoint "${providerName}"`);
2364
- console.log('使用 "cc-run list" 查看可用的 endpoints');
2363
+ console.log('使用 "runcc list" 查看可用的 endpoints');
2365
2364
  process.exit(1);
2366
2365
  }
2367
2366
  let token = endpoint.token || getToken(providerName);
@@ -2387,7 +2386,7 @@ async function runProvider(providerName, configureClaude, passthroughArgs = [])
2387
2386
  if (configureClaude) {
2388
2387
  setThirdPartyApi(endpoint.endpoint, token);
2389
2388
  console.log(`已配置原生 claude 命令使用 ${providerName}`);
2390
- console.log('使用 "cc-run --claude" 可恢复官方配置');
2389
+ console.log('使用 "runcc --claude" 可恢复官方配置');
2391
2390
  }
2392
2391
  const child = launchClaude({
2393
2392
  apiEndpoint: endpoint.endpoint,
@@ -2465,12 +2464,12 @@ function validateDashPosition(argv) {
2465
2464
  // src/index.ts
2466
2465
  function safeLog2(message) {
2467
2466
  const encoder = new TextEncoder;
2468
- Bun.write(Bun.stdout, encoder.encode(message + `
2467
+ process.stdout.write(encoder.encode(message + `
2469
2468
  `));
2470
2469
  }
2471
2470
  function safeError(message) {
2472
2471
  const encoder = new TextEncoder;
2473
- Bun.write(Bun.stderr, encoder.encode(message + `
2472
+ process.stderr.write(encoder.encode(message + `
2474
2473
  `));
2475
2474
  }
2476
2475
  var isBunCompiled = typeof Bun !== "undefined" && !import.meta.dir;
@@ -2483,17 +2482,17 @@ if (isBunCompiled) {
2483
2482
  };
2484
2483
  }
2485
2484
  var program2 = new Command;
2486
- program2.name("cc-run").description("Claude \u542F\u52A8\u5668 - \u652F\u6301\u5207\u6362\u4E0D\u540C\u7684 API endpoint").version("0.1.0");
2487
- program2.command("list").description("\u5217\u51FA\u6240\u6709\u53EF\u7528\u7684 endpoints").action(list);
2488
- program2.command("add").description("\u6DFB\u52A0\u81EA\u5B9A\u4E49 endpoint").argument("<name>", "endpoint \u540D\u79F0").argument("<endpoint>", "API \u5730\u5740").action(add);
2489
- program2.command("remove").description("\u5220\u9664\u81EA\u5B9A\u4E49 endpoint").argument("<name>", "endpoint \u540D\u79F0").action(remove);
2490
- var proxyCmd = program2.command("proxy").description("\u4EE3\u7406\u7BA1\u7406");
2491
- proxyCmd.command("on").description("\u5F00\u542F\u4EE3\u7406").action(proxyOn);
2492
- proxyCmd.command("off").description("\u5173\u95ED\u4EE3\u7406").action(proxyOff);
2493
- proxyCmd.command("reset").description("\u91CD\u7F6E\u4EE3\u7406\u914D\u7F6E").action(proxyReset);
2494
- proxyCmd.command("status").description("\u67E5\u770B\u4EE3\u7406\u72B6\u6001").action(proxyStatus);
2495
- proxyCmd.command("help").description("\u4EE3\u7406\u5E2E\u52A9\u4FE1\u606F").action(proxyHelp);
2496
- program2.argument("[provider]", "provider \u540D\u79F0 (glm, deepseek, minimax \u6216\u81EA\u5B9A\u4E49)").option("--claude", "\u914D\u7F6E\u539F\u751F claude \u547D\u4EE4").allowExcessArguments(true).action(async (provider, options) => {
2485
+ program2.name("runcc").description("Claude 启动器 - 支持切换不同的 API endpoint").version("0.1.0");
2486
+ program2.command("list").description("列出所有可用的 endpoints").action(list);
2487
+ program2.command("add").description("添加自定义 endpoint").argument("<name>", "endpoint 名称").argument("<endpoint>", "API 地址").action(add);
2488
+ program2.command("remove").description("删除自定义 endpoint").argument("<name>", "endpoint 名称").action(remove);
2489
+ var proxyCmd = program2.command("proxy").description("代理管理");
2490
+ proxyCmd.command("on").description("开启代理").action(proxyOn);
2491
+ proxyCmd.command("off").description("关闭代理").action(proxyOff);
2492
+ proxyCmd.command("reset").description("重置代理配置").action(proxyReset);
2493
+ proxyCmd.command("status").description("查看代理状态").action(proxyStatus);
2494
+ proxyCmd.command("help").description("代理帮助信息").action(proxyHelp);
2495
+ program2.argument("[provider]", "provider 名称 (glm, deepseek, minimax 或自定义)").option("--claude", "配置原生 claude 命令").allowExcessArguments(true).action(async (provider, options) => {
2497
2496
  try {
2498
2497
  validateDashPosition(process.argv);
2499
2498
  const passthroughArgs = extractPassthroughArgs(process.argv);
@@ -2508,14 +2507,14 @@ program2.argument("[provider]", "provider \u540D\u79F0 (glm, deepseek, minimax \
2508
2507
  }
2509
2508
  } catch (error) {
2510
2509
  if (error instanceof PassthroughArgsError) {
2511
- console.error("\u274C \u53C2\u6570\u4F4D\u7F6E\u4E0D\u6B63\u786E");
2510
+ console.error(" 参数位置不正确");
2512
2511
  console.error("");
2513
- console.error("\u6B63\u786E\u7684\u7528\u6CD5\u793A\u4F8B:");
2514
- console.error(" cc-run glm -- <claude\u53C2\u6570> # \u4F7F\u7528 glm provider \u5E76\u900F\u4F20\u53C2\u6570");
2515
- console.error(" cc-run --claude -- <\u53C2\u6570> # \u6062\u590D\u5B98\u65B9\u914D\u7F6E\u5E76\u900F\u4F20\u53C2\u6570");
2516
- console.error(" cc-run glm --claude -- <\u53C2\u6570> # \u914D\u7F6E\u539F\u751F claude \u547D\u4EE4\u4F7F\u7528 glm");
2512
+ console.error("正确的用法示例:");
2513
+ console.error(" runcc glm -- <claude参数> # 使用 glm provider 并透传参数");
2514
+ console.error(" runcc --claude -- <参数> # 恢复官方配置并透传参数");
2515
+ console.error(" runcc glm --claude -- <参数> # 配置原生 claude 命令使用 glm");
2517
2516
  console.error("");
2518
- console.error("\u8BF4\u660E: -- \u5206\u9694\u7B26\u7528\u4E8E\u5C06\u540E\u7EED\u53C2\u6570\u900F\u4F20\u7ED9 Claude CLI");
2517
+ console.error("说明: -- 分隔符用于将后续参数透传给 Claude CLI");
2519
2518
  process.exit(1);
2520
2519
  }
2521
2520
  throw error;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "runcc",
3
- "version": "0.1.1",
3
+ "version": "0.1.3",
4
4
  "description": "CC launcher with endpoint switching support",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -0,0 +1,28 @@
1
+ #!/bin/bash
2
+ # 本地安装测试脚本
3
+
4
+ set -e
5
+
6
+ echo "🔨 构建项目..."
7
+ bun run build
8
+
9
+ echo ""
10
+ echo "📦 打包..."
11
+ npm pack
12
+
13
+ echo ""
14
+ echo "🌍 全局安装..."
15
+ PKG=$(ls runcc-*.tgz)
16
+ npm install -g ./$PKG
17
+
18
+ echo ""
19
+ echo "✅ 测试中文输出..."
20
+ runcc list
21
+
22
+ echo ""
23
+ echo "🧹 清理..."
24
+ npm uninstall -g runcc
25
+ rm $PKG
26
+
27
+ echo ""
28
+ echo "✨ 测试完成!"
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
- ```