@j6e/pi-md-web-surfer
v0.9.3
Published
Pi extension: fetch web pages as markdown and search the web, powered by Jina AI
Downloads
57
Readme
pi-md-web-surfer
A pi extension that adds fetch_markdown and web_search tools — fetch web pages as clean markdown and search the web.
Inspired by the skill of the same name.
Tools
fetch_markdown
Fetch any web page as clean, token-efficient markdown.
Three strategies, tried in order:
- Content Negotiation — Sends
Accept: text/markdownheader. Sites using Cloudflare's Markdown for Agents return markdown directly (~80% fewer tokens than HTML). - Direct text/plain — For raw
.mdfiles,text/plainresponses, etc. The body is already clean text, so we use it directly. - Jina Reader (fallback) — For sites that return HTML, routes through
r.jina.aiwhich renders the page and extracts clean markdown.
Usage:
fetch_markdown(url, info?)web_search
Search the web and return results as clean markdown via Jina Search.
Requires a Jina API key. Get one free at jina.ai/?newKey, then configure it with /md-web-surfer-config or the JINA_API_KEY environment variable.
Usage:
web_search(query, num?, info?, retainImages?, withLinksSummary?)query— Search querynum— Number of results (1–20, default 5)info— Include metadata (method, tokens)retainImages— Image retention mode:"none"(default),"all", or"alt_text"(keep alt text with auto-generation)withLinksSummary— Include a summary section for hyperlinks (default: false)
Configuration
/md-web-surfer-config
Interactive command to set your Jina API key. Writes to ~/.config/pi-md-web-surfer/config.json (chmod 0600).
/md-web-surfer-config # prompt for key
/md-web-surfer-config --show # show current key status (masked)API key resolution
First match wins:
JINA_API_KEYenvironment variablejinaApiKeyfield in~/.config/pi-md-web-surfer/config.json
Installation
Quick test (one session)
pi -e ./src/index.tsPersistent (auto-discovered)
ln -s $(pwd) ~/.pi/agent/extensions/pi-md-web-surferThen run pi normally. The tools appear alongside read, write, edit, etc.
As a pi package
pi install npm:@j6e/pi-md-web-surferDevelopment
npm install
npm test # run tests once
npm run test:watch # TDD mode
npm run check # typecheckSmoke test against real URLs:
node --experimental-strip-types scripts/smoke-test.tsRequirements
- Node.js 22+ (for
--experimental-strip-types) - pi-coding-agent 0.74+
License
MIT
