@@ -138,6 +138,26 @@ pick_tagline() {
138138
139139TAGLINE=$( pick_tagline)
140140
141+ NO_ONBOARD=${CLAWDBOT_NO_ONBOARD:- 0}
142+
143+ parse_args () {
144+ while [[ $# -gt 0 ]]; do
145+ case " $1 " in
146+ --no-onboard)
147+ NO_ONBOARD=1
148+ shift
149+ ;;
150+ --onboard)
151+ NO_ONBOARD=0
152+ shift
153+ ;;
154+ * )
155+ shift
156+ ;;
157+ esac
158+ done
159+ }
160+
141161echo -e " ${ACCENT}${BOLD} "
142162echo " 🦞 Clawdbot Installer"
143163echo -e " ${NC}${ACCENT_DIM} ${TAGLINE}${NC} "
@@ -225,6 +245,67 @@ install_node() {
225245 fi
226246}
227247
248+ # Check Git
249+ check_git () {
250+ if command -v git & > /dev/null; then
251+ echo -e " ${SUCCESS} ✓${NC} Git already installed"
252+ return 0
253+ fi
254+ echo -e " ${WARN} →${NC} Git not found"
255+ return 1
256+ }
257+
258+ install_git () {
259+ echo -e " ${WARN} →${NC} Installing Git..."
260+ if [[ " $OS " == " macos" ]]; then
261+ brew install git
262+ elif [[ " $OS " == " linux" ]]; then
263+ if command -v apt-get & > /dev/null; then
264+ sudo apt-get update -y
265+ sudo apt-get install -y git
266+ elif command -v dnf & > /dev/null; then
267+ sudo dnf install -y git
268+ elif command -v yum & > /dev/null; then
269+ sudo yum install -y git
270+ else
271+ echo -e " ${ERROR} Error: Could not detect package manager for Git${NC} "
272+ exit 1
273+ fi
274+ fi
275+ echo -e " ${SUCCESS} ✓${NC} Git installed"
276+ }
277+
278+ # Fix npm permissions for global installs (Linux)
279+ fix_npm_permissions () {
280+ if [[ " $OS " != " linux" ]]; then
281+ return 0
282+ fi
283+
284+ local npm_prefix
285+ npm_prefix=" $( npm config get prefix 2> /dev/null || true) "
286+ if [[ -z " $npm_prefix " ]]; then
287+ return 0
288+ fi
289+
290+ if [[ -w " $npm_prefix " || -w " $npm_prefix /lib" ]]; then
291+ return 0
292+ fi
293+
294+ echo -e " ${WARN} →${NC} Configuring npm for user-local installs..."
295+ mkdir -p " $HOME /.npm-global"
296+ npm config set prefix " $HOME /.npm-global"
297+
298+ local path_line=' export PATH="$HOME/.npm-global/bin:$PATH"'
299+ for rc in " $HOME /.bashrc" " $HOME /.zshrc" ; do
300+ if [[ -f " $rc " ]] && ! grep -q " .npm-global" " $rc " ; then
301+ echo " $path_line " >> " $rc "
302+ fi
303+ done
304+
305+ export PATH=" $HOME /.npm-global/bin:$PATH "
306+ echo -e " ${SUCCESS} ✓${NC} npm configured for user installs"
307+ }
308+
228309# Check for existing Clawdbot installation
229310check_existing_clawdbot () {
230311 if command -v clawdbot & > /dev/null; then
@@ -279,10 +360,18 @@ main() {
279360 install_node
280361 fi
281362
282- # Step 3: Clawdbot
363+ # Step 3: Git (required for npm installs that may fetch from git or apply patches)
364+ if ! check_git; then
365+ install_git
366+ fi
367+
368+ # Step 4: npm permissions (Linux)
369+ fix_npm_permissions
370+
371+ # Step 5: Clawdbot
283372 install_clawdbot
284373
285- # Step 4 : Run doctor for migrations if upgrading
374+ # Step 6 : Run doctor for migrations if upgrading
286375 if [[ " $is_upgrade " == " true" ]]; then
287376 run_doctor
288377 fi
@@ -301,13 +390,18 @@ main() {
301390 if [[ " $is_upgrade " == " true" ]]; then
302391 echo -e " Upgrade complete. Run ${INFO} clawdbot doctor${NC} to check for additional migrations."
303392 else
304- echo -e " Starting setup..."
305- echo " "
306- exec clawdbot onboard
393+ if [[ " $NO_ONBOARD " == " 1" ]]; then
394+ echo -e " Skipping onboard (requested). Run ${INFO} clawdbot onboard${NC} later."
395+ else
396+ echo -e " Starting setup..."
397+ echo " "
398+ exec clawdbot onboard
399+ fi
307400 fi
308401
309402 echo " "
310403 echo -e " FAQ: ${INFO} https://docs.clawd.bot/start/faq${NC} "
311404}
312405
406+ parse_args " $@ "
313407main
0 commit comments