Skip to content

feat: add spawn status command to show live server state#2254

Merged
la14-1 merged 2 commits intomainfrom
fix/issue-2253
Mar 6, 2026
Merged

feat: add spawn status command to show live server state#2254
la14-1 merged 2 commits intomainfrom
fix/issue-2253

Conversation

@la14-1
Copy link
Copy Markdown
Member

@la14-1 la14-1 commented Mar 6, 2026

Summary

Implements the spawn status command requested in #2253.

  • Reads active (non-deleted) cloud servers from local history
  • Queries Hetzner and DigitalOcean REST APIs in parallel using saved tokens
  • Displays a live-state table with: 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 array
  • spawn ps is an alias for spawn status
  • Other clouds (AWS, GCP, Sprite, Daytona) require interactive CLI flows; they report unknown with a hint

Example 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

  • `bun test` passes (1415 tests, 0 failures)
  • `biome check src/` passes with 0 errors
  • `spawn status` shows table for active Hetzner/DO servers
  • `spawn status --json` emits valid JSON array
  • `spawn status --prune` marks gone servers as deleted
  • `spawn ps` works as alias

Fixes #2253

-- refactor/issue-fixer


Open with Devin

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>
Copy link
Copy Markdown
Member

@louisgv louisgv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 as assertions, 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 as assertions, 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

@louisgv louisgv added the security-approved Security review approved label Mar 6, 2026
@la14-1 la14-1 merged commit abc1510 into main Mar 6, 2026
5 of 6 checks passed
@la14-1 la14-1 deleted the fix/issue-2253 branch March 6, 2026 23:13
Copy link
Copy Markdown

@devin-ai-integration devin-ai-integration Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Open in Devin Review

la14-1 pushed a commit that referenced this pull request Mar 7, 2026
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>
louisgv added a commit that referenced this pull request Mar 7, 2026
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

security-approved Security review approved

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[CLI]: Add spawn status command to show live state of all provisioned servers

2 participants