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

Function snapshot

atomic-agent/src/record/scope.rs:111–138  ·  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

109/// Return fingerprints for dirty files and explicitly requested prior candidates.
110/// The protocol version also lets plugins refuse an older, unscoped CLI.
111pub fn snapshot(root: &Path, extra: &[String]) -> Result<serde_json::Value, String> {
112 let repo = Repository::open_readonly_wait(root, std::time::Duration::from_secs(10))
113 .map_err(|e| e.to_string())?;
114 let working_copy = repo.require_working_copy_id().map_err(|e| e.to_string())?;
115 let status = repo
116 .status(working_copy, StatusOptions::default().with_untracked(true))
117 .map_err(|e| e.to_string())?;
118 let dirty: Vec<String> = status
119 .entries()
120 .iter()
121 .map(|e| e.path().to_string_lossy().to_string())
122 .collect();
123 let mut files = FileManifest::new();
124 for path in status
125 .entries()
126 .iter()
127 .map(|e| e.path().to_string_lossy().to_string())
128 .chain(extra.iter().cloned())
129 {
130 if root.join(&path).is_dir() && !root.join(&path).is_symlink() {
131 continue;
132 }
133 files.insert(path.clone(), fingerprint(root, &path)?);
134 }
135 Ok(
136 serde_json::json!({"scope_version":1, "view":repo.current_view(), "files":files, "dirty":dirty}),
137 )
138}
139
140pub(super) fn manifest(options: &TurnRecordOptions<'_>) -> AgentResult<Option<FileManifest>> {
141 let raw = options

Calls 11

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