-
Notifications
You must be signed in to change notification settings - Fork 2.6k
feat: enhance rule file loading with .roo/rules directory support #2354
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
Conversation
- Introduced functions to safely read files and check for directory existence.
- Added capability to read all text files from a specified directory in alphabetical order.
- Updated `loadRuleFiles` to prioritize loading rules from a `.roo/rules/` directory, falling back to existing rule files if necessary.
- Enhanced `addCustomInstructions` to support loading mode-specific rules from a `.roo/rules-{mode}/` directory, improving flexibility in rule management.
This change improves the organization and retrieval of rule files, allowing for better modularity and maintainability.
|
|
@mrubens I would like you to review the Pull Request to confirm if the direction is aligned 😄 I am intentionally leaving |
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.
Seems on the right track to me! Let's do it.
|
I just pushed a small change to update the promptsview and associated strings, hopefully not stepping on toes! |
| /** | ||
| * Safely read a file and return its trimmed content | ||
| */ | ||
| async function safeReadFile(filePath: string): Promise<string> { |
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.
This function is identical to the existing implementation. Consider importing and reusing the existing function instead.
- function
safeReadFile(custom-system-prompt.ts)
|
I'm not sure that the system prompt preview is loading the rules directories correctly |
- Implemented functionality in `custom-instruction.ts` to handle loading rules from custom instruction paths. - Refactored and fixed previously incorrect logic in `custom-instruction.ts` for better reliability and maintainability. (comment in RooCodeInc#2354) - Enhanced `system.ts` to pass custom instruction paths to `addCustomInstructions`. - Extended `roo-code.d.ts` and `types.ts` to include `customInstructionsPaths` in `ModeConfig`. - Modified `index.ts` schema to define `customInstructionsPathsConfigSchema` and integrate it into `ModeConfig`. - Updated `modes.ts` to support `customInstructionsPaths` in mode configuration and full mode details.
* initial * More error handling and git option * Cleanup and tweaks * one small change * Update src/integrations/checkpoints/CheckpointUtils.ts Co-authored-by: ellipsis-dev[bot] <65095814+ellipsis-dev[bot]@users.noreply.github.com> --------- Co-authored-by: ellipsis-dev[bot] <65095814+ellipsis-dev[bot]@users.noreply.github.com>
Context
This PR enhances the custom instructions system by adding support for directory-based rule loading and improving the file handling functionality. The main goal is to allow users to organize their rules in directories (
.roo/rules/and.roo/rules-${mode}/) while maintaining backward compatibility with existing file-based rules (.roorulesand.clinerules).Design Doc: https://hackmd.io/@upamune/roo-rule-directory
Implementation
The changes introduce several new functions and modify existing ones to support directory-based rule loading:
directoryExistsfunction to safely check if a directory existsreadTextFilesFromDirectoryfunction to read all text files from a directory recursivelyformatDirectoryContentfunction to format content from multiple files with proper headersloadRuleFilesto first check for.roo/rules/directory before falling back to single file rulesaddCustomInstructionsto support.roo/rules-${mode}/directory for mode-specific rulesThe implementation follows a progressive enhancement approach:
Key improvements:
How to Test
.roo/rules/directory and add some rule files.roo/rules-${mode}/directory (e.g.,.roo/rules-dev/) and add mode-specific rule files.roorulesand.clinerulesfiles.roorules-${mode}and.clinerules-${mode}files for mode-specific rulesGet in Touch
I'm available in the Roo Code Discord for any questions or discussions about these changes. (
serizawa_)Important
Enhance rule file loading by supporting
.roo/rules/directories, updating UI, tests, and translations for directory-based rule management.loadRuleFilesandaddCustomInstructionsnow support loading rules from.roo/rules/and.roo/rules-${mode}/directories..roorulesand.clinerulesif directories are not found.directoryExists,readTextFilesFromDirectory, andformatDirectoryContentincustom-instructions.ts.PromptsView.tsxto open rule files from new directory structure.custom-instructions.test.tsto cover new directory-based rule loading.This description was created by
for 381d526. It will automatically update as commits are pushed.