clawt 3.6.1 → 3.6.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/dist/index.js +8 -2
- package/package.json +1 -1
- package/src/utils/conflict-resolver.ts +2 -0
- package/src/utils/shell.ts +12 -0
package/dist/index.js
CHANGED
|
@@ -958,6 +958,10 @@ function enableConsoleTransport() {
|
|
|
958
958
|
|
|
959
959
|
// src/utils/shell.ts
|
|
960
960
|
import { execSync, execFileSync, spawn, spawnSync } from "child_process";
|
|
961
|
+
function getEnvWithoutNestedSessionFlag() {
|
|
962
|
+
const { CLAUDECODE: _, ...env } = process.env;
|
|
963
|
+
return env;
|
|
964
|
+
}
|
|
961
965
|
function execCommand(command, options) {
|
|
962
966
|
logger.debug(`\u6267\u884C\u547D\u4EE4: ${command}${options?.cwd ? ` (cwd: ${options.cwd})` : ""}`);
|
|
963
967
|
const result = execSync(command, {
|
|
@@ -971,7 +975,8 @@ function spawnProcess(command, args, options) {
|
|
|
971
975
|
logger.debug(`\u542F\u52A8\u5B50\u8FDB\u7A0B: ${command} ${args.join(" ")}${options?.cwd ? ` (cwd: ${options.cwd})` : ""}`);
|
|
972
976
|
return spawn(command, args, {
|
|
973
977
|
cwd: options?.cwd,
|
|
974
|
-
stdio: options?.stdio ?? ["pipe", "pipe", "pipe"]
|
|
978
|
+
stdio: options?.stdio ?? ["pipe", "pipe", "pipe"],
|
|
979
|
+
env: getEnvWithoutNestedSessionFlag()
|
|
975
980
|
});
|
|
976
981
|
}
|
|
977
982
|
function killAllChildProcesses(children) {
|
|
@@ -4216,7 +4221,8 @@ function invokeClaudeForConflictResolve(prompt, cwd) {
|
|
|
4216
4221
|
cwd,
|
|
4217
4222
|
encoding: "utf-8",
|
|
4218
4223
|
stdio: ["pipe", "pipe", "pipe"],
|
|
4219
|
-
timeout: getConflictResolveTimeout()
|
|
4224
|
+
timeout: getConflictResolveTimeout(),
|
|
4225
|
+
env: getEnvWithoutNestedSessionFlag()
|
|
4220
4226
|
});
|
|
4221
4227
|
return output;
|
|
4222
4228
|
} catch (error) {
|
package/package.json
CHANGED
|
@@ -7,6 +7,7 @@ import { printInfo, printSuccess, printWarning } from './formatter.js';
|
|
|
7
7
|
import { confirmAction } from './formatter.js';
|
|
8
8
|
import { MESSAGES } from '../constants/index.js';
|
|
9
9
|
import { CONFLICT_RESOLVE_PROMPT } from '../constants/ai-prompts.js';
|
|
10
|
+
import { getEnvWithoutNestedSessionFlag } from './shell.js';
|
|
10
11
|
|
|
11
12
|
/** 默认 Claude Code 冲突解决超时时间(毫秒) */
|
|
12
13
|
const DEFAULT_CONFLICT_RESOLVE_TIMEOUT_MS = 300000;
|
|
@@ -51,6 +52,7 @@ export function invokeClaudeForConflictResolve(prompt: string, cwd: string): str
|
|
|
51
52
|
encoding: 'utf-8',
|
|
52
53
|
stdio: ['pipe', 'pipe', 'pipe'],
|
|
53
54
|
timeout: getConflictResolveTimeout(),
|
|
55
|
+
env: getEnvWithoutNestedSessionFlag(),
|
|
54
56
|
});
|
|
55
57
|
return output;
|
|
56
58
|
} catch (error: unknown) {
|
package/src/utils/shell.ts
CHANGED
|
@@ -1,6 +1,17 @@
|
|
|
1
1
|
import { execSync, execFileSync, spawn, spawnSync, type ChildProcess, type SpawnSyncReturns, type StdioOptions } from 'node:child_process';
|
|
2
2
|
import { logger } from '../logger/index.js';
|
|
3
3
|
|
|
4
|
+
/**
|
|
5
|
+
* 获取移除了 CLAUDECODE 嵌套会话标记的环境变量副本
|
|
6
|
+
* 仅用于 claude -p 等非交互式子进程,避免被 Claude Code 误判为嵌套会话而拒绝启动
|
|
7
|
+
* 不适用于交互式启动 Claude Code(如 clawt resume),交互式场景应保留原始环境变量
|
|
8
|
+
* @returns {NodeJS.ProcessEnv} 移除 CLAUDECODE 后的环境变量
|
|
9
|
+
*/
|
|
10
|
+
export function getEnvWithoutNestedSessionFlag(): NodeJS.ProcessEnv {
|
|
11
|
+
const { CLAUDECODE: _, ...env } = process.env;
|
|
12
|
+
return env;
|
|
13
|
+
}
|
|
14
|
+
|
|
4
15
|
/** 并行命令执行的单个结果 */
|
|
5
16
|
export interface ParallelCommandResult {
|
|
6
17
|
/** 执行的命令字符串 */
|
|
@@ -63,6 +74,7 @@ export function spawnProcess(
|
|
|
63
74
|
return spawn(command, args, {
|
|
64
75
|
cwd: options?.cwd,
|
|
65
76
|
stdio: options?.stdio ?? ['pipe', 'pipe', 'pipe'],
|
|
77
|
+
env: getEnvWithoutNestedSessionFlag(),
|
|
66
78
|
});
|
|
67
79
|
}
|
|
68
80
|
|