Skip to content

Commit c0d6801

Browse files
juhgiyoclaude
andauthored
Add --json flag to codex exec for structured output (#12)
## Summary - Adds `--json` flag to `codex exec` command in the build output - Suppresses verbose prompt echo, outputs structured JSONL events instead ## Test plan - [ ] Run a session via strawpot-codex and verify prompt is no longer echoed in output - [ ] Verify JSONL events are emitted on stdout 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 474d57f commit c0d6801

2 files changed

Lines changed: 6 additions & 3 deletions

File tree

codex/wrapper/main.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,9 @@ func cmdBuild(args []string) {
231231
// Build codex command
232232
cmd := []string{"codex", "exec"}
233233

234+
// JSON output for machine parsing (suppresses prompt echo)
235+
cmd = append(cmd, "--json")
236+
234237
if ba.Task != "" {
235238
cmd = append(cmd, ba.Task)
236239
}

codex/wrapper/main_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -134,9 +134,9 @@ func TestCmdBuild_WithTaskAndModel(t *testing.T) {
134134

135135
cmd := result["cmd"].([]interface{})
136136

137-
// Task is positional after "codex exec"
138-
if len(cmd) < 3 || cmd[2] != "fix the bug" {
139-
t.Errorf("cmd[2] = %v, want %q", cmd[2], "fix the bug")
137+
// Task is positional after "codex exec --json"
138+
if len(cmd) < 4 || cmd[3] != "fix the bug" {
139+
t.Errorf("cmd[3] = %v, want %q", cmd[3], "fix the bug")
140140
}
141141
assertSequence(t, cmd, "-m", "gpt-5.2-codex")
142142
}

0 commit comments

Comments
 (0)