Skip to content

Commit 7a563b6

Browse files
fix(agent): add --skip-git-repo-check to codex LoopCommand
Non-interactive codex exec calls should not be blocked by git repo validation. Also tightens InteractiveCommand test to use exact arg matching. Based on #51 by @ernestoacevedo, trimmed to current main.
1 parent 8227078 commit 7a563b6

2 files changed

Lines changed: 10 additions & 4 deletions

File tree

internal/agent/codex.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ func (p *CodexProvider) CLIPath() string { return p.cliPath }
3030

3131
// LoopCommand implements loop.Provider.
3232
func (p *CodexProvider) LoopCommand(ctx context.Context, prompt, workDir string) *exec.Cmd {
33-
cmd := exec.CommandContext(ctx, p.cliPath, "exec", "--json", "--yolo", "-C", workDir, "-")
33+
cmd := exec.CommandContext(ctx, p.cliPath, "exec", "--json", "--yolo", "--skip-git-repo-check", "-C", workDir, "-")
3434
cmd.Dir = workDir
3535
cmd.Stdin = strings.NewReader(prompt)
3636
return cmd

internal/agent/codex_test.go

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ func TestCodexProvider_LoopCommand(t *testing.T) {
4040
if cmd.Path != "/bin/codex" {
4141
t.Errorf("LoopCommand Path = %q, want /bin/codex", cmd.Path)
4242
}
43-
wantArgs := []string{"/bin/codex", "exec", "--json", "--yolo", "-C", "/work/dir", "-"}
43+
wantArgs := []string{"/bin/codex", "exec", "--json", "--yolo", "--skip-git-repo-check", "-C", "/work/dir", "-"}
4444
if len(cmd.Args) != len(wantArgs) {
4545
t.Fatalf("LoopCommand Args len = %d, want %d: %v", len(cmd.Args), len(wantArgs), cmd.Args)
4646
}
@@ -65,8 +65,14 @@ func TestCodexProvider_InteractiveCommand(t *testing.T) {
6565
if cmd.Dir != "/work" {
6666
t.Errorf("InteractiveCommand Dir = %q, want /work", cmd.Dir)
6767
}
68-
if len(cmd.Args) < 2 || cmd.Args[0] != "codex" || cmd.Args[1] != "my prompt" {
69-
t.Errorf("InteractiveCommand Args = %v", cmd.Args)
68+
wantInteractiveArgs := []string{"codex", "my prompt"}
69+
if len(cmd.Args) != len(wantInteractiveArgs) {
70+
t.Fatalf("InteractiveCommand Args len = %d, want %d: %v", len(cmd.Args), len(wantInteractiveArgs), cmd.Args)
71+
}
72+
for i, w := range wantInteractiveArgs {
73+
if cmd.Args[i] != w {
74+
t.Errorf("InteractiveCommand Args[%d] = %q, want %q", i, cmd.Args[i], w)
75+
}
7076
}
7177
}
7278

0 commit comments

Comments
 (0)