-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·168 lines (152 loc) · 4.88 KB
/
Copy pathinstall.sh
File metadata and controls
executable file
·168 lines (152 loc) · 4.88 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
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
79
80
81
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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
#!/bin/bash
# Atomic Bits - Install Script
# Copies Atomic Bits to a target project
set -euo pipefail
# Colors
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
NC='\033[0m'
# Get script directory (where atomic-bits lives)
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
# Get target directory
TARGET="${1:-.}"
TARGET="$(cd "$TARGET" 2>/dev/null && pwd)" || {
echo -e "${RED}Error: Target directory '$1' does not exist${NC}"
exit 1
}
echo -e "${GREEN}Atomic Bits Installer${NC}"
echo "━━━━━━━━━━━━━━━━━━━━━"
echo ""
echo "Source: $SCRIPT_DIR"
echo "Target: $TARGET"
echo ""
# Check if already installed
if [ -f "$TARGET/.atomic/bits.sh" ]; then
echo -e "${YELLOW}Warning: Atomic Bits already exists in target.${NC}"
read -p "Overwrite? (y/n) " -n 1 -r
echo
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
echo "Aborted."
exit 0
fi
fi
# Ask about permission mode
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo ""
echo -e "${BLUE}Choose permission mode:${NC}"
echo ""
echo " 1) Safe Mode (recommended)"
echo " Claude will prompt for approval before file changes and commands."
echo " Best for: learning, sensitive projects, first-time users."
echo ""
echo " 2) Bypass Mode (automated)"
echo " Claude can read/write files and run commands without prompting."
echo " Best for: trusted automation, disposable environments, experienced users."
echo ""
read -p "Select mode [1/2]: " -n 1 -r MODE_CHOICE
echo ""
echo ""
BYPASS_MODE=false
if [[ $MODE_CHOICE == "2" ]]; then
BYPASS_MODE=true
echo -e "${YELLOW}Bypass mode selected.${NC} Permissions will be skipped."
else
echo -e "${GREEN}Safe mode selected.${NC} You'll approve actions as you go."
fi
echo ""
# Create directories
mkdir -p "$TARGET/.atomic/phases"
mkdir -p "$TARGET/.claude/commands"
mkdir -p "$TARGET/.claude/agents"
# Copy .atomic files
echo "Copying .atomic/..."
cp "$SCRIPT_DIR/.atomic/bits.sh" "$TARGET/.atomic/"
cp "$SCRIPT_DIR/.atomic/patterns.md" "$TARGET/.atomic/"
cp "$SCRIPT_DIR/.atomic/project.md" "$TARGET/.atomic/"
cp "$SCRIPT_DIR/.atomic/roadmap.md" "$TARGET/.atomic/"
cp "$SCRIPT_DIR/.atomic/state.json" "$TARGET/.atomic/"
chmod +x "$TARGET/.atomic/bits.sh"
# Copy .claude files
echo "Copying .claude/..."
cp "$SCRIPT_DIR/.claude/commands/atomic.md" "$TARGET/.claude/commands/"
cp "$SCRIPT_DIR/.claude/agents/executor.md" "$TARGET/.claude/agents/"
cp "$SCRIPT_DIR/.claude/agents/verifier.md" "$TARGET/.claude/agents/"
# Generate settings.json based on mode choice
echo "Configuring permissions..."
if [ "$BYPASS_MODE" = true ]; then
cat > "$TARGET/.claude/settings.json" << 'EOF'
{
"permissions": {
"defaultMode": "bypassPermissions",
"deny": [
"Read(.env)",
"Read(.env.*)",
"Read(**/secrets/**)",
"Read(**/*.pem)",
"Read(**/*.key)"
]
}
}
EOF
else
cat > "$TARGET/.claude/settings.json" << 'EOF'
{
"permissions": {
"deny": [
"Read(.env)",
"Read(.env.*)",
"Read(**/secrets/**)",
"Read(**/*.pem)",
"Read(**/*.key)"
]
}
}
EOF
fi
echo ""
echo -e "${GREEN}✓ Installed successfully!${NC}"
echo ""
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo ""
if [ "$BYPASS_MODE" = true ]; then
echo -e "${YELLOW}Installed in BYPASS MODE${NC}"
echo ""
echo "Permissions are disabled. Claude can read, write, and execute without prompting."
echo ""
echo "Getting started:"
echo ""
echo " cd $TARGET"
echo " claude"
echo " /atomic"
echo ""
echo "For multi-phase automation with fresh context:"
echo ""
echo " ./.atomic/bits.sh --confirm"
echo ""
echo -e "${YELLOW}Safety tips:${NC}"
echo " • Commit your work to git before running"
echo " • Review the generated roadmap.md"
echo " • Consider running in a container/VM"
else
echo -e "${GREEN}Installed in SAFE MODE${NC}"
echo ""
echo "Claude will prompt for approval before file changes and commands."
echo ""
echo "Getting started:"
echo ""
echo " cd $TARGET"
echo " claude"
echo " /atomic"
echo ""
echo "For multi-phase automation (requires --confirm):"
echo ""
echo " ./.atomic/bits.sh --confirm"
echo ""
echo "Note: bits.sh always uses bypass mode for automation."
echo "You can change modes later by editing .claude/settings.json"
fi
echo ""
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo ""