Documentation
¶
Overview ¶
Package paths centralizes filesystem path resolution honoring AGENTSYNC_HOME and AGENTSYNC_TARGET_ROOT. Production code MUST use this package; lint forbids os.UserHomeDir in *_test.go files.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AgentsyncHome ¶
AgentsyncHome returns the directory where agentsync stores its source repo. Resolution order:
- $AGENTSYNC_HOME (explicit override; absolute path)
- <HomeDir>/.agentsync
func FromHomeRelative ¶
FromHomeRelative is the inverse of HomeRelative: it expands a leading "${HOME}" / "${HOME}/" in a stored state path back to an absolute path rooted at userHome. Paths stored absolute (because they were outside home when recorded) are returned unchanged. Callers that turn a stored state key back into a real filesystem path (e.g. `agent disable --purge`) MUST route through this so they don't operate on the literal "${HOME}/..." string.
func HomeDir ¶
HomeDir returns the effective home dir. AGENTSYNC_TARGET_ROOT takes precedence (used by tests to redirect away from the real $HOME); otherwise falls back to $HOME.
func HomeRelative ¶
HomeRelative converts an absolute destination path into the portable form stored in state files: "${HOME}/.claude.json" instead of the machine-specific absolute "/Users/alice/.claude.json". Paths that do not live under home are returned unchanged.
Without this normalization, state.Files / state.Keys keys would embed the absolute path that existed on the machine that wrote them, so a state file synced via chezmoi from /Users/alice/ to /home/alice/ would have every key prefix change and every native file would reclassify as ForeignCollision on the next apply.
HomeRelative uses forward-slash separators in the stored form so the same key is produced on POSIX and Windows when home is the equivalent path.