#!/bin/bash set -euo pipefail # saTway Daily Routine - 7-phase morning workflow # Implements "Morning Start Protocol (15 Min)" mkdir -p "$HOME/logs" 2>/dev/null || true LOCAL_LOG="$HOME/logs/daily-routine-$(date +%Y%m%d).log" HEALTH_SCRIPT="$(dirname "$0")/morning-health-check.sh" WORKSPACE="$HOME/internal/mw-pfeddersheim-workstation" # ANSI colors RED='\033[0;31m' YELLOW='\033[0;33m' GREEN='\033[0;32m' BLUE='\033[0;34m' NC='\033[0m' log() { echo -e "$1" | tee -a "$LOCAL_LOG" } phase_header() { log "\n${BLUE}--- Phase $1: $2 ---${NC}" } run_health_check() { log "Running health check..." if [ -x "$HEALTH_SCRIPT" ]; then HEALTH_EXIT=0 # Disable set -e for the health check call set +e bash "$HEALTH_SCRIPT" 2>&1 | tee -a "$LOCAL_LOG" HEALTH_EXIT=$? set -e if [ "$HEALTH_EXIT" -eq 2 ]; then log "\n${RED}CRITICAL: Health check failed with critical errors.${NC}" # Still proceed for the morning-full routine but with a big warning? # Or exit? Let's follow the previous script logic for health: # morning-full should probably still show the rest of the protocol # so the user can see everything. elif [ "$HEALTH_EXIT" -eq 1 ]; then log "\n${YELLOW}WARNING: Health check finished with warnings.${NC}" fi else log "${YELLOW}WARNING: Health check script not found or not executable${NC}" fi } phase_0_readiness() { phase_header "0" "Physical & Mental Readiness" log "Checklist:" log " [ ] Hydrated" log " [ ] Light movement" log " [ ] 1-minute mindfulness" log " [ ] Time block established" log "\nActivating DND (macOS)..." if [[ "$OSTYPE" == "darwin"* ]]; then osascript -e 'do shell script "defaults write com.apple.controlcenter \"NSStatusItem Visible DoNotDisturb\" -bool true"' || log " Failed to set DND" pkill -f "Slack" 2>/dev/null || true pkill -f "Discord" 2>/dev/null || true log " DND enabled and distractions closed." else log " SKIP: Not on macOS" fi } phase_1_context() { phase_header "1" "Context Restoration" log "Recent WIP commits:" git -C "$WORKSPACE" log -5 --pretty=format:"%h %s" --grep="wip:" || log " No WIP commits found" log "\nRecent learnings:" ls -lt "$WORKSPACE/docs/learnings/" 2>/dev/null | head -3 || log " No learnings found" log "\nGit status:" git -C "$WORKSPACE" status --short } phase_2_validation() { phase_header "2" "Environment Validation" run_health_check } phase_3_priority() { phase_header "3" "Priority Framework (MoSCoW)" log "Define exactly 3 priorities. No more." log " 1. [MUST] _____________________" log " 2. [MUST/SHOULD] ______________" log " 3. [SHOULD] ___________________" } phase_4_sync() { phase_header "4" "Team Synchronization" log " [ ] Async Standup: Post yesterday, today, blockers, availability." log " [ ] Block Focus Time: Calendar updated." } phase_5_warmup() { phase_header "5" "Cognitive Warmup" log "Choose ONE (2-5 minutes):" log " - Review simple PR" log " - Fix trivial lint warning" log " - Write small test case" log " - Document one function" } phase_6_ai_setup() { phase_header "6" "AI Setup" if command -v cline &> /dev/null; then log "cline version:" cline --version | head -n 1 | tee -a "$LOCAL_LOG" else log "${YELLOW}WARNING: cline CLI not found${NC}" fi } phase_7_launch() { phase_header "7" "Launch Deep Work" log "Ready to start?" log " 1. Create branch: git checkout -b feat/\$(date +%Y%m%d)_morning_start" log " 2. Start timer: timer 90m \"Deep work complete!\" &" log " 3. FIRST ACTION: Write ONE thing that proves work has started (e.g., 1 failing test)." } # Command line interface case "${1:-morning}" in "health") run_health_check ;; "morning") log "--- Starting Lightweight Daily Routine $(date) ---" phase_2_validation log "\n--- Daily Routine Finished $(date) ---" ;; "morning-full") log "--- Starting Full Morning Protocol $(date) ---" phase_0_readiness phase_1_context phase_2_validation phase_3_priority phase_4_sync phase_5_warmup phase_6_ai_setup phase_7_launch log "\n--- Full Morning Protocol Finished $(date) ---" ;; *) echo "Usage: $0 {health|morning|morning-full}" exit 1 ;; esac