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-guard

v0.2.0

Published

Pi extension that corrects LLM tool calls: normalizes argument aliases for edit/write/read and strips trailing pipeline extractors from bash commands

Readme

pi-tool-guard

A pi extension that corrects common LLM tool call mistakes: normalizes argument aliases for edit/write/read and strips trailing pipeline extractors from bash commands.

Install

pi install npm:pi-tool-guard

Features

1. Argument alias normalization (edit / write / read)

When the LLM calls a tool with wrong field names, the extension normalizes them before schema validation. No error, no re-execution.

| Tool | Canonical | Accepted aliases | |---|---|---| | edit | path | file, filePath, file_path, target, filename, file_name | | edit | edits[].oldText | old_str, old_string, oldContent, old, original, search | | edit | edits[].newText | new_str, new_string, newContent, new, replacement, replace | | write | path | file, filePath, file_path, target, filename, file_name | | write | content | text, body, code, data, fileContent, contents | | read | path | file, filePath, file_path, target, filename, file_name | | read | offset | start, startLine, start_line, from, line | | read | limit | lines, maxLines, max_lines, count, numLines, num_lines |

Edit tool shorthand: top-level oldText/newText (or aliases) are automatically wrapped into an edits array.

Read tool type coercion: string values for offset and limit are coerced to numbers.

2. Bash pipeline extractor stripping

When the LLM appends truncation commands (tail, head, grep, etc.) to bash commands, the extension strips them and applies the extractor intelligently.

Three-case strategy:

| Scenario | UI Notification | LLM Response | |---|---|---| | Fast command (< 10s), truncated | Filtered via \head`| Filtered result only | | Fast command (< 10s), not truncated |Filtered via `head`| Filtered result only | | Slow command (truncated or not) |The full output is above...| Result +This is a slow command. Avoid re-running...` |

Example: vitest run | tail -n 10

  • If vitest finishes in < 10s → run tail on result (or full output file if truncated), notify UI
  • If vitest is slow → return result as-is, notify UI, append slow-command hint to LLM

Detected extractors: head, tail, grep, egrep, fgrep, rg, sed, awk, cut, sort, uniq, wc, less, more, column, jq, yq, tr

All trailing extractors are stripped: npm test | grep FAIL | head -5 → strips grep FAIL | head -5


Architecture

Both features use prepareArguments on overridden built-in tools — the cleanest pi extension pattern for argument correction:

  • edit/write/read: createXxxToolDefinition(cwd) + prepareArguments normalizes aliases before schema validation
  • bash: createBashToolDefinition(cwd) + custom execute override:
    1. prepareArguments parses the command with unbash, strips trailing extractors
    2. execute runs the stripped command via the original built-in execute
    3. If fast (< 10s) + truncated → runs extractor on the full output file via pi.exec
    4. If fast (< 10s) + not truncated → pipes result through extractor via pi.exec
    5. If slow (truncated or not) → returns result as-is with notice

No error recovery, no session scanning.

Development

pnpm install
pnpm test        # Run all tests
pnpm typecheck   # Type check

License

MIT