Skip to content

bug(wizard): PAI_DIR and secrets not properly shared between wizard and packs #260

@mellanon

Description

@mellanon

The bundle wizard and pack installers don't coordinate on where configuration is stored, causing several problems during installation.

Problem 1: Secrets saved to .zshrc, packs expect .env file

Wizard behavior (install.ts lines 816-833):

// Wizard writes to shell profile (.zshrc), NOT .env:
const envExports = `
export PAI_DIR="${config.paiDir}"
export DA="${config.daName}"
export ELEVENLABS_API_KEY="${config.elevenLabsApiKey}"
`;
await Bun.write(shellProfile, existingProfile + "\n" + envExports);

Pack behavior:

// Pack looks for .env file which doesn't exist
await Bun.file("~/.claude/.env").text()

Result: User provides ElevenLabs API key during wizard, then pack asks for it AGAIN because it can't find the .env file.

Problem 2: PAI_DIR not available to packs

The wizard adds PAI_DIR to .zshrc but:

  1. Doesn't export to current session
  2. User is told to "reload shell" but Claude Code sessions don't reload
  3. Packs fall back to ~/.config/pai instead of user's chosen directory

Problem 3: Wizard may write wrong PAI_DIR

When ~/.claude is a symlink (common for multi-environment setups), the wizard sometimes writes the wrong path to .zshrc.

Suggested Fixes

Option A - Wizard creates BOTH .zshrc exports AND .env file:

// After writing to .zshrc, ALSO create .env
const envContent = `
DA="${config.daName}"
PAI_DIR="${config.paiDir}"
ELEVENLABS_API_KEY="${config.elevenLabsApiKey}"
`;
await Bun.write(`${paiDir}/.env`, envContent);

Option B - Wizard exports to current session:

// After writing to .zshrc
process.env.PAI_DIR = config.paiDir;
process.env.ELEVENLABS_API_KEY = config.elevenLabsApiKey;

Option C - Packs confirm installation directory before proceeding:

Installing kai-hook-system...
Target directory: ~/.config/pai (from PAI_DIR or default)
Is this correct? [Y/n]:

Environment

  • macOS
  • PAI v2 (current main branch)
  • Tested in clean sandbox with symlinked ~/.claude

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions