Support XDG Base Directory Specification for config/data/cache paths
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 19.9k
- Forks
- 2.3k
- Avg merge
- 2d 7h
- Merged PRs (30d)
- 30
Description
Summary
Jcode currently stores all user data under ~/.jcode, mixing configuration, runtime data, caches, and state in a single directory. This conflicts with the XDG Base Directory Specification which is widely adopted on Linux and increasingly respected on macOS.
Proposed Behavior
Respect XDG environment variables (with sensible defaults) to separate concerns:
| Purpose | XDG Variable | Default (Linux) | Default (macOS) | Current |
|---|---|---|---|---|
Config (config.toml) |
XDG_CONFIG_HOME |
~/.config/jcode |
~/Library/Application Support/jcode or ~/.config/jcode |
~/.jcode/config.toml |
| Data (sessions, todos, auth) | XDG_DATA_HOME |
~/.local/share/jcode |
~/.local/share/jcode |
~/.jcode/ |
| Cache (builds, logs) | XDG_CACHE_HOME |
~/.cache/jcode |
~/Library/Caches/jcode |
~/.jcode/ |
| Runtime (PIDs, sockets) | XDG_RUNTIME_DIR |
/run/user/$UID/jcode |
$TMPDIR/jcode |
~/.jcode/ |
Migration
- On first run with the new version, automatically migrate from
~/.jcodeto the new locations (or provide ajcode migratecommand). - Continue to respect
~/.jcodeas a fallback if it exists and XDG dirs do not, for backward compatibility. - Optionally support
JCODE_HOMEas an override that preserves the single-directory layout.
Motivation
- Keeps
$HOMEclean for users who care about dotfile hygiene. - Allows caches to be excluded from backups without excluding config.
- Aligns with community expectations (see: similar issues in countless CLI tools).
- Enables proper separation on multi-user or containerized systems.
References
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
No files or tests are named in the issue. Start by locating the current ~/.jcode path handling and its config, data, cache, and runtime call sites, then review the XDG specification and platform defaults; done means separated paths, migration or fallback behavior, and optional JCODE_HOME support work without breaking existing users.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- cli, operating-systems
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100