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 regex::Regex;
11use serde::{Deserialize, Serialize};
12use sha2::{Digest, Sha256};
13use std::str::FromStr;
14use url::Url;
15
16const CONTENT_HASH_FILE: &str = harn_modules::package_execution::CONTENT_HASH_FILE;
17const CACHE_METADATA_FILE: &str = harn_modules::package_execution::CACHE_METADATA_FILE;
18const HARN_CACHE_DIR_ENV: &str = "HARN_CACHE_DIR";
19const HARN_PACKAGE_REGISTRY_ENV: &str = "HARN_PACKAGE_REGISTRY";
20const HARN_PACKAGE_REGISTRY_TOKEN_ENV: &str = "HARN_PACKAGE_REGISTRY_TOKEN";
21const DEFAULT_PACKAGE_REGISTRY_URL: &str = "https://packages.harnlang.com/harn-package-index.toml";
22const CACHE_METADATA_VERSION: u32 = 1;
23const LOCK_FILE_VERSION: u32 = 4;
24const REGISTRY_INDEX_VERSION: u32 = 1;
25const PACKAGE_ARCHIVE_MAX_BYTES: u64 = 64 * 1024 * 1024;
26const PACKAGE_ARCHIVE_MAX_UNPACKED_BYTES: u64 = 64 * 1024 * 1024;
27const MANIFEST: &str = harn_modules::manifest_walk::MANIFEST_FILENAME;
28const LOCK_FILE: &str = "harn.lock";
29const TRIGGER_RETRY_MAX_LIMIT: u32 = 100;
30
31pub(crate) mod errors;
32mod extensions;
33mod generations;
34mod git_cwd;
35mod lockfile;
36mod manifest;
37mod manifest_search;
38mod maturity;
39mod mutation;
40mod package_ops;
41mod persona_activation;
42mod persona_runtime;
43mod registry;
44mod skills;
45mod validation;
46
47#[allow(unused_imports)]
48pub use errors::{PackageError, PackageResult};
49
50pub use extensions::*;
51pub(crate) use generations::*;
52pub(crate) use git_cwd::Cwd;
53#[cfg(test)]
54pub use lockfile::add_package;
55pub(crate) use lockfile::*;
56pub use lockfile::{
57 add_package_with_registry, ensure_dependencies_materialized, install_packages, lock_packages,
58 remove_package, update_packages, PackageLockExport, PackageLockExports,
59};
60pub use manifest::*;
61pub(crate) use manifest_search::*;
62pub use maturity::{
63 artifacts_check, artifacts_manifest, audit_packages, outdated_packages, ArtifactDriftReport,
64 AuditCode, AuditFinding, AuditReport, AuditSeverity, OutdatedEntry, OutdatedReport,
65 OutdatedStatus,
66};
67pub(crate) use mutation::*;
68pub use package_ops::*;
69pub use persona_activation::*;
70pub(crate) use persona_runtime::*;
71pub(crate) use registry::*;
72pub use registry::{
73 clean_package_cache, list_package_cache, search_package_registry, search_rule_package_registry,
74 show_package_registry_info, verify_package_cache,
75};
76pub use skills::*;
77pub(crate) use validation::*;
78
79#[cfg(test)]
80pub(crate) mod test_support;