Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
870be34
fix: warn on stderr when piped stdin is empty
Nov 24, 2026
fd7f292
fix: agent cache key, truncated streams, timeouts, panic, symlink wri…
Nov 24, 2026
1250ffd
feat: repo .priniarc cannot set providers/run/write until trusted
Nov 24, 2026
d5995fb
fix: the passed global config is trusted in load_from
Nov 24, 2026
f507ebf
feat: --run asks before non-read-only commands; -y skips the question
Nov 24, 2026
2bb15b0
feat: --cmd and a zsh widget that turns a request into an editable co…
Nov 24, 2026
49c915e
feat: directory config beats env; a repo can always tighten run/write
Nov 24, 2026
c35fc10
test: use a setting the layering test does not read
Nov 24, 2026
18f5414
feat: prinia init picks a local model for this machine and writes the…
Nov 24, 2026
967005f
feat: -t NAME runs a saved instruction from .prinia/templates
Nov 24, 2026
3bce079
feat: --each runs one call per stdin line in parallel; providers are …
Nov 24, 2026
00dbba1
feat: max_input splits long stdin into parts and combines the answers…
Nov 24, 2026
e77ed84
chore: clippy, README entries for init, trust and --each
Nov 24, 2026
9696ae2
feat: private mode; providers marked private = true are the only ones…
Nov 24, 2026
e05badf
feat: provider tags; a project's tag setting picks the provider that …
Nov 24, 2026
df7d590
feat: tiered context (verbatim, older questions, opt-in summaries) an…
Nov 24, 2026
b9f621d
feat: history ask finds matching turns across the whole history (time…
Nov 24, 2026
8681b3e
feat: -c pulls in older turns that match the new question; fix first-…
Nov 24, 2026
a9319f0
fix: audit items - tighter read-only list, private turns stay with pr…
Nov 24, 2026
63f810f
fix: children never re-split input, trust shows files and asks, key r…
Nov 24, 2026
5629952
refactor: split ask(), share Request::plain; fix: init test hook, his…
Nov 24, 2026
3a22f52
feat: widget works in vi modes; PRINIA_WIDGET_KEY takes several keys
Nov 24, 2026
3b1f36f
feat: Windows approval prompt (CONIN$/CONOUT$) and process-tree kill …
Nov 24, 2026
0faee6d
fix: key.rs built on Windows (bail! only used under cfg(unix))
Nov 24, 2026
f662482
docs: settings, provider fields, env vars and flags added in this PR
Nov 24, 2026
c3e0954
test: close the store before deleting its folder (Windows)
Nov 24, 2026
3fed4dd
test: keep SystemRoot and temp vars in the cleared test environment (…
Nov 24, 2026
8379158
ci: Windows tests are a required check
Nov 24, 2026
bb5874d
docs: Windows status (CI only)
Nov 24, 2026
0ff07b2
feat: prinia update [--check] runs the release installer in place; re…
Nov 24, 2026
5cf3146
test: release_server helper only builds where its test does (Windows …
Nov 24, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,19 @@ jobs:
- run: cargo clippy --locked --all-targets -- -D warnings
- run: cargo test --locked

# Separate from the matrix: no fmt step (line endings), the rest as on Unix.
test-windows:
name: Test (windows-latest)
runs-on: windows-latest
timeout-minutes: 30
steps:
- uses: actions/checkout@v7
with:
persist-credentials: false

- run: cargo clippy --locked --all-targets -- -D warnings
- run: cargo test --locked

# The installer is piped into sh on users' machines.
shell:
name: Shell scripts
Expand Down Expand Up @@ -60,7 +73,7 @@ jobs:
required-checks-passed:
name: Required checks passed
runs-on: ubuntu-latest
needs: [test, shell, zizmor, actionlint]
needs: [test, test-windows, shell, zizmor, actionlint]
if: always()
steps:
- if: contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled')
Expand Down
24 changes: 22 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,18 @@ export ANTHROPIC_API_KEY=... # or OPENAI_API_KEY, or configure a local mode
prinia "hello"
```

### Local models

No account or API key needed. With [Ollama](https://ollama.com) running:

```bash
prinia init
```

It checks how much memory you have, suggests a model that fits (for example `qwen2.5:14b` on 16 GB or more, plus `qwen2.5:32b` for `-d` on 40 GB or more), offers to `ollama pull` it, and writes `~/.config/prinia/config.toml` (it never overwrites an existing one). To do it by hand, see [Configuration](docs/configuration.md#providers).

Small models (3B and under) invent commands and ignore instructions. Other OpenAI-compatible runners (LM Studio, llama.cpp, vLLM) work with a different `base_url`.

See [Install](docs/install.md) for other platforms and building from source, and [Configuration](docs/configuration.md) for local models and other providers.

## Usage
Expand All @@ -44,11 +56,19 @@ cmd | prinia "instruction" | cmd2 # a pipeline step
prinia -f "..." # fast tier
prinia -d "..." # reasoning tier
prinia -p local "..." # a configured provider
cat list.txt | prinia --each "..." # one call per line, in parallel (-j N)
prinia -t NAME "..." # a saved instruction (docs/usage.md#templates)
prinia --cmd "..." # one shell command; `eval "$(prinia shell zsh)"` binds it to ctrl-g
prinia -x "..." # let the model run commands to answer (agent + --run); asks before anything not read-only, -y skips that
prinia -a "..." # agent: the model reads and searches files here (--write, --run to allow more)
prinia -c "..." # include earlier turns from this directory
prinia -c "..." # include earlier turns from this directory (recent, relevant, older questions)
prinia context ["question"] # show what -c would send
prinia --no-cache "..." # ask again even if the call is in your history
prinia --no-record "..." # don't save this call

prinia init # pick a local model for this machine and write the config
prinia update [--check] # update prinia (curl-installed binaries; brew users: brew upgrade)
prinia trust # allow this repo's .priniarc to turn on run/write/agent
prinia history # browse everything you asked (fzf when available)
prinia history search kestrel # find turns by words in prompt, input or answer
prinia history ask "what did I ask about TLS?" # a fast model answers from your history
Expand Down Expand Up @@ -76,7 +96,7 @@ More in [Usage](docs/usage.md) and [History](docs/history.md).

prinia is beta software.

- macOS and Linux are tested. Windows is untested.
- macOS and Linux are tested. Windows builds and passes the tests in CI, but has not been used by hand.
- Agent mode has run against a mock server and one OpenAI-compatible provider; the Anthropic tool-call format has not run against the real API yet.

## License
Expand Down
16 changes: 13 additions & 3 deletions docs/agent.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,31 @@
prinia -a "which file defines the retry logic, and how many times does it retry?"
prinia -a --write "rename the function parse to parse_config everywhere"
prinia -a --run "run the tests and tell me what fails"
prinia -x "what is my public ip" # -x = --agent --run
```

With `-a` (`--agent`) the model can look around in the current directory before it answers: it calls tools, `prinia` runs them and returns the results, and this repeats until the model gives a final answer. The answer goes to stdout like any other call, and one line per tool call goes to stderr so you can see what it did.

## Making it the default

```toml
agent = true # use agent mode for every call at a terminal
run = true # and let it run commands (`write = true` for file edits)
```

The model then decides per question whether to call a tool. The `agent` setting only applies when both stdin and stdout are terminals, so pipelines stay plain filters; `-a` forces it anywhere, `--no-agent` turns it off for one call. `--json` and `--check` never use it. `run` and `write` are the same permissions as the flags: commands still ask first unless they are read-only, but file writes do not, so enable `write` only where changes can be reviewed.

## What it can do

| Tool | Needs | What it does |
| :--- | :--- | :--- |
| `read_file` | nothing | Reads a text file, with line numbers, optionally a line range |
| `read_file` | nothing | Reads a text file (regular files up to 10 MB), with line numbers, optionally a line range |
| `list_dir` | nothing | Lists a directory |
| `search` | nothing | Finds lines containing a text (case-insensitive) under a path; skips hidden directories, `target` and `node_modules` |
| `write_file`, `replace` | `--write` | Creates or overwrites a file; replaces one exact, unique piece of text |
| `run_command` | `--run` | Runs a shell command in the directory and returns its output and exit code; stopped after 60 seconds |
| `run_command` | `--run` | Runs a shell command (asking first unless read-only) in the directory and returns its output and exit code; stopped after 60 seconds |

Reading is the default and changes nothing. Writing and running commands are separate switches, so you can allow one without the other. There is no per-action confirmation: the flag is the permission, so use `--write` and `--run` where you would be comfortable letting a script run, and in a git repository where changes can be reviewed.
Reading is the default and changes nothing. Writing and running commands are separate switches, so you can allow one without the other. `--run` asks before each command on your terminal (`[y/N]`), except a pipeline of read-only commands (`ls`, `cat`, `head`, `find`, `grep`, `rg`, `sort`, `wc`, `date`, ...), which runs straight away. Anything with `;`, `&&`, `$(...)`, redirects, or flags that write or run a program (`find -exec`, `-delete`, `sort -o`, `rg --pre`) asks. `git` always asks, because a repository's own config can make even `git status` run a program. With no terminal to ask on, such a command is refused and the model is told. `-y` (`--yes`) runs everything without asking. `--write` has no per-file confirmation, so use it in a git repository where changes can be reviewed.

All file tools stay inside the directory you ran the command in. A path that leaves it, by `..`, an absolute path or a symbolic link, is refused. `run_command` is not limited this way, since a shell command can do anything your account can.

Expand Down
63 changes: 57 additions & 6 deletions docs/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,56 @@
Every setting can be given four ways. The first that applies wins:

1. A **flag** (where one exists, such as `-m` or `--no-record`)
2. An **environment variable**: `PRINIA_` plus the setting name in capitals, e.g. `PRINIA_MAX_TOKENS=2000`
3. A **`.priniarc`** file in the current directory or a parent. Closer files win over farther ones
2. A **`.priniarc`** file in the current directory or a parent. Closer files win over farther ones
3. An **environment variable**: `PRINIA_` plus the setting name in capitals, e.g. `PRINIA_MAX_TOKENS=2000`
4. The **global config**: `~/.config/prinia/config.toml` (`$XDG_CONFIG_HOME` is respected, on Windows `%APPDATA%\prinia`; `PRINIA_CONFIG` points at another file)

A directory beats the environment on purpose: a project that says `record = false` or `run = false` keeps saying it, whatever your shell exports. Only a flag overrides it, for one call. This is safe because a project file can only set behaviour (below), never where your data goes.

```toml
# ~/.config/prinia/config.toml, or .priniarc in a project
provider = "anthropic"
record = true
cache_ttl = "3d"
```

`prinia config` prints every setting, its effective value and its source (`env`, `config` or `default`), the files that were read and the configured providers. Unknown keys and values of the wrong type are reported on stderr and ignored, so a typo never silently changes behaviour. Booleans in environment variables accept `1/0`, `true/false`, `yes/no`, `on/off`.
`prinia config` prints every setting, its effective value and its source (`directory`, `env`, `global` or `default`), the files that were read and the configured providers. Unknown keys and values of the wrong type are reported on stderr and ignored, so a typo never silently changes behaviour. Booleans in environment variables accept `1/0`, `true/false`, `yes/no`, `on/off`.

A `.priniarc` holds behaviour only: `record`, `cache`, `cache_ttl`, `context`, `context_chars`, `max_tokens`, `effort`, `fast_under`, `deep_over`, `check_retries`, `max_input`, `agent`, `agent_steps`, `run`, `write` and the two prompts. Everything about the device is read only from your global config and ignored, with a warning, in a project file: `[providers.*]`, `provider`, the model names, `keychain` and the history limits. A repository therefore cannot choose where your prompts go.

Settings that let the model act on your machine or change what it is told (`run`, `write`, `agent`, `prompt_pipe`, `prompt_interactive`) are ignored in a project file until you run `prinia trust`, which prints each file and asks before trusting it (`--yes` skips the question). Turning `run`, `write` or `agent` off needs no trust. Trust is tied to the file's exact contents, so any later change, such as from a `git pull`, needs trusting again. Your own global config is always trusted.

### Tags and private mode

Providers can carry tags, and a project asks for a tag instead of naming a provider. The device decides which provider that means, so the same `.priniarc` works on every machine.

```toml
# ~/.config/prinia/config.toml
provider = "local"

[providers.local]
type = "openai"
base_url = "http://localhost:11434/v1"
tags = ["private"]

[providers.corp] # a company key covered by an NDA
type = "anthropic"
api_key_env = "CORP_ANTHROPIC_KEY"
tags = ["private", "work"]
```

```toml
# .priniarc
tag = "work" # use a provider tagged "work" (your default if it has the tag, else the first by name)
```

- `tag = "NAME"` (project or global setting) makes prinia use a provider with that tag. If none has it, the call fails; there is no fallback to another provider. `-p NAME` must name a provider with the tag, or it is refused before anything is sent.
- `private` is a tag with shorthand: `private = true` on a provider means `tags = ["private"]`, and `private = true` as a setting requires that tag. It combines with `tag`, so a project can need both `work` and `private`.
- Built-in `anthropic` and `openai` have no tags unless you define `[providers.anthropic]` with them.
- Tags mean what you decide. prinia cannot check that a provider is covered by an agreement; marking it `private` is your statement that it is.
- The check covers every call, including `history ask` and agent mode. `prinia init` tags the local model `private`.

A `.priniarc` is how a project gets its own behaviour: a repository that should never be recorded says `record = false`; one that must use a local model says `provider = "local"`.
A `.priniarc` is how a project gets its own behaviour: a repository that should never be recorded says `record = false`, one that must never run commands says `run = false`.

## Providers

Expand Down Expand Up @@ -44,6 +80,8 @@ fast_model = "meta-llama/Llama-3.2-3B-Instruct-Turbo"
| `base_url` | The API endpoint. Defaults to the official one for the type |
| `api_key_env` | Environment variable holding the key. Defaults to `ANTHROPIC_API_KEY` / `OPENAI_API_KEY`. Not needed for a local endpoint |
| `model`, `fast_model`, `deep_model` | Models for the three tiers |
| `tags` | Labels a project can ask for with the `tag` setting, e.g. `["private", "work"]` ([Tags and private mode](#tags-and-private-mode)) |
| `private` | `true` is shorthand for the tag `private` |

Without `-p` or `provider`, prinia uses the first of `ANTHROPIC_API_KEY` and `OPENAI_API_KEY` that is set.

Expand All @@ -62,13 +100,24 @@ API keys are read from the environment and are never written to the history or t
| `cache` | `pipe` | When identical calls are answered from history: `pipe`, `always`, `off` |
| `context` | `0` | Earlier turns from this directory sent with every call; `-c` uses it, or 5 when unset |
| `context_chars` | `16000` | Size cap for that context (characters; oldest turns are dropped first) |
| `context_relevant` | `3` | Older turns matching the new question, sent in full (`0` = off; see [Context](usage.md#context)) |
| `context_older` | `30` | Further older turns sent as one line each (`0` = off) |
| `context_summary` | `false` | Add model-written summaries of older blocks of turns |
| `context_blocks` | `4` | How many of those summaries |
| `cache_ttl` | `7d` | How long a history entry can answer a call (`12h`, `3d`, `2w`, `1m`) |
| `max_size` | `500m` | Size limit for the history's stored content (`100k`, `500m`, `2g`); the oldest turns go first |
| `max_age` | none | Also drop turns older than this (`90d`, `52w`) |
| `fast_under` | `0` (off) | Calls with fewer characters than this use the fast tier unless a tier or model is given |
| `deep_over` | none | Calls with more characters than this use the deep tier unless a tier or model is given |
| `history_scan` | `200` | Newest turns that `history ask` and `history agent` read |
| `excerpt_prompt` / `excerpt_reply` | `200` / `400` | Characters of each prompt and answer sent for `history ask` and `history agent` |
| `history_scan` | `200` | Newest turns that `history agent` reads |
| `ask_turns` | `15` | Best-matching turns `history ask` sends to the model |
| `excerpt_prompt` / `excerpt_reply` | `200` / `400` (`history ask`: `400` / `1000`) | Characters of each prompt and answer sent for `history ask` and `history agent` |
| `max_input` | `0` (off) | Longer stdin is processed in parts and combined ([Long input](usage.md#long-input)) |
| `private` | `false` | Only use providers tagged `private` ([Tags and private mode](#tags-and-private-mode)) |
| `tag` | none | Only use a provider with this tag |
| `agent` | `false` | Agent mode for every call at a terminal ([Agent](agent.md)) |
| `run` / `write` | `false` | Let agent mode run commands / change files |
| `agent_steps` | `25` | Tool rounds before an agent session stops |
| `check_retries` | `2` | Extra attempts when an answer fails `--json` or `--check` |
| `keychain` | `false` | Keep the history key in the OS credential store instead of a file ([History](history.md#where-the-key-lives)) |
| `prompt_pipe`, `prompt_interactive` | see below | The system prompts |
Expand All @@ -93,3 +142,5 @@ prinia sends one of these as the system prompt, depending on whether input or ou
| :--- | :--- |
| `ANTHROPIC_API_KEY`, `OPENAI_API_KEY` (or the variable named by `api_key_env`) | Provider credentials |
| `PRINIA_CONFIG` | Path of the global config file |
| `PRINIA_WIDGET_KEY` | Keys for the zsh widget, space-separated (default `^g`); set before `eval "$(prinia shell zsh)"` |
| `PRINIA_OLLAMA_URL` | Where `prinia init` looks for Ollama (default `http://localhost:11434`) |
10 changes: 9 additions & 1 deletion docs/history.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,15 @@ prinia history search kestrel nest # turns containing every word, any case,
prinia history ask "what did I ask about TLS last month?"
```

`search` is plain text matching and makes no network call. `ask` sends excerpts of your most recent turns to the fast model and prints its answer, so those excerpts leave your machine like any other prompt. The excerpt size and how many turns are scanned are settings (`excerpt_prompt`, `excerpt_reply`, `history_scan`). Neither command is recorded in the history. Filters (`--since`, `--older`, `--here`) narrow what is searched.
`search` is plain text matching and makes no network call.

`ask` finds the turns that match your question across the whole history, then a fast model answers from them:

1. **Time:** words like `yesterday`, `last week`, `last month`, `this week` or `3 days ago` narrow the range (generously: "last week" means the past two weeks). `--since`, `--older` and `--here` replace the guess. If nothing falls in the guessed range, it searches everything.
2. **Keywords:** the remaining meaningful words are matched against prompt, input and answer; a match in the prompt counts most. With no keyword hit, the newest turns are used.
3. **Answer:** the best `ask_turns` turns (default 15) go to the model with longer excerpts (`excerpt_prompt` 400, `excerpt_reply` 1000 characters), and it answers citing `#id`. If they do not contain the answer it should say so. stderr lists the turns used; open one with `prinia history show ID`.

Those excerpts leave your machine like any other prompt, so `ask` uses your configured provider and the `private` / `tag` rules apply. Turns made with a `private` provider are left out unless the provider answering is `private` too (the same goes for `history agent`). It is not recorded. Matching is plain words, not meaning: ask with the words you would have used at the time.

## Deleting

Expand Down
17 changes: 15 additions & 2 deletions docs/install.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,19 @@ The script picks the release for your OS and architecture, verifies it against t
| `PRINIA_INSTALL_DIR=/usr/local/bin` | Install somewhere else |
| `PRINIA_DOWNLOAD_URL=...` | Download from a mirror |

## Updating

```bash
prinia update --check # is a newer release out?
prinia update # install it in place
```

`prinia update` downloads the installer from the latest release and runs it into the folder the current binary lives in, so it does exactly what the install script does, including the checksum check; the installer is the only copy of that logic. Nothing is checked or downloaded unless you run the command.

It refuses for a binary installed by Homebrew or cargo (use `brew upgrade prinia` or `cargo install`) and for a development build. It is not available on Windows. Running the install script again always works as well, for any version.

Note that the checksum comes from the same release as the binary: it catches a corrupt download, not a compromised release.

## Homebrew

```bash
Expand All @@ -40,9 +53,9 @@ Building needs a Rust toolchain and a C compiler (SQLite and zstd are compiled f
| :--- | :--- | :--- |
| macOS, arm64 and x86-64 | yes | yes |
| Linux, arm64 and x86-64 | yes (glibc 2.39 or newer: Ubuntu 24.04, Debian 13, Fedora 40) | yes |
| Windows | no | no |
| Windows | no | in CI only |

On older Linux systems, build from source. Windows has code paths (Credential Manager for the optional [credential store](history.md#where-the-key-lives)) that have never been built or run.
On older Linux systems, build from source. On Windows, build from source (`cargo install --path .`). It builds and passes the test suite in CI on every change, but nobody has used it by hand yet: the command approval prompt (`CONIN$` / `CONOUT$`) and the Credential Manager key store (`keychain = true`) have not run on a real Windows console.

The command is `prinia`. If you want something shorter, alias it in your shell: `alias ai=prinia`.

Expand Down
Loading
Loading