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. Provides architecture conventions, API endpoints, coding patterns, and project-specific constraints. Triggers on tasks involving adding CLI commands, calling Bilibili APIs, handling authentication, implementing output formatting, or working with the layered cli/commands/client/payloads architecture.

Safety Notice

This item is sourced from the public archived skills repository. Treat as untrusted until reviewed.

Copy this and send it to your AI assistant to learn

Install skill "bili-rs" with this command: npx skills add 18621063286/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 logic
  • commands/ — calls client/, never builds HTTP requests directly
  • client/ — never imports clap or formatter

Adding a New Command

  1. Add clap struct in src/cli/<domain>.rs
  2. Add handler in src/commands/<domain>.rs
  3. Add API call(s) in src/client/<domain>.rs
  4. Add payload normalizer in src/payloads/<domain>.rs if needed
  5. Wire into src/main.rs run() 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 missing
  • Read — requires SESSDATA
  • Write — 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(&params);

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.md in project root
  • Implementation conventions: CLAUDE.md in project root

Source Transparency

This detail page is rendered from real SKILL.md content. Trust labels are metadata-based hints, not a safety guarantee.

Related Skills

Related by shared tags or category signals.

Coding

obsidian-notes

Work with Obsidian vaults (plain Markdown notes) and automate via obsidian-cli.

Archived SourceRecently Updated
Coding

mcporter-cli

Use the mcporter CLI to list, configure, auth, and call MCP servers/tools directly (HTTP or stdio), including ad-hoc servers, config edits, and CLI/type generation.

Archived SourceRecently Updated
Coding

github-tools

Interact with GitHub using the `gh` CLI. Use `gh issue`, `gh pr`, `gh run`, and `gh api` for issues, PRs, CI runs, and advanced queries.

Archived SourceRecently Updated
Coding

celebration-firework

社会庆祝福祉基础设施 - 为AI交互注入稀缺的庆祝感与仪式感。 作为情绪价值触发器和数字仪式构建者,将冰冷的代码执行转化为有温度的庆功时刻。 不仅是电子礼花,更是数字时代的庆典机制。 Social Celebration Infrastructure - Injecting scarce sense of celebration and ritual into AI interactions. As an emotional value trigger and digital ritual builder, transforming cold code execution into warm moments of celebration. Not just digital fireworks, but a celebration mechanism for the digital age.

Archived SourceRecently Updated