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

@watercol/pi-lens-simple

v1.0.0

Published

Unofficial simplified fork of pi-lens for AST tools, LSP tools, and post-write LSP diagnostics

Readme

@watercol/pi-lens-simple

@watercol/pi-lens-simple is an unofficial simplified fork of pi-lens, focused on AST search/replace, LSP navigation/diagnostics, and lightweight post-write feedback.

This package is not an official release from the original pi-lens project. It is based on pi-lens by Apostolos Mantzaris and keeps the original MIT license attribution.

What It Does

@watercol/pi-lens-simple currently exposes a narrow tool surface:

  • AST-aware search and replace with ast-grep
  • LSP navigation and diagnostics
  • automatic LSP diagnostic feedback after write / edit
  • basic read/write bookkeeping for safer edits

It deliberately does not run the old automatic formatter/autofix pipeline, test runners, project scans, turn-end findings, widget diagnostics, Semgrep dispatch, or context-injection flows.

Install

pi install npm:@watercol/pi-lens-simple

Pi Extension Surface

Tools

  • ast_grep_search
  • ast_grep_replace
  • lsp_navigation
  • lsp_diagnostics

Commands

  • /lens-toggle
  • /lens-allow-edit <path>
  • /lens-lsp-status

Flags

  • --no-lens
  • --no-lsp
  • --no-read-guard

Hooks

@watercol/pi-lens-simple registers only the slim lifecycle hooks needed for the current surface:

  • resources_discover
  • session_start
  • turn_start
  • tool_call
  • tool_result
  • session_shutdown

AST Search and Replace

ast_grep_search and ast_grep_replace use ast-grep to match code by structure rather than text. Patterns must be valid code shapes for the target lang, with ast-grep metavariables added.

Good starting patterns:

| Language | Pattern | Use | |---|---|---| | TypeScript/JavaScript | fetchMetrics($$$ARGS) | call with any number of args | | TypeScript/JavaScript | function $NAME($$$ARGS) { $$$BODY } | function declaration | | TypeScript/JavaScript | import { $NAMES } from $PATH | named import | | Python | class $NAME | class declaration | | Python | def $NAME($$$ARGS) $$$BODY | function declaration; no colon or braces | | Python | $OBJ.$METHOD($$$ARGS) | method call | | Go | func $NAME($$$ARGS) { $$$BODY } | function declaration | | Rust | fn $NAME($$$ARGS) { $$$BODY } | function declaration |

Metavariables:

  • $X matches one AST node and captures it.
  • $$$ matches zero or more AST nodes without a capture.
  • $$$ARGS matches zero or more AST nodes and captures the list.

Useful parameters:

  • paths scopes the search to specific files/folders.
  • context shows surrounding source lines.
  • strictness: "relaxed" can recover from punctuation-sensitive misses.
  • insideKind, hasKind, follows, and precedes synthesize an ast-grep YAML rule for structural constraints.
  • rule accepts a raw ast-grep YAML rule when the full DSL is needed.
  • skip paginates large result sets.

ast_grep_replace is dry-run by default. Use apply: true only after reviewing the preview.

LSP Navigation and Diagnostics

lsp_diagnostics actively checks one file, a folder, or an explicit filePaths batch:

lsp_diagnostics({ filePath: "src/file.ts" })
lsp_diagnostics({ filePaths: ["src/a.ts", "src/b.ts"], severity: "all" })

lsp_navigation provides IDE-style code intelligence:

  • definition
  • references
  • hover
  • signatureHelp
  • documentSymbol
  • findSymbol
  • workspaceSymbol
  • codeAction
  • rename
  • rename_file
  • implementation
  • prepareCallHierarchy
  • incomingCalls
  • outgoingCalls
  • workspaceDiagnostics
  • capabilities

Line and character positions are 1-based. For position-based operations, pass symbol when you know the line but not the exact column. signatureHelp only works inside a function or method call's parentheses; if it returns empty, use hover or definition instead of retrying nearby declaration positions.

Post-Write/Edit Feedback

After a write or edit tool result, pi-lens appends current LSP diagnostics for the changed file:

pi-lens LSP: src/file.ts - 2 diagnostic(s)

This path is intentionally LSP-only. It does not call the legacy dispatch pipeline, formatters, autofixers, test runners, project scans, or turn-end context injection.

Read Guard

The slim read guard keeps basic file bookkeeping:

  • read records delivered line coverage.
  • write marks the file as agent-authored.
  • edit checks whether the target file has been read before editing.

Use /lens-allow-edit <path> to allow a single edit, or --no-read-guard to disable the guard.

MCP Server

The bundled MCP server exposes only the slim tool set:

  • pilens_ast_grep_search
  • pilens_ast_grep_replace
  • pilens_lsp_navigation
  • pilens_lsp_diagnostics

Other legacy MCP facades are not part of the current surface.

Skills

The package exposes only these skill directories:

  • skills/ast-grep
  • skills/write-ast-grep-rule
  • skills/lsp-navigation

These skills are written for the slim AST/LSP surface and avoid removed-tool recovery paths.

Development

npm run lint          # strict type-check, includes tests
npm run build         # emit in-place JS used by vitest imports
npm test              # full vitest suite
npm run build:dist    # refresh dist for local package/MCP use; do not commit dist

Because source imports use .js specifiers while development edits happen in .ts, run npm run build before targeted Vitest runs after TypeScript changes.