MCPcopy Create free account
hub / github.com/ScriptedAlchemy/tracedecay / hermes_profile_targets

Function hermes_profile_targets

src/agent_cmd.rs:9–60  ·  view source on GitHub ↗
(
    home: &Path,
)

Source from the content-addressed store, hash-verified

7};
8
9pub(crate) fn hermes_profile_targets(
10 home: &Path,
11) -> tracedecay::errors::Result<Vec<Option<String>>> {
12 let mut targets = vec![None];
13 let profiles_dir = home.join(".hermes/profiles");
14 let entries = match std::fs::read_dir(&profiles_dir) {
15 Ok(entries) => entries,
16 Err(e) if e.kind() == io::ErrorKind::NotFound => return Ok(targets),
17 Err(e) => {
18 return Err(tracedecay::errors::TraceDecayError::Config {
19 message: format!(
20 "failed to read Hermes profiles directory {}: {e}",
21 profiles_dir.display()
22 ),
23 });
24 }
25 };
26
27 let mut profile_names = Vec::new();
28 for entry in entries {
29 let entry = entry.map_err(|e| tracedecay::errors::TraceDecayError::Config {
30 message: format!(
31 "failed to read Hermes profiles directory {}: {e}",
32 profiles_dir.display()
33 ),
34 })?;
35 let file_type =
36 entry
37 .file_type()
38 .map_err(|e| tracedecay::errors::TraceDecayError::Config {
39 message: format!(
40 "failed to inspect Hermes profile {}: {e}",
41 entry.path().display()
42 ),
43 })?;
44 if !file_type.is_dir() {
45 continue;
46 }
47 let name = entry.file_name().into_string().map_err(|_| {
48 tracedecay::errors::TraceDecayError::Config {
49 message: format!(
50 "Hermes profile path is not valid UTF-8: {}",
51 entry.path().display()
52 ),
53 }
54 })?;
55 profile_names.push(name);
56 }
57 profile_names.sort();
58 targets.extend(profile_names.into_iter().map(Some));
59 Ok(targets)
60}
61
62pub(crate) fn validate_hermes_profile_flags(
63 agent: Option<&str>,

Calls 2

kindMethod · 0.80
pushMethod · 0.80