feat: add PLANNOTATOR_DATA_DIR env var to customize data directory#795
Open
IstPlayer wants to merge 5 commits into
Open
feat: add PLANNOTATOR_DATA_DIR env var to customize data directory#795IstPlayer wants to merge 5 commits into
IstPlayer wants to merge 5 commits into
Conversation
OpenCode plugin and VS Code extension still used hardcoded ~/.plannotator paths, causing the IPC registry and plan backing file to diverge from the server when PLANNOTATOR_DATA_DIR is set. Also exports data-dir from @plannotator/shared and documents the new env var in AGENTS.md. Co-authored-by: Chris Werner Rau <14326070+cwrau@users.noreply.github.com> Co-authored-by: João O. Santos <34689526+Joao-O-Santos@users.noreply.github.com>
Owner
|
Thanks for the PR @IstPlayer — clean approach and the right default behavior (nothing changes unless you explicitly set the env var). I pushed a fix commit (
For context: There are two other open PRs tackling the same problem with different approaches:
This PR (#795) is the simplest and safest of the three — one env var, opt-in only, zero risk for anyone who doesn't set it. The co-author trailers on the fix commit credit @cwrau and @Joao-O-Santos since their work helped identify the full scope of files that needed updating. |
The Pi extension copies shared/server modules into generated/ at build time. Without vendoring data-dir.ts and rewriting the parent-relative imports, typecheck fails on all generated files that import getPlannotatorDataDir.
- VS Code extension: replace inlined getPlannotatorDataDir() copy with import from the canonical packages/shared/data-dir.ts (esbuild bundles it, so no runtime dependency needed) - storage.ts: hoist repeated getPlannotatorDataDir() calls to a module-level DATA_DIR constant, matching the pattern config.ts uses - data-dir.ts: remove inaccurate docstring claim about relative path resolution (the code does not call resolve()) - improvement-hooks.ts: hoist to DATA_DIR constant, clarify comments on the two-level hook lookup (hooks/ subdir vs root fallback)
A relative value like ./data would break readArchivedPlan's path traversal guard, which compares a resolve()'d absolute path against the still-relative planDir prefix. Always return an absolute path so all callers get consistent path shapes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Add a
PLANNOTATOR_DATA_DIRenvironment variable that allows users to relocate the Plannotator data directory (default:~/.plannotator) to any path they prefer.Motivation
Plannotator currently hardcodes
~/.plannotator/as the base data directory in multiple places —storage.ts,config.ts,draft.ts,improvement-hooks.ts,sessions.ts,codex-review.ts,tour-review.ts,browser.ts, andpr-gitlab.ts. This clutters the home directory and conflicts with XDG conventions (XDG_DATA_HOME,XDG_CACHE_HOME, etc.) that many users follow to keep their home directories clean.The
PASTE_DATA_DIRenv var already exists as precedent for customizing sub-paths. This PR extends that pattern to the entire data directory.Changes
packages/shared/data-dir.ts— shared helpergetPlannotatorDataDir()that checksPLANNOTATOR_DATA_DIRfirst (with~expansion), falls back to~/.plannotatorjoin(homedir(), ".plannotator", ...)calls replaced withgetPlannotatorDataDir()homedirimports removed where possibleUsage
Backward Compatibility
Default behavior is unchanged — when
PLANNOTATOR_DATA_DIRis absent or empty, the data directory remains~/.plannotator.