Skip to content

feat(airc-bash): split — extract platform_adapters.sh as Phase 3 feasibility (#152) - #173

Merged
joelteply merged 1 commit into
canaryfrom
feat/airc-bash-file-split-platform-adapters
Apr 27, 2026
Merged

joelteply merged 1 commit into
canaryfrom
feat/airc-bash-file-split-platform-adapters

Conversation

@joelteply

Copy link
Copy Markdown
Contributor

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

  • airc bash: 5529 → 5371 lines
  • New: `lib/airc_bash/platform_adapters.sh` (~158 lines, self-contained)
  • Cumulative bash reduction this session (Phase 1 + Phase 3 step 1): ~530 lines

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

  • cmd_connect (biggest cmd_*, ~1000-1500 lines)
  • cmd_send / cmd_doctor / cmd_part / cmd_teardown
  • helpers.sh (die, validate_peer_name, get_*)

Goal: no single file >600 lines after Phase 3 completes.

Test posture

scenario result
platform_adapters 11/11 (sourced from real file)
tabs 19/19
identity 19/19
whois 5/5
part_persists 8/8
list 4/4
general_sidecar_default 12/12

…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)
Copilot AI review requested due to automatic review settings April 27, 2026 22:52
@joelteply
joelteply merged commit 088adbc into canary Apr 27, 2026
2 checks passed
@joelteply
joelteply deleted the feat/airc-bash-file-split-platform-adapters branch April 27, 2026 22:52

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 airc to source the extracted adapters via the existing lib-dir resolver and hard-fail if missing.
  • Updated scenario_platform_adapters integration test to source the real adapters file instead of awk-extracting from airc.

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 thread test/integration.sh
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 thread airc
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants