feat(cli): add -f/--format to webcmd daemon status - #325
Open
rohan911438 wants to merge 2 commits into
Open
Conversation
`daemon status` fetches a fully-typed `DaemonStatus` object but only ever printed it as hand-written text lines, rejecting `-f` entirely. Agents/scripts polling daemon health had no structured way to read it (agentrhq#175). Add `-f, --format` (default `table`, unchanged text output). Other formats render a `{ running, ...status }` envelope through the shared output path — `running` distinguishes the "daemon not reachable" case, which previously had no structured representation at all (`fetchDaemonStatus` returns null rather than a partial status object). Scope note: same slice-of-agentrhq#175 approach as the `validate` PR — one complete, tested command rather than a partial pass across the full list in the issue. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Contributor
🟠 Maintainer review suggested — low confidenceThe automated review could not reach a fully supported conclusion. This review is advisory and does not block merging. |
There was a problem hiding this comment.
Pull request overview
Adds structured output support to the built-in webcmd daemon status command by wiring it into the shared renderer when a non-default output format is requested, enabling scripts/agents to reliably consume daemon health data.
Changes:
- Updated
daemonStatus()to accept an optional format parameter and torender()a structured{ running, ...status }envelope for non-tableformats. - Added unit tests for
-f jsonstructured output for both “running” and “not running” daemon states. - Extended CLI registration for
daemon statusto accept-f, --format <fmt>and validate/normalize the format viaresolveOutputFormat().
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| src/commands/daemon.ts | Adds format-aware rendering for structured outputs while keeping legacy default output intact. |
| src/commands/daemon.test.ts | Adds tests for structured output behavior (currently JSON-only in the PR). |
| src/cli.ts | Registers -f/--format for daemon status and passes the validated format through. |
Suppressed comments (1)
src/commands/daemon.test.ts:133
- The new structured-output coverage for the stopped/unreachable daemon case only asserts JSON. Add a YAML variant too so
daemon status -f yamlhas test coverage for the{ running: false }envelope.
it('renders a structured envelope for -f json when not running (#175)', async () => {
fetchDaemonStatusMock.mockResolvedValue(null);
await daemonStatus('json');
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
+109
to
+127
| it('renders a structured envelope for -f json when running (#175)', async () => { | ||
| fetchDaemonStatusMock.mockResolvedValue({ | ||
| ok: true, | ||
| pid: 12345, | ||
| uptime: 60, | ||
| daemonVersion: PKG_VERSION, | ||
| runtimeConnected: true, | ||
| runtimeName: 'fake', | ||
| pending: 0, | ||
| memoryMB: 64, | ||
| port: 9777, | ||
| }); | ||
|
|
||
| await daemonStatus('json'); | ||
|
|
||
| const printed = stdoutSpy.mock.calls.map((c: unknown[]) => c[0]).join('\n'); | ||
| const data = JSON.parse(printed); | ||
| expect(data).toMatchObject({ running: true, pid: 12345, port: 9777 }); | ||
| }); |
Address PR review feedback on agentrhq#325: the new structured-output tests only covered -f json for both the running and not-running daemon states. Add the yaml equivalents so daemon status -f yaml is exercised too. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Partial slice of #175.
daemon statusfetches a fully-typedDaemonStatusobject but onlyever printed it as hand-written text lines, rejecting
-fentirely.Agents/scripts polling daemon health had no structured way to read it.
Changes
daemonStatus()now takes an optionalfmt(defaulttable,unchanged text output).
{ running, ...status }envelope through theshared output path.
runningdistinguishes the "daemon notreachable" case, which previously had no structured representation
at all (
fetchDaemonStatusreturnsnullrather than a partialstatus object).
-f, --formattodaemon status.Scope note
Same slice-of-#175 approach as the
validatePR — one complete,tested command rather than a partial pass across the full list in the
issue.
Test plan
src/commands/daemon.test.ts:-f jsonwhenrunning and when not running.
npx tsc --noEmitclean.npx vitest run --project unit src/commands/daemon.test.ts— 16/16 pass.webcmd daemon status -f json/webcmd daemon status.