feat(cli)!: add agent-first chat and session ask output modes

This commit is contained in:
coconut-yc
2026-06-21 02:41:36 +08:00
committed by lyingbug
parent 238297e2c5
commit 9437e1ac3c
18 changed files with 1317 additions and 355 deletions
+13 -7
View File
@@ -77,11 +77,15 @@ token (emitting as a JSON array is planned for v0.8).
`detail` carries structured per-error context (e.g. `unknown_subcommand`'s
`available[]` list).
### NDJSON event stream (chat / session ask)
### Buffered JSON and NDJSON streams (chat / session ask)
`--format json` and `--format ndjson` both produce one JSON event per line —
no envelope wrapping. The CLI injects exactly one event (`init`) at the head;
all subsequent events pass through verbatim from the SDK:
`--format json` (the default) buffers the SSE stream and emits one normal
success envelope whose `data.events` contains answer events by default.
`--reference` adds `kb_id` / `chunk_id` / `parent_chunk_id` indexes;
`--verbose` adds reasoning, tool, metadata, and lifecycle events. `--format
text` renders the same projection live.
`--format ndjson` is the raw event/debug surface: the CLI injects exactly one
`init` event at the head and passes all subsequent SDK events through verbatim:
```
{"type":"init","session_id":"...","kb_id":"...","profile":"...","agent_id":"..."}
@@ -91,7 +95,9 @@ all subsequent events pass through verbatim from the SDK:
{"type":"complete","done":true}
```
For prose rendering, pass `--format text`.
MCP `chat` / `session_ask` return the same `events` shape and accept
`reference` / `verbose` booleans. NDJSON ignores both presentation flags and
always stays raw.
### `_notice` evolution policy
@@ -170,8 +176,8 @@ is or isn't aligned with.
| | |
|---|---|
| **WeKnora** | streaming commands (`chat`, `session ask`) emit bare `{type:...}` per line; no envelope |
| **Rationale** | This matches established practice across NDJSON-emitting CLIs and webhook protocols. A streaming envelope requires unwrap before dispatch — net burden with no benefit. |
| **WeKnora** | `chat` / `session ask --format ndjson` emit bare `{type:...}` per line; default JSON buffers a bounded answer-event projection into one envelope |
| **Rationale** | This matches established practice across NDJSON-emitting CLIs and webhook protocols. Each complete line can be decoded and dispatched as it arrives; the buffered envelope is reserved for normal JSON mode. |
### 5. No `schema_version` field in payload