Treehouse is a Go CLI tool that manages a pool of git worktrees for parallel AI coding agent workflows. It maintains reusable, pre-warmed worktrees so agents get isolated environments instantly.
main.go— entry point, callscmd.Execute()cmd/— CLI commands (cobra):get,return,status,destroyinternal/config/— config file loading (treehouse.toml)internal/pool/— pool manager (acquire, release, list, destroy) + state fileinternal/git/— git operations (shells out togitbinary)internal/process/— in-use detection and lingering process termination for worktreesinternal/shell/— subshell spawninginternal/ui/— Y/n confirmation prompts
go build -o treehouse .
# or
make buildgo test ./...
# or
make test- No daemon — all operations are inline CLI commands
- Detached HEAD worktrees reset to whichever of local or origin default branch is further ahead (prefers origin on divergence)
- In-use detection is runtime-only (process scanning), never persisted
- State file only tracks pool membership, not usage status
- Git operations shell out to
git(go-git has incomplete worktree support) - Self-healing: stale state entries are auto-removed
This project targets Linux, macOS, and Windows. All new code must work on Windows. Follow these rules:
- Paths: Never hardcode
/as a path separator. Usefilepath.Join(),filepath.Separator, orfilepath.ToSlash()as appropriate. - Shell: Do not assume
/bin/shor$SHELLexist. On Windows, use%COMSPEC%(usuallycmd.exe). Seeinternal/shell/shell.gofor the pattern. - Syscalls: Unix-only syscalls (e.g.,
syscall.Flock) must be isolated behind build tags (//go:build !windows///go:build windows). Seeinternal/pool/lock_unix.goandlock_windows.gofor the pattern. - Build tags: Follow the existing
_unix.go/_windows.gonaming convention (see alsointernal/updater/sysproc_*.go). - CI: The CI matrix runs tests on
ubuntu,macOS, andwindows. Cross-compile locally withGOOS=windows go build ./...to catch issues early. - Process detection:
gopsutilis cross-platform — no special handling needed, but avoid importing platform-specific process APIs directly.
Place treehouse.toml in repo root or ~/.config/treehouse/config.toml:
max_trees = 16