@nicknisi/pi-compact-tools
v0.2.0
Published
Two-line tool displays with native click and Ctrl+O expansion
Maintainers
Readme
pi-compact-tools
Collapse every tool display to a header and one preview line. Press Ctrl+O to expand all tools, or click a tool in Pi's fullscreen mode to expand just that tool.
▸ $ pnpm test
Test run started … [ctrl+o]Only the display changes. Tool execution, saved results, images, details, and model context stay untouched. Expanding restores the tool's original renderer, including syntax highlighting, diffs, and custom extension displays.
Install
From a local checkout:
pi install /absolute/path/to/pi-extensions/packages/compact-toolsAfter publication:
pi install npm:@nicknisi/pi-compact-toolsRestart Pi or run /reload after installation.
Behavior
| Action or state | Display |
| ----------------------------- | ----------------------------------------------------------------------------------- |
| Before a result arrives | One line using the tool's normal human-readable header |
| Streaming or completed result | Header plus one readable preview line |
| Multiline output | An ellipsis after the preview |
| Success | Both lines use Pi's green toolSuccessBg background |
| Running | Both lines use Pi's toolPendingBg background |
| Error | Both lines use Pi's red toolErrorBg background, with an explicit Error: preview |
| Images | An image count in the preview; pi still draws inline images below the row |
| Ctrl+O | Pi's existing expand/collapse toggle for all tools |
| Fullscreen left click | Expand one collapsed tool. Click its original header or result to collapse it again |
There is one blank separator before each tool. Long lines truncate to the terminal width rather than wrapping. Built-in, extension, MCP, dynamically registered, and restored tool rows all use the same compact display. Headers reuse the tool's existing renderer, such as read src/index.ts or $ pnpm test. Tools without a custom header show their name and a path, command, query, action, or URL when available. The fallback never dumps JSON arguments or file contents.
Tools start collapsed on session start and reload. The key hint follows your app.tools.expand binding in ~/.pi/agent/keybindings.json. No new tools, commands, shortcuts, widgets, or session entry types are registered.
Configuration
None. The default is two content lines. Use Pi's existing expansion controls when you need more detail.
Dependencies and caveats
- Pi supplies
@earendil-works/pi-coding-agentand@earendil-works/pi-tuias peer dependencies.@nicknisi/pi-sharedsupplies terminal-label sanitization. - Needs Pi 1.0.1 or newer (
pi.registerToolRenderer). Regular terminal mode leaves mouse input to terminal scrollback, so use Ctrl+O there. - Uses Pi's public
pi.registerToolRenderer()hook, wrapping whatever renderer the tool (or a later extension) provides. Rows draw their own shell so collapsed rows stay two lines; expanded rows re-create Pi's default box around the original renderer. - Pi draws inline images for a result regardless of the row's renderer, so collapsed rows with images are not fully compact.
- Previews use the tool's existing result renderer when available, falling back to the first nonempty output line. JSON-only output shows an item or field count instead of serialized data. No model call is made. Custom controls and detailed progress displays are available when expanded.
- Expanded displays retain each tool's own limits. This extension cannot recover output already truncated by a tool.
- User shell commands entered with
!or!!use a separate Pi component and are unchanged.
Development
pnpm test -- packages/compact-tools/index.test.ts
pnpm typecheck
pnpm lint