Skip to content

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

Updated prereqs

Daniel Miessler0910abefad05
diff --git a/.claude/hooks/context-compression-hook.ts b/.claude/hooks/context-compression-hook.ts
new file mode 100755
index 00000000..4f331b9d
--- /dev/null
+++ b/.claude/hooks/context-compression-hook.ts
@@ -0,0 +1,147 @@
+#!/usr/bin/env bun
+/**
+ * PreCompact Hook - Triggered before context compression
+ * Extracts context information from transcript and notifies about compression
+ */
+
+import { readFileSync } from 'fs';
+
+interface NotificationPayload {
+ title: string;
+ message: string;
+ voice_enabled: boolean;
+ priority?: 'low' | 'normal' | 'high';
+}
+
+interface HookInput {
+ session_id: string;
+ transcript_path: string;
+ hook_event_name: string;
+ compact_type?: string;
+}
+
+interface TranscriptEntry {
+ type: string;
+ message?: {
+ role?: string;
+ content?: Array<{
+ type: string;
+ text: string;
+ }>
+ };
+ timestamp?: string;
+}
+
+/**
+ * Send notification to the Kai notification server
+ */
+async function sendNotification(payload: NotificationPayload): Promise<void> {
+ try {
+ await fetch('http://localhost:8888/notify', {
+ method: 'POST',
+ headers: { 'Content-Type': 'application/json' },
+ body: JSON.stringify(payload),
+ });
+ } catch (error) {
+ // Silently handle notification failures
+ }
+}
+
+/**
+ * Count messages in transcript to provide context
+ */
+function getTranscriptStats(transcriptPath: string): { messageCount: number; isLarge: boolean } {
+ try {
+ const content = readFileSync(transcriptPath, 'utf-8');
+ const lines = content.trim().split('\n');
+
+ let userMessages = 0;
+ let assistantMessages = 0;
+
+ for (const line of lines) {
+ if (line.trim()) {
+ try {
+ const entry = JSON.parse(line) as TranscriptEntry;
+ if (entry.type === 'user') {
+ userMessages++;
+ } else if (entry.type === 'assistant') {
+ assistantMessages++;
+ }
+ } catch {
+ // Skip invalid JSON lines
+ }
+ }
+ }
+
+ const totalMessages = userMessages + assistantMessages;
+ const isLarge = totalMessages > 50; // Consider large if more than 50 messages
+
+ return { messageCount: totalMessages, isLarge };
+ } catch (error) {
+ return { messageCount: 0, isLarge: false };
+ }
+}
+
+async function main() {
+ let hookInput: HookInput | null = null;
+
+ try {
+ // Read the JSON input from stdin
+ const decoder = new TextDecoder();
+ const reader = Bun.stdin.stream().getReader();
+ let input = '';
+
+ const timeoutPromise = new Promise<void>((resolve) => {
+ setTimeout(() => resolve(), 500);
+ });
+
+ const readPromise = (async () => {
+ while (true) {
+ const { done, value } = await reader.read();
+ if (done) break;
+ input += decoder.decode(value, { stream: true });
+ }
+ })();
+
+ await Promise.race([readPromise, timeoutPromise]);
+
+ if (input.trim()) {
+ hookInput = JSON.parse(input) as HookInput;
+ }
+ } catch (error) {
+ // Silently handle input errors
+ }
+
+ // Determine the type of compression
+ const compactType = hookInput?.compact_type || 'auto';
+ let message = 'Compressing context to continue';
+
+ // Get transcript statistics if available
+ if (hookInput && hookInput.transcript_path) {
+ const stats = getTranscriptStats(hookInput.transcript_path);
+ if (stats.messageCount > 0) {
+ if (compactType === 'manual') {
+ message = `Manually compressing ${stats.messageCount} messages`;
+ } else {
+ message = stats.isLarge
+ ? `Auto-compressing large context with ${stats.messageCount} messages`
+ : `Compressing context with ${stats.messageCount} messages`;
+ }
+ }
+ }
+
+ // Send notification with voice
+ await sendNotification({
+ title: 'Kai Context',
+ message: message,
+ voice_enabled: true,
+ priority: 'low',
+ });
+
+ process.exit(0);
+}
+
+// Run the hook
+main().catch(() => {
+ process.exit(0);
+});
\ No newline at end of file
diff --git a/.claude/hooks/load-dynamic-requirements.ts b/.claude/hooks/load-dynamic-requirements.ts
old mode 100644
new mode 100755
diff --git a/.claude/hooks/session-start-hook.ts b/.claude/hooks/session-start-hook.ts
new file mode 100755
index 00000000..121df4a5
--- /dev/null
+++ b/.claude/hooks/session-start-hook.ts
@@ -0,0 +1,38 @@
+#!/usr/bin/env bun
+
+async function sendNotification(title: string, message: string, priority: string = 'normal') {
+ try {
+ const response = await fetch('http://localhost:8888/notify', {
+ method: 'POST',
+ headers: {
+ 'Content-Type': 'application/json',
+ },
+ body: JSON.stringify({
+ title,
+ message,
+ voice_enabled: true,
+ priority,
+ voice_id: 'jqcCZkN6Knx8BJ5TBdYR' // Kai's voice ID
+ }),
+ });
+
+ if (!response.ok) {
+ console.error(`Notification failed: ${response.status}`);
+ }
+ } catch (error) {
+ console.error('Failed to send notification:', error);
+ }
+}
+
+async function main() {
+ try {
+ const message = `Kai here, ready to go.`;
+ await sendNotification('Kai Systems Initialized', message, 'low');
+ process.exit(0);
+ } catch (error) {
+ console.error('SessionStart hook error:', error);
+ process.exit(1);
+ }
+}
+
+main();
\ No newline at end of file
diff --git a/.claude/hooks/stop-hook.ts b/.claude/hooks/stop-hook.ts
new file mode 100755
index 00000000..80b92439
--- /dev/null
+++ b/.claude/hooks/stop-hook.ts
@@ -0,0 +1,205 @@
+#!/usr/bin/env bun
+
+import { readFileSync } from 'fs';
+
+// Simple voice mappings
+const VOICES = {
+ researcher: 'AXdMgz6evoL7OPd7eU12',
+ pentester: 'hmMWXCj9K7N5mCPcRkfC',
+ engineer: 'kmSVBPu7loj4ayNinwWM',
+ designer: 'ZF6FPAbjXT4488VcRRnw',
+ writer: 'gfRt6Z3Z8aTbpLfexQ7N',
+ kai: 'jqcCZkN6Knx8BJ5TBdYR'
+};
+
+function summarizeTask(description: string, content: string): string {
+ // Look at the task description and content to create a 6-word summary
+ const words = [];
+
+ // Extract key terms from description
+ if (description) {
+ const descWords = description.toLowerCase()
+ .replace(/[^\w\s]/g, ' ')
+ .split(/\s+/)
+ .filter(w => w.length > 2 && !['the', 'and', 'for', 'with', 'task', 'test'].includes(w));
+ words.push(...descWords.slice(0, 3));
+ }
+
+ // Extract key terms from content
+ if (content) {
+ const contentWords = content.toLowerCase()
+ .replace(/[^\w\s]/g, ' ')
+ .split(/\s+/)
+ .filter(w => w.length > 3 && !['completed', 'task', 'test', 'analysis', 'system'].includes(w));
+ words.push(...contentWords.slice(0, 3));
+ }
+
+ // Take first 6 unique words
+ const uniqueWords = [...new Set(words)].slice(0, 6);
+ return uniqueWords.join(' ');
+}
+
+async function main() {
+ // Get input
+ let input = '';
+ const decoder = new TextDecoder();
+ const reader = Bun.stdin.stream().getReader();
+
+ try {
+ while (true) {
+ const { done, value } = await reader.read();
+ if (done) break;
+ input += decoder.decode(value, { stream: true });
+ }
+ } catch (e) {
+ process.exit(0);
+ }
+
+ if (!input) process.exit(0);
+
+ let transcriptPath;
+ try {
+ const parsed = JSON.parse(input);
+ transcriptPath = parsed.transcript_path;
+ } catch (e) {
+ process.exit(0);
+ }
+
+ if (!transcriptPath) process.exit(0);
+
+ // Read the transcript
+ let transcript;
+ try {
+ transcript = readFileSync(transcriptPath, 'utf-8');
+ } catch (e) {
+ process.exit(0);
+ }
+
+ // Parse the JSON lines to find the last Task tool usage
+ const lines = transcript.trim().split('\n');
+ let taskDescription = '';
+ let taskResult = '';
+ let agentType = '';
+
+ // Look for Task tool usage and result
+ for (let i = lines.length - 1; i >= 0; i--) {
+ try {
+ const entry = JSON.parse(lines[i]);
+
+ // Look for Task tool_use
+ if (entry.type === 'assistant' && entry.message?.content) {
+ for (const content of entry.message.content) {
+ if (content.type === 'tool_use' && content.name === 'Task') {
+ taskDescription = content.input?.description || '';
+ agentType = content.input?.subagent_type || '';
+
+ // Find the corresponding tool_result
+ for (let j = i + 1; j < lines.length; j++) {
+ const resultEntry = JSON.parse(lines[j]);
+ if (resultEntry.type === 'user' && resultEntry.message?.content) {
+ for (const resultContent of resultEntry.message.content) {
+ if (resultContent.type === 'tool_result' && resultContent.tool_use_id === content.id) {
+ taskResult = resultContent.content;
+ break;
+ }
+ }
+ }
+ if (taskResult) break;
+ }
+ break;
+ }
+ }
+ }
+ if (taskDescription && taskResult) break;
+ } catch (e) {
+ // Skip invalid JSON
+ }
+ }
+
+ // Generate the announcement
+ let message = '';
+ let voiceId = VOICES.kai;
+
+ if (agentType && taskResult) {
+ // AGENT DID THE TASK - Look for [AGENT:type] I completed something
+ const agentMatch = taskResult.match(/\[AGENT:(\w+)\]\s*I\s+completed\s+(.+?)(?:\n|$)/is);
+
+ if (agentMatch) {
+ const agentType = agentMatch[1].toLowerCase();
+ let completedText = agentMatch[2].trim();
+
+ // Clean up but keep the full completion message
+ completedText = completedText.replace(/[^\w\s+]/g, ' ').replace(/\s+/g, ' ').trim();
+
+ const agentName = agentType.charAt(0).toUpperCase() + agentType.slice(1);
+ message = `${agentName} completed ${completedText}`;
+ voiceId = VOICES[agentType] || VOICES.kai;
+
+ console.error(`🎯 AGENT COMPLETION: ${message}`);
+ } else {
+ // Fallback to old method if no proper completion found
+ const summary = summarizeTask(taskDescription, taskResult);
+ const agentName = agentType.charAt(0).toUpperCase() + agentType.slice(1);
+ message = `${agentName} completed ${summary}`;
+ voiceId = VOICES[agentType] || VOICES.kai;
+
+ console.error(`🎯 AGENT COMPLETION (fallback): ${message}`);
+ }
+
+ } else {
+ // I (KAI) DID THE TASK - Look for my COMPLETED line
+ const lastResponse = lines[lines.length - 1];
+ try {
+ const entry = JSON.parse(lastResponse);
+ if (entry.type === 'assistant' && entry.message?.content) {
+ const content = entry.message.content.map(c => c.text || '').join(' ');
+
+ console.error(`🔍 KAI CONTENT: "${content.substring(0, 200)}..."`);
+
+ // Look for the COMPLETED line - multiple patterns
+ const completedPatterns = [
+ /🎯\s*COMPLETED:\s*(.+?)(?:\n|$)/i,
+ /\*\*🎯\s*COMPLETED:\*\*\s*(.+?)(?:\n|$)/i,
+ /COMPLETED:\s*(.+?)(?:\n|$)/i
+ ];
+
+ let completedMatch = null;
+ for (const pattern of completedPatterns) {
+ completedMatch = content.match(pattern);
+ if (completedMatch) break;
+ }
+
+ if (completedMatch) {
+ let completedText = completedMatch[1].trim();
+
+ // The COMPLETED line is already a perfect summary - use it entirely
+ // Just clean up any weird characters but keep the full message
+ completedText = completedText.replace(/[^\w\s+]/g, ' ').replace(/\s+/g, ' ').trim();
+
+ message = completedText;
+
+ console.error(`🎯 KAI COMPLETION: ${message}`);
+ } else {
+ message = 'Kai completed task';
+ }
+ }
+ } catch (e) {
+ message = 'Kai completed task';
+ }
+ }
+
+ if (message) {
+ // Send to voice server
+ await fetch('http://localhost:8888/notify', {
+ method: 'POST',
+ headers: { 'Content-Type': 'application/json' },
+ body: JSON.stringify({
+ message: message,
+ voice_id: voiceId,
+ voice_enabled: true
+ })
+ }).catch(() => {});
+ }
+}
+
+main().catch(() => {});
\ No newline at end of file
diff --git a/.claude/hooks/subagent-stop-hook.ts b/.claude/hooks/subagent-stop-hook.ts
new file mode 100755
index 00000000..4d2f55ad
--- /dev/null
+++ b/.claude/hooks/subagent-stop-hook.ts
@@ -0,0 +1,235 @@
+#!/usr/bin/env bun
+
+import { readFileSync, existsSync } from 'fs';
+
+// Voice mappings for different agent types
+const AGENT_VOICE_IDS: Record<string, string> = {
+ researcher: 'AXdMgz6evoL7OPd7eU12',
+ pentester: 'hmMWXCj9K7N5mCPcRkfC',
+ engineer: 'kmSVBPu7loj4ayNinwWM',
+ designer: 'ZF6FPAbjXT4488VcRRnw',
+ writer: 'gfRt6Z3Z8aTbpLfexQ7N',
+ default: 'AXdMgz6evoL7OPd7eU12'
+};
+
+async function delay(ms: number): Promise<void> {
+ return new Promise(resolve => setTimeout(resolve, ms));
+}
+
+async function findTaskResult(transcriptPath: string, maxAttempts: number = 10): Promise<{ result: string | null, agentType: string | null }> {
+ for (let attempt = 0; attempt < maxAttempts; attempt++) {
+ if (attempt > 0) {
+ // Wait progressively longer between attempts
+ await delay(100 * attempt);
+ }
+
+ if (!existsSync(transcriptPath)) {
+ continue;
+ }
+
+ try {
+ const transcript = readFileSync(transcriptPath, 'utf-8');
+ const lines = transcript.trim().split('\n');
+
+ // Search from the end of the transcript backwards
+ for (let i = lines.length - 1; i >= 0; i--) {
+ try {
+ const entry = JSON.parse(lines[i]);
+
+ // Look for assistant messages that contain Task tool_use
+ if (entry.type === 'assistant' && entry.message?.content) {
+ for (const content of entry.message.content) {
+ if (content.type === 'tool_use' && content.name === 'Task') {
+ // Found a Task invocation, now look for its result
+ // The result should be in a subsequent user message
+ for (let j = i + 1; j < lines.length; j++) {
+ const resultEntry = JSON.parse(lines[j]);
+ if (resultEntry.type === 'user' && resultEntry.message?.content) {
+ for (const resultContent of resultEntry.message.content) {
+ if (resultContent.type === 'tool_result' && resultContent.tool_use_id === content.id) {
+ // Found the matching Task result
+ const taskOutput = resultContent.content;
+
+ // Extract agent type from the output
+ let agentType = 'default';
+ const agentMatch = taskOutput.match(/Sub-agent\s+(\w+)\s+completed/i);
+ if (agentMatch) {
+ agentType = agentMatch[1].toLowerCase();
+ }
+
+ return { result: taskOutput, agentType };
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ } catch (e) {
+ // Invalid JSON line, skip
+ }
+ }
+ } catch (e) {
+ // Error reading file, will retry
+ }
+ }
+
+ return { result: null, agentType: null };
+}
+
+function extractCompletionMessage(taskOutput: string): { message: string | null, agentType: string | null } {
+ console.error('🔍 DEBUG - Extracting from task output, length:', taskOutput.length);
+ console.error('🔍 DEBUG - First 200 chars:', taskOutput.substring(0, 200));
+ console.error('🔍 DEBUG - Last 200 chars:', taskOutput.substring(taskOutput.length - 200));
+
+ // Look for the COMPLETED section in the agent's output
+ // Priority is given to [AGENT:type] format
+ const agentPatterns = [
+ /🎯\s*COMPLETED:\s*\[AGENT:(\w+)\]\s*I\s+completed\s+(.+?)(?:\n|$)/is,
+ /COMPLETED:\s*\[AGENT:(\w+)\]\s*I\s+completed\s+(.+?)(?:\n|$)/is,
+ /\[AGENT:(\w+)\]\s*I\s+completed\s+(.+?)(?:\.|!|\n|$)/is,
+ // New pattern for our current format
+ /🎯.*COMPLETED.*\[AGENT:(\w+)\]\s*I\s+completed\s+(.+?)(?:\n|$)/is
+ ];
+
+ // First try to match agent-specific patterns
+ for (const pattern of agentPatterns) {
+ const match = taskOutput.match(pattern);
+ if (match && match[1] && match[2]) {
+ const agentType = match[1].toLowerCase();
+ let message = match[2].trim();
+
+ // Clean up the message
+ message = message.replace(/\*+/g, '');
+ message = message.replace(/\s+/g, ' ');
+
+ // Prepend agent name for spoken message
+ const agentName = agentType.charAt(0).toUpperCase() + agentType.slice(1);
+ const fullMessage = `${agentName} completed ${message}`;
+
+ console.error(`✅ FOUND AGENT MATCH: [${agentType}] ${fullMessage}`);
+
+ // Return agent type and message
+ return { message: fullMessage, agentType };
+ }
+ }
+
+ // Fall back to generic patterns
+ const genericPatterns = [
+ /🎯\s*COMPLETED:\s*(.+?)(?:\n|$)/i,
+ /COMPLETED:\s*(.+?)(?:\n|$)/i,
+ /Sub-agent\s+\w+\s+completed\s+(.+?)(?:\.|!|\n|$)/i,
+ /Agent\s+completed\s+(.+?)(?:\.|!|\n|$)/i
+ ];
+
+ for (const pattern of genericPatterns) {
+ const match = taskOutput.match(pattern);
+ if (match && match[1]) {
+ let message = match[1].trim();
+
+ // Clean up the message
+ message = message.replace(/^(the\s+)?requested\s+task$/i, '');
+ message = message.replace(/\*+/g, '');
+ message = message.replace(/\s+/g, ' ');
+
+ // Only return if it's not a generic message
+ if (message &&
+ !message.match(/^(the\s+)?requested\s+task$/i) &&
+ !message.match(/^task$/i) &&
+ message.length > 5) {
+ return { message, agentType: null };
+ }
+ }
+ }
+
+ return { message: null, agentType: null };
+}
+
+async function main() {
+ console.error('🔍 SubagentStop hook started');
+ // Read input from stdin with timeout
+ let input = '';
+ try {
+ const decoder = new TextDecoder();
+ const reader = Bun.stdin.stream().getReader();
+
+ const timeoutPromise = new Promise<void>((resolve) => {
+ setTimeout(() => resolve(), 500);
+ });
+
+ const readPromise = (async () => {
+ while (true) {
+ const { done, value } = await reader.read();
+ if (done) break;
+ input += decoder.decode(value, { stream: true });
+ }
+ })();
+
+ await Promise.race([readPromise, timeoutPromise]);
+ } catch (e) {
+ console.error('Failed to read input:', e);
+ process.exit(0);
+ }
+
+ if (!input) {
+ console.log('No input received');
+ process.exit(0);
+ }
+
+ let transcriptPath: string;
+ try {
+ const parsed = JSON.parse(input);
+ transcriptPath = parsed.transcript_path;
+ } catch (e) {
+ console.error('Invalid input JSON:', e);
+ process.exit(0);
+ }
+
+ if (!transcriptPath) {
+ console.log('No transcript path provided');
+ process.exit(0);
+ }
+
+ // Wait for and find the Task result
+ const { result: taskOutput, agentType } = await findTaskResult(transcriptPath);
+
+ if (!taskOutput) {
+ console.log('No Task result found in transcript after waiting');
+ process.exit(0);
+ }
+
+ // Extract the completion message and agent type
+ const { message: completionMessage, agentType: extractedAgentType } = extractCompletionMessage(taskOutput);
+
+ if (!completionMessage) {
+ console.log('No specific completion message found in Task output');
+ process.exit(0);
+ }
+
+ // Use extracted agent type if available, otherwise use the one from task analysis
+ const finalAgentType = extractedAgentType || agentType || 'default';
+
+ // Prepare the notification
+ const fullMessage = completionMessage; // Message is already prepared with agent name
+
+ // Send to notification server
+ try {
+ await fetch('http://localhost:8888/notify', {
+ method: 'POST',
+ headers: { 'Content-Type': 'application/json' },
+ body: JSON.stringify({
+ title: `${agentName} Agent`,
+ message: fullMessage,
+ voice_enabled: true,
+ agent_type: finalAgentType,
+ voice_id: AGENT_VOICE_IDS[finalAgentType] || AGENT_VOICE_IDS.default
+ })
+ });
+
+ console.log(`✅ Sent: [${agentName}] ${fullMessage}`);
+ } catch (e) {
+ console.error('Failed to send notification:', e);
+ }
+}
+
+main().catch(console.error);
\ No newline at end of file
diff --git a/.claude/statusline-command.sh b/.claude/statusline-command.sh
new file mode 100755
index 00000000..99205cb7
--- /dev/null
+++ b/.claude/statusline-command.sh
@@ -0,0 +1,158 @@
+#!/bin/bash
+
+# Read JSON input from stdin
+input=$(cat)
+
+# Extract data from JSON input
+current_dir=$(echo "$input" | jq -r '.workspace.current_dir')
+model_name=$(echo "$input" | jq -r '.model.display_name')
+
+# Get directory name
+dir_name=$(basename "$current_dir")
+
+# Count items from specified directories
+# - Services count from ~/Projects/FoundryServices/Services
+# - Commands from ~/.claude/commands/
+# - MCPs from settings.json
+# - Patterns from ~/.config/fabric/patterns
+claude_dir="/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)
+if [ -d "$claude_dir/commands" ]; then
+ commands_count=$(find "$claude_dir/commands" -maxdepth 1 -name "*.md" 2>/dev/null | wc -l | tr -d ' ')
+fi
+
+# Count MCPs from settings.json
+if [ -f "$claude_dir/settings.json" ]; then
+ mcps_count=$(jq -r '.mcpServers | keys | length' "$claude_dir/settings.json" 2>/dev/null || echo "0")
+fi
+
+# Count Services from FoundryServices directory
+services_dir="/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 ' ')
+fi
+
+# Count Fabric patterns from ~/.config/fabric/patterns
+fabric_patterns_dir="/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 ' ')
+fi
+
+# Get daily usage data from ccusage (for line 3)
+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
+ 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
+
+# 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}"
+ fi
+ done
+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
+
+# LINE 1 - MOSTLY PURPLE: Complete first line with all counts (services, commands, MCPs, patterns)
+printf "${LINE1_PRIMARY}Kai here${RESET}${LINE1_PRIMARY}, running on ${LINE1_ACCENT}🧠 ${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
+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
diff --git a/.claude/voice-server/README.md b/.claude/voice-server/README.md
new file mode 100644
index 00000000..3cba4735
--- /dev/null
+++ b/.claude/voice-server/README.md
@@ -0,0 +1,195 @@
+# PAIVoice - Personal AI Voice Framework
+
+PAIVoice is a flexible voice notification framework for Personal AI (PAI) systems on macOS. It provides natural-sounding voice notifications using ElevenLabs AI voices or fallback to macOS's built-in text-to-speech.
+
+## 🎯 Purpose
+
+This framework enables ANY Personal AI system to:
+- Send voice notifications to users
+- Provide audio feedback for completed tasks
+- Create more engaging AI interactions
+- Work with any AI assistant (not limited to a specific name or personality)
+
+## 🚀 Features
+
+- **AI Voice Support**: Natural voices via ElevenLabs API
+- **Fallback Mode**: Works without API key using macOS 'say' command
+- **Menu Bar Icon**: Visual status indicator with quick controls
+- **Service Management**: Runs as a background service
+- **Simple API**: Easy HTTP endpoints for notifications
+- **Customizable**: Choose your own voice and personality
+
+## 📦 Quick Setup
+
+### 1. Install Prerequisites
+```bash
+# Install Bun (JavaScript runtime)
+curl -fsSL https://bun.sh/install | bash
+```
+
+### 2. Configure API Keys (Optional)
+```bash
+# Add to ~/.env for AI voices
+echo "ELEVENLABS_API_KEY=your_key_here" >> ~/.env
+echo "ELEVENLABS_VOICE_ID=voice_id_here" >> ~/.env
+```
+
+Get a free API key from [ElevenLabs](https://elevenlabs.io) (10,000 chars/month free)
+
+### 3. Install as Service
+```bash
+cd ~/.claude/voice-server/macos-service
+./install.sh
+```
+
+### 4. Add Menu Bar Icon (Optional)
+```bash
+cd ~/.claude/voice-server/macos-service/menubar
+./install-menubar.sh
+```
+
+## 🎙️ Usage
+
+### Send a Notification
+```bash
+curl -X POST http://localhost:8888/notify \
+ -H "Content-Type: application/json" \
+ -d '{
+ "title": "Your PAI Name",
+ "message": "Task completed successfully",
+ "voice_enabled": true
+ }'
+```
+
+### PAI Assistant Notification
+```bash
+curl -X POST http://localhost:8888/pai \
+ -H "Content-Type: application/json" \
+ -d '{
+ "title": "Assistant",
+ "message": "I've finished analyzing your data"
+ }'
+```
+
+## 🔧 Customization
+
+### Choose Your Voice
+
+Popular ElevenLabs voice IDs:
+- `jqcCZkN6Knx8BJ5TBdYR` - Friendly assistant (default)
+- `21m00Tcm4TlvDq8ikWAM` - Rachel (calm, professional)
+- `AZnzlk1XvdvUeBnXmlld` - Domi (energetic)
+- `EXAVITQu4vr4xnSDxMaL` - Bella (warm, friendly)
+
+Set in `~/.env`:
+```bash
+ELEVENLABS_VOICE_ID=your_chosen_voice_id
+```
+
+### Customize for Your PAI
+
+The framework is designed to work with ANY Personal AI system:
+- Use your PAI's name in the `title` field
+- Customize messages to match your PAI's personality
+- Integrate with your existing AI tools and workflows
+
+## 📡 API Endpoints
+
+- `POST /notify` - General notification with optional voice
+- `POST /pai` - PAI-specific notification (always with voice)
+- `GET /health` - Service health check
+
+### Request Format
+```json
+{
+ "title": "Your PAI Name",
+ "message": "Notification text",
+ "voice_enabled": true,
+ "voice_id": "optional_voice_override"
+}
+```
+
+## 🛠️ Service Management
+
+```bash
+# Control the service
+./macos-service/voice-server-ctl.sh status
+./macos-service/voice-server-ctl.sh start
+./macos-service/voice-server-ctl.sh stop
+./macos-service/voice-server-ctl.sh restart
+
+# View logs
+./macos-service/voice-server-ctl.sh logs
+
+# Test the service
+./macos-service/voice-server-ctl.sh test
+```
+
+## 📊 Menu Bar Icon
+
+The menu bar icon shows:
+- 🎙️ = Server running
+- 🔇 = Server stopped
+
+Click for quick access to controls and status.
+
+## 🔒 Security
+
+- API keys stored locally in `~/.env`
+- Service runs as user (not root)
+- Only accepts local connections
+- No data sent except to ElevenLabs (if configured)
+
+## 📁 Project Structure
+
+```
+voice-server/
+├── server.ts # Main server code
+├── start.sh # Manual start script
+├── macos-service/
+│ ├── com.paivoice.server.plist # Service configuration
+│ ├── install.sh # Service installer
+│ ├── uninstall.sh # Service remover
+│ ├── voice-server-ctl.sh # Service control
+│ ├── validate-setup.sh # Setup validator
+│ └── menubar/ # Menu bar icon
+└── README.md # This file
+```
+
+## 🤝 Integration Examples
+
+### With Python AI Agent
+```python
+import requests
+
+def send_voice_notification(message):
+ requests.post('http://localhost:8888/pai', json={
+ 'title': 'My AI Assistant',
+ 'message': message
+ })
+
+# Use in your AI workflow
+send_voice_notification("Analysis complete. Found 3 insights.")
+```
+
+### With Node.js/Bun
+```javascript
+async function notify(message) {
+ await fetch('http://localhost:8888/pai', {
+ method: 'POST',
+ headers: { 'Content-Type': 'application/json' },
+ body: JSON.stringify({
+ title: 'AI Helper',
+ message: message
+ })
+ });
+}
+```
+
+## 📝 License
+
+Open source - Customize for your needs!
+
+## 🙏 Credits
+
+Built as a framework for Personal AI systems, inspired by the need for better human-AI interaction through voice.
\ No newline at end of file
diff --git a/.claude/voice-server/logs/voice-server-error.log b/.claude/voice-server/logs/voice-server-error.log
new file mode 100644
index 00000000..e69de29b
diff --git a/.claude/voice-server/logs/voice-server.log b/.claude/voice-server/logs/voice-server.log
new file mode 100644
index 00000000..e69de29b
diff --git a/.claude/voice-server/macos-service/README.md b/.claude/voice-server/macos-service/README.md
new file mode 100644
index 00000000..24d46dd1
--- /dev/null
+++ b/.claude/voice-server/macos-service/README.md
@@ -0,0 +1,272 @@
+# PAIVoice Server - Personal AI Voice Framework for macOS
+
+This directory contains all the components needed to run the PAIVoice Server as a macOS LaunchAgent service that starts automatically on login. PAIVoice is a framework for giving ANY Personal AI (PAI) system voice capabilities on macOS.
+
+## 🚀 Quick Start
+
+### Prerequisites
+
+1. **Install Bun** (if not already installed):
+ ```bash
+ curl -fsSL https://bun.sh/install | bash
+ ```
+
+2. **Set up API Keys** (Optional but recommended):
+
+ The server can work in two modes:
+ - **Basic Mode**: Uses macOS built-in 'say' command (no API key needed)
+ - **AI Voice Mode**: Uses ElevenLabs for natural AI voices (requires API key)
+
+ To enable AI voices:
+ ```bash
+ # Add to ~/.env file:
+ echo "ELEVENLABS_API_KEY=your_api_key_here" >> ~/.env
+ echo "ELEVENLABS_VOICE_ID=voice_id_here" >> ~/.env # Optional
+ ```
+
+ Get a free API key from [ElevenLabs](https://elevenlabs.io) (includes 10,000 characters/month free)
+
+### Install and Start the Service
+
+```bash
+cd ~/.claude/voice-server/macos-service
+./install.sh
+```
+
+That's it! The server will now start automatically when you log in.
+
+### Validate Setup (Recommended)
+
+Check if everything is configured correctly:
+```bash
+./validate-setup.sh
+```
+
+### Test the Service
+
+```bash
+./voice-server-ctl.sh test
+```
+
+## 📁 Files in this Directory
+
+- **`com.paivoice.server.plist`** - macOS LaunchAgent configuration file
+- **`install.sh`** - Installs the service
+- **`uninstall.sh`** - Removes the service
+- **`voice-server-ctl.sh`** - Service management utility
+- **`validate-setup.sh`** - Checks if everything is configured correctly
+- **`README.md`** - This documentation
+
+## 🛠️ Service Management
+
+Use the control script for all service operations:
+
+```bash
+# Check service status
+./voice-server-ctl.sh status
+
+# Start the service
+./voice-server-ctl.sh start
+
+# Stop the service
+./voice-server-ctl.sh stop
+
+# Restart the service
+./voice-server-ctl.sh restart
+
+# View live logs
+./voice-server-ctl.sh logs
+
+# Test with a notification
+./voice-server-ctl.sh test
+```
+
+## 📋 Manual Commands
+
+If you prefer using launchctl directly:
+
+```bash
+# Start service
+launchctl start com.paivoice.server
+
+# Stop service
+launchctl stop com.paivoice.server
+
+# Check if running
+launchctl list | grep com.paivoice.server
+
+# View logs
+tail -f ~/.claude/voice-server/logs/voice-server.log
+```
+
+## 🔧 Configuration
+
+### Environment Variables
+
+All configuration is done via `~/.env` file in your home directory:
+
+```bash
+# Required for AI voices (get free at https://elevenlabs.io)
+ELEVENLABS_API_KEY=your_api_key_here
+
+# Optional - customize voice (defaults to default voice)
+ELEVENLABS_VOICE_ID=voice_id_here
+
+# Optional - change port (default 8888)
+PORT=8888
+```
+
+### Available Voice IDs
+
+Popular ElevenLabs voices you can use:
+- `jqcCZkN6Knx8BJ5TBdYR` - Default voice (friendly assistant)
+- `21m00Tcm4TlvDq8ikWAM` - Rachel (calm, professional)
+- `AZnzlk1XvdvUeBnXmlld` - Domi (energetic)
+- `EXAVITQu4vr4xnSDxMaL` - Bella (warm, friendly)
+
+Find more voices at [ElevenLabs Voice Library](https://elevenlabs.io/voice-library)
+
+### Service Settings
+
+The service configuration is stored in the plist file:
+
+- **Port**: 8888 (default, configurable via ~/.env)
+- **Auto-start**: Yes (RunAtLoad)
+- **Keep-alive**: Yes (restarts on crash)
+- **Logs**: `~/.claude/voice-server/logs/`
+
+### Modify Settings
+
+After changing `~/.env`:
+```bash
+./voice-server-ctl.sh restart
+```
+
+For plist changes:
+```bash
+./uninstall.sh
+./install.sh
+```
+
+## 📡 API Endpoints
+
+Once running, the server provides:
+
+- `POST http://localhost:8888/notify` - Send notification with optional voice
+- `POST http://localhost:8888/pai` - Send PAI assistant notification
+- `GET http://localhost:8888/health` - Health check
+
+### Example Request
+
+```bash
+curl -X POST http://localhost:8888/notify \
+ -H "Content-Type: application/json" \
+ -d '{
+ "title": "Test",
+ "message": "Hello from Voice Server",
+ "voice_enabled": true
+ }'
+```
+
+## 🗑️ Uninstall
+
+To completely remove the service:
+
+```bash
+./uninstall.sh
+```
+
+This will:
+- Stop the running service
+- Remove it from LaunchAgents
+- Preserve log files for reference
+
+## 🔑 About ElevenLabs API Keys
+
+### What is ElevenLabs?
+ElevenLabs provides state-of-the-art AI voice synthesis. Their voices sound natural and expressive, far superior to traditional text-to-speech.
+
+### Do I Need an API Key?
+- **No** - The server works without one, using macOS 'say' command
+- **Recommended** - For natural AI voices that sound like real people
+
+### How to Get a Free API Key
+1. Visit [ElevenLabs](https://elevenlabs.io)
+2. Sign up for a free account
+3. Go to your [API Keys page](https://elevenlabs.io/api-keys)
+4. Copy your API key
+5. Add it to `~/.env`:
+ ```bash
+ echo "ELEVENLABS_API_KEY=your_key_here" >> ~/.env
+ ```
+
+### Free Tier Limits
+- **10,000 characters/month** free
+- Approximately 1,500-2,000 notifications
+- Resets monthly
+- No credit card required
+
+### Is My API Key Safe?
+- Stored only in your local `~/.env` file
+- Never committed to git (add `.env` to `.gitignore`)
+- Only accessible by your user account
+- Not included in the service configuration files
+
+## 🐛 Troubleshooting
+
+### Service won't start
+
+1. Check logs:
+ ```bash
+ cat ~/.claude/voice-server/logs/voice-server-error.log
+ ```
+
+2. Verify bun is installed:
+ ```bash
+ which bun
+ ```
+
+3. Check port 8888 is free:
+ ```bash
+ lsof -i :8888
+ ```
+
+### Service starts but no voice
+
+1. Test ElevenLabs API key in the plist file
+2. Check network connectivity
+3. Verify audio permissions in System Preferences
+
+### Permission Issues
+
+If you get permission denied errors:
+```bash
+chmod +x ~/.claude/voice-server/macos-service/*.sh
+```
+
+## 📊 Service Architecture
+
+```
+User Login
+ ↓
+launchd reads plist
+ ↓
+Starts bun process
+ ↓
+server.ts runs
+ ↓
+Listens on port 8888
+ ↓
+Ready for notifications
+```
+
+## 🔐 Security Notes
+
+- Service runs as your user (not root)
+- Only accepts local connections (localhost)
+- API keys stored in plist (user-readable only)
+- Logs stored in user home directory
+
+## 📝 License
+
+Internal tool - not for distribution
\ No newline at end of file
diff --git a/.claude/voice-server/macos-service/com.paivoice.server.plist b/.claude/voice-server/macos-service/com.paivoice.server.plist
new file mode 100644
index 00000000..43a38aca
--- /dev/null
+++ b/.claude/voice-server/macos-service/com.paivoice.server.plist
@@ -0,0 +1,48 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+ <key>Label</key>
+ <string>com.paivoice.server</string>
+
+ <key>ProgramArguments</key>
+ <array>
+ <string>/usr/local/bin/bun</string>
+ <string>run</string>
+ <string>/Users/daniel/.claude/voice-server/server.ts</string>
+ </array>
+
+ <key>EnvironmentVariables</key>
+ <dict>
+ <key>PORT</key>
+ <string>8888</string>
+ <key>PATH</key>
+ <string>/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin</string>
+ <key>HOME</key>
+ <string>/Users/daniel</string>
+ </dict>
+
+ <key>WorkingDirectory</key>
+ <string>/Users/daniel/.claude/voice-server</string>
+
+ <key>RunAtLoad</key>
+ <true/>
+
+ <key>KeepAlive</key>
+ <dict>
+ <key>SuccessfulExit</key>
+ <false/>
+ <key>Crashed</key>
+ <true/>
+ </dict>
+
+ <key>StandardOutPath</key>
+ <string>/Users/daniel/.claude/voice-server/logs/voice-server.log</string>
+
+ <key>StandardErrorPath</key>
+ <string>/Users/daniel/.claude/voice-server/logs/voice-server-error.log</string>
+
+ <key>ThrottleInterval</key>
+ <integer>10</integer>
+</dict>
+</plist>
\ No newline at end of file
diff --git a/.claude/voice-server/macos-service/install.sh b/.claude/voice-server/macos-service/install.sh
new file mode 100755
index 00000000..e83c3cd4
--- /dev/null
+++ b/.claude/voice-server/macos-service/install.sh
@@ -0,0 +1,94 @@
+#!/bin/bash
+
+# PAIVoice Server Service Installer
+# This script installs the voice server as a macOS LaunchAgent
+
+set -e
+
+SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
+SERVICE_NAME="com.paivoice.server"
+PLIST_FILE="com.paivoice.server.plist"
+LAUNCH_AGENTS_DIR="$HOME/Library/LaunchAgents"
+VOICE_SERVER_DIR="$HOME/.claude/voice-server"
+
+echo "🚀 PAIVoice Server Service Installer"
+echo "==========================================="
+echo ""
+
+# Check if bun is installed
+if ! command -v bun &> /dev/null; then
+ echo "❌ Error: bun is not installed"
+ echo "Please install bun first: curl -fsSL https://bun.sh/install | bash"
+ exit 1
+fi
+
+# Check for ElevenLabs API configuration
+echo "🔑 Checking API configuration..."
+if [ -f ~/.env ] && grep -q "ELEVENLABS_API_KEY" ~/.env 2>/dev/null; then
+ echo "✅ ElevenLabs API key found in ~/.env"
+else
+ echo "⚠️ No ElevenLabs API key found"
+ echo ""
+ echo " The server will use macOS 'say' command for voice."
+ echo " To enable ElevenLabs AI voices:"
+ echo ""
+ echo " 1. Get a free API key from: https://elevenlabs.io"
+ echo " 2. Add to ~/.env file:"
+ echo " ELEVENLABS_API_KEY=your_api_key_here"
+ echo " ELEVENLABS_VOICE_ID=voice_id_here # Optional, defaults to default voice"
+ echo ""
+ read -p " Continue without ElevenLabs? (y/n): " -n 1 -r
+ echo
+ if [[ ! $REPLY =~ ^[Yy]$ ]]; then
+ echo "Installation cancelled. Set up ~/.env and try again."
+ exit 1
+ fi
+fi
+
+# Create logs directory
+echo "📁 Creating logs directory..."
+mkdir -p "${VOICE_SERVER_DIR}/logs"
+
+# Create LaunchAgents directory if it doesn't exist
+echo "📁 Creating LaunchAgents directory..."
+mkdir -p "${LAUNCH_AGENTS_DIR}"
+
+# Stop existing service if running
+if launchctl list | grep -q "${SERVICE_NAME}"; then
+ echo "⏹️ Stopping existing service..."
+ launchctl unload "${LAUNCH_AGENTS_DIR}/${PLIST_FILE}" 2>/dev/null || true
+ launchctl remove "${SERVICE_NAME}" 2>/dev/null || true
+fi
+
+# Copy plist file to LaunchAgents
+echo "📝 Installing service configuration..."
+cp "${SCRIPT_DIR}/${PLIST_FILE}" "${LAUNCH_AGENTS_DIR}/"
+
+# Load the service
+echo "🔧 Loading service..."
+launchctl load -w "${LAUNCH_AGENTS_DIR}/${PLIST_FILE}"
+
+# Check if service is running
+sleep 2
+if launchctl list | grep -q "${SERVICE_NAME}"; then
+ echo "✅ Service installed and running successfully!"
+ echo ""
+ echo "📊 Service Status:"
+ launchctl list | grep "${SERVICE_NAME}"
+ echo ""
+ echo "🔍 Test the service:"
+ echo " curl http://localhost:8888/health"
+ echo ""
+ echo "📋 Service Management Commands:"
+ echo " Start: launchctl start ${SERVICE_NAME}"
+ echo " Stop: launchctl stop ${SERVICE_NAME}"
+ echo " Status: launchctl list | grep ${SERVICE_NAME}"
+ echo " Logs: tail -f ${VOICE_SERVER_DIR}/logs/voice-server.log"
+ echo ""
+ echo "🗑️ To uninstall:"
+ echo " ${SCRIPT_DIR}/uninstall.sh"
+else
+ echo "❌ Failed to start service. Check logs at:"
+ echo " ${VOICE_SERVER_DIR}/logs/voice-server-error.log"
+ exit 1
+fi
\ No newline at end of file
diff --git a/.claude/voice-server/macos-service/menubar/README.md b/.claude/voice-server/macos-service/menubar/README.md
new file mode 100644
index 00000000..d2eb6282
--- /dev/null
+++ b/.claude/voice-server/macos-service/menubar/README.md
@@ -0,0 +1,120 @@
+# PAIVoice Server Menu Bar Icon
+
+Adds a status icon to your macOS menu bar that shows if the PAIVoice server is running and provides quick controls for your Personal AI voice system.
+
+## 🚀 Quick Install
+
+```bash
+cd ~/.claude/voice-server/macos-service/menubar
+./install-menubar.sh
+```
+
+## 📊 What It Shows
+
+### Menu Bar Icons
+- **🎙️** = Voice server is running (active)
+- **🔇** = Voice server is stopped (inactive)
+
+### Click Menu Options
+When you click the icon, you'll see:
+- Server status (running/stopped)
+- Port number
+- Voice type (AI/macOS)
+- Quick actions:
+ - Test notification
+ - Start/Stop/Restart server
+ - View logs
+ - Check setup
+
+## 🛠️ Requirements
+
+### SwiftBar (Required)
+The menu bar icon uses SwiftBar, a free app that runs scripts in your menu bar.
+
+**Install SwiftBar:**
+- **Option 1:** Download from [swiftbar.app](https://swiftbar.app)
+- **Option 2:** Install with Homebrew:
+ ```bash
+ brew install --cask swiftbar
+ ```
+
+## 📁 Files
+
+- `voice-server.5s.sh` - The SwiftBar plugin script (refreshes every 5 seconds)
+- `install-menubar.sh` - Automated installer
+- `README.md` - This documentation
+
+## 🔧 Manual Installation
+
+If you prefer to install manually:
+
+1. Install SwiftBar from [swiftbar.app](https://swiftbar.app)
+
+2. Copy the plugin to SwiftBar's plugins folder:
+ ```bash
+ cp voice-server.5s.sh ~/Library/Application\ Support/SwiftBar/Plugins/
+ chmod +x ~/Library/Application\ Support/SwiftBar/Plugins/voice-server.5s.sh
+ ```
+
+3. Open SwiftBar and select the plugins folder when prompted
+
+## ⚙️ Customization
+
+### Change Refresh Rate
+The `5s` in the filename means it refreshes every 5 seconds. You can change this:
+- `voice-server.1s.sh` - Refresh every second (more responsive)
+- `voice-server.10s.sh` - Refresh every 10 seconds (less CPU usage)
+- `voice-server.30s.sh` - Refresh every 30 seconds (minimal CPU)
+
+### Modify Icons
+Edit `voice-server.5s.sh` and change the emoji icons:
+```bash
+echo "🎙️" # Change this to any emoji or text
+```
+
+Popular alternatives:
+- `🔊` - Speaker
+- `🎵` - Musical note
+- `🗣️` - Speaking head
+- `📢` - Megaphone
+- `●` - Simple dot (red/green with colors)
+
+## 🗑️ Uninstall
+
+Remove the menu bar icon:
+```bash
+rm ~/Library/Application\ Support/SwiftBar/Plugins/voice-server.5s.sh
+```
+
+Or keep SwiftBar and just disable the plugin in SwiftBar preferences.
+
+## 🐛 Troubleshooting
+
+### Icon not appearing
+1. Make sure SwiftBar is running
+2. Check SwiftBar is using the correct plugins folder:
+ - Click SwiftBar icon → Preferences
+ - Verify Plugin Folder path
+3. Ensure plugin is executable:
+ ```bash
+ chmod +x ~/Library/Application\ Support/SwiftBar/Plugins/voice-server.5s.sh
+ ```
+
+### Icon not updating
+- Click the icon and select "Refresh"
+- Check if the server is actually running:
+ ```bash
+ curl http://localhost:8888/health
+ ```
+
+### SwiftBar using too much CPU
+- Rename the plugin file to use a longer refresh interval (e.g., `voice-server.30s.sh`)
+
+## 🎨 How It Works
+
+The plugin is a simple bash script that:
+1. Checks if the server is running (via health endpoint)
+2. Outputs text in SwiftBar format
+3. Provides clickable menu items that run commands
+
+SwiftBar runs this script at the specified interval and displays the output in your menu bar.
\ No newline at end of file
diff --git a/.claude/voice-server/macos-service/menubar/install-menubar.sh b/.claude/voice-server/macos-service/menubar/install-menubar.sh
new file mode 100755
index 00000000..9123a7cf
--- /dev/null
+++ b/.claude/voice-server/macos-service/menubar/install-menubar.sh
@@ -0,0 +1,103 @@
+#!/bin/bash
+
+# PAIVoice Server Menu Bar Installer
+# Installs SwiftBar and sets up the voice server status plugin
+
+set -e
+
+# Colors for output
+RED='\033[0;31m'
+GREEN='\033[0;32m'
+YELLOW='\033[1;33m'
+BLUE='\033[0;34m'
+NC='\033[0m' # No Color
+
+echo "🎙️ PAIVoice Server Menu Bar Installer"
+echo "============================================"
+echo ""
+
+SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
+PLUGIN_FILE="voice-server.5s.sh"
+
+# Check if SwiftBar is installed
+if [ -d "/Applications/SwiftBar.app" ]; then
+ echo -e "${GREEN}✅ SwiftBar is installed${NC}"
+else
+ echo -e "${YELLOW}⚠️ SwiftBar not found${NC}"
+ echo ""
+ echo "SwiftBar is required for the menu bar icon."
+ echo ""
+ echo "Install options:"
+ echo "1. Download from: https://swiftbar.app"
+ echo "2. Install with Homebrew: brew install --cask swiftbar"
+ echo ""
+ read -p "Would you like to install SwiftBar with Homebrew? (y/n): " -n 1 -r
+ echo
+ if [[ $REPLY =~ ^[Yy]$ ]]; then
+ if command -v brew &> /dev/null; then
+ echo "Installing SwiftBar..."
+ brew install --cask swiftbar
+ echo -e "${GREEN}✅ SwiftBar installed${NC}"
+ else
+ echo -e "${RED}❌ Homebrew not found${NC}"
+ echo "Please install SwiftBar manually from https://swiftbar.app"
+ exit 1
+ fi
+ else
+ echo "Please install SwiftBar from https://swiftbar.app and run this script again."
+ exit 1
+ fi
+fi
+
+# Find SwiftBar plugins directory
+DEFAULT_PLUGIN_DIR="$HOME/Library/Application Support/SwiftBar/Plugins"
+if [ -d "$DEFAULT_PLUGIN_DIR" ]; then
+ PLUGIN_DIR="$DEFAULT_PLUGIN_DIR"
+ echo -e "${GREEN}✅ Found SwiftBar plugins directory${NC}"
+else
+ # SwiftBar might not be configured yet
+ echo -e "${YELLOW}⚠️ SwiftBar plugins directory not found${NC}"
+ echo ""
+ echo "Creating default plugins directory..."
+ mkdir -p "$DEFAULT_PLUGIN_DIR"
+ PLUGIN_DIR="$DEFAULT_PLUGIN_DIR"
+fi
+
+# Copy plugin to SwiftBar plugins directory
+echo "📝 Installing voice server plugin..."
+cp "${SCRIPT_DIR}/${PLUGIN_FILE}" "${PLUGIN_DIR}/"
+chmod +x "${PLUGIN_DIR}/${PLUGIN_FILE}"
+
+echo -e "${GREEN}✅ Plugin installed${NC}"
+
+# Check if SwiftBar is running
+if pgrep -x "SwiftBar" > /dev/null; then
+ echo -e "${GREEN}✅ SwiftBar is running${NC}"
+ echo ""
+ echo "The voice server icon should appear in your menu bar shortly."
+ echo "It refreshes every 5 seconds."
+else
+ echo ""
+ echo -e "${YELLOW}⚠️ SwiftBar is not running${NC}"
+ echo ""
+ echo "Starting SwiftBar..."
+ open -a SwiftBar
+
+ echo ""
+ echo "SwiftBar Setup:"
+ echo "1. SwiftBar will ask you to select a plugins folder"
+ echo "2. Choose: ~/Library/Application Support/SwiftBar/Plugins"
+ echo "3. The voice server icon will appear in your menu bar"
+fi
+
+echo ""
+echo "📊 Menu Bar Icon Status:"
+echo " 🎙️ = Voice server is running"
+echo " 🔇 = Voice server is stopped"
+echo ""
+echo "Click the icon to see status and control options."
+echo ""
+echo "To uninstall the menu bar icon:"
+echo " rm '${PLUGIN_DIR}/${PLUGIN_FILE}'"
+echo ""
+echo -e "${GREEN}✨ Menu bar setup complete!${NC}"
\ No newline at end of file
diff --git a/.claude/voice-server/macos-service/menubar/voice-server.5s.sh b/.claude/voice-server/macos-service/menubar/voice-server.5s.sh
new file mode 100755
index 00000000..d6a0a2ff
--- /dev/null
+++ b/.claude/voice-server/macos-service/menubar/voice-server.5s.sh
@@ -0,0 +1,85 @@
+#!/bin/bash
+
+# PAIVoice Server SwiftBar Plugin
+# Filename must end in .Xs.sh where X is refresh interval (5s = 5 seconds)
+#
+# To install:
+# 1. Install SwiftBar from https://swiftbar.app
+# 2. Copy this file to your SwiftBar plugins folder
+# 3. Make it executable: chmod +x voice-server.5s.sh
+
+export PATH="/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin"
+
+# Configuration
+SERVICE_NAME="com.paivoice.server"
+SERVER_URL="http://localhost:8888"
+VOICE_SERVER_DIR="$HOME/.claude/voice-server"
+
+# Check if server is running
+if curl -s "${SERVER_URL}/health" > /dev/null 2>&1; then
+ # Server is running - show active icon
+ echo "🎙️"
+ echo "---"
+ echo "✅ Voice Server Active | color=green"
+
+ # Get server info
+ HEALTH=$(curl -s "${SERVER_URL}/health" 2>/dev/null || echo "{}")
+ PORT=$(echo "$HEALTH" | grep -o '"port":[0-9]*' | grep -o '[0-9]*' || echo "8888")
+
+ echo "📡 Port: $PORT | color=#666666"
+
+ # Check if using ElevenLabs
+ if [ -f ~/.env ] && grep -q "ELEVENLABS_API_KEY=" ~/.env 2>/dev/null; then
+ API_KEY=$(grep "ELEVENLABS_API_KEY=" ~/.env | cut -d'=' -f2)
+ if [[ "$API_KEY" != "your_api_key_here" ]] && [[ -n "$API_KEY" ]]; then
+ echo "🤖 AI Voice: Enabled | color=#666666"
+ else
+ echo "🔊 Voice: macOS Say | color=#666666"
+ fi
+ else
+ echo "🔊 Voice: macOS Say | color=#666666"
+ fi
+
+ # Check service status
+ if launchctl list | grep -q "${SERVICE_NAME}"; then
+ PID=$(launchctl list | grep "${SERVICE_NAME}" | awk '{print $1}')
+ if [ "$PID" != "-" ]; then
+ echo "🚀 Service: Running (PID: $PID) | color=#666666"
+ else
+ echo "⚠️ Service: Loaded but stopped | color=orange"
+ fi
+ else
+ echo "⚠️ Running manually (not as service) | color=orange"
+ fi
+
+ echo "---"
+ echo "📢 Test Notification | bash='${VOICE_SERVER_DIR}/macos-service/voice-server-ctl.sh' param1=test terminal=false"
+ echo "🔄 Restart Server | bash='${VOICE_SERVER_DIR}/macos-service/voice-server-ctl.sh' param1=restart terminal=false refresh=true"
+ echo "⏹️ Stop Server | bash='${VOICE_SERVER_DIR}/macos-service/voice-server-ctl.sh' param1=stop terminal=false refresh=true"
+
+else
+ # Server is not running - show inactive icon
+ echo "🔇"
+ echo "---"
+ echo "❌ Voice Server Offline | color=red"
+
+ # Check if service is installed
+ if [ -f ~/Library/LaunchAgents/${SERVICE_NAME}.plist ]; then
+ echo "Service installed but not running | color=#666666"
+ echo "---"
+ echo "▶️ Start Server | bash='${VOICE_SERVER_DIR}/macos-service/voice-server-ctl.sh' param1=start terminal=false refresh=true"
+ else
+ echo "Service not installed | color=#666666"
+ echo "---"
+ echo "📦 Install Service | bash='cd ${VOICE_SERVER_DIR}/macos-service && ./install.sh' terminal=true refresh=true"
+ fi
+fi
+
+echo "---"
+echo "📋 View Logs | bash='${VOICE_SERVER_DIR}/macos-service/voice-server-ctl.sh' param1=logs terminal=true"
+echo "🔍 Check Setup | bash='cd ${VOICE_SERVER_DIR}/macos-service && ./validate-setup.sh' terminal=true"
+echo "---"
+echo "📁 Open Voice Server Folder | bash='open' param1='${VOICE_SERVER_DIR}' terminal=false"
+echo "📄 View README | bash='open' param1='${VOICE_SERVER_DIR}/macos-service/README.md' terminal=false"
+echo "---"
+echo "🔄 Refresh | refresh=true"
\ No newline at end of file
diff --git a/.claude/voice-server/macos-service/uninstall.sh b/.claude/voice-server/macos-service/uninstall.sh
new file mode 100755
index 00000000..096c3878
--- /dev/null
+++ b/.claude/voice-server/macos-service/uninstall.sh
@@ -0,0 +1,35 @@
+#!/bin/bash
+
+# PAIVoice Server Service Uninstaller
+
+set -e
+
+SERVICE_NAME="com.paivoice.server"
+PLIST_FILE="com.paivoice.server.plist"
+LAUNCH_AGENTS_DIR="$HOME/Library/LaunchAgents"
+
+echo "🗑️ PAIVoice Server Service Uninstaller"
+echo "============================================"
+echo ""
+
+# Check if service is installed
+if [ ! -f "${LAUNCH_AGENTS_DIR}/${PLIST_FILE}" ]; then
+ echo "⚠️ Service is not installed"
+ exit 0
+fi
+
+# Stop and unload the service
+if launchctl list | grep -q "${SERVICE_NAME}"; then
+ echo "⏹️ Stopping service..."
+ launchctl unload "${LAUNCH_AGENTS_DIR}/${PLIST_FILE}" 2>/dev/null || true
+ launchctl remove "${SERVICE_NAME}" 2>/dev/null || true
+fi
+
+# Remove plist file
+echo "🗑️ Removing service configuration..."
+rm -f "${LAUNCH_AGENTS_DIR}/${PLIST_FILE}"
+
+echo "✅ Service uninstalled successfully!"
+echo ""
+echo "Note: Log files have been preserved at:"
+echo " ~/.claude/voice-server/logs/"
\ No newline at end of file
diff --git a/.claude/voice-server/macos-service/validate-setup.sh b/.claude/voice-server/macos-service/validate-setup.sh
new file mode 100755
index 00000000..cc7ade02
--- /dev/null
+++ b/.claude/voice-server/macos-service/validate-setup.sh
@@ -0,0 +1,180 @@
+#!/bin/bash
+
+# PAIVoice Server Setup Validator
+# This script checks if everything is properly configured
+
+set -e
+
+# Colors for output
+RED='\033[0;31m'
+GREEN='\033[0;32m'
+YELLOW='\033[1;33m'
+BLUE='\033[0;34m'
+NC='\033[0m' # No Color
+
+echo "🔍 PAIVoice Server Setup Validator"
+echo "=========================================="
+echo ""
+
+ISSUES_FOUND=0
+WARNINGS_FOUND=0
+
+# Function to check requirements
+check_requirement() {
+ local name=$1
+ local check_command=$2
+ local install_hint=$3
+
+ if eval "$check_command" &>/dev/null; then
+ echo -e "${GREEN}✅ $name${NC}"
+ return 0
+ else
+ echo -e "${RED}❌ $name${NC}"
+ echo " $install_hint"
+ ISSUES_FOUND=$((ISSUES_FOUND + 1))
+ return 1
+ fi
+}
+
+# Function to check warnings
+check_warning() {
+ local name=$1
+ local check_command=$2
+ local hint=$3
+
+ if eval "$check_command" &>/dev/null; then
+ echo -e "${GREEN}✅ $name${NC}"
+ return 0
+ else
+ echo -e "${YELLOW}⚠️ $name${NC}"
+ echo " $hint"
+ WARNINGS_FOUND=$((WARNINGS_FOUND + 1))
+ return 1
+ fi
+}
+
+echo "📋 Checking Requirements:"
+echo ""
+
+# Check Bun installation
+check_requirement "Bun installed" \
+ "command -v bun" \
+ "Install with: curl -fsSL https://bun.sh/install | bash"
+
+# Check server.ts exists
+check_requirement "Server file exists" \
+ "[ -f ~/.claude/voice-server/server.ts ]" \
+ "Server file missing at ~/.claude/voice-server/server.ts"
+
+# Check if port 8888 is available or used by our service
+PORT_CHECK=$(lsof -i :8888 2>/dev/null | grep -v COMMAND | head -1)
+if [ -z "$PORT_CHECK" ]; then
+ echo -e "${GREEN}✅ Port 8888 available${NC}"
+elif echo "$PORT_CHECK" | grep -q "bun"; then
+ echo -e "${GREEN}✅ Port 8888 used by voice server (bun)${NC}"
+else
+ echo -e "${RED}❌ Port 8888 used by another service${NC}"
+ echo " Stop the conflicting service or change PORT in ~/.env"
+ ISSUES_FOUND=$((ISSUES_FOUND + 1))
+fi
+
+echo ""
+echo "🔑 Checking API Configuration:"
+echo ""
+
+# Check ~/.env file exists
+if [ -f ~/.env ]; then
+ echo -e "${GREEN}✅ ~/.env file exists${NC}"
+
+ # Check for ElevenLabs API key
+ if grep -q "ELEVENLABS_API_KEY=" ~/.env 2>/dev/null; then
+ # Check if it's not a placeholder
+ API_KEY=$(grep "ELEVENLABS_API_KEY=" ~/.env | cut -d'=' -f2)
+ if [[ "$API_KEY" == "your_api_key_here" ]] || [[ -z "$API_KEY" ]]; then
+ check_warning "ElevenLabs API key configured" \
+ "false" \
+ "Replace placeholder with actual API key from https://elevenlabs.io"
+ else
+ echo -e "${GREEN}✅ ElevenLabs API key configured${NC}"
+
+ # Check if voice ID is set
+ if grep -q "ELEVENLABS_VOICE_ID=" ~/.env 2>/dev/null; then
+ echo -e "${GREEN}✅ Custom voice ID configured${NC}"
+ else
+ echo -e "${BLUE}ℹ️ Using default voice (Kai)${NC}"
+ fi
+ fi
+ else
+ check_warning "ElevenLabs API key configured" \
+ "false" \
+ "Add ELEVENLABS_API_KEY=your_key to ~/.env for AI voices"
+ fi
+else
+ check_warning "~/.env file exists" \
+ "false" \
+ "Create ~/.env and add ELEVENLABS_API_KEY=your_key for AI voices"
+fi
+
+echo ""
+echo "🚀 Checking Service Status:"
+echo ""
+
+# Check if service is installed
+if [ -f ~/Library/LaunchAgents/com.kainotify.voice-server.plist ]; then
+ echo -e "${GREEN}✅ Service is installed${NC}"
+
+ # Check if service is running
+ if launchctl list | grep -q "com.kainotify.voice-server"; then
+ STATUS_LINE=$(launchctl list | grep "com.kainotify.voice-server")
+ PID=$(echo "$STATUS_LINE" | awk '{print $1}')
+
+ if [ "$PID" != "-" ]; then
+ echo -e "${GREEN}✅ Service is running (PID: $PID)${NC}"
+
+ # Test server endpoint
+ if curl -s http://localhost:8888/health > /dev/null 2>&1; then
+ echo -e "${GREEN}✅ Server is responding${NC}"
+ else
+ echo -e "${RED}❌ Server not responding${NC}"
+ echo " Check logs: tail -f ~/.claude/voice-server/logs/voice-server-error.log"
+ ISSUES_FOUND=$((ISSUES_FOUND + 1))
+ fi
+ else
+ echo -e "${YELLOW}⚠️ Service is loaded but not running${NC}"
+ echo " Start with: launchctl start com.kainotify.voice-server"
+ WARNINGS_FOUND=$((WARNINGS_FOUND + 1))
+ fi
+ else
+ echo -e "${YELLOW}⚠️ Service is installed but not loaded${NC}"
+ echo " Load with: launchctl load ~/Library/LaunchAgents/com.kainotify.voice-server.plist"
+ WARNINGS_FOUND=$((WARNINGS_FOUND + 1))
+ fi
+else
+ echo -e "${BLUE}ℹ️ Service not installed${NC}"
+ echo " Install with: ./install.sh"
+fi
+
+echo ""
+echo "📊 Summary:"
+echo "=========="
+
+if [ $ISSUES_FOUND -eq 0 ] && [ $WARNINGS_FOUND -eq 0 ]; then
+ echo -e "${GREEN}✨ Everything looks good! Your setup is complete.${NC}"
+ echo ""
+ echo "Test the server with:"
+ echo " ./voice-server-ctl.sh test"
+elif [ $ISSUES_FOUND -eq 0 ]; then
+ echo -e "${YELLOW}⚠️ Setup is functional with $WARNINGS_FOUND warning(s)${NC}"
+ echo "The server will work but some features may be limited."
+else
+ echo -e "${RED}❌ Found $ISSUES_FOUND critical issue(s) and $WARNINGS_FOUND warning(s)${NC}"
+ echo "Please fix the critical issues before proceeding."
+ exit 1
+fi
+
+echo ""
+echo "📚 Quick Commands:"
+echo " Install service: ./install.sh"
+echo " Test server: ./voice-server-ctl.sh test"
+echo " View logs: ./voice-server-ctl.sh logs"
+echo " Check status: ./voice-server-ctl.sh status"
\ No newline at end of file
diff --git a/.claude/voice-server/macos-service/voice-server-ctl.sh b/.claude/voice-server/macos-service/voice-server-ctl.sh
new file mode 100755
index 00000000..3b2add72
--- /dev/null
+++ b/.claude/voice-server/macos-service/voice-server-ctl.sh
@@ -0,0 +1,195 @@
+#!/bin/bash
+
+# PAIVoice Server Service Control Script
+# Manage the voice server macOS service
+
+SERVICE_NAME="com.paivoice.server"
+PLIST_FILE="com.paivoice.server.plist"
+LAUNCH_AGENTS_DIR="$HOME/Library/LaunchAgents"
+VOICE_SERVER_DIR="$HOME/.claude/voice-server"
+SERVER_URL="http://localhost:8888"
+
+# Colors for output
+RED='\033[0;31m'
+GREEN='\033[0;32m'
+YELLOW='\033[1;33m'
+BLUE='\033[0;34m'
+NC='\033[0m' # No Color
+
+function print_usage() {
+ echo "PAIVoice Server Control"
+ echo "Usage: $0 {start|stop|restart|status|logs|test|install|uninstall}"
+ echo ""
+ echo "Commands:"
+ echo " start - Start the voice server service"
+ echo " stop - Stop the voice server service"
+ echo " restart - Restart the voice server service"
+ echo " status - Show service status"
+ echo " logs - Tail the service logs"
+ echo " test - Test the server with a notification"
+ echo " install - Install the service"
+ echo " uninstall - Uninstall the service"
+}
+
+function check_service_installed() {
+ if [ ! -f "${LAUNCH_AGENTS_DIR}/${PLIST_FILE}" ]; then
+ echo -e "${RED}❌ Service is not installed${NC}"
+ echo "Run: $0 install"
+ exit 1
+ fi
+}
+
+function start_service() {
+ check_service_installed
+ echo -e "${BLUE}🚀 Starting voice server...${NC}"
+ launchctl start "${SERVICE_NAME}"
+ sleep 2
+ status_service
+}
+
+function stop_service() {
+ check_service_installed
+ echo -e "${YELLOW}⏹️ Stopping voice server...${NC}"
+ launchctl stop "${SERVICE_NAME}"
+ echo -e "${GREEN}✅ Service stopped${NC}"
+}
+
+function restart_service() {
+ check_service_installed
+ echo -e "${BLUE}🔄 Restarting voice server...${NC}"
+ launchctl stop "${SERVICE_NAME}" 2>/dev/null || true
+ sleep 1
+ launchctl start "${SERVICE_NAME}"
+ sleep 2
+ status_service
+}
+
+function status_service() {
+ echo -e "${BLUE}📊 Service Status:${NC}"
+
+ # Check if plist is installed
+ if [ ! -f "${LAUNCH_AGENTS_DIR}/${PLIST_FILE}" ]; then
+ echo -e "${RED}❌ Service not installed${NC}"
+ return 1
+ fi
+
+ # Check launchctl status
+ if launchctl list | grep -q "${SERVICE_NAME}"; then
+ STATUS_LINE=$(launchctl list | grep "${SERVICE_NAME}")
+ PID=$(echo "$STATUS_LINE" | awk '{print $1}')
+ EXIT_CODE=$(echo "$STATUS_LINE" | awk '{print $2}')
+
+ if [ "$PID" != "-" ]; then
+ echo -e "${GREEN}✅ Service is running (PID: $PID)${NC}"
+
+ # Test server endpoint
+ if curl -s "${SERVER_URL}/health" > /dev/null 2>&1; then
+ HEALTH=$(curl -s "${SERVER_URL}/health")
+ echo -e "${GREEN}✅ Server is responding${NC}"
+ echo " Health: $HEALTH"
+ else
+ echo -e "${YELLOW}⚠️ Server not responding on port 8888${NC}"
+ fi
+ else
+ echo -e "${YELLOW}⚠️ Service is loaded but not running${NC}"
+ if [ "$EXIT_CODE" != "0" ]; then
+ echo " Last exit code: $EXIT_CODE"
+ fi
+ fi
+ else
+ echo -e "${RED}❌ Service is not loaded${NC}"
+ fi
+
+ # Check for log files
+ if [ -f "${VOICE_SERVER_DIR}/logs/voice-server.log" ]; then
+ echo ""
+ echo "📋 Recent logs:"
+ tail -n 5 "${VOICE_SERVER_DIR}/logs/voice-server.log" 2>/dev/null | sed 's/^/ /'
+ fi
+}
+
+function show_logs() {
+ check_service_installed
+ echo -e "${BLUE}📋 Tailing voice server logs...${NC}"
+ echo "Press Ctrl+C to stop"
+ echo ""
+
+ # Create logs directory if it doesn't exist
+ mkdir -p "${VOICE_SERVER_DIR}/logs"
+ touch "${VOICE_SERVER_DIR}/logs/voice-server.log"
+ touch "${VOICE_SERVER_DIR}/logs/voice-server-error.log"
+
+ # Tail both log files
+ tail -f "${VOICE_SERVER_DIR}/logs/voice-server.log" "${VOICE_SERVER_DIR}/logs/voice-server-error.log"
+}
+
+function test_server() {
+ echo -e "${BLUE}🧪 Testing voice server...${NC}"
+
+ # Check if server is running
+ if ! curl -s "${SERVER_URL}/health" > /dev/null 2>&1; then
+ echo -e "${RED}❌ Server is not running${NC}"
+ echo "Start it with: $0 start"
+ exit 1
+ fi
+
+ echo "Sending test notification..."
+
+ RESPONSE=$(curl -s -X POST "${SERVER_URL}/notify" \
+ -H "Content-Type: application/json" \
+ -d '{
+ "title": "Voice Server Test",
+ "message": "Hello! This is a test notification from the voice server.",
+ "voice_enabled": true
+ }')
+
+ if echo "$RESPONSE" | grep -q "success"; then
+ echo -e "${GREEN}✅ Test notification sent successfully!${NC}"
+ echo " You should see a notification and hear the voice."
+ else
+ echo -e "${RED}❌ Test failed${NC}"
+ echo " Response: $RESPONSE"
+ fi
+}
+
+function install_service() {
+ SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
+ "${SCRIPT_DIR}/install.sh"
+}
+
+function uninstall_service() {
+ SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
+ "${SCRIPT_DIR}/uninstall.sh"
+}
+
+# Main command handling
+case "$1" in
+ start)
+ start_service
+ ;;
+ stop)
+ stop_service
+ ;;
+ restart)
+ restart_service
+ ;;
+ status)
+ status_service
+ ;;
+ logs)
+ show_logs
+ ;;
+ test)
+ test_server
+ ;;
+ install)
+ install_service
+ ;;
+ uninstall)
+ uninstall_service
+ ;;
+ *)
+ print_usage
+ exit 1
+ ;;
+esac
\ No newline at end of file
diff --git a/.claude/voice-server/server.ts b/.claude/voice-server/server.ts
new file mode 100644
index 00000000..894be9b5
--- /dev/null
+++ b/.claude/voice-server/server.ts
@@ -0,0 +1,211 @@
+#!/usr/bin/env bun
+/**
+ * PAIVoice - Personal AI Voice notification server for macOS with ElevenLabs
+ */
+
+import { serve } from "bun";
+import { exec } from "child_process";
+import { promisify } from "util";
+import { writeFile, unlink } from "fs/promises";
+import { tmpdir } from "os";
+import { join } from "path";
+import { homedir } from "os";
+import { existsSync } from "fs";
+
+// Load .env from user home directory
+const envPath = join(homedir(), '.env');
+if (existsSync(envPath)) {
+ const envContent = await Bun.file(envPath).text();
+ envContent.split('\n').forEach(line => {
+ const [key, value] = line.split('=');
+ if (key && value && !key.startsWith('#')) {
+ process.env[key.trim()] = value.trim();
+ }
+ });
+}
+
+const execAsync = promisify(exec);
+const PORT = parseInt(process.env.PORT || "8888");
+
+// ElevenLabs configuration - MUST be set in ~/.env
+const ELEVENLABS_API_KEY = process.env.ELEVENLABS_API_KEY;
+const ELEVENLABS_VOICE_ID = process.env.ELEVENLABS_VOICE_ID || "jqcCZkN6Knx8BJ5TBdYR";
+
+if (!ELEVENLABS_API_KEY) {
+ console.error("⚠️ Warning: ELEVENLABS_API_KEY not found in ~/.env");
+ console.error(" Voice features will fall back to macOS 'say' command");
+ console.error(" To enable ElevenLabs voices, add to ~/.env:");
+ console.error(" ELEVENLABS_API_KEY=your_api_key_here");
+}
+
+// Generate voice using ElevenLabs
+async function generateVoice(text, voiceId = null) {
+ // If no API key, return null to trigger fallback
+ if (!ELEVENLABS_API_KEY) {
+ return null;
+ }
+
+ const voiceToUse = voiceId || ELEVENLABS_VOICE_ID;
+
+ try {
+ const response = await fetch(
+ `https://api.elevenlabs.io/v1/text-to-speech/${voiceToUse}`,
+ {
+ method: "POST",
+ headers: {
+ "Accept": "audio/mpeg",
+ "Content-Type": "application/json",
+ "xi-api-key": ELEVENLABS_API_KEY
+ },
+ body: JSON.stringify({
+ text,
+ model_id: "eleven_turbo_v2_5",
+ voice_settings: {
+ stability: 0.75,
+ similarity_boost: 0.75,
+ style: 0.5,
+ use_speaker_boost: true
+ }
+ })
+ }
+ );
+
+ if (!response.ok) {
+ console.error(`ElevenLabs API error: ${response.status}`);
+ return null;
+ }
+
+ const audioBuffer = await response.arrayBuffer();
+ const tempFile = join(tmpdir(), `kainotify-${Date.now()}.mp3`);
+ await writeFile(tempFile, Buffer.from(audioBuffer));
+
+ return tempFile;
+ } catch (error) {
+ console.error("ElevenLabs error:", error);
+ return null;
+ }
+}
+
+// Send macOS notification with voice
+async function sendNotification(title, message, voiceEnabled = true, voiceId = null) {
+ if (voiceEnabled) {
+ const audioFile = await generateVoice(message, voiceId);
+
+ if (audioFile) {
+ execAsync(`afplay "${audioFile}"`).then(() => {
+ unlink(audioFile).catch(() => {});
+ }).catch(() => {
+ console.error("Failed to play ElevenLabs audio");
+ execAsync(`say "${message}"`).catch(() => {});
+ });
+ } else {
+ execAsync(`say "${message}"`).catch(() => {
+ console.error("Failed to speak message");
+ });
+ }
+ }
+
+ const escapedMessage = message.replace(/'/g, "'\\''").replace(/"/g, '\\"');
+ const escapedTitle = title.replace(/'/g, "'\\''").replace(/"/g, '\\"');
+ const script = `display notification "${escapedMessage}" with title "${escapedTitle}" sound name ""`;
+ await execAsync(`osascript -e '${script}'`);
+}
+
+// Start HTTP server
+const server = serve({
+ port: PORT,
+ async fetch(req) {
+ const url = new URL(req.url);
+
+ const corsHeaders = {
+ "Access-Control-Allow-Origin": "*",
+ "Access-Control-Allow-Methods": "GET, POST, OPTIONS",
+ "Access-Control-Allow-Headers": "Content-Type"
+ };
+
+ if (req.method === "OPTIONS") {
+ return new Response(null, { headers: corsHeaders, status: 204 });
+ }
+
+ if (url.pathname === "/notify" && req.method === "POST") {
+ try {
+ const data = await req.json();
+ const title = data.title || "PAI Notification";
+ const message = data.message || "Task completed";
+ const voiceEnabled = data.voice_enabled !== false;
+ const voiceId = data.voice_id || null;
+
+ console.log(`📨 Received notification: "${title}" - "${message}" (voice: ${voiceEnabled}, voiceId: ${voiceId}`);
+
+ await sendNotification(title, message, voiceEnabled, voiceId);
+
+ return new Response(
+ JSON.stringify({ status: "success", message: "Notification sent" }),
+ {
+ headers: { ...corsHeaders, "Content-Type": "application/json" },
+ status: 200
+ }
+ );
+ } catch (error) {
+ return new Response(
+ JSON.stringify({ status: "error", message: error.message }),
+ {
+ headers: { ...corsHeaders, "Content-Type": "application/json" },
+ status: 500
+ }
+ );
+ }
+ }
+
+ if (url.pathname === "/pai" && req.method === "POST") {
+ try {
+ const data = await req.json();
+ const title = data.title || "PAI Assistant";
+ const message = data.message || "Task completed";
+
+ console.log(`🤖 PAI notification: "${title}" - "${message}"`);
+
+ await sendNotification(title, message, true);
+
+ return new Response(
+ JSON.stringify({ status: "success", message: "PAI notification sent" }),
+ {
+ headers: { ...corsHeaders, "Content-Type": "application/json" },
+ status: 200
+ }
+ );
+ } catch (error) {
+ return new Response(
+ JSON.stringify({ status: "error", message: error.message }),
+ {
+ headers: { ...corsHeaders, "Content-Type": "application/json" },
+ status: 500
+ }
+ );
+ }
+ }
+
+ if (url.pathname === "/health") {
+ return new Response(
+ JSON.stringify({ status: "healthy", port: PORT }),
+ {
+ headers: { ...corsHeaders, "Content-Type": "application/json" },
+ status: 200
+ }
+ );
+ }
+
+ return new Response("PAIVoice Server - POST to /notify or /pai", {
+ headers: corsHeaders,
+ status: 200
+ });
+ },
+});
+
+console.log(`🚀 PAIVoice Server running on port ${PORT}`);
+if (ELEVENLABS_API_KEY) {
+ console.log(`🎙️ Using ElevenLabs voice: ${ELEVENLABS_VOICE_ID}`);
+} else {
+ console.log(`🎙️ Using macOS 'say' command (no ElevenLabs API key)`);
+}
+console.log(`📡 POST to http://localhost:${PORT}/notify`);
\ No newline at end of file
diff --git a/.claude/voice-server/start.sh b/.claude/voice-server/start.sh
new file mode 100755
index 00000000..368e07cc
--- /dev/null
+++ b/.claude/voice-server/start.sh
@@ -0,0 +1,28 @@
+#!/bin/bash
+
+# PAIVoice Server Start Script
+
+# Load environment variables from ~/.env
+if [ -f ~/.env ]; then
+ export $(grep -v '^#' ~/.env | xargs)
+fi
+
+# Set default port if not in .env
+export PORT="${PORT:-8888}"
+
+# Kill any existing voice server processes
+pkill -f "voice-server/server.ts" 2>/dev/null
+
+# Start the server
+echo "🚀 Starting PAIVoice Server on port $PORT"
+cd /Users/daniel/.claude/voice-server
+bun run server.ts &
+
+echo "✅ Voice server started with PID $!"
+echo "📡 Listening on http://localhost:$PORT"
+
+# Check if ElevenLabs API key is configured
+if [ -z "$ELEVENLABS_API_KEY" ]; then
+ echo "⚠️ No ElevenLabs API key found - using macOS 'say' command"
+ echo " To enable ElevenLabs voices, add ELEVENLABS_API_KEY to ~/.env"
+fi
\ No newline at end of file
diff --git a/README.md b/README.md
index 6ac2e02b..151a60c1 100644
--- a/README.md
+++ b/README.md
@@ -108,7 +108,11 @@ Based off my own personal Digital Assistant, **Kai**, it combines a scaffolding
### **Quick Start**
-One thing to note is that when you download the project, the.Claude directory is hidden by default because it's a dot directory. So cd into `.claude` when you're done with the instructions.
+I use *Typescript* as my main language (instead of Python), and I use `bun` as my main Javascript/Typescript system. Think: runtime, package management, etc. So if you want to use this system as-is, make sure you have `bun` installed before getting started.
+
+`brew install bun`
+
+One thing to note is that when you download the project, the `.claude` directory is hidden by default because it's a dot directory. So cd into `.claude` when you're done with the instructions.
`cd .claude`
@@ -126,9 +130,10 @@ ls -lah
### **Prerequisites**
-- [Claude Code](https://claude.ai/code) - The primary AI interface, which can be any similar system
-- Text editor (any will work - it's all Markdown/Text!)
-- Ideal: Basic command line familiarity
+- [Claude Code](https://claude.ai/code) - The primary AI interface, which can ultimately be any similar system, e.g., Gemini, Codex, etc.
+- [Bun](https://bun.com/) - The node.js system we're using
+- Text editor (Neovim recommended, but any will work—it's all Markdown/Text!)
+- Ideal: Decent Command Line Interface skills
<br/>
diff --git a/claude b/claude
new file mode 120000
index 00000000..c8161850
--- /dev/null
+++ b/claude
@@ -0,0 +1 @@
+.claude
\ No newline at end of file