mirror of
https://github.com/QwenLM/qwen-code.git
synced 2025-12-21 09:17:53 +00:00
feat: Implement Plan Mode for Safe Code Planning (#658)
This commit is contained in:
@@ -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.',
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user