feat(config): resolve relative paths based on config file parent directory#166
feat(config): resolve relative paths based on config file parent directory#166
Conversation
…cation Relative paths in `definitions.paths` and `definitions.sandbox` (fs.writable, fs.deny) were used as-is, causing different results depending on the working directory when running `runok exec`. Following the convention of ESLint, TypeScript, and other tools, relative paths are now resolved against the parent directory of the configuration file that defines them. Each config file's paths are resolved before merging, so global and local configs use their respective base directories. Preset files loaded via `extends` also resolve paths relative to the preset file's location. - Add `path_resolver` module with `resolve_path()` and `resolve_config_paths()` for path classification and resolution - Integrate path resolution into `ConfigLoader` (before merge) and `load_local_preset` / `load_preset_with` (for extends) - Move `expand_tilde()` from `command_executor` to `path_resolver` to consolidate path handling logic - Add integration tests verifying consistent results across different cwd values Co-Authored-By: Claude Opus 4.6 <[email protected]>
Clippy denies `unwrap_used`, `expect_used`, and `panic` in this project. The path_resolution integration tests used `unwrap_or_else` with `panic!` in the fixture, which triggered `clippy::panic`. Replace the `#[fixture]` with a `make_env()` helper returning `Result`, and convert all test functions to return `Result<(), Box<dyn Error>>` with `?` operator. This eliminates all `unwrap()`, `expect()`, and `panic!()` calls from the test module. Co-Authored-By: Claude Opus 4.6 <[email protected]>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #166 +/- ##
==========================================
+ Coverage 89.44% 89.55% +0.11%
==========================================
Files 37 38 +1
Lines 6981 7154 +173
==========================================
+ Hits 6244 6407 +163
- Misses 737 747 +10
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request significantly improves the reliability and predictability of path handling within configuration files. By shifting the base for relative path resolution from the current working directory to the configuration file's parent directory, it eliminates a source of inconsistent behavior. This change, along with the introduction of a dedicated path resolution module, ensures that all configured paths, including those in sandbox policies and extended presets, are interpreted consistently across different execution environments. Highlights
Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
This project's code comments should be in English per the repository conventions. The path resolution feature was initially implemented with Japanese comments across all new and modified files. Co-Authored-By: Claude Opus 4.6 <[email protected]>
`resolve_config_paths` treated `<path:name>` references (e.g.
`<path:sensitive>`) as relative paths and joined them with base_dir,
producing `/project/<path:sensitive>`. This broke the later
`expand_sandbox_path_refs()` step which uses `strip_prefix("<path:")`
to match these references.
Skip `<path:name>` references in the resolve loop. Also extract the
repeated resolve-and-replace logic into a `resolve_vec` closure, and
revert an unnecessary comment change in command_executor.rs.
Co-Authored-By: Claude Opus 4.6 <[email protected]>
Why
definitions.paths,definitions.sandboxfs.writable/fs.deny) are resolved based on cwd, causing different paths to be referenced depending on where the command is executedWhat
/) are used as-is, home directory paths (~/) are expanded with$HOME, and relative paths are joined with the config file's parent directoryextendsare also resolved relative to the preset file's parent directoryexpand_tilde()fromcommand_executor.rsinto thepath_resolvermodule