Skip to content

Pipeline Plan 1

ezigus edited this page Feb 21, 2026 · 1 revision

Based on my analysis of the codebase, the implementation is already partially complete on this branch (8 autonomous loop iterations have run). Here is the complete implementation plan:


Implementation Plan: Shell Completion Installation in shipwright init

Files to Modify

File Action
scripts/sw-init.sh Add shell completion installation section (after pipeline templates, before Claude settings)
scripts/sw-init-test.sh Add tests 22-26 covering zsh, bash, fish, fpath config, and idempotency

Implementation Steps

  1. Add Shell Completions section to scripts/sw-init.sh (after the Pipeline Templates section, around line 387):

    • Detect $SHELL environment variable for login shell type (zsh, bash, fish)
    • Set COMPLETIONS_SRC="$REPO_DIR/completions"
    • Use SHELL_TYPE variable to branch on shell type (avoid relying on $BASH_VERSION since init runs in bash regardless)
  2. Implement zsh completion installation:

    • Target: ~/.zsh/completions/_shipwright
    • Source: completions/_shipwright
    • mkdir -p ~/.zsh/completions then cp the file
    • Check ~/.zshrc for existing fpath+=~/.zsh/completions — append if absent
    • Check ~/.zshrc for compinit — append autoload -Uz compinit && compinit if absent
    • Print success "Installed zsh completions → ~/.zsh/completions/_shipwright"
  3. Implement bash completion installation:

    • Target: ~/.local/share/bash-completion/completions/shipwright
    • Source: completions/shipwright.bash
    • mkdir -p the target dir then cp
    • Check ~/.bashrc for existing source line — append if absent
    • Print success "Installed bash completions → ~/.local/share/bash-completion/completions/shipwright"
  4. Implement fish completion installation:

    • Target: ~/.config/fish/completions/shipwright.fish
    • Source: completions/shipwright.fish
    • mkdir -p ~/.config/fish/completions then cp
    • Print success "Installed fish completions → ~/.config/fish/completions/shipwright.fish"
  5. Print reload hint after successful install:

    • zsh: source ~/.zshrc
    • bash: source ~/.bashrc
    • fish: source ~/.config/fish/config.fish
  6. Add tests 22-26 to scripts/sw-init-test.sh under a "Shell Completions" group:

    • test_zsh_completions_installed — run init with SHELL=/bin/zsh, assert ~/.zsh/completions/_shipwright exists
    • test_zsh_fpath_configured — run init with SHELL=/bin/zsh, assert ~/.zshrc contains fpath
    • test_bash_completions_installed — run init with SHELL=/bin/bash, assert ~/.local/share/bash-completion/completions/shipwright exists
    • test_fish_completions_installed — run init with SHELL=/usr/local/bin/fish, assert ~/.config/fish/completions/shipwright.fish exists
    • test_completions_idempotent — run init twice with SHELL=/bin/zsh, assert no errors and file still present

Task Checklist

  • Task 1: Verify completions/ directory exists with _shipwright, shipwright.bash, shipwright.fish
  • Task 2: Add Shell Completions section header comment to sw-init.sh
  • Task 3: Implement shell type detection from $SHELL (not $BASH_VERSION)
  • Task 4: Implement zsh completion copy to ~/.zsh/completions/_shipwright
  • Task 5: Implement fpath injection into ~/.zshrc (idempotent, checks before appending)
  • Task 6: Implement compinit line injection into ~/.zshrc (idempotent)
  • Task 7: Implement bash completion copy to ~/.local/share/bash-completion/completions/shipwright
  • Task 8: Implement bash source line injection into ~/.bashrc (idempotent)
  • Task 9: Implement fish completion copy to ~/.config/fish/completions/shipwright.fish
  • Task 10: Print reload hint after successful installation
  • Task 11: Add test_zsh_completions_installed test with SHELL=/bin/zsh
  • Task 12: Add test_zsh_fpath_configured test asserting .zshrc fpath entry
  • Task 13: Add test_bash_completions_installed test with SHELL=/bin/bash
  • Task 14: Add test_fish_completions_installed test with SHELL=/usr/local/bin/fish
  • Task 15: Add test_completions_idempotent test running init twice and verifying no corruption

Testing Approach

Tests use the existing sandboxed HOME test harness in sw-init-test.sh:

# Tests 22-26 in the Shell Completions group override $SHELL per test:
SHELL="/bin/zsh" bash "$REAL_INIT_SCRIPT" --no-claude-md

# Then assert against the sandboxed HOME:
assert_file_exists "$TEMP_DIR/home/.zsh/completions/_shipwright"
assert_file_contains "$TEMP_DIR/home/.zshrc" "fpath"

Idempotency is verified by running init twice in the same $TEMP_DIR/home and asserting the completion file still exists and .zshrc does not contain duplicate fpath lines.

Run the full test suite to confirm no regressions:

bash scripts/sw-init-test.sh
npm test   # runs all 102 test suites

Definition of Done

  • bash scripts/sw-init.sh with SHELL=/bin/zsh creates ~/.zsh/completions/_shipwright and adds fpath to ~/.zshrc
  • bash scripts/sw-init.sh with SHELL=/bin/bash creates ~/.local/share/bash-completion/completions/shipwright
  • bash scripts/sw-init.sh with SHELL=/usr/local/bin/fish creates ~/.config/fish/completions/shipwright.fish
  • Running init twice does not duplicate entries in .zshrc/.bashrc
  • All 26 tests in sw-init-test.sh pass
  • npm test passes (all 102 suites)
  • Shell type detection falls back gracefully when $SHELL is unset or unknown (shows warn and skips)

Status note: The implementation code is already present on this branch (feat/add-shell-completion-installation-to-shi-1) from prior autonomous loop iterations 1–8. The sw-init.sh shell completions section (lines 387–489) and test cases 22–26 in sw-init-test.sh are written and ready for the build/test stages.

Clone this wiki locally