Repository navigation
feat(airc-bash): split — extract platform_adapters.sh as Phase 3 feasibility (#152) - #173
Merged
Merged
Conversation
…ibility (#152) Joel 2026-04-27: "think my bigger issue is 5000 line files... like straightforward programming... senior would have hit pause at 500." Lesson saved (memory: flag file size proactively, threshold ~500 not ~5000). Starting Phase 3 — split airc bash into multiple files so each is normal-software-shaped, not a giant monolith. ## What `lib/airc_bash/platform_adapters.sh` (~158 lines, the existing "Platform adapters" marked block from airc) is now its own file. The airc top-level sources it via the lib-dir resolver: if [ -n "${_airc_lib_dir:-}" ] && [ -f "$_airc_lib_dir/airc_bash/platform_adapters.sh" ]; then source "$_airc_lib_dir/airc_bash/platform_adapters.sh" fi Test harness updated — `scenario_platform_adapters` no longer needs to awk-extract the section; it sources the real file directly. ## Why platform_adapters first - Already a self-contained marked region. - Already has integration test coverage. - Smallest blast radius if the source-from-file pattern flubs. - Same shape Phase 0a (iso_to_epoch) used to prove airc_core. ## Impact - airc bash: 5529 → 5371 lines (-158 lines, ~3% of file) - Cumulative bash-side reduction today (Phase 1 + Phase 3 step 1): ~530 lines moved to dedicated files. ## Next Same pattern scales: - lib/airc_bash/cmd_connect.sh (the biggest cmd_*, ~1000-1500 lines) - lib/airc_bash/cmd_send.sh - lib/airc_bash/cmd_doctor.sh - lib/airc_bash/cmd_part.sh + cmd_teardown.sh - lib/airc_bash/helpers.sh (die, validate_peer_name, get_*) After Phase 3, no single file should exceed ~600 lines. ## Test posture - platform_adapters: 11/11 (sourced from real file, all assertions via the same `_adapter_call` shim now pointing at lib/airc_bash/) - tabs / identity / whois / part_persists / list / general_sidecar_default: all green (the airc-startup sourcing path works for the real run)
There was a problem hiding this comment.
Pull request overview
This PR is a Phase 3 feasibility step for issue #152’s “split the giant bash script” effort: it extracts the existing “Platform adapters” block out of the monolithic airc bash script into a dedicated library file, and updates integration tests accordingly.
Changes:
- Extracted the platform adapter helper functions into
lib/airc_bash/platform_adapters.sh. - Updated
aircto source the extracted adapters via the existing lib-dir resolver and hard-fail if missing. - Updated
scenario_platform_adaptersintegration test to source the real adapters file instead of awk-extracting fromairc.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
airc |
Replaces the inlined platform adapter block with sourcing lib/airc_bash/platform_adapters.sh and a startup error if missing. |
lib/airc_bash/platform_adapters.sh |
New extracted bash library containing proc_*, port_*, file_*, detect_platform, and iso_to_epoch. |
test/integration.sh |
Stops awk-extracting adapters from airc; directly sources the new adapters file in the scenario test. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
2759
to
2762
| # Sourcing $AIRC directly would trigger the bottom-of-file case | ||
| # statement and either die ("Unknown command") or print cmd_help. | ||
| # Extract just the marked adapter section into a temp file we can | ||
| # safely source. |
Comment on lines
+857
to
+864
| if [ -n "${_airc_lib_dir:-}" ] && [ -f "$_airc_lib_dir/airc_bash/platform_adapters.sh" ]; then | ||
| # shellcheck source=lib/airc_bash/platform_adapters.sh | ||
| source "$_airc_lib_dir/airc_bash/platform_adapters.sh" | ||
| else | ||
| echo "ERROR: airc_bash/platform_adapters.sh not found via lib-dir resolver." >&2 | ||
| echo " Resolved lib_dir: ${_airc_lib_dir:-<empty>}" >&2 | ||
| echo " Re-run install.sh or check AIRC_DIR." >&2 | ||
| exit 1 |
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.
Joel 2026-04-27: "think my bigger issue is 5000 line files... senior would have hit pause at 500."
Phase 3 of #152 architecture pivot: split airc bash into multiple files. Step 1 — extract the existing "Platform adapters" marked block to its own file as a feasibility proof.
Impact
Pattern for the rest
```bash
if [ -n "${_airc_lib_dir:-}" ] && [ -f "$_airc_lib_dir/airc_bash/.sh" ]; then
source "$_airc_lib_dir/airc_bash/.sh"
fi
```
Same lib-dir resolver as airc_core. Tests source the file directly instead of awk-extracting.
Next slices
Goal: no single file >600 lines after Phase 3 completes.
Test posture