Personal_AI_Infrastructure icon indicating copy to clipboard operation
Personal_AI_Infrastructure copied to clipboard

Kai/install.ts --update flag ignores PAI_DIR when reading existing config

Open SimonBlancoE opened this issue 11 months ago • 2 comments

Problem: When running bun Bundles/Kai/install.ts --update, the script fails to detect existing configuration (specifically userName) if the installation uses a PAI_DIR other than ~/.claude. This causes the update to prompt for full configuration instead of preserving existing values. This confuses the user (who confirmed the update option) as there's no indication that the process failed and fell back to normal configuration.

Root Cause: readExistingConfig() hardcodes ~/.claude instead of respecting PAI_DIR: const claudeDir = ${process.env.HOME}/.claude; // Line 92

Fix: const claudeDir = process.env.PAI_DIR || ${process.env.HOME}/.claude;

Also improved the userName regex to be more precise: // Before /Role:\s*([^'\n]+)'s\s+AI\s+assistant/i // After
/^\s*-\s*Role:\s*([^'\n]+)'s\s+AI\s+assistant/im Impact: Affects any user with custom PAI_DIR attempting to use update mode.

SimonBlancoE avatar Jan 01 '26 19:01 SimonBlancoE

Confirmed - Encountered This During Linux Testing

We hit this exact issue while testing PR #288 (Linux compatibility fixes).

Our Experience

Testing environment:

  • System PAI installed in: /home/elidev/.config/pai
  • PAI_DIR in .bashrc: export PAI_DIR="/home/elidev/.config/pai"
  • But current session had: PAI_DIR=/home/elidev/.claude

What broke: The verification script in kai-voice-system/VERIFY.md showed files as "MISSING" even though they existed:

❌ voice-server/server.ts MISSING
❌ config/voice-personalities.json MISSING

Root cause (same as yours):

PAI_CHECK="${PAI_DIR:-$HOME/.config/pai}"
# Looked in: /home/elidev/.claude/voice-server/server.ts (wrong)
# Files at:  /home/elidev/.config/pai/voice-server/server.ts (correct)

When we re-ran with explicit PAI_DIR="/home/elidev/.config/pai", all checks passed ✅

Systemic Issue?

Your fix for install.ts is correct, but this suggests many PAI scripts may have hardcoded ~/.claude instead of respecting PAI_DIR.

Potential candidates to audit:

  • Bundles/Kai/install.ts (your finding)
  • Verification scripts in Packs
  • Hook installation scripts
  • Any script that reads/writes config

Documentation Impact

This might warrant a note in PAI setup docs:

"⚠️ If using custom PAI_DIR, ensure it's exported in your shell profile AND current session before running PAI scripts."

Great catch on this! Your fix looks solid.


Context: Testing results from PR #288 documented in this comment

fayerman-source avatar Jan 01 '26 23:01 fayerman-source

Good catch! Fixed readExistingConfig() to respect PAI_DIR environment variable instead of hardcoding ~/.claude.

Thanks for reporting this!

danielmiessler avatar Jan 02 '26 04:01 danielmiessler