← Catalog

pig-web-search-and-fetch

Go extension for the PiG coding agent that adds real-time web search, clean Markdown fetch and deep research via Exa, with a unified /ws command

PackageCommunity listing

Install

Install with PiG

pig install npm:pig-web-search-and-fetch
Review before installing

Packages run code with your permissions and influence agent behavior. Catalog inclusion is not a security audit. Review the source before installing a third-party package.

Pi manifest JSON

The pi field of package.json.

{
  "extensions": [
    "extensions/*"
  ]
}

README

Written by the package's publisher, shown as published in version 0.1.0 (README.md). PiG does not review it.

🐷 pig-web-search-and-fetch

License: MIT pig Extension

Give your PiG coding agent real-time web intelligence: neural search, clean Markdown fetch and deep research. 🐽

pig-web-search-and-fetch brings live web tools to the PiG coding agent — web_search, web_fetch and web_deep_search — powered by Exa, with a unified /ws control command and smart coordination with Requesty's native search.

🐖 Go port of pi-web-search-and-fetch (TypeScript, Pi) into a native PiG extension. Same tool surface, same /ws ergonomics — but compiled by PiG into a runtime cell, with no Node runtime and no node_modules.


⚡ Superpowers & Features

  • 🔍 Real-Time Neural Web Search (web_search) — Semantic search with category, domain and date filters, plus transparent similarUrl discovery.
  • 📄 High-Fidelity Web Fetch (web_fetch) — Clean Markdown extraction for one or many URLs in a single call, with per-page isolation blocks.
  • 🧠 Deep Research (web_deep_search) — Synthesized answers with citations via Exa /answer, with automatic fallback to parallel multi-query synthesis.
  • 🎛️ Unified /ws Command — Status report, on|off toggles, provider assignment wizard, Exa key configuration and an interactive hub loop.
  • 🤝 Requesty Synergy — Reads the shared pi-requesty.json switch and the requesty-models.json catalog cache: when Requesty native search is active for a compatible non-Gemini model, web_search is suppressed to avoid duplication. web_fetch always stays on.
  • 🔒 Secure Credentials — Exa key in <agent-dir>/auth.json (0600), preserving other providers' entries, with EXA_API_KEY fallback.

🚀 Quick Installation

From npm

pig install npm:pig-web-search-and-fetch

Until the package is published, install from GitHub or locally.

From GitHub

pig install git:github.com/xinaps-dev/pig-web-search-and-fetch

Local Development

git clone https://github.com/xinaps-dev/pig-web-search-and-fetch.git
cd pig-web-search-and-fetch

# Install the Package root (not the extension directory)
pig install .

Requirements: PiG 0.4.0 or later (pig version) and Go 1.27.1 to build from source (pig setup go). PiG compiles the extension into a runtime cell on first use and loads it from cache afterwards.


🎯 Getting Started

1. Store your Exa key

Inside a pig session:

/ws config exa
  1. Choose Yes for Use API Key.
  2. Paste your key (get one at dashboard.exa.ai).

The key is saved to <agent-dir>/auth.json (0600). Alternatively, export EXA_API_KEY — the stored key wins when both exist. Without any key, search and fetch keep working through Exa's public endpoint under global limits (zero-config, as in the original); deep research always needs a key.

2. Toggle tools

/ws status
/ws deep on
/ws search off

web_search and web_fetch are enabled by default, web_deep_search is opt-in — exactly like the TypeScript original.

3. Ask the web

With an Exa key configured, just ask. The model calls the tools directly; use /ws status to confirm which tools the next turn sees.


🛠️ Command Reference

/ws ships with autocomplete. Without arguments it opens the interactive hub (a Select loop with the same actions as the text commands).

CommandDescription
/wsInteractive control hub (toggle, assign, configure, status)
/ws statusDetailed report: tools, Exa credential source, Requesty state
/ws search on|offEnable/disable web_search
/ws fetch on|offEnable/disable web_fetch
/ws deep on|offEnable/disable web_deep_search
/ws provider <tool> <id|none>Assign a provider (tool: search|fetch|deep; none disables, keeping the id)
/ws providerInteractive 3-step assignment wizard
/ws config [exa]Configure the Exa API key / mode
/ws helpUsage help

Only exa is registered today; none disables the tool while remembering its provider id.


🧰 Tools

ToolParamsBehaviour
web_searchquery (required), numResults, category, includeDomains, excludeDomains, startPublishedDate, endPublishedDate, similarUrlExa /search (or /findSimilar when similarUrl is set). Output is wrapped in <web_content> isolation blocks with a security notice.
web_fetchurls (string or string[]), url (alias), maxCharacters (default 5000)Exa /contents with Markdown truncation at natural boundaries. Batch failures degrade per URL.
web_deep_searchquery (required), numSources (default 5), includeText (default true), numResults, category, additionalQueriesExa /answer first; on failure, parallel /search synthesis with URL dedup. Disabled by default.

⚙️ Environment Variables

VariableDescriptionDefault
EXA_API_KEYExa API key fallback when no stored credential exists(none)

Credential precedence: auth.json["exa"] → EXA_API_KEY. When providers.exa.useApiKey is false, no key is resolved and the tools report how to re-enable it.

Files the extension owns

All inside PiG's agent dir (~/.pig/agent by default, or whatever PIG_CODING_AGENT_DIR sets):

FileContents
pi-web-search-and-fetch.jsonTool toggles (search/fetch/deepSearch) and providers.exa.useApiKey. Same name as the TypeScript extension, so configs carry over.
auth.jsonThe exa credential ({"type":"api_key","key":"..."}). Shared with PiG; other providers' entries are preserved. Mode 0600.

Files the extension reads (Requesty compatibility)

FileContents
pi-requesty.jsonThe shared Requesty switch (nativeSearch). Same file used by pi-requesty-provider and pig-requesty-provider — install either one and this extension stays compatible.
requesty-models.jsonRequesty catalog cache, consulted for supports_web_search before suppressing web_search. Absent/unknown ⇒ no suppression (safe default).

🔄 Porting notes

Differences from the TypeScript pi-web-search-and-fetch that are intentional in this Go port:

  • Exa via REST with key, MCP without. With an API key the port calls https://api.exa.ai/{search,findSimilar,contents,answer} directly, staying stateless inside PiG runtime cells (no persistent connection, nothing to close on session_shutdown). Without a key, search and fetch fall back to the public https://mcp.exa.ai/mcp endpoint — the same server the TypeScript original uses — so zero-config mode keeps working under global limits. Deep research requires a key in both implementations.
  • Hub without custom TUI. The original dashboard is a ui.custom component; this port implements /ws as text subcommands plus a blocking Select loop with the same actions (toggle, wizard, configure, status).
  • Suppression via catalog cache. The original inspects the live model object for supportsWebSearch; the Go SDK's ModelInfo has no such field, so this port reads the cached requesty-models.json written by either Requesty extension. Behaviour is otherwise identical: suppress only on Requesty provider + nativeSearch: true + non-Gemini + catalog support.

✅ Verification

# Manifest + registration + unit tests + /ws surface
scripts/verify.sh

# Unit tests only
cd extensions/pig-web-search-and-fetch && go test ./...

scripts/verify.sh uses a throwaway agent dir and never touches the real ~/.pig configuration.


📄 License

MIT — see LICENSE.