Skip to content

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

feat(wizard): add --update flag for non-destructive updates

Daniel Miessler7d3378e32b6e
diff --git a/Bundles/Kai/README.md b/Bundles/Kai/README.md
index bdf4fc32..1be872ba 100644
--- a/Bundles/Kai/README.md
+++ b/Bundles/Kai/README.md
@@ -71,10 +71,15 @@ AI agents systematically create "simplified" versions of pack implementations. I
## Quick Start
```bash
-# Run the installation wizard
+# Fresh install (with backup)
bun run install.ts
+
+# Update existing installation (preserves config)
+bun run install.ts --update
```
+### Fresh Install
+
The wizard will:
1. **Detect existing AI systems** - Scans for Claude Code, Cursor, Windsurf, Cline, Aider, Continue
2. **Show you what it found** and explain what will be backed up
@@ -86,6 +91,21 @@ The wizard will:
**Safety First:** The installer will not modify anything until you explicitly confirm. Your original files are always preserved in the backup.
+### Update Mode
+
+After pulling new changes from the repo, use `--update` to apply them without losing your configuration:
+
+```bash
+git pull
+bun run install.ts --update
+```
+
+Update mode will:
+- **Skip backup** - Your files stay in place
+- **Read existing config** - Uses your .env values as defaults
+- **Preserve customizations** - Hooks, history, and personal settings untouched
+- **Update infrastructure** - Only refreshes core skill files
+
---
## What This Bundle Provides
diff --git a/Bundles/Kai/install.ts b/Bundles/Kai/install.ts
index 0546dd9f..0db20bb3 100644
--- a/Bundles/Kai/install.ts
+++ b/Bundles/Kai/install.ts
@@ -1,17 +1,25 @@
#!/usr/bin/env bun
/**
- * Kai Bundle Installation Wizard v1.2.0
+ * Kai Bundle Installation Wizard v1.3.0
*
* Simplified interactive CLI wizard for setting up the Kai bundle.
* Auto-detects AI system directories and creates safety backups.
*
- * Usage: bun run install.ts
+ * Usage:
+ * bun run install.ts # Fresh install with backup
+ * bun run install.ts --update # Update existing installation (no backup, preserves config)
*/
import { $ } from "bun";
import * as readline from "readline";
import { existsSync } from "fs";
+// =============================================================================
+// UPDATE MODE DETECTION
+// =============================================================================
+
+const isUpdateMode = process.argv.includes("--update") || process.argv.includes("-u");
+
// =============================================================================
// TYPES
// =============================================================================
@@ -65,6 +73,70 @@ function printHeader(title: string) {
console.log("=".repeat(60) + "\n");
}
+// =============================================================================
+// EXISTING CONFIG DETECTION
+// =============================================================================
+
+interface ExistingConfig {
+ daName?: string;
+ timeZone?: string;
+ userName?: string;
+ elevenLabsApiKey?: string;
+ elevenLabsVoiceId?: string;
+}
+
+async function readExistingConfig(): Promise<ExistingConfig> {
+ const claudeDir = `${process.env.HOME}/.claude`;
+ const config: ExistingConfig = {};
+
+ // Try to read from .env file
+ try {
+ const envPath = `${claudeDir}/.env`;
+ if (existsSync(envPath)) {
+ const envContent = await Bun.file(envPath).text();
+ const lines = envContent.split("\n");
+ for (const line of lines) {
+ const match = line.match(/^([A-Z_]+)=(.*)$/);
+ if (match) {
+ const [, key, value] = match;
+ switch (key) {
+ case "DA":
+ config.daName = value;
+ break;
+ case "TIME_ZONE":
+ config.timeZone = value;
+ break;
+ case "ELEVENLABS_API_KEY":
+ config.elevenLabsApiKey = value;
+ break;
+ case "ELEVENLABS_VOICE_ID":
+ config.elevenLabsVoiceId = value;
+ break;
+ }
+ }
+ }
+ }
+ } catch {
+ // No .env file, continue with empty config
+ }
+
+ // Try to read userName from SKILL.md
+ try {
+ const skillPath = `${claudeDir}/skills/CORE/SKILL.md`;
+ if (existsSync(skillPath)) {
+ const skillContent = await Bun.file(skillPath).text();
+ const userMatch = skillContent.match(/Role:\s*(\w+)'s AI assistant/);
+ if (userMatch) {
+ config.userName = userMatch[1];
+ }
+ }
+ } catch {
+ // No SKILL.md, continue
+ }
+
+ return config;
+}
+
// =============================================================================
// AI SYSTEM DETECTION
// =============================================================================
@@ -101,6 +173,22 @@ async function detectAndBackup(): Promise<boolean> {
const claudeDir = `${process.env.HOME}/.claude`;
const backupDir = `${process.env.HOME}/.claude-BACKUP`;
+ // In update mode, skip backup entirely
+ if (isUpdateMode) {
+ if (!existsSync(claudeDir)) {
+ console.log("❌ Update mode requires an existing installation.");
+ console.log(" Run without --update for a fresh install.\n");
+ return false;
+ }
+ console.log("📦 Update mode: Preserving existing configuration.\n");
+ console.log(" ✓ Skipping backup (your files stay in place)");
+ console.log(" ✓ Will use existing .env values as defaults");
+ console.log(" ✓ Only updating infrastructure files\n");
+
+ const proceed = await askYesNo("Proceed with update?", true);
+ return proceed;
+ }
+
console.log("Scanning for existing AI system directories...\n");
// Show detection results
@@ -184,11 +272,36 @@ async function detectAndBackup(): Promise<boolean> {
async function gatherConfig(): Promise<WizardConfig> {
printHeader("KAI BUNDLE SETUP");
- console.log("This wizard will configure your AI assistant.\n");
+ // In update mode, read existing config first
+ const existing = isUpdateMode ? await readExistingConfig() : {};
+
+ if (isUpdateMode) {
+ console.log("Update mode: Using existing configuration as defaults.\n");
+ if (existing.daName) console.log(` Found AI name: ${existing.daName}`);
+ if (existing.userName) console.log(` Found user: ${existing.userName}`);
+ if (existing.timeZone) console.log(` Found timezone: ${existing.timeZone}`);
+ if (existing.elevenLabsApiKey) console.log(` Found ElevenLabs API key: ****${existing.elevenLabsApiKey.slice(-4)}`);
+ console.log();
+
+ // In update mode, just confirm existing values
+ const keepExisting = await askYesNo("Keep existing configuration?", true);
+ if (keepExisting && existing.daName && existing.userName && existing.timeZone) {
+ return {
+ daName: existing.daName,
+ timeZone: existing.timeZone,
+ userName: existing.userName,
+ elevenLabsApiKey: existing.elevenLabsApiKey,
+ elevenLabsVoiceId: existing.elevenLabsVoiceId,
+ };
+ }
+ console.log("\nLet's update your configuration:\n");
+ } else {
+ console.log("This wizard will configure your AI assistant.\n");
+ }
// Check for existing PAI_DIR environment variable
const existingPaiDir = process.env.PAI_DIR;
- if (existingPaiDir) {
+ if (existingPaiDir && !isUpdateMode) {
console.log(`📍 Existing PAI_DIR detected: ${existingPaiDir}\n`);
const useExisting = await askYesNo(
`Use existing PAI_DIR (${existingPaiDir}) for installation?`,
@@ -200,34 +313,45 @@ async function gatherConfig(): Promise<WizardConfig> {
console.log("\n⚠️ Installation will use ~/.claude (standard Claude Code location)");
console.log(" You may need to update your PAI_DIR environment variable after installation.\n");
}
- } else {
+ } else if (!isUpdateMode) {
console.log("Installation directory: ~/.claude (standard Claude Code location)\n");
}
- // Essential questions only
- const userName = await ask("What is your name? ");
+ // Essential questions - use existing values as defaults in update mode
+ const userName = existing.userName
+ ? await askWithDefault("What is your name?", existing.userName)
+ : await ask("What is your name? ");
const daName = await askWithDefault(
"What would you like to name your AI assistant?",
- "Kai"
+ existing.daName || "Kai"
);
const timeZone = await askWithDefault(
"What's your timezone?",
- Intl.DateTimeFormat().resolvedOptions().timeZone
+ existing.timeZone || Intl.DateTimeFormat().resolvedOptions().timeZone
);
- // Voice is optional
- const wantsVoice = await askYesNo("\nDo you want voice notifications? (requires ElevenLabs API key)", false);
+ // Voice - in update mode, default to yes if already configured
+ const defaultWantsVoice = !!existing.elevenLabsApiKey;
+ const wantsVoice = await askYesNo(
+ "\nDo you want voice notifications? (requires ElevenLabs API key)",
+ defaultWantsVoice
+ );
let elevenLabsApiKey: string | undefined;
let elevenLabsVoiceId: string | undefined;
if (wantsVoice) {
- elevenLabsApiKey = await ask("Enter your ElevenLabs API key: ");
+ if (existing.elevenLabsApiKey) {
+ const keepKey = await askYesNo(`Keep existing ElevenLabs API key (****${existing.elevenLabsApiKey.slice(-4)})?`, true);
+ elevenLabsApiKey = keepKey ? existing.elevenLabsApiKey : await ask("Enter your ElevenLabs API key: ");
+ } else {
+ elevenLabsApiKey = await ask("Enter your ElevenLabs API key: ");
+ }
elevenLabsVoiceId = await askWithDefault(
"Enter your preferred voice ID",
- "s3TPKV1kjDlVtZbl4Ksh"
+ existing.elevenLabsVoiceId || "s3TPKV1kjDlVtZbl4Ksh"
);
}
@@ -407,6 +531,7 @@ Generated: ${new Date().toISOString().split("T")[0]}
// =============================================================================
async function main() {
+ const modeLabel = isUpdateMode ? "UPDATE MODE" : "v1.3.0";
console.log(`
╔═══════════════════════════════════════════════════════════════════╗
║ ║
@@ -417,7 +542,7 @@ async function main() {
║ ██║ ██╗██║ ██║██║ ██████╔╝╚██████╔╝██║ ╚████║██████╔╝███████╗
║ ╚═╝ ╚═╝╚═╝ ╚═╝╚═╝ ╚═════╝ ╚═════╝ ╚═╝ ╚═══╝╚═════╝ ╚══════╝
║ ║
-║ Personal AI Infrastructure - v1.2.0 ║
+║ Personal AI Infrastructure - ${modeLabel.padEnd(12)} ║
║ ║
╚═══════════════════════════════════════════════════════════════════╝
`);
@@ -553,9 +678,34 @@ ${config.elevenLabsVoiceId ? `export ELEVENLABS_VOICE_ID="${config.elevenLabsVoi
}
// Summary
- printHeader("INSTALLATION COMPLETE");
+ printHeader(isUpdateMode ? "UPDATE COMPLETE" : "INSTALLATION COMPLETE");
+
+ if (isUpdateMode) {
+ console.log(`
+Your Kai system has been updated:
+
+ 📁 Installation: ~/.claude
+ 🤖 Assistant Name: ${config.daName}
+ 👤 User: ${config.userName}
+ 🌍 Timezone: ${config.timeZone}
+ 🔊 Voice: ${config.elevenLabsApiKey ? "Enabled" : "Disabled"}
+
+Files updated:
+ - ~/.claude/skills/CORE/SKILL.md
+ - ~/.claude/skills/CORE/Contacts.md
+ - ~/.claude/skills/CORE/CoreStack.md
+ - ~/.claude/.env
+ - ~/.claude/settings.json
+
+Next steps:
+
+ 1. Re-install any packs that have been updated (check changelog)
+ 2. Restart Claude Code to activate changes
- console.log(`
+Your existing hooks, history, and customizations have been preserved.
+`);
+ } else {
+ console.log(`
Your Kai system is configured:
📁 Installation: ~/.claude
@@ -584,6 +734,7 @@ Next steps:
Your backup is at ~/.claude-BACKUP if you need to restore.
`);
+ }
} catch (error) {
console.error("\n❌ Installation failed:", error);