Documentation
¶
Overview ¶
Package setup runs the post-creation steps after a worktree is added: copying env/config files and installing dependencies.
Index ¶
- func Apply(changes []Change) (int, error)
- func ApplySymlinks(changes []SymlinkChange) (int, error)
- func DeregisterClaudePlugins(worktreePath string) error
- func DirenvAllow(repoRoot, worktreePath string)
- func InstallDeps(worktreePath string) error
- func PlanAll(srcRoot, dstRoot string) ([]Change, []SymlinkChange, error)
- func RegisterClaudePlugins(repoRoot, worktreePath string) error
- func SetupConfigs(srcRoot, dstRoot string) error
- type Change
- type ChangeKind
- type SymlinkChange
- type SymlinkKind
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Apply ¶
Apply writes the non-identical changes to disk. Returns the number of files actually written and the first error encountered; per-file failures are logged to stderr and do not stop subsequent files.
func ApplySymlinks ¶
func ApplySymlinks(changes []SymlinkChange) (int, error)
ApplySymlinks creates, repairs, or removes symlinks for the non-identical changes. Returns the number of symlink operations performed and the first error encountered.
func DeregisterClaudePlugins ¶
DeregisterClaudePlugins removes plugin entries whose projectPath matches worktreePath from ~/.claude/plugins/installed_plugins.json.
func DirenvAllow ¶
func DirenvAllow(repoRoot, worktreePath string)
DirenvAllow runs `direnv allow` in worktreePath if:
- .envrc exists there, AND
- its SHA-256 matches the .envrc at repoRoot (i.e. it's the file we just copied, not something that changed out from under us)
If direnv is not on PATH the call is silently skipped.
func InstallDeps ¶
InstallDeps walks worktreePath, picks the highest-priority lockfile in each directory, and runs `<tool> install` there. Skips entirely if WTREE_SKIP_INSTALL is set.
func PlanAll ¶
func PlanAll(srcRoot, dstRoot string) ([]Change, []SymlinkChange, error)
PlanAll loads config once and returns both copy and symlink plans together.
func RegisterClaudePlugins ¶
RegisterClaudePlugins copies any local-scoped plugin entries for repoRoot into entries for worktreePath in ~/.claude/plugins/installed_plugins.json.
func SetupConfigs ¶
SetupConfigs runs both copy and symlink plans and applies them. This is the add-time entry point.
Types ¶
type Change ¶
type Change struct {
Rel string // path relative to the source/destination roots
Src string
Dst string
Kind ChangeKind
}
Change is one source→destination file copy in a Plan.
type ChangeKind ¶
type ChangeKind int
ChangeKind classifies what an Apply call would do for one file.
const ( ChangeNew ChangeKind = iota // file does not exist at the destination ChangeOverwrite // file exists at the destination with different content ChangeIdentical // file exists with identical content (no-op on Apply) )
type SymlinkChange ¶
type SymlinkChange struct {
Rel string // path relative to the source/destination roots
Src string // absolute path in primary worktree
Dst string // absolute path in child worktree
Kind SymlinkKind
}
SymlinkChange is one source→destination symlink in a PlanSymlinks result.
func PlanSymlinks ¶
func PlanSymlinks(srcRoot, dstRoot string) ([]SymlinkChange, error)
PlanSymlinks resolves the configured symlink patterns against srcRoot and reports the per-entry changes that linking into dstRoot would produce. It does not touch the filesystem under dstRoot. Each pattern match (file or directory) becomes a single symlink — directories are not walked.
type SymlinkKind ¶
type SymlinkKind int
SymlinkKind classifies what an ApplySymlinks call would do for one entry.
const ( SymlinkNew SymlinkKind = iota // nothing at dst — create symlink SymlinkExists // correct symlink already in place — no-op SymlinkWrong // symlink present but points elsewhere — re-link SymlinkConflict // regular file/dir at dst — skip SymlinkOrphaned // symlink points to srcRoot but pattern no longer active — remove )