Skip to content

bug: --json commands must always return valid JSON, even for empty/error states #369

Description

@Wirasm

Problem

Some --json commands return plain text instead of JSON for certain states:

kild pr my-branch --json
# "No PR found for branch 'kild/my-branch'"   ← plain text, not JSON

This breaks the Assistant Agent persona's ability to reliably parse CLI output. The --json flag is a contract: "this command will return valid JSON."

Expected Behavior

Every --json command should return valid JSON for all states:

kild pr my-branch --json
# {"pr": null, "branch": "kild/my-branch"}

kild pr my-branch --json  # when PR exists
# {"pr": {"number": 123, "state": "open", ...}, "branch": "kild/my-branch"}

Scope

Audit all commands with --json flag:

  • kild list --json — appears correct
  • kild status --json — appears correct
  • kild stats --json — appears correct
  • kild stats --all --json — appears correct
  • kild overlaps --json — appears correct
  • kild pr --jsonBROKEN (returns plain text for no-PR case)
  • kild pr --json --refresh — needs verification
  • kild daemon status --json — appears correct
  • kild health --json — needs verification (if it exists)

Principle

From the branding docs: "Must have --json output for parsing" and "Meaningful exit codes." The --json output is the programmatic API surface for the Assistant Agent and Worker Agent personas. It must be reliable.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P1High priority - Address soon, next in queuebugSomething is brokencliCLI commands and user interfaceeffort/lowSingle file or function, one responsibility, isolated change

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions