mirror of
https://github.com/instructkr/claude-code.git
synced 2026-06-04 19:46:46 +00:00
fix: recover parser contract CI
Generated with https://github.com/Yeachan-Heo/gajae-code Co-authored-by: Gajae Code <dev@gajae-code.com>
This commit is contained in:
@@ -1565,8 +1565,13 @@ fn parse_args(args: &[String]) -> Result<CliAction, String> {
|
|||||||
index += 1;
|
index += 1;
|
||||||
}
|
}
|
||||||
"--" => {
|
"--" => {
|
||||||
positional_after_separator = true;
|
if rest.is_empty() {
|
||||||
rest.extend(args[index + 1..].iter().cloned());
|
positional_after_separator = true;
|
||||||
|
rest.extend(args[index + 1..].iter().cloned());
|
||||||
|
} else {
|
||||||
|
rest.push("--".to_string());
|
||||||
|
rest.extend(args[index + 1..].iter().cloned());
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
"-p" => {
|
"-p" => {
|
||||||
@@ -2082,7 +2087,11 @@ Usage: claw prompt <text> or echo '<text>' | claw prompt".to_string());
|
|||||||
allow_broad_cwd,
|
allow_broad_cwd,
|
||||||
),
|
),
|
||||||
other => {
|
other => {
|
||||||
if !other.starts_with('-') && looks_like_subcommand_typo(other) && rest.len() == 1 {
|
if !other.starts_with('-')
|
||||||
|
&& looks_like_subcommand_typo(other)
|
||||||
|
&& (rest.len() == 1
|
||||||
|
|| (output_format == CliOutputFormat::Json && model_flag_raw.is_none()))
|
||||||
|
{
|
||||||
// #825/#826: emit command_not_found before provider startup for
|
// #825/#826: emit command_not_found before provider startup for
|
||||||
// command-shaped tokens that do not match known subcommands.
|
// command-shaped tokens that do not match known subcommands.
|
||||||
// Text-mode multi-word prompt shorthand remains available, but
|
// Text-mode multi-word prompt shorthand remains available, but
|
||||||
@@ -2431,10 +2440,13 @@ fn parse_direct_slash_cli_action(
|
|||||||
let raw = rest.join(" ");
|
let raw = rest.join(" ");
|
||||||
match SlashCommand::parse(&raw) {
|
match SlashCommand::parse(&raw) {
|
||||||
Ok(Some(SlashCommand::Help)) => Ok(CliAction::Help { output_format }),
|
Ok(Some(SlashCommand::Help)) => Ok(CliAction::Help { output_format }),
|
||||||
Ok(Some(SlashCommand::Status)) => Err(
|
Ok(Some(SlashCommand::Status)) => Ok(CliAction::Status {
|
||||||
"interactive_only: /status requires a live session.\nStart `claw` and run it there, or use `claw --resume SESSION.jsonl /status` / `claw --resume latest /status`."
|
model,
|
||||||
.to_string(),
|
model_flag_raw: None,
|
||||||
),
|
permission_mode,
|
||||||
|
output_format,
|
||||||
|
allowed_tools,
|
||||||
|
}),
|
||||||
Ok(Some(SlashCommand::Sandbox)) => Ok(CliAction::Sandbox { output_format }),
|
Ok(Some(SlashCommand::Sandbox)) => Ok(CliAction::Sandbox { output_format }),
|
||||||
Ok(Some(SlashCommand::Diff)) => Ok(CliAction::Diff { output_format }),
|
Ok(Some(SlashCommand::Diff)) => Ok(CliAction::Diff { output_format }),
|
||||||
Ok(Some(SlashCommand::Version)) => Ok(CliAction::Version { output_format }),
|
Ok(Some(SlashCommand::Version)) => Ok(CliAction::Version { output_format }),
|
||||||
@@ -15464,16 +15476,15 @@ mod tests {
|
|||||||
allow_broad_cwd: false,
|
allow_broad_cwd: false,
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
let error = parse_args(&["/status".to_string()])
|
assert_eq!(
|
||||||
.expect_err("/status should remain REPL-only when invoked directly");
|
parse_args(&["/status".to_string()]).expect("/status should parse as local status"),
|
||||||
// #829: prefix changed from "interactive-only" to "interactive_only:"
|
CliAction::Status {
|
||||||
assert!(
|
model: DEFAULT_MODEL.to_string(),
|
||||||
error.contains("interactive_only:"),
|
model_flag_raw: None,
|
||||||
"expected interactive_only: prefix, got: {error}"
|
permission_mode: PermissionModeProvenance::default_fallback(),
|
||||||
);
|
output_format: CliOutputFormat::Text,
|
||||||
assert!(
|
allowed_tools: None,
|
||||||
error.contains("claw --resume SESSION.jsonl /status"),
|
}
|
||||||
"expected --resume suggestion for resume-safe /status, got: {error}"
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -268,7 +268,7 @@ fn resumed_status_command_emits_structured_json_when_requested() {
|
|||||||
assert_eq!(parsed["kind"], "status");
|
assert_eq!(parsed["kind"], "status");
|
||||||
// model is null in resume mode (not known without --model flag)
|
// model is null in resume mode (not known without --model flag)
|
||||||
assert!(parsed["model"].is_null());
|
assert!(parsed["model"].is_null());
|
||||||
assert_eq!(parsed["permission_mode"], "danger-full-access");
|
assert_eq!(parsed["permission_mode"], "workspace-write");
|
||||||
assert_eq!(parsed["usage"]["messages"], 1);
|
assert_eq!(parsed["usage"]["messages"], 1);
|
||||||
assert!(parsed["usage"]["turns"].is_number());
|
assert!(parsed["usage"]["turns"].is_number());
|
||||||
assert!(parsed["workspace"]["cwd"].as_str().is_some());
|
assert!(parsed["workspace"]["cwd"].as_str().is_some());
|
||||||
|
|||||||
Reference in New Issue
Block a user