Skip to main content

Paths

Struct Paths 

Source
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

Source

pub fn from_env<F>(env: F) -> Self
where F: Fn(&str) -> Option<String>,

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.

Source

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.

Source

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.

Source

pub fn with_config_dir(self, dir: impl Into<PathBuf>) -> Self

Override the config directory (default: <home>/.config/tinyharness).

Source

pub fn with_data_dir(self, dir: impl Into<PathBuf>) -> Self

Override the data directory (default: <home>/.local/share/tinyharness).

Source

pub fn with_project_dir(self, dir: impl Into<PathBuf>) -> Self

Override the project directory that .tinyharness/ discovery starts from.

Source

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.

Source

pub fn config_dir(&self) -> &Path

The app’s config directory (e.g. ~/.config/tinyharness).

Source

pub fn data_dir(&self) -> &Path

The app’s data directory (e.g. ~/.local/share/tinyharness).

Source

pub fn project_dir(&self) -> &Path

Directory that .tinyharness/ project discovery walks up from.

Source

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.

Source

pub fn settings_file(&self) -> PathBuf

~/.config/tinyharness/settings.json

Source

pub fn prompts_dir(&self) -> PathBuf

~/.config/tinyharness/prompts/

Source

pub fn custom_tools_file(&self) -> PathBuf

~/.config/tinyharness/custom_tools.json

Source

pub fn sessions_dir(&self) -> PathBuf

~/.local/share/tinyharness/sessions/

Source

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.

Source

pub fn audit_log_file(&self) -> PathBuf

~/.local/share/tinyharness/audit.jsonl

Source

pub fn backups_dir(&self) -> PathBuf

~/.local/share/tinyharness/backups/

Source

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.

Source

pub fn project_config_root(&self) -> PathBuf

<project_dir>/.tinyharness/

Source

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.

Source

pub fn project_custom_tools_file(&self) -> PathBuf

Starting point for the .tinyharness/custom_tools.json walk-up.

Source

pub fn project_skills_dir(&self) -> PathBuf

<project_dir>/.tinyharness/skills/

Trait Implementations§

Source§

impl Clone for Paths

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Paths

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Paths

Source§

fn default() -> Self

Resolve from the real process environment and CWD.

Source§

impl Eq for Paths

Source§

impl PartialEq for Paths

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more