resolveDevPort
resolveDevPort(
ports,worktreePath,readFile?,httpProbe?):Promise<number|null>
Defined in: src/preview.ts:313
Resolve the active dev port for a worktree, honoring an optional
.shepherd-preview hint file.
Honor rule: the hint is used ONLY when the declared port is in ports
(confirmed listening) AND passes the HTTP liveness check — the same check
pickPrimaryPort uses for non-curated ports (curated ports are trusted
unprobed). This preserves every invariant from #345:
- never surface a dead port or a port owned by another process/worktree
- never surface a non-HTTP socket (DB port, debugger, etc.)
- the hint’s purpose is to disambiguate WHICH live HTTP port wins over the heuristic for multi-listener apps or apps on uncommon ports
Falls through to pickPrimaryPort when the hint is absent, unreadable,
not in ports, or not an HTTP server.
Parameters
Section titled “Parameters”number[]
Listening ports for this worktree (from /proc scan).
worktreePath
Section titled “worktreePath”string
Absolute path to the worktree root (hint file location).
readFile?
Section titled “readFile?”(path, enc) => Promise<string>
Injectable file reader (forwarded to readPreviewHint).
httpProbe?
Section titled “httpProbe?”(port) => Promise<boolean>
Injectable HTTP liveness probe (default: real network call).
Returns
Section titled “Returns”Promise<number | null>