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
agentp is a tiny CLI that pipes prompt text into a running OpenCode TUI session and streams the assistant final answer back to stdout.
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] [port]Options:
--qa: print question/answer separators around the streamed answer--help: show help message
Arguments:
port: OpenCode TUI port (defaults to4096)
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 QA separators and explicit port:
cat prompt.txt | agentp --qa 4096Capture answer to a file:
cat prompt.txt | agentp > answer.txtFrom 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 QA separators in the same file:
:'<,'>!agentp --qaHow It 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