Skip to content

Structured output & CLI API hardening (output + errors + --describe) #2622

Open

Description

@aristidesstaffieri

Part of the Improve Agent UX for Wallets epic.

Summary

Harden the CLI API so an agent/human can parse any command's result and chain commands together without scraping plain text. Three facets, tracked as one task: a global structured-output flag, a structured error catalog, and a --describe machine-readable schema.

1. Structured output

New global flag:

output=json|default
  • default — today's default (plain text for most commands, a few existing JSON exceptions).
  • json — an object with predictable keys representing the same data plus enriched output in some cases (e.g. errors paired with a resolution).

Example (ok):

{ "status": "ok", "result": "9999999500", "error": null }

Example (error):

{
  "status": "error",
  "result": null,
  "error": {
    "code": "tx_simulation_failed",
    "domain": "tx",
    "message": "host invocation failed: Error(Contract, #2)",
    "details": {
      "contract_id": "C...",
      "error_code": 2,
      "error_name": "InsufficientBalance",
      "diagnostic_events": ["..."]
    }
  }
}

2. Structured errors

commands return an object with a consistent set of keys.
errors add context along with raw error details to aid users/agents towards remediation of the error.

3. --describe

A projection of the command spec: a machine-readable schema for a command or the tree (args, output schema, errors[], examples). Backed by a command-spec source file feeding the parser / --help / --describe generator.

Build on existing OutputFormat patterns (events.rs, fee_stats.rs, ledger/fetch.rs) and print.rs.

Acceptance criteria

  • The spec's example envelopes (ok-result and error-with-remediation) reproduce.
  • --describe emits args / output / errors[] / examples.
  • commands emit parseable JSON under output=json.

Activity

  1. moved this to Backlog (Not Ready) in DevXon Jun 24, 2026
  2. janewang commented on Jun 29, 2026

    @janewang
    Contributor

    @aristidesstaffieri @oceans404 @fnando Does it make sense only for machine-facing CLI API, or should it be for humans too?

  3. aristidesstaffieri commented on Jun 29, 2026

    @aristidesstaffieri
    CollaboratorAuthor

    @aristidesstaffieri @oceans404 @fnando Does it make sense only for machine-facing CLI API, or should it be for humans too?

    the summary just focuses on the improvement in a parsable format, but it is useful for humans also, I will update the text.

  4. oceans404 commented on Nov 1, 2026

    @oceans404

    A data point for sequencing, from checking HackMeridian 2026 hackathon repos (147 public repos) against 28.1.0: tx sign and tx send look like a natural first pair to move onto the Output system from #2635.

    • tx sign prints only the signed XDR. The hash is an info line on stderr, and under -q a failure prints nothing at all (--quiet hides the error message when a command fails #2876). Teams that wanted to sign from code read the secret out with keys secret instead (13 repos).
    • tx send already prints its result as JSON, but a failure is the human error line, so a script can't tell a retryable failure from a real one without parsing text.
    • Both have one obvious result shape and no human-facing table to keep, so they'd be a small first slice.

    Related: #2876 (-q hides errors), #2875 and #2879 (other commands scripts parse today).


    Generated by Claude Code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    • Status
      Backlog (Not Ready)

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions