worktreeman
v0.2.6
Published
worktreeman is the local app for creating Git worktrees, preparing branch-scoped runtime environments, managing background commands, and attaching to tmux-backed browser terminals.
Readme
worktreeman
worktreeman is the local app for creating Git worktrees, preparing branch-scoped runtime environments, managing background commands, and attaching to tmux-backed browser terminals.
- Hosted docs: https://ericwooley.github.io/worktreeman/
Quick Start
One-off run without a global install:
npx -y worktreeman create --cwd /path/to/repo
npx -y worktreeman init --cwd /path/to/repo
npx -y worktreeman start --cwd /path/to/repoThen open the printed local URL, usually http://localhost:4312.
Quick start notes:
npx -y worktreeman startis the fastest way to try the published CLI without installing it globallycreatebootstraps the required bare-layout repository structureinitcreateswtm-settings/worktree.ymlso the UI has runtime config to loadstartserves the local UI and prints the resolved bind host and port
Local Development
pnpm install
pnpm run dev -- create --cwd /path/to/repo
pnpm run dev:watch -- --cwd /path/to/repo
node --import tsx src/cli.ts start --cwd /path/to/repoThen open http://localhost:4312.
pnpm run dev -- <subcommand>runs the CLI once and exitspnpm run dev -- create --cwd /path/to/repobootstraps the required bare layout with.bare/,.git,main/, andwtm-settings/pnpm run dev -- clone <remote> --cwd /path/to/repoclones a remote into that same layout and checks outmain/pluswtm-settings/pnpm run dev:watch -- --cwd /path/to/repostarts the watched local server flow and refuses to run outside the required bare layoutworktreeman startdefaults to localhost for the local-only UIworktreeman start --host autoprefers a Tailscale address, then WireGuard, then a private LAN address, then localhostworktreeman start --host 0.0.0.0 --dangerously-expose-to-networkis required for wildcard binds because the terminal UI would otherwise be exposed to the network
Host selection notes:
--host autoprefers a Tailscale interface, then WireGuard, then a private LAN address, and finally falls back to localhost. This is convenient when using remote networking such as Tailscale.- Binding to wildcard hosts like
0.0.0.0will refuse to start unless you pass--dangerously-expose-to-networkto acknowledge that the terminal-enabled UI will be accessible on all interfaces.
Required repository layout
worktreeman only runs in this layout:
repo-root/
.bare/
.git # exactly: gitdir: ./.bare
main/
wtm-settings/.bare/must be a bare Git repository.gitmust be a plain text file containing exactlygitdir: ./.barewtm-settings/worktree.ymlis the only config source- generated feature worktrees live directly under the same root, for example
repo-root/feature-x
Build outputs
pnpm run builddist/webcontains the local app frontend used by the CLI serverdist/docscontains the standalone documentation website generated from Markdown files indocs/
Package distribution
Run without installing globally (recommended for one-off use):
npx -y worktreeman startOr install globally for repeated local use:
npm install -g worktreeman
worktreeman --helpnpx -y worktreeman startruns the published CLI without a global install and immediately starts the UInpm install -g worktreemaninstalls the command globally for repeated local usenpm packandnpm publishuse theprepackscript to builddist/cli.jsanddist/web
Configuration Examples
Minimal worktree.yml:
runtimePorts:
- PORT
derivedEnv:
APP_URL: http://localhost:${PORT}
quickLinks:
- name: App
url: http://localhost:${PORT}
startupCommands:
- pnpm install
backgroundCommands:
Web dev:
command: pnpm run devPin the local UI to a preferred port when available:
preferredPort: 4900Configuration notes:
preferredPortapplies to the worktreeman HTTP server itself; if that port is busy and you did not explicitly force a CLI port, worktreeman will choose another free portruntimePortsreserve loopback ports for your app processes and inject them into startup commands, background commands, tmux shells, derived env, and quick linksstartupCommandsrun sequentially in the user's shell viaSHELL -lc '<command>'backgroundCommandsare long-running processes managed under PM2 after startup commands finish
Troubleshooting
worktreeman startfails outside the managed layout: runworktreeman create --cwd /path/to/repoorworktreeman clone <remote> --cwd /path/to/repofirst- Browser terminal loads but copy-mode clipboard does not reach the system clipboard: add the tmux clipboard settings from the
tmux clipboardsection below - Expected
localhost:4312but got another port: a preferred/default port was already in use, so worktreeman allocated another free port and printed it at startup - Remote host binding refused: wildcard hosts such as
0.0.0.0require--dangerously-expose-to-network - Startup command behaves differently than expected: remember commands run through the user's shell, so shell startup files and shell syntax can affect behavior
Platform support
- The published CLI runs on Node.js 20+; pnpm is the expected package manager for developing this repository
- macOS and Linux are the intended platforms because the runtime terminal depends on
tmuxand a Unix-style shell environment - Windows is not currently supported for the full runtime flow
tmux clipboard
For tmux-native copy mode in the browser terminal, add clipboard support to your tmux config:
set -s set-clipboard external
set -g allow-passthrough on
set -g terminal-features 'xterm-256color:clipboard'
set -as terminal-overrides ',xterm-256color:Ms=\E]52;%p1%s;%p2%s\a'set-clipboard externallets tmux copy-mode push selections to the outer terminal clipboard without accepting clipboard writes from every app inside tmuxallow-passthrough onhelps modern passthrough-friendly terminal flows- the
terminal-featuresandterminal-overrideslines ensure OSC 52 clipboard support is available forxterm-256color
Docs source
docs/*.mdis the source of truth for the standalone docs websitepnpm run build:docsbuilds the publishable docs sitepnpm run preview:docsbuilds and serves the docs site athttp://127.0.0.1:4174
CLI help
node --import tsx src/cli.ts --help
node --import tsx src/cli.ts init --help