mirror of
https://github.com/instructkr/claude-code.git
synced 2026-05-28 16:36:45 +00:00
fix(#711): add missing action fields to version/system-prompt/export/init json responses; add contract test assertions
This commit is contained in:
@@ -2954,6 +2954,7 @@ fn print_system_prompt(
|
||||
"{}",
|
||||
serde_json::to_string_pretty(&json!({
|
||||
"kind": "system-prompt",
|
||||
"action": "show",
|
||||
"status": "ok",
|
||||
"message": message,
|
||||
"sections": sections,
|
||||
@@ -2977,6 +2978,7 @@ fn version_json_value() -> serde_json::Value {
|
||||
let executable_path = env::current_exe().ok().map(|p| p.display().to_string());
|
||||
json!({
|
||||
"kind": "version",
|
||||
"action": "show",
|
||||
"status": "ok",
|
||||
"message": render_version_report(),
|
||||
"version": VERSION,
|
||||
@@ -4174,6 +4176,7 @@ fn run_resume_command(
|
||||
)),
|
||||
json: Some(serde_json::json!({
|
||||
"kind": "export",
|
||||
"action": "export",
|
||||
"status": "ok",
|
||||
"file": export_path.display().to_string(),
|
||||
"message_count": msg_count,
|
||||
@@ -7603,6 +7606,7 @@ fn init_json_value(report: &crate::init::InitReport, message: &str) -> serde_jso
|
||||
let status = "ok";
|
||||
json!({
|
||||
"kind": "init",
|
||||
"action": "init",
|
||||
"status": status,
|
||||
"project_path": report.project_root.display().to_string(),
|
||||
"created": report.artifacts_with_status(InitStatus::Created),
|
||||
@@ -8209,6 +8213,7 @@ fn run_export(
|
||||
"{}",
|
||||
serde_json::to_string_pretty(&json!({
|
||||
"kind": "export",
|
||||
"action": "export",
|
||||
"status": "ok",
|
||||
"message": report,
|
||||
"session_id": handle.id,
|
||||
@@ -8231,6 +8236,7 @@ fn run_export(
|
||||
"{}",
|
||||
serde_json::to_string_pretty(&json!({
|
||||
"kind": "export",
|
||||
"action": "export",
|
||||
"status": "ok",
|
||||
"session_id": handle.id,
|
||||
"file": handle.path.display().to_string(),
|
||||
|
||||
@@ -73,6 +73,10 @@ fn version_emits_json_when_requested() {
|
||||
|
||||
let parsed = assert_json_command(&root, &["--output-format", "json", "version"]);
|
||||
assert_eq!(parsed["kind"], "version");
|
||||
assert_eq!(
|
||||
parsed["action"], "show",
|
||||
"version JSON must have action:show (#711)"
|
||||
);
|
||||
assert_eq!(parsed["version"], env!("CARGO_PKG_VERSION"));
|
||||
// Provenance fields must be present for binary identification (#507).
|
||||
assert!(
|
||||
@@ -478,6 +482,10 @@ fn bootstrap_and_system_prompt_emit_json_when_requested() {
|
||||
|
||||
let prompt = assert_json_command(&root, &["--output-format", "json", "system-prompt"]);
|
||||
assert_eq!(prompt["kind"], "system-prompt");
|
||||
assert_eq!(
|
||||
prompt["action"], "show",
|
||||
"system-prompt JSON must have action:show (#711)"
|
||||
);
|
||||
assert!(prompt["message"]
|
||||
.as_str()
|
||||
.expect("prompt text")
|
||||
@@ -508,6 +516,10 @@ fn dump_manifests_and_init_emit_json_when_requested() {
|
||||
fs::create_dir_all(&workspace).expect("workspace should exist");
|
||||
let init = assert_json_command(&workspace, &["--output-format", "json", "init"]);
|
||||
assert_eq!(init["kind"], "init");
|
||||
assert_eq!(
|
||||
init["action"], "init",
|
||||
"init JSON must have action:init (#711)"
|
||||
);
|
||||
assert!(workspace.join("CLAUDE.md").exists());
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user