Skip to content

Conversation

@ammar-agent
Copy link
Collaborator

@ammar-agent ammar-agent commented Oct 12, 2025

Splits file edit replace into two separate tools instead of using a discriminated union, as AI providers don't support complex union schemas.

Changes

  • Two separate tools with simple object schemas:
    • file_edit_replace_string: String-based text replacement
    • file_edit_replace_lines: Line range replacement
  • Shared implementation in file_edit_replace_shared.ts for code reuse
  • Updated tool definitions, registries, UI components, and types
  • All tests updated to cover both tools independently

Benefits

  • AI provider compatible: Simple object schemas that all providers accept
  • Code reuse: Shared helper functions reduce duplication
  • Clear separation: Tools are distinct in the registry and UI
  • Type safety: Separate payload/result types for each tool
  • Easier to maintain: Tool-specific logic isolated

Test Results

✅ TypeScript passing
✅ Unit tests passing (379 tests)
✅ Tool policy tests passing (20 tests)
✅ Lint + Format passing

Generated with cmux

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

https://github.com/coder/cmux/blob/9bdbc520d9807927f1f8b180690fbf92ce729406/src/utils/messages/toolOutputRedaction.ts#L13-L16
P0 Badge Update toolOutputRedaction to new replace tool types

toolOutputRedaction.ts still imports FileEditReplaceToolResult and switches on file_edit_replace (lines 13‑14, 96). The type no longer exists after the rename and the new tools are file_edit_replace_string/file_edit_replace_lines, so this file will not compile and none of the replace-tool outputs will be redacted.

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

@ammar-agent ammar-agent force-pushed the feature/file-edit-replace-lines branch 4 times, most recently from ef564c6 to c0ef42f Compare October 12, 2025 17:01
@ammar-agent
Copy link
Collaborator Author

Applied Codex suggestions: cleaned up file_edit_replace_lines definition and ensured create:true works before invoking shared helper. Re-ran tests locally.

@ammar-agent ammar-agent force-pushed the feature/file-edit-replace-lines branch 5 times, most recently from f1c9fda to 966e72c Compare October 12, 2025 18:00
@ammar-agent ammar-agent force-pushed the feature/file-edit-replace-lines branch from ba9f0b8 to 0f1eb57 Compare October 12, 2025 18:34
Consolidates file_edit_replace_string and file_edit_replace_lines into a
single file_edit_replace tool using discriminated unions.

Changes:
- New unified tool with mode: 'string' | 'lines' discriminant
- Updated type system with FileEditReplaceToolArgs union type
- Simplified frontend with single tool rendering path
- Updated all tool definitions, registries, and utilities
- Removed legacy tool implementations and tests

Benefits:
- Simpler API (1 tool instead of 2)
- Easier to extend with new modes
- Reduced code duplication (~327 line net reduction)

All tests passing (TypeScript, unit tests, tool policy tests).

_Generated with `cmux`_
Prevents checking PR status when:
- Working directory has uncommitted changes
- Local branch doesn't have upstream configured
- Local branch is out of sync with remote (ahead/behind/diverged)

Provides clear error messages with suggested remediation steps.

_Generated with `cmux`_
@ammar-agent ammar-agent force-pushed the feature/file-edit-replace-lines branch from 27c5f47 to feca0e7 Compare October 12, 2025 19:05
Instead of using a discriminated union (which AI providers don't support),
create two separate tools that share implementation:

- file_edit_replace_string: String-based text replacement
- file_edit_replace_lines: Line range replacement
- file_edit_replace_shared.ts: Shared helper functions

Benefits:
- Simple object schemas that AI providers accept
- Code reuse through shared helpers
- Clearer tool separation in registry
- Type safety maintained throughout

Updated:
- Tool definitions with two separate simple schemas
- Tool registry to register both tools
- UI components to handle both tool names
- Types to separate payload/result types
- Tests to cover both tools independently
@ammar-agent ammar-agent changed the title 🤖 Add line-range replace tool and unify file edit pipeline 🤖 Split file_edit_replace into two separate tools Oct 12, 2025
Update test to look for either file_edit_replace_string or
file_edit_replace_lines instead of the old unified tool name.
@ammario ammario merged commit 21cfaf4 into main Oct 12, 2025
9 checks passed
@ammario ammario deleted the feature/file-edit-replace-lines branch October 12, 2025 19:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants