Skip to content

Commit be066dc

Browse files
fix: address code review — security, CLI flags, and memory guard
- Fix dangerouslyAllowAll defaulting to true → false (security) - Register --amp-mode flag on auto and template commands - Add maxOutputBytes truncation guard to runAmpCli Amp-Thread-ID: https://ampcode.com/threads/T-019ce298-ab61-760e-b725-803364016be5 Co-authored-by: Amp <amp@ampcode.com>
1 parent f815205 commit be066dc

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

src/cli.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -319,6 +319,10 @@ program
319319
.option('--dry-run', 'Preview mode - show tasks without executing')
320320
.option('--skip-pr', 'Skip PR creation (commit only)')
321321
.option('--agent <name>', 'Specify agent to use')
322+
.option(
323+
'--amp-mode <mode>',
324+
'Amp agent mode: smart (frontier), rush (fast), deep (extended reasoning)'
325+
)
322326
.option('--validate', 'Run validation after each task', true)
323327
.option('--no-validate', 'Skip validation')
324328
.option('--max-iterations <n>', 'Max iterations per task (default: 15)')
@@ -412,6 +416,10 @@ program
412416
.option('--validate', 'Run tests/lint/build after each iteration')
413417
.option('--max-iterations <n>', 'Maximum loop iterations')
414418
.option('--agent <name>', 'Specify agent (claude-code, cursor, codex, opencode, openclaw, amp)')
419+
.option(
420+
'--amp-mode <mode>',
421+
'Amp agent mode: smart (frontier), rush (fast), deep (extended reasoning)'
422+
)
415423
.action(async (action: string | undefined, args: string[], options) => {
416424
await templateCommand(action, args, options);
417425
});

src/loop/agents.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,7 @@ async function runAmpAgent(
349349
prompt: options.task,
350350
options: {
351351
cwd: options.cwd,
352-
dangerouslyAllowAll: options.auto ?? true,
352+
dangerouslyAllowAll: options.auto ?? false,
353353
mode: options.ampMode ?? 'smart',
354354
},
355355
};
@@ -425,7 +425,9 @@ function runAmpCli(
425425
});
426426

427427
let output = '';
428+
let outputBytes = 0;
428429
let stdoutBuffer = '';
430+
const maxOutputBytes = options.maxOutputBytes || 50 * 1024 * 1024;
429431

430432
const timeoutMs = options.timeoutMs || 300000;
431433
const timeout = setTimeout(() => {
@@ -435,6 +437,14 @@ function runAmpCli(
435437

436438
proc.stdout?.on('data', (data: Buffer) => {
437439
const chunk = data.toString();
440+
outputBytes += data.byteLength;
441+
442+
if (outputBytes > maxOutputBytes) {
443+
const keepBytes = Math.floor(maxOutputBytes * 0.8);
444+
output = output.slice(-keepBytes);
445+
outputBytes = Buffer.byteLength(output);
446+
}
447+
438448
output += chunk;
439449
stdoutBuffer += chunk;
440450

0 commit comments

Comments
 (0)