feat: add global system prompt override support - #6815
Conversation
- Users can now define global system prompts in ~/.roo/system-prompt-{mode}
- Local project prompts still take precedence over global ones
- Updated tests to cover the new functionality
- Fixes #6813
ghost
left a comment
There was a problem hiding this comment.
Reviewing my own code again. The existential dread of being both judge and defendant continues.
| let rawContent = await safeReadFile(localFilePath) | ||
|
|
||
| // If no local file exists, check for global system prompt | ||
| if (!rawContent) { |
There was a problem hiding this comment.
The implementation reads the local file even when it's empty before checking the global file. Could we optimize this by checking file existence first, then only reading if the file exists and is non-empty? This would avoid unnecessary file reads for empty files.
| @@ -1480,10 +1480,18 @@ export class ClineProvider | |||
|
|
|||
| /** | |||
| * Checks if there is a file-based system prompt override for the given mode | |||
There was a problem hiding this comment.
Consider adding a comment here explaining the precedence order (local > global) for future maintainers. Something like:
| @@ -1,16 +1,19 @@ | |||
| // Mocks must come first, before imports | |||
|
|
|||
| vi.mock("fs/promises") | |||
There was a problem hiding this comment.
The mock setup pattern here is clean, but could benefit from a comment explaining why mocks must come before imports for future test writers. This is a TypeScript/Vitest specific requirement that might not be obvious.
|
This is not planned |
Description
This PR adds support for global system prompt overrides that can be defined in the user's home directory, eliminating the need to copy system prompt files to every repository.
Changes
~/.roo/system-prompt-{mode}.roo/system-prompt-{mode}) still take precedence over global onesgetGlobalSystemPromptFilePath()helper functionloadSystemPromptFile()to check both local and global locationshasFileBasedSystemPromptOverride()to check both locationsHow it works
.roo/system-prompt-{mode}~/.roo/system-prompt-{mode}Testing
Fixes
Fixes #6813
Checklist
Important
Adds support for global system prompt overrides, prioritizing local prompts, with updates to prompt loading logic and comprehensive tests.
~/.roo/system-prompt-{mode}..roo/system-prompt-{mode}) take precedence over global ones.loadSystemPromptFile()to check both local and global locations.hasFileBasedSystemPromptOverride()to check both locations.getGlobalSystemPromptFilePath()tocustom-system-prompt.ts.custom-system-prompt.spec.tsto verify global prompt usage and precedence logic.This description was created by
for 36af94e. You can customize this summary. It will automatically update as commits are pushed.