Conversation
Read, write, migrate, and protect Auto Mode's global config and logs under Pi's effective agent directory. The extension previously hardcoded `~/.pi/agent`, which broke setups where `PI_CODING_AGENT_DIR` relocates Pi's config (e.g. `~/.config/pi/agent`). A single resolvePiAgentDir() helper resolves the effective directory, expanding a leading `~` the same way Pi does. Global settings, the legacy config migration path, the in-memory observability log root, and the deterministic safety-control protections all follow it. Resolves config paths at call time so tests can exercise the override directly.
Drop the custom resolvePiAgentDir() wrapper (honoring PI_CODING_AGENT_DIR was already handled upstream) and hardcoded '/.pi/' segments in favor of the canonical @earendil-works/pi-coding-agent exports. Adjust the bounded wildcard child-process timeout for cold-start import cost.
|
Removed the duplicated PI_CODING_AGENT_DIR resolution. The extension now uses Pi's canonical |
czottmann
left a comment
There was a problem hiding this comment.
Thanks for this addition, @Susensio! The direction is good. Pi’s getAgentDir() and CONFIG_DIR_NAME avoid duplicated path-resolution logic.
I found one merge blocker, tho.
P1: Canonicalize the effective agent directory before safety-path comparisons
extensions/auto-mode/paths.ts:240 compares a canonicalized target path with the raw value from getAgentDir().
Different path spellings for the same directory make this comparison fail. Examples include:
- macOS
/varand/private/varpaths - a symlinked agent directory
- a relative
PI_CODING_AGENT_DIRvalue - an agent directory with a trailing separator
The PR’s new test exposes this defect on macOS. tests/agent-dir.test.ts:58 fails because os.tmpdir() uses /var/folders. The target resolves through /private/var/folders (it's a FS link, basically).
This defect removes the deterministic hard-deny for the effective settings.json and extensions/ paths. I reproduced a write(*) allow rule that permitted the settings write with zero classifier calls.
Please canonicalize the agent root with the same policy that resolves the target. One option is resolvePathForPolicy(resolve(getAgentDir())), with the resolved absolute path as the fallback. Please also add regression tests for symlinks, relative paths, and trailing separators.
P2: Update the remaining path documentation
These documents give ~/.pi/agent as the unconditional location:
docs/observability-logging.md:47docs/diagnostics.md:68docs/automode-classifier-flow.md:92
Please identify these paths as defaults. State that PI_CODING_AGENT_DIR changes them.
Validation
I tested the PR in an isolated checkout that also contained the newest main branch:
npm run checkpassed.npm pack --dry-runpassed.npm testreported 316 passed, 1 failed, and 1 skipped.- The test that did not pass is the new agent-directory hard-deny test described above.
Thanks!
Summary
PI_CODING_AGENT_DIRValidation
npm run checknpm pack --dry-runnpm test(299 passed, 1 environment-sensitive timeout in the existing adversarial wildcard child-process test; 3 skipped)