@zhcsyncer/pi-tool-display-intent

Intent-aware tool rendering, diff visualization, and output compaction for Pi.

Packages

Package details

extension

Install @zhcsyncer/pi-tool-display-intent from npm and Pi will load the resources declared by the package manifest.

$ pi install npm:@zhcsyncer/pi-tool-display-intent
Package
@zhcsyncer/pi-tool-display-intent
Version
0.10.2
Published
Nov 21, 2026
Downloads
239/mo · 58/wk
Author
zhcsyncer
License
MIT
Types
extension
Size
996.6 KB
Dependencies
0 dependencies · 2 peers
Pi manifest JSON
{
  "image": "https://raw.githubusercontent.com/zhcsyncer/pi-extensions/main/packages/pi-tool-display-intent/assets/demo-aggregate-1.png",
  "extensions": [
    "./extensions/tool-display-intent.ts"
  ]
}

Security note

Pi packages can execute code and influence agent behavior. Review the source before installing third-party packages.

README

pi-tool-display-intent

简体中文

Collapsed Run ledger

pi-tool-display-intent is a modified fork of MasuRii/pi-tool-display 0.5.0. It keeps compact tool rendering and adds model-written, user-facing intent. The displaySummary field is adapted from mertdeveci5/pi-tool-display-summary 0.1.0.

read docs/tax-code.pdf — Checking the Colorado tax code
$ pnpm test — Verifying the extension test suite

● Read(docs/tax-code.pdf) — Checking the Colorado tax code
  ⎿ loaded 42 lines

The current model writes displaySummary in the normal tool call. This extension does not make another inference request, use a second model, or need another API key.

Features

  • Bash asks the current model for a displaySummary intent. Direct calls and codemode scripts that omit it receive a fallback; other invalid arguments still fail validation. Other built-ins keep their original schemas.
  • Unified rows for built-ins, custom tools, late-connected MCP tools, and saved tool history, while preserving tools' specialized content.
  • Claude-style rows: status mark, Name(target), and indented results.
  • Faster redraws of completed text-tool histories while live output keeps updating.
  • Optional aggregate layout: one Run ledger per user request, including Agent and consult by default.
  • Fullscreen mouse support: click a collapsed Run block to expand that run, click its expanded summary to collapse it, and inspect individual call results without rerunning tools.
  • Optional context-growth receipts and per-turn badges to spot context-heavy steps.
  • Short values-only call previews, indented failure details, and complete key/value arguments in the click-to-open viewer.
  • Same compact / summary / preview result modes as upstream.
  • Cooperative API so other tools can still opt into the same intent field.

Do not load pi-tool-display, pi-tool-display-summary, and this extension together. They register the same built-in tool names.

Install

Requires Pi 1.1 or newer. Ordinary direct calls remain fully supported; installing this extension does not enable codemode or connect MCP servers. When you opt into codemode, its JavaScript input and structured tool results stay unchanged.

pi install npm:@zhcsyncer/pi-tool-display-intent
pi install npm:@zhcsyncer/pi-extensions

Then restart Pi or run /reload.

Use

/tools
/tools aggregate
/tools individual

Empty /tools opens the settings panel. Switching layout asks to reload this session, then saves and reloads. Bash intent language is available in both layouts and applies after /reload; layout-specific display knobs stay in the panel. Changing preview limits or result modes in the panel also refreshes existing history rows.

Very large previews, diffs, and detail views may show an explicit display-omission notice, even when expanded-row limits are disabled. These safeguards do not change execution results, model input, or usage. An omitted diff is not presented as a complete comparison; full-output links are shown only when the tool provides a real artifact.

Layouts

individual is the default: each tool keeps its own row. A Write row can compare the content captured immediately before that write with the supplied new content, even if the file changes again afterward. Historical rows never reread the current file to invent an earlier version.

Scripts and tools that call other tools keep one top-level entry. Native codemode keeps its script, progress, and output; recorded descendants appear under the root without repeating its direct native call rows. Aggregate counts the root once, not each child or model call. A successful root may still have failed, cancelled, or unfinished children.

Nested views keep at most 256 calls, with argument limits of 8 KiB each and 32 KiB total (compact JSON, UTF-8). Native argument snippets remain previews, not full arguments. Partial lists and visible-only costs are labeled; nested rows do not add usage again. Missing historical arguments, parent links, timing, or child result bodies stay unavailable—no tool is rerun to fill them in.

aggregate folds every registered built-in, custom, MCP, and late-loaded tool in one user request into one Run view:

Collapsed Run ledger

Expanded Run timeline

Failed Run ledger

● Run (37 calls · 3 turns) · read ×12 · ask_user_question ×1 · edit ×8 · bash ×16
  › 先对照两边入口
  ● Bash — 把策略固化成 zone · 54 lines · 2.3KB           12s

● Run (38 calls · 3 turns) · read ×12 · ask_user_question ×1 · edit ×8 · bash ×17
  ↳ 2 steers
  took 2m14s · tok ↑62k ↓8.4k R120k W4.1k · at 2026-04-08 14:32:14

While a turn is running, the latest assistant note stays under the header as Markdown, up to three lines. Each visible call keeps its elapsed time right-aligned on the first row and may use one bounded continuation row. After it settles, notes hide and a muted receipt shows duration, tokens, cache, and local time. Collapsed failures are N failed only. Mid-turn steers stay on the same Run ledger: first lines pin under the header while it runs, then one ↳ N steers line remains. Ctrl+O expands the original timeline, with each ↳ in place, up to eight rows per call; failure details use an indented continuation row. The default flat timeline still shows one timed entry per call; set toolCalls.expandedTimeline to turns to group those entries under ↻ 1/3 · 3 calls headers with indented calls. Long bash scripts show intent and size instead of the body. Agent and consult use the same compact call rows. Image reads stay in the Run ledger like other output. Switch back with /tools individual.

User prompts use the accent-gutter box by default. In either layout, open /tools, type native to find User message box, and press Space/Enter to turn it off for native/downstream user-message rendering. Changes apply to existing and new messages immediately and persist after /reload; aggregate steer folding and grouping are unchanged. Styled messages retain Pi's message-navigation boundaries.

Agent and consult

Both are aggregated by default. Agent rows show the agent type and task description, not the full prompt or control flags:

↗ Agent(Explore · Inspect ledger interactions) · dispatched
✓ Agent(Plan · Review the approach)
✓ consult(Review aggregate compatibility)

dispatched confirms a background invocation was accepted, not that the child task finished; its timing is the invocation time. Confirmed completed foreground calls use ✓, and queued/scheduled receipts remain distinct. Existing subagent widgets and /agents still provide live task views and history. Clicking a ledger row opens the ordinary Result / Args viewer; it does not open the subagent-specific viewer.

Visible custom messages, including subagent completion notifications, now fold into Run in their original transcript order. Expanding preserves their original renderer and native buttons. Notifications arriving after a final answer start a new segment rather than moving back to the dispatching run. Message-only segments show Run (N messages); messages do not count as tool calls. Hidden messages remain hidden, and widgets and UI-only custom entries stay separate. tools.passthrough controls tool calls, not these messages.

Explicit passthrough lists are preserved. These tools keep their native content, expansion and interactions, aligned with the ledger's content inset rather than the terminal's left edge. Set tools.passthrough to [] and /reload if an existing configuration still keeps Agent or consult outside the ledger.

Click to inspect

In Pi 1.1+ fullscreen mode, click anywhere in a collapsed Run block, including the receipt and current-call previews, to expand only that run. When expanded, the whole title/summary area can collapse it again. Top/bottom padding and expanded narration text do not toggle the ledger; dragging still selects text. Ctrl+O still switches the whole transcript and overrides local Run expansion choices. Passthrough tools keep their native interactions.

Expanding a run keeps its aggregate title in view instead of following the newly expanded content to the bottom. When you scroll into a long expanded run and its title moves above the viewport, a right-aligned ↑ Run (…) · Collapse control appears at the top of the above-editor widget group. Click it to collapse only that run and return to its aggregate title. The control does not take keyboard focus or cover the transcript. These viewport controls require a compatible Pi 1.1+ fullscreen renderer; ordinary terminal-scrollback mode does not provide ledger mouse interaction.

Internal calls stay collapsed when a Run expands. A parent with internal calls shows ▸ codemode · … internal calls (or the corresponding tool name), including failure counts. Click its main row to expand or collapse only its children; click [Script / Output] for codemode, or [Details] for other parent tools, to inspect the original call instead. The button moves to a continuation line when needed. Local child-list choices survive Run folding and streaming updates within the session. Children are indented one level further, with status, argument or intent summaries, and known durations; sub-second durations use milliseconds. Incomplete records and argument previews remain labeled.

Codemode's [Script / Output] opens the read-only viewer on Script, with JavaScript syntax highlighting; switch to Output for the script's output. Codemode without internal calls opens the same script-first viewer by clicking its row. Other tools keep Result / Args, opened through [Details] or their row when there are no internal calls. Result formats JSON, Markdown files read from .md / .markdown / .mdx paths, and clear custom-tool Markdown; other source and logs remain literal. Args uses key/value rows and multiline blocks, with shell syntax colors for Bash commands. Extra Metadata lives behind ⋯ / M; it does not enter the primary Tab cycle. Raw / R shows source text or JSON. The popup does not redact credentials; terminal-control filtering and explicit size limits still apply, so check content before sharing it. Long text lines wrap automatically, including after resizing. Use Tab to switch tabs, arrows/Page Up/Page Down or the wheel to scroll, and Esc to return. Output already truncated by the tool cannot be recovered.

Click an expanded child call, including its wrapped or error lines, to inspect Args / Call info: recorded parameters, status, timing, errors, and available parent/cost information. Complete parameters use the usual field/JSON view and Bash highlighting; previews stay literal and missing arguments are labeled unavailable. This read-only snapshot does not live-refresh and contains no separately saved full return body or substituted parent output.

For successful Edit calls with returned diff data, Result is the diff, without a separate tab. Successful Write calls use the same view to show supplied content as additions, explicitly labeled as written content rather than an overwrite delta. Write always uses a single-column layout; Edit follows the global Diff layout and diff.splitMinWidth. Both retain the global Diff indicators and diff.wordWrap settings. Layout and indicator settings are also available in aggregate /tools. Raw retains the original return and source content; failures or missing required data show the ordinary result. Historical changes are never reconstructed from the current file.

In the ledger, Bash(command) is shown only when the complete target fits one display row. Longer or multiline commands show Bash, intent and size instead; open its details to inspect the complete arguments.

Expanded steers wrap at the terminal width. Up to eight content rows stay visible; longer messages keep the first three and last two rows around … N lines hidden · click to view. Click that omission row to inspect the original message. Collapsed steers still occupy one line each.

Context growth

In aggregate, open /tools and turn Context growth on (default: off). The run receipt shows net growth; choose Expanded timeline → turns to see which steps contributed:

took 18s · ctx ≈+3.2k · tok ↑… ↓…
↻ 1/2 · 2 calls · ctx +2.4k

A subsequent completed request supplies the input difference, displayed on the preceding turn. The last/unconfirmed turn uses a local estimate marked ≈; any estimate also marks the run total. Ordinary replies without tool calls never get a context footer; their final usage still contributes to the run total. Tool-bearing passthrough turns may use a lightweight footer. flat shows only the run total. Switching this setting does not reload.

ctx measures context growth, not cumulative token consumption (tok) or individual tool costs. Reported differences may also reflect prompt/provider transformations. Missing data or known context boundaries such as steering, compaction, or model changes make the run total ctx n/a instead of a misleading number.

Settings

Open /tools or edit the example at config/config.example.json.

What you change Effect
toolCalls.layout individual or aggregate
toolCalls.expandedTimeline flat per-call Ctrl+O rows, or turns grouped by agent turn (aggregate only; no reload)
toolCalls.showContextGrowth Show ctx run totals and turn badges; default false (aggregate only; no reload)
transcript.userMessageBox Style ordinary user messages; default true. Set false for native/downstream rendering; steers are unchanged
results.mode compact, summary, or preview
intent.language Bash intent language: best-effort request following, Simplified Chinese, or English (applies after /reload)
diff.layout / diff.indicators Edit diff layout and shared Edit/Write markers; Write is always single-column
diff.collapsedMode body preview, or summary stats only (individual tool rows)
tools.passthrough Explicit tools that keep their original renderer; default []

Older toolCalls.style and transcript.userMessageStyle settings are ignored.

Custom tools

In aggregate mode, generic custom tools show at most two identifying values without key names, such as web_search(prod metrics) or todo(Review the migration). Prompts, payloads, control flags and credential-like values stay out of the inline preview; open Args for full key/value detail. A tool-provided getCallPresentation remains authoritative. Individual mode keeps its existing parameter preview.

Custom renderers keep their specialized call/result content. Per-tool output settings apply to generic fallback content; use tools.passthrough to leave a tool's entire presentation alone.

Wrap the tool before pi.registerTool only if you want to opt that tool into the same intent field. overrideExistingRenderers: true explicitly opts into replacing its renderers:

import {
  decorateToolForDisplay,
  withDisplaySummary,
} from "@zhcsyncer/pi-tool-display-intent/tool-display-api-consumer";
import { Type } from "typebox";

const tool = withDisplaySummary({
  name: "web_search",
  label: "Web Search",
  description: "Search the web.",
  parameters: Type.Object({
    query: Type.String()
  }),
  async execute(_toolCallId: string, args: { query: string }) {
    return runSearch(args.query);
  }
}, {
  language: "auto",
  required: true
});

pi.registerTool(decorateToolForDisplay(tool, {
  kind: "generic",
  outputMode: "inherit",
  overrideExistingRenderers: true
}));

License

MIT. See LICENSE and UPSTREAM_LICENSE.