MCPcopy Create free account
hub / github.com/ScriptedAlchemy/tracedecay / codex_apply_patch_rel_paths

Function codex_apply_patch_rel_paths

src/hooks/codex.rs:434–465  ·  view source on GitHub ↗

Extracts the project-relative paths touched by a Codex `apply_patch` command.

(command: &str, cwd: &Path, project_root: &Path)

Source from the content-addressed store, hash-verified

432
433/// Extracts the project-relative paths touched by a Codex `apply_patch` command.
434pub 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
467async fn codex_post_compact(event_json: &str) {
468 let work = async {

Calls 4

rel_under_rootFunction · 0.85
pushMethod · 0.80
is_emptyMethod · 0.45
containsMethod · 0.45