use crate::brain::goal::{goal_command_prompt, goal_usage_warning, is_bare};
use crate::brain::tools::slash_command::normalize_command;
#[test]
fn multiword_command_field_is_split_into_command_and_args() {
let (cmd, args) = normalize_command("/goal debug opencrabs last commits", "");
assert_eq!(cmd, "/goal");
assert_eq!(args, "debug opencrabs last commits");
}
#[test]
fn already_split_command_passes_through_unchanged() {
let (cmd, args) = normalize_command("/goal", "debug the build");
assert_eq!(cmd, "/goal");
assert_eq!(args, "debug the build");
}
#[test]
fn bare_command_keeps_empty_args() {
let (cmd, args) = normalize_command("/goal", "");
assert_eq!(cmd, "/goal");
assert_eq!(args, "");
}
#[test]
fn command_trailing_words_prepend_to_existing_args() {
let (cmd, args) = normalize_command("/goal set", "fix the flaky test");
assert_eq!(cmd, "/goal");
assert_eq!(args, "set fix the flaky test");
}
#[test]
fn whitespace_is_trimmed_on_both_fields() {
let (cmd, args) = normalize_command(" /goal status ", " ");
assert_eq!(cmd, "/goal");
assert_eq!(args, "status");
}
#[test]
fn normalize_is_generic_across_commands() {
let (cmd, args) = normalize_command("/models gpt-5", "");
assert_eq!(cmd, "/models");
assert_eq!(args, "gpt-5");
}
#[test]
fn is_bare_true_for_empty_and_whitespace() {
assert!(is_bare(""));
assert!(is_bare(" "));
assert!(is_bare("\t \n"));
}
#[test]
fn is_bare_false_when_text_present() {
assert!(!is_bare("fix the build"));
assert!(!is_bare(" status "));
}
#[test]
fn prompt_never_folds_args_into_command_field() {
let p = goal_command_prompt("debug opencrabs last commits");
assert!(
p.contains("command='/goal'"),
"directive must keep command as exactly /goal: {p}"
);
assert!(
p.contains("args='debug opencrabs last commits'"),
"directive must pass the goal text via args: {p}"
);
assert!(
!p.contains("command='/goal debug"),
"directive must NOT stuff the goal text into the command field: {p}"
);
}
#[test]
fn prompt_trims_surrounding_whitespace_in_args() {
let p = goal_command_prompt(" fix the build ");
assert!(p.contains("args='fix the build'"), "{p}");
}
#[test]
fn usage_warning_shows_correct_shape() {
let w = goal_usage_warning();
assert!(w.contains("/goal <your goal>"), "{w}");
assert!(w.contains("/goal status"), "{w}");
assert!(w.contains("/goal clear"), "{w}");
}