feat(cli): add terminals wait/wait-output/send-keys/attach/resume-all, schema, completions, config check

AV
2mo ago
+4612-23

Summary

Ports the highest-leverage CLI/product gaps identified against Herdr (the terminal-multiplexer competitor) — the CLI goes from a thin wrapper around the desktop app to a first-class way to script, diagnose, and directly control the agent fleet.

10 new capabilities, roughly half the diff is tests:

  • terminals wait — block until an agent reaches a target lifecycle status. No more hand-rolled polling loops around terminals read.
  • terminals wait-output — same idea for any process (test watchers, servers), not just agents.
  • terminals send-keys — real key injection (esc, ctrl+c, arrows, ...). terminals send could previously only type text + Enter. As a side effect, sending an interrupt also clears a wedged status, since Esc/Ctrl+C fire no hook — the exact failure mode behind Superset's least-trustworthy status readings.
  • terminals attach — interactive tmux/herdr-style attach to a live terminal session, over the same WebSocket protocol the desktop's own renderer uses. Works on a remote host via the existing --host flag, for free.
  • terminals resume-all — bulk-sweep every dead-but-resumable session in a workspace at once (--dry-run to preview), instead of noticing and resuming one pane at a time.
  • explain / wait: msSincePtyOutput — independent PTY-silence evidence alongside the hook-derived status. Never overrides it — it's additional evidence for a human or script, not an automatic correction (guessing wrong on live status would be worse than the existing gap).
  • completion bash|zsh — generated live from the real command tree, so it can't drift out of sync as commands are added.
  • schema — the full command tree + every option as real JSON. (--help --json existed but never actually printed JSON.)
  • config check — validates ~/.superset/config.json. Running it against my own machine's real config caught two genuinely stale keys nothing reads anymore.

What's deliberately not in here

Three items from the Herdr comparison aren't built, each backed by checked evidence rather than assumption:

  • Pane geometry control — no persisted layout model exists server-side (checked both DB schemas); the desktop's pane tree lives only in browser localStorage, per-device. Building this means a real sync-layer project, not a CLI command.
  • Attaching hooks to a process Superset didn't launch — Superset's terminals are always spawned by Superset itself; there's no adoption mechanism for an arbitrary external process (confirmed via the actual session-adoption code path).
  • A general notification feed — no persisted notification model exists; building one is new product surface, not a port.

Test plan

  • tsc --noEmit clean across host-service, cli, and cli-framework.
  • Full suites green: 211/211 cli, 203/203 host-service, 40/40 cli-framework.
  • Every --help output confirmed through the real CLI framework binary, not just typechecked.
  • terminals attach had no unit-testable client wiring on its own, so I stood up a local WebSocket server mirroring the host-service's real terminal protocol byte-for-byte and ran the actual client bridge class against it — all 6 protocol assertions passed (JSON control frames, binary output frames, resize, detach-on-close).
  • config check and schema were run for real (read-only) against a live machine.
  • Merged main in after the fact; found and fixed one real gap the auto-merge couldn't catch by compiling alone (resume-all needed the new hasSession dependency main's account-switch fix added to the resume path) — separate commit, easy to review on its own.

https://claude.ai/code/session_01N29v4UPewWLJxf5MvKaz4H

Summary by CodeRabbit

  • New Features

    • Added Bash and Zsh shell completion generation, CLI schema output, and config check validation.
    • Added terminal commands for attaching, explaining agent status, waiting for status or matching output, sending keys, and resuming eligible sessions.
    • Added terminal-agent status monitoring, output-activity details, and bulk session resumption.
    • Added static CLI comparison and verification reports.
  • Documentation

    • Updated orchestration guidance for terminal monitoring and recovery.
  • Tests

    • Added coverage for completions, configuration validation, terminal interactions, waiting, and agent lifecycle behavior.