Bili Rs
/install bili-rs
bili-rs Development Skill
Rust rewrite of bilibili-cli. Single binary, no runtime deps. Full feature parity with the Python original.
Architecture (strict layering)
cli/ (clap structs only) → commands/ (business logic) → client/ (HTTP async fn)
↓
payloads/ (normalize raw JSON → structs)
↓
formatter.rs (JSON/YAML/Rich output)
Rules:
cli/— clap derive structs only, zero business logiccommands/— callsclient/, never builds HTTP requests directlyclient/— never imports clap or formatter
Adding a New Command
- Add clap struct in
src/cli/\x3Cdomain>.rs - Add handler in
src/commands/\x3Cdomain>.rs - Add API call(s) in
src/client/\x3Cdomain>.rs - Add payload normalizer in
src/payloads/\x3Cdomain>.rsif needed - Wire into
src/main.rsrun()match arm
Key Patterns
Error handling
// client/ layer: always map API errors
let code = body["code"].as_i64().unwrap_or(-1);
if code != 0 {
return Err(map_api_error(code, body["message"].as_str().unwrap_or("unknown")));
}
// commands/ layer
match result {
Ok(data) => formatter::output(data, format),
Err(e) => { emit_error(&e, format); std::process::exit(1); }
}
Output envelope (never change the field names)
SuccessEnvelope { ok: true, schema_version: "1", data: T }
ErrorEnvelope { ok: false, schema_version: "1", error: ErrorBody }
Output format resolution
--json > --yaml > $OUTPUT env var > TTY→Rich / non-TTY→YAML
Authentication levels
Optional— load saved creds if available, don't fail if missingRead— requires SESSDATAWrite— requires SESSDATA + bili_jct
Credential file: ~/.bilibili-cli/credential.json (0o600, 7-day TTL)
WBI Signature
Some Bilibili endpoints require a WBI request signature (a per-request HMAC-like parameter). Use src/client/wbi.rs:
let (img_key, sub_key) = fetch_wbi_keys(cred).await?;
let params = sign_params(vec![("bvid".to_string(), bvid)], &img_key, &sub_key);
req = req.query(¶ms);
Known endpoints needing WBI: /x/web-interface/view/conclusion/get
Output & Terminal
- Status/errors → stderr with
console::style - Data → stdout as table (
comfy-table) or JSON/YAML - Counts ≥ 10000 →
"X.X万"format
Quality Gate (run before every commit)
cargo build && cargo clippy -- -D warnings && cargo fmt --check && cargo test
References
- All CLI commands & options: See references/commands.md
- API endpoints & payloads: See references/api.md
- Full project spec:
PRD.mdin project root - Implementation conventions:
CLAUDE.mdin project root
- 确保已安装 OpenClaw(本地或 Docker 部署)
- 在对话框中输入安装命令:
/install bili-rs - 安装完成后,直接呼叫该 Skill 的名称或使用
/bili-rs触发 - 根据 Skill 的参数说明提供必要输入,即可获得结构化输出
Bili Rs 是什么?
Development skill for bili-rs, a Rust CLI tool for Bilibili (B站). Use when implementing features, fixing bugs, or extending the bilibili-cli-rust codebase. P... 它是一个面向 Claude Code / OpenClaw 的 AI Agent Skill 插件,目前累计下载 177 次。
如何安装 Bili Rs?
在 OpenClaw 或 Claude Code 对话框中运行命令「/install bili-rs」即可一键安装,无需额外配置。
Bili Rs 是免费的吗?
是的,Bili Rs 完全免费,采用 MIT-0 许可证,可自由下载、安装和使用。
Bili Rs 支持哪些平台?
Bili Rs 跨平台运行,可在任意部署了 OpenClaw / Claude Code 的环境中使用(cross-platform)。
谁开发了 Bili Rs?
由 18621063286(@18621063286)开发并维护,当前版本 v1.0.1。