feat(skill): merge upstream reader-report contract

This commit is contained in:
Jesse
2026-08-06 11:31:51 +08:00
parent 685ed00e2f
commit 03d3b58ff7
8 changed files with 1163 additions and 2 deletions
+36
View File
@@ -1024,6 +1024,42 @@ class MockDataFactory:
]
# ═══════════════════════════════════════════════════════════════
# Reader report output contract
# ═══════════════════════════════════════════════════════════════
def render_reader_report(reader_report: Dict[str, Any]) -> Dict[str, Any]:
"""Return the stable reader order without recalculating report facts.
The evidence appendix is collapsed for normal users and expanded by default
only in explicit research mode. Unknown commercial extensions are retained
after the three reader-facing sections for backward compatibility.
"""
executive_summary = reader_report.get("executive_summary")
thematic_narrative = reader_report.get("thematic_narrative")
supplied_appendix = reader_report.get("evidence_appendix")
evidence_appendix = dict(supplied_appendix) if isinstance(supplied_appendix, dict) else {}
presentation_mode = reader_report.get("presentation_mode")
if not presentation_mode and isinstance(executive_summary, dict):
presentation_mode = executive_summary.get("presentation_mode")
presentation_mode = presentation_mode or "default"
evidence_appendix["expanded"] = presentation_mode == "research"
extensions = {
key: value
for key, value in reader_report.items()
if key not in {"presentation_mode", "executive_summary", "thematic_narrative", "evidence_appendix"}
}
rendered = {
"presentation_mode": presentation_mode,
"executive_summary": executive_summary,
"thematic_narrative": thematic_narrative,
"evidence_appendix": evidence_appendix,
}
rendered.update(extensions)
return rendered
# ═══════════════════════════════════════════════════════════════
# 演示与测试入口
# ═══════════════════════════════════════════════════════════════