New:Introducing Socket Scanning for VS Code Marketplace Extensions.Learn more →
Get Started

pi-mgrep

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install
Package was removed
Sorry, it seems this package was removed from the registry

pi-mgrep

Unified search extension for Pi coding agent — mgrep semantic search + DuckDuckGo fallback. Auto-installs mgrep. Zero config.

latest
Source
npmnpm
Version
0.2.2
Version published
Maintainers
1
Created
Source

pi-mgrep

Ripgrep + mgrep dual-routing. Both auto-install. Zero config.

Unified search extension for Pi Coding Agent.

Quick Start

npm install -g pi-mgrep
# Restart pi — ripgrep and mgrep auto-install on first use.

What it gives you

Three LLM-callable tools.

search — Dual-Engine Router

Auto-routes based on query type:

QueryEngineSpeed
registerTool (camelCase)ripgrep0.02s
calculate_total (snake_case)ripgrep0.02s
app.tsx (path/ext)ripgrep0.02s
{ status: 200 } (syntax)ripgrep0.02s
error handling logic (NL)mgrep3-8s
how to handle errors (NL)mgrep3-8s

If ripgrep is unavailable, mgrep handles everything silently.

search({ query: "registerTool" })
// → ripgrep 0.02s, file + line matches

search({ query: "error handling logic", answer: true })
// → mgrep semantic, AI-generated summary

mgrep web with automatic DuckDuckGo fallback.

web_search({ query: "React 19 new features" })
// → 5 ranked URLs

web_search({ query: "React 19 new features", count: 10 })
// → 10 ranked URLs (max customizable)

web_search({ query: "React 19 new features", answer: true })
// → AI-generated answer with citations

web_fetch — Page Reader

Fetch URL, strip HTML, return plain text.

web_fetch({ url: "https://react.dev/blog/2024/12/05/react-19" })
// → Clean text, max 6000 chars

Customizing Results Count

Default is 5 results per search.

Per-query (via prompt)

Ask the Agent in natural language — no code changes needed:

"Search the web for React 19 new features, return 10 results"
"请搜索 React 19 新特性,返回 10 条结果"

The Agent will automatically pass count: 10 to web_search. Works in English and Chinese.

Change the default permanently

Ask the Agent directly:

"请将 web_search 的默认返回数量从 5 改为 10"
"Change the default result count of web_search from 5 to 10"

The Agent will edit .pi/extensions/mgrep.ts for you — change both occurrences of the number, then restart pi.

Interactive Commands

CommandPurpose
/search <query> [path]Local search (auto routes rg/mgrep)
/web <query>Web search
/fetch <url>Fetch URL content

How it works

┌─ resolveRg() ──────────────────────────────────────────────┐
│  which rg → known paths → brew install ripgrep              │
├─ resolveMgrep() ───────────────────────────────────────────┤
│  which mgrep → known paths → npm install -g @mixedbread/mgrep │
├────────────────────────────────────────────────────────────┤
│  Tool: search                                               │
│    code-like? → rg (if available, 0.02s)                    │
│             els → mgrep (3-8s, semantic)                    │
│             answer=true? → -a (AI summary)                  │
├────────────────────────────────────────────────────────────┤
│  Tool: web_search                                           │
│    mgrep -w /tmp/mgrep-empty                                │
│    fail? → DuckDuckGo HTML (zero-dep fallback)              │
├────────────────────────────────────────────────────────────┤
│  Tool: web_fetch                                            │
│    Node.js http.get → strip HTML → plain text               │
└────────────────────────────────────────────────────────────┘

Requirements

  • Pi Coding Agent ≥ 0.73.0
  • Everything else auto-installs (ripgrep + mgrep)

Authentication

mgrep needs auth to Mixedbread's API.

Device login (7-day expiry)

mgrep login
# ~/.zshrc
export MXBAI_API_KEY="mxb_your_key_here"

Design choices

  • Dual-engine — ripgrep 0.02s for code, mgrep 3-8s for natural language
  • Auto-install — both engines install via system package managers
  • Graceful degradation — rg missing → mgrep for all. mgrep missing → DDG for web
  • Output limits — 6000 char cap on every tool

Test Report

CategoryScenarioEngineTime
Code symbol registerToolLocalripgrep0.007s
NL web search fallback logicLocalmgrep12.9s
Chinese NL 错误处理策略Localmgrep4.5s
NL + answer summaryLocalmgrep13.7s
Default count: 5Webmgrep5.1s
answer: true + 9 citationsWebmgrep9.9s
count: 3 / count: 7 truncationWebfilterWeb—
HTML fetch & stripFetchNode.js<1s
DuckDuckGo fallbackDegradeDDG1.3s
6000-char truncationEdge——

15/15 passed. Full details: docs/test-report.md.

License

MIT

Keywords

pi

FAQs

Package last updated on 05 May 2026

Related posts