8000 Refactoring System Prompt by shariqriazz · Pull Request #3275 · RooCodeInc/Roo-Code · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Refactoring System Prompt #3275

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

Draft
wants to merge 18 commits into
base: main
Choose a base branch
from

Conversation

shariqriazz
Copy link
@shariqriazz shariqriazz commented May 7, 2025

Description

This PR refactors the system prompt generation logic and simplifies various sections of the prompt for conciseness and clarity. The main goals were to provide more flexibility in how system prompts are defined and to make the prompts easier for the AI to process.

Key changes include:

  • System Prompt Generation Refactor (src/core/prompts/system.ts):

    • Introduced an internal generatePrompt function to assemble the prompt from modular components.
    • The main SYSTEM_PROMPT export now prioritizes loading custom system prompts from dedicated files (e.g., .cline/.system-prompt or .cline/modes/your-mode/.system-prompt).
    • If a file-based custom prompt is used, it results in a simpler overall system prompt structure that primarily uses the file's content, appending only the role definition and custom instructions, and omitting detailed tool descriptions and other standard sections.
    • If no file-based prompt is found, the system falls back to the component-based generation, producing the full, detailed prompt as before, but with updated sections.
    • Improved JSDoc comments and parameter handling for clarity.
  • Simplification of Prompt Sections:

    • Rules Section (src/core/prompts/sections/rules.ts): Significantly condensed and streamlined. Redundant explanations, lengthy examples, and verbose wording have been removed or shortened to make the rules more direct.
    • Tool Descriptions (various files in src/core/prompts/tools/ and sections/): Descriptions for tools like apply_diff, write_to_file, insert_content, and search_and_replace were updated for brevity and clarity within the main "TOOL USE" section and related "RULES". The FILE_CONTENT_WARNING constant is now used for write_to_file.
    • MCP Server Creation Instructions (src/core/prompts/instructions/create-mcp-server.ts): The instructions for creating MCP servers have been heavily refactored into a more concise quick reference guide. It now focuses on configuration examples (local stdio and remote SSE) and essential steps, removing verbose explanations.
    • Other prompt sections (e.g., capabilities.ts, custom-instructions.ts, modes.ts, objective.ts, system-info.ts, tool-use-guidelines.ts) received minor updates to align with the overall simplification and refactoring.
  • Constants (src/core/prompts/constants.ts): Introduced/updated constants like FILE_CONTENT_WARNING to centralize common messages.

  • Testing:

  • Shared Mode Logic: Minor updates in src/shared/modes.ts and src/shared/__tests__/modes.test.ts.

This refactor should improve the maintainability of the prompt generation code and the effectiveness of the prompts themselves.

Test Procedure

  1. Review the updated Jest snapshots in src/core/prompts/__tests__/__snapshots__/system.test.ts.snap to see the new prompt structures.
  2. Manually trigger system prompt generation in various modes (especially default code mode and any custom modes) to inspect the output.
  3. Test the file-based custom system prompt functionality:
    • Create a .cline/.system-prompt file in the workspace root with custom content. Observe that the generated prompt uses this content and has a simpler structure.
    • Create a .cline/modes/your-custom-mode/.system-prompt file for a specific custom mode and verify it's used for that mode.
  4. Verify that when no file-based custom prompt is present, the full component-based prompt is generated with the new concise sections.
  5. Test fetch_instructions for create_mcp_server and create_mode to see the updated instructions.
  6. Run all unit tests (npm test) to ensure they pass.

Type of Change

  • 🐛 Bug Fix: Non-breaking change that fixes an issue.
  • New Feature: Non-breaking change that adds functionality (file-based custom system prompts).
  • ♻️ Refactor: Code change that neither fixes a bug nor adds a feature (primary focus is refactoring and simplification).
  • 💅 Style: Changes that do not affect the meaning of the code (white-space, formatting, etc.).
  • 📚 Documentation: Updates to documentation files (JSDoc comments improved).
  • ⚙️ Build/CI: Changes to the build process or CI configuration.
  • 🧹 Chore: Other changes that don't modify `src` or test files.

Pre-Submission Checklist

  • Scope: My changes are focused on the linked issue (one major feature/fix per PR).
  • Self-Review: I have performed a thorough self-review of my code.
  • Code Quality:
    • My code adheres to the project's style guidelines.
    • There are no new linting errors or warnings (`npm run lint`).
    • All debug code (e.g., `console.log`) has been removed.
  • Testing:
    • New and/or updated tests have been added to cover my changes (snapshots updated, existing tests cover logic).
    • All tests pass locally (`npm test`).
    • The application builds successfully with my changes.
  • Branch Hygiene: My branch is up-to-date with the `main` branch.
  • Documentation Impact: Have you considered if your changes require documentation updates? (See "Documentation Updates" section below).
  • Changeset: Does this PR include user-facing changes or dependency updates that require a changeset (`npm run changeset`)?

Screenshots / Videos

N/A (Changes are to internal prompt generation)

Documentation Updates

  • No documentation updates are required.
  • Yes, documentation updates are required. (The new functionality for file-based custom system prompts should be documented for users, explaining how to create and use `.system-prompt` files in `.cline/` or `.cline/modes//` directories.)

Additional Notes

This refactor is a significant step towards making system prompts more manageable and customizable. The introduction of file-based prompts offers users greater control over the AI's persona and instructions for specific modes or globally.


Important

Refactors system prompt generation for modularity and clarity, introduces file-based custom prompts, and updates tool descriptions and prompt sections for improved maintainability and user customization.

  • Behavior:
    • Refactors system prompt generation in system.ts with generatePrompt() for modular assembly.
    • Supports file-based custom prompts, simplifying structure by omitting standard sections if a file is used.
    • Updates SYSTEM_PROMPT to prioritize file-based prompts, falling back to component-based generation.
  • Prompt Sections:
    • Simplifies rules.ts, capabilities.ts, and tool-use-guidelines.ts for clarity and brevity.
    • Updates tool descriptions in tools/ for consistency and clarity.
    • Refactors create-mcp-server.ts and create-mode.ts instructions for conciseness.
  • Constants:
    • Introduces constants.ts for shared text elements like TOOL_USE_FORMAT and FILE_CONTENT_WARNING.
  • Testing:
    • Updates Jest snapshots in system.test.ts.snap to reflect prompt changes.
    • Minor test updates in responses-rooignore.test.ts and sections.test.ts.
  • Misc:
    • Updates modes.ts with new mode configurations and instructions.

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

Copy link
changeset-bot bot commented May 7, 2025

⚠️ No Changeset found

Latest commit: 018c202

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:XXL This PR changes 1000+ lines, ignoring generated files. documentation Improvements or additions to documentation enhancement New feature or request labels May 7, 2025
@shariqriazz shariqriazz marked this pull request as draft May 7, 2025 16:37
@shariqriazz
Copy link
Author

I recommend 0.25 temp for coder

@hannesrudolph hannesrudolph moved this from New to PR [Pre Approval Review] in Roo Code Roadmap May 7, 2025
@hannesrudolph hannesrudolph moved this from PR [Pre Approval Review] to PR [Draft/WIP] in Roo Code Roadmap May 10, 2025
@hannesrudolph hannesrudolph moved this from New to PR [Draft/WIP] in Roo Code Roadmap May 20, 2025
@hannesrudolph hannesrudolph moved this from PR [Draft / In Progress] to TEMP in Roo Code Roadmap May 26, 2025
@hannesrudolph hannesrudolph moved this from TEMP to PR [Draft / In Progress] 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
documentation Improvements or additions to documentation enhancement New feature or request PR - Draft / In Progress size:XXL This PR changes 1000+ lines, ignoring generated files.
Projects
Status: PR [Draft / In Progress]
Development

Successfully merging this pull request may close these issues.

3 participants
0