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

Function load_default_user_identity

atomic-agent/src/identity.rs:415–437  ·  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

413/// - No default identity is configured
414/// - The default identity's files can't be read
415fn load_default_user_identity(override_dir: Option<&Path>) -> Option<UserIdentityInfo> {
416 let identities_dir = match override_dir {
417 Some(dir) => dir.to_path_buf(),
418 None => default_identities_dir()?,
419 };
420
421 if !identities_dir.is_dir() {
422 return None;
423 }
424
425 // Read config.toml to find the default identity
426 let config_path = identities_dir.join("config.toml");
427 let config_content = std::fs::read_to_string(&config_path).ok()?;
428
429 // Parse the config to find the default identity directory name
430 let default_id = extract_default_identity_from_config(&config_content)?;
431
432 // Try to find the identity directory
433 // The store uses {name}-{usage}-{id_short} as directory names,
434 // but we can also match by the ID directly
435 load_identity_by_id(&identities_dir, &default_id)
436 .or_else(|| load_identity_by_scanning(&identities_dir, &default_id))
437}
438
439/// Get the default identities directory: `~/.atomic/identities/`
440fn 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