Skip to content

Conversation

@KJ7LNW
Copy link
Contributor

@KJ7LNW KJ7LNW commented Jun 5, 2025

Context

Fixes #2931.

This PR implements the core functionality to allow escaping of context mentions with backslashes, enabling users to pass CLI-style arguments like @/foo literally without triggering file content expansion.

This PR is a focused implementation of the core functionality requested in issue #2931, separated from the UI changes that were proposed in PR #3088. The UI changes will be implemented in a separate PR+issue combination as requested by @hannesrudolph.

Implementation

  1. Mention Parsing (src/shared/context-mentions.ts)

    • The mention parser now includes a negative lookbehind (?<!\\) in the regex to ignore escaped @ symbols.
    • Tests updated to confirm that \@foo is ignored and \\@foo is interpreted as @foo.
  2. Subtask Unescaping (src/core/tools/newTaskTool.ts)

    • In newTaskTool, \\@ is converted to \@ before initializing the subtask.
    • This ensures each subtask layer peels off one escape level, preserving intended mentions.
  3. Tests

    • Added tests to verify correct behavior with one or more levels of escaping (\@, \\@, \\\\@).
    • Confirms proper transformation and message integrity across nested tasks.

Get in Touch

Discord: KJ7LNW


Important

Adds functionality to escape context mentions using backslashes, updating regex and task handling logic, with corresponding tests.

  • Behavior:
    • Allows escaping of context mentions using backslashes in context-mentions.ts.
    • Updates mentionRegex to include negative lookbehind (?<!\\) to ignore escaped @ symbols.
    • In newTaskTool.ts, converts \\@ to \@ before initializing subtasks.
  • Tests:
    • Added tests in newTaskTool.test.ts to verify unescaping behavior for \\@, \@, and @.
    • Updated context-mentions.test.ts to confirm regex changes handle escaped mentions correctly.
  • Misc:

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

@KJ7LNW KJ7LNW requested review from cte and mrubens as code owners June 5, 2025 04:34
@dosubot dosubot bot added size:L This PR changes 100-499 lines, ignoring generated files. enhancement New feature or request labels Jun 5, 2025
@KJ7LNW KJ7LNW moved this from Triage to PR [Needs Prelim Review] in Roo Code Roadmap Jun 5, 2025
Copy link
Member

@daniel-lxs daniel-lxs left a comment

Choose a reason for hiding this comment

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

Thank you @KJ7LNW, This looks good.

As I mentioned in the previous PR, this new functionality needs a good documentation, some examples of the behavior regarding subtasks since it is quite confusing even for the agents reading the code.

cc: @hannesrudolph

@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Jun 7, 2025
@daniel-lxs daniel-lxs requested a review from jr as a code owner June 7, 2025 17:46
@daniel-lxs daniel-lxs moved this from PR [Needs Prelim Review] to PR [Needs Review] in Roo Code Roadmap Jun 7, 2025
@daniel-lxs daniel-lxs added PR - Needs Review documentation Improvements or additions to documentation and removed PR - Needs Preliminary Review labels Jun 7, 2025
@mrubens mrubens merged commit 53e7e6b into RooCodeInc:main Jun 12, 2025
13 checks passed
@github-project-automation github-project-automation bot moved this from PR [Needs Review] to Done in Roo Code Roadmap Jun 12, 2025
@github-project-automation github-project-automation bot moved this from New to Done in Roo Code Roadmap Jun 12, 2025
cte pushed a commit that referenced this pull request Jun 24, 2025
* allow escaping of context mentions

* refactor: update comment

---------

Co-authored-by: cannuri <[email protected]>
Co-authored-by: Daniel <[email protected]>
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 lgtm This PR has been approved by a maintainer PR - Needs Review 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.

Need escape mechanism for '@' symbol to prevent unwanted file content expansion

5 participants