refactor(scripts): extract shared bash helpers into lib/#157
Merged
Conversation
Move duplicated helpers out of fleet-tick.sh, cap-swap-daemon.sh, and
cap-probe.sh into two sourced libraries:
- scripts/codex-fleet/lib/agents.sh: derive_aid (and email_to_id alias),
the canonical email -> agent-id derivation. Replaces the inline bash
copy in fleet-tick.sh and the two python3 copies in cap-swap-daemon.sh
and cap-probe.sh. Functionally identical (verified against
alice@gmail.com, bob@magnoliavilag.hu, carol@gitguardex.com,
dave@pipacsclub.org, eve+x@example.co.uk). Documents the cross-language
sync requirement with rust/fleet-data/src/fleet.rs::derive_agent_id.
- scripts/codex-fleet/lib/ui-helpers.sh: strip_ansi, ios_visible_len,
pct_color, ios_status_chip_label. Pulled out of fleet-tick.sh.
Both libs use a __CODEX_FLEET_LIB_*_SH guard so double-sourcing is a
no-op and are set -u safe. Functions only, no top-level side effects.
Scripts source them via "$(dirname "${BASH_SOURCE[0]}")/lib/..." so
invocation from any cwd resolves correctly.
Co-Authored-By: Claude Opus 4.7 (1M context) <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
scripts/codex-fleet/lib/agents.sh—derive_aid/email_to_id. Header documents the cross-language sync requirement withrust/fleet-data/src/fleet.rs::derive_agent_id(lines 105-118).scripts/codex-fleet/lib/ui-helpers.sh—strip_ansi,ios_visible_len,pct_color,ios_status_chip_label.__CODEX_FLEET_LIB_*_SH=1double-source guard and define functions only (no side effects).fleet-tick.sh,cap-swap-daemon.sh,cap-probe.sh— removed inline duplicates.Behavior
cap-swap-daemon.sh/cap-probe.shspawned a python3 process per email→id call; the unified bash implementation removes that subprocess.Notes
full-bringup.sh,plan-tree-anim.sh, andclaude-supervisor.shas duplicators — they don't contain these helpers (andclaude-supervisor.shdoesn't exist). The actual duplicators werefleet-tick.sh,cap-swap-daemon.sh,cap-probe.sh.waves-anim.sh/watcher-board.sh/review-anim.shredefinestrip_ansi+ theIOS_*palette; not touched here. Worth a follow-up dedup pass.Test plan
bash -nclean on all 5 touched filesset -uFLEET_TICK_SOURCE_ONLY=1source-and-call: all helpers produce identical output to pre-refactorscripts/codex-fleet/test/test-status-chips.shfails on this branch — also fails onmain(pre-existing regression unrelated to this PR)🤖 Generated with Claude Code