原始内容
pi-web-search
A shareable pi package that adds a web_search tool.
The tool searches the web and returns ranked results with titles, URLs, and snippets. It can use Brave Search when an API key is available, or DuckDuckGo HTML without an API key.
Install
Install directly from git:
pi install git:github.com/narumiruna/pi-web-search
Or install from a local checkout:
pi install /absolute/path/to/pi-web-search
# or, for this project only:
pi install -l ./pi-web-search
If published to npm, install with:
pi install npm:@narumitw/pi-web-search
To try it for one run without adding it to settings:
pi -e git:github.com/narumiruna/pi-web-search
# or
pi -e /absolute/path/to/pi-web-search
Security note: pi packages can execute code with your user permissions. Review packages before installing them.
Tool
web_search searches the web and returns source URLs with snippets.
Parameters:
query(string, required): search querymax_results(integer, optional): number of results, 1-10, defaults to 5provider(auto|brave|duckduckgo, optional): defaults toautosafe_search(boolean, optional): defaults totrue
Providers
auto: uses Brave Search whenBRAVE_SEARCH_API_KEYis set; otherwise uses DuckDuckGo HTML.brave: uses the Brave Search API and requires:export BRAVE_SEARCH_API_KEY=...duckduckgo: no API key required; scrapes DuckDuckGo's HTML endpoint, so it may be less reliable than an API-backed provider.
Example prompt
Search the web for the latest pi-coding-agent extension docs and summarize the top sources.
Package layout
This repository is a pi package. package.json declares:
{
"keywords": ["pi-package"],
"pi": {
"extensions": ["./extensions"]
}
}
The extension entrypoint is:
extensions/web-search.ts
Pi loads TypeScript extensions directly, so there is no build step.
Development
Install dependencies:
npm install
Run formatter, linter, and TypeScript checks:
npm run format
npm run check
Install the pre-commit hooks:
pre-commit install
Run hooks manually:
pre-commit run --all-files
Publishing to npm
Update
package.jsonmetadata (name,version, repository fields if needed).Preview the npm tarball:
npm pack --dry-runPublish:
npm publish --access public
After publishing, users can run:
pi install npm:@narumitw/pi-web-search