feat: add spawn status command to show live server state#2254
Conversation
Implements the `spawn status` command requested in #2253. The command: - Reads active (non-deleted) cloud servers from history - Queries Hetzner and DigitalOcean REST APIs in parallel using saved tokens - Shows a live-state table: ID, Agent, Cloud, IP, State, Since - States: running (green), stopped (yellow), gone (dim), unknown (dim) - --prune flag marks gone servers as deleted in history - --json flag outputs machine-readable JSON for scripting - `spawn ps` is an alias for `spawn status` Other clouds (AWS, GCP, Sprite, Daytona) require CLI auth flows that cannot run non-interactively; they report "unknown" with a helpful hint. Agent: issue-fixer Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
louisgv
left a comment
There was a problem hiding this comment.
Security Review
Verdict: APPROVED
Commit: 7c00781
Findings
No security issues found. The code follows secure practices:
- API calls: Uses proper timeout (10s AbortSignal), validates responses with parseJsonObj + type guards
- Input validation: serverId/dropletId from history records (not user input), safe template interpolation in fetch URLs
- Credentials: Uses loadApiToken() helper, tokens properly scoped to Authorization headers
- Output: JSON output properly escaped via JSON.stringify(), console.log with safe string formatting
- Type safety: No
asassertions, uses parseJsonObj + toRecord + isString guards throughout - Error handling: All fetch calls wrapped in try/catch, graceful degradation to "unknown" state
Tests
- bash -n: N/A (no shell scripts modified)
- bun test: PASS (1415/1415 tests pass)
- biome lint: PASS (0 errors)
- Type safety: PASS (no
asassertions, proper valibot schemas)
Code Quality
- Follows ESM-only convention (no require/CJS)
- Proper version bump (0.15.1 → 0.15.2)
- Clean export additions to commands/index.ts
- Appropriate feature scope (status command for Hetzner/DO, graceful fallback for other clouds)
-- security/pr-reviewer
There was a problem hiding this comment.
Devin Review found 1 potential issue.
🐛 1 issue in files not directly in the diff
🐛 --prune and --json flags missing from KNOWN_FLAGS, making spawn status --prune and spawn status --json unusable (packages/cli/src/flags.ts:3-31)
The new status command accepts --prune and --json flags (parsed in dispatchStatusCommand at packages/cli/src/index.ts:589-590), but neither flag was added to the KNOWN_FLAGS set in packages/cli/src/flags.ts:3-31. Since checkUnknownFlags(filteredArgs) runs at packages/cli/src/index.ts:874 — before dispatchCommand at line 897 — any invocation like spawn status --prune or spawn status --json will immediately exit with an "Unknown flag" error. This makes both flags completely non-functional. Compare with --clear (used by spawn list --clear), which IS listed in KNOWN_FLAGS at packages/cli/src/flags.ts:24.
View 3 additional findings in Devin Review.
The status command (PR #2254) added --prune and --json flags but did not register them in KNOWN_FLAGS. This caused the CLI to reject them with "Unknown flag" errors before the command could even dispatch. Bump CLI version 0.15.4 -> 0.15.5. Agent: ux-engineer Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
The status command (PR #2254) added --prune and --json flags but did not register them in KNOWN_FLAGS. This caused the CLI to reject them with "Unknown flag" errors before the command could even dispatch. Bump CLI version 0.15.4 -> 0.15.5. Agent: ux-engineer Co-authored-by: B <6723574+louisgv@users.noreply.github.com> Co-authored-by: Claude Sonnet 4.5 <noreply@anthropic.com>
Summary
Implements the
spawn statuscommand requested in #2253.running(green),stopped(yellow),gone(dim),unknown(dim)--pruneflag marks gone servers as deleted in history--jsonflag outputs machine-readable JSON arrayspawn psis an alias forspawn statusunknownwith a hintExample output
```
$ spawn status
ID Agent Cloud IP State Since
abc123 claude hetzner 1.2.3.4 running 2h ago
def456 claude digitalocean (terminated) gone 5d ago
ghi789 codex aws 5.6.7.8 unknown 3d ago
1 server gone. Run `spawn status --prune` to remove them.
1 server on aws: live check not supported.
1 server running. Use `spawn list` to reconnect.
```
Test plan
Fixes #2253
-- refactor/issue-fixer