pi-fast-context
v1.0.1
Published
AI-driven semantic code search for the Pi coding agent — Windsurf SWE-grep protocol as a native pi package.
Maintainers
Readme
Fast Context for Pi
AI-driven semantic code search as a Pi coding agent package — powered by Windsurf's reverse-engineered SWE-grep protocol.
This is a port of fast-context-mcp from MCP to a native Pi extension. Search logic is unchanged: a remote Devstral model proposes rg / readfile / tree commands, they run locally, and you get file paths, line ranges, and grep keywords.
How It Works
You: "where is the authentication logic?"
│
▼
┌─────────────────────────┐
│ Fast Context (pi ext) │
│ │
│ 1. Maps project → /codebase
│ 2. Sends query to Windsurf Devstral API
│ 3. AI generates rg/readfile/tree commands
│ 4. Executes commands locally (bundled rg)
│ 5. Returns results to AI
│ 6. Repeats for N rounds
│ 7. Returns file paths + line ranges
│ + suggested search keywords
└─────────────────────────┘Prerequisites
- Node.js >= 20
- Pi coding agent
- Windsurf / Devin account — free tier works (needed for an API key)
No system ripgrep install is required (@vscode/ripgrep is bundled).
Install
From npm:
pi install npm:pi-fast-contextFrom git:
pi install git:github.com/hemo94931/pi-fast-contextTry once without persisting:
pi -e npm:pi-fast-contextProject-local (writes .pi/settings.json):
pi install -l npm:pi-fast-contextFrom a local checkout:
pi install /absolute/path/to/pi-fast-contextAfter install, start pi and confirm the tools with /tools, or run /fast-context status.
Setup
Run /fast-context setup inside pi. It extracts a key from the local Devin/Windsurf install and writes:
{getAgentDir()}/extensions/pi-fast-context/config.jsongetAgentDir() is Pi's agent config directory (~/.pi/agent by default, or $PI_CODING_AGENT_DIR). Do not hardcode that path.
You can also set WINDSURF_API_KEY yourself; the env var wins over config.json.
If local discovery finds no key, /fast-context setup prompts you to paste one. The value is shown as • per character (not plaintext, not a blank field). Enter saves it; an empty value errors without writing files; Esc cancels setup.
Search key resolution: env var → config.json → live Devin/Windsurf discovery.
Desktop credentials (used by setup / live discovery) are tried in this order: Devin, legacy Deviv, then Windsurf.
| Platform | Path |
|----------|------|
| macOS | ~/Library/Application Support/Devin/User/globalStorage/state.vscdb |
| Windows | %APPDATA%/Devin/User/globalStorage/state.vscdb |
| Linux | ~/.config/Devin/User/globalStorage/state.vscdb |
On WSL/Linux, discovery first checks Devin CLI credentials at ~/.local/share/devin/credentials.toml. If a Windows-extracted key returns 403 inside WSL, run devin login inside WSL and retry.
The key is never printed in full. /fast-context setup persists it in config.json for later sessions.
Tools and commands
fast_context_search
| Parameter | Type | Required | Default | Description |
|-----------|------|----------|---------|-------------|
| query | string | Yes | — | Natural language search query |
| project_path | string | No | cwd | Absolute path to project root |
| tree_depth | integer | No | 3 | Directory tree depth for repo map (1-6). Auto-falls back if tree exceeds 250KB. |
| max_turns | integer | No | 3 | Search rounds (1-5) |
| max_results | integer | No | 10 | Maximum files to return (1-30) |
| exclude_paths | string[] | No | [] | Patterns excluded from the repository map |
Example output:
Found 3 relevant files.
[1/3] /project/src/auth/handler.py (L10-60, L120-180)
[2/3] /project/src/middleware/jwt.py (L1-40)
[3/3] /project/src/models/user.py (L20-80)
grep keywords: authenticate, jwt.*verify, session.*token
[config] tree_depth=3, tree_size=12.5KB, max_turns=3/fast-context
/fast-contextor/fast-context status— whether a key is available (env or config.json)/fast-context setup— extract a local Devin/Windsurf key and write{getAgentDir()}/extensions/pi-fast-context/config.json
Environment Variables
| Variable | Default | Description |
|----------|---------|-------------|
| WINDSURF_API_KEY | (config.json, then auto-discover) | Windsurf API key |
| FC_MAX_TURNS | 3 | Search rounds per query |
| FC_MAX_COMMANDS | 8 | Max parallel commands per round |
| FC_TIMEOUT_MS | 30000 | Connect-Timeout-Ms for streaming requests |
| FC_RESULT_MAX_LINES | 50 | Max lines per command output |
| FC_LINE_MAX_CHARS | 250 | Max characters per output line |
| FC_CACHE_DISABLED | (unset) | Disable the in-memory result cache (1 / true / yes / on) |
| FC_CACHE_TTL_MS | 300000 | Result-cache TTL; <=0 disables caching |
| FC_CACHE_MAX_ENTRIES | 200 | Maximum in-memory cache entries |
| FC_ALLOW_INSECURE_TLS | (unset) | Set to 1 only when a trusted corporate proxy requires disabled TLS verification |
| WS_MODEL | MODEL_SWE_1_6_FAST | Windsurf model name |
| WS_APP_VER | 1.48.2 | Windsurf app version (protocol metadata) |
| WS_LS_VER | 1.9544.35 | Windsurf language server version (protocol metadata) |
Available Models
Change the model with WS_MODEL.

Default: MODEL_SWE_1_6_FAST — fastest speed, richest grep keywords, finest location granularity.
Package layout
pi-fast-context/
├── package.json # pi manifest (extensions)
├── extensions/index.ts # Pi extension: tools + /fast-context
├── src/ # Search core (unchanged from fast-context-mcp)
├── test/
└── README.mdHow the Search Works
- Project directory is mapped to virtual
/codebasepath - Directory tree generated at requested depth (default L=3), with automatic fallback if tree exceeds 250KB
- Query + directory tree sent to Windsurf's Devstral model via Connect-RPC/Protobuf
- Devstral generates tool commands (ripgrep, file reads, tree, ls, glob)
- Commands executed locally in parallel (up to
FC_MAX_COMMANDSper round) - Results sent back to Devstral for the next round
- After
max_turnsrounds, Devstral returns file paths + line ranges - All rg patterns used during search are collected as suggested keywords
- Diagnostic metadata appended so the calling model can retune parameters
Technical Details
- Protocol: Connect-RPC over HTTP/1.1, Protobuf encoding, gzip compression
- Model: Devstral (
MODEL_SWE_1_6_FAST, configurable) - Local tools:
rg(bundled via@vscode/ripgrep),readfile(Node.js fs),tree(tree-node-cli),ls(Node.js fs),glob(Node.js fs) - Auth: API Key → JWT (auto-fetched per session)
- Runtime: Node.js >= 20 (ESM). Pi loads
extensions/index.tsvia jiti — no compile step.
Dependencies
| Package | Purpose |
|---------|---------|
| @vscode/ripgrep | Bundled ripgrep binary (cross-platform) |
| tree-node-cli | Cross-platform directory tree |
| sql.js | Read Devin/Windsurf's local SQLite DB without a native build |
Pi core packages (@earendil-works/pi-coding-agent, typebox) are peer dependencies provided at runtime.
Credit
Search core ported from SammySnake-d/fast-context-mcp (MIT).
Not affiliated with Windsurf, Codeium, or Cognition.
License
MIT. Copyright (c) 2025 SammySnake-d; Copyright (c) 2026 hemo94931.
