-
Notifications
You must be signed in to change notification settings - Fork 2.3k
feat: add support for loading rules from global and project-local .roo directories #5016
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add support for loading rules from global and project-local .roo directories #5016
Conversation
fa190a9
to
bd23c9d
Compare
There was a problem hiding this 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!
|
||
const result = await loadRuleFiles(mockCwd) | ||
|
||
originalConsoleLog("Result:", result) |
There was a problem hiding this comment.
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?
…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.
…d examples and usage
bd23c9d
to
edde83a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
…o directories (#5016) Co-authored-by: Daniel Riccio <ricciodaniel98@gmail.com>
…o directories (RooCodeInc#5016) Co-authored-by: Daniel Riccio <ricciodaniel98@gmail.com>
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
~/.roo/rules/
directory that apply across all projects.roo/rules/
take precedence over global rulesrules-{mode}/
directories🏗️ Architecture Changes
New
roo-config
service: Centralized service for managing .roo directory operationsgetGlobalRooDirectory()
- Platform-aware global .roo path resolutiongetRooDirectoriesForCwd()
- Ordered list of directories to checkloadConfiguration()
- Unified configuration loading with merge supportdirectoryExists
,fileExists
,readFileIfExists
)Enhanced
custom-instructions
module: Updated to use the new roo-config serviceTest Procedure
Pre-Submission Checklist
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.~/.roo/rules/
) and project-local (.roo/rules/
) directories.rules-{mode}/
directories..roorules
files if no.roo/rules
directories exist.roo-config
service with functions:getGlobalRooDirectory()
,getProjectRooDirectoryForCwd()
,directoryExists()
,fileExists()
,readFileIfExists()
,getRooDirectoriesForCwd()
,loadConfiguration()
.custom-instructions.ts
to useroo-config
service for rule loading.loadRuleFiles()
andaddCustomInstructions()
incustom-instructions-global.spec.ts
.roo-config
functions inindex.spec.ts
.This description was created by
for fa190a9. You can customize this summary. It will automatically update as commits are pushed.