Skip to content

⛰️ LifeOS — The AI-powered Life Operating System that helps you hill climb to wherever you're going.

Added configurable Digital Assistant name via DA environment variable

Daniel Miessleraf83518eb1ea
diff --git a/.claude/hooks/session-start-hook.ts b/.claude/hooks/session-start-hook.ts
index 121df4a5..e365fa5d 100755
--- a/.claude/hooks/session-start-hook.ts
+++ b/.claude/hooks/session-start-hook.ts
@@ -12,7 +12,7 @@ async function sendNotification(title: string, message: string, priority: string
message,
voice_enabled: true,
priority,
- voice_id: 'jqcCZkN6Knx8BJ5TBdYR' // Kai's voice ID
+ voice_id: 'jqcCZkN6Knx8BJ5TBdYR' // Assistant's voice ID
}),
});
@@ -26,8 +26,9 @@ async function sendNotification(title: string, message: string, priority: string
async function main() {
try {
- const message = `Kai here, ready to go.`;
- await sendNotification('Kai Systems Initialized', message, 'low');
+ const daName = process.env.DA || 'Kai';
+ const message = `${daName} here, ready to go.`;
+ await sendNotification(`${daName} Systems Initialized`, message, 'low');
process.exit(0);
} catch (error) {
console.error('SessionStart hook error:', error);
diff --git a/.claude/statusline-command.sh b/.claude/statusline-command.sh
index ccae3c21..0ea8174d 100755
--- a/.claude/statusline-command.sh
+++ b/.claude/statusline-command.sh
@@ -3,6 +3,9 @@
# Read JSON input from stdin
input=$(cat)
+# Get Digital Assistant name from environment (default to Kai if not set)
+DA_NAME="${DA:-Kai}"
+
# Extract data from JSON input
current_dir=$(echo "$input" | jq -r '.workspace.current_dir')
model_name=$(echo "$input" | jq -r '.model.display_name')
@@ -10,153 +13,193 @@ model_name=$(echo "$input" | jq -r '.model.display_name')
# Get directory name
dir_name=$(basename "$current_dir")
+# Cache file and lock file for ccusage data
+CACHE_FILE="/tmp/.claude_ccusage_cache"
+LOCK_FILE="/tmp/.claude_ccusage.lock"
+CACHE_AGE=30 # 30 seconds for more real-time updates
+
# Count items from specified directories
-# - Services count from ~/Projects/FoundryServices/Services
-# - Commands from ${PAI_HOME}/.claude/commands/
-# - MCPs from settings.json
-# - Patterns from ${PAI_HOME}/.config/fabric/patterns
claude_dir="${PAI_HOME:-/Users/daniel}/.claude"
commands_count=0
mcps_count=0
fobs_count=0
fabric_count=0
-# Count commands (only .md files in root of commands directory, not subdirectories)
+# Count commands (optimized - direct ls instead of find)
if [ -d "$claude_dir/commands" ]; then
- commands_count=$(find "$claude_dir/commands" -maxdepth 1 -name "*.md" 2>/dev/null | wc -l | tr -d ' ')
+ commands_count=$(ls -1 "$claude_dir/commands/"*.md 2>/dev/null | wc -l | tr -d ' ')
fi
-# Count MCPs from settings.json
+# Count MCPs from settings.json (single parse)
+mcp_names_raw=""
if [ -f "$claude_dir/settings.json" ]; then
- mcps_count=$(jq -r '.mcpServers | keys | length' "$claude_dir/settings.json" 2>/dev/null || echo "0")
+ mcp_data=$(jq -r '.mcpServers | keys | join(" "), length' "$claude_dir/settings.json" 2>/dev/null)
+ mcp_names_raw=$(echo "$mcp_data" | head -1)
+ mcps_count=$(echo "$mcp_data" | tail -1)
else
mcps_count="0"
fi
-# Count Services from FoundryServices directory
+# Count Services (optimized - count .md files directly)
services_dir="${PAI_HOME:-/Users/daniel}/Projects/FoundryServices/Services"
if [ -d "$services_dir" ]; then
- fobs_count=$(find "$services_dir" -type f -name "*.md" 2>/dev/null | wc -l | tr -d ' ')
+ fobs_count=$(ls -1 "$services_dir/"*.md 2>/dev/null | wc -l | tr -d ' ')
fi
-# Count Fabric patterns from ~/.config/fabric/patterns
+# Count Fabric patterns (optimized - count subdirectories)
fabric_patterns_dir="${PAI_HOME:-/Users/daniel}/.config/fabric/patterns"
if [ -d "$fabric_patterns_dir" ]; then
- fabric_count=$(find "$fabric_patterns_dir" -maxdepth 1 -type d ! -path "$fabric_patterns_dir" 2>/dev/null | wc -l | tr -d ' ')
+ # Count immediate subdirectories only
+ fabric_count=$(find "$fabric_patterns_dir" -maxdepth 1 -type d -not -path "$fabric_patterns_dir" 2>/dev/null | wc -l | tr -d ' ')
fi
-# Get daily usage data from ccusage (for line 3)
+# Get cached ccusage data - SAFE VERSION without background processes
daily_tokens=""
daily_cost=""
-if command -v bunx >/dev/null 2>&1; then
- # Run ccusage daily, strip ANSI codes, extract Total line data
- ccusage_output=$(bunx ccusage 2>/dev/null | sed 's/\x1b\[[0-9;]*m//g' | grep "│ Total" | head -1)
- if [ -n "$ccusage_output" ]; then
- # Extract tokens and cost
- daily_input=$(echo "$ccusage_output" | awk -F'│' '{print $4}' | tr -d ' ,')
- daily_output=$(echo "$ccusage_output" | awk -F'│' '{print $5}' | tr -d ' ,')
- daily_cost=$(echo "$ccusage_output" | awk -F'│' '{print $9}' | tr -d ' ')
-
- # Calculate total tokens if both are valid numbers
- if [[ "$daily_input" =~ ^[0-9]+$ ]] && [[ "$daily_output" =~ ^[0-9]+$ ]]; then
- daily_total=$((daily_input + daily_output))
- # Format tokens with commas
- daily_tokens=$(printf "%'d" "$daily_total" 2>/dev/null || echo "$daily_total")
- fi
+
+# Check if cache exists and load it
+if [ -f "$CACHE_FILE" ]; then
+ # Always load cache data first (if it exists)
+ source "$CACHE_FILE"
+fi
+
+# If cache is stale, missing, or we have no data, update it SYNCHRONOUSLY with timeout
+cache_needs_update=false
+if [ ! -f "$CACHE_FILE" ] || [ -z "$daily_tokens" ]; then
+ cache_needs_update=true
+elif [ -f "$CACHE_FILE" ]; then
+ cache_age=$(($(date +%s) - $(stat -f%m "$CACHE_FILE" 2>/dev/null || echo 0)))
+ if [ $cache_age -ge $CACHE_AGE ]; then
+ cache_needs_update=true
fi
fi
-# Tokyo Night Storm Color Scheme
-# Background: #24283b (dark blue-gray)
-# Foreground: #c0caf5 (light blue-white)
-# Blue: #7aa2f7
-# Purple: #bb9af7
-# Green: #9ece6a
-# Orange: #ff9e64
-# Red: #f7768e
-# Yellow: #e0af68
-# Cyan: #7dcfff
-
-# Tokyo Night Storm - Line-Based Color Scheme
-# Design Philosophy: Each line has a distinct dominant color for visual separation
-
-# Base colors
-BACKGROUND='\033[48;2;36;40;59m' # #24283b - Dark blue-gray background
-BRIGHT_PURPLE='\033[38;2;187;154;247m' # #bb9af7 - Line 1 primary color
-BRIGHT_BLUE='\033[38;2;122;162;247m' # #7aa2f7 - Line 2 primary color
-DARK_BLUE='\033[38;2;100;140;200m' # Darker blue variant for Line 2
-BRIGHT_GREEN='\033[38;2;158;206;106m' # #9ece6a - Line 3 primary color
-DARK_GREEN='\033[38;2;130;170;90m' # Darker green variant for Line 3
-BRIGHT_ORANGE='\033[38;2;255;158;100m' # #ff9e64 - Line 4 cost color
-BRIGHT_RED='\033[38;2;247;118;142m' # #f7768e - Bright red for errors
-
-# Line-specific color assignments
-# LINE 1 - MOSTLY PURPLE (#bb9af7)
-LINE1_PRIMARY="$BRIGHT_PURPLE" # Primary purple for most line 1 content
-LINE1_ACCENT='\033[38;2;160;130;210m' # Slightly different purple shade for variety
-MODEL_PURPLE='\033[38;2;138;99;210m' # Different purple for model name - deeper violet
-KAI_PURPLE='\033[38;2;147;112;219m' # Different purple for "Kai" - medium violet
-
-# LINE 2 - MOSTLY DARK BLUE
-LINE2_PRIMARY="$DARK_BLUE" # Primary dark blue for most line 2 content
-LINE2_ACCENT='\033[38;2;110;150;210m' # Slightly different blue shade for variety
-
-# LINE 3 - MOSTLY DARK GREEN
-LINE3_PRIMARY="$DARK_GREEN" # Primary dark green for most line 3 content
-LINE3_ACCENT='\033[38;2;140;180;100m' # Slightly different green shade for variety
-
-# LINE 3 - All green scheme
-COST_COLOR="$LINE3_ACCENT" # Cost in green
-TOKENS_COLOR='\033[38;2;169;177;214m' # Tokens in light gray
-
-# Separators and punctuation - subtle for all lines
-SEPARATOR_COLOR='\033[38;2;140;152;180m' # #8c98b4 - Subtle gray for separators
-
-# Individual MCP names - use line 2 blue scheme with accent colors for important ones
-MCP_DAEMON="$BRIGHT_BLUE" # Daemon - bright blue accent
-MCP_STRIPE="$LINE2_ACCENT" # Stripe - blue accent (keeping in line 2 theme)
-MCP_DEFAULT="$LINE2_PRIMARY" # All other MCPs - standard line 2 blue
-
-RESET='\033[0m' # Reset all formatting
-
-# Get MCP names for line 2 with blue color scheme
-mcp_names_formatted=""
-if [ -f "$claude_dir/settings.json" ]; then
- mcp_names_raw=$(jq -r '.mcpServers | keys[]' "$claude_dir/settings.json" 2>/dev/null | tr '\n' ' ')
- # Format MCP names - line 2 blue scheme with accent colors for important ones
- for mcp in $mcp_names_raw; do
- case "$mcp" in
- "daemon") formatted="${MCP_DAEMON}Daemon${RESET}" ;; # Bright blue accent: Personal API
- "stripe") formatted="${MCP_STRIPE}Stripe${RESET}" ;; # Blue accent: Financial ops
- # All other MCPs use line 2 blue
- "httpx") formatted="${MCP_DEFAULT}HTTPx${RESET}" ;;
- "brightdata") formatted="${MCP_DEFAULT}BrightData${RESET}" ;;
- "naabu") formatted="${MCP_DEFAULT}Naabu${RESET}" ;;
- "apify") formatted="${MCP_DEFAULT}Apify${RESET}" ;;
- "content") formatted="${MCP_DEFAULT}Content${RESET}" ;;
- "Ref") formatted="${MCP_DEFAULT}Ref${RESET}" ;;
- "pai") formatted="${MCP_DEFAULT}Foundry${RESET}" ;;
- "playwright") formatted="${MCP_DEFAULT}Playwright${RESET}" ;;
- *) formatted="${MCP_DEFAULT}${mcp^}${RESET}" ;; # Capitalize first letter, line 2 blue
- esac
-
- if [ -z "$mcp_names_formatted" ]; then
- mcp_names_formatted="$formatted"
- else
- mcp_names_formatted="$mcp_names_formatted${SEPARATOR_COLOR}, ${formatted}"
+if [ "$cache_needs_update" = true ]; then
+ # Try to acquire lock (non-blocking)
+ if mkdir "$LOCK_FILE" 2>/dev/null; then
+ # We got the lock - update cache with timeout
+ if command -v bunx >/dev/null 2>&1; then
+ # Run ccusage with a timeout (5 seconds for faster updates)
+ # Check if gtimeout is available (macOS), otherwise try timeout (Linux)
+ if command -v gtimeout >/dev/null 2>&1; then
+ ccusage_output=$(gtimeout 5 bunx ccusage 2>/dev/null | sed 's/\x1b\[[0-9;]*m//g' | grep "│ Total" | head -1)
+ elif command -v timeout >/dev/null 2>&1; then
+ ccusage_output=$(timeout 5 bunx ccusage 2>/dev/null | sed 's/\x1b\[[0-9;]*m//g' | grep "│ Total" | head -1)
+ else
+ # Fallback without timeout (but faster than before)
+ ccusage_output=$(bunx ccusage 2>/dev/null | sed 's/\x1b\[[0-9;]*m//g' | grep "│ Total" | head -1)
+ fi
+
+ if [ -n "$ccusage_output" ]; then
+ # Extract input/output tokens, removing commas and ellipsis
+ daily_input=$(echo "$ccusage_output" | awk -F'│' '{print $4}' | sed 's/[^0-9]//g' | head -c 10)
+ daily_output=$(echo "$ccusage_output" | awk -F'│' '{print $5}' | sed 's/[^0-9]//g' | head -c 10)
+ # Extract cost, keep the dollar sign
+ daily_cost=$(echo "$ccusage_output" | awk -F'│' '{print $9}' | sed 's/^ *//;s/ *$//')
+
+ if [ -n "$daily_input" ] && [ -n "$daily_output" ]; then
+ daily_total=$((daily_input + daily_output))
+ daily_tokens=$(printf "%'d" "$daily_total" 2>/dev/null || echo "$daily_total")
+
+ # Write to cache file (properly escape dollar sign)
+ echo "daily_tokens=\"$daily_tokens\"" > "$CACHE_FILE"
+ # Use printf to properly escape the dollar sign in the cost
+ printf "daily_cost=\"%s\"\n" "${daily_cost//$/\\$}" >> "$CACHE_FILE"
+ # Add timestamp for debugging
+ echo "cache_updated=\"$(date)\"" >> "$CACHE_FILE"
+ fi
+ fi
fi
- done
+
+ # Always remove lock when done
+ rmdir "$LOCK_FILE" 2>/dev/null
+ else
+ # Someone else is updating - check if lock is stale (older than 30 seconds)
+ if [ -d "$LOCK_FILE" ]; then
+ lock_age=$(($(date +%s) - $(stat -f%m "$LOCK_FILE" 2>/dev/null || echo 0)))
+ if [ $lock_age -gt 30 ]; then
+ # Stale lock - remove it and try again
+ rmdir "$LOCK_FILE" 2>/dev/null
+ fi
+ fi
+
+ # Just use cached data if available
+ if [ -f "$CACHE_FILE" ]; then
+ source "$CACHE_FILE"
+ fi
+ fi
fi
-# Output the line-based color themed statusline
-# Light blue color for directory
-DIR_COLOR='\033[38;2;135;206;250m' # Light sky blue for directory
+# Tokyo Night Storm Color Scheme
+BACKGROUND='\033[48;2;36;40;59m'
+BRIGHT_PURPLE='\033[38;2;187;154;247m'
+BRIGHT_BLUE='\033[38;2;122;162;247m'
+DARK_BLUE='\033[38;2;100;140;200m'
+BRIGHT_GREEN='\033[38;2;158;206;106m'
+DARK_GREEN='\033[38;2;130;170;90m'
+BRIGHT_ORANGE='\033[38;2;255;158;100m'
+BRIGHT_RED='\033[38;2;247;118;142m'
+
+# Line-specific colors
+LINE1_PRIMARY="$BRIGHT_PURPLE"
+LINE1_ACCENT='\033[38;2;160;130;210m'
+MODEL_PURPLE='\033[38;2;138;99;210m'
+KAI_PURPLE='\033[38;2;147;112;219m'
+
+LINE2_PRIMARY="$DARK_BLUE"
+LINE2_ACCENT='\033[38;2;110;150;210m'
+
+LINE3_PRIMARY="$DARK_GREEN"
+LINE3_ACCENT='\033[38;2;140;180;100m'
+COST_COLOR="$LINE3_ACCENT"
+TOKENS_COLOR='\033[38;2;169;177;214m'
+
+SEPARATOR_COLOR='\033[38;2;140;152;180m'
+DIR_COLOR='\033[38;2;135;206;250m'
+
+# MCP colors
+MCP_DAEMON="$BRIGHT_BLUE"
+MCP_STRIPE="$LINE2_ACCENT"
+MCP_DEFAULT="$LINE2_PRIMARY"
+
+RESET='\033[0m'
+
+# Format MCP names efficiently
+mcp_names_formatted=""
+for mcp in $mcp_names_raw; do
+ case "$mcp" in
+ "daemon") formatted="${MCP_DAEMON}Daemon${RESET}" ;;
+ "stripe") formatted="${MCP_STRIPE}Stripe${RESET}" ;;
+ "httpx") formatted="${MCP_DEFAULT}HTTPx${RESET}" ;;
+ "brightdata") formatted="${MCP_DEFAULT}BrightData${RESET}" ;;
+ "naabu") formatted="${MCP_DEFAULT}Naabu${RESET}" ;;
+ "apify") formatted="${MCP_DEFAULT}Apify${RESET}" ;;
+ "content") formatted="${MCP_DEFAULT}Content${RESET}" ;;
+ "Ref") formatted="${MCP_DEFAULT}Ref${RESET}" ;;
+ "pai") formatted="${MCP_DEFAULT}Foundry${RESET}" ;;
+ "playwright") formatted="${MCP_DEFAULT}Playwright${RESET}" ;;
+ *) formatted="${MCP_DEFAULT}${mcp^}${RESET}" ;;
+ esac
+
+ if [ -z "$mcp_names_formatted" ]; then
+ mcp_names_formatted="$formatted"
+ else
+ mcp_names_formatted="$mcp_names_formatted${SEPARATOR_COLOR}, ${formatted}"
+ fi
+done
-# LINE 1 - MOSTLY PURPLE: Complete first line with all counts (services, commands, MCPs, patterns)
-printf "${KAI_PURPLE}Kai${RESET}${LINE1_PRIMARY} here, running on ${MODEL_PURPLE}🧠 ${model_name}${RESET}${LINE1_PRIMARY} in ${DIR_COLOR}📁 ${dir_name}${RESET}${LINE1_PRIMARY}, wielding: ${RESET}${LINE1_PRIMARY}🔧 ${fobs_count} Services${RESET}${LINE1_PRIMARY}, ${RESET}${LINE1_PRIMARY}⚙️ ${commands_count} Commands${RESET}${LINE1_PRIMARY}, ${RESET}${LINE1_PRIMARY}🔌 ${mcps_count} MCPs${RESET}${LINE1_PRIMARY}, and ${RESET}${LINE1_PRIMARY}📚 ${fabric_count} Patterns${RESET}\n"
+# Output the full 3-line statusline
+# LINE 1 - PURPLE theme with all counts
+printf "${KAI_PURPLE}${DA_NAME}${RESET}${LINE1_PRIMARY} here, running on ${MODEL_PURPLE}🧠 ${model_name}${RESET}${LINE1_PRIMARY} in ${DIR_COLOR}📁 ${dir_name}${RESET}${LINE1_PRIMARY}, wielding: ${RESET}${LINE1_PRIMARY}🔧 ${fobs_count} Services${RESET}${LINE1_PRIMARY}, ${RESET}${LINE1_PRIMARY}⚙️ ${commands_count} Commands${RESET}${LINE1_PRIMARY}, ${RESET}${LINE1_PRIMARY}🔌 ${mcps_count} MCPs${RESET}${LINE1_PRIMARY}, and ${RESET}${LINE1_PRIMARY}📚 ${fabric_count} Patterns${RESET}\n"
-# LINE 2 - MOSTLY DARK BLUE: MCP names list
+# LINE 2 - BLUE theme with MCP names
printf "${LINE2_PRIMARY}🔌 MCPs${RESET}${LINE2_PRIMARY}${SEPARATOR_COLOR}: ${RESET}${mcp_names_formatted}${RESET}\n"
-# LINE 3 - MOSTLY DARK GREEN: Daily tokens and cost
-printf "${LINE3_PRIMARY}💎 Total Tokens${RESET}${LINE3_PRIMARY}${SEPARATOR_COLOR}: ${RESET}${LINE3_ACCENT}${daily_tokens:-N/A}${RESET}${LINE3_PRIMARY} Total Cost${RESET}${LINE3_PRIMARY}${SEPARATOR_COLOR}: ${RESET}${COST_COLOR}${daily_cost:-N/A}${RESET}\n"
\ No newline at end of file
+# LINE 3 - GREEN theme with tokens and cost (show cached or N/A)
+# If we have cached data but it's empty, still show N/A
+tokens_display="${daily_tokens:-N/A}"
+cost_display="${daily_cost:-N/A}"
+if [ -z "$daily_tokens" ]; then tokens_display="N/A"; fi
+if [ -z "$daily_cost" ]; then cost_display="N/A"; fi
+
+printf "${LINE3_PRIMARY}💎 Total Tokens${RESET}${LINE3_PRIMARY}${SEPARATOR_COLOR}: ${RESET}${LINE3_ACCENT}${tokens_display}${RESET}${LINE3_PRIMARY} Total Cost${RESET}${LINE3_PRIMARY}${SEPARATOR_COLOR}: ${RESET}${COST_COLOR}${cost_display}${RESET}\n"
\ No newline at end of file
diff --git a/README.md b/README.md
index 3f34bbb9..da866d44 100644
--- a/README.md
+++ b/README.md
@@ -38,6 +38,16 @@
> **[🎉 v0.2 Released!](https://github.com/danielmiessler/PAI/releases/tag/v0.2)** - Enhanced documentation and Human 3.0 integration
<details open>
+<summary><strong>📅 September 25, 2025 - DA Environment Variable</strong></summary>
+
+- 🤖 **DA Variable**: Added configurable Digital Assistant name via `DA` environment variable
+- 🎨 **Statusline**: Updated statusline to dynamically display assistant name from `$DA` variable
+- 🔊 **Session Hook**: Modified session-start-hook to use `$DA` for voice announcements
+- ⚙️ **Configuration**: Add `export DA="YourAssistantName"` to `.zshrc` to customize
+
+</details>
+
+<details>
<summary><strong>📅 September 22, 2025 - v0.2 Release</strong></summary>
- 🔗 **Human 3.0**: Added link to projects fit together blog post