* feat(server): branch off a pull request and list every git worktree A workspace.create worktree source with action "branch-off" and a checkoutSource used to check the pull request out, because core took any change request as a checkout. Branch-off now fetches the pull request's head into a remote-tracking ref (origin/<head> for a same-repo head, paseo-pr-<N>/<head> otherwise) and starts the new branch there, with no upstream and no remote added. A request with no action still checks the pull request out, as older clients expect. checkout.worktrees.list returns all git worktrees of the repository, not only the ones Paseo created, so the New workspace screen can offer any of them. Bare and prunable entries are left out. Hosts advertise both through server_info.features: worktreeRefActions and checkoutWorktreeList. Older hosts ignore the branch-off action on a pull request, so the app must gate on the flag. * feat(app): pick an existing worktree, and branch off or check out a ref Isolation now offers Project directory (was "Local"), New worktree, and Existing worktree. Existing worktree is a local workspace at the chosen worktree's path, not a third isolation value, so plugins, preferences, and the create request still see "local". The list comes from checkout.worktrees.list, so it includes worktrees Paseo did not create. The ref picker gains Branches / Pull requests pills and a Branch off / Check out toggle with a tooltip per action. Branches default to Branch off and pull requests to Check out. On a host without worktreeRefActions the toggle is hidden and the defaults apply. Git keeps a branch in one worktree at a time. Picking a held branch in Check out mode moves to the worktree that holds it, and creating from a held branch that was never picked fails with an explanation. Without this the server would silently check out a "<branch>-1" copy. * docs: describe Existing worktree and Branch off / Check out * fix(server): give a fork pull request branch-off a base the repository has A branch off a fork's pull request stored the fork's head as its base, under refs/remotes/paseo-pr-<N>. Create PR then asked for a pull request into a branch the base repository does not have, and the ref piled up in base branch pickers because no remote owns it. The new branch now starts at the fetched head, kept under refs/paseo/change-requests/<N>, and its base is the pull request's base branch. A same-repository branch-off still stacks on the pull request's branch. A routed create_workspace with a prNumber and no mode checks the pull request out again, as before branch-off could start from a pull request. The worktree list skips a locked worktree whose directory is gone, since it cannot be opened. * fix(app): start an existing worktree's agent in that worktree Existing worktree created the workspace at the worktree, but the composer and terminal still used the project directory, so the daemon rejected the first agent as outside the workspace. The screen now derives one working directory from the isolation and uses it for the workspace, the composer, and the terminal. A worktree that left the list is no longer a choice. The ref picker names change requests the way the project's forge does, so a GitLab project shows Merge requests. The schedule form uses the isolation labels Project directory and New worktree. * fix(server): compare a fork pull request branch-off against the remote base The base was stored as the bare branch name, which resolves to the local branch first. A local main behind origin/main put upstream commits in the workspace's changes for its whole life, and a base branch the clone never fetched failed creation. The base branch is now fetched from origin and stored as its remote-tracking ref. * fix(server): take a pull request's base and a checked-out branch from the remote that has them A fork branch-off fetched its base from origin. In a clone whose base repository is upstream, origin is the user's fork or missing, so the base was stale or the create failed. The base now comes from the remote that served the pull request, and a failed base fetch falls back to the bare branch name. Check out of a branch that only a remote other than origin has failed with an unknown branch. The local branch is now created from the one remote-tracking ref with that name, tracking it, as git does. The fork branch-off test passes a git identity to commit-tree, which CI runners do not have. * fix(server): branch off a pull request from the remote that serves it A same-repository pull request's head was fetched into refs/remotes/origin. In a fork clone, upstream serves the pull request and origin is the fork, so the base refresh replaced the head with the fork's branch of the same name and the new branch started from code that is not the pull request. The head now lands under refs/paseo/change-requests/<N>, the branch starts there, and the base is fetched from the remote that served the head. A routed create_workspace that branches off a pull request is refused, as it is on the local host. * fix(app): branch off a plugin's base ref whatever the branch action setBaseRef chose the base but kept the user's Check out switch, so a plugin's base became a checkout or a held-branch error. A base is what a new worktree starts from, so setBaseRef switches branches back to Branch off.
11 KiB
title, description, nav, order, category
| title | description | nav | order | category |
|---|---|---|---|---|
| Git worktrees | Run agents in isolated git worktrees with setup hooks, scripts, and long-running services. | Git worktrees | 11 | Workspaces |
Git worktrees
Git worktrees are one kind of workspace.
A workspace is the place where a task happens. When that workspace is backed by a git worktree, Paseo creates a separate directory on a separate branch so parallel agents never step on each other.
This page covers the git-specific details: where worktrees live, how branches are chosen, and how to configure setup hooks, scripts, terminals, and long-running services through paseo.json.
Layout and workflow
Worktrees live under $PASEO_HOME/worktrees/ by default, grouped by a hash of the source checkout path. You can change the base directory with worktrees.root in config.json. Each worktree gets a slug and a branch when its workspace is created.
~/.paseo/worktrees/
└── 1vnnm9k3/ # hash of source checkout path
├── tidy-fox/ # worktree slug
└── bold-owl/
With a custom root, Paseo keeps the same hashed layout under that directory:
{
"worktrees": {
"root": "/mnt/fast/paseo-worktrees"
}
}
Plugins can choose a location anywhere on disk with worktree.create.before. The worktree-placement example places worktrees next to the source checkout. Paseo validates the path, refuses an existing destination, and manages listing, archive, and deletion there. Recovery uses the recorded path without running creation hooks.
- Create a workspace with worktree isolation, Paseo creates the worktree and runs your setup hooks
- Launch one or more agents in that workspace
- Review the diff against the base branch
- Merge or archive the workspace; after the last workspace using it is archived, Paseo runs teardown and removes the worktree
Scheduled runs archive their workspaces when they finish by default. Turn off Archive on finish in the schedule's app form to keep run workspaces and their worktrees until you archive them.
Create a worktree-backed workspace
In the app, set Isolation to New worktree, then pick a branch or a pull request. Next to the list, choose what the new worktree does with your pick:
- Branch off starts a new branch from it. Branches use this by default.
- Check out works on the branch itself. Pull requests use this by default.
When you branch off a pull request, the new branch starts at the pull request's latest commit and has no upstream. A push does not go to the pull request's branch. The workspace's base branch is the pull request's branch. For a pull request from a fork, it is the branch that the pull request merges into.
Git keeps a branch in one worktree at a time. If you check out a branch that a worktree already has, Paseo selects that worktree under Existing worktree instead of making a copy.
The examples below use the current directory as the source checkout. Pass --path ~/dev/my-app to create the workspace from another checkout.
Branch off from a base branch:
paseo workspace create \
--isolation worktree \
--mode branch-off \
--new-branch feature/auth \
--worktree-slug feature-auth \
--base origin/main
Use origin/main rather than main. Paseo fetches remote refs in the background, so the remote-tracking branch is current, while your local main is whatever you last pulled. An unqualified main resolves to that local branch first, and the worktree starts from stale history. Prefixing the remote names the fetched ref explicitly.
Check out an existing branch:
paseo workspace create \
--isolation worktree \
--mode checkout-branch \
--branch feature/existing \
--worktree-slug existing-copy
Or open a pull request in its own workspace:
paseo workspace create \
--isolation worktree \
--mode checkout-pr \
--pr-number 2186
Add --forge <name> when Paseo cannot infer the forge from the source checkout.
Work in an existing worktree
To continue in a worktree that is already on disk, set Isolation to Existing worktree and pick it. The list shows every git worktree of the repository, including worktrees that you made with git worktree add. The workspace works on the branch that the worktree has checked out. Paseo does not create a branch or run setup.
From the CLI, create a local workspace at the worktree's directory:
paseo workspace create --isolation local --path ~/dev/my-app-feature
Copy local files with .worktreeinclude
Use .worktreeinclude to copy selected gitignored files, such as .env, from your source checkout before setup runs.
paseo.json
Drop a paseo.json in your repo root. Paseo reads it from the committed version of the base branch you picked, so uncommitted changes in other branches don't apply.
{
"worktree": {
"setup": "npm ci",
"teardown": "rm -rf .cache"
},
"scripts": {
"test": { "command": "npm test" },
"web": { "command": "npm run dev", "type": "service", "port": 3000 }
}
}
Setup and teardown
Plugins can use worktree.create.after to write files before setup, terminals, and the first agent.
setup runs once after the worktree is created. Use setup to install dependencies and run project initialization. Use .worktreeinclude to copy ignored files such as .env. teardown runs during archive, before the directory is removed.
{
"worktree": {
"setup": "npm ci\nnpm run db:migrate",
"teardown": "npm run db:drop || true"
}
}
Both fields accept a multiline shell script or an array of commands; commands run sequentially either way.
Commands run with the worktree as cwd. Use $PASEO_SOURCE_CHECKOUT_PATH to reach files in the original checkout (untracked config, local caches, etc).
Teardown commands share a one minute limit. Set teardownTimeoutMs to change it, in milliseconds:
{
"worktree": {
"teardown": "docker compose down",
"teardownTimeoutMs": 300000
}
}
At the limit, Paseo tries to stop the command and its child processes and stops waiting for output. If teardown fails or reaches the limit, the workspace still archives and the worktree stays on disk. teardownTimeoutMs accepts whole numbers from 1 to 2147483647. Other values use the default.
Scripts and services
scripts are named commands you can run inside a worktree on demand. Mark one as a service and Paseo supervises it as a long-running process, assigns it a port, and routes HTTP traffic to it through the daemon's reverse proxy.
Run them from the app, or manage them from automation with paseo script and the workspace-script MCP tools.
Plain scripts
{
"scripts": {
"test": { "command": "npm test" },
"lint": { "command": "npm run lint" },
"generate": { "command": "npm run codegen" }
}
}
Services
{
"scripts": {
"web": {
"type": "service",
"command": "npm run dev -- --port $PASEO_PORT",
"port": 3000
},
"api": {
"type": "service",
"command": "npm run api -- --port $PASEO_PORT"
}
}
}
Omit port to let Paseo auto-assign one. Bind your process to $PASEO_PORT rather than hard-coding, each worktree gets a distinct port so multiple copies of the same service coexist.
Dynamic port allocation
By default, Paseo asks the OS for an available ephemeral port. Configure a range globally in
~/.paseo/config.json or per project in paseo.json:
// ~/.paseo/config.json
{
"worktrees": {
"servicePorts": { "range": "3000-4000" }
}
}
// paseo.json
{
"worktree": {
"servicePorts": { "range": "3000-4000" }
}
}
The range is inclusive. A project servicePorts block replaces the global block. An explicit
service port always wins over either setting.
For an external allocator, configure portScript instead:
{
"worktree": {
"servicePorts": { "portScript": "/usr/bin/portmake" }
}
}
Paseo runs the executable in the workspace directory with four arguments: service name, workspace
ID, branch name, and worktree path. Since the script is executed directly without a shell, portScript must point to a real executable (such as a compiled binary or a script with a proper shebang line like #!/bin/bash) rather than an inline shell command or pipeline. If you need shell evaluation or pipelines, wrap them in a small executable script. A missing branch is passed as an empty string. The same values
are available as PASEO_SCRIPTNAME, PASEO_WORKSPACE_ID, PASEO_BRANCH_NAME, and
PASEO_WORKTREE_PATH. It must print one valid TCP port to stdout. portScript wins over range in
the same block. Paseo trusts the external allocator, so the returned port may already be in use, for
example by a service Paseo will attach to.
Reverse proxy
Every service is reachable through the daemon at a deterministic hostname:
http://<script>--<branch>--<project>.localhost:<daemon-port>
# on the default branch, the branch label is dropped:
http://<script>--<project>.localhost:<daemon-port>
*.localhost resolves to 127.0.0.1 on modern systems, so these URLs work out of the box. The proxy supports WebSocket upgrades.
Service-to-service
Services launched from the same workspace see each other's ports and proxy URLs. Given web and api above, each process gets:
PASEO_PORT=3000 # this service's port
PASEO_URL=http://web--my-app.localhost:6767 # this service's proxy URL
PASEO_SERVICE_API_PORT=51732
PASEO_SERVICE_API_URL=http://api--my-app.localhost:6767
PASEO_SERVICE_WEB_PORT=3000
PASEO_SERVICE_WEB_URL=http://web--my-app.localhost:6767
Script names are upper-cased and non-alphanumerics become _. Point your frontend at $PASEO_SERVICE_API_URL instead of hard-coding a port.
Terminals
Open terminals automatically when a worktree is created. Useful for tailing logs or leaving a REPL ready to go.
{
"worktree": {
"terminals": [
{ "name": "logs", "command": "tail -f dev.log" },
{ "name": "shell", "command": "bash" }
]
}
}
Environment variables
Setup, teardown, scripts, and services all see:
$PASEO_SOURCE_CHECKOUT_PATH, the original repo root$PASEO_WORKTREE_PATH, the worktree directory$PASEO_BRANCH_NAME, the worktree's branch$PASEO_WORKTREE_PORT, legacy per-worktree port (prefer$PASEO_PORTinside services)
Services additionally get:
$PASEO_PORT, this service's assigned port$PASEO_URL, this service's proxy URL$PASEO_SERVICE_<NAME>_PORT/_URL, peer service ports and URLs$HOST,127.0.0.1for local-only daemons,0.0.0.0when the daemon binds all interfaces
Manage the workspace
paseo workspace ls
paseo run --workspace <workspace-id> "implement auth"
paseo workspace rename <workspace-id> "Auth rework"
paseo workspace archive <workspace-id>
For the common case, paseo run --new-workspace worktree --worktree-mode branch-off --new-branch feature/auth --base origin/main "implement auth" creates both the workspace and its first agent.