Skip to content

feat: -x, --cmd widget, init, templates, --each, max_input, safer config; fixes from audit - #6

Merged
JustMaris merged 31 commits into
mainfrom
warn-empty-stdin
Nov 24, 2026
Merged

JustMaris merged 31 commits into
mainfrom
warn-empty-stdin

Conversation

@JustMaris

@JustMaris JustMaris commented Nov 24, 2026 •

Copy link
Copy Markdown
Member

Fixes (from a code audit)

  • Agent runs no longer share a cache key with plain calls.
  • A stream that ends without a finish marker is an error, not a cacheable answer.
  • HTTP response/body timeouts; history agent no longer panics on ] ... [; dangling symlinks refused for --write; run_command kills the whole process group on timeout.
  • Piped-but-empty stdin prints a warning on stderr.

Safer agent

  • --run / -x ask [y/N] on the terminal before any command that is not a read-only pipeline (ls, find, cat, git log, ...). -y skips the question; with no terminal such commands are refused.

Config

  • .priniarc holds behaviour only. Providers, provider, model names, keychain and history limits are device-level (global config only).
  • run, write, agent and the prompts need prinia trust in a repo file; turning them off never does.
  • Order is now flag > directory > env > global > default. prinia config shows directory, env, global or default.
  • New settings: agent, write, run, max_input, private, tag.
  • Provider tags: tags = ["private", "work"] under [providers.NAME]; a .priniarc says tag = "work" and the device picks the provider that has it (no fallback; -p must match). private is a tag: private = true on a provider, or as a setting to require it. prinia init tags the local model private.

New

  • -x (agent + run), --no-agent, -y.

  • --cmd and prinia shell zsh: a ctrl-g widget that turns a request into an editable command. Bound in emacs and both vi modes; PRINIA_WIDGET_KEY takes one or several keys.

  • prinia init: finds Ollama, picks a model for the machine's memory, offers to pull it, writes the config.

  • -t NAME: saved instructions from .prinia/templates/.

  • --each / -j N: one call per stdin line, parallel, ordered.

  • Tiered -c context: newest turns verbatim, older turns that match the new question in full (context_relevant), then one line per older question (context_older), then opt-in model summaries of older blocks (context_summary, derived from history, dropped on any delete, made by the call's own provider). prinia context shows what -c would send; --summarize builds the summaries now.

  • max_input: long stdin is processed in parts and combined.

  • README: local-model setup.

  • history ask finds matching turns across the whole history (time words like "last week", keywords, ranking) and cites turn ids.

  • Fix: parallel first use of a fresh history could create two keys or fail with a UNIQUE error; the key is now created under a write lock, with a 5 s busy timeout.

Second audit (all 14 findings fixed)

  • --run auto-approve list no longer includes git, uniq, hostname, or flags that write or run programs.
  • Turns made with a private provider are never sent to a non-private provider (-c, history ask, history agent).
  • Child processes never re-split long input (a project max_input used to defeat the env guard).
  • [DONE] counts as a complete stream; read_file refuses FIFOs and files over 10 MB.
  • prinia trust prints each file and asks first.
  • key rotate is crash-safe (pending wrapping, finished on next open).
  • ask() split into helpers; one Request::plain; one shell spawn helper; fewer git spawns.
  • New tests: map-reduce and project max_input, trust, private turns, dropped streams, key-rotation crash, init, FIFO.

Docs

  • docs/configuration.md: the settings table lists every new setting (context_relevant, context_older, context_summary, context_blocks, max_input, private, tag, agent, run/write, agent_steps); provider fields tags and private; env vars PRINIA_WIDGET_KEY and PRINIA_OLLAMA_URL.
  • docs/usage.md: flag and command reference covers -t, --each/-j, --cmd, -a/-x, --write/--run/-y/--no-agent, init, trust, context, shell zsh.
  • docs/agent.md: no longer says run = true runs commands without asking.
  • README: quick reference only (-x with -y, prinia context); details live in docs/.

Self-update

  • prinia update downloads the installer from the latest release and runs it into the folder the current binary lives in (the checksum logic stays in scripts/install.sh, no new dependency). prinia update --check only compares versions.
  • Refuses for Homebrew and cargo installs (prints the right command), for development builds, and on Windows. Nothing runs in the background and nothing is checked unless the command is run.
  • Documented in docs/install.md#updating, the README and the usage reference. Tested against a local release server: version check, in-place install, installer failure, already current, and the refusals.
  • Known limit, documented: the checksum comes from the same release as the binary, so it catches a corrupt download, not a compromised release. Signed attestations are the follow-up before 1.0.

Windows

  • The --run approval prompt opens the console on Windows (CONIN$ / CONOUT$); Unix keeps /dev/tty. With no terminal the answer is still no.
  • A command that runs past 60 seconds is killed with its whole process tree on Windows (taskkill /T /F); Unix keeps the process-group kill.
  • Fixes found by the first Windows build: key.rs did not compile (an import used only under cfg(unix)); a test deleted a folder with the database still open; the cleared test environment lacked SystemRoot, so Windows could not open sockets (os error 10106).
  • New required CI job Test (windows-latest): clippy and the full test suite, part of required-checks-passed. It is green.
  • README and docs/install.md say Windows is tested in CI only. Not tested by hand: the approval prompt on a real console, the Credential Manager key store.

Not done

  • A history search index: 5,000 turns search in ~70 ms, so it is not needed yet; it would also lose substring matching and add leakage.

Testing

cargo test --locked (26 unit, 33 integration), clippy -D warnings, fmt clean. CI is green on macOS, Linux and Windows (all required), plus shellcheck, actionlint and zizmor.
Manual, against a local Ollama (qwen2.5:14b): -x, --cmd, --each, max_input, init, history ask, -c. prinia update is tested against a local fake release server, not a real release.
Manual, in a real pseudo-terminal: the zsh widget in emacs, vi-insert and vi-command mode (text replaced, nothing runs until Enter) and the --run [y/N] prompt (n runs nothing, y runs the command).
Windows: clippy and the test suite in CI (required). Not run: prinia update against a real release (none exists yet), the Anthropic path against the real API, Windows by hand, a hosted private provider.

@JustMaris JustMaris changed the title fix: warn on stderr when piped stdin is empty feat: -x, --cmd widget, init, templates, --each, max_input, safer config; fixes from audit Nov 24, 2026
Maris Popens added 16 commits November 24, 2026 20:09
…ivate providers, [DONE] ends a stream, safe file reads, shared shell spawn, fewer git spawns
…(taskkill /T); informational Windows CI job
@JustMaris
JustMaris merged commit c5c127d into main Nov 24, 2026
7 checks passed
@JustMaris
JustMaris deleted the warn-empty-stdin branch November 24, 2026 19:21
@dnb-robot dnb-robot Bot mentioned this pull request Nov 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant