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

Function build_file_change_summary

atomic-agent/src/record/message.rs:289–334  ·  view source on GitHub ↗

Build a human-readable summary of file changes from the repository status. Groups changes by kind and lists filenames (not full paths) to keep the message concise. Examples: - `"Add src/main.rs, Cargo.toml"` - `"Modify auth.rs; delete old_config.toml"` - `"Add 12 files"` - `"Modify handler.rs; add 5 files"`

(
    status: &RepositoryStatus,
    untracked_paths: &[String],
)

Source from the content-addressed store, hash-verified

287/// - `"Add 12 files"`
288/// - `"Modify handler.rs; add 5 files"`
289pub(crate) fn build_file_change_summary(
290 status: &RepositoryStatus,
291 untracked_paths: &[String],
292) -> String {
293 let mut added: Vec<String> = Vec::new();
294 let mut modified: Vec<String> = Vec::new();
295 let mut deleted: Vec<String> = Vec::new();
296
297 for entry in status.entries() {
298 let filename = entry
299 .path()
300 .file_name()
301 .map(|n| n.to_string_lossy().to_string())
302 .unwrap_or_else(|| entry.path().to_string_lossy().to_string());
303
304 match entry.status() {
305 FileStatus::Added => added.push(filename),
306 FileStatus::Modified => modified.push(filename),
307 FileStatus::Deleted => deleted.push(filename),
308 _ => {}
309 }
310 }
311
312 // Untracked files that will be auto-added count as "Add"
313 for path in untracked_paths {
314 let filename = std::path::Path::new(path)
315 .file_name()
316 .map(|n| n.to_string_lossy().to_string())
317 .unwrap_or_else(|| path.clone());
318 added.push(filename);
319 }
320
321 let mut parts: Vec<String> = Vec::new();
322
323 if !modified.is_empty() {
324 parts.push(format_file_group("Modify", &modified));
325 }
326 if !added.is_empty() {
327 parts.push(format_file_group("Add", &added));
328 }
329 if !deleted.is_empty() {
330 parts.push(format_file_group("Delete", &deleted));
331 }
332
333 parts.join("; ")
334}
335
336/// Format a group of files with a verb prefix.
337///

Callers 3

test_summary_emptyFunction · 0.85
build_turn_messageFunction · 0.85

Calls 8

format_file_groupFunction · 0.85
entriesMethod · 0.80
file_nameMethod · 0.80
pathMethod · 0.45
statusMethod · 0.45
pushMethod · 0.45
cloneMethod · 0.45
is_emptyMethod · 0.45

Tested by 2

test_summary_emptyFunction · 0.68