You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
refactor: decompose bash tool into helper functions
Extracted three helper functions to improve clarity and reduce duplication:
1. **validateScript()** - Centralizes all input validation (empty script, sleep
commands, redundant cd). Returns error result or null.
2. **createLineHandler()** - Unified line processing logic for both stdout and
stderr. Eliminates 84 lines of duplicate code. Enforces truncation limits
consistently.
3. **formatResult()** - Handles all result formatting based on exit code and
truncation state. Simplifies the main execution flow.
## Benefits
- **-80 LoC of duplication removed** (stdout/stderr handlers)
- **Clearer separation of concerns** - validation, processing, formatting
- **Easier to test** - helpers are pure functions
- **More maintainable** - single source of truth for line processing logic
## Testing
- All 955 unit tests pass
- Static checks pass (lint + typecheck + format)
- No behavior changes, pure refactor
---
_Generated with `cmux`_
0 commit comments