npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

bocha-web-search-pi-extension

v1.0.0

Published

Bocha Web Search pi extension

Readme

Bocha Web Search pi Extension

pi 开发的 Bocha AI 网页搜索扩展,注册一个 bocha_web_search 工具,用于搜索网页并返回 Markdown 格式的结果列表。

功能简介

  • 调用 Bocha AI /v1/web-search 接口搜索网页。
  • 支持设置返回结果数量、时间范围(freshness)以及是否返回 AI 摘要。
  • 结果以 Markdown 列表形式返回,包含标题、链接、摘要/片段和发布日期。
  • 当输出超过默认行数或字节限制时,会自动截断并将完整内容保存到临时文件。

安装

通过 pi 安装(推荐)

全局安装(对当前用户生效):

pi install npm:bocha-web-search-pi-extension

项目级安装(写入当前项目的 .pi/settings.json):

pi install npm:bocha-web-search-pi-extension -l

安装后,在 pi 中执行 /reload 即可加载扩展。

如果你想先试用再安装,可以使用本地路径加载:

pi -e /path/to/bocha-web-search

配置文件

配置文件固定保存在以下路径,不会随 npm 包目录变化

~/.pi/agent/bocha-web-search/config.json

首次使用前,请按以下步骤准备配置文件(扩展会在首次调用工具时自动创建配置目录):

mkdir -p ~/.pi/agent/bocha-web-search
cp /path/to/bocha-web-search/config.json.example ~/.pi/agent/bocha-web-search/config.json

YOUR_BOCHA_API_KEY 替换为你的真实 Bocha API Key:

{
  "apiKey": "YOUR_BOCHA_API_KEY"
}

注意config.json 包含敏感信息,请勿提交到 GitHub。本仓库的 .gitignore 已默认忽略相关文件,但仍需确保不会误传。

配置示例

{
  "apiKey": "sk-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
}

使用示例

在 pi 中调用 bocha_web_search 工具:

bocha_web_search(query: "pi coding agent 最新功能")

带参数调用:

bocha_web_search(
  query: "人工智能最新进展",
  count: 10,
  freshness: "oneWeek",
  summary: true
)

参数说明

| 参数 | 类型 | 必填 | 默认值 | 说明 | |------|------|------|--------|------| | query | string | 是 | - | 搜索关键词 | | count | integer | 否 | 5 | 返回结果数量,范围 1~50 | | freshness | string | 否 | "noLimit" | 时间范围,可选:noLimitoneDayoneWeekoneMonthoneYear | | summary | boolean | 否 | true | 是否返回 AI 生成的摘要 |

注意事项

  • 安装完成后请务必在 pi 中执行 /reload 重新加载扩展。
  • 如果配置文件不存在或 API Key 未设置,调用工具时会抛出明确错误并提示配置文件路径。
  • 扩展会自动创建 ~/.pi/agent/bocha-web-search/ 配置目录,但不会自动创建 config.json 文件;请按上述步骤手动准备配置文件。