Extracts the project-relative paths touched by a Codex `apply_patch` command.
(command: &str, cwd: &Path, project_root: &Path)
| 432 | |
| 433 | /// Extracts the project-relative paths touched by a Codex `apply_patch` command. |
| 434 | pub fn codex_apply_patch_rel_paths(command: &str, cwd: &Path, project_root: &Path) -> Vec<String> { |
| 435 | const PREFIXES: [&str; 4] = [ |
| 436 | "*** Add File:", |
| 437 | "*** Update File:", |
| 438 | "*** Delete File:", |
| 439 | "*** Move to:", |
| 440 | ]; |
| 441 | let mut rels: Vec<String> = Vec::new(); |
| 442 | for line in command.lines() { |
| 443 | let line = line.trim(); |
| 444 | for prefix in PREFIXES { |
| 445 | if let Some(rest) = line.strip_prefix(prefix) { |
| 446 | let raw = rest.trim(); |
| 447 | if raw.is_empty() { |
| 448 | continue; |
| 449 | } |
| 450 | let candidate = Path::new(raw); |
| 451 | let abs = if candidate.is_absolute() { |
| 452 | candidate.to_path_buf() |
| 453 | } else { |
| 454 | cwd.join(candidate) |
| 455 | }; |
| 456 | if let Some(rel) = rel_under_root(project_root, &abs) { |
| 457 | if !rels.contains(&rel) { |
| 458 | rels.push(rel); |
| 459 | } |
| 460 | } |
| 461 | } |
| 462 | } |
| 463 | } |
| 464 | rels |
| 465 | } |
| 466 | |
| 467 | async fn codex_post_compact(event_json: &str) { |
| 468 | let work = async { |