-
Notifications
You must be signed in to change notification settings - Fork 1
Pipeline Design 1
Now I have everything I need. Let me produce the ADR. I notice an important conflict between the original plan and the existing design document — the plan proposes inlining the completion logic, while the design document (Pipeline-Design-1.md) recommends delegating to install-completions.sh. There's also a critical .npmignore issue. Let me write the ADR.
Shipwright has shell completions for bash, zsh, and fish in completions/ and a standalone installer at scripts/install-completions.sh (64 lines). However, the primary onboarding command shipwright init does not install completions. Users must discover and run the standalone script separately.
Current state:
-
completions/_shipwright(zsh),completions/shipwright.bash,completions/shipwright.fish— full subcommand/flag coverage -
scripts/install-completions.sh— detects$SHELL, copies to per-user dirs, installs for all three aliases (shipwright,sw,cct), warns aboutfpath -
scripts/cct(CLI router, line 160-243) — nocompletionscase inmain() -
scripts/cct-init.sh(439 lines) — installs tmux, overlay, templates, settings, hooks, CLAUDE.md, deploy — no completions -
install.shline 690 referencesshipwright completions installbut the command doesn't exist -
.npmignoreline 8 excludesscripts/install-completions.shfrom npm packages, but thecompletions/directory itself is not excluded (it ships)
Constraints:
- Bash 3.2 compatibility — no
declare -A, noreadarray, no${var,,}/${var^^} -
set -euo pipefailin all scripts - Output via
info(),success(),warn(),error()helpers -
cct-init.shis designed as non-interactive ("one command, no prompts")
Delegate to install-completions.sh from cct-init.sh rather than inlining the shell-detection logic. Also wire up shipwright completions install as a standalone CLI subcommand.
Approach — three changes:
-
scripts/cct-init.sh— Insert a# ─── Shell Completionssection between the CLAUDE.md per-repo block (line 275) and the tmux reload (line 277). Guard with[[ -x "$SCRIPT_DIR/install-completions.sh" ]]. Call with|| trueso init never fails on completion errors. -
scripts/cct— Add acompletions)case inmain()thatexecs$SCRIPT_DIR/install-completions.sh "$@". Addcompletionstoshow_help(). -
install.sh— Addinstall-completions.shto the subcommand scripts copied to$BIN_DIR(line 384 list), and copy thecompletions/source directory to$HOME/.shipwright/completions/so the script works when invoked from~/.local/bin/.
Error handling:
-
cct-init.shcatches failures with|| true— completions are nice-to-have, not blocking - Standalone
shipwright completions installsurfaces errors directly - If
completions/source directory is missing (e.g., npm install where it wasn't packaged),install-completions.shfails on itscdat line 8 — caught by|| truein init, shown as error in standalone
Idempotency: install-completions.sh uses cp unconditionally (quick overwrite). The plan's cmp -s approach would add value for messaging ("already installed" vs "installed"), but adds complexity. Recommend keeping the simple cp — completions are tiny files and overwriting is harmless. The zsh fpath check already uses grep -q to avoid duplicate .zshrc entries.
Path resolution risk: When install-completions.sh is copied to ~/.local/bin/, its SCRIPT_DIR/../completions resolves to ~/.local/completions which doesn't exist. Fix by also copying completions/ to ~/.shipwright/completions/ in install.sh, and adding a fallback in install-completions.sh:
COMPLETIONS_DIR="$(cd "$SCRIPT_DIR/../completions" 2>/dev/null && pwd)" \
|| COMPLETIONS_DIR="$HOME/.shipwright/completions"-
Inline completion logic into cct-init.sh (the plan's approach) — Pros: self-contained, no external script dependency, can add
cmp -sidempotency naturally / Cons: duplicates 64 lines of shell-detection logic already ininstall-completions.sh, creates two copies to maintain, doesn't give users a standalonecompletionscommand. The plan proposes single-file-only changes but this leaves the existinginstall-completions.shorphaned and divergent. -
Only add
completionssubcommand, skip init integration — Pros: minimal change (router only) / Cons: new users still miss completions during onboarding, which defeats the purpose. -
Remove
install-completions.shand only inline — Pros: single source of truth / Cons: breaksinstall.sh's reference at line 690, breaksinstall-remote.shwhich calls it at line 125-127, breaks Homebrew formula expectations. Too many consumers.
- Files to create: None
-
Files to modify:
-
scripts/cct-init.sh— Add ~8-line Shell Completions section at line 276 (after CLAUDE.md per-repo, before tmux reload) -
scripts/cct— Addcompletions)case inmain()(~2 lines at line 227). Add entry inshow_help()(~1 line at line 87) -
install.sh— Addinstall-completions.shto the script install loop (line 384). Addcompletions/directory copy to~/.shipwright/completions/(~4 lines after line 451) -
scripts/install-completions.sh— Add fallback path resolution forCOMPLETIONS_DIR(line 8, ~2 line change) so it works from~/.local/bin/
-
- Dependencies: None new
-
Risk areas:
-
.npmignoreexcludesinstall-completions.sh(line 8) — npm users won't have the standalone installer. Thecompletions/directory is shipped, so init could fallback to inline logic for npm installs, but the simplest fix is to remove line 8 from.npmignore. This should be a conscious decision. -
install-completions.shpath resolution when run from~/.local/bin/— mitigated by theCOMPLETIONS_DIRfallback and copying completions to~/.shipwright/completions/ -
Homebrew installs bypass both
initandinstall.sh— Homebrew formula already handles completions at lines 54-58 viabash_completion.install,zsh_completion.install,fish_completion.install. No change needed there.
-
-
shipwright initinstalls completions for the current shell without prompting, and shows success/warn output -
shipwright initsucceeds whencompletions/directory is missing (graceful warn + skip) -
shipwright initsucceeds wheninstall-completions.shis missing (graceful warn + skip) -
shipwright completions installworks as a standalone command -
shipwright helplistscompletionsin the command list - Running
shipwright inittwice doesn't produce errors or duplicate.zshrcentries - After init,
shipwright <TAB>shows subcommands in the user's shell -
install.shcopiesinstall-completions.shandcompletions/to appropriate locations -
install-completions.shworks correctly when invoked from~/.local/bin/(fallback path) - All scripts remain Bash 3.2 compatible
-
npm testpasses with no regressions - Decide whether to remove
install-completions.shfrom.npmignore(line 8) — if kept, npm users only get completions viainitwith inline fallback; if removed, standalone command also works for npm installs