1use std::collections::{BTreeMap, BTreeSet, HashMap, HashSet};
2use std::ffi::OsStr;
3use std::fs::File;
4use std::path::{Path, PathBuf};
5use std::sync::{Arc, OnceLock};
6use std::time::{Duration, SystemTime, UNIX_EPOCH};
7use std::{fs, process};
8
9use chrono_tz::Tz;
10use fs2::FileExt;
11use regex::Regex;
12use serde::{Deserialize, Serialize};
13use sha2::{Digest, Sha256};
14use std::str::FromStr;
15use url::Url;
16
17const CONTENT_HASH_FILE: &str = harn_modules::package_execution::CONTENT_HASH_FILE;
18const CACHE_METADATA_FILE: &str = harn_modules::package_execution::CACHE_METADATA_FILE;
19const HARN_CACHE_DIR_ENV: &str = "HARN_CACHE_DIR";
20const HARN_PACKAGE_REGISTRY_ENV: &str = "HARN_PACKAGE_REGISTRY";
21const HARN_PACKAGE_REGISTRY_TOKEN_ENV: &str = "HARN_PACKAGE_REGISTRY_TOKEN";
22const DEFAULT_PACKAGE_REGISTRY_URL: &str = "https://packages.harnlang.com/harn-package-index.toml";
23const CACHE_METADATA_VERSION: u32 = 1;
24const LOCK_FILE_VERSION: u32 = 4;
25const REGISTRY_INDEX_VERSION: u32 = 1;
26const PACKAGE_ARCHIVE_MAX_BYTES: u64 = 64 * 1024 * 1024;
27const PACKAGE_ARCHIVE_MAX_UNPACKED_BYTES: u64 = 64 * 1024 * 1024;
28const MANIFEST: &str = "harn.toml";
29const LOCK_FILE: &str = "harn.lock";
30const TRIGGER_RETRY_MAX_LIMIT: u32 = 100;
31
32pub(crate) mod errors;
33mod extensions;
34mod generations;
35mod lockfile;
36mod manifest;
37mod maturity;
38mod package_ops;
39mod persona_activation;
40mod persona_runtime;
41mod registry;
42mod skills;
43mod validation;
44
45#[allow(unused_imports)]
46pub use errors::{PackageError, PackageResult};
47
48pub use extensions::*;
49pub(crate) use generations::*;
50#[cfg(test)]
51pub use lockfile::add_package;
52pub(crate) use lockfile::*;
53pub use lockfile::{
54 add_package_with_registry, ensure_dependencies_materialized, install_packages, lock_packages,
55 remove_package, update_packages, PackageLockExport, PackageLockExports,
56};
57pub use manifest::*;
58pub use maturity::{
59 artifacts_check, artifacts_manifest, audit_packages, outdated_packages, ArtifactDriftReport,
60 AuditCode, AuditFinding, AuditReport, AuditSeverity, OutdatedEntry, OutdatedReport,
61 OutdatedStatus,
62};
63pub use package_ops::*;
64pub use persona_activation::*;
65pub(crate) use persona_runtime::*;
66pub(crate) use registry::*;
67pub use registry::{
68 clean_package_cache, list_package_cache, search_package_registry, search_rule_package_registry,
69 show_package_registry_info, verify_package_cache,
70};
71pub use skills::*;
72pub(crate) use validation::*;
73
74#[cfg(test)]
75pub(crate) mod test_support;