MCPcopy Index your code
hub / github.com/0xSero/open-trees

github.com/0xSero/open-trees @v0.2.0

Chat with this repo
repository ↗ · DeepWiki ↗ · release v0.2.0 ↗ · + Follow
97 symbols 370 edges 29 files 0 documented · 0% updated 3mo agov0.2.0 · 2026-01-07★ 752 open issues
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

Open Trees

OpenCode plugin for fast, safe git worktree workflows.

Install

bun add open-trees

Add the plugin to your OpenCode config (usually ~/.config/opencode/opencode.json):

{
  "plugin": ["open-trees"]
}

Or run the helper CLI:

bunx open-trees add

For local development, build the plugin and point OpenCode at the local package:

bun install
bun run build
{
  "plugin": ["/absolute/path/to/open-trees"]
}

Worktree mode

Worktree tools are gated behind worktree mode so they do not clutter the default tool list. Enable it when you want to work with worktrees, then disable it when you are done.

worktree_mode { "action": "on" }
worktree_mode { "action": "off" }

worktree_mode also prints a help sheet with examples and defaults.

Tools

  • worktree_mode — enable/disable worktree mode and show help.
  • worktree_overview — list, status, or dashboard worktrees.
  • worktree_make — create/open/fork worktrees and sessions.
  • worktree_cleanup — remove or prune worktrees safely.

Examples

Enable worktree mode:

worktree_mode { "action": "on" }

List worktrees:

worktree_overview

Status for all worktrees:

worktree_overview { "view": "status" }

Show the worktree/session dashboard:

worktree_overview { "view": "dashboard" }

Create a worktree (branch derived from name):

worktree_make { "action": "create", "name": "feature audit" }

Start a new session (creates or reuses a worktree):

worktree_make { "action": "start", "name": "feature audit", "openSessions": true }

Open a session in an existing worktree:

worktree_make { "action": "open", "pathOrBranch": "feature/audit", "openSessions": true }

Fork the current session into a worktree:

worktree_make { "action": "fork", "name": "feature audit", "openSessions": true }

Create a swarm of worktrees/sessions:

worktree_make { "action": "swarm", "tasks": ["refactor-auth", "docs-refresh"], "openSessions": true }

Remove a worktree:

worktree_cleanup { "action": "remove", "pathOrBranch": "feature/audit" }

Prune stale worktree entries:

worktree_cleanup { "action": "prune", "dryRun": true }

Defaults and safety

  • Default worktree path (when path is omitted):
  • <repo>/.worktrees/<branch>
  • Relative path inputs are resolved under .worktrees/ to prevent traversal.
  • Branch name is derived from name when branch is omitted (lowercased, spaces to -).
  • worktree_cleanup refuses to delete dirty worktrees unless force: true.
  • All tools return readable output with explicit paths and git commands.

Session workflow

worktree_make actions (start, open, fork) create or reuse a worktree, then create a session in that directory. Each action records a mapping entry at:

  • ~/.config/opencode/open-trees/state.json (or ${XDG_CONFIG_HOME}/opencode/open-trees/state.json)

The session title defaults to wt:<branch>, and the output includes the session ID plus next steps.

Swarm safety notes:

  • worktree_make with action: "swarm" refuses to reuse existing branches or paths unless force: true.
  • It never deletes existing worktrees; it only creates new ones.

Optional command file examples:

# .opencode/command/worktree-start.md
worktree_make { "action": "start", "name": "$1", "openSessions": true }
# .opencode/command/worktree-open.md
worktree_make { "action": "open", "pathOrBranch": "$1", "openSessions": true }

Slash commands (drop these files into .opencode/command):

/worktree-on
/worktree-overview
/worktree-make <name>
/worktree-clean <pathOrBranch>

Development

E2E tests exercise the CLI against a temporary OpenCode config file.

bun run lint
bun run typecheck
bun run build
bun run test
bun run test:e2e
bun pm scan
npm audit --omit=dev

Versioning

Open Trees follows Semantic Versioning and tracks notable changes in CHANGELOG.md.

Contributing

See CONTRIBUTING.md for setup, testing, and release guidelines.

Core symbols most depended-on inside this repo

formatError
called by 53
src/format.ts
err
called by 34
src/result.ts
runGit
called by 12
src/git.ts
branchLabel
called by 11
src/worktree-helpers.ts
formatCommand
called by 10
src/format.ts
formatGitFailure
called by 9
src/git.ts
ok
called by 9
src/result.ts
unwrapSdkResponse
called by 9
src/sdk.ts

Shape

Function 97

Languages

TypeScript100%

Modules by API surface

src/worktree-session.ts10 symbols
src/git.ts8 symbols
src/cli.ts8 symbols
src/state.ts7 symbols
src/format.ts7 symbols
src/worktree.ts6 symbols
src/worktree-dashboard.ts6 symbols
src/paths.ts6 symbols
src/worktree-helpers.ts5 symbols
src/tools.ts5 symbols
src/mode.ts5 symbols
src/worktree-swarm.ts4 symbols

For agents

$ claude mcp add open-trees \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact