Skip to content

Conversation

@roomote
Copy link
Contributor

@roomote roomote bot commented Aug 7, 2025

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

  • Added support for global system prompts in ~/.roo/system-prompt-{mode}
  • Local project prompts (.roo/system-prompt-{mode}) still take precedence over global ones
  • Added getGlobalSystemPromptFilePath() helper function
  • Updated loadSystemPromptFile() to check both local and global locations
  • Updated hasFileBasedSystemPromptOverride() to check both locations
  • Added comprehensive tests for the new functionality

How it works

  1. When loading a system prompt, the system first checks for a local project-specific file at .roo/system-prompt-{mode}
  2. If no local file exists or it's empty, it checks for a global file at ~/.roo/system-prompt-{mode}
  3. Local files always take precedence, allowing project-specific overrides

Testing

  • All existing tests pass
  • Added new tests to verify:
    • Global prompt is used when local doesn't exist
    • Local prompt takes precedence when both exist
    • Proper fallback behavior

Fixes

Fixes #6813

Checklist

  • Code follows the project's style guidelines
  • Tests have been added/updated
  • All tests pass
  • Documentation has been updated (if applicable)

Important

Adds support for global system prompt overrides, prioritizing local prompts, with updates to prompt loading logic and comprehensive tests.

  • Behavior:
    • Adds support for global system prompts in ~/.roo/system-prompt-{mode}.
    • Local project prompts (.roo/system-prompt-{mode}) take precedence over global ones.
    • Updates loadSystemPromptFile() to check both local and global locations.
    • Updates hasFileBasedSystemPromptOverride() to check both locations.
  • Functions:
    • Adds getGlobalSystemPromptFilePath() to custom-system-prompt.ts.
  • Testing:
    • Adds tests in custom-system-prompt.spec.ts to verify global prompt usage and precedence logic.
  • Misc:

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

- 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
@roomote roomote bot requested review from cte, jr and mrubens as code owners August 7, 2025 15:28
@dosubot dosubot bot added size:L This PR changes 100-499 lines, ignoring generated files. documentation Improvements or additions to documentation enhancement New feature or request labels Aug 7, 2025
Copy link
Contributor Author

@roomote roomote bot left a comment

Choose a reason for hiding this comment

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

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) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

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.

}

/**
* Checks if there is a file-based system prompt override for the given mode
Copy link
Contributor Author

Choose a reason for hiding this comment

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

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")
Copy link
Contributor Author

Choose a reason for hiding this comment

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

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.

@hannesrudolph hannesrudolph added the Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels. label Aug 7, 2025
@daniel-lxs
Copy link
Member

This is not planned

@daniel-lxs daniel-lxs closed this Aug 9, 2025
@github-project-automation github-project-automation bot moved this from New to Done in Roo Code Roadmap Aug 9, 2025
@github-project-automation github-project-automation bot moved this from Triage to Done in Roo Code Roadmap Aug 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation 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

Archived in project

Development

Successfully merging this pull request may close these issues.

Global system prompt override for custom mode

4 participants