This repository has been archived on 2026-08-16. You can view files and clone it, but cannot push or open issues or pull requests.
ollie-core/paths/paths.go

80 lines
2.0 KiB
Go

package paths
import (
"os"
"path/filepath"
"strconv"
"strings"
)
// ExpandHome replaces a leading "~" or "~/" with the user's home directory.
func ExpandHome(path string) string {
if path == "~" || strings.HasPrefix(path, "~/") {
if home, _ := os.UserHomeDir(); home != "" {
return home + path[1:]
}
}
return path
}
// CfgDir returns the ollie config root: ~/.config/ollie.
func CfgDir() string {
home, _ := os.UserHomeDir()
return home + "/.config/ollie"
}
// DataDir returns the ollie data root: ~/.local/share/ollie.
func DataDir() string {
home, _ := os.UserHomeDir()
return home + "/.local/share/ollie"
}
// ToolsDir returns the tools directory: CfgDir()/tools.
func ToolsDir() string {
return CfgDir() + "/tools"
}
// PromptsDirs returns prompt directories: [CfgDir()/prompts].
func PromptsDirs() []string {
return []string{CfgDir() + "/prompts"}
}
// AgentsDirs returns agent directories: [CfgDir()/agents].
func AgentsDirs() []string {
return []string{CfgDir() + "/agents"}
}
// SkillsDir returns the skills directory: CfgDir()/skills.
func SkillsDir() string {
return CfgDir() + "/skills"
}
// MemoryDir returns the memory directory: CfgDir()/memory.
func MemoryDir() string {
return CfgDir() + "/memory"
}
// TranscriptDir returns the transcript directory: CfgDir()/transcript.
func TranscriptDir() string {
return CfgDir() + "/transcript"
}
// TmpDir returns the temporary working directory: $TMPDIR/ollie.
func TmpDir() string {
return filepath.Join(os.TempDir(), "ollie")
}
// UsageLogFile returns the usage log file: DataDir()/usage.jsonl.
func UsageLogFile() string {
return filepath.Join(DataDir(), "usage.jsonl")
}
// ElevateSocket returns the elevation broker socket: XDG_RUNTIME_DIR/ollie/elevate.sock.
func ElevateSocket() string {
xdgRuntime := os.Getenv("XDG_RUNTIME_DIR")
if xdgRuntime == "" {
xdgRuntime = filepath.Join("/run/user", strconv.FormatInt(int64(os.Getuid()), 10))
}
return filepath.Join(xdgRuntime, "ollie", "elevate.sock")
}