pi-webfind 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +126 -0
- package/extensions/web-search.ts +662 -0
- package/lib/adapters.ts +228 -0
- package/lib/apis.ts +221 -0
- package/lib/cache.ts +160 -0
- package/lib/engine.ts +418 -0
- package/lib/extract.ts +320 -0
- package/lib/fetcher.ts +475 -0
- package/lib/pdf.ts +181 -0
- package/lib/rank.ts +169 -0
- package/package.json +56 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Jawwad Zafar
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
<p align="center">
|
|
2
|
+
<img alt="pi-webfind logo" src="docs/public/logo.png" width="128">
|
|
3
|
+
</p>
|
|
4
|
+
|
|
5
|
+
<h1 align="center">pi-webfind</h1>
|
|
6
|
+
|
|
7
|
+
<p align="center">
|
|
8
|
+
<a href="https://www.npmjs.com/package/pi-webfind"><img alt="npm" src="https://img.shields.io/npm/v/pi-webfind?style=flat-square" /></a>
|
|
9
|
+
<a href="https://github.com/jawwadzafar/pi-webfind/actions/workflows/deploy-docs.yml"><img alt="docs" src="https://img.shields.io/website?url=https%3A%2F%2Fjawwadzafar.github.io%2Fpi-webfind%2F&style=flat-square&label=docs" /></a>
|
|
10
|
+
<a href="https://github.com/jawwadzafar/pi-webfind/blob/main/LICENSE"><img alt="license" src="https://img.shields.io/npm/l/pi-webfind?style=flat-square" /></a>
|
|
11
|
+
<a href="https://github.com/jawwadzafar/pi-webfind/stargazers"><img alt="stars" src="https://img.shields.io/github/stars/jawwadzafar/pi-webfind?style=flat-square&color=b5bd68" /></a>
|
|
12
|
+
</p>
|
|
13
|
+
|
|
14
|
+
<p align="center">
|
|
15
|
+
<b>Claude Code-style web research for the <a href="https://github.com/earendil-works/pi">pi coding agent</a>.<br>100% free — no API keys, no signups, zero dependencies.</b>
|
|
16
|
+
</p>
|
|
17
|
+
|
|
18
|
+
<p align="center">
|
|
19
|
+
<a href="https://jawwadzafar.github.io/pi-webfind/">Docs</a> ·
|
|
20
|
+
<a href="https://github.com/jawwadzafar/pi-webfind/releases">Releases</a> ·
|
|
21
|
+
<a href="#security">Security</a>
|
|
22
|
+
</p>
|
|
23
|
+
|
|
24
|
+
---
|
|
25
|
+
|
|
26
|
+
## Install
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
pi install npm:pi-webfind
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
or straight from GitHub:
|
|
33
|
+
|
|
34
|
+
```bash
|
|
35
|
+
pi install git:github.com/jawwadzafar/pi-webfind
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
## What it does
|
|
39
|
+
|
|
40
|
+
Same muscle memory as Claude Code's WebSearch — `⏺ Web Search("query")`
|
|
41
|
+
headers, live status, `✓ 8 results · ddg+brave · 2.1s`, expandable rows,
|
|
42
|
+
document reading, grouped synthesis. No cost, no keys.
|
|
43
|
+
|
|
44
|
+

|
|
45
|
+
|
|
46
|
+
**7 tools + 1 command:**
|
|
47
|
+
|
|
48
|
+
| Tool | Best for |
|
|
49
|
+
|---|---|
|
|
50
|
+
| `web_search` | news, articles, broad queries — DuckDuckGo + Brave + Bing RSS, RRF-fused |
|
|
51
|
+
| `fetch_page` | read any URL — HTML/PDF/JSON, query-aware passages, bot-wall busting |
|
|
52
|
+
| `search_stackoverflow` | error messages, debugging |
|
|
53
|
+
| `search_wikipedia` | definitions, concepts, history |
|
|
54
|
+
| `search_npm` | JS/TS packages with quality scores |
|
|
55
|
+
| `search_github` | repos, stars, languages |
|
|
56
|
+
| `search_hn` | tech community opinion, launches |
|
|
57
|
+
| `/research <topic>` | parallel multi-source research → grouped briefing |
|
|
58
|
+
|
|
59
|
+
## Reading comprehension, not just fetching
|
|
60
|
+
|
|
61
|
+
- **`fetch_page` with `query`** — returns the intro plus the most
|
|
62
|
+
query-relevant passages (BM25, heading trails), not the first 8,000
|
|
63
|
+
characters. The difference between an infobox dump and the two paragraphs
|
|
64
|
+
that answer you.
|
|
65
|
+
- **`web_search` with `deep: true`** — reads the top results in parallel and
|
|
66
|
+
attaches a query-relevant excerpt to every row. Factual questions often
|
|
67
|
+
answer themselves without a single fetch.
|
|
68
|
+
- **Markdown extraction** — density-scored article detection turns pages into
|
|
69
|
+
structured markdown; Wikipedia arrives as prose, not `{{cite web}}` soup.
|
|
70
|
+
- **Site adapters** — GitHub repos/issues/PRs/files, Stack Overflow, HN,
|
|
71
|
+
Reddit and Wikipedia skip scraping entirely and come from their clean free
|
|
72
|
+
APIs. The output header tells you which served you (`github-issue-api`,
|
|
73
|
+
`stackexchange-api`, …).
|
|
74
|
+
|
|
75
|
+
<div align="center">
|
|
76
|
+
<video src="https://jawwadzafar.github.io/pi-webfind/demo.mp4" controls muted playsinline width="100%"></video>
|
|
77
|
+
<p><sub>70s: <code>/research do browsers cache dns how long</code> — multi-engine search, source dives, final briefing with citations</sub></p>
|
|
78
|
+
</div>
|
|
79
|
+
|
|
80
|
+
## When engines fight back
|
|
81
|
+
|
|
82
|
+
Every search and fetch walks a fallback ladder before admitting failure:
|
|
83
|
+
|
|
84
|
+
```text
|
|
85
|
+
web_search DDG html → lite → POST → r.jina.ai proxy → Bing RSS
|
|
86
|
+
→ engine "multi": DDG ∥ Brave ∥ Bing in parallel, RRF-fused
|
|
87
|
+
→ any primary failure auto-retries via multi
|
|
88
|
+
|
|
89
|
+
fetch_page site adapter (GitHub/SE/HN/Reddit/Wikipedia APIs)
|
|
90
|
+
→ direct fetch (browser UA, 3× backoff)
|
|
91
|
+
→ 401/403/429/503 → Wayback Machine snapshot
|
|
92
|
+
→ thin/SPA page → r.jina.ai headless render
|
|
93
|
+
→ block-page detection (never shows fake content as success)
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
Disk-backed caches (`~/.pi/agent/cache/webfind/`) survive restarts: 10-min
|
|
97
|
+
search, 1-h fetch. `refresh` / `no_cache` flags skip them.
|
|
98
|
+
|
|
99
|
+
## Security
|
|
100
|
+
|
|
101
|
+
pi-webfind runs with full system access like any pi extension. What it does
|
|
102
|
+
with it:
|
|
103
|
+
|
|
104
|
+
- **Outbound HTTPS only** — search engines, public APIs, pages you fetch
|
|
105
|
+
- **SSRF-guarded** — localhost, private ranges and link-local addresses are blocked
|
|
106
|
+
- **Never executes or writes fetched content**; it reads URLs and returns text
|
|
107
|
+
- Politeness throttle per host; fake-browser UA only where required, honest
|
|
108
|
+
`pi-webfind/x.y` UA everywhere it matters
|
|
109
|
+
- The only optional credential is `GITHUB_TOKEN` (lifts GitHub's 10 req/min
|
|
110
|
+
anonymous limit). Everything else is keyless by design.
|
|
111
|
+
|
|
112
|
+
## Limits (be honest about free)
|
|
113
|
+
|
|
114
|
+
- Scraped engines tighten defenses anytime — the fallback ladder is the mitigation
|
|
115
|
+
- Unauthenticated GitHub is 10 req/min (see `GITHUB_TOKEN` above)
|
|
116
|
+
- Result dates appear only when engines provide them (DDG stamps, Bing pubDates)
|
|
117
|
+
- Public SearXNG instances rate-limit cloud IPs; jina proxy + Brave cover that gap
|
|
118
|
+
|
|
119
|
+
## Docs
|
|
120
|
+
|
|
121
|
+
Full tool reference, parameters and guides at
|
|
122
|
+
**[jawwadzafar.github.io/pi-webfind](https://jawwadzafar.github.io/pi-webfind/)**.
|
|
123
|
+
|
|
124
|
+
## License
|
|
125
|
+
|
|
126
|
+
MIT
|