fix: full-auto support in quiet mode (#374)
Fixes https://github.com/openai/codex/issues/292 --------- Co-authored-by: Thibault Sottiaux <tibo@openai.com>
This commit is contained in:
@@ -327,9 +327,6 @@ const additionalWritableRoots: ReadonlyArray<string> = (
|
|||||||
|
|
||||||
// If we are running in --quiet mode, do that and exit.
|
// If we are running in --quiet mode, do that and exit.
|
||||||
const quietMode = Boolean(cli.flags.quiet);
|
const quietMode = Boolean(cli.flags.quiet);
|
||||||
const autoApproveEverything = Boolean(
|
|
||||||
cli.flags.dangerouslyAutoApproveEverything,
|
|
||||||
);
|
|
||||||
const fullStdout = Boolean(cli.flags.fullStdout);
|
const fullStdout = Boolean(cli.flags.fullStdout);
|
||||||
|
|
||||||
if (quietMode) {
|
if (quietMode) {
|
||||||
@@ -341,12 +338,19 @@ if (quietMode) {
|
|||||||
);
|
);
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Determine approval policy for quiet mode based on flags
|
||||||
|
const quietApprovalPolicy: ApprovalPolicy =
|
||||||
|
cli.flags.fullAuto || cli.flags.approvalMode === "full-auto"
|
||||||
|
? AutoApprovalMode.FULL_AUTO
|
||||||
|
: cli.flags.autoEdit || cli.flags.approvalMode === "auto-edit"
|
||||||
|
? AutoApprovalMode.AUTO_EDIT
|
||||||
|
: config.approvalMode || AutoApprovalMode.SUGGEST;
|
||||||
|
|
||||||
await runQuietMode({
|
await runQuietMode({
|
||||||
prompt: prompt as string,
|
prompt: prompt as string,
|
||||||
imagePaths: imagePaths || [],
|
imagePaths: imagePaths || [],
|
||||||
approvalPolicy: autoApproveEverything
|
approvalPolicy: quietApprovalPolicy,
|
||||||
? AutoApprovalMode.FULL_AUTO
|
|
||||||
: config.approvalMode || AutoApprovalMode.SUGGEST,
|
|
||||||
additionalWritableRoots,
|
additionalWritableRoots,
|
||||||
config,
|
config,
|
||||||
});
|
});
|
||||||
@@ -470,7 +474,12 @@ async function runQuietMode({
|
|||||||
getCommandConfirmation: (
|
getCommandConfirmation: (
|
||||||
_command: Array<string>,
|
_command: Array<string>,
|
||||||
): Promise<CommandConfirmation> => {
|
): Promise<CommandConfirmation> => {
|
||||||
return Promise.resolve({ review: ReviewDecision.NO_CONTINUE });
|
// In quiet mode, default to NO_CONTINUE, except when in full-auto mode
|
||||||
|
const reviewDecision =
|
||||||
|
approvalPolicy === AutoApprovalMode.FULL_AUTO
|
||||||
|
? ReviewDecision.YES
|
||||||
|
: ReviewDecision.NO_CONTINUE;
|
||||||
|
return Promise.resolve({ review: reviewDecision });
|
||||||
},
|
},
|
||||||
onLastResponseId: () => {
|
onLastResponseId: () => {
|
||||||
/* intentionally ignored in quiet mode */
|
/* intentionally ignored in quiet mode */
|
||||||
|
|||||||
Reference in New Issue
Block a user