pyrycode

module
v0.12.0 Latest Latest
Warning

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

Go to latest
Published: May 14, 2026 License: MIT

README

Pyrycode

A process supervisor and runtime for Claude Code. Run pyry instead of claude to get a long-lived, self-healing host for your AI assistant — with a control socket for status, logs, graceful shutdown, and detach/reattach from any shell.

Status

Phase 0 complete and dogfooded. Foreground mode is a drop-in claude wrapper with auto-restart. Service mode runs pyry under launchd or systemd and exposes a Unix-socket control plane. As of v0.5.2 pyry is daily-driver-grade on Linux: pyrybox now runs claude under systemd via the public install path described below, replacing the prior tmux + bash restart-loop setup.

Production hardening — multi-session routing, Channels integration, in-process knowledge capture, remote access, voice — is on the roadmap (see docs/plan.md).

What it does

  • Supervises claude in a pseudo-terminal with crash recovery and exponential backoff.
  • Resumes the previous session on every restart so conversation history survives crashes.
  • Two modes from one binary. Run from a TTY for interactive development; run under a service manager (no TTY) for production. The same binary auto-detects and adapts.
  • Control plane on a Unix socket. Query state, stream logs, request shutdown, attach a terminal — all from any shell, with single-user filesystem permissions as the security boundary.
  • CLI transparency. Anything pyry doesn't recognise is forwarded to claude verbatim. Pyry's own flags use a -pyry-* prefix so they never collide.

Platforms

Linux and macOS, including Apple Silicon (arm64) — prebuilt darwin_arm64 binaries ship with every release. Windows is out of scope (different PTY backend, different signal model).

Install

Universal one-liner (Linux / macOS, amd64 / arm64):

curl -fsSL https://raw.githubusercontent.com/pyrycode/pyrycode/main/install.sh | bash

Drops pyry in ~/.local/bin/. Set PYRY_VERSION=v0.5.2 to pin a release; set PYRY_INSTALL_DIR=/usr/local/bin (run with sudo bash) for a system-wide install.

Homebrew (macOS, Linuxbrew):

brew install pyrycode/tap/pyry

Go-native (any platform Go supports):

go install github.com/pyrycode/pyrycode/cmd/pyry@latest

From source:

git clone https://github.com/pyrycode/pyrycode
cd pyrycode
make build           # ./pyry — current platform
make linux           # cross-compile dist/pyry-linux-amd64
make dist            # adds darwin × {amd64, arm64}

Requires a working claude binary on PATH to actually do anything useful. Building from source needs Go 1.26 or later.

Quickstart

Foreground (development). Run pyry instead of claude:

pyry "summarize foo.md"           # forwarded as claude's initial prompt
pyry --model sonnet -p "..."      # any claude flag passes through

If claude exits, pyry restarts it with --continue so you keep your session.

Service mode (production). Two commands. pyry install-service writes a systemd unit (Linux) or launchd plist (macOS), inheriting your shell's $PATH so nvm / pyenv / brew tools come along automatically:

pyry install-service -- \
  --dangerously-skip-permissions \
  --channels plugin:discord@claude-plugins-official

systemctl --user daemon-reload
systemctl --user enable --now pyry

(macOS: launchctl load ~/Library/LaunchAgents/dev.pyrycode.pyry.plist in place of the systemctl lines.)

The supervised claude has no terminal of its own; connect to it on demand:

pyry attach    # your terminal becomes claude's terminal
               # press Ctrl-B d to detach — pyry stays running

pyry status, pyry logs, and pyry stop work from any shell, talking to the daemon over its Unix socket at ~/.pyry/pyry.sock.

For the full walkthrough — multi-instance, troubleshooting, hooks under service-mode PATH, boot persistence — see docs/guide.md and docs/deployment.md.

Documentation

Development

make check           # vet + race-enabled tests + staticcheck
make build           # ./pyry
make linux           # cross-compile for Linux

CODING-STYLE.md covers Go conventions used in the repo.

License

MIT — see LICENSE.

Directories

Path Synopsis
cmd
pyry command
Command pyry is the Pyrycode daemon — a process supervisor for Claude Code.
Command pyry is the Pyrycode daemon — a process supervisor for Claude Code.
internal
agentrun
Package agentrun provides helpers used by the `pyry agent-run` verb (wired in #338B) and the JSONL watcher (#333) to interoperate with claude's on-disk state.
Package agentrun provides helpers used by the `pyry agent-run` verb (wired in #338B) and the JSONL watcher (#333) to interoperate with claude's on-disk state.
agentrun/budget
Package budget enforces the pyry-side --max-turns cap for agent-run by counting assistant JSONL entries and signalling the claude child when the budget is reached.
Package budget enforces the pyry-side --max-turns cap for agent-run by counting assistant JSONL entries and signalling the claude child when the budget is reached.
agentrun/jsonl
Package jsonl parses claude session JSONL output into structured events, surfacing every line (assistant, user, tool_use, tool_result, system, attachment, or unrecognised) with its verbatim bytes, alongside a deterministic end-of-turn signal on assistant entries.
Package jsonl parses claude session JSONL output into structured events, surfacing every line (assistant, user, tool_use, tool_result, system, attachment, or unrecognised) with its verbatim bytes, alongside a deterministic end-of-turn signal on assistant entries.
agentrun/jsonl/tail
Package tail watches ~/.claude/projects/<encoded-cwd>/<sid>.jsonl for claude's per-session JSONL output, opens the file as it appears, and feeds appended bytes into a jsonl.Reader until the deterministic end-of-turn signal fires or the caller cancels.
Package tail watches ~/.claude/projects/<encoded-cwd>/<sid>.jsonl for claude's per-session JSONL output, opens the file as it appears, and feeds appended bytes into a jsonl.Reader until the deterministic end-of-turn signal fires or the caller cancels.
agentrun/selfcheck
Package selfcheck implements the boot-time verification that permissions.defaultMode "deny" in the per-spawn settings file still enforces the whitelist when claude is spawned in interactive mode.
Package selfcheck implements the boot-time verification that permissions.defaultMode "deny" in the per-spawn settings file still enforces the whitelist when claude is spawned in interactive mode.
agentrun/streamjson
Package streamjson re-emits the parsed claude session-JSONL Event stream onto a writer (typically pyry's stdout) and composes a single `type:"result"` trailer line when the run terminates.
Package streamjson re-emits the parsed claude session-JSONL Event stream onto a writer (typically pyry's stdout) and composes a single `type:"result"` trailer line when the run terminates.
brokenpyry command
Package main is a deliberately-broken pyry stand-in for the TestUpdate_BrokenNewBinary_E2E test.
Package main is a deliberately-broken pyry stand-in for the TestUpdate_BrokenNewBinary_E2E test.
config
Package config loads the on-disk Pyrycode configuration file.
Package config loads the on-disk Pyrycode configuration file.
control
Package control implements pyry's local control plane: a Unix domain socket that lets clients (such as `pyry status`) query the running daemon.
Package control implements pyry's local control plane: a Unix domain socket that lets clients (such as `pyry status`) query the running daemon.
conversations
Package conversations defines the Phase 3 Conversation entity: a long-lived thread that owns a sequence of underlying claude sessions and carries presentation metadata (name, promoted/unpromoted state).
Package conversations defines the Phase 3 Conversation entity: a long-lived thread that owns a sequence of underlying claude sessions and carries presentation metadata (name, promoted/unpromoted state).
devices
Package devices defines the on-disk Device type and the token hashing/verification primitives used by `pyry pair` and the mobile auth path.
Package devices defines the on-disk Device type and the token hashing/verification primitives used by `pyry pair` and the mobile auth path.
dispatch
Package dispatch demultiplexes inbound binary↔relay frames by RoutingEnvelope.ConnID and routes each frame through a handler table.
Package dispatch demultiplexes inbound binary↔relay frames by RoutingEnvelope.ConnID and routes each frame through a handler table.
e2e/internal/fakeclaude command
Command fakeclaude is a test-only stand-in for the real `claude` CLI used by Pyrycode's e2e harness.
Command fakeclaude is a test-only stand-in for the real `claude` CLI used by Pyrycode's e2e harness.
e2e/internal/fakephone
Package fakephone is an in-process WebSocket client that speaks the phone half of the mobile↔relay protocol (docs/protocol-mobile.md § Authentication, § Message envelope).
Package fakephone is an in-process WebSocket client that speaks the phone half of the mobile↔relay protocol (docs/protocol-mobile.md § Authentication, § Message envelope).
e2e/internal/fakerelay
Package fakerelay is an in-process WebSocket server that speaks the routing half of the mobile↔relay protocol (docs/protocol-mobile.md § Authentication, § Routing envelope).
Package fakerelay is an in-process WebSocket server that speaks the routing half of the mobile↔relay protocol (docs/protocol-mobile.md § Authentication, § Routing envelope).
identity
Package identity owns typed identifiers that span subsystems — server-id today; potential future device-id, paired-device-id — and the bootstrap of those identifiers from disk.
Package identity owns typed identifiers that span subsystems — server-id today; potential future device-id, paired-device-id — and the bootstrap of those identifiers from disk.
install
Package install writes service-manager unit files (systemd, launchd) for pyry.
Package install writes service-manager unit files (systemd, launchd) for pyry.
pair
Package pair encodes the {server, relay, token} tuple a paired mobile device needs to connect through the relay back to this binary, and decodes strings produced by the same encoder.
Package pair encodes the {server, relay, token} tuple a paired mobile device needs to connect through the relay back to this binary, and decodes strings produced by the same encoder.
protocol
Package protocol declares the wire-format types for pyrycode's mobile WebSocket protocol v1.
Package protocol declares the wire-format types for pyrycode's mobile WebSocket protocol v1.
relay
Package relay drives the binary's outbound long-lived connection to the relay: opens the WSS via internal/transport, runs the one-shot hello/hello_ack handshake on every fresh conn, and exposes inbound frames as protocol.RoutingEnvelope values via Frames().
Package relay drives the binary's outbound long-lived connection to the relay: opens the WSS via internal/transport, runs the one-shot hello/hello_ack handshake on every fresh conn, and exposes inbound frames as protocol.RoutingEnvelope values via Frames().
sessions
Package sessions owns the set of supervised claude instances managed by one pyry process.
Package sessions owns the set of supervised claude instances managed by one pyry process.
sessions/rotation
Package rotation watches claude's session directory for /clear-style UUID rotations and notifies its host (internal/sessions) so the registry can follow claude to the new <uuid>.jsonl in real time.
Package rotation watches claude's session directory for /clear-style UUID rotations and notifies its host (internal/sessions) so the registry can follow claude to the new <uuid>.jsonl in real time.
supervisor
Package supervisor runs Claude Code under process supervision: spawn in a PTY, stream I/O transparently to the controlling terminal, and restart the child with exponential backoff when it exits.
Package supervisor runs Claude Code under process supervision: spawn in a PTY, stream I/O transparently to the controlling terminal, and restart the child with exponential backoff when it exits.
transport
Package transport provides a long-lived WSS client with automatic reconnect, exponential backoff with jitter, and native ping/pong heartbeat.
Package transport provides a long-lived WSS client with automatic reconnect, exponential backoff with jitter, and native ping/pong heartbeat.
update
Package update implements pyrycode's self-update logic: release manifest parsing, version comparison, fetch, and replace.
Package update implements pyrycode's self-update logic: release manifest parsing, version comparison, fetch, and replace.

Jump to

Keyboard shortcuts

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