Skip to content

[Enhancement]: Add JSON output format for 'conversation show' subcommand #161

@spachava753

Description

@spachava753

Enhancement Category

CLI commands/flags

Problem or Use Case

When using the conversation show subcommand, the output is currently formatted for human readability. However, users who want to:

  • Post-process conversation data with other tools
  • Export conversations to different formats
  • Analyze conversation patterns programmatically
  • Integrate CPE conversation history into other workflows

...cannot easily do so because there's no machine-readable output format.

Proposed Solution

Add a --json or -j flag to the conversation show subcommand that outputs the conversation in JSON format.

Example usage:

# Output conversation in JSON format
cpe conversation show <message_id> --json

# Pipe to jq for processing
cpe conversation show <message_id> --json | jq '.messages[] | select(.role == "assistant")'

# Save to file for external processing
cpe conversation show <message_id> --json > conversation.json

The JSON output should include:

  • Message IDs
  • Roles (user/assistant)
  • Content (text and any tool calls/results)
  • Timestamps
  • Parent message references (for branching context)
  • Model used (if available)

Alternatives Considered

  • Manually parsing the current pretty-printed output (fragile, breaks on format changes)
  • Directly querying the SQLite .cpeconvo database (requires knowledge of internal schema, not stable API)

Impact Scope

Everyone using CPE

Additional Context

This aligns with common CLI conventions where tools provide --json flags for machine-readable output (e.g., docker, gh, kubectl). It would make CPE more composable in scripted workflows and pipelines.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions