npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

pi-tool-display

v0.3.6

Published

Compact tool call rendering, diff visualization, and output truncation extension for Pi coding agent. Hides, collapses, and truncates verbose tool output for cleaner TUI display.

Readme

pi-tool-display

npm version License

OpenCode-style tool rendering for the Pi coding agent.

pi-tool-display keeps tool calls compact by default, adds richer diff rendering for file edits, and improves a few core chat UI details such as thinking labels and the native user prompt box.

Features

  • Compact built-in tool rendering for read, grep, find, ls, bash, edit, and write
  • MCP-aware rendering with hidden, summary, and preview modes
  • Adaptive edit/write diffs with split or unified layouts, syntax highlighting, inline emphasis, and narrow-pane width clamping
  • Workspace-scoped projected pending edit/write previews that show pending edit, pending overwrite, and pending create diffs while partial tool calls are still streaming
  • Progressive collapsed diff hints that shorten automatically on small terminal widths instead of overflowing
  • Three presets: opencode, balanced, and verbose
  • Thinking labels during streaming and final message rendering, with context sanitization to avoid leaking presentation labels back into future model turns
  • Optional native user message box with markdown-aware rendering and safer ANSI/background handling
  • Per-tool ownership toggles so this extension can coexist with other renderer extensions
  • Capability-aware settings that automatically hide MCP and RTK-specific controls when those features are unavailable

Installation

Local extension folder

Place this folder in one of Pi's auto-discovery locations:

# Global default (when PI_CODING_AGENT_DIR is unset)
~/.pi/agent/extensions/pi-tool-display

# Project-specific
.pi/extensions/pi-tool-display

npm package

pi install npm:pi-tool-display

Git repository

pi install git:github.com/MasuRii/pi-tool-display

Usage

Interactive settings

Open the settings modal:

/tool-display

The modal exposes the day-to-day controls most people change regularly:

  • preset profile
  • read output mode
  • grep/find/ls output mode
  • MCP output mode (when MCP is available)
  • preview line count
  • bash collapsed line count
  • diff layout mode
  • native user message box toggle

Advanced options remain in config.json.

Direct commands

/tool-display show                    # Show the effective config summary
/tool-display reset                   # Reset to the default opencode preset
/tool-display preset opencode         # Apply opencode preset
/tool-display preset balanced         # Apply balanced preset
/tool-display preset verbose          # Apply verbose preset

Presets

| Preset | Read Output | Search Output | MCP Output | Bash Output | Preview Lines | Bash Lines | |--------|-------------|---------------|------------|--------------|---------------|------------| | opencode | hidden | hidden | hidden | opencode | 8 | 10 | | balanced | summary | count | summary | summary | 8 | 10 | | verbose | preview | preview | preview | preview | 12 | 20 |

  • opencode (default): minimal inline-only display; tool results stay collapsed
  • balanced: compact summaries with line counts and match totals; bash shows line count only
  • verbose: larger previews for read/search/MCP/bash output

Bash Output Modes

| Mode | Behavior | |------|----------| | opencode | Classic collapsed output using bashCollapsedLines limit with expansion hint | | summary | Shows only line count (e.g., "↳ 3 lines returned") — no output displayed | | preview | Shows actual output lines using previewLines limit |

Configuration

Runtime configuration is stored at:

Default global path: ~/.pi/agent/extensions/pi-tool-display/config.json
Actual global path: $PI_CODING_AGENT_DIR/extensions/pi-tool-display/config.json when PI_CODING_AGENT_DIR is set

A starter template is included at config/config.example.json.

Configuration options

| Option | Type | Default | Description | |--------|------|---------|-------------| | debug | boolean | false | Opt-in file logging for extension diagnostics; missing values are treated as false | | registerToolOverrides | object | all true | Per-tool ownership flags | | enableNativeUserMessageBox | boolean | true | Enable bordered user prompt rendering | | readOutputMode | string | "hidden" | hidden, summary, or preview | | searchOutputMode | string | "hidden" | hidden, count, or preview | | mcpOutputMode | string | "hidden" | hidden, summary, or preview | | previewLines | number | 8 | Lines shown in collapsed preview mode | | expandedPreviewMaxLines | number | 4000 | Max preview lines when fully expanded | | bashOutputMode | string | "opencode" | opencode (collapse), summary (line count), or preview (show lines) | | bashCollapsedLines | number | 10 | Lines shown for collapsed bash output (opencode mode) | | diffViewMode | string | "auto" | auto, split, or unified | | diffIndicatorMode | string | "bars" | bars (vertical indicators), classic (+/- markers), or none | | diffSplitMinWidth | number | 120 | Minimum width before auto mode prefers split diffs | | diffCollapsedLines | number | 24 | Diff lines shown before collapsing | | diffWordWrap | boolean | true | Wrap long diff lines when needed | | showTruncationHints | boolean | false | Show truncation indicators for compacted output | | showRtkCompactionHints | boolean | false | Show RTK compaction hints when RTK metadata exists |

Tool ownership

Use registerToolOverrides to control which built-in tools this extension owns:

{
  "registerToolOverrides": {
    "read": true,
    "grep": true,
    "find": true,
    "ls": true,
    "bash": true,
    "edit": true,
    "write": true
  }
}

Set any entry to false if another extension should handle that tool instead.

Changes to tool ownership take effect after /reload.

Example config

{
  "debug": false,
  "registerToolOverrides": {
    "read": true,
    "grep": true,
    "find": true,
    "ls": true,
    "bash": true,
    "edit": true,
    "write": true
  },
  "enableNativeUserMessageBox": true,
  "readOutputMode": "summary",
  "searchOutputMode": "count",
  "mcpOutputMode": "summary",
  "previewLines": 12,
  "expandedPreviewMaxLines": 4000,
  "bashOutputMode": "opencode",
  "bashCollapsedLines": 15,
  "diffViewMode": "auto",
  "diffIndicatorMode": "bars",
  "diffSplitMinWidth": 120,
  "diffCollapsedLines": 24,
  "diffWordWrap": true,
  "showTruncationHints": false,
  "showRtkCompactionHints": false
}

Debug logging

Debug logging is disabled by default. Set debug to true in the extension root config.json only when collecting diagnostics; missing or non-true values are treated as false. When enabled, diagnostics are appended to debug/debug.log under a runtime-created debug/ directory, and no debug output is written to the terminal.

Rendering notes

Edit and write diffs

edit and write results use the same diff renderer. In auto mode the extension chooses split or unified layout based on available width. On narrow panes it clamps rendered lines and shortens collapsed hint text so the diff stays readable instead of spilling past the terminal width.

While tool arguments are still streaming, partial edit and write calls can show projected pending previews. Deterministic edits render as pending edit diffs against current file contents, writes render as pending overwrite or pending create, and unresolved projections show a clear preview notice instead of guessing. Preview file reads are scoped to the active workspace so pending previews avoid reading paths outside the current project.

Write summaries

When content is available, write call summaries include line count and byte size information inline so you can quickly see the size of the pending write before expanding the result.

Thinking labels

Thinking blocks are labeled during streaming and on final messages. Before the next model turn, the extension sanitizes those presentation labels out of the stored assistant context so they do not accumulate or pollute future prompts.

Native user message box

When enabled, user prompts render inside a bordered box using Pi's native user message component. The renderer preserves markdown content more safely and normalizes ANSI/background handling to avoid odd nested background artifacts.

Capability detection

The extension checks the current Pi environment and adjusts behavior automatically:

  • MCP tooling unavailable: MCP settings are hidden and MCP output is forced off
  • RTK optimizer unavailable: RTK hint settings are hidden and RTK compaction hints are disabled

This keeps the UI aligned with what the current environment can actually support.

Troubleshooting

Tool ownership conflicts

If another extension is already rendering one of the built-in tools:

  1. Set registerToolOverrides.<tool> to false
  2. Run /reload
  3. Use /tool-display show to confirm the effective ownership state

Config not loading

If your settings are not being applied:

  1. Check that the global Pi tool-display config exists (default: ~/.pi/agent/extensions/pi-tool-display/config.json, respects PI_CODING_AGENT_DIR)
  2. Make sure the JSON is valid
  3. Run /tool-display show to inspect the effective config summary

MCP or RTK settings missing

Those controls only appear when the corresponding capability is available in the current Pi environment.

Project structure

pi-tool-display/
├── index.ts                         # Extension entrypoint for Pi auto-discovery
├── src/
│   ├── index.ts                     # Bootstrap and extension registration
│   ├── capabilities.ts              # MCP/RTK capability detection
│   ├── config-modal.ts              # /tool-display settings UI and command handling
│   ├── config-store.ts              # Config load/save and normalization
│   ├── diff-renderer.ts             # Edit/write diff rendering engine
│   ├── line-width-safety.ts         # Width clamping helpers for narrow panes
│   ├── pending-diff-preview.ts      # Partial edit/write preview projection helpers
│   ├── presets.ts                   # Preset definitions and matching
│   ├── render-utils.ts              # Shared rendering helpers
│   ├── thinking-label.ts            # Thinking label formatting and context sanitization
│   ├── tool-overrides.ts            # Built-in and MCP renderer overrides
│   ├── types.ts                     # Shared config and type definitions
│   ├── user-message-box-markdown.ts # Markdown extraction for user message rendering
│   ├── user-message-box-native.ts   # Native user message box registration
│   ├── user-message-box-patch.ts    # Safe native render patching helpers
│   ├── user-message-box-renderer.ts # User message border renderer
│   ├── user-message-box-utils.ts    # ANSI/background normalization helpers
│   ├── write-display-utils.ts       # Write summary helpers
│   └── zellij-modal.ts              # Modal UI primitives
├── config/
│   └── config.example.json          # Starter config template
└── tests/
    ├── diff-renderer-ansi.test.ts   # ANSI/background handling tests for diff rendering
    ├── diff-renderer-width.test.ts  # Width and background coverage tests for diff rendering
    ├── tool-overrides-registration.test.ts # Tool override registration tests
    └── tool-ui-utils.test.ts        # Utility tests for user message and diff helpers

Development

# Type check
npm run build

# Run tests
npm run test

# Full verification
npm run check

Related Pi Extensions

License

MIT