diff --git a/.claude/skills/parse-book/scripts/parse_upgrade.py b/.claude/skills/parse-book/scripts/parse_upgrade.py index c2756f4..bdc4c56 100644 --- a/.claude/skills/parse-book/scripts/parse_upgrade.py +++ b/.claude/skills/parse-book/scripts/parse_upgrade.py @@ -251,8 +251,9 @@ def _strip_prefix(s): import re as _re global WIN_PREFIX_RE if WIN_PREFIX_RE is None: - # [窗…]/[本窗…] 任意变体全剥(窗29实测模型自造 "[窗本窗]",仅数字版剥不掉) - WIN_PREFIX_RE = _re.compile(r"^(?:\[[窗本][^\]]{0,6}\]\s*)+") + # [窗…]/[本窗…] 任意变体全剥(窗29实测模型自造 "[窗本窗]",仅数字版剥不掉; + # 深空实测又造 "[窗387-388]" 章号范围变体,7 字符超旧上限 6——放宽到 12) + WIN_PREFIX_RE = _re.compile(r"^(?:\[[窗本][^\]]{0,12}\]\s*)+") return WIN_PREFIX_RE.sub("", str(s)).strip() @@ -425,10 +426,26 @@ def new_card(conn, work_id, win_no, ent): note = _clean_alias(m.group(2)) if note: extra_alias.append(note) + # 初卡字段过守卫(深空 4917 实测:立卡路不走 merge_card,粘连/自造前缀/垃圾 + # 原样入库——更新路守了、立卡路漏了):列表值逐条拆分、剥前缀、垃圾拦截、带窗号 + fields0 = {} + for k, v in (ent.get("字段", {}) or {}).items(): + if not isinstance(v, list): + fields0[k] = v + continue + out, seen = [], set() + for it in v: + for seg in re.split(r";\s*(?=\[[窗本])", str(it)): + core = _strip_prefix(seg) + if not core or _is_garbage(core) or core in seen: + continue + out.append(f"[窗{win_no}] {core}") + seen.add(core) + fields0[k] = out payload = {"type": ent["型"], "名称": raw, "别名": [x for x in ([_clean_alias(a) for a in ent.get("别名", [])] + extra_alias) if x], "一句话摘要": ent.get("一句话摘要", ""), - "字段": ent.get("字段", {}) or {}, + "字段": fields0, "出场章": sorted(set(ent.get("出场章", []))), "来源": f"升格@窗{win_no}", "状态": "草稿", "目标库": "本书作品库", "可见范围": "本书私有",