# pi-web-surf

Internet research extension for the pi coding agent — powered by [ketch](https://github.com/1broseidon/ketch) CLI (v0.12+).

## Tools

| Tool | Description |
|------|-------------|
| `internet_search` | Web search (DuckDuckGo, Brave, SearXNG, Exa, Firecrawl, Keenable). Supports `--scrape` for full content. |
| `internet_scrape` | Fetch URLs → clean markdown. Auto-detects SPAs, handles PDFs, CSS selectors. |
| `code_search` | Grep real OSS source across public repos (Grep.app, Sourcegraph, GitHub Code Search). |
| `library_docs` | Curated, version-aware library/API docs via Context7. |
| `web_crawl` | BFS same-host crawl → markdown per page. For multi-page docs sites. |

## Install

### Prerequisites

```bash
brew install 1broseidon/tap/ketch
# or: go install github.com/1broseidon/ketch@latest
```

### As a pi package

Add to `~/.config/pi/agent/settings.json`:

```json
{
  "packages": [
    "git:github.com/yanralapdy/pi-web-surf"
  ]
}
```

### As a local extension

```bash
ln -s ~/sites/js/node/pi-web-surf ~/.pi/agent/extensions/pi-web-surf
```

## Configuration

ketch reads config from `~/Library/Application Support/ketch/config.json` (macOS) or `~/.config/ketch/config.json` (Linux):

```bash
ketch config set backend ddg          # DuckDuckGo (free, no key)
ketch config set brave_api_key <key>  # or use Brave (free key from brave.com/search/api)
ketch config set context7_api_key <k> # for library_docs (free from context7.com)
```

## Usage

In pi:
```
/reload

# The model uses these tools automatically based on task:
# - "search for X" → internet_search
# - "read this URL" → internet_scrape  
# - "find code that uses X" → code_search
# - "show me the docs for X" → library_docs
# - "crawl this docs site" → web_crawl
```

## Requires

- ketch >= v0.12.0
- pi >= 0.80.0

## License

MIT
