Uh oh!
There was an error while loading. Please reload this page.
refactor: reduce complexity in discovery.sh, record.sh, and common.sh - #1123
Merged
Conversation
Break down overly complex functions into smaller, single-purpose helpers: discovery.sh: - Extract _sync_and_setup() from run_team_cycle() for git sync + setup - Extract _launch_claude() to handle process startup - Extract _session_completed() to check session status - Extract _cleanup_cycle_files() for file cleanup - Reduces run_team_cycle() from 71 lines to 39 lines record.sh: - Extract _validate_response_not_empty() for empty check - Extract _validate_response_json() for JSON validation - Extract _validate_response_no_error() for API error checking - Extract _record_fixture_metadata() for metadata recording - Reduces _save_live_fixture() from 34 lines to 15 lines shared/common.sh: - Extract _check_agent_in_path() for PATH verification - Extract _check_agent_runs() for execution verification - Reduces verify_agent_installed() from 32 lines to 11 lines Each helper is focused on one concern, improving maintainability and testability. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
louisgv
approved these changes
Feb 14, 2026
louisgv
left a comment
Collaborator
There was a problem hiding this comment.
Security Review
Verdict: APPROVED
Findings
No security issues found. This is a pure refactoring PR that extracts inline code blocks into named helper functions with no behavioral changes:
- discovery.sh:
run_team_cycle()decomposed into_sync_and_setup(),_launch_claude(),_session_completed(),_cleanup_cycle_files()— all logic preserved, dynamic scoping forPROMPT_FILEis the existing pattern - shared/common.sh:
verify_agent_installed()decomposed into_check_agent_in_path()and_check_agent_runs()— command execution properly quoted, unchanged from original - test/record.sh:
_save_live_fixture()decomposed into validation and metadata helpers — dynamic scoping for counters matches existing pattern
Tests
- bash -n: PASS (all 3 changed .sh files)
- test/run.sh: PASS (80 passed, 0 failed)
- curl|bash: OK (no source/eval patterns changed)
- macOS compat: OK (no bash 3.x incompatible constructs introduced)
-- security/pr-reviewer
Uh oh!
There was an error while loading. Please reload this page.
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 freeto 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
Refactored three complex functions to improve maintainability and readability:
discovery.sh: Extracted process lifecycle helpers from
run_team_cycle()(71→39 lines)_sync_and_setup()- git sync and prompt preparation_launch_claude()- claude process startup_session_completed()- check for session completion_cleanup_cycle_files()- cleanup temp filesrecord.sh: Extracted validation helpers from
_save_live_fixture()(34→15 lines)_validate_response_not_empty()- check non-empty response_validate_response_json()- validate JSON format_validate_response_no_error()- check for API errors_record_fixture_metadata()- record fixture metadatashared/common.sh: Extracted verification helpers from
verify_agent_installed()(32→11 lines)_check_agent_in_path()- verify command in PATH_check_agent_runs()- verify command executionTest plan
bash -n)-- refactor/complexity-hunter