Skip to main content

gitcore/
lib.rs

1//! # Gitcore: The Programmatic Engine for Git Identity Management
2//!
3//! Gitcore is a high-assurance Rust library designed to solve the complexity of
4//! managing multiple Git identities on a single machine. It provides a
5//! deterministic, secure, and automated way to isolate SSH keys, commit
6//! authorship, and cryptographic signing across different environments.
7//!
8//! ## Core Philosophy
9//! Traditional Git workflows rely on global configurations that lead to "identity
10//! leakage" (e.g., using a personal email for a corporate commit). Gitcore
11//! eliminates this by providing:
12//! - **Cryptographic Isolation**: Every account is backed by its own unique Ed25519 keypair.
13//! - **Automated Orchestration**: Seamless management of `~/.ssh/config` without touching existing manual entries.
14//! - **Contextual Awareness**: Automatic detection and injection of identity metadata during `clone` or `remote` operations.
15//!
16//! ## Library vs. CLI
17//! This crate serves as the underlying engine for the `gitcore` CLI. By exposing
18//! this engine programmatically, Gitcore enables developers to:
19//! - Build custom Git automation and CI/CD pipelines.
20//! - Integrate identity management into IDEs or developer portals.
21//! - Extend the core logic for specialized hosting providers.
22//!
23//! ## Getting Started
24//! ```no_run
25//! use gitcore::{Gitcore, AddAccountRequest, Platform};
26//!
27//! // Initialize the service with standard user paths
28//! let service = Gitcore::new();
29//!
30//! // Provision and register a new identity
31//! let request = AddAccountRequest {
32//!     name: "work".to_string(),
33//!     platform: Platform::Github,
34//!     username: "octocat".to_string(),
35//!     email: "octocat@example.com".to_string(),
36//!     ..Default::default()
37//! };
38//!
39//! service.register_account(request)?;
40//! # Ok::<(), gitcore::GitcoreError>(())
41//! ```
42
43mod command_runner;
44mod config;
45mod error;
46mod git;
47mod gpg;
48mod models;
49mod service;
50mod ssh;
51mod vault;
52
53pub use error::{GitcoreError, Result};
54pub use gpg::{GpgKey, list_gpg_keys};
55pub use models::{Account, GitcoreConfig, Platform};
56pub use service::{
57    AddAccountRequest, AuditReport, BackupReport, CloneReport, CloneRequest, FileAudit, Gitcore,
58    GitcorePaths, KeyAudit, KeyDeletionReport, KeyProvisionReport, RegisteredAccount,
59    RemoteAddRequest, RemoteReport, RemoteSwitchRequest, RestoreReport, RotationReport,
60    SshTestReport, UpdateAccountRequest,
61};
62pub use ssh::{HostKeyStatus, delete_account_keys, generate_ssh_key, get_ssh_dir};