@pikecode/api-key-manager 1.0.8 → 1.0.10
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 +4 -0
- package/package.json +1 -1
- package/src/commands/switch.js +17 -11
- package/src/utils/env-launcher.js +16 -5
package/README.md
CHANGED
package/package.json
CHANGED
package/src/commands/switch.js
CHANGED
|
@@ -200,9 +200,12 @@ class EnvSwitcher extends BaseCommand {
|
|
|
200
200
|
|
|
201
201
|
async launchProvider(provider, selectedLaunchArgs) {
|
|
202
202
|
try {
|
|
203
|
-
|
|
204
|
-
if (
|
|
205
|
-
|
|
203
|
+
// 只对 Claude Code 执行设置兼容性检查
|
|
204
|
+
if (provider.ideName !== 'codex') {
|
|
205
|
+
const shouldContinue = await this.ensureClaudeSettingsCompatibility(provider);
|
|
206
|
+
if (!shouldContinue) {
|
|
207
|
+
return;
|
|
208
|
+
}
|
|
206
209
|
}
|
|
207
210
|
|
|
208
211
|
this.clearScreen();
|
|
@@ -214,25 +217,28 @@ class EnvSwitcher extends BaseCommand {
|
|
|
214
217
|
console.log(UIHelper.createCard('启动参数', selectedLaunchArgs.join(', '), UIHelper.icons.settings));
|
|
215
218
|
}
|
|
216
219
|
console.log();
|
|
217
|
-
|
|
220
|
+
|
|
218
221
|
// 显示进度
|
|
219
222
|
const loadingInterval = UIHelper.createLoadingAnimation('正在设置环境...');
|
|
220
|
-
|
|
223
|
+
|
|
221
224
|
try {
|
|
222
225
|
// 设置为当前供应商
|
|
223
226
|
await this.configManager.setCurrentProvider(provider.name);
|
|
224
|
-
|
|
227
|
+
|
|
225
228
|
// 更新使用统计
|
|
226
229
|
provider.usageCount = (provider.usageCount || 0) + 1;
|
|
227
230
|
provider.lastUsed = new Date().toISOString();
|
|
228
231
|
await this.configManager.save();
|
|
229
|
-
|
|
232
|
+
|
|
230
233
|
UIHelper.clearLoadingAnimation(loadingInterval);
|
|
231
|
-
|
|
232
|
-
|
|
234
|
+
|
|
235
|
+
// 根据 IDE 类型显示不同的启动提示
|
|
236
|
+
const ideName = provider.ideName === 'codex' ? 'Codex' : 'Claude Code';
|
|
237
|
+
const ideIcon = provider.ideName === 'codex' ? '⚙️' : '🚀';
|
|
238
|
+
console.log(UIHelper.createCard('准备就绪', `环境配置完成,正在启动 ${ideIcon} ${ideName}...`, UIHelper.icons.success));
|
|
233
239
|
console.log();
|
|
234
|
-
|
|
235
|
-
//
|
|
240
|
+
|
|
241
|
+
// 设置环境变量并启动对应的 IDE
|
|
236
242
|
await executeWithEnv(provider, selectedLaunchArgs);
|
|
237
243
|
|
|
238
244
|
} catch (error) {
|
|
@@ -24,8 +24,9 @@ function clearTerminal() {
|
|
|
24
24
|
function buildEnvVariables(config) {
|
|
25
25
|
const env = { ...process.env };
|
|
26
26
|
|
|
27
|
-
// Claude Code
|
|
28
|
-
|
|
27
|
+
// Claude Code 配置(明确检查 ideName === 'claude')
|
|
28
|
+
// 注意:不再使用 !config.ideName 作为默认值,避免混淆
|
|
29
|
+
if (config.ideName === 'claude') {
|
|
29
30
|
if (config.authMode === 'oauth_token') {
|
|
30
31
|
env.CLAUDE_CODE_OAUTH_TOKEN = config.authToken;
|
|
31
32
|
} else if (config.authMode === 'api_key') {
|
|
@@ -75,14 +76,24 @@ function buildEnvVariables(config) {
|
|
|
75
76
|
}
|
|
76
77
|
|
|
77
78
|
async function executeWithEnv(config, launchArgs = []) {
|
|
79
|
+
// 安全检查:确保 ideName 被明确设置
|
|
80
|
+
if (!config.ideName) {
|
|
81
|
+
throw new Error('供应商配置缺少 ideName 字段,无法启动 IDE');
|
|
82
|
+
}
|
|
83
|
+
|
|
78
84
|
const env = buildEnvVariables(config);
|
|
79
85
|
const args = [...launchArgs];
|
|
80
86
|
|
|
81
87
|
clearTerminal();
|
|
82
88
|
|
|
83
|
-
// 确定要启动的命令(claude 或 codex)
|
|
84
|
-
|
|
85
|
-
const
|
|
89
|
+
// 根据 ideName 确定要启动的命令(claude 或 codex)
|
|
90
|
+
// 这是关键的 IDE 选择点 - 避免任何混淆
|
|
91
|
+
const isCodex = config.ideName === 'codex';
|
|
92
|
+
const command = isCodex ? 'codex' : 'claude';
|
|
93
|
+
const description = isCodex ? 'Codex' : 'Claude Code';
|
|
94
|
+
const ideIcon = isCodex ? '⚙️' : '🚀';
|
|
95
|
+
|
|
96
|
+
console.log(`\n启动 ${ideIcon} ${description}...\n`);
|
|
86
97
|
|
|
87
98
|
return new Promise((resolve, reject) => {
|
|
88
99
|
const child = spawn(command, args, {
|