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])
| 109 | /// Return fingerprints for dirty files and explicitly requested prior candidates. |
| 110 | /// The protocol version also lets plugins refuse an older, unscoped CLI. |
| 111 | pub 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 | |
| 140 | pub(super) fn manifest(options: &TurnRecordOptions<'_>) -> AgentResult<Option<FileManifest>> { |
| 141 | let raw = options |