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

@kreeger/pi-edit-split

v0.1.0

Published

A side-by-side diff preview for the pi-coding-agent edit tool.

Downloads

32

Readme

pi-edit-split

A side-by-side diff preview for the pi-coding-agent edit tool. It shows what changes will be made before they're applied, rendered as a split view (old vs new) when your terminal is wide enough, or falling back to unified and compact modes on narrower screens.

It uses fuzzy matching to handle typographic quotes, dashes, and spaces, and strips UTF-8 BOM characters before processing. The preview computation runs asynchronously and non-blocking.

How it looks

The edit tool preview replaces pi's default diff output with a side-by-side comparison. Context lines appear on both sides, removed lines in red on the left, added lines in green on the right, and line numbers are shown for reference.

pi-edit-split preview

How it works

flowchart LR
    subgraph pi["pi-coding-agent"]
        EDIT["edit tool"]
        API["Extension API"]
    end

    subgraph split["pi-edit-split extension"]
        PREVIEW["Preview renderer<br/>(async, non-blocking)"]
        PATCH["Unified patch parser"]
        PAIR["Line pairer<br/>(LCS diff)"]
        RENDER["DiffRenderer<br/>(split/unified/compact)"]
    end

    API -- registerTool --> EDIT
    EDIT -- renderCall --> PREVIEW
    PREVIEW -- generate patch --> PATCH
    PATCH -- parse hunks --> PAIR
    PAIR -- pair lines --> RENDER
    EDIT -- renderResult --> RENDER
    RENDER -- render(width) --> pi

On tool registration, pi-edit-split wraps pi's built-in edit tool. When the tool is called, it reads the target file, applies the edits in-memory to generate a diff, and renders a live preview. The actual file modification is delegated to pi's original edit tool execution.

Two rendering modes adapt to terminal width:

  • Split view (width >= 120): Side-by-side old/new with a vertical divider. Each cell shows line numbers and content.
  • Unified diff (narrower): Standard unified format, delegated to pi's built-in renderDiff.

Features

  • Side-by-side diff — split view when terminal width >= 120 chars
  • Unified diff — standard unified format on narrower screens
  • Fuzzy matching — normalizes typographic quotes, dashes, and spaces for more reliable text matching
  • BOM handling — strips UTF-8 BOM before processing
  • Async preview — preview computation runs non-blocking
  • Collapsible hunks — shows first change + context, hides the rest

Installation

Install from the git repository using pi install:

pi install [email protected]:kreeger/pi-edit-split.git

Pass the repository URL directly as a single argument.

If you've cloned the repository locally, you can also install from the local path:

pi install /path/to/pi-edit-split

After installation, restart your pi session. The edit preview appears automatically — there's no activation step needed.

Verify it is installed

ls ~/.pi/agent/extensions/pi-edit-split/

You should see TypeScript source files. The pi agent loads extensions from this directory at startup.

Configuration

No configuration needed — pi-edit-split activates automatically as a drop-in replacement for the built-in edit tool renderer.

Development

Setup

Clone the repository and install dependencies:

git clone [email protected]:kreeger/pi-edit-split.git
cd pi-edit-split
npm install

Running tests

npm test

Tests live alongside source files (.test.ts). They run with Vitest. There are tests for the patch parser, line pairing (LCS diff), the preview renderer, and the DiffRenderer component.

Deploying your changes

The deploy script copies the source files (minus test files) to ~/.pi/agent/extensions/pi-edit-split/. Use it to push local changes into pi without publishing to npm:

npm run deploy

Restart your pi session to pick up changes.

Architecture notes

  • index.ts — Extension entry point. Wraps pi's edit tool, wires up async preview computation, and renders the DiffRenderer component.
  • preview.ts — Reads the target file, applies edits in-memory, generates a unified patch, and computes the preview result. Includes fuzzy text matching and BOM handling.
  • pairing.ts — Lines the diff from two sides using LCS-based alignment. Groups consecutive removes and adds into matched pairs.
  • patch-parser.ts — Parses unified diff hunks into structured ParsedHunk objects with line numbers and types.
  • diff-component.ts — The TUI Component that renders the diff. Chooses split/unified/compact mode based on available width.
  • types.ts — Shared TypeScript interfaces for hunks, lines, cells, rows, and preview state.

License

MIT