MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / capture_files

Function capture_files

atomic-agent/src/turn/capture.rs:106–131  ·  view source on GitHub ↗

Every stored capture for one turn, oldest first (legacy single file first, then per-attempt files in attempt order).

(sessions_dir: &Path, session_id: &str, turn: u32)

Source from the content-addressed store, hash-verified

104/// Every stored capture for one turn, oldest first (legacy single file
105/// first, then per-attempt files in attempt order).
106fn capture_files(sessions_dir: &Path, session_id: &str, turn: u32) -> AgentResult<Vec<PathBuf>> {
107 let mut files = Vec::new();
108 let legacy = capture_path(sessions_dir, session_id, turn)?;
109 if legacy.exists() {
110 files.push(legacy);
111 }
112 let prefix = format!("turn-{turn}.attempt-");
113 if let Ok(entries) = std::fs::read_dir(capture_dir(sessions_dir, session_id)?) {
114 let mut attempts: Vec<(u32, PathBuf)> = entries
115 .flatten()
116 .filter_map(|entry| {
117 let name = entry.file_name().to_string_lossy().to_string();
118 let rest = name
119 .strip_prefix(&prefix)?
120 .strip_suffix(".json")?
121 .to_string();
122 rest.parse::<u32>()
123 .ok()
124 .map(|attempt| (attempt, entry.path()))
125 })
126 .collect();
127 attempts.sort_by_key(|(attempt, _)| *attempt);
128 files.extend(attempts.into_iter().map(|(_, path)| path));
129 }
130 Ok(files)
131}
132
133/// The most recent capture file for one turn (the latest commit attempt),
134/// when any exists.

Callers 3

latest_capture_fileFunction · 0.85
has_captureFunction · 0.85

Calls 10

capture_pathFunction · 0.85
capture_dirFunction · 0.85
extendMethod · 0.80
existsMethod · 0.45
pushMethod · 0.45
collectMethod · 0.45
file_nameMethod · 0.45
okMethod · 0.45
pathMethod · 0.45
into_iterMethod · 0.45