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

Function capture_files

atomic-agent/src/turn/capture.rs:104–129  ·  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

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