mirror of
https://github.com/getcompanion-ai/co-mono.git
synced 2026-04-16 14:01:06 +00:00
Add CLI file arguments support via @file prefix
Implements ability to include files directly in the initial message using @ prefix. Features: - All @file arguments are coalesced into the first user message - Text files wrapped in <file name="path">content</file> tags - Images (.jpg, .jpeg, .png, .gif, .webp) attached as base64-encoded attachments - Supports ~ expansion, relative and absolute paths - Empty files are skipped silently - Non-existent files cause immediate error with clear message - Works in interactive, --print, and --mode text/json modes - Not supported in --mode rpc (errors with clear message) Examples: pi @prompt.md @image.png "Do this" pi --print @code.ts "Review this code" pi @requirements.md @design.png "Implement this" Closes #54
This commit is contained in:
parent
48df1ff259
commit
f95f41b1c4
3 changed files with 211 additions and 7 deletions
|
|
@ -650,9 +650,58 @@ pi --session /path/to/my-session.jsonl
|
|||
## CLI Options
|
||||
|
||||
```bash
|
||||
pi [options] [messages...]
|
||||
pi [options] [@files...] [messages...]
|
||||
```
|
||||
|
||||
### File Arguments (`@file`)
|
||||
|
||||
You can include files directly in your initial message using the `@` prefix:
|
||||
|
||||
```bash
|
||||
# Include a text file in your prompt
|
||||
pi @prompt.md "Answer the question"
|
||||
|
||||
# Include multiple files
|
||||
pi @requirements.md @context.txt "Summarize these"
|
||||
|
||||
# Include images (vision-capable models only)
|
||||
pi @screenshot.png "What's in this image?"
|
||||
|
||||
# Mix text and images
|
||||
pi @prompt.md @diagram.png "Explain based on the diagram"
|
||||
|
||||
# Files without additional text
|
||||
pi @task.md
|
||||
```
|
||||
|
||||
**How it works:**
|
||||
- All `@file` arguments are combined into the first user message
|
||||
- Text files are wrapped in `<file name="path">content</file>` tags
|
||||
- Images (`.jpg`, `.jpeg`, `.png`, `.gif`, `.webp`) are attached as base64-encoded attachments
|
||||
- Paths support `~` for home directory and relative/absolute paths
|
||||
- Empty files are skipped
|
||||
- Non-existent files cause an immediate error
|
||||
|
||||
**Examples:**
|
||||
```bash
|
||||
# All files go into first message, regardless of position
|
||||
pi @file1.md @file2.txt "prompt" @file3.md
|
||||
|
||||
# This sends:
|
||||
# Message 1: file1 + file2 + file3 + "prompt"
|
||||
# (Any additional plain text arguments become separate messages)
|
||||
|
||||
# Home directory expansion works
|
||||
pi @~/Documents/notes.md "Summarize"
|
||||
|
||||
# Combine with other options
|
||||
pi --print @requirements.md "List the main points"
|
||||
```
|
||||
|
||||
**Limitations:**
|
||||
- Not supported in `--mode rpc` (will error)
|
||||
- Images require vision-capable models (e.g., Claude, GPT-4o, Gemini)
|
||||
|
||||
### Options
|
||||
|
||||
**--provider <name>**
|
||||
|
|
@ -727,9 +776,15 @@ pi
|
|||
# Interactive mode with initial prompt (stays running after completion)
|
||||
pi "List all .ts files in src/"
|
||||
|
||||
# Include files in your prompt
|
||||
pi @requirements.md @design.png "Implement this feature"
|
||||
|
||||
# Non-interactive mode (process prompt and exit)
|
||||
pi -p "List all .ts files in src/"
|
||||
|
||||
# Non-interactive with files
|
||||
pi -p @code.ts "Review this code for bugs"
|
||||
|
||||
# JSON mode - stream all agent events (non-interactive)
|
||||
pi --mode json "List all .ts files in src/"
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue