dknowc-dsh 2.2.1 → 2.3.1
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.
- package/README.md +10 -38
- package/package.json +2 -2
- package/skills/dknowc-official-doc-writer/README.md +34 -31
- package/skills/dknowc-official-doc-writer/SKILL.md +87 -373
- package/skills/dknowc-official-doc-writer/reference/anti_ai_patterns.md +1 -1
- package/skills/dknowc-official-doc-writer/reference/fact_discipline.md +17 -2
- package/skills/dknowc-official-doc-writer/reference/genre_writing_notes.md +116 -0
- package/skills/dknowc-official-doc-writer/reference/initialization.md +69 -0
- package/skills/dknowc-official-doc-writer/reference/local_memory_guide.md +7 -7
- package/skills/dknowc-official-doc-writer/reference/material_usage_guidance.md +7 -0
- package/skills/dknowc-official-doc-writer/reference/materials_pipeline.md +42 -0
- package/skills/dknowc-official-doc-writer/reference/onboarding_scripts.md +44 -33
- package/skills/dknowc-official-doc-writer/reference/outline_rules.md +36 -0
- package/skills/dknowc-official-doc-writer/reference/output_guide.md +80 -12
- package/skills/dknowc-official-doc-writer/reference/research_notes.md +6 -4
- package/skills/dknowc-official-doc-writer/reference/review_checklist.md +24 -0
- package/skills/dknowc-official-doc-writer/reference/revision_workflow.md +2 -2
- package/skills/dknowc-official-doc-writer/reference/sample_trace_report.html +3 -3
- package/skills/dknowc-official-doc-writer/reference/search_guide.md +35 -33
- package/skills/dknowc-official-doc-writer/reference/search_intro.md +4 -4
- package/skills/dknowc-official-doc-writer/reference/search_policy.md +27 -19
- package/skills/dknowc-official-doc-writer/reference/standards/00_index.md +64 -78
- package/skills/dknowc-official-doc-writer/reference/standards/29_research.md +7 -0
- package/skills/dknowc-official-doc-writer/reference/standards/99_expressions.md +3 -2
- package/skills/dknowc-official-doc-writer/reference/task_router.md +3 -3
- package/skills/dknowc-official-doc-writer/reference/working_principles.md +32 -0
- package/skills/dknowc-official-doc-writer/reference/writing_rules.md +83 -0
- package/skills/dknowc-official-doc-writer/scripts/api_key.py +9 -2
- package/skills/dknowc-official-doc-writer/scripts/attribution.py +1 -1
- package/skills/dknowc-official-doc-writer/scripts/build_trace_json.py +43 -11
- package/skills/dknowc-official-doc-writer/scripts/check_materials.py +123 -14
- package/skills/dknowc-official-doc-writer/scripts/deep_convert.py +17 -14
- package/skills/dknowc-official-doc-writer/scripts/deep_query.py +3 -3
- package/skills/dknowc-official-doc-writer/scripts/dkag_search.py +133 -55
- package/skills/dknowc-official-doc-writer/scripts/extract_reference.py +1 -1
- package/skills/dknowc-official-doc-writer/scripts/format_document.py +43 -23
- package/skills/dknowc-official-doc-writer/scripts/initialize.py +15 -7
- package/skills/dknowc-official-doc-writer/scripts/mcp_direct.py +2 -3
- package/skills/dknowc-official-doc-writer/scripts/merge_search_results.py +36 -13
- package/skills/dknowc-official-doc-writer/scripts/outline_reference.py +1 -1
- package/skills/dknowc-official-doc-writer/scripts/prose_lint.py +7 -2
- package/skills/dknowc-official-doc-writer/scripts/register.mjs +540 -207
- package/skills/dknowc-official-doc-writer/scripts/render_trace_html.py +247 -44
- package/skills/dknowc-official-doc-writer/scripts/review_document.py +1 -1
- package/skills/dknowc-official-doc-writer/scripts/source_note_html.py +20 -8
- package/skills/dknowc-official-doc-writer/scripts/template_generator.py +1 -1
- package/skills/dknowc-ppt-assistant/README.md +21 -6
- package/skills/dknowc-ppt-assistant/SKILL.md +23 -68
- package/skills/dknowc-ppt-assistant/THIRD_PARTY_NOTICES.md +3 -2
- package/skills/dknowc-ppt-assistant/references/initialization.md +106 -0
- package/skills/dknowc-ppt-assistant/references/material_usage.md +12 -8
- package/skills/dknowc-ppt-assistant/references/onboarding_scripts.md +48 -17
- package/skills/dknowc-ppt-assistant/references/svg-authoring.md +3 -3
- package/skills/dknowc-ppt-assistant/references/upstream-example/README.md +2 -0
- package/skills/dknowc-ppt-assistant/scripts/api_key.py +7 -0
- package/skills/dknowc-ppt-assistant/scripts/attribution.py +2 -2
- package/skills/dknowc-ppt-assistant/scripts/compact_svg_coordinates.py +1 -1
- package/skills/dknowc-ppt-assistant/scripts/config.py +9 -9
- package/skills/dknowc-ppt-assistant/scripts/console_encoding.py +1 -2
- package/skills/dknowc-ppt-assistant/scripts/error_helper.py +3 -3
- package/skills/dknowc-ppt-assistant/scripts/hyperlink_contract.py +1 -1
- package/skills/dknowc-ppt-assistant/scripts/initialize.py +11 -13
- package/skills/dknowc-ppt-assistant/scripts/language_tags.py +1 -1
- package/skills/dknowc-ppt-assistant/scripts/mcp_convert.py +17 -15
- package/skills/dknowc-ppt-assistant/scripts/mcp_direct.py +3 -2
- package/skills/dknowc-ppt-assistant/scripts/native_payloads.py +1 -1
- package/skills/dknowc-ppt-assistant/scripts/pptx_animations.py +1 -1
- package/skills/dknowc-ppt-assistant/scripts/pptx_shapes/__init__.py +1 -1
- package/skills/dknowc-ppt-assistant/scripts/pptx_shapes/errors.py +1 -1
- package/skills/dknowc-ppt-assistant/scripts/pptx_shapes/formula.py +1 -1
- package/skills/dknowc-ppt-assistant/scripts/pptx_shapes/loader.py +1 -1
- package/skills/dknowc-ppt-assistant/scripts/pptx_shapes/models.py +1 -1
- package/skills/dknowc-ppt-assistant/scripts/pptx_shapes/registry.py +2 -2
- package/skills/dknowc-ppt-assistant/scripts/pptx_shapes/semantic_hash.py +1 -1
- package/skills/dknowc-ppt-assistant/scripts/pptx_shapes/semantics.py +3 -3
- package/skills/dknowc-ppt-assistant/scripts/pptx_to_svg/animation_import.py +1 -1
- package/skills/dknowc-ppt-assistant/scripts/pptx_to_svg/formula_import.py +1 -1
- package/skills/dknowc-ppt-assistant/scripts/pptx_to_svg/hyperlinks.py +2 -2
- package/skills/dknowc-ppt-assistant/scripts/pptx_to_svg/preset_authoring.py +2 -2
- package/skills/dknowc-ppt-assistant/scripts/pptx_to_svg/preset_registry_to_svg.py +2 -2
- package/skills/dknowc-ppt-assistant/scripts/pptx_to_svg/preset_svg_markup.py +2 -2
- package/skills/dknowc-ppt-assistant/scripts/pptx_to_svg/slide_to_svg.py +1 -1
- package/skills/dknowc-ppt-assistant/scripts/pptx_to_svg/transition_import.py +1 -1
- package/skills/dknowc-ppt-assistant/scripts/pptx_transitions.py +2 -2
- package/skills/dknowc-ppt-assistant/scripts/preset_shape_svg.py +2 -2
- package/skills/dknowc-ppt-assistant/scripts/preview_slide_html.py +2 -2
- package/skills/dknowc-ppt-assistant/scripts/project_utils.py +2 -2
- package/skills/dknowc-ppt-assistant/scripts/register_key.mjs +710 -322
- package/skills/dknowc-ppt-assistant/scripts/render_trace_html.py +207 -40
- package/skills/dknowc-ppt-assistant/scripts/resource_paths.py +1 -1
- package/skills/dknowc-ppt-assistant/scripts/shape_boolean_svg.py +2 -2
- package/skills/dknowc-ppt-assistant/scripts/slide_roster.py +1 -1
- package/skills/dknowc-ppt-assistant/scripts/svg_finalize/__init__.py +2 -9
- package/skills/dknowc-ppt-assistant/scripts/svg_finalize/align_embed_images.py +1 -1
- package/skills/dknowc-ppt-assistant/scripts/svg_finalize/crop_images.py +3 -3
- package/skills/dknowc-ppt-assistant/scripts/svg_quality/__init__.py +2 -2
- package/skills/dknowc-ppt-assistant/scripts/svg_quality/checker.py +9 -10
- package/skills/dknowc-ppt-assistant/scripts/svg_quality/cli.py +4 -4
- package/skills/dknowc-ppt-assistant/scripts/svg_quality/svg_contracts.py +2 -2
- package/skills/dknowc-ppt-assistant/scripts/svg_quality/xml_support.py +1 -1
- package/skills/dknowc-ppt-assistant/scripts/svg_quality_checker.py +1 -1
- package/skills/dknowc-ppt-assistant/scripts/svg_to_pptx/drawingml/hyperlinks.py +2 -2
- package/skills/dknowc-ppt-assistant/scripts/svg_to_pptx/drawingml/theme_colors.py +1 -1
- package/skills/dknowc-ppt-assistant/scripts/svg_to_pptx/drawingml/theme_fonts.py +1 -1
- package/skills/dknowc-ppt-assistant/scripts/svg_to_pptx/geometry_properties.py +1 -1
- package/skills/dknowc-ppt-assistant/scripts/svg_to_pptx/native_objects/formula.py +2 -2
- package/skills/dknowc-ppt-assistant/scripts/svg_to_pptx/native_objects/formula_ast.py +1 -1
- package/skills/dknowc-ppt-assistant/scripts/svg_to_pptx/native_objects/formula_compiler.py +2 -2
- package/skills/dknowc-ppt-assistant/scripts/svg_to_pptx/native_objects/formula_omml.py +2 -2
- package/skills/dknowc-ppt-assistant/scripts/svg_to_pptx/native_objects/formula_parser.py +2 -2
- package/skills/dknowc-ppt-assistant/scripts/svg_to_pptx/native_objects/formula_profile.py +1 -1
- package/skills/dknowc-ppt-assistant/scripts/svg_to_pptx/native_objects/formula_run_properties.py +1 -1
- package/skills/dknowc-ppt-assistant/scripts/svg_to_pptx/native_objects/inline_formula.py +2 -2
- package/skills/dknowc-ppt-assistant/scripts/svg_to_pptx/pptx_package/builder.py +9 -11
- package/skills/dknowc-ppt-assistant/scripts/svg_to_pptx/pptx_package/cli.py +7 -5
- package/skills/dknowc-ppt-assistant/scripts/svg_to_pptx/pptx_package/template_structure.py +1 -1
- package/skills/dknowc-ppt-assistant/scripts/svg_to_pptx/pptx_package/template_validation.py +1 -1
- package/skills/dknowc-ppt-assistant/scripts/svg_to_pptx/semantic_markers.py +1 -1
- package/skills/dknowc-ppt-assistant/scripts/svg_to_pptx/shape_boolean.py +2 -2
- package/skills/dknowc-ppt-assistant/scripts/svg_to_pptx/text_outline.py +2 -2
- package/skills/dknowc-ppt-assistant/scripts/svg_to_pptx.py +1 -1
- package/skills/dknowc-ppt-assistant/scripts/trusted_search.py +63 -11
- package/skills/dknowc-ppt-assistant/scripts/update_spec.py +25 -1
- package/skills/dknowc-ppt-assistant/workflows/generate-pptx.md +30 -16
- package/skills/dknowc-ppt-assistant/workflows/routing.md +1 -1
- package/skills/dknowc-trusted-search/README.md +13 -13
- package/skills/dknowc-trusted-search/SKILL.md +96 -56
- package/skills/dknowc-trusted-search/reference/onboarding_scripts.md +40 -15
- package/skills/dknowc-trusted-search/scripts/api_key.py +11 -26
- package/skills/dknowc-trusted-search/scripts/attribution.py +1 -1
- package/skills/dknowc-trusted-search/scripts/deep_query.py +4 -2
- package/skills/dknowc-trusted-search/scripts/initialize.py +10 -10
- package/skills/dknowc-trusted-search/scripts/mcp_direct.py +3 -2
- package/skills/dknowc-trusted-search/scripts/merge_search_results.py +68 -10
- package/skills/dknowc-trusted-search/scripts/register_key.mjs +617 -275
- package/skills/dknowc-trusted-search/scripts/render_trace_html.py +87 -19
- package/skills/dknowc-trusted-search/scripts/trusted_search.py +109 -44
- package/skills/dknowc-official-doc-writer/scripts/mcp_convert.py +0 -272
- package/skills/dknowc-ppt-assistant/references/upstream-docs/svg-pipeline.md +0 -842
- package/skills/dknowc-ppt-assistant/scripts/finalize_svg.py +0 -507
- package/skills/dknowc-ppt-assistant/scripts/svg_finalize/svg_rect_to_path.py +0 -346
- package/skills/dknowc-trusted-search/scripts/mcp_convert.py +0 -198
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
- outline 提纲版:结构方案确认门前的提纲答案文件(页面规划表 + 口径事项清单)→ 事前核验
|
|
6
6
|
- final 成稿版:交付时的页面级结论文本 → 事后溯源
|
|
7
7
|
|
|
8
|
-
3.7.x
|
|
8
|
+
3.7.x 同源架构(参考深知晓交互原型,数据口径保持自有与真实):
|
|
9
9
|
- 顶栏:身份章 + 标题 + 工具组(只看正文 / 复制全文 / 打印归档)+ 阅读进度条
|
|
10
10
|
- Hero:大标题 + 真实统计(N 次检索 · M 条材料 · K 处引用)+ 双视图切换
|
|
11
11
|
- 过程回顾条:检索 → 入库 → 逐条比对 → 核验完成(静态回放,数字全部真实计算)
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
接口提供存档快照(screenShotPath)时作为**附加回看入口**与原文链接并存
|
|
16
16
|
(路径容错补 /A/、纯本地格式校验)
|
|
17
17
|
|
|
18
|
-
PPT
|
|
18
|
+
PPT 特有口径(与同源版本的既定差异):
|
|
19
19
|
- 提醒制:数据缺口(缺原文链接/缺摘录)不判不通过、指标恒绿附温和提醒;只有无素材/
|
|
20
20
|
正文无角标/角标未绑定三种真实错误才判不通过
|
|
21
21
|
- 双版 stage:提纲版(事前核验)与成稿版(事后溯源)同脚本同形式,标题与身份章带版本后缀
|
|
@@ -35,8 +35,10 @@ import json
|
|
|
35
35
|
import re
|
|
36
36
|
import sys
|
|
37
37
|
from datetime import datetime
|
|
38
|
+
from html.parser import HTMLParser
|
|
38
39
|
from pathlib import Path
|
|
39
40
|
from typing import Any, Dict, List, Optional, Tuple
|
|
41
|
+
from urllib.parse import urlsplit
|
|
40
42
|
|
|
41
43
|
SKILL_ROOT = Path(__file__).resolve().parent.parent
|
|
42
44
|
# 工作区根:dsh 场景通过环境变量 DKNWOC_WS_ROOT 指向会话工作区,未设置时回退到 cwd
|
|
@@ -97,6 +99,27 @@ def esc(value: Any) -> str:
|
|
|
97
99
|
return html.escape(str(value or ""), quote=True)
|
|
98
100
|
|
|
99
101
|
|
|
102
|
+
def safe_url(value: Any) -> str:
|
|
103
|
+
"""外链协议白名单:仅放行 http/https,其余(javascript:/data:/file: 等)返回空串。
|
|
104
|
+
|
|
105
|
+
所有 href 一律经由本函数,非法协议链接不渲染(防点击执行)。
|
|
106
|
+
"""
|
|
107
|
+
url = str(value or "").strip()
|
|
108
|
+
if not url:
|
|
109
|
+
return ""
|
|
110
|
+
try:
|
|
111
|
+
scheme = urlsplit(url).scheme.lower()
|
|
112
|
+
except ValueError:
|
|
113
|
+
return ""
|
|
114
|
+
return url if scheme in ("http", "https") else ""
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
def dumps_for_script(obj: Any) -> str:
|
|
118
|
+
"""嵌入 <script> 的序列化:补全字符级转义防注入(< > & 全转义,不只是 </)。"""
|
|
119
|
+
s = json.dumps(obj, ensure_ascii=False)
|
|
120
|
+
return s.replace("<", "\\u003c").replace(">", "\\u003e").replace("&", "\\u0026")
|
|
121
|
+
|
|
122
|
+
|
|
100
123
|
def load_json(path: Path) -> Dict[str, Any]:
|
|
101
124
|
with path.open("r", encoding="utf-8") as f:
|
|
102
125
|
data = json.load(f)
|
|
@@ -304,7 +327,8 @@ def source_from_article(item: Dict[str, Any], index: int, segment: Optional[Dict
|
|
|
304
327
|
),
|
|
305
328
|
"date": first_str(item.get("发布日期"), item.get("date"), item.get("发布时间"), item.get("createDate"), vo.get("dateTime"), vo.get("createDate")),
|
|
306
329
|
"url": first_str(item.get("sourceUrl"), item.get("source_url"), item.get("源网址"), item.get("原文链接"), item.get("url"), item.get("原文"), vo.get("sourceUrl"), vo.get("url")),
|
|
307
|
-
"policy_url": first_str(item.get("policyUrl"), item.get("policy_url"), item.get("知识专库原文"),
|
|
330
|
+
"policy_url": first_str(item.get("policyUrl"), item.get("policy_url"), item.get("知识专库原文"),
|
|
331
|
+
item.get("知识专库链接"), vo.get("policyUrl")),
|
|
308
332
|
"excerpt": segment.get("text") or paragraph_text(item),
|
|
309
333
|
"section": first_str(item.get("正文对应"), item.get("section"), item.get("支撑")),
|
|
310
334
|
"kind": first_str(item.get("类型"), item.get("type"), item.get("素材类型"), vo.get("typeName"), "材料"),
|
|
@@ -328,10 +352,15 @@ def source_from_article(item: Dict[str, Any], index: int, segment: Optional[Dict
|
|
|
328
352
|
source["doc_section"] = " › ".join(first_chain)
|
|
329
353
|
source["chain_full"] = " › ".join(segments[0]["chain"]) if segments else ""
|
|
330
354
|
# 发文字号:必须是标准格式(〔年份〕序号号);描述性文字("XX印发"类自造
|
|
331
|
-
#
|
|
355
|
+
# 描述)不显示、当无文号处理(模型把文号写成
|
|
332
356
|
# "中办、国办 2026 年印发"类描述导致关键性行失真)。
|
|
333
357
|
_dn = first_str(item.get("文号"), item.get("发文字号"), item.get("doc_number"))
|
|
334
358
|
source["doc_number"] = _dn if re.search(r"〔\d{4}〕\s*\d+\s*号", _dn) else ""
|
|
359
|
+
# V2 文章级新字段(生效/失效日期、文章类型):只认接口字段,空则不显示;
|
|
360
|
+
# 文号不从段落正文提取(V2 的 policyFiles.writtenText 实测为空,文号统一取文章级字段)。
|
|
361
|
+
source["effective_date"] = first_str(item.get("生效日期"), item.get("effective_date"))
|
|
362
|
+
source["expiry_date"] = first_str(item.get("失效日期"), item.get("expiry_date"))
|
|
363
|
+
source["article_type"] = first_str(item.get("文章类型"), item.get("article_type"))
|
|
335
364
|
# 所属搜索条件(多路检索分组)与引用状态(未引用=接口召回但正文未采用)
|
|
336
365
|
source["search_key"] = first_str(item.get("搜索条件"), item.get("search_key"))
|
|
337
366
|
source["used"] = item.get("已引用", item.get("used", True))
|
|
@@ -410,7 +439,7 @@ def collect_raw_articles(payload: Dict[str, Any]) -> List[Dict[str, Any]]:
|
|
|
410
439
|
|
|
411
440
|
|
|
412
441
|
def _dedupe_key(source: Dict[str, Any]) -> tuple:
|
|
413
|
-
"""归一去重键:标题 +
|
|
442
|
+
"""归一去重键:标题 + 原网址(同款修复)。
|
|
414
443
|
|
|
415
444
|
旧键含 id(材料编号),而 id 要么是位置兜底序号、要么是角标号——同一篇文章被
|
|
416
445
|
多路召回或按段落返回多条片段时,各条 id 不同,含 id 的键**等于从不去重**,
|
|
@@ -545,7 +574,7 @@ def classify_check_value(raw: Any) -> Tuple[str, str]:
|
|
|
545
574
|
兼容多种写法:`pass` / `true` / `通过` / `通过:说明文字` / `✓` 等;
|
|
546
575
|
值后面的说明文字保留下来供核验单展示。红项(fail)只给显式声明的
|
|
547
576
|
"未通过";无法识别的描述性文本按"未记录"(none)处理不判红——
|
|
548
|
-
|
|
577
|
+
自检书写格式走样不应被放大成核验红项(实测
|
|
549
578
|
模型写入"备注"等额外键导致交付前检查误判红)。
|
|
550
579
|
"""
|
|
551
580
|
text = str(raw or "").strip()
|
|
@@ -601,7 +630,7 @@ def compute_verification(answer: str, sources: List[Dict[str, str]], payload: Di
|
|
|
601
630
|
no_citation = bool(sources) and not cited
|
|
602
631
|
|
|
603
632
|
# ③ 时效检查:材料日期范围与历史材料计数
|
|
604
|
-
#
|
|
633
|
+
# 统计口径:③材料新旧/④材料构成只算正文引用的来源文章——
|
|
605
634
|
# sources 含未引用召回,其未来日期/类型会把时效范围与构成写歪。
|
|
606
635
|
dated = [parse_year_month(s.get("date")) for s in cited_sources]
|
|
607
636
|
dated = [d for d in dated if d]
|
|
@@ -675,11 +704,15 @@ def compute_verification(answer: str, sources: List[Dict[str, str]], payload: Di
|
|
|
675
704
|
# 过程回顾 / 热词(真实计算,不虚构流程)
|
|
676
705
|
# ============================================================
|
|
677
706
|
|
|
678
|
-
def compute_process_stats(sources: List[Dict[str, str]], answer: str
|
|
707
|
+
def compute_process_stats(sources: List[Dict[str, str]], answer: str,
|
|
708
|
+
call_log: Optional[List[Dict[str, Any]]] = None) -> Dict[str, Any]:
|
|
679
709
|
"""过程回顾条数据:检索次数、每组检索的召回/采用数、入库与引用计数。
|
|
680
710
|
|
|
681
711
|
全部来自素材自带的真实字段(search_key 分组、used 引用状态、正文角标计数),
|
|
682
|
-
不虚构任何流程步骤。
|
|
712
|
+
不虚构任何流程步骤。call_log=合并 JSON 顶层「检索记录」(可选项,每条
|
|
713
|
+
{purpose, query, 通道, new_articles, added_paragraphs},由合并补搜轮时按合并
|
|
714
|
+
前后差值如实填写):存在时过程条按真实调用次数统计,补搜路展示
|
|
715
|
+
「新增 N 篇 · 补充 K 段」,让补搜有没有用一眼可见。
|
|
683
716
|
"""
|
|
684
717
|
order: List[str] = []
|
|
685
718
|
for s in sources:
|
|
@@ -698,6 +731,25 @@ def compute_process_stats(sources: List[Dict[str, str]], answer: str) -> Dict[st
|
|
|
698
731
|
used_count = sum(1 for s in sources if s.get("used", True))
|
|
699
732
|
unused_count = len(sources) - used_count
|
|
700
733
|
n_cite_marks = len(re.findall(r"\[(\d+)\]", answer))
|
|
734
|
+
# 检索记录(可选):主检索/补搜逐次记录;补搜路的增量来自记录中的真实差值
|
|
735
|
+
log_rows: List[Dict[str, Any]] = []
|
|
736
|
+
n_supplement = 0
|
|
737
|
+
if isinstance(call_log, list) and call_log:
|
|
738
|
+
for entry in call_log:
|
|
739
|
+
if not isinstance(entry, dict):
|
|
740
|
+
continue
|
|
741
|
+
is_supp = str(entry.get("通道") or entry.get("channel") or "").find("补搜") >= 0 \
|
|
742
|
+
or str(entry.get("purpose") or "").find("补搜") >= 0
|
|
743
|
+
if is_supp:
|
|
744
|
+
n_supplement += 1
|
|
745
|
+
log_rows.append({
|
|
746
|
+
"purpose": first_str(entry.get("purpose"), entry.get("方向"), ""),
|
|
747
|
+
"query": first_str(entry.get("query"), entry.get("检索词"), ""),
|
|
748
|
+
"channel": first_str(entry.get("通道"), entry.get("channel"), "主检索" if not is_supp else "补搜"),
|
|
749
|
+
"is_supp": is_supp,
|
|
750
|
+
"new_articles": entry.get("new_articles", entry.get("新增文章")),
|
|
751
|
+
"added_paragraphs": entry.get("added_paragraphs", entry.get("补充段落")),
|
|
752
|
+
})
|
|
701
753
|
return {
|
|
702
754
|
"conds": cond_rows,
|
|
703
755
|
"n_searches": n_searches,
|
|
@@ -706,6 +758,9 @@ def compute_process_stats(sources: List[Dict[str, str]], answer: str) -> Dict[st
|
|
|
706
758
|
"used_count": used_count,
|
|
707
759
|
"unused_count": unused_count,
|
|
708
760
|
"n_cite_marks": n_cite_marks,
|
|
761
|
+
"call_log": log_rows,
|
|
762
|
+
"n_main_calls": (len(log_rows) - n_supplement) if log_rows else 0,
|
|
763
|
+
"n_supplement": n_supplement,
|
|
709
764
|
}
|
|
710
765
|
|
|
711
766
|
|
|
@@ -808,21 +863,102 @@ def render_markdown_table(lines: List[str], citation_repl) -> str:
|
|
|
808
863
|
return f'<div class="tbl-wrap"><table class="data-tbl{wide_cls}"><thead><tr>{head_html}</tr></thead><tbody>{"".join(rows)}</tbody></table></div>'
|
|
809
864
|
|
|
810
865
|
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
866
|
+
_TABLE_ALLOWED_TAGS = {"table", "thead", "tbody", "tr", "td", "th", "br"}
|
|
867
|
+
_TABLE_VOID_TAGS = {"br"}
|
|
868
|
+
_TABLE_SKIP_CONTENT_TAGS = {"script", "style"}
|
|
869
|
+
|
|
870
|
+
|
|
871
|
+
class _TableSanitizer(HTMLParser):
|
|
872
|
+
"""表格 HTML 元素级白名单(替代正则清洗,防标签注入与属性注入):
|
|
873
|
+
|
|
874
|
+
- 只放行 table/thead/tbody/tr/td/th/br,输出不带任何属性;
|
|
875
|
+
- 其余标签一律丢弃(文本继续走 handle_data,统一转义);
|
|
876
|
+
- script/style 连内容一起丢弃;
|
|
877
|
+
- 乱序/未闭合标签按栈自平衡,不产生悬空标签;
|
|
878
|
+
- 解析异常由调用方兜底为整体转义。
|
|
879
|
+
"""
|
|
880
|
+
|
|
881
|
+
def __init__(self) -> None:
|
|
882
|
+
super().__init__(convert_charrefs=True)
|
|
883
|
+
self.out: List[str] = []
|
|
884
|
+
self.stack: List[str] = []
|
|
885
|
+
self.skip_depth = 0
|
|
886
|
+
|
|
887
|
+
def handle_starttag(self, tag: str, attrs) -> None:
|
|
888
|
+
tag = tag.lower()
|
|
889
|
+
if tag in _TABLE_SKIP_CONTENT_TAGS:
|
|
890
|
+
self.skip_depth += 1
|
|
891
|
+
return
|
|
892
|
+
if self.skip_depth or tag not in _TABLE_ALLOWED_TAGS:
|
|
893
|
+
return
|
|
894
|
+
if tag in _TABLE_VOID_TAGS:
|
|
895
|
+
self.out.append("<br>")
|
|
896
|
+
return
|
|
897
|
+
self.out.append(f"<{tag}>")
|
|
898
|
+
self.stack.append(tag)
|
|
899
|
+
|
|
900
|
+
def handle_startendtag(self, tag: str, attrs) -> None:
|
|
901
|
+
self.handle_starttag(tag, attrs)
|
|
902
|
+
self.handle_endtag(tag)
|
|
903
|
+
|
|
904
|
+
def handle_endtag(self, tag: str) -> None:
|
|
905
|
+
tag = tag.lower()
|
|
906
|
+
if tag in _TABLE_SKIP_CONTENT_TAGS:
|
|
907
|
+
self.skip_depth = max(0, self.skip_depth - 1)
|
|
908
|
+
return
|
|
909
|
+
if self.skip_depth or tag not in _TABLE_ALLOWED_TAGS or tag in _TABLE_VOID_TAGS:
|
|
910
|
+
return
|
|
911
|
+
if tag in self.stack:
|
|
912
|
+
while self.stack:
|
|
913
|
+
top = self.stack.pop()
|
|
914
|
+
self.out.append(f"</{top}>")
|
|
915
|
+
if top == tag:
|
|
916
|
+
break
|
|
917
|
+
|
|
918
|
+
def handle_data(self, data: str) -> None:
|
|
919
|
+
if not self.skip_depth:
|
|
920
|
+
self.out.append(html.escape(data, quote=False))
|
|
921
|
+
|
|
922
|
+
def close(self) -> None:
|
|
923
|
+
super().close()
|
|
924
|
+
while self.stack:
|
|
925
|
+
self.out.append(f"</{self.stack.pop()}>")
|
|
926
|
+
|
|
927
|
+
|
|
928
|
+
def _fix_thead_rows(table_html: str) -> str:
|
|
929
|
+
"""修正源表格把多行数据包进 <thead> 的畸形结构:只保留第一行为表头,其余移入 <tbody>。
|
|
930
|
+
|
|
931
|
+
政府门户抓取的表格常把数据行一起包在 thead 里(如统计分类表 4 行数据全在
|
|
932
|
+
thead、仅最后 1 行在 tbody)。白名单清洗只保结构不改行归属,CSS 又给 thead
|
|
933
|
+
单元格加表头底色——数据行整片变"表头色"。此处把 thead 第 2 行起全部并入
|
|
934
|
+
tbody(无 tbody 则新建),只有真正的首行作表头。
|
|
935
|
+
"""
|
|
936
|
+
m = re.search(r"<thead>(.*?)</thead>", table_html, flags=re.S)
|
|
937
|
+
if not m:
|
|
938
|
+
return table_html
|
|
939
|
+
rows = re.findall(r"<tr>.*?</tr>", m.group(1), flags=re.S)
|
|
940
|
+
if len(rows) <= 1:
|
|
941
|
+
return table_html
|
|
942
|
+
head = f"<thead>{rows[0]}</thead>"
|
|
943
|
+
moved = "".join(rows[1:])
|
|
944
|
+
rest = table_html[m.end():]
|
|
945
|
+
tb = re.search(r"<tbody>(.*?)</tbody>", rest, flags=re.S)
|
|
946
|
+
if tb:
|
|
947
|
+
rest = rest[:tb.start()] + f"<tbody>{moved}{tb.group(1)}</tbody>" + rest[tb.end():]
|
|
948
|
+
else:
|
|
949
|
+
rest = f"<tbody>{moved}</tbody>" + rest
|
|
950
|
+
return table_html[:m.start()] + head + rest
|
|
951
|
+
|
|
824
952
|
|
|
825
|
-
|
|
953
|
+
def sanitize_table_html(text: str) -> str:
|
|
954
|
+
"""清洗接口表格 HTML:只保留表格结构标签,属性丢弃、文本转义、脚本样式连内容丢弃。"""
|
|
955
|
+
parser = _TableSanitizer()
|
|
956
|
+
try:
|
|
957
|
+
parser.feed(str(text or ""))
|
|
958
|
+
parser.close()
|
|
959
|
+
except Exception: # 解析异常兜底:整体转义,宁可不渲染表格
|
|
960
|
+
return html.escape(str(text or ""), quote=False)
|
|
961
|
+
return _fix_thead_rows("".join(parser.out))
|
|
826
962
|
|
|
827
963
|
|
|
828
964
|
def render_excerpt_html(text: str) -> str:
|
|
@@ -843,13 +979,13 @@ def parse_answer_blocks(answer: str, valid_ids: set, chip_map: Optional[Dict[str
|
|
|
843
979
|
jb = chip_map.get(cid)
|
|
844
980
|
if not jb:
|
|
845
981
|
return ""
|
|
846
|
-
#
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
link = (f'<a class="jb-src" href="{esc(
|
|
852
|
-
f'{ARROW_SVG}<span
|
|
982
|
+
# 链接原样给出(不做死活检测);无原文链接但有存档快照时,快照作为附加入口。
|
|
983
|
+
# href 一律经 safe_url 协议白名单(仅 http/https),非法协议不渲染。
|
|
984
|
+
jb_url = safe_url(jb.get("url")) or safe_url(jb.get("snapshot"))
|
|
985
|
+
if jb_url:
|
|
986
|
+
btn_txt = "查看全文" if safe_url(jb.get("url")) else "查看存档全文"
|
|
987
|
+
link = (f'<a class="jb-src" href="{esc(jb_url)}" target="_blank" rel="noopener noreferrer">'
|
|
988
|
+
f'{ARROW_SVG}<span>{btn_txt}</span></a>')
|
|
853
989
|
else:
|
|
854
990
|
link = ""
|
|
855
991
|
# 原文直达区展示标题链(多段分块,各段带链——快速人工核验的核心抓手)
|
|
@@ -1034,8 +1170,12 @@ def build_chip_data(sources: List[Dict[str, str]]) -> Dict[str, Dict[str, Any]]:
|
|
|
1034
1170
|
|
|
1035
1171
|
def render_source_links(url: str, policy_url: str = "", snapshot: str = "") -> str:
|
|
1036
1172
|
"""链接区:接口返回的链接**原样展示**(不做连通性检测、不隐藏);
|
|
1037
|
-
存档快照作为**附加回看入口**与原文链接并存,文案如实区分不冒充原文。
|
|
1173
|
+
存档快照作为**附加回看入口**与原文链接并存,文案如实区分不冒充原文。
|
|
1174
|
+
href 一律经 safe_url 协议白名单(仅 http/https),非法协议不渲染。"""
|
|
1038
1175
|
links = []
|
|
1176
|
+
url = safe_url(url)
|
|
1177
|
+
snapshot = safe_url(snapshot)
|
|
1178
|
+
policy_url = safe_url(policy_url)
|
|
1039
1179
|
if url and url != "接口未返回":
|
|
1040
1180
|
links.append(f'<a href="{esc(url)}" target="_blank" rel="noopener">查看全文 ↗</a>')
|
|
1041
1181
|
if snapshot:
|
|
@@ -1123,7 +1263,7 @@ def render_verify_panel(v: Dict[str, Any], stage: str = "final") -> str:
|
|
|
1123
1263
|
f'<span class="d">检索 JSON 没写入 self_check(默认查:{esc(default_names)})</span></div>')
|
|
1124
1264
|
|
|
1125
1265
|
# 3.7.2 起「现行效力」提示行移除:该提示对用户无操作价值,policy_count
|
|
1126
|
-
#
|
|
1266
|
+
# 保留在计算层不再展示(口径)。
|
|
1127
1267
|
|
|
1128
1268
|
what = "提纲页面规划" if stage == "outline" else "页面级结论"
|
|
1129
1269
|
return f"""
|
|
@@ -1223,7 +1363,7 @@ def strip_leading_chain(text: str, chain: List[str]) -> str:
|
|
|
1223
1363
|
def render_crumb(chain: List[str]) -> str:
|
|
1224
1364
|
"""面包屑标题链:文章 › 章 › 节(标题链是模型生成的结构化位置,核验核心抓手)。
|
|
1225
1365
|
|
|
1226
|
-
|
|
1366
|
+
降级规则:段落本身无章节层级(链上只有文章名)时不显示
|
|
1227
1367
|
标题链行——材料卡标题已是文章名,单独一行重复文章名对定位无增量。
|
|
1228
1368
|
"""
|
|
1229
1369
|
parts = [esc(level) for level in chain if level]
|
|
@@ -1267,8 +1407,13 @@ def render_source_card(source: Dict[str, str], for_print: bool = False) -> str:
|
|
|
1267
1407
|
vk = f'<span class="sc-vk warn">◐ {reason}</span>'
|
|
1268
1408
|
note_html = ""
|
|
1269
1409
|
links = render_source_links(source.get("url"), source.get("policy_url", ""), source.get("snapshot", ""))
|
|
1270
|
-
#
|
|
1271
|
-
|
|
1410
|
+
# 关键性行:有文号时"文号 · 生效/失效 · 类型 · 数据源 · 日期",空字段自动跳过
|
|
1411
|
+
eff = source.get("effective_date")
|
|
1412
|
+
exp = source.get("expiry_date")
|
|
1413
|
+
eff_txt = f"生效 {eff}" if eff else ""
|
|
1414
|
+
exp_txt = f"失效 {exp}" if exp else ""
|
|
1415
|
+
meta_parts = [v for v in [source.get("doc_number"), eff_txt, exp_txt, source.get("article_type"),
|
|
1416
|
+
source.get("agency"), source.get("date"), source.get("area")]
|
|
1272
1417
|
if v and v != "未知来源"]
|
|
1273
1418
|
meta = " | ".join(meta_parts)
|
|
1274
1419
|
# 高可信徽标:仅"发布日期可信度=高"(模型治理入库、标题模型精抽)的材料;"较高"(门户抓取)不标。
|
|
@@ -1311,6 +1456,22 @@ def render_process_bar(stats: Dict[str, Any], verification: Dict[str, Any]) -> s
|
|
|
1311
1456
|
f'<span>召回 {row["total"]} 条 · 正文采用 {row["used"]} 条</span></div>'
|
|
1312
1457
|
for row in stats["conds"]
|
|
1313
1458
|
) or '<div class="pd-row"><span>本次溯源 JSON 未记录各次检索条件</span></div>'
|
|
1459
|
+
# 检索记录存在时,明细补一行补搜说明(新增 N 篇 · 补充 K 段),补搜有没有用一眼可见
|
|
1460
|
+
call_log = stats.get("call_log") or []
|
|
1461
|
+
for entry in call_log:
|
|
1462
|
+
if not entry.get("is_supp"):
|
|
1463
|
+
continue
|
|
1464
|
+
na = entry.get("new_articles")
|
|
1465
|
+
np_ = entry.get("added_paragraphs")
|
|
1466
|
+
inc_parts = []
|
|
1467
|
+
if isinstance(na, int):
|
|
1468
|
+
inc_parts.append(f"新增 {na} 篇")
|
|
1469
|
+
if isinstance(np_, int):
|
|
1470
|
+
inc_parts.append(f"补充 {np_} 段")
|
|
1471
|
+
inc_txt = " · ".join(inc_parts) if inc_parts else "增量未记录"
|
|
1472
|
+
label = esc(entry.get("purpose") or entry.get("query") or "缺口补搜")
|
|
1473
|
+
detail_rows += (f'<div class="pd-row"><b>补搜 · {label}</b>'
|
|
1474
|
+
f'<span>{inc_txt}</span></div>')
|
|
1314
1475
|
detail_hint = f'{esc(short(first_query, 26))}…' if (stats["n_searches"] > 1 and first_query) else "查看检索明细"
|
|
1315
1476
|
if stats["n_searches"] > 1:
|
|
1316
1477
|
step1_sub = f"共 {stats['n_searches']} 路检索 · {detail_hint}"
|
|
@@ -1322,13 +1483,15 @@ def render_process_bar(stats: Dict[str, Any], verification: Dict[str, Any]) -> s
|
|
|
1322
1483
|
step4_icon = "✓" if ov["passed"] else "!"
|
|
1323
1484
|
step4_label = "核验完成" if ov["passed"] else "核验未完全通过"
|
|
1324
1485
|
step4_sub = "结论:正文依据逐条对过原文" if ov["passed"] else esc(short(";".join(ov["reasons"]) or "见核验报告单", 30))
|
|
1486
|
+
n_supp = stats.get("n_supplement") or 0
|
|
1487
|
+
step1_title = f"深知检索 {stats['n_searches']} 路" + (f" · 补搜 {n_supp} 次" if n_supp else "")
|
|
1325
1488
|
return f"""
|
|
1326
1489
|
<section class="process" aria-label="生成过程回顾">
|
|
1327
1490
|
<div class="p-head"><b>过程回顾</b><span>数字来自本次任务的真实记录</span></div>
|
|
1328
1491
|
<ol class="p-steps">
|
|
1329
1492
|
<li class="p-step expandable" id="p-step-search" role="button" tabindex="0" title="展开各路检索明细">
|
|
1330
1493
|
<span class="p-no">1</span>
|
|
1331
|
-
<div class="p-txt"><b
|
|
1494
|
+
<div class="p-txt"><b>{step1_title}</b><i>{step1_sub}</i></div>
|
|
1332
1495
|
</li>
|
|
1333
1496
|
<li class="p-arrow" aria-hidden="true">›</li>
|
|
1334
1497
|
<li class="p-step">
|
|
@@ -1437,7 +1600,7 @@ def _next_version_path(path: Path) -> Path:
|
|
|
1437
1600
|
"""输出文件已存在时不覆盖:自动改为 原名_v2 / _v3 … 另存。
|
|
1438
1601
|
|
|
1439
1602
|
追加修改后重跑渲染时,旧版本保留、新版本号递增——不覆盖已交付内容,
|
|
1440
|
-
也不会再靠宿主目录里的 "名字 (2)"
|
|
1603
|
+
也不会再靠宿主目录里的 "名字 (2)" 兜底。命名与交付重名规则一致(同名 _v2 副本化)。
|
|
1441
1604
|
"""
|
|
1442
1605
|
if not path.exists():
|
|
1443
1606
|
return path
|
|
@@ -2253,13 +2416,17 @@ def render_html(payload: Dict[str, Any], title: str, answer_override: str = "",
|
|
|
2253
2416
|
s["used"] = False
|
|
2254
2417
|
# 3.7.2 起知识专库原始召回存档(kb_zone)移除:并行检索下接口返回的
|
|
2255
2418
|
# knowledgeBase 链接会错乱不可靠,且未引用召回材料已在专库全量展示,
|
|
2256
|
-
#
|
|
2419
|
+
# 「知识专库链接不进报告」的前提(检索并行化的前置)。
|
|
2257
2420
|
generated_at = generated_at or datetime.now()
|
|
2258
2421
|
generated = generated_at.strftime("%Y-%m-%d %H:%M")
|
|
2259
2422
|
stage_label = STAGE_LABELS.get(stage, "成稿版")
|
|
2260
2423
|
|
|
2261
2424
|
verification = compute_verification(answer, sources, payload, generated_at)
|
|
2262
|
-
|
|
2425
|
+
call_log = payload.get("检索记录")
|
|
2426
|
+
if not isinstance(call_log, list):
|
|
2427
|
+
content_layer = payload.get("content") if isinstance(payload.get("content"), dict) else {}
|
|
2428
|
+
call_log = content_layer.get("检索记录") if isinstance(content_layer.get("检索记录"), list) else None
|
|
2429
|
+
process_stats = compute_process_stats(sources, answer, call_log)
|
|
2263
2430
|
hot_terms = extract_hot_terms(answer, sources)
|
|
2264
2431
|
citation_warning = ""
|
|
2265
2432
|
if sources and not used:
|
|
@@ -2288,7 +2455,7 @@ def render_html(payload: Dict[str, Any], title: str, answer_override: str = "",
|
|
|
2288
2455
|
origin_html = (f'<div class="hero-q"><span class="q-tag">原问题</span>'
|
|
2289
2456
|
f'<span class="q-txt">{esc(origin_question)}</span></div>')
|
|
2290
2457
|
|
|
2291
|
-
jb_tables_json =
|
|
2458
|
+
jb_tables_json = dumps_for_script(jb_tables)
|
|
2292
2459
|
jb_tables_script = (f'<script type="application/json" id="jb-tables">{jb_tables_json}</script>\n'
|
|
2293
2460
|
if jb_tables else "")
|
|
2294
2461
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env python3
|
|
2
2
|
"""
|
|
3
|
-
PPT
|
|
3
|
+
深知可信PPT - Shape Boolean SVG Fragment Tool
|
|
4
4
|
|
|
5
5
|
Combine closed SVG shapes or resolvable text outlines and print the resulting
|
|
6
6
|
canonical SVG path fragment to stdout. Result geometry is in SVG-root coordinate
|
|
@@ -22,7 +22,7 @@ Examples:
|
|
|
22
22
|
--operation subtract --source scrim --source chapter-number --id reveal
|
|
23
23
|
|
|
24
24
|
Dependencies:
|
|
25
|
-
skia-pathops, local PPT
|
|
25
|
+
skia-pathops, local 深知可信PPT modules, and uharfbuzz for text operands
|
|
26
26
|
"""
|
|
27
27
|
|
|
28
28
|
from __future__ import annotations
|
|
@@ -1,12 +1,5 @@
|
|
|
1
1
|
"""svg_finalize — shared self-containment + DrawingML-compat utilities.
|
|
2
2
|
|
|
3
|
-
Used by
|
|
4
|
-
|
|
5
|
-
1. finalize_svg.py — writes svg_output/ → svg_final/ on disk
|
|
6
|
-
2. svg_to_pptx (use_expander, tspan_flattener) — reuses these modules
|
|
7
|
-
in memory during native pptx conversion
|
|
8
|
-
|
|
9
|
-
Deleting any module here is likely to break native pptx output, not just
|
|
10
|
-
svg_final/. See scripts/docs/svg-pipeline.md for the full per-module consumer
|
|
11
|
-
table.
|
|
3
|
+
Used by svg_to_pptx (use_expander, tspan_flattener) in memory during native pptx
|
|
4
|
+
conversion.
|
|
12
5
|
"""
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env python3
|
|
2
2
|
"""
|
|
3
|
-
PPT
|
|
3
|
+
深知可信PPT - Smart Image Cropping Tool
|
|
4
4
|
|
|
5
5
|
Smartly crops images based on the preserveAspectRatio attribute of <image> elements in SVG:
|
|
6
6
|
- slice: Crop to fill (similar to CSS object-fit: cover)
|
|
@@ -325,7 +325,7 @@ def process_directory(directory: str, dry_run: bool = False, verbose: bool = Tru
|
|
|
325
325
|
def main() -> None:
|
|
326
326
|
"""Run the CLI entry point."""
|
|
327
327
|
parser = argparse.ArgumentParser(
|
|
328
|
-
description='PPT
|
|
328
|
+
description='深知可信PPT - Smart Image Cropping Tool',
|
|
329
329
|
formatter_class=argparse.RawDescriptionHelpFormatter,
|
|
330
330
|
epilog='''
|
|
331
331
|
Examples:
|
|
@@ -352,7 +352,7 @@ preserveAspectRatio usage:
|
|
|
352
352
|
print(f"[ERROR] Path not found: {args.path}")
|
|
353
353
|
sys.exit(1)
|
|
354
354
|
|
|
355
|
-
print("PPT
|
|
355
|
+
print("深知可信PPT - Smart Image Cropping")
|
|
356
356
|
print("=" * 50)
|
|
357
357
|
|
|
358
358
|
if args.path.is_file():
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env python3
|
|
2
|
-
"""PPT
|
|
2
|
+
"""深知可信PPT SVG quality-check internals.
|
|
3
3
|
|
|
4
4
|
Use the stable ``scripts/svg_quality_checker.py`` entry point for CLI execution
|
|
5
5
|
and compatibility imports.
|
|
@@ -11,5 +11,5 @@ Examples:
|
|
|
11
11
|
from svg_quality_checker import SVGQualityChecker
|
|
12
12
|
|
|
13
13
|
Dependencies:
|
|
14
|
-
Local PPT
|
|
14
|
+
Local 深知可信PPT validation modules.
|
|
15
15
|
"""
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env python3
|
|
2
|
-
"""PPT
|
|
2
|
+
"""深知可信PPT SVG quality-check implementation.
|
|
3
3
|
|
|
4
4
|
Owns SVG, project-contract, template, and report validation. The stable CLI and
|
|
5
5
|
compatibility import surface remain in ``scripts/svg_quality_checker.py``.
|
|
@@ -11,7 +11,7 @@ Examples:
|
|
|
11
11
|
from svg_quality_checker import SVGQualityChecker
|
|
12
12
|
|
|
13
13
|
Dependencies:
|
|
14
|
-
Standard library plus local PPT
|
|
14
|
+
Standard library plus local 深知可信PPT validation modules.
|
|
15
15
|
"""
|
|
16
16
|
|
|
17
17
|
import copy
|
|
@@ -5516,8 +5516,8 @@ class SVGQualityChecker:
|
|
|
5516
5516
|
'release SVG projects require an explicit spec_lock.md '
|
|
5517
5517
|
'pptx_structure.mode: flat (free design / brand-only) or '
|
|
5518
5518
|
f'structured (deck/layout template); found {label}. New '
|
|
5519
|
-
'free-design projects use mode: flat;
|
|
5520
|
-
'
|
|
5519
|
+
'free-design projects use mode: flat; follow the SVG authoring contract '
|
|
5520
|
+
'in references/svg-authoring.md, '
|
|
5521
5521
|
'then generate new structured SVG pages before export. Existing '
|
|
5522
5522
|
'PPTX/SVG files are not upgraded in place.',
|
|
5523
5523
|
))
|
|
@@ -6775,7 +6775,7 @@ class SVGQualityChecker:
|
|
|
6775
6775
|
- **Explicit structure gaps** are errors when positive structure checks
|
|
6776
6776
|
are enabled: every current reusable SVG declares its Master and Layout
|
|
6777
6777
|
identity. Zero-placeholder Layouts are valid. Legacy template-mode
|
|
6778
|
-
packages fail and must be
|
|
6778
|
+
packages fail and must be migrated to a structured workspace.
|
|
6779
6779
|
- **Placeholder gaps** are reported as *warnings*. Templates may
|
|
6780
6780
|
legitimately omit conventional placeholders or swap them out (e.g.
|
|
6781
6781
|
``{{CLOSING_MESSAGE}}`` instead of ``{{THANK_YOU}}``), and a content
|
|
@@ -6797,7 +6797,7 @@ class SVGQualityChecker:
|
|
|
6797
6797
|
'explicit_structure_mode',
|
|
6798
6798
|
"design_spec.md frontmatter must declare "
|
|
6799
6799
|
"native_structure_mode: structured; legacy template-mode "
|
|
6800
|
-
"workspaces must be re-created
|
|
6800
|
+
"workspaces must be re-created as structured workspaces",
|
|
6801
6801
|
))
|
|
6802
6802
|
if check_structure:
|
|
6803
6803
|
native_contract_path = dir_path / 'native_structure.json'
|
|
@@ -6874,7 +6874,7 @@ class SVGQualityChecker:
|
|
|
6874
6874
|
'legacy_native_structure_pair',
|
|
6875
6875
|
"legacy native_structure.json/source_template.pptx template "
|
|
6876
6876
|
"contracts must be replaced through "
|
|
6877
|
-
"
|
|
6877
|
+
"references/svg-authoring.md",
|
|
6878
6878
|
))
|
|
6879
6879
|
|
|
6880
6880
|
if declared_structure_mode != 'structured':
|
|
@@ -6891,8 +6891,7 @@ class SVGQualityChecker:
|
|
|
6891
6891
|
'error',
|
|
6892
6892
|
'legacy_structure_contract',
|
|
6893
6893
|
"legacy template structure detected; create a new current "
|
|
6894
|
-
"workspace
|
|
6895
|
-
"create-template.md before Step 3 consumption",
|
|
6894
|
+
"workspace per references/svg-authoring.md before Step 3 consumption",
|
|
6896
6895
|
))
|
|
6897
6896
|
spec_pages = self._extract_spec_roster(spec_text) if spec_text else []
|
|
6898
6897
|
custom_contract = self._extract_frontmatter_placeholders(spec_text) if spec_text else {}
|
|
@@ -7578,7 +7577,7 @@ class SVGQualityChecker:
|
|
|
7578
7577
|
def export_report(self, output_file: str = 'svg_quality_report.txt'):
|
|
7579
7578
|
"""Export check report"""
|
|
7580
7579
|
with open(output_file, 'w', encoding='utf-8') as f:
|
|
7581
|
-
f.write("PPT
|
|
7580
|
+
f.write("深知可信PPT SVG Quality Check Report\n")
|
|
7582
7581
|
f.write("=" * 80 + "\n\n")
|
|
7583
7582
|
|
|
7584
7583
|
for result in self.results:
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env python3
|
|
2
|
-
"""PPT
|
|
2
|
+
"""深知可信PPT SVG quality-check CLI implementation.
|
|
3
3
|
|
|
4
4
|
Parses the legacy command-line contract and delegates validation to the checker.
|
|
5
5
|
|
|
@@ -10,7 +10,7 @@ Examples:
|
|
|
10
10
|
python3 scripts/svg_quality_checker.py projects/demo --stage final --json
|
|
11
11
|
|
|
12
12
|
Dependencies:
|
|
13
|
-
Standard library plus local PPT
|
|
13
|
+
Standard library plus local 深知可信PPT validation modules.
|
|
14
14
|
"""
|
|
15
15
|
|
|
16
16
|
import sys
|
|
@@ -55,7 +55,7 @@ def _default_json_report_path(
|
|
|
55
55
|
|
|
56
56
|
def print_usage() -> None:
|
|
57
57
|
"""Print CLI usage information."""
|
|
58
|
-
print("PPT
|
|
58
|
+
print("深知可信PPT - SVG Quality Check Tool\n")
|
|
59
59
|
print("Usage:")
|
|
60
60
|
print(" python3 scripts/svg_quality_checker.py <svg_file>")
|
|
61
61
|
print(" python3 scripts/svg_quality_checker.py <directory>")
|
|
@@ -85,7 +85,7 @@ def print_usage() -> None:
|
|
|
85
85
|
print(" native_structure_mode: structured also enables complete")
|
|
86
86
|
print(" per-file and cross-page structure validation. Legacy")
|
|
87
87
|
print(" native_structure_mode: template fails and must be")
|
|
88
|
-
print(" re-created
|
|
88
|
+
print(" re-created as a structured workspace before validation.")
|
|
89
89
|
print(" Warnings are advisory: they require no modification and do not affect exit status;")
|
|
90
90
|
print(" only errors make the command exit with status 1.")
|
|
91
91
|
|