Summary
saveState() in skills/PAIUpgrade/Tools/Anthropic.ts writes to State/last-check.json but doesn't create the parent directory if it doesn't exist. On first run after a fresh install (or after State/ is deleted), the initial write ENOENT's. The tool currently retries via fallback path and succeeds, but the initial error is noise and could mask other failures.
Repro
rm -rf ~/.claude/skills/PAIUpgrade/State/
bun ~/.claude/skills/PAIUpgrade/Tools/Anthropic.ts
# First save attempt: ENOENT on State/last-check.json
# Retry: succeeds
Observed during a PAIUpgrade audit run 2026-05-15.
Proposed fix
Add a mkdir -p equivalent before the first write in saveState():
import { mkdirSync } from 'fs';
import { dirname } from 'path';
// At the top of saveState(), before fs.writeFileSync(STATE_PATH, ...)
mkdirSync(dirname(STATE_PATH), { recursive: true });
One-line fix, idempotent, no behavior change when directory already exists.
Environment
- PAI 5.0.0
- skills/PAIUpgrade tool
Summary
saveState()inskills/PAIUpgrade/Tools/Anthropic.tswrites toState/last-check.jsonbut doesn't create the parent directory if it doesn't exist. On first run after a fresh install (or afterState/is deleted), the initial write ENOENT's. The tool currently retries via fallback path and succeeds, but the initial error is noise and could mask other failures.Repro
Observed during a PAIUpgrade audit run 2026-05-15.
Proposed fix
Add a
mkdir -pequivalent before the first write insaveState():One-line fix, idempotent, no behavior change when directory already exists.
Environment