@zaofan/dsh-qqbot 1.11.21 → 1.11.22

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 (2) hide show
  1. package/package.json +1 -1
  2. package/settings-host.js +34 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zaofan/dsh-qqbot",
3
- "version": "1.11.21",
3
+ "version": "1.11.22",
4
4
  "description": "QQ Bot IM channel plugin for deepseek-harness (dsh)",
5
5
  "type": "module",
6
6
  "main": "./entry.js",
package/settings-host.js CHANGED
@@ -795,7 +795,23 @@ export function apply(ctx) {
795
795
  for (const b of list) {
796
796
  const cfg = b.cfg || {};
797
797
  if (cfg.dataRoot) return String(cfg.dataRoot);
798
- if (cfg.cwd) return join(String(cfg.cwd), 'dshqqbot'); // 与 DEFAULT_DATA_SUBDIR 一致
798
+ if (cfg.cwd) return join(absCwd(cfg.cwd) || String(cfg.cwd), 'dshqqbot'); // 与 DEFAULT_DATA_SUBDIR 一致
799
+ }
800
+
801
+ // ★ 2026-10-30 修 issue #33:**实例没写 cwd/dataRoot 时也要能推出来**。
802
+ // 插件侧 src/gateway/data-root.ts 的默认口径是
803
+ // dataRoot = config.dataRoot || {absCwd(config.cwd) || process.cwd()}/dshqqbot
804
+ // 也就是说 patch 里不写 cwd,插件照样在 {process.cwd()}/dshqqbot 下建数据。
805
+ // 以前桥这边只认"显式写出"的 cwd ⇒ 返回空 ⇒ qun/* 全部报「推不出数据根」
806
+ // (现象:群管理的二维码/踢人/成员列表在简配实例上完全不可用),而 market/* 走
807
+ // resolveDataRootForWorkspace() 有完整兜底,所以看起来"市场能用、群管理坏了"。
808
+ // 这里补上同一套保守兜底:只在**确实存在启用中的实例**时返回默认根,
809
+ // 一个实例都没有仍然返回空(面板不该替用户凭空造数据根)。
810
+ const enabled = bots.filter((b) => b && !b.disabled && b.cfg);
811
+ if (enabled.length) {
812
+ const first = enabled[0].cfg || {};
813
+ const base = absCwd(first.cwd) || process.cwd();
814
+ return join(base, 'dshqqbot');
799
815
  }
800
816
  } catch { /* 推不出来就交给 ensurePath 兜底 */ }
801
817
  return '';
@@ -1185,6 +1201,23 @@ export function apply(ctx) {
1185
1201
  i += 1;
1186
1202
  }
1187
1203
  }
1204
+ // ★ 2026-10-30 修 issue #33(同类问题一次收口):
1205
+ // patch 里**没写** cwd/dataRoot 的实例,解析结果里 cwd 一直是空,
1206
+ // 而下游一大票路由都是 `bot.cfg.dataRoot || bot.cwd` ⇒ 全拿到空串
1207
+ // (qun/* 报「推不出数据根」;导出、图库、群台账、join-pending… 同理)。
1208
+ // 这里按插件 src/gateway/data-root.ts 的口径补默认值:
1209
+ // dataRoot || {absCwd(cfg.cwd) || process.cwd()}/dshqqbot
1210
+ // ⚠️ bot.cwd 的历史语义就是【数据根】,不是工作目录(cfg.cwd 才是工作目录)。
1211
+ for (const b of bots) {
1212
+ if (!b) continue;
1213
+ const cfg = b.cfg || {};
1214
+ if (b.cwd) continue;
1215
+ try {
1216
+ b.cwd = cfg.dataRoot
1217
+ ? String(cfg.dataRoot)
1218
+ : join(absCwd(cfg.cwd) || process.cwd(), 'dshqqbot');
1219
+ } catch { b.cwd = ''; }
1220
+ }
1188
1221
  return { raw, hasFile, bots };
1189
1222
  }
1190
1223
  /** 从磁盘读取并解析(parsePatchFrom 的包装) */