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

pi-cliproxyapi-websearch

v0.2.2

Published

Zero-configuration native web search injection for CLIProxyAPI in Pi

Readme

pi-cliproxyapi-websearch

A native web search extension (web_search) tailored for the CLIProxyAPI provider in Pi.

Zero configuration, zero secondary authentication, no extra API keys or OAuth required — seamlessly reuses existing cliproxyapi connections and model credentials from Pi.

English | 中文说明

⚠️ Prerequisites:


Features

  • Zero Config, No Re-authentication: Directly reuses the authenticated CLIProxyAPI credentials (BaseURL and API Key) from Pi's model runtime. No re-OAuth or manual API key configuration required.
  • Dynamic Current Model / Automatic Fallback:
    • By default, uses the active cliproxyapi model from your current session to perform searches (supports gemini-3.8-flash-high, gpt-5.6-*, gpt-6-*, grok-*, gpt-5.5, etc.).
    • If the active session uses a model from another provider, the extension automatically selects an available search model from the registered cliproxyapi catalog.
  • Isolated Sub-request Architecture: Dispatches lightweight sub-requests containing only the native web_search tool, completely isolated from local coding tools to prevent mixed-tool conflicts and server-side stripping issues.
  • Model Switching Command: Built-in /websearch-model slash command to inspect, configure, or reset the search model anytime.
  • Execution Time Display: Displays execution duration (Took X.Xs / Elapsed X.Xs) matching Pi's shell tool conventions.

Installation

# 1. Install the CLIProxyAPI Provider extension (if not already installed)
pi install npm:@router-for-me/pi-cliproxyapi-provider

# 2. Install this search extension
pi install npm:pi-cliproxyapi-websearch

Local development or testing: pi -e ./extensions/index.ts


Commands

| Command | Description | | :--- | :--- | | /websearch-model | Interactive selection: Opens a terminal selection menu (ctx.ui.select), with the top option dynamically following the current session model, followed by candidate models in alphabetical order. | | /websearch-model <model-id> | Direct assignment: Directly configure a specific CLIProxyAPI search model (supports Tab completion). | | /websearch-model reset | Reset to default: Restore dynamic tracking of the current session model (aliases: reset, current, auto). |


Codemode

With Codemode enabled in Pi 1.0.0, scripts can call tools.web_search({ query }) and receive an object with:

  • query: the trimmed search query.
  • text: the same Markdown summary returned by a normal tool call.
  • sources: all unique reported sources as { url, title? } (an empty array when none are reported).

To enable Codemode in Pi, add +codemode to defaultTools in ~/.pi/agent/settings.json:

{
  "defaultTools": ["+codemode"]
}

Example Codemode script:

const results = await Promise.all([
  tools.web_search({ query: "Node.js release notes" }),
  tools.web_search({ query: "TypeScript release notes" }),
]);
for (const result of results) {
  text(result.text);
  text(result.sources.map((source) => source.url));
}

The tool remains available for normal calls without Codemode; text output, progress updates, and terminal rendering are unchanged. Failed searches reject the script call rather than returning an empty success result.


Development

npm ci
npm run check  # TypeScript typecheck + unit tests (Node.js native test runner)

中文说明

专为 Pi 的 CLIProxyAPI Provider 打造的原生网络搜索插件(web_search)。

零配置、零二次认证、无需额外 API Key 或 OAuth,直接复用 Pi 中已有的 cliproxyapi 连接与模型凭据。

⚠️ 前置依赖:


特性

  • 零配置、免二次认证:直接从 Pi 的模型运行时中复用已登录的 CLIProxyAPI 凭据(BaseURL 与 API Key),无需重新 OAuth,也无需手动配置 API Key。
  • 直接使用当前模型 / 自动回退:
    • 默认跟随当前会话中的 cliproxyapi 模型执行搜索(支持 gemini-3.8-flash-high、gpt-5.6-*、gpt-6-*、grok-*、gpt-5.5 等系列)。
    • 若当前会话使用的是其他 Provider 模型,插件会自动从已注册的 cliproxyapi 目录中选取可用的搜索模型回退执行。
  • 纯净子请求架构:后台发起仅包含原生 web_search 的纯净轻量请求,完全剥离本地编码工具,彻底杜绝混合工具冲突与服务端剥离问题。
  • 模型切换命令:内置 /websearch-model 命令,随时查看、指定或重置搜索模型。
  • 执行时间显示:显示执行耗时(Took X.Xs / Elapsed X.Xs),与 Pi 的终端工具规范一致。

安装

# 1. 安装 CLIProxyAPI Provider 插件(若未安装)
pi install npm:@router-for-me/pi-cliproxyapi-provider

# 2. 安装本搜索插件
pi install npm:pi-cliproxyapi-websearch

本地开发或测试加载:pi -e ./extensions/index.ts


命令

| 命令 | 说明 | | :--- | :--- | | /websearch-model | 交互式选择:弹出终端选择菜单(ctx.ui.select),首项为动态跟随当前会话模型,其余候选模型按字母顺序排列,直接用方向键选择 | | /websearch-model <model-id> | 命令行直设:直接指定特定的 CLIProxyAPI 搜索模型(支持 Tab 键自动补全) | | /websearch-model reset | 重置为默认:恢复为自动跟随当前会话模型(支持 reset、current、auto) |


Codemode

在 Pi 1.0.0 中启用 Codemode 后,脚本可通过 tools.web_search({ query }) 获取结构化对象:

  • query:去除首尾空白后的查询。
  • text:与普通工具调用相同的 Markdown 搜索总结。
  • sources:返回的全部去重来源,格式为 { url, title? },无来源时为空数组。

要在 Pi 中启用 Codemode,推荐在 ~/.pi/agent/settings.json 的 defaultTools 中添加 +codemode:

{
  "defaultTools": ["+codemode"]
}

Codemode 脚本示例:

const results = await Promise.all([
  tools.web_search({ query: "Node.js 发布说明" }),
  tools.web_search({ query: "TypeScript 发布说明" }),
]);
for (const result of results) {
  text(result.text);
  text(result.sources.map((source) => source.url));
}

未启用 Codemode 时仍可正常调用,文本输出、进度通知和终端展示保持不变。搜索失败时脚本调用会抛出错误,不会返回空的成功结果。


开发

npm ci
npm run check  # TypeScript 类型检查 + 单元测试(Node.js 原生测试套件)