datadir

package
v0.1.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 9, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package datadir resolves and (lazily) creates tai's global per-user data directory.

Precedence (per add-tai-foundation/specs/cli-framework/spec.md):

  1. $TAI_DATA_DIR if set and non-empty (used verbatim — no suffix).
  2. $XDG_DATA_HOME/tai/ if $XDG_DATA_HOME is set and non-empty.
  3. $HOME/.local/share/tai/ on Linux and macOS.
  4. %LOCALAPPDATA%\tai\ on Windows.

Resolve MUST NOT touch the filesystem. EnsureWritable creates the directory tree lazily and reports DATA_DIR_UNWRITABLE on failure.

Stability contract: this package is part of the pkg/ public surface — its exported functions and the DATA_DIR_UNWRITABLE errcode are append-only. Promoted from plugins/triage/internal/datadir in Phase 2 of pivot-to-ai-as-code (when core/internal/sync started needing data-directory resolution).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EnsureWritable

func EnsureWritable() (string, error)

EnsureWritable resolves the data directory and creates it (and any missing parents) if absent, returning the resolved path on success.

Returns a *errcode.Error{Code: DataDirUnwritable} if the directory cannot be created or is not writable. The remediation block points at $TAI_DATA_DIR as the most direct fix.

func Resolve

func Resolve() (string, error)

Resolve returns the path tai should use for its data directory. It reads environment variables and (on POSIX) the user's home directory, but creates no files or directories.

Returns an error only when the home directory cannot be located AND no explicit override is set — a rare configuration on real machines.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL