pollytool

module
v0.0.0-...-c35be98 Latest Latest
Warning

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

Go to latest
Published: Nov 30, 2026 License: MIT

README

Pollytool (polly)

My LLM harness. There are many like it. This one is mine.

Polly is a terminal assistant with tools, saved conversations, and subagents. Run it as a full-screen TUI, pipe it a prompt, or embed it in your own Go program.

polly TUI with viewed image strips beside an agent panel polly TUI with a finished answer beside an agent panel

Contents

Install

Polly builds from source with Go 1.27 or later, and it needs Git on your path.

go build -o polly ./cmd/polly/

Put the binary on your PATH (or run ./polly) and start it from your project directory.

Quick start

polly                                      # open the TUI
polly -m openai/gpt-5.4 -p "Explain this repo"
echo "Hello?" | polly                       # prompt from stdin
git diff | polly ask "Explain this change"  # piped input with a prompt
polly -f image.jpg -p "What's in this image?"

The first launch walks you through setup: pick a provider, a model, and a key. In the TUI that's a form; anywhere else it asks one question at a time. Come back to it whenever you like with /setup or polly --setup, or skip the questions by handing polly --setup the answers up front with --model, --effort, --theme, and --sandbox or --nosandbox. The default model is anthropic/claude-opus-5.

Keys come from the environment, such as POLLYTOOL_ANTHROPICKEY. A key typed into /setup lasts only as long as the process, because Polly never saves keys. Ollama and custom --baseurl endpoints can run without one.

A ChatGPT plan works without a key: polly --login codex (or /login in the TUI) signs you in through your browser, keeps the sign-in in ~/.pollytool/auth.json, and unlocks the codex/ models your plan includes.

Everything else can go in ~/.pollytool/config. Flags beat environment variables, which beat the config file. A saved session keeps its own settings unless you pass a flag.

Setup and configuration details →

One-shot output

For a single turn, use -p, polly ask "…", or pipe a prompt to stdin. Pipe input and pass a prompt, and the input rides along with it. The answer lands on stdout and live activity on stderr, so redirecting stdout gives you clean, raw Markdown.

Flag Effect
--stream Print text as it arrives
--quiet Hide activity
--metadata Emit a JSON run-outcome object to stderr
Structured output

Pass --schema person.schema.json and stdout becomes validated JSON. Image attachments work here too.

Output details →

TUI

Run polly with no prompt and nothing piped in, and you get the full-screen TUI. Under TERM=dumb or a redirect, Polly falls back to a simpler line frontend.

Click agents in the status bar to open the agent panel. A turn's work shows as one row per run of related calls, such as Read 4 files or Tests failed, and a long turn folds to one row that counts all of it. Click a row to list its calls and thoughts, then a call for its output or a thought for its text. In the status bar, click the session name to switch sessions or the model to change it.

Key Action
Enter Send; input during a turn queues for later
Tab Accept an active @file/argument completion, complete /command (unless the own-screen agent panel is open), or cycle focus through open panels
Alt-P Dock or float the focused panel
Ctrl-C Interrupt; again, or while idle, quit
Esc Dismiss the popup or focused panel; otherwise interrupt
Ctrl-R / Ctrl-G Search history / pick a session
Ctrl-O Collapse or expand all activity
Ctrl-V Attach a clipboard image
Alt+1…9 Switch between open sessions

Type @ to attach a workspace file, or start a line with / for commands and skills. Dragging a file into the composer attaches it, and Shift-drag selects text. Inside Rex, tmux, or Zellij, Polly automatically opens panels as native floating windows or split panes, runs sessions in their own tabs or windows, and supports /wall to tile active subagents side by side.

A few commands worth knowing:

Command Action
/help Filterable command and skill picker
/model Switch models for the current session
/set [key [value]] Inspect or change session preferences
/speed [default|fast|ultrafast] Inspect or change processing speed for this session
/setup Configure model, key override, theme, and launch defaults
/new, /resume, /close Open, resume, or close a session
/plan [goal] Draft and review a plan before allowing implementation
/todo See the session’s outcomes, progress, and blockers — no plan required
/wall Tile running subagents side by side (in Rex, tmux, or Zellij)
/compact Summarize context now, retaining the saved transcript
/copy Copy the last completed response to the clipboard
/theme Preview and switch themes
/sandbox-init Set up this project's sandbox
Subagents

Ask Polly to delegate, or do it yourself with /spawn [--read-only] [--review] <brief>. Research agents come back with findings. Editing agents work in isolated Git snapshots, and the parent integrates their changes when they're done. Subagents need Git 2.40 or later.

Click Agents in the status bar to follow along or answer an approval request, and run /workflow SCRIPT.js INPUT.json to drive agents from a JavaScript workflow.

TUI guide → · Swarms and workflows →

Sessions

TUI conversations save themselves. Unnamed sessions get a generated handle such as quiet-otter and expire after seven idle days; give a session a name and it never expires. One-shot runs leave nothing behind unless you pass -c.

polly -L                              # resume the last session
polly -c project                      # open a named session
polly -c project -p "Continue"         # continue it from the CLI
cat notes.txt | polly -c project --add # add context without a model call

/title sets a session's title and /rename changes its handle. Everything lives in ~/.pollytool/polly.db.

Session settings and commands →

Models

Pick a model at launch with -m provider/model or POLLYTOOL_MODEL. In a session, use /set model provider/model for that session alone, or open /setup to update the session and save launch defaults.

Provider prefix API key environment variable
openai/ POLLYTOOL_OPENAIKEY
anthropic/ POLLYTOOL_ANTHROPICKEY
gemini/ POLLYTOOL_GEMINIKEY
qwencloud/ POLLYTOOL_QWENCLOUDKEY
deepseek/ POLLYTOOL_DEEPSEEKKEY
openrouter/ POLLYTOOL_OPENROUTERKEY
ollama/ POLLYTOOL_OLLAMAKEY (optional)
huggingface/ POLLYTOOL_HUGGINGFACEKEY
codex/ none: sign in with a ChatGPT plan, polly --login codex

The /setup form completes the model names it discovers, and you can always type one in by hand. --baseurl points Polly at an OpenAI-compatible or Ollama endpoint.

Reasoning effort defaults to high; change it with --effort or /set effort <value>. Use /speed in a session or --speed <mode> at launch to choose default, fast, or ultrafast. Fast and Ultrafast are available on supported OpenAI and Codex models and can cost more or draw more on your plan. Context limits are detected where possible; use /set maxcontext <value> to adjust them. A conversation that outgrows its limit is compacted, by a cheaper model if --compactmodel names one.

Model discovery, routing, and limits →

Tools

Built-in tools

Out of the box, Polly can run Bash, read and edit files, delegate to agents, view images, and recall earlier work:

Purpose Tools
Shell and files bash, read_file, write_file, edit_file, list_dir, restore_artifact
Agents and session spawn_agent, set_session_title, update_todos, ask_user (TUI only)
Images and themes view_image, set_theme (TUI only)
Recall list_artifacts, read_artifact, read_transcript
Rex (opt-in) rex_inspect, rex_layout, rex_terminal, rex_lua, rex_api, rex_client

Rex tools are opt-in: enable them explicitly with -t (for example -t bash -t rex_inspect -t rex_terminal), and add the rex sandbox preset (--sandbox default+rex) if you run sandboxed. Inside Rex, the TUI also emits OSC 7501 status updates for active turns, prompts, and workers.

On multi-step requests, update_todos records outcomes and blockers in the session; /todo shows them. No plan is required. For work you want to approve first, /plan restricts Polly to investigation and editing the session draft with read_plan_draft and write_plan_draft. Once approved, the outcomes join the same checklist with their wording fixed. read_accepted_plan lets Polly read the frozen plan in pages without adding the whole document to every request. See plan mode.

Add --confirm to approve each tool call yourself. To choose your own set, pass -t / --tool once per tool; any --tool replaces the defaults.

Shell tools

Any executable can be a tool. It just has to answer --schema with a JSON Schema and --execute <json-args> with its result. Load it with -t ./uppercase.sh.

Shell tool example →

MCP servers

Point -t at a Claude Desktop-format config to load its servers (-t mcp.json), or pick out one (-t mcp.json#filesystem). Their tools show up as server__tool. Stdio servers follow the session's sandbox policy; SSE and streamable HTTP servers run on their own, outside it.

Tool behavior and configuration →

Skills

A skill is a folder with a SKILL.md in it. Polly discovers project skills in .agents/skills from the Git root down to your working directory, plus personal skills in ~/.pollytool/skills. Outside Git, it checks only the working directory for project skills. Nearer project skills shadow personal and built-in skills. Use --skilldir to replace the search directories, or add and activate one with -S <dir|git|url>. In the TUI, start a prompt with /name to activate a skill.

Four skills ship with Polly:

Skill Use it for
feature-workflow Plan, research, implement, and review a feature
simplify Simplify changes without changing behavior
theme-designer Create a theme with the colors you want
sandbox-setup Prepare builds and tests through /sandbox-init

A skill of your own with the same name shadows the built-in. --listskills shows what's available, and --noskills turns skills off.

Skill loading and activation →

Themes

/theme opens a preview picker; /theme <name> switches directly. Confirming a choice applies it to the UI and saves the default for later launches. --theme <name> picks one at launch. The default follows your terminal's own palette, and four full themes ship alongside it: amber-parrot, azure-parrot, midnight-parrot, and verdant-parrot.

polly's masthead and status bar in the default, amber-parrot, azure-parrot, and verdant-parrot themes

Your own themes go in ~/.pollytool/themes/, and the TUI reloads the active one as you edit it. Ask the theme-designer skill to make one, or write the JSON by hand.

Theme files, colors, and roles →

Sandboxing

Sandboxing is opt-in. Unless a flag, the environment, or the config file asks for a sandbox policy, tool commands run unsandboxed.

polly --sandbox default                   # workspace + network + Git writes
polly --sandbox readonly                  # no writes or network
polly --sandbox default+private-home      # also hide ungranted home paths

Inside a sandbox, your ordinary home files stay readable, while known credential paths and Polly's own storage stay masked. Writing to home takes a specific grant, and adding private-home hides the rest of home as well.

--add-dir ../shared brings in another project directory, read-only under a sandbox. In the TUI, /sandbox-init gets a project ready: it prepares isolated build storage, runs the project's builds and tests, and records the commands that worked in AGENTS.md. /sandbox shows live posture and the workspace profile, and /sandbox try <command> helps you work out why an operation was denied.

Presets and everyday commands → · Policies and platform details →

Control backends

--backend URL (POLLYTOOL_BACKEND) runs turns in a daemon that speaks the JSON-RPC control contract, such as polly-zig serve, instead of in polly's own process. The TUI and the CLI work as usual, and every session is read through the daemon, so a socket forwarded from another machine works too.

polly --backend exec://polly-zig                       # find or start polly-zig's daemon
polly --backend unix:///run/user/1000/polly-zig/1-<key>.sock -p "hi"
polly --backend exec://polly-zig --attach fix-tests    # follow its running turn from here
polly --backend exec://polly-zig --stop fix-tests      # stop it

The backend serves anthropic, openai, openrouter, deepseek and huggingface models. --workspace ssh:HOST[:DIR] or docker:CONTAINER[:DIR] runs its tools elsewhere. Its tools run outside polly's sandbox, so a sandbox policy or --confirm refuses the launch.

URLs, what runs where, and what is refused →

Documentation

polly --help lists every flag, and most have a matching POLLYTOOL_* environment variable.

Documentation index →

Guide Covers
CLI and TUI Setup, commands, attachments, models, tools, and themes
Swarms and workflows Delegation, review, integration, and JavaScript workflows
Sandboxing Permissions, workspace profiles, and platform behavior
Go API Embed Polly in your own program

See also

Soulshack: IRC chatbot built on Polly.

License

MIT

Directories

Path Synopsis
Package artifacts describes large or binary conversation payloads.
Package artifacts describes large or binary conversation payloads.
cmd
polly command
polly/internal/headlessscreen
Package headlessscreen runs tcell's native renderer against a terminal emulator.
Package headlessscreen runs tcell's native renderer against a terminal emulator.
polly/internal/markdown
Package markdown renders assistant Markdown into the transcript's styled text: gotui markup with the semantic palette, highlighted code, aligned tables, and sidecar image slots for explicit local image references.
Package markdown renders assistant Markdown into the transcript's styled text: gotui markup with the semantic palette, highlighted code, aligned tables, and sidecar image slots for explicit local image references.
polly/internal/screenimg
Package screenimg rasterizes a text screen into an image, so the TUI can write a PNG of the frame it painted: the cells, their colors and the theme's surface substitution are exactly what the screen holds, with no terminal capture, screen-recording permission or external converter in the way.
Package screenimg rasterizes a text screen into an image, so the TUI can write a PNG of the frame it painted: the cells, their colors and the theme's surface substitution are exactly what the screen holds, with no terminal capture, screen-recording permission or external converter in the way.
polly/internal/style
Package style is the transcript text vocabulary shared by every polly surface: gotui inline markup and its bracket escaping, cell wrapping, the theme role table that resolves those markup color names, and the sidecar image slots that Markdown rendering leaves in styled text.
Package style is the transcript text vocabulary shared by every polly surface: gotui inline markup and its bracket escaping, cell wrapping, the theme role table that resolves those markup color names, and the sidecar image slots that Markdown rendering leaves in styled text.
polly/internal/termimg
Package termimg draws transcript thumbnails with the terminal's native graphics protocol, Kitty or Sixel: it detects which one the terminal speaks, prepares scaled pixels off the event loop, and places or deletes them by screen cell without disturbing the text layer.
Package termimg draws transcript thumbnails with the terminal's native graphics protocol, Kitty or Sixel: it detects which one the terminal speaks, prepares scaled pixels off the event loop, and places or deletes them by screen cell without disturbing the text layer.
controltest
Package controltest is an in-process control daemon for tests: it speaks the control contract's lines over a Unix socket, keeps sessions in memory, and runs each turn by a script the test gives.
Package controltest is an in-process control daemon for tests: it speaks the control contract's lines over a Unix socket, keeps sessions in memory, and runs each turn by a script the test gives.
experiments
textfx command
textfx is an isolated gotui/tcell playground; it does not start Polly or a provider.
textfx is an isolated gotui/tcell playground; it does not start Polly or a provider.
windowfx command
windowfx is a local window-chrome playground.
windowfx is a local window-chrome playground.
Package images applies the portable image contract shared by every ingestion boundary: user attachments in cmd/polly and model-initiated views through the view_image tool.
Package images applies the portable image contract shared by every ingestion boundary: user attachments in cmd/polly and model-initiated views through the view_image tool.
internal
envstorage
Package envstorage manages only directories created for a sandbox environment.
Package envstorage manages only directories created for a sandbox environment.
filelock
Package filelock provides cross-platform file locking backed by flock(2) on Unix and LockFileEx/UnlockFileEx on Windows.
Package filelock provides cross-platform file locking backed by flock(2) on Unix and LockFileEx/UnlockFileEx on Windows.
ids
Package ids generates the random hexadecimal identifiers shared by the swarm, workflow, and worktree runtimes.
Package ids generates the random hexadecimal identifiers shared by the swarm, workflow, and worktree runtimes.
log
safefile
Package safefile opens local files and verifies that the object opened is a regular file, refusing special files that could block the caller.
Package safefile opens local files and verifies that the object opened is a regular file, refusing special files that could block the caller.
scratch
Package scratch removes runtime-owned temporary directories.
Package scratch removes runtime-owned temporary directories.
sessiontest
Package sessiontest provides storage conformance fixtures shared by session and runtime tests.
Package sessiontest provides storage conformance fixtures shared by session and runtime tests.
textdiff
Package textdiff computes line-oriented unified diffs without external dependencies.
Package textdiff computes line-oriented unified diffs without external dependencies.
llm
anthropic
Package anthropic is a minimal REST client for the Anthropic Messages API (api.anthropic.com/v1/messages), covering the slice polly uses: streaming and non-streaming message creation with tools, thinking, and structured output.
Package anthropic is a minimal REST client for the Anthropic Messages API (api.anthropic.com/v1/messages), covering the slice polly uses: streaming and non-streaming message creation with tools, thinking, and structured output.
codex
Package codex signs a user in with their ChatGPT account and sends completions to OpenAI's Codex backend on the plan that account carries, the way the Codex CLI does.
Package codex signs a user in with their ChatGPT account and sends completions to OpenAI's Codex backend on the plan that account carries, the way the Codex CLI does.
deepseek
Package deepseek talks to DeepSeek's OpenAI-compatible Chat Completions API.
Package deepseek talks to DeepSeek's OpenAI-compatible Chat Completions API.
gemini
Package gemini is a minimal REST client for the Gemini Developer API (generativelanguage.googleapis.com) covering the slice polly uses: generateContent, streamGenerateContent over SSE, and batchEmbedContents, authenticated by API key.
Package gemini is a minimal REST client for the Gemini Developer API (generativelanguage.googleapis.com) covering the slice polly uses: generateContent, streamGenerateContent over SSE, and batchEmbedContents, authenticated by API key.
internal/catalog
Package catalog holds what every provider's model listing shares: a bounded JSON fetch that never follows a redirect with credentials, the loosely typed accessors for provider records, the neutral fields of a model record, a page walker with cycle detection, and the listing collector that dedupes, filters, and sorts.
Package catalog holds what every provider's model listing shares: a bounded JSON fetch that never follows a redirect with credentials, the loosely typed accessors for provider records, the neutral fields of a model record, a page walker with cycle detection, and the listing collector that dedupes, filters, and sorts.
internal/contract
Package contract holds the request contract shared by the llm package and its provider packages: the LLM and stream-processor interfaces, the completion request, the thinking-effort model, model capabilities, the stream watchdog, and the per-run caches providers read.
Package contract holds the request contract shared by the llm package and its provider packages: the LLM and stream-processor interfaces, the completion request, the thinking-effort model, model capabilities, the stream watchdog, and the per-run caches providers read.
internal/httpx
Package httpx holds the HTTP plumbing every provider client shares: a retrying POST with the official SDKs' backoff policy, bounded error-body decoding, and a server-sent-events scanner.
Package httpx holds the HTTP plumbing every provider client shares: a retrying POST with the official SDKs' backoff policy, bounded error-body decoding, and a server-sent-events scanner.
internal/retry
Package retry provides a bounded budget shared by nested retry loops.
Package retry provides a bounded budget shared by nested retry loops.
ollama
Package ollama is a minimal client for the Ollama native chat API (/api/chat), covering the slice polly uses.
Package ollama is a minimal client for the Ollama native chat API (/api/chat), covering the slice polly uses.
openai
Package openai is a minimal REST client for the OpenAI API and OpenAI-compatible servers, covering the slice polly uses: Chat Completions (the dialect every compatible provider speaks — DeepSeek, OpenRouter, HuggingFace, custom base URLs), the Responses API (native OpenAI), and embeddings.
Package openai is a minimal REST client for the OpenAI API and OpenAI-compatible servers, covering the slice polly uses: Chat Completions (the dialect every compatible provider speaks — DeepSeek, OpenRouter, HuggingFace, custom base URLs), the Responses API (native OpenAI), and embeddings.
openrouter
Package openrouter talks to the OpenRouter gateway.
Package openrouter talks to the OpenRouter gateway.
qwencloud
Package qwencloud talks to QwenCloud's OpenAI-compatible Chat Completions API.
Package qwencloud talks to QwenCloud's OpenAI-compatible Chat Completions API.
replay
Package replay is the model behind a headless shot fixture: a provider that plays scripted turns instead of calling an API, so a TUI frame that only a live stream shows — thinking, half-streamed text, a tool call being handed over, a stream error — can be captured deterministically and without a credential.
Package replay is the model behind a headless shot fixture: a provider that plays scripted turns instead of calling an API, so a TUI frame that only a live stream shows — thinking, half-streamed text, a tool call being handed over, a stream error — can be captured deterministically and without a credential.
Package rex provides a programmatic Go client for the Rex terminal multiplexer over Rex's direct control WebSocket (/api/control, rex.control.v1) and HTTP (/api/help) APIs, with automatic CLI fallback for CLI-only features such as ad-hoc Lua evaluation ("rex do"), remote SSH/Tailscale hosts, and active port-forwarding tunnels.
Package rex provides a programmatic Go client for the Rex terminal multiplexer over Rex's direct control WebSocket (/api/control, rex.control.v1) and HTTP (/api/help) APIs, with automatic CLI fallback for CLI-only features such as ad-hoc Lua evaluation ("rex do"), remote SSH/Tailscale hosts, and active port-forwarding tunnels.
Package subagent lets a model delegate work to a child agent.
Package subagent lets a model delegate work to a child agent.
Package swarm provides durable coordination for one parent and its direct children.
Package swarm provides durable coordination for one parent and its direct children.
internal/live
Package live maintains in-memory, display-only activity snapshots and bounded live transcript tails for running swarm members.
Package live maintains in-memory, display-only activity snapshots and bounded live transcript tails for running swarm members.
internal/state
Package state owns the durable coordination record types, format versioning, JSON codecs, copy-on-write edit delta tracking, state cache, and edit queue for package swarm.
Package state owns the durable coordination record types, format versioning, JSON codecs, copy-on-write edit delta tracking, state cache, and edit queue for package swarm.
Package workflow executes bounded JavaScript orchestration over a host's existing agent runtime.
Package workflow executes bounded JavaScript orchestration over a host's existing agent runtime.
Package worktree captures dirty Git checkouts and prepares isolated changes.
Package worktree captures dirty Git checkouts and prepares isolated changes.

Jump to

Keyboard shortcuts

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