Personal_AI_Infrastructure icon indicating copy to clipboard operation
Personal_AI_Infrastructure copied to clipboard

v2.5 Upgrade: Statusline shows all zeros — PAI_DIR not expanded, fd missing, USER files not migrated

Open DolphusCY opened this issue 10 months ago • 4 comments

Summary

After upgrading to PAI v2.5, the statusline shows 0 for all memory counters (Work, Sessions, Research, Ratings) and all USER files (ABOUTME, CONTACTS, TELOS, etc.) contain only template placeholders. Three distinct bugs were found during a post-upgrade audit.

Environment

  • macOS (Darwin 25.2.0, Apple Silicon)
  • Claude Code 2.1.29
  • PAI v2.5 (fresh upgrade from v2.3)
  • Shell: zsh

Bug 1: PAI_DIR set to literal $HOME/.claude (Critical)

File: PAI/.claude/settings.json

The project-level settings.json has:

"env": {
  "PAI_DIR": "$HOME/.claude"
}

Claude Code sets environment variables from this file but does not expand shell variables. The statusline and hooks receive PAI_DIR as the literal string $HOME/.claude, not /Users/<username>/.claude. Every path lookup fails silently.

Impact: All statusline counters show 0. Any hook or tool using $PAI_DIR operates on a nonexistent path.

Fix: The installer should write the absolute expanded path:

"PAI_DIR": "/Users/<username>/.claude"

Reproduction:

# In a Claude Code session within the PAI project:
echo "$PAI_DIR"
# Expected: /Users/<username>/.claude
# Actual:   $HOME/.claude

Bug 2: fd dependency not installed / needs --no-ignore

File: ~/.claude/statusline-command.sh (lines 251-253)

The statusline uses fd to count WORK directories, JSONL sessions, and RESEARCH files:

work_count=$(fd -t d -d 1 . "$PAI_DIR/MEMORY/WORK" ...)
sessions_count=$(fd -e jsonl . "$PAI_DIR/MEMORY" ...)
research_count=$(fd -e md -e json . "$PAI_DIR/MEMORY/RESEARCH" ...)

Two issues:

  1. fd is not listed as a dependency and may not be installed (brew install fd required)
  2. Even when installed, fd respects .gitignore by default. Since MEMORY/ is gitignored, all counts return 0. The --no-ignore flag is required.

Fix: Either document fd as a required dependency and add --no-ignore, or use find as a fallback:

work_count=$(fd --no-ignore -t d -d 1 . "$PAI_DIR/MEMORY/WORK" 2>/dev/null | wc -l | tr -d ' ')

Bug 3: USER files contain only template placeholders after upgrade

Directory: ~/.claude/skills/PAI/USER/

All 43 USER files (ABOUTME.md, CONTACTS.md, BASICINFO.md, TELOS/*.md, etc.) contain only template text like [Your name], [City, Country], G0: [Primary Goal].

The v2.5 upgrade restructured from skills/CORE/USER/ to skills/PAI/USER/ but appears to have written fresh templates rather than migrating existing content. Checking all available backups (.claude-backup-20260131, .claude-v2.3-backup, .claude-backups/CORE-backup-20260114) shows the same templates — suggesting the migration tool either didn't detect populated files or the files were never populated in v2.3 either.

Note: This may not be a v2.5 bug specifically — the USER files may have been templates since v2.3 installation. The installer should either:

  • Prompt users to populate USER files post-install
  • Detect and warn if USER files still contain placeholder text
  • Provide a guided setup wizard for personal data

Fixes Applied Locally

Bug Fix Applied
PAI_DIR literal Changed to absolute path in PAI/.claude/settings.json
fd missing Installed via brew install fd
fd gitignore Added --no-ignore flag to all 3 fd calls in statusline
USER templates Not yet resolved — needs manual population

Suggested Installer Improvements

  1. Expand $HOME at install time — Write absolute paths in settings.json, not shell variables
  2. Check for fd dependency — Either install it, document it, or use find as fallback
  3. Add --no-ignore to all fd calls touching gitignored directories
  4. Post-install validation — Run a health check that verifies the statusline returns non-zero counts
  5. USER file migration — If upgrading from a previous version, detect and preserve populated USER files

DolphusCY avatar Jan 31 '26 21:01 DolphusCY

Additional bug: repo HEAD find fix introduces depth mismatch

The repo HEAD (.claude/statusline-command.sh) replaced fd with find to resolve Bug 2, but introduced a new counting bug:

# Current repo HEAD (line 132):
work_count=$(find "$PAI_DIR/MEMORY/WORK" -mindepth 2 -maxdepth 2 -type d 2>/dev/null | wc -l | tr -d ' ')

This expects a two-level directory structure (WORK/{date}/{session}/), but AutoWorkCreation.hook.ts creates flat directories:

WORK/20260208-164044_changes-made-to-zshrc-by-installts/
WORK/20260209-021353_whats-missing-from-our-paiviki-setup/

The hook (line 185) uses join(WORK_DIR, workDirName) — one level, not two. So -mindepth 2 -maxdepth 2 finds nothing and work_count is always 0.

Suggested fix — match the flat structure the hook actually creates:

work_count=$(find "$PAI_DIR/MEMORY/WORK" -mindepth 1 -maxdepth 1 -type d 2>/dev/null | wc -l | tr -d ' ')

virtualian avatar Feb 09 '26 02:02 virtualian

Thanks for reporting this! We've been doing a major restructuring of PAI's core systems, including a complete redesign of the hook architecture (consolidated from 22 to ~19 hooks), a rewritten Algorithm (now v0.5.1 with PRD-based verification), removal of the observability system, and numerous path/configuration fixes.

This specific issue is addressed by those changes. We're targeting a v3.0 release soon that will include all of this. We appreciate your patience and your help in identifying these issues — it directly informed our redesign work. Stay tuned!

danielmiessler avatar Feb 10 '26 21:02 danielmiessler

For Bug 2 (fd dependency missing / needs --no-ignore): I took a different approach in #642 that eliminates the fd dependency entirely.

Instead of adding --no-ignore to fd calls, the statusline now reads work/research/ratings counts from settings.json (populated by a fixed UpdateCounts.ts at session end). No fd, no find, no file scanning at render time.

See the full diffs in this comment on #642.

jlacour-git avatar Feb 13 '26 21:02 jlacour-git

Thanks for the detailed report! These were v2.5-specific issues (PAI_DIR expansion, fd dependency, USER migration). v3.0 (now released) has a completely rewritten installer and statusline that address these. Please upgrade to v3.0.

kaimagnus avatar Feb 15 '26 17:02 kaimagnus