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-search-agent

v1.0.1

Published

Semantic codebase search with sub-agent processing

Readme

pi-search-agent extension

Overview

pi-search-agent adds local semantic search to pi. It builds a semantic index of your codebase, runs embedding-based retrieval, and uses a configurable LLM to filter and summarize results via a search subagent.

First-time setup

On first run you will be prompted (via UI) to:

  1. Enter your OPENAI_API_KEY (used for embeddings).
  2. Choose a search model (recommended: cerebras / zai-glm-4.7).
    • Alternatively, anthropic / claude-haiku-4-5 is a good default if you want reasoning.

Configuration is stored in:

~/.pi/extensions/pi-search-agent/.env

You can edit the file manually later. Supported keys:

  • OPENAI_API_KEY
  • SEARCH_PROVIDER (e.g. cerebras, openai)
  • SEARCH_MODEL (e.g. zai-glm-4.7, gpt-4o-mini)
  • SEARCH_THINKING (optional: off, minimal, low, medium, high, xhigh)

Tools

search_agent(query, cwd?, queryExtrapolation?, path?, mode?, logSubagent?)

Search locally and run a subagent to refine results.

  • query: natural language search query
  • cwd: directory to search (defaults to current workspace)
  • queryExtrapolation: additional queries to run and merge
  • path: optional filter (file/dir/glob/substring)
  • mode: currently ignored (defaults to code)
  • logSubagent: writes JSON log to disk when true

Example:

search_agent(query: "How do we authenticate API requests?", path: "src", logSubagent: true)

local_embedding_search(query, cwd?, path?, mode?)

Run embedding search only (one result per file).

Example:

local_embedding_search(query: "retry logic", path: "packages/api")

Commands

/search-agent-settings

Open an interactive UI to configure or change:

  • OPENAI_API_KEY
  • SEARCH_PROVIDER + SEARCH_MODEL
  • SEARCH_THINKING

Settings are saved to:

~/.pi/extensions/pi-search-agent/.env

/search-agent <query> [--path <filter>] [--cwd <dir>] [--mode <mode>] [--log]

Run the semantic search pipeline directly from a user command (no need to ask the model to call the tool).

Examples:

/search-agent How do we authenticate API requests?
/search-agent "retry logic" --path packages/api
/search-agent "where is initializeOpenAI" --cwd ~/src/ai-extensions/semantic-search --log

How it works

  1. File discovery: streams find results and yields to the event loop to avoid blocking the UI.
  2. Chunking: files are split into overlapping chunks for stable embeddings.
  3. Embeddings: generated with OpenAI (text-embedding-3-small) and cached on disk.
  4. Index storage: index metadata + chunks are persisted per-cwd.
  5. Search pipeline:
    • embedding matches → merged per file
    • subagent refines results and provides a concise answer
  6. Summaries / filtering: uses the configured SEARCH_PROVIDER + SEARCH_MODEL (and optional SEARCH_THINKING).

Data locations

  • Index: ~/.pi/agent/cache/semantic-search/<hash>/
  • Embedding cache: ~/.pi/agent/cache/semantic-search/embeddings/
  • Subagent logs (when enabled): ~/.pi/agent/cache/semantic-search/subagent-logs/

Legacy tools / UI

Legacy tools are disabled by default. Enable them with:

PI_SEMANTIC_LEGACY=1

This re-enables:

  • semantic_index, semantic_search
  • /semantic interactive UI

Notes

  • mode is accepted but currently ignored; code includes markdown.
  • Indexing is per-cwd. If no index exists, it is created automatically.
  • The recommended search model is cerebras / zai-glm-4.7.
  • SEARCH_THINKING is clamped to off for non-reasoning models (so it has no effect for cerebras/zai-glm-4.7).