Package Exports
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (agentp) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
agentp
This package provides two CLI tools:
agentp— pipes prompt text into a running OpenCode TUI session and streams the assistant final answer back to stdoutocmux— manages OpenCode server + TUI sessions in tmux (create, switch, kill, list)
It is designed for prompt-driven workflows where you want to do things like:
- compose prompts with
cat,printf, or heredocs - submit them to OpenCode from scripts
- capture output in files or pipe to other tools
- drive prompts directly from editors like Vim/Neovim
Install
From npm:
npm install -g agentpFor local development in this repo:
npm linkRequirements
- Node.js 18+
- An OpenCode server session listening locally (default port:
4096)
Notes:
agentpconnects to the OpenCode event endpoint over HTTP.- In practice this means running
opencode serve(or equivalent serve mode) so the port is open. opencode attachis optional but useful to monitor the full conversation in another terminal/tmux pane.
Usage
agentp [options] [url]Options:
--qa: print the original prompt and answer with labels (useful when used as a filter)--version: show version--help: show help message
Arguments:
url: OpenCode TUI server URL or port number (defaults to4096). Examples:4096,http://localhost:4096,http://192.168.1.50:4096
Examples
Send a one-line prompt:
printf "Summarize the latest logs" | agentpType and send a multi-line prompt:
cat | agentp
# (press Ctrl+D to end input)Send a multi-line prompt from a file:
cat prompt.txt | agentpUse an explicit port:
cat prompt.txt | agentp 4096Capture answer to a file:
cat prompt.txt | agentp > answer.txtConnect to a remote OpenCode server:
cat prompt.txt | agentp http://192.168.1.50:4096From Vim/Neovim, send the current visual selection and replace it in place with the assistant answer:
:'<,'>!agentpFrom Vim/Neovim, send the current visual selection and keep the prompt with the answer:
:'<,'>!agentp --qaocmux
Manage OpenCode server + TUI in tmux for project directories.
ocmux [-l] [<subcommand>] [<directory>]Without arguments, searches upward from <directory> (default: $PWD) for .ocmux.json and switches to that server's tmux window.
Subcommands:
new [--git|--GIT] [dir]— Create a new server indir(default:$PWD). Errors if one already exists there. Warns if a parent directory already has a server.--gitresolvesdirto the nearest parent with a.gitentry (file or dir); errors if none is found.--GITresolvesdirto the nearest parent with a.gitdirectory only; errors if none is found.
kill [dir]— Kill the server found upward fromdir. Removes its tmux window and state file.list— List all running servers with their directories, URLs, and status.
Options:
-l: long output for default/new commands (append→ <dir>after the URL)--version: show version-h: show help message--: treat the next argument as a directory even if it matches a subcommand name
Notes:
- If
<directory>is not a valid path,ocmuxtries to match it against the basenames of existing sessions (exact unique match). - When using
--git/--GIT,ocmuxrefuses to create a new server above an existing.ocmux.jsonfound while searching for the git root.
Requirements
- Node.js 18+
- tmux — session multiplexer
opencodebinary in PATH (the OpenCode CLI)
State file
ocmux stores per-project state in .ocmux.json (contains URL, log path, window index). It searches upward from the target directory, similar to git.
How agentp Works
- Clears the current TUI prompt input.
- Appends each line from stdin to the TUI prompt.
- Submits the prompt.
- Listens to the event stream and prints assistant text parts.
- Stops when the session reaches idle state.
Operational hint:
- You can keep a separate
opencode attachview open to see the full run context whileagentpis used from shell scripts or editor buffers.
License
MIT