Documentation
¶
Overview ¶
Package appname is the single source of truth for the running app's *path-safe identifier* — the slug used in `~/.<app>/` for DB, logs, agents Layout, gate spec/socket. Every artefact lands under one tree.
Resolution order (first non-empty wins):
- BuildAppName — ldflag-baked at compile time by `wick build`
- wick.yml — top-level `name:` field, walked from cwd
- "wick" — last-ditch fallback
`APP_NAME` env var is intentionally NOT in this chain. That env holds the human-readable display label (e.g. "My App" with spaces and capitalization) used by the UI / login / systray title — it must not contaminate filesystem paths. Path identifiers come from `name:` in wick.yml, which already enforces no-space slug rules.
The package has zero deps on the rest of the codebase so any other internal package can import it without risking cycles.
Index ¶
Constants ¶
const DataDirEnv = "WICK_DATA_DIR"
DataDirEnv is the env var that overrides the root data directory.
Unlike APP_NAME (a display label, deliberately kept out of path math — see the package doc), this one IS a path and is the only supported way to relocate the tree for a downloaded binary: `BuildAppName` is baked in at compile time and wick.yml is absent next to a release binary, so without this env a user has no way to move their data off `~/.<app>/`.
Variables ¶
var BuildAppName = ""
BuildAppName is the ldflag injection target. Builder writes here via `-X github.com/yogasw/wick/internal/appname.BuildAppName=<name>`. Empty when not built via `wick build` (e.g. `go run`, VSCode debug).
var BuildAppVersion = "dev"
BuildAppVersion is the ldflag injection target for the downstream app version. Injected via `-X github.com/yogasw/wick/internal/appname.BuildAppVersion=<ver>`. Falls back to "dev" when not injected.
Functions ¶
func AgentsDir ¶ added in v0.39.0
func AgentsDir() string
AgentsDir is the agents sub-tree (`<DataDir>/agents`): sessions, projects, presets, workflows, the gate dir, and the control sockets.
func DataDir ¶ added in v0.39.0
func DataDir() string
DataDir returns the root directory every wick artefact lives under — the DB, config.json, logs, skills, plugins, and the whole agents tree. Sub-trees are derived from it, never rebuilt from the home dir, so a single override moves all of them together.
Resolution order (first non-empty wins):
- $WICK_DATA_DIR — absolute path, or `~/...` which expands to the home dir. A relative path is made absolute against the cwd.
- ~/.<app>/ — the platform default, `<app>` from Resolve().
- ./.<app>/ — only when the home dir lookup fails, so callers never have to handle an error or a panic.
Cached for the process lifetime: the inputs are fixed at start-up, and a path that changed mid-run would split one process's data across two trees. Tests call ResetDataDirForTest to re-resolve.
func DataDirOverride ¶ added in v0.39.0
func DataDirOverride() string
DataDirOverride returns the normalized $WICK_DATA_DIR, or "" when the env is unset. Callers that keep their own default (userconfig.Dir, whose fallback is keyed on a caller-supplied app name rather than on Resolve()) use this to honour the override without giving up that default. Everything else should just call DataDir.
func LogsDir ¶ added in v0.39.0
func LogsDir() string
LogsDir holds the per-day log files (`<DataDir>/logs`) written by the server, worker, app, and gate.
func ResetDataDirForTest ¶ added in v0.39.0
func ResetDataDirForTest()
ResetDataDirForTest clears the cached DataDir so the next call re-reads $WICK_DATA_DIR. Test-only; production inputs never change at runtime.
func Resolve ¶
func Resolve() string
Resolve returns the active app name. Result is cached for the process lifetime — chain inputs (BuildAppName, env, yml) don't change at runtime, so we resolve exactly once.
func ResolveAfterChdir ¶ added in v0.13.0
func ResolveAfterChdir() string
ResolveAfterChdir re-runs resolution from scratch and re-caches the result. Call this once after os.Chdir to the project root so that wick.yml-based names are picked up even when Resolve() fired before the chdir (e.g. MCP stdio). No-op if BuildAppName is already baked via ldflags (ldflag always wins).
Types ¶
This section is empty.