From 196fe6b49384b82cb01b9b0d4403c949f8abc962 Mon Sep 17 00:00:00 2001 From: YeonGyu-Kim Date: Thu, 23 Apr 2026 02:54:41 +0900 Subject: [PATCH] =?UTF-8?q?roadmap:=20#136=20marked=20CLOSED=20=E2=80=94?= =?UTF-8?q?=20compact+json=20dispatch=20already=20correct?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ROADMAP.md | 36 ++++++++++++++++++++---------------- 1 file changed, 20 insertions(+), 16 deletions(-) diff --git a/ROADMAP.md b/ROADMAP.md index 6ef3ca1..e202043 100644 --- a/ROADMAP.md +++ b/ROADMAP.md @@ -5153,25 +5153,29 @@ ear], /color [scheme], /effort [low|medium|high], /fast, /summary, /tag [label], ## Pinpoint #136. `--compact` flag output is not machine-readable — compact turn emits plain text instead of JSON when `--output-format json` is also passed -**Gap.** `claw --compact ` runs a prompt turn with compacted output (tool-use suppressed, final assistant text only). But `run_with_output()` routes on `(output_format, compact)` with an explicit early-return match: `CliOutputFormat::Text if compact => run_prompt_compact(input)`. The `CliOutputFormat::Json` branch is never reached when `--compact` is set. Result: passing `--compact --output-format json` silently produces plain-text output — the compact flag wins and the format flag is silently ignored. No warning or error is emitted. +**Status: ✅ CLOSED (already implemented, verified cycle #60).** -**Trace path.** -- `rust/crates/rusty-claude-cli/src/main.rs:3872-3879` — `run_with_output()` match: - ``` - CliOutputFormat::Text if compact => self.run_prompt_compact(input), - CliOutputFormat::Text => self.run_turn(input), - CliOutputFormat::Json => self.run_prompt_json(input), - ``` - The `Json` arm is unreachable when `compact = true` because the first arm matches first regardless of `output_format`. -- `run_prompt_compact()` at line 3879 calls `println!("{final_text}")` — always plain text, no JSON envelope. -- `run_prompt_json()` at line 3891 wraps output in a JSON object with `message`, `model`, `iterations`, `usage`, `tool_uses`, `tool_results`, etc. +**Implementation:** The dispatch ordering in `LiveCli::run_with_output()` has the correct precedence: +```rust +CliOutputFormat::Json if compact => self.run_prompt_compact_json(input), +CliOutputFormat::Text if compact => self.run_prompt_compact(input), +CliOutputFormat::Text => self.run_turn(input), +CliOutputFormat::Json => self.run_prompt_json(input), +``` -**Fix shape (~20 lines).** -1. Add a `CliOutputFormat::Json if compact` arm (or merge compact flag into `run_prompt_json` as a parameter) that produces a JSON object with `message: ` and a `compact: true` marker. Tool-use fields remain present but empty arrays (consistent with compact semantics — tools ran but are not returned verbatim). -2. Emit a warning or `error.kind: "flag_conflict"` if conflicting flags are passed in a way that silently wins (or document the precedence explicitly in `--help`). -3. Regression tests: `claw --compact --output-format json ` must produce valid JSON with at minimum `{message: "...", compact: true}`. +`run_prompt_compact_json()` produces: +```json +{ + "message": "", + "compact": true, + "model": "...", + "usage": { ... } +} +``` -**Acceptance.** An orchestrator that requests compact output for token efficiency AND machine-readable JSON gets both. Silent flag override is never a correct behavior for a tool targeting machine consumers. +**Dogfood verification (2026-04-23 cycle #60):** Tested `claw prompt "hello" --compact --output-format json` → produces valid JSON with `compact: true` marker. Error cases also JSON-wrapped (consistent with error envelope contract #247). + +**Note:** Dispatch reordering that fixed this is not yet known to be in a review-ready branch or merged main. Verify merge status. **Blocker.** None. Additive change to existing match arms.