Skip to content

Commit e020303

Browse files
committed
fix(#777): resumed /plugins mutations return interactive_only error_kind + non-null hint instead of unknown+null
1 parent 2684737 commit e020303

3 files changed

Lines changed: 69 additions & 5 deletions

File tree

ROADMAP.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7719,3 +7719,5 @@ Original filing (2026-04-18): the session emitted `SessionStart hook (completed)
77197719
775. **Missing integration tests for #769-#771 interactive-only guards and #774 hint fields** — dogfooded 2026-05-27 on `c760a49c`. Fixes #769-#771 (session/cost/clear/memory/ultraplan/model/usage/stats/fork interactive-only guards) and #774 (agents/plugins/mcp unknown-subcommand hints) had no integration tests — a regression in any of those 10+ match arms would go undetected. Also: classify_error_kind unit test for `unknown_agents_subcommand` used the old single-line format string, not the `\n`-delimited format emitted after #774. Fixed: (1) updated unit test string to match new `\n`-delimited emission; (2) added `agents_plugins_mcp_unknown_subcommand_have_hint_774` asserting `error_kind` + non-null `hint` for all three; (3) added `interactive_only_guard_batch_769_to_771` asserting `interactive_only` + non-null `hint` for 10 cases. 38 CLI contract tests pass. [SCOPE: claw-code] Source: Jobdori test-coverage sweep on `c760a49c`, 2026-05-27.
77207720

77217721
776. **Resume-mode JSON errors had opaque `error_kind:"resume_command_error"` + `hint:null`** — dogfooded 2026-05-27 on `028998d0` (pinpoint identified by Gaebal-gajae). `run_resume_command` returned errors (e.g. from `parse_history_count`) with hardcoded `error_kind:"resume_command_error"` and the full error string in `error` with no hint extraction. Wrappers had to regex prose instead of switching on typed fields. Three co-located gaps fixed: (1) `resume_session` JSON error path now applies `classify_error_kind` + `split_error_hint` so errors get specific `error_kind` (e.g. `invalid_history_count`) and non-null `hint`; (2) `parse_history_count` errors now use `invalid_history_count:` prefix + `\n` usage hint; (3) `/session exists|delete|switch|fork` missing-arg and unsupported-action errors now use `\n`-delimited format with `unsupported_resumed_command:` prefix. Existing test updated to match new error message format. 38 CLI contract tests pass. [SCOPE: claw-code] Source: Gaebal-gajae pinpoint + Jobdori implementation on `028998d0`, 2026-05-27.
7722+
7723+
777. **Resumed `/plugins install|enable|disable|uninstall|update` returned opaque error_kind instead of interactive_only** — dogfooded 2026-05-27 on `2684737d` (pinpoint by Gaebal-gajae). The mutation arm in `run_resume_command` returned a bare single-line error; after #776 it was classified/split by the caller but fell to `error_kind:"unknown"` + `hint:null` because there was no `interactive_only:` prefix. Orchestrators had no stable signal to distinguish "command rejected — switch to REPL" from a transient error. Fix: each mutation verb now returns `interactive_only: /plugins {action} requires a live session...\n...hint...` so the caller emits `error_kind:"interactive_only"` + non-null hint pointing at REPL or direct CLI. Integration test `resume_plugin_mutations_are_typed_interactive_only_777` covers all 5 mutation verbs. 39 CLI contract tests pass. [SCOPE: claw-code] Source: Gaebal-gajae pinpoint + Jobdori implementation on `2684737d`, 2026-05-27.

rust/crates/rusty-claude-cli/src/main.rs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4475,11 +4475,13 @@ fn run_resume_command(
44754475
SlashCommand::Plugins { action, target } => {
44764476
// Only list is supported in resume mode (no runtime to reload)
44774477
match action.as_deref() {
4478-
Some("install") | Some("uninstall") | Some("enable") | Some("disable")
4479-
| Some("update") => {
4480-
return Err(
4481-
"resumed /plugins mutations are interactive-only; start `claw` and run `/plugins` in the REPL".into(),
4482-
);
4478+
Some(action @ ("install" | "uninstall" | "enable" | "disable" | "update")) => {
4479+
// #777: use interactive_only: prefix + \n hint so #776's classify/split
4480+
// emits error_kind:interactive_only + non-null hint instead of unknown+null.
4481+
// Orchestrators can now detect this and switch to a live REPL instead of retrying.
4482+
return Err(format!(
4483+
"interactive_only: /plugins {action} requires a live session to reload the plugin runtime.\nStart `claw` and run `/plugins {action}` inside the REPL, or use `claw plugins {action}` as a direct CLI command."
4484+
).into());
44834485
}
44844486
_ => {}
44854487
}

rust/crates/rusty-claude-cli/tests/output_format_contract.rs

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2215,3 +2215,63 @@ fn interactive_only_guard_batch_769_to_771() {
22152215
);
22162216
}
22172217
}
2218+
2219+
#[test]
2220+
fn resume_plugin_mutations_are_typed_interactive_only_777() {
2221+
// #777: `/plugins install|enable|disable|uninstall|update` in resume mode returned
2222+
// a generic single-line error; after #776's classify/split it fell to
2223+
// error_kind:"unknown" + hint:null because there was no interactive_only: prefix.
2224+
// Fix: each mutation arm now returns "interactive_only: ... \n..." so the caller
2225+
// gets error_kind:interactive_only + non-null hint pointing at live REPL.
2226+
let root = unique_temp_dir("resume-plugin-mutations-777");
2227+
fs::create_dir_all(&root).expect("temp dir should exist");
2228+
std::process::Command::new("git")
2229+
.args(["init", "-q"])
2230+
.current_dir(&root)
2231+
.output()
2232+
.ok();
2233+
2234+
// Create a minimal session file so we get past session load and into command dispatch
2235+
let session_file = write_session_fixture(&root, "resume-plugin-777", None);
2236+
2237+
for mutation in &["install", "enable", "disable", "uninstall", "update"] {
2238+
let cmd = format!("/plugins {mutation} my-plugin");
2239+
let output = run_claw(
2240+
&root,
2241+
&[
2242+
"--resume",
2243+
session_file.to_str().unwrap(),
2244+
"--output-format",
2245+
"json",
2246+
&cmd,
2247+
],
2248+
&[],
2249+
);
2250+
assert!(
2251+
!output.status.success(),
2252+
"/plugins {mutation} in resume mode should exit non-zero"
2253+
);
2254+
let stderr = String::from_utf8_lossy(&output.stderr);
2255+
let json_line = stderr
2256+
.lines()
2257+
.find(|l| l.trim_start().starts_with('{'))
2258+
.unwrap_or_else(|| {
2259+
panic!("/plugins {mutation} should emit JSON error, got stderr: {stderr}")
2260+
});
2261+
let parsed: serde_json::Value = serde_json::from_str(json_line).unwrap();
2262+
assert_eq!(
2263+
parsed["error_kind"], "interactive_only",
2264+
"/plugins {mutation} must return interactive_only, got {:?}",
2265+
parsed["error_kind"]
2266+
);
2267+
let hint = parsed["hint"].as_str().unwrap_or("");
2268+
assert!(
2269+
!hint.is_empty(),
2270+
"/plugins {mutation} must have non-null hint (#777)"
2271+
);
2272+
assert!(
2273+
hint.contains("claw") || hint.contains("REPL") || hint.contains("plugins"),
2274+
"/plugins {mutation} hint must reference live session or CLI, got: {hint:?}"
2275+
);
2276+
}
2277+
}

0 commit comments

Comments
 (0)