dcdpr / dcdpr/jp

Switch from `PathBuf` to `relative-path` crate for cross-platform configuration storage

Open
#191 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
Dominant language
Rust
Stars
16
Forks
3
Avg merge
1d 1h
Merged PRs (30d)
121

Description

Replace PathBuf usage with the relative-path crate to ensure cross-platform compatibility for paths stored in configuration files and JSON files in .jp/.

Context

Currently, JP uses std::path::PathBuf throughout the codebase for handling paths, including those that are persisted in configuration files and JSON files stored in the .jp/ directory. This creates cross-platform compatibility issues because:

  1. PathBuf can accidentally store absolute paths in configuration files, making them non-portable between different user environments
  2. Platform-specific path separators (backslash on Windows, forward slash on Unix) can get persisted in configuration files
  3. Paths that work on one platform may fail on another when configuration files are shared

The relative-path crate (32M+ downloads) solves these issues by providing portable relative UTF-8 paths that use forward slashes regardless of platform and require explicit specification of what paths are relative to at runtime, preventing accidental absolute path storage.

Alternatives

We could continue using PathBuf and implement manual path normalization, but this would be error-prone and the relative-path crate already provides a well-tested solution. According to the crate's documentation, it was specifically designed to solve the portability issues that PathBuf creates when paths are stored in configuration files.

Tasks

  • Add relative-path crate dependency with serde feature
  • Replace config_load_paths field in Config struct to use RelativePathBuf
  • Modify configuration parsing to resolve relative paths at runtime using workspace root
  • Update CLI path handling to convert between PathBuf and RelativePathBuf
  • Add migration logic for existing configuration files with absolute paths
  • Update documentation with examples of relative path usage
  • Test cross-platform compatibility with sample configuration files

Resources

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with crates/jp_config/src/config.rs, then inspect path handling in crates/jp_mcp/src/transport.rs and crates/jp_cli/src/lib.rs. Trace how configuration and .jp/ JSON paths are parsed and passed to the CLI, including existing absolute-path data. Done means portable relative paths are serialized, resolved from the workspace root, migrated where needed, documented, and checked across platforms.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
cli, tooling
Issue type
Refactor
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.