pi-search-agent
Semantic codebase search with sub-agent processing
Package details
Install pi-search-agent from npm and Pi will load the resources declared by the package manifest.
$ pi install npm:pi-search-agent- Package
pi-search-agent- Version
1.0.1- Published
- Feb 6, 2026
- Downloads
- 17/mo · 2/wk
- Author
- toorusr
- License
- unknown
- Types
- extension
- Size
- 111.2 KB
- Dependencies
- 2 dependencies · 0 peers
Pi manifest JSON
{
"extensions": [
"./index.ts"
]
}Security note
Pi packages can execute code and influence agent behavior. Review the source before installing third-party packages.
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:
- Enter your
OPENAI_API_KEY(used for embeddings). - 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_KEYSEARCH_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_KEYSEARCH_PROVIDER+SEARCH_MODELSEARCH_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
- File discovery: streams
findresults and yields to the event loop to avoid blocking the UI. - Chunking: files are split into overlapping chunks for stable embeddings.
- Embeddings: generated with OpenAI (
text-embedding-3-small) and cached on disk. - Index storage: index metadata + chunks are persisted per-cwd.
- Search pipeline:
- embedding matches → merged per file
- subagent refines results and provides a concise answer
- Summaries / filtering: uses the configured
SEARCH_PROVIDER+SEARCH_MODEL(and optionalSEARCH_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/semanticinteractive UI
Notes
modeis accepted but currently ignored;codeincludes markdown.- Indexing is per-cwd. If no index exists, it is created automatically.
- The recommended search model is cerebras / zai-glm-4.7.
SEARCH_THINKINGis clamped toofffor non-reasoning models (so it has no effect for cerebras/zai-glm-4.7).