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-mono-multi-edit

v2.0.0

Published

Additive Pi tools for cross-file, repeated-occurrence, and Codex-style patch edits

Readme

Multi-Edit — Additive Editing Tools for Pi

A Pi extension that complements the native edit tool with two capabilities the core tool does not provide:

  • multi_file_edit — preflighted exact replacements across multiple files or repeated identical occurrences in one file
  • apply_patch — Codex-style add, update, and delete operations

The extension does not override edit. Pi's native tool remains the preferred path for ordinary single-file work, including multiple disjoint replacements through its edits[] parameter.

Why additive tools?

Pi's native edit now provides robust same-file batching, uniqueness and overlap validation, Unicode/whitespace normalization, CRLF and BOM preservation, mutation queuing, and live diff previews. Maintaining a replacement for that behavior would duplicate core functionality and drift as Pi improves.

This package therefore keeps only its differentiated cross-file and patch workflows.

multi_file_edit

Use this tool when exact replacements span multiple files and should be preflighted together, or when the same oldText must replace multiple occurrences in one file. Native edit requires each oldText to be unique in the original file; multi_file_edit resolves repeated identical entries positionally.

{
  "edits": [
    {
      "path": "src/a.ts",
      "oldText": "export const oldName = 1;",
      "newText": "export const newName = 1;"
    },
    {
      "path": "src/b.ts",
      "oldText": "import { oldName } from './a';",
      "newText": "import { newName } from './a';"
    }
  ]
}

A top-level path can be inherited by entries that omit their own path:

{
  "path": "src/index.ts",
  "edits": [
    { "oldText": "before one", "newText": "after one" },
    { "oldText": "before two", "newText": "after two" }
  ]
}

For ordinary changes confined to one file, use native edit instead.

For repeated identical occurrences, repeat the edit entry once per intended replacement:

{
  "path": "src/example.test.ts",
  "edits": [
    { "oldText": "getByRole('button')", "newText": "getByRole('link')" },
    { "oldText": "getByRole('button')", "newText": "getByRole('link')" }
  ]
}

This replaces the first two matching occurrences in file order without requiring artificial surrounding context.

Behavior

  • Every replacement is checked against a virtual filesystem before real files are changed.
  • Same-file entries are ordered by their position in the original content.
  • Repeated identical entries match successive occurrences; repeat an entry only as many times as it should be replaced.
  • Cross-file writes use best-effort rollback if an unexpected I/O failure or abort interrupts the batch.
  • Exact matching falls back to curly-quote and trailing-whitespace normalization.
  • Per-file diffs are returned in the tool result.

apply_patch

Use this tool for coordinated patches that add, update, or delete files.

{
  "patch": "*** Begin Patch\n*** Add File: src/new.ts\n+export const value = 1;\n*** Update File: src/index.ts\n@@\n-export { oldValue } from './old';\n+export { value } from './new';\n*** Delete File: src/old.ts\n*** End Patch"
}

Supported operations:

| Header | Effect | | ------------------------- | -------------------------------------------------- | | *** Add File: <path> | Create or overwrite a file from +-prefixed lines | | *** Update File: <path> | Apply one or more @@-delimited hunks | | *** Delete File: <path> | Delete an existing file |

Patch operations are preflighted against a virtual filesystem before mutation. Update hunks support exact matching followed by per-line trailing-whitespace tolerance.

Unsupported patch features

  • *** Move to: renames — use add plus delete
  • *** End of File sentinel hunks
  • Full whitespace or Unicode-normalized patch matching

Choosing a tool

| Task | Tool | | ------------------------------------------------- | ----------------------------------------------------- | | One replacement in one file | Native edit | | Several unique, disjoint replacements in one file | Native edit with edits[] | | Repeated identical occurrences in one file | multi_file_edit, repeating the entry per occurrence | | Exact replacements across multiple files | multi_file_edit | | Add/delete files or apply coordinated hunks | apply_patch | | Create or fully rewrite one file | Native write |

Development

npm test
npm run bench
npm run bench -- --from-session --all

The benchmark supports synthetic scenarios and historical Pi JSONL session analysis.