omp packages

pi-nuon0.1.0

Pi coding agent extension — replaces the built-in bash tool with Nushell, optimized for LLM tokens (nuon output, lean prompt)

rzph Published 2 days ago MIT ~0 downloads/mo

Untested on omp

This is a pi package. No one has reported whether it works on omp yet. If you try it, add your result below.

Did it work for you?

Result

One report per person. A new report replaces your old one.

Reports 0

No reports yet.

Readme

pi-nuon 🐘

A Pi coding agent extension that replaces the built-in bash tool with Nushell — optimized for LLM token usage: structured output returns as nuon instead of ASCII tables, and the tool carries a deliberately lean prompt (~200 tokens/turn over the bash tool).

Inspired by kiil/nupi, with three differences:

  1. The nuon hook actually works in script mode. Nupi's README config (and nushell's docs) return the converted value from display_output — but when nu runs a script file (which is how the extension spawns it), the hook's returned value is not rendered and a reused $in comes back null. pi-nuon's bundled config binds $in to a variable on the first line and prints explicitly.
  2. Zero manual setup. Nupi requires you to hand-create ~/.config/nushell/pi.nu (it hardcodes that path and fails on every call without it). pi-nuon ships a bundled config; override it with the PI_NU_CONFIG env var if you want your own.
  3. Lean prompt. 6 guidelines instead of 12 verbose ones (~−350 tokens/turn); everything else is discoverable at runtime via help commands.

Install

pi install git:github.com/rzph/pi-nuon

Requirements: Nushell (nu in PATH). No config file needed.

What the agent gets

Same-name override: the tool is still called bash (shown as nushell in the TUI), so anything that manages pi's tools by name — routers, toggles, permission setups — keeps working untouched. As a same-name override it also inherits the built-in bash renderers for free.

# Structured pipelines, one tool call instead of several:
ls src/**/*.ts | where size > 10kb | sort-by size --reverse | first 10 | select name size

# HTTP + extraction in one call (no jq gymnastics):
http get https://api.github.com/repos/nushell/nushell | select stargazers_count

# What lands in the model's context (nuon, not an ASCII table):
[
  [name,  size];
  ["a.ts", 12kb],
  ["b.ts", 8kb]
]

Custom nu config

Point PI_NU_CONFIG at your own config to add aliases, modules, or a different display hook. If you write one yourself, remember the script-mode gotcha: bind $in first (let v = $in), and print the result — do not return it.

Using nushell for ! / !! commands too

pi invokes !command with shellPath -c, which cannot take extra arguments, so the bundled config isn't loaded there. Two settings fix it (nu syntax — remove both if you uninstall the extension):

{
  "shellPath": "/usr/bin/nu",
  "shellCommandPrefix": "source ~/.config/nushell/pi-hook.nu"
}

with pi-hook.nu installing the same display hook inline. See shell-aliases docs.

Benchmarks (why nuon matters)

Median of 3 runs on real agent-style tasks (large node_modules tree, session JSONL, GitHub API) — output size ≈ tokens the model reads:

Task bash nushell (table) nushell (nuon)
Count entries by type in a 284 KB JSONL log 93 tok 127 tok 28 tok
Top-10 largest files in a 15k-file tree 269 tok 1 321 tok 290 tok
HTTP JSON field extraction (no jq) 1 684 tok 76 tok 19 tok

Raw text search stays with grep/rg (callable from nu like any CLI).

License

MIT