Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Feb 8, 2026

Addresses PR review feedback from thread #3769662762. Package parsing was duplicated in two locations, and environment lists were hardcoded in three places (help text, interactive menu, "all" loop), creating drift risk when adding new environments.

Extracted package parsing helper

  • parse_packages() function now used in both setup_apt_environment() and batch install path
  • Single source of truth for comment/whitespace handling

Dynamic environment discovery

  • get_available_environments() scans apt/ directory at runtime
  • Interactive menu, help text, and "all" loop now derive from same source
  • Adding new environment directory automatically makes it available

Input validation

  • Numeric validation for user choice
  • Empty environment name filtering
  • Safe undefined variable handling (${all_option:-})
  • Graceful empty directory list handling

Example flow

# Before: hardcoded array, duplicated parsing
envs=("common" "test" "docker" ...)
pkgs=$(sed 's/#.*//' "apt/$env/packages.txt" | xargs)

# After: discovered dynamically, centralized parsing
envs=($(get_available_environments))
pkgs=$(parse_packages "apt/$env/packages.txt")

Preserves all batch installation optimizations. Zero functional changes to package installation behavior.


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI and others added 4 commits February 8, 2026 11:56
…mically

- Added parse_packages() function to eliminate code duplication
- Added get_available_environments() to dynamically derive environment list from apt/ directory
- Updated interactive menu to use dynamically generated environment list
- Updated help text to reflect dynamic environment detection
- Addresses PR review feedback from thread #3769662762

Co-authored-by: swarm-protocol <169869917+swarm-protocol@users.noreply.github.com>
- Add validation for empty environment names in get_available_environments()
- Add numeric validation for user choice input
- Fix all_option check to handle undefined variable safely
- Addresses code review feedback

Co-authored-by: swarm-protocol <169869917+swarm-protocol@users.noreply.github.com>
- Quote function parameter to prevent word splitting
- Handle empty environment list gracefully
- Add numeric validation for all_option before comparison
- Fix Cloudflare capitalization (one word, lowercase 'f')
- Addresses final code review feedback

Co-authored-by: swarm-protocol <169869917+swarm-protocol@users.noreply.github.com>
- Extract all_option validation into separate boolean for readability
- Fix error message to only mention apt/ directory (matching function behavior)
- Addresses final code review feedback

Co-authored-by: swarm-protocol <169869917+swarm-protocol@users.noreply.github.com>
Copilot AI changed the title [WIP] Optimize APT package installations in bootstrap.sh Refactor bootstrap.sh: eliminate duplication, derive environments dynamically Feb 8, 2026
Copilot AI requested a review from swarm-protocol February 8, 2026 12:00
Base automatically changed from bolt-batch-apt-install-6206753697854150493 to main February 8, 2026 12:02
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