Skip to content

feat(cli): add -f/--format to webcmd profile list - #326

Open
rohan911438 wants to merge 1 commit into
agentrhq:mainfrom
rohan911438:feat/profile-list-structured-output-175
Open

feat(cli): add -f/--format to webcmd profile list#326
rohan911438 wants to merge 1 commit into
agentrhq:mainfrom
rohan911438:feat/profile-list-structured-output-175

Conversation

@rohan911438

Copy link
Copy Markdown

Summary

Partial slice of #175.

Local profile list rejected -f entirely and only printed prose,
while hosted profile list already supports -f json|yaml|csv|md
(src/hosted/runner.ts) — the same command name behaving differently
between modes with no indication why. #175 explicitly calls out
"align local profile list with hosted profile-list formatting."

Changes

  • Add -f, --format (default table, prose output unchanged).
  • Other formats render one row per profile through the shared output
    path. Row shape aligns with hosted's where the concept overlaps
    (default), plus locally-meaningful fields hosted doesn't have
    (connected, runtimeVersion) since Cloak profiles are live
    runtime connections, not persisted Cloud records.
  • Disconnected saved aliases (already shown in the prose output) are
    included as connected: false rows so the structured view doesn't
    silently drop information the text view shows.
  • The daemon-not-running/stale/no-profiles branches render [] for
    non-table formats rather than swallowing output, mirroring the
    existing adapter status empty-list convention.

Scope note

Same slice-of-#175 approach as the validate and daemon status PRs.

Test plan

  • New cases in src/cli.test.ts: -f json with no profiles
    (→ []), and with a connected profile + a disconnected saved
    alias + a disconnected default (→ structured rows).
  • npx tsc --noEmit clean.
  • npx vitest run --project unit src/cli.test.ts — 104/104 pass.
  • Manual smoke: webcmd profile list -f json / webcmd profile list.

Local `profile list` rejected `-f` entirely and only printed prose,
while hosted `profile list` already supports `-f json|yaml|csv|md`
(src/hosted/runner.ts) — the same command name behaving differently
between modes with no indication why (agentrhq#175).

Add `-f, --format` (default `table`, prose output unchanged). Other
formats render one row per profile through the shared output path.
Row shape aligns with hosted's where the concept overlaps (`default`),
plus locally-meaningful fields hosted doesn't have (`connected`,
`runtimeVersion`) since Cloak profiles are live runtime connections,
not persisted Cloud records. Disconnected saved aliases (already shown
in the prose output) are included as `connected: false` rows so the
structured view doesn't silently drop information the text view shows.
The daemon-not-running/stale/no-profiles branches render `[]` for
non-table formats rather than swallowing output, mirroring the
existing `adapter status` empty-list convention.

Scope note: same slice-of-agentrhq#175 approach as the `validate` and
`daemon status` PRs.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Copilot AI lite review requested due to automatic review settings August 16, 2026 16:13
@github-actions

Copy link
Copy Markdown
Contributor

🟠 Maintainer review suggested — low confidence

The automated review could not reach a fully supported conclusion.

Limitations

  • The automated review returned an invalid structured result.

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

This PR adds structured output formatting to the local webcmd profile list command so it can emit machine-readable results (via the shared renderOutput path) and behave more consistently with hosted mode’s profile list.

Changes:

  • Adds -f, --format <fmt> to local profile list (defaulting to the existing human/prose output path).
  • Emits structured rows for non-table formats, including connected runtime profiles plus disconnected saved aliases/defaults.
  • Adds new unit tests covering -f json output for empty and mixed connected/disconnected cases.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
src/cli.ts Adds -f/--format support to local profile list and routes non-table formats through shared structured output.
src/cli.test.ts Adds unit tests for JSON structured output for local profile list.
Suppressed comments (1)

src/cli.test.ts:1779

  • This structured-row test verifies JSON output but not YAML. Adding a YAML assertion here would ensure the shared output path produces the same rows across the two primary structured formats referenced in #175.
    await program.parseAsync(['node', 'webcmd', 'profile', 'list', '-f', 'json']);

    const output = stdoutSpy.mock.calls.flat().join('\n');
    expect(JSON.parse(output)).toEqual([
      { contextId: 'work', alias: 'work', default: true, connected: true, runtimeVersion: '1.2.3' },
      { contextId: 'gone', alias: 'archived', default: false, connected: false, runtimeVersion: null },

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/cli.ts
Comment on lines +1811 to +1813
// Aligns with the hosted `profile list` row shape (`default`); local rows also
// carry `connected`/`runtimeVersion` since Cloak profiles are live runtime
// connections, not persisted Cloud records.
Comment thread src/cli.test.ts
Comment on lines +1743 to +1749
const program = createProgram('', '');

await program.parseAsync(['node', 'webcmd', 'profile', 'list', '-f', 'json']);

const output = stdoutSpy.mock.calls.flat().join('\n');
expect(JSON.parse(output)).toEqual([]);
});
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.

3 participants