-
Notifications
You must be signed in to change notification settings - Fork 1
Pipeline Design 6
shipwright doctor (scripts/sw-doctor.sh) validates the entire Shipwright setup across 13 numbered sections (tmux, Claude Code, GitHub, etc.) but has no checks for the dashboard subsystem. Users who run shipwright dashboard without Bun installed, without dashboard files present, or with port 8767 already occupied get opaque failures. The doctor command should catch these issues proactively.
Constraints:
- Bash 3.2 compatible (no associative arrays,
readarray,${var,,}) -
set -euo pipefailthroughout - Dashboard is optional — all checks must use
check_warn, nevercheck_fail - Default dashboard port is 8767 (confirmed in
dashboard/server.ts:18andscripts/sw-dashboard.sh:43) - Doctor currently defines
_DOCTOR_SCRIPT_DIR(line ~864) which can be reused for relative path resolution - Existing test harness pattern: mock binaries in sandboxed
$PATH, PASS/FAIL counters, ERR trap
Add a new Section 14: Dashboard to sw-doctor.sh between the GitHub Integration section (13) and the Summary block. The section performs three checks:
-
Bun runtime —
command -v bunwith version display; warn with install URL if missing -
Dashboard files — Search repo-relative
dashboard/server.tsfirst, then fallback to~/.local/share/shipwright/dashboardand~/.shipwright/dashboard; separately checkpublic/index.htmlfor frontend assets -
Port 8767 availability — Use
lsof -iTCP:8767 -sTCP:LISTENif available; skip gracefully iflsofnot found
All checks emit check_warn on failure (not check_fail) since the dashboard is an optional feature. This matches how Section 13 (GitHub) uses warns for missing gh CLI.
The test suite follows the established pattern from sw-connect-test.sh: sandboxed HOME, mock binaries directory prepended to PATH, full doctor invocation with output capture and string matching.
-
Add checks inside
sw-dashboard.shstartup — Pros: checks run only when dashboard is actually needed / Cons: doesn't provide proactive diagnosis; doctor is the canonical "is everything set up?" command; users expect doctor to surface all issues -
Use
check_failfor missing Bun — Pros: stronger signal / Cons: dashboard is optional; a failing doctor check for an optional feature frustrates users who never use the dashboard;check_warnis correct severity -
Check port via
ssinstead oflsof— Pros:ssis standard on Linux / Cons: macOS (primary target) shipslsofbut notss;lsofis the better cross-platform choice; we already skip gracefully if neither is available -
Use
nc -zfor port check — Pros: widely available / Cons: behavior varies across BSD vs GNU netcat;lsofdirectly queries the kernel socket table which is more reliable for checking listener state
-
Files to create:
-
scripts/sw-doctor-test.sh— New test suite (~12 test cases)
-
-
Files to modify:
-
scripts/sw-doctor.sh— Insert Section 14 (~45 lines) between Section 13 and Summary -
package.json— Append&& bash scripts/sw-doctor-test.shto"test"script (suite #23)
-
-
Dependencies: None new. Bun is checked-for, not required.
-
Risk areas:
-
_DOCTOR_SCRIPT_DIRmust already be defined before Section 14 runs (it is — set in Section 13 at line ~864) -
lsofflag syntax differs slightly across platforms;-iTCP:8767 -sTCP:LISTENis POSIX-compatible and works on both macOS and Linux - Mock environment for tests must include all prerequisite mocks (tmux, jq, claude, git, gh, node) since doctor runs all 14 sections — a missing mock causes early
set -eexit before reaching Section 14
-
-
shipwright doctoroutputs a "DASHBOARD" section header with Bun, file, and port checks - Bun check shows version when installed, shows
bun.sh/installURL when missing - Dashboard file search covers repo-relative path + two fallback locations
- Port check uses 8767, warns when in use, skips gracefully without lsof
- All dashboard checks use
check_warn/check_pass— nevercheck_fail -
sw-doctor-test.shcontains 10+ tests covering all positive and negative branches -
sw-doctor-test.shregistered inpackage.jsonas test suite #23 - All 23 test suites pass (
npm test) - Script is Bash 3.2 compatible — no associative arrays, no
readarray, no${var,,} - No regressions in existing doctor sections 1-13