-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathdebug_detection.sh
More file actions
executable file
·48 lines (37 loc) · 1.37 KB
/
debug_detection.sh
File metadata and controls
executable file
·48 lines (37 loc) · 1.37 KB
1
2
3
4
5
6
7
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#!/bin/bash
# Debug script to test AI detection
# Load only the detection functions from executable_git to avoid exec side effects
eval "$(sed -n '/^process_contains()/,/^}/p' executable_git)"
eval "$(sed -n '/^check_env_vars()/,/^}/p' executable_git)"
eval "$(sed -n '/^check_ps_tree()/,/^}/p' executable_git)"
eval "$(sed -n '/^detect_ai_tool()/,/^}/p' executable_git)"
echo "=== Debug AI Detection ==="
echo "Current PID: $$"
echo "Current PPID: $(ps -p $$ -o ppid= | tr -d ' ')"
echo -e "\n=== Environment Variables ==="
echo "CLAUDECODE: $CLAUDECODE"
echo "CLAUDE_CODE_ENTRYPOINT: $CLAUDE_CODE_ENTRYPOINT"
echo "TERM_PROGRAM: $TERM_PROGRAM"
echo "ZED_TERM: $ZED_TERM"
echo -e "\n=== Process Tree ==="
current_pid=$$
depth=0
while [ $depth -lt 5 ]; do
if [[ "$OSTYPE" == "darwin"* ]]; then
parent_pid=$(ps -p "$current_pid" -o ppid= 2>/dev/null | tr -d ' ')
fi
if [ -z "$parent_pid" ] || [ "$parent_pid" -eq 1 ]; then
break
fi
process_info=$(ps -p "$parent_pid" -o pid=,comm=,command= 2>/dev/null)
echo "Depth $depth: $process_info"
current_pid=$parent_pid
depth=$((depth + 1))
done
echo -e "\n=== Detection Results ==="
env_detected=$(check_env_vars)
echo "Environment detected: '$env_detected'"
ps_detected=$(check_ps_tree)
echo "Process tree detected: '$ps_detected'"
final_result=$(detect_ai_tool)
echo "Final result: '$final_result'"