dknowc-dsh 2.1.0 → 2.2.0

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 (45) hide show
  1. package/README.md +25 -8
  2. package/package.json +3 -3
  3. package/skills/dknowc-official-doc-writer/README.md +17 -8
  4. package/skills/dknowc-official-doc-writer/SKILL.md +31 -29
  5. package/skills/dknowc-official-doc-writer/reference/fact_discipline.md +2 -0
  6. package/skills/dknowc-official-doc-writer/reference/material_usage_guidance.md +1 -1
  7. package/skills/dknowc-official-doc-writer/reference/output_guide.md +4 -4
  8. package/skills/dknowc-official-doc-writer/reference/research_notes.md +6 -2
  9. package/skills/dknowc-official-doc-writer/reference/review_checklist.md +11 -11
  10. package/skills/dknowc-official-doc-writer/reference/revision_workflow.md +4 -4
  11. package/skills/dknowc-official-doc-writer/reference/sample_search_result.md +1 -1
  12. package/skills/dknowc-official-doc-writer/reference/sample_trace_report.html +387 -430
  13. package/skills/dknowc-official-doc-writer/reference/search_guide.md +8 -8
  14. package/skills/dknowc-official-doc-writer/reference/search_intro.md +2 -2
  15. package/skills/dknowc-official-doc-writer/reference/search_policy.md +4 -4
  16. package/skills/dknowc-official-doc-writer/reference/task_router.md +77 -34
  17. package/skills/dknowc-official-doc-writer/scripts/attribution.py +1 -1
  18. package/skills/dknowc-official-doc-writer/scripts/build_trace_json.py +9 -1
  19. package/skills/dknowc-official-doc-writer/scripts/check_materials.py +57 -23
  20. package/skills/dknowc-official-doc-writer/scripts/deep_convert.py +27 -4
  21. package/skills/dknowc-official-doc-writer/scripts/deep_query.py +1 -1
  22. package/skills/dknowc-official-doc-writer/scripts/dkag_search.py +5 -2
  23. package/skills/dknowc-official-doc-writer/scripts/extract_reference.py +1 -1
  24. package/skills/dknowc-official-doc-writer/scripts/format_document.py +1 -1
  25. package/skills/dknowc-official-doc-writer/scripts/initialize.py +1 -1
  26. package/skills/dknowc-official-doc-writer/scripts/merge_search_results.py +102 -2
  27. package/skills/dknowc-official-doc-writer/scripts/outline_reference.py +1 -1
  28. package/skills/dknowc-official-doc-writer/scripts/render_trace_html.py +253 -246
  29. package/skills/dknowc-official-doc-writer/scripts/review_document.py +1 -1
  30. package/skills/dknowc-official-doc-writer/scripts/source_note_html.py +9 -7
  31. package/skills/dknowc-official-doc-writer/scripts/template_generator.py +1 -1
  32. package/skills/dknowc-ppt-assistant/README.md +10 -12
  33. package/skills/dknowc-ppt-assistant/SKILL.md +8 -8
  34. package/skills/dknowc-ppt-assistant/scripts/initialize.py +1 -1
  35. package/skills/dknowc-ppt-assistant/scripts/render_trace_html.py +6 -3
  36. package/skills/dknowc-ppt-assistant/workflows/generate-pptx.md +19 -23
  37. package/skills/dknowc-trusted-search/README.md +11 -12
  38. package/skills/dknowc-trusted-search/SKILL.md +30 -26
  39. package/skills/dknowc-trusted-search/scripts/deep_convert.py +124 -0
  40. package/skills/dknowc-trusted-search/scripts/deep_query.py +10 -0
  41. package/skills/dknowc-trusted-search/scripts/initialize.py +1 -0
  42. package/skills/dknowc-trusted-search/scripts/merge_search_results.py +109 -12
  43. package/skills/dknowc-trusted-search/scripts/render_trace_html.py +333 -253
  44. package/skills/dknowc-trusted-search/scripts/trusted_search.py +7 -0
  45. package/src/index.js +3 -3
@@ -1,14 +1,15 @@
1
1
  #!/usr/bin/env python3
2
- """可信溯源核验报告渲染器:把结构化正文/素材 JSON 渲染为单文件可核验 HTML。
2
+ """产出物 HTML 渲染器:把结构化正文/素材 JSON 渲染为单文件三页 HTML(正文 / 溯源核验报告 / 知识专库)。
3
3
 
4
4
  报告定位:不止展示"材料从哪来"(溯源),更要传达"我们查过了,可以交付"(核验)。
5
- 3.7.0 架构(交互形态参考自研原型,数据口径保持自有与真实):
6
- - 顶栏:身份章 + 标题 + 工具组(只看正文 / 复制全文 / 打印归档)+ 阅读进度条
7
- - Hero:大标题 + 真实统计(N 次检索 · M 条材料 · K 处引用)+ 双视图切换
5
+ 3.8.0 架构(交互形态参考自研原型,数据口径保持自有与真实):
6
+ - 顶栏:身份章 + 标题 + 工具组(复制全文 / 打印归档)+ 阅读进度条
7
+ - Hero:大标题 + 真实统计(N 次检索 · M 条材料 · K 处引用)+ 三页切换
8
8
  - 过程回顾条:检索 → 入库 → 逐条比对 → 核验完成(静态回放,数字全部真实计算;
9
9
  无思考流数据就不展示"思考"步骤——硬造即违背核验诚实性)
10
- - 核验报告视图(默认):核验报告单 + 正文分节卡;角标点击跳知识专库定位
11
- - 知识专库视图(全屏):大搜索 + 热词(标题/正文高频词真实计算)+ 检索分组 tabs + 材料卡
10
+ - 正文页(默认):干净正式内容,不带任何角标/胶囊(与 Word 正文一致)
11
+ - 溯源核验报告页:过程回顾 + 核验报告单 + 带角标正文(角标可点击跳来源)
12
+ - 知识专库页(全屏):大搜索 + 热词(标题/正文高频词真实计算)+ 检索分组 tabs + 材料卡
12
13
  三个核验层次:报告级(核验报告单)/材料级(来源卡核验链标记)/引用级(角标一一绑定)。
13
14
  诚实原则:脚本真实计算的结果才打勾;无法自动判定的项不虚构展示("现行效力"人工复核提示行已按产品要求移除)。
14
15
  布局为单文件静态 HTML;打印归档模式单栏全展开并附材料附录。
@@ -265,8 +266,9 @@ def source_from_article(item: Dict[str, Any], index: int, segment: Optional[Dict
265
266
  source["chain_full"] = " › ".join(segments[0]["chain"]) if segments else ""
266
267
  # 发文字号(接口 policyFiles.writtenText,本地标题匹配)
267
268
  source["doc_number"] = first_str(item.get("文号"), item.get("doc_number"))
268
- # 所属搜索条件(多路检索分组)与引用状态(未引用=接口召回但正文未采用)
269
+ # 所属搜索条件(多路检索分组)、检索通道(深知深度搜索/深知可信搜索)与引用状态
269
270
  source["search_key"] = first_str(item.get("搜索条件"), item.get("search_key"))
271
+ source["channel"] = first_str(item.get("检索通道"), item.get("channel"))
270
272
  source["used"] = item.get("已引用", item.get("used", True))
271
273
  if not isinstance(source["used"], bool):
272
274
  source["used"] = True
@@ -587,18 +589,31 @@ def compute_process_stats(sources: List[Dict[str, str]], answer: str) -> Dict[st
587
589
  cond_rows = []
588
590
  for key in order:
589
591
  group = [s for s in sources if (s.get("search_key") or "").strip() == key]
592
+ # 该路检索的接口通道(深知深度搜索/深知可信搜索):取组内多数通道
593
+ # (同一材料被两接口召回时通道为顿号拼接的多值,按拆分后的单值计数)
594
+ chan_counts: Dict[str, int] = {}
595
+ for s in group:
596
+ ch = (s.get("channel") or "").strip()
597
+ for token in [t.strip() for t in ch.split("、") if t.strip()]:
598
+ chan_counts[token] = chan_counts.get(token, 0) + 1
599
+ channel = max(chan_counts, key=chan_counts.get) if chan_counts else ""
590
600
  cond_rows.append({
591
601
  "key": key,
592
602
  "total": len(group),
593
603
  "used": sum(1 for s in group if s.get("used", True)),
604
+ "channel": channel,
594
605
  })
595
606
  n_searches = len(cond_rows) or (1 if sources else 0)
607
+ deep_routes = sum(1 for r in cond_rows if "深度" in r.get("channel", ""))
608
+ trusted_routes = sum(1 for r in cond_rows if "可信" in r.get("channel", ""))
596
609
  used_count = sum(1 for s in sources if s.get("used", True))
597
610
  unused_count = len(sources) - used_count
598
611
  n_cite_marks = len(re.findall(r"\[(\d+)\]", answer))
599
612
  return {
600
613
  "conds": cond_rows,
601
614
  "n_searches": n_searches,
615
+ "deep_routes": deep_routes,
616
+ "trusted_routes": trusted_routes,
602
617
  "has_cond_detail": bool(cond_rows),
603
618
  "n_materials": len(sources),
604
619
  "used_count": used_count,
@@ -607,60 +622,6 @@ def compute_process_stats(sources: List[Dict[str, str]], answer: str) -> Dict[st
607
622
  }
608
623
 
609
624
 
610
- HOT_STOP = {
611
- "关于", "通知", "工作", "意见", "方案", "实施", "有关", "问题", "情况", "报告", "总结",
612
- "制度", "体系", "机制", "指导", "贯彻", "落实", "进一步", "以及", "其他", "相关", "以下",
613
- "以上", "共和国", "人民", "中华", "国务院", "人民政府", "办公厅", "印发", "试行",
614
- "办法", "条例", "若干", "的重点", "有所", "一个", "方面", "方式", "内容", "基本",
615
- "发展", "建设", "政策", "产业", "企业", "应用", "改革", "目标", "任务", "规划",
616
- "领域", "措施", "支持", "行动", "服务", "管理", "政府",
617
- }
618
-
619
-
620
- def extract_hot_terms(answer: str, sources: List[Dict[str, str]], top: int = 8) -> List[str]:
621
- """知识专库热词:材料标题(加权)+ 检索条件 + 正文的高频 2-4 字词,真实统计。
622
-
623
- 泛词过滤:出现在超过 60% 材料标题中的词(如库内全部材料共有的主题词)
624
- 无法筛出子集,没有筛选价值,剔除。
625
- """
626
- corpus_parts: List[str] = []
627
- for s in sources:
628
- if s.get("title"):
629
- corpus_parts.extend([s["title"]] * 3)
630
- if s.get("search_key"):
631
- corpus_parts.extend([s["search_key"]] * 2)
632
- clean_answer = re.sub(r"\[\d+\]", "", answer or "")
633
- corpus_parts.append(clean_answer)
634
- corpus = "\n".join(corpus_parts)
635
-
636
- counts: Dict[str, int] = {}
637
- for run in re.findall(r"[一-鿿]{2,}", corpus):
638
- for n in (2, 3, 4):
639
- for i in range(len(run) - n + 1):
640
- gram = run[i:i + n]
641
- counts[gram] = counts.get(gram, 0) + 1
642
-
643
- titles = [s.get("title") or "" for s in sources]
644
- n_titles = max(1, len(titles))
645
- df_limit = max(1, int(n_titles * 0.6))
646
-
647
- cands = [(g, c) for g, c in counts.items()
648
- if c >= 2 and g not in HOT_STOP and "的" not in g and not any(ch.isdigit() for ch in g)
649
- and sum(1 for t in titles if g in t) <= df_limit]
650
- cands.sort(key=lambda x: (-x[1], -len(x[0])))
651
- kept: List[Tuple[str, int]] = []
652
- for gram, count in cands:
653
- redundant = False
654
- for kgram, kcount in kept:
655
- # 短词是已入选高频长词的子串且计数接近 → 被长词覆盖,剔除
656
- if gram in kgram and kcount >= count * 0.6:
657
- redundant = True
658
- break
659
- if not redundant:
660
- kept.append((gram, count))
661
- if len(kept) >= top:
662
- break
663
- return [g for g, _ in kept]
664
625
 
665
626
 
666
627
  # ============================================================
@@ -725,7 +686,8 @@ def render_excerpt_html(text: str) -> str:
725
686
  return f'<div class="sc-excerpt rich">{sanitize_table_html(value)}</div>'
726
687
 
727
688
 
728
- def parse_answer_blocks(answer: str, valid_ids: set, chip_map: Optional[Dict[str, str]] = None) -> Tuple[List[Dict[str, Any]], set]:
689
+ def parse_answer_blocks(answer: str, valid_ids: set, chip_map: Optional[Dict[str, str]] = None,
690
+ strip_cites: bool = False) -> Tuple[List[Dict[str, Any]], set]:
729
691
  """把正文 Markdown 解析为结构化块;同时收集全部角标。
730
692
 
731
693
  角标渲染为原型式 sup.cite 上标胶囊;段落对应的溯源卡(src-card)由
@@ -782,7 +744,10 @@ def parse_answer_blocks(answer: str, valid_ids: set, chip_map: Optional[Dict[str
782
744
 
783
745
  def make_block_repl(block_text: str):
784
746
  """按块构造角标替换器:同段同材料只保留最后一次出现的角标(前处整体删除),
785
- 最后一处挂数字角标 + 引文胶囊——一段中同一材料只出现一次。"""
747
+ 最后一处挂数字角标 + 引文胶囊——一段中同一材料只出现一次。
748
+ 正文页(strip_cites=True)直接删掉全部角标,输出干净正文。"""
749
+ if strip_cites:
750
+ return lambda match: ""
786
751
  remaining: Dict[str, int] = {}
787
752
  for cid in re.findall(r"\[(\d+)\]", block_text):
788
753
  remaining[cid] = remaining.get(cid, 0) + 1
@@ -812,7 +777,7 @@ def parse_answer_blocks(answer: str, valid_ids: set, chip_map: Optional[Dict[str
812
777
  # 注意:须把连续角标序列整体换位(如 [13][14];),否则标点被夹在两个胶囊
813
778
  # 中间——[13];[14] 会让分号"跑到胶囊后边"。
814
779
  block = re.sub(r"((?:\[\d+\])+)([。;,、!?:;,.])", r"\2\1", block)
815
- ids = citation_ids(block)
780
+ ids = [] if strip_cites else citation_ids(block)
816
781
  repl = make_block_repl(block)
817
782
  heading_match = re.match(r"^(#{1,4})\s+(.+)$", block)
818
783
  if heading_match:
@@ -826,7 +791,8 @@ def parse_answer_blocks(answer: str, valid_ids: set, chip_map: Optional[Dict[str
826
791
  table_lines.append(lines[idx].strip())
827
792
  idx += 1
828
793
  repl = make_block_repl("\n".join(table_lines))
829
- blocks.append({"kind": "table", "html": render_markdown_table(table_lines, repl), "cites": citation_ids("\n".join(table_lines))})
794
+ blocks.append({"kind": "table", "html": render_markdown_table(table_lines, repl),
795
+ "cites": [] if strip_cites else citation_ids("\n".join(table_lines))})
830
796
  elif block in {"---", "***"}:
831
797
  blocks.append({"kind": "hr", "html": '<hr class="doc-divider">', "cites": []})
832
798
  idx += 1
@@ -940,7 +906,14 @@ def render_source_links(url: str, policy_url: str = "", snapshot: str = "", link
940
906
 
941
907
  def render_verify_panel(v: Dict[str, Any]) -> str:
942
908
  """核验报告单:报告级核验结论 + 五项指标。"""
943
- manual_checks_html = "".join("<br>· " + esc(x) for x in v.get("manual_checks", []))
909
+ # 核验明细(溯源 JSON 的 verification_checks)默认折叠——明细可能很长(逐条"已完成…"),
910
+ # 平铺会把核验单撑得过高;折叠后默认只见一句方式说明,点开才展开逐条明细。
911
+ _checks = [str(x) for x in (v.get("manual_checks") or []) if str(x).strip()]
912
+ manual_checks_html = ""
913
+ if _checks:
914
+ _items = "".join(f"<li>{esc(x)}</li>" for x in _checks)
915
+ manual_checks_html = (f'<details class="v-checks"><summary>查看核验明细({len(_checks)} 项)</summary>'
916
+ f'<ul>{_items}</ul></details>')
944
917
  ov = v["overall"]
945
918
  state = "ok" if ov["passed"] else "fail"
946
919
  stamp = '<span class="v-stamp">已核验</span>' if ov["passed"] else '<span class="v-stamp bad">核验未通过</span>'
@@ -976,7 +949,7 @@ def render_verify_panel(v: Dict[str, Any]) -> str:
976
949
  bd_html = '<div class="vi"><span class="s none">— 引用对应 0/0</span><span class="d">正文里没有来源角标</span></div>'
977
950
  elif not bd["unbound"]:
978
951
  bd_html = (f'<div class="vi"><span class="s ok">✓ 引用对应 {bd["bound"]}/{bd["total"]}</span>'
979
- f'<span class="d">正文每处 [n] 都能找到对应来源文章</span></div>')
952
+ f'<span class="d">正文每一处引用都已对回来源文章,点开即可核对原文</span></div>')
980
953
  else:
981
954
  unbound_text = "、".join(f"[{esc(x)}]" for x in bd["unbound"][:8])
982
955
  bd_html = (f'<div class="vi"><span class="s fail">✗ 引用对应 {bd["bound"]}/{bd["total"]}</span>'
@@ -1000,9 +973,8 @@ def render_verify_panel(v: Dict[str, Any]) -> str:
1000
973
  f'<span class="d">{esc(" · ".join(parts)) if parts else "材料没标类型"}</span></div>')
1001
974
 
1002
975
  sc = v["self_check"]
976
+ selfcheck_notes_html = ""
1003
977
  if sc["status"] == "pass":
1004
- notes = ";".join(note for _, note in sc["items"].values() if note)
1005
- title_attr = f' title="{esc(notes)}"' if notes else ""
1006
978
  missing = sc.get("missing_items") or []
1007
979
  none_count = sum(1 for status, _ in sc["items"].values() if status == "none")
1008
980
  unrecorded = len(missing) + none_count
@@ -1011,10 +983,15 @@ def render_verify_panel(v: Dict[str, Any]) -> str:
1011
983
  if missing:
1012
984
  detail = f"缺少:{'、'.join(missing)}"
1013
985
  else:
1014
- item_names = "、".join(sc["items"].keys())
1015
- detail = item_names + (" · 悬停查看说明" if notes else "")
1016
- sc_html = (f'<div class="vi"><span class="s ok"{title_attr}>✓ 交付前检查 {sc["passed"]}/{sc["total"]}{esc(none_note)}</span>'
986
+ detail = "、".join(sc["items"].keys())
987
+ sc_html = (f'<div class="vi"><span class="s ok">✓ 交付前检查 {sc["passed"]}/{sc["total"]}{esc(none_note)}</span>'
1017
988
  f'<span class="d">{esc(detail)}</span></div>')
989
+ # 逐项说明默认折叠(与底部"核验明细"同款交互、触屏可用),不再用鼠标悬浮 tooltip
990
+ note_items = [(label, note) for label, (status, note) in sc["items"].items() if note]
991
+ if note_items:
992
+ _li = "".join(f"<li><b>{esc(label)}</b>:{esc(note)}</li>" for label, note in note_items)
993
+ selfcheck_notes_html = (f'<details class="v-checks"><summary>查看交付前检查说明({len(note_items)} 项)</summary>'
994
+ f'<ul>{_li}</ul></details>')
1018
995
  elif sc["status"] == "fail":
1019
996
  failed_parts = []
1020
997
  for label, (status, note) in sc["items"].items():
@@ -1036,7 +1013,7 @@ def render_verify_panel(v: Dict[str, Any]) -> str:
1036
1013
  <div class="v-grid">
1037
1014
  {tr_html}{bd_html}{fr_html}{cov_html}{sc_html}
1038
1015
  </div>
1039
- <div class="v-note">核验方式:先用深知可信搜索找权威来源,再把正文每处依据和原文逐条比对(都能点开原文回看),最后做了交付前五项检查。{manual_checks_html}</div>
1016
+ <div class="v-note">AI 已完成自验收,正文依据可逐条点开原文复核。{selfcheck_notes_html}{manual_checks_html}</div>
1040
1017
  </div>"""
1041
1018
 
1042
1019
 
@@ -1070,10 +1047,12 @@ def render_src_card(jb: Dict[str, str], cid: str, dup: bool = False) -> str:
1070
1047
  )
1071
1048
 
1072
1049
 
1073
- def render_section_cards(sections: List[Dict[str, Any]], sources: List[Dict[str, str]]) -> str:
1050
+ def render_section_cards(sections: List[Dict[str, Any]], sources: List[Dict[str, str]],
1051
+ with_ids: bool = True, id_prefix: str = "sec") -> str:
1074
1052
  """正文渲染(原型复刻):chapter(h2)+ lead/para 段落 + 段后 src-card 溯源卡。
1075
1053
 
1076
1054
  溯源卡按段内角标顺序输出;同一材料在同段只出一张,跨段重复出现标记 dup-card(灰化)。
1055
+ with_ids=False 时不输出 `id="sec-N"`(正文页锚点唯一,溯源核验报告页复用同一份正文时避免重复 id)。
1077
1056
  """
1078
1057
  parts: List[str] = []
1079
1058
  first_para = True
@@ -1093,7 +1072,8 @@ def render_section_cards(sections: List[Dict[str, Any]], sources: List[Dict[str,
1093
1072
  state = "bad" if unbound else ""
1094
1073
  text = f"本章引用 {len(sec_cites)} 处" + (f" · {unbound} 处未绑定" if unbound else " · 已核验")
1095
1074
  badge_html = f'<span class="sec-badge {state}">{esc(text)}</span>'
1096
- parts.append(f'<section class="chapter" id="sec-{sec_idx}">'
1075
+ sec_id = f' id="{id_prefix}-{sec_idx}"' if with_ids else ""
1076
+ parts.append(f'<section class="chapter"{sec_id}>'
1097
1077
  f'<header class="ch-head"><h2>{esc(chapter_title)}</h2>{badge_html}</header>')
1098
1078
  for b in sec["blocks"]:
1099
1079
  if b["kind"] == "heading":
@@ -1221,9 +1201,22 @@ def render_process_bar(stats: Dict[str, Any], verification: Dict[str, Any]) -> s
1221
1201
  ov = verification["overall"]
1222
1202
  tr = verification["traceability"]
1223
1203
  first_query = stats["conds"][0]["key"] if stats["conds"] else ""
1204
+ # 步骤一标题按接口通道拆分(深度搜索与可信搜索是两个接口,不混计成一个数);
1205
+ # 无通道信息(历史 JSON)时退回"深知检索 N 次"
1206
+ deep_n = stats.get("deep_routes", 0)
1207
+ trusted_n = stats.get("trusted_routes", 0)
1208
+ if deep_n and trusted_n:
1209
+ step1_title = f"深度搜索 {deep_n} 路 · 可信补搜 {trusted_n} 次"
1210
+ elif deep_n:
1211
+ step1_title = f"深知深度搜索 {deep_n} 路"
1212
+ elif trusted_n:
1213
+ step1_title = f"深知可信搜索 {trusted_n} 次"
1214
+ else:
1215
+ step1_title = f"深知检索 {stats['n_searches']} 次"
1224
1216
  detail_rows = "".join(
1225
- f'<div class="pd-row"><b>{esc(row["key"])}</b>'
1226
- f'<span>召回 {row["total"]} 条 · 正文采用 {row["used"]} 条</span></div>'
1217
+ f'<div class="pd-row"><b>{esc(row["key"])}'
1218
+ + (f'({"深度搜索+可信搜索" if ("深度" in row.get("channel", "") and "可信" in row.get("channel", "")) else ("深度搜索" if "深度" in row.get("channel", "") else "可信搜索")})' if row.get("channel") else "")
1219
+ + f'</b><span>召回 {row["total"]} 条 · 正文采用 {row["used"]} 条</span></div>'
1227
1220
  for row in stats["conds"]
1228
1221
  ) or '<div class="pd-row"><span>本次溯源 JSON 未记录各次检索条件</span></div>'
1229
1222
  detail_hint = f'{esc(short(first_query, 26))}…' if (stats["n_searches"] > 1 and first_query) else "查看检索明细"
@@ -1238,12 +1231,12 @@ def render_process_bar(stats: Dict[str, Any], verification: Dict[str, Any]) -> s
1238
1231
  step4_label = "核验完成" if ov["passed"] else "核验未完全通过"
1239
1232
  step4_sub = "结论:正文依据逐条对过原文" if ov["passed"] else esc(short(";".join(ov["reasons"]) or "见核验报告单", 30))
1240
1233
  return f"""
1241
- <section class="process" aria-label="生成过程回顾">
1242
- <div class="p-head"><b>过程回顾</b><span>数字来自本次任务的真实记录</span></div>
1234
+ <section class="process" aria-label="AI 自验收">
1235
+ <div class="p-head"><b>AI 自验收</b><span>交付前由 AI 自动完成,数字来自本次任务的真实记录</span></div>
1243
1236
  <ol class="p-steps">
1244
1237
  <li class="p-step expandable" id="p-step-search" role="button" tabindex="0" title="展开各路检索明细">
1245
1238
  <span class="p-no">1</span>
1246
- <div class="p-txt"><b>深知检索 {stats['n_searches']} 次</b><i>{step1_sub}</i></div>
1239
+ <div class="p-txt"><b>{esc(step1_title)}</b><i>{step1_sub}</i></div>
1247
1240
  </li>
1248
1241
  <li class="p-arrow" aria-hidden="true">›</li>
1249
1242
  <li class="p-step">
@@ -1265,7 +1258,7 @@ def render_process_bar(stats: Dict[str, Any], verification: Dict[str, Any]) -> s
1265
1258
  </section>"""
1266
1259
 
1267
1260
 
1268
- def render_library_view(sources: List[Dict[str, str]], hot_terms: List[str]) -> str:
1261
+ def render_library_view(sources: List[Dict[str, str]], doc_title: str = "") -> str:
1269
1262
  """知识专库全屏视图:大搜索 + 热词 + 检索分组 tabs + 材料卡列表。"""
1270
1263
  if not sources:
1271
1264
  return ('<section class="view" id="view-library" aria-label="知识专库">'
@@ -1288,30 +1281,18 @@ def render_library_view(sources: List[Dict[str, str]], hot_terms: List[str]) ->
1288
1281
  tabs = [f'<button class="on" data-cond="" type="button">全部({len(sources)})</button>']
1289
1282
  for name, count in conds:
1290
1283
  tabs.append(f'<button data-cond="{esc(name)}" type="button">{esc(name)}({count})</button>')
1291
- if unused_sources:
1292
- tabs.append(f'<button data-cond="__unused__" type="button">未引用({len(unused_sources)})</button>')
1293
-
1294
- hot_html = ""
1295
- if hot_terms:
1296
- hot_items = "".join(f'<button class="hot-term" type="button">{esc(term)}</button>' for term in hot_terms)
1297
- hot_html = f'<div class="hot-terms" aria-label="热门搜索词"><span class="hot-label">大家都在搜</span>{hot_items}</div>'
1298
-
1299
1284
  cards_html = "".join(render_source_card(s) for s in used_sources)
1300
1285
  cards_html += "".join(render_source_card(s) for s in unused_sources)
1301
1286
 
1302
- cited_verified = sum(1 for s in used_sources if s.get("verified"))
1303
- badge = "全部已核验" if used_sources and cited_verified == len(used_sources) else f"{cited_verified}/{len(used_sources)} 已核验"
1287
+ lib_title = f"知识专库:{doc_title}" if (doc_title or "").strip() else "知识专库"
1304
1288
  return f"""
1305
1289
  <section class="view" id="view-library" aria-label="知识专库">
1306
1290
  <div class="lib-head">
1307
- <div class="lib-title"><b>知识专库</b>
1308
- <span>共 {len(sources)} 条 · 已引用 {len(used_sources)} · {esc(badge)}</span>
1309
- </div>
1291
+ <div class="lib-title"><b>{esc(lib_title)}</b></div>
1310
1292
  <div class="lib-searchWrap">
1311
1293
  <span class="lib-searchIcon" aria-hidden="true">⌕</span>
1312
1294
  <input class="lib-search" type="search" placeholder="搜索标题 / 来源 / 摘录…" aria-label="搜索来源文章">
1313
1295
  </div>
1314
- {hot_html}
1315
1296
  <div class="lib-tabs" role="tablist" aria-label="按检索分组筛选">{"".join(tabs)}</div>
1316
1297
  </div>
1317
1298
  <div class="lib-list" id="lib-list">{cards_html}</div>
@@ -1333,7 +1314,7 @@ def render_toc(sections: List[Dict[str, Any]]) -> str:
1333
1314
  continue
1334
1315
  number, title_text = split_heading_number(title)
1335
1316
  label = f"{number} {title_text}" if (number and title_text) else title_text
1336
- items.append(f'<a href="#sec-{i}">{esc(short(label, 16))}</a>')
1317
+ items.append(f'<a href="#sec-{i}" data-sec="{i}">{esc(short(label, 16))}</a>')
1337
1318
  if len(items) < 6:
1338
1319
  return ""
1339
1320
  return f'<nav class="toc" aria-label="章节目录">{"".join(items)}</nav>'
@@ -1385,16 +1366,20 @@ body{margin:0;font-family:-apple-system,BlinkMacSystemFont,"SF Pro Text","Segoe
1385
1366
  color:var(--ink);background:#f4f5f7;line-height:1.75;font-size:14.5px}
1386
1367
  a{color:var(--brand)}
1387
1368
 
1388
- /* ===== 顶栏 ===== */
1389
- .topbar{position:sticky;top:0;z-index:50;display:flex;justify-content:space-between;align-items:center;gap:10px;
1390
- padding:9px 22px;background:rgba(255,255,255,.92);backdrop-filter:blur(10px);
1391
- border-bottom:1px solid var(--line)}
1392
- .tb-left{display:flex;align-items:center;gap:10px;min-width:0}
1369
+ /* ===== Banner 统一区 =====
1370
+ 2026-10-14 反馈意见一:整体结构=上部 banner 区+下部正文区。
1371
+ banner 内统一收纳:文档名+三切换+工具(复制/导出)+原问题+统计;
1372
+ 切换三页时 banner 高度与位置保持不变(同一容器,无页面各自的顶部块)。 */
1373
+ .banner{position:sticky;top:0;z-index:50;background:rgba(255,255,255,.94);backdrop-filter:blur(10px);
1374
+ border-bottom:1px solid var(--line);padding:8px 22px 9px}
1375
+ .banner-bar{display:flex;align-items:center;gap:14px;max-width:1080px;margin:0 auto}
1376
+ .banner-bar .tb-title{flex:0 1 auto;min-width:0;max-width:30%;overflow:hidden;text-overflow:ellipsis;
1377
+ white-space:nowrap;color:var(--muted);font-size:12.5px}
1378
+ .banner-bar .view-switch{margin:0 auto}
1379
+ .banner-bar .tb-tools{flex:0 0 auto}
1393
1380
  .tb-stamp{flex:none;font-size:12.5px;font-weight:800;color:var(--navy);letter-spacing:4px;text-indent:4px}
1394
1381
  .tb-stamp::before,.tb-stamp::after{content:"";display:inline-block;width:22px;border-top:1px solid var(--line-strong);
1395
1382
  vertical-align:middle;margin:0 6px}
1396
- .tb-title{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;color:var(--muted);font-size:13px}
1397
- .tb-right{display:flex;align-items:center;gap:8px;flex:none}
1398
1383
  .view-switch{display:inline-flex;border:1px solid var(--line);border-radius:999px;overflow:hidden;background:#fff}
1399
1384
  .view-switch button{border:0;background:transparent;color:var(--muted);font-size:12.5px;font-weight:700;
1400
1385
  padding:5px 14px;cursor:pointer}
@@ -1415,33 +1400,27 @@ a{color:var(--brand)}
1415
1400
  .progress{position:absolute;left:0;right:0;bottom:-1px;height:2px;background:transparent}
1416
1401
  .progress i{display:block;height:100%;width:0;background:linear-gradient(90deg,#6512ad,#8b5cf6)}
1417
1402
 
1418
- /* ===== Hero ===== */
1419
- .hero{position:relative;background:linear-gradient(180deg,#fbfaff 0%,#f7f4fd 100%);
1420
- color:var(--ink);padding:32px 22px 58px;text-align:center;border-bottom:1px solid var(--line)}
1421
- .r-badge{display:inline-flex;align-items:center;gap:14px;margin:0 0 8px;
1422
- background:var(--grad);color:#fff;border-radius:999px;padding:4px 22px;
1423
- font-size:15px;font-weight:800;letter-spacing:7px;text-indent:7px;line-height:1.6;
1424
- box-shadow:0 2px 8px rgba(101,18,173,.22)}
1425
- .hero h1{margin:0 0 10px;font-size:24px;line-height:1.5;max-width:860px;margin-left:auto;margin-right:auto;color:var(--ink)}
1426
- .hero .meta{color:var(--muted);font-size:13px;letter-spacing:.5px}
1403
+ /* ===== banner 内的原问题行与统计行 ===== */
1404
+ .banner .orig-q{max-width:1080px;margin:7px auto 0;color:var(--ink);font-size:13.5px;line-height:1.6;text-align:center}
1405
+ .banner .orig-q b{color:var(--brand);margin-right:2px}
1406
+ .banner .meta{max-width:1080px;margin:3px auto 0;color:var(--muted);font-size:11.5px;letter-spacing:.3px;text-align:center}
1407
+ .banner-bar .view-switch{border-color:#d9c9f4;background:#fff;box-shadow:0 1px 3px rgba(24,20,40,.04)}
1408
+ .banner-bar .view-switch button{color:#70678a;padding:6px 18px;font-size:13px}
1409
+ .banner-bar .view-switch button.on{background:var(--grad);color:#fff}
1427
1410
  /* 原问题行:报告须含完整原问题才能独立使用 */
1428
- .hero .orig-q{margin-top:8px;padding:8px 14px;background:rgba(255,255,255,.72);border:1px solid var(--line);
1429
- border-radius:10px;color:var(--ink);font-size:13.5px;line-height:1.7;text-align:left}
1430
- .hero .orig-q b{color:var(--brand);margin-right:2px}
1431
- .hero-switch{margin-top:16px;display:flex;justify-content:center}
1432
- .hero-switch .view-switch{border-color:#d9c9f4;background:#fff;box-shadow:0 1px 3px rgba(24,20,40,.04)}
1433
- .hero-switch .view-switch button{color:#70678a;padding:6px 22px;font-size:13px}
1434
- .hero-switch .view-switch button.on{background:var(--grad);color:#fff}
1435
1411
 
1436
1412
  /* ===== 容器与视图 ===== */
1437
1413
  .container{max-width:1080px;margin:0 auto;padding:0 18px}
1438
- .app[data-view="library"] #view-report{display:none}
1439
- #view-library{display:none}
1414
+ .app{padding-top:16px}
1415
+ /* 三页产出物:正文 / 溯源核验报告 / 知识专库,单文件顶部切换 */
1416
+ #view-body,#view-report,#view-library{display:none}
1417
+ .app[data-view="body"] #view-body{display:block}
1418
+ .app[data-view="report"] #view-report{display:block}
1440
1419
  .app[data-view="library"] #view-library{display:block}
1441
1420
 
1442
1421
  /* ===== 过程回顾条 ===== */
1443
1422
  .process{background:#fff;border:1px solid var(--line);border-radius:14px;box-shadow:var(--shadow-1);
1444
- padding:15px 20px 13px;margin:-36px auto 16px;position:relative}
1423
+ padding:15px 20px 13px;margin:0 auto 16px;position:relative}
1445
1424
  .p-head{display:flex;align-items:baseline;gap:10px;margin-bottom:10px}
1446
1425
  .p-head b{font-size:14.5px;color:var(--navy);letter-spacing:1px}
1447
1426
  .p-head span{font-size:11.5px;color:var(--muted)}
@@ -1468,7 +1447,7 @@ a{color:var(--brand)}
1468
1447
  .pd-row span{color:var(--muted)}
1469
1448
 
1470
1449
  /* ===== 核验报告视图 ===== */
1471
- #view-report{padding-bottom:26px}
1450
+ #view-body,#view-report{padding-bottom:26px}
1472
1451
  .warn-box{margin:0 0 16px;padding:13px 16px;border:1.5px solid var(--danger);border-radius:10px;
1473
1452
  background:#fdf3f3;color:#8f2626;font-size:13.5px;line-height:1.7}
1474
1453
  .verify{margin:0 0 16px;background:#fff;border:1px solid #bfe8da;border-left:4px solid var(--ok);
@@ -1492,6 +1471,15 @@ a{color:var(--brand)}
1492
1471
  .vi .s.man{color:var(--case)}
1493
1472
  .vi .s.none{color:var(--muted)}
1494
1473
  .vi .d{color:var(--muted);min-width:0}
1474
+ /* 溯源核验报告页正文区的文头标题(反馈意见:标题放正文区,而非页面顶部) */
1475
+ .paper-title{margin:0 0 18px;font-size:20px;font-weight:800;color:var(--ink);text-align:center;line-height:1.55;letter-spacing:.3px}
1476
+ .v-checks{margin-top:9px}
1477
+ .v-checks summary{cursor:pointer;color:var(--brand);font-weight:700;font-size:12.5px;list-style:none;display:inline-flex;align-items:center;gap:5px}
1478
+ .v-checks summary::-webkit-details-marker{display:none}
1479
+ .v-checks summary::before{content:"+";font-weight:700;font-size:12px}
1480
+ .v-checks[open] summary::before{content:"-"}
1481
+ .v-checks ul{margin:7px 0 0 4px;padding-left:16px}
1482
+ .v-checks li{font-size:12.5px;color:var(--sub);line-height:1.72;margin:5px 0}
1495
1483
  .v-note{margin-top:11px;padding-top:9px;border-top:1px dashed var(--line);font-size:11.5px;color:var(--muted);line-height:1.7}
1496
1484
 
1497
1485
  /* 正文(原型复刻):章节 / 段落 / 角标 / 句后溯源卡 */
@@ -1573,29 +1561,23 @@ a.jb-quote{text-decoration:none}
1573
1561
  #view-library{padding:26px 0 30px}
1574
1562
  .lib-head{max-width:860px;margin:0 auto 16px;text-align:center}
1575
1563
  .lib-title{margin-bottom:14px}
1576
- .lib-title b{font-size:17px;color:var(--navy);letter-spacing:2px}
1577
- .lib-title span{display:block;font-size:12px;color:var(--muted);margin-top:2px}
1564
+ .lib-title b{font-size:16px;color:var(--navy);letter-spacing:.5px;line-height:1.5}
1578
1565
  .lib-searchWrap{position:relative;max-width:620px;margin:0 auto}
1579
1566
  .lib-searchIcon{position:absolute;left:14px;top:50%;transform:translateY(-50%);color:#a6adbd;font-size:16px;font-weight:700}
1580
1567
  .lib-search{width:100%;padding:11px 16px 11px 38px;border:1.5px solid var(--line-strong);border-radius:999px;
1581
1568
  font-size:14px;background:#fff;box-shadow:var(--shadow-1);outline:none}
1582
1569
  .lib-search:focus{border-color:var(--brand-2);box-shadow:0 0 0 3px rgba(139,92,246,.18)}
1583
- .hot-terms{display:flex;flex-wrap:wrap;justify-content:center;gap:7px;margin-top:12px;align-items:center}
1584
- .hot-label{font-size:12px;color:var(--muted)}
1585
- .hot-term{border:0;border-radius:999px;background:var(--brand-soft);color:var(--brand);
1586
- font-size:12.3px;font-weight:700;padding:3px 13px;cursor:pointer}
1587
- .hot-term:hover{background:var(--grad);color:#fff}
1588
1570
  .lib-tabs{display:flex;flex-wrap:wrap;justify-content:center;gap:6px;margin-top:14px}
1589
1571
  .lib-tabs button{border:1px solid var(--line);border-radius:999px;background:#fff;color:var(--muted);
1590
1572
  padding:4px 13px;font-size:12.3px;cursor:pointer}
1591
1573
  .lib-tabs button.on{background:var(--grad);border-color:var(--brand);color:#fff;font-weight:700}
1592
- .lib-list{max-width:860px;margin:0 auto;display:grid;grid-template-columns:1fr;gap:14px}
1574
+ .lib-list{max-width:860px;margin:0 auto;display:grid;grid-template-columns:minmax(0,1fr);gap:14px}
1593
1575
  .lib-empty{max-width:860px;margin:30px auto;text-align:center;color:var(--muted);font-size:13.5px}
1594
1576
  .lib-empty.hide{display:none}
1595
1577
  .lib-foot{text-align:center;color:var(--muted);font-size:11.5px;padding:18px 0 0;line-height:1.8}
1596
1578
 
1597
1579
  /* ===== 材料卡 ===== */
1598
- .scard{border:1px solid var(--line);border-left-width:3px;border-radius:12px;padding:14px 18px;
1580
+ .scard{min-width:0;border:1px solid var(--line);border-left-width:3px;border-radius:12px;padding:14px 18px;
1599
1581
  background:#fff;box-shadow:var(--shadow-1);transition:box-shadow .25s}
1600
1582
  .scard:hover{box-shadow:var(--shadow-2)}
1601
1583
  .scard.pol{border-left-color:var(--policy)}
@@ -1648,16 +1630,14 @@ a.jb-quote{text-decoration:none}
1648
1630
  line-height:1.5;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
1649
1631
  .toc a.on{color:var(--brand);border-left-color:var(--brand);font-weight:700}
1650
1632
  /* 切到知识专库视图时隐藏章节目录(避免进入专库页后左侧仍残留目录栏)。
1651
- 目录节点渲染在 .app 之后(.app 的兄弟节点),故主规则用兄弟选择器;同时兼容其被移入 .app 内的情况。 */
1633
+ 正文页与溯源核验报告页都有分节正文,目录在这两页都显示;目录节点渲染在 .app 之后
1634
+ (.app 的兄弟节点),故主规则用兄弟选择器;同时兼容其被移入 .app 内的情况。 */
1652
1635
  .app[data-view="library"] ~ .toc,.app[data-view="library"] .toc{display:none}
1653
1636
  @media (max-width:1460px){.toc{display:none}}
1654
1637
 
1638
+ /* 顶部任务区(三切换+原问题+工具)样式已并入顶部 .banner 统一区 */
1655
1639
  .foot{text-align:center;color:var(--muted);font-size:11.5px;padding:16px 0 4px;line-height:1.8}
1656
1640
 
1657
- /* ===== 只看正文(纯净阅读态) ===== */
1658
- body.reading .process,body.reading .verify,body.reading .jb,body.reading .sec-badge,
1659
- body.reading .cite,body.reading .toc,body.reading .p-detail{display:none!important}
1660
-
1661
1641
  /* ===== 打印附录 ===== */
1662
1642
  .print-appendix{display:none}
1663
1643
 
@@ -1666,23 +1646,23 @@ body.reading .cite,body.reading .toc,body.reading .p-detail{display:none!importa
1666
1646
  .sheet{display:none}
1667
1647
  @media (max-width:680px){
1668
1648
  body{font-size:14px;line-height:1.8}
1669
- .topbar{padding:7px 10px;gap:6px}
1649
+ .banner{padding:6px 10px 7px}
1670
1650
  .tb-stamp{font-size:11px;letter-spacing:2px;text-indent:2px}
1671
1651
  .tb-stamp::before,.tb-stamp::after{width:12px;margin:0 4px}
1672
- .tb-title{display:none}
1673
- .topbar .view-switch{display:none}
1652
+ .banner-bar{flex-wrap:wrap;justify-content:center;gap:7px}
1653
+ .banner-bar .tb-title{display:none}
1654
+ .banner-bar .view-switch{margin:0}
1655
+ .banner-bar .view-switch button{padding:5px 11px;font-size:12px}
1656
+ .banner .orig-q{font-size:12.5px}
1657
+ .banner .meta{font-size:11px}
1674
1658
  .tb-tools button{font-size:11.5px;padding:4px 8px}
1675
- .hero{padding:24px 14px 50px}
1676
1659
  .ch-head{gap:8px;margin-bottom:14px;flex-wrap:nowrap}
1677
1660
  .ch-head h2{font-size:17px;line-height:1.45}
1661
+ .paper-title{font-size:17.5px;margin-bottom:16px}
1678
1662
  .ch-head::after{display:none}
1679
1663
  .ch-head .sec-badge{font-size:10.5px;padding:2px 7px;white-space:nowrap}
1680
1664
  .jb-name{max-width:calc(100vw - 72px)}
1681
- .r-badge{font-size:13.5px;letter-spacing:6px;text-indent:6px;gap:10px}
1682
- .hero h1{font-size:18.5px}
1683
- .hero .meta{font-size:11.5px;line-height:1.7}
1684
- .hero-switch .view-switch button{padding:6px 16px;font-size:12.5px}
1685
- .process{margin-top:-30px;padding:12px 12px 11px}
1665
+ .process{padding:12px 12px 11px}
1686
1666
  .p-step{flex:1 1 100%}
1687
1667
  .p-arrow{display:none}
1688
1668
  .verify{padding:13px 14px}
@@ -1707,7 +1687,7 @@ body.reading .cite,body.reading .toc,body.reading .p-detail{display:none!importa
1707
1687
  -webkit-overflow-scrolling:touch;scrollbar-width:none}
1708
1688
  .lib-tabs::-webkit-scrollbar{display:none}
1709
1689
  .lib-tabs button{flex:none}
1710
- .lib-list{grid-template-columns:1fr;gap:10px}
1690
+ .lib-list{grid-template-columns:minmax(0,1fr);gap:10px}
1711
1691
  .scard{padding:10px 11px}
1712
1692
  .crumb{font-size:11px}
1713
1693
  .sc-excerpt{font-size:11.5px}
@@ -1741,13 +1721,14 @@ body.reading .cite,body.reading .toc,body.reading .p-detail{display:none!importa
1741
1721
 
1742
1722
  /* ===== 打印归档 ===== */
1743
1723
  @media print{
1744
- .topbar,.process .p-detail,.hero-switch,.tb-tools,.view-switch,.lib-head,.toc,.sheet,.sheet-mask,
1724
+ .banner-bar,.process .p-detail,.lib-head,.toc,.sheet,.sheet-mask,
1745
1725
  .progress{display:none!important}
1746
- #view-library{display:none!important}
1747
- #view-report{display:block!important}
1748
- .app[data-view="library"] #view-report{display:block!important}
1749
- .hero{background:none;border:0;color:var(--ink);padding:10px 0 4px}
1750
- .hero .meta{color:var(--muted)}
1726
+ /* 溯源核验报告导出:三页顺序打印 */
1727
+ #view-body,#view-report,#view-library{display:block!important}
1728
+ .banner{position:static;background:none;border:0;padding:0 0 6px}
1729
+ .banner .orig-q{text-align:left;font-size:13px}
1730
+ .banner .meta{color:var(--muted);text-align:left}
1731
+ .app{padding-top:0}
1751
1732
  *{-webkit-print-color-adjust:exact;print-color-adjust:exact}
1752
1733
  .process{box-shadow:none;margin:6px 0 12px}
1753
1734
  .verify{border-color:#bbb;box-shadow:none;break-inside:avoid}
@@ -1764,13 +1745,14 @@ body.reading .cite,body.reading .toc,body.reading .p-detail{display:none!importa
1764
1745
  .jb.active{break-inside:avoid}
1765
1746
  .jb.active .jb-body{display:block!important}
1766
1747
  .jb.active .jb-body .jb-quote{break-inside:avoid}
1767
- body.reading .verify,body.reading .process,body.reading .ev-row,body.reading .sec-badge,
1768
- body.reading .cite{display:none!important}
1769
1748
  .print-appendix{display:block;break-before:page}
1770
- body.print-body-only .verify,body.print-body-only .process,body.print-body-only .print-appendix,
1771
- body.print-body-only .jb,body.print-body-only .foot{display:none!important}
1749
+ body.print-body-only #view-report,body.print-body-only #view-library,
1750
+ body.print-body-only .print-appendix,body.print-body-only .foot{display:none!important}
1772
1751
  .print-appendix h3{font-size:15px;color:var(--navy);border-bottom:1px solid #999;padding-bottom:6px;margin:0 0 12px}
1773
1752
  .print-appendix .scard{margin-bottom:10px}
1753
+ /* 打印时宽表格贴合页宽(屏幕端靠 .sc-excerpt.rich 横向滚动,纸张上不能滚) */
1754
+ .print-appendix .sc-excerpt.rich,.sc-excerpt.rich{overflow-x:visible}
1755
+ .print-appendix .sc-excerpt.rich table,.sc-excerpt.rich table{width:100%!important;min-width:0}
1774
1756
  }
1775
1757
  """
1776
1758
 
@@ -1783,8 +1765,9 @@ PAGE_JS = """
1783
1765
  var app = $(".app");
1784
1766
  var isMobile = function () { return window.matchMedia("(max-width:680px)").matches; };
1785
1767
 
1786
- /* ===== 1. 双视图切换(保存/恢复各自滚动位置) ===== */
1787
- var savedScroll = { report: 0, library: 0 };
1768
+ /* ===== 1. 三页切换(正文 / 溯源核验报告 / 知识专库;保存/恢复各自滚动位置) ===== */
1769
+ var savedScroll = { body: 0, report: 0, library: 0 };
1770
+ var viewChangeHook = null; /* 切页后重算目录锚点等 */
1788
1771
  function setView(view) {
1789
1772
  if (!app || app.getAttribute("data-view") === view) return;
1790
1773
  savedScroll[app.getAttribute("data-view") || "report"] = window.scrollY;
@@ -1793,6 +1776,7 @@ PAGE_JS = """
1793
1776
  b.classList.toggle("on", b.getAttribute("data-view") === view);
1794
1777
  });
1795
1778
  window.scrollTo(0, Math.max(0, savedScroll[view] || 0));
1779
+ if (viewChangeHook) viewChangeHook(view);
1796
1780
  }
1797
1781
  $$(".view-switch button").forEach(function (b) {
1798
1782
  b.addEventListener("click", function () { setView(b.getAttribute("data-view")); });
@@ -1809,26 +1793,14 @@ PAGE_JS = """
1809
1793
  window.addEventListener("scroll", updateProgress, { passive: true });
1810
1794
  updateProgress();
1811
1795
 
1812
- /* ===== 3. 只看正文(纯净阅读态切换) ===== */
1813
- var readBtn = $("#btn-reading");
1814
- if (readBtn) {
1815
- readBtn.addEventListener("click", function () {
1816
- var on = document.body.classList.toggle("reading");
1817
- readBtn.setAttribute("aria-pressed", on ? "true" : "false");
1818
- readBtn.textContent = on ? "显示核验" : "只看正文";
1819
- /* 只看正文只作用于核验报告视图:正在知识专库时切回报告,专库不受影响 */
1820
- if (on && app && app.getAttribute("data-view") !== "report") setView("report");
1821
- });
1822
- }
1823
-
1824
- /* ===== 4. 复制全文(章节标题 + 段落 + 表格,去角标) ===== */
1796
+ /* ===== 3. 复制全文(章节标题 + 段落 + 表格,去角标) ===== */
1825
1797
  var copyBtn = $("#btn-copy");
1826
1798
  if (copyBtn) {
1827
1799
  copyBtn.addEventListener("click", function () {
1828
1800
  var parts = [];
1829
1801
  /* 按文档流顺序收集章节标题/段落/表格;克隆后剔除引文胶囊与角标,
1830
1802
  只复制正文本身(胶囊标题/展开摘录/编号数字均不带出) */
1831
- var nodes = $$("#view-report .ch-head h2, #view-report .lead, #view-report .para, #view-report .tbl-wrap");
1803
+ var nodes = $$("#view-body .ch-head h2, #view-body .lead, #view-body .para, #view-body .tbl-wrap");
1832
1804
  nodes.sort(function (a, b) { return (a.compareDocumentPosition(b) & 4) ? -1 : 1; });
1833
1805
  nodes.forEach(function (el) {
1834
1806
  var clone = el.cloneNode(true);
@@ -1863,26 +1835,45 @@ PAGE_JS = """
1863
1835
  });
1864
1836
  }
1865
1837
 
1866
- /* ===== 5. 打印归档(PDF):下拉双选项——只打印正文 / 完整归档 ===== */
1867
- var printBtn = $("#btn-print");
1868
- var printDrop = $("#print-drop");
1838
+ /* ===== 5. 导出:正文 Markdown / PDF(浏览器打印另存为 PDF) ===== */
1839
+ var exportBtn = $("#btn-export");
1840
+ var exportDrop = $("#export-drop");
1841
+ function docTitleForFile() {
1842
+ var t = $(".tb-title");
1843
+ var name = (t ? t.textContent.trim() : "") || document.title || "文稿";
1844
+ return name.replace(/[\\/:*?"<>|]+/g, "_").trim() || "文稿";
1845
+ }
1846
+ function exportMarkdown() {
1847
+ var el = document.getElementById("doc-export");
1848
+ var data = { title: docTitleForFile(), markdown: "" };
1849
+ if (el) { try { data = JSON.parse(el.textContent) || data; } catch (err) {} }
1850
+ var blob = new Blob([data.markdown || ""], { type: "text/markdown;charset=utf-8" });
1851
+ var url = URL.createObjectURL(blob);
1852
+ var a = document.createElement("a");
1853
+ a.href = url;
1854
+ a.download = (data.title || docTitleForFile()) + ".md";
1855
+ document.body.appendChild(a);
1856
+ a.click();
1857
+ setTimeout(function () { URL.revokeObjectURL(url); if (a.parentNode) a.parentNode.removeChild(a); }, 800);
1858
+ }
1869
1859
  function printBy(mode) {
1870
1860
  if (mode === "body") document.body.classList.add("print-body-only");
1871
- if (printDrop) printDrop.hidden = true;
1861
+ if (exportDrop) exportDrop.hidden = true;
1872
1862
  window.print();
1873
1863
  }
1874
- if (printBtn && printDrop) {
1875
- printBtn.addEventListener("click", function (e) {
1864
+ if (exportBtn && exportDrop) {
1865
+ exportBtn.addEventListener("click", function (e) {
1876
1866
  e.stopPropagation();
1877
- printDrop.hidden = !printDrop.hidden;
1867
+ exportDrop.hidden = !exportDrop.hidden;
1878
1868
  });
1879
- printDrop.addEventListener("click", function (e) {
1869
+ exportDrop.addEventListener("click", function (e) {
1880
1870
  e.stopPropagation();
1881
1871
  var t = e.target.closest("button");
1882
1872
  if (!t) return;
1883
- printBy(t.id === "print-body" ? "body" : "full");
1873
+ if (t.id === "export-md") { exportMarkdown(); exportDrop.hidden = true; return; }
1874
+ printBy(t.id === "export-pdf-body" ? "body" : "full");
1884
1875
  });
1885
- document.addEventListener("click", function () { printDrop.hidden = true; });
1876
+ document.addEventListener("click", function () { exportDrop.hidden = true; });
1886
1877
  /* 打印结束移除临时模式(浏览器打印窗口关闭后触发) */
1887
1878
  window.addEventListener("afterprint", function () { document.body.classList.remove("print-body-only"); });
1888
1879
  }
@@ -2044,15 +2035,6 @@ PAGE_JS = """
2044
2035
  });
2045
2036
  var search = $(".lib-search");
2046
2037
  if (search) search.addEventListener("input", function () { kw = search.value.trim().toLowerCase(); applyFilter(); });
2047
- $$(".hot-term").forEach(function (t) {
2048
- t.addEventListener("click", function () {
2049
- if (!search) return;
2050
- search.value = t.textContent.trim();
2051
- kw = search.value.toLowerCase();
2052
- applyFilter();
2053
- if (search.focus) search.focus();
2054
- });
2055
- });
2056
2038
 
2057
2039
  /* ===== 8. 过程回顾条:检索步骤展开 ===== */
2058
2040
  var pStep = $("#p-step-search");
@@ -2065,20 +2047,30 @@ PAGE_JS = """
2065
2047
  });
2066
2048
  }
2067
2049
 
2068
- /* ===== 9. 章节目录(spy) ===== */
2050
+ /* ===== 9. 章节目录(spy;正文页与溯源核验报告页共用,按当前视图切换锚点) ===== */
2069
2051
  var toc = $(".toc");
2070
2052
  if (toc) {
2071
2053
  var links = $$("a", toc);
2072
- var secs = links.map(function (a) { return document.querySelector(a.getAttribute("href")); });
2054
+ function tocPrefix() {
2055
+ var v = app ? app.getAttribute("data-view") : "";
2056
+ return v === "report" ? "rsec" : (v === "body" ? "sec" : "");
2057
+ }
2058
+ function tocSecs() {
2059
+ var p = tocPrefix();
2060
+ if (!p) return [];
2061
+ return links.map(function (a) { return document.getElementById(p + "-" + a.getAttribute("data-sec")); });
2062
+ }
2063
+ var secs = tocSecs();
2073
2064
  links.forEach(function (a) {
2074
2065
  a.addEventListener("click", function (e) {
2075
2066
  e.preventDefault();
2076
- var target = document.querySelector(a.getAttribute("href"));
2067
+ var p = tocPrefix();
2068
+ var target = p ? document.getElementById(p + "-" + a.getAttribute("data-sec")) : null;
2077
2069
  if (!target) return;
2078
2070
  /* 手动定位而非 scrollIntoView({block:"start"}):后者把标题顶到视口 y=0,
2079
2071
  会被 sticky 顶栏盖住(点"四、…"后一级标题看不见)。
2080
2072
  偏移量与目录吸顶位置同一基准(顶栏高 + 20px)。 */
2081
- var bar = document.querySelector(".topbar");
2073
+ var bar = document.querySelector(".banner");
2082
2074
  var offset = (bar ? bar.offsetHeight : 0) + 20;
2083
2075
  var y = target.getBoundingClientRect().top + window.scrollY - offset;
2084
2076
  window.scrollTo({ top: Math.max(0, y), behavior: "smooth" });
@@ -2091,24 +2083,20 @@ PAGE_JS = """
2091
2083
  links.forEach(function (a, i) { a.classList.toggle("on", i === current); });
2092
2084
  }
2093
2085
  window.addEventListener("scroll", spy, { passive: true });
2094
- spy();
2095
- /* 目录纵向定位:此前 CSS 写死 top:120px,目录顶部与页头齐平、离正文很远。
2096
- 改为——初始与正文首节对齐,滚动时吸附在顶栏下方。 */
2097
- var topbar = document.querySelector(".topbar");
2086
+ /* 目录纵向定位:初始与正文首节对齐,滚动时吸附在顶栏下方(目录过长由 CSS max-height 内部滚动兜底)。 */
2087
+ var bannerEl = document.querySelector(".banner");
2098
2088
  function placeToc() {
2099
2089
  var first = secs[0];
2100
2090
  if (!first) return;
2101
- var stick = (topbar ? topbar.offsetHeight : 0) + 20;
2091
+ var stick = (bannerEl ? bannerEl.offsetHeight : 0) + 20;
2102
2092
  var want = Math.round(first.getBoundingClientRect().top);
2103
- /* 不再按"视口内放不放得下"压缩位置:正文首节上方还有页头、
2104
- 过程回顾和核验单,首屏内它常位于视口之外;若按 innerHeight 把目录上移,目录会被
2105
- 顶到页面中上部,反而显得"悬得过高",与正文脱节。直接跟随正文首节——首屏看不到
2106
- 目录属正常,向下滚动后它自然吸附在顶栏下方。目录过长时由 CSS 的
2107
- max-height:60vh + overflow:auto 内部滚动兜底。 */
2108
2093
  toc.style.top = Math.max(stick, want) + "px";
2109
2094
  }
2110
2095
  window.addEventListener("scroll", placeToc, { passive: true });
2111
2096
  window.addEventListener("resize", placeToc);
2097
+ /* 切页时重算锚点与高亮(正文页 sec-N / 溯源核验报告页 rsec-N) */
2098
+ viewChangeHook = function () { secs = tocSecs(); spy(); placeToc(); };
2099
+ spy();
2112
2100
  placeToc();
2113
2101
  }
2114
2102
  })();
@@ -2148,7 +2136,6 @@ def render_html(payload: Dict[str, Any], title: str, answer_override: str = "",
2148
2136
 
2149
2137
  verification = compute_verification(answer, sources, payload, generated_at)
2150
2138
  process_stats = compute_process_stats(sources, answer)
2151
- hot_terms = extract_hot_terms(answer, sources)
2152
2139
  citation_warning = ""
2153
2140
  if sources and not used:
2154
2141
  citation_warning = (
@@ -2165,6 +2152,9 @@ def render_html(payload: Dict[str, Any], title: str, answer_override: str = "",
2165
2152
  for key, html in (jb.pop("_tables", {}) or {}).items():
2166
2153
  jb_tables[key] = html
2167
2154
  doc_title, sections = group_sections(blocks)
2155
+ # 正文页:同一份正文去掉全部角标/引文胶囊,输出干净正式内容(核验内容归"溯源核验报告"页)
2156
+ clean_blocks, _ = parse_answer_blocks(answer, {s["id"] for s in sources}, chip_map, strip_cites=True)
2157
+ _, clean_sections = group_sections(clean_blocks)
2168
2158
  display_title = doc_title or title
2169
2159
  # 原问题行:溯源报告须含完整原问题才能独立使用。
2170
2160
  # 只认调用方显式传入的 question_override(source_note_html 读溯源 JSON 顶层
@@ -2172,91 +2162,110 @@ def render_html(payload: Dict[str, Any], title: str, answer_override: str = "",
2172
2162
  # question 字段兜底(该字段历史上常被报告标题冒充,显示了反而误导);为空或与
2173
2163
  # 标题相同时不显示该行(历史 JSON 兼容)。
2174
2164
  question_text = (question_override or "").strip()
2175
- orig_q_html = (f'<div class="orig-q"><b>原问题</b>:{esc(question_text)}</div>'
2165
+ orig_q_html = (f'<div class="orig-q" title="{esc(question_text)}"><b>原问题</b>:{esc(question_text)}</div>'
2176
2166
  if question_text and question_text != display_title else "")
2177
2167
 
2178
2168
  jb_tables_json = json.dumps(jb_tables, ensure_ascii=False).replace("</", "<\\/")
2179
2169
  jb_tables_script = (f'<script type="application/json" id="jb-tables">{jb_tables_json}</script>\n'
2180
2170
  if jb_tables else "")
2171
+ # 导出用正文 Markdown(去角标,干净正文),供顶部"导出 ▾ → 导出正文 Markdown"下载
2172
+ export_payload = {"title": display_title, "markdown": strip_citation_markers(answer)}
2173
+ export_json = json.dumps(export_payload, ensure_ascii=False).replace("</", "<\\/")
2174
+ export_script = f'<script type="application/json" id="doc-export">{export_json}</script>\n'
2181
2175
 
2182
2176
  meta_bits = []
2183
2177
  if process_stats["n_searches"]:
2184
- meta_bits.append(f"深知检索 {process_stats['n_searches']} 次")
2178
+ # 检索计数按接口通道拆分显示(深度搜索与可信搜索是两个接口来源)
2179
+ _deep_n = process_stats.get("deep_routes", 0)
2180
+ _trusted_n = process_stats.get("trusted_routes", 0)
2181
+ if _deep_n and _trusted_n:
2182
+ meta_bits.append(f"深度搜索 {_deep_n} 路 · 可信补搜 {_trusted_n} 次")
2183
+ elif _deep_n:
2184
+ meta_bits.append(f"深知深度搜索 {_deep_n} 路")
2185
+ elif _trusted_n:
2186
+ meta_bits.append(f"深知可信搜索 {_trusted_n} 次")
2187
+ else:
2188
+ meta_bits.append(f"深知检索 {process_stats['n_searches']} 次")
2185
2189
  if sources:
2186
- meta_bits.append(f"来源文章 {len(sources)} 篇")
2190
+ meta_bits.append(f"知识专库文章 {len(sources)} 篇")
2187
2191
  if process_stats["n_cite_marks"]:
2188
- meta_bits.append(f"正文引用 {process_stats['n_cite_marks']} 处")
2192
+ meta_bits.append(f"正文实际引用 {process_stats['n_cite_marks']} 处")
2189
2193
  meta_bits.append(f"生成于 {generated}")
2190
2194
  meta_line = " · ".join(meta_bits)
2195
+ # 来源=材料实际使用的检索通道(深知深度搜索 / 深知可信搜索,动态汇总);
2196
+ # 历史溯源 JSON 无通道信息时保留旧文案
2197
+ _channels: List[str] = []
2198
+ for s in sources:
2199
+ _ch = (s.get("channel") or "").strip()
2200
+ # 通道可能为顿号拼接的多值(同一材料被两接口召回),拆分后逐 token 汇总
2201
+ for token in [t.strip() for t in _ch.split("、") if t.strip()]:
2202
+ if token not in _channels:
2203
+ _channels.append(token)
2204
+ source_line = " · ".join(_channels) if _channels else "深知可信搜索"
2191
2205
 
2192
2206
  return f"""<!doctype html>
2193
2207
  <html lang="zh-CN">
2194
2208
  <head>
2195
2209
  <meta charset="utf-8">
2196
2210
  <meta name="viewport" content="width=device-width, initial-scale=1">
2197
- <title>{esc(display_title)} · 溯源核验报告</title>
2211
+ <title>{esc(display_title)}</title>
2198
2212
  <style>{PAGE_CSS}</style>
2199
2213
  </head>
2200
2214
  <body>
2201
2215
 
2202
- <header class="topbar">
2203
- <div class="tb-left">
2204
- <span class="tb-stamp">溯源核验报告</span>
2216
+ <header class="banner">
2217
+ <div class="banner-bar">
2205
2218
  <span class="tb-title">{esc(display_title)}</span>
2206
- </div>
2207
- <div class="tb-right">
2208
- <div class="view-switch" role="tablist" aria-label="视图切换">
2209
- <button class="on" data-view="report" type="button">核验报告</button>
2210
- <button data-view="library" type="button">知识专库</button>
2219
+ <div class="view-switch" role="tablist" aria-label="页面切换">
2220
+ <button data-view="body" type="button">正文(去索引)</button>
2221
+ <button class="on" data-view="report" type="button">溯源核验报告</button>
2222
+ <button data-view="library" type="button">知识专库({len(sources)})</button>
2211
2223
  </div>
2212
2224
  <div class="tb-tools">
2213
- <button id="btn-reading" type="button" aria-pressed="false" title="隐藏核验元素,纯阅读正文">只看正文</button>
2214
2225
  <button id="btn-copy" type="button" title="复制正文纯文本">复制全文</button>
2215
2226
  <span class="print-menu">
2216
- <button id="btn-print" type="button" aria-haspopup="true" title="浏览器打印/另存为 PDF">打印归档 ▾</button>
2217
- <span class="print-drop" id="print-drop" hidden>
2218
- <button id="print-body" type="button">只打印正文</button>
2219
- <button id="print-full" type="button">完整归档(含来源文章)</button>
2227
+ <button id="btn-export" type="button" aria-haspopup="true" title="导出正文 Markdown 或 PDF">导出 ▾</button>
2228
+ <span class="print-drop" id="export-drop" hidden>
2229
+ <button id="export-md" type="button">导出 Markdown(正文)</button>
2230
+ <button id="export-pdf-body" type="button">导出 PDF(正文)</button>
2231
+ <button id="export-pdf-full" type="button">导出 PDF(溯源核验报告)</button>
2220
2232
  </span>
2221
2233
  </span>
2222
2234
  </div>
2223
2235
  </div>
2236
+ {orig_q_html}
2237
+ <div class="meta">{esc(meta_line)} | 来源:{esc(source_line)}</div>
2224
2238
  <div class="progress" aria-hidden="true"><i></i></div>
2225
2239
  </header>
2226
2240
 
2227
- <div class="hero">
2228
- <div class="r-badge">溯源核验报告</div>
2229
- <h1>{esc(display_title)}</h1>
2230
- <div class="meta">{esc(meta_line)} | 来源:深知可信搜索</div>
2231
- {orig_q_html}
2232
- <div class="hero-switch">
2233
- <div class="view-switch" role="tablist" aria-label="视图切换">
2234
- <button class="on" data-view="report" type="button">核验报告</button>
2235
- <button data-view="library" type="button">知识专库({len(sources)})</button>
2236
- </div>
2237
- </div>
2238
- </div>
2239
-
2240
2241
  <div class="app container" data-view="report">
2241
- {render_process_bar(process_stats, verification)}
2242
+ <main class="view" id="view-body" aria-label="正文">
2243
+ <h2 class="paper-title">{esc(display_title)}</h2>
2244
+ <div class="doc-paper">
2245
+ {render_section_cards(clean_sections, sources, with_ids=True, id_prefix="sec")}
2246
+ </div>
2247
+ <div class="foot">深知公文写作 · 正文 | 内容由 AI 生成,仅供参考</div>
2248
+ </main>
2242
2249
 
2243
- <main class="view" id="view-report" aria-label="核验报告正文">
2250
+ <main class="view" id="view-report" aria-label="溯源核验报告">
2251
+ <h2 class="paper-title">溯源核验报告:{esc(display_title)}</h2>
2244
2252
  {citation_warning}
2253
+ {render_process_bar(process_stats, verification)}
2245
2254
  {render_verify_panel(verification)}
2246
2255
  <div class="doc-paper">
2247
- {render_section_cards(sections, sources)}
2256
+ {render_section_cards(sections, sources, with_ids=True, id_prefix="rsec")}
2248
2257
  </div>
2249
2258
  <div class="foot">深知公文写作 · 溯源核验报告 | 内容由 AI 生成,仅供参考</div>
2250
2259
  </main>
2251
2260
 
2252
- {render_library_view(sources, hot_terms)}
2261
+ {render_library_view(sources, display_title)}
2253
2262
  {render_print_appendix(sources)}
2254
2263
  </div>
2255
2264
 
2256
2265
  {render_toc(sections)}
2257
2266
 
2258
2267
  <div class="ev-panel" id="ev-pop" hidden></div>
2259
- {jb_tables_script}<div class="sheet-mask" aria-hidden="true"></div>
2268
+ {export_script}{jb_tables_script}<div class="sheet-mask" aria-hidden="true"></div>
2260
2269
  <div class="sheet" role="dialog" aria-label="来源文章">
2261
2270
  <div class="sheet-grab"></div>
2262
2271
  <div class="sheet-head"><b>依据对照</b><button class="sheet-close" type="button">收起</button></div>
@@ -2311,10 +2320,8 @@ def _check_degraded_input(payload: Dict[str, Any], path: str) -> None:
2311
2320
  )
2312
2321
 
2313
2322
 
2314
-
2315
-
2316
2323
  def _dsh_default_output_dir() -> str:
2317
- """dsh:未显式传 --output 时,默认输出到会话产物目录 official-docs/output/。"""
2324
+ """dsh:默认输出目录锚定会话工作区(与其他脚本的 WS_ROOT 同源解析)。"""
2318
2325
  import os as _os
2319
2326
  _ws = _os.environ.get("DKNWOC_WS_ROOT")
2320
2327
  if not _ws: