Module paths

Module paths 

Source
Expand description

Path utilities for gglib data directories and user-configurable locations.

This module provides the canonical path resolution for all gglib components:

  • Database location
  • Models directory
  • Llama.cpp binaries
  • Application data and resource roots

Β§Design

  • Returns PathBuf and PathError for clear error handling
  • No interactive/terminal I/O - adapters handle user prompts separately
  • OS-specific logic is kept private in platform

ModulesΒ§

config πŸ”’
Configuration file utilities.
database πŸ”’
Database path resolution.
ensure πŸ”’
Directory creation and verification utilities.
error πŸ”’
Path-related error types.
llama πŸ”’
Llama.cpp binary path resolution.
models πŸ”’
Models directory resolution.
pids πŸ”’
PID file directory path resolution.
platform πŸ”’
Platform-specific path detection and resolution.
resolver πŸ”’
Pure path resolver for testing and CLI introspection.

StructsΒ§

ModelsDirResolution
Resolution result for the models directory.
ResolvedPaths
All resolved paths captured in a single struct.

EnumsΒ§

DirectoryCreationStrategy
Strategy for how to handle missing directories when ensuring they exist.
ModelsDirSource
How the models directory was derived.
PathError
Errors that can occur during path resolution and directory operations.

ConstantsΒ§

DEFAULT_MODELS_DIR_RELATIVE
Default relative location for downloaded models under the user’s home directory.

FunctionsΒ§

data_root
Get the root directory for application data (database, config).
database_path
Get the path to the gglib database file.
default_models_dir
Return the platform-specific default models directory.
ensure_directory
Ensure the provided directory exists and is writable according to the chosen strategy.
env_file_path
Location of the .env file that stores user overrides.
gglib_data_dir
Get the gglib data directory containing llama binaries.
is_prebuilt_binary
Check if we are running from a pre-built binary (not from the source repo).
llama_cli_path
Get the path to the managed llama-cli binary.
llama_config_path
Get the path to the llama build configuration file.
llama_cpp_dir
Get the path to the llama.cpp repository directory.
llama_server_path
Get the path to the managed llama-server binary.
persist_env_value
Persist a key=value pair into the .env file.
persist_models_dir
Persist the selected models directory into .env.
pids_dir
Returns the directory where PID files are stored.
resolve_models_dir
Resolve the models directory from an explicit override, env var, or default.
resource_root
Get the root directory for application resources (binaries, static assets).
verify_writable
Verify a directory is writable by attempting to create a test file.