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

b5-fusion

v0.2.0

Published

Multi-model B5 fusion ensemble for pi — every turn runs all candidates, the aggregator fuses the best answer

Readme

B5 Fusion for pi

pi coding agent 的多模型聚合融合扩展。每个回合所有启用的候选并行运行,单一聚合器融合它们的草稿,输出一个最佳回答。

不是路由器,也不是分级器。 每回合 所有 启用的候选都跑。 聚合器看到所有候选(推理 + 文本),再综合输出。

       ┌── 候选 1(deepseek-v4-flash, thinking: minimal)──┐
       ├── 候选 2(MiniMax-M3,        thinking: low)     ──┤
回合 ──├── 候选 3(deepseek-v4-pro,   thinking: high)    ──├─→ 聚合器
       ├── 候选 4(qwen3.7-plus,      thinking: medium)  ──┤   (deepseek-v4-flash)
       └── 候选 5(GLM-5.1,           thinking: medium)  ──┘

设计灵感来自 Anthropic 关于 Claude Fable 5 的研究方向 (多个中端模型聚合,能在相近预算下匹配一个前沿模型)。


核心特性

  • 真·聚合 — 所有候选每回合都跑,没有角色/等级路由
  • 自包含配置 — 每个候选自带 baseUrl + apiKey + model
  • OpenAI 兼容 — 兼容 OpenRouter、vLLM、LM Studio、Anthropic-via-代理、自建网关
  • 工具调用 — 聚合器可调用 pi 的全部工具(read、bash、edit、MCP …)
  • 7 语种 UI — 完整本地化:zh-CN、en-US、de-DE、ru-RU、ko-KR、ja-JP、sa-Deva(梵语 IAST 转写)
  • 智能中止 — quorum 满足后给慢候选 graceful 时间窗口再统一 abort
  • 推理转发 — 每个候选的 <THINKING> 块被完整转发给聚合器

安装

需要 pi ≥ v0.80,Node ≥ 20。

从 npm 安装(发布后):

pi install npm:b5-fusion

从本仓库克隆安装:

git clone https://github.com/<your-org>/b5-fusion-pi
pi install ./b5-fusion-pi

临时试用(不装到全局):

pi -e ./b5-fusion-pi

安装后用 /model b5-ensemble/b5-fusion 切到 B5 模型。

配置样例见 config.example.json。运行时配置文件位于 ~/.pi/b5-fusion-settings.json。


快速上手

  1. 安装(任选上面任一方法)。

  2. 编辑配置 至少 1 个候选 + 1 个聚合器:

    // ~/.pi/b5-fusion-settings.json
    {
      "version": 6,
      "enabled": true,
      "language": "auto",           // 或 "zh-CN" / "de-DE" / …
      "candidates": [
        { "label": "快查",  "enabled": true,
          "baseUrl": "https://api.openrouter.ai/v1", "apiKey": "$OPENROUTER_API_KEY",
          "model": "deepseek/deepseek-chat", "thinking": "minimal" },
        { "label": "代码",  "enabled": true,
          "baseUrl": "https://api.openrouter.ai/v1", "apiKey": "$OPENROUTER_API_KEY",
          "model": "anthropic/claude-3.5-sonnet",   "thinking": "low" },
        { "label": "推理",  "enabled": true,
          "baseUrl": "https://api.openrouter.ai/v1", "apiKey": "$OPENROUTER_API_KEY",
          "model": "deepseek/deepseek-reasoner",    "thinking": "high" }
      ],
      "aggregator": {
        "baseUrl": "https://api.openrouter.ai/v1",
        "apiKey":  "$OPENROUTER_API_KEY",
        "model":   "anthropic/claude-3.5-sonnet",
        "thinking": "low"
      },
      "minSuccessfulProposers": 2,
      "quorumGraceSeconds": 10,
      "proposerTimeoutSeconds": 1200,
      "aggregatorTimeoutSeconds": 1800,
      "draftMaxChars": 8000,
      "shuffleCandidates": true
    }

    $OPENROUTER_API_KEY 会从环境变量读取,也可以直接写 API key。

  3. 重载 pi(或按 /reload)。

  4. 选模型:/model b5-ensemble/b5-fusion。

  5. 开聊 — 状态栏实时显示候选进度,面板显示最终结果。


命令

| 命令 | 说明 | |---|---| | /b5-status | 显示当前阵容 + 聚合器 + UI 语言 | | /b5-reload | 从磁盘重新加载配置 | | /b5-lang [语言] | 显示 / 切换 UI 语言,auto 清除 override |

示例:

/b5-lang                  # 列出可用语言
/b5-lang zh-CN            # 切换到简体中文
/b5-lang auto             # 跟随系统语言

支持的语言:zh-CN 简体中文 · en-US English · de-DE Deutsch · ru-RU Русский · ko-KR 한국어 · ja-JP 日本語 · sa-Deva संस्कृतम्。


工作原理

用户输入
   │
   ▼  (每个回合)
┌────────── 候选并行生成 ──────────┐
│ 候选 1 ─────────► 草稿          │
│ 候选 2 ─────────► 草稿          │
│ ...                              │
│ 候选 N ─────────► 草稿 + 🧠     │
└────────── (quorum 满足后)──────┘
   │
   ▼
┌── 聚合器(单一模型,可调用工具) ──┐
│  看到:原 prompt + 所有草稿         │
│        + 所有思考/推理块           │
│  输出:一个融合回答(可调用工具)    │
└────────────────────────────────────┘
   │
   ▼
用户

延迟优化:一旦 minSuccessfulProposers 份草稿到位,B5 Fusion 等待 quorumGraceSeconds(默认 10s),然后 abort 仍在跑的慢候选。聚合器立即开始,总耗时 ≈ 多数候选的耗时,而不是最慢一个。

Quorum 失败:如果通过数 < minSuccessfulProposers,聚合器依然会运行,但会被告知草稿参考不完整。


配置字段

完整 schema 与默认值见 docs/configuration.md。

核心字段:

| 字段 | 默认 | 说明 | |---|---|---| | enabled | false | 总开关 | | language | "auto" | "auto" 跟随系统语言;否则填语言代码 | | candidates[] | [] | 启用的候选每回合都跑 | | aggregator | 空 | 单一聚合器 — 建议支持工具调用 | | minSuccessfulProposers | 2 | 融合所需的最小通过数 | | quorumGraceSeconds | 30 | quorum 满足后等待多久再 abort 慢候选 | | proposerTimeoutSeconds | 300 | 候选硬超时 | | aggregatorTimeoutSeconds | 480 | 聚合器硬超时 | | draftMaxChars | 8000 | 每份草稿传聚合器前的最大字符数 | | shuffleCandidates | true | 随机排序草稿,避免位置偏好 |

API key 可以直接写,也可以用 $ENV_VAR 从 process.env 读取。


架构

extensions/b5-fusion/
├── index.ts                # 扩展入口:provider + 命令 + prompt 注入
├── config.ts               # 配置类型、持久化、校验
├── ensemble-engine.ts      # 候选并行、quorum、聚合器流式
├── openai-client.ts        # OpenAI 兼容 HTTP + SSE 流式
├── aggregator-prompt.ts    # 多语言用户消息构造
├── b5-fusion-prompt.ts     # 多语言 system prompt 分发
├── i18n.ts                 # 翻译核心(检测 + override + 回退)
└── locales/
    ├── zh-CN.ts            # 简体中文
    ├── en-US.ts            # English (参考标准)
    ├── de-DE.ts            # Deutsch
    ├── ru-RU.ts            # Русский
    ├── ko-KR.ts            # 한국어
    ├── ja-JP.ts            # 日本語
    └── sa-Deva.ts          # संस्कृतम्(IAST 转写)

各模块职责见 docs/architecture.md。


限制

  • 每个 enabled: true 的候选必须可达。 不会自动重试切换到其他端点。
  • 聚合器决定是否调用工具。 候选只是参考草稿,不会拿到工具定义。
  • 推理格式:不同厂商暴露方式不同。扩展会透明转发 reasoning_content(DeepSeek 风格)和 <THINKING> 块;其他厂商私有格式会回退为纯文本。
  • 接口是 OpenAI 兼容 /v1/chat/completions。 不做 Anthropic 原生 / Gemini 原生到 OpenAI 的转换 — 用 OpenRouter(或任何兼容代理)即可。

开发

# 安装 bun(locale 测试需要)
curl -fsSL https://bun.sh/install | bash

# 全部检查
bun run test

# 校验各语言 key 覆盖率
bun run test:locales

# 校验 npm 包结构
npm run test:package

许可证

MIT © 2026 B5 Fusion Contributors.