Skip to content

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

feat: Standardize all pack INSTALL.md to AI wizard format

Daniel Miesslerc51d7e9b8ae3
diff --git a/Packs/pai-agents-skill/INSTALL.md b/Packs/pai-agents-skill/INSTALL.md
index 2f18a3cf..280a469e 100644
--- a/Packs/pai-agents-skill/INSTALL.md
+++ b/Packs/pai-agents-skill/INSTALL.md
@@ -1,127 +1,392 @@
-# Installation Guide - Kai Agents Skill
+# PAI Agents Skill v1.0.0 - Installation Guide
-## Prerequisites
+**This guide is designed for AI agents installing this pack into a user's infrastructure.**
-- **Bun runtime**: `curl -fsSL https://bun.sh/install | bash`
-- **Claude Code** (or compatible agent system)
-- **pai-core-install** pack installed (provides skill routing)
-- **Optional**: pai-voice-system pack for voice notifications
+---
+
+## AI Agent Instructions
+
+**This is a wizard-style installation.** Use Claude Code's native tools to guide the user through installation:
+
+1. **AskUserQuestion** - For user decisions and confirmations
+2. **TodoWrite** - For progress tracking
+3. **Bash/Read/Write** - For actual installation
+4. **VERIFY.md** - For final validation
-## Pre-Installation: System Analysis
+### Welcome Message
+
+Before starting, greet the user:
+```
+"I'm installing PAI Agents Skill v1.0.0 - Dynamic agent composition and personality system.
+
+Let me analyze your system and guide you through installation."
+```
+
+---
+
+## Phase 1: System Analysis
+
+**Execute this analysis BEFORE any file operations.**
+
+### 1.1 Run These Commands
```bash
-# 1. Check PAI_DIR
-echo "PAI_DIR: ${PAI_DIR:-'NOT SET - will use ~/.config/pai'}"
+# Check for PAI directory
+PAI_CHECK="${PAI_DIR:-$HOME/.claude}"
+echo "PAI_DIR: $PAI_CHECK"
+
+# Check if pai-core-install is installed (REQUIRED)
+if [ -f "$PAI_CHECK/skills/CORE/SKILL.md" ]; then
+ echo "✓ pai-core-install is installed"
+else
+ echo "❌ pai-core-install NOT installed - REQUIRED!"
+fi
-# 2. Check for existing Agents skill
-PAI_CHECK="${PAI_DIR:-$HOME/.config/pai}"
+# Check for existing Agents skill
if [ -d "$PAI_CHECK/skills/Agents" ]; then
- echo "Warning: Agents skill already exists"
- ls -la "$PAI_CHECK/skills/Agents"
+ echo "⚠️ Existing Agents skill found at: $PAI_CHECK/skills/Agents"
+ ls -la "$PAI_CHECK/skills/Agents/"
else
- echo "Clean install - no existing Agents skill"
+ echo "✓ No existing Agents skill (clean install)"
fi
-# 3. Check dependencies
-if [ -f "$PAI_CHECK/skills/CORE/SKILL.md" ]; then
- echo "pai-core-install: INSTALLED"
+# Check for Bun runtime
+if command -v bun &> /dev/null; then
+ echo "✓ Bun is installed: $(bun --version)"
+else
+ echo "❌ Bun not installed - REQUIRED!"
+fi
+
+# Check for pai-voice-system (optional)
+if [ -d "$PAI_CHECK/VoiceServer" ]; then
+ echo "✓ pai-voice-system is installed (voice features available)"
else
- echo "Warning: pai-core-install not found (required)"
+ echo "⚠️ pai-voice-system not installed (voice features unavailable)"
fi
```
+### 1.2 Present Findings
+
+Tell the user what you found:
+```
+"Here's what I found on your system:
+- pai-core-install: [installed / NOT INSTALLED - REQUIRED]
+- Existing Agents skill: [Yes at path / No]
+- Bun runtime: [installed vX.X / NOT INSTALLED - REQUIRED]
+- pai-voice-system: [installed / not installed (optional)]"
+```
+
+**STOP if pai-core-install or Bun is not installed.** Tell the user:
+```
+"pai-core-install and Bun are required. Please install them first, then return to install this pack."
+```
+
+---
+
+## Phase 2: User Questions
+
+**Use AskUserQuestion tool at each decision point.**
+
+### Question 1: Conflict Resolution (if existing found)
+
+**Only ask if existing Agents skill detected:**
+
+```json
+{
+ "header": "Conflict",
+ "question": "Existing Agents skill detected. How should I proceed?",
+ "multiSelect": false,
+ "options": [
+ {"label": "Backup and Replace (Recommended)", "description": "Creates timestamped backup, then installs new version"},
+ {"label": "Replace Without Backup", "description": "Overwrites existing without backup"},
+ {"label": "Abort Installation", "description": "Cancel installation, keep existing"}
+ ]
+}
+```
+
+### Question 2: Voice Integration
+
+**Only ask if pai-voice-system is installed:**
+
+```json
+{
+ "header": "Voice",
+ "question": "Configure voice personalities for agents?",
+ "multiSelect": false,
+ "options": [
+ {"label": "Yes, set up voices (Recommended)", "description": "Creates voice ID mappings in Traits.yaml"},
+ {"label": "Skip for now", "description": "You can configure voice IDs later manually"}
+ ]
+}
+```
+
+### Question 3: Final Confirmation
+
+```json
+{
+ "header": "Install",
+ "question": "Ready to install PAI Agents Skill v1.0.0?",
+ "multiSelect": false,
+ "options": [
+ {"label": "Yes, install now (Recommended)", "description": "Proceeds with installation using choices above"},
+ {"label": "Show me what will change", "description": "Lists all files that will be created/modified"},
+ {"label": "Cancel", "description": "Abort installation"}
+ ]
+}
+```
+
---
-## Installation Steps
+## Phase 3: Backup (If Needed)
-### Step 1: Create Directory Structure
+**Only execute if user chose "Backup and Replace":**
```bash
-PAI_DIR="${PAI_DIR:-$HOME/.config/pai}"
+PAI_DIR="${PAI_DIR:-$HOME/.claude}"
+BACKUP_DIR="$PAI_DIR/Backups/agents-skill-$(date +%Y%m%d-%H%M%S)"
+mkdir -p "$BACKUP_DIR"
+[ -d "$PAI_DIR/skills/Agents" ] && cp -r "$PAI_DIR/skills/Agents" "$BACKUP_DIR/"
+echo "Backup created at: $BACKUP_DIR"
+```
+
+---
+## Phase 4: Installation
+
+**Create a TodoWrite list to track progress:**
+
+```json
+{
+ "todos": [
+ {"content": "Create skill directory structure", "status": "pending", "activeForm": "Creating directory structure"},
+ {"content": "Copy skill files from pack", "status": "pending", "activeForm": "Copying skill files"},
+ {"content": "Install dependencies", "status": "pending", "activeForm": "Installing dependencies"},
+ {"content": "Configure voice IDs", "status": "pending", "activeForm": "Configuring voice IDs"},
+ {"content": "Run verification", "status": "pending", "activeForm": "Running verification"}
+ ]
+}
+```
+
+### 4.1 Create Skill Directory Structure
+
+**Mark todo "Create skill directory structure" as in_progress.**
+
+```bash
+PAI_DIR="${PAI_DIR:-$HOME/.claude}"
mkdir -p "$PAI_DIR/skills/Agents/Data"
mkdir -p "$PAI_DIR/skills/Agents/Tools"
mkdir -p "$PAI_DIR/skills/Agents/Templates"
mkdir -p "$PAI_DIR/skills/Agents/Workflows"
mkdir -p "$PAI_DIR/skills/Agents/Contexts"
-
-ls -la "$PAI_DIR/skills/Agents/"
```
-### Step 2: Copy Skill Files
+**Mark todo as completed.**
-Copy from this pack's `src/` directory to your PAI installation:
+### 4.2 Copy Skill Files
-| Source | Destination |
-|--------|-------------|
-| `src/skills/Agents/SKILL.md` | `$PAI_DIR/skills/Agents/SKILL.md` |
-| `src/skills/Agents/Data/Traits.yaml` | `$PAI_DIR/skills/Agents/Data/Traits.yaml` |
-| `src/skills/Agents/Tools/AgentFactory.ts` | `$PAI_DIR/skills/Agents/Tools/AgentFactory.ts` |
-| `src/skills/Agents/Templates/DynamicAgent.hbs` | `$PAI_DIR/skills/Agents/Templates/DynamicAgent.hbs` |
-| `src/skills/Agents/Workflows/CreateCustomAgent.md` | `$PAI_DIR/skills/Agents/Workflows/CreateCustomAgent.md` |
-| `src/skills/Agents/Workflows/ListTraits.md` | `$PAI_DIR/skills/Agents/Workflows/ListTraits.md` |
-| `src/skills/Agents/AgentPersonalities.md` | `$PAI_DIR/skills/Agents/AgentPersonalities.md` |
+**Mark todo "Copy skill files from pack" as in_progress.**
+
+Copy all files from the pack's `src/skills/Agents/` directory:
```bash
-PAI_DIR="${PAI_DIR:-$HOME/.config/pai}"
-PACK_DIR="[PATH_TO_THIS_PACK]"
+# From the pack directory (where this INSTALL.md is located)
+PACK_DIR="$(pwd)"
+PAI_DIR="${PAI_DIR:-$HOME/.claude}"
cp "$PACK_DIR/src/skills/Agents/SKILL.md" "$PAI_DIR/skills/Agents/"
+cp "$PACK_DIR/src/skills/Agents/AgentPersonalities.md" "$PAI_DIR/skills/Agents/"
cp "$PACK_DIR/src/skills/Agents/Data/Traits.yaml" "$PAI_DIR/skills/Agents/Data/"
cp "$PACK_DIR/src/skills/Agents/Tools/AgentFactory.ts" "$PAI_DIR/skills/Agents/Tools/"
cp "$PACK_DIR/src/skills/Agents/Templates/DynamicAgent.hbs" "$PAI_DIR/skills/Agents/Templates/"
-cp "$PACK_DIR/src/skills/Agents/Workflows/CreateCustomAgent.md" "$PAI_DIR/skills/Agents/Workflows/"
-cp "$PACK_DIR/src/skills/Agents/Workflows/ListTraits.md" "$PAI_DIR/skills/Agents/Workflows/"
-cp "$PACK_DIR/src/skills/Agents/AgentPersonalities.md" "$PAI_DIR/skills/Agents/"
+cp "$PACK_DIR/src/skills/Agents/Workflows/"*.md "$PAI_DIR/skills/Agents/Workflows/"
```
-### Step 3: Install Dependencies
+**Files copied:**
+- `SKILL.md` - Main skill routing
+- `AgentPersonalities.md` - 10+ pre-built agent personalities
+- `Data/Traits.yaml` - 30+ composable traits
+- `Tools/AgentFactory.ts` - Agent composition CLI
+- `Templates/DynamicAgent.hbs` - Agent prompt template
+- `Workflows/*.md` - CreateCustomAgent, ListTraits workflows
+
+**Mark todo as completed.**
+
+### 4.3 Install Dependencies
+
+**Mark todo "Install dependencies" as in_progress.**
```bash
+PAI_DIR="${PAI_DIR:-$HOME/.claude}"
cd "$PAI_DIR/skills/Agents/Tools"
bun add yaml handlebars
```
-### Step 4: Configure Voice IDs (Optional)
+**Mark todo as completed.**
-If using pai-voice-system, edit `Traits.yaml` to replace placeholder voice IDs:
+### 4.4 Configure Voice IDs (If User Chose Yes)
-```bash
-# Edit voice mappings with your TTS provider's voice IDs
-nano "$PAI_DIR/skills/Agents/Data/Traits.yaml"
+**Mark todo "Configure voice IDs" as in_progress.**
+
+**Only execute if user chose to set up voices:**
+
+The `Traits.yaml` file contains placeholder voice IDs. If the user has pai-voice-system installed, help them configure their ElevenLabs voice IDs.
+
+Tell the user:
+```
+"To enable voice for agents, you'll need to edit the voice mappings in Traits.yaml.
+Each agent trait can have a voice ID from your TTS provider (e.g., ElevenLabs).
+
+The file is at: $PAI_DIR/skills/Agents/Data/Traits.yaml
+Look for 'voice:' entries and replace 'YOUR_*_VOICE_ID' with actual IDs."
```
-Replace `YOUR_*_VOICE_ID` placeholders with actual voice IDs from your TTS provider.
+**Mark todo as completed (or skip if user declined).**
---
-## Verification
+## Phase 5: Verification
+
+**Mark todo "Run verification" as in_progress.**
+
+**Execute all checks from VERIFY.md:**
```bash
-PAI_DIR="${PAI_DIR:-$HOME/.config/pai}"
+PAI_DIR="${PAI_DIR:-$HOME/.claude}"
-echo "Checking installation..."
+echo "=== PAI Agents Skill Verification ==="
-[ -f "$PAI_DIR/skills/Agents/SKILL.md" ] && echo "[OK] SKILL.md" || echo "[MISSING] SKILL.md"
-[ -f "$PAI_DIR/skills/Agents/Data/Traits.yaml" ] && echo "[OK] Traits.yaml" || echo "[MISSING] Traits.yaml"
-[ -f "$PAI_DIR/skills/Agents/Tools/AgentFactory.ts" ] && echo "[OK] AgentFactory.ts" || echo "[MISSING] AgentFactory.ts"
-[ -f "$PAI_DIR/skills/Agents/Templates/DynamicAgent.hbs" ] && echo "[OK] DynamicAgent.hbs" || echo "[MISSING] DynamicAgent.hbs"
+# Check skill files exist
+echo "Checking skill files..."
+[ -f "$PAI_DIR/skills/Agents/SKILL.md" ] && echo "✓ SKILL.md" || echo "❌ SKILL.md missing"
+[ -f "$PAI_DIR/skills/Agents/Data/Traits.yaml" ] && echo "✓ Traits.yaml" || echo "❌ Traits.yaml missing"
+[ -f "$PAI_DIR/skills/Agents/Tools/AgentFactory.ts" ] && echo "✓ AgentFactory.ts" || echo "❌ AgentFactory.ts missing"
+[ -f "$PAI_DIR/skills/Agents/Templates/DynamicAgent.hbs" ] && echo "✓ DynamicAgent.hbs" || echo "❌ DynamicAgent.hbs missing"
+# Test AgentFactory
echo ""
echo "Testing AgentFactory..."
bun run "$PAI_DIR/skills/Agents/Tools/AgentFactory.ts" --list | head -20
+# Test trait composition
echo ""
echo "Testing trait composition..."
bun run "$PAI_DIR/skills/Agents/Tools/AgentFactory.ts" \
--traits "security,skeptical,thorough" \
--output summary
+
+echo "=== Verification Complete ==="
+```
+
+**Mark todo as completed when all checks pass.**
+
+---
+
+## Success/Failure Messages
+
+### On Success
+
+```
+"PAI Agents Skill v1.0.0 installed successfully!
+
+What's available:
+- 'create custom agents' - Compose agents from 30+ traits
+- 'spin up agents' / 'interns' - Launch parallel agents
+- 'list traits' - See all available personality traits
+- 'show agent personalities' - Pre-built agent configurations
+
+Try it: Ask me to 'create a skeptical security researcher agent'"
+```
+
+### On Failure
+
+```
+"Installation encountered issues. Here's what to check:
+
+1. Ensure pai-core-install is installed first
+2. Verify Bun is installed: `bun --version`
+3. Check directory permissions on $PAI_DIR/skills/
+4. Run the verification commands in VERIFY.md
+
+Need help? Check the Troubleshooting section below."
```
---
-## Environment Variables
+## Troubleshooting
+
+### "pai-core-install not found"
-| Variable | Required | Description |
-|----------|----------|-------------|
-| `PAI_DIR` | No | Custom PAI directory (default: `~/.config/pai`) |
+This pack requires pai-core-install. Install it first:
+```
+Give the AI the pai-core-install pack directory and ask it to install.
+```
+
+### "bun: command not found"
+
+```bash
+# Install Bun
+curl -fsSL https://bun.sh/install | bash
+# Restart terminal or source ~/.bashrc
+```
+
+### "AgentFactory.ts fails to run"
+
+```bash
+# Check dependencies are installed
+cd $PAI_DIR/skills/Agents/Tools
+bun install
+
+# Or reinstall
+bun add yaml handlebars
+```
+
+### Traits.yaml parsing errors
+
+```bash
+# Validate YAML syntax
+bun -e "const yaml = require('yaml'); yaml.parse(require('fs').readFileSync('$PAI_DIR/skills/Agents/Data/Traits.yaml', 'utf8'))"
+```
+
+---
+
+## What's Included
+
+| File | Purpose |
+|------|---------|
+| `SKILL.md` | Main skill definition with workflow routing |
+| `AgentPersonalities.md` | 10+ pre-built agent personalities |
+| `Data/Traits.yaml` | 30+ composable personality traits |
+| `Tools/AgentFactory.ts` | CLI for composing agents from traits |
+| `Templates/DynamicAgent.hbs` | Handlebars template for agent prompts |
+| `Workflows/CreateCustomAgent.md` | Agent creation workflow |
+| `Workflows/ListTraits.md` | Trait listing workflow |
+
+---
+
+## Usage
+
+### From Claude Code
+
+```
+"Create a skeptical security researcher agent"
+"Spin up 3 interns to research these companies"
+"List available agent traits"
+"Show me the agent personalities"
+```
+
+### CLI Examples
+
+```bash
+# List all traits
+bun run $PAI_DIR/skills/Agents/Tools/AgentFactory.ts --list
+
+# Create agent from traits
+bun run $PAI_DIR/skills/Agents/Tools/AgentFactory.ts \
+ --traits "security,skeptical,thorough" \
+ --output full
+
+# Show specific trait details
+bun run $PAI_DIR/skills/Agents/Tools/AgentFactory.ts \
+ --trait security \
+ --output details
+```
diff --git a/Packs/pai-algorithm-skill/INSTALL.md b/Packs/pai-algorithm-skill/INSTALL.md
index e65b84bc..bfa8e0b2 100644
--- a/Packs/pai-algorithm-skill/INSTALL.md
+++ b/Packs/pai-algorithm-skill/INSTALL.md
@@ -1,76 +1,204 @@
-# Installation Guide - THE ALGORITHM Skill
+# THE ALGORITHM Skill v0.5.0 - Installation Guide
-## Prerequisites
+**This guide is designed for AI agents installing this pack into a user's infrastructure.**
-- **Bun runtime**: `curl -fsSL https://bun.sh/install | bash`
-- **Claude Code** (or compatible agent system)
-- **pai-core-install** pack installed (provides skill routing and CORE context)
-- **pai-agents-skill** pack installed (provides AgentFactory for custom agents)
-- **Optional**: pai-voice-system pack for voice notifications during phase transitions
+---
+
+## AI Agent Instructions
+
+**This is a wizard-style installation.** Use Claude Code's native tools to guide the user through installation:
+
+1. **AskUserQuestion** - For user decisions and confirmations
+2. **TodoWrite** - For progress tracking
+3. **Bash/Read/Write** - For actual installation
+4. **VERIFY.md** - For final validation
+
+### Welcome Message
+
+Before starting, greet the user:
+```
+"I'm installing THE ALGORITHM Skill v0.5.0 - Universal execution engine using scientific method to achieve ideal state.
+
+Let me analyze your system and guide you through installation."
+```
-## Pre-Installation: System Analysis
+---
+
+## Phase 1: System Analysis
+
+**Execute this analysis BEFORE any file operations.**
+
+### 1.1 Run These Commands
```bash
-# 1. Check PAI_DIR
-echo "PAI_DIR: ${PAI_DIR:-'NOT SET - will use ~/.config/pai'}"
+# Check for PAI directory
+PAI_CHECK="${PAI_DIR:-$HOME/.claude}"
+echo "PAI_DIR: $PAI_CHECK"
-# 2. Check for existing THEALGORITHM skill
-PAI_CHECK="${PAI_DIR:-$HOME/.config/pai}"
+# Check if pai-core-install is installed (REQUIRED)
+if [ -f "$PAI_CHECK/skills/CORE/SKILL.md" ]; then
+ echo "✓ pai-core-install is installed"
+else
+ echo "❌ pai-core-install NOT installed - REQUIRED!"
+fi
+
+# Check if pai-agents-skill is installed (REQUIRED)
+if [ -f "$PAI_CHECK/skills/Agents/SKILL.md" ]; then
+ echo "✓ pai-agents-skill is installed"
+else
+ echo "❌ pai-agents-skill NOT installed - REQUIRED!"
+fi
+
+# Check for existing THEALGORITHM skill
if [ -d "$PAI_CHECK/skills/THEALGORITHM" ]; then
- echo "Warning: THEALGORITHM skill already exists"
- ls -la "$PAI_CHECK/skills/THEALGORITHM"
+ echo "⚠️ Existing THEALGORITHM skill found at: $PAI_CHECK/skills/THEALGORITHM"
+ ls -la "$PAI_CHECK/skills/THEALGORITHM/"
else
- echo "Clean install - no existing THEALGORITHM skill"
+ echo "✓ No existing THEALGORITHM skill (clean install)"
fi
-# 3. Check dependencies
-if [ -f "$PAI_CHECK/skills/CORE/SKILL.md" ]; then
- echo "pai-core-install: INSTALLED"
+# Check for Bun runtime
+if command -v bun &> /dev/null; then
+ echo "✓ Bun is installed: $(bun --version)"
else
- echo "Warning: pai-core-install not found (required)"
+ echo "❌ Bun not installed - REQUIRED!"
fi
-if [ -f "$PAI_CHECK/skills/Agents/SKILL.md" ]; then
- echo "pai-agents-skill: INSTALLED"
+# Check for pai-voice-system (optional)
+if [ -d "$PAI_CHECK/VoiceServer" ]; then
+ echo "✓ pai-voice-system is installed (voice features available)"
else
- echo "Warning: pai-agents-skill not found (required for custom agents)"
+ echo "⚠️ pai-voice-system not installed (voice transitions unavailable)"
fi
```
+### 1.2 Present Findings
+
+Tell the user what you found:
+```
+"Here's what I found on your system:
+- pai-core-install: [installed / NOT INSTALLED - REQUIRED]
+- pai-agents-skill: [installed / NOT INSTALLED - REQUIRED]
+- Existing THEALGORITHM skill: [Yes at path / No]
+- Bun runtime: [installed vX.X / NOT INSTALLED - REQUIRED]
+- pai-voice-system: [installed / not installed (optional)]"
+```
+
+**STOP if pai-core-install, pai-agents-skill, or Bun is not installed.** Tell the user:
+```
+"pai-core-install, pai-agents-skill, and Bun are required. Please install them first, then return to install this pack."
+```
+
---
-## Installation Steps
+## Phase 2: User Questions
+
+**Use AskUserQuestion tool at each decision point.**
+
+### Question 1: Conflict Resolution (if existing found)
+
+**Only ask if existing THEALGORITHM skill detected:**
+
+```json
+{
+ "header": "Conflict",
+ "question": "Existing THEALGORITHM skill detected. How should I proceed?",
+ "multiSelect": false,
+ "options": [
+ {"label": "Backup and Replace (Recommended)", "description": "Creates timestamped backup, then installs new version"},
+ {"label": "Replace Without Backup", "description": "Overwrites existing without backup"},
+ {"label": "Abort Installation", "description": "Cancel installation, keep existing"}
+ ]
+}
+```
-### Step 1: Create Directory Structure
+### Question 2: Voice Transitions
+
+**Only ask if pai-voice-system is installed:**
+
+```json
+{
+ "header": "Voice",
+ "question": "Enable voice announcements during phase transitions?",
+ "multiSelect": false,
+ "options": [
+ {"label": "Yes, enable voice (Recommended)", "description": "AlgorithmDisplay will speak phase changes"},
+ {"label": "Silent mode", "description": "Visual display only, no voice"}
+ ]
+}
+```
+
+### Question 3: Final Confirmation
+
+```json
+{
+ "header": "Install",
+ "question": "Ready to install THE ALGORITHM Skill v0.5.0?",
+ "multiSelect": false,
+ "options": [
+ {"label": "Yes, install now (Recommended)", "description": "Proceeds with installation using choices above"},
+ {"label": "Show me what will change", "description": "Lists all files that will be created/modified"},
+ {"label": "Cancel", "description": "Abort installation"}
+ ]
+}
+```
+
+---
+
+## Phase 3: Backup (If Needed)
+
+**Only execute if user chose "Backup and Replace":**
```bash
-PAI_DIR="${PAI_DIR:-$HOME/.config/pai}"
+PAI_DIR="${PAI_DIR:-$HOME/.claude}"
+BACKUP_DIR="$PAI_DIR/Backups/thealgorithm-skill-$(date +%Y%m%d-%H%M%S)"
+mkdir -p "$BACKUP_DIR"
+[ -d "$PAI_DIR/skills/THEALGORITHM" ] && cp -r "$PAI_DIR/skills/THEALGORITHM" "$BACKUP_DIR/"
+echo "Backup created at: $BACKUP_DIR"
+```
+
+---
+
+## Phase 4: Installation
+
+**Create a TodoWrite list to track progress:**
+
+```json
+{
+ "todos": [
+ {"content": "Create skill directory structure", "status": "pending", "activeForm": "Creating directory structure"},
+ {"content": "Copy skill files from pack", "status": "pending", "activeForm": "Copying skill files"},
+ {"content": "Install dependencies", "status": "pending", "activeForm": "Installing dependencies"},
+ {"content": "Create MEMORY directories", "status": "pending", "activeForm": "Creating MEMORY directories"},
+ {"content": "Run verification", "status": "pending", "activeForm": "Running verification"}
+ ]
+}
+```
+
+### 4.1 Create Skill Directory Structure
+**Mark todo "Create skill directory structure" as in_progress.**
+
+```bash
+PAI_DIR="${PAI_DIR:-$HOME/.claude}"
mkdir -p "$PAI_DIR/skills/THEALGORITHM/Tools"
mkdir -p "$PAI_DIR/skills/THEALGORITHM/Data"
mkdir -p "$PAI_DIR/skills/THEALGORITHM/Phases"
mkdir -p "$PAI_DIR/skills/THEALGORITHM/Reference"
-mkdir -p "$PAI_DIR/MEMORY/Work"
-mkdir -p "$PAI_DIR/MEMORY/State"
-
-ls -la "$PAI_DIR/skills/THEALGORITHM/"
```
-### Step 2: Copy Skill Files
+**Mark todo as completed.**
-Copy from this pack's `src/` directory to your PAI installation:
+### 4.2 Copy Skill Files
-| Source | Destination |
-|--------|-------------|
-| `src/skills/THEALGORITHM/SKILL.md` | `$PAI_DIR/skills/THEALGORITHM/SKILL.md` |
-| `src/skills/THEALGORITHM/Data/Capabilities.yaml` | `$PAI_DIR/skills/THEALGORITHM/Data/Capabilities.yaml` |
-| `src/skills/THEALGORITHM/Tools/*.ts` | `$PAI_DIR/skills/THEALGORITHM/Tools/` |
-| `src/skills/THEALGORITHM/Phases/*.md` | `$PAI_DIR/skills/THEALGORITHM/Phases/` |
-| `src/skills/THEALGORITHM/Reference/*.md` | `$PAI_DIR/skills/THEALGORITHM/Reference/` |
+**Mark todo "Copy skill files from pack" as in_progress.**
+
+Copy all files from the pack's `src/skills/THEALGORITHM/` directory:
```bash
-PAI_DIR="${PAI_DIR:-$HOME/.config/pai}"
-PACK_DIR="[PATH_TO_THIS_PACK]"
+# From the pack directory (where this INSTALL.md is located)
+PACK_DIR="$(pwd)"
+PAI_DIR="${PAI_DIR:-$HOME/.claude}"
# Copy main skill file
cp "$PACK_DIR/src/skills/THEALGORITHM/SKILL.md" "$PAI_DIR/skills/THEALGORITHM/"
@@ -88,69 +216,235 @@ cp "$PACK_DIR/src/skills/THEALGORITHM/Phases/"*.md "$PAI_DIR/skills/THEALGORITHM
cp "$PACK_DIR/src/skills/THEALGORITHM/Reference/"*.md "$PAI_DIR/skills/THEALGORITHM/Reference/"
```
-### Step 3: Install Dependencies
+**Files copied:**
+- `SKILL.md` - Main skill routing and quick reference
+- `Data/Capabilities.yaml` - 30+ orchestratable capabilities registry
+- `Tools/AlgorithmDisplay.ts` - LCARS-style visual display with voice
+- `Tools/EffortClassifier.ts` - Request effort level classification
+- `Tools/CapabilityLoader.ts` - Load capabilities by effort level
+- `Tools/CapabilitySelector.ts` - Select capabilities for ISC rows
+- `Tools/ISCManager.ts` - Create/update/query ISC tables
+- `Tools/TraitModifiers.ts` - Effort-to-trait mappings
+- `Tools/RalphLoopExecutor.ts` - Persistent iteration executor
+- `Phases/*.md` - Detailed phase documentation (OBSERVE through LEARN)
+- `Reference/*.md` - Capability and effort matrices
+
+**Mark todo as completed.**
+
+### 4.3 Install Dependencies
+
+**Mark todo "Install dependencies" as in_progress.**
```bash
+PAI_DIR="${PAI_DIR:-$HOME/.claude}"
cd "$PAI_DIR/skills/THEALGORITHM/Tools"
bun add yaml
```
-### Step 4: Update Path References
+**Mark todo as completed.**
-The tools use `$PAI_DIR` environment variable or default to `~/.config/pai`. If your PAI installation is elsewhere, set the environment variable:
+### 4.4 Create MEMORY Directories
+
+**Mark todo "Create MEMORY directories" as in_progress.**
```bash
-# Add to your shell profile (.zshrc, .bashrc, etc.)
-export PAI_DIR="$HOME/.config/pai"
+PAI_DIR="${PAI_DIR:-$HOME/.claude}"
+mkdir -p "$PAI_DIR/MEMORY/Work"
+mkdir -p "$PAI_DIR/MEMORY/State"
```
-### Step 5: Register Skill (Optional)
-
-If using the skill index system, regenerate the skill index:
+These directories store ISC state between sessions.
-```bash
-bun run "$PAI_DIR/Tools/GenerateSkillIndex.ts"
-```
+**Mark todo as completed.**
---
-## Verification
+## Phase 5: Verification
+
+**Mark todo "Run verification" as in_progress.**
+
+**Execute all checks from VERIFY.md:**
```bash
-PAI_DIR="${PAI_DIR:-$HOME/.config/pai}"
+PAI_DIR="${PAI_DIR:-$HOME/.claude}"
-echo "Checking installation..."
+echo "=== THE ALGORITHM Skill Verification ==="
-[ -f "$PAI_DIR/skills/THEALGORITHM/SKILL.md" ] && echo "[OK] SKILL.md" || echo "[MISSING] SKILL.md"
-[ -f "$PAI_DIR/skills/THEALGORITHM/Data/Capabilities.yaml" ] && echo "[OK] Capabilities.yaml" || echo "[MISSING] Capabilities.yaml"
-[ -f "$PAI_DIR/skills/THEALGORITHM/Tools/EffortClassifier.ts" ] && echo "[OK] EffortClassifier.ts" || echo "[MISSING] EffortClassifier.ts"
-[ -f "$PAI_DIR/skills/THEALGORITHM/Tools/ISCManager.ts" ] && echo "[OK] ISCManager.ts" || echo "[MISSING] ISCManager.ts"
-[ -f "$PAI_DIR/skills/THEALGORITHM/Tools/AlgorithmDisplay.ts" ] && echo "[OK] AlgorithmDisplay.ts" || echo "[MISSING] AlgorithmDisplay.ts"
+# Check skill files exist
+echo "Checking skill files..."
+[ -f "$PAI_DIR/skills/THEALGORITHM/SKILL.md" ] && echo "✓ SKILL.md" || echo "❌ SKILL.md missing"
+[ -f "$PAI_DIR/skills/THEALGORITHM/Data/Capabilities.yaml" ] && echo "✓ Capabilities.yaml" || echo "❌ Capabilities.yaml missing"
+[ -f "$PAI_DIR/skills/THEALGORITHM/Tools/EffortClassifier.ts" ] && echo "✓ EffortClassifier.ts" || echo "❌ EffortClassifier.ts missing"
+[ -f "$PAI_DIR/skills/THEALGORITHM/Tools/ISCManager.ts" ] && echo "✓ ISCManager.ts" || echo "❌ ISCManager.ts missing"
+[ -f "$PAI_DIR/skills/THEALGORITHM/Tools/AlgorithmDisplay.ts" ] && echo "✓ AlgorithmDisplay.ts" || echo "❌ AlgorithmDisplay.ts missing"
+# Check MEMORY directories
+echo ""
+echo "Checking MEMORY directories..."
+[ -d "$PAI_DIR/MEMORY/Work" ] && echo "✓ MEMORY/Work" || echo "❌ MEMORY/Work missing"
+[ -d "$PAI_DIR/MEMORY/State" ] && echo "✓ MEMORY/State" || echo "❌ MEMORY/State missing"
+
+# Test EffortClassifier
echo ""
echo "Testing EffortClassifier..."
bun run "$PAI_DIR/skills/THEALGORITHM/Tools/EffortClassifier.ts" --request "Add a new feature" --output json | head -10
+# Test ISCManager
echo ""
echo "Testing ISCManager..."
bun run "$PAI_DIR/skills/THEALGORITHM/Tools/ISCManager.ts" --help | head -5
+
+echo "=== Verification Complete ==="
```
+**Mark todo as completed when all checks pass.**
+
---
-## Environment Variables
+## Success/Failure Messages
+
+### On Success
+
+```
+"THE ALGORITHM Skill v0.5.0 installed successfully!
+
+What's available:
+- 7 execution phases: OBSERVE → THINK → PLAN → BUILD → EXECUTE → VERIFY → LEARN
+- ISC (Ideal State Criteria) tracking
+- Effort-based capability selection (TRIVIAL → DETERMINED)
+- Ralph Loop for persistent iteration
+- LCARS-style visual display with voice support
+
+Try it: Ask me to 'run the algorithm on: Add dark mode toggle'"
+```
-| Variable | Required | Description |
-|----------|----------|-------------|
-| `PAI_DIR` | No | Custom PAI directory (default: `~/.config/pai`) |
+### On Failure
-## Post-Installation
+```
+"Installation encountered issues. Here's what to check:
-### Voice Support (Optional)
+1. Ensure pai-core-install is installed first
+2. Ensure pai-agents-skill is installed second
+3. Verify Bun is installed: `bun --version`
+4. Check directory permissions on $PAI_DIR/skills/
+5. Run the verification commands in VERIFY.md
-If you have the pai-voice-system pack installed, the AlgorithmDisplay tool will automatically send voice notifications during phase transitions. No additional configuration needed.
+Need help? Check the Troubleshooting section below."
+```
+
+---
-### Integration with Other Skills
+## Troubleshooting
+
+### "pai-core-install not found"
+
+This pack requires pai-core-install. Install it first:
+```
+Give the AI the pai-core-install pack directory and ask it to install.
+```
+
+### "pai-agents-skill not found"
+
+This pack requires pai-agents-skill for custom agent composition. Install it:
+```
+Give the AI the pai-agents-skill pack directory and ask it to install.
+```
+
+### "bun: command not found"
+
+```bash
+# Install Bun
+curl -fsSL https://bun.sh/install | bash
+# Restart terminal or source ~/.bashrc
+```
+
+### EffortClassifier not found
+
+```bash
+# Check PAI_DIR is set correctly
+echo $PAI_DIR
+# Should output your PAI directory (default: ~/.claude)
+```
+
+### Capability loading fails
+
+```bash
+# Validate YAML syntax
+bun -e "const yaml = require('yaml'); yaml.parse(require('fs').readFileSync('$PAI_DIR/skills/THEALGORITHM/Data/Capabilities.yaml', 'utf8'))"
+```
+
+### Voice not working
+
+```bash
+# Check if voice server is running
+curl -s http://localhost:8888/status || echo "Voice server not running"
+# Install pai-voice-system if needed
+```
+
+### ISC not saving
+
+```bash
+# Check MEMORY directories exist
+ls -la "$PAI_DIR/MEMORY/Work/"
+ls -la "$PAI_DIR/MEMORY/State/"
+```
+
+---
+
+## What's Included
+
+| File | Purpose |
+|------|---------|
+| `SKILL.md` | Main skill definition with workflow routing |
+| `Data/Capabilities.yaml` | 30+ orchestratable capabilities registry |
+| `Tools/AlgorithmDisplay.ts` | LCARS-style visual display with voice |
+| `Tools/EffortClassifier.ts` | Classify requests by effort level |
+| `Tools/CapabilityLoader.ts` | Load capabilities by effort level |
+| `Tools/CapabilitySelector.ts` | Select capabilities for ISC rows |
+| `Tools/ISCManager.ts` | Create, update, query ISC tables |
+| `Tools/TraitModifiers.ts` | Effort-to-trait mappings |
+| `Tools/RalphLoopExecutor.ts` | Persistent iteration executor |
+| `Phases/*.md` | Phase documentation (OBSERVE through LEARN) |
+| `Reference/*.md` | Capability and effort matrices |
+
+---
+
+## Usage
+
+### From Claude Code
+
+```
+"Run the algorithm on: Add dark mode toggle"
+"Use THE ALGORITHM for this complex task"
+"Start algorithm with effort level THOROUGH"
+```
+
+### CLI Examples
+
+```bash
+# Start with visual display
+bun run $PAI_DIR/skills/THEALGORITHM/Tools/AlgorithmDisplay.ts start STANDARD -r "Add dark mode toggle"
+
+# Classify effort level
+bun run $PAI_DIR/skills/THEALGORITHM/Tools/EffortClassifier.ts --request "Add dark mode toggle"
+
+# Create ISC
+bun run $PAI_DIR/skills/THEALGORITHM/Tools/ISCManager.ts create --request "Add dark mode toggle"
+
+# Transition phases
+bun run $PAI_DIR/skills/THEALGORITHM/Tools/AlgorithmDisplay.ts phase THINK
+bun run $PAI_DIR/skills/THEALGORITHM/Tools/AlgorithmDisplay.ts phase EXECUTE
+
+# Ralph loop for persistent iteration
+bun run $PAI_DIR/skills/THEALGORITHM/Tools/RalphLoopExecutor.ts \
+ --prompt "Fix the auth bug" \
+ --completion-promise "All tests pass" \
+ --max-iterations 15
+```
+
+---
+
+## Integration with Other Skills
THE ALGORITHM integrates with:
- **Agents skill** - For custom agent composition via AgentFactory
@@ -161,15 +455,3 @@ THE ALGORITHM integrates with:
- **Browser skill** - For web verification
These integrations work automatically if the skills are installed.
-
----
-
-## Troubleshooting
-
-| Issue | Solution |
-|-------|----------|
-| EffortClassifier not found | Check `$PAI_DIR` is set correctly |
-| Missing dependencies | Run `bun add yaml` in Tools directory |
-| Voice not working | Ensure pai-voice-system is installed and running |
-| ISC not saving | Check `$PAI_DIR/MEMORY/Work/` directory exists |
-| Capability loading fails | Verify Capabilities.yaml syntax is valid |
diff --git a/Packs/pai-art-skill/INSTALL.md b/Packs/pai-art-skill/INSTALL.md
index fa81e5b6..fa06559c 100644
--- a/Packs/pai-art-skill/INSTALL.md
+++ b/Packs/pai-art-skill/INSTALL.md
@@ -1,94 +1,202 @@
-# Installation Guide - Kai Art Skill
+# PAI Art Skill v1.0.0 - Installation Guide
-## Prerequisites
+**This guide is designed for AI agents installing this pack into a user's infrastructure.**
-- **Bun runtime**: `curl -fsSL https://bun.sh/install | bash`
-- **Claude Code** (or compatible agent system with skill support)
-- **Write access** to `$PAI_DIR/` (default: `~/.config/pai`)
-- **API Keys** (at least one required):
- - `REPLICATE_API_TOKEN` - For Flux and Nano Banana models
- - `GOOGLE_API_KEY` - For Nano Banana Pro (Gemini 3) model
- - `OPENAI_API_KEY` - For GPT-image-1 model
- - `REMOVEBG_API_KEY` - For background removal feature
+---
+
+## AI Agent Instructions
+
+**This is a wizard-style installation.** Use Claude Code's native tools to guide the user through installation:
+
+1. **AskUserQuestion** - For user decisions and confirmations
+2. **TodoWrite** - For progress tracking
+3. **Bash/Read/Write** - For actual installation
+4. **VERIFY.md** - For final validation
+
+### Welcome Message
+
+Before starting, greet the user:
+```
+"I'm installing PAI Art Skill v1.0.0 - Visual content generation with multiple AI models (Flux, Nano Banana, GPT-image-1).
+
+Let me analyze your system and guide you through installation."
+```
+
+---
+
+## Phase 1: System Analysis
-## Pre-Installation: System Analysis
+**Execute this analysis BEFORE any file operations.**
-### Step 0.1: Detect Current Configuration
+### 1.1 Run These Commands
```bash
-# 1. Check PAI_DIR
-echo "PAI_DIR: ${PAI_DIR:-'NOT SET - will use ~/.config/pai'}"
+# Check for PAI directory
+PAI_CHECK="${PAI_DIR:-$HOME/.claude}"
+echo "PAI_DIR: $PAI_CHECK"
-# 2. Check for existing Skills directory
-PAI_CHECK="${PAI_DIR:-$HOME/.config/pai}"
+# Check if pai-core-install is installed (REQUIRED)
+if [ -f "$PAI_CHECK/skills/CORE/SKILL.md" ]; then
+ echo "✓ pai-core-install is installed"
+else
+ echo "❌ pai-core-install NOT installed - REQUIRED!"
+fi
+
+# Check for existing Art skill
if [ -d "$PAI_CHECK/skills/Art" ]; then
- echo "WARNING: Art skill already exists at: $PAI_CHECK/skills/Art"
- ls -la "$PAI_CHECK/skills/Art" 2>/dev/null || echo " (empty)"
+ echo "⚠️ Existing Art skill found at: $PAI_CHECK/skills/Art"
+ ls -la "$PAI_CHECK/skills/Art/"
else
- echo "OK: No existing Art skill (clean install)"
+ echo "✓ No existing Art skill (clean install)"
fi
-# 3. Check for API keys
+# Check for Bun runtime
+if command -v bun &> /dev/null; then
+ echo "✓ Bun is installed: $(bun --version)"
+else
+ echo "❌ Bun not installed - REQUIRED!"
+fi
+
+# Check for API keys
echo ""
echo "API Key Status:"
-[ -n "$REPLICATE_API_TOKEN" ] && echo " REPLICATE_API_TOKEN: Set" || echo " REPLICATE_API_TOKEN: NOT SET"
-[ -n "$GOOGLE_API_KEY" ] && echo " GOOGLE_API_KEY: Set" || echo " GOOGLE_API_KEY: NOT SET"
-[ -n "$OPENAI_API_KEY" ] && echo " OPENAI_API_KEY: Set" || echo " OPENAI_API_KEY: NOT SET"
-[ -n "$REMOVEBG_API_KEY" ] && echo " REMOVEBG_API_KEY: Set" || echo " REMOVEBG_API_KEY: NOT SET"
+[ -n "$REPLICATE_API_TOKEN" ] && echo "✓ REPLICATE_API_TOKEN: Set" || echo "⚠️ REPLICATE_API_TOKEN: NOT SET (needed for Flux, Nano Banana)"
+[ -n "$GOOGLE_API_KEY" ] && echo "✓ GOOGLE_API_KEY: Set" || echo "⚠️ GOOGLE_API_KEY: NOT SET (needed for Nano Banana Pro)"
+[ -n "$OPENAI_API_KEY" ] && echo "✓ OPENAI_API_KEY: Set" || echo "⚠️ OPENAI_API_KEY: NOT SET (needed for GPT-image-1)"
+[ -n "$REMOVEBG_API_KEY" ] && echo "✓ REMOVEBG_API_KEY: Set" || echo "⚠️ REMOVEBG_API_KEY: NOT SET (needed for background removal)"
```
-### Step 0.2: Conflict Resolution Matrix
+### 1.2 Present Findings
-| Scenario | Existing State | Action |
-|----------|---------------|--------|
-| **Clean Install** | No Art skill exists | Proceed with Step 1 |
-| **Skill Exists** | Art skill already present | Backup existing, then replace |
-| **No API Keys** | Missing all API keys | Add at least one key to .env |
+Tell the user what you found:
+```
+"Here's what I found on your system:
+- pai-core-install: [installed / NOT INSTALLED - REQUIRED]
+- Existing Art skill: [Yes at path / No]
+- Bun runtime: [installed vX.X / NOT INSTALLED - REQUIRED]
+- API Keys:
+ - REPLICATE_API_TOKEN: [set / not set]
+ - GOOGLE_API_KEY: [set / not set]
+ - OPENAI_API_KEY: [set / not set]
+ - REMOVEBG_API_KEY: [set / not set]
+
+Note: At least one image generation API key is required."
+```
-### Step 0.3: Backup Existing Configuration (If Needed)
+**STOP if pai-core-install or Bun is not installed.** Tell the user:
+```
+"pai-core-install and Bun are required. Please install them first, then return to install this pack."
+```
-```bash
-PAI_CHECK="${PAI_DIR:-$HOME/.config/pai}"
-if [ -d "$PAI_CHECK/skills/Art" ]; then
- BACKUP_DIR="$HOME/.pai-backup/$(date +%Y%m%d-%H%M%S)"
- mkdir -p "$BACKUP_DIR"
- cp -r "$PAI_CHECK/skills/Art" "$BACKUP_DIR/Art"
- echo "Backed up existing Art skill to: $BACKUP_DIR/Art"
-fi
+---
+
+## Phase 2: User Questions
+
+**Use AskUserQuestion tool at each decision point.**
+
+### Question 1: Conflict Resolution (if existing found)
+
+**Only ask if existing Art skill detected:**
+
+```json
+{
+ "header": "Conflict",
+ "question": "Existing Art skill detected. How should I proceed?",
+ "multiSelect": false,
+ "options": [
+ {"label": "Backup and Replace (Recommended)", "description": "Creates timestamped backup, then installs new version"},
+ {"label": "Replace Without Backup", "description": "Overwrites existing without backup"},
+ {"label": "Abort Installation", "description": "Cancel installation, keep existing"}
+ ]
+}
+```
+
+### Question 2: API Key Setup
+
+**Only ask if any API keys are missing:**
+
+```json
+{
+ "header": "API Keys",
+ "question": "Some API keys are missing. How should I proceed?",
+ "multiSelect": false,
+ "options": [
+ {"label": "Create .env template (Recommended)", "description": "Creates template file for you to add keys later"},
+ {"label": "I'll set them manually", "description": "Skip .env creation, set keys in shell profile"},
+ {"label": "Continue without all keys", "description": "Some generation models won't work"}
+ ]
+}
+```
+
+### Question 3: Final Confirmation
+
+```json
+{
+ "header": "Install",
+ "question": "Ready to install PAI Art Skill v1.0.0?",
+ "multiSelect": false,
+ "options": [
+ {"label": "Yes, install now (Recommended)", "description": "Proceeds with installation using choices above"},
+ {"label": "Show me what will change", "description": "Lists all files that will be created/modified"},
+ {"label": "Cancel", "description": "Abort installation"}
+ ]
+}
```
---
-## Installation Steps
+## Phase 3: Backup (If Needed)
-### Step 1: Create Directory Structure
+**Only execute if user chose "Backup and Replace":**
```bash
-PAI_DIR="${PAI_DIR:-$HOME/.config/pai}"
+PAI_DIR="${PAI_DIR:-$HOME/.claude}"
+BACKUP_DIR="$PAI_DIR/Backups/art-skill-$(date +%Y%m%d-%H%M%S)"
+mkdir -p "$BACKUP_DIR"
+[ -d "$PAI_DIR/skills/Art" ] && cp -r "$PAI_DIR/skills/Art" "$BACKUP_DIR/"
+echo "Backup created at: $BACKUP_DIR"
+```
+
+---
+
+## Phase 4: Installation
+**Create a TodoWrite list to track progress:**
+
+```json
+{
+ "todos": [
+ {"content": "Create skill directory structure", "status": "pending", "activeForm": "Creating directory structure"},
+ {"content": "Copy skill files from pack", "status": "pending", "activeForm": "Copying skill files"},
+ {"content": "Install dependencies", "status": "pending", "activeForm": "Installing dependencies"},
+ {"content": "Set up environment template", "status": "pending", "activeForm": "Setting up environment template"},
+ {"content": "Run verification", "status": "pending", "activeForm": "Running verification"}
+ ]
+}
+```
+
+### 4.1 Create Skill Directory Structure
+
+**Mark todo "Create skill directory structure" as in_progress.**
+
+```bash
+PAI_DIR="${PAI_DIR:-$HOME/.claude}"
mkdir -p "$PAI_DIR/skills/Art/Workflows"
mkdir -p "$PAI_DIR/skills/Art/Tools"
-
-echo "Created directories:"
-ls -la "$PAI_DIR/skills/Art/"
```
-### Step 2: Copy Skill Files
+**Mark todo as completed.**
-Copy from this pack's `src/` directory to your PAI installation:
+### 4.2 Copy Skill Files
-| Source | Destination |
-|--------|-------------|
-| `src/skills/Art/SKILL.md` | `$PAI_DIR/skills/Art/SKILL.md` |
-| `src/skills/Art/Aesthetic.md` | `$PAI_DIR/skills/Art/Aesthetic.md` |
-| `src/skills/Art/Workflows/TechnicalDiagrams.md` | `$PAI_DIR/skills/Art/Workflows/TechnicalDiagrams.md` |
-| `src/skills/Art/Workflows/Essay.md` | `$PAI_DIR/skills/Art/Workflows/Essay.md` |
-| `src/skills/Art/Workflows/Comics.md` | `$PAI_DIR/skills/Art/Workflows/Comics.md` |
-| `src/skills/Art/Tools/Generate.ts` | `$PAI_DIR/skills/Art/Tools/Generate.ts` |
+**Mark todo "Copy skill files from pack" as in_progress.**
+
+Copy all files from the pack's `src/skills/Art/` directory:
```bash
-PAI_DIR="${PAI_DIR:-$HOME/.config/pai}"
-PACK_DIR="[PATH_TO_THIS_PACK]"
+# From the pack directory (where this INSTALL.md is located)
+PACK_DIR="$(pwd)"
+PAI_DIR="${PAI_DIR:-$HOME/.claude}"
cp "$PACK_DIR/src/skills/Art/SKILL.md" "$PAI_DIR/skills/Art/"
cp "$PACK_DIR/src/skills/Art/Aesthetic.md" "$PAI_DIR/skills/Art/"
@@ -98,10 +206,36 @@ cp "$PACK_DIR/src/skills/Art/Workflows/Comics.md" "$PAI_DIR/skills/Art/Workflows
cp "$PACK_DIR/src/skills/Art/Tools/Generate.ts" "$PAI_DIR/skills/Art/Tools/"
```
-### Step 3: Set Up Environment Variables
+**Files copied:**
+- `SKILL.md` - Main skill routing and model selection
+- `Aesthetic.md` - Visual style guidelines and principles
+- `Workflows/TechnicalDiagrams.md` - Technical diagram generation workflow
+- `Workflows/Essay.md` - Essay illustration workflow
+- `Workflows/Comics.md` - Comic strip generation workflow
+- `Tools/Generate.ts` - Image generation CLI tool
+
+**Mark todo as completed.**
+
+### 4.3 Install Dependencies
+
+**Mark todo "Install dependencies" as in_progress.**
```bash
-PAI_DIR="${PAI_DIR:-$HOME/.config/pai}"
+PAI_DIR="${PAI_DIR:-$HOME/.claude}"
+cd "$PAI_DIR/skills/Art/Tools"
+bun add replicate openai @google/genai
+```
+
+**Mark todo as completed.**
+
+### 4.4 Set Up Environment Template (If User Chose Yes)
+
+**Mark todo "Set up environment template" as in_progress.**
+
+**Only execute if user chose to create .env template:**
+
+```bash
+PAI_DIR="${PAI_DIR:-$HOME/.claude}"
# Create .env if it doesn't exist
if [ ! -f "$PAI_DIR/.env" ]; then
@@ -127,40 +261,180 @@ else
fi
```
-### Step 4: Install Dependencies
-
-```bash
-cd "$PAI_DIR/skills/Art/Tools"
-bun install replicate openai @google/genai
+Tell the user:
```
+"Created .env template at $PAI_DIR/.env
+Please edit this file and add your API keys:
+- REPLICATE_API_TOKEN from replicate.com
+- GOOGLE_API_KEY from Google AI Studio
+- OPENAI_API_KEY from OpenAI
+- REMOVEBG_API_KEY from remove.bg (optional)"
+```
+
+**Mark todo as completed (or skip if user declined).**
---
-## Verification
+## Phase 5: Verification
-Run the verification script:
+**Mark todo "Run verification" as in_progress.**
+
+**Execute all checks from VERIFY.md:**
```bash
-PAI_DIR="${PAI_DIR:-$HOME/.config/pai}"
+PAI_DIR="${PAI_DIR:-$HOME/.claude}"
-echo "Verifying Art Skill installation..."
+echo "=== PAI Art Skill Verification ==="
-# Check files
-echo "Files:"
-[ -f "$PAI_DIR/skills/Art/SKILL.md" ] && echo " [OK] SKILL.md" || echo " [MISSING] SKILL.md"
-[ -f "$PAI_DIR/skills/Art/Aesthetic.md" ] && echo " [OK] Aesthetic.md" || echo " [MISSING] Aesthetic.md"
-[ -f "$PAI_DIR/skills/Art/Workflows/TechnicalDiagrams.md" ] && echo " [OK] TechnicalDiagrams.md" || echo " [MISSING] TechnicalDiagrams.md"
-[ -f "$PAI_DIR/skills/Art/Workflows/Essay.md" ] && echo " [OK] Essay.md" || echo " [MISSING] Essay.md"
-[ -f "$PAI_DIR/skills/Art/Workflows/Comics.md" ] && echo " [OK] Comics.md" || echo " [MISSING] Comics.md"
-[ -f "$PAI_DIR/skills/Art/Tools/Generate.ts" ] && echo " [OK] Generate.ts" || echo " [MISSING] Generate.ts"
+# Check skill files exist
+echo "Checking skill files..."
+[ -f "$PAI_DIR/skills/Art/SKILL.md" ] && echo "✓ SKILL.md" || echo "❌ SKILL.md missing"
+[ -f "$PAI_DIR/skills/Art/Aesthetic.md" ] && echo "✓ Aesthetic.md" || echo "❌ Aesthetic.md missing"
+[ -f "$PAI_DIR/skills/Art/Workflows/TechnicalDiagrams.md" ] && echo "✓ TechnicalDiagrams.md" || echo "❌ TechnicalDiagrams.md missing"
+[ -f "$PAI_DIR/skills/Art/Workflows/Essay.md" ] && echo "✓ Essay.md" || echo "❌ Essay.md missing"
+[ -f "$PAI_DIR/skills/Art/Workflows/Comics.md" ] && echo "✓ Comics.md" || echo "❌ Comics.md missing"
+[ -f "$PAI_DIR/skills/Art/Tools/Generate.ts" ] && echo "✓ Generate.ts" || echo "❌ Generate.ts missing"
# Test CLI tool
echo ""
-echo "Test CLI tool:"
-bun run "$PAI_DIR/skills/Art/Tools/Generate.ts" --help | head -5
+echo "Testing Generate.ts CLI..."
+bun run "$PAI_DIR/skills/Art/Tools/Generate.ts" --help | head -10
-echo ""
-echo "Installation complete!"
+echo "=== Verification Complete ==="
+```
+
+**Mark todo as completed when all checks pass.**
+
+---
+
+## Success/Failure Messages
+
+### On Success
+
+```
+"PAI Art Skill v1.0.0 installed successfully!
+
+What's available:
+- 'create image' - Generate images with Flux, Nano Banana, or GPT-image-1
+- 'technical diagram' - Create architecture and flow diagrams
+- 'essay illustration' - Generate illustrations for blog posts
+- 'comic strip' - Create comic-style sequences
+- '--remove-bg' flag - Remove backgrounds from generated images
+
+Try it: Ask me to 'create a header image for a blog post about AI agents'"
+```
+
+### On Failure
+
+```
+"Installation encountered issues. Here's what to check:
+
+1. Ensure pai-core-install is installed first
+2. Verify Bun is installed: `bun --version`
+3. Check at least one API key is set (REPLICATE_API_TOKEN, OPENAI_API_KEY, or GOOGLE_API_KEY)
+4. Check directory permissions on $PAI_DIR/skills/
+5. Run the verification commands in VERIFY.md
+
+Need help? Check the Troubleshooting section below."
+```
+
+---
+
+## Troubleshooting
+
+### "pai-core-install not found"
+
+This pack requires pai-core-install. Install it first:
+```
+Give the AI the pai-core-install pack directory and ask it to install.
+```
+
+### "bun: command not found"
+
+```bash
+# Install Bun
+curl -fsSL https://bun.sh/install | bash
+# Restart terminal or source ~/.bashrc
+```
+
+### "No API keys found"
+
+```bash
+# Check your .env file
+cat $PAI_DIR/.env
+
+# Or export directly
+export REPLICATE_API_TOKEN="YOUR_REPLICATE_TOKEN"
+export OPENAI_API_KEY="YOUR_OPENAI_KEY"
+```
+
+### "Generate.ts fails to run"
+
+```bash
+# Check dependencies are installed
+cd $PAI_DIR/skills/Art/Tools
+bun install
+
+# Or reinstall
+bun add replicate openai @google/genai
+```
+
+### "Background removal not working"
+
+```bash
+# Check REMOVEBG_API_KEY is set
+echo $REMOVEBG_API_KEY
+
+# Get a key from remove.bg if needed
+```
+
+---
+
+## What's Included
+
+| File | Purpose |
+|------|---------|
+| `SKILL.md` | Main skill definition with model selection |
+| `Aesthetic.md` | Visual style guidelines and principles |
+| `Workflows/TechnicalDiagrams.md` | Technical diagram workflow |
+| `Workflows/Essay.md` | Essay illustration workflow |
+| `Workflows/Comics.md` | Comic strip workflow |
+| `Tools/Generate.ts` | Image generation CLI tool |
+
+---
+
+## Usage
+
+### From Claude Code
+
+```
+"Create a header image for my blog post about AI"
+"Generate a technical diagram showing microservices architecture"
+"Create an illustration for an essay about consciousness"
+"Make a comic strip about debugging code"
+```
+
+### CLI Examples
+
+```bash
+# Generate with Flux (default)
+bun run $PAI_DIR/skills/Art/Tools/Generate.ts \
+ --prompt "A futuristic AI interface" \
+ --model flux
+
+# Generate with background removal
+bun run $PAI_DIR/skills/Art/Tools/Generate.ts \
+ --prompt "A robot mascot" \
+ --model flux \
+ --remove-bg
+
+# Generate with GPT-image-1
+bun run $PAI_DIR/skills/Art/Tools/Generate.ts \
+ --prompt "A detailed technical diagram" \
+ --model gpt-image-1
+
+# List available models
+bun run $PAI_DIR/skills/Art/Tools/Generate.ts --list-models
```
---
@@ -173,4 +447,4 @@ echo "Installation complete!"
| `GOOGLE_API_KEY` | Nano Banana Pro | Google Gemini API access |
| `OPENAI_API_KEY` | GPT-image-1 | OpenAI API access |
| `REMOVEBG_API_KEY` | Background removal | remove.bg API access |
-| `PAI_DIR` | All | Custom PAI directory (optional) |
+| `PAI_DIR` | All | Custom PAI directory (optional, default: ~/.claude) |
diff --git a/Packs/pai-history-system/INSTALL.md b/Packs/pai-history-system/INSTALL.md
index d0ba23aa..d38d4c72 100644
--- a/Packs/pai-history-system/INSTALL.md
+++ b/Packs/pai-history-system/INSTALL.md
@@ -1,151 +1,451 @@
-# Installation Guide: Kai History System
+# PAI History System v1.0.0 - Installation Guide
-## Installation Prompt
+**This guide is designed for AI agents installing this pack into a user's infrastructure.**
-You are receiving a PAI Pack - a modular upgrade for AI agent systems.
-
-**What is PAI?** See: [PAI Project Overview](../../README.md#what-is-pai)
-
-**What is a Pack?** See: [Pack System](../../README.md#pack-system)
+---
-This pack adds automatic memory to your entire AI infrastructure. The Kai History System is not just about agent outputs - it's a granular context-tracking system for EVERYTHING that happens:
+## AI Agent Instructions
-- **Continuous Learning**: Capture insights as they happen
-- **Bug Fixing**: Trace exactly what was done when debugging
-- **Avoiding Mistakes**: Learn from past errors automatically
-- **After-Action Reviews**: Analyze what worked and what didn't
-- **Restoration Points**: Recover from data loss with historical snapshots
+**This is a wizard-style installation.** Use Claude Code's native tools to guide the user through installation:
-**Core principle:** Work normally, documentation handles itself.
+1. **AskUserQuestion** - For user decisions and confirmations
+2. **TodoWrite** - For progress tracking
+3. **Bash/Read/Write** - For actual installation
+4. **VERIFY.md** - For final validation
----
+### Welcome Message
-## Prerequisites
+Before starting, greet the user:
+```
+"I'm installing PAI History System v1.0.0 - Automatic memory for your AI infrastructure. Captures sessions, learnings, research, and decisions.
-- **Bun runtime**: `curl -fsSL https://bun.sh/install | bash`
-- **Claude Code** (or compatible agent system with hook support)
-- **Write access** to `$PAI_DIR/` (or your PAI directory)
-- **pai-hook-system Pack** installed (this pack depends on the hook infrastructure)
+Let me analyze your system and guide you through installation."
+```
---
-## Pre-Installation: System Analysis
+## Phase 1: System Analysis
-### Step 0.1: Verify Dependencies
+**Execute this analysis BEFORE any file operations.**
+
+### 1.1 Run These Commands
```bash
-PAI_CHECK="${PAI_DIR:-$HOME/.config/pai}"
+# Check for PAI directory
+PAI_CHECK="${PAI_DIR:-$HOME/.claude}"
+echo "PAI_DIR: $PAI_CHECK"
-# Check that hook system is installed
-if [ -f "$PAI_CHECK/hooks/lib/observability.ts" ]; then
- echo "✓ Hook system is installed"
+# Check if pai-core-install is installed (REQUIRED)
+if [ -f "$PAI_CHECK/skills/CORE/SKILL.md" ]; then
+ echo "✓ pai-core-install is installed"
else
- echo "❌ Hook system NOT installed - install pai-hook-system first!"
+ echo "❌ pai-core-install NOT installed - REQUIRED!"
fi
-# Check hooks directory exists
-if [ -d "$PAI_CHECK/hooks" ]; then
- echo "✓ Hooks directory exists"
- ls "$PAI_CHECK/hooks"/*.ts 2>/dev/null | head -5
+# Check if pai-hook-system is installed (REQUIRED)
+if [ -f "$PAI_CHECK/hooks/lib/observability.ts" ]; then
+ echo "✓ pai-hook-system is installed"
else
- echo "❌ Hooks directory missing - install pai-hook-system first!"
+ echo "❌ pai-hook-system NOT installed - REQUIRED!"
fi
-```
-
-### Step 0.2: Detect Existing History System
-
-```bash
-PAI_CHECK="${PAI_DIR:-$HOME/.config/pai}"
# Check for existing history directory
if [ -d "$PAI_CHECK/history" ]; then
- echo "⚠️ History directory EXISTS at: $PAI_CHECK/history"
- echo "Existing categories:"
- ls -la "$PAI_CHECK/history" 2>/dev/null
+ echo "⚠️ Existing history directory found at: $PAI_CHECK/history"
+ ls -la "$PAI_CHECK/history/" 2>/dev/null | head -10
else
echo "✓ No existing history directory (clean install)"
fi
+
+# Check for Bun runtime
+if command -v bun &> /dev/null; then
+ echo "✓ Bun is installed: $(bun --version)"
+else
+ echo "❌ Bun not installed - REQUIRED!"
+fi
```
-### Step 0.3: Backup Existing History (If Needed)
+### 1.2 Present Findings
-```bash
-BACKUP_DIR="$HOME/.pai-backup/$(date +%Y%m%d-%H%M%S)"
-PAI_CHECK="${PAI_DIR:-$HOME/.config/pai}"
+Tell the user what you found:
+```
+"Here's what I found on your system:
+- pai-core-install: [installed / NOT INSTALLED - REQUIRED]
+- pai-hook-system: [installed / NOT INSTALLED - REQUIRED]
+- Existing history directory: [Yes at path / No]
+- Bun runtime: [installed vX.X / NOT INSTALLED - REQUIRED]"
+```
-if [ -d "$PAI_CHECK/history" ]; then
- mkdir -p "$BACKUP_DIR"
- cp -r "$PAI_CHECK/history" "$BACKUP_DIR/history"
- echo "✓ Backed up history to $BACKUP_DIR/history"
-fi
+**STOP if pai-core-install, pai-hook-system, or Bun is not installed.** Tell the user:
+```
+"pai-core-install and pai-hook-system are required. Please install them first, then return to install this pack.
+
+Install order:
+1. pai-core-install
+2. pai-hook-system
+3. pai-history-system (this pack)"
```
---
-## Step 1: Create Directory Structure
+## Phase 2: User Questions
-```bash
-# Create all required directories
-mkdir -p $PAI_DIR/hooks/lib
-mkdir -p $PAI_DIR/history/{sessions,learnings,research,decisions,raw-outputs}
-mkdir -p $PAI_DIR/history/execution/{features,bugs,refactors}
+**Use AskUserQuestion tool at each decision point.**
-# Verify structure
-ls -la $PAI_DIR/
-ls -la $PAI_DIR/history/
+### Question 1: Conflict Resolution (if existing found)
+
+**Only ask if existing history directory detected:**
+
+```json
+{
+ "header": "Conflict",
+ "question": "Existing history directory detected. How should I proceed?",
+ "multiSelect": false,
+ "options": [
+ {"label": "Keep existing, add hooks (Recommended)", "description": "Preserves all existing history, installs capture hooks"},
+ {"label": "Backup and start fresh", "description": "Creates timestamped backup, then creates new structure"},
+ {"label": "Abort Installation", "description": "Cancel installation, keep existing"}
+ ]
+}
+```
+
+### Question 2: History Categories
+
+```json
+{
+ "header": "Categories",
+ "question": "Which history categories do you want to enable?",
+ "multiSelect": true,
+ "options": [
+ {"label": "Sessions (Recommended)", "description": "Capture session summaries and context"},
+ {"label": "Learnings (Recommended)", "description": "Automatic learning capture from work"},
+ {"label": "Research", "description": "Research findings and discoveries"},
+ {"label": "Decisions", "description": "Architecture and design decisions"}
+ ]
+}
+```
+
+### Question 3: Final Confirmation
+
+```json
+{
+ "header": "Install",
+ "question": "Ready to install PAI History System v1.0.0?",
+ "multiSelect": false,
+ "options": [
+ {"label": "Yes, install now (Recommended)", "description": "Proceeds with installation using choices above"},
+ {"label": "Show me what will change", "description": "Lists all files that will be created/modified"},
+ {"label": "Cancel", "description": "Abort installation"}
+ ]
+}
+```
+
+---
+
+## Phase 3: Backup (If Needed)
+
+**Only execute if user chose "Backup and start fresh":**
+
+```bash
+PAI_DIR="${PAI_DIR:-$HOME/.claude}"
+BACKUP_DIR="$PAI_DIR/Backups/history-system-$(date +%Y%m%d-%H%M%S)"
+mkdir -p "$BACKUP_DIR"
+[ -d "$PAI_DIR/history" ] && cp -r "$PAI_DIR/history" "$BACKUP_DIR/"
+echo "Backup created at: $BACKUP_DIR"
```
---
-## Step 2: Install Source Files
+## Phase 4: Installation
+
+**Create a TodoWrite list to track progress:**
+
+```json
+{
+ "todos": [
+ {"content": "Create history directory structure", "status": "pending", "activeForm": "Creating directory structure"},
+ {"content": "Copy hook files from pack", "status": "pending", "activeForm": "Copying hook files"},
+ {"content": "Copy library files from pack", "status": "pending", "activeForm": "Copying library files"},
+ {"content": "Register hooks in settings.json", "status": "pending", "activeForm": "Registering hooks"},
+ {"content": "Run verification", "status": "pending", "activeForm": "Running verification"}
+ ]
+}
+```
+
+### 4.1 Create History Directory Structure
+
+**Mark todo "Create history directory structure" as in_progress.**
+
+```bash
+PAI_DIR="${PAI_DIR:-$HOME/.claude}"
+
+# Create all history category directories
+mkdir -p "$PAI_DIR/history/sessions"
+mkdir -p "$PAI_DIR/history/learnings"
+mkdir -p "$PAI_DIR/history/research"
+mkdir -p "$PAI_DIR/history/decisions"
+mkdir -p "$PAI_DIR/history/raw-outputs"
+mkdir -p "$PAI_DIR/history/execution/features"
+mkdir -p "$PAI_DIR/history/execution/bugs"
+mkdir -p "$PAI_DIR/history/execution/refactors"
+```
+
+**Mark todo as completed.**
+
+### 4.2 Copy Hook Files
-Copy all TypeScript files from this pack's `src/` directory to your hooks directory:
+**Mark todo "Copy hook files from pack" as in_progress.**
+
+Copy hook files from the pack's `src/` directory:
```bash
+# From the pack directory (where this INSTALL.md is located)
+PACK_DIR="$(pwd)"
+PAI_DIR="${PAI_DIR:-$HOME/.claude}"
+
+# Ensure hooks directory exists
+mkdir -p "$PAI_DIR/hooks"
+
# Copy hook files
-cp src/capture-all-events.ts $PAI_DIR/hooks/
-cp src/stop-hook.ts $PAI_DIR/hooks/
-cp src/subagent-stop-hook.ts $PAI_DIR/hooks/
-cp src/capture-session-summary.ts $PAI_DIR/hooks/
+cp "$PACK_DIR/src/capture-all-events.ts" "$PAI_DIR/hooks/"
+cp "$PACK_DIR/src/stop-hook.ts" "$PAI_DIR/hooks/"
+cp "$PACK_DIR/src/subagent-stop-hook.ts" "$PAI_DIR/hooks/"
+cp "$PACK_DIR/src/capture-session-summary.ts" "$PAI_DIR/hooks/"
+```
+
+**Files copied:**
+- `capture-all-events.ts` - Captures all Claude Code events
+- `stop-hook.ts` - End-of-session capture
+- `subagent-stop-hook.ts` - Subagent completion capture
+- `capture-session-summary.ts` - Session summary generation
+
+**Mark todo as completed.**
+
+### 4.3 Copy Library Files
+
+**Mark todo "Copy library files from pack" as in_progress.**
+
+```bash
+PACK_DIR="$(pwd)"
+PAI_DIR="${PAI_DIR:-$HOME/.claude}"
+
+# Ensure lib directory exists
+mkdir -p "$PAI_DIR/hooks/lib"
# Copy library files
-cp src/lib/metadata-extraction.ts $PAI_DIR/hooks/lib/
+cp "$PACK_DIR/src/lib/metadata-extraction.ts" "$PAI_DIR/hooks/lib/"
+```
+
+**Mark todo as completed.**
+
+### 4.4 Register Hooks in settings.json
+
+**Mark todo "Register hooks in settings.json" as in_progress.**
+
+Read the hook configuration from `config/settings-hooks.json` and merge it into the user's `~/.claude/settings.json`.
-# Verify all files are in place
-ls -la $PAI_DIR/hooks/*.ts
-ls -la $PAI_DIR/hooks/lib/*.ts
+Tell the user:
+```
+"I need to add the history hooks to your settings.json.
+The hooks configuration is in config/settings-hooks.json.
+
+I'll merge these hooks with your existing configuration."
+```
+
+**Important:** Merge the hooks array, don't replace it. Existing hooks should be preserved.
+
+**Mark todo as completed.**
+
+---
+
+## Phase 5: Verification
+
+**Mark todo "Run verification" as in_progress.**
+
+**Execute all checks from VERIFY.md:**
+
+```bash
+PAI_DIR="${PAI_DIR:-$HOME/.claude}"
+
+echo "=== PAI History System Verification ==="
+
+# Check directory structure
+echo "Checking history directories..."
+[ -d "$PAI_DIR/history/sessions" ] && echo "✓ sessions" || echo "❌ sessions missing"
+[ -d "$PAI_DIR/history/learnings" ] && echo "✓ learnings" || echo "❌ learnings missing"
+[ -d "$PAI_DIR/history/research" ] && echo "✓ research" || echo "❌ research missing"
+[ -d "$PAI_DIR/history/decisions" ] && echo "✓ decisions" || echo "❌ decisions missing"
+[ -d "$PAI_DIR/history/raw-outputs" ] && echo "✓ raw-outputs" || echo "❌ raw-outputs missing"
+
+# Check hook files
+echo ""
+echo "Checking hook files..."
+[ -f "$PAI_DIR/hooks/capture-all-events.ts" ] && echo "✓ capture-all-events.ts" || echo "❌ capture-all-events.ts missing"
+[ -f "$PAI_DIR/hooks/stop-hook.ts" ] && echo "✓ stop-hook.ts" || echo "❌ stop-hook.ts missing"
+[ -f "$PAI_DIR/hooks/subagent-stop-hook.ts" ] && echo "✓ subagent-stop-hook.ts" || echo "❌ subagent-stop-hook.ts missing"
+[ -f "$PAI_DIR/hooks/capture-session-summary.ts" ] && echo "✓ capture-session-summary.ts" || echo "❌ capture-session-summary.ts missing"
+
+# Check library files
+echo ""
+echo "Checking library files..."
+[ -f "$PAI_DIR/hooks/lib/metadata-extraction.ts" ] && echo "✓ metadata-extraction.ts" || echo "❌ metadata-extraction.ts missing"
+
+# Check settings.json for hooks
+echo ""
+echo "Checking settings.json for hooks..."
+if grep -q "capture-all-events" ~/.claude/settings.json 2>/dev/null; then
+ echo "✓ History hooks registered in settings.json"
+else
+ echo "⚠️ History hooks may not be registered - check settings.json"
+fi
+
+echo "=== Verification Complete ==="
+```
+
+**Mark todo as completed when all checks pass.**
+
+Tell the user:
+```
+"Hooks are loaded when Claude Code starts. Please restart Claude Code to activate the history system."
```
---
-## Step 3: Register Hooks in settings.json
+## Success/Failure Messages
+
+### On Success
+
+```
+"PAI History System v1.0.0 installed successfully!
+
+What's available:
+- Automatic session capture (every conversation logged)
+- Learning extraction (insights captured as you work)
+- Research findings (discoveries organized)
+- Decision tracking (architecture decisions logged)
+
+The system works automatically - just work normally and documentation handles itself.
-Merge the hook configuration from `config/settings-hooks.json` into your `~/.claude/settings.json`.
+**Important:** Restart Claude Code to activate the hooks."
+```
+
+### On Failure
+
+```
+"Installation encountered issues. Here's what to check:
-**For existing installations:** Add the history hooks alongside your existing hooks in `~/.claude/settings.json`.
+1. Ensure pai-core-install is installed first
+2. Ensure pai-hook-system is installed second
+3. Verify Bun is installed: `bun --version`
+4. Check directory permissions on $PAI_DIR/
+5. Verify hooks are registered in ~/.claude/settings.json
+6. Run the verification commands in VERIFY.md
+
+Need help? Check the Troubleshooting section below."
+```
---
-## Step 4: Restart Claude Code
+## Troubleshooting
+
+### "pai-core-install not found"
+
+This pack requires pai-core-install. Install it first:
+```
+Give the AI the pai-core-install pack directory and ask it to install.
+```
+
+### "pai-hook-system not found"
+
+This pack requires pai-hook-system for hook infrastructure. Install it:
+```
+Give the AI the pai-hook-system pack directory and ask it to install.
+```
+
+### "bun: command not found"
+
+```bash
+# Install Bun
+curl -fsSL https://bun.sh/install | bash
+# Restart terminal or source ~/.bashrc
+```
+
+### Hooks not firing
+
+```bash
+# Check hooks are registered
+grep -A 20 '"hooks"' ~/.claude/settings.json
+
+# Restart Claude Code to reload hooks
+# Hooks are only loaded at startup
+```
+
+### History not being captured
-Hooks are only loaded when Claude Code starts. Restart Claude Code to activate the new hooks.
+```bash
+# Check history directory has write permissions
+ls -la $PAI_DIR/history/
+
+# Check recent captures
+ls -la $PAI_DIR/history/raw-outputs/
+```
---
-## Installation Verification
+## What's Included
-After completing installation, run the verification steps in [VERIFY.md](VERIFY.md).
+| File | Purpose |
+|------|---------|
+| `capture-all-events.ts` | PostToolUse hook - captures all events |
+| `stop-hook.ts` | Stop hook - end-of-session capture |
+| `subagent-stop-hook.ts` | Subagent stop hook - capture subagent completions |
+| `capture-session-summary.ts` | Generate session summaries |
+| `lib/metadata-extraction.ts` | Extract metadata from events |
---
-## Anti-Simplification Directive
+## Usage
+
+### Automatic Capture
+
+The history system captures automatically. Just work normally:
+- Session summaries are captured when you end a session
+- Learnings are extracted from your work
+- Research findings are organized by topic
+- Decisions are logged with rationale
+
+### Manual Access
+
+```bash
+# View recent sessions
+ls -la $PAI_DIR/history/sessions/
+
+# View learnings
+ls -la $PAI_DIR/history/learnings/
+
+# View raw event stream
+ls -la $PAI_DIR/history/raw-outputs/
+```
-**CRITICAL FOR AI AGENTS:**
+### From Claude Code
-This installation MUST be completed EXACTLY as specified. DO NOT:
-- Skip any files
-- Summarize or simplify code
-- Modify file paths
-- Skip verification steps
+```
+"What did we work on last session?"
+"Show me recent learnings"
+"Find the decision about authentication"
+```
+
+---
-After installation, you MUST complete the verification checklist in [VERIFY.md](VERIFY.md).
+## History Categories
+
+| Category | Purpose | Location |
+|----------|---------|----------|
+| `sessions` | Session summaries and context | `$PAI_DIR/history/sessions/` |
+| `learnings` | Insights extracted from work | `$PAI_DIR/history/learnings/` |
+| `research` | Research findings | `$PAI_DIR/history/research/` |
+| `decisions` | Architecture decisions | `$PAI_DIR/history/decisions/` |
+| `raw-outputs` | Raw event stream | `$PAI_DIR/history/raw-outputs/` |
+| `execution/features` | Feature implementations | `$PAI_DIR/history/execution/features/` |
+| `execution/bugs` | Bug fixes | `$PAI_DIR/history/execution/bugs/` |
+| `execution/refactors` | Refactoring work | `$PAI_DIR/history/execution/refactors/` |
diff --git a/Packs/pai-hook-system/INSTALL.md b/Packs/pai-hook-system/INSTALL.md
index a3f94a7f..6240d7f8 100644
--- a/Packs/pai-hook-system/INSTALL.md
+++ b/Packs/pai-hook-system/INSTALL.md
@@ -1,73 +1,60 @@
-# Installation Guide: Kai Hook System
+# PAI Hook System v1.0.0 - Installation Guide
-## Installation Prompt
+**This guide is designed for AI agents installing this pack into a user's infrastructure.**
-You are receiving a PAI Pack - a modular upgrade for AI agent systems.
-
-**What is PAI?** See: [PAI Project Overview](../../README.md#what-is-pai)
-
-**What is a Pack?** See: [Pack System](../../README.md#pack-system)
-
-This Pack adds event-driven automation to your AI infrastructure. The Kai Hook System is the foundation that enables all other hook-based Packs to work:
+---
-- **Security Validation**: Block dangerous commands before execution
-- **Session Management**: Initialize sessions with context and state
-- **Context Injection**: Load skill definitions at session start
-- **Terminal Integration**: Update tab titles with task context
-- **Event Pipeline**: PreToolUse, PostToolUse, Stop, SessionStart, and more
+## AI Agent Instructions
-**Core principle:** Hooks intercept events and add intelligence without interrupting work.
+**This is a wizard-style installation.** Use Claude Code's native tools to guide the user through installation:
-Please follow the installation instructions below to integrate this Pack into your infrastructure.
+1. **AskUserQuestion** - For user decisions and confirmations
+2. **TodoWrite** - For progress tracking
+3. **Bash/Read/Write** - For actual installation
+4. **VERIFY.md** - For final validation
----
+### Welcome Message
-## Prerequisites
+Before starting, greet the user:
+```
+"I'm installing PAI Hook System v1.0.0 - Event-driven automation for Claude Code. Security validation, session management, and context injection.
-- **Bun runtime**: `curl -fsSL https://bun.sh/install | bash`
-- **Claude Code** (or compatible agent system with hook support)
-- **Write access** to `$PAI_DIR/` (or your PAI directory)
+Let me analyze your system and guide you through installation."
+```
---
-## Pre-Installation: System Analysis
-
-**IMPORTANT:** Before installing, analyze the current system state to detect conflicts and determine the appropriate installation strategy.
+## Phase 1: System Analysis
-### Step 0.1: Detect Current Configuration
+**Execute this analysis BEFORE any file operations.**
-Run these commands to understand your current system:
+### 1.1 Run These Commands
```bash
-# 1. Check if PAI_DIR is set
-echo "PAI_DIR: ${PAI_DIR:-'NOT SET - will use ~/.config/pai'}"
-
-# 2. Check for existing PAI directory
-PAI_CHECK="${PAI_DIR:-$HOME/.config/pai}"
-if [ -d "$PAI_CHECK" ]; then
- echo "⚠️ PAI directory EXISTS at: $PAI_CHECK"
- echo "Contents:"
- ls -la "$PAI_CHECK" 2>/dev/null || echo " (empty or inaccessible)"
+# Check for PAI directory
+PAI_CHECK="${PAI_DIR:-$HOME/.claude}"
+echo "PAI_DIR: $PAI_CHECK"
+
+# Check if pai-core-install is installed (REQUIRED)
+if [ -f "$PAI_CHECK/skills/CORE/SKILL.md" ]; then
+ echo "✓ pai-core-install is installed"
else
- echo "✓ PAI directory does not exist (clean install)"
+ echo "❌ pai-core-install NOT installed - REQUIRED!"
fi
-# 3. Check for existing hooks directory
+# Check for existing hooks directory
if [ -d "$PAI_CHECK/hooks" ]; then
- echo "⚠️ Hooks directory EXISTS"
- echo "Existing hooks:"
- ls -la "$PAI_CHECK/hooks"/*.ts 2>/dev/null || echo " (no .ts files)"
+ echo "⚠️ Existing hooks directory found at: $PAI_CHECK/hooks"
+ ls "$PAI_CHECK/hooks"/*.ts 2>/dev/null | head -10
else
- echo "✓ No existing hooks directory"
+ echo "✓ No existing hooks directory (clean install)"
fi
-# 4. Check Claude settings for existing hooks
+# Check Claude settings for existing hooks
CLAUDE_SETTINGS="$HOME/.claude/settings.json"
if [ -f "$CLAUDE_SETTINGS" ]; then
- echo "Claude settings.json EXISTS"
if grep -q '"hooks"' "$CLAUDE_SETTINGS" 2>/dev/null; then
- echo "⚠️ Existing hooks configuration found:"
- grep -A 20 '"hooks"' "$CLAUDE_SETTINGS" | head -25
+ echo "⚠️ Existing hooks configuration found in settings.json"
else
echo "✓ No hooks configured in settings.json"
fi
@@ -75,215 +62,442 @@ else
echo "✓ No Claude settings.json (will be created)"
fi
-# 5. Check environment variables
+# Check for Bun runtime
+if command -v bun &> /dev/null; then
+ echo "✓ Bun is installed: $(bun --version)"
+else
+ echo "❌ Bun not installed - REQUIRED!"
+fi
+
+# Check environment variables
echo ""
-echo "Environment variables:"
-echo " DA: ${DA:-'NOT SET'}"
-echo " TIME_ZONE: ${TIME_ZONE:-'NOT SET'}"
-echo " PAI_SOURCE_APP: ${PAI_SOURCE_APP:-'NOT SET'}"
+echo "Environment Variables:"
+echo " DA: ${DA:-'NOT SET (default: PAI)'}"
+echo " TIME_ZONE: ${TIME_ZONE:-'NOT SET (default: system)'}"
+```
+
+### 1.2 Present Findings
+
+Tell the user what you found:
+```
+"Here's what I found on your system:
+- pai-core-install: [installed / NOT INSTALLED - REQUIRED]
+- Existing hooks directory: [Yes (N hooks) / No]
+- Claude settings.json: [has hooks / no hooks / doesn't exist]
+- Bun runtime: [installed vX.X / NOT INSTALLED - REQUIRED]
+- DA environment variable: [set / not set]"
+```
+
+**STOP if pai-core-install or Bun is not installed.** Tell the user:
+```
+"pai-core-install and Bun are required. Please install them first, then return to install this pack."
+```
+
+---
+
+## Phase 2: User Questions
+
+**Use AskUserQuestion tool at each decision point.**
+
+### Question 1: Conflict Resolution (if existing hooks found)
+
+**Only ask if existing hooks directory detected:**
+
+```json
+{
+ "header": "Conflict",
+ "question": "Existing hooks detected. How should I proceed?",
+ "multiSelect": false,
+ "options": [
+ {"label": "Merge with existing (Recommended)", "description": "Adds new hooks alongside your existing hooks"},
+ {"label": "Backup and replace", "description": "Creates timestamped backup, then installs fresh"},
+ {"label": "Abort Installation", "description": "Cancel installation, keep existing"}
+ ]
+}
```
-### Step 0.2: Conflict Resolution Matrix
+### Question 2: Environment Variables (if not set)
-Based on the detection above, follow the appropriate path:
+**Only ask if DA or TIME_ZONE are not set:**
-| Scenario | Existing State | Action |
-|----------|---------------|--------|
-| **Clean Install** | No PAI_DIR, no hooks | Proceed normally with Step 1 |
-| **PAI Directory Exists** | Directory with files | Review files, backup if needed, then proceed |
-| **Hooks Exist** | Files in `$PAI_DIR/hooks/` | Merge new hooks alongside existing, or backup and replace |
-| **Claude Settings Has Hooks** | `settings.json` has hook config | **MERGE** - add new hooks to existing array |
-| **Environment Variables Set** | PAI_DIR, DA already defined | Use existing values or update in shell profile |
+```json
+{
+ "header": "Environment",
+ "question": "Environment variables not set. How should I configure them?",
+ "multiSelect": false,
+ "options": [
+ {"label": "Create .env file (Recommended)", "description": "Creates $PAI_DIR/.env with default values"},
+ {"label": "I'll set them in shell profile", "description": "Skip .env, set in ~/.zshrc or ~/.bashrc"},
+ {"label": "Use defaults", "description": "Continue with default values (DA=PAI)"}
+ ]
+}
+```
-### Step 0.3: Backup Existing Configuration (If Needed)
+### Question 3: Hook Selection
-If conflicts were detected, create a backup before proceeding:
+```json
+{
+ "header": "Hooks",
+ "question": "Which hooks should I enable?",
+ "multiSelect": true,
+ "options": [
+ {"label": "Security Validator (Recommended)", "description": "Blocks dangerous bash commands"},
+ {"label": "Session Initializer (Recommended)", "description": "Sets up session context at start"},
+ {"label": "Core Context Loader (Recommended)", "description": "Loads CORE skill at session start"},
+ {"label": "Tab Title Updater", "description": "Updates terminal tab with task context"}
+ ]
+}
+```
+
+### Question 4: Final Confirmation
+
+```json
+{
+ "header": "Install",
+ "question": "Ready to install PAI Hook System v1.0.0?",
+ "multiSelect": false,
+ "options": [
+ {"label": "Yes, install now (Recommended)", "description": "Proceeds with installation using choices above"},
+ {"label": "Show me what will change", "description": "Lists all files that will be created/modified"},
+ {"label": "Cancel", "description": "Abort installation"}
+ ]
+}
+```
+
+---
+
+## Phase 3: Backup (If Needed)
+
+**Only execute if user chose "Backup and replace":**
```bash
-# Create timestamped backup
-BACKUP_DIR="$HOME/.pai-backup/$(date +%Y%m%d-%H%M%S)"
+PAI_DIR="${PAI_DIR:-$HOME/.claude}"
+BACKUP_DIR="$PAI_DIR/Backups/hook-system-$(date +%Y%m%d-%H%M%S)"
mkdir -p "$BACKUP_DIR"
-# Backup PAI directory if exists
-PAI_CHECK="${PAI_DIR:-$HOME/.config/pai}"
-if [ -d "$PAI_CHECK" ]; then
- cp -r "$PAI_CHECK" "$BACKUP_DIR/pai"
- echo "✓ Backed up PAI directory to $BACKUP_DIR/pai"
-fi
+# Backup hooks directory
+[ -d "$PAI_DIR/hooks" ] && cp -r "$PAI_DIR/hooks" "$BACKUP_DIR/"
-# Backup Claude settings if exists
-if [ -f "$HOME/.claude/settings.json" ]; then
- cp "$HOME/.claude/settings.json" "$BACKUP_DIR/settings.json"
- echo "✓ Backed up settings.json to $BACKUP_DIR/settings.json"
-fi
+# Backup settings.json
+[ -f "$HOME/.claude/settings.json" ] && cp "$HOME/.claude/settings.json" "$BACKUP_DIR/"
-echo "Backup complete: $BACKUP_DIR"
+echo "Backup created at: $BACKUP_DIR"
```
-### Step 0.4: Set Required Environment Variables
+---
-**If you used the Kai Bundle wizard:** Environment variables are already configured in `$PAI_DIR/.env` - skip to Step 1.
+## Phase 4: Installation
-**For manual installation:** Configure these in your shell profile (`~/.zshrc` or `~/.bashrc`):
+**Create a TodoWrite list to track progress:**
-```bash
-# Add to your shell profile
-export PAI_DIR="${HOME}/.config/pai"
-export DA="PAI" # Your AI assistant name
-export TIME_ZONE="America/Los_Angeles" # Your timezone
-export PAI_SOURCE_APP="${DA}"
+```json
+{
+ "todos": [
+ {"content": "Create hooks directory structure", "status": "pending", "activeForm": "Creating directory structure"},
+ {"content": "Copy hook files from pack", "status": "pending", "activeForm": "Copying hook files"},
+ {"content": "Copy library files from pack", "status": "pending", "activeForm": "Copying library files"},
+ {"content": "Set up environment variables", "status": "pending", "activeForm": "Setting up environment"},
+ {"content": "Register hooks in settings.json", "status": "pending", "activeForm": "Registering hooks"},
+ {"content": "Run verification", "status": "pending", "activeForm": "Running verification"}
+ ]
+}
+```
+
+### 4.1 Create Hooks Directory Structure
+
+**Mark todo "Create hooks directory structure" as in_progress.**
-# Reload your shell
-source ~/.zshrc # or ~/.bashrc
+```bash
+PAI_DIR="${PAI_DIR:-$HOME/.claude}"
+mkdir -p "$PAI_DIR/hooks/lib"
```
-**Alternative:** Create a `.env` file in your PAI directory:
+**Mark todo as completed.**
+
+### 4.2 Copy Hook Files
+
+**Mark todo "Copy hook files from pack" as in_progress.**
+
+Copy hook files from the pack's `src/` directory:
```bash
-# $PAI_DIR/.env
-DA="PAI"
-PAI_DIR="${HOME}/.config/pai"
-TIME_ZONE="America/Los_Angeles"
+# From the pack directory (where this INSTALL.md is located)
+PACK_DIR="$(pwd)"
+PAI_DIR="${PAI_DIR:-$HOME/.claude}"
+
+cp "$PACK_DIR/src/security-validator.ts" "$PAI_DIR/hooks/"
+cp "$PACK_DIR/src/initialize-session.ts" "$PAI_DIR/hooks/"
+cp "$PACK_DIR/src/load-core-context.ts" "$PAI_DIR/hooks/"
+cp "$PACK_DIR/src/update-tab-titles.ts" "$PAI_DIR/hooks/"
```
----
+**Files copied:**
+- `security-validator.ts` - Blocks dangerous bash commands (PreToolUse)
+- `initialize-session.ts` - Sets up session context (SessionStart)
+- `load-core-context.ts` - Loads CORE skill context (SessionStart)
+- `update-tab-titles.ts` - Updates terminal tab title (UserPromptSubmit)
+
+**Mark todo as completed.**
+
+### 4.3 Copy Library Files
-## Step 1: Create Directory Structure
+**Mark todo "Copy library files from pack" as in_progress.**
```bash
-# Create required directories
-mkdir -p $PAI_DIR/hooks/lib
+PACK_DIR="$(pwd)"
+PAI_DIR="${PAI_DIR:-$HOME/.claude}"
-# Verify structure
-ls -la $PAI_DIR/hooks/
+cp "$PACK_DIR/src/lib/observability.ts" "$PAI_DIR/hooks/lib/"
```
----
+**Mark todo as completed.**
+
+### 4.4 Set Up Environment Variables (If User Chose Yes)
-## Step 2: Install Source Files
+**Mark todo "Set up environment variables" as in_progress.**
-Copy all TypeScript files from this pack's `src/` directory to your hooks directory:
+**Only execute if user chose to create .env file:**
```bash
-# Copy hook files
-cp src/security-validator.ts $PAI_DIR/hooks/
-cp src/initialize-session.ts $PAI_DIR/hooks/
-cp src/load-core-context.ts $PAI_DIR/hooks/
-cp src/update-tab-titles.ts $PAI_DIR/hooks/
+PAI_DIR="${PAI_DIR:-$HOME/.claude}"
-# Copy library files
-cp src/lib/observability.ts $PAI_DIR/hooks/lib/
+# Create .env if it doesn't exist
+if [ ! -f "$PAI_DIR/.env" ]; then
+ cat > "$PAI_DIR/.env" << 'EOF'
+# PAI Hook System Configuration
+DA="PAI"
+PAI_DIR="${HOME}/.claude"
+TIME_ZONE="America/Los_Angeles"
+PAI_SOURCE_APP="${DA}"
+EOF
+ echo "Created $PAI_DIR/.env"
+else
+ echo ".env already exists at $PAI_DIR/.env"
+fi
+```
-# Verify all files are in place
-ls -la $PAI_DIR/hooks/*.ts
-ls -la $PAI_DIR/hooks/lib/*.ts
+Tell the user:
+```
+"Created .env at $PAI_DIR/.env
+You can customize:
+- DA - Your AI assistant name (default: PAI)
+- TIME_ZONE - Your timezone
+- PAI_SOURCE_APP - Source app identifier"
```
----
+**Mark todo as completed (or skip if user declined).**
-## Step 3: Register Hooks in settings.json
+### 4.5 Register Hooks in settings.json
-Claude Code looks for settings in `~/.claude/settings.json`. The hook configuration template is in `config/settings-hooks.json`.
+**Mark todo "Register hooks in settings.json" as in_progress.**
-**For new installations:**
+Read the hook configuration from `config/settings-hooks.json` and merge it into `~/.claude/settings.json`.
+**For new installations:**
```bash
# If no settings.json exists, copy the template
-cp config/settings-hooks.json ~/.claude/settings.json
+mkdir -p ~/.claude
+cp "$PACK_DIR/config/settings-hooks.json" ~/.claude/settings.json
```
**For existing installations:**
+Merge the hooks section from `config/settings-hooks.json` into the existing `~/.claude/settings.json`. Preserve existing hooks.
-Merge the hooks section from `config/settings-hooks.json` into your existing `~/.claude/settings.json`. The hooks section should look like:
+**Mark todo as completed.**
-```json
-{
- "hooks": {
- "SessionStart": [
- {
- "matcher": "*",
- "hooks": [
- {
- "type": "command",
- "command": "bun run $PAI_DIR/hooks/initialize-session.ts"
- },
- {
- "type": "command",
- "command": "bun run $PAI_DIR/hooks/load-core-context.ts"
- }
- ]
- }
- ],
- "PreToolUse": [
- {
- "matcher": "Bash",
- "hooks": [
- {
- "type": "command",
- "command": "bun run $PAI_DIR/hooks/security-validator.ts"
- }
- ]
- }
- ],
- "UserPromptSubmit": [
- {
- "matcher": "*",
- "hooks": [
- {
- "type": "command",
- "command": "bun run $PAI_DIR/hooks/update-tab-titles.ts"
- }
- ]
- }
- ]
- }
-}
+---
+
+## Phase 5: Verification
+
+**Mark todo "Run verification" as in_progress.**
+
+**Execute all checks from VERIFY.md:**
+
+```bash
+PAI_DIR="${PAI_DIR:-$HOME/.claude}"
+
+echo "=== PAI Hook System Verification ==="
+
+# Check hook files
+echo "Checking hook files..."
+[ -f "$PAI_DIR/hooks/security-validator.ts" ] && echo "✓ security-validator.ts" || echo "❌ security-validator.ts missing"
+[ -f "$PAI_DIR/hooks/initialize-session.ts" ] && echo "✓ initialize-session.ts" || echo "❌ initialize-session.ts missing"
+[ -f "$PAI_DIR/hooks/load-core-context.ts" ] && echo "✓ load-core-context.ts" || echo "❌ load-core-context.ts missing"
+[ -f "$PAI_DIR/hooks/update-tab-titles.ts" ] && echo "✓ update-tab-titles.ts" || echo "❌ update-tab-titles.ts missing"
+
+# Check library files
+echo ""
+echo "Checking library files..."
+[ -f "$PAI_DIR/hooks/lib/observability.ts" ] && echo "✓ observability.ts" || echo "❌ observability.ts missing"
+
+# Check settings.json
+echo ""
+echo "Checking settings.json..."
+if [ -f ~/.claude/settings.json ]; then
+ if grep -q '"hooks"' ~/.claude/settings.json; then
+ echo "✓ Hooks section exists in settings.json"
+ if grep -q "security-validator" ~/.claude/settings.json; then
+ echo "✓ Security validator registered"
+ fi
+ if grep -q "initialize-session" ~/.claude/settings.json; then
+ echo "✓ Initialize session registered"
+ fi
+ if grep -q "load-core-context" ~/.claude/settings.json; then
+ echo "✓ Load core context registered"
+ fi
+ else
+ echo "❌ Hooks section missing from settings.json"
+ fi
+else
+ echo "❌ settings.json not found"
+fi
+
+echo "=== Verification Complete ==="
+```
+
+**Mark todo as completed when all checks pass.**
+
+Tell the user:
+```
+"Hooks are loaded when Claude Code starts. Please restart Claude Code to activate the hooks."
```
---
-## Step 4: Restart Claude Code
+## Success/Failure Messages
-Hooks are only loaded when Claude Code starts. Restart Claude Code to activate the new hooks.
+### On Success
----
+```
+"PAI Hook System v1.0.0 installed successfully!
+
+What's available:
+- Security Validator - Blocks dangerous bash commands
+- Session Initializer - Sets up context at session start
+- Core Context Loader - Loads CORE skill automatically
+- Tab Title Updater - Shows task context in terminal tab
+
+The hooks fire automatically on the appropriate events.
+
+**Important:** Restart Claude Code to activate the hooks."
+```
-## Installation Verification
+### On Failure
-After completing installation, run the verification steps in [VERIFY.md](VERIFY.md).
+```
+"Installation encountered issues. Here's what to check:
+
+1. Ensure pai-core-install is installed first
+2. Verify Bun is installed: `bun --version`
+3. Check directory permissions on $PAI_DIR/
+4. Verify hooks are registered in ~/.claude/settings.json
+5. Run the verification commands in VERIFY.md
+
+Need help? Check the Troubleshooting section below."
+```
---
## Troubleshooting
+### "pai-core-install not found"
+
+This pack requires pai-core-install. Install it first:
+```
+Give the AI the pai-core-install pack directory and ask it to install.
+```
+
+### "bun: command not found"
+
+```bash
+# Install Bun
+curl -fsSL https://bun.sh/install | bash
+# Restart terminal or source ~/.bashrc
+```
+
### Hooks not firing
-1. Check that hooks are registered in `~/.claude/settings.json`
-2. Verify file paths use `$PAI_DIR` correctly
-3. Restart Claude Code after changes
+```bash
+# Check hooks are registered
+grep -A 30 '"hooks"' ~/.claude/settings.json
+
+# Verify file paths use $PAI_DIR correctly
+echo "PAI_DIR is: $PAI_DIR"
+
+# Restart Claude Code to reload hooks
+# Hooks are only loaded at startup
+```
### Security validator blocking valid commands
-1. Review the attack patterns in `security-validator.ts`
-2. Adjust patterns or action levels as needed
-3. Add exceptions for your specific workflow
+```bash
+# Review attack patterns in security-validator.ts
+cat $PAI_DIR/hooks/security-validator.ts | grep -A 5 "ATTACK_PATTERNS"
+
+# Adjust patterns or add exceptions as needed
+```
### Tab titles not updating
-1. Check that your terminal supports OSC escape sequences
-2. Verify the UserPromptSubmit hook is registered
-3. Check for errors in the hook output
+```bash
+# Check terminal supports OSC escape sequences
+# Most modern terminals (iTerm2, Hyper, etc.) support this
+
+# Verify the UserPromptSubmit hook is registered
+grep "update-tab-titles" ~/.claude/settings.json
+```
---
-## Anti-Simplification Directive
+## What's Included
-**CRITICAL FOR AI AGENTS:**
+| File | Purpose |
+|------|---------|
+| `security-validator.ts` | PreToolUse - blocks dangerous bash commands |
+| `initialize-session.ts` | SessionStart - sets up session context |
+| `load-core-context.ts` | SessionStart - loads CORE skill |
+| `update-tab-titles.ts` | UserPromptSubmit - updates terminal tab |
+| `lib/observability.ts` | Shared logging and event utilities |
-This installation MUST be completed EXACTLY as specified. DO NOT:
-- Skip any files
-- Summarize or simplify code
-- Modify file paths
-- Skip verification steps
+---
-After installation, you MUST complete the verification checklist in [VERIFY.md](VERIFY.md).
+## Usage
+
+### Automatic Behavior
+
+Hooks fire automatically on their respective events:
+- **SessionStart**: Context is loaded, session initialized
+- **PreToolUse (Bash)**: Commands are validated before execution
+- **UserPromptSubmit**: Terminal tab title is updated
+
+### Hook Events
+
+| Event | When | Hooks |
+|-------|------|-------|
+| `SessionStart` | Claude Code starts | initialize-session, load-core-context |
+| `PreToolUse` | Before tool execution | security-validator (Bash only) |
+| `PostToolUse` | After tool execution | (extensible) |
+| `UserPromptSubmit` | User sends message | update-tab-titles |
+| `Stop` | Session ends | (extensible) |
+
+### Adding Custom Hooks
+
+Create a new `.ts` file in `$PAI_DIR/hooks/` and register it in `~/.claude/settings.json`:
+
+```json
+{
+ "hooks": {
+ "PostToolUse": [
+ {
+ "matcher": "*",
+ "hooks": [
+ {
+ "type": "command",
+ "command": "bun run $PAI_DIR/hooks/my-custom-hook.ts"
+ }
+ ]
+ }
+ ]
+ }
+}
+```
diff --git a/Packs/pai-observability-server/INSTALL.md b/Packs/pai-observability-server/INSTALL.md
index 47b69547..2133d310 100644
--- a/Packs/pai-observability-server/INSTALL.md
+++ b/Packs/pai-observability-server/INSTALL.md
@@ -1,205 +1,566 @@
-# Kai Observability Server - Installation Guide
+# PAI Observability Server v1.0.0 - Installation Guide
-## Prerequisites
+**This guide is designed for AI agents installing this pack into a user's infrastructure.**
-- **Bun runtime**: `curl -fsSL https://bun.sh/install | bash`
-- **Node.js 18+** (for Vite dev server)
-- **Claude Code** (or compatible agent system)
-- **pai-hook-system** pack installed
-- **Write access** to `$PAI_DIR/`
+---
-## Pre-Installation Checks
+## AI Agent Instructions
-### Verify Hook System
+**This is a wizard-style installation.** Use Claude Code's native tools to guide the user through installation:
-```bash
-# Check that pai-hook-system is installed
-ls -la $PAI_DIR/hooks/
-# Should show: security-validator.ts, initialize-session.ts, etc.
+1. **AskUserQuestion** - For user decisions and confirmations
+2. **TodoWrite** - For progress tracking
+3. **Bash/Read/Write** - For actual installation
+4. **VERIFY.md** - For final validation
+
+### Welcome Message
+
+Before starting, greet the user:
+```
+"I'm installing PAI Observability Server v1.0.0 - Real-time multi-agent activity monitoring dashboard with WebSocket streaming.
-# Check that hooks are configured in Claude settings
-grep -A 10 '"hooks"' ~/.claude/settings.json
-# Should show PostToolUse hooks configured
+Let me analyze your system and guide you through installation."
```
-### Check for Existing Observability
+---
+
+## Phase 1: System Analysis
+
+**Execute this analysis BEFORE any file operations.**
+
+### 1.1 Run These Commands
```bash
-if [ -d "$PAI_DIR/observability" ]; then
- echo "Warning: Observability directory EXISTS"
- ls -la "$PAI_DIR/observability"
+# Check for PAI directory
+PAI_CHECK="${PAI_DIR:-$HOME/.claude}"
+echo "PAI_DIR: $PAI_CHECK"
+
+# Check if pai-core-install is installed (REQUIRED)
+if [ -f "$PAI_CHECK/skills/CORE/SKILL.md" ]; then
+ echo "✓ pai-core-install is installed"
+else
+ echo "❌ pai-core-install NOT installed - REQUIRED!"
+fi
+
+# Check if pai-hook-system is installed (REQUIRED)
+if [ -f "$PAI_CHECK/hooks/lib/observability.ts" ]; then
+ echo "✓ pai-hook-system is installed"
+else
+ echo "❌ pai-hook-system NOT installed - REQUIRED!"
+fi
+
+# Check for existing observability directory
+if [ -d "$PAI_CHECK/observability" ]; then
+ echo "⚠️ Existing observability directory found at: $PAI_CHECK/observability"
+ ls -la "$PAI_CHECK/observability/"
+else
+ echo "✓ No existing observability directory (clean install)"
+fi
+
+# Check for Bun runtime
+if command -v bun &> /dev/null; then
+ echo "✓ Bun is installed: $(bun --version)"
+else
+ echo "❌ Bun not installed - REQUIRED!"
+fi
+
+# Check for Node.js (for Vite)
+if command -v node &> /dev/null; then
+ echo "✓ Node.js is installed: $(node --version)"
+else
+ echo "⚠️ Node.js not installed - needed for Vite dev server"
+fi
+
+# Check for port availability
+if lsof -i :4000 &> /dev/null; then
+ echo "⚠️ Port 4000 is in use"
else
- echo "Clean install - no existing observability"
+ echo "✓ Port 4000 is available (server)"
+fi
+
+if lsof -i :5172 &> /dev/null; then
+ echo "⚠️ Port 5172 is in use"
+else
+ echo "✓ Port 5172 is available (client)"
fi
```
-## Installation Steps
+### 1.2 Present Findings
-### Step 1: Create Directory Structure
+Tell the user what you found:
+```
+"Here's what I found on your system:
+- pai-core-install: [installed / NOT INSTALLED - REQUIRED]
+- pai-hook-system: [installed / NOT INSTALLED - REQUIRED]
+- Existing observability: [Yes at path / No]
+- Bun runtime: [installed vX.X / NOT INSTALLED - REQUIRED]
+- Node.js: [installed vX.X / NOT INSTALLED - needed for Vite]
+- Port 4000 (server): [available / in use]
+- Port 5172 (client): [available / in use]"
+```
-```bash
-# Create observability directories
-mkdir -p $PAI_DIR/observability/apps/server/src
-mkdir -p $PAI_DIR/observability/apps/client/src/components
-mkdir -p $PAI_DIR/observability/apps/client/src/composables
-mkdir -p $PAI_DIR/history/raw-outputs
+**STOP if pai-core-install, pai-hook-system, or Bun is not installed.** Tell the user:
+```
+"pai-core-install and pai-hook-system are required. Please install them first, then return to install this pack.
-# Create hooks lib directory if not exists
-mkdir -p $PAI_DIR/hooks/lib
+Install order:
+1. pai-core-install
+2. pai-hook-system
+3. pai-observability-server (this pack)"
```
-### Step 2: Copy Source Files
+---
-Copy the following files from `src/` to their destinations:
+## Phase 2: User Questions
-| Source | Destination |
-|--------|-------------|
-| `src/hooks/lib/metadata-extraction.ts` | `$PAI_DIR/hooks/lib/metadata-extraction.ts` |
-| `src/hooks/capture-all-events.ts` | `$PAI_DIR/hooks/capture-all-events.ts` |
-| `src/observability/apps/server/src/types.ts` | `$PAI_DIR/observability/apps/server/src/types.ts` |
-| `src/observability/apps/server/src/file-ingest.ts` | `$PAI_DIR/observability/apps/server/src/file-ingest.ts` |
-| `src/observability/apps/server/src/index.ts` | `$PAI_DIR/observability/apps/server/src/index.ts` |
-| `src/observability/apps/server/package.json` | `$PAI_DIR/observability/apps/server/package.json` |
-| `src/observability/apps/client/src/main.ts` | `$PAI_DIR/observability/apps/client/src/main.ts` |
-| `src/observability/apps/client/src/style.css` | `$PAI_DIR/observability/apps/client/src/style.css` |
-| `src/observability/apps/client/src/App.vue` | `$PAI_DIR/observability/apps/client/src/App.vue` |
-| `src/observability/apps/client/package.json` | `$PAI_DIR/observability/apps/client/package.json` |
-| `src/observability/apps/client/vite.config.ts` | `$PAI_DIR/observability/apps/client/vite.config.ts` |
-| `src/observability/apps/client/index.html` | `$PAI_DIR/observability/apps/client/index.html` |
-| `src/observability/apps/client/tailwind.config.js` | `$PAI_DIR/observability/apps/client/tailwind.config.js` |
-| `src/observability/apps/client/postcss.config.js` | `$PAI_DIR/observability/apps/client/postcss.config.js` |
-| `src/observability/manage.sh` | `$PAI_DIR/observability/manage.sh` |
+**Use AskUserQuestion tool at each decision point.**
-### Step 3: Make Management Script Executable
+### Question 1: Conflict Resolution (if existing found)
+
+**Only ask if existing observability directory detected:**
+
+```json
+{
+ "header": "Conflict",
+ "question": "Existing observability installation detected. How should I proceed?",
+ "multiSelect": false,
+ "options": [
+ {"label": "Backup and Replace (Recommended)", "description": "Creates timestamped backup, then installs new version"},
+ {"label": "Replace Without Backup", "description": "Overwrites existing without backup"},
+ {"label": "Abort Installation", "description": "Cancel installation, keep existing"}
+ ]
+}
+```
+
+### Question 2: Auto-Start Configuration
+
+```json
+{
+ "header": "Auto-Start",
+ "question": "How should the observability server start?",
+ "multiSelect": false,
+ "options": [
+ {"label": "Manual start (Recommended)", "description": "Start with manage.sh when you want to observe"},
+ {"label": "Start on login", "description": "Create a LaunchAgent to auto-start (macOS only)"}
+ ]
+}
+```
+
+### Question 3: Final Confirmation
+
+```json
+{
+ "header": "Install",
+ "question": "Ready to install PAI Observability Server v1.0.0?",
+ "multiSelect": false,
+ "options": [
+ {"label": "Yes, install now (Recommended)", "description": "Proceeds with installation using choices above"},
+ {"label": "Show me what will change", "description": "Lists all files that will be created/modified"},
+ {"label": "Cancel", "description": "Abort installation"}
+ ]
+}
+```
+
+---
+
+## Phase 3: Backup (If Needed)
+
+**Only execute if user chose "Backup and Replace":**
```bash
-chmod +x $PAI_DIR/observability/manage.sh
+PAI_DIR="${PAI_DIR:-$HOME/.claude}"
+BACKUP_DIR="$PAI_DIR/Backups/observability-$(date +%Y%m%d-%H%M%S)"
+mkdir -p "$BACKUP_DIR"
+[ -d "$PAI_DIR/observability" ] && cp -r "$PAI_DIR/observability" "$BACKUP_DIR/"
+echo "Backup created at: $BACKUP_DIR"
```
-### Step 4: Register Capture Hooks
+---
+
+## Phase 4: Installation
-Add the following to your `~/.claude/settings.json` hooks section:
+**Create a TodoWrite list to track progress:**
```json
{
- "hooks": {
- "PostToolUse": [
- {
- "matcher": "*",
- "hooks": [
- {
- "type": "command",
- "command": "bun run $PAI_DIR/hooks/capture-all-events.ts --event-type PostToolUse"
- }
- ]
- }
- ],
- "PreToolUse": [
- {
- "matcher": "*",
- "hooks": [
- {
- "type": "command",
- "command": "bun run $PAI_DIR/hooks/capture-all-events.ts --event-type PreToolUse"
- }
- ]
- }
- ],
- "Stop": [
- {
- "matcher": "*",
- "hooks": [
- {
- "type": "command",
- "command": "bun run $PAI_DIR/hooks/capture-all-events.ts --event-type Stop"
- }
- ]
- }
- ],
- "SubagentStop": [
- {
- "matcher": "*",
- "hooks": [
- {
- "type": "command",
- "command": "bun run $PAI_DIR/hooks/capture-all-events.ts --event-type SubagentStop"
- }
- ]
- }
- ],
- "UserPromptSubmit": [
- {
- "matcher": "*",
- "hooks": [
- {
- "type": "command",
- "command": "bun run $PAI_DIR/hooks/capture-all-events.ts --event-type UserPromptSubmit"
- }
- ]
- }
- ]
- }
+ "todos": [
+ {"content": "Create directory structure", "status": "pending", "activeForm": "Creating directory structure"},
+ {"content": "Copy server files", "status": "pending", "activeForm": "Copying server files"},
+ {"content": "Copy client files", "status": "pending", "activeForm": "Copying client files"},
+ {"content": "Copy hook files", "status": "pending", "activeForm": "Copying hook files"},
+ {"content": "Copy management script", "status": "pending", "activeForm": "Copying management script"},
+ {"content": "Install server dependencies", "status": "pending", "activeForm": "Installing server dependencies"},
+ {"content": "Install client dependencies", "status": "pending", "activeForm": "Installing client dependencies"},
+ {"content": "Register capture hooks", "status": "pending", "activeForm": "Registering capture hooks"},
+ {"content": "Run verification", "status": "pending", "activeForm": "Running verification"}
+ ]
}
```
-### Step 5: Install Dependencies
+### 4.1 Create Directory Structure
+
+**Mark todo "Create directory structure" as in_progress.**
```bash
-# Install server dependencies
-cd $PAI_DIR/observability/apps/server
-bun install
+PAI_DIR="${PAI_DIR:-$HOME/.claude}"
+
+# Create observability directories
+mkdir -p "$PAI_DIR/observability/apps/server/src"
+mkdir -p "$PAI_DIR/observability/apps/client/src/components"
+mkdir -p "$PAI_DIR/observability/apps/client/src/composables"
+
+# Create history directory for event storage
+mkdir -p "$PAI_DIR/history/raw-outputs"
+
+# Create hooks lib directory if not exists
+mkdir -p "$PAI_DIR/hooks/lib"
+```
+
+**Mark todo as completed.**
+
+### 4.2 Copy Server Files
+
+**Mark todo "Copy server files" as in_progress.**
+
+```bash
+PACK_DIR="$(pwd)"
+PAI_DIR="${PAI_DIR:-$HOME/.claude}"
+
+# Copy server source files
+cp "$PACK_DIR/src/observability/apps/server/src/types.ts" "$PAI_DIR/observability/apps/server/src/"
+cp "$PACK_DIR/src/observability/apps/server/src/file-ingest.ts" "$PAI_DIR/observability/apps/server/src/"
+cp "$PACK_DIR/src/observability/apps/server/src/index.ts" "$PAI_DIR/observability/apps/server/src/"
+cp "$PACK_DIR/src/observability/apps/server/package.json" "$PAI_DIR/observability/apps/server/"
+```
+
+**Files copied:**
+- `types.ts` - TypeScript interfaces
+- `file-ingest.ts` - JSONL file watcher
+- `index.ts` - HTTP + WebSocket server
+- `package.json` - Server dependencies
+
+**Mark todo as completed.**
+
+### 4.3 Copy Client Files
+
+**Mark todo "Copy client files" as in_progress.**
+
+```bash
+PACK_DIR="$(pwd)"
+PAI_DIR="${PAI_DIR:-$HOME/.claude}"
+
+# Copy client source files
+cp "$PACK_DIR/src/observability/apps/client/src/main.ts" "$PAI_DIR/observability/apps/client/src/"
+cp "$PACK_DIR/src/observability/apps/client/src/style.css" "$PAI_DIR/observability/apps/client/src/"
+cp "$PACK_DIR/src/observability/apps/client/src/App.vue" "$PAI_DIR/observability/apps/client/src/"
+
+# Copy client config files
+cp "$PACK_DIR/src/observability/apps/client/package.json" "$PAI_DIR/observability/apps/client/"
+cp "$PACK_DIR/src/observability/apps/client/vite.config.ts" "$PAI_DIR/observability/apps/client/"
+cp "$PACK_DIR/src/observability/apps/client/index.html" "$PAI_DIR/observability/apps/client/"
+cp "$PACK_DIR/src/observability/apps/client/tailwind.config.js" "$PAI_DIR/observability/apps/client/"
+cp "$PACK_DIR/src/observability/apps/client/postcss.config.js" "$PAI_DIR/observability/apps/client/"
+```
+
+**Files copied:**
+- `main.ts` - Vue app entry
+- `style.css` - Tailwind styles
+- `App.vue` - Main dashboard component
+- `package.json` - Client dependencies
+- Config files for Vite, Tailwind, PostCSS
+
+**Mark todo as completed.**
+
+### 4.4 Copy Hook Files
+
+**Mark todo "Copy hook files" as in_progress.**
+
+```bash
+PACK_DIR="$(pwd)"
+PAI_DIR="${PAI_DIR:-$HOME/.claude}"
+
+# Copy capture hook
+cp "$PACK_DIR/src/hooks/capture-all-events.ts" "$PAI_DIR/hooks/"
+
+# Copy metadata extraction library
+cp "$PACK_DIR/src/hooks/lib/metadata-extraction.ts" "$PAI_DIR/hooks/lib/"
+```
+
+**Files copied:**
+- `capture-all-events.ts` - Captures all events to JSONL
+- `lib/metadata-extraction.ts` - Extract agent metadata
+
+**Mark todo as completed.**
+
+### 4.5 Copy Management Script
+
+**Mark todo "Copy management script" as in_progress.**
+
+```bash
+PACK_DIR="$(pwd)"
+PAI_DIR="${PAI_DIR:-$HOME/.claude}"
+
+# Copy management script
+cp "$PACK_DIR/src/observability/manage.sh" "$PAI_DIR/observability/"
-# Install client dependencies
-cd $PAI_DIR/observability/apps/client
+# Make executable
+chmod +x "$PAI_DIR/observability/manage.sh"
+```
+
+**Mark todo as completed.**
+
+### 4.6 Install Server Dependencies
+
+**Mark todo "Install server dependencies" as in_progress.**
+
+```bash
+PAI_DIR="${PAI_DIR:-$HOME/.claude}"
+cd "$PAI_DIR/observability/apps/server"
bun install
```
-### Step 6: Verify Installation
+**Mark todo as completed.**
+
+### 4.7 Install Client Dependencies
+
+**Mark todo "Install client dependencies" as in_progress.**
```bash
-# Start observability
-$PAI_DIR/observability/manage.sh start
+PAI_DIR="${PAI_DIR:-$HOME/.claude}"
+cd "$PAI_DIR/observability/apps/client"
+bun install
+```
-# In another terminal, check health
-curl http://localhost:4000/health
-# Expected: {"status":"ok","timestamp":...}
+**Mark todo as completed.**
-# Open browser to http://localhost:5172
-# Should see the observability dashboard
+### 4.8 Register Capture Hooks
-# Stop when done testing
+**Mark todo "Register capture hooks" as in_progress.**
+
+Add the event capture hooks to `~/.claude/settings.json`. These hooks capture all Claude Code events to the JSONL file that the server watches.
+
+Read `config/settings-hooks.json` and merge the hooks into the user's existing settings.
+
+**Important:** Merge the hooks, don't replace existing hooks.
+
+**Mark todo as completed.**
+
+---
+
+## Phase 5: Verification
+
+**Mark todo "Run verification" as in_progress.**
+
+**Execute all checks from VERIFY.md:**
+
+```bash
+PAI_DIR="${PAI_DIR:-$HOME/.claude}"
+
+echo "=== PAI Observability Server Verification ==="
+
+# Check server files
+echo "Checking server files..."
+[ -f "$PAI_DIR/observability/apps/server/src/index.ts" ] && echo "✓ server/index.ts" || echo "❌ server/index.ts missing"
+[ -f "$PAI_DIR/observability/apps/server/src/file-ingest.ts" ] && echo "✓ server/file-ingest.ts" || echo "❌ server/file-ingest.ts missing"
+[ -f "$PAI_DIR/observability/apps/server/package.json" ] && echo "✓ server/package.json" || echo "❌ server/package.json missing"
+
+# Check client files
+echo ""
+echo "Checking client files..."
+[ -f "$PAI_DIR/observability/apps/client/src/App.vue" ] && echo "✓ client/App.vue" || echo "❌ client/App.vue missing"
+[ -f "$PAI_DIR/observability/apps/client/package.json" ] && echo "✓ client/package.json" || echo "❌ client/package.json missing"
+
+# Check hook files
+echo ""
+echo "Checking hook files..."
+[ -f "$PAI_DIR/hooks/capture-all-events.ts" ] && echo "✓ capture-all-events.ts" || echo "❌ capture-all-events.ts missing"
+[ -f "$PAI_DIR/hooks/lib/metadata-extraction.ts" ] && echo "✓ metadata-extraction.ts" || echo "❌ metadata-extraction.ts missing"
+
+# Check management script
+echo ""
+echo "Checking management script..."
+[ -x "$PAI_DIR/observability/manage.sh" ] && echo "✓ manage.sh is executable" || echo "❌ manage.sh not executable"
+
+# Test server start (quick test)
+echo ""
+echo "Testing server..."
+$PAI_DIR/observability/manage.sh start &
+sleep 3
+if curl -s http://localhost:4000/health | grep -q "ok"; then
+ echo "✓ Server responding on port 4000"
+else
+ echo "❌ Server not responding"
+fi
$PAI_DIR/observability/manage.sh stop
+
+echo "=== Verification Complete ==="
+```
+
+**Mark todo as completed when all checks pass.**
+
+---
+
+## Success/Failure Messages
+
+### On Success
+
```
+"PAI Observability Server v1.0.0 installed successfully!
+
+What's available:
+- Real-time event streaming via WebSocket
+- Multi-agent activity tracking
+- Event timeline visualization
+- Agent swim lanes
-## Post-Installation
+To start the dashboard:
+1. Run: $PAI_DIR/observability/manage.sh start
+2. Open: http://localhost:5172
-After installation:
-1. Start observability: `$PAI_DIR/observability/manage.sh start`
-2. Open http://localhost:5172
-3. Use Claude Code - events should stream to dashboard
-4. Use `/observability status` to check status from Claude Code
+To stop: $PAI_DIR/observability/manage.sh stop"
+```
+
+### On Failure
+
+```
+"Installation encountered issues. Here's what to check:
+
+1. Ensure pai-core-install is installed first
+2. Ensure pai-hook-system is installed second
+3. Verify Bun is installed: `bun --version`
+4. Check ports 4000 and 5172 are available
+5. Check directory permissions on $PAI_DIR/
+6. Run the verification commands in VERIFY.md
+
+Need help? Check the Troubleshooting section below."
+```
+
+---
## Troubleshooting
-### Port Already in Use
+### "pai-core-install not found"
+
+This pack requires pai-core-install. Install it first:
+```
+Give the AI the pai-core-install pack directory and ask it to install.
+```
+
+### "pai-hook-system not found"
+
+This pack requires pai-hook-system for hook infrastructure. Install it:
+```
+Give the AI the pai-hook-system pack directory and ask it to install.
+```
+
+### "bun: command not found"
+
+```bash
+# Install Bun
+curl -fsSL https://bun.sh/install | bash
+# Restart terminal or source ~/.bashrc
+```
+
+### Port already in use
```bash
-# Check what's using the port
+# Check what's using the ports
lsof -i :4000
lsof -i :5172
-# Kill the processes if needed
+# Kill existing processes
$PAI_DIR/observability/manage.sh stop
```
-### No Events Appearing
+### No events appearing in dashboard
+
+```bash
+# Check hooks are registered
+grep -A5 'capture-all-events' ~/.claude/settings.json
+
+# Check JSONL file is being written
+ls -la $PAI_DIR/history/raw-outputs/$(date +%Y-%m)/
+
+# Restart Claude Code to reload hooks
+```
+
+### WebSocket not connecting
+
+```bash
+# Check server is running
+curl http://localhost:4000/health
+
+# Check browser console for errors
+# Open DevTools > Console tab
+```
+
+---
+
+## What's Included
+
+| File | Purpose |
+|------|---------|
+| `observability/apps/server/src/index.ts` | HTTP + WebSocket server |
+| `observability/apps/server/src/file-ingest.ts` | JSONL file watcher |
+| `observability/apps/server/src/types.ts` | TypeScript interfaces |
+| `observability/apps/client/src/App.vue` | Vue dashboard |
+| `observability/manage.sh` | Start/stop/restart script |
+| `hooks/capture-all-events.ts` | Event capture hook |
+| `hooks/lib/metadata-extraction.ts` | Agent metadata extraction |
+
+---
+
+## Usage
+
+### Starting the Dashboard
+
+```bash
+# Start both server and client
+$PAI_DIR/observability/manage.sh start
+
+# Open in browser
+open http://localhost:5172
+
+# Check status
+$PAI_DIR/observability/manage.sh status
+```
+
+### Stopping the Dashboard
+
+```bash
+$PAI_DIR/observability/manage.sh stop
+```
+
+### Running in Background
+
+```bash
+# Start detached (survives terminal close)
+$PAI_DIR/observability/manage.sh start-detached
+```
+
+### From Claude Code
+
+```
+"Start observability"
+"Check observability status"
+"Stop observability"
+```
+
+---
+
+## Configuration
+
+**Environment variables:**
-1. Check hooks are registered: `grep -A5 'capture-all-events' ~/.claude/settings.json`
-2. Check the JSONL file is being written: `ls -la $PAI_DIR/history/raw-outputs/*/`
-3. Check server is watching the right file: Server logs show "Watching: ..."
+| Variable | Default | Purpose |
+|----------|---------|---------|
+| `PAI_DIR` | `~/.claude` | Root PAI directory |
+| `TIME_ZONE` | System default | Timestamp timezone |
+| `DA` | `main` | Default agent name |
-### WebSocket Not Connecting
+**Ports:**
-1. Ensure server is running on port 4000
-2. Check browser console for errors
-3. Try `curl http://localhost:4000/health`
+| Service | Port | Purpose |
+|---------|------|---------|
+| Server | 4000 | HTTP API + WebSocket |
+| Client | 5172 | Dashboard UI |
diff --git a/Packs/pai-prompting-skill/INSTALL.md b/Packs/pai-prompting-skill/INSTALL.md
index 633caf82..b1b62a47 100644
--- a/Packs/pai-prompting-skill/INSTALL.md
+++ b/Packs/pai-prompting-skill/INSTALL.md
@@ -1,104 +1,485 @@
-# Installation Guide - Kai Prompting Skill
+# PAI Prompting Skill v1.0.0 - Installation Guide
-## Prerequisites
+**This guide is designed for AI agents installing this pack into a user's infrastructure.**
-- **Bun runtime**: `curl -fsSL https://bun.sh/install | bash`
-- **Claude Code** (or compatible agent system)
-- **pai-core-install Pack** installed (required for Skills directory)
+---
-## Step 1: Create Directory Structure
+## AI Agent Instructions
+
+**This is a wizard-style installation.** Use Claude Code's native tools to guide the user through installation:
+
+1. **AskUserQuestion** - For user decisions and confirmations
+2. **TodoWrite** - For progress tracking
+3. **Bash/Read/Write** - For actual installation
+4. **VERIFY.md** - For final validation
+
+### Welcome Message
+
+Before starting, greet the user:
+```
+"I'm installing PAI Prompting Skill v1.0.0 - Meta-prompting system with Handlebars templates, primitives, and standards for dynamic prompt generation.
+
+Let me analyze your system and guide you through installation."
+```
+
+---
+
+## Phase 1: System Analysis
+
+**Execute this analysis BEFORE any file operations.**
+
+### 1.1 Run These Commands
+
+```bash
+# Check for PAI directory
+PAI_CHECK="${PAI_DIR:-$HOME/.claude}"
+echo "PAI_DIR: $PAI_CHECK"
+
+# Check if pai-core-install is installed (REQUIRED)
+if [ -f "$PAI_CHECK/skills/CORE/SKILL.md" ]; then
+ echo "✓ pai-core-install is installed"
+else
+ echo "❌ pai-core-install NOT installed - REQUIRED!"
+fi
+
+# Check for existing Prompting skill
+if [ -d "$PAI_CHECK/skills/Prompting" ]; then
+ echo "⚠️ Existing Prompting skill found at: $PAI_CHECK/skills/Prompting"
+ ls -la "$PAI_CHECK/skills/Prompting/"
+else
+ echo "✓ No existing Prompting skill (clean install)"
+fi
+
+# Check for Bun runtime
+if command -v bun &> /dev/null; then
+ echo "✓ Bun is installed: $(bun --version)"
+else
+ echo "❌ Bun not installed - REQUIRED!"
+fi
+
+# Check for fabric patterns (optional integration)
+if [ -d "$PAI_CHECK/Tools/fabric/Patterns" ]; then
+ PATTERN_COUNT=$(ls "$PAI_CHECK/Tools/fabric/Patterns" 2>/dev/null | wc -l)
+ echo "✓ Fabric patterns available: $PATTERN_COUNT patterns"
+else
+ echo "⚠️ Fabric patterns not found (optional - can integrate later)"
+fi
+```
+
+### 1.2 Present Findings
+
+Tell the user what you found:
+```
+"Here's what I found on your system:
+- pai-core-install: [installed / NOT INSTALLED - REQUIRED]
+- Existing Prompting skill: [Yes at path / No]
+- Bun runtime: [installed vX.X / NOT INSTALLED - REQUIRED]
+- Fabric patterns: [installed (N patterns) / not installed (optional)]"
+```
+
+**STOP if pai-core-install or Bun is not installed.** Tell the user:
+```
+"pai-core-install and Bun are required. Please install them first, then return to install this pack."
+```
+
+---
+
+## Phase 2: User Questions
+
+**Use AskUserQuestion tool at each decision point.**
+
+### Question 1: Conflict Resolution (if existing found)
+
+**Only ask if existing Prompting skill detected:**
+
+```json
+{
+ "header": "Conflict",
+ "question": "Existing Prompting skill detected. How should I proceed?",
+ "multiSelect": false,
+ "options": [
+ {"label": "Backup and Replace (Recommended)", "description": "Creates timestamped backup, then installs new version"},
+ {"label": "Merge templates", "description": "Keep existing custom templates, add new primitives"},
+ {"label": "Abort Installation", "description": "Cancel installation, keep existing"}
+ ]
+}
+```
+
+### Question 2: Template Extensions
+
+```json
+{
+ "header": "Templates",
+ "question": "Which template categories do you want to install?",
+ "multiSelect": true,
+ "options": [
+ {"label": "Core Primitives (Recommended)", "description": "Roster, Voice, Structure, Briefing, Gate templates"},
+ {"label": "Eval Templates", "description": "LLM-as-Judge patterns (Judge.hbs, Rubric.hbs)"},
+ {"label": "Data Examples", "description": "Sample YAML data files for template testing"}
+ ]
+}
+```
+
+### Question 3: Final Confirmation
+
+```json
+{
+ "header": "Install",
+ "question": "Ready to install PAI Prompting Skill v1.0.0?",
+ "multiSelect": false,
+ "options": [
+ {"label": "Yes, install now (Recommended)", "description": "Proceeds with installation using choices above"},
+ {"label": "Show me what will change", "description": "Lists all files that will be created/modified"},
+ {"label": "Cancel", "description": "Abort installation"}
+ ]
+}
+```
+
+---
+
+## Phase 3: Backup (If Needed)
+
+**Only execute if user chose "Backup and Replace":**
+
+```bash
+PAI_DIR="${PAI_DIR:-$HOME/.claude}"
+BACKUP_DIR="$PAI_DIR/Backups/prompting-skill-$(date +%Y%m%d-%H%M%S)"
+mkdir -p "$BACKUP_DIR"
+[ -d "$PAI_DIR/skills/Prompting" ] && cp -r "$PAI_DIR/skills/Prompting" "$BACKUP_DIR/"
+echo "Backup created at: $BACKUP_DIR"
+```
+
+---
+
+## Phase 4: Installation
+
+**Create a TodoWrite list to track progress:**
+
+```json
+{
+ "todos": [
+ {"content": "Create skill directory structure", "status": "pending", "activeForm": "Creating directory structure"},
+ {"content": "Copy skill files from pack", "status": "pending", "activeForm": "Copying skill files"},
+ {"content": "Copy template primitives", "status": "pending", "activeForm": "Copying template primitives"},
+ {"content": "Copy tools", "status": "pending", "activeForm": "Copying tools"},
+ {"content": "Install dependencies", "status": "pending", "activeForm": "Installing dependencies"},
+ {"content": "Run verification", "status": "pending", "activeForm": "Running verification"}
+ ]
+}
+```
+
+### 4.1 Create Skill Directory Structure
+
+**Mark todo "Create skill directory structure" as in_progress.**
+
+```bash
+PAI_DIR="${PAI_DIR:-$HOME/.claude}"
+mkdir -p "$PAI_DIR/skills/Prompting/Templates/Primitives"
+mkdir -p "$PAI_DIR/skills/Prompting/Templates/Data/Examples"
+mkdir -p "$PAI_DIR/skills/Prompting/Templates/Compiled"
+mkdir -p "$PAI_DIR/skills/Prompting/Templates/Evals"
+mkdir -p "$PAI_DIR/skills/Prompting/Templates/Partials"
+mkdir -p "$PAI_DIR/skills/Prompting/Tools"
+```
+
+**Mark todo as completed.**
+
+### 4.2 Copy Skill Files
+
+**Mark todo "Copy skill files from pack" as in_progress.**
+
+```bash
+# From the pack directory (where this INSTALL.md is located)
+PACK_DIR="$(pwd)"
+PAI_DIR="${PAI_DIR:-$HOME/.claude}"
+
+cp "$PACK_DIR/src/skills/Prompting/SKILL.md" "$PAI_DIR/skills/Prompting/"
+cp "$PACK_DIR/src/skills/Prompting/Standards.md" "$PAI_DIR/skills/Prompting/"
+cp "$PACK_DIR/src/skills/Prompting/Templates/README.md" "$PAI_DIR/skills/Prompting/Templates/"
+```
+
+**Files copied:**
+- `SKILL.md` - Main skill routing and meta-prompting system
+- `Standards.md` - Prompt engineering best practices and patterns
+- `Templates/README.md` - Template system documentation
+
+**Mark todo as completed.**
+
+### 4.3 Copy Template Primitives
+
+**Mark todo "Copy template primitives" as in_progress.**
+
+```bash
+PACK_DIR="$(pwd)"
+PAI_DIR="${PAI_DIR:-$HOME/.claude}"
+
+# Copy primitive templates
+cp "$PACK_DIR/src/skills/Prompting/Templates/Primitives/Roster.hbs" "$PAI_DIR/skills/Prompting/Templates/Primitives/"
+cp "$PACK_DIR/src/skills/Prompting/Templates/Primitives/Voice.hbs" "$PAI_DIR/skills/Prompting/Templates/Primitives/"
+cp "$PACK_DIR/src/skills/Prompting/Templates/Primitives/Structure.hbs" "$PAI_DIR/skills/Prompting/Templates/Primitives/"
+cp "$PACK_DIR/src/skills/Prompting/Templates/Primitives/Briefing.hbs" "$PAI_DIR/skills/Prompting/Templates/Primitives/"
+cp "$PACK_DIR/src/skills/Prompting/Templates/Primitives/Gate.hbs" "$PAI_DIR/skills/Prompting/Templates/Primitives/"
+```
+
+**Primitives copied:**
+- `Roster.hbs` - Agent roster template
+- `Voice.hbs` - Voice/persona configuration
+- `Structure.hbs` - Output structure template
+- `Briefing.hbs` - Task briefing template
+- `Gate.hbs` - Quality gate template
+
+**Mark todo as completed.**
+
+### 4.4 Copy Tools
+
+**Mark todo "Copy tools" as in_progress.**
+
+```bash
+PACK_DIR="$(pwd)"
+PAI_DIR="${PAI_DIR:-$HOME/.claude}"
+
+cp "$PACK_DIR/src/skills/Prompting/Tools/RenderTemplate.ts" "$PAI_DIR/skills/Prompting/Tools/"
+cp "$PACK_DIR/src/skills/Prompting/Tools/ValidateTemplate.ts" "$PAI_DIR/skills/Prompting/Tools/"
+```
+
+**Tools copied:**
+- `RenderTemplate.ts` - Renders Handlebars templates with YAML data
+- `ValidateTemplate.ts` - Validates template syntax and data structure
+
+**Mark todo as completed.**
+
+### 4.5 Install Dependencies
+
+**Mark todo "Install dependencies" as in_progress.**
+
+```bash
+PAI_DIR="${PAI_DIR:-$HOME/.claude}"
+cd "$PAI_DIR/skills/Prompting/Tools"
+bun add handlebars yaml
+```
+
+**Mark todo as completed.**
+
+---
+
+## Phase 5: Verification
+
+**Mark todo "Run verification" as in_progress.**
+
+**Execute all checks from VERIFY.md:**
```bash
-mkdir -p $PAI_DIR/skills/Prompting/Templates/Primitives
-mkdir -p $PAI_DIR/skills/Prompting/Templates/Data/Examples
-mkdir -p $PAI_DIR/skills/Prompting/Templates/Compiled
-mkdir -p $PAI_DIR/skills/Prompting/Tools
+PAI_DIR="${PAI_DIR:-$HOME/.claude}"
+
+echo "=== PAI Prompting Skill Verification ==="
+
+# Check skill files exist
+echo "Checking skill files..."
+[ -f "$PAI_DIR/skills/Prompting/SKILL.md" ] && echo "✓ SKILL.md" || echo "❌ SKILL.md missing"
+[ -f "$PAI_DIR/skills/Prompting/Standards.md" ] && echo "✓ Standards.md" || echo "❌ Standards.md missing"
+
+# Check template files
+echo ""
+echo "Checking template primitives..."
+[ -f "$PAI_DIR/skills/Prompting/Templates/Primitives/Roster.hbs" ] && echo "✓ Roster.hbs" || echo "❌ Roster.hbs missing"
+[ -f "$PAI_DIR/skills/Prompting/Templates/Primitives/Voice.hbs" ] && echo "✓ Voice.hbs" || echo "❌ Voice.hbs missing"
+[ -f "$PAI_DIR/skills/Prompting/Templates/Primitives/Structure.hbs" ] && echo "✓ Structure.hbs" || echo "❌ Structure.hbs missing"
+[ -f "$PAI_DIR/skills/Prompting/Templates/Primitives/Briefing.hbs" ] && echo "✓ Briefing.hbs" || echo "❌ Briefing.hbs missing"
+[ -f "$PAI_DIR/skills/Prompting/Templates/Primitives/Gate.hbs" ] && echo "✓ Gate.hbs" || echo "❌ Gate.hbs missing"
+
+# Check tools
+echo ""
+echo "Checking tools..."
+[ -f "$PAI_DIR/skills/Prompting/Tools/RenderTemplate.ts" ] && echo "✓ RenderTemplate.ts" || echo "❌ RenderTemplate.ts missing"
+[ -f "$PAI_DIR/skills/Prompting/Tools/ValidateTemplate.ts" ] && echo "✓ ValidateTemplate.ts" || echo "❌ ValidateTemplate.ts missing"
+
+# Test RenderTemplate CLI
+echo ""
+echo "Testing RenderTemplate..."
+bun run "$PAI_DIR/skills/Prompting/Tools/RenderTemplate.ts" --help | head -5
+
+echo "=== Verification Complete ==="
```
-## Step 2: Copy Files
+**Mark todo as completed when all checks pass.**
+
+---
+
+## Success/Failure Messages
-Copy files from this pack to your PAI installation:
+### On Success
-| Source | Destination |
-|--------|-------------|
-| `src/skills/Prompting/SKILL.md` | `$PAI_DIR/skills/Prompting/SKILL.md` |
-| `src/skills/Prompting/Standards.md` | `$PAI_DIR/skills/Prompting/Standards.md` |
-| `src/skills/Prompting/Templates/README.md` | `$PAI_DIR/skills/Prompting/Templates/README.md` |
-| `src/skills/Prompting/Templates/Primitives/Roster.hbs` | `$PAI_DIR/skills/Prompting/Templates/Primitives/Roster.hbs` |
-| `src/skills/Prompting/Templates/Primitives/Voice.hbs` | `$PAI_DIR/skills/Prompting/Templates/Primitives/Voice.hbs` |
-| `src/skills/Prompting/Templates/Primitives/Structure.hbs` | `$PAI_DIR/skills/Prompting/Templates/Primitives/Structure.hbs` |
-| `src/skills/Prompting/Templates/Primitives/Briefing.hbs` | `$PAI_DIR/skills/Prompting/Templates/Primitives/Briefing.hbs` |
-| `src/skills/Prompting/Templates/Primitives/Gate.hbs` | `$PAI_DIR/skills/Prompting/Templates/Primitives/Gate.hbs` |
-| `src/skills/Prompting/Tools/RenderTemplate.ts` | `$PAI_DIR/skills/Prompting/Tools/RenderTemplate.ts` |
-| `src/skills/Prompting/Tools/ValidateTemplate.ts` | `$PAI_DIR/skills/Prompting/Tools/ValidateTemplate.ts` |
+```
+"PAI Prompting Skill v1.0.0 installed successfully!
+
+What's available:
+- 5 template primitives (Roster, Voice, Structure, Briefing, Gate)
+- RenderTemplate.ts - Compile templates with YAML data
+- ValidateTemplate.ts - Validate template syntax
+- Standards.md - Prompt engineering best practices
+
+Try it: Ask me to 'render a briefing template' or 'validate my prompt template'"
+```
+
+### On Failure
+
+```
+"Installation encountered issues. Here's what to check:
+
+1. Ensure pai-core-install is installed first
+2. Verify Bun is installed: `bun --version`
+3. Check directory permissions on $PAI_DIR/skills/
+4. Verify handlebars and yaml packages installed
+5. Run the verification commands in VERIFY.md
+
+Need help? Check the Troubleshooting section below."
+```
+
+---
+
+## Troubleshooting
+
+### "pai-core-install not found"
+
+This pack requires pai-core-install. Install it first:
+```
+Give the AI the pai-core-install pack directory and ask it to install.
+```
+
+### "bun: command not found"
+
+```bash
+# Install Bun
+curl -fsSL https://bun.sh/install | bash
+# Restart terminal or source ~/.bashrc
+```
-## Step 3: Install Dependencies
+### Template rendering fails
```bash
+# Check dependencies are installed
cd $PAI_DIR/skills/Prompting/Tools
-bun init -y
+bun install
+
+# Or reinstall
bun add handlebars yaml
```
-## Step 4: Generate Skill Index (If Using pai-core-install)
+### "Cannot find module 'handlebars'"
```bash
-bun run $PAI_DIR/Tools/GenerateSkillIndex.ts
+# Reinstall dependencies
+cd $PAI_DIR/skills/Prompting/Tools
+rm -rf node_modules bun.lockb
+bun add handlebars yaml
```
-## Step 5: Update Architecture
+### Template validation errors
```bash
-bun run $PAI_DIR/Tools/PaiArchitecture.ts log-upgrade "Installed pai-prompting-skill v1.0.0" pack
-bun run $PAI_DIR/Tools/PaiArchitecture.ts generate
+# Validate template syntax
+bun run $PAI_DIR/skills/Prompting/Tools/ValidateTemplate.ts \
+ --template "$PAI_DIR/skills/Prompting/Templates/Primitives/Briefing.hbs"
```
-## Customization
+---
-### Create Your Own Templates
+## What's Included
-1. Create a new `.hbs` file in `Templates/Primitives/` or a new subdirectory
-2. Follow Handlebars syntax
-3. Document the expected data structure in the template header
-4. Test with sample data before production use
+| File | Purpose |
+|------|---------|
+| `SKILL.md` | Main skill definition with workflow routing |
+| `Standards.md` | Prompt engineering best practices |
+| `Templates/README.md` | Template system documentation |
+| `Templates/Primitives/Roster.hbs` | Agent roster template |
+| `Templates/Primitives/Voice.hbs` | Voice/persona configuration |
+| `Templates/Primitives/Structure.hbs` | Output structure template |
+| `Templates/Primitives/Briefing.hbs` | Task briefing template |
+| `Templates/Primitives/Gate.hbs` | Quality gate template |
+| `Tools/RenderTemplate.ts` | Template rendering CLI |
+| `Tools/ValidateTemplate.ts` | Template validation CLI |
-### Extend the Helpers
+---
-Add custom Handlebars helpers in `Tools/RenderTemplate.ts`:
+## Usage
-```typescript
-Handlebars.registerHelper('myHelper', (value: string) => {
- // Your custom logic
- return transformedValue;
-});
+### From Claude Code
+
+```
+"Render the briefing template with this task data"
+"Validate my custom template for syntax errors"
+"Show me prompt engineering standards"
+"Create a new primitive template for X"
```
-### Optional Extensions
+### CLI Examples
+
+```bash
+# Render a template with YAML data
+bun run $PAI_DIR/skills/Prompting/Tools/RenderTemplate.ts \
+ --template "Primitives/Briefing.hbs" \
+ --data "path/to/briefing-data.yaml"
+
+# Validate template syntax
+bun run $PAI_DIR/skills/Prompting/Tools/ValidateTemplate.ts \
+ --template "Primitives/Gate.hbs"
+
+# Render to file
+bun run $PAI_DIR/skills/Prompting/Tools/RenderTemplate.ts \
+ --template "Primitives/Roster.hbs" \
+ --data "agents.yaml" \
+ --output "compiled/agent-roster.md"
+```
-| Customization | Location | Impact |
-|---------------|----------|--------|
-| **Add Eval Templates** | `Templates/Evals/` | LLM-as-Judge patterns |
-| **Create Partials** | `Templates/Partials/` | Reusable template fragments |
-| **Add Data Files** | `Templates/Data/` | Pre-configured YAML sources |
-| **Extend Standards** | `Standards.md` | Project-specific guidelines |
+---
## Integration with Other Skills
### Agents Skill
-```typescript
-import { renderTemplate } from '$PAI_DIR/skills/Prompting/Tools/RenderTemplate.ts';
-
-const prompt = renderTemplate({
- templatePath: 'Primitives/Briefing.hbs',
- dataPath: 'path/to/briefing-data.yaml'
-});
+Use prompting templates to generate agent system prompts:
+```bash
+bun run $PAI_DIR/skills/Prompting/Tools/RenderTemplate.ts \
+ --template "Primitives/Briefing.hbs" \
+ --data "agent-config.yaml"
```
### Evals Skill
-The Prompting skill can host eval-specific templates (`Judge.hbs`, `Rubric.hbs`) that the Evals skill references.
+The Prompting skill hosts eval-specific templates (`Judge.hbs`, `Rubric.hbs`) that the Evals skill references for LLM-as-Judge patterns.
+
+### THEALGORITHM Skill
+
+Reference `Standards.md` for prompt best practices during ISC creation and capability selection.
+
+---
+
+## Creating Custom Templates
+
+### Add New Primitives
+
+1. Create a new `.hbs` file in `Templates/Primitives/`
+2. Follow Handlebars syntax
+3. Document expected data structure in template header
+4. Validate with `ValidateTemplate.ts`
+
+### Extend Helpers
+
+Add custom Handlebars helpers in `Tools/RenderTemplate.ts`:
+
+```typescript
+Handlebars.registerHelper('myHelper', (value: string) => {
+ // Your custom logic
+ return transformedValue;
+});
+```
-### Development Skill
+### Template Categories
-Reference `Standards.md` for prompt best practices during spec-driven development.
+| Category | Location | Purpose |
+|----------|----------|---------|
+| Primitives | `Templates/Primitives/` | Core building blocks |
+| Evals | `Templates/Evals/` | LLM-as-Judge patterns |
+| Partials | `Templates/Partials/` | Reusable fragments |
+| Data | `Templates/Data/` | Pre-configured YAML sources |
+| Compiled | `Templates/Compiled/` | Rendered output cache |
diff --git a/Packs/pai-upgrades-skill/INSTALL.md b/Packs/pai-upgrades-skill/INSTALL.md
index 0968e5ae..a8571942 100644
--- a/Packs/pai-upgrades-skill/INSTALL.md
+++ b/Packs/pai-upgrades-skill/INSTALL.md
@@ -1,58 +1,241 @@
-# PAI Upgrades Skill Installation
+# PAI Upgrades Skill v1.0.0 - Installation Guide
-> **FOR AI AGENTS:** Follow these steps in order. Complete each step fully before proceeding.
+**This guide is designed for AI agents installing this pack into a user's infrastructure.**
---
-## Prerequisites
+## AI Agent Instructions
-- pai-core-install must be installed (provides skills directory structure)
-- [yt-dlp](https://github.com/yt-dlp/yt-dlp) for YouTube monitoring (optional)
+**This is a wizard-style installation.** Use Claude Code's native tools to guide the user through installation:
+
+1. **AskUserQuestion** - For user decisions and confirmations
+2. **TodoWrite** - For progress tracking
+3. **Bash/Read/Write** - For actual installation
+4. **VERIFY.md** - For final validation
+
+### Welcome Message
+
+Before starting, greet the user:
+```
+"I'm installing PAI Upgrades Skill v1.0.0 - Monitor Anthropic ecosystem and AI YouTube channels for updates.
+
+Let me analyze your system and guide you through installation."
+```
---
-## Installation Steps
+## Phase 1: System Analysis
-### Step 1: Create Directory Structure
+**Execute this analysis BEFORE any file operations.**
+
+### 1.1 Run These Commands
```bash
-mkdir -p ~/.claude/skills/Upgrades/{Workflows,Tools,State}
-mkdir -p ~/.claude/SKILLCUSTOMIZATIONS/Upgrades
+# Check for PAI directory
+PAI_CHECK="${PAI_DIR:-$HOME/.claude}"
+echo "PAI_DIR: $PAI_CHECK"
+
+# Check if pai-core-install is installed (REQUIRED)
+if [ -f "$PAI_CHECK/skills/CORE/SKILL.md" ]; then
+ echo "✓ pai-core-install is installed"
+else
+ echo "❌ pai-core-install NOT installed - REQUIRED!"
+fi
+
+# Check for existing Upgrades skill
+if [ -d "$PAI_CHECK/skills/Upgrades" ]; then
+ echo "⚠️ Existing Upgrades skill found at: $PAI_CHECK/skills/Upgrades"
+ ls -la "$PAI_CHECK/skills/Upgrades/"
+else
+ echo "✓ No existing Upgrades skill (clean install)"
+fi
+
+# Check for yt-dlp (optional)
+if command -v yt-dlp &> /dev/null; then
+ echo "✓ yt-dlp is installed: $(yt-dlp --version)"
+else
+ echo "⚠️ yt-dlp not installed (optional - needed for YouTube monitoring)"
+fi
+```
+
+### 1.2 Present Findings
+
+Tell the user what you found:
+```
+"Here's what I found on your system:
+- pai-core-install: [installed / NOT INSTALLED - REQUIRED]
+- Existing Upgrades skill: [Yes at path / No]
+- yt-dlp: [installed vX.X / NOT INSTALLED (optional)]"
+```
+
+**STOP if pai-core-install is not installed.** Tell the user:
+```
+"pai-core-install is required. Please install it first, then return to install this pack."
```
-### Step 2: Copy Skill Files
+---
+
+## Phase 2: User Questions
-Copy all files from `src/skills/Upgrades/` to `~/.claude/skills/Upgrades/`:
+**Use AskUserQuestion tool at each decision point.**
+
+### Question 1: yt-dlp Installation (if missing)
+
+**Only ask if yt-dlp is NOT installed:**
+
+```json
+{
+ "header": "yt-dlp",
+ "question": "yt-dlp is not installed. It's needed for YouTube channel monitoring. Should I install it?",
+ "multiSelect": false,
+ "options": [
+ {"label": "Yes, install yt-dlp (Recommended)", "description": "Installs via Homebrew for YouTube video detection"},
+ {"label": "Skip - I'll install manually", "description": "YouTube monitoring won't work until you install it"}
+ ]
+}
+```
+
+### Question 2: Conflict Resolution (if existing found)
+
+**Only ask if existing Upgrades skill detected:**
+
+```json
+{
+ "header": "Conflict",
+ "question": "Existing Upgrades skill detected. How should I proceed?",
+ "multiSelect": false,
+ "options": [
+ {"label": "Backup and Replace (Recommended)", "description": "Creates timestamped backup, then installs new version"},
+ {"label": "Replace Without Backup", "description": "Overwrites existing without backup"},
+ {"label": "Abort Installation", "description": "Cancel installation, keep existing"}
+ ]
+}
+```
+
+### Question 3: YouTube Channels
+
+```json
+{
+ "header": "Channels",
+ "question": "Would you like to configure YouTube channels for AI development content?",
+ "multiSelect": false,
+ "options": [
+ {"label": "Yes, set up channels (Recommended)", "description": "Creates customization file with example channel"},
+ {"label": "Skip for now", "description": "You can add channels later via SKILLCUSTOMIZATIONS"}
+ ]
+}
+```
+
+### Question 4: Final Confirmation
+
+```json
+{
+ "header": "Install",
+ "question": "Ready to install PAI Upgrades Skill v1.0.0?",
+ "multiSelect": false,
+ "options": [
+ {"label": "Yes, install now (Recommended)", "description": "Proceeds with installation using choices above"},
+ {"label": "Show me what will change", "description": "Lists all files that will be created/modified"},
+ {"label": "Cancel", "description": "Abort installation"}
+ ]
+}
+```
+
+---
+
+## Phase 3: Backup (If Needed)
+
+**Only execute if user chose "Backup and Replace":**
```bash
-# From this pack's src directory
-cp -r src/skills/Upgrades/* ~/.claude/skills/Upgrades/
+PAI_DIR="${PAI_DIR:-$HOME/.claude}"
+BACKUP_DIR="$PAI_DIR/Backups/upgrades-skill-$(date +%Y%m%d-%H%M%S)"
+mkdir -p "$BACKUP_DIR"
+[ -d "$PAI_DIR/skills/Upgrades" ] && cp -r "$PAI_DIR/skills/Upgrades" "$BACKUP_DIR/"
+echo "Backup created at: $BACKUP_DIR"
```
-**Files to copy:**
+---
+
+## Phase 4: Installation
+
+**Create a TodoWrite list to track progress:**
+
+```json
+{
+ "todos": [
+ {"content": "Create skill directory structure", "status": "pending", "activeForm": "Creating directory structure"},
+ {"content": "Copy skill files from pack", "status": "pending", "activeForm": "Copying skill files"},
+ {"content": "Initialize state files", "status": "pending", "activeForm": "Initializing state files"},
+ {"content": "Set up YouTube customization", "status": "pending", "activeForm": "Setting up YouTube customization"},
+ {"content": "Install yt-dlp", "status": "pending", "activeForm": "Installing yt-dlp"},
+ {"content": "Run verification", "status": "pending", "activeForm": "Running verification"}
+ ]
+}
+```
+
+### 4.1 Create Skill Directory Structure
+
+**Mark todo "Create skill directory structure" as in_progress.**
+
+```bash
+PAI_DIR="${PAI_DIR:-$HOME/.claude}"
+mkdir -p $PAI_DIR/skills/Upgrades/{Workflows,Tools,State}
+mkdir -p $PAI_DIR/SKILLCUSTOMIZATIONS/Upgrades
+```
+
+**Mark todo as completed.**
+
+### 4.2 Copy Skill Files
+
+**Mark todo "Copy skill files from pack" as in_progress.**
+
+Copy all files from the pack's `src/skills/Upgrades/` directory:
+
+```bash
+# From the pack directory (where this INSTALL.md is located)
+PACK_DIR="$(pwd)"
+PAI_DIR="${PAI_DIR:-$HOME/.claude}"
+
+cp "$PACK_DIR/src/skills/Upgrades/SKILL.md" "$PAI_DIR/skills/Upgrades/"
+cp "$PACK_DIR/src/skills/Upgrades/sources.json" "$PAI_DIR/skills/Upgrades/"
+cp "$PACK_DIR/src/skills/Upgrades/youtube-channels.json" "$PAI_DIR/skills/Upgrades/"
+cp "$PACK_DIR/src/skills/Upgrades/Workflows/"*.md "$PAI_DIR/skills/Upgrades/Workflows/"
+cp "$PACK_DIR/src/skills/Upgrades/Tools/"*.ts "$PAI_DIR/skills/Upgrades/Tools/"
+```
+
+**Files copied:**
- `SKILL.md` - Main skill routing
-- `sources.json` - Anthropic sources configuration
-- `youtube-channels.json` - Base channels (empty)
-- `Workflows/Anthropic.md` - Anthropic check workflow
+- `sources.json` - 30+ Anthropic sources configuration
+- `youtube-channels.json` - Base channels template
+- `Workflows/Anthropic.md` - Anthropic update check workflow
- `Workflows/YouTube.md` - YouTube monitoring workflow
- `Workflows/ReleaseNotesDeepDive.md` - Deep research workflow
-- `Tools/Anthropic.ts` - Source checking tool
+- `Tools/Anthropic.ts` - Source checking CLI tool
+
+**Mark todo as completed.**
-### Step 3: Initialize State Directory
+### 4.3 Initialize State Files
-Create empty state files:
+**Mark todo "Initialize state files" as in_progress.**
```bash
-echo '{"last_check_timestamp": null, "sources": {}}' > ~/.claude/skills/Upgrades/State/last-check.json
-echo '{"last_check_timestamp": null, "channels": {}}' > ~/.claude/skills/Upgrades/State/youtube-videos.json
+PAI_DIR="${PAI_DIR:-$HOME/.claude}"
+echo '{"last_check_timestamp": null, "sources": {}}' > "$PAI_DIR/skills/Upgrades/State/last-check.json"
+echo '{"last_check_timestamp": null, "channels": {}}' > "$PAI_DIR/skills/Upgrades/State/youtube-videos.json"
```
-### Step 4: Set Up YouTube Customization (Optional)
+**Mark todo as completed.**
-Create your personal YouTube channels file:
+### 4.4 Set Up YouTube Customization (If User Chose Yes)
+
+**Mark todo "Set up YouTube customization" as in_progress.**
+
+**Only execute if user chose to set up channels:**
```bash
-cat > ~/.claude/SKILLCUSTOMIZATIONS/Upgrades/youtube-channels.json << 'EOF'
+PAI_DIR="${PAI_DIR:-$HOME/.claude}"
+cat > "$PAI_DIR/SKILLCUSTOMIZATIONS/Upgrades/youtube-channels.json" << 'EOF'
{
"_customization": {
"description": "Your personal YouTube channels for AI development content",
@@ -71,73 +254,105 @@ cat > ~/.claude/SKILLCUSTOMIZATIONS/Upgrades/youtube-channels.json << 'EOF'
EOF
```
-Add more channels by editing this file.
+**Mark todo as completed (or skip if user declined).**
+
+### 4.5 Install yt-dlp (If User Chose Yes)
-### Step 5: Create Customization Extension Manifest (Optional)
+**Mark todo "Install yt-dlp" as in_progress.**
+
+**Only execute if user chose to install yt-dlp:**
```bash
-cat > ~/.claude/SKILLCUSTOMIZATIONS/Upgrades/EXTEND.yaml << 'EOF'
-# Extension manifest for Upgrades skill customization
-skill: Upgrades
-version: 1.0.0
-files:
- - youtube-channels.json # Your personal YouTube channels
-EOF
+brew install yt-dlp
```
-### Step 6: Install yt-dlp (Optional, for YouTube Monitoring)
+**Mark todo as completed (or skip if user declined).**
+
+---
+
+## Phase 5: Verification
+
+**Mark todo "Run verification" as in_progress.**
+
+**Execute all checks from VERIFY.md:**
```bash
-# macOS
-brew install yt-dlp
+PAI_DIR="${PAI_DIR:-$HOME/.claude}"
-# Or via pip
-pip install yt-dlp
-```
+echo "=== PAI Upgrades Skill Verification ==="
+
+# Check skill directory
+echo "Checking skill directory..."
+ls -la "$PAI_DIR/skills/Upgrades/" || echo "❌ Skill directory missing"
+
+# Check workflow files
+echo "Checking workflows..."
+ls "$PAI_DIR/skills/Upgrades/Workflows/" || echo "❌ Workflows missing"
+
+# Check tools
+echo "Checking tools..."
+ls "$PAI_DIR/skills/Upgrades/Tools/" || echo "❌ Tools missing"
+
+# Check state files
+echo "Checking state files..."
+cat "$PAI_DIR/skills/Upgrades/State/last-check.json" | head -1 || echo "❌ State files missing"
-### Step 7: Verify Installation
+# Verify JSON validity
+python3 -c "import json; json.load(open('$PAI_DIR/skills/Upgrades/State/last-check.json'))" && echo "✓ State JSON valid"
-Run the verification checklist in `VERIFY.md`.
+echo "=== Verification Complete ==="
+```
+
+**Mark todo as completed when all checks pass.**
---
-## Post-Installation
+## Success/Failure Messages
-### Add More YouTube Channels
+### On Success
-Edit your customization file:
-```bash
-~/.claude/SKILLCUSTOMIZATIONS/Upgrades/youtube-channels.json
```
+"PAI Upgrades Skill v1.0.0 installed successfully!
-Add channels in this format:
-```json
-{
- "name": "Channel Name",
- "channel_id": "@channelhandle",
- "url": "https://www.youtube.com/@channelhandle",
- "priority": "HIGH",
- "description": "What this channel covers"
-}
+What's available:
+- 'check for updates' - Monitor 30+ Anthropic sources
+- 'check YouTube' - Monitor AI development channels
+- 'deep dive release notes' - Research new features in depth
+
+Try it: Ask me to 'check for Anthropic updates'"
```
-### Test the Skill
+### On Failure
```
-"Check for Anthropic updates"
-"Any new videos from my YouTube channels?"
-"Deep dive the latest Claude Code release notes"
+"Installation encountered issues. Here's what to check:
+
+1. Ensure pai-core-install is installed first
+2. Check directory permissions on ~/.claude/skills/
+3. Run the verification commands in VERIFY.md
+
+Need help? Check the Troubleshooting section below."
```
---
## Troubleshooting
-### "yt-dlp not found"
+### "pai-core-install not found"
+
+This pack requires pai-core-install. Install it first:
+```
+Give the AI the pai-core-install pack directory and ask it to install.
+```
+
+### "yt-dlp not found" (after installation)
-Install yt-dlp:
```bash
+# Verify Homebrew installation
brew install yt-dlp
+
+# Or use pip
+pip install yt-dlp
```
### State files not updating
@@ -145,21 +360,46 @@ brew install yt-dlp
Check permissions:
```bash
ls -la ~/.claude/skills/Upgrades/State/
+chmod 644 ~/.claude/skills/Upgrades/State/*.json
```
### YouTube channels not loading
-Verify customization file exists:
+Verify customization file:
```bash
cat ~/.claude/SKILLCUSTOMIZATIONS/Upgrades/youtube-channels.json
+# Should show valid JSON with channels array
```
---
-## Next Steps
+## What's Included
+
+| File | Purpose |
+|------|---------|
+| `SKILL.md` | Main skill definition with workflow routing |
+| `sources.json` | 30+ Anthropic sources (blogs, repos, changelogs) |
+| `youtube-channels.json` | Base template for channel monitoring |
+| `Workflows/Anthropic.md` | Check all Anthropic sources |
+| `Workflows/YouTube.md` | Monitor configured channels |
+| `Workflows/ReleaseNotesDeepDive.md` | Deep research workflow |
+| `Tools/Anthropic.ts` | CLI tool for source checking |
+
+---
+
+## Usage
-After installation:
-1. Add your preferred YouTube channels to the customization file
-2. Run "check for updates" to test Anthropic monitoring
-3. Run "check YouTube" to test channel monitoring
-4. Use "deep dive release notes" after major Claude Code releases
+### From Claude Code
+
+```
+"Check for Anthropic updates"
+"Any new AI development videos?"
+"Deep dive the latest Claude Code release notes"
+```
+
+### Testing Installation
+
+```
+"What sources does the Upgrades skill monitor?"
+# Should list blogs, GitHub repos, changelogs, documentation
+```
diff --git a/Packs/pai-voice-system/INSTALL.md b/Packs/pai-voice-system/INSTALL.md
index f835a031..75e663b4 100644
--- a/Packs/pai-voice-system/INSTALL.md
+++ b/Packs/pai-voice-system/INSTALL.md
@@ -1,225 +1,507 @@
-# PAI Voice System - Installation Guide
+# PAI Voice System v1.0.0 - Installation Guide
-## Prerequisites
+**This guide is designed for AI agents installing this pack into a user's infrastructure.**
-- **Bun runtime**: `curl -fsSL https://bun.sh/install | bash`
-- **macOS**: Currently the primary supported platform
-- **ElevenLabs account**: [elevenlabs.io](https://elevenlabs.io) - API key required
-- **Required PAI Packs** (install these first):
- - `pai-hook-system` - Foundation hook infrastructure
- - `pai-core-install` - Skills, identity, and response format
+---
+
+## AI Agent Instructions
+
+**This is a wizard-style installation.** Use Claude Code's native tools to guide the user through installation:
+
+1. **AskUserQuestion** - For user decisions and confirmations
+2. **TodoWrite** - For progress tracking
+3. **Bash/Read/Write** - For actual installation
+4. **VERIFY.md** - For final validation
+
+### Welcome Message
+
+Before starting, greet the user:
+```
+"I'm installing PAI Voice System v1.0.0 - Text-to-speech voice output for your AI assistant using ElevenLabs.
+
+Let me analyze your system and guide you through installation."
+```
---
-## Pre-Installation: System Analysis
+## Phase 1: System Analysis
+
+**Execute this analysis BEFORE any file operations.**
-### Step 0.1: Verify Required Dependencies
+### 1.1 Run These Commands
```bash
-PAI_CHECK="${PAI_DIR:-$HOME/.config/pai}"
+# Check for PAI directory
+PAI_CHECK="${PAI_DIR:-$HOME/.claude}"
+echo "PAI_DIR: $PAI_CHECK"
-echo "=== Checking Required Dependencies ==="
+# Check if pai-core-install is installed (REQUIRED)
+if [ -f "$PAI_CHECK/skills/CORE/SKILL.md" ]; then
+ echo "✓ pai-core-install is installed"
+else
+ echo "❌ pai-core-install NOT installed - REQUIRED!"
+fi
-# Check hook system (REQUIRED)
-if [ -d "$PAI_CHECK/hooks" ]; then
+# Check if pai-hook-system is installed (REQUIRED)
+if [ -f "$PAI_CHECK/hooks/lib/observability.ts" ]; then
echo "✓ pai-hook-system is installed"
else
echo "❌ pai-hook-system NOT installed - REQUIRED!"
fi
-# Check core install (REQUIRED)
-if [ -d "$PAI_CHECK/skills" ] && [ -f "$PAI_CHECK/skills/CORE/SKILL.md" ]; then
- echo "✓ pai-core-install is installed"
+# Check for existing VoiceServer
+if [ -d "$PAI_CHECK/VoiceServer" ]; then
+ echo "⚠️ Existing VoiceServer found at: $PAI_CHECK/VoiceServer"
+ ls -la "$PAI_CHECK/VoiceServer/"
else
- echo "❌ pai-core-install NOT installed - REQUIRED!"
+ echo "✓ No existing VoiceServer (clean install)"
fi
-```
-### Step 0.2: Check Port Availability
+# Check for Bun runtime
+if command -v bun &> /dev/null; then
+ echo "✓ Bun is installed: $(bun --version)"
+else
+ echo "❌ Bun not installed - REQUIRED!"
+fi
-```bash
-# Check if default port 8888 is available
-if lsof -i :8888 > /dev/null 2>&1; then
- echo "⚠️ Port 8888 is IN USE"
- lsof -i :8888 | head -5
- echo ""
- echo "Options:"
- echo " 1. Stop the service using port 8888"
- echo " 2. Use a different port (set VOICE_SERVER_PORT in ~/.env)"
+# Check for ElevenLabs API key
+echo ""
+echo "API Key Status:"
+[ -n "$ELEVENLABS_API_KEY" ] && echo "✓ ELEVENLABS_API_KEY: Set" || echo "⚠️ ELEVENLABS_API_KEY: NOT SET (required for voice)"
+
+# Check for port availability
+if lsof -i :8888 &> /dev/null; then
+ echo "⚠️ Port 8888 is in use"
+ lsof -i :8888 | head -3
+else
+ echo "✓ Port 8888 is available (voice server)"
+fi
+
+# Check macOS audio
+if command -v afplay &> /dev/null; then
+ echo "✓ afplay available (macOS audio)"
else
- echo "✓ Port 8888 is available"
+ echo "⚠️ afplay not found (may need alternative audio player)"
fi
```
+### 1.2 Present Findings
+
+Tell the user what you found:
+```
+"Here's what I found on your system:
+- pai-core-install: [installed / NOT INSTALLED - REQUIRED]
+- pai-hook-system: [installed / NOT INSTALLED - REQUIRED]
+- Existing VoiceServer: [Yes at path / No]
+- Bun runtime: [installed vX.X / NOT INSTALLED - REQUIRED]
+- ELEVENLABS_API_KEY: [set / not set]
+- Port 8888: [available / in use]
+- Audio playback: [afplay available / not available]"
+```
+
+**STOP if pai-core-install, pai-hook-system, or Bun is not installed.** Tell the user:
+```
+"pai-core-install and pai-hook-system are required. Please install them first, then return to install this pack.
+
+Install order:
+1. pai-core-install
+2. pai-hook-system
+3. pai-voice-system (this pack)"
+```
+
---
-## Step 1: Create Directory Structure
+## Phase 2: User Questions
-```bash
-PAI_DIR="${PAI_DIR:-$HOME/.config/pai}"
+**Use AskUserQuestion tool at each decision point.**
+
+### Question 1: Conflict Resolution (if existing found)
+
+**Only ask if existing VoiceServer detected:**
+
+```json
+{
+ "header": "Conflict",
+ "question": "Existing VoiceServer detected. How should I proceed?",
+ "multiSelect": false,
+ "options": [
+ {"label": "Backup and Replace (Recommended)", "description": "Creates timestamped backup, then installs new version"},
+ {"label": "Replace Without Backup", "description": "Overwrites existing without backup"},
+ {"label": "Abort Installation", "description": "Cancel installation, keep existing"}
+ ]
+}
+```
+
+### Question 2: ElevenLabs Setup
+
+**Only ask if ELEVENLABS_API_KEY is not set:**
+
+```json
+{
+ "header": "API Key",
+ "question": "ElevenLabs API key not found. How should I proceed?",
+ "multiSelect": false,
+ "options": [
+ {"label": "Create .env template (Recommended)", "description": "Creates template file for you to add API key later"},
+ {"label": "I'll set it manually", "description": "Skip .env creation, set key in shell profile"},
+ {"label": "Continue without voice", "description": "Install server but voice won't work until key is set"}
+ ]
+}
+```
+
+### Question 3: Auto-Start Configuration
+
+```json
+{
+ "header": "Auto-Start",
+ "question": "How should the voice server start?",
+ "multiSelect": false,
+ "options": [
+ {"label": "Manual start (Recommended)", "description": "Start with manage.sh when you want voice output"},
+ {"label": "Start on login", "description": "Create a LaunchAgent to auto-start (macOS only)"}
+ ]
+}
+```
-mkdir -p $PAI_DIR/hooks/lib
-mkdir -p $PAI_DIR/voice-server
+### Question 4: Final Confirmation
+
+```json
+{
+ "header": "Install",
+ "question": "Ready to install PAI Voice System v1.0.0?",
+ "multiSelect": false,
+ "options": [
+ {"label": "Yes, install now (Recommended)", "description": "Proceeds with installation using choices above"},
+ {"label": "Show me what will change", "description": "Lists all files that will be created/modified"},
+ {"label": "Cancel", "description": "Abort installation"}
+ ]
+}
```
---
-## Step 2: Install Voice Server
+## Phase 3: Backup (If Needed)
-Copy the voice server files:
+**Only execute if user chose "Backup and Replace":**
```bash
-# From pack directory
-cp src/voice/server.ts $PAI_DIR/voice-server/server.ts
-cp src/voice/manage.sh $PAI_DIR/voice-server/manage.sh
-chmod +x $PAI_DIR/voice-server/manage.sh
+PAI_DIR="${PAI_DIR:-$HOME/.claude}"
+BACKUP_DIR="$PAI_DIR/Backups/voice-system-$(date +%Y%m%d-%H%M%S)"
+mkdir -p "$BACKUP_DIR"
+[ -d "$PAI_DIR/VoiceServer" ] && cp -r "$PAI_DIR/VoiceServer" "$BACKUP_DIR/"
+echo "Backup created at: $BACKUP_DIR"
```
---
-## Step 3: Install Prosody Enhancer
+## Phase 4: Installation
+
+**Create a TodoWrite list to track progress:**
+
+```json
+{
+ "todos": [
+ {"content": "Create VoiceServer directory", "status": "pending", "activeForm": "Creating VoiceServer directory"},
+ {"content": "Copy voice server files", "status": "pending", "activeForm": "Copying voice server files"},
+ {"content": "Copy voice hooks", "status": "pending", "activeForm": "Copying voice hooks"},
+ {"content": "Copy prosody enhancer", "status": "pending", "activeForm": "Copying prosody enhancer"},
+ {"content": "Install dependencies", "status": "pending", "activeForm": "Installing dependencies"},
+ {"content": "Configure environment", "status": "pending", "activeForm": "Configuring environment"},
+ {"content": "Register hooks in settings.json", "status": "pending", "activeForm": "Registering hooks"},
+ {"content": "Run verification", "status": "pending", "activeForm": "Running verification"}
+ ]
+}
+```
+
+### 4.1 Create VoiceServer Directory
-Copy the prosody enhancer library:
+**Mark todo "Create VoiceServer directory" as in_progress.**
```bash
-cp src/hooks/lib/prosody-enhancer.ts $PAI_DIR/hooks/lib/prosody-enhancer.ts
+PAI_DIR="${PAI_DIR:-$HOME/.claude}"
+mkdir -p "$PAI_DIR/VoiceServer"
+mkdir -p "$PAI_DIR/hooks/lib"
```
----
+**Mark todo as completed.**
-## Step 4: Install Voice Hooks
+### 4.2 Copy Voice Server Files
-Copy the voice hooks:
+**Mark todo "Copy voice server files" as in_progress.**
```bash
-cp src/hooks/stop-hook-voice.ts $PAI_DIR/hooks/stop-hook-voice.ts
-cp src/hooks/subagent-stop-hook-voice.ts $PAI_DIR/hooks/subagent-stop-hook-voice.ts
+PACK_DIR="$(pwd)"
+PAI_DIR="${PAI_DIR:-$HOME/.claude}"
+
+# Copy voice server
+cp "$PACK_DIR/src/voice/server.ts" "$PAI_DIR/VoiceServer/"
+cp "$PACK_DIR/src/voice/voices.json" "$PAI_DIR/VoiceServer/"
+
+# Copy management scripts
+cp "$PACK_DIR/src/voice/manage.sh" "$PAI_DIR/VoiceServer/"
+cp "$PACK_DIR/src/voice/start.sh" "$PAI_DIR/VoiceServer/"
+cp "$PACK_DIR/src/voice/stop.sh" "$PAI_DIR/VoiceServer/"
+cp "$PACK_DIR/src/voice/restart.sh" "$PAI_DIR/VoiceServer/"
+cp "$PACK_DIR/src/voice/status.sh" "$PAI_DIR/VoiceServer/"
+
+# Make scripts executable
+chmod +x "$PAI_DIR/VoiceServer/"*.sh
```
----
+**Files copied:**
+- `server.ts` - ElevenLabs TTS HTTP server
+- `voices.json` - Agent voice configurations
+- `manage.sh` - Start/stop/restart/status management
+- `start.sh`, `stop.sh`, `restart.sh`, `status.sh` - Individual control scripts
-## Step 5: Configure ElevenLabs API
+**Mark todo as completed.**
-1. **Sign up** at [elevenlabs.io](https://elevenlabs.io)
-2. **Get your API key** from Profile → API key
-3. **Choose a voice** from the Voice Library and copy its ID
-4. **Add to ~/.env**:
+### 4.3 Copy Voice Hooks
+
+**Mark todo "Copy voice hooks" as in_progress.**
```bash
-ELEVENLABS_API_KEY=your-api-key-here
-ELEVENLABS_VOICE_ID=your-voice-id-here
+PACK_DIR="$(pwd)"
+PAI_DIR="${PAI_DIR:-$HOME/.claude}"
+
+cp "$PACK_DIR/src/hooks/stop-hook-voice.ts" "$PAI_DIR/hooks/"
+cp "$PACK_DIR/src/hooks/subagent-stop-hook-voice.ts" "$PAI_DIR/hooks/"
```
-### Test Your API Key
+**Files copied:**
+- `stop-hook-voice.ts` - Extracts and speaks 🗣️ line on session stop
+- `subagent-stop-hook-voice.ts` - Speaks subagent completions
+
+**Mark todo as completed.**
+
+### 4.4 Copy Prosody Enhancer
+
+**Mark todo "Copy prosody enhancer" as in_progress.**
```bash
-curl -X POST "https://api.elevenlabs.io/v1/text-to-speech/YOUR_VOICE_ID" \
- -H "xi-api-key: YOUR_API_KEY" \
- -H "Content-Type: application/json" \
- -d '{"text": "Hello, this is a test.", "model_id": "eleven_turbo_v2_5"}' \
- --output test.mp3
+PACK_DIR="$(pwd)"
+PAI_DIR="${PAI_DIR:-$HOME/.claude}"
-afplay test.mp3 # Should hear "Hello, this is a test"
-rm test.mp3
+cp "$PACK_DIR/src/hooks/lib/prosody-enhancer.ts" "$PAI_DIR/hooks/lib/"
```
----
+**Files copied:**
+- `prosody-enhancer.ts` - Adds SSML prosody tags for natural speech
-## Step 6: Register Hooks
+**Mark todo as completed.**
-Add the voice hooks to your `~/.claude/settings.json`:
+### 4.5 Install Dependencies
-```json
-{
- "hooks": {
- "Stop": [
- {
- "type": "command",
- "command": "bun run $PAI_DIR/hooks/stop-hook-voice.ts"
- }
- ],
- "SubagentStop": [
- {
- "type": "command",
- "command": "bun run $PAI_DIR/hooks/subagent-stop-hook-voice.ts"
- }
- ]
- }
-}
+**Mark todo "Install dependencies" as in_progress.**
+
+```bash
+PAI_DIR="${PAI_DIR:-$HOME/.claude}"
+cd "$PAI_DIR/VoiceServer"
+bun add @elysiajs/cors
```
-**Note:** Replace `$PAI_DIR` with your actual PAI directory path, or ensure the environment variable is set.
+**Mark todo as completed.**
----
+### 4.6 Configure Environment (If User Chose Yes)
-## Step 7: Start Voice Server
+**Mark todo "Configure environment" as in_progress.**
+
+**Only execute if user chose to create .env template:**
```bash
-# Start the voice server
-$PAI_DIR/voice-server/manage.sh start
+PAI_DIR="${PAI_DIR:-$HOME/.claude}"
-# Or manually
-bun run $PAI_DIR/voice-server/server.ts &
+# Create or append to .env
+if [ ! -f "$PAI_DIR/.env" ]; then
+ cat > "$PAI_DIR/.env" << 'EOF'
+# PAI Voice System Configuration
-# Verify it's running
-curl http://localhost:8888/health
+# ElevenLabs API (REQUIRED for voice)
+# Get your key from: https://elevenlabs.io → Profile → API key
+ELEVENLABS_API_KEY=your-api-key-here
+
+# Default voice ID (optional - uses default if not set)
+# Browse voices at: https://elevenlabs.io/voice-library
+ELEVENLABS_VOICE_ID=your-voice-id-here
+
+# Voice server port (optional - default 8888)
+VOICE_SERVER_PORT=8888
+EOF
+ echo "Created $PAI_DIR/.env - Please add your ElevenLabs API key"
+else
+ # Check if ElevenLabs config already exists
+ if ! grep -q "ELEVENLABS_API_KEY" "$PAI_DIR/.env"; then
+ cat >> "$PAI_DIR/.env" << 'EOF'
+
+# PAI Voice System Configuration
+ELEVENLABS_API_KEY=your-api-key-here
+ELEVENLABS_VOICE_ID=your-voice-id-here
+VOICE_SERVER_PORT=8888
+EOF
+ echo "Added ElevenLabs config to $PAI_DIR/.env"
+ else
+ echo "ElevenLabs config already exists in $PAI_DIR/.env"
+ fi
+fi
+```
+
+Tell the user:
```
+"Created/updated .env at $PAI_DIR/.env
+
+Please add your ElevenLabs credentials:
+1. Sign up at https://elevenlabs.io
+2. Get API key from Profile → API key
+3. Choose a voice from the Voice Library
+4. Add both to your .env file"
+```
+
+**Mark todo as completed (or skip if user declined).**
+
+### 4.7 Register Hooks in settings.json
+
+**Mark todo "Register hooks in settings.json" as in_progress.**
+
+Read the hook configuration from `config/settings-hooks.json` and merge it into the user's `~/.claude/settings.json`.
+
+**Important:** Merge the hooks, don't replace existing hooks.
+
+**Mark todo as completed.**
---
-## Step 8: (Optional) Auto-Start on Login
-
-### macOS (LaunchAgent)
-
-```bash
-cat > ~/Library/LaunchAgents/com.pai.voice-server.plist << EOF
-<?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.pai.voice-server</string>
- <key>ProgramArguments</key>
- <array>
- <string>$HOME/.bun/bin/bun</string>
- <string>run</string>
- <string>$PAI_DIR/voice-server/server.ts</string>
- </array>
- <key>RunAtLoad</key>
- <true/>
- <key>KeepAlive</key>
- <true/>
- <key>StandardOutPath</key>
- <string>$HOME/Library/Logs/pai-voice-server.log</string>
- <key>StandardErrorPath</key>
- <string>$HOME/Library/Logs/pai-voice-server.log</string>
-</dict>
-</plist>
-EOF
+## Phase 5: Verification
-# Load the agent
-launchctl load ~/Library/LaunchAgents/com.pai.voice-server.plist
+**Mark todo "Run verification" as in_progress.**
+
+**Execute all checks from VERIFY.md:**
+
+```bash
+PAI_DIR="${PAI_DIR:-$HOME/.claude}"
+
+echo "=== PAI Voice System Verification ==="
+
+# Check VoiceServer files
+echo "Checking VoiceServer files..."
+[ -f "$PAI_DIR/VoiceServer/server.ts" ] && echo "✓ server.ts" || echo "❌ server.ts missing"
+[ -f "$PAI_DIR/VoiceServer/voices.json" ] && echo "✓ voices.json" || echo "❌ voices.json missing"
+[ -x "$PAI_DIR/VoiceServer/manage.sh" ] && echo "✓ manage.sh (executable)" || echo "❌ manage.sh not executable"
+
+# Check hook files
+echo ""
+echo "Checking hook files..."
+[ -f "$PAI_DIR/hooks/stop-hook-voice.ts" ] && echo "✓ stop-hook-voice.ts" || echo "❌ stop-hook-voice.ts missing"
+[ -f "$PAI_DIR/hooks/subagent-stop-hook-voice.ts" ] && echo "✓ subagent-stop-hook-voice.ts" || echo "❌ subagent-stop-hook-voice.ts missing"
+[ -f "$PAI_DIR/hooks/lib/prosody-enhancer.ts" ] && echo "✓ prosody-enhancer.ts" || echo "❌ prosody-enhancer.ts missing"
+
+# Check API key
+echo ""
+echo "Checking configuration..."
+if [ -n "$ELEVENLABS_API_KEY" ]; then
+ echo "✓ ELEVENLABS_API_KEY is set"
+else
+ echo "⚠️ ELEVENLABS_API_KEY not set (voice won't work)"
+fi
+
+# Test server start
+echo ""
+echo "Testing voice server..."
+$PAI_DIR/VoiceServer/manage.sh start &
+sleep 3
+if curl -s http://localhost:8888/health | grep -q "ok"; then
+ echo "✓ Voice server responding on port 8888"
+else
+ echo "⚠️ Voice server not responding (may need API key)"
+fi
+$PAI_DIR/VoiceServer/manage.sh stop
+
+echo "=== Verification Complete ==="
```
-**Note:** You'll need to replace `$HOME` and `$PAI_DIR` with actual paths in the plist file.
+**Mark todo as completed when all checks pass.**
---
-## Step 9: Verify Installation
+## Success/Failure Messages
-Run the verification checklist in VERIFY.md to confirm everything works.
+### On Success
+
+```
+"PAI Voice System v1.0.0 installed successfully!
+
+What's available:
+- ElevenLabs TTS voice server
+- Prosody enhancement for natural speech
+- Multi-agent voice personalities
+- Session and subagent voice hooks
+
+To start the voice server:
+ $PAI_DIR/VoiceServer/manage.sh start
+
+To test voice output:
+ curl -X POST http://localhost:8888/notify \
+ -H 'Content-Type: application/json' \
+ -d '{\"message\": \"Hello, voice is working!\"}'
+
+To stop: $PAI_DIR/VoiceServer/manage.sh stop"
+```
+
+### On Failure
+
+```
+"Installation encountered issues. Here's what to check:
+
+1. Ensure pai-core-install is installed first
+2. Ensure pai-hook-system is installed second
+3. Verify Bun is installed: `bun --version`
+4. Set ELEVENLABS_API_KEY in ~/.env
+5. Check port 8888 is available
+6. Check directory permissions on $PAI_DIR/
+7. Run the verification commands in VERIFY.md
+
+Need help? Check the Troubleshooting section below."
+```
---
## Troubleshooting
-### No Voice Output
+### "pai-core-install not found"
-1. Check voice server is running: `curl http://localhost:8888/health`
-2. Verify API key is set in `~/.env`
-3. Check logs: `tail -f /tmp/pai-voice-server.log`
+This pack requires pai-core-install. Install it first:
+```
+Give the AI the pai-core-install pack directory and ask it to install.
+```
+
+### "pai-hook-system not found"
+
+This pack requires pai-hook-system for hook infrastructure. Install it:
+```
+Give the AI the pai-hook-system pack directory and ask it to install.
+```
+
+### "bun: command not found"
-### ElevenLabs Errors
+```bash
+# Install Bun
+curl -fsSL https://bun.sh/install | bash
+# Restart terminal or source ~/.bashrc
+```
+
+### No voice output
+
+```bash
+# 1. Check server is running
+curl http://localhost:8888/health
+
+# 2. Check API key is set
+echo $ELEVENLABS_API_KEY
+
+# 3. Check logs
+tail -f /tmp/pai-voice-server.log
+```
+
+### ElevenLabs errors
| Error | Solution |
|-------|----------|
@@ -228,14 +510,148 @@ Run the verification checklist in VERIFY.md to confirm everything works.
| `missing_permissions` | Enable TTS permission in ElevenLabs dashboard |
| `voice_not_found` | Check voice ID is correct |
-### Audio Playback Issues
+### Port already in use
+
+```bash
+# Check what's using the port
+lsof -i :8888
+
+# Kill existing processes
+$PAI_DIR/VoiceServer/manage.sh stop
+
+# Or use a different port
+export VOICE_SERVER_PORT=9999
+```
+
+### Audio playback issues (macOS)
+
+```bash
+# Verify afplay works
+afplay /System/Library/Sounds/Ping.aiff
+
+# Check system volume
+# System Preferences → Sound
+
+# Check audio permissions
+# System Preferences → Security & Privacy → Microphone
+```
+
+---
+
+## What's Included
+
+| File | Purpose |
+|------|---------|
+| `VoiceServer/server.ts` | ElevenLabs TTS HTTP server |
+| `VoiceServer/voices.json` | Agent voice configurations |
+| `VoiceServer/manage.sh` | Start/stop/restart/status script |
+| `VoiceServer/start.sh` | Start voice server |
+| `VoiceServer/stop.sh` | Stop voice server |
+| `VoiceServer/restart.sh` | Restart voice server |
+| `VoiceServer/status.sh` | Check server status |
+| `hooks/stop-hook-voice.ts` | Session stop voice hook |
+| `hooks/subagent-stop-hook-voice.ts` | Subagent stop voice hook |
+| `hooks/lib/prosody-enhancer.ts` | SSML prosody enhancement |
+
+---
+
+## Usage
+
+### Starting the Voice Server
+
+```bash
+# Start
+$PAI_DIR/VoiceServer/manage.sh start
+
+# Check status
+$PAI_DIR/VoiceServer/manage.sh status
+
+# Stop
+$PAI_DIR/VoiceServer/manage.sh stop
+
+# Restart
+$PAI_DIR/VoiceServer/manage.sh restart
+```
+
+### Testing Voice Output
+
+```bash
+# Send a test notification
+curl -X POST http://localhost:8888/notify \
+ -H "Content-Type: application/json" \
+ -d '{"message": "Hello, this is a test."}'
+```
+
+### From Claude Code
+
+Once installed, the voice system works automatically:
+- Your AI's 🗣️ response line is spoken aloud
+- Subagent completions are announced
+- Session endings are narrated
+
+### CLI Examples
+
+```bash
+# Quick notification
+curl -s -X POST http://localhost:8888/notify \
+ -H "Content-Type: application/json" \
+ -d '{"message": "Task completed successfully."}' \
+ > /dev/null 2>&1 &
+
+# With specific speaker/voice
+curl -X POST http://localhost:8888/notify \
+ -H "Content-Type: application/json" \
+ -d '{"message": "Research complete.", "speaker": "Intern"}'
+```
+
+---
+
+## Voice Personalities
+
+The voice system supports multiple agent voices via `voices.json`:
+
+| Agent | Voice Style |
+|-------|-------------|
+| Main Assistant | Default configured voice |
+| Intern | Slightly faster, enthusiastic |
+| Architect | Measured, thoughtful pace |
+| Engineer | Clear, technical tone |
+
+Configure voices in `$PAI_DIR/VoiceServer/voices.json`.
+
+---
+
+## Auto-Start on Login (macOS)
+
+If you chose auto-start during installation, a LaunchAgent was created:
+
+```bash
+# Check LaunchAgent status
+launchctl list | grep pai-voice
+
+# View LaunchAgent
+cat ~/Library/LaunchAgents/com.pai.voice-server.plist
+
+# Reload if needed
+launchctl unload ~/Library/LaunchAgents/com.pai.voice-server.plist
+launchctl load ~/Library/LaunchAgents/com.pai.voice-server.plist
+```
+
+---
+
+## Configuration
+
+**Environment variables:**
-1. Verify `afplay` works: `afplay /System/Library/Sounds/Ping.aiff`
-2. Check system volume
-3. Check audio permissions in System Preferences
+| Variable | Default | Purpose |
+|----------|---------|---------|
+| `PAI_DIR` | `~/.claude` | Root PAI directory |
+| `ELEVENLABS_API_KEY` | (required) | ElevenLabs API authentication |
+| `ELEVENLABS_VOICE_ID` | (optional) | Default voice ID |
+| `VOICE_SERVER_PORT` | `8888` | Voice server HTTP port |
-### Server Won't Start
+**Ports:**
-1. Check port 8888 is free: `lsof -i :8888`
-2. Check bun is installed: `bun --version`
-3. Check for syntax errors: `bun run $PAI_DIR/voice-server/server.ts`
+| Service | Port | Purpose |
+|---------|------|---------|
+| Voice Server | 8888 | TTS HTTP API |