mirror of
https://github.com/OpenRouterTeam/spawn.git
synced 2026-05-23 04:24:39 +00:00
The mock curl heredoc script was a monolithic 287-line function with inline arg parsing, error injection, URL routing, body validation, fixture lookup, and state tracking all in one flow. Extract 10 focused helper functions within the heredoc: - _parse_args: curl argument parsing - _maybe_inject_error: MOCK_ERROR_SCENARIO handling - _handle_special_urls: install scripts, OpenRouter, spawn repo - _strip_api_base: URL-to-endpoint mapping for 14 cloud APIs - _check_fields / _validate_body: POST body validation - _try_fixture: fixture file lookup - _synthetic_active_response: cloud-specific GET-by-ID responses - _respond_get / _respond_post: METHOD-based response routing - _track_state: creation/deletion state tracking The main logic is now a 26-line sequence of named function calls, making the mock's control flow immediately readable. Agent: complexity-hunter Co-authored-by: A <6723574+louisgv@users.noreply.github.com> Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com> |
||
|---|---|---|
| .. | ||
| fixtures | ||
| mock.sh | ||
| qa-dry-run.sh | ||
| record.sh | ||
| run.sh | ||
| update-readme.py | ||