From 2e4c866da268318eb9c54e1e30bccd170065c191 Mon Sep 17 00:00:00 2001 From: andrepimenta Date: Wed, 9 Jul 2025 00:32:38 +0100 Subject: [PATCH] Yolo mode init --- package.json | 5 +++++ src/extension.ts | 28 +++++++++++++++++----------- src/permissions/mcp-permissions.ts | 6 ++++++ src/ui-styles.ts | 27 ++++++++++++++++++++++++++- src/ui.ts | 9 ++++++++- 5 files changed, 62 insertions(+), 13 deletions(-) diff --git a/package.json b/package.json index 84a3ca3..41a0ea7 100644 --- a/package.json +++ b/package.json @@ -180,6 +180,11 @@ ], "default": "think", "description": "Thinking mode intensity level. Higher levels provide more detailed reasoning but consume more tokens." + }, + "claudeCodeChat.permissions.yoloMode": { + "type": "boolean", + "default": false, + "description": "Enable Yolo Mode to skip all permission checks. Use with caution as Claude can execute any command without asking." } } } diff --git a/src/extension.ts b/src/extension.ts index 618db91..ada5285 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -413,14 +413,23 @@ class ClaudeChatProvider { '--output-format', 'stream-json', '--verbose' ]; - // Add MCP configuration for permissions - const mcpConfigPath = this.getMCPConfigPath(); - if (mcpConfigPath) { - args.push('--mcp-config', mcpConfigPath); - args.push('--allowedTools', 'mcp__permissions__approval_prompt'); - args.push('--permission-prompt-tool', 'mcp__permissions__approval_prompt'); - }else{ - args.push('--dangerously-skip-permissions') + // Get configuration + const config = vscode.workspace.getConfiguration('claudeCodeChat'); + const yoloMode = config.get('permissions.yoloMode', false); + + if (yoloMode) { + // Yolo mode: skip all permissions regardless of MCP config + args.push('--dangerously-skip-permissions'); + } else { + // Add MCP configuration for permissions + const mcpConfigPath = this.getMCPConfigPath(); + if (mcpConfigPath) { + args.push('--mcp-config', mcpConfigPath); + args.push('--allowedTools', 'mcp__permissions__approval_prompt'); + args.push('--permission-prompt-tool', 'mcp__permissions__approval_prompt'); + } else { + args.push('--dangerously-skip-permissions'); + } } // Add model selection if not using default @@ -438,9 +447,6 @@ class ClaudeChatProvider { } console.log('Claude command args:', args); - - // Get configuration - const config = vscode.workspace.getConfiguration('claudeCodeChat'); const wslEnabled = config.get('wsl.enabled', false); const wslDistro = config.get('wsl.distro', 'Ubuntu'); const nodePath = config.get('wsl.nodePath', '/usr/bin/node'); diff --git a/src/permissions/mcp-permissions.ts b/src/permissions/mcp-permissions.ts index bb3142d..31f4442 100644 --- a/src/permissions/mcp-permissions.ts +++ b/src/permissions/mcp-permissions.ts @@ -60,6 +60,12 @@ function isAlwaysAllowed(toolName: string, input: any): boolean { return toolPermission.some(allowedCmd => { // Support exact match or pattern matching if (allowedCmd.includes('*')) { + // Handle patterns like "npm i *" to match both "npm i" and "npm i something" + const baseCommand = allowedCmd.replace(' *', ''); + if (command === baseCommand) { + return true; // Exact match for base command + } + // Pattern match for command with arguments const pattern = allowedCmd.replace(/\*/g, '.*'); return new RegExp(`^${pattern}$`).test(command); } diff --git a/src/ui-styles.ts b/src/ui-styles.ts index 2108512..1b36862 100644 --- a/src/ui-styles.ts +++ b/src/ui-styles.ts @@ -368,7 +368,7 @@ const styles = ` .permissions-show-add-btn { background-color: transparent; color: var(--vscode-descriptionForeground); - border: none; + border: 1px solid var(--vscode-panel-border); border-radius: 3px; padding: 6px 8px; font-size: 11px; @@ -488,6 +488,31 @@ const styles = ` line-height: 1.3; } + .yolo-mode-section { + display: flex; + align-items: center; + gap: 6px; + margin-top: 12px; + opacity: 0.7; + transition: opacity 0.2s ease; + } + + .yolo-mode-section:hover { + opacity: 1; + } + + .yolo-mode-section input[type="checkbox"] { + transform: scale(0.8); + margin: 0; + } + + .yolo-mode-section label { + font-size: 10px; + color: var(--vscode-descriptionForeground); + cursor: pointer; + font-weight: 400; + } + /* WSL Alert */ .wsl-alert { margin: 8px 12px; diff --git a/src/ui.ts b/src/ui.ts index b8603be..7e0d1cd 100644 --- a/src/ui.ts +++ b/src/ui.ts @@ -288,6 +288,10 @@ const html = ` +
+ + +
@@ -2498,6 +2502,7 @@ const html = ` const wslDistro = document.getElementById('wsl-distro').value; const wslNodePath = document.getElementById('wsl-node-path').value; const wslClaudePath = document.getElementById('wsl-claude-path').value; + const yoloMode = document.getElementById('yolo-mode').checked; // Update WSL options visibility document.getElementById('wslOptions').style.display = wslEnabled ? 'block' : 'none'; @@ -2509,7 +2514,8 @@ const html = ` 'wsl.enabled': wslEnabled, 'wsl.distro': wslDistro || 'Ubuntu', 'wsl.nodePath': wslNodePath || '/usr/bin/node', - 'wsl.claudePath': wslClaudePath || '/usr/local/bin/claude' + 'wsl.claudePath': wslClaudePath || '/usr/local/bin/claude', + 'permissions.yoloMode': yoloMode } }); } @@ -2697,6 +2703,7 @@ const html = ` document.getElementById('wsl-distro').value = message.data['wsl.distro'] || 'Ubuntu'; document.getElementById('wsl-node-path').value = message.data['wsl.nodePath'] || '/usr/bin/node'; document.getElementById('wsl-claude-path').value = message.data['wsl.claudePath'] || '/usr/local/bin/claude'; + document.getElementById('yolo-mode').checked = message.data['permissions.yoloMode'] || false; // Show/hide WSL options document.getElementById('wslOptions').style.display = message.data['wsl.enabled'] ? 'block' : 'none';