Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Conversation

samhvw8
Copy link

@samhvw8 samhvw8 commented Jun 22, 2025

Related GitHub Issue

Closes: #4978

Description

Summary

This PR introduces a new hierarchical configuration system that supports both global (~/.roo/) and project-local (.roo/) directories for organizing rules and configuration files. This enhancement provides better organization and allows users to define global defaults while maintaining project-specific overrides.

What's Changed

🆕 New Features
  • Global configuration support: Rules can now be stored in ~/.roo/rules/ directory that apply across all projects
  • Project-local overrides: Project-specific rules in .roo/rules/ take precedence over global rules
  • Mode-specific rules: Both global and project-local mode-specific rules are supported via rules-{mode}/ directories
  • Hierarchical loading: Global rules are loaded first, then project-local rules are appended with clear labeling
🏗️ Architecture Changes
  • New roo-config service: Centralized service for managing .roo directory operations

    • getGlobalRooDirectory() - Platform-aware global .roo path resolution
    • getRooDirectoriesForCwd() - Ordered list of directories to check
    • loadConfiguration() - Unified configuration loading with merge support
    • Comprehensive file system utilities (directoryExists, fileExists, readFileIfExists)
  • Enhanced custom-instructions module: Updated to use the new roo-config service

    • Supports both new .roo directory structure and legacy .roorules files
    • Clear labeling of global vs project-specific rules in output
    • Maintains backward compatibility with existing rule files

Test Procedure

Pre-Submission Checklist

  • Issue Linked: This PR is linked to an approved GitHub Issue (see "Related GitHub Issue" above).
  • Scope: My changes are focused on the linked issue (one major feature/fix per PR).
  • Self-Review: I have performed a thorough self-review of my code.
  • Testing: New and/or updated tests have been added to cover my changes (if applicable).
  • Documentation Impact: I have considered if my changes require documentation updates (see "Documentation Updates" section below).
  • Contribution Guidelines: I have read and agree to the Contributor Guidelines.

Screenshots / Videos

Documentation Updates

Additional Notes

Get in Touch


Important

Adds support for hierarchical rule loading from global and project-local .roo directories, with tests and backward compatibility.

  • Behavior:
    • Supports loading rules from global (~/.roo/rules/) and project-local (.roo/rules/) directories.
    • Project-specific rules override global rules.
    • Supports mode-specific rules via rules-{mode}/ directories.
    • Falls back to legacy .roorules files if no .roo/rules directories exist.
  • Architecture:
    • Adds roo-config service with functions: getGlobalRooDirectory(), getProjectRooDirectoryForCwd(), directoryExists(), fileExists(), readFileIfExists(), getRooDirectoriesForCwd(), loadConfiguration().
    • Updates custom-instructions.ts to use roo-config service for rule loading.
  • Tests:
    • Adds tests for loadRuleFiles() and addCustomInstructions() in custom-instructions-global.spec.ts.
    • Adds tests for roo-config functions in index.spec.ts.

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

@samhvw8 samhvw8 requested review from cte, jr and mrubens as code owners June 22, 2025 16:07
@dosubot dosubot bot added size:XL This PR changes 500-999 lines, ignoring generated files. enhancement New feature or request labels Jun 22, 2025
@hannesrudolph hannesrudolph added the Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels. label Jun 22, 2025
@samhvw8 samhvw8 force-pushed the feat/support-dot-roo-global-folder branch from fa190a9 to bd23c9d Compare June 22, 2025 18:21
@daniel-lxs daniel-lxs moved this from Triage to PR [Needs Prelim Review] in Roo Code Roadmap Jun 22, 2025
@hannesrudolph hannesrudolph added PR - Needs Preliminary Review and removed Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels. labels Jun 22, 2025
Copy link
Collaborator

@daniel-lxs daniel-lxs left a comment

Choose a reason for hiding this comment

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

Thanks for your contribution! This PR is a great addition
I've left a few suggestions for improvement, mostly around consistency and robustness. Overall, great work!

src/services/roo-config/index.ts Show resolved Hide resolved
src/core/prompts/sections/custom-instructions.ts Outdated Show resolved Hide resolved
src/services/roo-config/index.ts Outdated Show resolved Hide resolved

const result = await loadRuleFiles(mockCwd)

originalConsoleLog("Result:", result)
Copy link
Collaborator

Choose a reason for hiding this comment

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

The tests include originalConsoleLog calls that don't seem to be used in the implementation. Could these be removed or converted to test assertions for cleaner tests?

src/services/roo-config/index.ts Outdated Show resolved Hide resolved
src/services/roo-config/index.ts Show resolved Hide resolved
@daniel-lxs daniel-lxs moved this from PR [Needs Prelim Review] to PR [Changes Requested] in Roo Code Roadmap Jun 23, 2025
samhvw8 added 4 commits June 24, 2025 09:45
…lobal directory detection

- Replace rooDir.includes(path.join(os.homedir(), '.roo')) with exact path comparison
- Use path.resolve() for robust path matching instead of string inclusion
- Import and use getGlobalRooDirectory() for consistency
- Add comprehensive tests for edge cases including paths with '.roo' in home directory
- Update existing test mocks to support new getGlobalRooDirectory function

This fixes potential false positives when home directory paths contain '.roo' elsewhere,
making the global vs project directory detection more reliable and maintainable.
…ted filesystem errors

- Replace broad catch-all error handling with specific error code checking
- Only catch expected errors (ENOENT, ENOTDIR, EISDIR) in filesystem operations
- Allow unexpected errors (EACCES, EIO, etc.) to propagate for proper diagnosis
- Update directoryExists(), fileExists(), and readFileIfExists() functions
- Add comprehensive test coverage for both expected and unexpected error scenarios
- Verify loadConfiguration() properly propagates errors from file operations

This prevents masking of critical system errors like permission issues, I/O failures,
and disk problems while maintaining graceful handling of expected "file not found" cases.
Improves debugging capabilities and follows error handling best practices.

Fixes potential issues where permission denied or I/O errors were silently treated
as "file doesn't exist", making troubleshooting difficult in production environments.
@samhvw8 samhvw8 force-pushed the feat/support-dot-roo-global-folder branch from bd23c9d to edde83a Compare June 24, 2025 04:43
Copy link
Collaborator

@daniel-lxs daniel-lxs left a comment

Choose a reason for hiding this comment

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

Thank you for addressing the suggestions!

I made a small change to clean up the rules headers to follow follow the current behavior, I don't think there's a benefit to explaining where the rules come from 2 times:

image

@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Jun 24, 2025
@samhvw8
Copy link
Author

samhvw8 commented Jun 24, 2025

Thank you for addressing the suggestions!

I made a small change to clean up the rules headers to follow follow the current behavior, I don't think there's a benefit to explaining where the rules come from 2 times:

image

thanks you for polish it <3

@daniel-lxs daniel-lxs moved this from PR [Changes Requested] to PR [Needs Review] in Roo Code Roadmap Jun 24, 2025
@mrubens mrubens merged commit c8b92e0 into RooCodeInc:main Jun 24, 2025
17 checks passed
@github-project-automation github-project-automation bot moved this from New to Done in Roo Code Roadmap Jun 24, 2025
@github-project-automation github-project-automation bot moved this from PR [Needs Review] to Done in Roo Code Roadmap Jun 24, 2025
cte pushed a commit that referenced this pull request Jun 24, 2025
…o directories (#5016)

Co-authored-by: Daniel Riccio <ricciodaniel98@gmail.com>
@samhvw8 samhvw8 deleted the feat/support-dot-roo-global-folder branch June 25, 2025 02:30
Alorse pushed a commit to Alorse/Roo-Code that referenced this pull request Jun 27, 2025
…o directories (RooCodeInc#5016)

Co-authored-by: Daniel Riccio <ricciodaniel98@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request lgtm This PR has been approved by a maintainer PR - Needs Review size:XL This PR changes 500-999 lines, ignoring generated files.

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

Cross-Workspace Custom Instructions Sharing with Global .roo/rules Directory Support

4 participants

Morty Proxy This is a proxified and sanitized view of the page, visit original site.