Skip to content

feat(cli): add -f/--format to webcmd daemon status - #325

Open
rohan911438 wants to merge 2 commits into
agentrhq:mainfrom
rohan911438:feat/daemon-status-structured-output-175
Open

feat(cli): add -f/--format to webcmd daemon status#325
rohan911438 wants to merge 2 commits into
agentrhq:mainfrom
rohan911438:feat/daemon-status-structured-output-175

Conversation

@rohan911438

Copy link
Copy Markdown

Summary

Partial slice of #175.

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.

Changes

  • daemonStatus() now takes an optional fmt (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).
  • CLI registration adds -f, --format to daemon status.

Scope note

Same slice-of-#175 approach as the validate PR — one complete,
tested command rather than a partial pass across the full list in the
issue.

Test plan

  • New cases in src/commands/daemon.test.ts: -f json when
    running and when not running.
  • npx tsc --noEmit clean.
  • npx vitest run --project unit src/commands/daemon.test.ts — 16/16 pass.
  • Manual smoke: webcmd daemon status -f json / webcmd daemon status.

`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>
Copilot AI lite review requested due to automatic review settings August 16, 2026 16:12
@github-actions

Copy link
Copy Markdown
Contributor

🟠 Maintainer review suggested — low confidence

The automated review could not reach a fully supported conclusion.

This review is advisory and does not block merging.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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 to render() a structured { running, ...status } envelope for non-table formats.
  • Added unit tests for -f json structured output for both “running” and “not running” daemon states.
  • Extended CLI registration for daemon status to accept -f, --format <fmt> and validate/normalize the format via resolveOutputFormat().

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 yaml has 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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants