Skip to content

Pipeline Plan inline

Seth Ford edited this page Mar 2, 2026 · 10 revisions

Plan saved to docs/plans/2026-03-01-ping-command.md.


Ping Command Implementation Plan

Socratic Design Analysis

Minimum viable change: 4 touches — create scripts/sw-ping.sh, create scripts/sw-ping-test.sh, add ping) case to scripts/sw router, add entry to package.json test script.

Alternatives considered:

Approach Trade-offs
Standalone script (chosen) Identical to 100+ existing commands; fully isolated; testable independently; ~67 lines
Inline in router Fewer files but mixes concerns, no independent test path, against project architecture

Chosen: Standalone script — same pattern as sw-hello.sh, lowest blast radius.


Files to Modify

Action File Notes
Create scripts/sw-ping.sh New command — ~67 lines, mirrors sw-hello.sh
Create scripts/sw-ping-test.sh 6-test suite — mirrors sw-hello-test.sh
Modify scripts/sw Insert ping) case before hello) at line 605
Modify package.json Insert bash scripts/sw-ping-test.sh && between pipeline-vitals and pm tests

Implementation Steps

  1. Create scripts/sw-ping-test.sh with 6 tests: output=pong, exit 0, --help contains USAGE, -h contains USAGE, --version matches semver, invalid option exits 1
  2. Run test — confirm fails (file not found) — TDD red phase
  3. Create scripts/sw-ping.sh — exact structure of sw-hello.sh with echo "pong" in the "" case; VERSION="3.2.4", set -euo pipefail, ERR trap
  4. chmod +x scripts/sw-ping.sh
  5. Run bash scripts/sw-ping-test.sh — confirm PASS: 6 FAIL: 0
  6. Commit sw-ping.sh + sw-ping-test.sh
  7. Edit scripts/sw — insert ping) exec "$SCRIPT_DIR/sw-ping.sh" "$@" ;; before hello) case
  8. Verify bash scripts/sw ping prints pong
  9. Commit router change
  10. Edit package.json — insert bash scripts/sw-ping-test.sh && after sw-pipeline-vitals-test.sh
  11. Run npm test — confirm full suite passes
  12. Commit package.json

Task Checklist

  • Task 1: Create scripts/sw-ping-test.sh (6 tests)
  • Task 2: Run test — confirm fails (TDD red)
  • Task 3: Create scripts/sw-ping.sh (mirrors sw-hello.sh, outputs pong)
  • Task 4: chmod +x scripts/sw-ping.sh
  • Task 5: Run bash scripts/sw-ping-test.sh — PASS: 6 FAIL: 0
  • Task 6: Commit sw-ping.sh + sw-ping-test.sh
  • Task 7: Add ping) case to scripts/sw before hello) (line 605)
  • Task 8: Verify bash scripts/sw ping prints pong
  • Task 9: Commit router change
  • Task 10: Add bash scripts/sw-ping-test.sh && to package.json test script
  • Task 11: Run npm test — confirm all suites pass
  • Task 12: Commit package.json

Risk Analysis

Risk What Breaks Mitigation
Router entry after *) ping is unreachable — falls through to "Unknown command" Insert before hello) which is before *)
Extra whitespace in pong output assert_equals "pong" "$output" fails Use bare echo "pong" — no color/prefix
ERR trap + invalid option test Trap fires on intentional exit 1 during test Mirror hello-test pattern: `
package.json position Test skipped if misplaced Insert alphabetically between pipeline-vitals and pm
VERSION drift Conventions violation Use VERSION="3.2.4" (from sw-hello.sh)

Definition of Done

  • bash scripts/sw-ping.sh prints exactly pong
  • Exit code is 0
  • bash scripts/sw-ping-test.sh → PASS: 6 FAIL: 0
  • bash scripts/sw ping prints pong (router verified)
  • npm test passes with ping test included
  • sw-ping.sh is executable and uses set -euo pipefail, VERSION="3.2.4", ERR trap

Clone this wiki locally