Skip to content

Commit 2f27ebe

Browse files
committed
fix(agent): correct CLI arguments for codex and claude
- Codex: use --full-auto instead of -a never (not available in exec mode) - Claude: add --add-dir for project directory access in -p mode Tested: commands construct correctly, execute properly (auth errors are expected when CLIs not configured with API keys) Relates to #536
1 parent 490147e commit 2f27ebe

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

mpp-core/src/commonMain/kotlin/cc/unitmesh/agent/external/ExternalCliCodingAgent.kt

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -151,28 +151,38 @@ class ExternalCliCodingAgent(
151151
ExternalCliKind.CLAUDE -> when (mode) {
152152
ExternalCliMode.NON_INTERACTIVE -> buildString {
153153
append(kind.binary)
154-
append(" -p --output-format text ")
154+
// -p: print mode (non-interactive), --output-format text: plain text output
155+
// --add-dir: allow tool access to project directory
156+
// --permission-mode default: use default permissions (no interactive prompts in -p mode)
157+
append(" -p --output-format text --add-dir ")
158+
append(ShellUtils.escapeShellArg(projectPath))
159+
append(' ')
155160
if (args.isNotBlank()) append(args).append(' ')
156161
append(promptArg)
157162
}
158163
ExternalCliMode.INTERACTIVE -> buildString {
159-
append(kind.binary).append(' ')
164+
append(kind.binary)
165+
append(" --add-dir ")
166+
append(ShellUtils.escapeShellArg(projectPath))
167+
append(' ')
160168
if (args.isNotBlank()) append(args).append(' ')
161169
append(promptArg)
162170
}
163171
}
164172
ExternalCliKind.CODEX -> when (mode) {
165173
ExternalCliMode.NON_INTERACTIVE -> buildString {
166174
append(kind.binary)
167-
append(" exec --color auto -a never -s workspace-write -C ")
175+
// codex exec: --full-auto = auto approval + workspace-write sandbox
176+
append(" exec --full-auto --color auto -C ")
168177
append(ShellUtils.escapeShellArg(projectPath))
169178
append(' ')
170179
if (args.isNotBlank()) append(args).append(' ')
171180
append(promptArg)
172181
}
173182
ExternalCliMode.INTERACTIVE -> buildString {
174183
append(kind.binary)
175-
append(" -C ")
184+
// Interactive mode: use main codex command with full-auto for sandboxed execution
185+
append(" --full-auto -C ")
176186
append(ShellUtils.escapeShellArg(projectPath))
177187
append(" --no-alt-screen ")
178188
if (args.isNotBlank()) append(args).append(' ')

0 commit comments

Comments
 (0)