dknowc-dsh 2.3.0 → 2.4.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 (270) hide show
  1. package/README.md +14 -50
  2. package/package.json +2 -2
  3. package/skills/dk-trace-report/SKILL.md +288 -0
  4. package/skills/dk-trace-report/config/examples/doc.json +56 -0
  5. package/skills/dk-trace-report/config/examples/legal.json +51 -0
  6. package/skills/dk-trace-report/config/examples/ppt.json +47 -0
  7. package/skills/dk-trace-report/config/examples/tax.json +46 -0
  8. package/skills/dk-trace-report/config/examples/trusted.json +122 -0
  9. package/skills/dk-trace-report/reference/sample_input.json +60 -0
  10. package/skills/dk-trace-report/resources/ECHARTS-NOTICE.txt +10 -0
  11. package/skills/dk-trace-report/resources/echarts.custom.min.js +48 -0
  12. package/skills/dk-trace-report/scripts/build_report_input.py +333 -0
  13. package/skills/{dknowc-trusted-search → dk-trace-report}/scripts/chart_embed.py +4 -1
  14. package/skills/{dknowc-trusted-search → dk-trace-report}/scripts/render_trace_html.py +1072 -537
  15. package/skills/dk-trace-report/scripts/run_paths.py +95 -0
  16. package/skills/dk-trace-report/scripts/trust_digest.py +77 -0
  17. package/skills/dknowc-legal-assistant/README.md +95 -0
  18. package/skills/dknowc-legal-assistant/SKILL.md +122 -0
  19. package/skills/dknowc-legal-assistant/attribution.json +5 -0
  20. package/skills/dknowc-legal-assistant/reference/answer-and-report.md +221 -0
  21. package/skills/dknowc-legal-assistant/reference/capability-layer.md +143 -0
  22. package/skills/dknowc-legal-assistant/reference/legal_claims.example.json +96 -0
  23. package/skills/dknowc-legal-assistant/reference/onboarding_scripts.md +198 -0
  24. package/skills/dknowc-legal-assistant/reference/policy_tags.json +2002 -0
  25. package/skills/dknowc-legal-assistant/reference/retrieval-statute.md +81 -0
  26. package/skills/dknowc-legal-assistant/reference/retrieval-v2.md +133 -0
  27. package/skills/dknowc-legal-assistant/reference/sample_search_result.md +33 -0
  28. package/skills/dknowc-legal-assistant/reference/sample_trace_report.html +940 -0
  29. package/skills/dknowc-legal-assistant/reference/tags.md +53 -0
  30. package/skills/dknowc-legal-assistant/reference/troubleshooting.md +50 -0
  31. package/skills/dknowc-legal-assistant/reference/verification-pass.md +59 -0
  32. package/skills/dknowc-legal-assistant/resources/echarts.custom.min.js +48 -0
  33. package/skills/dknowc-legal-assistant/scripts/api_key.py +68 -0
  34. package/skills/dknowc-legal-assistant/scripts/attribution.py +61 -0
  35. package/skills/dknowc-legal-assistant/scripts/calc_legal.py +375 -0
  36. package/skills/dknowc-legal-assistant/scripts/calc_period.py +155 -0
  37. package/skills/dknowc-legal-assistant/scripts/check_answer.py +664 -0
  38. package/skills/dknowc-legal-assistant/scripts/initialize.py +188 -0
  39. package/skills/dknowc-legal-assistant/scripts/legal_client.py +208 -0
  40. package/skills/dknowc-legal-assistant/scripts/legal_search.py +1059 -0
  41. package/skills/dknowc-legal-assistant/scripts/merge_search_results.py +630 -0
  42. package/skills/dknowc-legal-assistant/scripts/path_guard.py +92 -0
  43. package/skills/dknowc-legal-assistant/scripts/question_profile.py +215 -0
  44. package/skills/dknowc-legal-assistant/scripts/register_key.mjs +1152 -0
  45. package/skills/dknowc-legal-assistant/scripts/run_eval.py +109 -0
  46. package/skills/dknowc-legal-assistant/scripts/source_cards.py +321 -0
  47. package/skills/dknowc-legal-assistant/scripts/tag_catalog.py +162 -0
  48. package/skills/dknowc-legal-assistant/scripts/trace_report.config.json +66 -0
  49. package/skills/dknowc-legal-assistant/scripts/verify_claims.py +448 -0
  50. package/skills/dknowc-legal-assistant/scripts/websearch_convert.py +396 -0
  51. package/skills/dknowc-official-doc-writer/README.md +45 -25
  52. package/skills/dknowc-official-doc-writer/SKILL.md +28 -14
  53. package/skills/dknowc-official-doc-writer/config/trace_report.config.json +56 -0
  54. package/skills/dknowc-official-doc-writer/official-docs/input//345/274/225/347/224/250/345/257/271/347/205/247_/351/252/214/346/224/266_materials.json +628 -0
  55. package/skills/dknowc-official-doc-writer/official-docs/search-results/baseline_1555.json +345 -0
  56. package/skills/dknowc-official-doc-writer/official-docs/search-results/baseline_my.json +728 -0
  57. package/skills/dknowc-official-doc-writer/official-docs/search-results/baseline_wp.json +159 -0
  58. package/skills/dknowc-official-doc-writer/official-docs/search-results/baseline_wp2.json +1006 -0
  59. package/skills/dknowc-official-doc-writer/official-docs/search-results/test_tz.json +28 -0
  60. package/skills/dknowc-official-doc-writer/official-docs/search-results/tmp_q.json +1419 -0
  61. package/skills/dknowc-official-doc-writer/reference/anti_ai_patterns.md +13 -1
  62. package/skills/dknowc-official-doc-writer/reference/fact_discipline.md +4 -0
  63. package/skills/dknowc-official-doc-writer/reference/genre_writing_notes.md +4 -0
  64. package/skills/dknowc-official-doc-writer/reference/initialization.md +28 -20
  65. package/skills/dknowc-official-doc-writer/reference/material_usage_guidance.md +21 -0
  66. package/skills/dknowc-official-doc-writer/reference/materials_pipeline.md +64 -7
  67. package/skills/dknowc-official-doc-writer/reference/onboarding_scripts.md +43 -32
  68. package/skills/dknowc-official-doc-writer/reference/outline_rules.md +1 -1
  69. package/skills/dknowc-official-doc-writer/reference/output_guide.md +19 -20
  70. package/skills/dknowc-official-doc-writer/reference/research_notes.md +5 -3
  71. package/skills/dknowc-official-doc-writer/reference/review_checklist.md +6 -2
  72. package/skills/dknowc-official-doc-writer/reference/revision_workflow.md +2 -2
  73. package/skills/dknowc-official-doc-writer/reference/search_guide.md +45 -33
  74. package/skills/dknowc-official-doc-writer/reference/search_intro.md +4 -4
  75. package/skills/dknowc-official-doc-writer/reference/search_policy.md +63 -36
  76. package/skills/dknowc-official-doc-writer/reference/standards/00_index.md +63 -77
  77. package/skills/dknowc-official-doc-writer/reference/standards/01_report.md +3 -3
  78. package/skills/dknowc-official-doc-writer/reference/standards/02_qingshi.md +6 -3
  79. package/skills/dknowc-official-doc-writer/reference/standards/03_pifu.md +2 -2
  80. package/skills/dknowc-official-doc-writer/reference/standards/04_tongzhi.md +12 -3
  81. package/skills/dknowc-official-doc-writer/reference/standards/05_yijian.md +8 -2
  82. package/skills/dknowc-official-doc-writer/reference/standards/06_han.md +2 -2
  83. package/skills/dknowc-official-doc-writer/reference/standards/08_tongbao.md +2 -2
  84. package/skills/dknowc-official-doc-writer/reference/standards/09_tonggao.md +2 -2
  85. package/skills/dknowc-official-doc-writer/reference/standards/10_gonggao.md +2 -2
  86. package/skills/dknowc-official-doc-writer/reference/standards/11_fuhan_approve.md +2 -2
  87. package/skills/dknowc-official-doc-writer/reference/standards/12_fuhan_objection.md +2 -2
  88. package/skills/dknowc-official-doc-writer/reference/standards/13_reminder.md +3 -3
  89. package/skills/dknowc-official-doc-writer/reference/standards/14_generic.md +1 -1
  90. package/skills/dknowc-official-doc-writer/reference/standards/16_decision.md +2 -2
  91. package/skills/dknowc-official-doc-writer/reference/standards/18_order.md +1 -1
  92. package/skills/dknowc-official-doc-writer/reference/standards/19_gazette.md +1 -1
  93. package/skills/dknowc-official-doc-writer/reference/standards/20_motion.md +2 -2
  94. package/skills/dknowc-official-doc-writer/reference/standards/22_application.md +2 -2
  95. package/skills/dknowc-official-doc-writer/reference/standards/23_publicity.md +1 -1
  96. package/skills/dknowc-official-doc-writer/reference/standards/25_plan.md +2 -1
  97. package/skills/dknowc-official-doc-writer/reference/standards/26_summary.md +7 -1
  98. package/skills/dknowc-official-doc-writer/reference/standards/27_speech.md +4 -1
  99. package/skills/dknowc-official-doc-writer/reference/standards/99_expressions.md +1 -2
  100. package/skills/dknowc-official-doc-writer/reference/task_router.md +5 -5
  101. package/skills/dknowc-official-doc-writer/reference/working_principles.md +4 -4
  102. package/skills/dknowc-official-doc-writer/reference/writing_method.md +166 -0
  103. package/skills/dknowc-official-doc-writer/reference/writing_rules.md +11 -5
  104. package/skills/dknowc-official-doc-writer/scripts/api_key.py +30 -3
  105. package/skills/dknowc-official-doc-writer/scripts/attribution.py +1 -1
  106. package/skills/dknowc-official-doc-writer/scripts/build_trace_json.py +216 -22
  107. package/skills/dknowc-official-doc-writer/scripts/check_materials.py +375 -27
  108. package/skills/dknowc-official-doc-writer/scripts/deep_convert.py +9 -4
  109. package/skills/dknowc-official-doc-writer/scripts/deep_query.py +3 -2
  110. package/skills/dknowc-official-doc-writer/scripts/dkag_search.py +23 -9
  111. package/skills/dknowc-official-doc-writer/scripts/extract_reference.py +2 -1
  112. package/skills/dknowc-official-doc-writer/scripts/format_document.py +116 -41
  113. package/skills/dknowc-official-doc-writer/scripts/initialize.py +246 -12
  114. package/skills/dknowc-official-doc-writer/scripts/local_memory.py +2 -6
  115. package/skills/dknowc-official-doc-writer/scripts/mcp_direct.py +2 -3
  116. package/skills/dknowc-official-doc-writer/scripts/merge_search_results.py +113 -13
  117. package/skills/dknowc-official-doc-writer/scripts/outline_reference.py +3 -2
  118. package/skills/dknowc-official-doc-writer/scripts/prose_lint.py +7 -2
  119. package/skills/dknowc-official-doc-writer/scripts/register.mjs +782 -216
  120. package/skills/dknowc-official-doc-writer/scripts/review_document.py +2 -1
  121. package/skills/dknowc-official-doc-writer/scripts/source_note_html.py +120 -13
  122. package/skills/dknowc-official-doc-writer/scripts/template_generator.py +2 -1
  123. package/skills/dknowc-official-doc-writer/scripts/update_skill.py +339 -0
  124. package/skills/dknowc-official-doc-writer/scripts/websearch_convert.py +326 -0
  125. package/skills/dknowc-ppt-assistant/README.md +21 -9
  126. package/skills/dknowc-ppt-assistant/SKILL.md +29 -20
  127. package/skills/dknowc-ppt-assistant/THIRD_PARTY_NOTICES.md +3 -2
  128. package/skills/dknowc-ppt-assistant/config/trace_report.config.json +65 -0
  129. package/skills/dknowc-ppt-assistant/references/initialization.md +58 -7
  130. package/skills/dknowc-ppt-assistant/references/material_usage.md +51 -14
  131. package/skills/dknowc-ppt-assistant/references/onboarding_scripts.md +51 -18
  132. package/skills/dknowc-ppt-assistant/references/sample_trace_report.html +372 -920
  133. package/skills/dknowc-ppt-assistant/references/search_intro.md +2 -2
  134. package/skills/dknowc-ppt-assistant/references/svg-authoring.md +3 -3
  135. package/skills/dknowc-ppt-assistant/references/upstream-example/README.md +2 -0
  136. package/skills/dknowc-ppt-assistant/scripts/api_key.py +11 -27
  137. package/skills/dknowc-ppt-assistant/scripts/attribution.py +2 -2
  138. package/skills/dknowc-ppt-assistant/scripts/build_trace_input.py +188 -0
  139. package/skills/dknowc-ppt-assistant/scripts/compact_svg_coordinates.py +1 -1
  140. package/skills/dknowc-ppt-assistant/scripts/config.py +9 -9
  141. package/skills/dknowc-ppt-assistant/scripts/console_encoding.py +1 -2
  142. package/skills/dknowc-ppt-assistant/scripts/error_helper.py +3 -3
  143. package/skills/dknowc-ppt-assistant/scripts/hyperlink_contract.py +1 -1
  144. package/skills/dknowc-ppt-assistant/scripts/initialize.py +248 -15
  145. package/skills/dknowc-ppt-assistant/scripts/language_tags.py +1 -1
  146. package/skills/dknowc-ppt-assistant/scripts/mcp_convert.py +7 -14
  147. package/skills/dknowc-ppt-assistant/scripts/mcp_direct.py +3 -2
  148. package/skills/dknowc-ppt-assistant/scripts/merge_search_results.py +604 -0
  149. package/skills/dknowc-ppt-assistant/scripts/native_payloads.py +1 -1
  150. package/skills/dknowc-ppt-assistant/scripts/pptx_animations.py +1 -1
  151. package/skills/dknowc-ppt-assistant/scripts/pptx_shapes/__init__.py +1 -1
  152. package/skills/dknowc-ppt-assistant/scripts/pptx_shapes/errors.py +1 -1
  153. package/skills/dknowc-ppt-assistant/scripts/pptx_shapes/formula.py +1 -1
  154. package/skills/dknowc-ppt-assistant/scripts/pptx_shapes/loader.py +1 -1
  155. package/skills/dknowc-ppt-assistant/scripts/pptx_shapes/models.py +1 -1
  156. package/skills/dknowc-ppt-assistant/scripts/pptx_shapes/registry.py +2 -2
  157. package/skills/dknowc-ppt-assistant/scripts/pptx_shapes/semantic_hash.py +1 -1
  158. package/skills/dknowc-ppt-assistant/scripts/pptx_shapes/semantics.py +3 -3
  159. package/skills/dknowc-ppt-assistant/scripts/pptx_to_svg/animation_import.py +1 -1
  160. package/skills/dknowc-ppt-assistant/scripts/pptx_to_svg/formula_import.py +1 -1
  161. package/skills/dknowc-ppt-assistant/scripts/pptx_to_svg/hyperlinks.py +2 -2
  162. package/skills/dknowc-ppt-assistant/scripts/pptx_to_svg/preset_authoring.py +2 -2
  163. package/skills/dknowc-ppt-assistant/scripts/pptx_to_svg/preset_registry_to_svg.py +2 -2
  164. package/skills/dknowc-ppt-assistant/scripts/pptx_to_svg/preset_svg_markup.py +2 -2
  165. package/skills/dknowc-ppt-assistant/scripts/pptx_to_svg/slide_to_svg.py +1 -1
  166. package/skills/dknowc-ppt-assistant/scripts/pptx_to_svg/transition_import.py +1 -1
  167. package/skills/dknowc-ppt-assistant/scripts/pptx_transitions.py +2 -2
  168. package/skills/dknowc-ppt-assistant/scripts/preset_shape_svg.py +2 -2
  169. package/skills/dknowc-ppt-assistant/scripts/preview_slide_html.py +4 -11
  170. package/skills/dknowc-ppt-assistant/scripts/project_utils.py +2 -2
  171. package/skills/dknowc-ppt-assistant/scripts/register_key.mjs +890 -341
  172. package/skills/dknowc-ppt-assistant/scripts/resource_paths.py +1 -1
  173. package/skills/dknowc-ppt-assistant/scripts/shape_boolean_svg.py +2 -2
  174. package/skills/dknowc-ppt-assistant/scripts/slide_roster.py +1 -1
  175. package/skills/dknowc-ppt-assistant/scripts/svg_finalize/__init__.py +2 -9
  176. package/skills/dknowc-ppt-assistant/scripts/svg_finalize/align_embed_images.py +1 -1
  177. package/skills/dknowc-ppt-assistant/scripts/svg_finalize/crop_images.py +3 -3
  178. package/skills/dknowc-ppt-assistant/scripts/svg_quality/__init__.py +2 -2
  179. package/skills/dknowc-ppt-assistant/scripts/svg_quality/checker.py +9 -10
  180. package/skills/dknowc-ppt-assistant/scripts/svg_quality/cli.py +4 -4
  181. package/skills/dknowc-ppt-assistant/scripts/svg_quality/svg_contracts.py +2 -2
  182. package/skills/dknowc-ppt-assistant/scripts/svg_quality/xml_support.py +1 -1
  183. package/skills/dknowc-ppt-assistant/scripts/svg_quality_checker.py +1 -1
  184. package/skills/dknowc-ppt-assistant/scripts/svg_to_pptx/drawingml/hyperlinks.py +2 -2
  185. package/skills/dknowc-ppt-assistant/scripts/svg_to_pptx/drawingml/theme_colors.py +1 -1
  186. package/skills/dknowc-ppt-assistant/scripts/svg_to_pptx/drawingml/theme_fonts.py +1 -1
  187. package/skills/dknowc-ppt-assistant/scripts/svg_to_pptx/geometry_properties.py +1 -1
  188. package/skills/dknowc-ppt-assistant/scripts/svg_to_pptx/native_objects/formula.py +2 -2
  189. package/skills/dknowc-ppt-assistant/scripts/svg_to_pptx/native_objects/formula_ast.py +1 -1
  190. package/skills/dknowc-ppt-assistant/scripts/svg_to_pptx/native_objects/formula_compiler.py +2 -2
  191. package/skills/dknowc-ppt-assistant/scripts/svg_to_pptx/native_objects/formula_omml.py +2 -2
  192. package/skills/dknowc-ppt-assistant/scripts/svg_to_pptx/native_objects/formula_parser.py +2 -2
  193. package/skills/dknowc-ppt-assistant/scripts/svg_to_pptx/native_objects/formula_profile.py +1 -1
  194. package/skills/dknowc-ppt-assistant/scripts/svg_to_pptx/native_objects/formula_run_properties.py +1 -1
  195. package/skills/dknowc-ppt-assistant/scripts/svg_to_pptx/native_objects/inline_formula.py +2 -2
  196. package/skills/dknowc-ppt-assistant/scripts/svg_to_pptx/pptx_package/builder.py +9 -11
  197. package/skills/dknowc-ppt-assistant/scripts/svg_to_pptx/pptx_package/cli.py +7 -5
  198. package/skills/dknowc-ppt-assistant/scripts/svg_to_pptx/pptx_package/template_structure.py +1 -1
  199. package/skills/dknowc-ppt-assistant/scripts/svg_to_pptx/pptx_package/template_validation.py +1 -1
  200. package/skills/dknowc-ppt-assistant/scripts/svg_to_pptx/semantic_markers.py +1 -1
  201. package/skills/dknowc-ppt-assistant/scripts/svg_to_pptx/shape_boolean.py +2 -2
  202. package/skills/dknowc-ppt-assistant/scripts/svg_to_pptx/text_outline.py +2 -2
  203. package/skills/dknowc-ppt-assistant/scripts/svg_to_pptx.py +1 -1
  204. package/skills/dknowc-ppt-assistant/scripts/trusted_search.py +51 -17
  205. package/skills/dknowc-ppt-assistant/scripts/update_skill.py +314 -0
  206. package/skills/dknowc-ppt-assistant/scripts/update_spec.py +25 -1
  207. package/skills/dknowc-ppt-assistant/scripts/websearch_convert.py +326 -0
  208. package/skills/dknowc-ppt-assistant/workflows/generate-pptx.md +99 -34
  209. package/skills/dknowc-tax-assistant/README.md +54 -0
  210. package/skills/dknowc-tax-assistant/SKILL.md +99 -0
  211. package/skills/dknowc-tax-assistant/attribution.json +5 -0
  212. package/skills/dknowc-tax-assistant/reference/answer-and-report.md +100 -0
  213. package/skills/dknowc-tax-assistant/reference/capability-layer.md +205 -0
  214. package/skills/dknowc-tax-assistant/reference/onboarding_scripts.md +68 -0
  215. package/skills/dknowc-tax-assistant/reference/policy_tags.json +2002 -0
  216. package/skills/dknowc-tax-assistant/reference/retrieval-policy.md +43 -0
  217. package/skills/dknowc-tax-assistant/reference/retrieval-v2.md +58 -0
  218. package/skills/dknowc-tax-assistant/reference/tags.md +53 -0
  219. package/skills/dknowc-tax-assistant/reference/tax_claims.example.json +76 -0
  220. package/skills/dknowc-tax-assistant/reference/trace_report.config.json +46 -0
  221. package/skills/dknowc-tax-assistant/reference/troubleshooting.md +70 -0
  222. package/skills/dknowc-tax-assistant/reference/websearch-fallback.md +59 -0
  223. package/skills/dknowc-tax-assistant/resources/THIRD_PARTY_NOTICES.md +9 -0
  224. package/skills/dknowc-tax-assistant/resources/echarts.custom.min.js +48 -0
  225. package/skills/dknowc-tax-assistant/scripts/api_key.py +60 -0
  226. package/skills/dknowc-tax-assistant/scripts/attribution.py +61 -0
  227. package/skills/dknowc-tax-assistant/scripts/calc_period.py +156 -0
  228. package/skills/dknowc-tax-assistant/scripts/calc_tax.py +179 -0
  229. package/skills/dknowc-tax-assistant/scripts/check_answer.py +210 -0
  230. package/skills/dknowc-tax-assistant/scripts/initialize.py +208 -0
  231. package/skills/dknowc-tax-assistant/scripts/merge_search_results.py +631 -0
  232. package/skills/dknowc-tax-assistant/scripts/path_guard.py +23 -0
  233. package/skills/dknowc-tax-assistant/scripts/question_profile.py +444 -0
  234. package/skills/dknowc-tax-assistant/scripts/register_key.mjs +1173 -0
  235. package/skills/dknowc-tax-assistant/scripts/run_dir.py +149 -0
  236. package/skills/dknowc-tax-assistant/scripts/source_cards.py +372 -0
  237. package/skills/dknowc-tax-assistant/scripts/tag_catalog.py +164 -0
  238. package/skills/dknowc-tax-assistant/scripts/tax_client.py +218 -0
  239. package/skills/dknowc-tax-assistant/scripts/tax_search.py +403 -0
  240. package/skills/dknowc-tax-assistant/scripts/verify_claims.py +587 -0
  241. package/skills/dknowc-tax-assistant/scripts/websearch_convert.py +352 -0
  242. package/skills/dknowc-trusted-search/README.md +29 -23
  243. package/skills/dknowc-trusted-search/SKILL.md +257 -107
  244. package/skills/dknowc-trusted-search/config/trace_report.config.json +119 -0
  245. package/skills/dknowc-trusted-search/reference/onboarding_scripts.md +40 -15
  246. package/skills/dknowc-trusted-search/reference/sample_trace_report.html +286 -191
  247. package/skills/dknowc-trusted-search/resources/ECHARTS-NOTICE.txt +10 -0
  248. package/skills/dknowc-trusted-search/scripts/api_key.py +10 -26
  249. package/skills/dknowc-trusted-search/scripts/attribution.py +1 -1
  250. package/skills/dknowc-trusted-search/scripts/build_trace_input.py +173 -0
  251. package/skills/dknowc-trusted-search/scripts/deep_convert.py +79 -30
  252. package/skills/dknowc-trusted-search/scripts/deep_query.py +23 -34
  253. package/skills/dknowc-trusted-search/scripts/initialize.py +353 -12
  254. package/skills/dknowc-trusted-search/scripts/mcp_direct.py +3 -2
  255. package/skills/dknowc-trusted-search/scripts/merge_search_results.py +222 -35
  256. package/skills/dknowc-trusted-search/scripts/register_key.mjs +845 -291
  257. package/skills/dknowc-trusted-search/scripts/source_display.py +59 -0
  258. package/skills/dknowc-trusted-search/scripts/trusted_search.py +69 -36
  259. package/skills/dknowc-trusted-search/scripts/update_skill.py +300 -0
  260. package/skills/dknowc-trusted-search/scripts/websearch_convert.py +328 -0
  261. package/src/index.js +15 -0
  262. package/skills/dknowc-official-doc-writer/scripts/mcp_convert.py +0 -287
  263. package/skills/dknowc-official-doc-writer/scripts/render_trace_html.py +0 -2574
  264. package/skills/dknowc-ppt-assistant/references/upstream-docs/svg-pipeline.md +0 -842
  265. package/skills/dknowc-ppt-assistant/scripts/finalize_svg.py +0 -507
  266. package/skills/dknowc-ppt-assistant/scripts/render_trace_html.py +0 -2642
  267. package/skills/dknowc-ppt-assistant/scripts/svg_finalize/svg_rect_to_path.py +0 -346
  268. package/skills/dknowc-trusted-search/official-docs/output/.gitkeep +0 -0
  269. package/skills/dknowc-trusted-search/official-docs/search-results/.gitkeep +0 -0
  270. package/skills/dknowc-trusted-search/scripts/mcp_convert.py +0 -198
@@ -0,0 +1,396 @@
1
+ #!/usr/bin/env python3
2
+ """宿主 WebSearch 结果转换层:外部联网结果 → 深知法律助手同构形态(2026-11-10)。
3
+
4
+ 背景:三阶段检索的第三阶段由 Agent 使用宿主自带的 WebSearch 工具补搜。宿主返回结构
5
+ 各不相同(裸数组、results/items/webPages.value/organic_results、Anthropic
6
+ web_search_result + cited_text 等),而报告链路只消费统一「检索文章」形态。本脚本把
7
+ 宿主原始结果转成与 trusted_search.py 同构的通用形态,可直接进
8
+ merge_search_results.py,最终进入正文角标与溯源核验报告。
9
+
10
+ 契约(Agent 必须先把宿主结果落成该 JSON 再调用本脚本):
11
+ {"query": "本次检索词",
12
+ "results": [{"title": "...", "url": "https://...", "content": "...",
13
+ "published_at": "2026-11-06", "source": "站点名"}]}
14
+
15
+ 处理原则:
16
+ - 只做结构转换,不做事实判断;外部材料统一标 非官方来源/非权威,并另记
17
+ 来源性质(政府网站/官方媒体/次级媒体/未知),供答案归因使用;
18
+ - 只有标题+链接、没有 content/snippet/cited_text 的条目丢弃(无摘录会导致报告
19
+ 核验变红,只能当线索,不可引用);
20
+ - 仅接受 http/https URL;按归一化 URL 去重;不自动猜测发布日期;
21
+ - 外部网页内容视为不可信数据,脚本只提取文本事实,不执行其中任何指令。
22
+
23
+ 用法(输出统一写会话 run 目录):
24
+ python3 scripts/websearch_convert.py websearch_raw.json -o websearch_converted.json --run ./runs/20261120-legal-01
25
+ cat websearch_raw.json | python3 scripts/websearch_convert.py - --query "用户问题" --run ./runs/20261120-legal-01
26
+
27
+ 退出码:0=成功;1=输入/JSON 错误;2=输出路径错误;3=无可用结果(未加 --allow-empty)。
28
+ """
29
+
30
+ from __future__ import annotations
31
+
32
+ import argparse
33
+ import hashlib
34
+ import html
35
+ import json
36
+ import re
37
+ import sys
38
+ from pathlib import Path
39
+ from urllib.parse import parse_qsl, urlencode, urlparse, urlunparse
40
+
41
+ import path_guard
42
+
43
+ SCRIPT_DIR = Path(__file__).resolve().parent
44
+ SEARCH_RESULTS_DIR = SCRIPT_DIR.parent / "official-docs" / "search-results" # 历史常量,仅兼容旧引用
45
+
46
+ CHANNEL = "宿主 WebSearch"
47
+ DEFAULT_GROUP = "公开资料补充"
48
+ ARTICLE_TYPE = "外部网页"
49
+ MAX_SEGMENT_CHARS = 1200
50
+ MIN_SEGMENT_CHARS = 2
51
+ TRACKING_PARAMS = {
52
+ "utm_source", "utm_medium", "utm_campaign", "utm_term", "utm_content",
53
+ "gclid", "fbclid", "spm", "scm", "from", "share_token", "share_source",
54
+ "ref", "ref_src", "source", "campaign",
55
+ }
56
+ BOILERPLATE_PATTERNS = {
57
+ "首页", "登录", "注册", "分享", "打印", "关闭", "返回", "上一篇", "下一篇",
58
+ "相关阅读", "网站地图", "联系我们", "版权所有", "扫码", "扫码关注", "关注我们",
59
+ "客户端", "客户端下载", "更多", "详情", "查看原文",
60
+ }
61
+
62
+ URL_KEYS = ("url", "link", "uri", "sourceUrl", "source_url", "href")
63
+ TITLE_KEYS = ("title", "name", "page_title", "pageTitle")
64
+ CONTENT_KEYS = ("content", "snippet", "summary", "text", "description", "cited_text", "citedText")
65
+ SOURCE_KEYS = ("source", "site_name", "siteName", "publisher", "domain", "display_link", "displayLink")
66
+ DATE_KEYS = ("published_at", "publishedAt", "published", "date", "page_age", "pageAge", "datePublished")
67
+
68
+
69
+ def _first(d: dict, keys) -> str:
70
+ for key in keys:
71
+ value = d.get(key)
72
+ if isinstance(value, str) and value.strip():
73
+ return value.strip()
74
+ return ""
75
+
76
+
77
+ def _norm_url(raw: str) -> str:
78
+ """URL 归一:去 fragment、常见 tracking 参数、尾斜杠;保留业务 query 参数。"""
79
+ text = html.unescape(str(raw or "")).strip()
80
+ if not text:
81
+ return ""
82
+ try:
83
+ parsed = urlparse(text)
84
+ except ValueError:
85
+ return ""
86
+ if parsed.scheme.lower() not in ("http", "https") or not parsed.netloc:
87
+ return ""
88
+ # 拒绝 userinfo(https://user:pass@host/...):凭据不得进入报告或日志
89
+ if parsed.username or parsed.password:
90
+ return ""
91
+ query = [
92
+ (k, v) for k, v in parse_qsl(parsed.query, keep_blank_values=True)
93
+ if k.lower() not in TRACKING_PARAMS
94
+ ]
95
+ path = parsed.path.rstrip("/") or "/"
96
+ return urlunparse((
97
+ parsed.scheme.lower(), parsed.netloc.lower(), path,
98
+ "", urlencode(sorted(query)), "",
99
+ ))
100
+
101
+
102
+ def _hostname(url: str) -> str:
103
+ try:
104
+ return (urlparse(url).hostname or "").lower()
105
+ except ValueError:
106
+ return ""
107
+
108
+
109
+ OFFICIAL_MEDIA_HOSTS = (
110
+ "cctv.com", "cnr.cn", "xinhuanet.com", "news.cn", "people.com.cn",
111
+ "ce.cn", "chinadaily.com.cn", "gmw.cn", "china.com.cn",
112
+ )
113
+
114
+
115
+ def _source_nature(host: str, source: str = "") -> str:
116
+ """来源性质:只用于答案归因,不改变“非官方来源=True”的外部材料标记。"""
117
+ host = (host or "").lower()
118
+ source = source or ""
119
+ if host == "gov.cn" or host.endswith(".gov.cn"):
120
+ return "政府网站"
121
+ if any(host == item or host.endswith("." + item) for item in OFFICIAL_MEDIA_HOSTS):
122
+ return "官方媒体"
123
+ if any(term in source for term in ("人民政府", "人力资源和社会保障", "财政厅", "人社局", "政府办公厅")):
124
+ return "政府网站"
125
+ if any(term in source for term in ("日报", "晚报", "新闻", "财经", "记者", "头条", "公众号", "自媒体", "传媒")):
126
+ return "次级媒体"
127
+ return "未知"
128
+
129
+
130
+ def _clean_text(raw: str) -> str:
131
+ """外部正文轻清洗:去脚本/样式块、标签转行、实体反转义、压缩空白。"""
132
+ text = html.unescape(str(raw or ""))
133
+ text = re.sub(r"<script\b[^>]*>.*?</script>", " ", text, flags=re.S | re.I)
134
+ text = re.sub(r"<style\b[^>]*>.*?</style>", " ", text, flags=re.S | re.I)
135
+ text = re.sub(r"<br\s*/?>", "\n", text, flags=re.I)
136
+ text = re.sub(r"</(?:p|div|li|tr|h[1-6])\s*>", "\n", text, flags=re.I)
137
+ text = re.sub(r"<[^>]+>", " ", text)
138
+ lines = [re.sub(r"[ \t ]+", " ", line).strip() for line in text.splitlines()]
139
+ kept = []
140
+ for line in lines:
141
+ if not line:
142
+ continue
143
+ compact = re.sub(r"\s+", "", line)
144
+ if len(compact) < MIN_SEGMENT_CHARS:
145
+ continue
146
+ # 模板行只按“整行等于导航词”判定,避免「需随船返回」这类正文被“返回”误杀
147
+ if re.sub(r"[\s\-—_|·::,,。.!!??]+", "", line) in BOILERPLATE_PATTERNS:
148
+ continue
149
+ kept.append(line)
150
+ return "\n".join(kept)
151
+
152
+
153
+ def _split_long(text: str, limit: int) -> list:
154
+ """按句末标点把超长块切成 <=limit 的片段;无标点时硬切。"""
155
+ if len(text) <= limit:
156
+ return [text]
157
+ pieces = re.split(r"(?<=[。!?;!?;])", text)
158
+ out, buf = [], ""
159
+ for piece in pieces:
160
+ if not piece:
161
+ continue
162
+ if len(buf) + len(piece) <= limit:
163
+ buf += piece
164
+ continue
165
+ if buf:
166
+ out.append(buf)
167
+ while len(piece) > limit:
168
+ out.append(piece[:limit])
169
+ piece = piece[limit:]
170
+ buf = piece
171
+ if buf:
172
+ out.append(buf)
173
+ return out
174
+
175
+
176
+ _TABLE_BLOCK_RE = re.compile(r"<table\b[^>]*>.*?</table>", re.S | re.I)
177
+ _TABLE_MARK_RE = re.compile(r"^@@TABLE(\d+)@@$")
178
+
179
+
180
+ def _sanitize_table_html(raw: str) -> str:
181
+ """外部网页表格最小清洗:只保留 table/tr/td/th,去属性与其它标签。
182
+
183
+ 表格必须整体保留(2026-11-20 口径):外部网页的表格是参考卡里最容易被
184
+ 截断/拆散的内容,清洗时先摘出来、按整块写回,不能当普通正文行切分。
185
+ """
186
+ value = re.sub(r"<(script|style)\b[^>]*>.*?</\1>", " ", str(raw or ""), flags=re.S | re.I)
187
+ value = re.sub(r"<(?!/?(?:table|tr|td|th)\b)[^>]+>", " ", value, flags=re.I)
188
+ value = re.sub(r"<(?P<tag>table|tr|td|th)\b[^>]*>", r"<\g<tag>>", value, flags=re.I)
189
+ value = re.sub(r"[ \t]{2,}", " ", value)
190
+ return value.strip()
191
+
192
+
193
+ def _segments(content: str, max_chars: int):
194
+ """正文 → 段落列表;返回 (段落, 是否截断)。
195
+
196
+ 表格内容先以占位符摘出,正文清洗后按整块还原:表格不参与按标点切分、
197
+ 不受 1200 字分段上限约束(普通文本摘要仍可截断)。
198
+ """
199
+ raw = str(content or "")
200
+ tables: list[str] = []
201
+
202
+ def _stash(match: re.Match) -> str:
203
+ tables.append(match.group(0))
204
+ return f"\n\n@@TABLE{len(tables) - 1}@@\n\n"
205
+
206
+ stashed = _TABLE_BLOCK_RE.sub(_stash, raw)
207
+ text = _clean_text(stashed)
208
+ if not text:
209
+ return [], False
210
+ truncated = len(text) > max_chars
211
+ text = text[:max_chars]
212
+ blocks = [b.strip() for b in re.split(r"\n\s*\n|\n", text) if b.strip()]
213
+ paragraphs = []
214
+ for block in blocks:
215
+ mark = _TABLE_MARK_RE.match(block)
216
+ if mark:
217
+ table_html = _sanitize_table_html(tables[int(mark.group(1))])
218
+ if table_html:
219
+ paragraphs.append(table_html)
220
+ continue
221
+ # 兜底:清洗后若块内仍带表格 HTML(上游未命中占位),整块保留不切分
222
+ if "<table" in block.lower():
223
+ paragraphs.append(_sanitize_table_html(block))
224
+ continue
225
+ paragraphs.extend(_split_long(block, MAX_SEGMENT_CHARS))
226
+ out = [{"id": i, "标题": "", "内容": p} for i, p in enumerate(paragraphs, 1)]
227
+ return out, truncated
228
+
229
+
230
+ def _iter_dicts(node):
231
+ if isinstance(node, dict):
232
+ yield node
233
+ for value in node.values():
234
+ yield from _iter_dicts(value)
235
+ elif isinstance(node, list):
236
+ for value in node:
237
+ yield from _iter_dicts(value)
238
+
239
+
240
+ def _candidate_url(d: dict) -> str:
241
+ return _norm_url(_first(d, URL_KEYS))
242
+
243
+
244
+ def _collect(payload) -> tuple:
245
+ """递归收集候选结果:按 URL 合并 title/content/source/date。"""
246
+ candidates = {}
247
+ cited = {}
248
+ for d in _iter_dicts(payload):
249
+ url = _candidate_url(d)
250
+ if not url:
251
+ continue
252
+ cited_text = _first(d, ("cited_text", "citedText"))
253
+ if cited_text:
254
+ cited[url] = cited_text
255
+ title = _first(d, TITLE_KEYS)
256
+ content = _first(d, CONTENT_KEYS)
257
+ source = _first(d, SOURCE_KEYS)
258
+ date = _first(d, DATE_KEYS)
259
+ if not (title or content):
260
+ continue
261
+ item = candidates.setdefault(url, {})
262
+ for key, value in (("title", title), ("content", content), ("source", source), ("date", date)):
263
+ if value and not item.get(key):
264
+ item[key] = value
265
+ for url, item in candidates.items():
266
+ if not item.get("content") and cited.get(url):
267
+ item["content"] = cited[url]
268
+ return candidates
269
+
270
+
271
+ def _make_article(url: str, item: dict, group: str, max_chars: int) -> dict:
272
+ content = item.get("content") or ""
273
+ paragraphs, truncated = _segments(content, max_chars)
274
+ host = _hostname(url)
275
+ return {
276
+ "文章Id": "ws-" + hashlib.sha1(url.encode("utf-8")).hexdigest()[:12],
277
+ "文章类型": ARTICLE_TYPE,
278
+ "文件标签": ["外部联网"],
279
+ "文章标题": item.get("title") or host or content[:30],
280
+ "数据源": item.get("source") or host,
281
+ "来源性质": _source_nature(host, item.get("source") or ""),
282
+ "发布日期": item.get("date") or "",
283
+ "发布日期可信度": "未标注",
284
+ "源网址": url,
285
+ "数据权威性": "非权威",
286
+ "非官方来源": True,
287
+ "来源通道": "外部联网",
288
+ "检索通道": CHANNEL,
289
+ "搜索条件": group,
290
+ "段落": paragraphs,
291
+ "_truncated": truncated,
292
+ }
293
+
294
+
295
+ def convert(payload, query: str = "", group: str = DEFAULT_GROUP, max_results: int = 50,
296
+ max_chars: int = 20000) -> dict:
297
+ if isinstance(payload, dict) and not query:
298
+ query = str(payload.get("query") or payload.get("q") or "").strip()
299
+
300
+ candidates = _collect(payload)
301
+ articles = []
302
+ meta = {
303
+ "websearch_converted": True,
304
+ "query": query,
305
+ "group": group,
306
+ "input_candidates": len(candidates),
307
+ "articles": 0,
308
+ "dropped_no_excerpt": 0,
309
+ "truncated_articles": 0,
310
+ "truncated_by_limit": 0,
311
+ }
312
+ for url, item in candidates.items():
313
+ if not item.get("content"):
314
+ meta["dropped_no_excerpt"] += 1
315
+ continue
316
+ if len(articles) >= max_results:
317
+ meta["truncated_by_limit"] = len(candidates) - len(articles) - meta["dropped_no_excerpt"]
318
+ break
319
+ article = _make_article(url, item, group, max_chars)
320
+ if article.pop("_truncated"):
321
+ meta["truncated_articles"] += 1
322
+ articles.append(article)
323
+
324
+ meta["articles"] = len(articles)
325
+ return {
326
+ "search_meta": meta,
327
+ "content": {"data": {"检索文章": articles, "policyFiles": []}},
328
+ }
329
+
330
+
331
+ def resolve_output(name: str) -> Path:
332
+ path = Path(name).expanduser()
333
+ if not path.is_absolute():
334
+ path = (SEARCH_RESULTS_DIR / path.name).resolve()
335
+ try:
336
+ path.relative_to(SEARCH_RESULTS_DIR.resolve())
337
+ except ValueError:
338
+ print(f"错误:输出文件必须位于 {SEARCH_RESULTS_DIR}", file=sys.stderr)
339
+ raise SystemExit(2) from None
340
+ return path
341
+
342
+
343
+ def _load(path: str, run: str | None = None):
344
+ if path == "-":
345
+ raw = sys.stdin.read()
346
+ else:
347
+ # 相对路径按会话 run 目录解析(不再回退 Skill 内 official-docs/)
348
+ try:
349
+ src = path_guard.safe_read_path(path, run)
350
+ except ValueError as exc:
351
+ raise SystemExit(f"错误:{exc}") from None
352
+ raw = src.read_text(encoding="utf-8")
353
+ try:
354
+ return json.loads(raw)
355
+ except json.JSONDecodeError as exc:
356
+ raise SystemExit(f"错误:输入不是有效 JSON({exc})") from None
357
+
358
+
359
+ def main() -> None:
360
+ if hasattr(sys.stdout, "reconfigure"):
361
+ sys.stdout.reconfigure(encoding="utf-8")
362
+ parser = argparse.ArgumentParser(description="宿主 WebSearch 结果转换(外部联网 → 可信同构通用形态)")
363
+ parser.add_argument("input", nargs="?", default="-", help="宿主 WebSearch 原始 JSON(run 目录内文件名、绝对路径,或 - 读 stdin)")
364
+ parser.add_argument("-o", "--output", default="websearch_converted.json", help="输出文件名(落到 --run 目录)")
365
+ parser.add_argument("--run", help="会话 run 目录(也可用环境变量 DKNOWC_RUN_DIR)")
366
+ parser.add_argument("--query", default="", help="本次检索词(输入 JSON 顶层带 query 时可省略)")
367
+ parser.add_argument("--group", default=DEFAULT_GROUP, help=f"报告检索分组标签,默认「{DEFAULT_GROUP}」")
368
+ parser.add_argument("--max-results", type=int, default=50, help="最多转换条数(默认 50)")
369
+ parser.add_argument("--max-chars", type=int, default=20000, help="单条正文最多字符数(默认 20000)")
370
+ parser.add_argument("--allow-empty", action="store_true", help="无可用结果时仍写空产物并以 0 退出")
371
+ args = parser.parse_args()
372
+
373
+ payload = _load(args.input, args.run)
374
+ result = convert(payload, query=args.query, group=args.group,
375
+ max_results=max(1, args.max_results), max_chars=max(200, args.max_chars))
376
+ try:
377
+ out = path_guard.safe_write_path(args.output, args.run)
378
+ path_guard.refuse_existing(out, kind="输出")
379
+ except ValueError as exc:
380
+ print(f"错误:{exc}", file=sys.stderr)
381
+ raise SystemExit(2) from None
382
+ out.write_text(json.dumps(result, ensure_ascii=False, indent=2), encoding="utf-8")
383
+
384
+ meta = result["search_meta"]
385
+ print(f"已转换:{out}")
386
+ print(
387
+ f"输入候选 {meta['input_candidates']} 条 · 输出文章 {meta['articles']} 篇 · "
388
+ f"丢弃无摘录 {meta['dropped_no_excerpt']} 条 · 截断 {meta['truncated_articles']} 篇"
389
+ )
390
+ if not meta["articles"] and not args.allow_empty:
391
+ print("错误:没有可用结果(外部结果需带 content/snippet/cited_text 才能进报告)", file=sys.stderr)
392
+ sys.exit(3)
393
+
394
+
395
+ if __name__ == "__main__":
396
+ main()
@@ -1,6 +1,6 @@
1
1
  # 深知公文写作(dsh 版)
2
2
 
3
- 这是深知公文写作的 SkillHub 分发版本。功能逻辑与主干完整版保持一致,但不内置深知搜索 API Key。API Key 只对需要深知搜索的任务(查政策依据、数据支撑、案例参考、最新政策情况)是前置条件;不涉及搜索的简单通知、改写润色、只生成 Word 等任务可直接使用,不要求配置 Key。需要搜索时,由 Agent 通过 MaaS 注册接口完成手机号注册、验证码确认和 API Key 获取,并写入本机 Key 专用配置文件(`~/.config/dknowc/api_key`)。
3
+ 这是深知公文写作的 dsh 分发版本。功能与该 Skill 完整功能一致,但不内置深知搜索 API Key。API Key 只对需要深知搜索的任务(查政策依据、数据支撑、案例参考、最新政策情况)是前置条件;不涉及搜索的简单通知、改写润色、只生成 Word 等任务可直接使用,不要求配置 Key。需要搜索时,由 Agent 通过 MaaS 注册接口完成手机号注册、验证码确认和 API Key 获取(默认走渠道注册通行码一次请求发码;通道不可用时回落文字题校验,必要时由手机号持有人完成一次页面验证),并写入本机 Key 专用配置文件(`~/.config/dknowc/api_key`)。
4
4
 
5
5
  ## 能力范围
6
6
 
@@ -12,9 +12,9 @@
12
12
  - 文种写法:`reference/genre_writing_notes.md` 按文种补充“怎么写、哪些不要补”,与 `reference/standards/*.md` 的格式标准配合使用。
13
13
  - 质量审查:`reference/review_checklist.md` 定义公文内容、可信溯源、文种专项和 Word 输出检查项。
14
14
  - Word 排版:通过 `scripts/format_document.py` 生成普通格式 `.docx`,支持标准 Markdown 表格和宽表横向页面。
15
- - 产出物 HTML:执行过搜索时,通过 `scripts/source_note_html.py` 和 `scripts/render_trace_html.py` 生成单文件产出物 HTML(顶部切换 **正文(去索引) / 溯源核验报告 / 知识专库** 三页):正文页为干净正式正文(与 Word 正文一致);溯源核验报告页含 **AI 自验收**(过程回顾条)、核验单与带角标的正文(角标为可点击引文胶囊);知识专库页按检索分组展示来源材料;原文链接原样给出、附存档快照兜底。顶栏「导出」可导出正文 Markdown(.md)或 PDF(正文 / 溯源核验报告)。文件名按用户需求(正文标题)生成,形如 `XXX.html`。
15
+ - 产出物 HTML:执行过搜索时,通过 `scripts/source_note_html.py`(装配与渲染入口,渲染内核在插件内兄弟 skill dk-trace-report)生成单文件产出物 HTML(顶部切换 **正文(去索引) / 溯源核验报告 / 知识专库** 三页):正文页为干净正式正文(与 Word 正文一致);溯源核验报告页含 **AI 自验收**(过程回顾条)、核验单与带角标的正文(角标为可点击引文胶囊);知识专库页按检索分组展示来源材料;原文链接原样给出、附存档快照兜底。顶栏「导出」可导出正文 Markdown(.md)或 PDF(正文 / 溯源核验报告)。文件名按用户需求(正文标题)生成,形如 `XXX.html`。
16
16
  - 已有 Word 审查:通过 `scripts/review_document.py` 只读提取已有 `.docx` 的格式信息和待核验事实表述。
17
- - 红头文件:通过 `scripts/template_generator.py` 代码化生成红头和表尾,不依赖 `templates/` 中的 Word 模板。
17
+ - 红头文件:通过 `scripts/template_generator.py` 代码化生成红头和表尾,不依赖 Word 模板。
18
18
  - 个人素材库与写作偏好:`scripts/local_memory.py` 管理本机私有素材库与偏好(不随公开包分发)。
19
19
  - PDF:当前版本不支持自动生成 PDF;用户明确要求 PDF 时,交付 `.docx` 并建议用户使用本机 Word/WPS 另存或导出为 PDF。
20
20
 
@@ -36,7 +36,7 @@ node --version
36
36
 
37
37
  ## 首次启动初始化
38
38
 
39
- 调用本 Skill 后,Agent 应先运行 `python3 <skillDir>/scripts/initialize.py` 检查 Python、`python-docx`、`requests` 等基础运行环境。只要 `ready=true` 即可开始写作。
39
+ 调用本 Skill 后,Agent 应先运行 `python3 {baseDir}/scripts/initialize.py` 检查 Python、`python-docx`、`requests` 等基础运行环境。只要 `ready=true` 即可开始写作。
40
40
 
41
41
  API Key 按需配置:
42
42
 
@@ -47,36 +47,56 @@ API Key 按需配置:
47
47
 
48
48
  只有当前任务需要深知搜索(政策依据、数据支撑、案例参考,或查最新政策、最新情况)时,才需要配置 API Key(当前版本统一走脚本通道;MCP 通道暂未启用)。配置 API Key 后,深知公文写作可调用深知可信搜索,从权威文件库中检索政策依据、权威数据和典型案例,检索结果附原文来源,便于写作时引用和核验。不涉及搜索的写作任务无需配置 Key,可直接使用。引导与注册各环节的固定话术(含报错处理)见 `reference/onboarding_scripts.md`;向用户介绍搜索能力可参考 `reference/search_intro.md`,用户犹豫时可用 `reference/sample_search_result.md` 与 `reference/sample_trace_report.html` 展示效果(示例数据,仅供展示)。
49
49
 
50
- SkillHub 版默认使用:
50
+ dsh 版默认使用:
51
51
 
52
- - 接入点 `type=6`,即深知可信搜索。
53
- - 渠道码 `46A3BA1D-3E1A-4E8C-BD50-A6DCBEE1DB05`(dsh 专属)。
52
+ - 接入点:深知可信搜索(注册接口不传数字 type 参数)。
53
+ - dsh 专属渠道码 `46A3BA1D-3E1A-4E8C-BD50-A6DCBEE1DB05`。
54
54
  - 统一环境变量 `DKNOWC_API_KEY` 保存 API Key,由公文范文大纲接口和深知可信搜索接口共用。
55
55
 
56
- 当任务需要搜索且当前环境变量 `DKNOWC_API_KEY` 未配置时,进入 MaaS 注册。第 1 步,发送短信验证码(只调用一次、不自动重试):
56
+ 当任务需要搜索且当前环境变量 `DKNOWC_API_KEY` 未配置时,进入 MaaS 注册。
57
+
58
+ 第 1 步,申请验证码(只调用一次、不自动重试):
59
+
60
+ ```bash
61
+ node scripts/register.mjs challenge --phone <手机号>
62
+ ```
63
+
64
+ - **默认走固定注册通行码通道**:`challenge` 携带本渠道固定注册通行码直接申请发码,**不需要领题作答**。成功时退出 0、`code="SMS_SENT"`、`flow="key"`,直接等用户提供 6 位验证码;限频返回 `SMS_RATE_LIMIT`(带剩余秒数)、号码被拒返回 `SMS_REQUEST_REJECTED`、结果未确认返回 `RESULT_UNKNOWN`,均按 `user_message` 停点处理。
65
+ - **注册通行码失效或通道不可用**:自动回落原领题流程,输出带 `keyFallback` 原因字段,`flow` 变为 `agent-text` 或 `legacy`,对用户等价。
66
+
67
+ 第 1 步(回落时),领题:
57
68
 
58
69
  ```bash
59
- node <skillDir>/scripts/register.mjs send --phone 13812345678
70
+ node scripts/register.mjs challenge --phone <手机号>
60
71
  ```
61
72
 
62
- 发码有两个分支,都必须支持(注册链路):
73
+ - **退出 0(`status=true`)**:返回 `question.prompt` 与 `answerFormat`,直接计算后进入第 2 步;答题过程不进入对话,返回 `reused=true` 表示沿用本机未过期的同一道题。
74
+ - **再回退兜底**:若官方指引也不可用(平台尚未上线文字题或临时回退),`challenge` 改走原有短信直发分支,退出 0 即 `code="SMS_SENT"`,**不需要调用 `answer`**;退出 2 为人工验证链接。输出 `flow` 字段标明 `key`、`agent-text` 或 `legacy`。
75
+ - **退出 2(`code="HUMAN_REQUIRED"`,短信尚未发送)**:转述 `user_message` 并原样给出脚本返回、经安全校验的验证链接,暂停等待手机号持有人本人完成页面验证并回复短信验证码。完成验证后不得再调 challenge 或 answer;只说"验证好了"时仅追问短信码。链接一次性、约 10 分钟有效。
76
+ - **退出 1(错误)**:按 `user_message` 处理;限频、目标锁定、服务不可用、号码被拒、发送结果未确认等各有停点,不循环重试、不换号、不绕过。
77
+
78
+ 第 2 步(回落时),提交答案并申请发码(答案必须是非负整数,不带单位):
79
+
80
+ ```bash
81
+ node scripts/register.mjs answer --phone <手机号> --answer <整数答案>
82
+ ```
63
83
 
64
- - **退出 0(`status=true`,短信直发)**:转述脚本输出的 `user_message`(含脱敏手机号与"最新一条"提示),暂停并请用户提供收到的 6 位验证码。
65
- - **退出 2(`code="CAPTCHA_REQUIRED"`,短信尚未发送)**:转述 `user_message` 并原样给出脚本返回、经安全校验的验证链接,暂停等待用户在页面完成验证并回复短信验证码。用户在页面完成验证后不得再调 send;只说"验证好了"时仅追问短信码。链接一次性、约 10 分钟有效。(退出 2 也可能是参数错误,需结合 JSON 的 `code` 字段判断。)
66
- - **退出 1(错误)**:按 `user_message` 处理;限频、验证链接过期、供应商失败、发送结果未确认等各有停点,不循环重试。
84
+ - **退出 0(`SMS_SENT`)**:转述 `user_message`(含脱敏手机号与"最新一条"提示),暂停并请用户提供收到的 6 位验证码;不得重复调用。
85
+ - **退出 3(`AGENT_TEXT_RETRY`)**:答错已换新题,JSON 带新的 `question`,重新计算后再次调用,含首次最多 3 次;不得重置 attempt、不得重复领题刷机会。
86
+ - **退出 2 / 4 / 1**:分别对应转人工、发送结果未确认(不自动重发)、失败停点。
67
87
 
68
- 第 2 步,注册并获取 API Key:
88
+ 第 3 步,注册并获取 API Key:
69
89
 
70
90
  ```bash
71
- node <skillDir>/scripts/register.mjs register --phone 13812345678 --vcode 123456 --organ 个人 --name 用户
91
+ node scripts/register.mjs register --phone <手机号> --vcode <验证码> --organ 个人 --name 用户
72
92
  ```
73
93
 
74
- 注册第二步会固定携带 `source="agent"`(注册接口的合同标记,服务端按它放行老用户直接返 Key),并继续使用 SkillHub 渠道码;调用来源统计走 `X-Dknowc-Attribution` 请求头(`agentSource=` 为本 Skill 标识),两者互不影响。手机号已注册时,默认查回该账号已有可用 API Key;手机号未注册时,按 MaaS 注册流程创建账号并获取 API Key;账号已建但密钥仍在准备时返回 `pending=true`(非错误,稍后同参数重试一次)。成功后,脚本会把 API Key 写入本机专用配置文件(`~/.config/dknowc/api_key`),并返回 `user_message`(含注册赠送 10 万积分与实名认证再送 10 万积分告知,Agent 必须转述)。返回的完整 Key 仅供 Agent 当前任务临时注入环境变量使用,不得向用户展示完整 API Key,不得要求用户手动复制 Key。
94
+ 注册第二步会固定携带 `source="agent"`(注册接口的合同标记,服务端按它放行老用户直接返 Key),并使用 dsh 专属渠道码;调用来源统计走 `X-Dknowc-Attribution` 请求头(`agentSource=` 为本 Skill 标识),两者互不影响。手机号已注册时,默认查回该账号已有可用 API Key;手机号未注册时,按 MaaS 注册流程创建账号并获取 API Key;账号已建但密钥仍在准备时返回 `pending=true`(非错误,稍后同参数重试一次)。成功后,脚本会把 API Key 写入本机专用配置文件(`~/.config/dknowc/api_key`),并返回 `user_message`(含注册赠送 10 万积分与实名认证再送 10 万积分告知,Agent 必须转述)。主配置写入失败时,脚本自动改写入兜底凭据文件(`~/.config/dknowc/api_key.fallback`,600 权限),读取链自动兜底;**脚本不返回明文 Key**,按输出的 `envWriteInstruction` 处理,不得向用户展示完整 API Key,不得要求用户手动复制 Key。
75
95
 
76
96
  默认不重新生成 API Key。只有用户明确要求重新生成或新建 Key 时,才追加 `--new-key`:
77
97
 
78
98
  ```bash
79
- node <skillDir>/scripts/register.mjs register --phone 13812345678 --vcode 123456 --organ 个人 --name 用户 --new-key
99
+ node scripts/register.mjs register --phone <手机号> --vcode <验证码> --organ 个人 --name 用户 --new-key
80
100
  ```
81
101
 
82
102
  如自动注册链路失败,可按脚本 `user_message` 降级引导用户访问 MaaS 平台:
@@ -91,7 +111,7 @@ https://platform.dknowc.cn/auth/#/login
91
111
  https://open.dknowc.cn/open-api/maas/dependable/v2/search
92
112
  ```
93
113
 
94
- API Key 只能通过环境变量 `DKNOWC_API_KEY` 注入或本机专用配置文件(`~/.config/dknowc/api_key`)持久化,不得硬编码,不得写入公开包。脚本读取顺序为进程环境变量优先、缺失时自动读取配置文件,历史 `~/.zshrc` 中的 Key 块仅作迁移期兜底,无需重启宿主。
114
+ 用户检索凭证(API Key)只能通过环境变量 `DKNOWC_API_KEY` 注入或本机专用配置文件(`~/.config/dknowc/api_key`)持久化,不得硬编码、不得写入公开包;渠道注册通行码是例外(只用于申请注册验证码、读不到检索数据、按渠道可吊销),见 `scripts/register.mjs`。脚本读取顺序为进程环境变量优先、缺失时自动读取配置文件,历史 `~/.zshrc` 中的 Key 块仅作迁移期兜底,无需重启宿主。
95
115
 
96
116
  ## 交付形态
97
117
 
@@ -104,7 +124,7 @@ API Key 只能通过环境变量 `DKNOWC_API_KEY` 注入或本机专用配置文
104
124
 
105
125
  ## 版本说明
106
126
 
107
- 当前 dsh 版基于 SkillHub 母版 `3.9.2`(版本号 `3.9.2-dsh`)。
127
+ 当前版本 `3.9.10-dsh`:渲染内核抽离到插件内兄弟 skill「溯源核验报告生成器」(dk-trace-report),本包保留业务装配入口;产物落会话工作区 `dknowc-output/<会话ID前8位>/`;注册默认通行码通道。
108
128
 
109
129
  检索通道:统一走脚本通道(`deep_query.py` / `dkag_search.py` / `outline_reference.py`,需 API Key)。当前版本 MCP「深知可信工作台」通道暂未启用。
110
130
 
@@ -113,35 +133,35 @@ API Key 只能通过环境变量 `DKNOWC_API_KEY` 注入或本机专用配置文
113
133
  范文大纲生成:
114
134
 
115
135
  ```bash
116
- python3 <skillDir>/scripts/outline_reference.py "请写一份关于基层治理工作的调研报告,重点包括背景、做法、问题和建议。"
136
+ python3 {baseDir}/scripts/outline_reference.py "请写一份关于基层治理工作的调研报告,重点包括背景、做法、问题和建议。"
117
137
  ```
118
138
 
119
139
  普通 Word 生成:
120
140
 
121
141
  ```bash
122
- python3 <skillDir>/scripts/format_document.py dknowc-output/${DSH_SESSION_ID:0:8}/official-docs/input/示例正文.md --output 示例正文.docx
142
+ python3 {baseDir}/scripts/format_document.py dknowc-output/${DSH_SESSION_ID:0:8}/official-docs/input/示例正文.md --output 示例正文.docx
123
143
  ```
124
144
 
125
145
  红头 Word 生成:
126
146
 
127
147
  ```bash
128
- python3 <skillDir>/scripts/template_generator.py 通知 --input 示例正文.docx --org "XX单位" --doc-number "XX〔2026〕1号" --output 示例正文-红头.docx
148
+ python3 {baseDir}/scripts/template_generator.py 通知 --input 示例正文.docx --org "XX单位" --doc-number "XX〔2026〕1号" --output 示例正文-红头.docx
129
149
  ```
130
150
 
131
151
  搜索结果保存:
132
152
 
133
153
  ```bash
134
- python3 <skillDir>/scripts/dkag_search.py "人才服务政策" --area 某省 --purpose "核查当地人才服务政策依据" --clean --output result_policy.json
154
+ python3 {baseDir}/scripts/dkag_search.py "人才服务政策" --area 某省 --purpose "核查当地人才服务政策依据" --clean --output result_policy.json
135
155
  ```
136
156
 
137
157
  多次搜索合并:
138
158
 
139
159
  ```bash
140
- python3 <skillDir>/scripts/merge_search_results.py result_policy.json result_data.json --output merged.json
160
+ python3 {baseDir}/scripts/merge_search_results.py result_policy.json result_data.json --output merged.json
141
161
  ```
142
162
 
143
163
  溯源核验报告 HTML:
144
164
 
145
165
  ```bash
146
- python3 <skillDir>/scripts/source_note_html.py dknowc-output/${DSH_SESSION_ID:0:8}/official-docs/input/trace-report.json --output trace-report.html
166
+ python3 {baseDir}/scripts/source_note_html.py dknowc-output/${DSH_SESSION_ID:0:8}/official-docs/input/trace-report.json --output trace-report.html
147
167
  ```