Skip to content

Solution for long term memory for agent coding CLIs and to facilitate handoff between different agent vendors

Rust

test(config): flag only one-line example tables in the layout check

Vinícius DS Andrade883465a79c3e
diff --git a/crates/ai-memory-cli/src/config.rs b/crates/ai-memory-cli/src/config.rs
index 90d4566a..5eba1183 100644
--- a/crates/ai-memory-cli/src/config.rs
+++ b/crates/ai-memory-cli/src/config.rs
@@ -3846,28 +3846,30 @@ mod tests {
#[test]
fn the_shipped_default_config_examples_keep_their_tables() {
const TEMPLATE: &str = include_str!("../templates/config.default.toml");
+ // A one-line example is `# ` followed by a line that parses as TOML on
+ // its own. Indented examples stay commented: some are alternatives
+ // for the same key, others span several lines.
+ fn example(line: &str) -> Option<&str> {
+ line.strip_prefix("# ")
+ .filter(|code| !code.starts_with(' '))
+ .filter(|code| code.parse::<toml_edit::DocumentMut>().is_ok())
+ }
+
let first_table = TEMPLATE
.lines()
.position(|line| line.trim_start().starts_with('['))
.expect("the template declares tables");
for line in TEMPLATE.lines().take(first_table) {
+ let example_table = example(line).is_some_and(|code| code.starts_with('['));
assert!(
- !line.starts_with("# ["),
+ !example_table,
"{line:?} is above the first table and would capture top-level keys"
);
}
- // A one-line example is `# ` followed by a line that parses as TOML on
- // its own. Indented examples stay commented: some are alternatives
- // for the same key, others span several lines.
let uncommented = TEMPLATE
.lines()
- .map(|line| {
- line.strip_prefix("# ")
- .filter(|code| !code.starts_with(' '))
- .filter(|code| code.parse::<toml_edit::DocumentMut>().is_ok())
- .unwrap_or(line)
- })
+ .map(|line| example(line).unwrap_or(line))
.collect::<Vec<_>>()
.join("\n");
let cfg = load_with_toml(&uncommented).expect("the uncommented template must load");