aihezu 2.8.1 → 2.8.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
@@ -16,7 +16,7 @@
16
16
 
17
17
  - `ccinstall` / `install`:交互式配置 Claude(默认)或 Codex
18
18
  - Claude:默认 `https://cc.aihezu.dev/api`,企业可用 `--api` / `--api-url` 指定独立域名
19
- - Codex:默认 `https://cc.aihezu.dev/openai`,企业可用 `--api` / `--api-url` 指定独立域名;写入 `~/.codex/config.toml` 和 `auth.json`,使用 `AIHEZU_OAI_KEY`
19
+ - Codex:默认 `https://cc.aihezu.dev/openai`,企业可用 `--api` / `--api-url` 指定独立域名;写入 `~/.codex/config.toml` 和 `auth.json`,使用 `OPENAI_API_KEY`
20
20
  - `ccclear`:清理 Claude Code 缓存和配置
21
21
  - `usage`:查看 Claude Code / Codex / Gemini 用量统计(支持 `--key` 指定 API Key)
22
22
 
package/bin/aihezu.js CHANGED
@@ -52,7 +52,7 @@ function showHelp() {
52
52
  console.log(' 环境变量: ANTHROPIC_AUTH_TOKEN, ANTHROPIC_BASE_URL');
53
53
  console.log(' Codex:');
54
54
  console.log(' 配置文件: ~/.codex/config.toml, ~/.codex/auth.json');
55
- console.log(' 环境变量: AIHEZU_OAI_KEY');
55
+ console.log(' 环境变量: OPENAI_API_KEY');
56
56
  console.log(' Google Gemini:');
57
57
  console.log(' 配置文件: ~/.gemini/.env, ~/.gemini/settings.json (可选)');
58
58
  console.log(' 环境变量: GEMINI_API_KEY, GOOGLE_GEMINI_BASE_URL');
package/commands/check.js CHANGED
@@ -113,7 +113,7 @@ function checkCodex() {
113
113
  try {
114
114
  const authData = JSON.parse(fs.readFileSync(authPath, 'utf8'));
115
115
  console.log(' ✅ 文件存在');
116
- console.log(' 📝 AIHEZU_OAI_KEY:', maskSensitive(authData.AIHEZU_OAI_KEY));
116
+ console.log(' 📝 OPENAI_API_KEY:', maskSensitive(authData.OPENAI_API_KEY));
117
117
  } catch (e) {
118
118
  console.log(' ❌ 文件存在但格式错误:', e.message);
119
119
  }
@@ -123,8 +123,8 @@ function checkCodex() {
123
123
 
124
124
  // Check environment variables
125
125
  console.log('\n3️⃣ 环境变量:');
126
- const envKey = process.env.AIHEZU_OAI_KEY;
127
- console.log(' 📝 AIHEZU_OAI_KEY:', maskSensitive(envKey));
126
+ const envKey = process.env.OPENAI_API_KEY;
127
+ console.log(' 📝 OPENAI_API_KEY:', maskSensitive(envKey));
128
128
 
129
129
  // Priority explanation
130
130
  console.log('\n4️⃣ 优先级说明:');
package/commands/usage.js CHANGED
@@ -133,7 +133,7 @@ function readCodexConfig() {
133
133
  const configs = [];
134
134
 
135
135
  // 读取环境变量
136
- const envAuthToken = process.env.AIHEZU_OAI_KEY || '';
136
+ const envAuthToken = process.env.OPENAI_API_KEY || '';
137
137
 
138
138
  // 读取配置文件中的 base_url
139
139
  let fileBaseUrl = '';
@@ -159,7 +159,7 @@ function readCodexConfig() {
159
159
  try {
160
160
  const content = fs.readFileSync(authPath, 'utf8');
161
161
  const authData = JSON.parse(content);
162
- fileAuthToken = authData.AIHEZU_OAI_KEY || '';
162
+ fileAuthToken = authData.OPENAI_API_KEY || '';
163
163
  } catch (error) {
164
164
  // 忽略错误
165
165
  }
@@ -225,7 +225,7 @@ copy C:\Windows\System32\drivers\etc\hosts.backup-20260130123456 C:\Windows\Syst
225
225
  ```bash
226
226
  echo $ANTHROPIC_BASE_URL
227
227
  echo $ANTHROPIC_AUTH_TOKEN
228
- echo $AIHEZU_OAI_KEY
228
+ echo $OPENAI_API_KEY
229
229
  echo $GEMINI_API_KEY
230
230
  ```
231
231
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "aihezu",
3
- "version": "2.8.1",
3
+ "version": "2.8.2",
4
4
  "description": "AI 开发环境配置工具 - 支持 Claude Code, Codex, Google Gemini 的本地化配置、代理设置与缓存清理",
5
5
  "main": "bin/aihezu.js",
6
6
  "bin": {
package/services/codex.js CHANGED
@@ -32,75 +32,22 @@ module.exports = {
32
32
  fs.mkdirSync(configDir, { recursive: true });
33
33
  }
34
34
 
35
- // Handle config.toml
36
- let configContent = '';
37
- let existingConfig = '';
38
- let providerName = 'aihezu';
39
-
40
- if (fs.existsSync(configPath)) {
41
- existingConfig = fs.readFileSync(configPath, 'utf8');
42
-
43
- const providerMatch = existingConfig.match(/model_provider\s*=\s*"([^"]+)"/);
44
- if (providerMatch) {
45
- providerName = providerMatch[1];
46
- }
47
-
48
- // Update logic (simplified from original)
49
- let newConfig = existingConfig;
50
-
51
- // Update model
52
- const modelPattern = /^model\s*=\s*"[^"]*"/m;
53
- if (modelPattern.test(newConfig)) {
54
- newConfig = newConfig.replace(modelPattern, `model = "${modelName}"`);
55
- }
56
-
57
- // Update base_url
58
- const baseUrlPattern = new RegExp(
59
- `(\[model_providers\.${providerName}\][\s\S]*?base_url\s*=\s*)"[^"]*"`,
60
- 'm'
61
- );
62
-
63
- if (baseUrlPattern.test(newConfig)) {
64
- newConfig = newConfig.replace(baseUrlPattern, `$1"${apiUrl}"`);
65
- } else {
66
- // If provider block exists but no base_url (rare), or provider block missing
67
- const providerSectionPattern = new RegExp(`\[model_providers\.${providerName}\]`, 'm');
68
- if (providerSectionPattern.test(newConfig)) {
69
- newConfig = newConfig.replace(
70
- providerSectionPattern,
71
- `[model_providers.${providerName}]\nbase_url = "${apiUrl}"`
72
- );
73
- } else {
74
- // Append new provider
75
- newConfig = newConfig.trim() + '\n\n' +
76
- `[model_providers.${providerName}]\n` +
77
- `name = "${providerName}"\n` +
78
- `base_url = "${apiUrl}"\n` +
79
- `wire_api = "responses"\n` +
80
- `requires_openai_auth = true\n` +
81
- `env_key = "AIHEZU_OAI_KEY"\n`;
82
- }
83
- }
84
- configContent = newConfig;
85
-
86
- } else {
87
- // New Config
88
- configContent = [
89
- 'model_provider = "aihezu"',
90
- `model = "${modelName}"`,
91
- 'model_reasoning_effort = "high"',
92
- 'disable_response_storage = true',
93
- 'preferred_auth_method = "apikey"',
94
- '',
95
- '[model_providers.aihezu]',
96
- 'name = "aihezu"',
97
- `base_url = "${apiUrl}"`,
98
- 'wire_api = "responses"',
99
- 'requires_openai_auth = true',
100
- 'env_key = "AIHEZU_OAI_KEY"',
101
- ''
102
- ].join('\n');
103
- }
35
+ // Handle config.toml - always regenerate to avoid duplication issues
36
+ const providerName = 'aihezu';
37
+ const configContent = [
38
+ `model_provider = "${providerName}"`,
39
+ `model = "${modelName}"`,
40
+ 'model_reasoning_effort = "high"',
41
+ 'disable_response_storage = true',
42
+ 'preferred_auth_method = "apikey"',
43
+ '',
44
+ `[model_providers.${providerName}]`,
45
+ `name = "${providerName}"`,
46
+ `base_url = "${apiUrl}"`,
47
+ 'wire_api = "responses"',
48
+ 'requires_openai_auth = true',
49
+ ''
50
+ ].join('\n');
104
51
 
105
52
  fs.writeFileSync(configPath, configContent, 'utf8');
106
53
 
@@ -113,7 +60,9 @@ module.exports = {
113
60
  authData = {};
114
61
  }
115
62
  }
116
- authData.AIHEZU_OAI_KEY = apiKey;
63
+ // Remove legacy key if present
64
+ delete authData.AIHEZU_OAI_KEY;
65
+ authData.OPENAI_API_KEY = apiKey;
117
66
  fs.writeFileSync(authPath, JSON.stringify(authData, null, 2), 'utf8');
118
67
 
119
68
  // Fix permissions if running with sudo