Skip to content

Clean up logic for tool definitions #7822

@worksofliam

Description

@worksofliam

What specific problem does this solve?

The logic which makes up a tool (instructions, parameters, implementation, group) is spread across multiple files. Let's use write_file as an example:

  • Implementation defined src/core/tools/writeToFileTool.ts
  • Prompt defined in src/core/prompts/tools/write-to-file.ts
  • Groups defined in src/shared/tools.ts

This doesn't seem right. Would it not be better if everything that made up a tool belong in a single class or interface?

Additional context (optional)

At the same time, I think it might be worth uncoupling some of the hardcoded values for the sake of typing, like ToolName and toolParamNames.

Roo Code Task Links (Optional)

No response

Request checklist

  • I've searched existing Issues and Discussions for duplicates
  • This describes a specific problem with clear impact and context

Interested in implementing this?

  • Yes, I'd like to help implement this feature

Implementation requirements

  • I understand this needs approval before implementation begins

How should this be solved? (REQUIRED if contributing, optional otherwise)

  • Implement a new base class for a RooTool with abstractions for getting the prompts, groups, parameters, and invocating
  • Re-work all existing tools into a class (extending RooTool)
  • Remove any likeness of tool maps for individual values (like toolDescriptionMap) or switch statements (src/core/assistant-message/presentAssistantMessage.ts)
  • Frontend logic would not be touch as part of this pull-request.

How will we know it works? (Acceptance Criteria - REQUIRED if contributing, optional otherwise)

  • Existing test cases need to continue passing, or updated based on signature changes.
  • UX should not change at all.

Technical considerations (REQUIRED if contributing, optional otherwise)

The goal is this should simplify the maintenance of tools instead of having all this logic spread out across many files.

Trade-offs and risks (REQUIRED if contributing, optional otherwise)

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Issue - Needs ApprovalReady to move forward, but waiting on maintainer or team sign-off.enhancementNew feature or requestproposal

    Type

    No type

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions