JiuwenSwarm is an intelligent AI Agent built on openJiuwen. It extends the powerful capabilities of large language models directly to your fingertips through various communication apps you use daily.
Python
fix(skillturbo): 取消图表 mount 写盘硬门禁,避免单页缺图导致整本无法导出
Kinsame033ee3000eb
diff --git a/jiuwenswarm/server/runtime/skill_turbo/skill_codes/ppt/ppt_page_gen.py b/jiuwenswarm/server/runtime/skill_turbo/skill_codes/ppt/ppt_page_gen.pyindex c9b56810b9..0c10fca88f 100644--- a/jiuwenswarm/server/runtime/skill_turbo/skill_codes/ppt/ppt_page_gen.py+++ b/jiuwenswarm/server/runtime/skill_turbo/skill_codes/ppt/ppt_page_gen.py@@ -1025,8 +1025,7 @@ def _validate_content_template_fill_output(seed_html: str, filled_html: str) ->return False, "invalid_dom"if not _validate_chart_height_chain(filled_html):return False, "invalid_chart_height_chain"- if not _validate_chart_mount_references(filled_html):- return False, "chart_mount_id_mismatch"+ # mount 错配不在此硬拒:对齐 pptx-craft(落盘后由 check-layout 等软修),禁止进 missingreturn True, ""@@ -1051,8 +1050,7 @@ def _validate_custom_content_template_fill_output(return False, "invalid_dom"if not _validate_chart_height_chain(filled_html):return False, "invalid_chart_height_chain"- if not _validate_chart_mount_references(filled_html):- return False, "chart_mount_id_mismatch"+ # mount 错配不在此硬拒:对齐 pptx-craft,禁止因图表 id 进 missingreturn True, ""@@ -2242,10 +2240,11 @@ _SCRIPT_BODY_RE = re.compile(def _validate_chart_mount_references(html: str) -> bool:- """P8.1 写盘前校验:含 echarts.init 的活跃脚本中 getElementById 须在页内存在对应 id。+ """诊断用:活跃 echarts 脚本中 getElementById 是否在页内有对应 id。- 仅扫描去掉 HTML 注释后的 script 块,避免 dormant CHART_SCAFFOLD 误报;- 与 designer.md「容器 id 须与 getElementById 一致」及方案 A 互补。+ 仅扫描去掉 HTML 注释后的 script 块,避免 dormant CHART_SCAFFOLD 误报。+ 对齐 pptx-craft designer checklist;**不得**作为写盘/missing 硬门禁+ (错配最多软警告,由后续 check-layout 等处理,禁止因缺图丢页)。"""if not html or "echarts.init" not in html.lower():return True@@ -2261,6 +2260,21 @@ def _validate_chart_mount_references(html: str) -> bool:return True+def _warn_chart_mount_mismatch_soft(html: str, *, page_num: int | None = None) -> None:+ """mount 错配仅记软警告,不阻断写盘、不进 missing_pages。"""+ if _validate_chart_mount_references(html):+ return+ if page_num is not None:+ logger.warning(+ "[P8.1] 图表容器 id 与 getElementById 不一致(软警告,不阻断写盘) page=%d",+ page_num,+ )+ else:+ logger.warning(+ "[P8.1] 图表容器 id 与 getElementById 不一致(软警告,不阻断写盘)"+ )++def _chart_scaffold_option_populated(script_body: str) -> bool:"""与 pptx-craft hasOptionAssignment ∧ ¬hasNullOption 同口径(仅看可执行代码)。"""code = _strip_js_comments(script_body or "")@@ -4460,12 +4474,7 @@ def _postprocess_generated_html(raw_html: str, ctx: PageGenContext) -> tuple[strif not _validate_chart_height_chain(html):logger.warning("[P8.1] 页面 %d 图表容器高度链校验失败", ctx.page_num)return "", html, "invalid_chart_height_chain"- if not _validate_chart_mount_references(html):- logger.warning(- "[P8.1] 页面 %d 图表容器 id 与 getElementById 不一致",- ctx.page_num,- )- return "", html, "chart_mount_id_mismatch"+ _warn_chart_mount_mismatch_soft(html, page_num=ctx.page_num)return html, "", ""@@ -4511,6 +4520,7 @@ def _postprocess_content_template_fill(repaired,)if ok_repaired:+ _warn_chart_mount_mismatch_soft(repaired, page_num=ctx.page_num)logger.info("[P8.1] repaired=content_template_chrome page=%d style=%s ""from_reason=%s",@@ -4535,6 +4545,7 @@ def _postprocess_content_template_fill(reason,)return "", html, reason+ _warn_chart_mount_mismatch_soft(html, page_num=ctx.page_num)logger.info("[P8.1] 内容页官方模板填槽完成 page=%d style=%s",ctx.page_num,diff --git a/tests/unit_tests/server/runtime/skill_turbo/test_pptx_craft_compat_adapt.py b/tests/unit_tests/server/runtime/skill_turbo/test_pptx_craft_compat_adapt.pyindex 86a98b80fb..d2892a4889 100644--- a/tests/unit_tests/server/runtime/skill_turbo/test_pptx_craft_compat_adapt.py+++ b/tests/unit_tests/server/runtime/skill_turbo/test_pptx_craft_compat_adapt.py@@ -20,6 +20,7 @@ from jiuwenswarm.server.runtime.skill_turbo.skill_codes.ppt.ppt_page_gen import_repair_content_template_chrome,_uses_content_template_fill,_uses_structural_template_fill,+ _validate_chart_mount_references,_validate_custom_content_template_fill_output,)from jiuwenswarm.server.runtime.skill_turbo.skill_turbo_tools import skill_turbo@@ -452,6 +453,37 @@ def test_validate_custom_content_fill_theme_and_placeholders():assert reason2 == "unfilled_placeholders"+def test_custom_content_fill_does_not_hard_fail_on_chart_mount_mismatch():+ """贵阳 case 回归:mount 错配不得使填槽校验失败(禁止进 missing / 拒导出)。"""+ pad = "<!-- pad -->" * 20+ seed = (+ '<!DOCTYPE html><html><head><style id="theme-contract">'+ "{{THEME_CSS_VARIABLES}}</style></head><body>"+ f"{pad}"+ '<div class="ppt-slide"><div class="content-safe">'+ "<header><h1>{{PAGE_TITLE}}</h1></header>"+ '<main class="page-main flex-1">{{PAGE_CONTENT}}</main>'+ "<footer><p>{{PAGE_FOOTER}}</p></footer>"+ "</div></div></body></html>"+ )+ mismatch_body = (+ '<div class="flex-1 min-h-0 flex flex-col">'+ '<div id="chart-2" class="w-full h-full"></div></div>'+ "<script>"+ 'echarts.init(document.getElementById("chart-1"));'+ "var option={};"+ "</script>"+ )+ filled = seed.replace("{{THEME_CSS_VARIABLES}}", "--color-text:#111;")+ filled = filled.replace("{{PAGE_TITLE}}", "标题")+ filled = filled.replace("{{PAGE_CONTENT}}", mismatch_body)+ filled = filled.replace("{{PAGE_FOOTER}}", "来源")+ assert _validate_chart_mount_references(filled) is False+ ok, reason = _validate_custom_content_template_fill_output(seed, filled)+ assert ok, reason+ assert reason != "chart_mount_id_mismatch"++@pytest.mark.asyncioasync def test_skill_turbo_template_path_bypass_hard_fails():raw = await skill_turbo.invoke(