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

Function snapshot

atomic-agent/src/record/scope.rs:84–110  ·  view source on GitHub ↗

Return fingerprints for dirty files and explicitly requested prior candidates. The protocol version also lets plugins refuse an older, unscoped CLI.

(root: &Path, extra: &[String])

Source from the content-addressed store, hash-verified

82/// Return fingerprints for dirty files and explicitly requested prior candidates.
83/// The protocol version also lets plugins refuse an older, unscoped CLI.
84pub fn snapshot(root: &Path, extra: &[String]) -> Result<serde_json::Value, String> {
85 let repo = Repository::open_readonly_wait(root, std::time::Duration::from_secs(10))
86 .map_err(|e| e.to_string())?;
87 let status = repo
88 .status(StatusOptions::default().with_untracked(true))
89 .map_err(|e| e.to_string())?;
90 let dirty: Vec<String> = status
91 .entries()
92 .iter()
93 .map(|e| e.path().to_string_lossy().to_string())
94 .collect();
95 let mut files = FileManifest::new();
96 for path in status
97 .entries()
98 .iter()
99 .map(|e| e.path().to_string_lossy().to_string())
100 .chain(extra.iter().cloned())
101 {
102 if root.join(&path).is_dir() && !root.join(&path).is_symlink() {
103 continue;
104 }
105 files.insert(path.clone(), fingerprint(root, &path)?);
106 }
107 Ok(
108 serde_json::json!({"scope_version":1, "view":repo.current_view(), "files":files, "dirty":dirty}),
109 )
110}
111
112pub(super) fn manifest(options: &TurnRecordOptions<'_>) -> AgentResult<Option<FileManifest>> {
113 let raw = options

Calls 9

fingerprintFunction · 0.85
with_untrackedMethod · 0.80
entriesMethod · 0.80
is_dirMethod · 0.80
statusMethod · 0.45
iterMethod · 0.45
pathMethod · 0.45
insertMethod · 0.45
cloneMethod · 0.45