Compare commits

...

27 Commits

Author SHA1 Message Date
YeonGyu-Kim
b778d4e3d4 fix(#768): --resume non-slash trailing arg now has error_kind:invalid_resume_argument + hint 2026-05-27 01:35:46 +09:00
YeonGyu-Kim
89735dbd33 fix(#766): claw diff extra args now classified as unexpected_extra_args with hint; track #767 session subcommand gap 2026-05-27 01:33:24 +09:00
YeonGyu-Kim
d29a8e216b fix(#765): login/logout removed_subcommand now has error_kind + non-null hint 2026-05-27 01:28:35 +09:00
YeonGyu-Kim
4ea255ca6a fix(#764): config_parse_error now populates hint field via Display newline delimiter 2026-05-27 01:23:00 +09:00
YeonGyu-Kim
c86dc73d8c fix(#763): config JSON parse errors now classify as config_parse_error 2026-05-27 01:16:04 +09:00
YeonGyu-Kim
88ce181031 test(#762): classify_error_kind now covers all 23 classifier arms (was 8 of 23) 2026-05-27 00:33:11 +09:00
YeonGyu-Kim
d83de563c1 fix(#761): mcp server_not_found and skill_not_found envelopes now include hint field 2026-05-27 00:03:53 +09:00
YeonGyu-Kim
7fa81b5dae fix(#760): agent_not_found and plugin_not_found envelopes now include hint field 2026-05-26 23:36:30 +09:00
YeonGyu-Kim
ef31328aab fix(#759): validate_model_syntax error strings now use newline separator so hint is non-null 2026-05-26 23:04:04 +09:00
YeonGyu-Kim
b8b3af6fc9 fix(#758): --cwd, --date, --session missing-value errors now use missing_flag_value prefix + hint 2026-05-26 22:34:18 +09:00
YeonGyu-Kim
02d77ae1f1 fix(#757): --permission-mode invalid and --allowedTools missing now emit typed error_kind and hint 2026-05-26 22:04:00 +09:00
YeonGyu-Kim
4df146188f fix+test(#756): missing/invalid flag-value errors now emit typed error_kind and non-null hint 2026-05-26 21:37:28 +09:00
YeonGyu-Kim
0e8a449ea9 fix+test(#755): -p consumes exactly one token; flags after prompt text now parse normally 2026-05-26 21:27:39 +09:00
YeonGyu-Kim
c70312bd04 fix(#754): missing_credentials hint now newline-delimited so JSON hint field is non-null 2026-05-26 21:23:03 +09:00
YeonGyu-Kim
e93271356f fix+test(#753): claw -p (no arg) parity with #750: error_kind:missing_prompt with non-null hint 2026-05-26 20:46:27 +09:00
YeonGyu-Kim
cfc26729cf fix(#752): cli_parse unrecognized-arg errors now emit non-null hint for all subcommands 2026-05-26 20:41:12 +09:00
YeonGyu-Kim
ddc71b5620 test(#751): regression guard for #750 prompt no-arg error_kind and hint contract 2026-05-26 20:05:34 +09:00
YeonGyu-Kim
ac925ed41c fix(#750): claw prompt (no arg) now emits error_kind:missing_prompt with non-null hint 2026-05-26 20:03:14 +09:00
YeonGyu-Kim
2dfb7af66e fix+test(#749): compact interactive-only hint now non-null; extend compact JSON test for hint contract 2026-05-26 19:38:09 +09:00
YeonGyu-Kim
3975f2b3ab fix(#748): mcp unknown subcommand now emits error_kind:unknown_mcp_action matching agents/plugins parity 2026-05-26 19:35:55 +09:00
YeonGyu-Kim
04eb661e57 test(#747): regression guard for #745 bare slash command hint contract (issue/pr/commit) 2026-05-26 19:06:59 +09:00
YeonGyu-Kim
18e7744e42 fix(#746): non-TTY interactive-only error populates hint field via newline split 2026-05-26 19:04:56 +09:00
YeonGyu-Kim
3c5459a33b fix(#745): bare slash command guidance adds newline before hint; claw issue/pr/commit etc now have non-null hint 2026-05-26 18:36:21 +09:00
YeonGyu-Kim
92e053a133 test(#744): regression guard for #741 config unsupported-section hint contract 2026-05-26 18:06:35 +09:00
YeonGyu-Kim
1d5db5f77d fix(#743): plugins help --output-format json now emits usage envelope matching agents/mcp/skills help shape; resolves #420 2026-05-26 18:04:04 +09:00
YeonGyu-Kim
2036f0bd4c test(#742): add git-fixture test for diff changed_file_count dedup; fixes unreachable branch in #740 coverage 2026-05-26 17:41:02 +09:00
YeonGyu-Kim
6e78c1fc8b fix(#741): config unsupported_config_section error now populates hint field; list/show/help verbs get usage hint 2026-05-26 17:38:02 +09:00
8 changed files with 919 additions and 51 deletions

View File

@@ -7647,3 +7647,59 @@ Original filing (2026-04-18): the session emitted `SessionStart hook (completed)
739. **`claw skills <unknown-subcommand> --output-format json` emitted two JSON objects on stdout: first the usage envelope (`action:"help", unexpected:"X"`), then a second error abort envelope (`kind:"unknown", error:"skills command failed"`) — the `print_skills` JSON path returned `Err` on `status:"error"` responses even when the response was a normal usage-display (`action:"help"`), causing the generic error serializer to emit the second envelope** — dogfooded 2026-05-26 on `4c3cb0f3`. Fix: skip the `return Err` path when `action == "help"`; usage envelopes are informational, not fatal errors. The root prompt-dispatch gap (`claw skills bogus``CliAction::Prompt``missing_credentials` in no-creds env) is a pre-existing auth-gate-on-local-surface issue (ROADMAP #431/#449) and not addressed here. Source: Jobdori dogfood on `4c3cb0f3`, 2026-05-26.
740. **Test coverage gap for ROADMAP #733: `diff_json_has_status_and_result_field_702` did not assert `changed_file_count` contract** — dogfooded 2026-05-26 on `d5f0d6ed`. The test asserts `kind`, `status`, `result`, `action`, `working_directory` but not the new `changed_file_count` field added by #733. Coverage gap: (a) no assertion that the field exists, (b) no assertion of numeric type in git repos, (c) no regression guard for dedupe behavior (staged+unstaged to the same file = 1 changed file). Fix: extend the test to assert `changed_file_count: null` in non-git repos and `changed_file_count: u64` in git repos. Source: gaebal-gajae dogfood on `d5f0d6ed`, 2026-05-26.
741. **`claw config list`, `claw config show`, `claw config bogus` --output-format json returned `hint: null` — the unsupported_config_section error envelope had no `hint` field populated, so callers reading `.hint` get null with no actionable guidance** — dogfooded 2026-05-26 on `5d072d21`. The `render_config_json` unsupported-section branch returned a JSON object with `error` (contains the section list) but no `hint` field. Notably `config list` and `config show` are natural verb patterns that users type expecting a list/show subcommand, but claw config uses `claw config` (no args) for list and `claw config <section>` for show — the error gave no indication of this. Fix: add `hint` field to unsupported_config_section error; verbs (`list`, `show`, `help`, `info`) get a hint explaining the correct idiom (`claw config` / `claw config <section>`); other unknown sections get a "not a config section" hint listing valid values. Source: Jobdori dogfood on `5d072d21`, 2026-05-26.
742. **ROADMAP #740 test coverage gap: the new `changed_file_count` branch for git repos was unreachable — the fixture is a plain `unique_temp_dir` (no `git init`), so the test always exercises the `no_git_repo` path and never proves the numeric contract or deduplication behavior** — confirmed by gaebal-gajae on `5d072d21`, fixed on `6e78c1fc`. Fix: add `diff_json_changed_file_count_deduplication_733` test that (a) `git init`s a temp repo, (b) commits a file, (c) asserts `result:"clean"` + `changed_file_count:0`, (d) stages an edit + makes an unstaged edit to the same file, (e) asserts `result:"changes"` + `changed_file_count:1` — proving the BTreeSet deduplication actually works. Source: gaebal-gajae dogfood on `5d072d21`, 2026-05-26.
743. **`claw plugins help --output-format json` returned `error_kind:"unknown_plugins_action"` with `hint:null` instead of the usage envelope (`action:"help", status:"ok", unexpected:null, usage:{...}`) that `agents help`, `mcp help`, and `skills help` all emit — schema drift within the same command family (ROADMAP #420)** — dogfooded 2026-05-26 on `2036f0bd`. Fix: (a) added `Some("help" | "-h" | "--help")` arm to `handle_plugins_slash_command` returning a text usage message (text path parity); (b) added early-return JSON help envelope in `print_plugins` JSON path matching shape of agents/mcp help: `{action:"help", kind:"plugin", status:"ok", unexpected:null, usage:{direct_cli, slash_command}}`. Source: Jobdori dogfood on `2036f0bd`, 2026-05-26.
744. **ROADMAP #741 has no regression test: `claw config list/show/bogus --output-format json hint` field could silently regress to null** — confirmed by gaebal-gajae on `2036f0bd`. Pattern same as #736#737 and #740#742: implementation fix without a pinning test. Fix: add `config_unsupported_section_json_hint_741` test iterating `[list, show, bogus, help]` and asserting `kind:config`, `status:error`, `error_kind:unsupported_config_section`, `hint` is non-empty string, `supported_sections[]` is non-empty. Source: gaebal-gajae dogfood on `2036f0bd`, 2026-05-26.
745. **`claw issue --output-format json` and all other direct-CLI slash commands (pr, commit, etc.) returned `hint: null` — the `bare_slash_command_guidance` message strings had no `\n` separator between short error and remediation text, so `split_error_hint` couldn't populate the hint field** — dogfooded 2026-05-26 on `92e053a1`. The #738 fix added `\n` to the `--resume SESSION /cmd` path but missed the direct-CLI path (e.g. `claw issue`, `claw pr`). The `bare_slash_command_guidance` function formats two message variants: resume-supported and non-resume; both lacked `\n`. Fix: add `\n` before the remediation text in both format strings. Source: Jobdori dogfood on `92e053a1`, 2026-05-26.
746. **`claw --output-format json` (bare, no TTY, no prompt) returned `hint: null` — the non-TTY interactive-only guard error string had no `\n` separator, so `split_error_hint` couldn't extract the remediation text into `.hint`** — dogfooded 2026-05-26 on `3c5459a3`. The single-string message `"interactive_only: claw requires an interactive terminal (stdin is not a TTY and no prompt was provided \u2014 pipe a prompt or run in a TTY)"` contained the hint inline but no newline, so callers reading `.hint` got null and had to parse the prose `error` string. Fix: split at `\n` — short error `"interactive_only: claw requires an interactive terminal."` + hint `"Stdin is not a TTY…pipe a prompt with \`echo 'task' | claw\` or run \`claw\` in an interactive terminal."`. Source: Jobdori dogfood on `3c5459a3`, 2026-05-26.
747. **ROADMAP #745 has no regression test: `claw issue/pr/commit --output-format json hint` could silently regress to null** — confirmed by gaebal-gajae on `3c5459a33`. Same pattern as #737, #742, #744. Fix: add `bare_slash_command_hint_745` test iterating `issue`, `pr`, `commit` and asserting `error_kind:"interactive_only"` + non-empty `hint` field. Source: gaebal-gajae dogfood on `3c5459a33`, fixed on `18e7744e`, 2026-05-26.
748. **`claw mcp bogussubcmd --output-format json` returned `error_kind: null` when an unknown subcommand was passed — `render_mcp_usage_json(Some("bogus"))` set `status:"error"` but left `error_kind` absent — while `agents bogussubcmd` emits `error_kind:"unknown_agents_subcommand"`** — dogfooded 2026-05-26 on `04eb661e`. Fix: add `error_kind: "unknown_mcp_action"` to `render_mcp_usage_json` when `unexpected.is_some()`; remains `null` for the `help` path (`unexpected: null`). Source: Jobdori dogfood on `04eb661e`, 2026-05-26.
749. **`claw compact --output-format json` returned `hint: null``compact_interactive_only_error()` returned a single-line string with no `\n` between short error and remediation text, so `split_error_hint` couldn't populate the hint field** — identified by gaebal-gajae on `04eb661e`. Same class as #738 / #745 / #746. Fix: add `\n` before the remediation text in `compact_interactive_only_error`. Regression guard: extended `compact_subcommand_json_help_fails_fast_when_stdin_closed` to also assert `hint` is non-empty and mentions `/compact` or `--resume`. Source: gaebal-gajae dogfood on `04eb661e`, 2026-05-26.
750. **`claw prompt --output-format json` (no text argument) returned `error_kind:"unknown"` and `hint: null`** — dogfooded 2026-05-26 on `2dfb7af6`. The error string `"prompt subcommand requires a prompt string"` had no prefix prefix for classifier and no `\n` for hint extraction. Fix: (a) prefix with `"missing_prompt: "` + newline before usage hint; (b) add `message.starts_with("missing_prompt:")``"missing_prompt"` classifier arm. Result: `error_kind:"missing_prompt"`, `hint:"Usage: claw prompt <text> or echo '<text>' | claw"`. Source: Jobdori dogfood on `2dfb7af6`, 2026-05-26.
751. **ROADMAP #750 has no regression test: `claw prompt --output-format json` no-arg `error_kind` and `hint` could silently regress** — confirmed by gaebal-gajae on `ac925ed4`. Fix: add `prompt_no_arg_json_error_kind_750` test asserting nonzero exit, `error_kind:"missing_prompt"`, non-empty `hint` mentioning `claw prompt` or `echo`. Source: gaebal-gajae dogfood on `ac925ed4`, 2026-05-26.
752. **`claw <subcommand> --output-format json <bogus-arg>` returned `hint: null` for all `cli_parse` errors when an unrecognized positional arg was supplied** — dogfooded 2026-05-26 on `ddc71b56`. Generic `unrecognized argument` format string had no `\n` so `split_error_hint` emitted null hint (only the `--json` special-case added a hint). Fix: add else-branch appending `\nRun `claw <verb> --help` for usage.` to the generic arm. Affected surfaces: `sandbox`, `doctor`, `version`, and any other subcommand routing through the same unrecognized-arg path. Source: Jobdori dogfood on `ddc71b56`, 2026-05-26.
753. **`claw --output-format json -p` (no prompt arg) returned `error_kind:"unknown"` and `hint: null`** — parity gap with #750/#751 which fixed the explicit `prompt` verb. Identified by gaebal-gajae on `ddc71b56`. Fix: same `missing_prompt:` prefix + newline usage hint as #750. Regression guard: `short_p_flag_no_arg_json_error_kind_753` asserting nonzero exit, `error_kind:"missing_prompt"`, non-empty hint mentioning `claw -p` or `claw prompt`. Source: gaebal-gajae dogfood on `ddc71b56`, 2026-05-26.
754. **`missing_credentials` JSON envelope always had `hint: null` even when a contextual hint was available** — dogfooded 2026-05-26 on `e9327135`. `ApiError::Display` for `MissingCredentials` appended the hint via ` — hint: {hint}` (inline, no `\n`), so `split_error_hint()` could not extract it and left the JSON `hint` field null. Fix: change delimiter from ` — hint: ` to `\n` in `api/src/error.rs` Display impl; update two tests in `api/src/error.rs` and `api/src/providers/mod.rs` to assert newline separator. Source: Jobdori dogfood on `e9327135`, 2026-05-26.
755. **`claw -p hello --model sonnet` swallowed `--model sonnet` into the prompt string** — gaebal-gajae pinpoint on `e9327135` (#117 revival). `-p` used `args[index+1..].join(" ")`, consuming all remaining tokens as prompt. Fix: capture exactly one token via `args.get(index+1)`, reject flag-like tokens (`starts_with('-')`) as `missing_prompt`, support `--` sentinel for literal flag-text, then `continue` the flag loop so `--model`/`--output-format`/etc. parse normally. Dispatch via `short_p_prompt` after full flag scan. Regression guard: `short_p_flag_swallows_no_flags_755` asserts `--output-format json` is parsed (not swallowed) and `--model` as prompt-arg is rejected. Source: gaebal-gajae dogfood on `e9327135`, 2026-05-26.
756. **`--reasoning-effort bogus`, `--model` (no value), and sibling missing/invalid flag-value errors all returned `error_kind:"unknown"` + `hint:null`** — gaebal-gajae pinpoint on `0e8a449e`. All `missing value for --X` and `invalid value for --reasoning-effort` error strings were single-line with no classifier arm. Fix: (a) prefix all with `missing_flag_value:` / `invalid_flag_value:` + `\n` usage hint; (b) add `message.starts_with("missing_flag_value:")``"missing_flag_value"` and `message.starts_with("invalid_flag_value:")``"invalid_flag_value"` classifier arms. Covers `--model`, `--output-format`, `--permission-mode`, `--base-commit`, `--reasoning-effort`. Regression guard: `flag_value_errors_have_error_kind_and_hint_756` — invalid `--reasoning-effort HIGH``invalid_flag_value` + hint with valid values; missing `--model``missing_flag_value` + non-null hint. Source: gaebal-gajae dogfood on `0e8a449e`, 2026-05-26.
757. **`--permission-mode bogus` and `--allowedTools` (no value) returned `error_kind:"unknown"` + `hint:null`** — dogfooded 2026-05-26 on `4df14618`. `parse_permission_mode_arg()` error format had no prefix and no `\n`; `--allowedTools` missing-value string was plain. Fix: prefix `parse_permission_mode_arg` error with `invalid_flag_value:` + `\n` valid-values hint (both call sites); prefix `--allowedTools` missing-value with `missing_flag_value:` + `\n` usage hint. Both now classified by existing `missing_flag_value`/`invalid_flag_value` arms added in #756. Source: Jobdori dogfood on `4df14618`, 2026-05-26.
758. **Three remaining `missing value for --X` strings in `parse_init_args` were still untyped** — dogfooded 2026-05-26 on `02d77ae1`. `--cwd`, `--date`, `--session` missing-value errors in the init-args parser used the old plain-string form with no `missing_flag_value:` prefix and no `\n` hint, unlike the main `parse_args` flags fixed in #756/#757. Fix: applied `missing_flag_value:` prefix + `\n` usage hint to all three. `grep '"missing value for --'` now returns zero results outside of test assertions. Source: Jobdori dogfood sweep on `02d77ae1`, 2026-05-26.
759. **`--model badmodel --output-format json` returned `error_kind:"invalid_model_syntax"` but `hint: null`** — dogfooded 2026-05-26 on `b8b3af6f`. `validate_model_syntax()` had hint text embedded after a period in the error string (no `\n`), so `split_error_hint()` could not extract it. Affected paths: (a) generic invalid format `"invalid model syntax: '{}'. Expected ..."` — joined with `.` not `\n`; (b) spaces-in-model `"contains spaces. Use ..."` — same issue; (c) empty model string — no hint at all. Fix: added `\n` before hint text in all three format strings in `validate_model_syntax`. Source: Jobdori dogfood sweep on `b8b3af6f`, 2026-05-26.
760. **`agent_not_found` and `plugin_not_found` error envelopes lacked `hint` field** — dogfooded 2026-05-26 on `ef31328a`. `claw agents show nonexistent-agent --output-format json` returned `error_kind:"agent_not_found"` with `hint: null`; same for `claw plugins show`. Both structured JSON envelopes in `commands/src/lib.rs` and `main.rs` omitted `hint`. Fix: added `"hint": "Run \`claw agents list\` to see available agents."` to the `agent_not_found` envelope; `"hint": "Run \`claw plugins list\` to see available plugins."` to the `plugin_not_found` envelope. Source: Jobdori dogfood sweep on `ef31328a`, 2026-05-26.
761. **`mcp show <nonexistent>` and `skills show <nonexistent>` returned `hint: null`** — dogfooded 2026-05-27 on `7fa81b5d`. `server_not_found` envelope in `render_mcp_show_json` and `skill_not_found` envelope in `print_skills` JSON path both lacked `hint` fields, unlike `agent_not_found`/`plugin_not_found` fixed in #760. Fix: added `"hint": "Run \`claw mcp list\` to see configured servers."` to `server_not_found` and `"hint": "Run \`claw skills list\` to see available skills."` to `skill_not_found`. All four `*_not_found` envelopes now have hints. Source: Jobdori dogfood sweep on `7fa81b5d`, 2026-05-27.
762. **`classify_error_kind` unit test missing coverage for 15 of 23 classifier arms** — dogfooded 2026-05-27 on `d83de563`. `classify_error_kind_returns_correct_discriminants` only asserted 8 of the 23 arms, leaving `missing_flag_value`, `invalid_flag_value`, `missing_prompt`, `interactive_only`, `unknown_agents_subcommand`, `agent_not_found`, `plugin_not_found`, `skill_not_found`, `unsupported_config_section`, `no_managed_sessions`, `legacy_session_no_workspace_binding`, `missing_manifests`, `unknown_plugins_action`, `unsupported_skills_action`, and `confirmation_required` uncovered. Any discriminant string drift would silently fall to `"unknown"` without a failing test. Fix: added 18 new `assert_eq!` invocations covering all previously untested arms. Source: Jobdori test-brittleness sweep on `d83de563`, 2026-05-27.
763. **Config JSON parse errors fall to `error_kind:"unknown"`** — dogfooded 2026-05-27 on `88ce1810`. Malformed `.claw/settings.json` or `.claw.json` (unterminated string, type mismatch, unknown keys) produce serde_json errors like `"/path/.claw/settings.json: expected ',', found end of input"` but classify as `error_kind:"unknown"` + `hint:null`. Callers must regex the error message to route. Fix: added `config_parse_error` classifier arm that matches on presence of `.claw/settings.json` or `.claw.json` in the error message. All three error patterns now consistently produce `error_kind:"config_parse_error"`. Test coverage added. Source: Jobdori event/log opacity probe on `88ce1810`, 2026-05-27.
764. **`config_parse_error` returned `hint: null` despite #763 adding the classifier** — dogfooded 2026-05-27 on `c86dc73d`. #763 fixed `error_kind` classification but `hint` remained `null` because `ConfigError::Parse` Display impl emitted only the bare serde_json error string (no `\n` delimiter). `split_error_hint()` found nothing to split. Fix: updated `Display for ConfigError::Parse` in `runtime/src/config.rs` to append `\nFix: open the file shown above and correct the JSON syntax, then retry.`. Integration test `config_parse_error_has_typed_error_kind_and_hint_764` added to `output_format_contract.rs` asserting non-zero exit + `error_kind:config_parse_error` + non-empty hint. 31 contract tests pass. Source: Jobdori follow-up probe on `c86dc73d`, 2026-05-27.
765. **`claw login`/`claw logout` returned `error_kind:"unknown"` + `hint:null`** — dogfooded 2026-05-27 on `4ea255ca` (gaebal-gajae pinpoint against `88ce1810`, revised ID after #763/#764 landed). `removed_auth_surface_error()` emitted single-line string with no `\n` delimiter; `split_error_hint()` couldn't extract hint, and no `removed_subcommand` classifier arm existed. Fix: (1) `removed_auth_surface_error()` now emits two-line format (`has been removed.\nSet ANTHROPIC_API_KEY or ANTHROPIC_AUTH_TOKEN instead.`); (2) `classify_error_kind()` arm added matching `has been removed.`; (3) unit test assertions and integration test `login_logout_removed_subcommands_have_error_kind_and_hint_765` added verifying both `error_kind:removed_subcommand` and non-null hint mentioning the env var migration. 32 CLI contract tests pass. [SCOPE: claw-code] Source: Gaebal-gajae + Jobdori probe on `4ea255ca`, 2026-05-27.
766. **`claw diff <extra>` returned `error_kind:"unknown"` + `hint:null`** — dogfooded 2026-05-27 on `d29a8e21`. `claw diff --bogus --output-format json` emitted bare error string `"unexpected extra arguments after \`claw diff\`: --bogus"` with no `\n` delimiter and no classifier arm. Fix: (1) added `\nUsage: claw diff` to the error format string; (2) added `unexpected_extra_args` classifier arm matching `starts_with("unexpected extra arguments")`; (3) unit test assertion + integration test `diff_extra_args_have_typed_error_kind_and_hint_766` added. 33 CLI contract tests pass. [SCOPE: claw-code] Source: Jobdori probe on `d29a8e21`, 2026-05-27.
767. **`claw session bogus --output-format json` ignores JSON flag and falls through to credential check** — dogfooded 2026-05-27 on `d29a8e21`. `claw --output-format json session bogus` dispatches to the full interactive REPL runtime instead of rejecting `bogus` as an unknown session subcommand. Output is `error_kind:"missing_credentials"` rather than `error_kind:"unknown_session_subcommand"`. Root cause: `session` arg parser has no unknown-subcommand guard before dispatch; `bogus` is silently accepted as a session ID / switch target and reaches the credential-check gate. Fix needed: validate known session subcommands (`list`, `exists`, `switch`, `fork`, `delete`) before dispatch, return structured `unknown_session_subcommand` error for unrecognized tokens. [SCOPE: claw-code] Source: Jobdori probe on `d29a8e21`, 2026-05-27.
768. **`claw --resume latest compact` returned `error_kind:"unknown"` + `hint:null`** — dogfooded 2026-05-27 on `89735dbd` (gaebal-gajae pinpoint against `d29a8e21`, revised ID after #766/#767 landed). Resume trailing-arg validator emitted single-line `"--resume trailing arguments must be slash commands"` with no typed prefix and no `\n` hint. Fix: (1) changed error to `"invalid_resume_argument: \`{token}\` is not a slash command.\nUsage: claw --resume <session-id|latest> /<slash-command>"` so `split_error_hint()` extracts the hint; (2) added `invalid_resume_argument` classifier arm; (3) unit test assertion + integration test `resume_non_slash_trailing_arg_has_typed_error_kind_and_hint_768` added. 34 CLI contract tests pass. [SCOPE: claw-code] Source: Gaebal-gajae + Jobdori probe on `89735dbd`, 2026-05-27.

View File

@@ -273,7 +273,10 @@ impl Display for ApiError {
}
}
if let Some(hint) = hint {
write!(f, " — hint: {hint}")?;
// #754: newline-delimited so split_error_hint() can extract the hint
// into the JSON envelope's `hint` field. The em-dash form was a
// single-line string that left hint:null in --output-format json.
write!(f, "\n{hint}")?;
}
Ok(())
}
@@ -608,11 +611,16 @@ mod tests {
rendered.starts_with("missing Anthropic credentials;"),
"hint should be appended, not replace the base message: {rendered}"
);
let hint_marker = " — hint: I see OPENAI_API_KEY is set — if you meant to use the OpenAI-compat provider, prefix your model name with `openai/` so prefix routing selects it.";
// #754: hint is now newline-delimited so split_error_hint() can extract it
let hint_text = "I see OPENAI_API_KEY is set — if you meant to use the OpenAI-compat provider, prefix your model name with `openai/` so prefix routing selects it.";
assert!(
rendered.ends_with(hint_marker),
rendered.ends_with(hint_text),
"rendered error should end with the hint: {rendered}"
);
assert!(
rendered.contains('\n'),
"rendered error must contain newline separator so split_error_hint works: {rendered}"
);
// Classification semantics are unaffected by the presence of a hint.
assert_eq!(error.safe_failure_class(), "provider_auth");
assert!(!error.is_retryable());

View File

@@ -1649,10 +1649,15 @@ NO_EQUALS_LINE
rendered.starts_with("missing Anthropic credentials;"),
"canonical base message should still lead the rendered error: {rendered}"
);
// #754: hint delimiter changed from " — hint: " to "\n" so split_error_hint works
assert!(
rendered.contains(" — hint: I see OPENAI_API_KEY is set"),
rendered.contains("I see OPENAI_API_KEY is set"),
"rendered error should carry the env-driven hint: {rendered}"
);
assert!(
rendered.contains('\n'),
"rendered error must use newline separator (#754): {rendered}"
);
}
#[test]

View File

@@ -2334,6 +2334,13 @@ pub fn handle_plugins_slash_command(
reload_runtime: false,
})
}
// #743/#420: "help" was caught by Some(other) → unknown_plugins_action error with hint:null.
// agents/mcp/skills all return a help envelope; plugins must match that parity.
Some("help" | "-h" | "--help") => Ok(PluginsCommandResult {
message: "Plugins\n Usage /plugins [list|show <id>|install <id>|enable <id>|disable <id>|uninstall <id>|update <id>|help]\n Subcommands list show install enable disable uninstall update help"
.to_string(),
reload_runtime: false,
}),
Some(other) => Err(PluginError::CommandFailed(format!(
"unknown_plugins_action: '{other}' is not a supported /plugins action. Use list, show, install, enable, disable, uninstall, or update."
))),
@@ -2461,6 +2468,8 @@ pub fn handle_agents_slash_command_json(args: Option<&str>, cwd: &Path) -> std::
"requested": name,
// #734: parity with skills show which always emits a message field
"message": format!("agent '{}' not found", name),
// #760: hint so callers know how to enumerate available agents
"hint": "Run `claw agents list` to see available agents.",
}));
}
Ok(render_agents_report_json_with_action(cwd, &matched, "show"))
@@ -2612,6 +2621,8 @@ pub fn handle_skills_slash_command_json(args: Option<&str>, cwd: &Path) -> std::
"error_kind": "skill_not_found",
"message": format!("skill '{}' not found", name),
"requested": name,
// #761: hint so callers know how to enumerate available skills
"hint": "Run `claw skills list` to see available skills.",
}));
}
Ok(render_skills_report_json_with_action(&matched, "show"))
@@ -4047,6 +4058,8 @@ fn render_mcp_server_report_json(
"found": false,
"server_name": server_name,
"message": format!("server `{server_name}` is not configured"),
// #761: hint so callers know how to enumerate configured MCP servers
"hint": "Run `claw mcp list` to see configured servers.",
}),
}
}
@@ -4154,11 +4167,18 @@ fn render_mcp_usage(unexpected: Option<&str>) -> String {
}
fn render_mcp_usage_json(unexpected: Option<&str>) -> Value {
// #748: add error_kind when unexpected is set, matching agents/plugins unknown-subcommand shape.
let error_kind: Value = if unexpected.is_some() {
json!("unknown_mcp_action")
} else {
Value::Null
};
json!({
"kind": "mcp",
"action": "help",
"ok": unexpected.is_none(),
"status": if unexpected.is_some() { "error" } else { "ok" },
"error_kind": error_kind,
"usage": {
"slash_command": "/mcp [list|show <server>|help]",
"direct_cli": "claw mcp [list|show <server>|help]",

View File

@@ -217,7 +217,10 @@ impl Display for ConfigError {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
match self {
Self::Io(error) => write!(f, "{error}"),
Self::Parse(error) => write!(f, "{error}"),
Self::Parse(error) => write!(
f,
"{error}\nFix: open the file shown above and correct the JSON syntax, then retry."
),
}
}
}

View File

@@ -286,6 +286,10 @@ fn classify_error_kind(message: &str) -> &'static str {
"unsupported_skills_action"
} else if message.contains("unrecognized argument") || message.contains("unknown option") {
"cli_parse"
} else if message.starts_with("missing_flag_value:") {
"missing_flag_value"
} else if message.starts_with("invalid_flag_value:") {
"invalid_flag_value"
} else if message.contains("invalid model syntax") {
"invalid_model_syntax"
} else if message.contains("is not yet implemented") {
@@ -298,6 +302,9 @@ fn classify_error_kind(message: &str) -> &'static str {
"api_http_error"
} else if message.contains("mcpServers") {
"malformed_mcp_config"
} else if message.contains(".claw/settings.json") || message.contains(".claw.json") {
// #763: config file JSON parse / validation errors (e.g. unterminated string, type mismatch)
"config_parse_error"
} else if message.starts_with("empty prompt") {
"empty_prompt"
} else if message.starts_with("interactive_only:") || message.contains("stdin is not a TTY") {
@@ -316,6 +323,19 @@ fn classify_error_kind(message: &str) -> &'static str {
"unsupported_config_section"
} else if message.contains("unknown_plugins_action") {
"unknown_plugins_action"
} else if message.starts_with("missing_prompt:") {
"missing_prompt"
} else if message.contains("has been removed.") {
// #765: removed subcommands (login, logout) — hint contains migration guidance
"removed_subcommand"
} else if message.starts_with("unexpected extra arguments") {
// #766: extra positionals after commands that take no arguments (e.g. claw diff)
"unexpected_extra_args"
} else if message.starts_with("invalid_resume_argument:") {
// #768: --resume trailing arg is not a slash command
"invalid_resume_argument"
} else if message.starts_with("unknown_option:") {
"unknown_option"
} else if message.contains("is a slash command")
|| message.starts_with("interactive_only:")
// #735: "slash command /X is interactive-only" emitted by interactive-only guard
@@ -740,6 +760,9 @@ fn parse_args(args: &[String]) -> Result<CliAction, String> {
let mut base_commit: Option<String> = None;
let mut reasoning_effort: Option<String> = None;
let mut allow_broad_cwd = false;
// #755: -p prompt text captured as single token; remaining args continue
// flag parsing. None until `-p <text>` is seen.
let mut short_p_prompt: Option<String> = None;
let mut rest: Vec<String> = Vec::new();
let mut index = 0;
@@ -771,7 +794,7 @@ fn parse_args(args: &[String]) -> Result<CliAction, String> {
"--model" => {
let value = args
.get(index + 1)
.ok_or_else(|| "missing value for --model".to_string())?;
.ok_or_else(|| "missing_flag_value: missing value for --model.\nUsage: --model <provider/model> e.g. --model anthropic/claude-opus-4-7".to_string())?;
let resolved = resolve_model_alias_with_config(value);
debug!("Resolved --model '{}' -> '{}'", value, resolved);
validate_model_syntax(&resolved)?;
@@ -791,14 +814,14 @@ fn parse_args(args: &[String]) -> Result<CliAction, String> {
"--output-format" => {
let value = args
.get(index + 1)
.ok_or_else(|| "missing value for --output-format".to_string())?;
.ok_or_else(|| "missing_flag_value: missing value for --output-format.\nUsage: --output-format text or --output-format json".to_string())?;
output_format = CliOutputFormat::parse(value)?;
index += 2;
}
"--permission-mode" => {
let value = args
.get(index + 1)
.ok_or_else(|| "missing value for --permission-mode".to_string())?;
.ok_or_else(|| "missing_flag_value: missing value for --permission-mode.\nUsage: --permission-mode default|acceptEdits|bypassPermissions|dangerFullAccess".to_string())?;
permission_mode_override = Some(parse_permission_mode_arg(value)?);
index += 2;
}
@@ -821,7 +844,7 @@ fn parse_args(args: &[String]) -> Result<CliAction, String> {
"--base-commit" => {
let value = args
.get(index + 1)
.ok_or_else(|| "missing value for --base-commit".to_string())?;
.ok_or_else(|| "missing_flag_value: missing value for --base-commit.\nUsage: --base-commit <git-sha>".to_string())?;
base_commit = Some(value.clone());
index += 2;
}
@@ -832,10 +855,10 @@ fn parse_args(args: &[String]) -> Result<CliAction, String> {
"--reasoning-effort" => {
let value = args
.get(index + 1)
.ok_or_else(|| "missing value for --reasoning-effort".to_string())?;
.ok_or_else(|| "missing_flag_value: missing value for --reasoning-effort.\nUsage: --reasoning-effort low|medium|high".to_string())?;
if !matches!(value.as_str(), "low" | "medium" | "high") {
return Err(format!(
"invalid value for --reasoning-effort: '{value}'; must be low, medium, or high"
"invalid_flag_value: invalid value for --reasoning-effort: '{value}'.\nUsage: --reasoning-effort low|medium|high"
));
}
reasoning_effort = Some(value.clone());
@@ -845,7 +868,7 @@ fn parse_args(args: &[String]) -> Result<CliAction, String> {
let value = &flag[19..];
if !matches!(value, "low" | "medium" | "high") {
return Err(format!(
"invalid value for --reasoning-effort: '{value}'; must be low, medium, or high"
"invalid_flag_value: invalid value for --reasoning-effort: '{value}'.\nUsage: --reasoning-effort low|medium|high"
));
}
reasoning_effort = Some(value.to_string());
@@ -856,23 +879,40 @@ fn parse_args(args: &[String]) -> Result<CliAction, String> {
index += 1;
}
"-p" => {
// Claw Code compat: -p "prompt" = one-shot prompt
let prompt = args[index + 1..].join(" ");
if prompt.trim().is_empty() {
return Err("-p requires a prompt string".to_string());
// Claw Code compat: -p "prompt" = one-shot prompt.
// #755: consume exactly one token so subsequent flags like
// --model/--output-format are parsed normally instead of
// being swallowed into the prompt string (#117).
let next = args.get(index + 1).map(|s| s.as_str());
match next {
None | Some("") => {
return Err("missing_prompt: -p requires a prompt string.\nUsage: claw -p <text> or claw prompt <text>".to_string());
}
Some(tok) if tok.starts_with('-') && tok != "--" => {
// Looks like a flag, not a prompt. Reject so the user
// knows to quote the literal text or use `--`.
return Err(format!(
"missing_prompt: -p requires a prompt string before flags; got `{tok}`.\nUsage: claw -p <text> --model sonnet or claw -p -- {tok} (literal)"
));
}
Some(tok) => {
// `--` sentinel: skip it and take the token after as literal
let (prompt_text, skip) = if tok == "--" {
match args.get(index + 2) {
Some(t) => (t.as_str(), 3usize),
None => return Err("missing_prompt: -p -- requires a prompt string after `--`.\nUsage: claw -p -- <text>".to_string()),
}
} else {
(tok, 2usize)
};
if prompt_text.trim().is_empty() {
return Err("missing_prompt: -p requires a non-empty prompt string.\nUsage: claw -p <text> or claw prompt <text>".to_string());
}
short_p_prompt = Some(prompt_text.to_string());
index += skip;
continue;
}
}
return Ok(CliAction::Prompt {
prompt,
model: resolve_model_alias_with_config(&model),
output_format,
allowed_tools: normalize_allowed_tools(&allowed_tool_values)?,
permission_mode: permission_mode_override
.unwrap_or_else(default_permission_mode),
compact,
base_commit: base_commit.clone(),
reasoning_effort: reasoning_effort.clone(),
allow_broad_cwd,
});
}
"--print" => {
// Claw Code compat: --print makes output non-interactive
@@ -895,7 +935,7 @@ fn parse_args(args: &[String]) -> Result<CliAction, String> {
"--allowedTools" | "--allowed-tools" => {
let value = args
.get(index + 1)
.ok_or_else(|| "missing value for --allowedTools".to_string())?;
.ok_or_else(|| "missing_flag_value: missing value for --allowedTools.\nUsage: --allowedTools <tool-name> e.g. --allowedTools Bash".to_string())?;
allowed_tool_values.push(value.clone());
index += 2;
}
@@ -962,6 +1002,21 @@ fn parse_args(args: &[String]) -> Result<CliAction, String> {
let allowed_tools = normalize_allowed_tools(&allowed_tool_values)?;
// #755: -p consumed exactly one token; dispatch now that all flags are parsed
if let Some(prompt) = short_p_prompt {
return Ok(CliAction::Prompt {
prompt,
model: resolve_model_alias_with_config(&model),
output_format,
allowed_tools,
permission_mode: permission_mode_override.unwrap_or_else(default_permission_mode),
compact,
base_commit,
reasoning_effort,
allow_broad_cwd,
});
}
if rest.is_empty() {
let permission_mode = permission_mode_override.unwrap_or_else(default_permission_mode);
// When stdin is not a terminal (pipe/redirect) and no prompt is given on the
@@ -990,7 +1045,8 @@ fn parse_args(args: &[String]) -> Result<CliAction, String> {
// (#696: emit a typed error instead of hanging indefinitely)
// Skip this guard in test builds (parse_args tests run in non-TTY context).
#[cfg(not(test))]
return Err("interactive_only: claw requires an interactive terminal (stdin is not a TTY and no prompt was provided — pipe a prompt or run in a TTY)".into());
// #746: newline before remediation so split_error_hint populates hint field
return Err("interactive_only: claw requires an interactive terminal.\nStdin is not a TTY and no prompt was provided — pipe a prompt with `echo 'task' | claw` or run `claw` in an interactive terminal.".into());
}
return Ok(CliAction::Repl {
model,
@@ -1095,7 +1151,7 @@ fn parse_args(args: &[String]) -> Result<CliAction, String> {
"diff" => {
if rest.len() > 1 {
return Err(format!(
"unexpected extra arguments after `claw diff`: {}",
"unexpected extra arguments after `claw diff`: {}\nUsage: claw diff",
rest[1..].join(" ")
));
}
@@ -1146,7 +1202,8 @@ fn parse_args(args: &[String]) -> Result<CliAction, String> {
"prompt" => {
let prompt = rest[1..].join(" ");
if prompt.trim().is_empty() {
return Err("prompt subcommand requires a prompt string".to_string());
// #750: provide error_kind-compatible prefix + \n for hint extraction
return Err("missing_prompt: prompt subcommand requires a prompt string.\nUsage: claw prompt <text> or echo '<text>' | claw".to_string());
}
Ok(CliAction::Prompt {
prompt,
@@ -1322,6 +1379,9 @@ fn parse_single_word_command_alias(
// Hint at the correct flag so they don't have to re-read --help.
if rest[1] == "--json" {
msg.push_str("\nDid you mean `--output-format json`?");
} else {
// #752: generic fallback hint so cli_parse errors always have non-null hint
msg.push_str(&format!("\nRun `claw {} --help` for usage.", verb));
}
return Some(Err(msg));
}
@@ -1407,26 +1467,29 @@ fn bare_slash_command_guidance(command_name: &str) -> Option<String> {
let slash_command = slash_command_specs()
.iter()
.find(|spec| spec.name == command_name)?;
// #745: newline before remediation text so split_error_hint populates hint field
let guidance = if slash_command.resume_supported {
format!(
"`claw {command_name}` is a slash command. Use `claw --resume SESSION.jsonl /{command_name}` or start `claw` and run `/{command_name}`."
"`claw {command_name}` is a slash command.\nUse `claw --resume SESSION.jsonl /{command_name}` or start `claw` and run `/{command_name}`."
)
} else {
format!(
"`claw {command_name}` is a slash command. Start `claw` and run `/{command_name}` inside the REPL."
"`claw {command_name}` is a slash command.\nStart `claw` and run `/{command_name}` inside the REPL."
)
};
Some(guidance)
}
fn compact_interactive_only_error() -> String {
"interactive_only: `claw compact` is an interactive/session command. Start `claw` and run `/compact`, or use `claw --resume SESSION.jsonl /compact` to compact an existing session."
// #749: newline before remediation so split_error_hint populates hint field
"interactive_only: `claw compact` is an interactive/session command.\nStart `claw` and run `/compact`, or use `claw --resume SESSION.jsonl /compact` to compact an existing session."
.to_string()
}
fn removed_auth_surface_error(command_name: &str) -> String {
// #765: two-line format so split_error_hint() extracts hint into JSON envelope
format!(
"`claw {command_name}` has been removed. Set ANTHROPIC_API_KEY or ANTHROPIC_AUTH_TOKEN instead."
"`claw {command_name}` has been removed.\nSet ANTHROPIC_API_KEY or ANTHROPIC_AUTH_TOKEN instead."
)
}
@@ -1730,12 +1793,12 @@ fn resolve_model_alias_with_config(model: &str) -> String {
fn validate_model_syntax(model: &str) -> Result<(), String> {
let trimmed = model.trim();
if trimmed.is_empty() {
return Err("model string cannot be empty".to_string());
return Err("invalid model syntax: model string cannot be empty.\nUsage: --model <provider/model> e.g. --model anthropic/claude-opus-4-7".to_string());
}
// Check for spaces (malformed)
if trimmed.contains(' ') {
return Err(format!(
"invalid model syntax: '{}' contains spaces. Use provider/model format or known alias",
"invalid model syntax: '{}' contains spaces.\nUse provider/model format (e.g., anthropic/claude-opus-4-7) or a known alias.",
trimmed
));
}
@@ -1744,7 +1807,7 @@ fn validate_model_syntax(model: &str) -> Result<(), String> {
if parts.len() != 2 || parts[0].is_empty() || parts[1].is_empty() {
// #154: hint if the model looks like it belongs to a different provider
let mut err_msg = format!(
"invalid model syntax: '{}'. Expected provider/model (e.g., anthropic/claude-opus-4-6)",
"invalid model syntax: '{}'.\nExpected provider/model (e.g., anthropic/claude-opus-4-7)",
trimmed
);
if trimmed.starts_with("gpt-") || trimmed.starts_with("gpt_") {
@@ -1803,7 +1866,7 @@ fn parse_permission_mode_arg(value: &str) -> Result<PermissionMode, String> {
normalize_permission_mode(value)
.ok_or_else(|| {
format!(
"unsupported permission mode '{value}'. Use read-only, workspace-write, or danger-full-access."
"invalid_flag_value: unsupported permission mode '{value}'.\nUsage: --permission-mode read-only|workspace-write|danger-full-access"
)
})
.map(permission_mode_from_label)
@@ -1901,16 +1964,17 @@ fn parse_system_prompt_args(
while index < args.len() {
match args[index].as_str() {
"--cwd" => {
let value = args
.get(index + 1)
.ok_or_else(|| "missing value for --cwd".to_string())?;
let value = args.get(index + 1).ok_or_else(|| {
"missing_flag_value: missing value for --cwd.\nUsage: --cwd <path>".to_string()
})?;
cwd = PathBuf::from(value);
index += 2;
}
"--date" => {
let value = args
.get(index + 1)
.ok_or_else(|| "missing value for --date".to_string())?;
let value = args.get(index + 1).ok_or_else(|| {
"missing_flag_value: missing value for --date.\nUsage: --date <YYYY-MM-DD>"
.to_string()
})?;
date.clone_from(value);
index += 2;
}
@@ -1943,7 +2007,7 @@ fn parse_export_args(args: &[String], output_format: CliOutputFormat) -> Result<
"--session" => {
let value = args
.get(index + 1)
.ok_or_else(|| "missing value for --session".to_string())?;
.ok_or_else(|| "missing_flag_value: missing value for --session.\nUsage: --session <session-id>".to_string())?;
session_reference.clone_from(value);
index += 2;
}
@@ -1963,7 +2027,7 @@ fn parse_export_args(args: &[String], output_format: CliOutputFormat) -> Result<
index += 1;
}
other if other.starts_with('-') => {
return Err(format!("unknown export option: {other}"));
return Err(format!("unknown_option: unknown export option: {other}.\nRun `claw export --help` for usage."));
}
other if output_path.is_none() => {
output_path = Some(PathBuf::from(other));
@@ -2006,7 +2070,7 @@ fn parse_dump_manifests_args(
index += 1;
continue;
}
return Err(format!("unknown dump-manifests option: {arg}"));
return Err(format!("unknown_option: unknown dump-manifests option: {arg}.\nRun `claw dump-manifests --help` for usage."));
}
Ok(CliAction::DumpManifests {
@@ -2041,7 +2105,10 @@ fn parse_resume_args(args: &[String], output_format: CliOutputFormat) -> Result<
}
if current_command.is_empty() {
return Err("--resume trailing arguments must be slash commands".to_string());
// #768: typed prefix + \n hint so split_error_hint() extracts hint into JSON envelope
return Err(format!(
"invalid_resume_argument: `{token}` is not a slash command.\nUsage: claw --resume <session-id|latest> /<slash-command> (e.g. /compact, /status)"
));
}
current_command.push(' ');
@@ -5906,7 +5973,7 @@ impl LiveCli {
let normalized = normalize_permission_mode(&mode).ok_or_else(|| {
format!(
"unsupported permission mode '{mode}'. Use read-only, workspace-write, or danger-full-access."
"invalid_flag_value: unsupported permission mode '{mode}'.\nUsage: --permission-mode read-only|workspace-write|danger-full-access"
)
})?;
@@ -6108,6 +6175,23 @@ impl LiveCli {
CliOutputFormat::Text => println!("{}", payload.message),
CliOutputFormat::Json => {
let action_str = action.unwrap_or("list");
// #743/#420: plugins help must return a usage envelope matching agents/mcp/skills help shape.
if matches!(action_str, "help" | "-h" | "--help") {
let cwd_str = cwd.display().to_string();
let obj = json!({
"kind": "plugin",
"action": "help",
"status": "ok",
"unexpected": null,
"usage": {
"direct_cli": "claw plugins [list|show <id>|install <id>|enable <id>|disable <id>|uninstall <id>|update <id>|help]",
"slash_command": "/plugins [list|show <id>|install <id>|enable <id>|disable <id>|uninstall <id>|update <id>|help]",
},
"cwd": cwd_str,
});
println!("{}", serde_json::to_string_pretty(&obj)?);
return Ok(());
}
// For show/info/describe, filter to the named plugin (exact match).
// For list with a target, treat target as a substring filter.
let is_show_action = matches!(action_str, "show" | "info" | "describe");
@@ -6161,6 +6245,8 @@ impl LiveCli {
"requested": name,
// #734: parity with skills show which always emits a message field
"message": format!("plugin '{}' not found", name),
// #760: hint so callers know how to enumerate available plugins
"hint": "Run `claw plugins list` to see available plugins.",
});
println!("{}", serde_json::to_string_pretty(&obj)?);
return Ok(());
@@ -7791,6 +7877,17 @@ fn render_config_json(
"skills" => runtime_config.get("skills").map(|v| v.render()),
"agents" => runtime_config.get("agents").map(|v| v.render()),
other => {
// #741: populate hint field for unsupported section errors so callers reading
// .hint get actionable guidance instead of null
let hint = if matches!(other, "list" | "show" | "help" | "info") {
format!(
"'claw config {other}' is not a subcommand. To list all config: `claw config`. To inspect a section: `claw config <section>` where section is one of: env, hooks, model, plugins, mcp, sandbox, permissions, skills, agents."
)
} else {
format!(
"'{other}' is not a config section. Supported: env, hooks, model, plugins, mcp, sandbox, permissions, skills, agents."
)
};
return Ok(serde_json::json!({
"kind": "config",
"action": "show",
@@ -7799,6 +7896,7 @@ fn render_config_json(
"section": other,
"ok": false,
"error": format!("Unsupported config section '{other}'. Use: env, hooks, model, plugins, mcp, sandbox, permissions, skills, or agents."),
"hint": hint,
"supported_sections": ["env", "hooks", "model", "plugins", "mcp", "sandbox", "permissions", "skills", "agents"],
"cwd": cwd.display().to_string(),
"loaded_files": loaded_paths.len(),
@@ -12753,6 +12851,125 @@ mod tests {
classify_error_kind("something completely unknown"),
"unknown"
);
// #762: coverage for all classifier arms added since #77 — prevents silent fallback
// to "unknown" if discriminant strings drift.
assert_eq!(
classify_error_kind("Manifest source files are missing: /tmp/x"),
"missing_manifests"
);
assert_eq!(
classify_error_kind("no managed sessions found in /tmp"),
"no_managed_sessions"
);
assert_eq!(
classify_error_kind("legacy session is missing workspace binding"),
"legacy_session_no_workspace_binding"
);
assert_eq!(
classify_error_kind("unsupported skills action: bogus. Supported actions: list"),
"unsupported_skills_action"
);
assert_eq!(
classify_error_kind(
"missing_flag_value: missing value for --model.\nUsage: --model <provider/model>"
),
"missing_flag_value"
);
assert_eq!(
classify_error_kind("invalid_flag_value: unsupported permission mode 'bogus'.\nUsage: --permission-mode read-only|workspace-write|danger-full-access"),
"invalid_flag_value"
);
assert_eq!(
classify_error_kind("is not yet implemented"),
"unsupported_command"
);
assert_eq!(
classify_error_kind("confirmation required before running destructive operation"),
"confirmation_required"
);
assert_eq!(
classify_error_kind("api returned unexpected status 429"),
"api_http_error"
);
assert_eq!(
classify_error_kind("interactive_only: this command requires an interactive terminal"),
"interactive_only"
);
assert_eq!(
classify_error_kind("slash command /compact is interactive-only"),
"interactive_only"
);
assert_eq!(
classify_error_kind("unknown agents subcommand: bogus. Supported: list, show, help"),
"unknown_agents_subcommand"
);
assert_eq!(
classify_error_kind("agent not found: my-agent"),
"agent_not_found"
);
assert_eq!(
classify_error_kind("my-plugin is not installed"),
"plugin_not_found"
);
assert_eq!(
classify_error_kind("skill source /path/to/skill not found"),
"skill_not_found"
);
assert_eq!(
classify_error_kind("skill 'my-skill' does not exist"),
"skill_not_found"
);
assert_eq!(
classify_error_kind("Unsupported config section 'show'. Use: env, hooks, model"),
"unsupported_config_section"
);
assert_eq!(
classify_error_kind("unknown_plugins_action: bogus"),
"unknown_plugins_action"
);
assert_eq!(
classify_error_kind(
"missing_prompt: -p requires a prompt string.\nUsage: claw -p <text>"
),
"missing_prompt"
);
assert_eq!(
classify_error_kind("/tmp/.claw/settings.json: expected ',', found end of input"),
"config_parse_error"
);
assert_eq!(
classify_error_kind(
"/path/to/.claw.json: field \"model\" must be a string, got a number"
),
"config_parse_error"
);
// #765: removed auth subcommands must classify as removed_subcommand
assert_eq!(
classify_error_kind(
"`claw login` has been removed.\nSet ANTHROPIC_API_KEY or ANTHROPIC_AUTH_TOKEN instead."
),
"removed_subcommand"
);
// #766: unexpected extra arguments must classify as unexpected_extra_args
assert_eq!(
classify_error_kind(
"unexpected extra arguments after `claw diff`: --bogus\nUsage: claw diff"
),
"unexpected_extra_args"
);
assert_eq!(
classify_error_kind(
"`claw logout` has been removed.\nSet ANTHROPIC_API_KEY or ANTHROPIC_AUTH_TOKEN instead."
),
"removed_subcommand"
);
// #768: invalid resume trailing arg must classify as invalid_resume_argument
assert_eq!(
classify_error_kind(
"invalid_resume_argument: `compact` is not a slash command.\nUsage: claw --resume <session-id|latest> /<slash-command>"
),
"invalid_resume_argument"
);
}
#[test]

View File

@@ -283,6 +283,16 @@ fn compact_subcommand_json_help_fails_fast_when_stdin_closed() {
.contains("claw compact"),
"message should name compact: {parsed}"
);
// #749: hint must be non-empty (was null before fix — same class as #738/#745/#746)
let hint = parsed["hint"].as_str().unwrap_or("");
assert!(
!hint.is_empty(),
"compact interactive-only JSON must have non-empty hint (#749); got: {parsed}"
);
assert!(
hint.contains("/compact") || hint.contains("--resume"),
"hint should mention /compact or --resume: {hint}"
);
fs::remove_dir_all(&workspace).expect("workspace cleanup should succeed");
}

View File

@@ -1376,6 +1376,404 @@ fn diff_json_has_status_and_result_field_702() {
}
}
#[test]
fn diff_json_changed_file_count_deduplication_733() {
// #733/#742: changed_file_count must be numeric in a git repo, be 0 for clean,
// and deduplicate staged+unstaged edits to the same file (1 file changed = count 1).
use std::process::Command;
let root = unique_temp_dir("diff-changed-dedup");
fs::create_dir_all(&root).expect("temp dir");
// git init + identity config + initial commit
Command::new("git")
.args(["init"])
.current_dir(&root)
.output()
.expect("git init");
Command::new("git")
.args(["config", "user.email", "test@claw.test"])
.current_dir(&root)
.output()
.expect("git config email");
Command::new("git")
.args(["config", "user.name", "Test"])
.current_dir(&root)
.output()
.expect("git config name");
fs::write(root.join("tracked.txt"), b"v1").expect("write tracked");
Command::new("git")
.args(["add", "tracked.txt"])
.current_dir(&root)
.output()
.expect("git add");
Command::new("git")
.args(["commit", "-m", "init"])
.current_dir(&root)
.output()
.expect("git commit");
// Clean state: changed_file_count must be 0
let bin = env!("CARGO_BIN_EXE_claw");
let clean = Command::new(bin)
.current_dir(&root)
.args(["--output-format", "json", "diff"])
.output()
.expect("claw diff clean");
let clean_json: serde_json::Value =
serde_json::from_slice(&clean.stdout).expect("diff clean stdout must be valid JSON");
assert_eq!(clean_json["result"], "clean", "fresh repo must be clean");
assert_eq!(
clean_json["changed_file_count"].as_u64(),
Some(0),
"clean repo must have changed_file_count:0 (#733)"
);
// Make a staged edit AND an unstaged edit to the same file
fs::write(root.join("tracked.txt"), b"v2").expect("staged write");
Command::new("git")
.args(["add", "tracked.txt"])
.current_dir(&root)
.output()
.expect("git add staged");
fs::write(root.join("tracked.txt"), b"v3").expect("unstaged write");
// Dirty state: same file appears in staged+unstaged — must deduplicate to count 1
let dirty = Command::new(bin)
.current_dir(&root)
.args(["--output-format", "json", "diff"])
.output()
.expect("claw diff dirty");
let dirty_json: serde_json::Value =
serde_json::from_slice(&dirty.stdout).expect("diff dirty stdout must be valid JSON");
assert_eq!(
dirty_json["result"], "changes",
"dirty repo must have result:changes (#733)"
);
assert_eq!(
dirty_json["changed_file_count"].as_u64(),
Some(1),
"staged+unstaged edits to same file must deduplicate to changed_file_count:1 (#733)"
);
}
#[test]
fn prompt_no_arg_json_error_kind_750() {
// #751/#750: `claw prompt --output-format json` with no prompt argument must emit
// error_kind:"missing_prompt" and a non-empty hint. Before #750 it returned
// error_kind:"unknown" + hint:null.
use std::process::Command;
let root = unique_temp_dir("prompt-no-arg");
fs::create_dir_all(&root).expect("temp dir");
let bin = env!("CARGO_BIN_EXE_claw");
let output = Command::new(bin)
.current_dir(&root)
.args(["--output-format", "json", "prompt"])
.output()
.expect("claw prompt should run");
assert!(
!output.status.success(),
"claw prompt with no arg must exit non-zero"
);
let stdout = String::from_utf8_lossy(&output.stdout);
let stderr = String::from_utf8_lossy(&output.stderr)
.lines()
.filter(|l| l.starts_with('{'))
.collect::<Vec<_>>()
.join("");
let raw = if stdout.trim().starts_with('{') {
stdout.trim().to_string()
} else {
stderr
};
let parsed: serde_json::Value = serde_json::from_str(&raw).unwrap_or_else(|_| {
panic!("claw prompt (no arg) --output-format json must emit valid JSON; got: {raw}")
});
assert_eq!(
parsed["error_kind"], "missing_prompt",
"claw prompt no-arg must have error_kind:missing_prompt (#750); got: {parsed}"
);
let hint = parsed["hint"].as_str().unwrap_or("");
assert!(
!hint.is_empty(),
"claw prompt no-arg hint must be non-empty (#750)"
);
assert!(
hint.contains("claw prompt") || hint.contains("echo"),
"hint should mention 'claw prompt' or 'echo': {hint}"
);
}
#[test]
fn flag_value_errors_have_error_kind_and_hint_756() {
// #756: missing/invalid flag-value errors must emit typed error_kind + non-null hint.
// Before #756: all returned error_kind:"unknown" + hint:null.
use std::process::Command;
let root = unique_temp_dir("flag-value-errors");
fs::create_dir_all(&root).expect("temp dir");
let bin = env!("CARGO_BIN_EXE_claw");
// Case 1: --reasoning-effort with invalid value
let out = Command::new(bin)
.current_dir(&root)
.args(["--output-format", "json", "--reasoning-effort", "HIGH"])
.output()
.expect("claw --reasoning-effort HIGH should run");
assert!(
!out.status.success(),
"invalid reasoning-effort must exit non-zero"
);
let raw = String::from_utf8_lossy(&out.stderr)
.lines()
.filter(|l| l.starts_with('{'))
.collect::<Vec<_>>()
.join("");
let parsed: serde_json::Value = serde_json::from_str(&raw)
.unwrap_or_else(|_| panic!("invalid --reasoning-effort must emit JSON; got: {raw}"));
assert_eq!(
parsed["error_kind"], "invalid_flag_value",
"invalid --reasoning-effort must be invalid_flag_value (#756): {parsed}"
);
assert!(
parsed["hint"].as_str().map_or(false, |h| h.contains("low")
|| h.contains("medium")
|| h.contains("high")),
"hint must mention valid values (#756): {parsed}"
);
// Case 2: --model flag with missing value (trailing flag)
let out2 = Command::new(bin)
.current_dir(&root)
.args(["--output-format", "json", "--model"])
.output()
.expect("claw --model (no value) should run");
assert!(
!out2.status.success(),
"missing --model value must exit non-zero"
);
let raw2 = String::from_utf8_lossy(&out2.stderr)
.lines()
.filter(|l| l.starts_with('{'))
.collect::<Vec<_>>()
.join("");
let parsed2: serde_json::Value = serde_json::from_str(&raw2)
.unwrap_or_else(|_| panic!("missing --model value must emit JSON; got: {raw2}"));
assert_eq!(
parsed2["error_kind"], "missing_flag_value",
"missing --model value must be missing_flag_value (#756): {parsed2}"
);
assert!(
parsed2["hint"].as_str().map_or(false, |h| !h.is_empty()),
"missing --model hint must be non-empty (#756): {parsed2}"
);
}
#[test]
fn short_p_flag_swallows_no_flags_755() {
// #755: `claw -p hello --output-format json` must parse --output-format json
// as a flag rather than swallowing it as part of the prompt. Before #755,
// args[index+1..].join(" ") consumed all remaining tokens into the prompt.
// After #755, -p consumes exactly one token and remaining flags are parsed.
// We verify by checking that the envelope IS JSON (meaning --output-format json
// was interpreted as a flag, not literal prompt text).
use std::process::Command;
let root = unique_temp_dir("short-p-flags");
fs::create_dir_all(&root).expect("temp dir");
let bin = env!("CARGO_BIN_EXE_claw");
// -p hello --output-format json: with no credentials, should fail with
// missing_credentials (not missing_prompt), proving --output-format json was parsed.
let output = Command::new(bin)
.current_dir(&root)
.args(["-p", "hello", "--output-format", "json"])
.env_remove("ANTHROPIC_API_KEY")
.env_remove("ANTHROPIC_AUTH_TOKEN")
.output()
.expect("claw -p should run");
assert!(
!output.status.success(),
"claw -p hello --output-format json must exit non-zero (no credentials)"
);
let raw = String::from_utf8_lossy(&output.stderr)
.lines()
.filter(|l| l.starts_with('{'))
.collect::<Vec<_>>()
.join("");
// Must be valid JSON (i.e. --output-format json was parsed, not swallowed)
let parsed: serde_json::Value = serde_json::from_str(&raw).unwrap_or_else(|_| {
panic!("--output-format json must be parsed as a flag, not prompt text; stderr: {raw}")
});
assert_eq!(
parsed["error_kind"], "missing_credentials",
"flags after -p prompt text must be parsed normally (#755); got: {parsed}"
);
// Also verify -p --model bogus is rejected as missing_prompt (flag-as-prompt guard)
let output2 = Command::new(bin)
.current_dir(&root)
.args(["--output-format", "json", "-p", "--model", "sonnet"])
.output()
.expect("claw -p flag-as-prompt should run");
let raw2 = String::from_utf8_lossy(&output2.stderr)
.lines()
.filter(|l| l.starts_with('{'))
.collect::<Vec<_>>()
.join("");
let parsed2: serde_json::Value = serde_json::from_str(&raw2)
.unwrap_or_else(|_| panic!("claw -p --model must emit JSON; got: {raw2}"));
assert_eq!(
parsed2["error_kind"], "missing_prompt",
"flag-like token after -p must be rejected as missing_prompt (#755): {parsed2}"
);
assert!(
parsed2["hint"].as_str().map_or(false, |h| !h.is_empty()),
"missing_prompt hint must be non-empty (#755)"
);
}
#[test]
fn short_p_flag_no_arg_json_error_kind_753() {
// #753: `claw --output-format json -p` (no prompt) must emit error_kind:"missing_prompt"
// and non-empty hint. Before #753 it returned error_kind:"unknown" + hint:null.
// Parity with #750 which fixed the explicit `prompt` verb.
use std::process::Command;
let root = unique_temp_dir("short-p-no-arg");
fs::create_dir_all(&root).expect("temp dir");
let bin = env!("CARGO_BIN_EXE_claw");
let output = Command::new(bin)
.current_dir(&root)
.args(["--output-format", "json", "-p"])
.output()
.expect("claw -p should run");
assert!(
!output.status.success(),
"claw -p with no arg must exit non-zero"
);
let stdout = String::from_utf8_lossy(&output.stdout);
let raw = if stdout.trim().starts_with('{') {
stdout.trim().to_string()
} else {
String::from_utf8_lossy(&output.stderr)
.lines()
.filter(|l| l.starts_with('{'))
.collect::<Vec<_>>()
.join("")
};
let parsed: serde_json::Value = serde_json::from_str(&raw).unwrap_or_else(|_| {
panic!("claw -p (no arg) --output-format json must emit valid JSON; got: {raw}")
});
assert_eq!(
parsed["error_kind"], "missing_prompt",
"claw -p no-arg must have error_kind:missing_prompt (#753); got: {parsed}"
);
let hint = parsed["hint"].as_str().unwrap_or("");
assert!(
!hint.is_empty(),
"claw -p no-arg hint must be non-empty (#753)"
);
assert!(
hint.contains("claw -p") || hint.contains("claw prompt"),
"hint should mention 'claw -p' or 'claw prompt': {hint}"
);
}
#[test]
fn bare_slash_command_hint_745() {
// #747/#745: claw <slash-cmd> --output-format json must return non-null hint.
// bare_slash_command_guidance() previously had no \n so split_error_hint returned hint:null.
use std::process::Command;
let root = unique_temp_dir("bare-slash-hint");
fs::create_dir_all(&root).expect("temp dir");
let bin = env!("CARGO_BIN_EXE_claw");
// issue and pr are non-resume-supported; commit is resume-supported.
// All must emit non-null hint in their interactive_only error envelope.
for cmd in &["issue", "pr", "commit"] {
let output = Command::new(bin)
.current_dir(&root)
.args(["--output-format", "json", cmd])
.env("ANTHROPIC_API_KEY", "test")
.output()
.expect("claw should run");
assert!(
!output.status.success(),
"claw {cmd} outside REPL must exit non-zero"
);
// Error envelope is on stderr (type:error path) or stdout
let stderr = String::from_utf8_lossy(&output.stderr)
.lines()
.filter(|l| l.starts_with('{'))
.collect::<Vec<_>>()
.join("");
let stdout = String::from_utf8_lossy(&output.stdout);
let raw = if !stderr.is_empty() {
stderr
} else {
stdout.trim().to_string()
};
let parsed: serde_json::Value = serde_json::from_str(&raw)
.unwrap_or_else(|_| panic!("claw {cmd} must emit JSON; got: {raw}"));
assert_eq!(
parsed["error_kind"], "interactive_only",
"claw {cmd} must have error_kind:interactive_only (#745)"
);
let hint = parsed["hint"].as_str().unwrap_or("");
assert!(
!hint.is_empty(),
"claw {cmd} --output-format json hint must be non-empty (#745); got null"
);
}
}
#[test]
fn config_unsupported_section_json_hint_741() {
// #744/#741: claw config <unknown-section> --output-format json must return
// error_kind:unsupported_config_section with a non-null hint and supported_sections[].
// This is the regression guard for #741 (hint was null before fix).
use std::process::Command;
let root = unique_temp_dir("config-unsupported-section");
fs::create_dir_all(&root).expect("temp dir");
let bin = env!("CARGO_BIN_EXE_claw");
for section in &["list", "show", "bogus", "help"] {
let output = Command::new(bin)
.current_dir(&root)
.args(["--output-format", "json", "config", section])
.output()
.expect("claw config should run");
let stdout = String::from_utf8_lossy(&output.stdout);
let parsed: serde_json::Value = serde_json::from_str(stdout.trim()).unwrap_or_else(|_| {
panic!("claw config {section} --output-format json must emit valid JSON; got: {stdout}")
});
assert_eq!(
parsed["kind"], "config",
"config {section} JSON must have kind:config (#741)"
);
assert_eq!(
parsed["status"], "error",
"config {section} must return status:error (#741)"
);
assert_eq!(
parsed["error_kind"], "unsupported_config_section",
"config {section} must return error_kind:unsupported_config_section (#741)"
);
// #741: hint must be a non-empty string (was null before fix)
let hint = parsed["hint"].as_str().unwrap_or("");
assert!(
!hint.is_empty(),
"config {section} --output-format json hint must be non-empty (#741)"
);
// supported_sections must still be present and non-empty
assert!(
parsed["supported_sections"]
.as_array()
.map_or(false, |a| !a.is_empty()),
"config {section} JSON must include supported_sections (#741)"
);
}
}
#[test]
fn export_json_has_kind_702() {
// #458/#702: `claw export --output-format json` must emit kind:export.
@@ -1431,3 +1829,154 @@ fn export_json_has_kind_702() {
);
}
}
#[test]
fn config_parse_error_has_typed_error_kind_and_hint_764() {
// #764: Malformed .claw/settings.json must emit error_kind:config_parse_error
// and a non-null hint in --output-format json mode (was error_kind:"unknown"
// + hint:null before #763/#764 fixes).
let root = unique_temp_dir("config-parse-error-764");
fs::create_dir_all(root.join(".claw")).expect("temp .claw dir should exist");
// Write an invalid JSON file (type mismatch: model must be a string)
fs::write(root.join(".claw").join("settings.json"), r#"{"model": 99}"#)
.expect("settings.json should write");
let output = run_claw(&root, &["--output-format", "json", "config", "show"], &[]);
assert!(
!output.status.success(),
"malformed settings.json should cause non-zero exit"
);
let stderr = String::from_utf8_lossy(&output.stderr);
let json_line = stderr
.lines()
.find(|l| l.trim_start().starts_with('{'))
.expect("stderr should contain a JSON error envelope");
let parsed: serde_json::Value =
serde_json::from_str(json_line).expect("error envelope should be valid JSON");
assert_eq!(
parsed["error_kind"], "config_parse_error",
"malformed settings.json must return error_kind:config_parse_error (#763)"
);
let hint = parsed["hint"].as_str().unwrap_or("");
assert!(
!hint.is_empty(),
"malformed settings.json must return non-null hint (#764), got: {hint:?}"
);
}
#[test]
fn login_logout_removed_subcommands_have_error_kind_and_hint_765() {
// #765: `claw login` and `claw logout` are removed; JSON envelope must carry
// error_kind:removed_subcommand + non-null hint pointing to the env var migration.
// Before fix: single-line error string → error_kind:"unknown" + hint:null.
let root = unique_temp_dir("login-logout-removed-765");
fs::create_dir_all(&root).expect("temp dir should exist");
for subcmd in &["login", "logout"] {
let output = run_claw(&root, &["--output-format", "json", subcmd], &[]);
assert!(
!output.status.success(),
"claw {subcmd} should exit non-zero"
);
let stderr = String::from_utf8_lossy(&output.stderr);
let json_line = stderr
.lines()
.find(|l| l.trim_start().starts_with('{'))
.unwrap_or_else(|| panic!("claw {subcmd} stderr should contain a JSON envelope"));
let parsed: serde_json::Value =
serde_json::from_str(json_line).expect("error envelope should be valid JSON");
assert_eq!(
parsed["error_kind"], "removed_subcommand",
"claw {subcmd} must return error_kind:removed_subcommand (#765)"
);
let hint = parsed["hint"].as_str().unwrap_or("");
assert!(
!hint.is_empty(),
"claw {subcmd} must return non-null hint (#765), got: {hint:?}"
);
assert!(
hint.contains("ANTHROPIC_API_KEY") || hint.contains("ANTHROPIC_AUTH_TOKEN"),
"claw {subcmd} hint must mention the env var migration path, got: {hint:?}"
);
}
}
#[test]
fn diff_extra_args_have_typed_error_kind_and_hint_766() {
// #766: `claw diff --bogus` returned error_kind:"unknown" + hint:null.
// `diff` takes no arguments; extra args were unclassified with no remediation.
let root = unique_temp_dir("diff-extra-args-766");
fs::create_dir_all(&root).expect("temp dir should exist");
// Need a git repo for diff to parse past arg validation
std::process::Command::new("git")
.args(["init", "-q"])
.current_dir(&root)
.output()
.ok();
let output = run_claw(&root, &["--output-format", "json", "diff", "--bogus"], &[]);
assert!(
!output.status.success(),
"claw diff --bogus should exit non-zero"
);
let stderr = String::from_utf8_lossy(&output.stderr);
let json_line = stderr
.lines()
.find(|l| l.trim_start().starts_with('{'))
.expect("stderr should contain a JSON error envelope");
let parsed: serde_json::Value =
serde_json::from_str(json_line).expect("error envelope should be valid JSON");
assert_eq!(
parsed["error_kind"], "unexpected_extra_args",
"claw diff --bogus must return error_kind:unexpected_extra_args (#766)"
);
let hint = parsed["hint"].as_str().unwrap_or("");
assert!(
!hint.is_empty(),
"claw diff --bogus must return non-null hint (#766), got: {hint:?}"
);
}
#[test]
fn resume_non_slash_trailing_arg_has_typed_error_kind_and_hint_768() {
// #768: `claw --resume latest compact` (missing leading /) returned
// error_kind:"unknown" + hint:null. Resume is orchestration-critical;
// wrappers need a machine-readable signal with a recovery hint.
let root = unique_temp_dir("resume-invalid-arg-768");
fs::create_dir_all(&root).expect("temp dir should exist");
let output = run_claw(
&root,
&["--output-format", "json", "--resume", "latest", "compact"],
&[],
);
assert!(
!output.status.success(),
"claw --resume latest compact should exit non-zero"
);
let stderr = String::from_utf8_lossy(&output.stderr);
let json_line = stderr
.lines()
.find(|l| l.trim_start().starts_with('{'))
.expect("stderr should contain a JSON error envelope");
let parsed: serde_json::Value =
serde_json::from_str(json_line).expect("error envelope should be valid JSON");
assert_eq!(
parsed["error_kind"], "invalid_resume_argument",
"non-slash resume trailing arg must return error_kind:invalid_resume_argument (#768)"
);
let hint = parsed["hint"].as_str().unwrap_or("");
assert!(
!hint.is_empty(),
"non-slash resume trailing arg must return non-null hint (#768), got: {hint:?}"
);
assert!(
hint.contains("/compact") || hint.contains("slash-command"),
"hint must reference slash-command usage, got: {hint:?}"
);
}