Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

建议:新增 bl completion <shell> 命令,提供 zsh/bash/fish 自动补全

Đang mở
#286 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức phù hợp với người mới
55/100
Loại issue
Tính năng
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
bash, fish, node.js, shell, typescript, zsh

Hướng nghiên cứu

Run bl --introspect and read where the existing skill/reference generators consume that metadata under packages/cli; the new completion subcommand and its introspect→shell conversion layer belong alongside them. Build the zsh path first against the issue's acceptance cases (bl text ch<TAB>, --api <TAB> listing choices, --outpu<TAB>), then reuse the same conversion for bash and fish, and add choices for --output to globalFlags in the introspect schema. Done when pnpm check passes and every acceptance example completes; coordinate with the reporter, who has a working local prototype.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

背景

bl 目前没有 shell 补全命令(bl completion 报 Unknown command),322 个多级子命令(如 memory node show、agents security alerts)加上每个命令十几个 flag,纯靠手敲和 --help 记忆成本比较高。

现状
  • bl --introspect 已经输出结构化的命令元数据(commands[].path / flags / choices / description,globalFlags),天然适合作为补全的数据源,但目前只有 skill/reference 生成在消费它。
  • issues 里没有找到补全相关的既有讨论。
提议

新增顶层命令:

bl completion <zsh|bash|fish>          # 输出补全脚本到 stdout(可重定向)
bl completion zsh --install            # (可选)自动写入 rc 文件

数据流复用 --introspect:

introspect JSON → 转换层 → 各 shell 的补全脚本/函数

zsh 侧的转换规则(已在本地验证可行):

introspect 字段 zsh spec
flags.choices: [chat, responses] '--api[desc]:value:(chat responses)'
type: switch '--stream[desc]'
valueHint 含 path/file ':file:_files'
其他 string '--message[desc]:value:'

多级命令用「收集已输入的非 flag 词 → 前缀匹配 → 前缀组补下一级 / 叶子命令补 flags」的 dispatch 即可,不需要为每个命令写死函数。

实现时值得注意的两个坑(本地原型踩过)
  1. zsh _arguments 里消费已输入子命令的占位 positional 必须写成 'N:cmd:'(带尾冒号、空 action);写成 'N:cmd' 会被当成可补全位置参数,与 flag 候选形成"二义",导致单次 TAB 只列出不插入。
  2. flag 描述文本需要双层转义:shell 引号层 + _arguments 描述层的 ] 和 :(zh-CN 描述里的全角冒号没事,但半角冒号会截断 spec)。
顺带发现的数据缺口

--introspect 的 globalFlags 里 --output 没有带 choices: ["text", "json"],补全只能硬编码。建议在 schema 里补上这个字段,任何消费方都能受益。

验收示例(以 zsh 为例)
bl text ch<TAB>            → bl text chat
bl text chat --sys<TAB>    → --system(列出时带描述)
bl text chat --api <TAB>   → chat / responses
bl --outpu<TAB>            → --output
备注

我已按上述思路在本地基于 bl --introspect 生成 zsh 补全并逐项验证通过(bl 2.6.1,322 命令 / 81 命令组)。如果这个方向可行,我愿意提交 PR 把转换层按仓库结构(packages/cli + 单一逻辑改动 + pnpm check)实现。

Ngôn ngữ chính
TypeScript
Star
364
Fork
32
Merge trung bình
1 ngày 2 giờ
Pull request đã merge (30 ngày)
33

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của modelstudioai/cli

Tất cả issue của modelstudioai/cli

Issue tương tự

Thêm issue về TypeScript

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.