nikou-cli 0.1.4 → 0.1.5
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 +18 -20
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -6115,13 +6115,6 @@ import fs11 from "fs";
|
|
|
6115
6115
|
import path10 from "path";
|
|
6116
6116
|
import process6 from "process";
|
|
6117
6117
|
import { spawnSync as spawnSync3 } from "child_process";
|
|
6118
|
-
function quoteWindowsCmdArg(value) {
|
|
6119
|
-
const text = String(value ?? "");
|
|
6120
|
-
if (!text) {
|
|
6121
|
-
return '""';
|
|
6122
|
-
}
|
|
6123
|
-
return `"${text.replace(/(["^&|<>%])/g, "^$1")}"`;
|
|
6124
|
-
}
|
|
6125
6118
|
function isExecutableFile(filePath) {
|
|
6126
6119
|
if (!filePath || !fs11.existsSync(filePath)) {
|
|
6127
6120
|
return false;
|
|
@@ -6220,22 +6213,22 @@ function resolveCliExecution(commandName, args, env = process6.env) {
|
|
|
6220
6213
|
prependPathDir(env, path10.dirname(commandPath));
|
|
6221
6214
|
}
|
|
6222
6215
|
if (process6.platform === "win32") {
|
|
6223
|
-
const commandLine = [
|
|
6224
|
-
quoteWindowsCmdArg(commandPath),
|
|
6225
|
-
...normalizedArgs.map((item) => quoteWindowsCmdArg(item))
|
|
6226
|
-
].join(" ");
|
|
6227
6216
|
return {
|
|
6228
6217
|
command: "cmd.exe",
|
|
6229
|
-
args: ["/d", "/
|
|
6218
|
+
args: ["/d", "/c", "call", commandPath, ...normalizedArgs],
|
|
6230
6219
|
shell: false,
|
|
6231
|
-
displayCommand
|
|
6220
|
+
displayCommand,
|
|
6221
|
+
resolvedPath: commandPath,
|
|
6222
|
+
fallback: "cmd"
|
|
6232
6223
|
};
|
|
6233
6224
|
}
|
|
6234
6225
|
return {
|
|
6235
6226
|
command: commandPath,
|
|
6236
6227
|
args: normalizedArgs,
|
|
6237
6228
|
shell: false,
|
|
6238
|
-
displayCommand
|
|
6229
|
+
displayCommand,
|
|
6230
|
+
resolvedPath: commandPath,
|
|
6231
|
+
fallback: commandPath === commandName ? "direct-unresolved" : "direct"
|
|
6239
6232
|
};
|
|
6240
6233
|
}
|
|
6241
6234
|
|
|
@@ -6327,14 +6320,19 @@ var CodexRunner = class {
|
|
|
6327
6320
|
resolveCodexExecution(args, env = process7.env) {
|
|
6328
6321
|
return resolveCliExecution("codex", args, env);
|
|
6329
6322
|
}
|
|
6330
|
-
buildFailureMessage(stderr, stdout, code, dirPath,
|
|
6323
|
+
buildFailureMessage(stderr, stdout, code, dirPath, execConfig) {
|
|
6331
6324
|
const reason = stderr.trim() || stdout.trim() || `codex \u9000\u51FA\u7801 ${code}`;
|
|
6332
6325
|
return [
|
|
6333
6326
|
reason,
|
|
6334
6327
|
`cwd=${dirPath || "-"}`,
|
|
6335
|
-
`command=${displayCommand || "codex"}
|
|
6328
|
+
`command=${execConfig.displayCommand || "codex"}`,
|
|
6329
|
+
`resolved=${execConfig.resolvedPath || "-"}`,
|
|
6330
|
+
`fallback=${execConfig.fallback || "-"}`
|
|
6336
6331
|
].join("\n");
|
|
6337
6332
|
}
|
|
6333
|
+
buildExecutionLog(prefix, execConfig) {
|
|
6334
|
+
return `${prefix}: ${execConfig.displayCommand} (resolved=${execConfig.resolvedPath || "-"}, fallback=${execConfig.fallback || "direct"})`;
|
|
6335
|
+
}
|
|
6338
6336
|
writePromptToChildStdin(child, prompt, traceMessage = "") {
|
|
6339
6337
|
if (!this.shouldUseStdinPrompt(prompt) || !child?.stdin) {
|
|
6340
6338
|
return;
|
|
@@ -6433,7 +6431,7 @@ var CodexRunner = class {
|
|
|
6433
6431
|
this.logger.info(`Codex \u51C6\u5907\u6267\u884C: dir=${dirPath}, thread_key=${threadKey || "-"}, session_id=${resolvedSessionId || "-"}, resume=${isResume}`);
|
|
6434
6432
|
const childEnv = this.buildChildEnv(resolveTraceId(threadKey, resolvedSessionId, dirPath));
|
|
6435
6433
|
const execConfig = this.resolveCodexExecution(args, childEnv);
|
|
6436
|
-
this.logger.info(formatTraceLog(resolveTraceId(threadKey, resolvedSessionId, dirPath),
|
|
6434
|
+
this.logger.info(formatTraceLog(resolveTraceId(threadKey, resolvedSessionId, dirPath), this.buildExecutionLog("Codex \u6267\u884C\u547D\u4EE4", execConfig)));
|
|
6437
6435
|
const child = spawn(execConfig.command, execConfig.args, {
|
|
6438
6436
|
cwd: dirPath,
|
|
6439
6437
|
shell: execConfig.shell,
|
|
@@ -6479,7 +6477,7 @@ command=${execConfig.displayCommand}`));
|
|
|
6479
6477
|
this.stateManager.markCodexRun(dirPath);
|
|
6480
6478
|
}
|
|
6481
6479
|
if (code !== 0) {
|
|
6482
|
-
reject(new Error(this.buildFailureMessage(stderr, stdout, code, dirPath, execConfig
|
|
6480
|
+
reject(new Error(this.buildFailureMessage(stderr, stdout, code, dirPath, execConfig)));
|
|
6483
6481
|
return;
|
|
6484
6482
|
}
|
|
6485
6483
|
resolve3({
|
|
@@ -6530,7 +6528,7 @@ command=${execConfig.displayCommand}`));
|
|
|
6530
6528
|
let notifiedSessionId = false;
|
|
6531
6529
|
const childEnv = this.buildChildEnv(logTraceId);
|
|
6532
6530
|
const execConfig = this.resolveCodexExecution(args, childEnv);
|
|
6533
|
-
this.logger.info(formatTraceLog(logTraceId,
|
|
6531
|
+
this.logger.info(formatTraceLog(logTraceId, this.buildExecutionLog("Codex \u6267\u884C\u547D\u4EE4(\u6D41\u5F0F)", execConfig)));
|
|
6534
6532
|
const child = spawn(execConfig.command, execConfig.args, {
|
|
6535
6533
|
cwd: dirPath,
|
|
6536
6534
|
shell: execConfig.shell,
|
|
@@ -6660,7 +6658,7 @@ command=${execConfig.displayCommand}`));
|
|
|
6660
6658
|
this.stateManager.markCodexRun(dirPath);
|
|
6661
6659
|
}
|
|
6662
6660
|
if (code !== 0) {
|
|
6663
|
-
reject(new Error(this.buildFailureMessage(stderr, stdout, code, dirPath, execConfig
|
|
6661
|
+
reject(new Error(this.buildFailureMessage(stderr, stdout, code, dirPath, execConfig)));
|
|
6664
6662
|
return;
|
|
6665
6663
|
}
|
|
6666
6664
|
resolve3({
|