claude-yolo-extended 1.9.2 → 1.9.5
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/.claude/commands/shutdown.md +17 -17
- package/.claude/commands/startup.md +13 -13
- package/.editorconfig +21 -0
- package/.github/workflows/publish.yml +34 -0
- package/.prettierrc +8 -0
- package/AI_HANDOFF.md +17 -15
- package/CLAUDE.md +83 -83
- package/CONTRIBUTING.md +84 -0
- package/README.md +243 -243
- package/SECURITY.md +36 -0
- package/bin/ascii-art.js +58 -65
- package/bin/cl +116 -116
- package/bin/cl.js +174 -137
- package/bin/cl.ps1 +36 -36
- package/bin/claude-yolo.js +678 -388
- package/eslint.config.js +25 -0
- package/jest.config.js +9 -0
- package/lib/constants.js +97 -0
- package/package.json +57 -41
- package/postinstall.js +45 -51
- package/preuninstall.js +77 -0
- package/tests/constants.test.js +146 -0
package/bin/cl
CHANGED
|
@@ -1,117 +1,117 @@
|
|
|
1
|
-
#!/bin/bash
|
|
2
|
-
|
|
3
|
-
# Claude YOLO/SAFE Mode Wrapper Script
|
|
4
|
-
# Usage: cl /YON | /YOFF | /STATUS | /HELP | [claude commands]
|
|
5
|
-
|
|
6
|
-
#
|
|
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
|
-
#
|
|
15
|
-
STATE_FILE="$HOME/.claude_yolo_state"
|
|
16
|
-
|
|
17
|
-
#
|
|
18
|
-
get_mode() {
|
|
19
|
-
if [ -f "$STATE_FILE" ]; then
|
|
20
|
-
cat "$STATE_FILE"
|
|
21
|
-
else
|
|
22
|
-
echo "SAFE" #
|
|
23
|
-
fi
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
#
|
|
27
|
-
set_mode() {
|
|
28
|
-
echo "$1" > "$STATE_FILE"
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
#
|
|
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
|
-
#
|
|
87
|
-
MODE=$(get_mode)
|
|
88
|
-
|
|
89
|
-
#
|
|
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
|
-
;;
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
|
|
3
|
+
# Claude YOLO/SAFE Mode Wrapper Script
|
|
4
|
+
# Usage: cl /YON | /YOFF | /STATUS | /HELP | [claude commands]
|
|
5
|
+
|
|
6
|
+
# Terminal colors
|
|
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
|
+
# State file for mode persistence
|
|
15
|
+
STATE_FILE="$HOME/.claude_yolo_state"
|
|
16
|
+
|
|
17
|
+
# Function to get current mode
|
|
18
|
+
get_mode() {
|
|
19
|
+
if [ -f "$STATE_FILE" ]; then
|
|
20
|
+
cat "$STATE_FILE"
|
|
21
|
+
else
|
|
22
|
+
echo "SAFE" # Default to safe mode
|
|
23
|
+
fi
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
# Function to set mode
|
|
27
|
+
set_mode() {
|
|
28
|
+
echo "$1" > "$STATE_FILE"
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
# Process arguments
|
|
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
|
+
# Run Claude in current mode
|
|
87
|
+
MODE=$(get_mode)
|
|
88
|
+
|
|
89
|
+
# Show mode before running
|
|
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
117
|
esac
|
package/bin/cl.js
CHANGED
|
@@ -1,137 +1,174 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
import fs from 'fs';
|
|
4
|
-
import
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
import {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
function setMode(mode) {
|
|
35
|
-
fs.writeFileSync(
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
case '/
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
console.log(
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
process.exit(
|
|
136
|
-
}
|
|
137
|
-
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import fs from 'fs';
|
|
4
|
+
import { spawn } from 'child_process';
|
|
5
|
+
import { showYoloActivated, showSafeActivated, showModeStatus } from './ascii-art.js';
|
|
6
|
+
|
|
7
|
+
import {
|
|
8
|
+
YELLOW,
|
|
9
|
+
CYAN,
|
|
10
|
+
RESET,
|
|
11
|
+
BOLD,
|
|
12
|
+
DANGEROUS_CHARS_PATTERN,
|
|
13
|
+
STATE_FILE,
|
|
14
|
+
logError,
|
|
15
|
+
handleFatalError
|
|
16
|
+
} from '../lib/constants.js';
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Get current mode from state file
|
|
20
|
+
* @returns {string} Current mode ('YOLO' or 'SAFE')
|
|
21
|
+
*/
|
|
22
|
+
function getMode() {
|
|
23
|
+
try {
|
|
24
|
+
return fs.readFileSync(STATE_FILE, 'utf8').trim();
|
|
25
|
+
} catch {
|
|
26
|
+
return 'YOLO'; // Default to YOLO mode (matches claude-yolo-extended behavior)
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Set mode in state file
|
|
32
|
+
* @param {string} mode - Mode to set ('YOLO' or 'SAFE')
|
|
33
|
+
*/
|
|
34
|
+
function setMode(mode) {
|
|
35
|
+
fs.writeFileSync(STATE_FILE, mode);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Validate command-line arguments for shell injection (Windows only)
|
|
40
|
+
* @param {string[]} args - Arguments to validate
|
|
41
|
+
* @returns {boolean} True if all arguments are safe
|
|
42
|
+
*/
|
|
43
|
+
function validateArgs(args) {
|
|
44
|
+
const isWindows = process.platform === 'win32';
|
|
45
|
+
if (!isWindows) return true; // Non-Windows uses shell:false
|
|
46
|
+
|
|
47
|
+
for (const arg of args) {
|
|
48
|
+
if (DANGEROUS_CHARS_PATTERN.test(arg)) {
|
|
49
|
+
logError(`Invalid characters in argument: ${arg}`);
|
|
50
|
+
console.error('Arguments cannot contain: ; & | ` $ > <');
|
|
51
|
+
return false;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
return true;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
// Get command line arguments
|
|
58
|
+
const args = process.argv.slice(2);
|
|
59
|
+
|
|
60
|
+
// Handle special commands
|
|
61
|
+
if (args.length > 0) {
|
|
62
|
+
const command = args[0].toUpperCase();
|
|
63
|
+
|
|
64
|
+
switch (command) {
|
|
65
|
+
case '/YON':
|
|
66
|
+
showYoloActivated();
|
|
67
|
+
setMode('YOLO');
|
|
68
|
+
console.log(`${YELLOW}✓ YOLO mode is now ON${RESET}`);
|
|
69
|
+
|
|
70
|
+
// Auto-start with remaining args
|
|
71
|
+
if (args.length > 1) {
|
|
72
|
+
runClaude(args.slice(1));
|
|
73
|
+
} else {
|
|
74
|
+
runClaude([]);
|
|
75
|
+
}
|
|
76
|
+
break;
|
|
77
|
+
|
|
78
|
+
case '/YOFF':
|
|
79
|
+
showSafeActivated();
|
|
80
|
+
setMode('SAFE');
|
|
81
|
+
console.log(`${CYAN}✓ YOLO mode is now OFF (Safe mode ON)${RESET}`);
|
|
82
|
+
|
|
83
|
+
// Auto-start with remaining args
|
|
84
|
+
if (args.length > 1) {
|
|
85
|
+
runClaude(args.slice(1));
|
|
86
|
+
} else {
|
|
87
|
+
runClaude([]);
|
|
88
|
+
}
|
|
89
|
+
break;
|
|
90
|
+
|
|
91
|
+
case '/STATUS': {
|
|
92
|
+
const mode = getMode();
|
|
93
|
+
showModeStatus(mode);
|
|
94
|
+
break;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
case '/HELP':
|
|
98
|
+
case '/H':
|
|
99
|
+
case '/?':
|
|
100
|
+
console.log(`${BOLD}Claude CLI Wrapper - Help${RESET}`);
|
|
101
|
+
console.log('━━━━━━━━━━━━━━━━━━━━━━━━━━━━');
|
|
102
|
+
console.log(`${CYAN}cl /YON${RESET} - Enable YOLO mode (bypass safety)`);
|
|
103
|
+
console.log(`${CYAN}cl /YOFF${RESET} - Disable YOLO mode (safe mode)`);
|
|
104
|
+
console.log(`${CYAN}cl /STATUS${RESET} - Show current mode`);
|
|
105
|
+
console.log(`${CYAN}cl /HELP${RESET} - Show this help`);
|
|
106
|
+
console.log(`${CYAN}cl [args]${RESET} - Run claude with current mode`);
|
|
107
|
+
console.log('━━━━━━━━━━━━━━━━━━━━━━━━━━━━');
|
|
108
|
+
console.log('');
|
|
109
|
+
console.log(`${BOLD}Examples:${RESET}`);
|
|
110
|
+
console.log(' cl /YON # Enable YOLO mode');
|
|
111
|
+
console.log(' cl /YOFF # Enable SAFE mode');
|
|
112
|
+
console.log(' cl "write a function" # Run Claude in current mode');
|
|
113
|
+
console.log('');
|
|
114
|
+
console.log(`${BOLD}Mode Persistence:${RESET}`);
|
|
115
|
+
console.log('Your mode choice is saved in ~/.claude_yolo_state');
|
|
116
|
+
console.log('and persists between terminal sessions.');
|
|
117
|
+
break;
|
|
118
|
+
|
|
119
|
+
default:
|
|
120
|
+
// Run Claude with provided arguments
|
|
121
|
+
runClaude(args);
|
|
122
|
+
}
|
|
123
|
+
} else {
|
|
124
|
+
// No arguments, just run Claude
|
|
125
|
+
runClaude([]);
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* Run Claude CLI with the given arguments in current mode
|
|
130
|
+
* @param {string[]} claudeArgs - Arguments to pass to Claude
|
|
131
|
+
*/
|
|
132
|
+
function runClaude(claudeArgs) {
|
|
133
|
+
// Validate arguments before running (security check for Windows shell)
|
|
134
|
+
if (!validateArgs(claudeArgs)) {
|
|
135
|
+
process.exit(1);
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
const mode = getMode();
|
|
139
|
+
|
|
140
|
+
// Show current mode
|
|
141
|
+
if (mode === 'YOLO') {
|
|
142
|
+
console.log(`${YELLOW}[YOLO]${RESET} Running Claude in YOLO mode...`);
|
|
143
|
+
} else {
|
|
144
|
+
console.log(`${CYAN}[SAFE]${RESET} Running Claude in SAFE mode...`);
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
// Determine which command to run
|
|
148
|
+
const command = 'claude-yolo-extended';
|
|
149
|
+
const commandArgs = mode === 'SAFE' ? ['--safe', ...claudeArgs] : claudeArgs;
|
|
150
|
+
|
|
151
|
+
// Spawn the process
|
|
152
|
+
// Note: shell:false is safer (prevents command injection) but requires
|
|
153
|
+
// the command to be in PATH. On Windows, we need shell:true for .cmd files.
|
|
154
|
+
const isWindows = process.platform === 'win32';
|
|
155
|
+
const child = spawn(command, commandArgs, {
|
|
156
|
+
stdio: 'inherit',
|
|
157
|
+
shell: isWindows // Only use shell on Windows where it's required for PATH resolution
|
|
158
|
+
});
|
|
159
|
+
|
|
160
|
+
child.on('error', (err) => {
|
|
161
|
+
handleFatalError(`Failed to start ${command}: ${err.message}`, err);
|
|
162
|
+
});
|
|
163
|
+
|
|
164
|
+
child.on('exit', (code, signal) => {
|
|
165
|
+
if (signal) {
|
|
166
|
+
// Process was killed by signal - exit with 128 + signal number (Unix convention)
|
|
167
|
+
// Common signals: SIGTERM=15, SIGKILL=9, SIGINT=2
|
|
168
|
+
const signalCodes = { SIGTERM: 15, SIGKILL: 9, SIGINT: 2, SIGHUP: 1 };
|
|
169
|
+
const signalNum = signalCodes[signal] || 1;
|
|
170
|
+
process.exit(128 + signalNum);
|
|
171
|
+
}
|
|
172
|
+
process.exit(code ?? 0);
|
|
173
|
+
});
|
|
174
|
+
}
|
package/bin/cl.ps1
CHANGED
|
@@ -1,36 +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
|
|
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
|