mirror of
https://github.com/instructkr/claude-code.git
synced 2026-05-13 17:36:44 +00:00
Compare commits
3 Commits
03b817db2e
...
fix/resume
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d46e6b2737 | ||
|
|
1206f4131d | ||
|
|
c99330372c |
@@ -2627,12 +2627,15 @@ fn print_version(output_format: CliOutputFormat) -> Result<(), Box<dyn std::erro
|
||||
}
|
||||
|
||||
fn version_json_value() -> serde_json::Value {
|
||||
let executable_path = env::current_exe().ok().map(|p| p.display().to_string());
|
||||
json!({
|
||||
"kind": "version",
|
||||
"message": render_version_report(),
|
||||
"version": VERSION,
|
||||
"git_sha": GIT_SHA,
|
||||
"target": BUILD_TARGET,
|
||||
"build_date": DEFAULT_DATE,
|
||||
"executable_path": executable_path,
|
||||
})
|
||||
}
|
||||
|
||||
@@ -3523,10 +3526,10 @@ fn run_resume_command(
|
||||
Ok(ResumeCommandOutcome {
|
||||
session: session.clone(),
|
||||
message: Some(handle_agents_slash_command(args.as_deref(), &cwd)?),
|
||||
json: Some(serde_json::json!({
|
||||
"kind": "agents",
|
||||
"text": handle_agents_slash_command(args.as_deref(), &cwd)?,
|
||||
})),
|
||||
json: Some(
|
||||
serde_json::to_value(handle_agents_slash_command_json(args.as_deref(), &cwd)?)
|
||||
.unwrap_or_else(|_| serde_json::json!(null)),
|
||||
),
|
||||
})
|
||||
}
|
||||
SlashCommand::Skills { args } => {
|
||||
|
||||
@@ -30,6 +30,15 @@ fn version_emits_json_when_requested() {
|
||||
let parsed = assert_json_command(&root, &["--output-format", "json", "version"]);
|
||||
assert_eq!(parsed["kind"], "version");
|
||||
assert_eq!(parsed["version"], env!("CARGO_PKG_VERSION"));
|
||||
// Provenance fields must be present for binary identification (#507).
|
||||
assert!(
|
||||
parsed["build_date"].is_string(),
|
||||
"build_date must be a string in version JSON"
|
||||
);
|
||||
assert!(
|
||||
parsed["executable_path"].is_string(),
|
||||
"executable_path must be a string in version JSON so callers can identify which binary is running"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -360,6 +369,34 @@ fn resumed_inventory_commands_emit_structured_json_when_requested() {
|
||||
assert_eq!(skills["action"], "list");
|
||||
assert!(skills["summary"]["total"].is_number());
|
||||
assert!(skills["skills"].is_array());
|
||||
|
||||
let agents = assert_json_command_with_env(
|
||||
&root,
|
||||
&[
|
||||
"--output-format",
|
||||
"json",
|
||||
"--resume",
|
||||
session_path.to_str().expect("utf8 session path"),
|
||||
"/agents",
|
||||
],
|
||||
&[
|
||||
(
|
||||
"CLAW_CONFIG_HOME",
|
||||
config_home.to_str().expect("utf8 config home"),
|
||||
),
|
||||
("HOME", home.to_str().expect("utf8 home")),
|
||||
],
|
||||
);
|
||||
assert_eq!(agents["kind"], "agents");
|
||||
assert_eq!(agents["action"], "list");
|
||||
assert!(
|
||||
agents["agents"].is_array(),
|
||||
"agents field must be a JSON array"
|
||||
);
|
||||
assert!(
|
||||
agents["count"].is_number(),
|
||||
"count must be a number, not a text render"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
@@ -227,6 +227,8 @@ fn resumed_status_command_emits_structured_json_when_requested() {
|
||||
// given
|
||||
let temp_dir = unique_temp_dir("resume-status-json");
|
||||
fs::create_dir_all(&temp_dir).expect("temp dir should exist");
|
||||
let config_home = temp_dir.join("config-home");
|
||||
fs::create_dir_all(&config_home).expect("isolated config home should exist");
|
||||
let session_path = temp_dir.join("session.jsonl");
|
||||
|
||||
let mut session = workspace_session(&temp_dir);
|
||||
@@ -238,7 +240,9 @@ fn resumed_status_command_emits_structured_json_when_requested() {
|
||||
.expect("session should persist");
|
||||
|
||||
// when
|
||||
let output = run_claw(
|
||||
// Use an isolated CLAW_CONFIG_HOME so ~/.claw/settings.json is not loaded,
|
||||
// which would cause loaded_config_files to be non-zero (#65).
|
||||
let output = run_claw_with_env(
|
||||
&temp_dir,
|
||||
&[
|
||||
"--output-format",
|
||||
@@ -247,6 +251,7 @@ fn resumed_status_command_emits_structured_json_when_requested() {
|
||||
session_path.to_str().expect("utf8 path"),
|
||||
"/status",
|
||||
],
|
||||
&[("CLAW_CONFIG_HOME", config_home.to_str().expect("utf8 path"))],
|
||||
);
|
||||
|
||||
// then
|
||||
|
||||
Reference in New Issue
Block a user