runcc 0.1.4 → 0.1.5

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/CHANGELOG.md CHANGED
@@ -5,6 +5,17 @@ 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.5] - 2026-01-23
9
+
10
+ ### Fixed
11
+ - Fixed incorrect key/env configuration in Claude settings
12
+ - Migrated from apiUrl/anthropicApiKey fields to env.ANTHROPIC_* variables
13
+ - Fixed Claude Code integration to match actual configuration structure
14
+
15
+ ### Changed
16
+ - Added support for model mappings (ANTHROPIC_DEFAULT_*_MODEL) in --claude persistent mode
17
+ - Simplified installation instructions in README
18
+
8
19
  ## [0.1.4] - 2026-01-19
9
20
 
10
21
  ### Added
package/README.md CHANGED
@@ -13,11 +13,7 @@ Claude CLI 启动器,支持切换不同的 API endpoint。
13
13
  ## 安装
14
14
 
15
15
  ```bash
16
- # 全局安装
17
- bun install -g .
18
-
19
- # 或使用 npm
20
- npm install -g .
16
+ npm install runcc@latest -g
21
17
  ```
22
18
 
23
19
  ## 快速开始
@@ -53,11 +49,11 @@ runcc
53
49
  | `runcc add <name> <endpoint> [token]` | 添加自定义 endpoint |
54
50
  | `runcc remove <name>` | 删除自定义 endpoint |
55
51
 
56
- ### 原生命令配置
52
+ ### 原生命令配置(持久化)
57
53
 
58
54
  | 命令 | 说明 |
59
55
  |------|------|
60
- | `runcc <provider> --claude` | 配置原生 `claude` 命令使用第三方 endpoint |
56
+ | `runcc <provider> --claude` | 配置原生 `claude` 命令使用第三方 endpoint,持久化到 `~/.claude/settings.json` |
61
57
  | `runcc --claude` | 恢复原生 `claude` 命令使用官方 endpoint |
62
58
 
63
59
  ### 代理管理
@@ -106,12 +102,22 @@ runcc
106
102
 
107
103
  ### ~/.claude/settings.json
108
104
 
105
+ **使用官方 endpoint 时:**
109
106
  ```json
110
107
  {
111
108
  "proxy": "http://agent.baidu.com:8891"
112
109
  }
113
110
  ```
114
111
 
112
+ **运行 `runcc glm --claude` 后(使用第三方 endpoint):**
113
+ ```json
114
+ {
115
+ "apiUrl": "https://open.bigmodel.cn/api/paas/v4/",
116
+ "anthropicApiKey": "sk-glm-token",
117
+ "proxy": "http://agent.baidu.com:8891"
118
+ }
119
+ ```
120
+
115
121
  ## 使用示例
116
122
 
117
123
  ### 添加自定义 endpoint
@@ -146,19 +152,24 @@ runcc proxy status
146
152
  runcc proxy off
147
153
  ```
148
154
 
149
- ### 配置原生命令
155
+ ### 配置原生命令(持久化)
156
+
157
+ `--claude` 参数会将 endpoint 配置持久化写入 `~/.claude/settings.json`,之后直接运行 `claude` 命令时会使用指定的 endpoint。
150
158
 
151
159
  ```bash
152
160
  # 让原生 claude 命令使用 glm
161
+ # 这会将 glm 配置写入 ~/.claude/settings.json
153
162
  runcc glm --claude
154
163
 
155
- # 之后直接使用 claude 命令即可
164
+ # 之后直接使用 claude 命令即可,无需通过 runcc
156
165
  claude "你好"
157
166
 
158
167
  # 恢复使用官方 endpoint
159
168
  runcc --claude
160
169
  ```
161
170
 
171
+ **注意**:`--claude` 配置是持久的,关闭 Claude 后仍然生效。如需切换回官方 endpoint,需运行 `runcc --claude`。
172
+
162
173
  ## Token 管理
163
174
 
164
175
  首次使用某个 endpoint 时,如果未配置 token,会提示输入:
package/dist/index.js CHANGED
@@ -2148,16 +2148,38 @@ function removeClaudeProxy() {
2148
2148
  delete settings.proxy;
2149
2149
  writeClaudeSettings(settings);
2150
2150
  }
2151
- function setThirdPartyApi(apiUrl, apiKey) {
2151
+ function setThirdPartyApi(apiUrl, apiKey, models) {
2152
2152
  const settings = readClaudeSettings();
2153
- settings.apiUrl = apiUrl;
2154
- settings.anthropicApiKey = apiKey;
2153
+ if (!settings.env) {
2154
+ settings.env = {};
2155
+ }
2156
+ settings.env.ANTHROPIC_BASE_URL = apiUrl;
2157
+ settings.env.ANTHROPIC_AUTH_TOKEN = apiKey;
2158
+ if (models) {
2159
+ if (models.haiku) {
2160
+ settings.env.ANTHROPIC_DEFAULT_HAIKU_MODEL = models.haiku;
2161
+ }
2162
+ if (models.opus) {
2163
+ settings.env.ANTHROPIC_DEFAULT_OPUS_MODEL = models.opus;
2164
+ }
2165
+ if (models.sonnet) {
2166
+ settings.env.ANTHROPIC_DEFAULT_SONNET_MODEL = models.sonnet;
2167
+ }
2168
+ }
2155
2169
  writeClaudeSettings(settings);
2156
2170
  }
2157
2171
  function removeThirdPartyApi() {
2158
2172
  const settings = readClaudeSettings();
2159
- delete settings.apiUrl;
2160
- delete settings.anthropicApiKey;
2173
+ if (settings.env) {
2174
+ delete settings.env.ANTHROPIC_BASE_URL;
2175
+ delete settings.env.ANTHROPIC_AUTH_TOKEN;
2176
+ delete settings.env.ANTHROPIC_DEFAULT_HAIKU_MODEL;
2177
+ delete settings.env.ANTHROPIC_DEFAULT_OPUS_MODEL;
2178
+ delete settings.env.ANTHROPIC_DEFAULT_SONNET_MODEL;
2179
+ if (Object.keys(settings.env).length === 0) {
2180
+ delete settings.env;
2181
+ }
2182
+ }
2161
2183
  writeClaudeSettings(settings);
2162
2184
  }
2163
2185
  function backupClaudeSettings() {
@@ -2333,7 +2355,7 @@ async function runOfficial(passthroughArgs = []) {
2333
2355
  const claudeProxy = getClaudeProxy();
2334
2356
  const backup = backupClaudeSettings();
2335
2357
  let needsRestore = false;
2336
- if (backup.apiUrl || backup.anthropicApiKey) {
2358
+ if (backup.env?.ANTHROPIC_BASE_URL || backup.env?.ANTHROPIC_AUTH_TOKEN) {
2337
2359
  removeThirdPartyApi();
2338
2360
  needsRestore = true;
2339
2361
  console.log("已临时清除第三方 endpoint 配置");
@@ -2380,11 +2402,11 @@ async function runProvider(providerName, configureClaude, passthroughArgs = [])
2380
2402
  needsRestore = true;
2381
2403
  console.log("已临时清除 settings.json 中的 ANTHROPIC 配置");
2382
2404
  }
2383
- if (needsRestore) {
2405
+ if (needsRestore && !configureClaude) {
2384
2406
  console.log("Claude 退出后将恢复配置...");
2385
2407
  }
2386
2408
  if (configureClaude) {
2387
- setThirdPartyApi(endpoint.endpoint, token);
2409
+ setThirdPartyApi(endpoint.endpoint, token, endpoint.models);
2388
2410
  console.log(`已配置原生 claude 命令使用 ${providerName}`);
2389
2411
  console.log('使用 "runcc --claude" 可恢复官方配置');
2390
2412
  }
@@ -2395,7 +2417,7 @@ async function runProvider(providerName, configureClaude, passthroughArgs = [])
2395
2417
  models: endpoint.models
2396
2418
  }, passthroughArgs);
2397
2419
  const exitCode = await waitForExit(child);
2398
- if (needsRestore) {
2420
+ if (needsRestore && !configureClaude) {
2399
2421
  restoreClaudeSettings(backup);
2400
2422
  console.log("已恢复配置");
2401
2423
  }
@@ -2492,7 +2514,7 @@ proxyCmd.command("off").description("关闭代理").action(proxyOff);
2492
2514
  proxyCmd.command("reset").description("重置代理配置").action(proxyReset);
2493
2515
  proxyCmd.command("status").description("查看代理状态").action(proxyStatus);
2494
2516
  proxyCmd.command("help").description("代理帮助信息").action(proxyHelp);
2495
- program2.argument("[provider]", "provider 名称 (glm, deepseek, minimax 或自定义)").option("--claude", "配置原生 claude 命令").allowExcessArguments(true).action(async (provider, options) => {
2517
+ program2.argument("[provider]", "provider 名称 (glm, deepseek, minimax 或自定义)").option("--claude", "持久化配置到 ~/.claude/settings.json,让 claude 命令使用指定 endpoint").allowExcessArguments(true).action(async (provider, options) => {
2496
2518
  try {
2497
2519
  validateDashPosition(process.argv);
2498
2520
  const passthroughArgs = extractPassthroughArgs(process.argv);
@@ -2513,9 +2535,10 @@ program2.argument("[provider]", "provider 名称 (glm, deepseek, minimax 或自
2513
2535
  console.error(" runcc -- <claude参数> # 启动官方 Claude 并透传参数");
2514
2536
  console.error(" runcc glm -- <claude参数> # 使用 glm provider 并透传参数");
2515
2537
  console.error(" runcc --claude -- <参数> # 恢复官方配置并透传参数");
2516
- console.error(" runcc glm --claude -- <参数> # 配置原生 claude 命令使用 glm");
2538
+ console.error(" runcc glm --claude -- <参数> # 配置原生 claude 命令使用 glm(持久化)");
2517
2539
  console.error("");
2518
2540
  console.error("说明: -- 分隔符用于将后续参数透传给 Claude CLI");
2541
+ console.error(" --claude 会将配置写入 ~/.claude/settings.json,之后直接运行 claude 即可使用指定 endpoint");
2519
2542
  process.exit(1);
2520
2543
  }
2521
2544
  throw error;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "runcc",
3
- "version": "0.1.4",
3
+ "version": "0.1.5",
4
4
  "description": "CC launcher with endpoint switching support",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",