Skip to content

fix: store recap state in XDG state dir for cross-runtime installs#5

Open
jms830 wants to merge 1 commit into
Fornace:mainfrom
jms830:fix/xdg-state-dir
Open

fix: store recap state in XDG state dir for cross-runtime installs#5
jms830 wants to merge 1 commit into
Fornace:mainfrom
jms830:fix/xdg-state-dir

Conversation

@jms830

@jms830 jms830 commented Jun 13, 2026

Copy link
Copy Markdown

Problem

The global model override (state/config.json), the blacklist, and the debug log were resolved to a hardcoded ~/.pi/agent/extensions/pi-recap/ path. Two issues:

  1. Host-specific. Under oh-my-pi the package installs at ~/.omp/plugins/node_modules/pi-recap, so writing state into ~/.pi/... is surprising, and earlier attempts to keep state inside the package dir get wiped on every bun install/reinstall (node_modules).
  2. Not cross-runtime: the same machine running both pi and oh-my-pi had no single, stable home for the override.

Change

Resolve state under the XDG state dir, host-neutrally, in all three files (state/config.ts, state/blacklist.ts, util/log.ts):

PI_RECAP_HOME            (explicit override / e2e tests)
  -> <cwd>/state         (when cwd is the pi-recap project, dev)
  -> $XDG_STATE_HOME/pi-recap   (default ~/.local/state/pi-recap)
  -> legacy ~/.pi/agent/extensions/pi-recap   (read fallback if it already exists)
  • Host-neutral: identical resolution under pi and oh-my-pi — no ~/.pi-vs-~/.omp branching.
  • Reinstall-safe: state lives outside node_modules.
  • Back-compatible: existing pi users keep their current state via the legacy fallback (used whenever the XDG file doesn't exist yet but the legacy one does); fresh installs use XDG.

Notes

  • .js files regenerated from .ts with the repo transpile (tsc --module esnext --target es2022 --moduleResolution bundler); unchanged siblings emit byte-identical.
  • tsc --noEmit adds no new type errors vs main; ubs reports 0 critical / 0 warning on all three files (unchanged from main).
  • CLAUDE.md path references updated to match.
  • Verified all three resolution branches (default XDG, fresh-install default, legacy fallback) with a fake HOME/XDG_STATE_HOME harness.

The global model override, blacklist, and debug log were hardcoded under
~/.pi/agent/extensions/pi-recap/. That path is pi-specific and surprising
under other hosts (e.g. oh-my-pi installs the package at
~/.omp/plugins/node_modules/pi-recap, where state living inside the package
dir is wiped on every reinstall).

Resolve state under the XDG state dir instead:
  PI_RECAP_HOME -> <cwd>/state (dev) -> $XDG_STATE_HOME/pi-recap
(default ~/.local/state/pi-recap), with a read fallback to the legacy
~/.pi/agent/extensions/pi-recap location when it already exists.

Host-neutral (identical under pi and oh-my-pi), survives reinstalls, and
keeps existing pi users' state in place via the legacy fallback.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant