@pikecode/api-key-manager 1.0.6 → 1.0.8
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/package.json
CHANGED
package/src/commands/add.js
CHANGED
|
@@ -34,17 +34,18 @@ class ProviderAdder extends BaseCommand {
|
|
|
34
34
|
}, '取消添加');
|
|
35
35
|
|
|
36
36
|
try {
|
|
37
|
-
//
|
|
37
|
+
// 首先选择 IDE 类型或使用官方预设
|
|
38
38
|
const typeAnswer = await this.prompt([
|
|
39
39
|
{
|
|
40
40
|
type: 'list',
|
|
41
41
|
name: 'providerType',
|
|
42
|
-
message: '
|
|
42
|
+
message: '选择配置方式:',
|
|
43
43
|
choices: [
|
|
44
|
-
{ name: '🔒 官方 Claude Code (OAuth)', value: 'official_oauth' },
|
|
45
|
-
{ name: '
|
|
44
|
+
{ name: '🔒 官方 Claude Code (OAuth) - 推荐使用官方 token', value: 'official_oauth' },
|
|
45
|
+
{ name: '🚀 Claude Code - 自定义配置 (API Key 或 Auth Token)', value: 'custom_claude' },
|
|
46
|
+
{ name: '⚙️ Codex - OpenAI Codex (ChatGPT 登录或 API Key)', value: 'custom_codex' }
|
|
46
47
|
],
|
|
47
|
-
default: '
|
|
48
|
+
default: 'custom_claude'
|
|
48
49
|
}
|
|
49
50
|
]);
|
|
50
51
|
|
|
@@ -53,8 +54,12 @@ class ProviderAdder extends BaseCommand {
|
|
|
53
54
|
|
|
54
55
|
if (typeAnswer.providerType === 'official_oauth') {
|
|
55
56
|
return await this.addOfficialOAuthProvider();
|
|
57
|
+
} else if (typeAnswer.providerType === 'custom_codex') {
|
|
58
|
+
// 直接进入 Codex 配置流程,跳过 IDE 选择
|
|
59
|
+
return await this.addCustomProvider(true);
|
|
56
60
|
} else {
|
|
57
|
-
|
|
61
|
+
// 进入通用自定义配置流程
|
|
62
|
+
return await this.addCustomProvider(false);
|
|
58
63
|
}
|
|
59
64
|
} catch (error) {
|
|
60
65
|
// 移除 ESC 键监听
|
|
@@ -151,8 +156,9 @@ class ProviderAdder extends BaseCommand {
|
|
|
151
156
|
}
|
|
152
157
|
}
|
|
153
158
|
|
|
154
|
-
async addCustomProvider() {
|
|
155
|
-
|
|
159
|
+
async addCustomProvider(forceCodex = false) {
|
|
160
|
+
const ideLabel = forceCodex ? 'Codex' : '自定义';
|
|
161
|
+
console.log(UIHelper.createTitle(`添加${ideLabel}供应商`, UIHelper.icons.add));
|
|
156
162
|
console.log();
|
|
157
163
|
console.log(UIHelper.createTooltip('请填写供应商配置信息'));
|
|
158
164
|
console.log();
|
|
@@ -163,7 +169,7 @@ class ProviderAdder extends BaseCommand {
|
|
|
163
169
|
['ESC', '取消添加']
|
|
164
170
|
]));
|
|
165
171
|
console.log();
|
|
166
|
-
|
|
172
|
+
|
|
167
173
|
// 设置 ESC 键监听
|
|
168
174
|
const escListener = this.createESCListener(() => {
|
|
169
175
|
Logger.info('取消添加供应商');
|
|
@@ -202,7 +208,9 @@ class ProviderAdder extends BaseCommand {
|
|
|
202
208
|
{ name: '🚀 Claude Code - Anthropic 官方代码编辑器', value: 'claude' },
|
|
203
209
|
{ name: '⚙️ Codex - 代码生成和编辑工具', value: 'codex' }
|
|
204
210
|
],
|
|
205
|
-
default: 'claude'
|
|
211
|
+
default: forceCodex ? 'codex' : 'claude',
|
|
212
|
+
// 如果来自 Codex 快捷方式,跳过此选择(IDE 已确定为 Codex)
|
|
213
|
+
when: () => !forceCodex
|
|
206
214
|
},
|
|
207
215
|
{
|
|
208
216
|
type: 'list',
|
|
@@ -370,9 +378,12 @@ class ProviderAdder extends BaseCommand {
|
|
|
370
378
|
? await this.promptModelConfiguration()
|
|
371
379
|
: { primaryModel: null, smallFastModel: null };
|
|
372
380
|
|
|
381
|
+
// 如果是 Codex 快捷方式,确保 ideName 被设置为 'codex'
|
|
382
|
+
const finalIdeName = forceCodex ? 'codex' : answers.ideName;
|
|
383
|
+
|
|
373
384
|
await this.configManager.addProvider(answers.name, {
|
|
374
385
|
displayName: answers.displayName || answers.name,
|
|
375
|
-
ideName:
|
|
386
|
+
ideName: finalIdeName, // 'claude' 或 'codex'
|
|
376
387
|
baseUrl: answers.baseUrl,
|
|
377
388
|
authToken: answers.authToken,
|
|
378
389
|
authMode: answers.authMode,
|
package/src/commands/switch.js
CHANGED
|
@@ -40,11 +40,13 @@ class EnvSwitcher extends BaseCommand {
|
|
|
40
40
|
console.log();
|
|
41
41
|
console.log(UIHelper.createCard('供应商', UIHelper.formatProvider(provider), UIHelper.icons.info));
|
|
42
42
|
console.log();
|
|
43
|
+
// 根据 IDE 类型动态显示启动提示
|
|
44
|
+
const launchLabel = provider.ideName === 'codex' ? '启动 Codex' : '启动 Claude Code';
|
|
43
45
|
console.log(UIHelper.createHintLine([
|
|
44
46
|
['空格', '切换选中'],
|
|
45
47
|
['A', '全选'],
|
|
46
48
|
['I', '反选'],
|
|
47
|
-
['Enter',
|
|
49
|
+
['Enter', launchLabel],
|
|
48
50
|
['ESC', '返回供应商选择']
|
|
49
51
|
]));
|
|
50
52
|
console.log();
|
|
@@ -13,6 +13,21 @@ class ProviderStatusChecker {
|
|
|
13
13
|
return this._result('unknown', '未找到配置', null);
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
+
// Codex 的特殊处理
|
|
17
|
+
if (provider.ideName === 'codex') {
|
|
18
|
+
if (provider.authMode === 'chatgpt_login') {
|
|
19
|
+
return this._result('online', '使用 ChatGPT 登录', null);
|
|
20
|
+
}
|
|
21
|
+
if (provider.authMode === 'api_key' && !provider.authToken) {
|
|
22
|
+
return this._result('unknown', '未配置 OpenAI API Key', null);
|
|
23
|
+
}
|
|
24
|
+
// Codex 的 api_key 模式支持检测(通过 OpenAI API)
|
|
25
|
+
// 但目前我们暂不实现 OpenAI SDK 的检测,只提示已配置
|
|
26
|
+
if (provider.authMode === 'api_key') {
|
|
27
|
+
return this._result('online', '已配置 OpenAI API Key', null);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
16
31
|
if (provider.authMode === 'oauth_token') {
|
|
17
32
|
return this._result('unknown', '暂不支持 OAuth 令牌检测', null);
|
|
18
33
|
}
|
package/src/utils/ui-helper.js
CHANGED
|
@@ -77,7 +77,13 @@ class UIHelper {
|
|
|
77
77
|
const status = provider.current ? 'current' : 'inactive';
|
|
78
78
|
const statusText = this.createStatus(status, provider.name);
|
|
79
79
|
const displayName = this.colors.secondary(`(${provider.displayName})`);
|
|
80
|
-
|
|
80
|
+
|
|
81
|
+
// 添加 IDE 类型标识
|
|
82
|
+
const ideIcon = provider.ideName === 'codex' ? '⚙️' : '🚀';
|
|
83
|
+
const ideLabel = provider.ideName === 'codex' ? 'Codex' : 'Claude Code';
|
|
84
|
+
const ideText = this.colors.muted(`[${ideIcon} ${ideLabel}]`);
|
|
85
|
+
|
|
86
|
+
return `${statusText} ${displayName} ${ideText}`;
|
|
81
87
|
}
|
|
82
88
|
|
|
83
89
|
// 创建进度条
|