mirror of
https://github.com/instructkr/claude-code.git
synced 2026-05-28 16:36:45 +00:00
fix(#710): diff --output-format json adds missing action:diff and working_directory fields to both ok and error branches
This commit is contained in:
@@ -7585,3 +7585,5 @@ Original filing (2026-04-18): the session emitted `SessionStart hook (completed)
|
|||||||
708. **`claw skills show <name> --output-format json` returns `action:"list"` even on the show path — `render_skills_report_json` hardcoded `"action":"list"` for all skill responses including show/info/describe** — dogfooded 2026-05-26 on `26a50d91`. `claw skills show korea-weather --output-format json` returned `{action:"list"}` even when the show path was taken. Also had duplicate `"status":"ok"` key in the JSON object. Fix: renamed `render_skills_report_json` to `render_skills_report_json_with_action(skills, action)` and updated all call sites to pass `"list"` or `"show"` appropriately; removed duplicate status key. Source: Jobdori dogfood on `26a50d91`, 2026-05-26.
|
708. **`claw skills show <name> --output-format json` returns `action:"list"` even on the show path — `render_skills_report_json` hardcoded `"action":"list"` for all skill responses including show/info/describe** — dogfooded 2026-05-26 on `26a50d91`. `claw skills show korea-weather --output-format json` returned `{action:"list"}` even when the show path was taken. Also had duplicate `"status":"ok"` key in the JSON object. Fix: renamed `render_skills_report_json` to `render_skills_report_json_with_action(skills, action)` and updated all call sites to pass `"list"` or `"show"` appropriately; removed duplicate status key. Source: Jobdori dogfood on `26a50d91`, 2026-05-26.
|
||||||
|
|
||||||
709. **`render_agents_report_json` and `render_skill_install_report_json` in `commands/src/lib.rs` contained duplicate `"status":"ok"` keys in the same JSON object literal — second key silently overwrites first in serde_json** — found during #708 dogfood sweep on `47c0226a`. Rust `serde_json::json!` macros accept duplicate keys but `serde_json` silently keeps the last occurrence; any consumer relying on the first occurrence gets the wrong value if they are ever different. Fixed by removing the duplicate `status` key from `render_agents_report_json` and `render_skill_install_report_json`. Source: Jobdori dogfood on `47c0226a`, 2026-05-26.
|
709. **`render_agents_report_json` and `render_skill_install_report_json` in `commands/src/lib.rs` contained duplicate `"status":"ok"` keys in the same JSON object literal — second key silently overwrites first in serde_json** — found during #708 dogfood sweep on `47c0226a`. Rust `serde_json::json!` macros accept duplicate keys but `serde_json` silently keeps the last occurrence; any consumer relying on the first occurrence gets the wrong value if they are ever different. Fixed by removing the duplicate `status` key from `render_agents_report_json` and `render_skill_install_report_json`. Source: Jobdori dogfood on `47c0226a`, 2026-05-26.
|
||||||
|
|
||||||
|
710. **`claw diff --output-format json` missing `action` and `working_directory` fields — both the ok and error paths in `render_diff_json_for` omitted `action` entirely (returning `null` at parse time) and omitted `working_directory`** — dogfooded 2026-05-26 on `8f8eb41e`. Both the clean/changes success path and the no-git-repo error path were missing the two envelope fields that automation uses for routing and provenance. Fix: added `action:"diff"` and `working_directory: cwd.display()` to both branches of `render_diff_json_for`; added contract-test assertions for both fields. Source: Jobdori dogfood on `8f8eb41e`, 2026-05-26.
|
||||||
|
|||||||
@@ -7680,8 +7680,10 @@ fn render_diff_json_for(cwd: &Path) -> Result<serde_json::Value, Box<dyn std::er
|
|||||||
if !in_git_repo {
|
if !in_git_repo {
|
||||||
return Ok(serde_json::json!({
|
return Ok(serde_json::json!({
|
||||||
"kind": "diff",
|
"kind": "diff",
|
||||||
|
"action": "diff",
|
||||||
"status": "error",
|
"status": "error",
|
||||||
"result": "no_git_repo",
|
"result": "no_git_repo",
|
||||||
|
"working_directory": cwd.display().to_string(),
|
||||||
"detail": format!("{} is not inside a git project", cwd.display()),
|
"detail": format!("{} is not inside a git project", cwd.display()),
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
@@ -7689,7 +7691,9 @@ fn render_diff_json_for(cwd: &Path) -> Result<serde_json::Value, Box<dyn std::er
|
|||||||
let unstaged = run_git_diff_command_in(cwd, &["diff"])?;
|
let unstaged = run_git_diff_command_in(cwd, &["diff"])?;
|
||||||
Ok(serde_json::json!({
|
Ok(serde_json::json!({
|
||||||
"kind": "diff",
|
"kind": "diff",
|
||||||
|
"action": "diff",
|
||||||
"status": "ok",
|
"status": "ok",
|
||||||
|
"working_directory": cwd.display().to_string(),
|
||||||
"result": if staged.trim().is_empty() && unstaged.trim().is_empty() { "clean" } else { "changes" },
|
"result": if staged.trim().is_empty() && unstaged.trim().is_empty() { "clean" } else { "changes" },
|
||||||
"staged": staged.trim(),
|
"staged": staged.trim(),
|
||||||
"unstaged": unstaged.trim(),
|
"unstaged": unstaged.trim(),
|
||||||
|
|||||||
@@ -1114,6 +1114,18 @@ fn diff_json_has_status_and_result_field_702() {
|
|||||||
parsed.get("result").is_some(),
|
parsed.get("result").is_some(),
|
||||||
"diff JSON must have result field"
|
"diff JSON must have result field"
|
||||||
);
|
);
|
||||||
|
// #710: diff JSON must have action:diff and working_directory
|
||||||
|
assert_eq!(
|
||||||
|
parsed["action"], "diff",
|
||||||
|
"diff JSON must have action:diff (#710)"
|
||||||
|
);
|
||||||
|
assert!(
|
||||||
|
parsed
|
||||||
|
.get("working_directory")
|
||||||
|
.and_then(|v| v.as_str())
|
||||||
|
.is_some(),
|
||||||
|
"diff JSON must have working_directory field (#710)"
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|||||||
Reference in New Issue
Block a user