From fcebf64468e00db0203c3d2f5b6bdf45a8c88fb1 Mon Sep 17 00:00:00 2001 From: YeonGyu-Kim Date: Wed, 27 May 2026 19:04:15 +0900 Subject: [PATCH] fix(#802): four resume-mode and broad-cwd error envelopes now include hint field --- ROADMAP.md | 2 ++ rust/crates/rusty-claude-cli/src/main.rs | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/ROADMAP.md b/ROADMAP.md index 4be3fb63..6c3f1063 100644 --- a/ROADMAP.md +++ b/ROADMAP.md @@ -7768,3 +7768,5 @@ Original filing (2026-04-18): the session emitted `SessionStart hook (completed) 800. **`classify_error_kind` unit test coverage gap: `invalid_history_count` and `unknown_option` arms had zero assertions** — found 2026-05-27 on `efb1542a`. Audit of 39 distinct classifier return values vs 37 unit test assertions revealed 2 untested arms. Fix: added 3 `assert_eq!` covering both arms (invalid_history_count prefix + contains paths, unknown_option prefix). Committed as `6ee67d6c`. All 39 return values now have unit test coverage. [SCOPE: claw-code] 801. **`claw --output-format json diff` in a non-git directory was missing `error_kind`, `hint`, and `message` fields** — dogfooded 2026-05-27 on `1201dc60`. The diff handler's no-git-repo JSON branch constructed a custom object with only `status:"error"` + `result:"no_git_repo"` + `detail`, violating the error envelope contract that every error has `error_kind` + `hint`. Fix: added `error_kind: "no_git_repo"`, `hint: "Run git init..."`, and `message` fields. Integration test `diff_non_git_dir_has_error_kind_and_hint_801`. 62 CLI contract tests pass. [SCOPE: claw-code] Source: Jobdori non-git-dir probe on `1201dc60`, 2026-05-27. + +802. **Four `status:"error"` JSON sites in resume-mode and broad-cwd handlers were missing `hint` field** — found 2026-05-27 on `53953a81` via source audit of all `"status": "error"` sites in main.rs. The resume `unsupported_command` (L3433), `unsupported_resumed_command` (L3455), `cli_parse` (L3474), and `broad_cwd` (L4838) handlers all emitted JSON error envelopes with `error_kind` but no `hint` field. Fix: added contextual `hint` string to all four sites. Source audit now shows 0 `status:"error"` JSON objects missing `hint` across entire main.rs. 62 CLI contract tests pass. [SCOPE: claw-code] Source: Jobdori source-level audit of all error JSON sites, 2026-05-27. diff --git a/rust/crates/rusty-claude-cli/src/main.rs b/rust/crates/rusty-claude-cli/src/main.rs index 0e8dd30f..9e85c75c 100644 --- a/rust/crates/rusty-claude-cli/src/main.rs +++ b/rust/crates/rusty-claude-cli/src/main.rs @@ -3433,6 +3433,7 @@ fn resume_session(session_path: &Path, commands: &[String], output_format: CliOu "status": "error", "error_kind": "unsupported_command", "error": format!("/{cmd_root} is not yet implemented in this build"), + "hint": "This command is not available in the current build. Update claw or use a different command.", "exit_code": 2, "command": raw_command, }) @@ -3455,6 +3456,7 @@ fn resume_session(session_path: &Path, commands: &[String], output_format: CliOu "status": "error", "error_kind": "unsupported_resumed_command", "error": format!("unsupported resumed command: {raw_command}"), + "hint": "This command cannot be used with --resume. Use it in an interactive REPL session instead.", "exit_code": 2, "command": raw_command, }) @@ -3474,6 +3476,7 @@ fn resume_session(session_path: &Path, commands: &[String], output_format: CliOu "status": "error", "error_kind": "cli_parse", "error": error.to_string(), + "hint": "Run `claw --help` for usage.", "exit_code": 2, "command": raw_command, }) @@ -4838,6 +4841,7 @@ fn enforce_broad_cwd_policy( "status": "error", "error_kind": "broad_cwd", "error": message, + "hint": "Change to a more specific project directory, or use --cwd to set the workspace root.", "exit_code": 1, }) );