Skip to content

Pipeline Plan 1

Seth Ford edited this page Feb 14, 2026 · 3 revisions

Here's the implementation plan:

Plan: Add Shell Completion Installation to shipwright init

Analysis

The init script (scripts/sw-init.sh) already has zsh and bash completion installation (lines 199-284). The completions directory has all three shell files: _shipwright (zsh), shipwright.bash (bash), and shipwright.fish (fish).

What's Missing

  1. Fish shell support — The init script handles zsh and bash but ignores fish entirely
  2. Idempotency — The current code always overwrites completion files instead of checking if they're already identical (the issue asks for "already installed" skip messages)
  3. Test coverage — Zero tests for the completions section in sw-init-test.sh

What's Already Working

  • Shell detection via $SHELL and $ZSH_VERSION/$BASH_VERSION
  • Zsh: copies to ~/.zsh/completions/, ensures fpath in .zshrc
  • Bash: copies to ~/.local/share/bash-completion/completions/, sources in .bashrc
  • Success messages with reload instructions

Files to Modify

File Action Purpose
scripts/sw-init.sh Modify Add fish support, add idempotency checks
scripts/sw-init-test.sh Modify Add test cases for shell completion installation

Implementation Steps

Step 1: Add fish shell detection

In the shell detection block (lines 201-213), add fish detection to both the version-variable check and the $SHELL fallback.

Step 2: Add idempotency checks to zsh completions

Before copying _shipwright, check if the destination file is identical using cmp -s. If identical, show "already installed" and skip.

Step 3: Add idempotency checks to bash completions

Same cmp -s pattern as zsh.

Step 4: Add fish completion installation block

After the bash block (line 275), add a new elif for fish:

  • Target: ~/.config/fish/completions/shipwright.fish
  • Include idempotency check
  • No rc file modification needed — fish auto-loads from that directory

Step 5: Update reload instructions for fish

Add a fish case (no source needed — fish picks up completions automatically).

Step 6-8: Add tests

  • Test bash completions installed to correct path
  • Test completions idempotency (second run shows "already installed")
  • Test fish completions installed when $SHELL is overridden to fish

Step 9-10: Run test suites

Run sw-init-test.sh and npm test to verify no regressions.


Task Checklist

  • Task 1: Add fish shell detection ($SHELL == *fish*) to the shell type detection block
  • Task 2: Add idempotency check (cmp -s) to zsh completion installation — skip with "already installed" if files match
  • Task 3: Add idempotency check (cmp -s) to bash completion installation — skip with "already installed" if files match
  • Task 4: Add fish completion installation block — copy shipwright.fish to ~/.config/fish/completions/
  • Task 5: Update reload instructions section to handle fish
  • Task 6: Add test: bash completions file installed to correct path
  • Task 7: Add test: completions idempotency — second run shows "already installed"
  • Task 8: Add test: fish completions installed when SHELL is fish
  • Task 9: Run sw-init-test.sh — all tests pass
  • Task 10: Run npm test — all existing test suites pass

Testing Approach

  1. Unit tests in sw-init-test.sh using the existing sandboxed HOME pattern (tests already run with HOME="$TEMP_DIR/home")
  2. Shell override: For fish test, override SHELL=/usr/local/bin/fish in the invoke_init call
  3. Idempotency test: Run init twice, grep second run's output for "already installed"

Definition of Done

  • Fish completions installed automatically during init (in addition to existing zsh/bash)
  • Idempotent — running init twice skips with "already installed" message
  • Shows clear success/skip messages for all three shells
  • Test coverage for completions in sw-init-test.sh
  • All existing tests still pass (npm test)
  • Bash 3.2 compatible (no associative arrays, no readarray, etc.)

Clone this wiki locally