claude-yolo-extended 1.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md ADDED
@@ -0,0 +1,178 @@
1
+ # Claude YOLO Extended
2
+
3
+ A wrapper for the Claude CLI that can run in YOLO mode (bypassing all safety checks) OR Safe mode (standard Claude CLI behavior).
4
+
5
+ ⚠️ **SECURITY WARNING**: YOLO mode bypasses important safety checks! This completely bypasses the "human in the loop" checks, this could delete your data, leak your secrets and even brick your computer. Use at your own risk.
6
+
7
+ ## Features
8
+
9
+ - **Cross-Platform**: Works on Windows, Ubuntu, and other Unix-like systems
10
+ - **Dual Mode Support**: Switch between YOLO and SAFE modes
11
+ - **Mode Persistence**: Your mode choice is saved between sessions
12
+ - **Auto-start**: Claude starts automatically after mode switch
13
+ - **Root User Support**: YOLO mode works even as root user
14
+ - **Visual Mode Indicators**: Clear `[YOLO]` or `[SAFE]` prefixes
15
+ - **Auto-update**: Automatically checks for and installs updates to the Claude package
16
+
17
+ ## Installation
18
+
19
+ ```bash
20
+ # Clone the repository
21
+ git clone https://github.com/jslitzkerttcu/claude-yolo-extended.git
22
+ cd claude-yolo-extended
23
+
24
+ # Install dependencies
25
+ npm install
26
+
27
+ # Link globally to use the command anywhere
28
+ npm link
29
+ ```
30
+
31
+ The first time you run `claude-yolo-extended`, you will be presented with a consent prompt explaining the security implications. You must explicitly agree to continue.
32
+
33
+ <img width="750" alt="image" src="https://github.com/user-attachments/assets/f8e07cf0-6c43-4663-b9e2-f61b1afb4e99" />
34
+
35
+ Your consent choice is remembered for future runs.
36
+
37
+ ## New Safe Mode Feature 🛡️
38
+
39
+ ### Using command-line flags
40
+
41
+ ```bash
42
+ # Run in SAFE mode (normal Claude CLI behavior)
43
+ claude-yolo-extended --safe
44
+ claude-yolo-extended --no-yolo
45
+
46
+ # Run in YOLO mode (default)
47
+ claude-yolo-extended
48
+ ```
49
+
50
+ ### Using mode commands
51
+
52
+ ```bash
53
+ # Switch to YOLO mode
54
+ claude-yolo-extended mode yolo
55
+
56
+ # Switch to SAFE mode
57
+ claude-yolo-extended mode safe
58
+
59
+ # Check current mode
60
+ claude-yolo-extended mode
61
+ ```
62
+
63
+ ### Using the cl wrapper script (Recommended!)
64
+
65
+ For even easier mode management, use the included `cl` wrapper script (works on both Windows and Unix systems):
66
+
67
+ ```bash
68
+ # After npm link, the cl wrapper is available globally
69
+ # Or copy manually to your PATH
70
+ cp node_modules/claude-yolo-extended/bin/cl /usr/local/bin/cl
71
+ chmod +x /usr/local/bin/cl
72
+
73
+ # Now you can use:
74
+ cl /YON # Switch to YOLO mode AND start Claude
75
+ cl /YOFF # Switch to SAFE mode AND start Claude
76
+ cl /STATUS # Show current mode (without starting Claude)
77
+ cl /HELP # Show help
78
+
79
+ # Run Claude in current mode
80
+ cl "write a hello world function"
81
+
82
+ # Switch mode and run with command
83
+ cl /YON "create a web server"
84
+ ```
85
+
86
+ Mode preference is saved in `~/.claude_yolo_state` and persists between sessions.
87
+
88
+ ## Visual Mode Indicators
89
+
90
+ The tool now shows clear visual indicators of which mode you're in:
91
+
92
+ - **YOLO Mode**: `[YOLO]` prefix in yellow 🔥
93
+ - **SAFE Mode**: `[SAFE]` prefix in cyan 🛡️
94
+
95
+ ## Root User Support
96
+
97
+ Unlike the standard Claude CLI, this fork allows YOLO mode to run even as root user:
98
+
99
+ - Standard Claude CLI blocks `--dangerously-skip-permissions` when running as root
100
+ - This fork bypasses that check in YOLO mode
101
+ - You'll see a warning when running as root, but it will work
102
+ - SAFE mode respects all original Claude CLI security features
103
+
104
+ ## Usage
105
+
106
+ ```bash
107
+ claude-yolo-extended [options]
108
+ ```
109
+
110
+ All arguments and options are passed directly to the Claude CLI.
111
+
112
+ This wrapper in YOLO mode:
113
+ 1. Checks for and automatically installs updates to the Claude package
114
+ 2. Displays "🔥 YOLO MODE ACTIVATED 🔥" warning in yellow text
115
+ 3. Creates a modified copy of the Claude CLI code to bypass permission checks
116
+ - Replaces all `getIsDocker()` calls with `true`
117
+ - Replaces all `hasInternetAccess()` calls with `false`
118
+ - Bypasses root user checks (process.getuid() === 0)
119
+ - Adds colorful YOLO-themed loading messages
120
+ 4. Leaves the original Claude CLI file untouched (won't affect your normal `claude` command)
121
+ 5. Adds the `--dangerously-skip-permissions` flag to command line arguments
122
+ 6. Imports the modified copy of the CLI
123
+
124
+ In SAFE mode, it simply runs the original Claude CLI without modifications.
125
+
126
+
127
+ ## How It Works
128
+
129
+ - **YOLO Mode**: Creates a modified copy of the Claude CLI that bypasses permission checks
130
+ - **SAFE Mode**: Runs the original Claude CLI without modifications
131
+ - **Non-destructive**: Your regular `claude` command remains untouched
132
+ - **Debug mode**: Set `DEBUG=1` to see detailed logs
133
+
134
+ ## Why?
135
+
136
+ Sometimes you just want to YOLO and skip those pesky permission checks. But sometimes you want the safety checks back! This tool gives you the best of both worlds.
137
+
138
+ ## Debugging
139
+
140
+ If you encounter any issues, you can run with debug output:
141
+
142
+ ```bash
143
+ DEBUG=1 claude-yolo-extended
144
+ ```
145
+
146
+ This will show additional information about:
147
+ - Claude package update checks
148
+ - Current and latest available versions
149
+ - When updates are being installed
150
+ - Modifications being made to the CLI file
151
+ - Root bypass operations
152
+
153
+ ## Auto-Update Feature
154
+
155
+ Claude YOLO automatically checks for updates to the Claude package each time it runs:
156
+
157
+ 1. When you run `claude-yolo-extended`, it checks for the latest version of `@anthropic-ai/claude-code` on npm
158
+ 2. If your installed version is outdated, it will:
159
+ - Update your package.json with the latest version
160
+ - Run npm install to get the newest version
161
+ - Notify you that an update was applied
162
+ 3. This ensures you're always using the latest Claude CLI features
163
+
164
+ ## Important Security Disclaimer
165
+
166
+ This is an unofficial tool and not supported by Anthropic. Use at your own risk.
167
+
168
+ **SECURITY WARNING**:
169
+ - YOLO mode bypasses safety mechanisms intentionally built into the Claude CLI
170
+ - The `--dangerously-skip-permissions` flag was designed for use in container environments
171
+ - This fork additionally bypasses root user restrictions in YOLO mode
172
+ - By using this tool in YOLO mode, you acknowledge that:
173
+ - Important safety checks are being bypassed
174
+ - Claude may access files it normally would not have permission to access
175
+ - Running as root with bypassed permissions is extremely dangerous
176
+ - You accept full responsibility for any security implications
177
+
178
+ Anthropic designed these safety checks for good reason. Only use YOLO mode if you fully understand and accept these risks. Use SAFE mode when you want the standard Claude CLI protections.
package/bin/cl ADDED
@@ -0,0 +1,117 @@
1
+ #!/bin/bash
2
+
3
+ # Claude YOLO/SAFE Mode Wrapper Script
4
+ # Usage: cl /YON | /YOFF | /STATUS | /HELP | [claude commands]
5
+
6
+ # Barvy pro výstup
7
+ RED='\033[0;31m'
8
+ YELLOW='\033[1;33m'
9
+ CYAN='\033[0;36m'
10
+ GREEN='\033[0;32m'
11
+ RESET='\033[0m'
12
+ BOLD='\033[1m'
13
+
14
+ # Soubor pro uložení stavu
15
+ STATE_FILE="$HOME/.claude_yolo_state"
16
+
17
+ # Funkce pro čtení aktuálního režimu
18
+ get_mode() {
19
+ if [ -f "$STATE_FILE" ]; then
20
+ cat "$STATE_FILE"
21
+ else
22
+ echo "SAFE" # Výchozí je bezpečný režim
23
+ fi
24
+ }
25
+
26
+ # Funkce pro nastavení režimu
27
+ set_mode() {
28
+ echo "$1" > "$STATE_FILE"
29
+ }
30
+
31
+ # Zpracování argumentů
32
+ case "$1" in
33
+ /YON)
34
+ echo -e "${YELLOW}${BOLD}🔥 ACTIVATING YOLO MODE 🔥${RESET}"
35
+ echo -e "${RED}⚠️ WARNING: All safety checks will be DISABLED!${RESET}"
36
+ echo -e "${RED}⚠️ Claude can access ANY file without asking!${RESET}"
37
+ set_mode "YOLO"
38
+ echo -e "${YELLOW}✓ YOLO mode is now ON${RESET}"
39
+ ;;
40
+
41
+ /YOFF)
42
+ echo -e "${CYAN}${BOLD}🛡️ ACTIVATING SAFE MODE 🛡️${RESET}"
43
+ echo -e "${GREEN}✓ Safety checks will be enabled${RESET}"
44
+ echo -e "${GREEN}✓ Claude will ask for permissions${RESET}"
45
+ set_mode "SAFE"
46
+ echo -e "${CYAN}✓ YOLO mode is now OFF (Safe mode ON)${RESET}"
47
+ ;;
48
+
49
+ /STATUS)
50
+ MODE=$(get_mode)
51
+ echo -e "${BOLD}Claude CLI Status:${RESET}"
52
+ echo -e "━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
53
+ if [ "$MODE" = "YOLO" ]; then
54
+ echo -e "Mode: ${YELLOW}${BOLD}YOLO${RESET} 🔥"
55
+ echo -e "Safety: ${RED}DISABLED${RESET}"
56
+ echo -e "Permissions: ${RED}BYPASSED${RESET}"
57
+ else
58
+ echo -e "Mode: ${CYAN}${BOLD}SAFE${RESET} 🛡️"
59
+ echo -e "Safety: ${GREEN}ENABLED${RESET}"
60
+ echo -e "Permissions: ${GREEN}REQUIRED${RESET}"
61
+ fi
62
+ echo -e "━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
63
+ ;;
64
+
65
+ /HELP|/H|/?)
66
+ echo -e "${BOLD}Claude CLI Wrapper - Help${RESET}"
67
+ echo -e "━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
68
+ echo -e "${CYAN}cl /YON${RESET} - Enable YOLO mode (bypass safety)"
69
+ echo -e "${CYAN}cl /YOFF${RESET} - Disable YOLO mode (safe mode)"
70
+ echo -e "${CYAN}cl /STATUS${RESET} - Show current mode"
71
+ echo -e "${CYAN}cl /HELP${RESET} - Show this help"
72
+ echo -e "${CYAN}cl [args]${RESET} - Run claude with current mode"
73
+ echo -e "━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
74
+ echo -e ""
75
+ echo -e "${BOLD}Examples:${RESET}"
76
+ echo -e " cl /YON # Enable YOLO mode"
77
+ echo -e " cl /YOFF # Enable SAFE mode"
78
+ echo -e " cl \"write a function\" # Run Claude in current mode"
79
+ echo -e ""
80
+ echo -e "${BOLD}Mode Persistence:${RESET}"
81
+ echo -e "Your mode choice is saved in ~/.claude_yolo_state"
82
+ echo -e "and persists between terminal sessions."
83
+ ;;
84
+
85
+ *)
86
+ # Spustit Claude v aktuálním režimu
87
+ MODE=$(get_mode)
88
+
89
+ # Zobrazit režim před spuštěním
90
+ if [ "$MODE" = "YOLO" ]; then
91
+ echo -e "${YELLOW}[YOLO]${RESET} Running Claude in YOLO mode..."
92
+ # Check if claude-yolo-extended is installed
93
+ if command -v claude-yolo-extended &> /dev/null; then
94
+ claude-yolo-extended "$@"
95
+ else
96
+ echo -e "${RED}Error: claude-yolo-extended is not installed${RESET}"
97
+ echo -e "Install it with: ${CYAN}npm install -g claude-yolo-extended${RESET}"
98
+ exit 1
99
+ fi
100
+ else
101
+ echo -e "${CYAN}[SAFE]${RESET} Running Claude in SAFE mode..."
102
+ # Check if claude is installed
103
+ if command -v claude &> /dev/null; then
104
+ claude "$@"
105
+ else
106
+ # If regular claude is not installed, use claude-yolo-extended with --safe flag
107
+ if command -v claude-yolo-extended &> /dev/null; then
108
+ claude-yolo-extended --safe "$@"
109
+ else
110
+ echo -e "${RED}Error: Neither claude nor claude-yolo-extended is installed${RESET}"
111
+ echo -e "Install claude-yolo-extended with: ${CYAN}npm install -g claude-yolo-extended${RESET}"
112
+ exit 1
113
+ fi
114
+ fi
115
+ fi
116
+ ;;
117
+ esac
package/bin/cl.ps1 ADDED
@@ -0,0 +1,36 @@
1
+ # Claude YOLO/SAFE Mode Wrapper Script
2
+ # Usage: cl.ps1 /YON | /YOFF | /STATUS | /HELP | [claude commands]
3
+
4
+ param(
5
+ [Parameter(Position=0)]
6
+ [string]$Command,
7
+ [Parameter(Position=1)]
8
+ [string]$Argument
9
+ )
10
+
11
+ # Colors for output
12
+ $RED = "`e[31m"
13
+ $YELLOW = "`e[33m"
14
+ $CYAN = "`e[36m"
15
+ $GREEN = "`e[32m"
16
+ $RESET = "`e[0m"
17
+
18
+ function Write-Colored($Text, $Color) {
19
+ Write-Host "$Color$Text$RESET"
20
+ }
21
+
22
+ # Check if Node.js is installed
23
+ if (-not (Get-Command node -ErrorAction SilentlyContinue)) {
24
+ Write-Colored "Error: Node.js is not installed. Please install Node.js first." $RED
25
+ exit 1
26
+ }
27
+
28
+ # Check if the main script exists
29
+ $scriptPath = Join-Path $PSScriptRoot "claude-yolo.js"
30
+ if (-not (Test-Path $scriptPath)) {
31
+ Write-Colored "Error: Main script not found. Please reinstall the package." $RED
32
+ exit 1
33
+ }
34
+
35
+ # Run the main script with arguments
36
+ & node $scriptPath $Command $Argument
@@ -0,0 +1,388 @@
1
+ #!/usr/bin/env node
2
+
3
+
4
+ import fs from 'fs';
5
+ import path from 'path';
6
+ import { pathToFileURL } from 'url';
7
+ import os from 'os';
8
+ import { createRequire } from 'module';
9
+ import { fileURLToPath } from 'url';
10
+ import { execSync } from 'child_process';
11
+ import readline from 'readline';
12
+
13
+ // ANSI color codes
14
+ const RED = '\x1b[31m';
15
+ const YELLOW = '\x1b[33m';
16
+ const CYAN = '\x1b[36m';
17
+ const GREEN = '\x1b[32m';
18
+ const RESET = '\x1b[0m';
19
+ const BOLD = '\x1b[1m';
20
+
21
+ // Path to persistent state file
22
+ const stateFile = path.join(os.homedir(), '.claude_yolo_state');
23
+
24
+ // Function to get current mode from state file
25
+ function getMode() {
26
+ try {
27
+ return fs.readFileSync(stateFile, 'utf8').trim();
28
+ } catch {
29
+ return 'YOLO'; // Default mode
30
+ }
31
+ }
32
+
33
+ // Function to set mode in state file
34
+ function setMode(mode) {
35
+ fs.writeFileSync(stateFile, mode);
36
+ }
37
+
38
+ // Debug logging function that only logs if DEBUG env var is set
39
+ const debug = (message) => {
40
+ if (process.env.DEBUG) {
41
+ console.log(message);
42
+ }
43
+ };
44
+
45
+ // Function to ask for user consent
46
+ function askForConsent() {
47
+ return new Promise((resolve) => {
48
+ const rl = readline.createInterface({
49
+ input: process.stdin,
50
+ output: process.stdout
51
+ });
52
+
53
+ console.log(`\n${BOLD}${YELLOW}🔥 CLAUDE-YOLO-EXTENDED CONSENT REQUIRED 🔥${RESET}\n`);
54
+ console.log(`${CYAN}----------------------------------------${RESET}`);
55
+ console.log(`${BOLD}What is claude-yolo-extended?${RESET}`);
56
+ console.log(`This package creates a wrapper around the official Claude CLI tool that:`);
57
+ console.log(` 1. ${RED}BYPASSES safety checks${RESET} by automatically adding the --dangerously-skip-permissions flag`);
58
+ console.log(` 2. Automatically updates to the latest Claude CLI version`);
59
+ console.log(` 3. Adds colorful YOLO-themed loading messages`);
60
+ console.log(` 4. ${GREEN}NOW SUPPORTS SAFE MODE${RESET} with --safe flag\n`);
61
+
62
+ console.log(`${BOLD}${RED}⚠️ IMPORTANT SECURITY WARNING ⚠️${RESET}`);
63
+ console.log(`The ${BOLD}--dangerously-skip-permissions${RESET} flag was designed for use in containers`);
64
+ console.log(`and bypasses important safety checks. This includes ignoring file access`);
65
+ console.log(`permissions that protect your system and privacy.\n`);
66
+
67
+ console.log(`${BOLD}By using claude-yolo-extended in YOLO mode:${RESET}`);
68
+ console.log(` • You acknowledge these safety checks are being bypassed`);
69
+ console.log(` • You understand this may allow Claude CLI to access sensitive files`);
70
+ console.log(` • You accept full responsibility for any security implications\n`);
71
+
72
+ console.log(`${CYAN}----------------------------------------${RESET}\n`);
73
+
74
+ rl.question(`${YELLOW}Do you consent to using claude-yolo-extended with these modifications? (yes/no): ${RESET}`, (answer) => {
75
+ rl.close();
76
+ const lowerAnswer = answer.toLowerCase().trim();
77
+ if (lowerAnswer === 'yes' || lowerAnswer === 'y') {
78
+ console.log(`\n${YELLOW}🔥 YOLO MODE APPROVED 🔥${RESET}`);
79
+ resolve(true);
80
+ } else {
81
+ console.log(`\n${CYAN}Aborted. YOLO mode not activated.${RESET}`);
82
+ console.log(`If you want the official Claude CLI with normal safety features, run:`);
83
+ console.log(`claude`);
84
+ resolve(false);
85
+ }
86
+ });
87
+ });
88
+ }
89
+
90
+ // Get the directory of the current module
91
+ const __dirname = path.dirname(fileURLToPath(import.meta.url));
92
+ const require = createRequire(import.meta.url);
93
+
94
+ // Find node_modules directory by walking up from current file
95
+ let nodeModulesDir = path.resolve(__dirname, '..');
96
+ while (!fs.existsSync(path.join(nodeModulesDir, 'node_modules')) && nodeModulesDir !== '/') {
97
+ nodeModulesDir = path.resolve(nodeModulesDir, '..');
98
+ }
99
+
100
+ // Path to check package info
101
+ const packageJsonPath = path.join(nodeModulesDir, 'package.json');
102
+
103
+ // Check for updates to Claude package
104
+ async function checkForUpdates() {
105
+ try {
106
+ debug("Checking for Claude package updates...");
107
+
108
+ // Get the latest version available on npm
109
+ const latestVersionCmd = "npm view @anthropic-ai/claude-code version";
110
+ const latestVersion = execSync(latestVersionCmd).toString().trim();
111
+ debug(`Latest Claude version on npm: ${latestVersion}`);
112
+
113
+ // Get our current installed version
114
+ const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8'));
115
+ const dependencies = packageJson.dependencies || {};
116
+ const currentVersion = dependencies['@anthropic-ai/claude-code'];
117
+
118
+ debug(`Claude version from package.json: ${currentVersion}`);
119
+
120
+ // Get the global Claude version if available
121
+ let globalVersion;
122
+ if (globalClaudeDir) {
123
+ try {
124
+ const globalPackageJsonPath = path.join(globalClaudeDir, 'package.json');
125
+ if (fs.existsSync(globalPackageJsonPath)) {
126
+ const globalPackageJson = JSON.parse(fs.readFileSync(globalPackageJsonPath, 'utf8'));
127
+ globalVersion = globalPackageJson.version;
128
+ debug(`Global Claude version: ${globalVersion}`);
129
+
130
+ // If global version is latest, inform user
131
+ if (globalVersion === latestVersion) {
132
+ debug(`Global Claude installation is already the latest version`);
133
+ } else if (globalVersion && latestVersion) {
134
+ debug(`Global Claude installation (${globalVersion}) differs from latest (${latestVersion})`);
135
+ }
136
+ }
137
+ } catch (err) {
138
+ debug(`Error getting global Claude version: ${err.message}`);
139
+ }
140
+ }
141
+
142
+ // If using a specific version (not "latest"), and it's out of date, update
143
+ if (currentVersion !== "latest" && currentVersion !== latestVersion) {
144
+ console.log(`Updating Claude package from ${currentVersion || 'unknown'} to ${latestVersion}...`);
145
+
146
+ // Update package.json
147
+ packageJson.dependencies['@anthropic-ai/claude-code'] = latestVersion;
148
+ fs.writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2));
149
+
150
+ // Run npm install
151
+ console.log("Running npm install to update dependencies...");
152
+ execSync("npm install", { stdio: 'inherit', cwd: nodeModulesDir });
153
+ console.log("Update complete!");
154
+ } else if (currentVersion === "latest") {
155
+ // If using "latest", just make sure we have the latest version installed
156
+ debug("Using 'latest' tag in package.json, running npm install to ensure we have the newest version");
157
+ execSync("npm install", { stdio: 'inherit', cwd: nodeModulesDir });
158
+ }
159
+ } catch (error) {
160
+ console.error("Error checking for updates:", error.message);
161
+ debug(error.stack);
162
+ }
163
+ }
164
+
165
+ // Try to find global installation of Claude CLI first
166
+ let globalClaudeDir;
167
+ try {
168
+ const globalNodeModules = execSync('npm -g root').toString().trim();
169
+ debug(`Global node_modules: ${globalNodeModules}`);
170
+ const potentialGlobalDir = path.join(globalNodeModules, '@anthropic-ai', 'claude-code');
171
+
172
+ if (fs.existsSync(potentialGlobalDir)) {
173
+ globalClaudeDir = potentialGlobalDir;
174
+ debug(`Found global Claude installation at: ${globalClaudeDir}`);
175
+ }
176
+ } catch (error) {
177
+ debug(`Error finding global Claude installation: ${error.message}`);
178
+ }
179
+
180
+ // Path to the local Claude CLI installation
181
+ const localClaudeDir = path.join(nodeModulesDir, 'node_modules', '@anthropic-ai', 'claude-code');
182
+
183
+ // Prioritize global installation, fall back to local
184
+ const claudeDir = globalClaudeDir || localClaudeDir;
185
+ debug(`Using Claude installation from: ${claudeDir}`);
186
+ debug(`Using ${claudeDir === globalClaudeDir ? 'GLOBAL' : 'LOCAL'} Claude installation`);
187
+
188
+ // Check for both .js and .mjs versions of the CLI
189
+ let mjs = path.join(claudeDir, 'cli.mjs');
190
+ let js = path.join(claudeDir, 'cli.js');
191
+ let originalCliPath;
192
+ let yoloCliPath;
193
+
194
+ if (fs.existsSync(js)) {
195
+ originalCliPath = js;
196
+ yoloCliPath = path.join(claudeDir, 'cli-yolo.js');
197
+ debug(`Found Claude CLI at ${originalCliPath} (js version)`);
198
+ } else if (fs.existsSync(mjs)) {
199
+ originalCliPath = mjs;
200
+ yoloCliPath = path.join(claudeDir, 'cli-yolo.mjs');
201
+ debug(`Found Claude CLI at ${originalCliPath} (mjs version)`);
202
+ } else {
203
+ console.error(`Error: Claude CLI not found in ${claudeDir}. Make sure @anthropic-ai/claude-code is installed.`);
204
+ process.exit(1);
205
+ }
206
+ const consentFlagPath = path.join(claudeDir, '.claude-yolo-extended-consent');
207
+
208
+ // Main function to run the application
209
+ async function run() {
210
+ // Handle mode commands first
211
+ const args = process.argv.slice(2);
212
+ if (args[0] === 'mode') {
213
+ if (args[1] === 'yolo') {
214
+ console.log(`${YELLOW}🔥 Switching to YOLO mode...${RESET}`);
215
+ console.log(`${RED}⚠️ WARNING: All safety checks will be DISABLED!${RESET}`);
216
+ setMode('YOLO');
217
+ console.log(`${YELLOW}✓ YOLO mode activated${RESET}`);
218
+ return;
219
+ } else if (args[1] === 'safe') {
220
+ console.log(`${CYAN}🛡️ Switching to SAFE mode...${RESET}`);
221
+ console.log(`${GREEN}✓ Safety checks will be enabled${RESET}`);
222
+ setMode('SAFE');
223
+ console.log(`${CYAN}✓ SAFE mode activated${RESET}`);
224
+ return;
225
+ } else {
226
+ const currentMode = getMode();
227
+ console.log(`Current mode: ${currentMode === 'YOLO' ? YELLOW : CYAN}${currentMode}${RESET}`);
228
+ return;
229
+ }
230
+ }
231
+
232
+ // Check for --safe or --no-yolo flags
233
+ const safeMode = process.argv.includes('--safe') ||
234
+ process.argv.includes('--no-yolo') ||
235
+ getMode() === 'SAFE';
236
+
237
+ if (safeMode) {
238
+ // Remove our flags before passing to original CLI
239
+ process.argv = process.argv.filter(arg =>
240
+ arg !== '--safe' && arg !== '--no-yolo'
241
+ );
242
+
243
+ console.log(`${CYAN}[SAFE] Running Claude in SAFE mode${RESET}`);
244
+
245
+ // Update if needed
246
+ await checkForUpdates();
247
+
248
+ // Ensure original CLI exists
249
+ if (!fs.existsSync(originalCliPath)) {
250
+ console.error(`Error: ${originalCliPath} not found. Make sure @anthropic-ai/claude-code is installed.`);
251
+ process.exit(1);
252
+ }
253
+
254
+ // Run original CLI without modifications
255
+ const cliUrl = pathToFileURL(originalCliPath).href;
256
+ await import(cliUrl);
257
+ return; // Exit early
258
+ }
259
+
260
+ // YOLO MODE continues below
261
+ console.log(`${YELLOW}[YOLO] Running Claude in YOLO mode${RESET}`);
262
+
263
+ // Temporarily fake non-root for YOLO mode
264
+ if (process.getuid && process.getuid() === 0) {
265
+ console.log(`${YELLOW}⚠️ Running as root - applying YOLO bypass...${RESET}`);
266
+ // Store original getuid
267
+ const originalGetuid = process.getuid;
268
+ // Override getuid to return non-root
269
+ process.getuid = () => 1000; // Fake regular user ID
270
+ // Restore after a delay to allow CLI to start
271
+ setTimeout(() => {
272
+ process.getuid = originalGetuid;
273
+ }, 100);
274
+ }
275
+
276
+ // Check and update Claude package first
277
+ await checkForUpdates();
278
+
279
+ if (!fs.existsSync(originalCliPath)) {
280
+ console.error(`Error: ${originalCliPath} not found. Make sure @anthropic-ai/claude-code is installed.`);
281
+ process.exit(1);
282
+ }
283
+
284
+ // Check if consent is needed
285
+ const consentNeeded = !fs.existsSync(yoloCliPath) || !fs.existsSync(consentFlagPath);
286
+
287
+ // If consent is needed and not already given, ask for it
288
+ if (consentNeeded) {
289
+ const consent = await askForConsent();
290
+ if (!consent) {
291
+ // User didn't consent, exit
292
+ process.exit(1);
293
+ }
294
+
295
+ // Create a flag file to remember that consent was given
296
+ try {
297
+ fs.writeFileSync(consentFlagPath, 'consent-given');
298
+ debug("Created consent flag file");
299
+ } catch (err) {
300
+ debug(`Error creating consent flag file: ${err.message}`);
301
+ // Continue anyway
302
+ }
303
+ }
304
+
305
+ // Read the original CLI file content
306
+ let cliContent = fs.readFileSync(originalCliPath, 'utf8');
307
+
308
+ if (claudeDir === localClaudeDir) {
309
+ cliContent = cliContent.replace(/"punycode"/g, '"punycode/"');
310
+ debug('Replaced all instances of "punycode" with "punycode/"');
311
+ }
312
+
313
+ // Replace getIsDocker() calls with true
314
+ cliContent = cliContent.replace(/[a-zA-Z0-9_]*\.getIsDocker\(\)/g, 'true');
315
+ debug("Replaced all instances of *.getIsDocker() with true");
316
+
317
+ // Replace hasInternetAccess() calls with false
318
+ cliContent = cliContent.replace(/[a-zA-Z0-9_]*\.hasInternetAccess\(\)/g, 'false');
319
+ debug("Replaced all instances of *.hasInternetAccess() with false");
320
+
321
+ // Replace root check patterns
322
+ // Pattern 1: process.getuid() === 0
323
+ cliContent = cliContent.replace(/process\.getuid\(\)\s*===\s*0/g, 'false');
324
+ debug("Replaced process.getuid() === 0 checks with false");
325
+
326
+ // Pattern 2: process.getuid?.() === 0
327
+ cliContent = cliContent.replace(/process\.getuid\?\.\(\)\s*===\s*0/g, 'false');
328
+ debug("Replaced process.getuid?.() === 0 checks with false");
329
+
330
+ // Pattern 3: getuid() === 0 (with any variable)
331
+ cliContent = cliContent.replace(/(\w+)\.getuid\(\)\s*===\s*0/g, 'false');
332
+ debug("Replaced all getuid() === 0 checks with false");
333
+
334
+ // Pattern 4: Replace any EUID checks
335
+ cliContent = cliContent.replace(/process\.geteuid\(\)\s*===\s*0/g, 'false');
336
+ cliContent = cliContent.replace(/process\.geteuid\?\.\(\)\s*===\s*0/g, 'false');
337
+ debug("Replaced geteuid() checks with false");
338
+
339
+ // Add warning message
340
+ console.log(`${YELLOW}🔥 YOLO MODE ACTIVATED 🔥${RESET}`);
341
+
342
+ // Replace the loading messages array with YOLO versions
343
+ const originalArray = '["Accomplishing","Actioning","Actualizing","Baking","Brewing","Calculating","Cerebrating","Churning","Clauding","Coalescing","Cogitating","Computing","Conjuring","Considering","Cooking","Crafting","Creating","Crunching","Deliberating","Determining","Doing","Effecting","Finagling","Forging","Forming","Generating","Hatching","Herding","Honking","Hustling","Ideating","Inferring","Manifesting","Marinating","Moseying","Mulling","Mustering","Musing","Noodling","Percolating","Pondering","Processing","Puttering","Reticulating","Ruminating","Schlepping","Shucking","Simmering","Smooshing","Spinning","Stewing","Synthesizing","Thinking","Transmuting","Vibing","Working"]';
344
+ const yoloSuffixes = [
345
+ ` ${RED}(safety's off, hold on tight)${RESET}`,
346
+ ` ${YELLOW}(all gas, no brakes, lfg)${RESET}`,
347
+ ` ${BOLD}\x1b[35m(yolo mode engaged)${RESET}`,
348
+ ` ${CYAN}(dangerous mode! I guess you can just do things)${RESET}`
349
+ ];
350
+
351
+ // Function to add a random YOLO suffix to each word in the array
352
+ const addYoloSuffixes = (arrayStr) => {
353
+ try {
354
+ const array = JSON.parse(arrayStr);
355
+ const yoloArray = array.map(word => {
356
+ const randomSuffix = yoloSuffixes[Math.floor(Math.random() * yoloSuffixes.length)];
357
+ return word + randomSuffix;
358
+ });
359
+ return JSON.stringify(yoloArray);
360
+ } catch (e) {
361
+ debug(`Error modifying loading messages array: ${e.message}`);
362
+ return arrayStr;
363
+ }
364
+ };
365
+
366
+ cliContent = cliContent.replace(originalArray, addYoloSuffixes(originalArray));
367
+ debug("Replaced loading messages with YOLO versions");
368
+
369
+ // Write the modified content to a new file, leaving the original untouched
370
+ fs.writeFileSync(yoloCliPath, cliContent);
371
+ debug(`Created modified CLI at ${yoloCliPath}`);
372
+ debug("Modifications complete. The --dangerously-skip-permissions flag should now work everywhere.");
373
+
374
+ // Add the --dangerously-skip-permissions flag to the command line arguments
375
+ // This will ensure it's passed to the CLI even if the user didn't specify it
376
+ process.argv.splice(2, 0, '--dangerously-skip-permissions');
377
+ debug("Added --dangerously-skip-permissions flag to command line arguments");
378
+
379
+ // Now import the modified CLI
380
+ const yoloCliUrl = pathToFileURL(yoloCliPath).href;
381
+ await import(yoloCliUrl);
382
+ }
383
+
384
+ // Run the main function
385
+ run().catch(err => {
386
+ console.error("Error:", err);
387
+ process.exit(1);
388
+ });
package/package.json ADDED
@@ -0,0 +1,44 @@
1
+ {
2
+ "name": "claude-yolo-extended",
3
+ "version": "1.8.0",
4
+ "description": "Claude CLI wrapper with YOLO mode (bypass safety) and SAFE mode support, auto-updates, and colorful loading messages",
5
+ "bin": {
6
+ "claude-yolo-extended": "bin/claude-yolo.js",
7
+ "cl": "bin/cl"
8
+ },
9
+ "dependencies": {
10
+ "punycode": "latest",
11
+ "@anthropic-ai/claude-code": "1.0.53"
12
+ },
13
+ "type": "module",
14
+ "scripts": {
15
+ "postinstall": "node -e \"require('fs').chmodSync('./bin/cl', 0o755);\""
16
+ },
17
+ "repository": {
18
+ "type": "git",
19
+ "url": "git+https://github.com/jslitzkerttcu/claude-yolo.git"
20
+ },
21
+ "keywords": [
22
+ "claude",
23
+ "cli",
24
+ "anthropic",
25
+ "wrapper",
26
+ "yolo",
27
+ "safe-mode",
28
+ "permissions"
29
+ ],
30
+ "author": "jslitzkerttcu",
31
+ "license": "MIT",
32
+ "bugs": {
33
+ "url": "https://github.com/jslitzkerttcu/claude-yolo/issues"
34
+ },
35
+ "homepage": "https://github.com/jslitzkerttcu/claude-yolo#readme",
36
+ "engines": {
37
+ "node": ">=14.16"
38
+ },
39
+ "os": [
40
+ "win32",
41
+ "darwin",
42
+ "linux"
43
+ ]
44
+ }
package/postinstall.js ADDED
@@ -0,0 +1,52 @@
1
+ #!/usr/bin/env node
2
+
3
+ import readline from 'readline';
4
+
5
+ // ANSI color codes
6
+ const RED = '\x1b[31m';
7
+ const YELLOW = '\x1b[33m';
8
+ const CYAN = '\x1b[36m';
9
+ const RESET = '\x1b[0m';
10
+ const BOLD = '\x1b[1m';
11
+
12
+ // Create readline interface for user input
13
+ const rl = readline.createInterface({
14
+ input: process.stdin,
15
+ output: process.stdout
16
+ });
17
+
18
+ console.log(`\n${BOLD}${YELLOW}🔥 CLAUDE-YOLO INSTALLATION CONSENT REQUIRED 🔥${RESET}\n`);
19
+ console.log(`${CYAN}----------------------------------------${RESET}`);
20
+ console.log(`${BOLD}What is claude-yolo?${RESET}`);
21
+ console.log(`This package creates a wrapper around the official Claude CLI tool that:`);
22
+ console.log(` 1. ${RED}BYPASSES safety checks${RESET} by automatically adding the --dangerously-skip-permissions flag`);
23
+ console.log(` 2. Automatically updates to the latest Claude CLI version`);
24
+ console.log(` 3. Adds colorful YOLO-themed loading messages\n`);
25
+
26
+ console.log(`${BOLD}${RED}⚠️ IMPORTANT SECURITY WARNING ⚠️${RESET}`);
27
+ console.log(`The ${BOLD}--dangerously-skip-permissions${RESET} flag was designed for use in containers`);
28
+ console.log(`and bypasses important safety checks. This includes ignoring file access`);
29
+ console.log(`permissions that protect your system and privacy.\n`);
30
+
31
+ console.log(`${BOLD}By using claude-yolo:${RESET}`);
32
+ console.log(` • You acknowledge these safety checks are being bypassed`);
33
+ console.log(` • You understand this may allow Claude CLI to access sensitive files`);
34
+ console.log(` • You accept full responsibility for any security implications\n`);
35
+
36
+ console.log(`${CYAN}----------------------------------------${RESET}\n`);
37
+
38
+ // Ask for explicit consent
39
+ rl.question(`${YELLOW}Do you consent to installing claude-yolo with these modifications? (yes/no): ${RESET}`, (answer) => {
40
+ const lowerAnswer = answer.toLowerCase().trim();
41
+
42
+ if (lowerAnswer === 'yes' || lowerAnswer === 'y') {
43
+ console.log(`\n${YELLOW}🔥 YOLO MODE INSTALLATION APPROVED 🔥${RESET}`);
44
+ console.log(`Installation will continue. Use 'claude-yolo' instead of 'claude' to run in YOLO mode.`);
45
+ process.exit(0); // Success exit code
46
+ } else {
47
+ console.log(`\n${CYAN}Installation cancelled by user.${RESET}`);
48
+ console.log(`If you want the official Claude CLI with normal safety features, run:`);
49
+ console.log(`npm install -g @anthropic-ai/claude-code`);
50
+ process.exit(1); // Error exit code to abort installation
51
+ }
52
+ });