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,10 @@
1
+ ECharts 5.6.0
2
+ https://echarts.apache.org
3
+
4
+ ECharts is an Apache Software Foundation project.
5
+ Licensed under the Apache License, Version 2.0:
6
+ http://www.apache.org/licenses/LICENSE-2.0
7
+
8
+ This file (echarts.custom.min.js) is a custom minified build:
9
+ line / bar / pie charts + grid / tooltip / legend / title components, Canvas renderer.
10
+ Modifications: module subsetting and minification for offline single-file embedding.
@@ -5,15 +5,14 @@
5
5
  key 写入,或宿主安全更新后不再加载 shell 导出变量(WorkBuddy 5.5.3 实测持续
6
6
  读不到)。因此 Key 持久化统一落在本机专用配置文件(XDG 规范路径),脚本直读
7
7
  文件,避免误报缺失、触发不必要的手机号验证码引导,也免去"写完 key 必须重启
8
- 宿主"的限制。读取顺序:进程环境变量 → 专用配置文件 → 历史 ~/.zshrc 块
9
- (1.3.5 迁移期兜底,读到即视为已持久化)。key 仅在本机解析并用于调用深知接口,
10
- 不写入任何其他位置,不随公开包分发。
8
+ 宿主"的限制。读取顺序:进程环境变量 → 专用配置文件(两处均无则视为未配置)。
9
+ 不读取、不写入、不改写任何 shell 配置文件(如 ~/.zshrc)。key 仅在本机解析并用于
10
+ 调用深知接口,不写入任何其他位置,不随公开包分发。
11
11
  """
12
12
 
13
13
  from __future__ import annotations
14
14
 
15
15
  import os
16
- import re
17
16
  import sys
18
17
  from pathlib import Path
19
18
 
@@ -31,38 +30,23 @@ def api_key_file_path() -> Path:
31
30
  return base / "dknowc" / KEY_FILE_NAME
32
31
 
33
32
 
34
- def _read_legacy_zshrc() -> str:
35
- """迁移期:从历史 ~/.zshrc 块读取 Key(1.3.5 之前的写入位置)。"""
36
- zshrc = Path.home() / ".zshrc"
37
- try:
38
- text = zshrc.read_text(encoding="utf-8", errors="ignore")
39
- except OSError:
40
- return ""
41
- pattern = re.compile(
42
- r'^\s*export\s+' + re.escape(API_KEY_ENV) + r'\s*=\s*[\'"]?([^\'"\r\n#]+?)[\'"]?\s*$',
43
- re.M,
44
- )
45
- for value in reversed(pattern.findall(text)):
46
- value = value.strip()
47
- if value:
48
- return value
49
- return ""
50
-
51
33
 
52
34
  def resolve_api_key() -> tuple[str, str]:
53
- """返回 (key, source)。source ∈ {'environment', 'keyfile', 'zshrc', ''}(空串表示未找到)。"""
35
+ """返回 (key, source)。source ∈ {'environment', 'keyfile', ''}(空串表示未找到)。"""
54
36
  value = os.environ.get(API_KEY_ENV, "").strip()
55
37
  if value:
56
38
  return value, "environment"
57
39
 
40
+ # dsh:插件 shell-env 注入的 DSH_DKNOWC_API_KEY(与 MCP Bearer 同源;dsh 的安全机制
41
+ # 会清理名字含 KEY 的隐式环境变量,该 DSH_ 前缀变量是官方显式注入通道)。
42
+ value = os.environ.get("DSH_DKNOWC_API_KEY", "").strip()
43
+ if value:
44
+ return value, "environment"
45
+
58
46
  try:
59
47
  value = api_key_file_path().read_text(encoding="utf-8", errors="ignore").strip()
60
48
  except OSError:
61
49
  value = ""
62
50
  if value:
63
51
  return value, "keyfile"
64
-
65
- legacy = _read_legacy_zshrc()
66
- if legacy:
67
- return legacy, "zshrc"
68
52
  return "", ""
@@ -4,7 +4,7 @@
4
4
  依据 MaaS 平台调用来源统计方案(2026-09-14;2026-10-09 头内键名由 source 改为
5
5
  agentSource——平台方改名,区别于注册 body 的 source 合同标记,值不变):
6
6
 
7
- - 声明格式(单行纯 ASCII):`kind=skill;agentSource=dknowc-trusted-search;version=1.4.1;channel=skillhub`
7
+ - 声明格式(单行纯 ASCII):`kind=skill;agentSource=dknowc-trusted-search;version=1.8.2;channel=dsh`
8
8
  - kind/source/channel 读自**包根 `attribution.json`**(json 字段名保持 `source` 不变,仅请求头输出键名为 `agentSource`;渠道差异由打包期改这一个文件表达);
9
9
  - **version 运行时从 SKILL.md frontmatter 解析**(单一事实源,不硬编码);
10
10
  - 声明为调用方自报,**仅用于统计、不参与鉴权、不作安全凭证**;
@@ -0,0 +1,173 @@
1
+ #!/usr/bin/env python3
2
+ """深知可信搜索的通用输入入口(1.8.1):上游统一入口 + 本产品来源展示口径。
3
+
4
+ 在上游 `build_report_input.py`(merged 适配器)之上补充本产品的字段语义:
5
+ - 复用其映射与 `--policy-files` 文号回填;
6
+ - 用 `source_display.source_identity` 计算展示用「发布机构」——
7
+ 清除多机构串中的 `##`、政策缺机构显示“发文机构待补”、非政策缺机构显示
8
+ “公开网站”、站点名不得当发文机构、不从标题推导;
9
+ - 政策类型写入「素材类型」,保持来源卡类型口径(policy → 政策类)。
10
+
11
+ 输出仍是标准通用 JSON,渲染器不需要任何本产品定制。
12
+
13
+ 用法与上游一致:
14
+ python3 build_trace_input.py merged.json --run "$RUN" --output input.json \
15
+ --answer-file answer.txt --question-file question.txt \
16
+ --self-check-file selfcheck.json --policy-files
17
+ """
18
+
19
+ from __future__ import annotations
20
+
21
+ import argparse
22
+ import json
23
+ import sys
24
+ from pathlib import Path
25
+ from typing import Any, Dict, List
26
+
27
+ # dsh:内核抽离到插件内兄弟 skill「溯源核验报告生成器」(dk-trace-report),
28
+ # 此处注入其 scripts 目录到 sys.path;母版同目录形态下目录不存在、行为不变。
29
+ import sys as _sys
30
+ from pathlib import Path as _Path
31
+ _KERNEL_DIR = _Path(__file__).resolve().parent.parent.parent / "dk-trace-report" / "scripts"
32
+ if _KERNEL_DIR.is_dir():
33
+ _sys.path.insert(0, str(_KERNEL_DIR))
34
+
35
+ import build_report_input as base
36
+ from source_display import source_identity
37
+ from run_paths import RunPathError, SKILL_ROOT, is_within, resolve_input_path, resolve_run_dir
38
+
39
+
40
+ def enrich_materials(materials: List[Dict[str, Any]],
41
+ articles: List[Dict[str, Any]]) -> List[Dict[str, Any]]:
42
+ """把接口文章的发文机构展示口径写入通用材料(materials 与 articles 一一对应)。"""
43
+ for material, article in zip(materials, articles):
44
+ agency, _data_source, _issuer, is_policy = source_identity(article)
45
+ if agency:
46
+ material["发布机构"] = agency
47
+ if is_policy:
48
+ material["素材类型"] = "policy"
49
+ # 未引用召回材料的显式标记(接口/merge 自带时透传)
50
+ if article.get("已引用") is False or article.get("used") is False:
51
+ material["已引用"] = False
52
+ return materials
53
+
54
+
55
+ def main() -> int:
56
+ parser = argparse.ArgumentParser(description="深知可信搜索:检索/merge 产物 → 通用 JSON")
57
+ parser.add_argument("source_json", help="检索/merge 产物(content.data.检索文章 或顶层 检索文章)")
58
+ parser.add_argument("--run", help="本次运行的独立目录(相对路径基准;必须在 Skill 目录之外)")
59
+ parser.add_argument("--output", help="输出通用 JSON 文件名;相对名落 --run 目录(默认 input.json)")
60
+ parser.add_argument("--answer-file", help="最终答案文件(.txt/.md,关键结论带 [n] 角标)")
61
+ parser.add_argument("--answer", help="最终答案文本(文件优先)")
62
+ parser.add_argument("--question", help="用户原始问题")
63
+ parser.add_argument("--question-file", help="用户原始问题全文文件")
64
+ parser.add_argument("--self-check-file", help="答案自检结果 JSON")
65
+ parser.add_argument("--verify-file", help="域内核验记录 JSON(原样嵌入)")
66
+ parser.add_argument("--title", help="报告标题;缺省取输入 JSON 的 title 或问题")
67
+ parser.add_argument("--policy-files", action="store_true",
68
+ help="用 policyFiles 的 writtenText 回填空缺发文字号")
69
+ args = parser.parse_args()
70
+
71
+ try:
72
+ run_dir = resolve_run_dir(args.run) if args.run else None
73
+ except RunPathError as exc:
74
+ print(f"错误:{exc}", file=sys.stderr)
75
+ return 2
76
+
77
+ try:
78
+ source_path = resolve_input_path(args.source_json, run_dir, {".json"})
79
+ source = base.load_json_file(source_path)
80
+ except (RunPathError, json.JSONDecodeError, OSError) as exc:
81
+ print(f"错误:输入无法读取({exc})", file=sys.stderr)
82
+ return 2
83
+
84
+ articles = base.find_merged_articles(source)
85
+ if not articles:
86
+ print("错误:未在输入中找到「检索文章」(content.data.检索文章 或顶层 检索文章)。", file=sys.stderr)
87
+ return 2
88
+ materials = [base.map_merged_article(a) for a in articles]
89
+ if args.policy_files:
90
+ filled = base.apply_policy_files(materials, source)
91
+ if filled:
92
+ print(f"policyFiles 文号回填:{filled} 条")
93
+ enrich_materials(materials, articles)
94
+ for idx, material in enumerate(materials):
95
+ if not base.first_str(material.get("编号")):
96
+ material["编号"] = str(idx + 1)
97
+
98
+ source_meta = source if isinstance(source, dict) else {}
99
+ answer = ""
100
+ if args.answer_file:
101
+ try:
102
+ answer = resolve_input_path(args.answer_file, run_dir, {".txt", ".md"}).read_text(encoding="utf-8")
103
+ except (RunPathError, OSError) as exc:
104
+ print(f"错误:答案文件无法读取({exc})", file=sys.stderr)
105
+ return 2
106
+ elif args.answer:
107
+ answer = args.answer
108
+ else:
109
+ answer = base.first_str(source_meta.get("answer"), source_meta.get("答案"))
110
+
111
+ question = ""
112
+ if args.question_file:
113
+ try:
114
+ question = resolve_input_path(args.question_file, run_dir, {".txt", ".md"}).read_text(encoding="utf-8").strip()
115
+ except (RunPathError, OSError) as exc:
116
+ print(f"错误:问题文件无法读取({exc})", file=sys.stderr)
117
+ return 2
118
+ else:
119
+ question = base.first_str(args.question, source_meta.get("question"), source_meta.get("问题"))
120
+
121
+ self_check: Any = None
122
+ if args.self_check_file:
123
+ try:
124
+ self_check = base.load_json_file(resolve_input_path(args.self_check_file, run_dir, {".json"}))
125
+ except (RunPathError, json.JSONDecodeError, OSError) as exc:
126
+ print(f"错误:自检文件无法读取({exc})", file=sys.stderr)
127
+ return 2
128
+ else:
129
+ self_check = (source_meta.get("selfCheck") or source_meta.get("self_check")
130
+ or source_meta.get("agentCheck") or source_meta.get("agent_check"))
131
+
132
+ verify_record: Any = None
133
+ if args.verify_file:
134
+ try:
135
+ verify_record = base.load_json_file(resolve_input_path(args.verify_file, run_dir, {".json"}))
136
+ except (RunPathError, json.JSONDecodeError, OSError) as exc:
137
+ print(f"错误:核验记录无法读取({exc})", file=sys.stderr)
138
+ return 2
139
+
140
+ payload: Dict[str, Any] = {
141
+ "title": base.first_str(args.title, source_meta.get("title")) or question,
142
+ "question": question,
143
+ "answer": answer,
144
+ "materials": materials,
145
+ }
146
+ if isinstance(self_check, dict) and self_check:
147
+ payload["selfCheck"] = self_check
148
+ if isinstance(verify_record, dict) and verify_record:
149
+ payload["verifyRecord"] = verify_record
150
+
151
+ raw_output = Path(args.output or "input.json").expanduser()
152
+ if raw_output.is_absolute():
153
+ output = raw_output.resolve()
154
+ elif run_dir is not None:
155
+ output = (run_dir / raw_output).resolve()
156
+ else:
157
+ print("错误:相对 --output 必须同时用 --run 指定运行目录", file=sys.stderr)
158
+ return 2
159
+ if output.suffix.lower() != ".json":
160
+ output = output.with_suffix(".json")
161
+ if output == SKILL_ROOT or is_within(output, SKILL_ROOT):
162
+ print(f"错误:产物不能写入 Skill 安装目录:{output}", file=sys.stderr)
163
+ return 2
164
+
165
+ output.parent.mkdir(parents=True, exist_ok=True)
166
+ output.write_text(json.dumps(payload, ensure_ascii=False, indent=1), encoding="utf-8")
167
+ print(f"已生成通用 JSON:{output}")
168
+ print(f" 材料 {len(materials)} 条 · 答案 {len(answer)} 字")
169
+ return 0
170
+
171
+
172
+ if __name__ == "__main__":
173
+ raise SystemExit(main())
@@ -24,21 +24,67 @@ import json
24
24
  import sys
25
25
  from pathlib import Path
26
26
 
27
- SCRIPT_DIR = Path(__file__).resolve().parent
28
- # 工作区根:dsh 场景通过环境变量 DKNWOC_WS_ROOT 指向会话工作区,未设置时回退到 cwd
29
- import os as _os
30
- _ws = _os.environ.get("DKNWOC_WS_ROOT")
31
- if not _ws:
32
- # dsh 会话隔离:每会话独立产物目录 <工作区>/dknowc-output/<DSH_SESSION_ID前8位>/,
33
- # 多会话共用同一工作区时互不混杂;非 dsh 环境回退为工作区本身。
34
- _sid = _os.environ.get("DSH_SESSION_ID", "")
35
- _ws = str(Path(_os.getcwd()) / "dknowc-output" / (_sid[:8] if _sid else "_default"))
36
- WS_ROOT = Path(_ws).resolve()
37
- SEARCH_RESULTS_DIR = WS_ROOT / "official-docs" / "search-results"
27
+ from run_paths import RunPathError, resolve_input_path, resolve_output_path, resolve_run_dir
38
28
 
39
29
  DEEP_CHANNEL = "深知深度搜索"
40
30
 
41
31
 
32
+ def _paragraphs(article: dict) -> list:
33
+ """取文章段落文本列表(兼容 段落[].内容 / 内容 / content 等形态)。"""
34
+ paragraphs = article.get("段落") or article.get("paragraphs") or []
35
+ chunks = []
36
+ if isinstance(paragraphs, list):
37
+ for p in paragraphs:
38
+ if isinstance(p, dict):
39
+ chunks.append(str(p.get("内容") or p.get("text") or p.get("content") or ""))
40
+ else:
41
+ chunks.append(str(p or ""))
42
+ if not chunks:
43
+ chunks.append(str(article.get("内容") or article.get("content") or ""))
44
+ return [c for c in chunks if c.strip()]
45
+
46
+
47
+ def _paragraph_text(article: dict) -> str:
48
+ return "\n".join(_paragraphs(article)).strip()
49
+
50
+
51
+ def _is_version_index_text(text: str) -> bool:
52
+ """判断是否为政策库版本索引元数据段(不是法规正文)。
53
+
54
+ 与渲染层 clean_paragraph_noise 的口径一致:段首为“生效时间:”且含“所属地域:”,
55
+ 或仅有“修订说明:……相关文件有下面这些版本”的版本清单。
56
+ """
57
+ value = (text or "").strip()
58
+ if value.startswith("生效时间:") and "所属地域:" in value:
59
+ return True
60
+ if value.startswith("修订说明") and "相关文件有下面这些版本" in value:
61
+ return True
62
+ return False
63
+
64
+
65
+ def _mark_citability(article: dict) -> None:
66
+ """给文章补“可引用”判断(1.7.3)。
67
+
68
+ 政策库对多版本法规常返回 policy 版本索引记录:标题命中,但段落只有
69
+ 生效时间/失效日期/修订说明,没有条文正文。此类记录只能当版本线索,
70
+ 不能作为正文依据;在此显式标记,供 Agent 与渲染层统一识别。
71
+ """
72
+ texts = _paragraphs(article)
73
+ # 逐段判断:只要有一段不是版本索引元数据,就视为有正文(多段材料不能因首段是元数据而误杀)
74
+ substantive = any(not _is_version_index_text(t) for t in texts)
75
+ if substantive:
76
+ article["可引用"] = True
77
+ return
78
+ article["可引用"] = False
79
+ if str(article.get("文章类型") or "").strip() == "policy" or any(
80
+ _is_version_index_text(t) for t in texts):
81
+ article["材料性质"] = "版本索引"
82
+ article["不可引用原因"] = "policy 版本索引记录,仅含生效时间/修订说明,无正文段落"
83
+ else:
84
+ article["材料性质"] = "无正文"
85
+ article["不可引用原因"] = "接口未返回可引用的正文段落"
86
+
87
+
42
88
  def convert(payload: dict) -> dict:
43
89
  """摊平 v3 嵌套结构为通用检索文章列表(附分组与通道标记)。"""
44
90
  data = payload.get("data") if isinstance(payload.get("data"), dict) else {}
@@ -60,12 +106,16 @@ def convert(payload: dict) -> dict:
60
106
  out["搜索条件"] = search_key
61
107
  if not out.get("检索通道"):
62
108
  out["检索通道"] = DEEP_CHANNEL
109
+ _mark_citability(out)
63
110
  articles.append(out)
64
111
 
65
112
  for search in searches:
66
- areas = "、".join(str(a) for a in (search.get("areas") or []))
113
+ area_list = [str(a).strip() for a in (search.get("areas") or []) if str(a).strip()]
114
+ areas = "、".join(area_list)
67
115
  query = str(search.get("query") or "").strip()
68
- label = f"{areas}·{query[:14]}" if areas else query[:18]
116
+ # 地域已写进 query 时不再重复前缀(原会显示成"成都·成都 人才落户…")
117
+ area_in_query = bool(area_list) and all(a in query for a in area_list)
118
+ label = f"{areas}·{query[:14]}" if areas and not area_in_query else query[:18]
69
119
  for article in search.get("result") or []:
70
120
  _add(article, label)
71
121
  for article in data.get("common_articles") or []:
@@ -83,36 +133,35 @@ def convert(payload: dict) -> dict:
83
133
  }
84
134
 
85
135
 
86
- def resolve_output(name: str) -> Path:
87
- path = Path(name).expanduser()
88
- if not path.is_absolute():
89
- path = (SEARCH_RESULTS_DIR / path.name).resolve()
90
- try:
91
- path.relative_to(SEARCH_RESULTS_DIR.resolve())
92
- except ValueError:
93
- raise SystemExit(f"错误:输出文件必须位于 {SEARCH_RESULTS_DIR}") from None
94
- return path
136
+ def resolve_output(name: str, run_dir: Path | None) -> Path:
137
+ if not Path(name).expanduser().is_absolute() and run_dir is None:
138
+ raise RunPathError("相对 -o/--output 必须同时用 --run 指定运行目录")
139
+ return resolve_output_path(name, run_dir, {".json"}, ".json", "deep_converted.json")
95
140
 
96
141
 
97
142
  def main() -> None:
98
143
  if hasattr(sys.stdout, "reconfigure"):
99
144
  sys.stdout.reconfigure(encoding="utf-8")
100
145
  parser = argparse.ArgumentParser(description="深度搜索产物转换(v3 原始 → 可信同构通用形态)")
101
- parser.add_argument("input", help="deep_query.py --json-only 的落盘 JSON(official-docs/search-results/ 内文件名或绝对路径)")
102
- parser.add_argument("-o", "--output", default="deep_converted.json", help="输出文件名(official-docs/search-results/ 内),默认 deep_converted.json")
146
+ parser.add_argument("input", help="deep_query.py --json-only 的落盘 JSON(run 目录内文件名或绝对路径)")
147
+ parser.add_argument("--run", help="本次运行的独立目录(必须在 Skill 安装目录之外)")
148
+ parser.add_argument("-o", "--output", default="deep_converted.json", help="输出文件名;相对名落在 --run 目录")
103
149
  args = parser.parse_args()
104
150
 
105
- src = Path(args.input).expanduser()
106
- if not src.is_absolute():
107
- src = (SEARCH_RESULTS_DIR / src.name).resolve()
108
- if not src.is_file():
109
- raise SystemExit(f"错误:输入文件不存在: {src}")
151
+ try:
152
+ run_dir = resolve_run_dir(args.run) if args.run else None
153
+ src = resolve_input_path(args.input, run_dir, {".json"})
154
+ except RunPathError as exc:
155
+ raise SystemExit(f"错误:{exc}") from None
110
156
  payload = json.loads(src.read_text(encoding="utf-8"))
111
157
  if not (isinstance(payload.get("data"), dict) and isinstance(payload["data"].get("searches"), list)):
112
158
  raise SystemExit("错误:输入不是深度搜索 v3 原始产物(缺 data.searches)——若已是通用形态无需转换,直接进 merge。")
113
159
 
114
160
  result = convert(payload)
115
- out = resolve_output(args.output)
161
+ try:
162
+ out = resolve_output(args.output, run_dir)
163
+ except RunPathError as exc:
164
+ raise SystemExit(f"错误:{exc}") from None
116
165
  out.parent.mkdir(parents=True, exist_ok=True)
117
166
  out.write_text(json.dumps(result, ensure_ascii=False, indent=2), encoding="utf-8")
118
167
  meta = result["search_meta"]
@@ -18,20 +18,11 @@ import urllib.error
18
18
  import urllib.request
19
19
  from pathlib import Path
20
20
  from typing import Any, Dict, List, Optional
21
+ from source_display import source_identity
22
+ from run_paths import RunPathError, resolve_output_path, resolve_run_dir
21
23
 
22
24
 
23
25
  DEFAULT_ENDPOINT = "https://open.dknowc.cn/api/services/deep-query/v3"
24
- SKILL_ROOT = Path(__file__).resolve().parent.parent
25
- # 工作区根:dsh 场景通过环境变量 DKNWOC_WS_ROOT 指向会话工作区,未设置时回退到 cwd
26
- import os as _os
27
- _ws = _os.environ.get("DKNWOC_WS_ROOT")
28
- if not _ws:
29
- # dsh 会话隔离:每会话独立产物目录 <工作区>/dknowc-output/<DSH_SESSION_ID前8位>/,
30
- # 多会话共用同一工作区时互不混杂;非 dsh 环境回退为工作区本身。
31
- _sid = _os.environ.get("DSH_SESSION_ID", "")
32
- _ws = str(Path(_os.getcwd()) / "dknowc-output" / (_sid[:8] if _sid else "_default"))
33
- WS_ROOT = Path(_ws).resolve()
34
- SEARCH_RESULTS_DIR = WS_ROOT / "official-docs" / "search-results"
35
26
 
36
27
  # 余额/额度用尽的判定:HTTP 状态与业务错误消息双路径。
37
28
  # 命中后返回 quota_exhausted=true,Agent 必须停止重试并引导用户到 MaaS 处理,不得反复调用。
@@ -90,23 +81,11 @@ def _fail_request(stage: str, reason: str, status_code=None, errmsg=None):
90
81
 
91
82
 
92
83
 
93
- def resolve_output_json(output_path: str) -> Path:
94
- """把深度搜索结果 JSON 落到 official-docs/search-results/,阻断路径遍历。"""
95
- raw_path = Path(output_path).expanduser()
96
- if raw_path.is_absolute():
97
- resolved = raw_path.resolve()
98
- elif raw_path.parent == Path("."):
99
- resolved = (SEARCH_RESULTS_DIR / raw_path.name).resolve()
100
- else:
101
- resolved = raw_path.resolve()
102
-
103
- if resolved.suffix.lower() != ".json":
104
- resolved = resolved.with_suffix(".json")
105
- try:
106
- resolved.relative_to(SEARCH_RESULTS_DIR.resolve())
107
- except ValueError:
108
- raise ValueError(f"输出文件必须位于 official-docs/search-results/ 内: {output_path}")
109
- return resolved
84
+ def resolve_output_json(output_path: str, run_dir: Optional[Path] = None) -> Path:
85
+ """深度搜索结果只写会话工作区的 run 目录;拒绝写回 Skill 安装目录。"""
86
+ if not Path(output_path).expanduser().is_absolute() and run_dir is None:
87
+ raise RunPathError("相对 --output 必须同时用 --run 指定运行目录")
88
+ return resolve_output_path(output_path, run_dir, {".json"}, ".json", "deep_query.json")
110
89
 
111
90
 
112
91
  def _pick(*values: Optional[str]) -> str:
@@ -265,7 +244,7 @@ def _print_summary(body: Dict[str, Any], show_materials: int) -> None:
265
244
  print(f"\n重点材料(前 {min(show_materials, len(articles))} 篇)")
266
245
  for idx, item in enumerate(articles[:show_materials], start=1):
267
246
  title = item.get("文章标题") or "未命名材料"
268
- agency = item.get("数据源") or ""
247
+ agency, _, _, _ = source_identity(item)
269
248
  date = item.get("发布日期") or ""
270
249
  area = item.get("办理地域") or ""
271
250
  url = item.get("源网址") or ""
@@ -290,13 +269,20 @@ def main() -> None:
290
269
  parser.add_argument("--show-payload", action="store_true", help="打印请求参数")
291
270
  parser.add_argument("--dry-run", action="store_true", help="只打印请求参数,不发起请求")
292
271
  parser.add_argument("--json-only", action="store_true", help="仅输出接口原始 JSON")
293
- parser.add_argument("--output", "-o", help="深度搜索结果 JSON 文件名,写入 official-docs/search-results/(配合 --json-only 使用)")
272
+ parser.add_argument("--run", help="本次运行的独立目录(必须在 Skill 安装目录之外;重复运行自动另建)")
273
+ parser.add_argument("--output", "-o", help="深度搜索结果 JSON 文件名;相对名落在 --run 目录,配合 --json-only 使用")
294
274
  parser.add_argument("--show-materials", type=int, default=5, help="摘要中展示前 N 篇材料")
295
275
  # 默认 600s(2026-10-20 同号修正):深度链路网关超时已由 60s 放宽至 10 分钟(2026-09-24 群内
296
276
  # 调整;实测单地域 63–101s、重题可达 3–10 分钟),默认 300s 有重题被客户端提前掐断的风险。
297
277
  parser.add_argument("--timeout", type=int, default=600, help="请求超时秒数(默认 600,与链路 10 分钟上限对齐)")
298
278
  args = parser.parse_args()
299
279
 
280
+ try:
281
+ run_dir = resolve_run_dir(args.run) if args.run else None
282
+ except RunPathError as exc:
283
+ print(f"错误:{exc}", file=sys.stderr)
284
+ sys.exit(2)
285
+
300
286
  endpoint = _pick(
301
287
  args.endpoint,
302
288
  os.environ.get("DKNOWC_KNOW_DEEP_QUERY_ENDPOINT"),
@@ -307,7 +293,7 @@ def main() -> None:
307
293
  os.environ.get("DKNOWC_API_KEY"),
308
294
  )
309
295
  if not api_key:
310
- # 宿主进程读不到 shell 环境变量时,从专用配置文件兜底解析已持久化的 Key(历史 zshrc 兜底)
296
+ # 宿主进程读不到 shell 环境变量时,从专用配置文件兜底解析已持久化的 Key
311
297
  try:
312
298
  from api_key import resolve_api_key
313
299
  api_key, _source = resolve_api_key()
@@ -341,11 +327,14 @@ def main() -> None:
341
327
  _a["检索通道"] = "深知深度搜索"
342
328
  raw_json = json.dumps(body, ensure_ascii=False, indent=2)
343
329
  if args.output:
344
- output_path = resolve_output_json(args.output)
330
+ try:
331
+ output_path = resolve_output_json(args.output, run_dir)
332
+ except RunPathError as exc:
333
+ print(f"错误:{exc}", file=sys.stderr)
334
+ sys.exit(2)
345
335
  output_path.parent.mkdir(parents=True, exist_ok=True)
346
336
  output_path.write_text(raw_json, encoding="utf-8")
347
- # 绝对路径输出(2026-09-28 修复):同 trusted_search.py,避免 Agent 到 cwd 找不到而全盘 find
348
- print(f"已保存深度搜索结果 JSON(位于 skill 工作区,绝对路径):{output_path}")
337
+ print(f"已保存深度搜索结果 JSON(会话运行目录,绝对路径):{output_path}")
349
338
  else:
350
339
  print(raw_json)
351
340
  return