pi-code-previews

Syntax-highlighted previews for pi tool calls.

Package details

extension

Install pi-code-previews from npm and Pi will load the resources declared by the package manifest.

$ pi install npm:pi-code-previews
Package
pi-code-previews
Version
0.1.15
Published
May 4, 2026
Downloads
718/mo · 718/wk
Author
mrchu001
License
MIT
Types
extension
Size
158.3 KB
Dependencies
2 dependencies · 2 peers
Pi manifest JSON
{
  "extensions": [
    "./index.ts"
  ]
}

Security note

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

README

pi-code-previews

Syntax-highlighted previews for pi's built-in tool calls.

pi-code-previews makes bash, read, write, edit, grep, find, and ls output easier to scan in the pi TUI without changing what the tools do. If another extension already owns one of those tools, pi-code-previews skips that preview instead of conflicting with it.

Install

Install from npm:

pi install npm:pi-code-previews

Install from GitHub:

pi install git:github.com/mattleong/pi-code-previews

Features

  • Syntax-highlighted previews for commands, files, diffs, and search results.
  • Clearer edit and write diffs, including pending edit previews.
  • Readable grep results grouped by file.
  • Compact find and ls path lists with optional icons.
  • Optional visual warnings for risky-looking shell commands and secret-looking output.
  • Configurable themes, line counts, icons, and highlighting behavior.

Usage

Once installed, previews are enhanced automatically for:

  • bash
  • read
  • write
  • edit
  • grep
  • find
  • ls

Open settings inside pi with:

/code-preview-settings

Check status with:

/code-preview-health

The health panel shows configured tools, active previews, disabled tools, and previews skipped because another extension owns that tool. Individual tool toggles are available in the Preview tools submenu in /code-preview-settings and take effect after /reload.

Settings are stored globally in Pi's agent config directory:

$PI_CODING_AGENT_DIR/code-previews.json

When PI_CODING_AGENT_DIR is not set, this defaults to:

~/.pi/agent/code-previews.json

Environment variables

Optional defaults can be set before pi starts:

CODE_PREVIEW_THEME=github-dark
CODE_PREVIEW_READ_LINES=20
CODE_PREVIEW_WRITE_LINES=20
CODE_PREVIEW_EDIT_LINES=120 # or all
CODE_PREVIEW_WORD_EMPHASIS=all # all, smart, or off
CODE_PREVIEW_GREP_LINES=40
CODE_PREVIEW_PATH_LIST_LINES=40
CODE_PREVIEW_PATH_ICONS=unicode # unicode, nerd, or off
CODE_PREVIEW_TOOLS=write,edit,grep # comma/space list, all, or none

CODE_PREVIEW_TOOLS overrides codePreview.tools for the current pi process.

Project settings

You can also set defaults in .pi/settings.json:

{
  "codePreview": {
    "shikiTheme": "dark-plus",
    "wordEmphasis": "all",
    "grepCollapsedLines": 40,
    "pathListCollapsedLines": 40,
    "pathIcons": "unicode",
    "tools": ["bash", "write", "edit", "find", "ls"]
  }
}

Screenshot

Write:

Read:

Edit:

Bash, ls, find:

Grep: