feat(agentcompany-rust): scaffold native shell and runtime bridge

This commit is contained in:
ZacharyZhang-NY committed 2026-04-19 01:02:20 -04:00
1 parent 34814b4dfd
commit 2cddf89717
40 files changed
+11300 -3

No files matched your search

@@ -0,0 +1,2 @@
pub mod paths;
pub mod time;
@@ -0,0 +1,30 @@
use anyhow::{Result, anyhow};
use std::{
env, fs,
path::{Path, PathBuf},
};
pub const APP_NAME: &str = "AgentCompany";
pub const PROFILE_ENV: &str = "AGENTCOMPANY_PROFILE_DIR";
pub fn default_profile_dir() -> Result<PathBuf> {
dirs::data_dir()
.map(|path| path.join(APP_NAME).join("profile"))
.ok_or_else(|| anyhow!("OS data directory is unavailable"))
}
pub fn resolve_profile_dir() -> Result<PathBuf> {
match env::var(PROFILE_ENV) {
Ok(value) if !value.trim().is_empty() => Ok(PathBuf::from(value)),
_ => default_profile_dir(),
}
}
pub fn profile_db_path(profile_dir: &Path) -> PathBuf {
profile_dir.join("profile.sqlite")
}
pub fn ensure_profile_dir(profile_dir: &Path) -> Result<()> {
fs::create_dir_all(profile_dir)?;
Ok(())
}
@@ -0,0 +1,8 @@
use anyhow::{Context, Result};
use time::{OffsetDateTime, format_description::well_known::Rfc3339};
pub fn now_iso() -> Result<String> {
OffsetDateTime::now_utc()
.format(&Rfc3339)
.context("failed to format UTC timestamp")
}