feat: Implement Plan Mode for Safe Code Planning (#658)

This commit is contained in:
tanzhenxin
2025-09-24 14:26:17 +08:00
committed by GitHub
parent 8379bc4d81
commit 4e7a7e2656
43 changed files with 2895 additions and 281 deletions

View File

@@ -9,6 +9,7 @@ import type { Config } from '../config/config.js';
import os from 'node:os';
import { quote } from 'shell-quote';
import { doesToolInvocationMatch } from './tool-utils.js';
import { isShellCommandReadOnly } from './shellReadOnlyChecker.js';
const SHELL_TOOL_NAMES = ['run_shell_command', 'ShellTool'];
@@ -469,3 +470,19 @@ export function isCommandAllowed(
}
return { allowed: false, reason: blockReason };
}
export function isCommandNeedsPermission(command: string): {
requiresPermission: boolean;
reason?: string;
} {
const isAllowed = isShellCommandReadOnly(command);
if (isAllowed) {
return { requiresPermission: false };
}
return {
requiresPermission: true,
reason: 'Command requires permission to execute.',
};
}