ollie/scripts/README.md

194 lines
4.7 KiB
Markdown

# scripts
Shell scripts for interacting with the ollie 9P filesystem.
All scripts read `OLLIE` (default: `$HOME/mnt/ollie`) for the mount path.
`mk scripts` installs them and exposes them via the mounted filesystem,
so they are available without any `$PATH` changes:
```sh
exec $OLLIE/s/sh # start interactive shell
$OLLIE/s/ls # list sessions
$OLLIE/s/kill <id> # kill a session
$OLLIE/b/job "my prompt" # submit and wait for a batch job
$OLLIE/b/q "my prompt" # foreground one-shot query
$OLLIE/b/sched "my prompt" # submit a background job; prints b/ path
$OLLIE/u/optimize "prompt" # generate and return best optimized prompt
```
Scripts are organized by the filesystem namespace they are hosted under:
- `s/` — session management scripts
- `b/` — batch job scripts
- `u/` — utility scripts; compositions of other ollie primitives
---
## s/sh
Interactive chat interface for ollie sessions. Resumes the most recent
session for the current directory by default; creates a new one if none
exists.
```
s/sh [-new] [-resume] [-session ID] [-cwd DIR] [-backend B] [-model M] [-agent A]
```
**Flags**
| Flag | Description |
|---|---|
| `-new` | Always create a new session |
| `-resume` | Resume last session for the cwd; error if none |
| `-session ID` | Attach to a specific session by ID |
| `-cwd DIR` | Working directory (default: `pwd`) |
| `-backend B` | Backend override (e.g. `ollama`, `anthropic`) |
| `-model M` | Model override |
| `-agent A` | Agent config name |
**Input**
At the `>` prompt:
| Input | Action |
|---|---|
| `<text>` | Submit prompt, stream response |
| `/q <text>` | Enqueue prompt for later |
| `/<cmd>` | Send to session ctl (e.g. `/compact`, `/clear`) |
| `/kill` | Kill the session and exit |
| Ctrl-C | Interrupt running turn (or exit if idle) |
**Examples**
```sh
s/sh # resume or create session for pwd
s/sh -new -model gpt-4o # fresh session with model override
s/sh -session 1745123456-abc # attach to a specific session
```
---
## s/ls
List all active sessions.
```
s/ls
```
---
## s/kill
Kill a session by ID and remove it.
```
s/kill <id>
```
---
## b/job
Core batch job runner. Submits a prompt to `b/new`, waits for completion,
prints the result to stdout, then removes the job. Exit code is non-zero on
failure. `b/q` and `b/sched` are both wrappers around this script.
```
b/job [flags] [prompt...]
echo "prompt" | b/job [flags]
```
**Flags**
| Flag | Description |
|---|---|
| `-name N` | Base job name; jobs are suffixed `-0`, `-1`, ... |
| `-cwd DIR` | Working directory (default: `pwd`) |
| `-agent A` | Agent config name |
| `-backend B` | Backend override |
| `-model M` | Model override |
| `-output json` | Append JSON-only instruction to prompt |
| `-parallel N` | Run the same prompt N times in parallel (default: 1) |
| `-keep` | Do not remove job(s) after printing result |
| `-bg` | Submit and exit immediately; prints job id(s); implies `-keep` |
**Examples**
```sh
b/job "Summarize this repo in one sentence"
cat error.log | b/job "What is causing this error?"
b/job -output json "List the top 3 risks as JSON"
b/job -parallel 4 -keep "Write a haiku about filesystems"
b/job -backend ollama -model qwen3:8b "Explain this function" < main.go
```
With `-parallel N` and N > 1, results are separated by `=== {id} ===` headers.
---
## b/q
Foreground one-shot query; thin wrapper around `b/job`. Accepts the same flags.
```
b/q [flags] [prompt...]
echo "prompt" | b/q [flags]
```
---
## b/sched
Submit a background job; prints the `b/` path for each job. Wrapper around
`b/job -bg`.
```
b/sched [flags] [prompt...]
echo "prompt" | b/sched [flags]
```
**Flags**
| Flag | Description |
|---|---|
| `-name N` | Base job name |
| `-cwd DIR` | Working directory (default: `pwd`) |
| `-agent A` | Agent config name |
| `-backend B` | Backend override |
| `-model M` | Model override |
| `-output FORMAT` | Output format hint (e.g. `json`) |
| `-parallel N` | Submit N parallel jobs (default: 1) |
---
## u/optimize
Generates N candidate optimized prompts, judges them, and returns the best
one to stdout. Debugging output (progress messages) goes to stderr.
```
u/optimize [flags] [prompt...]
echo "prompt" | u/optimize [flags]
```
**Flags**
| Flag | Description |
|---|---|
| `-n N` | Number of candidates to generate (default: 3) |
| `-cb B` | Candidate generation backend |
| `-cm M` | Candidate generation model |
| `-jb B` | Judge backend |
| `-jm M` | Judge model |
**Examples**
```sh
u/optimize "Summarize this document"
u/optimize -n 5 -cm qwen/qwen3-8b -jm anthropic/claude-opus-4.6 "Write a haiku"
u/optimize "generate a hello world program. use c++." >[2]/dev/null | b/q
```
Outputs to stdout, making it composable with other pipeline stages.