⛰️ LifeOS — The AI-powered Life Operating System that helps you hill climb to wherever you're going.
fix: Resolve 7 community issues — security, voice, cross-platform
Daniel Miessler95d65cc7236c
diff --git a/Releases/v3.0/.claude/PAI-Install/engine/actions.ts b/Releases/v3.0/.claude/PAI-Install/engine/actions.tsindex bf933cf8..a7540f2f 100644--- a/Releases/v3.0/.claude/PAI-Install/engine/actions.ts+++ b/Releases/v3.0/.claude/PAI-Install/engine/actions.ts@@ -589,6 +589,25 @@ export async function runConfiguration(writeFileSync(zshrcPath, `${marker}\n${aliasLine}\n`);}+ // Set up fish shell config (if fish is installed)+ const fishConfigPath = join(homedir(), ".config", "fish", "config.fish");+ const fishConfigDir = join(homedir(), ".config", "fish");+ const paiToolPath = join(paiDir, "skills", "PAI", "Tools", "pai.ts");+ const fishFunction = `# PAI alias\nfunction pai\n bun ${paiToolPath} $argv\nend`;++ if (existsSync(fishConfigDir)) {+ if (existsSync(fishConfigPath)) {+ let content = readFileSync(fishConfigPath, "utf-8");+ // Remove old PAI/CORE fish functions+ content = content.replace(/^#\s*(?:PAI|CORE)\s*alias\nfunction pai\n.*\nend\n?/gm, "");+ content = content.replace(/^function pai\n.*\nend\n?/gm, "");+ content = content.trimEnd() + `\n\n${fishFunction}\n`;+ writeFileSync(fishConfigPath, content);+ } else {+ writeFileSync(fishConfigPath, `${fishFunction}\n`);+ }+ }+// Fix permissionsawait emit({ event: "progress", step: "configuration", percent: 90, detail: "Setting permissions..." });try {diff --git a/Releases/v3.0/.claude/PAI-Install/engine/detect.ts b/Releases/v3.0/.claude/PAI-Install/engine/detect.tsindex a596ae30..f2ec3742 100644--- a/Releases/v3.0/.claude/PAI-Install/engine/detect.ts+++ b/Releases/v3.0/.claude/PAI-Install/engine/detect.ts@@ -152,15 +152,30 @@ export function detectSystem(): DetectionResult {/*** Validate an ElevenLabs API key.+ * Uses /v1/voices endpoint (requires only voices_read permission)+ * instead of /v1/user (requires user_read, which many keys lack).+ * Also handles 401 with missing_permissions as "valid key, limited scope".*/export async function validateElevenLabsKey(key: string): Promise<{ valid: boolean; error?: string }> {try {- const res = await fetch("https://api.elevenlabs.io/v1/user", {+ const res = await fetch("https://api.elevenlabs.io/v1/voices", {headers: { "xi-api-key": key },signal: AbortSignal.timeout(10000),});if (res.ok) return { valid: true };++ // 401 with missing_permissions means the key IS valid but lacks a specific scope+ // This still means TTS will work (TTS doesn't need voices_read to use a known voice_id)+ if (res.status === 401) {+ try {+ const body = await res.json();+ if (body?.detail?.status === "missing_permissions") {+ return { valid: true }; // Key is valid, just limited permissions+ }+ } catch { /* fall through to error */ }+ }+return { valid: false, error: `HTTP ${res.status}` };} catch (e: any) {return { valid: false, error: e.message || "Network error" };diff --git a/Releases/v3.0/.claude/VoiceServer/server.ts b/Releases/v3.0/.claude/VoiceServer/server.tsindex 3d3a4400..2fb4685a 100644--- a/Releases/v3.0/.claude/VoiceServer/server.ts+++ b/Releases/v3.0/.claude/VoiceServer/server.ts@@ -436,7 +436,7 @@ async function sendNotification(voiceId: string | null = null,callerVoiceSettings?: Partial<ElevenLabsVoiceSettings> | null,callerVolume?: number | null,-) {+): Promise<{ voicePlayed: boolean; voiceError?: string }> {const titleValidation = validateInput(title);const messageValidation = validateInput(message);@@ -455,6 +455,9 @@ async function sendNotification(safeMessage = cleaned;// Generate and play voice using ElevenLabs+ let voicePlayed = false;+ let voiceError: string | undefined;+if (voiceEnabled && ELEVENLABS_API_KEY) {try {const voice = voiceId || DEFAULT_VOICE_ID;@@ -502,8 +505,10 @@ async function sendNotification(const audioBuffer = await generateSpeech(safeMessage, voice, resolvedSettings);await playAudio(audioBuffer, resolvedVolume);- } catch (error) {+ voicePlayed = true;+ } catch (error: any) {console.error("Failed to generate/play speech:", error);+ voiceError = error.message || "TTS generation failed";}}@@ -518,6 +523,8 @@ async function sendNotification(console.error("Notification display error:", error);}}++ return { voicePlayed, voiceError };}// Rate limiting@@ -586,7 +593,17 @@ const server = serve({console.log(`📨 Notification: "${title}" - "${message}" (voice: ${voiceEnabled}, voiceId: ${voiceId || DEFAULT_VOICE_ID})`);- await sendNotification(title, message, voiceEnabled, voiceId, voiceSettings, volume);+ const result = await sendNotification(title, message, voiceEnabled, voiceId, voiceSettings, volume);++ if (voiceEnabled && !result.voicePlayed && result.voiceError) {+ return new Response(+ JSON.stringify({ status: "error", message: `TTS failed: ${result.voiceError}`, notification_sent: true }),+ {+ headers: { ...corsHeaders, "Content-Type": "application/json" },+ status: 502+ }+ );+ }return new Response(JSON.stringify({ status: "success", message: "Notification sent" }),diff --git a/Releases/v3.0/.claude/hooks/SecurityValidator.hook.ts b/Releases/v3.0/.claude/hooks/SecurityValidator.hook.tsindex 348f33b9..f4a17caf 100755--- a/Releases/v3.0/.claude/hooks/SecurityValidator.hook.ts+++ b/Releases/v3.0/.claude/hooks/SecurityValidator.hook.ts@@ -236,6 +236,25 @@ function loadPatterns(): PatternsConfig {}}+// ========================================+// Command Normalization+// ========================================++/**+ * Strip leading environment variable assignments from a command.+ * Prevents bypass like: LANG=C rm -rf / or FOO="bar" dangerous-cmd+ * Also strips leading whitespace.+ */+function stripEnvVarPrefix(command: string): string {+ // Pattern: optional whitespace, then one or more VAR=value assignments+ // VAR names: [A-Z_][A-Z0-9_]* (standard env var naming)+ // Values: quoted ("..." or '...') or unquoted non-space sequences+ return command.replace(+ /^\s*(?:[A-Za-z_][A-Za-z0-9_]*=(?:"[^"]*"|'[^']*'|[^\s]*)\s+)*/,+ ''+ );+}+// ========================================// Pattern Matching// ========================================@@ -369,15 +388,17 @@ function validatePath(filePath: string, action: PathAction): { action: 'allow' |// ========================================function handleBash(input: HookInput): void {- const command = typeof input.tool_input === 'string'+ const rawCommand = typeof input.tool_input === 'string'? input.tool_input: (input.tool_input?.command as string) || '';- if (!command) {+ if (!rawCommand) {console.log(JSON.stringify({ continue: true }));return;}+ // Normalize: strip env var prefixes to prevent bypass (e.g., LANG=C rm -rf /)+ const command = stripEnvVarPrefix(rawCommand);const result = validateBashCommand(command);switch (result.action) {@@ -579,20 +600,37 @@ async function main(): Promise<void> {let input: HookInput;try {- // Fast stdin read with timeout- const text = await Promise.race([- Bun.stdin.text(),- new Promise<string>((_, reject) =>- setTimeout(() => reject(new Error('timeout')), 100)- )- ]);-- if (!text.trim()) {+ // Streaming stdin read with hard timeout.+ // Bun.stdin.text() can hang forever if stdin never closes (known Bun issue).+ // Use streaming reader + setTimeout that forces process.exit on timeout.+ const reader = Bun.stdin.stream().getReader();+ let raw = '';+ const readLoop = (async () => {+ while (true) {+ const { done, value } = await reader.read();+ if (done) break;+ raw += new TextDecoder().decode(value, { stream: true });+ }+ })();++ // Hard timeout: if stdin doesn't close in 200ms, exit the process.+ // setTimeout keeps the event loop alive, so we use process.exit to force cleanup.+ const timeout = setTimeout(() => {+ if (!raw.trim()) {+ console.log(JSON.stringify({ continue: true }));+ process.exit(0);+ }+ }, 200);++ await Promise.race([readLoop, new Promise<void>(r => setTimeout(r, 200))]);+ clearTimeout(timeout);++ if (!raw.trim()) {console.log(JSON.stringify({ continue: true }));return;}- input = JSON.parse(text);+ input = JSON.parse(raw);} catch {// Parse error or timeout - fail openconsole.log(JSON.stringify({ continue: true }));diff --git a/Releases/v3.0/.claude/hooks/VoiceGate.hook.ts b/Releases/v3.0/.claude/hooks/VoiceGate.hook.tsindex 26eae711..7832149f 100755--- a/Releases/v3.0/.claude/hooks/VoiceGate.hook.ts+++ b/Releases/v3.0/.claude/hooks/VoiceGate.hook.ts@@ -35,9 +35,20 @@ interface HookInput {}function isMainSession(sessionId: string): boolean {+ // Terminal detection: if we're in a recognized terminal, this is a main session.+ // Subagents spawned by Task tool don't inherit terminal environment variables,+ // so their absence indicates a subagent context.+ const termProgram = process.env.TERM_PROGRAM;+ if (termProgram === 'iTerm.app' || termProgram === 'WarpTerminal' ||+ termProgram === 'Alacritty' || termProgram === 'Apple_Terminal' ||+ process.env.ITERM_SESSION_ID) {+ return true; // Running in a recognized terminal → main session+ }++ // Kitty detection via session files (backward-compatible)const paiDir = process.env.PAI_DIR || join(homedir(), '.claude');const kittySessionsDir = join(paiDir, 'MEMORY', 'STATE', 'kitty-sessions');- if (!existsSync(kittySessionsDir)) return true; // Non-Kitty terminal: allow all sessions+ if (!existsSync(kittySessionsDir)) return true; // No session tracking dir → allowreturn existsSync(join(kittySessionsDir, `${sessionId}.json`));}diff --git a/Releases/v3.0/.claude/skills/PAI/Tools/SessionHarvester.ts b/Releases/v3.0/.claude/skills/PAI/Tools/SessionHarvester.tsindex 11de80ab..7ff06d56 100755--- a/Releases/v3.0/.claude/skills/PAI/Tools/SessionHarvester.ts+++ b/Releases/v3.0/.claude/skills/PAI/Tools/SessionHarvester.ts@@ -26,8 +26,11 @@ import { getLearningCategory, isLearningCapture } from "../../../hooks/lib/learn// ============================================================================const CLAUDE_DIR = path.join(process.env.HOME!, ".claude");-const USERNAME = process.env.USER || require("os").userInfo().username;-const PROJECTS_DIR = path.join(CLAUDE_DIR, "projects", `-Users-${USERNAME}--claude`);+// Derive the project slug dynamically from CLAUDE_DIR (works on macOS and Linux)+// macOS: /Users/daniel/.claude → -Users-daniel--claude+// Linux: /home/daniel/.claude → -home-daniel--claude+const CWD_SLUG = CLAUDE_DIR.replace(/[\/\.]/g, "-");+const PROJECTS_DIR = path.join(CLAUDE_DIR, "projects", CWD_SLUG);const LEARNING_DIR = path.join(CLAUDE_DIR, "MEMORY", "LEARNING");// Patterns indicating learning moments in conversations