From f1e4ad757484f3c76feeb6e15e2fea8abe97bcc8 Mon Sep 17 00:00:00 2001 From: YeonGyu-Kim Date: Wed, 22 Apr 2026 00:21:32 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20#156=20=E2=80=94=20error=20classificati?= =?UTF-8?q?on=20for=20text-mode=20output=20(Phase=202=20of=20#77)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Problem #77 Phase 1 added machine-readable error `kind` discriminants to JSON error payloads. Text-mode (stderr) errors still emit prose-only output with no structured classification. Observability tools (log aggregators, CI error parsers) parsing stderr can't distinguish error classes without regex-scraping the prose. ## Fix Added `[error-kind: ]` prefix line to all text-mode error output. The prefix appears before the error prose, making it immediately parseable by line-based log tools without any substring matching. **Examples:** ## Impact - Stderr observers (log aggregators, CI systems) can now parse error class from the first line without regex or substring scraping - Same classifier function used for JSON (#77 P1) and text modes - Text-mode output remains human-readable (error prose unchanged) - Prefix format follows syslog/structured-logging conventions ## Tests All 179 rusty-claude-cli tests pass. Verified on 3 different error classes. Closes ROADMAP #156. --- rust/crates/rusty-claude-cli/src/main.rs | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/rust/crates/rusty-claude-cli/src/main.rs b/rust/crates/rusty-claude-cli/src/main.rs index bed1686..c4ba812 100644 --- a/rust/crates/rusty-claude-cli/src/main.rs +++ b/rust/crates/rusty-claude-cli/src/main.rs @@ -223,14 +223,21 @@ fn main() { "hint": hint, }) ); - } else if message.contains("`claw --help`") { - eprintln!("error: {message}"); } else { - eprintln!( - "error: {message} + // #156: Add machine-readable error kind to text output so stderr observers + // don't need to regex-scrape the prose. + let kind = classify_error_kind(&message); + if message.contains("`claw --help`") { + eprintln!("[error-kind: {kind}] +error: {message}"); + } else { + eprintln!( + "[error-kind: {kind}] +error: {message} Run `claw --help` for usage." - ); + ); + } } std::process::exit(1); }