Skip to content

feat: auto-discover project root by walking up to find .rr.yaml#155

Merged
rileyhilliard merged 1 commit intomainfrom
feat/project-root-discovery
Jan 27, 2026
Merged

feat: auto-discover project root by walking up to find .rr.yaml#155
rileyhilliard merged 1 commit intomainfrom
feat/project-root-discovery

Conversation

@rileyhilliard
Copy link
Copy Markdown
Owner

Summary

  • Fix config discovery to find .rr.yaml at the git root when running from subdirectories
  • Use project root (where .rr.yaml is located) as the working directory for sync operations
  • Add ProjectRoot field to ResolvedConfig to track where config was found

Problem

When running rr from a subdirectory of the project (e.g., myapp/src/components/ instead of myapp/), commands fail or sync incorrectly because rr uses the current working directory as the project root.

Solution

Walk up the directory tree to find .rr.yaml, similar to how other tools work:

  • git finds .git directory
  • npm/bun find package.json
  • cargo finds Cargo.toml

The config discovery code already had parent walking logic, but it had a bug where it stopped at the git root BEFORE checking if .rr.yaml exists there. This fix reorders the check.

Test plan

  • Added tests for walking up to parent directories
  • Added test for finding config at git root (the bug fix)
  • Added test for stopping at git root (not going above)
  • Added tests for ProjectRoot being populated correctly
  • Added tests for setupWorkDir using project root
  • All existing tests pass

Fixes #154

🤖 Generated with Claude Code

When running rr from a subdirectory of the project, commands now work
correctly by:

1. Walking up the directory tree to find .rr.yaml (similar to git, npm, cargo)
2. Using the project root (where .rr.yaml is located) as the working directory
   for sync operations instead of the current directory

The config discovery already had parent walking logic, but it had a bug where
it stopped at the git root BEFORE checking if .rr.yaml exists there. This fix
reorders the check to find config at the git root.

Fixes #154

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@rileyhilliard rileyhilliard merged commit 4d01dce into main Jan 27, 2026
5 checks passed
@rileyhilliard rileyhilliard deleted the feat/project-root-discovery branch January 27, 2026 03:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Auto-discover project root by walking up to find .rr.yaml

1 participant