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,404 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""Propagate a spec_lock.md value change to both the lock file and svg_output/*.svg.
|
|
3
|
+
|
|
4
|
+
Examples:
|
|
5
|
+
python3 update_spec.py <project_path> primary=#0066AA
|
|
6
|
+
python3 update_spec.py <project_path> colors.text=#111111
|
|
7
|
+
python3 update_spec.py <project_path> \\
|
|
8
|
+
typography.font_family='Arial, "Microsoft YaHei", sans-serif'
|
|
9
|
+
|
|
10
|
+
v2 scope:
|
|
11
|
+
- `colors.*` — HEX value replacement across svg_output/*.svg (case-insensitive match).
|
|
12
|
+
- `typography.font_family` — replaces the inner value of every `font-family="..."`
|
|
13
|
+
/ `font-family='...'` attribute in svg_output/*.svg. This is a global replace:
|
|
14
|
+
every text element becomes the new family, regardless of role, and every
|
|
15
|
+
existing `typography.*_family` lock row is updated to the same value.
|
|
16
|
+
|
|
17
|
+
Bare `key=value` (no dot) is treated as `colors.key=value` for backward compat.
|
|
18
|
+
|
|
19
|
+
Other keys as independent targets (typography sizes, per-role
|
|
20
|
+
`typography.*_family` overrides, icons, images, canvas, forbidden) are
|
|
21
|
+
intentionally NOT supported — they involve attribute-scoped or semantic
|
|
22
|
+
replacements whose risk/benefit does not warrant bulk propagation. For
|
|
23
|
+
per-role family changes, edit spec_lock.md and re-author the affected pages.
|
|
24
|
+
"""
|
|
25
|
+
from __future__ import annotations
|
|
26
|
+
|
|
27
|
+
import argparse
|
|
28
|
+
import os
|
|
29
|
+
import re
|
|
30
|
+
import shutil
|
|
31
|
+
import sys
|
|
32
|
+
import tempfile
|
|
33
|
+
from pathlib import Path
|
|
34
|
+
|
|
35
|
+
from console_encoding import configure_utf8_stdio
|
|
36
|
+
from project_management.project_specs import parse_spec_lock as parse_lock
|
|
37
|
+
|
|
38
|
+
configure_utf8_stdio()
|
|
39
|
+
|
|
40
|
+
HEX_RE = re.compile(r"^#(?:[0-9A-Fa-f]{3,4}|[0-9A-Fa-f]{6}|[0-9A-Fa-f]{8})$")
|
|
41
|
+
FONT_FAMILY_RE = re.compile(r"""(font-family\s*=\s*)(["'])(.*?)\2""")
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
def plan_lock_values(
|
|
45
|
+
lock_path: Path, section: str, updates: dict[str, str]
|
|
46
|
+
) -> str:
|
|
47
|
+
"""Return a lock rewrite only after every target row validates."""
|
|
48
|
+
lines = lock_path.read_text(encoding="utf-8").splitlines(keepends=True)
|
|
49
|
+
in_section = False
|
|
50
|
+
found: set[str] = set()
|
|
51
|
+
for i, raw in enumerate(lines):
|
|
52
|
+
stripped = raw.rstrip("\r\n")
|
|
53
|
+
line_ending = raw[len(stripped) :]
|
|
54
|
+
if stripped.startswith("## "):
|
|
55
|
+
in_section = stripped[3:].strip() == section
|
|
56
|
+
continue
|
|
57
|
+
if not in_section:
|
|
58
|
+
continue
|
|
59
|
+
m = re.match(r"^(-\s+)([A-Za-z0-9_]+)(\s*:\s*)(.+?)(\s*)$", stripped)
|
|
60
|
+
if not m or m.group(2) not in updates:
|
|
61
|
+
continue
|
|
62
|
+
key = m.group(2)
|
|
63
|
+
if key in found:
|
|
64
|
+
raise ValueError(
|
|
65
|
+
f"duplicate key {key!r} under section {section!r} in {lock_path}"
|
|
66
|
+
)
|
|
67
|
+
found.add(key)
|
|
68
|
+
lines[i] = (
|
|
69
|
+
f"{m.group(1)}{key}{m.group(3)}{updates[key]}{m.group(5)}"
|
|
70
|
+
f"{line_ending}"
|
|
71
|
+
)
|
|
72
|
+
|
|
73
|
+
missing = set(updates) - found
|
|
74
|
+
if missing:
|
|
75
|
+
missing_list = ", ".join(sorted(missing))
|
|
76
|
+
raise KeyError(
|
|
77
|
+
f"key(s) {missing_list} not found under section {section!r} in {lock_path}"
|
|
78
|
+
)
|
|
79
|
+
return "".join(lines)
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
def _plan_color_updates(
|
|
83
|
+
svg_dir: Path,
|
|
84
|
+
old_hex: str,
|
|
85
|
+
new_hex: str,
|
|
86
|
+
) -> list[tuple[Path, str, int]]:
|
|
87
|
+
"""Return planned color rewrites without touching the SVG files."""
|
|
88
|
+
if not HEX_RE.match(old_hex) or not HEX_RE.match(new_hex):
|
|
89
|
+
raise ValueError(f"not a HEX color: old={old_hex!r} new={new_hex!r}")
|
|
90
|
+
pattern = re.compile(
|
|
91
|
+
rf"{re.escape(old_hex)}(?![0-9A-Fa-f])",
|
|
92
|
+
re.IGNORECASE,
|
|
93
|
+
)
|
|
94
|
+
planned: list[tuple[Path, str, int]] = []
|
|
95
|
+
for svg in sorted(svg_dir.glob("*.svg")):
|
|
96
|
+
text = svg.read_text(encoding="utf-8")
|
|
97
|
+
new_text, count = pattern.subn(new_hex, text)
|
|
98
|
+
if count > 0:
|
|
99
|
+
planned.append((svg, new_text, count))
|
|
100
|
+
return planned
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
def _plan_font_family_updates(
|
|
104
|
+
svg_dir: Path,
|
|
105
|
+
new_value: str,
|
|
106
|
+
) -> list[tuple[Path, str, int]]:
|
|
107
|
+
"""Return planned font-family rewrites without touching the SVG files."""
|
|
108
|
+
|
|
109
|
+
def replace_value(match: re.Match[str]) -> str:
|
|
110
|
+
prefix, quote, _inner = match.group(1), match.group(2), match.group(3)
|
|
111
|
+
outer = quote
|
|
112
|
+
if outer in new_value:
|
|
113
|
+
outer = "'" if quote == '"' else '"'
|
|
114
|
+
if outer in new_value:
|
|
115
|
+
raise ValueError(
|
|
116
|
+
f"new font_family value contains both ' and \" — cannot embed: "
|
|
117
|
+
f"{new_value!r}"
|
|
118
|
+
)
|
|
119
|
+
return f"{prefix}{outer}{new_value}{outer}"
|
|
120
|
+
|
|
121
|
+
planned: list[tuple[Path, str, int]] = []
|
|
122
|
+
for svg in sorted(svg_dir.glob("*.svg")):
|
|
123
|
+
text = svg.read_text(encoding="utf-8")
|
|
124
|
+
new_text, count = FONT_FAMILY_RE.subn(replace_value, text)
|
|
125
|
+
if count > 0 and new_text != text:
|
|
126
|
+
planned.append((svg, new_text, count))
|
|
127
|
+
return planned
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
def _publish_text_updates(updates: list[tuple[Path, str]]) -> None:
|
|
131
|
+
"""Publish existing text files as one rollback unit."""
|
|
132
|
+
if not updates:
|
|
133
|
+
return
|
|
134
|
+
targets = [path for path, _text in updates]
|
|
135
|
+
if len(targets) != len(set(targets)):
|
|
136
|
+
raise ValueError("transaction contains duplicate output paths")
|
|
137
|
+
for target in targets:
|
|
138
|
+
if not target.is_file() or target.is_symlink():
|
|
139
|
+
raise OSError(f"transaction target must be a regular file: {target}")
|
|
140
|
+
|
|
141
|
+
transaction_dir = Path(
|
|
142
|
+
tempfile.mkdtemp(
|
|
143
|
+
prefix=".update-spec-",
|
|
144
|
+
dir=targets[0].parent,
|
|
145
|
+
)
|
|
146
|
+
)
|
|
147
|
+
staged_dir = transaction_dir / "staged"
|
|
148
|
+
backup_dir = transaction_dir / "previous"
|
|
149
|
+
preserve_transaction = False
|
|
150
|
+
published: list[tuple[Path, Path]] = []
|
|
151
|
+
try:
|
|
152
|
+
staged_dir.mkdir()
|
|
153
|
+
backup_dir.mkdir()
|
|
154
|
+
staged: list[tuple[Path, Path, Path]] = []
|
|
155
|
+
transaction_device = transaction_dir.stat().st_dev
|
|
156
|
+
for index, (target, text) in enumerate(updates):
|
|
157
|
+
if target.parent.stat().st_dev != transaction_device:
|
|
158
|
+
raise OSError(
|
|
159
|
+
f"cannot atomically publish across filesystems: {target}"
|
|
160
|
+
)
|
|
161
|
+
staged_path = staged_dir / f"{index:06d}.new"
|
|
162
|
+
backup_path = backup_dir / f"{index:06d}.bak"
|
|
163
|
+
staged_path.write_text(text, encoding="utf-8")
|
|
164
|
+
shutil.copymode(target, staged_path)
|
|
165
|
+
shutil.copy2(target, backup_path, follow_symlinks=False)
|
|
166
|
+
staged.append((target, staged_path, backup_path))
|
|
167
|
+
|
|
168
|
+
try:
|
|
169
|
+
for target, staged_path, backup_path in staged:
|
|
170
|
+
os.replace(staged_path, target)
|
|
171
|
+
published.append((target, backup_path))
|
|
172
|
+
except BaseException as publish_error:
|
|
173
|
+
rollback_errors: list[str] = []
|
|
174
|
+
for target, backup_path in reversed(published):
|
|
175
|
+
try:
|
|
176
|
+
os.replace(backup_path, target)
|
|
177
|
+
except BaseException as rollback_error:
|
|
178
|
+
rollback_errors.append(
|
|
179
|
+
f"could not restore {target}: "
|
|
180
|
+
f"{type(rollback_error).__name__}: {rollback_error}"
|
|
181
|
+
)
|
|
182
|
+
if rollback_errors:
|
|
183
|
+
preserve_transaction = True
|
|
184
|
+
raise RuntimeError(
|
|
185
|
+
f"update_spec publish failed ({publish_error}); rollback was "
|
|
186
|
+
f"incomplete: {'; '.join(rollback_errors)}; recovery directory: "
|
|
187
|
+
f"{transaction_dir}"
|
|
188
|
+
) from publish_error
|
|
189
|
+
raise
|
|
190
|
+
finally:
|
|
191
|
+
if not preserve_transaction:
|
|
192
|
+
shutil.rmtree(transaction_dir, ignore_errors=True)
|
|
193
|
+
|
|
194
|
+
|
|
195
|
+
def replace_color_in_svgs(
|
|
196
|
+
svg_dir: Path, old_hex: str, new_hex: str, *, dry_run: bool = False
|
|
197
|
+
) -> list[tuple[Path, int]]:
|
|
198
|
+
"""Replace old_hex with new_hex in every .svg under svg_dir.
|
|
199
|
+
|
|
200
|
+
Returns a list of (path, replacement_count) for each changed file. The
|
|
201
|
+
count comes straight from re.subn so callers can spot anomalies —
|
|
202
|
+
e.g. one file with 50 hits when the rest have 4-8 is likely a stray
|
|
203
|
+
HEX literal inside <text> content rather than a styling attribute.
|
|
204
|
+
|
|
205
|
+
Two-phase: plan all file updates in memory, then publish them with rollback.
|
|
206
|
+
If planning or publishing fails, the original files are retained.
|
|
207
|
+
|
|
208
|
+
When dry_run=True, the planning phase still runs (so bad HEX still raises
|
|
209
|
+
and callers see which files would change), but no disk writes happen. The
|
|
210
|
+
returned list describes the would-change files.
|
|
211
|
+
"""
|
|
212
|
+
planned = _plan_color_updates(svg_dir, old_hex, new_hex)
|
|
213
|
+
if not dry_run:
|
|
214
|
+
_publish_text_updates([
|
|
215
|
+
(svg, new_text)
|
|
216
|
+
for svg, new_text, _count in planned
|
|
217
|
+
])
|
|
218
|
+
return [(path, count) for path, _text, count in planned]
|
|
219
|
+
|
|
220
|
+
|
|
221
|
+
def replace_font_family_in_svgs(
|
|
222
|
+
svg_dir: Path, new_value: str, *, dry_run: bool = False
|
|
223
|
+
) -> list[tuple[Path, int]]:
|
|
224
|
+
"""Replace the inner value of every `font-family="..."` / `font-family='...'`
|
|
225
|
+
attribute in every .svg under svg_dir.
|
|
226
|
+
|
|
227
|
+
Returns a list of (path, replacement_count) for each changed file.
|
|
228
|
+
|
|
229
|
+
Preserves the outer quote character when possible; if the new value contains
|
|
230
|
+
that same quote type, switches the outer quote to the other kind.
|
|
231
|
+
|
|
232
|
+
Two-phase: plan all file updates in memory, then publish them with rollback.
|
|
233
|
+
A conflicting quote style fails during planning, before files are touched.
|
|
234
|
+
|
|
235
|
+
When dry_run=True, the planning phase still runs (so the ValueError still
|
|
236
|
+
fires and callers see which files would change), but no disk writes happen.
|
|
237
|
+
The returned list describes the would-change files.
|
|
238
|
+
"""
|
|
239
|
+
planned = _plan_font_family_updates(svg_dir, new_value)
|
|
240
|
+
if not dry_run:
|
|
241
|
+
_publish_text_updates([
|
|
242
|
+
(svg, new_text)
|
|
243
|
+
for svg, new_text, _count in planned
|
|
244
|
+
])
|
|
245
|
+
return [(path, count) for path, _text, count in planned]
|
|
246
|
+
|
|
247
|
+
|
|
248
|
+
def main() -> int:
|
|
249
|
+
ap = argparse.ArgumentParser(description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter)
|
|
250
|
+
ap.add_argument("project_path", type=Path, help="project folder containing spec_lock.md and svg_output/")
|
|
251
|
+
ap.add_argument(
|
|
252
|
+
"assignment",
|
|
253
|
+
help=(
|
|
254
|
+
"section.key=value (e.g. colors.primary=#0066AA, "
|
|
255
|
+
"typography.font_family='Arial, \"Microsoft YaHei\", sans-serif'). "
|
|
256
|
+
"Bare key=value is treated as colors.key=value."
|
|
257
|
+
),
|
|
258
|
+
)
|
|
259
|
+
ap.add_argument(
|
|
260
|
+
"--dry-run",
|
|
261
|
+
"-n",
|
|
262
|
+
action="store_true",
|
|
263
|
+
help="preview which SVGs would change; do not write anything to disk.",
|
|
264
|
+
)
|
|
265
|
+
args = ap.parse_args()
|
|
266
|
+
|
|
267
|
+
project = args.project_path.resolve()
|
|
268
|
+
lock = project / "spec_lock.md"
|
|
269
|
+
svg_dir = project / "svg_output"
|
|
270
|
+
|
|
271
|
+
if not lock.exists():
|
|
272
|
+
print(f"error: spec_lock.md not found at {lock}", file=sys.stderr)
|
|
273
|
+
return 2
|
|
274
|
+
if not svg_dir.exists():
|
|
275
|
+
print(f"error: svg_output/ not found at {svg_dir}", file=sys.stderr)
|
|
276
|
+
return 2
|
|
277
|
+
|
|
278
|
+
if "=" not in args.assignment:
|
|
279
|
+
print("error: assignment must be [section.]key=value", file=sys.stderr)
|
|
280
|
+
return 2
|
|
281
|
+
lhs, new_value = args.assignment.split("=", 1)
|
|
282
|
+
lhs = lhs.strip()
|
|
283
|
+
new_value = new_value.strip()
|
|
284
|
+
if "." in lhs:
|
|
285
|
+
section, key = lhs.split(".", 1)
|
|
286
|
+
section = section.strip()
|
|
287
|
+
key = key.strip()
|
|
288
|
+
else:
|
|
289
|
+
section, key = "colors", lhs
|
|
290
|
+
|
|
291
|
+
sections = parse_lock(lock)
|
|
292
|
+
section_map = sections.get(section, {})
|
|
293
|
+
if key not in section_map:
|
|
294
|
+
known = {s: sorted(v) for s, v in sections.items()}
|
|
295
|
+
print(
|
|
296
|
+
f"error: {key!r} not found under `## {section}` in spec_lock.md.\n"
|
|
297
|
+
f"known keys: {known}",
|
|
298
|
+
file=sys.stderr,
|
|
299
|
+
)
|
|
300
|
+
return 2
|
|
301
|
+
|
|
302
|
+
old_value = section_map[key]
|
|
303
|
+
lock_changes: list[tuple[str, str, str]] = []
|
|
304
|
+
|
|
305
|
+
if section == "colors":
|
|
306
|
+
if not HEX_RE.match(new_value):
|
|
307
|
+
print(f"error: new value for colors.{key} must be a HEX color (got {new_value!r})", file=sys.stderr)
|
|
308
|
+
return 2
|
|
309
|
+
if old_value == new_value:
|
|
310
|
+
print(f"no change: colors.{key} already = {new_value}")
|
|
311
|
+
return 0
|
|
312
|
+
try:
|
|
313
|
+
planned_lock = plan_lock_values(lock, "colors", {key: new_value})
|
|
314
|
+
except (KeyError, ValueError) as exc:
|
|
315
|
+
print(f"error: {exc}", file=sys.stderr)
|
|
316
|
+
return 2
|
|
317
|
+
planned_svg = _plan_color_updates(svg_dir, old_value, new_value)
|
|
318
|
+
changed = [
|
|
319
|
+
(path, count)
|
|
320
|
+
for path, _text, count in planned_svg
|
|
321
|
+
]
|
|
322
|
+
lock_changes = [(key, old_value, new_value)]
|
|
323
|
+
if not args.dry_run:
|
|
324
|
+
try:
|
|
325
|
+
_publish_text_updates([
|
|
326
|
+
*(
|
|
327
|
+
(path, new_text)
|
|
328
|
+
for path, new_text, _count in planned_svg
|
|
329
|
+
),
|
|
330
|
+
(lock, planned_lock),
|
|
331
|
+
])
|
|
332
|
+
except (OSError, RuntimeError, ValueError) as exc:
|
|
333
|
+
print(f"error: update was not published: {exc}", file=sys.stderr)
|
|
334
|
+
return 2
|
|
335
|
+
elif section == "typography" and key == "font_family":
|
|
336
|
+
family_keys = [
|
|
337
|
+
name
|
|
338
|
+
for name in section_map
|
|
339
|
+
if name == "font_family" or name.endswith("_family")
|
|
340
|
+
]
|
|
341
|
+
lock_changes = [
|
|
342
|
+
(name, section_map[name], new_value)
|
|
343
|
+
for name in family_keys
|
|
344
|
+
if section_map[name] != new_value
|
|
345
|
+
]
|
|
346
|
+
if not lock_changes:
|
|
347
|
+
print(f"no change: all typography.*_family rows already = {new_value}")
|
|
348
|
+
return 0
|
|
349
|
+
try:
|
|
350
|
+
planned_lock = plan_lock_values(
|
|
351
|
+
lock,
|
|
352
|
+
"typography",
|
|
353
|
+
{name: new_value for name in family_keys},
|
|
354
|
+
)
|
|
355
|
+
planned_svg = _plan_font_family_updates(svg_dir, new_value)
|
|
356
|
+
changed = [
|
|
357
|
+
(path, count)
|
|
358
|
+
for path, _text, count in planned_svg
|
|
359
|
+
]
|
|
360
|
+
except (KeyError, ValueError) as e:
|
|
361
|
+
print(f"error: {e}", file=sys.stderr)
|
|
362
|
+
return 2
|
|
363
|
+
if not args.dry_run:
|
|
364
|
+
try:
|
|
365
|
+
_publish_text_updates([
|
|
366
|
+
*(
|
|
367
|
+
(path, new_text)
|
|
368
|
+
for path, new_text, _count in planned_svg
|
|
369
|
+
),
|
|
370
|
+
(lock, planned_lock),
|
|
371
|
+
])
|
|
372
|
+
except (OSError, RuntimeError, ValueError) as exc:
|
|
373
|
+
print(f"error: update was not published: {exc}", file=sys.stderr)
|
|
374
|
+
return 2
|
|
375
|
+
else:
|
|
376
|
+
print(
|
|
377
|
+
f"error: {section}.{key} is not supported by update_spec.py.\n"
|
|
378
|
+
f"v2 supports: colors.* (HEX), typography.font_family.\n"
|
|
379
|
+
f"Edit spec_lock.md and the affected SVGs by hand for other changes.",
|
|
380
|
+
file=sys.stderr,
|
|
381
|
+
)
|
|
382
|
+
return 2
|
|
383
|
+
|
|
384
|
+
if args.dry_run:
|
|
385
|
+
for lock_key, previous, replacement in lock_changes:
|
|
386
|
+
print(
|
|
387
|
+
f"[dry-run] spec_lock.md: "
|
|
388
|
+
f"{section}.{lock_key} {previous} → {replacement}"
|
|
389
|
+
)
|
|
390
|
+
print(f"[dry-run] svg_output/: {len(changed)} file(s) would be updated")
|
|
391
|
+
else:
|
|
392
|
+
for lock_key, previous, replacement in lock_changes:
|
|
393
|
+
print(
|
|
394
|
+
f"spec_lock.md: {section}.{lock_key} {previous} → {replacement}"
|
|
395
|
+
)
|
|
396
|
+
print(f"svg_output/: {len(changed)} file(s) updated")
|
|
397
|
+
for p, n in changed:
|
|
398
|
+
suffix = "replacement" if n == 1 else "replacements"
|
|
399
|
+
print(f" - {p.name} ({n} {suffix})")
|
|
400
|
+
return 0
|
|
401
|
+
|
|
402
|
+
|
|
403
|
+
if __name__ == "__main__":
|
|
404
|
+
sys.exit(main())
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
# Generate 生成演示稿 · 运行时权威
|
|
2
|
+
|
|
3
|
+
> 由 [`routing.md`](./routing.md) 选定 Generate 路线后加载。本文件拥有 Step 1-9 的执行顺序、确认门与强制命令。
|
|
4
|
+
|
|
5
|
+
**主管线**:
|
|
6
|
+
|
|
7
|
+
```
|
|
8
|
+
初始化门禁 → [深知检索(主题模式)] → 内容包 → 提纲版可信溯源核验报告
|
|
9
|
+
→【结构方案确认门 ⛔】→ 创建项目 → 逐页手写 SVG(P01 → 首页确认 ⛔ → 其余不间断)
|
|
10
|
+
→ SVG 质检 → 编译导出 .pptx → 成稿版可信溯源核验报告 → 交付
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
**执行纪律**:
|
|
14
|
+
|
|
15
|
+
- 主 Agent 逐页手写每个 SVG;禁止用脚本批量生成 `svg_output/` 页面。
|
|
16
|
+
- SVG 节奏:P01 → 首页确认门 → 其余页不间断完成 → 终检。不分组批量、不中途插入检查。
|
|
17
|
+
- 每个确认门必须等用户显式确认;门未关闭不得跨阶段捆绑工作。
|
|
18
|
+
- 质检/编译失败时只报告阻塞项与修复路径,不静默降级(如改导出整页图片)。
|
|
19
|
+
|
|
20
|
+
---
|
|
21
|
+
|
|
22
|
+
## Step 1 初始化门禁
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
python3 {skillDir}/scripts/initialize.py
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
- 基础依赖(`python3`/`requests`)缺失:暂停全部能力,按提示处理。
|
|
29
|
+
- `python_pptx=false` 或 `xlsxwriter=false`:仅阻断 SVG 编译导出(Step 7),素材检索与 SVG 创作可先行;编译时用 `uv run --with python-pptx --with XlsxWriter` 提供依赖。
|
|
30
|
+
- 需要检索的任务(主题模式、材料模式补检索)要求 `api_key_configured=true`;未配置时按 SKILL.md「统一 API Key 管理」引导,不得改用外部搜索。
|
|
31
|
+
|
|
32
|
+
## Step 2 深知检索(主题模式;材料模式仅补缺口)
|
|
33
|
+
|
|
34
|
+
1. 设计检索方案:覆盖政策依据、数据支撑、参考案例必要维度(表述参考不单列);写明搜索地域、每条 query 的目的、素材类型、使用边界。面向用户展示时不得出现脚本参数名。
|
|
35
|
+
2. **【检索方案确认门 ⛔】** 展示方案,等待用户确认或调整。确认话术:「我建议先按下面方案检索权威素材,请确认是否执行,或告诉我需要增删哪些搜索项。」
|
|
36
|
+
3. 用户确认后**串行**执行(禁止并发):
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
# dsh 默认走 MCP 工具 mcp__dknowc__trusted_search(参数同义:query/service_area/eff_time),
|
|
40
|
+
# 返回保存为 dknowc-output/${DSH_SESSION_ID:0:8}/official-docs/search-results/NN_语义名_mcp_raw.json,
|
|
41
|
+
# 再经适配脚本规范化:
|
|
42
|
+
python3 {skillDir}/scripts/adapt_mcp_result.py dknowc-output/${DSH_SESSION_ID:0:8}/official-docs/search-results/NN_语义名_mcp_raw.json \
|
|
43
|
+
--output dknowc-output/${DSH_SESSION_ID:0:8}/official-docs/search-results/NN_语义名.json --mode search
|
|
44
|
+
# 无 MCP 或临时 Key 场景的直连兜底:
|
|
45
|
+
python3 {skillDir}/scripts/trusted_search.py "检索问题" --service-area 单个地域 --eff-time 单个时间点 --json-only --output dknowc-output/${DSH_SESSION_ID:0:8}/official-docs/search-results/NN_语义名.json
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
4. 检索结果按素材四分类整理(政策依据/数据支撑/参考案例/表述参考),每条记录标题、来源、可支撑的结论——这就是后续素材清单的雏形。
|
|
49
|
+
5. 检索异常/空结果:停止,向用户说明哪个搜索项出问题,请用户确认下一步(重试/调整query/跳过/改用用户材料/明确同意改用外部搜索)。
|
|
50
|
+
|
|
51
|
+
## Step 3 内容包
|
|
52
|
+
|
|
53
|
+
按 [`references/content-pack.md`](../references/content-pack.md) 编制 `content-pack.md`:核心信息、叙事模式、页面规划(每页类型/标题/要点/素材ID)、素材清单(带来源)、风格预设(按 [`references/style-presets.md`](../references/style-presets.md) 推荐默认+备选)。此时项目短名(拼音或英文)应已确定,后续文件命名沿用。
|
|
54
|
+
|
|
55
|
+
## Step 4 提纲版可信溯源核验报告(执行过检索时必做)
|
|
56
|
+
|
|
57
|
+
把提纲固化为**带角标的答案文件**并生成提纲版报告——与成稿版同一脚本(`render_trace_html.py`)、同一形式,让用户在确认结构方案的同时逐条核验事实依据。编制规范见 [`references/material_usage.md`](../references/material_usage.md) 第三节。
|
|
58
|
+
|
|
59
|
+
1. 编制提纲答案文件 `official-docs/search-results/<项目短名>_outline.md`,三部分:
|
|
60
|
+
- **演示元信息**:受众与场合、叙事模式、风格预设、画布、页数;
|
|
61
|
+
- **页面规划表**:页 | 类型 | 标题 | 事实要点 | 依据。**每条事实性要点(政策名、数字、案例、时间点)后标 `[N]` 角标**,N 为素材清单检索编号;结构页/观点页依据留空;
|
|
62
|
+
- **口径事项清单**:需用户留意的问题(统计口径差异、外省材料定位、待补检索项),逐条带角标——这是提纲版的核心价值,把「待确认」变成可点击核验的书面记录。
|
|
63
|
+
2. 生成:
|
|
64
|
+
|
|
65
|
+
```bash
|
|
66
|
+
python3 {skillDir}/scripts/render_trace_html.py dknowc-output/${DSH_SESSION_ID:0:8}/official-docs/search-results/NN_语义名.json \
|
|
67
|
+
--title "<演示标题> 提纲 · 可信溯源核验报告" \
|
|
68
|
+
--answer-file dknowc-output/${DSH_SESSION_ID:0:8}/official-docs/search-results/<项目短名>_outline.md \
|
|
69
|
+
--question "用户原始需求"
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
3. **多轮检索**(多个 NN JSON):先手工合并为一个 JSON 供本步与成稿版使用——把各 JSON 的 `检索文章` 数组按素材清单 `[M]` 编号顺序合并(数组合并顺序即角标顺序,答案文件角标按此顺序书写)、`角标` 字段重排为清单编号,`knowledgeBase` 保留任一非空值;素材清单编号是角标唯一基准。渲染器兜底:若合并 JSON 未带 `角标` 字段,`render_trace_html.py` 按数组位置 1..N 自动编号(一条材料一张来源卡),因此**合并顺序必须与素材清单编号顺序一致**。
|
|
73
|
+
4. **编制纪律**:提纲中每个数字、政策名、案例必须能通过角标回溯到来源原文;挂不上角标的事实要点删除表述、降为概括表述、或列入口径事项清单标注「待补检索」,不得裸写。
|
|
74
|
+
5. **模式差异**:材料模式下,检索覆盖部分正常角标,纯用户材料要点在口径事项清单标注「用户提供 · 未经权威核验」;免检索模式不生成本报告,Step 5 确认门如实说明「提纲未经权威核验」。
|
|
75
|
+
|
|
76
|
+
## Step 5 结构方案确认门 ⛔
|
|
77
|
+
|
|
78
|
+
向用户展示(Markdown 分节,不塞长段落):
|
|
79
|
+
|
|
80
|
+
- 核心信息与叙事模式
|
|
81
|
+
- 页面规划总览(页序 + 每页标题 + 页类型)
|
|
82
|
+
- 关键素材及来源摘要
|
|
83
|
+
- 推荐风格预设 + 1-2 个备选 + 画布格式
|
|
84
|
+
- 提纲版可信溯源核验报告路径,并说明:「提纲中每条政策、数据和案例都已在报告中挂接权威来源,可点击逐条核对原文;另有 N 条口径事项需要你确认(见报告口径事项一节)。」
|
|
85
|
+
|
|
86
|
+
用户确认或调整后,方可创建项目。调整时先更新内容包与提纲答案文件、重新生成报告,再过本门。
|
|
87
|
+
|
|
88
|
+
## Step 6 创建项目与逐页手写 SVG
|
|
89
|
+
|
|
90
|
+
```bash
|
|
91
|
+
dknowc-projects/<项目名>/ # 项目名用主题短名(拼音或英文)
|
|
92
|
+
├── content-pack.md
|
|
93
|
+
├── sources/ # 用户自带材料(如有)
|
|
94
|
+
├── images/ # 页面引用的图片(如有)
|
|
95
|
+
├── svg_output/ # ★ 逐页手写的约束 SVG
|
|
96
|
+
├── validation/ # 质检报告(脚本自动写)
|
|
97
|
+
└── exports/ # 最终 .pptx 与两版可信溯源核验报告
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
项目创建后,把 Step 4 生成的提纲版报告从 `official-docs/output/` 复制归档到 `projects/<项目名>/exports/<演示名>_提纲核验报告.html`。
|
|
101
|
+
|
|
102
|
+
SVG 创作严格遵循 [`references/svg-authoring.md`](../references/svg-authoring.md)(元素契约、排版纪律、图表画法、禁止清单)与已确认风格预设。
|
|
103
|
+
|
|
104
|
+
节奏:**P01 完成后即请用户确认首页**(展示 SVG 文件内容或让用户直接打开文件查看;也可以先跑一次首页质检);确认后其余页不间断写完。写完顺手把页面引用的素材ID核对一遍。
|
|
105
|
+
|
|
106
|
+
## Step 7 质检与编译导出
|
|
107
|
+
|
|
108
|
+
```bash
|
|
109
|
+
# 质检(quick 无锁模式;--stage final --json 生成正式报告,导出的前置条件)
|
|
110
|
+
python3 {skillDir}/scripts/svg_quality_checker.py dknowc-projects/<项目名> --quick-generate --stage final --json
|
|
111
|
+
|
|
112
|
+
# 编译导出(原生 DrawingML)
|
|
113
|
+
uv run --with python-pptx --with XlsxWriter python3 {skillDir}/scripts/svg_to_pptx.py dknowc-projects/<项目名> --quick-generate
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
注意:导出脚本要求先存在**通过的 final 质检报告**(`validation/svg_quality_report.json`),所以质检必须带 `--stage final --json` 且退出码为 0,再执行导出。首页确认阶段可用不带 `--stage final` 的快速检查。
|
|
117
|
+
|
|
118
|
+
- 质检 exit 1(errors):逐条修复 SVG 后重跑;warnings 评估后可放行。
|
|
119
|
+
- 导出成功后 `.pptx` 位于 `projects/<项目名>/exports/`。
|
|
120
|
+
- 可选转场:`-t fade` 等参数仅用户明确要求动效时使用;默认不传。
|
|
121
|
+
|
|
122
|
+
## Step 8 成稿版可信溯源核验报告(执行过检索时必做)
|
|
123
|
+
|
|
124
|
+
把「最终演示的页面级结论文本」整理为答案文件(含 `[素材ID]` 角标对应关系说明),连同检索 JSON 生成成稿版报告:
|
|
125
|
+
|
|
126
|
+
```bash
|
|
127
|
+
python3 {skillDir}/scripts/render_trace_html.py dknowc-output/${DSH_SESSION_ID:0:8}/official-docs/search-results/NN_xxx.json \
|
|
128
|
+
--title "<演示标题> 可信溯源核验报告" \
|
|
129
|
+
--answer-file dknowc-output/${DSH_SESSION_ID:0:8}/official-docs/search-results/<项目短名>_answer.txt \
|
|
130
|
+
--question "用户原始需求"
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
输出 HTML 复制到 `projects/<项目名>/exports/<演示名>_成稿核验报告.html`。规则见 [`references/material_usage.md`](../references/material_usage.md)。
|
|
134
|
+
|
|
135
|
+
## Step 9 交付(三件套)
|
|
136
|
+
|
|
137
|
+
- 主交付物:`projects/<项目名>/exports/<演示名>.pptx` 路径 + 一句简短说明。
|
|
138
|
+
- 执行过检索时附两份报告路径并说明其为辅助核验文件、不是正文附件:
|
|
139
|
+
- `<演示名>_提纲核验报告.html`(提纲阶段事前核验);
|
|
140
|
+
- `<演示名>_成稿核验报告.html`(交付阶段事后溯源)。
|
|
141
|
+
- 不发送 SVG 源文件、内容包草稿、质检报告等中间产物,除非用户明确要看。
|
|
142
|
+
- 询问是否需要调整(改文字/换风格/调页序):调整走内容包 → SVG → 重导出的闭环,不直接改 .pptx。
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
# 路由规则(routing)
|
|
2
|
+
|
|
3
|
+
深知可信PPT v1 只有一条顶层路线:**Generate 生成演示稿**。本文件负责入口判断与模式选择。
|
|
4
|
+
|
|
5
|
+
## 一、路由纪律(改编自 ppt-master)
|
|
6
|
+
|
|
7
|
+
| 规则 | 行为 |
|
|
8
|
+
| --- | --- |
|
|
9
|
+
| 单一路线 | 所有「做 PPT / 演示文稿 / 汇报 / 课件」请求都进入 Generate 主线 |
|
|
10
|
+
| 匹配即执行 | 请求已明确匹配时直接执行,不得向用户罗列实现路径或让用户选流程 |
|
|
11
|
+
| 缺前置条件 | 说明缺什么并停止,不得发明替代方案(如缺 API Key 时不得改用外部搜索) |
|
|
12
|
+
| 一次一个判别问题 | 请求模糊时最多问一个判别问题,不连环追问 |
|
|
13
|
+
| 阻塞门必须停 | 每个确认门必须等用户显式确认;不得代用户决定、不得跨门捆绑工作 |
|
|
14
|
+
|
|
15
|
+
## 二、入口判断
|
|
16
|
+
|
|
17
|
+
本 skill 处理的请求形态:
|
|
18
|
+
|
|
19
|
+
- 从主题/需求生成 PPT(「做一份XX汇报PPT」「把XX做成演示文稿」)
|
|
20
|
+
- 从已有材料生成 PPT(用户提供 Word/PDF/Markdown/文本,要求转成 PPT)
|
|
21
|
+
- 修改/重做本 skill 已生成的项目(读取 `projects/` 下原项目,按内容包变更后重新出 SVG)
|
|
22
|
+
|
|
23
|
+
不处理的请求(说明并停止,或引导到对应能力):
|
|
24
|
+
|
|
25
|
+
- 纯公文写作(Word 交付)→ 不在本 skill,提示用户这是 PPT 专用 skill
|
|
26
|
+
- 只要文字大纲不要 PPT → 可给大纲,但说明本 skill 的交付物是 .pptx
|
|
27
|
+
|
|
28
|
+
## 三、Generate 内部模式选择
|
|
29
|
+
|
|
30
|
+
| 条件 | 模式 |
|
|
31
|
+
| --- | --- |
|
|
32
|
+
| 用户只给主题/场景,无素材 | **主题模式**:先设计检索方案,过「检索方案确认门」,深知检索补齐事实基线 |
|
|
33
|
+
| 用户给了材料(文档/文本) | **材料模式**:以用户材料为主体整理内容包;仅对影响结论的事实缺口按需补检索(补检索同样过确认门) |
|
|
34
|
+
| 用户给了材料且明确说「不用查,就用我给的」 | 材料模式免检索;可信溯源核验报告中素材标注「用户提供」 |
|
|
35
|
+
|
|
36
|
+
## 四、运行时权威
|
|
37
|
+
|
|
38
|
+
模式确定后,一切执行细节以 [`generate-pptx.md`](./generate-pptx.md) 为准。本文件只管入口判断,不得在执行阶段被重复引用。
|
|
@@ -7,7 +7,7 @@ description: "当用户需要检索权威材料、政策法规/标准原文、
|
|
|
7
7
|
description_zh: "深知可信搜索(法律、政策、标准)是由北京彩智科技有限公司旗下“深知可信智能”提供的可信搜索与权威材料检索 Skill,面向政策法规、政务办事依据、税务社保、公积金、企业补贴、资质证照、行业标准、公共服务、合规义务、政策调研、城市政策对比和企业投资/技改/税惠材料核验等工作场景。默认调用可信搜索接口,按需调用深度搜索接口,输出带权威来源、知识专库、可点击溯源 HTML 和干净 Markdown 的结果。"
|
|
8
8
|
description_en: "dknowc trusted search is a trusted search and authoritative-source retrieval Skill provided by dknowc Trusted Intelligence under Beijing Caizhi Technology Co., Ltd. It supports policy, regulation, government-service evidence, standards, compliance, subsidy, tax-benefit and policy research tasks. It defaults to trusted search, uses deep search only on explicit user request or confirmation, and delivers a direct answer, clickable provenance HTML, and clean Markdown without citation markers."
|
|
9
9
|
category: 通用办公
|
|
10
|
-
version: 1.1.
|
|
10
|
+
version: 1.1.4-dsh
|
|
11
11
|
author: 彩智科技
|
|
12
12
|
permissions:
|
|
13
13
|
network:
|
|
@@ -172,17 +172,18 @@ python3 <skillDir>/scripts/render_trace_html.py \
|
|
|
172
172
|
|
|
173
173
|
## 深度搜索调用(MCP)
|
|
174
174
|
|
|
175
|
-
|
|
175
|
+
用户明确要求深度搜索时,先提示耗时(单问题约 20-40 秒),再调用 `mcp__dknowc__deep_query`(**deep-query/v3,非流式一次性返回**):
|
|
176
176
|
|
|
177
177
|
```json
|
|
178
178
|
{
|
|
179
|
-
"
|
|
180
|
-
"
|
|
181
|
-
"show_materials": 5
|
|
179
|
+
"query": "忠实于用户目标的复杂问题",
|
|
180
|
+
"areas": ["单个地域(可选)"]
|
|
182
181
|
}
|
|
183
182
|
```
|
|
184
183
|
|
|
185
|
-
|
|
184
|
+
**v3 参数**:`query` 必填(复杂政策研究问题);`areas` 为字符串数组,支持一次传多个地域(服务端按地域自动拆分子查询);`queryId` 可选(续查用,默认不传)。
|
|
185
|
+
|
|
186
|
+
把 MCP 返回保存为 `dknowc-output/${DSH_SESSION_ID:0:8}/official-docs/search-results/dknowc_deep_mcp_raw.json`。**MCP v3 返回的实际字段形态**:外层 `code/msg`(code=0 成功;偶发 `code=500 转发失败` 属服务端问题,稍后重试即可),内层 `data.searches[]`(按子查询分组:`query`/`areas`/`result[]`,每组 result 为该子查询的材料数组)、`data.common_articles[]`(多查询公共文章)、`data.traceId`(链路追踪)。材料字段与可信搜索检索文章风格统一(`文章标题`/`源网址`/`数据源`/`发布日期`/`发布日期可信度`/`办理地域`/`段落`)。深度搜索**不直接返回答案正文**:最终答案由你基于材料综合形成,保存为答案文件后经 `--answer-file` 传入渲染。然后:
|
|
186
187
|
|
|
187
188
|
```bash
|
|
188
189
|
python3 <skillDir>/scripts/adapt_mcp_result.py dknowc-output/${DSH_SESSION_ID:0:8}/official-docs/search-results/dknowc_deep_mcp_raw.json \
|
|
@@ -195,7 +196,7 @@ python3 <skillDir>/scripts/render_trace_html.py \
|
|
|
195
196
|
--question "用户原始问题"
|
|
196
197
|
```
|
|
197
198
|
|
|
198
|
-
适配脚本会把
|
|
199
|
+
适配脚本会把 v3 的 `data.searches[].result[]` 与 `data.common_articles[]` 直通透传给渲染脚本(1.1.4 渲染器原生解析 v3 结构),并保留 `traceId`。
|
|
199
200
|
|
|
200
201
|
多地域、多层级任务应拆成多次调用,例如中国、重庆市、重庆两江新区分别搜索。如果用户没有明确要求深度搜索,不要主动调用。先完成可信搜索版答案和三件套交付,再询问用户是否升级深度搜索。
|
|
201
202
|
|