Skip to content

Conversation

@roomote
Copy link
Contributor

@roomote roomote bot commented Jul 24, 2025

This PR addresses the subtle but important difference pointed out by @CberYellowstone in issue #6159. The original proposal emphasized creating a truly isolated, dedicated process for diff generation in the apply_code tool.

Changes

  • Created isolated API handler for Stage 2: Instead of reusing the main Cline API instance, Stage 2 now creates its own isolated API handler using buildApiHandler(). This ensures complete separation from the main conversation context.

  • Hardcoded optimized system prompt: The diff generation stage now uses a hardcoded, specialized system prompt focused solely on generating accurate diffs, without any conversational elements.

  • Clean context without conversation history: Stage 2 receives only the essential information (original file content and new code) without any conversation history or additional context that could influence the diff generation.

  • Updated tests: All tests have been updated to reflect the new implementation and are passing.

Key Differences from Previous Implementation

The previous implementation reused the main Cline API instance with a modified system prompt. This new implementation creates a completely separate API handler, ensuring true isolation as originally proposed.

Testing

  • ✅ All unit tests passing
  • ✅ Linting passing
  • ✅ Type checking passing

Fixes #6159


Important

Introduces apply_code tool for improved code application using a two-stage process with isolated API context, updates settings, descriptions, and tests.

  • Behavior:
    • Introduces apply_code tool in applyCodeTool.ts for code changes using a two-stage process: code generation and diff generation.
    • Uses buildApiHandler() for isolated API context in diff generation.
    • Updates presentAssistantMessage.ts to handle apply_code tool execution.
  • Prompts and Descriptions:
    • Adds getApplyCodeDescription() in apply-code.ts for tool description.
    • Updates index.ts to include apply_code in tool descriptions.
  • Settings and Configuration:
    • Adds applyEnabled setting in provider-settings.ts to control tool availability.
    • Updates tool.ts to include apply_code in tool names.
  • Testing:
    • Adds applyCodeTool.spec.ts for unit tests covering parameter validation, API workflow, error handling, and user approval.
  • Misc:
    • Updates ExtensionMessage.ts and tools.ts to include apply_code in relevant interfaces and constants.

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

roomote added 2 commits July 24, 2025 09:57
- Add new apply_code tool that uses a two-stage approach:
  1. Creative code generation based on instructions
  2. Focused diff generation with clean context
- Add applyEnabled configuration option to enable/disable the feature
- Update tool descriptions and type definitions
- Add comprehensive tests for the new tool
- Integrate with existing diff application infrastructure

This addresses issue #6159 by providing a more reliable alternative
to apply_diff that separates creative code generation from technical
diff creation, reducing errors from noisy conversational contexts.
…ration

- Create truly isolated API handler for Stage 2 diff generation
- Use hardcoded, optimized system prompt for diff generation
- Ensure clean context without conversational history in Stage 2
- Update tests to reflect the new implementation

This addresses the subtle but important difference pointed out by @CberYellowstone
in issue #6159, where the original proposal emphasized creating a truly isolated,
dedicated process for diff generation.
@roomote roomote bot requested review from cte, jr and mrubens as code owners July 24, 2025 10:31
@dosubot dosubot bot added size:XL This PR changes 500-999 lines, ignoring generated files. enhancement New feature or request labels Jul 24, 2025
@hannesrudolph hannesrudolph added the Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels. label Jul 24, 2025
@daniel-lxs daniel-lxs moved this from Triage to PR [Needs Prelim Review] in Roo Code Roadmap Jul 25, 2025
@hannesrudolph hannesrudolph added PR - Needs Preliminary Review and removed Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels. labels Jul 25, 2025
@daniel-lxs
Copy link
Member

I don't think this implementation makes sense, I feel like if we ever implement this it should output the whole file with the updated content, this seems to have better results than applying a diff

@daniel-lxs daniel-lxs closed this Jul 28, 2025
@github-project-automation github-project-automation bot moved this from PR [Needs Prelim Review] to Done in Roo Code Roadmap Jul 28, 2025
@github-project-automation github-project-automation bot moved this from New to Done in Roo Code Roadmap Jul 28, 2025
@bhaktatejas922
Copy link

use morphs fast apply model for edits like kilo? https://morphllm.com

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request PR - Needs Preliminary Review size:XL This PR changes 500-999 lines, ignoring generated files.

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

Proposal: Implement a "Apply" Feature like Cursor's

5 participants