@bunli/plugin-completions

中文文档
0.3.5发布于 2026/03/28MITTypeScriptES Module近 30 天下载 3220

Shell completions plugin for Bunli CLI framework

原始使用文档
文档目录13 节
  1. Install
  2. Setup
  3. Commands
  4. Generate a completion script
  5. Dynamic completion protocol callback (used by the shell scr…
  6. Shell Setup Examples
  7. Bash
  8. Zsh
  9. Fish
  10. PowerShell
  11. Notes
  12. Runtime packaging
  13. @bomb.sh/tab types note

@bunli/plugin-completions

Tab-powered shell completions for Bunli CLIs.

This plugin delegates script generation and the dynamic completion protocol (complete -- <args>) to @bomb.sh/tab, and builds Tab’s command tree from Bunli’s generated metadata (.bunli/commands.gen.ts).

Install

bun add @bunli/plugin-completions

Setup

import { defineConfig } from '@bunli/core'
import { completionsPlugin } from '@bunli/plugin-completions'

export default defineConfig({
  name: 'my-cli',
  plugins: [
    completionsPlugin({
      // generatedPath: '.bunli/commands.gen.ts',
      // commandName: 'my-cli',
      // executable: 'my-cli',
      // includeAliases: true,
      // includeGlobalFlags: true
    })
  ]
})

You must have .bunli/commands.gen.ts available (run bunli generate, or enable codegen in your build).

Commands

Generate a completion script

my-cli completions zsh
my-cli completions bash
my-cli completions fish
my-cli completions powershell

Dynamic completion protocol callback (used by the shell scripts)

my-cli complete -- <args...>

Do not build your own integrations on Bunli’s parsed positional args for this path: Tab relies on a trailing empty-string sentinel ('') to detect “ends with space”, and Bunli’s parser drops empty strings. The implementation uses runtime.args directly.

Shell Setup Examples

Bash

source <(my-cli completions bash)

Zsh

source <(my-cli completions zsh)

Fish

my-cli completions fish > ~/.config/fish/completions/my-cli.fish

PowerShell

my-cli completions powershell | Out-String | Invoke-Expression

Notes

Runtime packaging

@bunli/plugin-completions publishes a bundled runtime (dist/index.js) that already includes Tab. Downstream consumers only install @bunli/plugin-completions and do not need a separate runtime dependency on @bomb.sh/tab.

@bomb.sh/tab types note

As of @bomb.sh/[email protected], the published package references dist/t.d.ts but ships only dist/t-<hash>.d.ts. Bunli’s monorepo uses bun patch during development/CI to keep TypeScript builds unblocked until upstream fixes packaging.

版本与发布记录

@bunli/plugin-completions 共发布 12 个版本,首次发布于 2026/01/30;过去 12 个月发布了 12 个版本。

版本发布日期距今
0.3.5latest2026/03/287 个月前
0.3.42026/03/048 个月前
0.3.32026/03/018 个月前
0.3.22026/03/018 个月前
0.3.12026/02/278 个月前
0.3.02026/02/278 个月前

关于 @bunli/plugin-completions 的常见问题

@bunli/plugin-completions 是什么?

Shell completions plugin for Bunli CLI framework

如何安装 @bunli/plugin-completions?

在项目目录运行 npm install @bunli/plugin-completions,或使用 pnpm add / yarn add / bun add。

@bunli/plugin-completions 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@bunli/plugin-completions 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@bunli/plugin-completions 可以商用吗?

@bunli/plugin-completions 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@bunli/plugin-completions 的下载量有多少?

根据 npm 官方下载统计,@bunli/plugin-completions 在 2026/10/09 – 2026/11/07 这 30 天内被下载 3,220 次,日均约 107 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@bunli/plugin-completions 还在维护吗?

最新版本 0.3.5 发布于 2026/03/28(7 个月前);至今共发布 12 个版本,其中过去 12 个月发布了 12 个;首次发布于 2026/01/30。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。