[Feature] stream-json output format for nanocoder run
Description
Add a stream-json output format to nanocoder run (one JSON event per line).
Use Case
nanocoder run --output-format json (and --json) prints a single result when the run ends. CI jobs, editor integrations and wrapper scripts that want to show progress, tool calls and token usage while the agent works have nothing to read until then, and a run killed by a timeout loses everything it had done. Other CLI agents offer a line-delimited event stream for this.
Proposed Solution
Accept --output-format stream-json. Emit newline-delimited JSON objects as they happen: session_start, assistant_text deltas or messages, tool_call (name, arguments), tool_result (isError, truncated content), usage per response, and a final result object matching what --json prints today. Keep stdout machine-only and send human text to stderr. Update the isValidOutputFormat check in source/cli.tsx (currently text or json), the help text and shell completions.
Alternatives Considered
Parsing the /export --json file after the run (only after it ends), or running ACP (heavier than a one-shot script needs).
Additional Context
- [x] I have searched existing issues to ensure this is not a duplicate
- [x] This feature aligns with the project's goals (local-first AI assistance)
Implementation Notes (optional)
The conversation loop already produces the data for --json and for the ACP timeline; a small event sink interface that both the --json collector and the stream writer implement would avoid a second code path.
Hi @iamcipherdev, thanks for your interest in the issue! Before opening a PR, please comment on the issue first and wait to be assigned. This helps us avoid duplicate work. PRs opened without an assignment may be closed. Thanks for understanding!