dsh-fish-soul 0.18.7 → 0.18.9

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.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  让一个 QQ 小号背后有"同一个人":固定人格、按人记记忆、有自己的生活节奏、会主动开口;同一个"她"同时出现在 QQ、B站、抖音。
4
4
 
5
- DSH 插件(单角色 `feiyu`)。版本 **0.18.7**。
5
+ DSH 插件(单角色 `feiyu`)。版本 **0.18.9**。
6
6
 
7
7
  QQ 交流群:**1125962189**
8
8
 
package/lib/browse.js CHANGED
@@ -35,7 +35,29 @@ export function afterRound(self, label, watched, pick) {
35
35
  });
36
36
  } catch { /* 动态可缺 */ }
37
37
  const s = watched.find((w) => w.share);
38
- if (!s || typeof self.share !== 'function') return;
38
+ // 模型这轮没标 [分享]:让自走层判断要不要主动挑一条(最近几天没分享过才挑,见 #133)。
39
+ // 原来这里是直接 return ⇒ 她不标就一条都不排,主人看到的就是「刷了但从不分享」。
40
+ if (!s) {
41
+ if (typeof self.shareFallback !== 'function') return;
42
+ // ⚠️ 用户在平台面板上明确关了「刷到就分享」⇒ 兜底也不许发。
43
+ // 不看这个开关的话,兜底会把用户的显式关闭**反转**(比不修更糟)。
44
+ if (typeof self.cfg === 'function' && self.cfg()?.share === false) return;
45
+ try {
46
+ const candidates = watched.map((w) => ({ ...pick(w), impression: w.impression, skipped: w.skipped, url: w.url }));
47
+ const r = self.shareFallback({ platform: label, candidates });
48
+ if (r?.ok) {
49
+ // 用它返回的那条(挑的规则在自走层那边,自己重算可能挑到不一样的)
50
+ const one = r.chosen ?? candidates.find((c) => c.impression) ?? candidates[0];
51
+ self.note?.('share', { title: label, reason: `最近没分享,主动挑一条《${String(one?.title ?? '').slice(0, 20)}》分享给你`, text: one?.url ?? '' });
52
+ } else if (r?.error && !/最近 .* 天分享过了|没有值得分享|兜底关着|分享视频关着/.test(r.error)) {
53
+ self.note?.('browse', { title: label, reason: `想主动分享但没排上:${r.error}` });
54
+ }
55
+ } catch (error) {
56
+ self.log('warn', `[fish-soul] 兜底分享失败:${String(error instanceof Error ? error.message : error)}`);
57
+ }
58
+ return;
59
+ }
60
+ if (typeof self.share !== 'function') return;
39
61
  try {
40
62
  const r = self.share({ platform: label, ...pick(s), url: s.url, impression: s.impression });
41
63
  self.note?.(r?.ok ? 'share' : 'browse', { title: label, reason: r?.ok ? `想把《${String(pick(s).title ?? '').slice(0, 20)}》分享给你` : `想分享但没排上:${r?.error ?? '不知道为什么'}`, text: s.url });
@@ -57,8 +79,11 @@ export class BiliBrowser {
57
79
  * @param {(level: string, msg: string) => void} [deps.log]
58
80
  * @param {[number, number]} [deps.watchDelayMs] 两条视频之间"看"多久(真实毫秒)
59
81
  */
60
- constructor({ db, clock, client, getConfig, callLlm, persona, worker, log, watchDelayMs = [8000, 20000], share, note, frames }) {
82
+ constructor({ db, clock, client, getConfig, callLlm, persona, worker, log, watchDelayMs = [8000, 20000], share, shareFallback, note, frames }) {
61
83
  this.share = share ?? null; // 刷到特别想分享的:交给自走层排一条主动消息(带链接)
84
+ // #133:模型没标 [分享] 时的兜底(最近几天没分享过就主动挑一条)。
85
+ // ⚠️ 漏了这个参数整个兜底就是死代码(afterRound 里 self.shareFallback 恒 undefined)。
86
+ this.shareFallback = shareFallback ?? null;
62
87
  this.note = note ?? null; // 记一条动态
63
88
  this.db = db;
64
89
  this.clock = clock;
@@ -981,6 +981,15 @@ export class DouyinChannel {
981
981
  status() {
982
982
  return {
983
983
  running: this.running,
984
+ // 「真的能用」= 轮询循环活着 && 浏览器在跑 && 登录态正常。
985
+ // 🔴 单看 `running` 会误判:`pollOnce` 在 `!this.host.running` 时**直接 return
986
+ // 且不记错误**,所以浏览器崩了/被暂停,轮询循环照样活着、`running` 仍是 true。
987
+ // `connected` 是那个 getter 的结果,和 QQ 的 `connected`、B站的 `loggedIn`
988
+ // 语义对齐 —— 诊断页判这个才看得出「真的不能用」。
989
+ connected: this.connected,
990
+ // ⚠️ 暂停时 `host.running` 仍是 true(只是停了轮询),所以 `connected` 看不出来 ——
991
+ // 单独给出来,让诊断页能说清「是被暂停了」而不是「没跑」。
992
+ paused: this.host?.paused === true,
984
993
  lastPollAt: this.lastPollAt,
985
994
  lastError: this.lastError,
986
995
  replyPaused: this.replyPaused,
package/lib/client.js CHANGED
@@ -437,6 +437,7 @@ window.__ModuleLoader__.load({
437
437
  enabled: pc.enabled !== false, dailyMaxCount: pc.dailyMaxCount ?? 10,
438
438
  activeStart: pc.activeHours?.[0] ?? 8, activeEnd: pc.activeHours?.[1] ?? 24, idleTriggerHours: pc.idleTriggerHours ?? 6,
439
439
  idleRealGapMinutes: pc.idleRealGapMinutes ?? 30, scheduleEnabled: pc.scheduleEnabled !== false,
440
+ shareMaxPerDay: pc.shareMaxPerDay ?? 2, shareFallbackDays: pc.shareFallbackDays ?? 2,
440
441
  masterPrivateChannelId: targets.masterPrivateChannelId ?? "", selfGroupChannelIds: [...(targets.selfGroupChannelIds ?? [])]
441
442
  }));
442
443
  if (!data || !form) return null;
@@ -456,6 +457,9 @@ window.__ModuleLoader__.load({
456
457
  idleTriggerHours: next.idleTriggerHours,
457
458
  idleRealGapMinutes: next.idleRealGapMinutes,
458
459
  scheduleEnabled: next.scheduleEnabled,
460
+ // #133:这两个字段不进 body ⇒ 面板改了存不进去(读回又是默认值,像保存失败但没报错)
461
+ shareMaxPerDay: next.shareMaxPerDay,
462
+ shareFallbackDays: next.shareFallbackDays,
459
463
  targets: { masterCanonicalId: targets.masterCanonicalId ?? "user:master", masterPrivateChannelId: next.masterPrivateChannelId, selfGroupChannelIds: next.selfGroupChannelIds }
460
464
  });
461
465
  if (res?.ok) refresh(); else notify(res?.error ?? "保存失败");
@@ -489,6 +493,12 @@ window.__ModuleLoader__.load({
489
493
  form.enabled ? Row({ title: "空闲多久后" }, num("idleTriggerHours", "空闲多久后", 1, 48, 6), Muted("小时")) : null,
490
494
  form.enabled ? Row({ title: "刚聊完先等等" }, num("idleRealGapMinutes", "刚聊完先等等", 0, 1440, 30), Muted("分钟"), Muted("0 = 不等")) : null,
491
495
  form.enabled ? Row({ title: "自走日程" }, h(Switch, { label: "自走日程", checked: form.scheduleEnabled, onChange: (v) => save({ scheduleEnabled: v }) }), Muted("关掉就不排今天干什么")) : null,
496
+ form.enabled ? Row({ title: "分享视频", stack: true },
497
+ num("shareMaxPerDay", "分享视频每天最多", 0, 20, 2), Muted("条/天"),
498
+ Muted("她刷到特别想分享的才会发")) : null,
499
+ form.enabled ? Row({ title: "几天没分享就主动挑一条", stack: true },
500
+ num("shareFallbackDays", "几天没分享就主动挑一条", 0, 30, 2), Muted("天"),
501
+ Muted("0 = 不主动挑(只用她自己想分享的)")) : null,
492
502
  form.enabled ? Row({ title: "主人私聊" }, Input({ value: form.masterPrivateChannelId, placeholder: "private:主人 QQ", onChange: (e) => patch({ masterPrivateChannelId: e.target.value }), onBlur: () => save() })) : null,
493
503
  form.enabled ? Row({ title: "群聊", stack: true },
494
504
  ...form.selfGroupChannelIds.map((cid) => Tag(cid, undefined, { key: cid },
@@ -954,6 +964,13 @@ window.__ModuleLoader__.load({
954
964
  if (r?.ok) { setData(r); notify(`已更新到 v${r.to},重启 DSH 生效`); }
955
965
  else notify(r?.error ?? "没更新成");
956
966
  }
967
+ // 开发目录(link)安装:更新 = 在那个目录里 git pull + 重启 DSH,不是 pnpm add。
968
+ // 用真实的开发目录路径,别给占位符(复制过去直接报错,等于没给命令)。
969
+ const devPath = String(data.installPath ?? "");
970
+ const devCommand = devPath === "" ? "在开发目录里 git pull,然后重启 DSH" : `git -C "${devPath}" pull && 重启 DSH`;
971
+ async function copyDev() {
972
+ try { await navigator.clipboard.writeText(devCommand); notify("已复制更新命令"); } catch { notify("复制失败,手动选中复制"); }
973
+ }
957
974
  const when = data.checkedAt ? new Date(data.checkedAt).toLocaleString("zh-CN", { hour12: false }) : "";
958
975
  const status = data.hasUpdate ? Tag(`有新版本 v${data.latest}`, "warning")
959
976
  : data.latest ? Tag("已是最新", "success")
@@ -964,11 +981,20 @@ window.__ModuleLoader__.load({
964
981
  Row({ title: status, meta: when ? `${when}${data.source ? ` · ${data.source}` : ""}` : undefined, desc: "每 12 小时自动看一次 npm / GitHub" },
965
982
  Button({ onClick: check, disabled: busy || data.checking }, busy || data.checking ? "检查中…" : "检查更新"),
966
983
  data.hasUpdate ? Button({ onClick: () => window.open(data.notesUrl, "_blank", "noopener") }, "更新说明") : null,
984
+ // ⚠️ 按钮的显隐由 **canApply**(宿主有没有插件管理服务)决定,
985
+ // 不是由 installMode 决定 —— 宿主才是唯一权威(updateBundle 自己会拒
986
+ // link 装并给出明确理由)。插件拿自己的启发式去藏按钮,
987
+ // 等于把「判据可能出错」从「多一句废话」升级成「功能直接没了」。
967
988
  data.hasUpdate && data.canApply ? Button({ variant: "primary", onClick: apply, disabled: busy }, busy ? "更新中…" : `更新到 v${data.latest}`) : null,
968
989
  data.hasUpdate && data.command ? Button({ variant: data.canApply ? "ghost" : "primary", onClick: copy, title: data.command }, "复制更新命令") : null),
969
990
  data.hasUpdate ? (data.notes ? h("pre", { className: "fs-report" }, data.notes)
970
991
  : h("p", { className: "fs-row-meta" },
971
992
  h("a", { href: data.notesUrl, target: "_blank", rel: "noopener noreferrer" }, "GitHub Releases"))) : null,
993
+ // 开发目录(link)安装:npm 版不会覆盖它 ⇒ 这里的「更新」是 git pull + 重启。
994
+ // 只是**追加一句说明**,不去替代上面那个按钮(宿主说行就行)。
995
+ data.installMode === "dev" ? Row({ title: "开发目录安装", desc: "npm 上的新版本不会覆盖这个目录,要更新在这里 git pull 之后重启 DSH" },
996
+ Button({ variant: "ghost", onClick: copyDev, title: devCommand }, "复制 git pull 命令"),
997
+ devPath === "" ? null : Muted(devPath)) : null,
972
998
  Row({ title: "自动检查更新", desc: "只提示,不会自动安装;点「更新到」才装,装完重启 DSH 生效" },
973
999
  h(Switch, { checked: data.autoCheck !== false, onChange: toggle, label: "自动检查更新" })));
974
1000
  }
@@ -176,6 +176,10 @@ export function fishSoulConfigSchema(z) {
176
176
  // #75:自走日程开关。关掉 = 不生成日程、不注入时段、不用忙/闲卡住主动与刷视频
177
177
  scheduleEnabled: z.boolean().default(true),
178
178
  shareMaxPerDay: z.number().default(2), // 刷到想分享的视频,一天最多主动发几条
179
+ shareVideos: z.boolean().default(true), // 分享视频总开关(以前代码读它但 schema 里没有 ⇒ 读不到,等于写不了)
180
+ // #133:最近 N 天没分享过就主动挑一条(0 = 关)。分享原本只靠模型标 [分享],
181
+ // 而提示词明说「大多数视频不用」⇒ 实测她几乎不标,分享待办长期为 0。
182
+ shareFallbackDays: z.number().default(2),
179
183
  targets: z.object({
180
184
  masterCanonicalId: z.string().default('user:master'),
181
185
  masterPrivateChannelId: z.string().default(''),