yymaxapi 1.0.97 → 1.0.98

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
@@ -23,6 +23,8 @@ $env:OPENCLAW_CLAUDE_KEY="你的Key"; npx yymaxapi@latest preset-claude
23
23
  set OPENCLAW_CLAUDE_KEY=你的Key && npx yymaxapi@latest preset-claude
24
24
  ```
25
25
 
26
+ 说明:`preset-claude` 现在只写 Claude Code CLI 自身配置,不会改动 OpenClaw、Codex CLI、Opencode。
27
+
26
28
  **方式三:一键配置 Codex**
27
29
  ```bash
28
30
  # macOS/Linux
@@ -38,22 +40,22 @@ set OPENCLAW_CODEX_KEY=你的Key && npx yymaxapi@latest preset-codex
38
40
  **方式四:完全自动化(无交互)**
39
41
  ```bash
40
42
  # macOS/Linux
41
- OPENCLAW_CLAUDE_KEY="你的Key" npx yymaxapi@latest preset-claude --model claude-opus-4-5 --set-primary true --force --test true
43
+ OPENCLAW_CLAUDE_KEY="你的Key" npx yymaxapi@latest preset-claude --model claude-opus-4-6 --set-primary true --force --test true
42
44
 
43
45
  # Windows PowerShell
44
- $env:OPENCLAW_CLAUDE_KEY="你的Key"; npx yymaxapi@latest preset-claude --model claude-opus-4-5 --set-primary true --force --test true
46
+ $env:OPENCLAW_CLAUDE_KEY="你的Key"; npx yymaxapi@latest preset-claude --model claude-opus-4-6 --set-primary true --force --test true
45
47
 
46
48
  # Windows CMD
47
- set OPENCLAW_CLAUDE_KEY=你的Key && npx yymaxapi@latest preset-claude --model claude-opus-4-5 --set-primary true --force --test true
49
+ set OPENCLAW_CLAUDE_KEY=你的Key && npx yymaxapi@latest preset-claude --model claude-opus-4-6 --set-primary true --force --test true
48
50
 
49
51
  # macOS/Linux
50
- OPENCLAW_CODEX_KEY="你的Key" npx yymaxapi@latest preset-codex --model gpt-5.2 --set-primary true --force --test true
52
+ OPENCLAW_CODEX_KEY="你的Key" npx yymaxapi@latest preset-codex --model gpt-5.4 --set-primary true --force --test true
51
53
 
52
54
  # Windows PowerShell
53
- $env:OPENCLAW_CODEX_KEY="你的Key"; npx yymaxapi@latest preset-codex --model gpt-5.2 --set-primary true --force --test true
55
+ $env:OPENCLAW_CODEX_KEY="你的Key"; npx yymaxapi@latest preset-codex --model gpt-5.4 --set-primary true --force --test true
54
56
 
55
57
  # Windows CMD
56
- set OPENCLAW_CODEX_KEY=你的Key && npx yymaxapi@latest preset-codex --model gpt-5.2 --set-primary true --force --test true
58
+ set OPENCLAW_CODEX_KEY=你的Key && npx yymaxapi@latest preset-codex --model gpt-5.4 --set-primary true --force --test true
57
59
  ```
58
60
 
59
61
  ## 重要说明
package/bin/yymaxapi.js CHANGED
@@ -829,82 +829,23 @@ function writeConfig(configPath, config) {
829
829
  // ============ 多工具配置同步 ============
830
830
 
831
831
  function writeClaudeCodeSettings(baseUrl, apiKey, modelId = getDefaultClaudeModel().id) {
832
- const home = os.homedir();
833
832
  // ~/.claude/settings.json
834
- const claudeDir = path.join(home, '.claude');
835
- const settingsPath = path.join(claudeDir, 'settings.json');
833
+ const settingsPath = getClaudeCodeSettingsPath();
834
+ const claudeDir = path.dirname(settingsPath);
836
835
  try {
837
836
  let settings = {};
838
837
  if (fs.existsSync(settingsPath)) {
839
838
  try { settings = JSON.parse(fs.readFileSync(settingsPath, 'utf8')); } catch { settings = {}; }
840
839
  }
841
840
  settings.apiBaseUrl = baseUrl.replace(/\/+$/, '');
842
- settings.model = modelId;
843
- settings.availableModels = CLAUDE_MODELS.map(model => model.id);
844
841
  if (!settings.env) settings.env = {};
845
- settings.env.ANTHROPIC_BASE_URL = baseUrl.replace(/\/+$/, '');
846
842
  settings.env.ANTHROPIC_AUTH_TOKEN = apiKey;
847
- settings.env.ANTHROPIC_MODEL = modelId;
843
+ delete settings.availableModels;
844
+ delete settings.env.ANTHROPIC_BASE_URL;
845
+ delete settings.env.ANTHROPIC_MODEL;
848
846
  if (!fs.existsSync(claudeDir)) fs.mkdirSync(claudeDir, { recursive: true });
849
847
  fs.writeFileSync(settingsPath, JSON.stringify(settings, null, 2), 'utf8');
850
848
  } catch { /* 非关键,静默失败 */ }
851
-
852
- // ~/.claude.json — 跳过 onboarding
853
- const claudeJsonPath = path.join(home, '.claude.json');
854
- try {
855
- let claudeJson = {};
856
- if (fs.existsSync(claudeJsonPath)) {
857
- try { claudeJson = JSON.parse(fs.readFileSync(claudeJsonPath, 'utf8')); } catch { claudeJson = {}; }
858
- }
859
- if (!claudeJson.hasCompletedOnboarding) {
860
- claudeJson.hasCompletedOnboarding = true;
861
- fs.writeFileSync(claudeJsonPath, JSON.stringify(claudeJson, null, 2), 'utf8');
862
- }
863
- } catch { /* 非关键,静默失败 */ }
864
-
865
- // 写入 shell 环境变量
866
- if (process.platform === 'win32') {
867
- try {
868
- const cleanUrl = baseUrl.replace(/\/+$/, '');
869
- execSync(
870
- `powershell -NoProfile -Command "[Environment]::SetEnvironmentVariable('ANTHROPIC_BASE_URL','${cleanUrl}','User'); [Environment]::SetEnvironmentVariable('ANTHROPIC_AUTH_TOKEN','${apiKey}','User'); [Environment]::SetEnvironmentVariable('ANTHROPIC_MODEL','${modelId}','User')"`,
871
- { stdio: 'pipe' }
872
- );
873
- } catch { /* best-effort */ }
874
- } else {
875
- const marker = '# >>> yymaxapi claude >>>';
876
- const markerEnd = '# <<< yymaxapi claude <<<';
877
- const cleanUrl = baseUrl.replace(/\/+$/, '');
878
- // 只持久化工具本身需要的 Claude 变量,TLS 放宽只能留在进程内临时使用。
879
- const block = [
880
- marker,
881
- `export ANTHROPIC_BASE_URL="${cleanUrl}"`,
882
- `export ANTHROPIC_AUTH_TOKEN="${apiKey}"`,
883
- `export ANTHROPIC_MODEL="${modelId}"`,
884
- markerEnd
885
- ].join('\n');
886
-
887
- const shellEnv = process.env.SHELL || '';
888
- const rcFiles = [];
889
- if (shellEnv.includes('zsh') || !shellEnv) rcFiles.push(path.join(home, '.zshrc'));
890
- if (shellEnv.includes('bash') || !shellEnv) rcFiles.push(path.join(home, '.bashrc'));
891
- if (rcFiles.length === 0) rcFiles.push(path.join(home, '.profile'));
892
-
893
- for (const rcFile of rcFiles) {
894
- try {
895
- let content = '';
896
- if (fs.existsSync(rcFile)) {
897
- content = fs.readFileSync(rcFile, 'utf8');
898
- const re = new RegExp(
899
- `${marker.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')}[\\s\\S]*?${markerEnd.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')}\\n?`,
900
- 'g'
901
- );
902
- content = content.replace(re, '').trimEnd();
903
- }
904
- fs.writeFileSync(rcFile, content ? `${content}\n\n${block}\n` : `${block}\n`, 'utf8');
905
- } catch { /* best-effort */ }
906
- }
907
- }
908
849
  }
909
850
 
910
851
  function writeCodexConfig(baseUrl, apiKey, modelId = 'gpt-5.4') {
@@ -4817,9 +4758,8 @@ async function activateClaudeCode(paths, args = {}) {
4817
4758
  console.log(chalk.gray(' API Key: 已设置'));
4818
4759
  console.log(chalk.gray('\n 已写入:'));
4819
4760
  console.log(chalk.gray(' • ~/.claude/settings.json'));
4820
- console.log(chalk.gray(' • ~/.claude.json (跳过 onboarding)'));
4821
- console.log(chalk.gray(' shell 环境变量 (ANTHROPIC_BASE_URL, ANTHROPIC_AUTH_TOKEN, ANTHROPIC_MODEL)'));
4822
- console.log(chalk.yellow('\n 提示: 请重新打开终端或执行 source ~/.zshrc 使环境变量生效'));
4761
+ console.log(chalk.gray(' • 最小字段: apiBaseUrl + env.ANTHROPIC_AUTH_TOKEN'));
4762
+ console.log(chalk.yellow('\n 提示: 如果 Claude Code 已在运行,重新打开一个会话即可读取新配置'));
4823
4763
 
4824
4764
  if (await confirmImmediateTest(args, '是否立即测试 Claude Code CLI 连接?')) {
4825
4765
  await testAdditionalCliConnections(args, { only: ['claude'] });
@@ -5200,7 +5140,7 @@ async function main() {
5200
5140
  return;
5201
5141
  }
5202
5142
  if (args.preset === 'claude' || args._.includes('preset-claude') || args._.includes('claude-preset')) {
5203
- await autoActivate(paths, { ...args, primary: 'claude' });
5143
+ await activateClaudeCode(paths, args);
5204
5144
  return;
5205
5145
  }
5206
5146
  if (args.preset === 'codex' || args._.includes('preset-codex') || args._.includes('codex-preset')) {
@@ -148,21 +148,20 @@ npx yymaxapi@latest
148
148
 
149
149
  **2. Claude Code CLI(本机终端)**
150
150
 
151
- 在终端执行一次,或写入 `~/.zshrc` / `~/.bashrc` 后 `source`,Claude Code 即走云翼 Claude:
151
+ 推荐直接写 `settings.json` 最小配置:
152
152
 
153
- ```bash
154
- export ANTHROPIC_BASE_URL="https://yunyi.rdzhvip.com/claude"
155
- export ANTHROPIC_AUTH_TOKEN="<你的云翼 API Key>"
156
- # 若遇证书报错可加:
157
- export NODE_TLS_REJECT_UNAUTHORIZED=0
153
+ ```json
154
+ {
155
+ "apiBaseUrl": "https://yunyi.rdzhvip.com/claude",
156
+ "env": {
157
+ "ANTHROPIC_AUTH_TOKEN": "<你的云翼 API Key>"
158
+ }
159
+ }
158
160
  ```
159
161
 
160
- Windows(PowerShell,用户级环境变量):
162
+ 文件位置:
161
163
 
162
- ```powershell
163
- [Environment]::SetEnvironmentVariable('ANTHROPIC_BASE_URL', 'https://yunyi.rdzhvip.com/claude', 'User')
164
- [Environment]::SetEnvironmentVariable('ANTHROPIC_AUTH_TOKEN', '<你的云翼 API Key>', 'User')
165
- [Environment]::SetEnvironmentVariable('NODE_TLS_REJECT_UNAUTHORIZED', '0', 'User')
166
- ```
164
+ - macOS / Linux:`~/.claude/settings.json`
165
+ - Windows:`%USERPROFILE%\\.claude\\settings.json`
167
166
 
168
167
  完成后:腾讯云 OpenClaw 里可选 Claude 或 GPT;本机 Claude Code CLI 使用同一 Key 走云翼 Claude。
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "yymaxapi",
3
- "version": "1.0.97",
3
+ "version": "1.0.98",
4
4
  "description": "跨平台 OpenClaw/Clawdbot 配置管理工具 - 管理中转地址、模型切换、API Keys、测速优化",
5
5
  "main": "bin/yymaxapi.js",
6
6
  "bin": {