Skip to main content

Python toolkit for orchestrating Parallel Codex agents across isolated worktrees.

Project description

parallel-codex

Primary implementation of Parallel Codex - Python toolkit for orchestrating Parallel Codex agents working in isolated Git worktrees. This package contains the core logic and CLI tools for managing agent worktrees, tmux sessions, a Textual TUI, and Codex agent orchestration.

Status: Core worktree management is implemented. Agent orchestration logic is in development. This is the main package that will be wrapped by npm and Homebrew in the future.

Install

uv tool install parallel-codex
# or: pip install parallel-codex

You’ll get two CLIs:

  • pcodex – minimal, cross‑platform helper that manages git worktrees + tmux and can run codex .
  • parallel-codex – launches the Textual TUI (pass --dev-log-panel during development to mirror logs in-app)

Prerequisites:

  • git and tmux on PATH. On Windows without tmux, pcodex auto-falls back to wsl.exe -- tmux ....
  • The codex command should be available if you use --run-codex or the TUI.
  • Codex CLI must be logged in: run echo $OPENAI_API_KEY | codex login --with-api-key once before using the TUI.

On all platforms, the Codex CLI path is resolved once (from PARALLEL_CODEX_CODEX_PATH if set, otherwise from your PATH) and that full path is reused for subprocess calls. This improves robustness on Windows (especially when shims/launchers are involved) and produces clearer errors if the resolved codex binary cannot be executed or is not authenticated. For unusual setups (for example, npm-style shims on Windows), you can point directly at the Codex binary via PARALLEL_CODEX_CODEX_PATH:

# POSIX shells (macOS, Linux, WSL, Git Bash)
export PARALLEL_CODEX_CODEX_PATH=/full/path/to/codex
# Windows (cmd.exe)
set PARALLEL_CODEX_CODEX_PATH=C:\Users\you\AppData\Roaming\npm\codex.CMD
# Windows (PowerShell)
$env:PARALLEL_CODEX_CODEX_PATH="C:\Users\you\AppData\Roaming\npm\codex.CMD"

Development commands

From packages/python-package, common development commands are:

  • uv sync – install dependencies
  • uv run pytest – run tests
  • uv run ruff check . – lint the codebase
  • uv run mypy src/ – type-check the code

CLI Usage (quickstart)

pcodex up reviewer main --run-codex --attach
pcodex switch reviewer
pcodex list
pcodex prune reviewer --kill-session --remove-dir

CLI Usage (development, no install)

Development now revolves exclusively around the TUI. Keep a dev log panel open at all times so you can see every logging call and stdout/stderr line inside the in-app widget.

Default dev loop (from packages/python-package)

cd packages/python-package
uv run src/main.py tui --dev-log-panel

The positional tui argument is optional, but it remains supported so existing scripts keep working. Passing --dev-log-panel enables the scrolling log widget so any logging.getLogger(__name__).info(...) (or prints) appear without tailing a file.

On Windows with cmd.exe:

cd C:\path\to\parallel-codex\packages\python-package
uv run python src\main.py tui --dev-log-panel

Default dev loop from the repo root (uv --project)

When you prefer to stay at the monorepo root, pin uv to the Python package and run:

uv run --project packages/python-package python -m parallel_codex.cli tui --dev-log-panel

On Windows with cmd.exe:

cd C:\path\to\parallel-codex
uv run --project packages\python-package python -m parallel_codex.cli tui --dev-log-panel

These invocations respect PARALLEL_CODEX_REPO_ROOT for pointing the TUI at a repo outside your current directory.

Published CLIs:

  • parallel-codex [tui] [--dev-log-panel] ... – launch the Textual TUI (only supported command).
  • pcodex up <agent> <branch> – ensure git worktree, ensure tmux session, optionally run codex ., and attach.
  • pcodex switch <agent> – switch/attach to the tmux session.
  • pcodex list – list worktrees and tmux session state.
  • pcodex prune <agent> [--kill-session] [--remove-dir] – kill session and/or remove directory.

TUI usage

The TUI is aimed at running several Codex sessions in parallel, each in its own git worktree:

  • One codex mcp-server subprocess is spawned and shared for all sessions.
  • Each session gets its own branch and worktree under ./.agents/<session-name>.
  • Your IDE can open each worktree separately to compare changes across sessions.

Launch the TUI from the root of your git repo (add --dev-log-panel during development to surface logs inside the widget):

parallel-codex tui \
  --repo . \
  --agents-base ./.agents \
  --model gpt-5-codex \
  --sandbox workspace-write \
  --dev-log-panel

Keyboard shortcuts:

  • Ctrl+N – create a new session (up to three visible side by side; further sessions can be managed but are currently hidden from the main row).
  • Ctrl+Tab – cycle focused session (and move the caret to that session's input).
  • Ctrl+W – close the focused session.
  • Esc – focus the input of the currently focused session.

Per-session worktrees:

  • For each new session session-N, the TUI creates or reuses a branch like pcx/session-N and a worktree under ./.agents/session-N.
  • Codex runs with workspace_path pointing at that worktree, so all file edits are isolated per session.
  • You can manually mix changes between sessions later using normal git operations (e.g. git merge pcx/session-1 from another branch).

Env-based TUI defaults

By default, parallel-codex tui assumes that --repo points at the current working directory. For development workflows where the Python package lives inside a larger git repo, you can use PARALLEL_CODEX_REPO_ROOT to point the TUI at the real git root without changing your CWD:

# POSIX shells (macOS, Linux, WSL, Git Bash)
export PARALLEL_CODEX_REPO_ROOT=/path/to/your/parallel-codex
parallel-codex tui

When running the TUI via uv run inside this repository, this allows you to keep --project pointing at the packages/python-package subdirectory while still using the top-level git repo as the TUI repo root:

# Recommended on Windows/monorepo setups (POSIX example shown here):
export PARALLEL_CODEX_REPO_ROOT=/path/to/your/parallel-codex
uv run --project packages/python-package python -m parallel_codex.cli tui

On Windows with cmd.exe, use set instead of export:

REM Recommended first step when developing on Windows in this repo:
set PARALLEL_CODEX_REPO_ROOT=C:\path\to\your\parallel-codex
uv run --project packages\python-package python -m parallel_codex.cli tui

On Windows with PowerShell, use the $env: prefix:

$env:PARALLEL_CODEX_REPO_ROOT = "C:\path\to\your\parallel-codex"
uv run --project packages\python-package python -m parallel_codex.cli tui

Logging via the dev panel

The --dev-log-panel flag is now the default development mode. It wires Python's standard logging module plus stdout/stderr directly into the in-app widget, so you can emit diagnostics without hunting for files.

import logging

LOG = logging.getLogger(__name__)
LOG.info("Bootstrapping repo sync for %s", repo_root)

Anything logged this way (or printed) scrolls live in the dev panel, which makes it the preferred way to surface debug information while iterating on agents.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

parallel_codex-1.0.1.tar.gz (45.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

parallel_codex-1.0.1-py3-none-any.whl (23.4 kB view details)

Uploaded Python 3

File details

Details for the file parallel_codex-1.0.1.tar.gz.

File metadata

  • Download URL: parallel_codex-1.0.1.tar.gz
  • Upload date:
  • Size: 45.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for parallel_codex-1.0.1.tar.gz
Algorithm Hash digest
SHA256 f22290d65a86d9a5b2bec95de72ed58616b36b9009d1d5ffb70048744df97cc1
MD5 665e89d9ae888ab040bc10b2bb7b393c
BLAKE2b-256 49dbc4278f81bcaa2b20b2effbc86d99d692951649bd37806a54cb110ef6ee77

See more details on using hashes here.

Provenance

The following attestation bundles were made for parallel_codex-1.0.1.tar.gz:

Publisher: deploy-python.yml on parallel-codex/parallel-codex

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file parallel_codex-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: parallel_codex-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 23.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for parallel_codex-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 5c58843d24e511a1964e3007d7e766fe37b6963c446dcd30e5d5c6b807d60606
MD5 7d3b948360e3b9359092fda8e21c0d9d
BLAKE2b-256 5020dc0538af1763f58aa92683094b60f2b9c7ea4bd81c8ea3eeb8f8099e3f22

See more details on using hashes here.

Provenance

The following attestation bundles were made for parallel_codex-1.0.1-py3-none-any.whl:

Publisher: deploy-python.yml on parallel-codex/parallel-codex

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page