dknowc-dsh 1.0.3 → 1.1.0

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.
Files changed (173) hide show
  1. package/README.md +9 -4
  2. package/package.json +2 -2
  3. package/skills/dknowc-official-doc-writer/SKILL.md +17 -8
  4. package/skills/dknowc-official-doc-writer/reference/sample_search_result.md +48 -0
  5. package/skills/dknowc-official-doc-writer/reference/sample_trace_report.html +75 -0
  6. package/skills/dknowc-official-doc-writer/reference/search_intro.md +72 -8
  7. package/skills/dknowc-official-doc-writer/scripts/register.mjs +1 -1
  8. package/skills/dknowc-ppt-assistant/README.md +54 -0
  9. package/skills/dknowc-ppt-assistant/SKILL.md +151 -0
  10. package/skills/dknowc-ppt-assistant/THIRD_PARTY_NOTICES.md +36 -0
  11. package/skills/dknowc-ppt-assistant/official-docs/output/.gitkeep +0 -0
  12. package/skills/dknowc-ppt-assistant/official-docs/search-results/.gitkeep +0 -0
  13. package/skills/dknowc-ppt-assistant/projects/.gitkeep +0 -0
  14. package/skills/dknowc-ppt-assistant/references/content-pack.md +55 -0
  15. package/skills/dknowc-ppt-assistant/references/material_usage.md +51 -0
  16. package/skills/dknowc-ppt-assistant/references/sample_effect.html +89 -0
  17. package/skills/dknowc-ppt-assistant/references/sample_search_result.md +48 -0
  18. package/skills/dknowc-ppt-assistant/references/search_intro.md +79 -0
  19. package/skills/dknowc-ppt-assistant/references/style-presets.md +126 -0
  20. package/skills/dknowc-ppt-assistant/references/svg-authoring.md +81 -0
  21. package/skills/dknowc-ppt-assistant/references/upstream-docs/svg-pipeline.md +842 -0
  22. package/skills/dknowc-ppt-assistant/references/upstream-example/01_cover.svg +28 -0
  23. package/skills/dknowc-ppt-assistant/references/upstream-example/02_quote.svg +38 -0
  24. package/skills/dknowc-ppt-assistant/references/upstream-example/03_origin.svg +96 -0
  25. package/skills/dknowc-ppt-assistant/references/upstream-example/README.md +15 -0
  26. package/skills/dknowc-ppt-assistant/references/upstream-example/design_spec.md +408 -0
  27. package/skills/dknowc-ppt-assistant/references/upstream-example/spec_lock.md +78 -0
  28. package/skills/dknowc-ppt-assistant/scripts/adapt_mcp_result.py +279 -0
  29. package/skills/dknowc-ppt-assistant/scripts/check_release.py +106 -0
  30. package/skills/dknowc-ppt-assistant/scripts/compact_svg_coordinates.py +345 -0
  31. package/skills/dknowc-ppt-assistant/scripts/config.py +707 -0
  32. package/skills/dknowc-ppt-assistant/scripts/console_encoding.py +33 -0
  33. package/skills/dknowc-ppt-assistant/scripts/error_helper.py +434 -0
  34. package/skills/dknowc-ppt-assistant/scripts/finalize_svg.py +507 -0
  35. package/skills/dknowc-ppt-assistant/scripts/hyperlink_contract.py +399 -0
  36. package/skills/dknowc-ppt-assistant/scripts/initialize.py +182 -0
  37. package/skills/dknowc-ppt-assistant/scripts/language_tags.py +283 -0
  38. package/skills/dknowc-ppt-assistant/scripts/mcp_direct.py +158 -0
  39. package/skills/dknowc-ppt-assistant/scripts/native_payloads.py +655 -0
  40. package/skills/dknowc-ppt-assistant/scripts/pptx_animation_presets.json +3440 -0
  41. package/skills/dknowc-ppt-assistant/scripts/pptx_animations.py +3965 -0
  42. package/skills/dknowc-ppt-assistant/scripts/pptx_effects.py +143 -0
  43. package/skills/dknowc-ppt-assistant/scripts/pptx_opc_validation.py +346 -0
  44. package/skills/dknowc-ppt-assistant/scripts/pptx_shapes/__init__.py +130 -0
  45. package/skills/dknowc-ppt-assistant/scripts/pptx_shapes/data/LICENSE-APACHE-2.0.txt +202 -0
  46. package/skills/dknowc-ppt-assistant/scripts/pptx_shapes/data/LICENSE-OPEN-XML-SDK-MIT.txt +23 -0
  47. package/skills/dknowc-ppt-assistant/scripts/pptx_shapes/data/NOTICE.md +54 -0
  48. package/skills/dknowc-ppt-assistant/scripts/pptx_shapes/data/presetShapeDefinitions.xml +19898 -0
  49. package/skills/dknowc-ppt-assistant/scripts/pptx_shapes/data/presetShapeSemantics.json +1217 -0
  50. package/skills/dknowc-ppt-assistant/scripts/pptx_shapes/data/shape_type_values.txt +187 -0
  51. package/skills/dknowc-ppt-assistant/scripts/pptx_shapes/errors.py +39 -0
  52. package/skills/dknowc-ppt-assistant/scripts/pptx_shapes/formula.py +336 -0
  53. package/skills/dknowc-ppt-assistant/scripts/pptx_shapes/loader.py +364 -0
  54. package/skills/dknowc-ppt-assistant/scripts/pptx_shapes/models.py +201 -0
  55. package/skills/dknowc-ppt-assistant/scripts/pptx_shapes/registry.py +270 -0
  56. package/skills/dknowc-ppt-assistant/scripts/pptx_shapes/semantic_hash.py +456 -0
  57. package/skills/dknowc-ppt-assistant/scripts/pptx_shapes/semantics.py +543 -0
  58. package/skills/dknowc-ppt-assistant/scripts/pptx_shapes/xml_safety.py +21 -0
  59. package/skills/dknowc-ppt-assistant/scripts/pptx_to_svg/__init__.py +21 -0
  60. package/skills/dknowc-ppt-assistant/scripts/pptx_to_svg/animation_import.py +287 -0
  61. package/skills/dknowc-ppt-assistant/scripts/pptx_to_svg/chart_to_svg.py +2377 -0
  62. package/skills/dknowc-ppt-assistant/scripts/pptx_to_svg/chartex_to_svg.py +422 -0
  63. package/skills/dknowc-ppt-assistant/scripts/pptx_to_svg/color_resolver.py +894 -0
  64. package/skills/dknowc-ppt-assistant/scripts/pptx_to_svg/converter.py +1143 -0
  65. package/skills/dknowc-ppt-assistant/scripts/pptx_to_svg/custgeom_to_svg.py +165 -0
  66. package/skills/dknowc-ppt-assistant/scripts/pptx_to_svg/effect_to_svg.py +410 -0
  67. package/skills/dknowc-ppt-assistant/scripts/pptx_to_svg/emu_units.py +258 -0
  68. package/skills/dknowc-ppt-assistant/scripts/pptx_to_svg/fill_to_svg.py +816 -0
  69. package/skills/dknowc-ppt-assistant/scripts/pptx_to_svg/formula_import.py +611 -0
  70. package/skills/dknowc-ppt-assistant/scripts/pptx_to_svg/hyperlinks.py +93 -0
  71. package/skills/dknowc-ppt-assistant/scripts/pptx_to_svg/import_diagnostics.py +37 -0
  72. package/skills/dknowc-ppt-assistant/scripts/pptx_to_svg/ln_to_svg.py +362 -0
  73. package/skills/dknowc-ppt-assistant/scripts/pptx_to_svg/normalized_chart_svg.py +1217 -0
  74. package/skills/dknowc-ppt-assistant/scripts/pptx_to_svg/ooxml_loader.py +506 -0
  75. package/skills/dknowc-ppt-assistant/scripts/pptx_to_svg/pic_to_svg.py +653 -0
  76. package/skills/dknowc-ppt-assistant/scripts/pptx_to_svg/preset_authoring.py +894 -0
  77. package/skills/dknowc-ppt-assistant/scripts/pptx_to_svg/preset_registry_to_svg.py +216 -0
  78. package/skills/dknowc-ppt-assistant/scripts/pptx_to_svg/preset_svg_markup.py +198 -0
  79. package/skills/dknowc-ppt-assistant/scripts/pptx_to_svg/prstgeom_to_svg.py +162 -0
  80. package/skills/dknowc-ppt-assistant/scripts/pptx_to_svg/shape_walker.py +556 -0
  81. package/skills/dknowc-ppt-assistant/scripts/pptx_to_svg/slide_to_svg.py +2002 -0
  82. package/skills/dknowc-ppt-assistant/scripts/pptx_to_svg/tbl_to_svg.py +1841 -0
  83. package/skills/dknowc-ppt-assistant/scripts/pptx_to_svg/transition_import.py +201 -0
  84. package/skills/dknowc-ppt-assistant/scripts/pptx_to_svg/txbody_to_svg.py +1433 -0
  85. package/skills/dknowc-ppt-assistant/scripts/pptx_transitions.py +3153 -0
  86. package/skills/dknowc-ppt-assistant/scripts/preset_shape_svg.py +450 -0
  87. package/skills/dknowc-ppt-assistant/scripts/project_utils.py +645 -0
  88. package/skills/dknowc-ppt-assistant/scripts/register_key.mjs +183 -0
  89. package/skills/dknowc-ppt-assistant/scripts/register_template.py +1327 -0
  90. package/skills/dknowc-ppt-assistant/scripts/render_trace_html.py +1048 -0
  91. package/skills/dknowc-ppt-assistant/scripts/resource_paths.py +282 -0
  92. package/skills/dknowc-ppt-assistant/scripts/shape_boolean_svg.py +189 -0
  93. package/skills/dknowc-ppt-assistant/scripts/slide_roster.py +44 -0
  94. package/skills/dknowc-ppt-assistant/scripts/svg_finalize/__init__.py +12 -0
  95. package/skills/dknowc-ppt-assistant/scripts/svg_finalize/align_embed_images.py +672 -0
  96. package/skills/dknowc-ppt-assistant/scripts/svg_finalize/crop_images.py +370 -0
  97. package/skills/dknowc-ppt-assistant/scripts/svg_finalize/embed_icons.py +564 -0
  98. package/skills/dknowc-ppt-assistant/scripts/svg_finalize/embed_images.py +288 -0
  99. package/skills/dknowc-ppt-assistant/scripts/svg_finalize/fix_image_aspect.py +389 -0
  100. package/skills/dknowc-ppt-assistant/scripts/svg_finalize/flatten_tspan.py +948 -0
  101. package/skills/dknowc-ppt-assistant/scripts/svg_finalize/svg_rect_to_path.py +346 -0
  102. package/skills/dknowc-ppt-assistant/scripts/svg_quality/__init__.py +15 -0
  103. package/skills/dknowc-ppt-assistant/scripts/svg_quality/checker.py +7791 -0
  104. package/skills/dknowc-ppt-assistant/scripts/svg_quality/cli.py +193 -0
  105. package/skills/dknowc-ppt-assistant/scripts/svg_quality/svg_contracts.py +1121 -0
  106. package/skills/dknowc-ppt-assistant/scripts/svg_quality/xml_support.py +35 -0
  107. package/skills/dknowc-ppt-assistant/scripts/svg_quality_checker.py +59 -0
  108. package/skills/dknowc-ppt-assistant/scripts/svg_to_pptx/__init__.py +37 -0
  109. package/skills/dknowc-ppt-assistant/scripts/svg_to_pptx/animation_config.py +1622 -0
  110. package/skills/dknowc-ppt-assistant/scripts/svg_to_pptx/canvas_contract.py +226 -0
  111. package/skills/dknowc-ppt-assistant/scripts/svg_to_pptx/drawingml/__init__.py +1 -0
  112. package/skills/dknowc-ppt-assistant/scripts/svg_to_pptx/drawingml/context.py +291 -0
  113. package/skills/dknowc-ppt-assistant/scripts/svg_to_pptx/drawingml/converter.py +1980 -0
  114. package/skills/dknowc-ppt-assistant/scripts/svg_to_pptx/drawingml/elements.py +5272 -0
  115. package/skills/dknowc-ppt-assistant/scripts/svg_to_pptx/drawingml/hyperlinks.py +162 -0
  116. package/skills/dknowc-ppt-assistant/scripts/svg_to_pptx/drawingml/paths.py +847 -0
  117. package/skills/dknowc-ppt-assistant/scripts/svg_to_pptx/drawingml/styles.py +752 -0
  118. package/skills/dknowc-ppt-assistant/scripts/svg_to_pptx/drawingml/text_properties.py +796 -0
  119. package/skills/dknowc-ppt-assistant/scripts/svg_to_pptx/drawingml/theme_colors.py +283 -0
  120. package/skills/dknowc-ppt-assistant/scripts/svg_to_pptx/drawingml/theme_fonts.py +330 -0
  121. package/skills/dknowc-ppt-assistant/scripts/svg_to_pptx/drawingml/utils.py +3555 -0
  122. package/skills/dknowc-ppt-assistant/scripts/svg_to_pptx/geometry_properties.py +140 -0
  123. package/skills/dknowc-ppt-assistant/scripts/svg_to_pptx/native_objects/__init__.py +356 -0
  124. package/skills/dknowc-ppt-assistant/scripts/svg_to_pptx/native_objects/chart_data.py +1449 -0
  125. package/skills/dknowc-ppt-assistant/scripts/svg_to_pptx/native_objects/chart_style.py +886 -0
  126. package/skills/dknowc-ppt-assistant/scripts/svg_to_pptx/native_objects/chart_xml.py +1495 -0
  127. package/skills/dknowc-ppt-assistant/scripts/svg_to_pptx/native_objects/chartex.py +272 -0
  128. package/skills/dknowc-ppt-assistant/scripts/svg_to_pptx/native_objects/fallback_hash.py +161 -0
  129. package/skills/dknowc-ppt-assistant/scripts/svg_to_pptx/native_objects/formula.py +243 -0
  130. package/skills/dknowc-ppt-assistant/scripts/svg_to_pptx/native_objects/formula_ast.py +592 -0
  131. package/skills/dknowc-ppt-assistant/scripts/svg_to_pptx/native_objects/formula_compiler.py +96 -0
  132. package/skills/dknowc-ppt-assistant/scripts/svg_to_pptx/native_objects/formula_omml.py +1049 -0
  133. package/skills/dknowc-ppt-assistant/scripts/svg_to_pptx/native_objects/formula_parser.py +2181 -0
  134. package/skills/dknowc-ppt-assistant/scripts/svg_to_pptx/native_objects/formula_profile.py +739 -0
  135. package/skills/dknowc-ppt-assistant/scripts/svg_to_pptx/native_objects/formula_run_properties.py +234 -0
  136. package/skills/dknowc-ppt-assistant/scripts/svg_to_pptx/native_objects/inline_formula.py +311 -0
  137. package/skills/dknowc-ppt-assistant/scripts/svg_to_pptx/native_objects/marker_attributes.py +182 -0
  138. package/skills/dknowc-ppt-assistant/scripts/svg_to_pptx/native_objects/marker_common.py +806 -0
  139. package/skills/dknowc-ppt-assistant/scripts/svg_to_pptx/native_objects/marker_status.py +190 -0
  140. package/skills/dknowc-ppt-assistant/scripts/svg_to_pptx/native_objects/table.py +1113 -0
  141. package/skills/dknowc-ppt-assistant/scripts/svg_to_pptx/native_objects/workbook.py +216 -0
  142. package/skills/dknowc-ppt-assistant/scripts/svg_to_pptx/pptx_package/__init__.py +1 -0
  143. package/skills/dknowc-ppt-assistant/scripts/svg_to_pptx/pptx_package/builder.py +6273 -0
  144. package/skills/dknowc-ppt-assistant/scripts/svg_to_pptx/pptx_package/cli.py +2059 -0
  145. package/skills/dknowc-ppt-assistant/scripts/svg_to_pptx/pptx_package/dimensions.py +189 -0
  146. package/skills/dknowc-ppt-assistant/scripts/svg_to_pptx/pptx_package/discovery.py +120 -0
  147. package/skills/dknowc-ppt-assistant/scripts/svg_to_pptx/pptx_package/media.py +160 -0
  148. package/skills/dknowc-ppt-assistant/scripts/svg_to_pptx/pptx_package/narration.py +696 -0
  149. package/skills/dknowc-ppt-assistant/scripts/svg_to_pptx/pptx_package/notes.py +336 -0
  150. package/skills/dknowc-ppt-assistant/scripts/svg_to_pptx/pptx_package/slide_xml.py +138 -0
  151. package/skills/dknowc-ppt-assistant/scripts/svg_to_pptx/pptx_package/template_structure.py +3457 -0
  152. package/skills/dknowc-ppt-assistant/scripts/svg_to_pptx/pptx_package/template_validation.py +1536 -0
  153. package/skills/dknowc-ppt-assistant/scripts/svg_to_pptx/semantic_markers.py +240 -0
  154. package/skills/dknowc-ppt-assistant/scripts/svg_to_pptx/shape_boolean.py +1355 -0
  155. package/skills/dknowc-ppt-assistant/scripts/svg_to_pptx/text_outline.py +1121 -0
  156. package/skills/dknowc-ppt-assistant/scripts/svg_to_pptx/tspan_flattener.py +64 -0
  157. package/skills/dknowc-ppt-assistant/scripts/svg_to_pptx/use_expander.py +577 -0
  158. package/skills/dknowc-ppt-assistant/scripts/svg_to_pptx.py +21 -0
  159. package/skills/dknowc-ppt-assistant/scripts/trusted_search.py +336 -0
  160. package/skills/dknowc-ppt-assistant/scripts/update_spec.py +404 -0
  161. package/skills/dknowc-ppt-assistant/workflows/generate-pptx.md +142 -0
  162. package/skills/dknowc-ppt-assistant/workflows/routing.md +38 -0
  163. package/skills/dknowc-trusted-consulting/SKILL.md +21 -5
  164. package/skills/dknowc-trusted-consulting/reference/consult_intro.md +79 -0
  165. package/skills/dknowc-trusted-consulting/reference/sample_consult_answer.md +31 -0
  166. package/skills/dknowc-trusted-consulting/reference/sample_trace_report.html +76 -0
  167. package/skills/dknowc-trusted-consulting/scripts/register_key.mjs +1 -0
  168. package/skills/dknowc-trusted-search/SKILL.md +30 -2
  169. package/skills/dknowc-trusted-search/reference/sample_search_result.md +33 -0
  170. package/skills/dknowc-trusted-search/reference/sample_trace_report.html +450 -0
  171. package/skills/dknowc-trusted-search/reference/search_intro.md +79 -0
  172. package/skills/dknowc-trusted-search/scripts/register_key.mjs +1 -0
  173. 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,面向政策法规、政务办事、税务社保、公积金、企业补贴、资质证照、行业标准、公共服务、合规义务、企业经营政策和办事导办等场景。它通过 MCP 调用可信统一问答接口,输出带权威来源角标和本地可点击溯源 HTML 的精准咨询结果。"
8
8
  description_en: "dknowc trusted consulting is a trusted consultation Skill provided by dknowc Trusted Intelligence under Beijing Caizhi Technology Co., Ltd. It answers policy, regulation, government service, tax, social security, housing fund, enterprise subsidy, licensing, industry standard, compliance and public-service questions through the trusted unified chat API (via MCP), with citation markers and local provenance HTML."
9
9
  category: 通用办公
10
- version: 1.0.4-dsh
10
+ version: 1.0.5-dsh
11
11
  author: 彩智科技
12
12
  permissions:
13
13
  network:
@@ -41,16 +41,32 @@ python3 <skillDir>/scripts/initialize.py
41
41
  - 配置生效后,`DSH_DKNOWC_API_KEY` 非空,门禁通过;**一次配置,之后免注册**;
42
42
  - 若用户后续修改/替换 Key,只需更新 `DKNOWC_API_KEY` 并重启 dsh 或新建会话。
43
43
 
44
- 如果初始化结果中 `api_key_configured=false`,或 `blocking_issues` 包含 `api_key_missing`,**不要中断当前任务**,先引导用户完成 MaaS Key 获取(见下),拿到 Key 后**用临时直连完成当前任务**,任务完成后再建议持久化。
44
+ 如果初始化结果中 `api_key_configured=false`,或 `blocking_issues` 包含 `api_key_missing`,**不要中断当前任务**,按下面的开通引导规则向用户说明并引导开通,拿到 Key 后**用临时直调 MCP 完成当前任务**(见下),任务完成后再建议持久化;用户明确拒绝或犹豫时按退路降级交付,不得反复劝说。
45
45
 
46
46
  **重要:门禁失败时禁止先探测 MCP 工具。** 初始化失败(`api_key_missing`)已明确说明 Key 未配置,此时 `mcp__dknowc__credible_chat` 必然返回 401/unauthorized——**不要调用它来"确认是否可用"**,也不要绕回 MCP 不可用处理分支(那针对的是"Key 已配置但工具异常"的情况)。门禁失败后唯一正确路径是:直接向用户说明需要配置 API Key → 引导注册 → 拿到临时 Key → 用 `mcp_direct.py` 直调完成当前任务。
47
47
 
48
- 如果检测到未配置 Key,先暂停原任务并向用户说明:
48
+ ## 开通引导规则(价值前置、时机后移、可退路)
49
+
50
+ 向用户引导时必须做到:
51
+
52
+ - 结合当前任务和用户语气自然表达,禁止逐字照抄固定模板,禁止说明书式复述流程。
53
+ - 不得向用户暴露内部术语和流程名,如"MaaS""API Key""环境变量 `DKNOWC_API_KEY`"等;用户侧只表达为"开通可信咨询功能",不说"注册""注册账号"。
54
+ - 先价值、后验证:必须先让用户理解可信咨询对当前这个问题的价值(权威口径、带出处、可核验),再提出手机号验证;不得开口就要手机号。
55
+ - 引导时机尽量后置:优先在用户确认咨询需求或表现出对权威答案的期待之后再引导开通;不要在任务一开始就要求验证。
56
+ - 解释要点:① 为什么需要:这个问题涉及具体的办事条件、金额口径或政策判断,凭记忆回答容易过时或记错地区差异,答错影响办事和决策,且普通回答说不清出处;开通后答案基于权威文件库原文,结论可溯源、可核验。② 有什么不一样:基于权威文件库作答(覆盖 600 万篇公开规范性文件、7000 万篇可溯源的权威公开资料,每日更新,覆盖 54 个行业、300 多个地市、2800 多个县),不是普通 AI 联网回答;关键结论带角标、附溯源报告。③ 怎么开:手机号收一次验证码,两步、约 10 秒,不用去网站、不用填表单,其余由 Agent 代办。
57
+ - 安全与边界说明(用户问起或犹豫时按需说明,不点名具体平台):手机号仅用于本次验证,不发营销短信、不打营销电话;本 Skill 已通过所在平台的安全审核上架,服务由北京彩智科技提供;验证后只在本机保存一个访问密钥,用户的对话和材料不会上传;不用了可随时注销。
58
+ - 给退路:用户拒绝或犹豫时,不得反复劝说、不得纠缠;基于模型已有知识作答,并在回答开头或结尾明确标注"未联网核验、政策口径可能过期或存在地区差异",不使用来源角标冒充可信结论,不生成本轮溯源报告;用户后续主动提出开通时再执行注册。
59
+ - 交付后轻提示:未开通的用户得到降级回答后,可自然带一句"以后遇到政策口径、办事条件这类问题,可开通可信咨询,每条结论都带原文出处";每个任务最多提示一次,不追问、不重复。
60
+ - 如需向用户介绍可信咨询的能力说明、安全说明和分场景话术范例,参考 `reference/consult_intro.md`;用户犹豫或询问效果时,可读取 `reference/sample_consult_answer.md` 和 `reference/sample_trace_report.html` 向用户展示带角标回答和可信溯源报告的效果。两个示例文件均为示例数据,仅供展示,不得作为答案素材引用,不得发给用户当作交付物。所有说明用自己的话自然组织,不得整段照抄参考文件。
61
+
62
+ 语气示范(不要照抄,模仿这种自然口吻组织语言):
49
63
 
50
64
  ```text
51
- 深知可信咨询需要通过 API Key 调用深知可信统一接口,获取可溯源的可信内容。当前还未检测到可用的 API Key,所以暂时不能继续查询。
65
+ 这个问题涉及具体的办事条件和金额口径,凭记忆回答容易过时或者记错地区差异,答错了会影响办事和决策。开通可信咨询后,我可以直接基于权威文件库回答——覆盖 600 万篇公开规范性文件、7000 万篇可溯源的权威公开资料,每日更新;回答里的条件、金额、办理路径都带原文出处,可点开核验,这是普通联网回答做不到的。
66
+
67
+ 开通只需手机号收一次验证码:两步、10 秒左右,不用去网站、不用填表单,剩下的我来办。手机号仅用于本次验证,不会有营销骚扰。
52
68
 
53
- 你可以注册或登录深知可信智能 MaaS 账号获取 API Key。拿到 Key 后,本轮任务可以直接使用它完成查询;任务完成后,我会再询问你是否把它保存为后续可复用的环境变量。
69
+ 也可以先不开通:我按已有知识先答,并标注"未联网核验、口径可能过期",你看答案时注意甄别。
54
70
  ```
55
71
 
56
72
  MaaS Key 获取(通过本 Skill 的 `scripts/register_key.mjs`,使用 dsh 专属渠道码):