Skip to content

Conversation

@roomote
Copy link

@roomote roomote bot commented Oct 25, 2025

Description

This PR implements hierarchical configuration resolution for .roo directories and .roomodes files in mono-repositories, addressing Issue #8825.

Problem

In mono-repository setups, the current .roo resolution only checks global (~/.roo) and workspace-local directories. This makes it challenging to manage configurations for projects with multiple tech stacks and nested workspace structures.

Solution

This implementation introduces hierarchical directory walking, similar to .editorconfig and nuget.config behavior. The configuration system now:

  1. Walks up the directory tree from the current workspace
  2. Collects all .roo directories and .roomodes files in the hierarchy
  3. Merges configurations with more specific settings overriding general ones
  4. Maintains backward compatibility with a legacy mode flag

Changes

Core Implementation

  • Enhanced getRooDirectoriesForCwd() in src/services/roo-config/index.ts to support hierarchical resolution
  • Updated CustomModesManager to handle multiple .roomodes files in the hierarchy
  • Added getHierarchicalRoomodes() method for discovering .roomodes files up the directory tree

Key Features

  • ✅ Hierarchical directory traversal from workspace to parent directories
  • ✅ Protection against infinite loops and circular references
  • ✅ Platform-specific path handling (Windows/Unix)
  • ✅ Respects home directory boundaries
  • ✅ Backward compatibility via optional enableHierarchical parameter (defaults to true)

Testing

  • Added comprehensive test suite in src/services/roo-config/__tests__/hierarchical-resolution.spec.ts
  • Updated existing tests to maintain backward compatibility
  • All tests passing ✅

Example

For a project structure:

/home/user/
├── .roo/                         # Global config
├── mono-repo/
│   ├── .roo/                     # Repository-wide config
│   └── packages/
│       ├── .roo/                 # Packages-specific config
│       └── frontend/
│           └── .roo/             # Frontend-specific config

The resolution order is now:

  1. /home/user/.roo (global - least specific)
  2. /home/user/mono-repo/.roo
  3. /home/user/mono-repo/packages/.roo
  4. /home/user/mono-repo/packages/frontend/.roo (most specific)

Breaking Changes

None - the feature is enabled by default but maintains full backward compatibility.

Testing Instructions

  1. Create a nested directory structure with .roo folders at different levels
  2. Add different configurations at each level
  3. Verify that more specific configurations override general ones
  4. Test with enableHierarchical: false to verify legacy behavior

Fixes #8825


Important

Adds hierarchical resolution for .roo directories and .roomodes files, allowing configurations to be resolved from global to specific in mono-repos, with backward compatibility.

  • Behavior:
    • Implements hierarchical resolution for .roo directories and .roomodes files in CustomModesManager and getRooDirectoriesForCwd().
    • Configurations are merged from global to specific, with specific settings overriding general ones.
    • Backward compatibility maintained with enableHierarchical flag (default true).
  • Core Implementation:
    • getHierarchicalRoomodes() in CustomModesManager collects .roomodes files up the directory tree.
    • getRooDirectoriesForCwd() in index.ts resolves directories hierarchically.
  • Testing:
    • Added hierarchical-resolution.spec.ts for comprehensive testing of hierarchical resolution.
    • Updated existing tests in index.spec.ts to ensure backward compatibility.

This description was created by Ellipsis for 1b499c4. You can customize this summary. It will automatically update as commits are pushed.

- Implement hierarchical directory walking in getRooDirectoriesForCwd
- Update CustomModesManager to support hierarchical .roomodes files
- Add comprehensive tests for hierarchical resolution
- Maintain backward compatibility with legacy mode (non-hierarchical)

Fixes #8825
@roomote roomote bot requested review from cte, jr and mrubens as code owners October 25, 2025 21:47
@dosubot dosubot bot added size:L This PR changes 100-499 lines, ignoring generated files. enhancement New feature or request labels Oct 25, 2025
@roomote
Copy link
Author

roomote bot commented Oct 25, 2025

Review Summary

I've reviewed this PR and identified 1 issue that should be addressed:

  • File watcher doesn't monitor parent directory .roomodes files - changes to .roomodes files outside the workspace won't trigger updates

Follow Along on Roo Code Cloud

Comment on lines +378 to +380
// Create a generic pattern to watch all .roomodes files in the workspace tree
const roomodesPattern = new vscode.RelativePattern(workspaceFolders[0], "**/.roomodes")
const roomodesWatcher = vscode.workspace.createFileSystemWatcher(roomodesPattern)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The file watcher pattern **/.roomodes only watches files within the workspace directory, but getHierarchicalRoomodes() walks up to parent directories outside the workspace. This means changes to .roomodes files in parent directories won't trigger updates, requiring users to restart VSCode. For example, if the workspace is /home/user/mono-repo/packages/frontend and there's a .roomodes at /home/user/mono-repo/.roomodes, changes to the parent file won't be detected since it's outside the workspace tree being watched.

@hannesrudolph hannesrudolph added the Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels. label Oct 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels. size:L This PR changes 100-499 lines, ignoring generated files.

Projects

Status: Triage

Development

Successfully merging this pull request may close these issues.

[ENHANCEMENT] Working in mono repos is tricking with rules and mode resolutions

2 participants