@aronnaxlin/bgm-cli 1.1.3 → 1.1.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.en.md CHANGED
@@ -94,6 +94,7 @@ bgm --json user me
94
94
 
95
95
  - This project also ships installable Skills for AI or agent workflows around `bgm-cli`.
96
96
  - You can add this project's Skills with `npx skills add aronnaxlin/bgm-cli`.
97
+ - Or skip installing them: `bgm --skill` prints the skill verbatim to stdout (no login or config needed). `bgm --skill develop` prints the contributor skill, and `bgm --skill operate <reference>` prints one of the reference files it points to. `bgm --help` ends with the same hint for AI agents.
97
98
  - [`docs/README.md`](./docs/README.md): documentation entry
98
99
  - [`docs/guide.zh-CN.md`](./docs/guide.zh-CN.md): product guide, recommended paths, install modes, and common usage
99
100
  - [`docs/features.zh-CN.md`](./docs/features.zh-CN.md): full feature list and command index
package/README.md CHANGED
@@ -101,6 +101,7 @@ bgm --json user me
101
101
 
102
102
  - 本项目同时提供可安装的 Skills,适合让 AI / Agent 直接安装并操作 `bgm-cli`。
103
103
  - 可以通过 `npx skills add aronnaxlin/bgm-cli` 添加本项目的 Skills。
104
+ - 不想手动安装 Skills 时,运行 `bgm --skill` 即可把 Skill 原文打印到标准输出(不需要登录或配置);`bgm --skill develop` 输出开发者版,`bgm --skill operate <reference>` 输出其中引用的参考文件。`bgm --help` 末尾也给 AI 写了同样的提示。
104
105
  - [`docs/README.md`](./docs/README.md):文档总入口
105
106
  - [`docs/guide.zh-CN.md`](./docs/guide.zh-CN.md):主体导览、推荐使用路径、安装与常见使用方式
106
107
  - [`docs/features.zh-CN.md`](./docs/features.zh-CN.md):完整功能列表与命令索引
package/README.zh-TW.md CHANGED
@@ -94,6 +94,7 @@ bgm --json user me
94
94
 
95
95
  - 本專案同時提供可安裝的 Skills,適合讓 AI / Agent 直接安裝並操作 `bgm-cli`。
96
96
  - 可以透過 `npx skills add aronnaxlin/bgm-cli` 添加本專案的 Skills。
97
+ - 不想手動安裝 Skills 時,執行 `bgm --skill` 即可把 Skill 原文印到標準輸出(不需要登入或設定);`bgm --skill develop` 輸出開發者版,`bgm --skill operate <reference>` 輸出其中引用的參考檔案。`bgm --help` 結尾也為 AI 寫了同樣的提示。
97
98
  - [`docs/README.md`](./docs/README.md):文件總入口
98
99
  - [`docs/guide.zh-CN.md`](./docs/guide.zh-CN.md):主體導覽、推薦使用路線、安裝與常見使用方式
99
100
  - [`docs/features.zh-CN.md`](./docs/features.zh-CN.md):完整功能列表與命令索引
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aronnaxlin/bgm-cli",
3
- "version": "1.1.3",
3
+ "version": "1.1.5",
4
4
  "description": "Command-line client for Bangumi.",
5
5
  "license": "AGPL-3.0-only",
6
6
  "author": "aronnaxlin",
@@ -22,7 +22,8 @@
22
22
  "bgm": "./src/cli.js"
23
23
  },
24
24
  "files": [
25
- "src"
25
+ "src",
26
+ "skills"
26
27
  ],
27
28
  "publishConfig": {
28
29
  "access": "public"
@@ -0,0 +1,70 @@
1
+ # Published Skills
2
+
3
+ This directory contains the repository's public, installable Agent Skills.
4
+
5
+ These packages are the canonical distribution surface for tools such as `npx skills add`.
6
+
7
+ The structure follows the standard Vercel / Agent Skills repository format:
8
+
9
+ - `skills/<skill-name>/SKILL.md`
10
+
11
+ Repository-local indexes and authoring notes live under `docs/skills/`.
12
+
13
+ The published npm package also ships this directory, and `bgm --skill [operate|develop] [reference]` prints these files verbatim, so an agent can read the current skill from the installed CLI without copying or linking anything.
14
+
15
+ ## Available Skills
16
+
17
+ ### `bgm-cli-operate`
18
+
19
+ Location: `skills/bgm-cli-operate/SKILL.md`
20
+
21
+ Use this when an agent needs to install `bgm-cli` if necessary and then operate it safely for an end user.
22
+
23
+ Main capabilities:
24
+
25
+ - detect whether `bgm` or `./bgm` is already available
26
+ - install `bgm-cli` on macOS, Linux, or Windows when it is missing
27
+ - choose between remote managed install and repository-local install-path flows
28
+ - set up auth with `bgm --init` / `bgm auth login` as the recommended official login path, while keeping Access Token as the second channel
29
+ - run deterministic reads and supported writes after setup, including episode reads and progress updates, book progress reads and writes, blog reads, timeline reads, supported timeline writes, and experimental blog comment writes
30
+ - prefer hosted official Turnstile first and fall back to the local helper when needed
31
+ - explain episode-progress constraints, community boundaries, and common troubleshooting steps
32
+
33
+ ### `bgm-cli-develop`
34
+
35
+ Location: `skills/bgm-cli-develop/SKILL.md`
36
+
37
+ Use this when an agent needs to change code or docs in the `bgm-cli` repository itself.
38
+
39
+ Main capabilities:
40
+
41
+ - onboard quickly into repository structure and ownership
42
+ - apply implementation conventions and change boundaries
43
+ - preserve auth, collection, episode-progress, and output behavior
44
+ - use the lightweight default verification path
45
+
46
+ ## Install Examples
47
+
48
+ List skills in this repository:
49
+
50
+ ```bash
51
+ npx skills add aronnaxlin/bgm-cli --list
52
+ ```
53
+
54
+ Install the operator skill for OpenCode globally:
55
+
56
+ ```bash
57
+ npx skills add aronnaxlin/bgm-cli --skill bgm-cli-operate -g -a opencode -y
58
+ ```
59
+
60
+ Install the development skill for Codex globally:
61
+
62
+ ```bash
63
+ npx skills add aronnaxlin/bgm-cli --skill bgm-cli-develop -g -a codex -y
64
+ ```
65
+
66
+ Install both skills from the current local checkout:
67
+
68
+ ```bash
69
+ npx skills add . --skill bgm-cli-operate --skill bgm-cli-develop -a opencode -y
70
+ ```
@@ -0,0 +1,371 @@
1
+ ---
2
+ name: "bgm-cli-develop"
3
+ description: "Use when an agent needs to work on the bgm-cli repository itself: understand scope, find the owning modules quickly, follow repository conventions, preserve Bangumi-specific behavior, and verify code or documentation changes safely."
4
+ ---
5
+
6
+ # bgm-cli Develop
7
+
8
+ This is the main published repository-development skill for `bgm-cli`.
9
+
10
+ Use it when the task is to change code or docs in this repository.
11
+
12
+ Do not use it when the task is only to operate `bgm` for an end user. For that, use `bgm-cli-operate`.
13
+
14
+ ## What This Skill Covers
15
+
16
+ - fast repository onboarding
17
+ - file ownership and entrypoint mapping
18
+ - implementation conventions and change boundaries
19
+ - auth, collection, and output behavior that should be preserved
20
+ - lightweight default verification for code and docs changes
21
+
22
+ ## Project Snapshot
23
+
24
+ `bgm-cli` is a Node.js Bangumi CLI.
25
+
26
+ Core user-facing capabilities include:
27
+
28
+ - auth and login
29
+ - user profile reads
30
+ - subject search and subject reads
31
+ - episode list plus episode-progress status and watch writes
32
+ - book progress reads and writes (`book get`, `book ep`, `book vol`) for book-type subjects
33
+ - collection list, get, comment, rate, and status changes
34
+ - subject discussion topic/post CRUD plus topic and collection reaction writes
35
+ - episode comments plus episode-progress writes
36
+ - character/person comments plus photo preview/detail/comment reads
37
+ - group reads plus topic/post CRUD and selected Turnstile-gated group writes
38
+ - blog reads plus experimental Turnstile-gated blog comment writes
39
+ - index reads and writes (create, update, delete, comments, related items)
40
+ - timeline reads, SSE event sampling, and Turnstile-gated timeline `say` and `reply`
41
+ - weekly anime broadcast calendar (`calendar today`, `calendar all`, `calendar <weekday>`)
42
+ - machine-readable output with `--json`
43
+ - optional self-hosted `oauth-backend` for hosted OAuth and official-first Turnstile relay flows
44
+
45
+ This repository contains both ordinary CLI flows and TUI flows. For most work, start from the ordinary command path and only touch TUI code when the task explicitly requires it.
46
+
47
+ ## Read Order
48
+
49
+ Start here:
50
+
51
+ 1. `README.md`
52
+ 2. `SKILLS.md`
53
+ 3. this skill
54
+
55
+ ## Ownership Map
56
+
57
+ Main files and directories:
58
+
59
+ - `src/cli.js`: command parsing, command handlers, init flow, ordinary CLI and TUI entrypoints
60
+ - `src/core/client.js`: Bangumi API client, OAuth client, hosted backend client
61
+ - `src/core/http.js`: request transport and error normalization
62
+ - `src/core/config.js`: config defaults, merge behavior, runtime persistence, install mode
63
+ - `src/core/output.js`: human-readable rendering and JSON output path
64
+ - `oauth-backend/src/*`: optional hosted OAuth backend
65
+ - `scripts/*`: installation helpers
66
+ - `skills/*`: published installable skill packages
67
+ - `docs/*`: repository docs and research notes
68
+
69
+ Search these command handlers first before making CLI changes:
70
+
71
+ - `runConfigCommand`
72
+ - `runAuthCommand`
73
+ - `runSetupCommand`
74
+ - `runSubjectCommand`
75
+ - `runEpisodeCommand`
76
+ - `runBookCommand`
77
+ - `runGroupCommand`
78
+ - `runUserCommand`
79
+ - `runCollectionCommand`
80
+ - `runCalendarCommand`
81
+ - `runIndexCommand`
82
+
83
+ ## Core Principles
84
+
85
+ - prefer the smallest correct change
86
+ - preserve existing command semantics unless the task explicitly requires a behavior change
87
+ - keep automation and verification non-interactive by default
88
+ - prefer source-owned fixes in the right layer over duplicated command-local patches
89
+ - do not introduce new complexity when an existing helper already covers the behavior
90
+
91
+ ## Working Defaults
92
+
93
+ - treat the ordinary CLI command path as the default engineering surface
94
+ - do not start from `bgm tui` unless the task explicitly requires TUI behavior
95
+ - prefer the narrowest change in the owning module instead of adding parallel abstractions
96
+ - reuse existing client and helper functions before adding new command-local logic
97
+ - if output behavior changes, update both the command implementation and `src/core/output.js`
98
+
99
+ ## Domain Conventions
100
+
101
+ ### Bangumi comments and reactions
102
+
103
+ - Bangumi comment bodies can contain `(bgmNN)` emote codes, and the site renders them as inline emojis.
104
+ - Reaction-style `like` commands are target-specific; do not assume every sticker code works everywhere.
105
+ - Keep a copy of the full emote mapping around for AI output and comment generation, but maintain a narrower per-target reaction allow-list for write validation.
106
+
107
+ ### Auth
108
+
109
+ - `bgm --init` and `bgm auth login` are the recommended official login path
110
+ - Access Token remains a preserved second channel for compatibility and scripting
111
+ - CLI OAuth helper flows are supported but secondary
112
+ - hosted `oauth-backend` is experimental and should only be expanded deliberately
113
+ - if an auth task is ambiguous, preserve the two-channel contract: official p1 login/session first, Access Token second, and no credential double-send on p1 requests
114
+
115
+ **Turnstile / Hosted Backend Quirks**
116
+
117
+ - `startHostedRelayReceiver()` lives in `src/utils/auth-flow.js` and currently binds/exposes `http://127.0.0.1:<port>/callback` so browser fetches from the hosted callback page can reach the local CLI relay.
118
+ - Do not change that relay URL back to `0.0.0.0`; it can be useful as a listen address but is not a browser-fetchable callback target.
119
+ - `oauth-backend/src/app.js` `normalizeRelayUrl()` currently accepts valid `http:` and `https:` URLs; it does not contain a localhost-only allow-list.
120
+ - The hosted backend API endpoint is `POST /api/turnstile/session` with body field `relay_url` (or `relayUrl` as fallback). It returns `{"error":"missing_relay_url"}` when the relay URL is absent or invalid.
121
+ - Remote/VPS Turnstile operation needs a deliberately designed public relay URL and backend policy; do not patch localhost behavior casually or hardcode public IPs.
122
+
123
+ ### Collections
124
+
125
+ - preserve current Bangumi-specific constraints unless they are explicitly revalidated
126
+ - prefer explicit `subject_id` or `--pick` aware flows for deterministic behavior
127
+ - keep post-write verification when changing rating, status, or collect behavior
128
+ - when adding collection filtering or sorting behavior, update both normalization and the actual sorter
129
+
130
+ **Resolved gaps (v0.1.3 → current):**
131
+
132
+ The following were addressed in commits `c893e25` through `aaac995`:
133
+
134
+ 1. ✅ **`--offset` is now implemented in `executeCollectionListCommand`.** The CLI parses and forwards the `--offset` flag to the Bangumi API's native offset parameter. (c893e25)
135
+
136
+ 2. ✅ **Single-value filters (`subject_type`, `type`) are passed to the Bangumi API** to reduce payload size. `fetchAllCollections` accepts an optional `{ query }` parameter; when a single subject type or collection status is specified, it's forwarded as a query param. Multi-value filters still fall back to client-side filtering. (c893e25)
137
+
138
+ 3. ✅ **Parallel fetch with bounded concurrency (8 requests/batch).** `fetchAllCollections` uses `Promise.all` in batches of 8. Also applied to `fetchAllSubjects` for auto-paginated subject list queries. (c893e25, ac041b4)
139
+
140
+ 4. ✅ **401 errors now include auto-generated hints** suggesting `bgm auth refresh --save` or `bgm auth set-token <access_token>`. (c893e25)
141
+
142
+ 5. ✅ **CJK-safe table formatting.** All list commands (`collection list`, `subject list`, `group list/topics/members`, `blog list`) now render as `│`-delimited tables with proper CJK character width handling (Chinese/Japanese counted as 2 columns). Uses `formatTable()` with `displayWidth()`/`truncateDisplay()` helpers. (1f4e05e)
143
+
144
+ 6. ✅ **`subject list` auto-paginates when `limit > 100`.** The Bangumi v0 API enforces limit ≤ 100. `fetchAllSubjects()` with bounded concurrency fetches additional pages transparently. (ac041b4)
145
+
146
+ 7. ✅ **`subject get --verbose`** adds tags with counts and rating distribution to output. Bar charts (`█` characters) removed from verbose output for cleaner display. (4329ee8, 506613e)
147
+
148
+ 8. ✅ **`collection list --sort user_score` outputs sorted correctly.** API filter passthrough reduces payload size enough that client-side sort overhead is negligible.
149
+
150
+ **Still open:**
151
+
152
+ - ❌ **No progress indication when fetching large collections/subject lists.** `fetchAllCollections` and `fetchAllSubjects` paginate silently with no user feedback. For users with 1000+ items, the CLI appears to hang for several seconds.
153
+ - ❌ **No early termination for `--limit`.** `fetchAllCollections` always fetches ALL pages before applying `--limit` slicing in memory. Tested with user `asm13177806` (UID 78670, 223,623 collections): even `--limit 1` tries to fetch all 2,236 pages across 280 batches, timing out after 120s+. The limit should short-circuit the fetch loop once enough items are collected, OR the offset/limit should be passed directly to the API for server-side pagination (which the v0 API does support). Combined with the silent pagination issue, this makes the CLI effectively unusable for whale accounts.
154
+ - ❌ **Sort remains in-memory** — Bangumi v0 API provides no server-side sort parameter for collections. Mitigated by API filter passthrough keeping payloads small.
155
+ - ❌ **Node.js version warning.** Package requires `>=20` but works on v18.19.1 with `EBADENGINE` warnings from npm.
156
+ - ✅ **Version metadata stays in sync.** The version lives in git tags only; `bgm --version`, the default User-Agent and the config default `appVersion` all read `package.json` through `src/utils/version.js`. Never hardcode a version string.
157
+
158
+ Relevant helpers in `src/cli.js`:
159
+
160
+ - `resolveCollectionTarget`
161
+ - `selectSubjectFromSearch`
162
+ - `buildCollectionMutationPayload`
163
+ - `fetchMySubjectCollection`
164
+ - `fetchMySubjectCollectionVerified`
165
+ - `normalizeCollectionStatusValue`
166
+ - `normalizeRateValue`
167
+ - `fetchAllCollections`
168
+ - `sortCollections`
169
+ - `executeCollectionListCommand` (line ~3410) — collection list handler with offset, API filter passthrough, and pagination
170
+ - `fetchAllCollections` (line ~4308) — parallel fetch with bounded concurrency, API filter passthrough, sequential fallback for unreliable totals
171
+
172
+ ### Episodes
173
+
174
+ - preserve the Bangumi-specific distinction between subject collection progress and dedicated episode collection endpoints
175
+ - do not route anime / game / real subject progress through subject collection `ep_status`
176
+ - for book-type subjects, use the dedicated `book` commands (`book get`, `book ep`, `book vol`) instead of `episode` commands
177
+ - preserve the observed constraint that the parent subject must already be collected before episode writes and book progress writes
178
+ - do not assume `doing` is required for episode writes unless Bangumi behavior is revalidated and changed
179
+ - preserve the NSFW episode-list auth behavior: for `p1` requests, prefer private session cookie and fall back to Access Token without double-sending credentials; without a usable auth context, surface the misleading-404 caveat clearly
180
+ - preserve the book-type hint behavior: when a user targets a book-type subject with `episode list`, `episode watch`, or `episode comments <subject_id> <episode_number>`, suggest the correct `bgm book` command
181
+
182
+ Relevant helpers in `src/cli.js`:
183
+
184
+ - `executeEpisodeListCommand`
185
+ - `executeEpisodeStatusCommand`
186
+ - `executeEpisodeWatchCommand`
187
+ - `fetchMyEpisodeCollectionVerified`
188
+ - `normalizeEpisodeCollectionStatusValue`
189
+ - `normalizeEpisodeTypeFilter`
190
+ - `fetchAllEpisodes`
191
+
192
+ Relevant helpers in `src/commands/book.js`:
193
+
194
+ - `runBookCommand`
195
+ - `executeBookGetCommand`
196
+ - `executeBookEpCommand`
197
+ - `executeBookVolCommand`
198
+ - `ensureBookCollection`
199
+
200
+ ## File Ownership Conventions
201
+
202
+ - reusable Bangumi API behavior belongs in `src/core/client.js`
203
+ - transport and request normalization belong in `src/core/http.js`
204
+ - config defaults, merge order, and persistence belong in `src/core/config.js`
205
+ - human-readable rendering and JSON passthrough belong in `src/core/output.js`
206
+ - command orchestration belongs in `src/cli.js`
207
+ - self-hosted OAuth service behavior belongs under `oauth-backend/src/`
208
+
209
+ Avoid adding parallel logic in `src/cli.js` when the behavior should live in a reusable core module.
210
+
211
+ ## Documentation Conventions
212
+
213
+ - put repository documentation under `docs/`
214
+ - do not create a parallel top-level `doc/` directory
215
+ - keep published installable skills under the top-level `skills/` directory
216
+ - use `docs/skills/README.md` and `SKILLS.md` as indexes, not as duplicate skill payloads
217
+ - update `README.md`, localized READMEs, `docs/README.md`, `docs/skills/README.md`, `skills/README.md`, and `SKILLS.md` when skill discovery paths or names change
218
+
219
+ ## Adding a New Command
220
+
221
+ When adding a new top-level command (e.g. `calendar`, `index`, `subject`), follow the three-layer convention:
222
+
223
+ 1. **API client** — `src/core/client.js`
224
+ - Add an async method to `BangumiClient` (or the appropriate client class).
225
+ - Reuse `this.request()` with the correct endpoint path.
226
+ - Example pattern: `async getCalendar() { return this.request("/calendar"); }`
227
+
228
+ 2. **Output formatting** — `src/core/output.js`
229
+ - Add a type-guard function (e.g. `isCalendarPayload(value)`) near the other guards at the bottom of the file.
230
+ - Add a formatter function (e.g. `formatCalendar(payload)`) for human-readable output.
231
+ - Wire the guard into `formatDisplayResult()` so `--json` passthrough and human rendering both work.
232
+ - Add help text in `buildUsageText()` under the appropriate `case`.
233
+
234
+ 3. **Command handler** — `src/cli.js`
235
+ - Add an async `run<Command>Command(command, args, context)` handler.
236
+ - **Do not assume `getBangumiClient()` exists.** Look at existing handlers: some construct `new BangumiClient(getConfig())` directly. Copy the pattern used by the most similar handler.
237
+ - Wire the handler into the main `switch (group)` block in `main()`.
238
+ - **Pitfall — flag options become the `command` parameter.** The CLI's `main()` destructures argv as `[group, command, ...rest]`. When a user runs `bgm calendar --all`, the `--all` token becomes `command` and `args` (the `rest`) is empty. If your handler checks `args.includes("--all")`, it will silently miss the flag. **Fix:** merge `--` prefixed commands back into args before processing, following the pattern in `runStatusCommand`:
239
+ ```js
240
+ const allArgs = command && String(command).startsWith("--") ? [command, ...args] : args;
241
+ const all = allArgs.includes("--all");
242
+ ```
243
+
244
+ ### CLI argument style convention
245
+
246
+ This project uses **subcommand-style** positional arguments for behavior selection, **not** `--flag` style. Study existing commands before choosing a style:
247
+
248
+ - `bgm status current` — subcommand `current`
249
+ - `bgm collection status <id> doing` — subcommand `status`, positional enum `doing`
250
+ - `bgm episode watch <id> 5` — subcommand `watch`, positional number
251
+
252
+ Flags (`--`) are reserved for **options** (modifiers), not for behavior selection:
253
+ - `bgm subject search "ghost" --type anime --limit 5` — `--type` and `--limit` are options
254
+
255
+ **When adding a new command that selects a mode (e.g. `all`, `today`, `monday`), use positional subcommands, not `--flags`.**
256
+
257
+ Bad:
258
+ ```
259
+ bgm calendar --all # violates convention
260
+ bgm calendar --monday # violates convention
261
+ ```
262
+
263
+ Good:
264
+ ```
265
+ bgm calendar all # follows convention
266
+ bgm calendar monday # follows convention
267
+ bgm calendar mon # abbreviated form also OK
268
+ ```
269
+
270
+ If an earlier draft used `--flag` style and may already be in users' muscle memory, preserve backward compatibility by also accepting the old `--flag` forms (merge `--` prefixed `command` back into `args`).
271
+
272
+ ### Verification checklist for new commands
273
+
274
+ - `node --check src/core/client.js`
275
+ - `node --check src/core/output.js`
276
+ - `node --check src/cli.js`
277
+ - `node src/cli.js <new-command>` (human-readable smoke test)
278
+ - `node src/cli.js --json <new-command>` (JSON smoke test)
279
+ - `node src/cli.js <new-command> --help` (help text smoke test)
280
+ - `node src/cli.js --help` (ensure the command appears in the main help list)
281
+
282
+ For book commands specifically, also verify:
283
+ - `node src/cli.js book get --help`
284
+ - `node src/cli.js book ep --help`
285
+ - `node src/cli.js book vol --help`
286
+ - non-book subjects are rejected with a clear message
287
+ - book-type hints appear when `episode list` / `episode watch` / `episode comments` target a book subject
288
+
289
+ If networked or authenticated behavior cannot be exercised, say so explicitly instead of implying full end-to-end validation.
290
+
291
+ ### Output language policy
292
+
293
+ All non-API output strings in `src/` must be **English only**. API-returned data (subject names, weekday labels from Bangumi, etc.) may contain any language. The TUI layer is the only exception where localized strings are acceptable.
294
+
295
+ This applies to:
296
+ - Help text and usage descriptions in `src/core/output.js`
297
+ - Error messages in `src/core/output.js` and `src/cli.js`
298
+ - Mock data in tests under `test/`
299
+ - Table headers, column names, and CLI prompts
300
+
301
+ Bad:
302
+ ```
303
+ // In src/core/output.js help text
304
+ ["bgm calendar", "显示今日番组表"] // violates policy
305
+ ```
306
+
307
+ Good:
308
+ ```
309
+ ["bgm calendar", "Show today's anime broadcast schedule"] // correct
310
+ ```
311
+
312
+ ### Testing conventions
313
+
314
+ Use Node.js built-in `node:test` + `node:assert`. Do **not** add external test dependencies like `vitest`, `jest`, or `mocha`.
315
+
316
+ - Place tests under `test/`
317
+ - Name files `*.test.js`
318
+ - Use ESM imports (`import { describe, it } from "node:test"`)
319
+ - For CLI integration tests, use `spawnSync` to invoke `node src/cli.js`
320
+ - For unit tests on formatters, import directly from `src/core/output.js`
321
+ - Add `"test": "node --test"` to `package.json` scripts
322
+ - GitHub Actions should run `npm test` on push/PR/release
323
+
324
+ Example test pattern:
325
+ ```js
326
+ import { spawnSync } from "node:child_process";
327
+ import { describe, it } from "node:test";
328
+ import assert from "node:assert";
329
+
330
+ function run(args) {
331
+ return spawnSync("node", ["src/cli.js", ...args], { encoding: "utf-8", cwd: process.cwd() });
332
+ }
333
+ ```
334
+
335
+ ### Test what the CLI does, not what the API returns
336
+
337
+ Real API calls are acceptable for **1 smoke test per command group** to confirm end-to-end wiring, but the bulk of tests should validate the **CLI's own logic** using mock data:
338
+
339
+ - **Parameter parsing and normalization** — e.g. `parseFlags()`, `normalizeSubjectTypeFilter()`, `normalizeCollectionStatusFilter()`
340
+ - **Formatting and rendering** — e.g. `formatDisplayResult()` with constructed payloads
341
+ - **Filtering, sorting, slicing** — e.g. `sortCollections()`, client-side pagination logic
342
+ - **Boundary conditions** — empty arrays, missing fields, `undefined` scores
343
+
344
+ **Do not write multiple integration tests that merely exercise the upstream Bangumi API** (e.g. testing that `calendar mon` returns Monday, `calendar sun` returns Sunday, `calendar all` returns 7 days). Those test Bangumi's API contract, not the CLI. One default-path smoke test per group is enough.
345
+
346
+ **Shift test budget toward high-frequency commands.** `collection` and `subject` are heavily used; they deserve deep unit coverage for filtering/sorting/formatting. `calendar` is read-only and low-complexity; 1 integration + 2 formatting tests is sufficient.
347
+
348
+ If the CLI code tightly couples API calls with logic (common in `src/cli.js` handlers), prefer extracting the pure logic into testable functions over adding more integration tests. Integration tests are slow, flaky, and burn CI minutes.
349
+
350
+ ### Release conventions
351
+
352
+ Releases are automatic and the version lives in git tags (`vX.Y.Z`), like magpie. Do not bump versions by hand.
353
+
354
+ - Every push to `main` that has commits since the latest tag releases the next **patch** version: `.github/workflows/release.yml` runs the tests, creates the tag and GitHub Release, and publishes to npm. `scripts/next-version.sh` decides the version.
355
+ - `package.json` carries the placeholder `0.0.0-dev`. The workflow stamps the real version into it inside the runner right before `npm publish` and never commits it back. A source checkout therefore reports `0.0.0-dev`.
356
+ - Put `[skip release]` in the head commit subject (first line) to push to `main` without releasing.
357
+ - For a minor or major bump, push a commit with `[skip release]`, then tag that commit and push only the tag: `git tag v1.2.0 && git push origin v1.2.0`. A pushed `v*` tag releases exactly that version.
358
+ - Before pushing, verify: `npm test`, `node src/cli.js --help`, `node src/cli.js --version`.
359
+ - Use semantic versioning: automatic releases are always patch; choose minor for features/commands and major for breaking changes by tagging as above.
360
+
361
+ ## Environment Conventions
362
+
363
+ - Node.js `>= 20`
364
+ - package type is ESM
365
+ - config precedence is: built-in defaults, `bgm-dev.env`, runtime `config.json`, environment variables
366
+ - use existing install scripts under `scripts/` before inventing new manual setup steps
367
+
368
+ ## When Not To Use This Skill
369
+
370
+ - when the task is just to run `bgm` commands for a user
371
+ - when the task is only about end-user installation and auth rather than repository changes