From 386937cfb39b1537bdb94c3725666e9e45c586d4 Mon Sep 17 00:00:00 2001 From: cexll Date: Fri, 5 Dec 2025 10:27:36 +0800 Subject: [PATCH] fix(codex-wrapper): defer startup log until args parsed MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 调整启动日志输出时机,在参数解析后再打印: 问题: - 之前在解析参数前打印日志,命令行显示的是原始参数 - 无法准确反映实际执行的 codex 命令 解决: - 将启动日志移到 buildCodexArgsFn 调用后 - 日志现在显示完整的 codex 命令(包括展开的参数) - 提升调试体验,准确反映执行上下文 改动位于 codex-wrapper/main.go:487-500 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- codex-wrapper/main.go | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/codex-wrapper/main.go b/codex-wrapper/main.go index 56a5343..5edee6f 100644 --- a/codex-wrapper/main.go +++ b/codex-wrapper/main.go @@ -444,12 +444,6 @@ func run() (exitCode int) { logInfo("Script started") - // Print startup information to stderr - fmt.Fprintf(os.Stderr, "[codex-wrapper]\n") - fmt.Fprintf(os.Stderr, " Command: %s\n", strings.Join(os.Args, " ")) - fmt.Fprintf(os.Stderr, " PID: %d\n", os.Getpid()) - fmt.Fprintf(os.Stderr, " Log: %s\n", logger.Path()) - cfg, err := parseArgs() if err != nil { logError(err.Error()) @@ -493,6 +487,18 @@ func run() (exitCode int) { useStdin := cfg.ExplicitStdin || shouldUseStdin(taskText, piped) + targetArg := taskText + if useStdin { + targetArg = "-" + } + codexArgs := buildCodexArgsFn(cfg, targetArg) + + // Print startup information to stderr + fmt.Fprintf(os.Stderr, "[codex-wrapper]\n") + fmt.Fprintf(os.Stderr, " Command: %s %s\n", codexCommand, strings.Join(codexArgs, " ")) + fmt.Fprintf(os.Stderr, " PID: %d\n", os.Getpid()) + fmt.Fprintf(os.Stderr, " Log: %s\n", logger.Path()) + if useStdin { var reasons []string if piped {