use super::*;
fn rows(content: &str) -> Vec<String> {
tool_round_prose(content)
}
#[test]
fn narration_keeps_the_readable_prose_and_drops_the_call() {
let cases: &[(&str, &[&str])] = &[
("Let me look at the file.", &["Let me look at the file."]),
(
"First I check the tests. Then I edit.",
&["First I check the tests. Then I edit."],
),
(
"The crates are at the top level (e.g. newt-core, newt-tui). Next I read.",
&["The crates are at the top level (e.g. newt-core, newt-tui). Next I read."],
),
("Para one.\n\nPara two.", &["Para one.", "Para two."]),
(r#"{"name":"read_file","arguments":{"path":"a.rs"}}"#, &[]),
(
"I'll read the file.\n\n```json\n{\"name\":\"read_file\"}\n```",
&["I'll read the file."],
),
(
"Reading it now:\n{\n \"name\": \"read_file\",\n \"arguments\": {}\n}",
&["Reading it now:"],
),
(
"<think>plan</think>\n\nLet me read that now.\n\n<read_file><path>x</path></read_file>",
&["Let me read that now."],
),
("Reading now<think>cut off mid-thought", &["Reading now"]),
(
"First I check the tests. Then I edit.\n\n<function=run_command>\n<parameter=command>ls</parameter>\n</function>\n</tool_call>",
&["First I check the tests. Then I edit."],
),
(
"## Plan\n1. Read the config then edit.\n2. Run the tests.",
&["Read the config then edit.", "Run the tests."],
),
(
"- extract denials.rs\n- extract find_tool.rs",
&["extract denials.rs", "extract find_tool.rs"],
),
("Here is config: {\"debug\": true}", &["Here is config:"]),
(
"Reading it now: {\"name\": \"read_file\", \"arguments\": {\"path\": \"a.rs\"}}",
&["Reading it now:"],
),
(
"Opening the file <function=read_file><parameter=path>a.rs</parameter></function>",
&["Opening the file"],
),
("", &[]),
(" \n\n", &[]),
("</tool_call>", &[]),
("```\nls -la\n```", &[]),
];
for (content, expected) in cases {
assert_eq!(rows(content), *expected, "content: {content:?}");
}
}
#[test]
fn narration_collapses_whitespace_within_a_row() {
assert_eq!(
rows("Reading the\n config\tfile now.\nThen more."),
vec!["Reading the config file now. Then more."]
);
}