dknowc-dsh 1.0.4 → 1.1.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 +9 -4
- package/package.json +2 -2
- package/skills/dknowc-ppt-assistant/README.md +54 -0
- package/skills/dknowc-ppt-assistant/SKILL.md +151 -0
- package/skills/dknowc-ppt-assistant/THIRD_PARTY_NOTICES.md +36 -0
- package/skills/dknowc-ppt-assistant/official-docs/output/.gitkeep +0 -0
- package/skills/dknowc-ppt-assistant/official-docs/search-results/.gitkeep +0 -0
- package/skills/dknowc-ppt-assistant/projects/.gitkeep +0 -0
- package/skills/dknowc-ppt-assistant/references/content-pack.md +55 -0
- package/skills/dknowc-ppt-assistant/references/material_usage.md +51 -0
- package/skills/dknowc-ppt-assistant/references/sample_effect.html +89 -0
- package/skills/dknowc-ppt-assistant/references/sample_search_result.md +48 -0
- package/skills/dknowc-ppt-assistant/references/search_intro.md +79 -0
- package/skills/dknowc-ppt-assistant/references/style-presets.md +126 -0
- package/skills/dknowc-ppt-assistant/references/svg-authoring.md +81 -0
- package/skills/dknowc-ppt-assistant/references/upstream-docs/svg-pipeline.md +842 -0
- package/skills/dknowc-ppt-assistant/references/upstream-example/01_cover.svg +28 -0
- package/skills/dknowc-ppt-assistant/references/upstream-example/02_quote.svg +38 -0
- package/skills/dknowc-ppt-assistant/references/upstream-example/03_origin.svg +96 -0
- package/skills/dknowc-ppt-assistant/references/upstream-example/README.md +15 -0
- package/skills/dknowc-ppt-assistant/references/upstream-example/design_spec.md +408 -0
- package/skills/dknowc-ppt-assistant/references/upstream-example/spec_lock.md +78 -0
- package/skills/dknowc-ppt-assistant/scripts/adapt_mcp_result.py +279 -0
- package/skills/dknowc-ppt-assistant/scripts/check_release.py +106 -0
- package/skills/dknowc-ppt-assistant/scripts/compact_svg_coordinates.py +345 -0
- package/skills/dknowc-ppt-assistant/scripts/config.py +707 -0
- package/skills/dknowc-ppt-assistant/scripts/console_encoding.py +33 -0
- package/skills/dknowc-ppt-assistant/scripts/error_helper.py +434 -0
- package/skills/dknowc-ppt-assistant/scripts/finalize_svg.py +507 -0
- package/skills/dknowc-ppt-assistant/scripts/hyperlink_contract.py +399 -0
- package/skills/dknowc-ppt-assistant/scripts/initialize.py +182 -0
- package/skills/dknowc-ppt-assistant/scripts/language_tags.py +283 -0
- package/skills/dknowc-ppt-assistant/scripts/mcp_direct.py +158 -0
- package/skills/dknowc-ppt-assistant/scripts/native_payloads.py +655 -0
- package/skills/dknowc-ppt-assistant/scripts/pptx_animation_presets.json +3440 -0
- package/skills/dknowc-ppt-assistant/scripts/pptx_animations.py +3965 -0
- package/skills/dknowc-ppt-assistant/scripts/pptx_effects.py +143 -0
- package/skills/dknowc-ppt-assistant/scripts/pptx_opc_validation.py +346 -0
- package/skills/dknowc-ppt-assistant/scripts/pptx_shapes/__init__.py +130 -0
- package/skills/dknowc-ppt-assistant/scripts/pptx_shapes/data/LICENSE-APACHE-2.0.txt +202 -0
- package/skills/dknowc-ppt-assistant/scripts/pptx_shapes/data/LICENSE-OPEN-XML-SDK-MIT.txt +23 -0
- package/skills/dknowc-ppt-assistant/scripts/pptx_shapes/data/NOTICE.md +54 -0
- package/skills/dknowc-ppt-assistant/scripts/pptx_shapes/data/presetShapeDefinitions.xml +19898 -0
- package/skills/dknowc-ppt-assistant/scripts/pptx_shapes/data/presetShapeSemantics.json +1217 -0
- package/skills/dknowc-ppt-assistant/scripts/pptx_shapes/data/shape_type_values.txt +187 -0
- package/skills/dknowc-ppt-assistant/scripts/pptx_shapes/errors.py +39 -0
- package/skills/dknowc-ppt-assistant/scripts/pptx_shapes/formula.py +336 -0
- package/skills/dknowc-ppt-assistant/scripts/pptx_shapes/loader.py +364 -0
- package/skills/dknowc-ppt-assistant/scripts/pptx_shapes/models.py +201 -0
- package/skills/dknowc-ppt-assistant/scripts/pptx_shapes/registry.py +270 -0
- package/skills/dknowc-ppt-assistant/scripts/pptx_shapes/semantic_hash.py +456 -0
- package/skills/dknowc-ppt-assistant/scripts/pptx_shapes/semantics.py +543 -0
- package/skills/dknowc-ppt-assistant/scripts/pptx_shapes/xml_safety.py +21 -0
- package/skills/dknowc-ppt-assistant/scripts/pptx_to_svg/__init__.py +21 -0
- package/skills/dknowc-ppt-assistant/scripts/pptx_to_svg/animation_import.py +287 -0
- package/skills/dknowc-ppt-assistant/scripts/pptx_to_svg/chart_to_svg.py +2377 -0
- package/skills/dknowc-ppt-assistant/scripts/pptx_to_svg/chartex_to_svg.py +422 -0
- package/skills/dknowc-ppt-assistant/scripts/pptx_to_svg/color_resolver.py +894 -0
- package/skills/dknowc-ppt-assistant/scripts/pptx_to_svg/converter.py +1143 -0
- package/skills/dknowc-ppt-assistant/scripts/pptx_to_svg/custgeom_to_svg.py +165 -0
- package/skills/dknowc-ppt-assistant/scripts/pptx_to_svg/effect_to_svg.py +410 -0
- package/skills/dknowc-ppt-assistant/scripts/pptx_to_svg/emu_units.py +258 -0
- package/skills/dknowc-ppt-assistant/scripts/pptx_to_svg/fill_to_svg.py +816 -0
- package/skills/dknowc-ppt-assistant/scripts/pptx_to_svg/formula_import.py +611 -0
- package/skills/dknowc-ppt-assistant/scripts/pptx_to_svg/hyperlinks.py +93 -0
- package/skills/dknowc-ppt-assistant/scripts/pptx_to_svg/import_diagnostics.py +37 -0
- package/skills/dknowc-ppt-assistant/scripts/pptx_to_svg/ln_to_svg.py +362 -0
- package/skills/dknowc-ppt-assistant/scripts/pptx_to_svg/normalized_chart_svg.py +1217 -0
- package/skills/dknowc-ppt-assistant/scripts/pptx_to_svg/ooxml_loader.py +506 -0
- package/skills/dknowc-ppt-assistant/scripts/pptx_to_svg/pic_to_svg.py +653 -0
- package/skills/dknowc-ppt-assistant/scripts/pptx_to_svg/preset_authoring.py +894 -0
- package/skills/dknowc-ppt-assistant/scripts/pptx_to_svg/preset_registry_to_svg.py +216 -0
- package/skills/dknowc-ppt-assistant/scripts/pptx_to_svg/preset_svg_markup.py +198 -0
- package/skills/dknowc-ppt-assistant/scripts/pptx_to_svg/prstgeom_to_svg.py +162 -0
- package/skills/dknowc-ppt-assistant/scripts/pptx_to_svg/shape_walker.py +556 -0
- package/skills/dknowc-ppt-assistant/scripts/pptx_to_svg/slide_to_svg.py +2002 -0
- package/skills/dknowc-ppt-assistant/scripts/pptx_to_svg/tbl_to_svg.py +1841 -0
- package/skills/dknowc-ppt-assistant/scripts/pptx_to_svg/transition_import.py +201 -0
- package/skills/dknowc-ppt-assistant/scripts/pptx_to_svg/txbody_to_svg.py +1433 -0
- package/skills/dknowc-ppt-assistant/scripts/pptx_transitions.py +3153 -0
- package/skills/dknowc-ppt-assistant/scripts/preset_shape_svg.py +450 -0
- package/skills/dknowc-ppt-assistant/scripts/project_utils.py +645 -0
- package/skills/dknowc-ppt-assistant/scripts/register_key.mjs +183 -0
- package/skills/dknowc-ppt-assistant/scripts/register_template.py +1327 -0
- package/skills/dknowc-ppt-assistant/scripts/render_trace_html.py +1048 -0
- package/skills/dknowc-ppt-assistant/scripts/resource_paths.py +282 -0
- package/skills/dknowc-ppt-assistant/scripts/shape_boolean_svg.py +189 -0
- package/skills/dknowc-ppt-assistant/scripts/slide_roster.py +44 -0
- package/skills/dknowc-ppt-assistant/scripts/svg_finalize/__init__.py +12 -0
- package/skills/dknowc-ppt-assistant/scripts/svg_finalize/align_embed_images.py +672 -0
- package/skills/dknowc-ppt-assistant/scripts/svg_finalize/crop_images.py +370 -0
- package/skills/dknowc-ppt-assistant/scripts/svg_finalize/embed_icons.py +564 -0
- package/skills/dknowc-ppt-assistant/scripts/svg_finalize/embed_images.py +288 -0
- package/skills/dknowc-ppt-assistant/scripts/svg_finalize/fix_image_aspect.py +389 -0
- package/skills/dknowc-ppt-assistant/scripts/svg_finalize/flatten_tspan.py +948 -0
- package/skills/dknowc-ppt-assistant/scripts/svg_finalize/svg_rect_to_path.py +346 -0
- package/skills/dknowc-ppt-assistant/scripts/svg_quality/__init__.py +15 -0
- package/skills/dknowc-ppt-assistant/scripts/svg_quality/checker.py +7791 -0
- package/skills/dknowc-ppt-assistant/scripts/svg_quality/cli.py +193 -0
- package/skills/dknowc-ppt-assistant/scripts/svg_quality/svg_contracts.py +1121 -0
- package/skills/dknowc-ppt-assistant/scripts/svg_quality/xml_support.py +35 -0
- package/skills/dknowc-ppt-assistant/scripts/svg_quality_checker.py +59 -0
- package/skills/dknowc-ppt-assistant/scripts/svg_to_pptx/__init__.py +37 -0
- package/skills/dknowc-ppt-assistant/scripts/svg_to_pptx/animation_config.py +1622 -0
- package/skills/dknowc-ppt-assistant/scripts/svg_to_pptx/canvas_contract.py +226 -0
- package/skills/dknowc-ppt-assistant/scripts/svg_to_pptx/drawingml/__init__.py +1 -0
- package/skills/dknowc-ppt-assistant/scripts/svg_to_pptx/drawingml/context.py +291 -0
- package/skills/dknowc-ppt-assistant/scripts/svg_to_pptx/drawingml/converter.py +1980 -0
- package/skills/dknowc-ppt-assistant/scripts/svg_to_pptx/drawingml/elements.py +5272 -0
- package/skills/dknowc-ppt-assistant/scripts/svg_to_pptx/drawingml/hyperlinks.py +162 -0
- package/skills/dknowc-ppt-assistant/scripts/svg_to_pptx/drawingml/paths.py +847 -0
- package/skills/dknowc-ppt-assistant/scripts/svg_to_pptx/drawingml/styles.py +752 -0
- package/skills/dknowc-ppt-assistant/scripts/svg_to_pptx/drawingml/text_properties.py +796 -0
- package/skills/dknowc-ppt-assistant/scripts/svg_to_pptx/drawingml/theme_colors.py +283 -0
- package/skills/dknowc-ppt-assistant/scripts/svg_to_pptx/drawingml/theme_fonts.py +330 -0
- package/skills/dknowc-ppt-assistant/scripts/svg_to_pptx/drawingml/utils.py +3555 -0
- package/skills/dknowc-ppt-assistant/scripts/svg_to_pptx/geometry_properties.py +140 -0
- package/skills/dknowc-ppt-assistant/scripts/svg_to_pptx/native_objects/__init__.py +356 -0
- package/skills/dknowc-ppt-assistant/scripts/svg_to_pptx/native_objects/chart_data.py +1449 -0
- package/skills/dknowc-ppt-assistant/scripts/svg_to_pptx/native_objects/chart_style.py +886 -0
- package/skills/dknowc-ppt-assistant/scripts/svg_to_pptx/native_objects/chart_xml.py +1495 -0
- package/skills/dknowc-ppt-assistant/scripts/svg_to_pptx/native_objects/chartex.py +272 -0
- package/skills/dknowc-ppt-assistant/scripts/svg_to_pptx/native_objects/fallback_hash.py +161 -0
- package/skills/dknowc-ppt-assistant/scripts/svg_to_pptx/native_objects/formula.py +243 -0
- package/skills/dknowc-ppt-assistant/scripts/svg_to_pptx/native_objects/formula_ast.py +592 -0
- package/skills/dknowc-ppt-assistant/scripts/svg_to_pptx/native_objects/formula_compiler.py +96 -0
- package/skills/dknowc-ppt-assistant/scripts/svg_to_pptx/native_objects/formula_omml.py +1049 -0
- package/skills/dknowc-ppt-assistant/scripts/svg_to_pptx/native_objects/formula_parser.py +2181 -0
- package/skills/dknowc-ppt-assistant/scripts/svg_to_pptx/native_objects/formula_profile.py +739 -0
- package/skills/dknowc-ppt-assistant/scripts/svg_to_pptx/native_objects/formula_run_properties.py +234 -0
- package/skills/dknowc-ppt-assistant/scripts/svg_to_pptx/native_objects/inline_formula.py +311 -0
- package/skills/dknowc-ppt-assistant/scripts/svg_to_pptx/native_objects/marker_attributes.py +182 -0
- package/skills/dknowc-ppt-assistant/scripts/svg_to_pptx/native_objects/marker_common.py +806 -0
- package/skills/dknowc-ppt-assistant/scripts/svg_to_pptx/native_objects/marker_status.py +190 -0
- package/skills/dknowc-ppt-assistant/scripts/svg_to_pptx/native_objects/table.py +1113 -0
- package/skills/dknowc-ppt-assistant/scripts/svg_to_pptx/native_objects/workbook.py +216 -0
- package/skills/dknowc-ppt-assistant/scripts/svg_to_pptx/pptx_package/__init__.py +1 -0
- package/skills/dknowc-ppt-assistant/scripts/svg_to_pptx/pptx_package/builder.py +6273 -0
- package/skills/dknowc-ppt-assistant/scripts/svg_to_pptx/pptx_package/cli.py +2059 -0
- package/skills/dknowc-ppt-assistant/scripts/svg_to_pptx/pptx_package/dimensions.py +189 -0
- package/skills/dknowc-ppt-assistant/scripts/svg_to_pptx/pptx_package/discovery.py +120 -0
- package/skills/dknowc-ppt-assistant/scripts/svg_to_pptx/pptx_package/media.py +160 -0
- package/skills/dknowc-ppt-assistant/scripts/svg_to_pptx/pptx_package/narration.py +696 -0
- package/skills/dknowc-ppt-assistant/scripts/svg_to_pptx/pptx_package/notes.py +336 -0
- package/skills/dknowc-ppt-assistant/scripts/svg_to_pptx/pptx_package/slide_xml.py +138 -0
- package/skills/dknowc-ppt-assistant/scripts/svg_to_pptx/pptx_package/template_structure.py +3457 -0
- package/skills/dknowc-ppt-assistant/scripts/svg_to_pptx/pptx_package/template_validation.py +1536 -0
- package/skills/dknowc-ppt-assistant/scripts/svg_to_pptx/semantic_markers.py +240 -0
- package/skills/dknowc-ppt-assistant/scripts/svg_to_pptx/shape_boolean.py +1355 -0
- package/skills/dknowc-ppt-assistant/scripts/svg_to_pptx/text_outline.py +1121 -0
- package/skills/dknowc-ppt-assistant/scripts/svg_to_pptx/tspan_flattener.py +64 -0
- package/skills/dknowc-ppt-assistant/scripts/svg_to_pptx/use_expander.py +577 -0
- package/skills/dknowc-ppt-assistant/scripts/svg_to_pptx.py +21 -0
- package/skills/dknowc-ppt-assistant/scripts/trusted_search.py +336 -0
- package/skills/dknowc-ppt-assistant/scripts/update_spec.py +404 -0
- package/skills/dknowc-ppt-assistant/workflows/generate-pptx.md +142 -0
- package/skills/dknowc-ppt-assistant/workflows/routing.md +38 -0
- package/skills/dknowc-trusted-search/SKILL.md +8 -7
- package/skills/dknowc-trusted-search/scripts/adapt_mcp_result.py +19 -37
- package/skills/dknowc-trusted-search/scripts/deep_query.py +117 -137
- package/skills/dknowc-trusted-search/scripts/render_trace_html.py +27 -22
- package/src/index.js +7 -2
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
# Execution Lock
|
|
2
|
+
|
|
3
|
+
## canvas
|
|
4
|
+
- viewBox: 0 0 1280 720
|
|
5
|
+
- format: PPT 16:9
|
|
6
|
+
|
|
7
|
+
## colors
|
|
8
|
+
- bg: #FFFFFF
|
|
9
|
+
- secondary_bg: #F4F4F4
|
|
10
|
+
- primary: #1A1A1A
|
|
11
|
+
- accent: #D9251D
|
|
12
|
+
- secondary_accent: #1A4FA0
|
|
13
|
+
- text: #1A1A1A
|
|
14
|
+
- text_secondary: #666666
|
|
15
|
+
- text_tertiary: #999999
|
|
16
|
+
- border: #E8E8E8
|
|
17
|
+
- image_rendering: minimalist-swiss
|
|
18
|
+
- image_palette: mono-ink
|
|
19
|
+
|
|
20
|
+
## typography
|
|
21
|
+
- font_family: Arial, "Microsoft YaHei", sans-serif
|
|
22
|
+
- title_family: "Arial Black", "Microsoft YaHei", sans-serif
|
|
23
|
+
- body_family: Arial, "Microsoft YaHei", sans-serif
|
|
24
|
+
- code_family: Consolas, "Courier New", monospace
|
|
25
|
+
- body: 18
|
|
26
|
+
- title: 32
|
|
27
|
+
- subtitle: 22
|
|
28
|
+
- annotation: 13
|
|
29
|
+
- cover_title: 84
|
|
30
|
+
- hero_number: 36
|
|
31
|
+
- display_xl: 92
|
|
32
|
+
- specimen: 240
|
|
33
|
+
|
|
34
|
+
## icons
|
|
35
|
+
- library: tabler-outline
|
|
36
|
+
- stroke_width: 1.5
|
|
37
|
+
- brand_library: simple-icons
|
|
38
|
+
- inventory: blockquote, grid-3x3
|
|
39
|
+
|
|
40
|
+
## images
|
|
41
|
+
- cover_bg: images/cover_bg.png
|
|
42
|
+
- negative_space: images/negative_space.png
|
|
43
|
+
- closing_grid: images/closing_grid.png
|
|
44
|
+
|
|
45
|
+
## page_rhythm
|
|
46
|
+
- P01: anchor
|
|
47
|
+
- P02: breathing
|
|
48
|
+
- P03: dense
|
|
49
|
+
- P04: dense
|
|
50
|
+
- P05: dense
|
|
51
|
+
- P06: dense
|
|
52
|
+
- P07: dense
|
|
53
|
+
- P08: dense
|
|
54
|
+
- P09: anchor
|
|
55
|
+
- P10: breathing
|
|
56
|
+
- P11: dense
|
|
57
|
+
- P12: dense
|
|
58
|
+
- P13: dense
|
|
59
|
+
- P14: breathing
|
|
60
|
+
|
|
61
|
+
## page_charts
|
|
62
|
+
- P03: timeline
|
|
63
|
+
- P04: vertical_list
|
|
64
|
+
- P05: team_roster
|
|
65
|
+
- P06: timeline
|
|
66
|
+
- P07: comparison_columns
|
|
67
|
+
- P08: quadrant_text_bullets
|
|
68
|
+
- P11: icon_grid
|
|
69
|
+
- P12: numbered_steps
|
|
70
|
+
- P13: icon_grid
|
|
71
|
+
|
|
72
|
+
## forbidden
|
|
73
|
+
- Mixing icon libraries
|
|
74
|
+
- `<style>`, `class`, `<foreignObject>`, `textPath`, `@font-face`, `<animate*>`, `<script>`, `<iframe>`, `<symbol>`+`<use>`
|
|
75
|
+
- HTML named entities in text — write as raw Unicode; XML reserved chars must be escaped as `& < > " '`
|
|
76
|
+
- Rounded corners (rx > 0) — except inside `simple-icons` brand glyphs
|
|
77
|
+
- Linear/radial gradients — pure flat color only
|
|
78
|
+
- Drop shadows / filter effects
|
|
@@ -0,0 +1,279 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""深知 dsh —— MCP 工具返回 → 渲染脚本输入 适配器。
|
|
3
|
+
|
|
4
|
+
dsh 场景下,skill 通过深知可信工作台 MCP 工具(credible_chat /
|
|
5
|
+
trusted_search / deep_query,或注册后经 mcp_direct.py 直调)拿数据。
|
|
6
|
+
MCP 返回是协议结构 {content:[{type:"text",text:"<业务JSON>"}]},其内层
|
|
7
|
+
业务 JSON 的字段形态与原直连接口不同,而 render_trace_html.py 等渲染
|
|
8
|
+
脚本按原接口结构消费字段。
|
|
9
|
+
|
|
10
|
+
本脚本按【MCP 实测返回】做字段映射(2026-08-19 实测三个工具确认):
|
|
11
|
+
|
|
12
|
+
credible_chat 内层(chat 模式,渲染脚本基本兼容,直通+防御):
|
|
13
|
+
answer 答案正文(渲染脚本 extract_answer 支持顶层 answer)
|
|
14
|
+
referenceMaterials[] 参考材料(title/url/sourceUrl/unit/content[].text 等,
|
|
15
|
+
与 source_from_article 字段兼容,直接透传)
|
|
16
|
+
policyFiles[] / recommendationItems[] / trace_report_url 附加信息,透传保留
|
|
17
|
+
|
|
18
|
+
trusted_search 内层(search 模式,需要映射):
|
|
19
|
+
materials[{title,source,date,paragraph,url}] → data.检索文章[]
|
|
20
|
+
(渲染脚本 extract_articles_from_search 只认中文键 data.检索文章)
|
|
21
|
+
knowledge_base_url → knowledgeBase / knowledgeBaseUrl(渲染脚本只认驼峰)
|
|
22
|
+
|
|
23
|
+
deep_query 内层(deep 模式,需要映射):
|
|
24
|
+
materials[] / search_groups[].materials[] → data.list[]
|
|
25
|
+
(渲染脚本 extract_articles_from_deep 认 data.list)
|
|
26
|
+
progress[](字符串过程记录)原样保留,供 Agent 综合答案时参考
|
|
27
|
+
答案不由接口给出,由 Agent 基于材料形成后经 --answer-file 传入
|
|
28
|
+
|
|
29
|
+
用法:
|
|
30
|
+
python3 scripts/adapt_mcp_result.py <mcp返回.json> --output <规范化.json> [--mode chat|search|deep]
|
|
31
|
+
|
|
32
|
+
- 输入:MCP 工具返回 JSON(mcp_direct.py --output 的产物,或模型保存的
|
|
33
|
+
dsh mcp-client 工具返回;支持 content[].text / structuredContent / 已解包形态)
|
|
34
|
+
- 输出:render_trace_html.py 可直接消费的接口 JSON
|
|
35
|
+
- --mode:chat=可信咨询 / search=可信搜索 / deep=深度搜索;缺省自动识别
|
|
36
|
+
"""
|
|
37
|
+
|
|
38
|
+
import argparse
|
|
39
|
+
import json
|
|
40
|
+
import sys
|
|
41
|
+
from pathlib import Path
|
|
42
|
+
from typing import Any, Dict, List, Optional
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
def _deep_find(o: Any, keys, depth=0, max_depth=8):
|
|
46
|
+
"""在任意嵌套结构里查找第一个命中任一 key 的非空值。"""
|
|
47
|
+
if depth > max_depth:
|
|
48
|
+
return None
|
|
49
|
+
if isinstance(o, dict):
|
|
50
|
+
for k, v in o.items():
|
|
51
|
+
if k in keys and v not in (None, "", [], {}):
|
|
52
|
+
return v
|
|
53
|
+
r = _deep_find(v, keys, depth + 1, max_depth)
|
|
54
|
+
if r is not None:
|
|
55
|
+
return r
|
|
56
|
+
elif isinstance(o, list):
|
|
57
|
+
for item in o:
|
|
58
|
+
r = _deep_find(item, keys, depth + 1, max_depth)
|
|
59
|
+
if r is not None:
|
|
60
|
+
return r
|
|
61
|
+
return None
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
def _extract_mcp_text(o: Any) -> Optional[str]:
|
|
65
|
+
"""从 MCP 协议返回中提取文本内容。
|
|
66
|
+
|
|
67
|
+
支持形态:
|
|
68
|
+
- {content: [{type:"text", text:"..."}]}(MCP 标准,text 为业务 JSON 字符串)
|
|
69
|
+
- {structuredContent: {...}}
|
|
70
|
+
- 已是解包后的业务 JSON dict
|
|
71
|
+
"""
|
|
72
|
+
if isinstance(o, dict):
|
|
73
|
+
sc = o.get("structuredContent")
|
|
74
|
+
if isinstance(sc, dict):
|
|
75
|
+
return json.dumps(sc, ensure_ascii=False)
|
|
76
|
+
content = o.get("content")
|
|
77
|
+
if isinstance(content, list):
|
|
78
|
+
parts = []
|
|
79
|
+
for block in content:
|
|
80
|
+
if isinstance(block, dict) and isinstance(block.get("text"), str):
|
|
81
|
+
parts.append(block["text"])
|
|
82
|
+
elif isinstance(block, str):
|
|
83
|
+
parts.append(block)
|
|
84
|
+
if parts:
|
|
85
|
+
return "\n".join(parts)
|
|
86
|
+
# result.content 嵌套形态(完整 MCP JSON-RPC 响应)
|
|
87
|
+
result = o.get("result")
|
|
88
|
+
if isinstance(result, dict):
|
|
89
|
+
return _extract_mcp_text(result)
|
|
90
|
+
# 已是业务 JSON(answer/materials/referenceMaterials 等特征键)
|
|
91
|
+
if any(k in o for k in ("answer", "referenceMaterials", "materials", "检索文章", "progress", "search_meta")):
|
|
92
|
+
return json.dumps(o, ensure_ascii=False)
|
|
93
|
+
return None
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
def _try_json(text: str) -> Any:
|
|
97
|
+
"""尝试把文本解析为 JSON。"""
|
|
98
|
+
if not isinstance(text, str):
|
|
99
|
+
return None
|
|
100
|
+
try:
|
|
101
|
+
return json.loads(text)
|
|
102
|
+
except json.JSONDecodeError:
|
|
103
|
+
return None
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
def _material_to_search_article(m: Dict[str, Any]) -> Dict[str, Any]:
|
|
107
|
+
"""trusted_search 的 materials 条目 → 渲染脚本认的检索文章结构。
|
|
108
|
+
|
|
109
|
+
渲染脚本 source_from_article 认的字段名(多 key 兜底):
|
|
110
|
+
标题:文章标题/title/标题;来源:unit/sourceElement/数据源/发布机关/来源;
|
|
111
|
+
日期:发布日期/date/发布时间;网址:sourceUrl/source_url/源网址/url/原文;
|
|
112
|
+
摘录:摘要/相关段落/全文/content/text。
|
|
113
|
+
这里把 MCP 的英文字段同时写入中文键与英文键,保证两条提取路径都能命中。
|
|
114
|
+
"""
|
|
115
|
+
title = str(m.get("title") or m.get("标题") or "")
|
|
116
|
+
source = str(m.get("source") or m.get("来源") or m.get("unit") or "")
|
|
117
|
+
date = str(m.get("date") or m.get("发布日期") or "")
|
|
118
|
+
url = str(m.get("url") or m.get("sourceUrl") or m.get("源网址") or "")
|
|
119
|
+
paragraph = str(m.get("paragraph") or m.get("content") or m.get("摘要") or "")
|
|
120
|
+
return {
|
|
121
|
+
"标题": title,
|
|
122
|
+
"title": title,
|
|
123
|
+
"来源": source,
|
|
124
|
+
"发布日期": date,
|
|
125
|
+
"date": date,
|
|
126
|
+
"源网址": url,
|
|
127
|
+
"sourceUrl": url,
|
|
128
|
+
"url": url,
|
|
129
|
+
"摘要": paragraph,
|
|
130
|
+
"全文": paragraph,
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
|
|
134
|
+
def _normalize_chat(payload: Dict[str, Any]) -> Dict[str, Any]:
|
|
135
|
+
"""规范化可信咨询(credible_chat)返回。
|
|
136
|
+
|
|
137
|
+
MCP 内层已是顶层 answer + referenceMaterials 形态,渲染脚本
|
|
138
|
+
extract_answer / extract_sources / source_from_article 直接兼容,
|
|
139
|
+
此处直通透传,仅做两处防御:
|
|
140
|
+
- answer 缺失时从任意位置兜底找正文,包成渲染脚本认的 resp.content
|
|
141
|
+
- 保留 trace_report_url / policyFiles / recommendationItems 等附加字段
|
|
142
|
+
"""
|
|
143
|
+
out = dict(payload)
|
|
144
|
+
if not (isinstance(out.get("answer"), str) and out.get("answer").strip()):
|
|
145
|
+
answer = _deep_find(payload, ("answer", "contentText"))
|
|
146
|
+
if isinstance(answer, str) and answer.strip():
|
|
147
|
+
out["answer"] = answer
|
|
148
|
+
# 渲染脚本 extract_answer 优先找 resp.content;补一份兼容形态
|
|
149
|
+
answer = out.get("answer")
|
|
150
|
+
if isinstance(answer, str) and answer.strip() and not isinstance(out.get("resp"), dict):
|
|
151
|
+
out["resp"] = {"content": answer}
|
|
152
|
+
return out
|
|
153
|
+
|
|
154
|
+
|
|
155
|
+
def _normalize_search(payload: Dict[str, Any]) -> Dict[str, Any]:
|
|
156
|
+
"""规范化可信搜索(trusted_search)返回:materials → data.检索文章,
|
|
157
|
+
knowledge_base_url → knowledgeBase(驼峰)。
|
|
158
|
+
"""
|
|
159
|
+
out = dict(payload)
|
|
160
|
+
materials = payload.get("materials")
|
|
161
|
+
if isinstance(materials, list):
|
|
162
|
+
articles = [_material_to_search_article(m) for m in materials if isinstance(m, dict)]
|
|
163
|
+
data = out.get("data") if isinstance(out.get("data"), dict) else {}
|
|
164
|
+
data["检索文章"] = articles
|
|
165
|
+
out["data"] = data
|
|
166
|
+
out["total_articles"] = out.get("total_articles") or len(articles)
|
|
167
|
+
# 兼容旧直连形态(content.data.检索文章)的防御提取
|
|
168
|
+
if not (isinstance(out.get("data"), dict) and isinstance(out["data"].get("检索文章"), list)):
|
|
169
|
+
legacy = _deep_find(payload, ("检索文章",))
|
|
170
|
+
if isinstance(legacy, list) and legacy:
|
|
171
|
+
data = out.get("data") if isinstance(out.get("data"), dict) else {}
|
|
172
|
+
data["检索文章"] = [x for x in legacy if isinstance(x, dict)]
|
|
173
|
+
out["data"] = data
|
|
174
|
+
# 知识专库链接:MCP 用下划线 knowledge_base_url,渲染脚本只认驼峰
|
|
175
|
+
kb = payload.get("knowledge_base_url") or payload.get("knowledgeBase") or payload.get("knowledgeBaseUrl")
|
|
176
|
+
if isinstance(kb, str) and kb.strip():
|
|
177
|
+
out["knowledgeBase"] = kb
|
|
178
|
+
out["knowledgeBaseUrl"] = kb
|
|
179
|
+
return out
|
|
180
|
+
|
|
181
|
+
|
|
182
|
+
def _normalize_deep(payload: Dict[str, Any]) -> Dict[str, Any]:
|
|
183
|
+
"""规范化深度搜索(deep_query)返回:materials / search_groups → data.list,
|
|
184
|
+
progress(字符串过程)保留,knowledge_base_url 映射驼峰。
|
|
185
|
+
深度搜索答案由 Agent 基于材料与 progress 综合形成,经 --answer-file 传入渲染。
|
|
186
|
+
"""
|
|
187
|
+
out = dict(payload)
|
|
188
|
+
items: List[Dict[str, Any]] = []
|
|
189
|
+
mats = payload.get("materials")
|
|
190
|
+
if isinstance(mats, list):
|
|
191
|
+
items.extend([m for m in mats if isinstance(m, dict)])
|
|
192
|
+
groups = payload.get("search_groups")
|
|
193
|
+
if isinstance(groups, list):
|
|
194
|
+
for g in groups:
|
|
195
|
+
if isinstance(g, dict) and isinstance(g.get("materials"), list):
|
|
196
|
+
items.extend([m for m in g["materials"] if isinstance(m, dict)])
|
|
197
|
+
elif isinstance(g, dict):
|
|
198
|
+
# search_groups 条目本身可能就是材料(含 title/url 等特征键)
|
|
199
|
+
if any(k in g for k in ("title", "url", "sourceUrl")):
|
|
200
|
+
items.append(g)
|
|
201
|
+
if items:
|
|
202
|
+
# 渲染脚本 extract_articles_from_deep 消费顶层 data.list
|
|
203
|
+
out["data"] = {"list": items}
|
|
204
|
+
# 兼容旧直连 events 形态的防御提取
|
|
205
|
+
if "data" not in out:
|
|
206
|
+
events = payload.get("events")
|
|
207
|
+
if isinstance(events, list):
|
|
208
|
+
out["events"] = events
|
|
209
|
+
kb = payload.get("knowledge_base_url") or payload.get("knowledgeBase") or payload.get("knowledgeBaseUrl")
|
|
210
|
+
if isinstance(kb, str) and kb.strip():
|
|
211
|
+
out["knowledgeBase"] = kb
|
|
212
|
+
out["knowledgeBaseUrl"] = kb
|
|
213
|
+
return out
|
|
214
|
+
|
|
215
|
+
|
|
216
|
+
def detect_mode(payload: Dict[str, Any]) -> str:
|
|
217
|
+
"""按 MCP 实测特征自动识别接口类型。
|
|
218
|
+
|
|
219
|
+
deep 的特征键(query_id/progress/search_groups/deep_query_meta)最特异,
|
|
220
|
+
必须先于 search 判断:deep 返回同样携带 materials 键,若先判 search
|
|
221
|
+
会被误判(materials 为空列表也是 list)。
|
|
222
|
+
"""
|
|
223
|
+
if (
|
|
224
|
+
"query_id" in payload
|
|
225
|
+
or isinstance(payload.get("progress"), list)
|
|
226
|
+
or isinstance(payload.get("search_groups"), list)
|
|
227
|
+
or isinstance(payload.get("deep_query_meta"), dict)
|
|
228
|
+
):
|
|
229
|
+
return "deep"
|
|
230
|
+
if isinstance(payload.get("search_meta"), dict) or (
|
|
231
|
+
isinstance(payload.get("materials"), list) and "answer" not in payload
|
|
232
|
+
):
|
|
233
|
+
return "search"
|
|
234
|
+
return "chat"
|
|
235
|
+
|
|
236
|
+
|
|
237
|
+
def main() -> int:
|
|
238
|
+
parser = argparse.ArgumentParser(description="MCP 返回 → 渲染脚本输入 适配器(按 2026-08-19 实测 MCP 结构映射)")
|
|
239
|
+
parser.add_argument("input_json", help="MCP 工具返回 JSON 文件路径")
|
|
240
|
+
parser.add_argument("--output", "-o", required=True, help="规范化 JSON 输出路径")
|
|
241
|
+
parser.add_argument("--mode", choices=["chat", "search", "deep"], default=None, help="接口类型;缺省自动识别")
|
|
242
|
+
args = parser.parse_args()
|
|
243
|
+
|
|
244
|
+
src = Path(args.input_json).expanduser()
|
|
245
|
+
if not src.exists():
|
|
246
|
+
print(f"错误:输入文件不存在:{src}", file=sys.stderr)
|
|
247
|
+
return 2
|
|
248
|
+
|
|
249
|
+
try:
|
|
250
|
+
raw = json.loads(src.read_text(encoding="utf-8"))
|
|
251
|
+
except json.JSONDecodeError as e:
|
|
252
|
+
print(f"错误:输入不是合法 JSON:{e}", file=sys.stderr)
|
|
253
|
+
return 2
|
|
254
|
+
|
|
255
|
+
# 1) 提取 MCP 协议层 → 业务 JSON
|
|
256
|
+
text = _extract_mcp_text(raw)
|
|
257
|
+
payload = _try_json(text) if text else None
|
|
258
|
+
if not isinstance(payload, dict):
|
|
259
|
+
# 纯文本回答(无业务 JSON)→ 包成 answer
|
|
260
|
+
payload = {"answer": text or json.dumps(raw, ensure_ascii=False)}
|
|
261
|
+
|
|
262
|
+
# 2) 按模式做字段映射
|
|
263
|
+
mode = args.mode or detect_mode(payload)
|
|
264
|
+
if mode == "search":
|
|
265
|
+
out = _normalize_search(payload)
|
|
266
|
+
elif mode == "deep":
|
|
267
|
+
out = _normalize_deep(payload)
|
|
268
|
+
else:
|
|
269
|
+
out = _normalize_chat(payload)
|
|
270
|
+
|
|
271
|
+
out_path = Path(args.output).expanduser()
|
|
272
|
+
out_path.parent.mkdir(parents=True, exist_ok=True)
|
|
273
|
+
out_path.write_text(json.dumps(out, ensure_ascii=False, indent=2), encoding="utf-8")
|
|
274
|
+
print(f"已规范化(mode={mode}):{out_path}")
|
|
275
|
+
return 0
|
|
276
|
+
|
|
277
|
+
|
|
278
|
+
if __name__ == "__main__":
|
|
279
|
+
sys.exit(main())
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""深知可信PPT发布前检查。
|
|
3
|
+
|
|
4
|
+
阻止 API Key、真实配置和本地生成物进入 SkillHub 公开包。
|
|
5
|
+
针对本 Skill 的抽取结构适配:允许第三方声明文件(THIRD_PARTY_NOTICES.md、
|
|
6
|
+
LICENSE*.txt、NOTICE.md)与编译器数据文件;projects/ 与 official-docs/
|
|
7
|
+
工作区内只允许 .gitkeep 占位。
|
|
8
|
+
"""
|
|
9
|
+
|
|
10
|
+
import re
|
|
11
|
+
from pathlib import Path
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
def _is_within(path: Path, parent: Path) -> bool:
|
|
15
|
+
try:
|
|
16
|
+
path.relative_to(parent)
|
|
17
|
+
return True
|
|
18
|
+
except ValueError:
|
|
19
|
+
return False
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
SKILL_ROOT = Path(__file__).resolve().parent.parent
|
|
23
|
+
SKIP_PARTS = {".git", "__pycache__"}
|
|
24
|
+
WORKSPACE_DIR_NAMES = {"official-docs", "projects"}
|
|
25
|
+
ALLOWED_WORKSPACE_FILES = {".gitkeep"}
|
|
26
|
+
SKIP_FILES = {"CHANGE_log.md", "release_blocklist.txt", "THIRD_PARTY_NOTICES.md"}
|
|
27
|
+
BANNED_FILES = {
|
|
28
|
+
"config.ini",
|
|
29
|
+
"config.ini.example",
|
|
30
|
+
"_meta.json",
|
|
31
|
+
"environment_state.json",
|
|
32
|
+
}
|
|
33
|
+
# 第三方许可文件随包分发(MIT 合规要求),不视为违禁。
|
|
34
|
+
ALLOWED_LICENSE_NAMES = {"THIRD_PARTY_NOTICES.md", "NOTICE.md"}
|
|
35
|
+
ALLOWED_LICENSE_PREFIXES = ("LICENSE-",)
|
|
36
|
+
ALLOWED_DATA_SUFFIXES = {".json", ".xml", ".txt"}
|
|
37
|
+
BANNED_ARTIFACT_NAMES = {".DS_Store"}
|
|
38
|
+
BANNED_ARTIFACT_SUFFIXES = {".pyc", ".pyo"}
|
|
39
|
+
ALLOWED_API_KEY_VALUES = {
|
|
40
|
+
"",
|
|
41
|
+
"your_api_key_here",
|
|
42
|
+
"你的深知可信搜索 API Key",
|
|
43
|
+
"你的深知搜索 API Key",
|
|
44
|
+
}
|
|
45
|
+
API_KEY_PATTERN = re.compile(r"(?im)^\s*api_key[^\S\r\n]*=[^\S\r\n]*([^\s#;]+)[^\S\r\n]*$")
|
|
46
|
+
SECRET_TOKEN_PATTERN = re.compile(r"\bsk-[A-Za-z0-9_-]{16,}\b")
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
def should_flag_api_key_value(value):
|
|
50
|
+
clean = value.strip().strip('"').strip("'")
|
|
51
|
+
if clean in ALLOWED_API_KEY_VALUES:
|
|
52
|
+
return False
|
|
53
|
+
if any(mark in clean for mark in ("(", ")", "[", "]", "{", "}", ".", ",")):
|
|
54
|
+
return False
|
|
55
|
+
return True
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
def _is_allowed_license_file(path: Path) -> bool:
|
|
59
|
+
if path.name in ALLOWED_LICENSE_NAMES:
|
|
60
|
+
return True
|
|
61
|
+
return any(path.name.startswith(p) for p in ALLOWED_LICENSE_PREFIXES)
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
def main():
|
|
65
|
+
findings = []
|
|
66
|
+
for path in SKILL_ROOT.rglob("*"):
|
|
67
|
+
rel = path.relative_to(SKILL_ROOT)
|
|
68
|
+
parts = rel.parts
|
|
69
|
+
if path.name in BANNED_ARTIFACT_NAMES or path.suffix in BANNED_ARTIFACT_SUFFIXES:
|
|
70
|
+
findings.append(f"{rel}: 公开包不得包含本地产物")
|
|
71
|
+
continue
|
|
72
|
+
if any(part in SKIP_PARTS for part in parts):
|
|
73
|
+
continue
|
|
74
|
+
if path.is_file() and path.name in BANNED_FILES:
|
|
75
|
+
findings.append(f"{rel}: 公开包不得包含真实配置文件")
|
|
76
|
+
continue
|
|
77
|
+
# 工作区目录只允许 .gitkeep(第三方许可文件除外)
|
|
78
|
+
if path.is_file() and WORKSPACE_DIR_NAMES.intersection(parts):
|
|
79
|
+
if path.name not in ALLOWED_WORKSPACE_FILES and not _is_allowed_license_file(path):
|
|
80
|
+
findings.append(f"{rel}: 工作区目录内只允许 .gitkeep 占位,公开包不得包含工作区产物")
|
|
81
|
+
continue
|
|
82
|
+
if not path.is_file() or path.name in SKIP_FILES:
|
|
83
|
+
continue
|
|
84
|
+
try:
|
|
85
|
+
text = path.read_text(encoding="utf-8")
|
|
86
|
+
except (UnicodeDecodeError, OSError):
|
|
87
|
+
# 二进制数据文件(json/xml/txt 之外的图片等)跳过文本扫描
|
|
88
|
+
if path.suffix.lower() not in ALLOWED_DATA_SUFFIXES:
|
|
89
|
+
continue
|
|
90
|
+
continue
|
|
91
|
+
for line_number, line in enumerate(text.splitlines(), 1):
|
|
92
|
+
for match in API_KEY_PATTERN.finditer(line):
|
|
93
|
+
if should_flag_api_key_value(match.group(1)):
|
|
94
|
+
findings.append(f"{rel}:{line_number}: 发现非占位符 api_key")
|
|
95
|
+
if SECRET_TOKEN_PATTERN.search(line):
|
|
96
|
+
findings.append(f"{rel}:{line_number}: 发现疑似 API Key")
|
|
97
|
+
|
|
98
|
+
if findings:
|
|
99
|
+
print("发布检查失败:发现不应进入 SkillHub 公开包的内容")
|
|
100
|
+
print("\n".join(findings))
|
|
101
|
+
raise SystemExit(1)
|
|
102
|
+
print("发布检查通过:未发现真实配置、API Key 或本地生成物")
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
if __name__ == "__main__":
|
|
106
|
+
main()
|