omp packages

pi-codemode-tidy0.1.3

Tidy transcript rendering for Pi's codemode tool: summarized nested calls, readable JSON output, and always-visible script errors — Ctrl+O expands the original view

orionoxe Published 11 days ago MIT ~294 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-codemode-tidy

Tidy transcript rendering for Pi's built-in codemode tool. Display only — tool results, model-facing content, and keybindings keep working exactly as before.

Why

codemode batches many tool calls into one script — and paints the screen with it: the full script, raw JSON arguments for every nested call, and output that wraps as one unreadable blob.

What you get

Before (Pi's built-in rendering):

codemode
const r = await Promise.allSettled([
  tools.fffind({pattern:"business",limit:12}),
  tools.fffind({pattern:"",path:"contracts/source/**",limit:8}),
  tools.read({path:"docs/agents/workflow.md",offset:1,limit:80}),
]);
for (let i = 0; i < r.length; i++) text({ check: i, ...r[i] });

✓ fffind {"pattern":"business","limit":12} 4ms
✓ fffind {"pattern":"","path":"contracts/source/**","limit":8} 2ms
✓ read {"path":"docs/agents/workflow.md","offset":1,"limit":80} 5ms
==> text 1/2 <==
{"check":0,"status":"fulfilled","value":"alpha\nbeta\ngamma\n..."} ← one long wrapped line
... (147 more lines, ctrl+o to expand)

After (collapsed — the default):

codemode  6 lines  Ctrl+O to expand

✓ fffind business · limit=12 4ms
✓ fffind contracts/source/** · limit=8 2ms
✓ read docs/agents/workflow.md · offset=1 · limit=80 5ms
==> text 1/2 <==
{
  "check": 0,
  "status": "fulfilled",
  "value": "alpha
beta
gamma"
... (3 more lines, Ctrl+O to expand)

Press Ctrl+O (your app.tools.expand binding) and the original rendering comes back, script and raw output included.

Details

  • Script collapses to one line (6 lines); expand to read it.
  • Nested calls become one summary row each — tool name, main argument, then limits and offsets — instead of raw argument JSON. Earlier successful calls fold away past 8 rows; running, failed, and cancelled calls remain visible.
  • Output previews 6 wrapped lines. Compact JSON is split at escaped \n and \t, so long payloads read as text instead of one wrapping blob; literal backslashes survive untouched.
  • Errors stay visible: script errors appear above the preview without a line cap. Failed calls remain visible with their full recorded error, even when earlier successful calls fold away. Long output keeps its Full output: /tmp/... path.
  • Display only: the tool result the model sees is never rewritten, and the expanded view is Pi's own renderer, not a reimplementation.

Install

pi install npm:pi-codemode-tidy

or straight from git:

pi install git:github.com/orionoxe/pi-codemode-tidy

Then /reload.

Requirements

Tested against Pi 1.1.0. Requires the registerToolRenderer extension API and the built-in codemode renderers. Other Pi versions have not been verified.

Development

npm install
npm test          # renders real fixtures through Pi's own codemode renderer
npm run typecheck

License

MIT