feat(gadgets): add multi-mode EditFile and line numbers to ReadFile#75
Merged
zbigniewsobiecki merged 1 commit intodevfrom Jan 18, 2026
Merged
feat(gadgets): add multi-mode EditFile and line numbers to ReadFile#75zbigniewsobiecki merged 1 commit intodevfrom
zbigniewsobiecki merged 1 commit intodevfrom
Conversation
EditFile now supports 3 modes via discriminated union: - search_replace: existing behavior with layered matching - insert_at_line: insert content at specific line (1-based) - remove_lines: remove range of lines (1-based, inclusive) ReadFile now supports optional showLineNumbers parameter that prefixes each line with its 1-based line number for precise editing. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
EditFile multi-mode: Refactored to support 3 operation modes via discriminated union:
search_replace: Existing behavior with layered matching (exact → whitespace → indentation → fuzzy)insert_at_line: Insert content at a specific line number (1-based, inserts BEFORE the specified line)remove_lines: Remove a range of lines (1-based, inclusive)ReadFile line numbers: Added optional
showLineNumbersparameter that prefixes each line with its 1-based line number (e.g.,1 | content) for precise line-based editingChanges
EditFile (
src/gadgets/EditFile.ts)z.discriminatedUnion('mode', [...])execute()to dispatch to mode-specific handlersinsert_at_line, 3 forremove_lines)mode: 'search_replace'ReadFile (
src/gadgets/ReadFile.ts)showLineNumbersoptional boolean parameter (default:false)addLineNumbers()helper methodEdge Cases Handled
Test plan
🤖 Generated with Claude Code