Skip to content

refactor: split tools.rs into focused submodules - #4

Merged
devfire merged 2 commits into
mainfrom
tools-split
Jun 19, 2026
Merged

refactor: split tools.rs into focused submodules#4
devfire merged 2 commits into
mainfrom
tools-split

Conversation

@devfire

@devfire devfire commented Jun 19, 2026

Copy link
Copy Markdown
Owner

Break the 1348-line tools.rs monolith into a tools/ directory with focused files:

  • response.rs: ToolResponse struct
  • options.rs: GrepOptions, FindOptions, OutputMode
  • sinks.rs: grep-searcher Sink impls for each output mode
  • common.rs: shared walker construction, filtering, error capture, drain_capped()
  • grep.rs: grep() and the three mode functions (content/files/count)
  • find.rs: find()
  • cat.rs: cat()
  • mod.rs: public re-exports and test helpers

Key improvements:

  • Public API unchanged: mod.rs re-exports grep/find/cat and their option/response types, so server.rs requires zero changes
  • Deduped: the identical ~20-line UTF-8 byte-cap drain loops are now common::drain_capped()
  • Tests colocated: grep tests in grep.rs, find tests in find.rs, etc.
  • No clippy warnings in tools/ (and fixed 4 pre-existing warnings in scope.rs)

Verification: cargo build clean, all 42 tests pass, clippy --all-targets 0 warnings.

Break the 1348-line tools.rs monolith into a tools/ directory with focused files:
- response.rs: ToolResponse struct
- options.rs: GrepOptions, FindOptions, OutputMode
- sinks.rs: grep-searcher Sink impls for each output mode
- common.rs: shared walker construction, filtering, error capture, drain_capped()
- grep.rs: grep() and the three mode functions (content/files/count)
- find.rs: find()
- cat.rs: cat()
- mod.rs: public re-exports and test helpers

Key improvements:
- Public API unchanged: mod.rs re-exports grep/find/cat and their option/response
  types, so server.rs requires zero changes
- Deduped: the identical ~20-line UTF-8 byte-cap drain loops are now common::drain_capped()
- Tests colocated: grep tests in grep.rs, find tests in find.rs, etc.
- No clippy warnings in tools/ (and fixed 4 pre-existing warnings in scope.rs)

Verification: cargo build clean, all 42 tests pass, clippy --all-targets 0 warnings.

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
@devfire devfire self-assigned this Jun 19, 2026
@devfire
devfire merged commit f4b400e into main Jun 19, 2026
2 checks passed
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.

1 participant