feat(skill): merge upstream reader-report contract
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
# ═══════════════════════════════════════════════════════════════
|
||||
# 演示与测试入口
|
||||
# ═══════════════════════════════════════════════════════════════
|
||||
|
||||
Reference in New Issue
Block a user