dsh-armory 2.4.3 → 2.4.4

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.
@@ -341,8 +341,19 @@ async function localExpertPluginJson(plugin) {
341
341
  // 主理人人设的本机来源:WorkBuddy 自己下载过的专家包里就有 agents/<name>.md。
342
342
  // 上游只把一部分专家放在公开分发地址上(2026-10-27 实测 428 个里 185 个 404),
343
343
  // 所以本机缓存不是「优化」,而是这些专家唯一能拿到正文的途径。
344
+ // 人设文件名只做「取最后一段 + 拒绝穿越」,不做 ASCII 化:WorkBuddy 里真实存在
345
+ // 中文 agentName(如「腾讯健康-觅影-眼底彩照疾病分析专家」),safeSegment 会把它压成
346
+ // 一串连字符,永远找不到本机缓存里的 agents/<agentName>.md。
347
+ function agentFileStem(value) {
348
+ const raw = String(value || "").trim();
349
+ if (!raw) return "";
350
+ const base = basename(raw.replace(/\\/g, "/")).replace(/\.md$/i, "").trim();
351
+ if (!base || base === "." || base === ".." || base.includes("\0")) return "";
352
+ return base;
353
+ }
354
+
344
355
  async function localExpertPersona(plugin, agentName) {
345
- const names = [agentName, plugin].map((value) => safeSegment(value || "")).filter(Boolean);
356
+ const names = [agentName, plugin].map(agentFileStem).filter(Boolean);
346
357
  for (const version of await localExpertVersions(plugin)) {
347
358
  const dir = join(version.dir, "agents");
348
359
  for (const name of new Set(names)) {
@@ -468,6 +479,11 @@ export async function wbExpertDetail(payload) {
468
479
  }
469
480
  } catch (error) {
470
481
  personaNotice = describePersonaFailure(error);
482
+ // 只有「上游确实没有这份文件」(404 / 410)才生成替身。断网 / 超时 / 5xx 是暂时故障,
483
+ // 静默换成替身会让用户以为专家原文就长这样——如实报错,让用户重试或放本机覆盖。
484
+ if (!/HTTP (404|410)\b/.test(String(error?.message || error))) {
485
+ throw new Error(`拉取专家人设失败:${String(error?.message || error)}。请检查网络后重试,或把原文放到本机覆盖目录后再打开。`);
486
+ }
471
487
  }
472
488
  }
473
489
  if (!persona) {