dsh-shlr-bilitoolkit 0.1.17 → 0.1.18

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.
Files changed (3) hide show
  1. package/AGENTS.md +5 -6
  2. package/dist/dsh.js +15 -33
  3. package/package.json +1 -1
package/AGENTS.md CHANGED
@@ -1,11 +1,10 @@
1
- (Agent 必读)
1
+ # AGENTS.md — dsh-shlr-bilitoolkit(Agent 必读)
2
2
 
3
3
  ## 登录(务必遵守)
4
- 用户要登录 B 站,或任何操作返回未登录(`-101` / `未登录` / `CookieError`)时:
5
- **必须调用 `bili_gen_qr`,并把返回的二维码图片展示给用户扫码**——用 `qrDataUrl` 以 Markdown 图片 `![qr](<qrDataUrl>)` 渲染(或引用 `qrImageUrl` / `qrImagePath`)。
6
-
7
- 禁止:只给链接、用 ASCII/文本二维码、让用户自己跑命令。用户扫码确认后调用 `bili_login_status` 完成登录并保存 Cookie。
4
+ 用户要登录 B 站,或任何操作返回未登录(-101 / 未登录 / CookieError)时:
5
+ **必须调用 bili_gen_qr,并把返回的二维码图片展示给用户扫码**——用 qrDataUrl 以 Markdown 图片 `![qr](<qrDataUrl>)` 渲染(或引用 qrImageUrl / qrImagePath)。
6
+ 禁止只给链接、用 ASCII、让用户自己跑命令。用户确认后调 bili_login_status 完成登录。
8
7
 
9
8
  ## 其它
10
- - 除常驻工具外,其它 B 站能力默认懒加载:先 `bili_catalog` 看分组,再 `bili_open(group)` 打开(下一轮生效),用完可 `bili_close` 释放。
9
+ - 非常驻的 B 站能力懒加载:`bili_open()` 看分组,`bili_open({ group })` 打开(下一轮生效)。
11
10
  - 写操作会真实修改账号状态,执行前先与用户确认。
package/dist/dsh.js CHANGED
@@ -1074,7 +1074,6 @@ const MAX_OPEN_GROUPS = 3;
1074
1074
  export const CORE_IDS = [
1075
1075
  "bili_gen_qr",
1076
1076
  "bili_login_status",
1077
- "bili_cache_clear",
1078
1077
  "bili_recommend",
1079
1078
  "bili_video_detail",
1080
1079
  "bili_search",
@@ -1097,6 +1096,7 @@ export const GROUPS = {
1097
1096
  message: { hint: "私信:发送 / 未读 / 聊天记录 / 撤回", ids: ["bili_send_message", "bili_message_unread", "bili_message_history", "bili_message_recall"] },
1098
1097
  notify: { hint: "消息中心:未读 / 回复·@·赞 列表", ids: ["bili_notify_unread", "bili_notify_list"] },
1099
1098
  profile: { hint: "个人资料:查看 / 修改", ids: ["bili_profile_info", "bili_profile_update"] },
1099
+ misc: { hint: "维护:清空本地缓存", ids: ["bili_cache_clear"] },
1100
1100
  };
1101
1101
  const TOOL_BY_ID = new Map(TOOLS.map((t) => [t.id, t]));
1102
1102
  function groupOfTool(id) {
@@ -1143,31 +1143,29 @@ function buildDef(tool) {
1143
1143
  return defineTool(options);
1144
1144
  }
1145
1145
  const lazyTools = [
1146
- {
1147
- id: "bili_catalog",
1148
- description: "列出 B 站能力分组与每组包含的工具。要用某个 B 站能力但不确定工具名时,先调本工具,再调 bili_open 打开对应分组(打开后下一轮起该组工具可调用)。",
1149
- parameters: { type: "object", properties: {} },
1150
- handler: async () => ({
1151
- groups: Object.entries(GROUPS).map(([name, g]) => ({
1152
- group: name,
1153
- hint: g.hint,
1154
- tools: g.ids,
1155
- open: openGroups.has(name),
1156
- })),
1157
- how: "bili_open({ group }) 或 bili_open({ tool }) 打开;bili_close({ group }) 关闭以节省上下文。",
1158
- }),
1159
- },
1160
1146
  {
1161
1147
  id: "bili_open",
1162
- description: "打开一组 B 站工具(group),或直接给工具名(tool)自动打开其所在组。打开后该组工具在下一轮即可调用。同时最多保留 3 组,超出会关闭最久未用的组。",
1148
+ description: "B 站能力开关。不带参数调用=列出所有能力分组;带 group(分组名)或 tool(工具名)调用=打开该组,打开后下一轮起可调用。同时最多保留 3 组,超出自动关闭最久未用的。",
1163
1149
  parameters: {
1164
1150
  type: "object",
1165
1151
  properties: {
1166
- group: { type: "string", description: "分组名(见 bili_catalog)" },
1152
+ group: { type: "string", description: "分组名(不带参调用可列出)" },
1167
1153
  tool: { type: "string", description: "或直接给工具名,自动打开其所在组" },
1168
1154
  },
1169
1155
  },
1170
1156
  handler: async (a) => {
1157
+ // 不带参数:列出能力目录
1158
+ if (a.group == null && a.tool == null) {
1159
+ return {
1160
+ groups: Object.entries(GROUPS).map(([name, g]) => ({
1161
+ group: name,
1162
+ hint: g.hint,
1163
+ tools: g.ids,
1164
+ open: openGroups.has(name),
1165
+ })),
1166
+ how: "带 group 或 tool 再次调用本工具即可打开;同时最多保留 3 组。",
1167
+ };
1168
+ }
1171
1169
  if (!toolsRegistry) {
1172
1170
  return { ok: false, message: "当前运行时不支持动态注册,懒加载不可用" };
1173
1171
  }
@@ -1212,22 +1210,6 @@ const lazyTools = [
1212
1210
  return { ok: true, group, tools: loaded, note: "该组工具已打开,下一轮起可调用。" };
1213
1211
  },
1214
1212
  },
1215
- {
1216
- id: "bili_close",
1217
- description: "关闭一组已打开的 B 站工具,释放上下文。不确定分组名先用 bili_catalog。",
1218
- parameters: {
1219
- type: "object",
1220
- properties: { group: { type: "string" } },
1221
- required: ["group"],
1222
- },
1223
- handler: async (a) => {
1224
- const group = String(a.group ?? "").trim();
1225
- if (!openGroups.has(group))
1226
- return { ok: false, message: "该组未打开" };
1227
- closeGroup(group);
1228
- return { ok: true, closed: group };
1229
- },
1230
- },
1231
1213
  ];
1232
1214
  /** 用最可用的注册入口注册一个内部工具。 */
1233
1215
  function registerOne(ctx, tool) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-shlr-bilitoolkit",
3
- "version": "0.1.17",
3
+ "version": "0.1.18",
4
4
  "description": "深海猎人专用B站接口工具箱 dsh 插件。",
5
5
  "type": "module",
6
6
  "main": "dist/dsh.js",