cortico-world-fish-sing 0.4.8 → 0.4.10

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/CHANGELOG.md CHANGED
@@ -2,6 +2,18 @@
2
2
 
3
3
  格式参考 [Keep a Changelog](https://keepachangelog.com/zh-CN/1.1.0/);版本号遵循语义化。
4
4
 
5
+ ## [0.4.10] - 2026-11-02
6
+
7
+ ### 修复
8
+ - **QQ 通知目标只填号码时静默失效**:`qqTarget` 写 `2587509374`(没有 `private:` 前缀)会被 `parseTarget` 判死,然后什么都不发、日志一条没有,看起来像"QQ 渠道坏了"。现在裸数字直接当私聊号处理;格式真的不对时也会 warn 一条「解析不了(要 group:/private:)」。
9
+ - 选模对比没发 QQ 时同样会 warn 说明原因(缺目标 / 缺 OneBot 地址),不再静默。
10
+ - `notify.qqTarget` 改为热更新字段(改完不用重启 Coo)。
11
+
12
+ ## [0.4.9] - 2026-11-02
13
+
14
+ ### 修复
15
+ - **训练完成后选模对比静默跳过**("只有一个可用存档(中间档可能被清理了)"):`save_every_weights=1` 时 RVC 把存档点导出成 `assets/weights/<实验>_e<N>_s<X>.pth`,logs 里只留滚动的 `G_2333333`(与 final 重复)。原实现只查 logs 里的 `G_<步数>.pth`,所以永远凑不齐两档。现在优先从 weights 目录取最近两个导出档(自动跳过与 final 重复的那个),老实验才退回查 logs。
16
+
5
17
  ## [0.4.8] - 2026-11-02
6
18
 
7
19
  ### 修复
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cortico-world-fish-sing",
3
- "version": "0.4.8",
3
+ "version": "0.4.10",
4
4
  "description": "让她真的开口唱:B 站点歌或本地文件 → 分离 → 换声 → 混音,本机出声或发 QQ 语音条",
5
5
  "type": "module",
6
6
  "main": "./src/index.ts",
package/src/config.ts CHANGED
@@ -337,7 +337,8 @@ export function fishsingConfigGroups(): ConfigGroup[] {
337
337
  [at('notify.qqTarget')]: {
338
338
  type: 'string',
339
339
  title: 'QQ 通知目标',
340
- description: 'group:<群号> 或 private:<QQ号>;留空 = 只用桌宠。',
340
+ description: 'group:<群号> 或 private:<QQ号>(只填号码也行);留空 = 只用桌宠。',
341
+ 'x-hot': true,
341
342
  },
342
343
  },
343
344
  },
package/src/deliver.ts CHANGED
@@ -87,9 +87,15 @@ export interface OneBotTarget {
87
87
  label: string;
88
88
  }
89
89
 
90
- /** `group:123` / `private:456`;也接受 `群:123` / `私聊:456`(她有时候会这么写)。 */
90
+ /** `group:123` / `private:456`;也接受 `群:123` / `私聊:456`(她有时候会这么写)。
91
+ * 裸数字当成私聊 QQ 号——用户第一反应就是直接填号码,不能因为少个前缀就静默不发。 */
91
92
  export function parseTarget(to: string): OneBotTarget | null {
92
93
  const text = String(to || '').trim();
94
+ const bare = /^(\d{5,12})$/.exec(text);
95
+ if (bare) {
96
+ const id = Number(bare[1]);
97
+ return { action: 'send_private_msg', params: { user_id: id }, label: `私聊 ${id}` };
98
+ }
93
99
  const m = /^(group|群|private|私聊)\s*[::]\s*(\d+)$/.exec(text);
94
100
  if (!m) return null;
95
101
  const isGroup = m[1] === 'group' || m[1] === '群';
package/src/notify.ts CHANGED
@@ -36,7 +36,13 @@ export async function notify(deps: NotifyDeps, title: string, body = ''): Promis
36
36
  const text = body ? `${title}\n${body}` : title;
37
37
 
38
38
  const channel = deps.cfg.channel ?? 'auto';
39
- const target = parseTarget(String(deps.cfg.qqTarget ?? ''));
39
+ const rawTarget = String(deps.cfg.qqTarget ?? '').trim();
40
+ const target = parseTarget(rawTarget);
41
+ if (channel === 'auto' && rawTarget && !target) {
42
+ // 这里以前是完全静默的:qqTarget 写了但格式不对 → 直接走桌宠,日志一条没有,
43
+ // 用户以为"QQ 渠道坏了"(0.4.9 的真实事故:填了裸号码没写 private:)。
44
+ deps.log.warn(`QQ 通知目标「${rawTarget}」解析不了(要 group:<群号> 或 private:<QQ号>),走桌宠`);
45
+ }
40
46
  const wantQQ = channel === 'qq' || (channel === 'auto' && Boolean(target) && Boolean(deps.onebot.httpUrl));
41
47
  if (wantQQ) {
42
48
  if (target && deps.onebot.httpUrl) {
package/src/world.ts CHANGED
@@ -329,15 +329,38 @@ export class FishSingWorld implements World {
329
329
  };
330
330
  const variants: { ckpt: string; label: string; index: string }[] = [];
331
331
  const finalPth = join(weights, `${exp}.pth`);
332
- if (existsSync(finalPth)) variants.push({ ckpt: finalPth, label: 'final', index: indexOf(logDir) });
332
+ const hasFinal = existsSync(finalPth);
333
+ if (hasFinal) variants.push({ ckpt: finalPth, label: 'final', index: indexOf(logDir) });
333
334
  try {
334
- // 中间档从新到旧取 2 个(G_2333333 是完整存档,跟 final 重复,不算)
335
- const gs = readdirSync(logDir)
336
- .map((f) => /^G_(\d+)\.pth$/.exec(f))
337
- .filter((m): m is RegExpExecArray => Boolean(m) && m[1] !== '2333333')
338
- .sort((a, b) => Number(b[1]) - Number(a[1]))
339
- .slice(0, 2);
340
- for (const m of gs) variants.push({ ckpt: join(logDir, m[0]), label: `e${m[1]}`, index: indexOf(logDir) });
335
+ // 中间档从新到旧取 2 个。
336
+ // 注意:save_every_weights=1 时 RVC 把每个存档点导出成 weights/<exp>_e<N>_s<X>.pth,
337
+ // logs 里只剩滚动的 G_2333333(跟 final 重复)——所以必须优先看 weights 目录。
338
+ // (0.4.8 之前只查 logs 里的 G_<步数>.pth,结果永远"只有一个存档",选模对比被静默跳过。)
339
+ const esc = exp.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
340
+ const re = new RegExp(`^${esc}_e(\\d+)_s\\d+\\.pth$`);
341
+ const exported = readdirSync(weights)
342
+ .map((f) => re.exec(f))
343
+ .filter((m): m is RegExpExecArray => Boolean(m))
344
+ .map((m) => ({ epoch: Number(m[1]), file: m[0] }))
345
+ .sort((a, b) => b.epoch - a.epoch);
346
+ // 最新一个导出的存档通常就等于 final,跳过它(否则同一份权重会比两次)
347
+ const pool = hasFinal ? exported.slice(1) : exported;
348
+ for (const it of pool.slice(0, 2)) {
349
+ variants.push({
350
+ ckpt: join(weights, it.file),
351
+ label: `e${it.epoch}`,
352
+ index: indexOf(logDir),
353
+ });
354
+ }
355
+ if (variants.length < 2) {
356
+ // 老实验没有导出文件时退回 logs 里的 G_<步数>.pth
357
+ const gs = readdirSync(logDir)
358
+ .map((f) => /^G_(\d+)\.pth$/.exec(f))
359
+ .filter((m): m is RegExpExecArray => Boolean(m) && m[1] !== '2333333')
360
+ .sort((a, b) => Number(b[1]) - Number(a[1]))
361
+ .slice(0, 2);
362
+ for (const m of gs) variants.push({ ckpt: join(logDir, m[0]), label: `e${m[1]}`, index: indexOf(logDir) });
363
+ }
341
364
  } catch {
342
365
  /* 没有中间档就只用 final */
343
366
  }
@@ -394,6 +417,11 @@ export class FishSingWorld implements World {
394
417
  } catch (e) {
395
418
  this.host?.log.warn(`[fish-sing] 选模片段发 QQ 失败:${e instanceof Error ? e.message : String(e)}`);
396
419
  }
420
+ } else {
421
+ // 别静默:用户会以为"QQ 渠道坏了",实际是配置缺一半
422
+ this.host?.log.warn(
423
+ `[fish-sing] 选模片段没发 QQ:${!obTarget ? 'qqTarget 没配或格式不对(要 group:/private: 前缀)' : 'OneBot HTTP 地址没配'}`,
424
+ );
397
425
  }
398
426
  }
399
427
  this.host?.log.info(`[fish-sing] 选模对比已生成:${labels.join(' / ')}(${outDir})`);
package/tests/smoke.mjs CHANGED
@@ -1,52 +1,59 @@
1
- /**
2
- * Node 侧冒烟测试:入口能加载、通知渠道兜底逻辑正确。
3
- * 跑法:node --experimental-strip-types tests/smoke.mjs
4
- */
5
- import { notify } from '../src/notify.ts';
6
-
7
- let failed = 0;
8
- function check(name, ok, detail = '') {
9
- console.log(`${ok ? '✓' : '✗'} ${name}${detail ? `(${detail})` : ''}`);
10
- if (!ok) failed += 1;
11
- }
12
-
13
- const log = { info: () => {}, warn: () => {}, error: () => {} };
14
-
15
- // ---- 1. 桌宠渠道:pushEvent 被调用 ----
16
- let pushed = [];
17
- const r1 = await notify(
18
- { cfg: { enabled: true, channel: 'pet' }, pushEvent: (e) => pushed.push(e), onebot: { httpUrl: '' }, log },
19
- '训练完成:dfy3', '200 轮全部完成。',
20
- );
21
- check('桌宠渠道走 pushEvent', r1.via === 'pet' && pushed.length === 1 && pushed[0].type === 'fishsing.notify');
22
- check('事件带正文', typeof pushed[0]?.text === 'string' && pushed[0].text.includes('dfy3'));
23
-
24
- // ---- 2. auto + 没配 QQ 目标 → 退桌宠 ----
25
- pushed = [];
26
- const r2 = await notify(
27
- { cfg: { enabled: true, channel: 'auto' }, pushEvent: (e) => pushed.push(e), onebot: { httpUrl: '' }, log },
28
- '测试2',
29
- );
30
- check('auto 无 QQ 目标 → 桌宠', r2.via === 'pet' && pushed.length === 1);
31
-
32
- // ---- 3. QQ 不通 → 退桌宠(用户定的兜底规则) ----
33
- pushed = [];
34
- const r3 = await notify(
35
- { cfg: { enabled: true, channel: 'auto', qqTarget: 'group:123' }, pushEvent: (e) => pushed.push(e), onebot: { httpUrl: 'http://127.0.0.1:59999' }, log },
36
- '测试3',
37
- );
38
- check('QQ 不通退桌宠', r3.via === 'pet' && pushed.length === 1);
39
-
40
- // ---- 4. 关闭 → 不发 ----
41
- pushed = [];
42
- const r4 = await notify(
43
- { cfg: { enabled: false, channel: 'pet' }, pushEvent: (e) => pushed.push(e), onebot: { httpUrl: '' }, log },
44
- '测试4',
45
- );
46
- check('enabled=false 不发', r4.via === 'off' && pushed.length === 0);
47
-
48
- if (failed) {
49
- console.error(`\n${failed} 项失败`);
50
- process.exit(1);
51
- }
52
- console.log('\n冒烟测试全部通过');
1
+ /**
2
+ * Node 侧冒烟测试:入口能加载、通知渠道兜底逻辑正确。
3
+ * 跑法:node --experimental-strip-types tests/smoke.mjs
4
+ */
5
+ import { notify } from '../src/notify.ts';
6
+
7
+ let failed = 0;
8
+ function check(name, ok, detail = '') {
9
+ console.log(`${ok ? '✓' : '✗'} ${name}${detail ? `(${detail})` : ''}`);
10
+ if (!ok) failed += 1;
11
+ }
12
+
13
+ const log = { info: () => {}, warn: () => {}, error: () => {} };
14
+
15
+ // ---- 1. 桌宠渠道:pushEvent 被调用 ----
16
+ let pushed = [];
17
+ const r1 = await notify(
18
+ { cfg: { enabled: true, channel: 'pet' }, pushEvent: (e) => pushed.push(e), onebot: { httpUrl: '' }, log },
19
+ '训练完成:dfy3', '200 轮全部完成。',
20
+ );
21
+ check('桌宠渠道走 pushEvent', r1.via === 'pet' && pushed.length === 1 && pushed[0].type === 'fishsing.notify');
22
+ check('事件带正文', typeof pushed[0]?.text === 'string' && pushed[0].text.includes('dfy3'));
23
+
24
+ // ---- 2. auto + 没配 QQ 目标 → 退桌宠 ----
25
+ pushed = [];
26
+ const r2 = await notify(
27
+ { cfg: { enabled: true, channel: 'auto' }, pushEvent: (e) => pushed.push(e), onebot: { httpUrl: '' }, log },
28
+ '测试2',
29
+ );
30
+ check('auto 无 QQ 目标 → 桌宠', r2.via === 'pet' && pushed.length === 1);
31
+
32
+ // ---- 3. QQ 不通 → 退桌宠(用户定的兜底规则) ----
33
+ pushed = [];
34
+ const r3 = await notify(
35
+ { cfg: { enabled: true, channel: 'auto', qqTarget: 'group:123' }, pushEvent: (e) => pushed.push(e), onebot: { httpUrl: 'http://127.0.0.1:59999' }, log },
36
+ '测试3',
37
+ );
38
+ check('QQ 不通退桌宠', r3.via === 'pet' && pushed.length === 1);
39
+
40
+ // ---- 4. 关闭 → 不发 ----
41
+ pushed = [];
42
+ const r4 = await notify(
43
+ { cfg: { enabled: false, channel: 'pet' }, pushEvent: (e) => pushed.push(e), onebot: { httpUrl: '' }, log },
44
+ '测试4',
45
+ );
46
+ check('enabled=false 不发', r4.via === 'off' && pushed.length === 0);
47
+
48
+
49
+ // ---- 5. 裸号码当私聊(0.4.10 的坑:填了号码没前缀就静默不发) ----
50
+ const { parseTarget } = await import('../src/deliver.ts');
51
+ const t1 = parseTarget('2587509374');
52
+ check('裸号码 → 私聊', Boolean(t1) && t1.action === 'send_private_msg' && t1.params.user_id === 2587509374);
53
+ check('乱码 → null', parseTarget('2587509374abc') === null);
54
+
55
+ if (failed) {
56
+ console.error(`\n${failed} 项失败`);
57
+ process.exit(1);
58
+ }
59
+ console.log('\n冒烟测试全部通过');