pub struct Paths { /* private fields */ }Expand description
Every filesystem location TinyHarness needs, fully injectable.
Construct with Paths::default (real environment), Paths::with_home
(a single root, ideal for tests and portable installs), Paths::from_env
(an injected environment map, for hermetic tests), or Paths::new plus
the with_* builders for arbitrary layouts.
All getters derive their paths on demand, so overriding one root automatically re-derives every file beneath it.
Implementations§
Source§impl Paths
impl Paths
Sourcepub fn from_env<F>(env: F) -> Self
pub fn from_env<F>(env: F) -> Self
Build from an injected environment lookup.
env returns None for unset variables. This is the seam for hermetic
tests: no process-global set_var (and its parallel-test races) needed.
HOME, USERPROFILE, and the XDG_* roots must be absolute, following
the XDG rule that a relative root is ignored. Absoluteness is
platform-dependent — Path::is_absolute treats /home/u as relative
on Windows — so a POSIX-style value inherited from an MSYS/Git Bash
parent shell is rejected there. Note that the lookup is HOME then
USERPROFILE, and the absolute check happens after: a HOME that is
set but unusable leaves home() as None rather than falling through
to USERPROFILE, and the config/data roots degrade to the .-relative
fallback. Paths itself never fails, so the tree stays self-consistent.
The project directory always comes from the process CWD — it is a
working location, not a configuration value — falling back to . if it
cannot be determined.
Sourcepub fn with_home(home: impl Into<PathBuf>) -> Self
pub fn with_home(home: impl Into<PathBuf>) -> Self
Derive every location from a single home directory.
Ignores XDG_* entirely: config goes to <home>/.config/tinyharness
and data to <home>/.local/share/tinyharness. This is the simplest way
to point the library at a disposable root.
The project directory is set to home itself, so the resulting layout
is fully self-contained: nothing outside home is read. Note the
consequence — <home>/.tinyharness/ then acts as both the legacy
personal-skills root and the project .tinyharness/ directory. Use
Paths::new + Paths::with_legacy_home to keep those distinct, as
a real install does.
Sourcepub fn new(config_dir: PathBuf, data_dir: PathBuf, project_dir: PathBuf) -> Self
pub fn new(config_dir: PathBuf, data_dir: PathBuf, project_dir: PathBuf) -> Self
Build from explicit roots, with no implicit home.
Because there is no home, the legacy ~/.tinyharness/skills directory
is not searched — only <config_dir>/skills. Use
Paths::with_legacy_home if you also need the legacy location.
Sourcepub fn with_config_dir(self, dir: impl Into<PathBuf>) -> Self
pub fn with_config_dir(self, dir: impl Into<PathBuf>) -> Self
Override the config directory (default: <home>/.config/tinyharness).
Sourcepub fn with_data_dir(self, dir: impl Into<PathBuf>) -> Self
pub fn with_data_dir(self, dir: impl Into<PathBuf>) -> Self
Override the data directory (default: <home>/.local/share/tinyharness).
Sourcepub fn with_project_dir(self, dir: impl Into<PathBuf>) -> Self
pub fn with_project_dir(self, dir: impl Into<PathBuf>) -> Self
Override the project directory that .tinyharness/ discovery starts from.
Sourcepub fn with_legacy_home(self, home: impl Into<PathBuf>) -> Self
pub fn with_legacy_home(self, home: impl Into<PathBuf>) -> Self
Record a home directory so the legacy ~/.tinyharness/skills location
is searched, without changing any other root.
Sourcepub fn config_dir(&self) -> &Path
pub fn config_dir(&self) -> &Path
The app’s config directory (e.g. ~/.config/tinyharness).
Sourcepub fn project_dir(&self) -> &Path
pub fn project_dir(&self) -> &Path
Directory that .tinyharness/ project discovery walks up from.
Sourcepub fn home(&self) -> Option<&Path>
pub fn home(&self) -> Option<&Path>
Resolved home directory, if one was available.
None for layouts built via Paths::new with no home, or when the
environment exposed no usable HOME.
Sourcepub fn settings_file(&self) -> PathBuf
pub fn settings_file(&self) -> PathBuf
~/.config/tinyharness/settings.json
Sourcepub fn prompts_dir(&self) -> PathBuf
pub fn prompts_dir(&self) -> PathBuf
~/.config/tinyharness/prompts/
Sourcepub fn custom_tools_file(&self) -> PathBuf
pub fn custom_tools_file(&self) -> PathBuf
~/.config/tinyharness/custom_tools.json
Sourcepub fn sessions_dir(&self) -> PathBuf
pub fn sessions_dir(&self) -> PathBuf
~/.local/share/tinyharness/sessions/
Sourcepub fn history_dir(&self) -> PathBuf
pub fn history_dir(&self) -> PathBuf
Directory holding the readline history file.
Same as Paths::data_dir; exposed separately so callers express
intent instead of reaching into the data root.
Sourcepub fn audit_log_file(&self) -> PathBuf
pub fn audit_log_file(&self) -> PathBuf
~/.local/share/tinyharness/audit.jsonl
Sourcepub fn backups_dir(&self) -> PathBuf
pub fn backups_dir(&self) -> PathBuf
~/.local/share/tinyharness/backups/
Sourcepub fn personal_skills_dirs(&self) -> Vec<PathBuf>
pub fn personal_skills_dirs(&self) -> Vec<PathBuf>
Personal skill directories, in increasing precedence order.
<config_dir>/skills first (the documented location), then the legacy
~/.tinyharness/skills when a home directory is known. Duplicates are
collapsed, so a layout where both resolve to the same path yields a
single entry. Earlier entries win on name collisions — see
crate::skill::discover_skills_in.
Sourcepub fn project_config_root(&self) -> PathBuf
pub fn project_config_root(&self) -> PathBuf
<project_dir>/.tinyharness/
Sourcepub fn project_settings_file(&self) -> PathBuf
pub fn project_settings_file(&self) -> PathBuf
Starting point for the .tinyharness/config.json walk-up.
Discovery itself walks ancestors, so the returned path is only the
seed — see crate::config::discover_project_settings.
Sourcepub fn project_custom_tools_file(&self) -> PathBuf
pub fn project_custom_tools_file(&self) -> PathBuf
Starting point for the .tinyharness/custom_tools.json walk-up.
Sourcepub fn project_skills_dir(&self) -> PathBuf
pub fn project_skills_dir(&self) -> PathBuf
<project_dir>/.tinyharness/skills/
Trait Implementations§
impl Eq for Paths
impl StructuralPartialEq for Paths
Auto Trait Implementations§
impl Forget for Paths
impl Freeze for Paths
impl RefUnwindSafe for Paths
impl Send for Paths
impl Sync for Paths
impl Unpin for Paths
impl UnsafeUnpin for Paths
impl UnwindSafe for Paths
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.