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.
- package/README.md +14 -50
- package/package.json +2 -2
- package/skills/dk-trace-report/SKILL.md +288 -0
- package/skills/dk-trace-report/config/examples/doc.json +56 -0
- package/skills/dk-trace-report/config/examples/legal.json +51 -0
- package/skills/dk-trace-report/config/examples/ppt.json +47 -0
- package/skills/dk-trace-report/config/examples/tax.json +46 -0
- package/skills/dk-trace-report/config/examples/trusted.json +122 -0
- package/skills/dk-trace-report/reference/sample_input.json +60 -0
- package/skills/dk-trace-report/resources/ECHARTS-NOTICE.txt +10 -0
- package/skills/dk-trace-report/resources/echarts.custom.min.js +48 -0
- package/skills/dk-trace-report/scripts/build_report_input.py +333 -0
- package/skills/{dknowc-trusted-search → dk-trace-report}/scripts/chart_embed.py +4 -1
- package/skills/{dknowc-trusted-search → dk-trace-report}/scripts/render_trace_html.py +1072 -537
- package/skills/dk-trace-report/scripts/run_paths.py +95 -0
- package/skills/dk-trace-report/scripts/trust_digest.py +77 -0
- package/skills/dknowc-legal-assistant/README.md +95 -0
- package/skills/dknowc-legal-assistant/SKILL.md +122 -0
- package/skills/dknowc-legal-assistant/attribution.json +5 -0
- package/skills/dknowc-legal-assistant/reference/answer-and-report.md +221 -0
- package/skills/dknowc-legal-assistant/reference/capability-layer.md +143 -0
- package/skills/dknowc-legal-assistant/reference/legal_claims.example.json +96 -0
- package/skills/dknowc-legal-assistant/reference/onboarding_scripts.md +198 -0
- package/skills/dknowc-legal-assistant/reference/policy_tags.json +2002 -0
- package/skills/dknowc-legal-assistant/reference/retrieval-statute.md +81 -0
- package/skills/dknowc-legal-assistant/reference/retrieval-v2.md +133 -0
- package/skills/dknowc-legal-assistant/reference/sample_search_result.md +33 -0
- package/skills/dknowc-legal-assistant/reference/sample_trace_report.html +940 -0
- package/skills/dknowc-legal-assistant/reference/tags.md +53 -0
- package/skills/dknowc-legal-assistant/reference/troubleshooting.md +50 -0
- package/skills/dknowc-legal-assistant/reference/verification-pass.md +59 -0
- package/skills/dknowc-legal-assistant/resources/echarts.custom.min.js +48 -0
- package/skills/dknowc-legal-assistant/scripts/api_key.py +68 -0
- package/skills/dknowc-legal-assistant/scripts/attribution.py +61 -0
- package/skills/dknowc-legal-assistant/scripts/calc_legal.py +375 -0
- package/skills/dknowc-legal-assistant/scripts/calc_period.py +155 -0
- package/skills/dknowc-legal-assistant/scripts/check_answer.py +664 -0
- package/skills/dknowc-legal-assistant/scripts/initialize.py +188 -0
- package/skills/dknowc-legal-assistant/scripts/legal_client.py +208 -0
- package/skills/dknowc-legal-assistant/scripts/legal_search.py +1059 -0
- package/skills/dknowc-legal-assistant/scripts/merge_search_results.py +630 -0
- package/skills/dknowc-legal-assistant/scripts/path_guard.py +92 -0
- package/skills/dknowc-legal-assistant/scripts/question_profile.py +215 -0
- package/skills/dknowc-legal-assistant/scripts/register_key.mjs +1152 -0
- package/skills/dknowc-legal-assistant/scripts/run_eval.py +109 -0
- package/skills/dknowc-legal-assistant/scripts/source_cards.py +321 -0
- package/skills/dknowc-legal-assistant/scripts/tag_catalog.py +162 -0
- package/skills/dknowc-legal-assistant/scripts/trace_report.config.json +66 -0
- package/skills/dknowc-legal-assistant/scripts/verify_claims.py +448 -0
- package/skills/dknowc-legal-assistant/scripts/websearch_convert.py +396 -0
- package/skills/dknowc-official-doc-writer/README.md +45 -25
- package/skills/dknowc-official-doc-writer/SKILL.md +28 -14
- package/skills/dknowc-official-doc-writer/config/trace_report.config.json +56 -0
- 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
- package/skills/dknowc-official-doc-writer/official-docs/search-results/baseline_1555.json +345 -0
- package/skills/dknowc-official-doc-writer/official-docs/search-results/baseline_my.json +728 -0
- package/skills/dknowc-official-doc-writer/official-docs/search-results/baseline_wp.json +159 -0
- package/skills/dknowc-official-doc-writer/official-docs/search-results/baseline_wp2.json +1006 -0
- package/skills/dknowc-official-doc-writer/official-docs/search-results/test_tz.json +28 -0
- package/skills/dknowc-official-doc-writer/official-docs/search-results/tmp_q.json +1419 -0
- package/skills/dknowc-official-doc-writer/reference/anti_ai_patterns.md +13 -1
- package/skills/dknowc-official-doc-writer/reference/fact_discipline.md +4 -0
- package/skills/dknowc-official-doc-writer/reference/genre_writing_notes.md +4 -0
- package/skills/dknowc-official-doc-writer/reference/initialization.md +28 -20
- package/skills/dknowc-official-doc-writer/reference/material_usage_guidance.md +21 -0
- package/skills/dknowc-official-doc-writer/reference/materials_pipeline.md +64 -7
- package/skills/dknowc-official-doc-writer/reference/onboarding_scripts.md +43 -32
- package/skills/dknowc-official-doc-writer/reference/outline_rules.md +1 -1
- package/skills/dknowc-official-doc-writer/reference/output_guide.md +19 -20
- package/skills/dknowc-official-doc-writer/reference/research_notes.md +5 -3
- package/skills/dknowc-official-doc-writer/reference/review_checklist.md +6 -2
- package/skills/dknowc-official-doc-writer/reference/revision_workflow.md +2 -2
- package/skills/dknowc-official-doc-writer/reference/search_guide.md +45 -33
- package/skills/dknowc-official-doc-writer/reference/search_intro.md +4 -4
- package/skills/dknowc-official-doc-writer/reference/search_policy.md +63 -36
- package/skills/dknowc-official-doc-writer/reference/standards/00_index.md +63 -77
- package/skills/dknowc-official-doc-writer/reference/standards/01_report.md +3 -3
- package/skills/dknowc-official-doc-writer/reference/standards/02_qingshi.md +6 -3
- package/skills/dknowc-official-doc-writer/reference/standards/03_pifu.md +2 -2
- package/skills/dknowc-official-doc-writer/reference/standards/04_tongzhi.md +12 -3
- package/skills/dknowc-official-doc-writer/reference/standards/05_yijian.md +8 -2
- package/skills/dknowc-official-doc-writer/reference/standards/06_han.md +2 -2
- package/skills/dknowc-official-doc-writer/reference/standards/08_tongbao.md +2 -2
- package/skills/dknowc-official-doc-writer/reference/standards/09_tonggao.md +2 -2
- package/skills/dknowc-official-doc-writer/reference/standards/10_gonggao.md +2 -2
- package/skills/dknowc-official-doc-writer/reference/standards/11_fuhan_approve.md +2 -2
- package/skills/dknowc-official-doc-writer/reference/standards/12_fuhan_objection.md +2 -2
- package/skills/dknowc-official-doc-writer/reference/standards/13_reminder.md +3 -3
- package/skills/dknowc-official-doc-writer/reference/standards/14_generic.md +1 -1
- package/skills/dknowc-official-doc-writer/reference/standards/16_decision.md +2 -2
- package/skills/dknowc-official-doc-writer/reference/standards/18_order.md +1 -1
- package/skills/dknowc-official-doc-writer/reference/standards/19_gazette.md +1 -1
- package/skills/dknowc-official-doc-writer/reference/standards/20_motion.md +2 -2
- package/skills/dknowc-official-doc-writer/reference/standards/22_application.md +2 -2
- package/skills/dknowc-official-doc-writer/reference/standards/23_publicity.md +1 -1
- package/skills/dknowc-official-doc-writer/reference/standards/25_plan.md +2 -1
- package/skills/dknowc-official-doc-writer/reference/standards/26_summary.md +7 -1
- package/skills/dknowc-official-doc-writer/reference/standards/27_speech.md +4 -1
- package/skills/dknowc-official-doc-writer/reference/standards/99_expressions.md +1 -2
- package/skills/dknowc-official-doc-writer/reference/task_router.md +5 -5
- package/skills/dknowc-official-doc-writer/reference/working_principles.md +4 -4
- package/skills/dknowc-official-doc-writer/reference/writing_method.md +166 -0
- package/skills/dknowc-official-doc-writer/reference/writing_rules.md +11 -5
- package/skills/dknowc-official-doc-writer/scripts/api_key.py +30 -3
- package/skills/dknowc-official-doc-writer/scripts/attribution.py +1 -1
- package/skills/dknowc-official-doc-writer/scripts/build_trace_json.py +216 -22
- package/skills/dknowc-official-doc-writer/scripts/check_materials.py +375 -27
- package/skills/dknowc-official-doc-writer/scripts/deep_convert.py +9 -4
- package/skills/dknowc-official-doc-writer/scripts/deep_query.py +3 -2
- package/skills/dknowc-official-doc-writer/scripts/dkag_search.py +23 -9
- package/skills/dknowc-official-doc-writer/scripts/extract_reference.py +2 -1
- package/skills/dknowc-official-doc-writer/scripts/format_document.py +116 -41
- package/skills/dknowc-official-doc-writer/scripts/initialize.py +246 -12
- package/skills/dknowc-official-doc-writer/scripts/local_memory.py +2 -6
- package/skills/dknowc-official-doc-writer/scripts/mcp_direct.py +2 -3
- package/skills/dknowc-official-doc-writer/scripts/merge_search_results.py +113 -13
- package/skills/dknowc-official-doc-writer/scripts/outline_reference.py +3 -2
- package/skills/dknowc-official-doc-writer/scripts/prose_lint.py +7 -2
- package/skills/dknowc-official-doc-writer/scripts/register.mjs +782 -216
- package/skills/dknowc-official-doc-writer/scripts/review_document.py +2 -1
- package/skills/dknowc-official-doc-writer/scripts/source_note_html.py +120 -13
- package/skills/dknowc-official-doc-writer/scripts/template_generator.py +2 -1
- package/skills/dknowc-official-doc-writer/scripts/update_skill.py +339 -0
- package/skills/dknowc-official-doc-writer/scripts/websearch_convert.py +326 -0
- package/skills/dknowc-ppt-assistant/README.md +21 -9
- package/skills/dknowc-ppt-assistant/SKILL.md +29 -20
- package/skills/dknowc-ppt-assistant/THIRD_PARTY_NOTICES.md +3 -2
- package/skills/dknowc-ppt-assistant/config/trace_report.config.json +65 -0
- package/skills/dknowc-ppt-assistant/references/initialization.md +58 -7
- package/skills/dknowc-ppt-assistant/references/material_usage.md +51 -14
- package/skills/dknowc-ppt-assistant/references/onboarding_scripts.md +51 -18
- package/skills/dknowc-ppt-assistant/references/sample_trace_report.html +372 -920
- package/skills/dknowc-ppt-assistant/references/search_intro.md +2 -2
- package/skills/dknowc-ppt-assistant/references/svg-authoring.md +3 -3
- package/skills/dknowc-ppt-assistant/references/upstream-example/README.md +2 -0
- package/skills/dknowc-ppt-assistant/scripts/api_key.py +11 -27
- package/skills/dknowc-ppt-assistant/scripts/attribution.py +2 -2
- package/skills/dknowc-ppt-assistant/scripts/build_trace_input.py +188 -0
- package/skills/dknowc-ppt-assistant/scripts/compact_svg_coordinates.py +1 -1
- package/skills/dknowc-ppt-assistant/scripts/config.py +9 -9
- package/skills/dknowc-ppt-assistant/scripts/console_encoding.py +1 -2
- package/skills/dknowc-ppt-assistant/scripts/error_helper.py +3 -3
- package/skills/dknowc-ppt-assistant/scripts/hyperlink_contract.py +1 -1
- package/skills/dknowc-ppt-assistant/scripts/initialize.py +248 -15
- package/skills/dknowc-ppt-assistant/scripts/language_tags.py +1 -1
- package/skills/dknowc-ppt-assistant/scripts/mcp_convert.py +7 -14
- package/skills/dknowc-ppt-assistant/scripts/mcp_direct.py +3 -2
- package/skills/dknowc-ppt-assistant/scripts/merge_search_results.py +604 -0
- package/skills/dknowc-ppt-assistant/scripts/native_payloads.py +1 -1
- package/skills/dknowc-ppt-assistant/scripts/pptx_animations.py +1 -1
- package/skills/dknowc-ppt-assistant/scripts/pptx_shapes/__init__.py +1 -1
- package/skills/dknowc-ppt-assistant/scripts/pptx_shapes/errors.py +1 -1
- package/skills/dknowc-ppt-assistant/scripts/pptx_shapes/formula.py +1 -1
- package/skills/dknowc-ppt-assistant/scripts/pptx_shapes/loader.py +1 -1
- package/skills/dknowc-ppt-assistant/scripts/pptx_shapes/models.py +1 -1
- package/skills/dknowc-ppt-assistant/scripts/pptx_shapes/registry.py +2 -2
- package/skills/dknowc-ppt-assistant/scripts/pptx_shapes/semantic_hash.py +1 -1
- package/skills/dknowc-ppt-assistant/scripts/pptx_shapes/semantics.py +3 -3
- package/skills/dknowc-ppt-assistant/scripts/pptx_to_svg/animation_import.py +1 -1
- package/skills/dknowc-ppt-assistant/scripts/pptx_to_svg/formula_import.py +1 -1
- package/skills/dknowc-ppt-assistant/scripts/pptx_to_svg/hyperlinks.py +2 -2
- package/skills/dknowc-ppt-assistant/scripts/pptx_to_svg/preset_authoring.py +2 -2
- package/skills/dknowc-ppt-assistant/scripts/pptx_to_svg/preset_registry_to_svg.py +2 -2
- package/skills/dknowc-ppt-assistant/scripts/pptx_to_svg/preset_svg_markup.py +2 -2
- package/skills/dknowc-ppt-assistant/scripts/pptx_to_svg/slide_to_svg.py +1 -1
- package/skills/dknowc-ppt-assistant/scripts/pptx_to_svg/transition_import.py +1 -1
- package/skills/dknowc-ppt-assistant/scripts/pptx_transitions.py +2 -2
- package/skills/dknowc-ppt-assistant/scripts/preset_shape_svg.py +2 -2
- package/skills/dknowc-ppt-assistant/scripts/preview_slide_html.py +4 -11
- package/skills/dknowc-ppt-assistant/scripts/project_utils.py +2 -2
- package/skills/dknowc-ppt-assistant/scripts/register_key.mjs +890 -341
- package/skills/dknowc-ppt-assistant/scripts/resource_paths.py +1 -1
- package/skills/dknowc-ppt-assistant/scripts/shape_boolean_svg.py +2 -2
- package/skills/dknowc-ppt-assistant/scripts/slide_roster.py +1 -1
- package/skills/dknowc-ppt-assistant/scripts/svg_finalize/__init__.py +2 -9
- package/skills/dknowc-ppt-assistant/scripts/svg_finalize/align_embed_images.py +1 -1
- package/skills/dknowc-ppt-assistant/scripts/svg_finalize/crop_images.py +3 -3
- package/skills/dknowc-ppt-assistant/scripts/svg_quality/__init__.py +2 -2
- package/skills/dknowc-ppt-assistant/scripts/svg_quality/checker.py +9 -10
- package/skills/dknowc-ppt-assistant/scripts/svg_quality/cli.py +4 -4
- package/skills/dknowc-ppt-assistant/scripts/svg_quality/svg_contracts.py +2 -2
- package/skills/dknowc-ppt-assistant/scripts/svg_quality/xml_support.py +1 -1
- package/skills/dknowc-ppt-assistant/scripts/svg_quality_checker.py +1 -1
- package/skills/dknowc-ppt-assistant/scripts/svg_to_pptx/drawingml/hyperlinks.py +2 -2
- package/skills/dknowc-ppt-assistant/scripts/svg_to_pptx/drawingml/theme_colors.py +1 -1
- package/skills/dknowc-ppt-assistant/scripts/svg_to_pptx/drawingml/theme_fonts.py +1 -1
- package/skills/dknowc-ppt-assistant/scripts/svg_to_pptx/geometry_properties.py +1 -1
- package/skills/dknowc-ppt-assistant/scripts/svg_to_pptx/native_objects/formula.py +2 -2
- package/skills/dknowc-ppt-assistant/scripts/svg_to_pptx/native_objects/formula_ast.py +1 -1
- package/skills/dknowc-ppt-assistant/scripts/svg_to_pptx/native_objects/formula_compiler.py +2 -2
- package/skills/dknowc-ppt-assistant/scripts/svg_to_pptx/native_objects/formula_omml.py +2 -2
- package/skills/dknowc-ppt-assistant/scripts/svg_to_pptx/native_objects/formula_parser.py +2 -2
- package/skills/dknowc-ppt-assistant/scripts/svg_to_pptx/native_objects/formula_profile.py +1 -1
- package/skills/dknowc-ppt-assistant/scripts/svg_to_pptx/native_objects/formula_run_properties.py +1 -1
- package/skills/dknowc-ppt-assistant/scripts/svg_to_pptx/native_objects/inline_formula.py +2 -2
- package/skills/dknowc-ppt-assistant/scripts/svg_to_pptx/pptx_package/builder.py +9 -11
- package/skills/dknowc-ppt-assistant/scripts/svg_to_pptx/pptx_package/cli.py +7 -5
- package/skills/dknowc-ppt-assistant/scripts/svg_to_pptx/pptx_package/template_structure.py +1 -1
- package/skills/dknowc-ppt-assistant/scripts/svg_to_pptx/pptx_package/template_validation.py +1 -1
- package/skills/dknowc-ppt-assistant/scripts/svg_to_pptx/semantic_markers.py +1 -1
- package/skills/dknowc-ppt-assistant/scripts/svg_to_pptx/shape_boolean.py +2 -2
- package/skills/dknowc-ppt-assistant/scripts/svg_to_pptx/text_outline.py +2 -2
- package/skills/dknowc-ppt-assistant/scripts/svg_to_pptx.py +1 -1
- package/skills/dknowc-ppt-assistant/scripts/trusted_search.py +51 -17
- package/skills/dknowc-ppt-assistant/scripts/update_skill.py +314 -0
- package/skills/dknowc-ppt-assistant/scripts/update_spec.py +25 -1
- package/skills/dknowc-ppt-assistant/scripts/websearch_convert.py +326 -0
- package/skills/dknowc-ppt-assistant/workflows/generate-pptx.md +99 -34
- package/skills/dknowc-tax-assistant/README.md +54 -0
- package/skills/dknowc-tax-assistant/SKILL.md +99 -0
- package/skills/dknowc-tax-assistant/attribution.json +5 -0
- package/skills/dknowc-tax-assistant/reference/answer-and-report.md +100 -0
- package/skills/dknowc-tax-assistant/reference/capability-layer.md +205 -0
- package/skills/dknowc-tax-assistant/reference/onboarding_scripts.md +68 -0
- package/skills/dknowc-tax-assistant/reference/policy_tags.json +2002 -0
- package/skills/dknowc-tax-assistant/reference/retrieval-policy.md +43 -0
- package/skills/dknowc-tax-assistant/reference/retrieval-v2.md +58 -0
- package/skills/dknowc-tax-assistant/reference/tags.md +53 -0
- package/skills/dknowc-tax-assistant/reference/tax_claims.example.json +76 -0
- package/skills/dknowc-tax-assistant/reference/trace_report.config.json +46 -0
- package/skills/dknowc-tax-assistant/reference/troubleshooting.md +70 -0
- package/skills/dknowc-tax-assistant/reference/websearch-fallback.md +59 -0
- package/skills/dknowc-tax-assistant/resources/THIRD_PARTY_NOTICES.md +9 -0
- package/skills/dknowc-tax-assistant/resources/echarts.custom.min.js +48 -0
- package/skills/dknowc-tax-assistant/scripts/api_key.py +60 -0
- package/skills/dknowc-tax-assistant/scripts/attribution.py +61 -0
- package/skills/dknowc-tax-assistant/scripts/calc_period.py +156 -0
- package/skills/dknowc-tax-assistant/scripts/calc_tax.py +179 -0
- package/skills/dknowc-tax-assistant/scripts/check_answer.py +210 -0
- package/skills/dknowc-tax-assistant/scripts/initialize.py +208 -0
- package/skills/dknowc-tax-assistant/scripts/merge_search_results.py +631 -0
- package/skills/dknowc-tax-assistant/scripts/path_guard.py +23 -0
- package/skills/dknowc-tax-assistant/scripts/question_profile.py +444 -0
- package/skills/dknowc-tax-assistant/scripts/register_key.mjs +1173 -0
- package/skills/dknowc-tax-assistant/scripts/run_dir.py +149 -0
- package/skills/dknowc-tax-assistant/scripts/source_cards.py +372 -0
- package/skills/dknowc-tax-assistant/scripts/tag_catalog.py +164 -0
- package/skills/dknowc-tax-assistant/scripts/tax_client.py +218 -0
- package/skills/dknowc-tax-assistant/scripts/tax_search.py +403 -0
- package/skills/dknowc-tax-assistant/scripts/verify_claims.py +587 -0
- package/skills/dknowc-tax-assistant/scripts/websearch_convert.py +352 -0
- package/skills/dknowc-trusted-search/README.md +29 -23
- package/skills/dknowc-trusted-search/SKILL.md +257 -107
- package/skills/dknowc-trusted-search/config/trace_report.config.json +119 -0
- package/skills/dknowc-trusted-search/reference/onboarding_scripts.md +40 -15
- package/skills/dknowc-trusted-search/reference/sample_trace_report.html +286 -191
- package/skills/dknowc-trusted-search/resources/ECHARTS-NOTICE.txt +10 -0
- package/skills/dknowc-trusted-search/scripts/api_key.py +10 -26
- package/skills/dknowc-trusted-search/scripts/attribution.py +1 -1
- package/skills/dknowc-trusted-search/scripts/build_trace_input.py +173 -0
- package/skills/dknowc-trusted-search/scripts/deep_convert.py +79 -30
- package/skills/dknowc-trusted-search/scripts/deep_query.py +23 -34
- package/skills/dknowc-trusted-search/scripts/initialize.py +353 -12
- package/skills/dknowc-trusted-search/scripts/mcp_direct.py +3 -2
- package/skills/dknowc-trusted-search/scripts/merge_search_results.py +222 -35
- package/skills/dknowc-trusted-search/scripts/register_key.mjs +845 -291
- package/skills/dknowc-trusted-search/scripts/source_display.py +59 -0
- package/skills/dknowc-trusted-search/scripts/trusted_search.py +69 -36
- package/skills/dknowc-trusted-search/scripts/update_skill.py +300 -0
- package/skills/dknowc-trusted-search/scripts/websearch_convert.py +328 -0
- package/src/index.js +15 -0
- package/skills/dknowc-official-doc-writer/scripts/mcp_convert.py +0 -287
- package/skills/dknowc-official-doc-writer/scripts/render_trace_html.py +0 -2574
- package/skills/dknowc-ppt-assistant/references/upstream-docs/svg-pipeline.md +0 -842
- package/skills/dknowc-ppt-assistant/scripts/finalize_svg.py +0 -507
- package/skills/dknowc-ppt-assistant/scripts/render_trace_html.py +0 -2642
- package/skills/dknowc-ppt-assistant/scripts/svg_finalize/svg_rect_to_path.py +0 -346
- package/skills/dknowc-trusted-search/official-docs/output/.gitkeep +0 -0
- package/skills/dknowc-trusted-search/official-docs/search-results/.gitkeep +0 -0
- package/skills/dknowc-trusted-search/scripts/mcp_convert.py +0 -198
|
@@ -9,6 +9,8 @@ self_check / recalled_materials / 标准字段,导致核验报告单多项"未
|
|
|
9
9
|
2. 字段完整性:materials 必须带 excerpts / type(source_url 允许缺省——接口未返回时
|
|
10
10
|
按规则不填、不猜测),recalled_materials 非空;
|
|
11
11
|
3. 角标对应:document_content 的 [n] 角标与 materials 一一对应,无越界;
|
|
12
|
+
3a. 引用绑定:每处角标必须有对应的引用实例(quote),且 quote 能在该材料原文中逐字找到、
|
|
13
|
+
sentence 能在正文中找到;外省材料只能作“借鉴”,标记“历史”的材料不得作为依据;
|
|
12
14
|
4. self_check 完整:五项检查结果必须全部写入(不得缺失导致"未记录");
|
|
13
15
|
5. 文号只认字段:正文每个文号必须能在 materials 的 `发文字号` 字段找到,
|
|
14
16
|
禁止从段落正文提取;
|
|
@@ -28,9 +30,20 @@ import argparse
|
|
|
28
30
|
import json
|
|
29
31
|
import re
|
|
30
32
|
import sys
|
|
33
|
+
import unicodedata
|
|
31
34
|
from pathlib import Path
|
|
32
35
|
|
|
33
36
|
SKILL_ROOT = Path(__file__).resolve().parent.parent
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
def _cm_ws_root() -> "Path":
|
|
40
|
+
"""dsh:会话工作区根(与各脚本的 WS_ROOT 同源解析)。"""
|
|
41
|
+
import os as _os
|
|
42
|
+
_ws = _os.environ.get("DKNWOC_WS_ROOT")
|
|
43
|
+
if not _ws:
|
|
44
|
+
_sid = _os.environ.get("DSH_SESSION_ID", "")
|
|
45
|
+
_ws = str(Path.cwd() / "dknowc-output" / (_sid[:8] if _sid else "_default"))
|
|
46
|
+
return Path(_ws).resolve()
|
|
34
47
|
SELF_CHECK_ITEMS = ["事实有据", "结构完整", "无占位残留", "无AI味", "格式合规"]
|
|
35
48
|
# 兼容键名空格差异("无 AI 味" vs "无AI味")
|
|
36
49
|
SELF_CHECK_KEYS = {
|
|
@@ -64,16 +77,6 @@ def load_json(path: Path):
|
|
|
64
77
|
raise SystemExit(f"错误:无法读取 {path}({exc})")
|
|
65
78
|
|
|
66
79
|
|
|
67
|
-
def _cm_ws_root() -> "Path":
|
|
68
|
-
"""dsh:会话工作区根(与各脚本的 WS_ROOT 同源解析)。"""
|
|
69
|
-
import os as _os
|
|
70
|
-
_ws = _os.environ.get("DKNWOC_WS_ROOT")
|
|
71
|
-
if not _ws:
|
|
72
|
-
_sid = _os.environ.get("DSH_SESSION_ID", "")
|
|
73
|
-
_ws = str(Path.cwd() / "dknowc-output" / (_sid[:8] if _sid else "_default"))
|
|
74
|
-
return Path(_ws).resolve()
|
|
75
|
-
|
|
76
|
-
|
|
77
80
|
def build_source_index(merged: dict) -> tuple:
|
|
78
81
|
"""从合并产物构建(标题索引, 全量 URL 集合)。
|
|
79
82
|
|
|
@@ -107,6 +110,296 @@ def build_source_index(merged: dict) -> tuple:
|
|
|
107
110
|
return index, urls
|
|
108
111
|
|
|
109
112
|
|
|
113
|
+
def norm_text(text) -> str:
|
|
114
|
+
"""比对用归一化:去空白、统一全半角括号与常见标点(只用于"是否包含"判断)。"""
|
|
115
|
+
s = str(text or "")
|
|
116
|
+
table = str.maketrans({"(": "(", ")": ")", ",": ",", ":": ":", ";": ";",
|
|
117
|
+
"“": '"', "”": '"', "‘": "'", "’": "'", " ": " "})
|
|
118
|
+
s = s.translate(table)
|
|
119
|
+
return re.sub(r"\s+", "", s)
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
def cmp_norm(text) -> str:
|
|
123
|
+
"""按“句子内容”比对用:去空白与全部标点/符号(含角标括号),只留文字与数字。"""
|
|
124
|
+
s = unicodedata.normalize("NFKC", str(text or ""))
|
|
125
|
+
return re.sub(r"[\s\W_]+", "", s)
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
SENTENCE_END = re.compile(r"[。!?!?;;\n\r]")
|
|
129
|
+
|
|
130
|
+
|
|
131
|
+
def mark_occurrences(body: str) -> list[tuple[int, str]]:
|
|
132
|
+
"""把正文按句切开,返回每处角标的 (mark, 该句归一化内容),按正文出现顺序。
|
|
133
|
+
|
|
134
|
+
公文习惯把角标写在句末标点之后("……工作。[1]"),因此紧跟句末标点的
|
|
135
|
+
“只含角标”的片段要并回前一句,否则会把角标自身当成一句。
|
|
136
|
+
"""
|
|
137
|
+
parts = re.split(r"(?<=[。!?!?;;\n\r])", body)
|
|
138
|
+
segs: list[str] = []
|
|
139
|
+
for part in parts:
|
|
140
|
+
if not part:
|
|
141
|
+
continue
|
|
142
|
+
residue = re.sub(r"[\[【]\s*\d+\s*[\]】]|\s", "", part)
|
|
143
|
+
if segs and residue == "":
|
|
144
|
+
segs[-1] += part
|
|
145
|
+
else:
|
|
146
|
+
segs.append(part)
|
|
147
|
+
out: list[tuple[int, str]] = []
|
|
148
|
+
for seg in segs:
|
|
149
|
+
out.extend(_marks_in(seg))
|
|
150
|
+
return out
|
|
151
|
+
|
|
152
|
+
|
|
153
|
+
def _marks_in(seg: str) -> list[tuple[int, str]]:
|
|
154
|
+
marks = [int(x.group(1)) for x in re.finditer(r"[\[【]\s*(\d+)\s*[\]】]", seg)]
|
|
155
|
+
return [(n, cmp_norm(seg)) for n in marks]
|
|
156
|
+
|
|
157
|
+
|
|
158
|
+
def check_mark_occurrence_binding(body: str, records: list) -> list[str]:
|
|
159
|
+
"""同一角标多次出现时,每条 sentence 必须对上“某一处”出现,不能多句套同一处。"""
|
|
160
|
+
errors: list[str] = []
|
|
161
|
+
occ: dict[int, list[str]] = {}
|
|
162
|
+
for mark, seg in mark_occurrences(body):
|
|
163
|
+
occ.setdefault(mark, []).append(seg)
|
|
164
|
+
rec: dict[int, list[str]] = {}
|
|
165
|
+
for r in records:
|
|
166
|
+
try:
|
|
167
|
+
mark = int(r.get("mark"))
|
|
168
|
+
except (TypeError, ValueError):
|
|
169
|
+
continue
|
|
170
|
+
rec.setdefault(mark, []).append(cmp_norm(r.get("sentence")))
|
|
171
|
+
for mark, segs in occ.items():
|
|
172
|
+
sentences = list(rec.get(mark) or [])
|
|
173
|
+
if len(sentences) != len(segs):
|
|
174
|
+
continue # 条数不匹配由上层的“逐处交付”检查报告
|
|
175
|
+
pool = list(sentences)
|
|
176
|
+
for i, seg in enumerate(segs, 1):
|
|
177
|
+
if seg in pool:
|
|
178
|
+
pool.remove(seg)
|
|
179
|
+
else:
|
|
180
|
+
errors.append(
|
|
181
|
+
f"角标 [{mark}] 第 {i} 处原句为「{seg[:26]}」,引用对照里没有对应这一处的 sentence"
|
|
182
|
+
f"(同一角标多处引用时,每处的 sentence 必须是该处自己的原句)")
|
|
183
|
+
if pool:
|
|
184
|
+
errors.append(f"角标 [{mark}] 有 {len(pool)} 条 sentence 与任何一处出现位置都对不上")
|
|
185
|
+
return errors
|
|
186
|
+
|
|
187
|
+
|
|
188
|
+
def build_article_text_index(merged: dict) -> dict:
|
|
189
|
+
"""合并产物 → {归一化标题/URL: 全文段落拼接},供引文逐字比对。"""
|
|
190
|
+
out: dict = {}
|
|
191
|
+
|
|
192
|
+
def add(key: str, text: str) -> None:
|
|
193
|
+
if not key:
|
|
194
|
+
return
|
|
195
|
+
out[key] = out.get(key, "") + "\n" + text
|
|
196
|
+
|
|
197
|
+
for art in merged.get("articles") or []:
|
|
198
|
+
text = "\n".join(
|
|
199
|
+
str(p.get("内容") or "") if isinstance(p, dict) else str(p)
|
|
200
|
+
for p in (art.get("段落") or [])
|
|
201
|
+
)
|
|
202
|
+
key_t = norm_text(first_value(art, SOURCE_TITLE_FIELDS))
|
|
203
|
+
key_u = norm_text(first_value(art, SOURCE_URL_FIELDS)).rstrip("/")
|
|
204
|
+
add(key_t, text)
|
|
205
|
+
add(key_u, text)
|
|
206
|
+
return out
|
|
207
|
+
|
|
208
|
+
|
|
209
|
+
CIT_USAGE_VALUES = ("依据", "借鉴")
|
|
210
|
+
CIT_STATUS_VALUES = ("现行", "历史", "参考")
|
|
211
|
+
CIT_REGION_VALUES = ("本地", "上级", "外省", "全国")
|
|
212
|
+
CIT_QUOTE_MIN = 10
|
|
213
|
+
ISSUER_FIELDS = ("issue_org", "发布机关", "发文机关", "发布或实施机构")
|
|
214
|
+
|
|
215
|
+
|
|
216
|
+
def check_citation_binding(trace: dict, merged: dict | None = None) -> list[str]:
|
|
217
|
+
"""引用实例级校验:角标↔原句↔原文片段三方一致,版本与地域使用合规。
|
|
218
|
+
|
|
219
|
+
merged 为 None 时跳过“quote 是否出现在该材料原文”的比对(没有合并产物可查),
|
|
220
|
+
其余校验照常执行——渲染前的门禁正是走这条路径。
|
|
221
|
+
"""
|
|
222
|
+
errors: list[str] = []
|
|
223
|
+
body = trace.get("document_content") or ""
|
|
224
|
+
counts: dict[int, int] = {}
|
|
225
|
+
for m in re.finditer(r"[\[【]\s*(\d+)\s*[\]】]", body):
|
|
226
|
+
n = int(m.group(1))
|
|
227
|
+
counts[n] = counts.get(n, 0) + 1
|
|
228
|
+
if not counts:
|
|
229
|
+
return errors
|
|
230
|
+
|
|
231
|
+
records = trace.get("citations") or []
|
|
232
|
+
if not records:
|
|
233
|
+
return [
|
|
234
|
+
"缺 citations——正文含 [n] 角标时必须提供引用对照(每处引用一条 quote),"
|
|
235
|
+
"否则无法核验“这句话是否真的出自该材料”"
|
|
236
|
+
]
|
|
237
|
+
|
|
238
|
+
by_id = {}
|
|
239
|
+
for i, mat in enumerate(trace.get("materials") or [], 1):
|
|
240
|
+
mid = mat.get("id") or i
|
|
241
|
+
by_id[int(mid)] = mat
|
|
242
|
+
text_index = build_article_text_index(merged) if merged is not None else {}
|
|
243
|
+
flat_body = norm_text(body)
|
|
244
|
+
|
|
245
|
+
per_mark: dict[int, int] = {}
|
|
246
|
+
for idx, rec in enumerate(records, 1):
|
|
247
|
+
try:
|
|
248
|
+
mark = int(rec.get("mark"))
|
|
249
|
+
material = int(rec.get("material", mark))
|
|
250
|
+
except (TypeError, ValueError):
|
|
251
|
+
errors.append(f"引用[{idx}] 的 mark/material 不是整数")
|
|
252
|
+
continue
|
|
253
|
+
per_mark[mark] = per_mark.get(mark, 0) + 1
|
|
254
|
+
quote = str(rec.get("quote") or "").strip()
|
|
255
|
+
sentence = str(rec.get("sentence") or "").strip()
|
|
256
|
+
usage = str(rec.get("用法") or rec.get("usage") or "").strip()
|
|
257
|
+
if mark not in counts:
|
|
258
|
+
errors.append(f"引用[{idx}] 的 mark={mark} 在正文中不存在")
|
|
259
|
+
continue
|
|
260
|
+
# ⓪ 角标号即素材清单序号:material 必须等于 mark,否则可拿别的材料顶替
|
|
261
|
+
if material != mark:
|
|
262
|
+
errors.append(
|
|
263
|
+
f"引用[{idx}] 的 material={material} 与 mark={mark} 不一致——"
|
|
264
|
+
f"角标号即素材清单序号,两者必须相同"
|
|
265
|
+
)
|
|
266
|
+
continue
|
|
267
|
+
# ① 原句:必填、必须含该角标、必须能在正文找到
|
|
268
|
+
if not sentence:
|
|
269
|
+
errors.append(f"引用[{idx}]([{mark}])缺 sentence(正文中该角标所在的原句)")
|
|
270
|
+
else:
|
|
271
|
+
if not re.search(rf"[\[【]\s*{mark}\s*[\]】]", sentence):
|
|
272
|
+
errors.append(
|
|
273
|
+
f"引用[{idx}]([{mark}])的 sentence 必须包含角标 [{mark}] 本身"
|
|
274
|
+
f"(照抄正文原句,含角标):{sentence[:30]}"
|
|
275
|
+
)
|
|
276
|
+
elif flat_body and norm_text(sentence) not in flat_body:
|
|
277
|
+
errors.append(f"引用[{idx}]([{mark}])的 sentence 在正文中找不到:{sentence[:30]}")
|
|
278
|
+
# ② 引文:必填且有长度下限(过短片段会在原文中偶然命中)
|
|
279
|
+
if len(norm_text(quote)) < CIT_QUOTE_MIN:
|
|
280
|
+
errors.append(
|
|
281
|
+
f"引用[{idx}]([{mark}])quote 为空或过短(须≥{CIT_QUOTE_MIN}字原文片段,"
|
|
282
|
+
f"当前 {len(norm_text(quote))} 字)"
|
|
283
|
+
)
|
|
284
|
+
mat = by_id.get(material)
|
|
285
|
+
if mat is None:
|
|
286
|
+
errors.append(f"引用[{idx}]([{mark}])的 material={material} 不在 materials 中")
|
|
287
|
+
continue
|
|
288
|
+
# ③ 引文逐字落在该材料的原文段落里(有合并产物时才比对)
|
|
289
|
+
if merged is not None:
|
|
290
|
+
title_key = norm_text(first_value(mat, MAT_TITLE_FIELDS))
|
|
291
|
+
url_key = norm_text(first_value(mat, MAT_URL_FIELDS)).rstrip("/")
|
|
292
|
+
source_text = text_index.get(title_key) or text_index.get(url_key) or ""
|
|
293
|
+
if not source_text.strip():
|
|
294
|
+
errors.append(f"引用[{idx}]([{mark}])的材料在合并产物中无正文段落,无法比对引文")
|
|
295
|
+
elif len(norm_text(quote)) >= CIT_QUOTE_MIN and norm_text(quote) not in norm_text(source_text):
|
|
296
|
+
errors.append(
|
|
297
|
+
f"引用[{idx}]([{mark}])的 quote 在《{first_value(mat, MAT_TITLE_FIELDS)[:30]}》原文中找不到"
|
|
298
|
+
f"(引用须逐字取自该材料):{quote[:40]}"
|
|
299
|
+
)
|
|
300
|
+
# ④ 用法与地域:外省材料只能作借鉴
|
|
301
|
+
if usage not in CIT_USAGE_VALUES:
|
|
302
|
+
errors.append(f"引用[{idx}]([{mark}])缺“用法”(依据/借鉴)")
|
|
303
|
+
region = str(mat.get("region") or "").strip()
|
|
304
|
+
if region == "外省" and usage == "依据":
|
|
305
|
+
errors.append(
|
|
306
|
+
f"引用[{idx}]([{mark}])把外省材料当本地依据——外省材料只能标“用法=借鉴”,"
|
|
307
|
+
"并在正文写明是外地做法"
|
|
308
|
+
)
|
|
309
|
+
# ⑤ 效力:历史版本不得作为正文依据
|
|
310
|
+
status = str(mat.get("status") or "").strip()
|
|
311
|
+
if status == "历史":
|
|
312
|
+
errors.append(
|
|
313
|
+
f"引用[{idx}]([{mark}])引用了标记为“历史”的材料《{first_value(mat, MAT_TITLE_FIELDS)[:30]}》"
|
|
314
|
+
"——同一事项已有更新文件时,正文不得再以旧文件为依据"
|
|
315
|
+
)
|
|
316
|
+
|
|
317
|
+
for mark, need in counts.items():
|
|
318
|
+
got = per_mark.get(mark, 0)
|
|
319
|
+
if got != need:
|
|
320
|
+
errors.append(
|
|
321
|
+
f"角标 [{mark}] 在正文出现 {need} 处,但引用对照只有 {got} 条——"
|
|
322
|
+
f"同一材料被多处引用时,每处都要有自己的原文片段"
|
|
323
|
+
)
|
|
324
|
+
# ⑥ 出现次序绑定:同一角标多处出现时,每条 sentence 必须对上各自的第 k 处
|
|
325
|
+
errors.extend(check_mark_occurrence_binding(body, records))
|
|
326
|
+
return errors
|
|
327
|
+
|
|
328
|
+
|
|
329
|
+
def check_material_metadata(trace: dict) -> list[str]:
|
|
330
|
+
"""素材清单选中条目必须带 status/region/发布机关(含未被引用的 recalled)。"""
|
|
331
|
+
errors: list[str] = []
|
|
332
|
+
groups = (("materials", trace.get("materials") or []),
|
|
333
|
+
("recalled_materials", trace.get("recalled_materials") or []))
|
|
334
|
+
for label, items in groups:
|
|
335
|
+
for idx, mat in enumerate(items, 1):
|
|
336
|
+
if not isinstance(mat, dict):
|
|
337
|
+
continue
|
|
338
|
+
# 合并产物里未被清单选中的召回材料不受此约束(from_selected=False)
|
|
339
|
+
if label == "recalled_materials" and mat.get("from_selected") is False:
|
|
340
|
+
continue
|
|
341
|
+
mid = mat.get("id") or idx
|
|
342
|
+
name = first_value(mat, MAT_TITLE_FIELDS)[:30] or f"材料{mid}"
|
|
343
|
+
status = str(mat.get("status") or "").strip()
|
|
344
|
+
region = str(mat.get("region") or "").strip()
|
|
345
|
+
issuer = first_value(mat, ISSUER_FIELDS)
|
|
346
|
+
if not status:
|
|
347
|
+
errors.append(f"材料[{mid}]《{name}》缺 status(现行/历史/参考)")
|
|
348
|
+
elif status not in CIT_STATUS_VALUES:
|
|
349
|
+
errors.append(f"材料[{mid}]《{name}》的 status 取值不合法:{status}(现行/历史/参考)")
|
|
350
|
+
if not region:
|
|
351
|
+
errors.append(
|
|
352
|
+
f"材料[{mid}]《{name}》缺 region(本地/上级/外省/全国)——"
|
|
353
|
+
"缺省会让外省材料绕过“只能作借鉴”的校验"
|
|
354
|
+
)
|
|
355
|
+
elif region not in CIT_REGION_VALUES:
|
|
356
|
+
errors.append(f"材料[{mid}]《{name}》的 region 取值不合法:{region}(本地/上级/外省/全国)")
|
|
357
|
+
return errors
|
|
358
|
+
|
|
359
|
+
|
|
360
|
+
def collect_material_warnings(trace: dict) -> list[str]:
|
|
361
|
+
"""软提醒(不阻断):素材清单条目缺发布机关——报告来源卡将不显示机构。
|
|
362
|
+
|
|
363
|
+
接口对部分材料(新闻、案例、部分转发件)不返回发文机构;强制必填会迫使编造,
|
|
364
|
+
因此只提示,不阻断。
|
|
365
|
+
"""
|
|
366
|
+
warnings: list[str] = []
|
|
367
|
+
groups = (("materials", trace.get("materials") or []),
|
|
368
|
+
("recalled_materials", trace.get("recalled_materials") or []))
|
|
369
|
+
for label, items in groups:
|
|
370
|
+
for idx, mat in enumerate(items, 1):
|
|
371
|
+
if not isinstance(mat, dict):
|
|
372
|
+
continue
|
|
373
|
+
if label == "recalled_materials" and mat.get("from_selected") is False:
|
|
374
|
+
continue
|
|
375
|
+
if first_value(mat, ISSUER_FIELDS):
|
|
376
|
+
continue
|
|
377
|
+
mid = mat.get("id") or idx
|
|
378
|
+
name = first_value(mat, MAT_TITLE_FIELDS)[:30] or f"材料{mid}"
|
|
379
|
+
warnings.append(f"材料[{mid}]《{name}》缺发布机关——来源卡将不显示机构,如能补请补")
|
|
380
|
+
return warnings
|
|
381
|
+
|
|
382
|
+
|
|
383
|
+
SELF_AUTHORED_MARKERS = ("台账", "专班", "责任人", "一式", "个工作日内送达",
|
|
384
|
+
"前完成", "逾期", "汇总表", "留档")
|
|
385
|
+
|
|
386
|
+
|
|
387
|
+
def collect_self_authored_warnings(trace: dict) -> list[str]:
|
|
388
|
+
"""软提醒(不阻断):本单位的时限/分工安排属于自撰句,不应挂依据类角标。"""
|
|
389
|
+
warnings: list[str] = []
|
|
390
|
+
for idx, rec in enumerate(trace.get("citations") or [], 1):
|
|
391
|
+
sentence = str(rec.get("sentence") or "")
|
|
392
|
+
if str(rec.get("用法") or "") != "依据":
|
|
393
|
+
continue
|
|
394
|
+
hit = [m for m in SELF_AUTHORED_MARKERS if m in sentence]
|
|
395
|
+
if hit:
|
|
396
|
+
warnings.append(
|
|
397
|
+
f"引用[{idx}] 所在句像是本单位安排(命中:{'、'.join(hit)}),"
|
|
398
|
+
f"自撰句不应挂依据角标——请确认这句是否真有政策依据:{sentence[:36]}"
|
|
399
|
+
)
|
|
400
|
+
return warnings
|
|
401
|
+
|
|
402
|
+
|
|
110
403
|
def check_material_source(mat: dict, index: dict, source_urls: set, mat_no: int) -> list[str]:
|
|
111
404
|
"""校验单条材料能否在合并产物中回溯到来源(URL 按全量变体集合判定)。"""
|
|
112
405
|
errors = []
|
|
@@ -135,7 +428,7 @@ def check_citations(content: str, materials: list) -> list[str]:
|
|
|
135
428
|
会移入 recalled_materials,因此 `build_trace_json.py` 产出的 materials **只装配被引用
|
|
136
429
|
的那些,id 天然是稀疏的**(如清单 65 篇中未引用第 30 篇,则 id = 1..29、31..65)。
|
|
137
430
|
故此处不能用 `len(materials)` 当上界、也不能要求 id 从 1 连续。
|
|
138
|
-
|
|
431
|
+
(按 `len(materials)` + `range(1, n+1)` 校验,只要素材清单里存在
|
|
139
432
|
未被正文引用的条目,就必然误报"角标越界"且校验永远无法通过,只能被迫裁清单、重编号角标。)
|
|
140
433
|
"""
|
|
141
434
|
errors = []
|
|
@@ -256,13 +549,33 @@ def _norm_key(k: str) -> str:
|
|
|
256
549
|
return re.sub(r"\s+", "", str(k))
|
|
257
550
|
|
|
258
551
|
|
|
552
|
+
def _verdict_of(item) -> str:
|
|
553
|
+
"""把一项自检的结论归一为 pass/fail/pending/none(口径与渲染内核一致)。"""
|
|
554
|
+
if isinstance(item, dict):
|
|
555
|
+
raw = item.get("verdict") or item.get("结论") or item.get("status")
|
|
556
|
+
else:
|
|
557
|
+
raw = item
|
|
558
|
+
text = str(raw or "").strip().lower()
|
|
559
|
+
if not text:
|
|
560
|
+
return "none"
|
|
561
|
+
for prefix in ("pending", "待定", "待确认", "待人工复核", "待复核"):
|
|
562
|
+
if text.startswith(prefix):
|
|
563
|
+
return "pending"
|
|
564
|
+
for prefix in ("fail", "未通过", "不通过", "不合格", "false", "否"):
|
|
565
|
+
if text.startswith(prefix):
|
|
566
|
+
return "fail"
|
|
567
|
+
for prefix in ("pass", "已通过", "通过", "合格", "ok", "true", "是"):
|
|
568
|
+
if text.startswith(prefix):
|
|
569
|
+
return "pass"
|
|
570
|
+
return "none"
|
|
571
|
+
|
|
572
|
+
|
|
259
573
|
def check_self_check(sc_raw) -> list[str]:
|
|
260
|
-
"""校验 self_check
|
|
574
|
+
"""校验 self_check 五项齐全且符合两轨验收结构(Agent 轨提交契约)。
|
|
261
575
|
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
③ 简单字符串 "通过" / "未通过"
|
|
576
|
+
主格式(与渲染内核一致):每项 {"verdict": "pass|fail|pending", "basis": "…", "evidence": ["…"]};
|
|
577
|
+
声明 pass 必须给非空 evidence(证据要素由渲染内核把关,此处先拦空证据)。
|
|
578
|
+
兼容旧字符串 "通过:说明" / "未通过:说明"(裸"通过"无证据,按内核口径也会被拦)。
|
|
266
579
|
兼容两种键名写法:'无AI味' 与 '无 AI 味'。
|
|
267
580
|
"""
|
|
268
581
|
errors = []
|
|
@@ -276,11 +589,32 @@ def check_self_check(sc_raw) -> list[str]:
|
|
|
276
589
|
for k in SELF_CHECK_ITEMS:
|
|
277
590
|
item = next((sc_raw[kk] for kk in sc_raw if _norm_key(kk) == _norm_key(k)), None)
|
|
278
591
|
if item is None or (isinstance(item, str) and not item.strip()):
|
|
279
|
-
errors.append(f"self_check[{k}]
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
errors.append(f"self_check[{k}]
|
|
592
|
+
errors.append(f"self_check[{k}] 为空(请按两轨验收契约写 {{verdict, basis, evidence}})")
|
|
593
|
+
continue
|
|
594
|
+
verdict = _verdict_of(item)
|
|
595
|
+
if verdict == "none":
|
|
596
|
+
errors.append(f"self_check[{k}] 结论无法识别(verdict 须为 pass/fail/pending,或以'通过/未通过/待复核'开头)")
|
|
597
|
+
continue
|
|
598
|
+
evidence = ""
|
|
599
|
+
if isinstance(item, dict):
|
|
600
|
+
ev = item.get("evidence") or item.get("证据")
|
|
601
|
+
if isinstance(ev, (list, tuple)):
|
|
602
|
+
evidence = ";".join(str(x).strip() for x in ev if str(x).strip())
|
|
603
|
+
else:
|
|
604
|
+
evidence = str(ev or "").strip()
|
|
605
|
+
else:
|
|
606
|
+
# 旧字符串写法:证据 = 去掉"通过:/未通过:/待复核:"等结论前缀后的说明;
|
|
607
|
+
# 裸"通过"剥完前缀为空,与内核口径一致按证据不足拦
|
|
608
|
+
text = str(item).strip()
|
|
609
|
+
lowered = text.lower()
|
|
610
|
+
for prefix in ("pending", "pass", "fail", "通过", "已通过", "未通过",
|
|
611
|
+
"不通过", "不合格", "合格", "待复核", "待定", "待确认"):
|
|
612
|
+
if lowered.startswith(prefix):
|
|
613
|
+
rest = text[len(prefix):].lstrip("::,,、 ").strip()
|
|
614
|
+
evidence = rest
|
|
615
|
+
break
|
|
616
|
+
if verdict == "pass" and not evidence:
|
|
617
|
+
errors.append(f"self_check[{k}] 声明通过但未给 evidence 证据(裸'通过'会被渲染器按证据不足拦截)")
|
|
284
618
|
elif isinstance(sc_raw, list):
|
|
285
619
|
keys = {_norm_key(str(x.get("name") or x.get("项") or "")) for x in sc_raw if isinstance(x, dict)}
|
|
286
620
|
missing = [k for k in SELF_CHECK_ITEMS if _norm_key(k) not in keys]
|
|
@@ -353,11 +687,21 @@ def main() -> int:
|
|
|
353
687
|
if not first_value(mat, MAT_TYPE_FIELDS):
|
|
354
688
|
errors.append(f"材料[{i}] 缺 type(四分类:政策依据型/数据支撑型/参考案例型/表述参考型)")
|
|
355
689
|
if not recalled:
|
|
356
|
-
|
|
690
|
+
# 未执行检索的写作任务不做此项校验;执行过检索却缺 recalled 才是错误
|
|
691
|
+
searched = bool(trace.get("检索记录") or trace.get("search_summary") or trace.get("检索通道"))
|
|
692
|
+
if searched:
|
|
693
|
+
errors.append("recalled_materials 为空——执行过搜索的任务必须包含全部未引用召回材料")
|
|
357
694
|
|
|
358
695
|
# ③ 角标对应
|
|
359
696
|
errors.extend(check_citations(trace.get("document_content") or "", materials))
|
|
360
697
|
|
|
698
|
+
# ③a 引用实例级校验:逐处原文片段、版本效力、地域用法
|
|
699
|
+
errors.extend(check_citation_binding(trace, merged))
|
|
700
|
+
# ③a-2 素材清单三字段:status/region/发布机关(含未被引用的 recalled)
|
|
701
|
+
errors.extend(check_material_metadata(trace))
|
|
702
|
+
warnings = collect_self_authored_warnings(trace)
|
|
703
|
+
warnings.extend(collect_material_warnings(trace))
|
|
704
|
+
|
|
361
705
|
# ③b 文号只认接口字段(禁止从段落正文提取)
|
|
362
706
|
errors.extend(check_doc_numbers(trace.get("document_content") or "", materials))
|
|
363
707
|
|
|
@@ -367,8 +711,8 @@ def main() -> int:
|
|
|
367
711
|
# ④ self_check 完整
|
|
368
712
|
errors.extend(check_self_check(trace.get("self_check")))
|
|
369
713
|
|
|
370
|
-
# ⑤ 研究资料 gate
|
|
371
|
-
#
|
|
714
|
+
# ⑤ 研究资料 gate:研究型与综合长篇文种必须落盘研究资料底稿
|
|
715
|
+
# (见 reference/research_notes.md:分类自检时初版、确认清单后定稿)。该层是
|
|
372
716
|
# 研究型文种分析深度与数据密度的来源,曾因只写在散文段而整层被跳过
|
|
373
717
|
# (无层 2509 字 vs 有层 9045 字)——此处在渲染前强制拦截。
|
|
374
718
|
doc_type = str(trace.get("doc_type") or "")
|
|
@@ -379,7 +723,7 @@ def main() -> int:
|
|
|
379
723
|
if not notes:
|
|
380
724
|
errors.append(
|
|
381
725
|
f"doc_type={doc_type} 属研究型/综合长篇文种,但未找到研究资料文件"
|
|
382
|
-
f"({input_dir}/*研究资料*.md)——按
|
|
726
|
+
f"({input_dir}/*研究资料*.md)——按 reference/research_notes.md 先生成研究资料"
|
|
383
727
|
f"(初版:核心事实总表+数据口径表;定稿:角标与素材清单对齐,正文基于定稿写作),"
|
|
384
728
|
f"缺少该层会导致正文过短")
|
|
385
729
|
|
|
@@ -387,15 +731,19 @@ def main() -> int:
|
|
|
387
731
|
print(json.dumps({"ok": False, "errors": errors, "file": str(Path(args.trace_json))},
|
|
388
732
|
ensure_ascii=False, indent=2))
|
|
389
733
|
return 1
|
|
390
|
-
|
|
734
|
+
result = {
|
|
391
735
|
"ok": True,
|
|
392
736
|
"file": str(Path(args.trace_json)),
|
|
393
737
|
"materials": len(materials),
|
|
394
738
|
"recalled_materials": len(recalled),
|
|
739
|
+
"citations": len(trace.get("citations") or []),
|
|
395
740
|
"body_chars": count_body_chars(trace.get("document_content") or ""),
|
|
396
741
|
"self_check": "完整" if trace.get("self_check") else "缺失",
|
|
397
742
|
"note": "校验通过,可生成溯源核验报告 HTML",
|
|
398
|
-
}
|
|
743
|
+
}
|
|
744
|
+
if warnings:
|
|
745
|
+
result["warnings"] = warnings
|
|
746
|
+
print(json.dumps(result, ensure_ascii=False, indent=2))
|
|
399
747
|
return 0
|
|
400
748
|
|
|
401
749
|
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"""把深知可信搜索 deep-query/v3(深度搜索)的返回转换成与 dkag_search.py --clean 同构的形态,
|
|
3
3
|
供本 Skill 全部下游流程复用(素材分类、研究资料、溯源 JSON、核验报告)。
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
背景:首轮检索改用深度搜索做广度召回——分 3 路(政策依据型/数据支撑型/参考案例型),
|
|
6
6
|
每路一次深度搜索,query 用「对象+关注方向」句式(不列举具体信息需求);拿到材料后,
|
|
7
7
|
政策原文/快照等缺口由可信搜索按需补搜;文号已由深搜自带(2026-10-23 起文章级 writtenText,映射为「发文字号」),不再为拿文号而必补。
|
|
8
8
|
|
|
@@ -34,7 +34,7 @@ import sys
|
|
|
34
34
|
from pathlib import Path
|
|
35
35
|
|
|
36
36
|
SKILL_ROOT = Path(__file__).resolve().parent.parent
|
|
37
|
-
# 工作区根:dsh 场景通过环境变量 DKNWOC_WS_ROOT 指向会话工作区,未设置时回退到 cwd
|
|
37
|
+
# 工作区根:dsh 场景通过环境变量 DKNWOC_WS_ROOT 指向会话工作区,未设置时回退到 cwd
|
|
38
38
|
import os as _os
|
|
39
39
|
_ws = _os.environ.get("DKNWOC_WS_ROOT")
|
|
40
40
|
if not _ws:
|
|
@@ -43,6 +43,7 @@ if not _ws:
|
|
|
43
43
|
_sid = _os.environ.get("DSH_SESSION_ID", "")
|
|
44
44
|
_ws = str(Path(_os.getcwd()) / "dknowc-output" / (_sid[:8] if _sid else "_default"))
|
|
45
45
|
WS_ROOT = Path(_ws).resolve()
|
|
46
|
+
|
|
46
47
|
SEARCH_RESULTS_DIR = WS_ROOT / "official-docs" / "search-results"
|
|
47
48
|
|
|
48
49
|
|
|
@@ -62,7 +63,7 @@ def strip_html(text) -> str:
|
|
|
62
63
|
"""去掉深度搜索段落内容里的 HTML 标签并反转义实体(真实返回含表格等标签)。
|
|
63
64
|
|
|
64
65
|
表格标签(table/thead/tbody/tr/td/th/br)原样保留:深度返回的
|
|
65
|
-
|
|
66
|
+
标准限值表/名单表曾被整体拍平成空格分隔文本,知识专库与引文胶囊无法按表格
|
|
66
67
|
形态展示(渲染端 sanitize_table_html / render_excerpt_html 对表格做白名单清洗与
|
|
67
68
|
展示,可信搜索通道 dkag_search 亦原样保留表格,两通道口径一致)。"""
|
|
68
69
|
raw = str(text or "")
|
|
@@ -156,6 +157,10 @@ def convert(data, area: str, purpose: str) -> dict:
|
|
|
156
157
|
if source_url:
|
|
157
158
|
article["源网址"] = source_url
|
|
158
159
|
article["原文链接"] = source_url
|
|
160
|
+
# 发文机构原样透传(来源卡只展示该字段;不回退数据源/站点名称)
|
|
161
|
+
agency = clean_text(first_value(raw, "发布或实施机构", "发布机关"))
|
|
162
|
+
if agency:
|
|
163
|
+
article["发布或实施机构"] = agency
|
|
159
164
|
region = clean_text(first_value(raw, "办理地域", "area"))
|
|
160
165
|
if region:
|
|
161
166
|
article["办理地域"] = region
|
|
@@ -179,7 +184,7 @@ def convert(data, area: str, purpose: str) -> dict:
|
|
|
179
184
|
raw_query = first_value(data, "query") if isinstance(data, dict) else ""
|
|
180
185
|
search_meta = {
|
|
181
186
|
"query": raw_query,
|
|
182
|
-
# purpose
|
|
187
|
+
# purpose 兜底--purpose 为空时用该路 query 兜底——
|
|
183
188
|
# 留空会导致合并产物文章"搜索目的"缺失,溯源分组键退化成地域碎片。
|
|
184
189
|
"purpose": purpose or raw_query,
|
|
185
190
|
"area": area,
|
|
@@ -22,7 +22,7 @@ from typing import Any, Dict, List, Optional
|
|
|
22
22
|
|
|
23
23
|
DEFAULT_ENDPOINT = "https://open.dknowc.cn/api/services/deep-query/v3"
|
|
24
24
|
SKILL_ROOT = Path(__file__).resolve().parent.parent
|
|
25
|
-
# 工作区根:dsh 场景通过环境变量 DKNWOC_WS_ROOT 指向会话工作区,未设置时回退到 cwd
|
|
25
|
+
# 工作区根:dsh 场景通过环境变量 DKNWOC_WS_ROOT 指向会话工作区,未设置时回退到 cwd
|
|
26
26
|
import os as _os
|
|
27
27
|
_ws = _os.environ.get("DKNWOC_WS_ROOT")
|
|
28
28
|
if not _ws:
|
|
@@ -31,6 +31,7 @@ if not _ws:
|
|
|
31
31
|
_sid = _os.environ.get("DSH_SESSION_ID", "")
|
|
32
32
|
_ws = str(Path(_os.getcwd()) / "dknowc-output" / (_sid[:8] if _sid else "_default"))
|
|
33
33
|
WS_ROOT = Path(_ws).resolve()
|
|
34
|
+
|
|
34
35
|
SEARCH_RESULTS_DIR = WS_ROOT / "official-docs" / "search-results"
|
|
35
36
|
|
|
36
37
|
# 余额/额度用尽的判定:HTTP 状态与业务错误消息双路径。
|
|
@@ -58,7 +59,7 @@ def detect_quota_exhausted(status_code=None, errmsg=None):
|
|
|
58
59
|
|
|
59
60
|
|
|
60
61
|
def user_message_for_error(status_code=None, quota_exhausted=False):
|
|
61
|
-
"""
|
|
62
|
+
"""按错误类型返回给用户的固定话术(本地模板,Agent 按原文告知用户,不要改写)。"""
|
|
62
63
|
if quota_exhausted:
|
|
63
64
|
return (f"检索调不动,很可能是积分用完了:到 {MAAS_PLATFORM_URL} 看一下积分,"
|
|
64
65
|
"完成实名认证可以再领 10 万积分。")
|