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

Function load_default_user_identity

atomic-agent/src/identity.rs:232–254  ·  view source on GitHub ↗

Load the user's default identity from the identity store. Looks for `~/.atomic/identities/config.toml` to find the default identity, then loads its `identity.toml` for name/email/public key. Returns `None` if: - The identity store directory doesn't exist - No default identity is configured - The default identity's files can't be read

(override_dir: Option<&Path>)

Source from the content-addressed store, hash-verified

230/// - No default identity is configured
231/// - The default identity's files can't be read
232fn load_default_user_identity(override_dir: Option<&Path>) -> Option<UserIdentityInfo> {
233 let identities_dir = match override_dir {
234 Some(dir) => dir.to_path_buf(),
235 None => default_identities_dir()?,
236 };
237
238 if !identities_dir.is_dir() {
239 return None;
240 }
241
242 // Read config.toml to find the default identity
243 let config_path = identities_dir.join("config.toml");
244 let config_content = std::fs::read_to_string(&config_path).ok()?;
245
246 // Parse the config to find the default identity directory name
247 let default_id = extract_default_identity_from_config(&config_content)?;
248
249 // Try to find the identity directory
250 // The store uses {name}-{usage}-{id_short} as directory names,
251 // but we can also match by the ID directly
252 load_identity_by_id(&identities_dir, &default_id)
253 .or_else(|| load_identity_by_scanning(&identities_dir, &default_id))
254}
255
256/// Get the default identities directory: `~/.atomic/identities/`
257fn default_identities_dir() -> Option<PathBuf> {

Callers 1

resolve_agent_authorFunction · 0.85

Calls 5

default_identities_dirFunction · 0.85
load_identity_by_idFunction · 0.85
is_dirMethod · 0.80

Tested by

no test coverage detected