maestro

module
v0.0.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 8, 2026 License: MIT

README

Maestro

tmux for coding agents. Run Codex, agy, OpenCode, Claude Code, Qoder, Kimi Code and Cursor Agent side by side in tabs. Each tab is a task with its own git worktree that becomes a PR, and Maestro keeps the history so you can switch agents without losing context.

[!NOTE] P1, P2, and P3 are implemented: isolated worktrees, embedded agent terminals, session resume, native conversation history and context handoff, plus GitHub PR workflows and safe cleanup. See docs/PLAN.md.

Install (from source)

go install github.com/mmoehabb/maestro/cmd/maestro@latest

Development

Product website

The static landing page lives in website/. It uses plain HTML, CSS, and JavaScript with local assets and no build step or package dependencies. Preview it from the repository root:

python3 -m http.server 8000 --directory website

Open http://localhost:8000. The terminal preview contains illustrative sessions; its tabs demonstrate the workflow without running real agents.

To publish, set Settings → Pages → Build and deployment → Source to GitHub Actions in the GitHub repository. The pages.yml workflow deploys only website/ when website files or the workflow change on main. You can also run it manually from the Actions tab on main. It uses the built-in GITHUB_TOKEN; no custom deployment secret is needed. The expected project URL is https://mmoehabb.github.io/maestro/. Relative asset paths also support a custom domain without code changes.

Application

Requires Go 1.26+ (see go.mod). Optional: golangci-lint v2.9.0+ built with a compatible Go version, goreleaser v2.

make build      # bin/maestro
make test       # go test -race ./...
make lint       # run the pinned Go-compatible golangci-lint
make snapshot   # local cross-platform release build into dist/

make lint and make fmt fetch the pinned linter through Go without replacing an installed binary. Set GOLANGCI_LINT=golangci-lint to use your own compatible installation.

Available now

Run inside a Git checkout with at least one commit:

maestro new "Fix login" -a codex -b main -p "Repair the login flow"
maestro               # restore all tasks and start/resume their agents
maestro open fix-login # restore tabs, focused on this task
maestro ls
maestro ls --all --json
maestro tabs --archived # list archived tabs (tabs is an alias for ls)
maestro archive fix-login
maestro reopen fix-login
maestro rm fix-login    # delete an archived task and its saved history
maestro switch fix-login -a agy # open the TUI and hand off this task
maestro history fix-login
maestro history fix-login --json
maestro config         # print effective configuration
maestro config path   # print global config file location
maestro doctor        # executable paths, versions, keyboard probe and prefix

new provisions a task without opening the TUI, so it also works in scripts. maestro and maestro open launch all unarchived task tabs. Creating a task inside the TUI immediately launches its agent. A failed agent launch stays visible with retry instructions. Quitting stops the agents and saves session identity, exit status and terminal fallback history; this is not a daemon.

The prefix is ctrl+m after the terminal confirms keyboard disambiguation, otherwise ctrl+b. Enter always reaches the agent. Use prefix ? for help:

Keys Action
alt+1…9, alt+h / alt+l Select, previous / next tab
prefix : Search actions and tasks
prefix D View diff against the task base
prefix s Toggle tabs / sidebar
prefix T Preview and save a color theme
prefix a Switch agents with context handoff
prefix h Task timeline and expandable conversation history
prefix H Copy the handoff instruction for manual-prompt agents
prefix n Edit task notes (Ctrl+S saves, Esc cancels)
prefix c New task: title, base branch, agent and prompt
prefix d Hide the current tab and stop its agent
prefix p, prefix P, prefix m Push, create/open PR, merge PR
prefix &, prefix u Archive/clean up, reopen an archived task
prefix x, prefix r Stop, restart/resume the agent
prefix R Explicitly start a fresh session
prefix t Open shell in task worktree
prefix z Suspend the maestro app
prefix [ Scroll history with j/k, arrows and page keys; y copies history
prefix e Open default/configured editor in current worktree
prefix prefix Send the prefix itself to the agent
prefix q Stop agents, save and quit

Click tabs to switch or drag to reorder. Mouse input within the terminal is forwarded; the wheel enters Maestro's scrollback. Background panes keep processing output. Runtime icons show Starting, Working, Done, NeedsInput, Exited and Crashed. Done uses native turn signals when available. A recognized native turn stays Working through silent tool execution; terminal notifications and the configurable quiet timer serve as fallbacks when native monitoring is unavailable. These fallbacks are heuristics, not proof that a long-running tool has finished. Prompt hints also use heuristics. icons = "nerd" conservatively uses Unicode glyphs because terminal glyph width does not reliably identify installed fonts; ascii uses ASCII runtime icons.

Palette, diff, layouts, and themes

Use prefix : to search actions and tasks with fuzzy matching. Arrow keys select, Enter runs the selection, and Escape returns to the agent. Actions retain their usual confirmations. prefix ? opens scrollable help.

prefix D opens a read-only diff of the task base against the current tracked working tree, including committed, staged, and unstaged changes. Untracked paths are listed separately and binary changes are identified. Use arrows/j/k to scroll, left/right to pan, r to refresh, and Escape to close. Output is capped at 2 MiB with an explicit truncation notice. External diff tools and textconv filters are disabled in this view. prefix d still hides the current tab.

prefix s toggles a sidebar; below 72 columns it falls back to top tabs. Drag a task onto another task to reorder in either layout. The order is saved in SQLite and restored on the next launch. Your active agent stays selected.

Choose from four built-in themes:

Theme Command name Colors
Forest dark Forest green, peach, and sage
Paper light Warm cream, ink, and terracotta
Catppuccin catppuccin Charcoal with pastel blue and lavender
Tokyo Night tokyo-night Deep navy, blue, and violet
maestro theme                     # list themes and the current selection
maestro theme tokyo-night         # save globally
maestro theme light --local       # save for this repository
maestro theme auto                # follow the terminal background

Inside the TUI, use prefix T or search “Choose color theme” in the command palette. ↑/↓ previews each theme immediately; Enter saves and Escape restores the previous choice. The picker saves globally unless the repository already sets its own theme, in which case it updates that override. CLI changes apply on the next TUI launch. --local resolves linked worktrees to the main checkout. Existing configuration comments and unrelated settings are preserved.

auto is the default selection mode rather than an additional palette. Set theme to auto, dark, light, catppuccin, or tokyo-night. Auto asks the terminal for its background color and defaults to dark if it gets no reply. The default dark palette matches the website preview: a forest-green surface, peach accent, and sage status colors. Light mode uses the site's cream and ink palette. The shell has spaced tabs, an agent/status heading, inset panes, and separate Git status and shortcut bars; short terminals use compact spacing. Explicit Catppuccin and Tokyo Night palettes remain available. Themes style Maestro's interface; agent programs retain their own ANSI colors. Custom palettes require all eight colors:

theme = "my-theme"

[themes.my-theme]
background = "#20242c"
foreground = "#e5e9f0"
muted = "#adb8c9"
accent = "#8fbcff"
success = "#a3d9a5"
warning = "#f0ca80"
error = "#f49b9b"
merged = "#c9adf0"

Background Done/NeedsInput transitions show local alerts and briefly highlight the task. Desktop delivery honors [activity] notify_on = ["done", "needs_input"]; use notify_on = [] to disable it. An unfocused terminal also receives alerts for its selected task when focus reporting is supported. Linux uses notify-send, macOS uses osascript, and Windows uses PowerShell and a temporary notification-area icon. OS permissions, desktop services, and notification settings determine delivery. Missing helpers leave the in-app alerts available and report availability once.

See custom agent configuration for complete template, session identity, manual prompt, handoff, and troubleshooting guidance, and the P4 UX checklist for manual acceptance checks.

Archive and delete tabs

maestro archive <task> hides a task from the tab bar and default listings. Inside the TUI, prefix d stops the current agent, saves its final history, and archives the tab. Worktrees, branches, session identity, and saved history are preserved. maestro reopen <task> makes the tab available on the next launch.

Reopening a task with a retained PR restores its PR lifecycle so polling can detect changes made while it was archived. After cleanup of a completed task, reopening creates a fresh branch for the next cycle. This allows normal pushes after a squash merge even when GitHub retains the previous source branch.

Recreated worktrees receive the configured worktree.copy files and worktree.setup commands before the task becomes active. Failed provisioning keeps the task archived; retrying reopen resumes at the unfinished step. Cleanup preserves commit snapshots under refs/maestro/recovery/<task-id>/<commit> across successive task cycles, including local commits saved during force cleanup.

maestro tabs (also ls or list) lists unarchived tasks. Use --all to include archived tasks, --archived to show only archived tasks, and --json for scripts. These listings remain available while the TUI is running.

maestro rm <task> (also delete) permanently deletes an archived task and all its saved Maestro history. It refuses unarchived tasks. The Git worktree and branch remain on disk; this command does not clean them up or delete the agent's own logs. Retained branches/worktrees must be dealt with before reusing the same task slug. Quit the TUI before using CLI archive, reopen, or delete commands, since the TUI holds the project lock.

Session resume

Built-in presets are available in the new-task picker and through maestro new -a <agent>:

Agent key Executable Session identity
codex codex Discovered from rollout metadata
agy agy Discovered from the workspace-to-conversation cache
opencode opencode Discovered from its JSON session listing
claude claude Maestro supplies a UUID using --session-id
qoder qoder Maestro supplies a UUID using --session-id
kimi kimi Discovered from Kimi Code's ~/.kimi-code/sessions metadata
cursor-agent cursor-agent Allocated by cursor-agent create-chat before launch

Install and authenticate the chosen CLI separately; maestro doctor checks executable availability. Override the preset's cmd if your installation uses another executable name, such as agent for Cursor or qodercli for older Qoder installations. The argument flags must also be supported by that version.

Claude and Cursor accept an initial prompt while remaining interactive. Qoder uses --prompt-interactive. Kimi's --prompt runs non-interactively with automatic approvals, so its preset requires manual prompt entry: omit Maestro's -p (leave the dialog's first prompt blank) and enter the prompt in the agent pane. Maestro rejects launch-time prompts for this preset before creating a worktree. The Kimi preset targets the current Kimi Code CLI and its .kimi-code session layout, not the older Python CLI's .kimi storage. Cursor session allocation uses its documented create-chat command.

Maestro saves native session IDs and resumes by ID without replaying the first prompt. Codex, agy and OpenCode also import native messages and tool activity. Private formats can change; parser failures retain existing history and fall back to terminal capture. If an existing resumable task has no discoverable ID, Maestro shows an error and offers prefix R for an explicit fresh start.

Custom agents can write their ID to a worktree-relative session_file, or opt into a generated UUID if they support client-supplied IDs:

[agents.custom]
cmd = "my-agent"
generate_session_id = true
new = ["--session-id", "{{.SessionID}}", "{{.Prompt}}"]
resume = ["--resume", "{{.SessionID}}", "{{.Prompt}}"]
input_hints = ["Approve?"]
# Alternative to generate_session_id: session_file = ".maestro/session-id"

Argument templates render directly into argv; empty arguments are dropped and prompts are never interpreted by a shell. MAESTRO_TASK and MAESTRO_SESSION_ID are also available to the child process. Stateless custom agents with no resume arguments restart as new processes.

Agents that allocate IDs through a separate command can instead use session_create = ["create-chat"]. Maestro runs those literal arguments with the configured executable in the task worktree before the first launch, captures the single ID from stdout, and supplies it as {{.SessionID}}. It does not run that command when resuming. This setting requires resume arguments and cannot be combined with generate_session_id or session_file.

Set manual_prompt = true when an agent cannot accept an initial prompt in interactive mode. This rejects launch-time prompts with instructions to enter them in the pane.

Configuration layers are built-in defaults, the global config file, then the main checkout's .maestro.toml. The new flags override the corresponding task choices. Agent tables merge by key, so overriding cmd preserves the default argument templates. See the default config for supported settings.

Data lives in the platform's XDG data directory under maestro: maestro.db, locks/, and worktrees/<repository-key>/<task-slug>/. The repository key hashes the Git common directory, keeping checkouts with identical names separate. Commands run from a linked worktree resolve to the same project as the main checkout. The TUI holds the project lock for its lifetime; CLI listing and history remain available. A second TUI or external task-creation command reports that the project is busy.

worktree.copy copies regular files only, skips missing files, and rejects symlinks, traversal, Git metadata and existing destinations. Copied files have owner-only permissions. worktree.setup runs trusted shell commands from your config in each new worktree (sh on Unix, cmd on Windows). Review repository config before using it. If initial copying, setup or database persistence fails after worktree creation, Maestro retains the checkout and reports its path and branch. Inspect and recover it manually before retrying creation; failed initial provisioning is not listed as a saved task. Reopen provisioning retains the archived task and saves progress for retry.

Context handoff and history

Use prefix a to choose an installed agent; the picker marks agents that previously worked on the task. Switching away from an active or approval-waiting agent asks before interruption. Maestro stops the old process, saves its final transcript, and writes .maestro/handoff.md in the same worktree before launching the new agent. Returning to an agent resumes that agent's own native session ID.

maestro switch <task> -a <agent> opens the focused TUI, restores other task tabs, and performs the same handoff. It needs an interactive terminal. An already-open TUI owns the project lock, so use its switch dialog instead of a second CLI process.

Handoffs include the goal, notes, agent timeline, explicit TODO mentions, recent conversation and Git state. Set [handoff] token_budget = 6000 to adjust the budget. The deterministic estimator conservatively counts each UTF-8 byte as a token; actual model token usage is usually lower. Older dialogue and tool output are trimmed, with omission markers. Terminal snapshots retain their newest lines and remain in the handoff when native history could not be fully imported. No model calls are made to summarize history.

Use prefix n to edit multiline task notes. Ctrl+S saves them and Escape cancels; notes are kept in SQLite and included in subsequent handoffs. Outside the TUI, maestro notes <task> prints them, maestro notes <task> --set "text" replaces them, and --file notes.md or --file - reads replacement notes from a file or stdin. --set "" clears notes. Notes accept up to 64 KiB of UTF-8 text. Reading works while the TUI is open; updates use the project lock.

Switching validates that the selected new/resume template includes the full handoff instruction in its rendered arguments before stopping the current agent. If an agent cannot accept prompts on launch, configure manual_prompt = true. Manual-prompt agents start without injected input; use prefix H to copy the instruction, then paste it into their pane.

A pending handoff is stored in SQLite before launch. If writing the file or starting the new process fails, retry with prefix r; the saved handoff is reused. An early startup crash also retains it. Delivery is acknowledged by a new native turn signal, a clean process exit, or an active pane surviving a two-second startup window (only for generic agents without native turn adapters). Native adapters retain pending context until a new turn signal or clean exit. If startup never created the recorded native session, use prefix R to retry fresh with the saved handoff. Merely creating a process no longer consumes pending context. If the selected target has no discoverable resume identity, the switch dialog asks before stopping the current agent and starting the target fresh with a handoff. This also applies to maestro switch. Use prefix R to start the current agent fresh. Use prefix & for worktree and branch cleanup.

prefix h opens history: Tab selects a session, Enter expands it, t reveals tool details, arrows/j/k and page keys scroll, r refreshes, and Escape returns to the pane. Terminal fallback snapshots are labeled terminal. maestro history <task> --json returns task, sessions, turns, events and handoffs. Native records are deduplicated across resumed launches. Persisted history remains available from the main repository even after the worktree or agent's source logs disappear. Terminal fallback capture preserves the alternate screen before teardown and keeps older scrollback lines at their original width after a terminal resize.

Native parser coverage:

Agent History Completion evidence
Codex Rollout messages and tool records Task start/complete and interruption events
agy Transcript user/planner/tool steps Completed textual planner response without tool calls; individual step DONE is insufficient
OpenCode Exported messages and parts; read-only SQLite fallback Completed final assistant response, excluding tool-call continuation steps
Other configured agents Terminal fallback Notifications and quiet timer

Internal reasoning and system/developer instructions are not imported. JSONL files are watched with periodic reconciliation; OpenCode exports are polled once per second. If its CLI produces no usable JSON, Maestro reads the known native SQLite schema in read-only mode, scoped to the task workspace and session. This also supports session discovery when the local CLI listing fails. An unknown schema still falls back to terminal history. The parsers are versioned with synthetic fixtures because native formats are not stable public APIs.

Verification

The test suite includes teatest/v2 screen coverage for every P4 view and existing dialog, persisted drag ordering, bounded diff loading, notification filtering, and real PTY processes, three-task restoration, a controlled Codex → agy → Codex handoff, pending-switch recovery, P1 database migration, duplicate-free transcript imports, native activity precedence, retained history after worktree deletion, and UI snapshots at 80×24 and 160×48. Regenerate snapshots with go test ./internal/tui -update and review the diff. A fake agent is available with go build -o /tmp/maestro-fakeagent ./internal/testutil/fakeagent; configure new = ["new", "{{.SessionID}}"], resume = ["resume", "{{.SessionID}}"] and generate_session_id = true to try it without API credentials.

Linux terminal smoke tests and Windows/macOS cross-builds have been performed. Read-only parser checks also exercise existing local Codex/agy transcripts and OpenCode native history. Native Windows/macOS behavior and authenticated live cross-agent conversations remain manual checks. GitHub PR, CI, review, merge, cleanup, and reopen behavior is covered by fake-server and integration tests; a real authenticated GitHub run remains a manual acceptance check.

Layout
Path Purpose
cmd/maestro Binary entry point
internal/cli Cobra command tree
internal/version Build metadata (set via -ldflags)
internal/{app,config,store,core,git,agent,term,tui} P1: MVP
internal/handoff P2: context handoff between agents
internal/forge P3: GitHub PRs, CI, merges

License

MIT

Directories

Path Synopsis
cmd
maestro command
Command maestro is a terminal multiplexer for coding agents.
Command maestro is a terminal multiplexer for coding agents.
internal
agent
Package agent defines the Agent interface, registry and built-in adapters.
Package agent defines the Agent interface, registry and built-in adapters.
app
Package app wires Maestro's services together and enforces the per-project lock.
Package app wires Maestro's services together and enforces the per-project lock.
cli
Package cli defines Maestro's command-line interface.
Package cli defines Maestro's command-line interface.
config
Package config loads layered TOML configuration (defaults, user, repo, flags).
Package config loads layered TOML configuration (defaults, user, repo, flags).
core
Package core implements the task service and lifecycle state machine.
Package core implements the task service and lifecycle state machine.
forge
Package forge abstracts git hosting providers (GitHub first) for PRs, CI and merges.
Package forge abstracts git hosting providers (GitHub first) for PRs, CI and merges.
forge/github
Package github implements the forge provider using GitHub's REST API.
Package github implements the forge provider using GitHub's REST API.
git
Package git wraps the system git binary for worktrees, branches and status.
Package git wraps the system git binary for worktrees, branches and status.
handoff
Package handoff builds context handoff briefs when switching agents within a task.
Package handoff builds context handoff briefs when switching agents within a task.
notify
Package notify delivers best-effort desktop alerts without a daemon.
Package notify delivers best-effort desktop alerts without a daemon.
store
Package store persists projects, tasks, agent sessions, turns and events in SQLite.
Package store persists projects, tasks, agent sessions, turns and events in SQLite.
term
Package term hosts agent processes in pseudo-terminals with a virtual terminal emulator.
Package term hosts agent processes in pseudo-terminals with a virtual terminal emulator.
testutil
Package testutil provides isolated repositories for integration tests.
Package testutil provides isolated repositories for integration tests.
tui
Package tui implements the Bubble Tea user interface.
Package tui implements the Bubble Tea user interface.
version
Package version exposes build metadata injected at link time via -ldflags.
Package version exposes build metadata injected at link time via -ldflags.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL