Skip to content

index --verbose --json writes human-readable lines to stdout, breaking JSON #1471

Description

@Widthdom

Summary

cdidx index --verbose writes human-readable status lines ([SKIP] foo.cs (matched filter), [DEL] bar.cs) to stdout. When the same invocation also passes --json, the JSON output is contaminated with non-JSON lines, breaking any parser on the receiving end.

Evidence

  • src/CodeIndex/Cli/IndexCommandRunner.cs:785, 797, 814Console.WriteLine(...) calls inside the verbose paths, regardless of whether options.Json is set.

Impact

  • cdidx index --verbose --json | jq . fails to parse.
  • Agents that always pass --json for machine consumption cannot also enable verbose status without breaking themselves.

Proposed direction

  • When options.Json is true, route verbose status lines to stderr (Console.Error.WriteLine) instead of stdout.
  • Stdout becomes a clean JSON-only stream; stderr carries human-readable progress.
  • Apply the same rule to any other --json-friendly subcommand that emits verbose progress.

Repro env

  • Branch: main @ 2ee912d (release v1.21.0)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions