Skip to content

feat: support external custom instruction files and extension-based targeting #6099

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

roomote[bot]
Copy link

@roomote roomote bot commented Jul 23, 2025

Summary

This PR implements two enhancements to improve the flexibility and scalability of RooCode's custom instruction system as requested in #6098:

1. Support for External Instruction Files with Path Reference

  • Users can now reference external instruction files by specifying their relative or absolute path
  • Example: ./.github/copilot-instructions.md
  • The system will attempt to load the file content; if the file doesn't exist, it falls back to treating the path as a literal instruction string
  • This allows reusing instruction templates across multiple projects

2. Extension-Based Instruction Targeting

  • Introduced a new function loadExtensionSpecificInstructions that loads instructions based on file extensions
  • Supports naming convention like py-instruction.md for Python files, ts-instruction.md for TypeScript files, etc.
  • The system checks for these files in:
    • Global .roo directory
    • Project-local .roo directory
    • Project root directory (for legacy support)
  • This enables precise, language-aware context based on the file being edited

Changes

  • Modified addCustomInstructions to support loading instructions from file paths
  • Added new loadExtensionSpecificInstructions function for extension-based targeting
  • Added comprehensive tests for both features
  • Exported the new function for future integration

Testing

  • Added 14 new test cases covering various scenarios
  • All existing tests continue to pass
  • Tests cover edge cases like non-existent files, directories, absolute/relative paths, and multiple instruction sources

Fixes #6098


Important

This PR adds support for external instruction files and extension-based targeting in RooCode's custom instruction system, enhancing flexibility and scalability.

  • Behavior:
    • addCustomInstructions now supports loading instructions from file paths, falling back to literal strings if files don't exist.
    • New loadExtensionSpecificInstructions function loads instructions based on file extensions, checking .roo directories and project root.
  • Functions:
    • Added loadInstructionFromPath to read instructions from file paths in custom-instructions.ts.
    • Modified addCustomInstructions to integrate file path support.
    • Added loadExtensionSpecificInstructions to handle extension-based targeting.
  • Testing:
    • Added 14 new test cases in custom-instructions.spec.ts for various scenarios including non-existent files and multiple instruction sources.
    • Tests cover edge cases like directories, absolute/relative paths, and extension-specific instructions.

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

…-based targeting

- Support loading custom instructions from external file paths (e.g., ./.github/copilot-instructions.md)
- Add extension-based instruction targeting (e.g., py-instruction.md for Python files)
- Add comprehensive tests for both features
- Export new loadExtensionSpecificInstructions function for future integration

Fixes #6098
@roomote roomote bot requested review from mrubens, cte and jr as code owners July 23, 2025 07:16
@dosubot dosubot bot added size:L This PR changes 100-499 lines, ignoring generated files. enhancement New feature or request labels Jul 23, 2025
@hannesrudolph hannesrudolph added the Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels. label Jul 23, 2025
@daniel-lxs
Copy link
Collaborator

Closing, see #6098 (comment)

@daniel-lxs daniel-lxs closed this Jul 24, 2025
@github-project-automation github-project-automation bot moved this from New to Done in Roo Code Roadmap Jul 24, 2025
@github-project-automation github-project-automation bot moved this from Triage to Done in Roo Code Roadmap Jul 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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
Status: Done
Development

Successfully merging this pull request may close these issues.

Support external custom instruction files and extension-based instruction targeting
3 participants