@pikecode/api-key-manager 2.1.2 → 2.1.3
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 +1 -1
- package/src/commands/switch.js +1 -0
- package/src/utils/env-launcher.js +16 -4
package/package.json
CHANGED
package/src/commands/switch.js
CHANGED
|
@@ -210,6 +210,7 @@ class EnvSwitcher extends BaseCommand {
|
|
|
210
210
|
console.log(UIHelper.createCard('准备就绪', `环境配置完成,正在启动 🚀 ${ideDisplayName}(新会话)...`, UIHelper.icons.success));
|
|
211
211
|
console.log();
|
|
212
212
|
await launchProviderProcess(provider, retryArgs);
|
|
213
|
+
return;
|
|
213
214
|
} catch (retryError) {
|
|
214
215
|
UIHelper.clearLoadingAnimation(retryLoadingInterval);
|
|
215
216
|
throw retryError;
|
|
@@ -59,18 +59,24 @@ async function executeWithEnv(config, launchArgs = []) {
|
|
|
59
59
|
|
|
60
60
|
return new Promise((resolve, reject) => {
|
|
61
61
|
const child = spawn('claude', args, {
|
|
62
|
-
stdio: ['inherit', '
|
|
62
|
+
stdio: ['inherit', 'pipe', 'pipe'],
|
|
63
63
|
env,
|
|
64
64
|
shell: false
|
|
65
65
|
});
|
|
66
66
|
|
|
67
67
|
let stderrOutput = '';
|
|
68
|
+
let stdoutOutput = '';
|
|
69
|
+
|
|
70
|
+
// 捕获 stdout 和 stderr 用于检查错误信息
|
|
71
|
+
child.stdout.on('data', (data) => {
|
|
72
|
+
const output = data.toString();
|
|
73
|
+
stdoutOutput += output;
|
|
74
|
+
process.stdout.write(data);
|
|
75
|
+
});
|
|
68
76
|
|
|
69
|
-
// 捕获 stderr 用于检查错误信息
|
|
70
77
|
child.stderr.on('data', (data) => {
|
|
71
78
|
const output = data.toString();
|
|
72
79
|
stderrOutput += output;
|
|
73
|
-
// 同时输出 stderr 给用户
|
|
74
80
|
process.stderr.write(data);
|
|
75
81
|
});
|
|
76
82
|
|
|
@@ -79,7 +85,13 @@ async function executeWithEnv(config, launchArgs = []) {
|
|
|
79
85
|
resolve();
|
|
80
86
|
} else {
|
|
81
87
|
// 检查是否是"没有可恢复会话"的错误
|
|
82
|
-
|
|
88
|
+
// 检查 stdout 和 stderr 中是否包含错误消息
|
|
89
|
+
const combinedOutput = (stderrOutput + stdoutOutput).toLowerCase();
|
|
90
|
+
const isNoConversationError =
|
|
91
|
+
combinedOutput.includes('no conversation found') ||
|
|
92
|
+
combinedOutput.includes('no recoverable session');
|
|
93
|
+
|
|
94
|
+
if (isNoConversationError) {
|
|
83
95
|
const error = new Error('没有可恢复的会话\n提示: 请选择不带 --continue 参数重新开始');
|
|
84
96
|
error.code = 'NO_CONVERSATION_FOUND';
|
|
85
97
|
reject(error);
|