Skip to content

Commit 511a7dd

Browse files
OneStepAt4timeArgus
authored andcommitted
fix(cli): add --accept-permissions flag to ag run and ag create (#3336, #3337)
Tasks requiring file writes stall at the permission gate because neither ag run nor ag create passes permissionMode to the session. Sessions sit idle waiting for approval that never comes. New flag: --accept-permissions / -y - Sets permissionMode: 'bypassPermissions' on session creation - ag run: completes autonomously instead of timing out - ag create: no longer stalls on permission-gated operations Fixes: #3336, #3337
1 parent bae7c72 commit 511a7dd

2 files changed

Lines changed: 5 additions & 1 deletion

File tree

src/cli.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,8 @@ async function handleCreate(args: string[], io: CliIO): Promise<number> {
120120
}
121121
}
122122

123+
const acceptPerms = args.includes('--accept-permissions') || args.includes('-y');
124+
123125
if (!brief) {
124126
writeLine(io.stderr, ' ❌ Missing brief. Usage: ag create "Build a login page"');
125127
return 1;
@@ -156,7 +158,7 @@ async function handleCreate(args: string[], io: CliIO): Promise<number> {
156158
const res = await fetch(`${baseUrl}/v1/sessions`, {
157159
method: 'POST',
158160
headers,
159-
body: JSON.stringify({ workDir: cwd, name: sessionName }),
161+
body: JSON.stringify({ workDir: cwd, name: sessionName, ...(acceptPerms ? { permissionMode: 'bypassPermissions' } : {}) }),
160162
});
161163

162164
if (!res.ok) {

src/commands/run.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,7 @@ export async function handleRun(args: string[], io: CliIO): Promise<number> {
261261
const portOverride = portIdx !== -1 ? parseIntSafe(args[portIdx + 1], 9100) : null;
262262

263263
const noStream = args.includes('--no-stream');
264+
const acceptPerms = args.includes('--accept-permissions') || args.includes('-y');
264265

265266
writeLine(io.stdout, ` 🚀 ag run: ${brief.slice(0, 60)}${brief.length > 60 ? '...' : ''}`);
266267

@@ -366,6 +367,7 @@ export async function handleRun(args: string[], io: CliIO): Promise<number> {
366367
workDir: cwd,
367368
prompt: brief,
368369
name: `run-${brief.slice(0, 20).replace(/[^a-zA-Z0-9-]/g, '-').toLowerCase()}`,
370+
...(acceptPerms ? { permissionMode: 'bypassPermissions' } : {}),
369371
}),
370372
});
371373

0 commit comments

Comments
 (0)