bb-plugins

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

bb plugins

bb 插件

bb plugins are TypeScript packages that run inside bb. They are how bb extends itself.
Many first-party features are plugins: GitHub, Docs, Memory, Tasks, Connect, Automations, Secrets, Keep Awake, and the coding-agent providers.
bb 插件是运行在 bb 内部的 TypeScript 包,是 bb 实现自我扩展的方式。
许多官方功能都是以插件形式存在的:GitHub、Docs、Memory、Tasks、Connect、Automations、Secrets、Keep Awake,以及 coding-agent 提供程序。

Trust

信任机制

Plugins are full-trust. Server code runs in-process. App UI is same-origin page code, not a sandbox. Host workers run as Node on enrolled machines.
Review source before installing third-party plugins. Keep credentials in
secret: true
settings.
插件拥有完全权限:服务端代码在进程内运行;应用 UI 是同源页面代码,而非沙箱环境;主机 worker 在已注册机器上以 Node 进程运行。
安装第三方插件前请先审核源代码。请将凭据存储在
secret: true
的设置项中。

This skill vs others

本技能与其他技能的区别

  • Use this skill to create, install, or change a plugin.
  • Use
    bb-cli
    to operate bb (threads, projects, environments).
  • For exact API signatures, read the
    bb-plugin-authoring
    skill if it is available, then run
    bb guide plugins
    . In the plugin directory, run
    bb plugin types
    before trusting local SDK types. Do not guess from minified
    dist/
    files.
  • 使用本技能创建、安装或修改插件。
  • 使用
    bb-cli
    技能操作 bb(线程、项目、环境)。
  • 如需了解准确的 API 签名,请先查看
    bb-plugin-authoring
    技能(若可用),然后运行
    bb guide plugins
    。在插件目录中,使用本地 SDK 类型前请先运行
    bb plugin types
    。不要从压缩后的
    dist/
    文件中猜测 API。

Scaffold

脚手架搭建

sh
bb plugin new hello            # add --app for a React UI
cd bb-plugin-hello
bb plugin install . --yes
bb plugin dev                  # rebuild + reload on save
The manifest is the
bb
object in
package.json
. Required:
bb.name
,
bb.description
,
bb.branding.icon
,
bb.server
. Optional:
bb.app
,
bb.host
,
bb.skills
,
bb.themes
.
Plugin id is the last package-name segment with a
bb-plugin-
prefix stripped.
bb-plugin-hello
and
@acme/bb-plugin-hello
both become
hello
.
Put runtime imports in
dependencies
. Leave types and tooling in
devDependencies
. Git installs run
npm install --omit=dev
.
sh
bb plugin new hello            # 添加 --app 参数以创建 React UI
cd bb-plugin-hello
bb plugin install . --yes
bb plugin dev                  # 保存时自动重建并重载
清单是
package.json
中的
bb
对象。必填项:
bb.name
bb.description
bb.branding.icon
bb.server
。可选项:
bb.app
bb.host
bb.skills
bb.themes
插件 ID 是包名的最后一段,去掉
bb-plugin-
前缀。
bb-plugin-hello
@acme/bb-plugin-hello
的插件 ID 均为
hello
将运行时依赖放入
dependencies
,类型和工具依赖放入
devDependencies
。Git 安装时会执行
npm install --omit=dev

What a plugin can add

插件可扩展的功能

A default-export factory in
server.ts
receives
BbPluginApi
and registers surfaces:
  • settings, kv + SQLite storage, HTTP, RPC, realtime
  • background services and cron
  • one top-level
    bb <name> …
    command
  • agent tools,
    skills/
    folders, extra instructions
  • mention providers
  • optional host workers and experimental agent providers
app.tsx
default-exports
definePluginApp
and can add pages, thread-panel actions, composer controls, file openers, and a replacement sidebar.
Do not copy the full API into this skill. Read
bb-plugin-authoring
when implementing a surface.
server.ts
中的默认导出工厂函数接收
BbPluginApi
并注册以下功能面:
  • 设置、键值存储 + SQLite 存储、HTTP、RPC、实时通信
  • 后台服务与定时任务
  • 一个顶级
    bb <name> …
    命令
  • Agent 工具、
    skills/
    文件夹、额外指令
  • 提及提供程序
  • 可选的主机 worker 和实验性 Agent 提供程序
app.tsx
中的默认导出
definePluginApp
可添加页面、线程面板操作、编辑器控件、文件打开器,以及自定义侧边栏。
请勿将完整 API 复制到本技能中。实现功能面时请查阅
bb-plugin-authoring
技能。

Install and ship

安装与发布

sh
bb plugin install .                                 # local path
bb plugin install github                            # bundled official plugin
bb plugin install npm:bb-plugin-notes@^1.0.0
bb plugin install git:https://github.com/acme/bb-plugin-notes.git@^1.2.0
bb plugin list
bb plugin reload <id>
bb plugin logs <id> -f
Installs prompt because the code is full-trust. Pass
--yes
to skip.
A failed managed update rolls back. Catalog refresh never installs code.
Community listings live at https://getbb.app/marketplace/v1/marketplace.json. Submit via a PR to https://github.com/get-bb/marketplace. Use the
submit-a-plugin
skill for that workflow.
sh
bb plugin install .                                 # 本地路径
bb plugin install github                            # 官方捆绑插件
bb plugin install npm:bb-plugin-notes@^1.0.0
bb plugin install git:https://github.com/acme/bb-plugin-notes.git@^1.2.0
bb plugin list
bb plugin reload <id>
bb plugin logs <id> -f
安装时会弹出提示(因为代码拥有完全权限),可添加
--yes
参数跳过提示。
失败的托管更新会回滚。目录刷新不会自动安装代码。
社区插件列表位于 https://getbb.app/marketplace/v1/marketplace.json。可通过向 https://github.com/get-bb/marketplace 提交 PR 来发布插件,该流程可使用
submit-a-plugin
技能。

Check the work

验证工作成果

  1. bb plugin list
    shows the plugin
    running
    .
  2. If it added a CLI,
    bb <command> --help
    works.
  3. If it added UI, open the page or panel in bb and confirm it loads.
  4. If the factory throws, the plugin is
    error
    . Read
    bb plugin logs <id>
    and fix, then
    bb plugin reload <id>
    .
  1. bb plugin list
    显示插件状态为
    running
  2. 若插件添加了 CLI 命令,
    bb <command> --help
    可正常运行。
  3. 若插件添加了 UI,在 bb 中打开对应的页面或面板,确认可正常加载。
  4. 若工厂函数抛出错误,插件状态为
    error
    。查看
    bb plugin logs <id>
    并修复问题,然后运行
    bb plugin reload <id>