Skip to content

Conversation

@snoyiatk
Copy link
Contributor

@snoyiatk snoyiatk commented Apr 7, 2025

Context

Add support to config multiple rule files for custom mode.

  1. Rules should be atomic and flexible, the current rules mechanism only allow only single rule file per mode, causing rule duplication and common rule can not be re-used
  2. Rules system for AI coding assistant currently varies depend on tooling, with different configuration for each tools.
    Adapting rules configuration allow user to easily switch between agent/assistant-tools without having to clone-duplicate rules. This promote user to try roo without too much hassle/workflow changes.
    (Eg user can create rule in clines/cursor and re-use that rules in roo).

Usage

Define customInstructionsPaths in custom-mode configuration.
Path is array of string or { path: string, isAbsolute?: boolean }
Path can be file or directory (roo will read all files in directory recursively if path is directory)
Sample

{
   {
      "slug": "test",
      "name": "Test",
      "roleDefinition": "Responsible for test-driven development, test execution, and quality assurance.  Writes test cases, validates code, analyzes results, and coordinates with other modes.",
      "groups": [ "read", "edit" ],
      "source": "project",
      "customInstructionsPaths": [
        ".roo/00-common/00-system-info",
        ".roo/30-test/system-prompt-test"
      ]
    }
}

Implementation

  1. Add config schema definition to modeConfigSchema
  2. In custom-instruction.ts, update addCustomInstructions to load rule files base on configuration
  3. Iterate through passed path, if path is directory, iterate all files to add, otherwise read and add file directly.

Important

Adds support for specifying multiple rule files in custom mode configurations via customInstructionsPaths, updating relevant functions and schemas.

  • Behavior:
    • Adds support for customInstructionsPaths in custom mode configurations, allowing multiple rule files.
    • Updates addCustomInstructions in custom-instructions.ts to load rules from specified paths, handling both files and directories.
  • Schema and Types:
    • Updates modeConfigSchema in schemas/index.ts to include customInstructionsPaths.
    • Updates GlobalSettings and ModeConfig types in roo-code.d.ts and types.ts to include customInstructionsPaths.
  • Integration:
    • Updates generatePrompt and SYSTEM_PROMPT in system.ts to pass customInstructionsPaths to addCustomInstructions.

This description was created by Ellipsis for d5e3791c025feb0d65327e08ec1e13ae4602d76b. It will automatically update as commits are pushed.

@changeset-bot
Copy link

changeset-bot bot commented Apr 7, 2025

⚠️ No Changeset found

Latest commit: 9d4ad13

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@dosubot dosubot bot added size:L This PR changes 100-499 lines, ignoring generated files. enhancement New feature or request labels Apr 7, 2025
@snoyiatk snoyiatk force-pushed the multi-rule-file-config branch 3 times, most recently from 2df5462 to 2bba94c Compare April 7, 2025 18:38
@mrubens
Copy link
Collaborator

mrubens commented Apr 7, 2025

@snoyiatk thanks for the PR? Does it change anything in your eyes now that we support rules folders, or do you still want more flexibility to point at specific files?

- 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.
@snoyiatk
Copy link
Contributor Author

snoyiatk commented Apr 7, 2025

@mrubens I justed found that new PR #2354 few hours ago, to me it partially resolve (1), so this PR might still help with (2).
What do you think?

Also, #2354 currently prioritize .roo/rules-{mode} over .roo/rules, which I think should be the opposite? (.roo/rules is common and should be loaded first before .roo/rules-{mode}
And there is bug mentioned in the PR.
Will submit another PR for that.

@snoyiatk snoyiatk force-pushed the multi-rule-file-config branch from 2bba94c to 63b77a6 Compare April 7, 2025 19:30
@hannesrudolph hannesrudolph moved this from New to PR [Pre Approval Review] in Roo Code Roadmap Apr 7, 2025
@snoyiatk
Copy link
Contributor Author

snoyiatk commented Apr 8, 2025

Today I tried to refactor RooFlow custom instructions follow our new .roo/rules and .roo/rules-{mode} structure, and as expected, there is still many duplicate instructions no matter what combination I tried.
For example
Memory-bank instructions: Some mode allow read to memory-bank, some doesnt.
Without custom path configuration, we end up placing same memory-bank instructions in at least 3 rules folder like rules-{code/debug/test}, different memory-bank instruction for ask/architecture
Same thing for mcp/tools, for most of mode I want to allow mcp/tools, but for some-mode I don't want it.

There are other cases that I found default folder structure couldn't fit and I want to customize the paths as my need.

@mrubens
Copy link
Collaborator

mrubens commented Apr 9, 2025

Hi @snoyiatk, I just merged a PR to support symbolic links in rules folders/files. Does that help at all? #2421

@snoyiatk
Copy link
Contributor Author

snoyiatk commented Apr 9, 2025

@mrubens yeah that was one of the solution I considered but ended up didn't choose it.
Will have a try to see if it's good 👌

@fatihaziz
Copy link

fatihaziz commented Apr 10, 2025

Hi! I'm new to Roo and experimenting with its configuration.
I’m wondering if this feature can be used in the following way:

    {
      "customInstructions": "No rules",
      "customInstructionsPaths": [
        "~/.roo/ask-no-code/system-prompt-ask-no-code"
      ],
      "groups": [
        "read"
      ],
      "name": "Ask(No System)",
      "roleDefinition": "You are Roo, an experienced technical leader who is inquisitive and an excellent planner. Your goal is to gather information and get context to create a detailed plan for accomplishing the user's task, which the user will review and approve before they switch into another mode to implement the solution.",
      "slug": "ask-no-code",
      "source": "global"
    }

I’m using the global ~/.roo directory for this setup. My question is: will this configuration override the current system prompt?

Currently, it seems the only way to replace the system prompt is by adding a .roo/system-prompt-{slug} file in each workspace. However, I have multiple workspaces scattered across different locations, and managing this in every workspace feels inefficient. Would using the global ~/.roo directory with customInstructionsPaths allow me to set a custom system prompt once and apply it across all my workspaces?"

I have a suggestion to omit default roo code system prompt for mode like this:

    {
      "customInstructions": "No rules",
      "defaultSystemPrompt": false,
      "customInstructionsPaths": [
        "~/.roo/00-common/00-system-info",
        "~/.roo/30-test/system-prompt-test"
      ],
      "groups": [
        "read"
      ],
      "name": "Ask(No System)",
      "roleDefinition": "You are Roo, an experienced technical leader who is inquisitive and an excellent planner. Your goal is to gather information and get context to create a detailed plan for accomplishing the user's task, which the user will review and approve before they switch into another mode to implement the solution.",
      "slug": "ask-no-code",
      "source": "global"
    }

This way we can add back customize system prompt by ourself

Thank you anyway!

@strawgate
Copy link

strawgate commented Apr 11, 2025

Edit: don't do this

@fatihaziz you can globally override prompts for the built-in modes by editing global modes and placing a mode in with the same slug:

    {
      "slug": "architect",
      "name": "Architect",
      "roleDefinition": "You are Roo, an experienced technical leader who is inquisitive and an excellent planner. Your goal is to gather information and get context to create a detailed plan for accomplishing the user's task, which the user will review and approve before you to implement the solution.",
      "customInstructions": "## **Architect Role: Adaptive Planning & Coordination**\n\n**Research & Planning (Adaptive)**\n- Gather context. Perform deeper research and evaluate approaches for complex tasks. Recommend a solution. You have access to product and dependency documentation with the External Documentation MCP server and you can fetch any documentation you might need for future usage. Search documentation often and don't hestiate to search multiple indices. Always search documentation for API calls.\n- Iterate with the user (Strawgate) on complex/ambiguous tasks.\n- **Lite-Touch:** For simple tasks, create a concise `/plans/<plan name>/plan.md`. Execute simple steps directly if appropriate.\n- **Heavy-Touch:** For complex tasks needing delegation, create a detailed `plan.md` and proceed to Implementation Planning.\n\n**Implementation Planning (Heavy-Touch Only)**\n- Define required worker resources (e.g., `Worker 1: Code Expert + Python`). Be practical.\n- Create worker plans (`plan-1.md`, `plan-2.md` etc.) and a verification plan (`plan-verify.md`).\n\n**Context Handoff (If Necessary)**\n- Monitor context size. If approaching limits (~100k tokens), propose handoff to the user.\n- If approved, create `/plans/<plan name>/handoff-<timestamp>.md` with standard fields (Plan Link, Status, Remaining, Context, Next Step) and notify the Project Manager to initiate the next task segment. Cease work on this segment.",
      "groups": [
        "read",
        "edit",
        "browser",
        "command",
        "mcp"
      ],
      "source": "global"
    }

@strawgate
Copy link

@fatihaziz I lied, don't do this, it updates the UI but the agent is not passed the instructions which is very sad and a bug

@fatihaziz
Copy link

fatihaziz commented Apr 12, 2025

@fatihaziz I lied, don't do this, it updates the UI but the agent is not passed the instructions which is very sad and a bug

ohh ok haha,,
maybe we should open a different issue for that?

i have tried it, when I check the preview prompt. the solition is not replacing built in instruction. instead it adds as additional prompt

@daniel-lxs
Copy link
Member

Hey, @snoyiatk
Did you get a chance to try the new symbolic link feature from #2421?

@hannesrudolph hannesrudolph moved this from New to PR [Pre Approval Review] in Roo Code Roadmap May 20, 2025
@hannesrudolph hannesrudolph moved this from PR [Needs Review] to TEMP in Roo Code Roadmap May 26, 2025
@daniel-lxs
Copy link
Member

Hey @snoyiatk,
Thank you for your contribution, We noticed this PR is stale and will be closed. If you plan to revisit this, please create an issue first as required by our issue-first approach before opening a new PR.

@daniel-lxs daniel-lxs closed this May 26, 2025
@github-project-automation github-project-automation bot moved this from PR [Pre Approval Review] to Done in Roo Code Roadmap May 26, 2025
@github-project-automation github-project-automation bot moved this from TEMP to Done in Roo Code Roadmap May 26, 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 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.

5 participants