@aronnaxlin/bgm-cli 1.1.4 → 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.
@@ -0,0 +1,259 @@
1
+ ---
2
+ name: "bgm-cli-operate"
3
+ description: "Use when an agent needs to get a user to a working bgm CLI and then operate it safely: detect availability, install bgm-cli if missing, set up Bangumi auth, run reads or writes, prefer JSON for automation, and troubleshoot install, auth, Access Token, session, or Turnstile issues."
4
+ ---
5
+
6
+ # bgm-cli Operate
7
+
8
+ This is the main published end-user skill for `bgm-cli`.
9
+
10
+ Use it when the task is to operate `bgm` for a user, including first-time installation and setup.
11
+
12
+ If the CLI is missing and terminal access is available, install it instead of only describing the steps.
13
+
14
+ ## Use This Skill For
15
+
16
+ - detecting whether `bgm` or `./bgm` is available
17
+ - installing `bgm-cli` on macOS, Linux, or Windows when needed
18
+ - choosing between remote managed install and repository-local install-path setup
19
+ - setting or checking Bangumi auth
20
+ - reading user, notification, subject, episode, group, collection, character, person, blog, index, timeline, trending, and calendar data
21
+ - performing supported collection writes, episode-progress writes, book-progress writes, notification clears, subject/group topic writes, character/person/blog/index comment writes, index writes, and supported timeline writes
22
+ - using Bangumi emote codes like `(bgm54)` in comments, where the site renders them as emojis
23
+ - using reaction-style `like` commands with target-specific numeric sticker values
24
+ - preferring `--json` for agent consumption
25
+ - troubleshooting PATH, Node, auth, Access Token, session, and Turnstile problems
26
+
27
+ ## Do Not Use This Skill For
28
+
29
+ - editing the `bgm-cli` repository itself
30
+ - changing command behavior or output contracts
31
+ - debugging source-level implementation details
32
+ - promising Bangumi site features that the CLI does not expose
33
+
34
+ ## Primary Contract
35
+
36
+ An agent using only this skill should be able to:
37
+
38
+ 1. detect the usable executable
39
+ 2. install `bgm-cli` if it is missing
40
+ 3. bring the user to a usable auth state
41
+ 4. run the requested task with the narrowest correct command
42
+ 5. verify important writes and report unsupported scope plainly
43
+
44
+ ## Default Workflow
45
+
46
+ ### 1. Detect the executable first
47
+
48
+ Try in this order:
49
+
50
+ 1. `bgm --help`
51
+ 2. `./bgm --help` when operating from a repository checkout
52
+
53
+ Once one works, use that executable consistently.
54
+
55
+ Preferred order:
56
+
57
+ 1. `bgm`
58
+ 2. `./bgm`
59
+
60
+ ### 2. Install if missing
61
+
62
+ If neither executable works, install the CLI.
63
+
64
+ Preferred install choice:
65
+
66
+ 1. remote managed install when the user just wants a working `bgm`
67
+ 2. repository-local install-path setup when the user is already in a cloned checkout and wants that checkout exposed as `bgm`
68
+ 3. direct `./bgm` use when the user only needs commands inside the current checkout
69
+
70
+ Use `references/install-and-auth.md`.
71
+
72
+ ### 3. Establish auth before real work
73
+
74
+ Preferred auth path:
75
+
76
+ 1. `bgm --init` for guided setup, choosing the recommended official Bangumi login
77
+ 2. `bgm auth login` when the user wants to start the official login directly
78
+ 3. `bgm auth set-token <access_token>` when the user already has an Access Token or needs the token channel for scripting
79
+ 4. OAuth helper flows only when the user explicitly wants them
80
+
81
+ Verify auth before important writes:
82
+
83
+ ```bash
84
+ bgm auth status
85
+ bgm user me
86
+ ```
87
+
88
+ If only the Access Token channel needs validation, use:
89
+
90
+ ```bash
91
+ bgm auth token-status
92
+ ```
93
+
94
+ If only private `p1` session state matters, use:
95
+
96
+ ```bash
97
+ bgm auth session-status
98
+ ```
99
+
100
+ ### 4. Prefer deterministic commands
101
+
102
+ - prefer ordinary CLI commands over `bgm tui`
103
+ - prefer `--json` for agent reasoning and follow-up checks
104
+ - prefer exact subject IDs and topic IDs over search-based resolution
105
+ - keep search result sets small when the user does not know an exact ID
106
+ - remember that `bgm --help` is now only a compact overview; use `bgm <group> --help` for full command details such as `bgm episode --help` or `bgm blog --help`
107
+
108
+ ### 5. Resolve pasted Bangumi links with the URL entry point
109
+
110
+ When the user supplies a Bangumi web link instead of an ID, hand the link to the CLI rather than parsing it by hand.
111
+
112
+ ```bash
113
+ bgm --json --url "https://bangumi.tv/group/topic/469977#post_4029724" --dry-run
114
+ bgm --json "https://bangumi.tv/group/topic/469977#post_4029724"
115
+ ```
116
+
117
+ - Three equivalent forms: `bgm <url>`, `bgm url <url>`, `bgm --url <url>` (`-url` is an alias).
118
+ - Hosts: `bgm.tv`, `bangumi.tv`, `chii.in`, `next.bgm.tv`, `api.bgm.tv`; `https://` and `www.` are optional.
119
+ - Run `--dry-run` first when the mapping matters; it prints the resolved command offline and makes no request.
120
+ - Resolution is read-only. A link never triggers a write, so keep using the explicit write commands.
121
+ - `#post_<id>` resolves to that single reply, not the whole topic.
122
+ - `--json` returns the target command's payload plus a `resolvedFrom` field (`url`, `site`, `command`, `args`), so downstream parsing is unchanged.
123
+ - Always quote links containing `#`, otherwise the shell truncates them.
124
+ - Unsupported paths fail with a `Did you mean: bgm ...` suggestion; follow the suggestion instead of retrying the link.
125
+ - Run `bgm url --help` for the full list of supported link shapes.
126
+
127
+ ### 6. Verify important writes
128
+
129
+ For collection, episode-progress, notification, subject/group topic, character/person/blog/index comment, index, or timeline writes, read back the final state when the result matters.
130
+
131
+ Examples:
132
+
133
+ ```bash
134
+ bgm --json collection get 348335
135
+ bgm --json episode list 348335 --type main --limit 5
136
+ bgm --json group topic 498114
137
+ bgm --json subject topic 29892
138
+ ```
139
+
140
+ ## Operational Rules
141
+
142
+ - If installation is required and terminal access is available, perform the installation.
143
+ - If auth is required and missing, prefer `bgm --init` or `bgm auth login` in an interactive terminal.
144
+ - Treat Access Token as a preserved second channel for users who already have a token or need scripting compatibility.
145
+ - Treat `session-login` as manual session import helper state, not as the normal official login path.
146
+ - Do not send both private session and Access Token credentials for `p1` requests; current CLI behavior prefers the private session cookie when it is saved.
147
+ - Treat book progress as separate from episode progress; use `bgm book get/ep/vol` for book-type subjects and `bgm episode` commands for anime/game/real subjects.
148
+ - Treat book writes as requiring that the parent subject is already in the user's collection and that the subject is a book-type entry.
149
+ - Treat episode progress as separate from the subject collection `ep_status` field for non-book subjects; prefer the dedicated `episode` commands.
150
+ - Treat episode writes as requiring that the parent subject is already in the user's collection.
151
+ - Do not assume the parent collection must be `doing`; Bangumi currently allows episode writes under `wish`, `collect`, `doing`, `on_hold`, and `dropped` as long as the subject is collected.
152
+ - Treat `episode watch` as a main-story helper only. For SP / OP / ED writes, use `episode status <episode_id> ...` directly.
153
+ - Treat NSFW episode listing as auth-sensitive. Without a usable auth context, Bangumi may return a misleading `404` instead of a clear auth error. For `p1` requests, the CLI prefers a private session cookie and falls back to Access Token when no session is saved.
154
+ - Treat reactions (贴贴) as stickers, never as likes. A `reactions[].value` in `--json` output and a `like` command value are sticker ids from a fixed set of twelve; only `140` (+1) means agreement and `141` is a question mark. Read `references/reactions.md` before interpreting or posting one.
155
+ - Treat reaction-style `like` values as target-specific. Reply-type targets accept all twelve current values; subject collection comments accept a subset of eight.
156
+ - Treat `bgm auth turnstile` as official-hosted-first and local-helper-second. Use `--manual` only when you explicitly need to force the local helper path.
157
+ - Treat subject/group topic creation and replies as Turnstile-gated operations.
158
+ - Treat character/person/blog comment writes as Turnstile-gated operations; blog comment writes are still experimental.
159
+ - Treat timeline `say` and `reply` as Turnstile-gated operations.
160
+ - Treat notification support as list/read and mark-read only; accepting or rejecting friend requests is not exposed as a notify command.
161
+ - Treat friend/follower commands as read-only list commands; friend/follow relationship mutations are not exposed.
162
+ - Use `bgm setup update` only for managed installs created by the remote installer.
163
+ - Use `bgm setup install-path` only when the user wants the current checkout exposed as global `bgm`.
164
+ - **Agent Turnstile human-in-the-loop for posting**: The agent cannot complete Cloudflare Turnstile CAPTCHA automatically. When the user asks to create a group topic (`group create-topic`) or reply (`group reply`), and the CLI returns a Turnstile-required error, the agent must: 1) run `bgm auth turnstile` to generate the official verification URL; 2) send the URL to the user; 3) wait for the user to complete verification manually and return the token; 4) re-run the post/reply command with `--turnstile-token`. Do not rely on the terminal auto-callback succeeding, because automatic browser launch is usually unavailable in agent environments.
165
+ - Do not infer unsupported community actions from the Bangumi website alone.
166
+
167
+ ## Fast Start Commands
168
+
169
+ ### Capability and auth
170
+
171
+ ```bash
172
+ bgm --help
173
+ bgm auth status
174
+ ```
175
+
176
+ ### Minimum ready state from zero
177
+
178
+ ```bash
179
+ bgm --init
180
+ bgm auth status
181
+ bgm user me
182
+ ```
183
+
184
+ ### Common reads
185
+
186
+ ```bash
187
+ bgm --json user me
188
+ bgm --json user friends sai --limit 10
189
+ bgm --json user followers sai --limit 10
190
+ bgm --json notify --limit 10
191
+ bgm --json subject search "Gundam" --type anime --limit 5
192
+ bgm --json subject get 253
193
+ bgm --json subject topics 253 --limit 10
194
+ bgm --json subject recent-topics --limit 10
195
+ bgm --json subject topic 29892
196
+ bgm --json episode list 253 --type main --limit 5
197
+ bgm --json episode list 253 --type op_ed --limit 10
198
+ bgm --json episode comments 253 1
199
+ bgm --json book get 3510
200
+ bgm --json collection get 253
201
+ bgm --json collection characters --user sai --limit 10
202
+ bgm --json collection persons --user sai --limit 10
203
+ bgm --json character search "夏娜" --limit 5
204
+ bgm --json person search "坂本真綾" --career seiyu --limit 5
205
+ bgm --json group topics boring --limit 20
206
+ bgm --json blog get 371953
207
+ bgm --json index get 1
208
+ bgm --json timeline list --mode friends --limit 10
209
+ bgm --json timeline user sai --limit 10
210
+ bgm --json timeline replies 123456
211
+ bgm --json calendar
212
+ bgm --json calendar all
213
+ bgm --json url https://bgm.tv/subject/253/characters
214
+ bgm --json --url https://bgm.tv/anime/list/sai/collect --dry-run
215
+ ```
216
+
217
+ ### Common writes
218
+
219
+ ```bash
220
+ bgm collection status 253 doing
221
+ bgm book ep 3510 10
222
+ bgm book vol 3510 2
223
+ bgm episode watch 253 1
224
+ bgm episode status 103232 watched
225
+ bgm collection rate 253 8
226
+ bgm collection comment 253 "Backfill"
227
+ bgm notify clear 123456
228
+ bgm subject reply 29892 "Reply content" --turnstile-token YOUR_TOKEN
229
+ bgm group reply 498114 "Reply content" --turnstile-token YOUR_TOKEN
230
+ bgm character comment 1 "Comment content" --turnstile-token YOUR_TOKEN
231
+ bgm person comment 1 "Comment content" --turnstile-token YOUR_TOKEN
232
+ bgm blog reply 371953 "Test comment" --turnstile-token YOUR_TOKEN
233
+ bgm timeline say "off work" --turnstile-token YOUR_TOKEN
234
+ bgm timeline reply 123456 "seen" --turnstile-token YOUR_TOKEN
235
+ bgm index comment 1 "Nice index" --turnstile-token YOUR_TOKEN
236
+ ```
237
+
238
+ ## Command Coverage
239
+
240
+ Read these references before guessing. If you cannot read files from this skill's directory, print any of them with `bgm --skill operate <name>` (for example `bgm --skill operate commands`):
241
+
242
+ - `references/install-and-auth.md`
243
+ - `references/commands.md`
244
+ - `references/troubleshooting.md`
245
+ - `references/community-boundaries.md`
246
+ - `references/reactions.md`
247
+
248
+ ## Output Expectations
249
+
250
+ When reporting back to a user or another agent, always say:
251
+
252
+ - which executable was used: `bgm` or `./bgm`
253
+ - whether installation was needed
254
+ - whether auth was already present or had to be set up
255
+ - which commands were run
256
+ - whether results came from JSON output or human-readable output
257
+ - when a pasted link was resolved, which command it resolved to (from `--dry-run` or the `resolvedFrom` field)
258
+ - for episode operations, whether the parent subject was already collected and whether NSFW auth restrictions affected the task
259
+ - what could not be completed because of missing auth, install failure, or unsupported CLI scope