mirror of
https://github.com/getcompanion-ai/co-mono.git
synced 2026-04-16 12:03:23 +00:00
feat(coding-agent): allow starting CLI with prompt in interactive mode (#46)
BREAKING CHANGE: Passing a prompt on the command line now starts interactive mode with the prompt pre-submitted, instead of exiting after completion. Use --print or -p to get the previous non-interactive behavior. - Add --print / -p flag for non-interactive mode - Update runInteractiveMode to accept initial messages - Update README documentation - Fix Model Selection Priority docs to include --models scope
This commit is contained in:
parent
3018b01460
commit
e89e657045
3 changed files with 48 additions and 15 deletions
|
|
@ -250,10 +250,11 @@ You can add custom HTTP headers to bypass Cloudflare bot detection, add authenti
|
|||
When starting `pi`, models are selected in this order:
|
||||
|
||||
1. **CLI args**: `--provider` and `--model` flags
|
||||
2. **Restored from session**: If using `--continue` or `--resume`
|
||||
3. **Saved default**: From `~/.pi/agent/settings.json` (set when you select a model with `/model`)
|
||||
4. **First available**: First model with a valid API key
|
||||
5. **None**: Allowed in interactive mode (shows error on message submission)
|
||||
2. **First from `--models` scope**: If `--models` is provided (skipped when using `--continue` or `--resume`)
|
||||
3. **Restored from session**: If using `--continue` or `--resume`
|
||||
4. **Saved default**: From `~/.pi/agent/settings.json` (set when you select a model with `/model`)
|
||||
5. **First available**: First model with a valid API key
|
||||
6. **None**: Allowed in interactive mode (shows error on message submission)
|
||||
|
||||
### Provider Defaults
|
||||
|
||||
|
|
@ -652,11 +653,14 @@ Custom system prompt. Can be:
|
|||
If the argument is a valid file path, the file contents will be used as the system prompt. Otherwise, the text is used directly. Project context files and datetime are automatically appended.
|
||||
|
||||
**--mode <mode>**
|
||||
Output mode for non-interactive usage. Options:
|
||||
Output mode for non-interactive usage (implies `--print`). Options:
|
||||
- `text` (default): Output only the final assistant message text
|
||||
- `json`: Stream all agent events as JSON (one event per line). Events are emitted by `@mariozechner/pi-agent` and include message updates, tool executions, and completions
|
||||
- `rpc`: JSON mode plus stdin listener for headless operation. Send JSON commands on stdin: `{"type":"prompt","message":"..."}` or `{"type":"abort"}`. See [test/rpc-example.ts](test/rpc-example.ts) for a complete example
|
||||
|
||||
**--print, -p**
|
||||
Non-interactive mode: process the prompt(s) and exit. Without this flag, passing a prompt starts interactive mode with the prompt pre-submitted. Similar to Claude's `-p` flag and Codex's `exec` command.
|
||||
|
||||
**--no-session**
|
||||
Don't save session (ephemeral mode)
|
||||
|
||||
|
|
@ -701,10 +705,13 @@ Show help message
|
|||
# Start interactive mode
|
||||
pi
|
||||
|
||||
# Single message mode (text output)
|
||||
# Interactive mode with initial prompt (stays running after completion)
|
||||
pi "List all .ts files in src/"
|
||||
|
||||
# JSON mode - stream all agent events
|
||||
# Non-interactive mode (process prompt and exit)
|
||||
pi -p "List all .ts files in src/"
|
||||
|
||||
# JSON mode - stream all agent events (non-interactive)
|
||||
pi --mode json "List all .ts files in src/"
|
||||
|
||||
# RPC mode - headless operation (see test/rpc-example.ts)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue