Remove learnings that already exist in the context file. Returns a new `Learnings` with only the Repo and Workflow entries that are not already present. Code learnings are always empty in the result because they're not written to context files. Comparison is by finding text (exact match on the list item content).
(existing_content: &str, new_learnings: &Learnings)
| 311 | /// |
| 312 | /// Comparison is by finding text (exact match on the list item content). |
| 313 | pub fn dedup_learnings(existing_content: &str, new_learnings: &Learnings) -> Learnings { |
| 314 | let existing = read_existing_learnings(existing_content); |
| 315 | |
| 316 | let repo: Vec<String> = new_learnings |
| 317 | .repo |
| 318 | .iter() |
| 319 | .filter(|item| !is_duplicate(&existing, &format!("- {}", item))) |
| 320 | .cloned() |
| 321 | .collect(); |
| 322 | |
| 323 | // Code learnings are not written to context files — skip them |
| 324 | let code: Vec<CodeLearning> = Vec::new(); |
| 325 | |
| 326 | let workflow: Vec<String> = new_learnings |
| 327 | .workflow |
| 328 | .iter() |
| 329 | .filter(|item| !is_duplicate(&existing, &format!("- {}", item))) |
| 330 | .cloned() |
| 331 | .collect(); |
| 332 | |
| 333 | Learnings { |
| 334 | repo, |
| 335 | code, |
| 336 | workflow, |
| 337 | } |
| 338 | } |
| 339 | |
| 340 | // Save to Context File |
| 341 |