@pi-kaush/pi-tool-call-markers
Compact and group Pi tool calls, with a bundled extension for adjacent thinking blocks.
Package details
Install @pi-kaush/pi-tool-call-markers from npm and Pi will load the resources declared by the package manifest.
$ pi install npm:@pi-kaush/pi-tool-call-markers- Package
@pi-kaush/pi-tool-call-markers- Version
0.2.3- Published
- Aug 18, 2026
- Downloads
- 914/mo · 345/wk
- Author
- kaushikgopal
- License
- MIT
- Types
- extension
- Size
- 55 KB
- Dependencies
- 0 dependencies · 2 peers
Pi manifest JSON
{
"extensions": [
"./src/index.ts",
"./src/thinking-block-merger.ts"
]
}Security note
Pi packages can execute code and influence agent behavior. Review the source before installing third-party packages.
README
@pi-kaush/pi-tool-call-markers
Collapse Pi's adjacent successful tool calls into one compact, gear-headed block per tool type, so a run of similar calls reads as a tidy bulleted list instead of a wall of repeated headers and results.
What it changes
When several tool calls run in a row, Pi normally renders each one as its own expanded block. This extension groups them:
- One gear header per contiguous tool type. A run of
readcalls shares a single⚙️ readheader; the followingwriterun gets its own⚙️ writeheader. - Bulleted call summaries. Each call in a group becomes one bullet with a short summary and, for common tools, a compact outcome such as
→ done,→ 42 lines, or→ +2/-1. - Vertical spacing between tool types. A blank line separates one tool group from the next.
- One-line, width-safe summaries. Long targets truncate before their useful outcome tail instead of wrapping into taller blocks.
- Running calls group immediately. Adjacent calls become bullets as they appear, and each pending marker or elapsed
bashtime updates to the final outcome in place. Successful settlement does not shrink the block, so the transcript only grows downwards. - Sequential calls merge across quiet turns. A later call joins the existing group immediately when no visible prose or thinking separates it; visible assistant content remains a hard boundary.
- Self-rendered tools get the same treatment. Tools that own their framing (e.g. MCP adapter rows) collapse to the same one-line summary — args label plus outcome — with pending, success, and error backgrounds; expanding restores their full custom render.
- Image results stay visible. Image-bearing results are not collapsed into text-only groups. Partial text output is held back while a call runs and surfaces through the final summary.
- Errors stay compact and visibly failed. A failed call keeps an error-colored block: native collapsed detail for built-in tools, or a one-line summary with the first error line for self-rendered tools.
- Ctrl+O restores full blocks. Expanding tools (
setToolsExpanded(true)) brings back Pi's individual full blocks, including complete error details and successful results.
Bundled thinking-block extension
The package ships a second extension entrypoint, src/thinking-block-merger.ts. Pi loads it independently from the tool presentation extension, so its AssistantMessageComponent patch and shutdown lifecycle stay isolated while install, update, and removal remain one package operation.
It combines only directly adjacent thinking blocks for display. Tool calls, text, and other content remain boundaries; provider blocks and signatures are not modified.
Install
After the first npm release:
pi install npm:@pi-kaush/pi-tool-call-markers@0.1.0
For local development:
pi \
-e ./extensions/pi-tool-call-markers/src/index.ts \
-e ./extensions/pi-tool-call-markers/src/thinking-block-merger.ts
Configuration
Grouping calls from the same assistant message is enabled by default. Pi normally executes those calls in parallel. To keep those same-message calls as individual compact rows while continuing to group sequential calls across quiet turns, start Pi with:
set -lx PI_TOOL_CALL_MARKERS_COLLAPSE_PARALLEL 0
pi
0, false, no, and off disable parallel grouping. 1, true, yes, and on enable it. The value is read when the extension loads.
Compatibility and risk
The tool presentation entrypoint currently relies on guarded, reversible prototype patches against two Pi component classes:
ToolExecutionComponent(render + display presentation),Container(transcript grouping).
The bundled thinking-block entrypoint separately patches AssistantMessageComponent.updateContent. Its patch and lifecycle do not share state with tool presentation.
Pi exposes no public transcript or tool-grouping hook today, so the extension patches those prototypes and restores the originals on session_shutdown. Every patch is wrapped in try/catch with an idempotency guard (Symbol.for(...) markers), so if Pi's internals change the extension silently no-ops and Pi's default rendering is preserved.
Compatible Pi version: @earendil-works/pi-coding-agent and @earendil-works/pi-tui >=0.80.6. Because the patches touch internal prototype methods, a future Pi release that renames or restructures those methods can silently disable the affected presentation until this package is updated. All original methods are restored on shutdown.
TODO: migrate to a public Pi tool/transcript rendering API when one becomes available, and remove the prototype patches.
Design
- No runtime dependencies.
- Startup only registers
session_start/session_shutdownhandlers and installs the reversible patches; no I/O, subprocesses, model requests, or timers. - Grouped output is cached per row and invalidated when any member's display version changes, so repeated renders reuse work while stale groups refresh on demand.
- Removing the package restores Pi's default rendering on the next session.
Development
From the repository root:
npm ci --ignore-scripts
npm run check
Inspect the publish payload:
npm pack --workspace @pi-kaush/pi-tool-call-markers --dry-run
License
MIT