dknowc-dsh 2.2.1 → 2.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +10 -38
- package/package.json +2 -2
- package/skills/dknowc-official-doc-writer/README.md +34 -31
- package/skills/dknowc-official-doc-writer/SKILL.md +87 -373
- package/skills/dknowc-official-doc-writer/reference/anti_ai_patterns.md +1 -1
- package/skills/dknowc-official-doc-writer/reference/fact_discipline.md +17 -2
- package/skills/dknowc-official-doc-writer/reference/genre_writing_notes.md +116 -0
- package/skills/dknowc-official-doc-writer/reference/initialization.md +69 -0
- package/skills/dknowc-official-doc-writer/reference/local_memory_guide.md +7 -7
- package/skills/dknowc-official-doc-writer/reference/material_usage_guidance.md +7 -0
- package/skills/dknowc-official-doc-writer/reference/materials_pipeline.md +42 -0
- package/skills/dknowc-official-doc-writer/reference/onboarding_scripts.md +44 -33
- package/skills/dknowc-official-doc-writer/reference/outline_rules.md +36 -0
- package/skills/dknowc-official-doc-writer/reference/output_guide.md +80 -12
- package/skills/dknowc-official-doc-writer/reference/research_notes.md +6 -4
- package/skills/dknowc-official-doc-writer/reference/review_checklist.md +24 -0
- package/skills/dknowc-official-doc-writer/reference/revision_workflow.md +2 -2
- package/skills/dknowc-official-doc-writer/reference/sample_trace_report.html +3 -3
- package/skills/dknowc-official-doc-writer/reference/search_guide.md +35 -33
- package/skills/dknowc-official-doc-writer/reference/search_intro.md +4 -4
- package/skills/dknowc-official-doc-writer/reference/search_policy.md +27 -19
- package/skills/dknowc-official-doc-writer/reference/standards/00_index.md +64 -78
- package/skills/dknowc-official-doc-writer/reference/standards/29_research.md +7 -0
- package/skills/dknowc-official-doc-writer/reference/standards/99_expressions.md +3 -2
- package/skills/dknowc-official-doc-writer/reference/task_router.md +3 -3
- package/skills/dknowc-official-doc-writer/reference/working_principles.md +32 -0
- package/skills/dknowc-official-doc-writer/reference/writing_rules.md +83 -0
- package/skills/dknowc-official-doc-writer/scripts/api_key.py +9 -2
- package/skills/dknowc-official-doc-writer/scripts/attribution.py +1 -1
- package/skills/dknowc-official-doc-writer/scripts/build_trace_json.py +43 -11
- package/skills/dknowc-official-doc-writer/scripts/check_materials.py +123 -14
- package/skills/dknowc-official-doc-writer/scripts/deep_convert.py +17 -14
- package/skills/dknowc-official-doc-writer/scripts/deep_query.py +3 -3
- package/skills/dknowc-official-doc-writer/scripts/dkag_search.py +133 -55
- package/skills/dknowc-official-doc-writer/scripts/extract_reference.py +1 -1
- package/skills/dknowc-official-doc-writer/scripts/format_document.py +43 -23
- package/skills/dknowc-official-doc-writer/scripts/initialize.py +15 -7
- package/skills/dknowc-official-doc-writer/scripts/mcp_direct.py +2 -3
- package/skills/dknowc-official-doc-writer/scripts/merge_search_results.py +36 -13
- package/skills/dknowc-official-doc-writer/scripts/outline_reference.py +1 -1
- package/skills/dknowc-official-doc-writer/scripts/prose_lint.py +7 -2
- package/skills/dknowc-official-doc-writer/scripts/register.mjs +540 -207
- package/skills/dknowc-official-doc-writer/scripts/render_trace_html.py +247 -44
- package/skills/dknowc-official-doc-writer/scripts/review_document.py +1 -1
- package/skills/dknowc-official-doc-writer/scripts/source_note_html.py +20 -8
- package/skills/dknowc-official-doc-writer/scripts/template_generator.py +1 -1
- package/skills/dknowc-ppt-assistant/README.md +21 -6
- package/skills/dknowc-ppt-assistant/SKILL.md +23 -68
- package/skills/dknowc-ppt-assistant/THIRD_PARTY_NOTICES.md +3 -2
- package/skills/dknowc-ppt-assistant/references/initialization.md +106 -0
- package/skills/dknowc-ppt-assistant/references/material_usage.md +12 -8
- package/skills/dknowc-ppt-assistant/references/onboarding_scripts.md +48 -17
- 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 +7 -0
- package/skills/dknowc-ppt-assistant/scripts/attribution.py +2 -2
- 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 +11 -13
- package/skills/dknowc-ppt-assistant/scripts/language_tags.py +1 -1
- package/skills/dknowc-ppt-assistant/scripts/mcp_convert.py +17 -15
- package/skills/dknowc-ppt-assistant/scripts/mcp_direct.py +3 -2
- 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 +2 -2
- package/skills/dknowc-ppt-assistant/scripts/project_utils.py +2 -2
- package/skills/dknowc-ppt-assistant/scripts/register_key.mjs +710 -322
- package/skills/dknowc-ppt-assistant/scripts/render_trace_html.py +207 -40
- 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 +63 -11
- package/skills/dknowc-ppt-assistant/scripts/update_spec.py +25 -1
- package/skills/dknowc-ppt-assistant/workflows/generate-pptx.md +30 -16
- package/skills/dknowc-ppt-assistant/workflows/routing.md +1 -1
- package/skills/dknowc-trusted-search/README.md +13 -13
- package/skills/dknowc-trusted-search/SKILL.md +96 -56
- package/skills/dknowc-trusted-search/reference/onboarding_scripts.md +40 -15
- package/skills/dknowc-trusted-search/scripts/api_key.py +11 -26
- package/skills/dknowc-trusted-search/scripts/attribution.py +1 -1
- package/skills/dknowc-trusted-search/scripts/deep_query.py +4 -2
- package/skills/dknowc-trusted-search/scripts/initialize.py +10 -10
- package/skills/dknowc-trusted-search/scripts/mcp_direct.py +3 -2
- package/skills/dknowc-trusted-search/scripts/merge_search_results.py +68 -10
- package/skills/dknowc-trusted-search/scripts/register_key.mjs +617 -275
- package/skills/dknowc-trusted-search/scripts/render_trace_html.py +87 -19
- package/skills/dknowc-trusted-search/scripts/trusted_search.py +109 -44
- package/skills/dknowc-official-doc-writer/scripts/mcp_convert.py +0 -272
- 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/svg_finalize/svg_rect_to_path.py +0 -346
- package/skills/dknowc-trusted-search/scripts/mcp_convert.py +0 -198
|
@@ -3,7 +3,8 @@
|
|
|
3
3
|
DKAG 素材召回接口脚本
|
|
4
4
|
用于根据查询关键词召回相关公文素材
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
使用深知可信搜索 V2 接口:/open-api/maas/dependable/v2/search
|
|
7
|
+
(V2 接口;不保留 V1 代码路径)
|
|
7
8
|
"""
|
|
8
9
|
|
|
9
10
|
import argparse
|
|
@@ -32,8 +33,8 @@ QUERY_TOO_SHORT_ERROR = f"错误:查询关键词过短,最少需要 {MIN_QUE
|
|
|
32
33
|
# API Key 与搜索结果路径
|
|
33
34
|
SKILL_ROOT = Path(__file__).resolve().parent.parent
|
|
34
35
|
API_KEY_ENV = "DKNOWC_API_KEY"
|
|
35
|
-
DEFAULT_BASE_URL = "https://open.dknowc.cn/dependable/search
|
|
36
|
-
# 工作区根:dsh 场景通过环境变量 DKNWOC_WS_ROOT 指向会话工作区,未设置时回退到 cwd
|
|
36
|
+
DEFAULT_BASE_URL = "https://open.dknowc.cn/open-api/maas/dependable/v2/search"
|
|
37
|
+
# 工作区根:dsh 场景通过环境变量 DKNWOC_WS_ROOT 指向会话工作区,未设置时回退到 cwd
|
|
37
38
|
import os as _os
|
|
38
39
|
_ws = _os.environ.get("DKNWOC_WS_ROOT")
|
|
39
40
|
if not _ws:
|
|
@@ -44,9 +45,12 @@ if not _ws:
|
|
|
44
45
|
WS_ROOT = Path(_ws).resolve()
|
|
45
46
|
SEARCH_RESULTS_DIR = WS_ROOT / "official-docs" / "search-results"
|
|
46
47
|
CONFIG_HELP_URL = "https://platform.dknowc.cn/"
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
DEFAULT_MATERIAL_LENGTH =
|
|
48
|
+
DEFAULT_SEGMENT_COUNT = 4 # 默认段数 4(经 2/4/8 参数对比,4/18000 质量最优)
|
|
49
|
+
DEFAULT_SIMPLIFIED = False
|
|
50
|
+
DEFAULT_MATERIAL_LENGTH = 18000 # 与 segmentCount=4 配套(经参数对比选定)
|
|
51
|
+
DEFAULT_SEARCH_TYPE = "policy" # V2 必填 searchType;每次调用只传一个,未指定时默认 policy
|
|
52
|
+
DEFAULT_FILTER_PARA = True # 剔除弱相关(R 级)段落
|
|
53
|
+
DEFAULT_QUERY_TOP_AREA = False # 上级地域材料走单独构路,不依赖接口开关
|
|
50
54
|
VALID_SEARCH_TYPES = {"policy", "affair", "govSite", "qa", "private"}
|
|
51
55
|
VALID_SEARCH_CHANNELS = {"govSearch", "webSearch", "wxSearch"}
|
|
52
56
|
|
|
@@ -284,7 +288,7 @@ def clean_dkag_response(api_response: dict) -> dict:
|
|
|
284
288
|
"发布日期": art.get("发布日期", ""),
|
|
285
289
|
"数据源": art.get("数据源", "未知来源"),
|
|
286
290
|
"段落": [],
|
|
287
|
-
# 检索通道标记:本产物来自深知可信搜索(
|
|
291
|
+
# 检索通道标记:本产物来自深知可信搜索(V2 生产入口)。
|
|
288
292
|
# 溯源报告据此区分"深度搜索 / 可信搜索"两个接口来源与各自路数。
|
|
289
293
|
"检索通道": "深知可信搜索",
|
|
290
294
|
}
|
|
@@ -310,6 +314,13 @@ def clean_dkag_response(api_response: dict) -> dict:
|
|
|
310
314
|
if art.get(key):
|
|
311
315
|
cleaned_art["快照链接"] = str(art[key]).strip()
|
|
312
316
|
break
|
|
317
|
+
# V2 新增文章级字段:原样透传(知识专库卡片展示 / 写作引用 / 素材分类使用)
|
|
318
|
+
for field in ("文章类型", "生效日期", "失效日期", "发文字号",
|
|
319
|
+
"文件标签", "发布或实施机构", "文章Id", "知识专库链接"):
|
|
320
|
+
if art.get(field) not in (None, ""):
|
|
321
|
+
cleaned_art[field] = art[field]
|
|
322
|
+
if art.get("知识专库链接"):
|
|
323
|
+
cleaned_art.setdefault("知识专库原文", str(art["知识专库链接"]).strip())
|
|
313
324
|
|
|
314
325
|
# 遍历段落并清洗
|
|
315
326
|
paragraphs = art.get("段落", [])
|
|
@@ -339,12 +350,15 @@ def clean_dkag_response(api_response: dict) -> dict:
|
|
|
339
350
|
content = content.strip()
|
|
340
351
|
|
|
341
352
|
if content:
|
|
342
|
-
# 分配全局唯一的自增 ID
|
|
343
|
-
|
|
353
|
+
# 分配全局唯一的自增 ID;V2 段落匹配等级原样保留(写作引用参考,不向用户展示)
|
|
354
|
+
paragraph = {
|
|
344
355
|
"id": global_id_counter,
|
|
345
356
|
"标题": p_title,
|
|
346
357
|
"内容": content
|
|
347
|
-
}
|
|
358
|
+
}
|
|
359
|
+
if p.get("匹配等级"):
|
|
360
|
+
paragraph["匹配等级"] = str(p["匹配等级"]).strip()
|
|
361
|
+
cleaned_art["段落"].append(paragraph)
|
|
348
362
|
global_id_counter += 1
|
|
349
363
|
|
|
350
364
|
# 只有当文章清洗后仍有有效段落时才添加
|
|
@@ -396,12 +410,15 @@ def dkag_search(
|
|
|
396
410
|
search_types: Optional[list[str]] = None,
|
|
397
411
|
search_channels: Optional[list[str]] = None,
|
|
398
412
|
material_length: Optional[int] = DEFAULT_MATERIAL_LENGTH,
|
|
413
|
+
segment_count: int = DEFAULT_SEGMENT_COUNT,
|
|
414
|
+
filter_para: bool = DEFAULT_FILTER_PARA,
|
|
415
|
+
query_top_area: bool = DEFAULT_QUERY_TOP_AREA,
|
|
399
416
|
) -> dict:
|
|
400
417
|
"""
|
|
401
|
-
|
|
418
|
+
调用深知可信搜索 V2 接口召回素材
|
|
402
419
|
|
|
403
420
|
API 文档:
|
|
404
|
-
- 请求路径: https://open.dknowc.cn/dependable/search
|
|
421
|
+
- 请求路径: https://open.dknowc.cn/open-api/maas/dependable/v2/search
|
|
405
422
|
- 请求方式: POST
|
|
406
423
|
- Content-Type: application/json
|
|
407
424
|
- 认证方式: api-key 请求头
|
|
@@ -414,15 +431,19 @@ def dkag_search(
|
|
|
414
431
|
purpose: 搜索方案中的搜索目的,用于素材来源说明中的知识专库链接显示名。
|
|
415
432
|
api_key: API 密钥(可选,如不传则从 DKNOWC_API_KEY 读取)
|
|
416
433
|
clean: 是否对返回结果进行数据清洗(默认 False)
|
|
417
|
-
policy: 是否返回规范性文件清单policyFiles(默认
|
|
434
|
+
policy: 是否返回规范性文件清单policyFiles(默认 True)
|
|
418
435
|
full: 是否返回文章全文(return_full_content,默认 False)
|
|
419
|
-
search_types: 指定搜索素材类型,如 policy、affair、govSite、qa、private
|
|
436
|
+
search_types: 指定搜索素材类型,如 policy、affair、govSite、qa、private;
|
|
437
|
+
V2 必填,每次调用只传一个,未指定时默认 policy;
|
|
438
|
+
需要不同来源时请分路并行调用后合并
|
|
420
439
|
search_channels: 指定动态搜索渠道,如 govSearch、webSearch、wxSearch
|
|
421
440
|
material_length: 控制返回素材总长度,默认 12000
|
|
422
|
-
|
|
441
|
+
segment_count: 每篇材料最多返回的相关段落数,默认 2(可调,用于参数调优)
|
|
442
|
+
filter_para: 是否剔除弱相关(R 级)段落,默认 True
|
|
443
|
+
query_top_area: 是否由接口带出上级地域材料,默认 False(上级材料走单独构路)
|
|
423
444
|
|
|
424
445
|
Returns:
|
|
425
|
-
|
|
446
|
+
搜索结果字典(含 tid,便于平台侧排查)
|
|
426
447
|
"""
|
|
427
448
|
# 验证查询关键词
|
|
428
449
|
if len(query) > MAX_QUERY_LENGTH:
|
|
@@ -458,28 +479,36 @@ def dkag_search(
|
|
|
458
479
|
VALID_SEARCH_CHANNELS,
|
|
459
480
|
"searchChannel"
|
|
460
481
|
)
|
|
482
|
+
if len(normalized_search_types) > 1:
|
|
483
|
+
raise ValueError(
|
|
484
|
+
"每次调用只传一个 searchType(policy / govSite / affair / qa / private);"
|
|
485
|
+
"需要不同来源时请分路并行调用后合并结果"
|
|
486
|
+
)
|
|
461
487
|
normalized_material_length = normalize_material_length(material_length)
|
|
488
|
+
if not isinstance(segment_count, int) or segment_count < 1:
|
|
489
|
+
raise ValueError("segmentCount 必须为正整数")
|
|
462
490
|
except ValueError as e:
|
|
463
491
|
return {
|
|
464
492
|
"error": True,
|
|
465
493
|
"message": str(e)
|
|
466
494
|
}
|
|
467
495
|
|
|
468
|
-
#
|
|
496
|
+
# 构建请求体(V2 格式:searchType 必填;segmentCount/filterPara/queryTopArea 可调)
|
|
469
497
|
payload = {
|
|
470
498
|
"query": query,
|
|
471
499
|
"eff_time": [normalized_time] if normalized_time else [""],
|
|
472
500
|
"service_area": [area] if area else [""],
|
|
501
|
+
"searchType": normalized_search_types or [DEFAULT_SEARCH_TYPE],
|
|
473
502
|
"knowBase": True,
|
|
474
503
|
"policy": policy,
|
|
475
504
|
"return_full_content": full,
|
|
476
|
-
"segmentCount":
|
|
477
|
-
"simplified":
|
|
478
|
-
"MaterialLength": normalized_material_length
|
|
505
|
+
"segmentCount": segment_count,
|
|
506
|
+
"simplified": DEFAULT_SIMPLIFIED,
|
|
507
|
+
"MaterialLength": normalized_material_length,
|
|
508
|
+
"filterPara": bool(filter_para),
|
|
509
|
+
"queryTopArea": bool(query_top_area),
|
|
479
510
|
}
|
|
480
511
|
|
|
481
|
-
if normalized_search_types:
|
|
482
|
-
payload["searchType"] = normalized_search_types
|
|
483
512
|
if normalized_search_channels:
|
|
484
513
|
payload["searchChannel"] = normalized_search_channels
|
|
485
514
|
|
|
@@ -508,53 +537,81 @@ def dkag_search(
|
|
|
508
537
|
"policy": policy,
|
|
509
538
|
"full": full,
|
|
510
539
|
"clean": clean,
|
|
511
|
-
"segmentCount":
|
|
512
|
-
"simplified":
|
|
540
|
+
"segmentCount": segment_count,
|
|
541
|
+
"simplified": DEFAULT_SIMPLIFIED,
|
|
513
542
|
"MaterialLength": normalized_material_length,
|
|
514
|
-
"searchType":
|
|
515
|
-
"searchChannel": normalized_search_channels
|
|
543
|
+
"searchType": payload["searchType"],
|
|
544
|
+
"searchChannel": normalized_search_channels,
|
|
545
|
+
"filterPara": bool(filter_para),
|
|
546
|
+
"queryTopArea": bool(query_top_area),
|
|
547
|
+
"tid": None,
|
|
516
548
|
}
|
|
517
549
|
|
|
518
|
-
# 发送请求(429 全部按额度用尽处理,不重试——见 detect_quota_exhausted 注释)
|
|
550
|
+
# 发送请求(429/402 全部按额度用尽处理,不重试——见 detect_quota_exhausted 注释)
|
|
519
551
|
try:
|
|
552
|
+
# 可信搜索为轻量补搜,默认 30 秒;深度搜索(deep_query.py)单次召回量大,默认 600 秒,两者按调用类型分别设定
|
|
520
553
|
response = requests.post(DEFAULT_BASE_URL, data=json.dumps(payload), headers=headers, timeout=30)
|
|
521
554
|
response.raise_for_status()
|
|
522
555
|
result = response.json()
|
|
523
|
-
|
|
524
|
-
# 新接口返回结构:content.检索文章
|
|
525
|
-
# 需要转换成旧接口的格式以保持兼容
|
|
526
|
-
if "content" in result and "检索文章" in result.get("content", {}):
|
|
527
|
-
# 包装成旧格式
|
|
528
|
-
result = {
|
|
529
|
-
"content": {
|
|
530
|
-
"data": result["content"]
|
|
531
|
-
}
|
|
532
|
-
}
|
|
533
|
-
|
|
534
|
-
if result.get("ret") not in (None, 0, "0") or result.get("errcode") not in (None, 0, "0"):
|
|
535
|
-
errmsg = result.get("errmsg")
|
|
536
|
-
biz_status = result.get("bizStatus")
|
|
537
|
-
quota_exhausted = detect_quota_exhausted(errmsg=errmsg, biz_status=biz_status)
|
|
556
|
+
if not isinstance(result, dict):
|
|
538
557
|
return {
|
|
539
558
|
"error": True,
|
|
540
|
-
"
|
|
541
|
-
"
|
|
542
|
-
if quota_exhausted else "深知搜索接口返回异常"),
|
|
543
|
-
"user_message": user_message_for_error(quota_exhausted=quota_exhausted),
|
|
544
|
-
"ret": result.get("ret"),
|
|
545
|
-
"errcode": result.get("errcode"),
|
|
546
|
-
"errmsg": errmsg,
|
|
547
|
-
"bizStatus": biz_status,
|
|
548
|
-
"maas_platform_url": MAAS_PLATFORM_URL if quota_exhausted else None,
|
|
549
|
-
"search_meta": search_meta
|
|
559
|
+
"message": "深知搜索接口返回格式异常",
|
|
560
|
+
"search_meta": search_meta,
|
|
550
561
|
}
|
|
551
562
|
|
|
563
|
+
# V2 返回结构:{tid, ret, content:{code, msg, data:{检索文章, policyFiles}}}
|
|
564
|
+
# 成功判定:ret==0(或无)且 content.code==200;业务错为 HTTP 200 + content.code=500 + 中文 msg。
|
|
565
|
+
search_meta["tid"] = result.get("tid")
|
|
566
|
+
content = result.get("content")
|
|
567
|
+
if isinstance(content, dict):
|
|
568
|
+
content_code = content.get("code")
|
|
569
|
+
if result.get("ret") not in (None, 0, "0") or content_code not in (None, 200, "200"):
|
|
570
|
+
msg = str(content.get("msg") or result.get("msg") or result.get("errmsg") or "").strip()
|
|
571
|
+
quota_exhausted = detect_quota_exhausted(errmsg=msg, biz_status=result.get("bizStatus"))
|
|
572
|
+
return {
|
|
573
|
+
"error": True,
|
|
574
|
+
"quota_exhausted": quota_exhausted,
|
|
575
|
+
"message": msg or "深知搜索接口返回异常",
|
|
576
|
+
"user_message": user_message_for_error(
|
|
577
|
+
status_code=(500 if str(content_code) == "500" else None),
|
|
578
|
+
quota_exhausted=quota_exhausted,
|
|
579
|
+
),
|
|
580
|
+
"tid": result.get("tid"),
|
|
581
|
+
"ret": result.get("ret"),
|
|
582
|
+
"content_code": content_code,
|
|
583
|
+
"msg": msg,
|
|
584
|
+
"maas_platform_url": MAAS_PLATFORM_URL if quota_exhausted else None,
|
|
585
|
+
"search_meta": search_meta
|
|
586
|
+
}
|
|
587
|
+
else:
|
|
588
|
+
# 扁平错误形态(如未包裹的 401):{code, msg},无 content
|
|
589
|
+
flat_code = result.get("code")
|
|
590
|
+
if flat_code not in (None, 0, 200, "200"):
|
|
591
|
+
msg = str(result.get("msg") or "").strip()
|
|
592
|
+
quota_exhausted = detect_quota_exhausted(status_code=flat_code, errmsg=msg)
|
|
593
|
+
return {
|
|
594
|
+
"error": True,
|
|
595
|
+
"quota_exhausted": quota_exhausted,
|
|
596
|
+
"message": msg or "深知搜索接口返回异常",
|
|
597
|
+
"user_message": user_message_for_error(
|
|
598
|
+
status_code=flat_code if flat_code in (401, 403, 402, 429, 500) else None,
|
|
599
|
+
quota_exhausted=quota_exhausted,
|
|
600
|
+
),
|
|
601
|
+
"tid": result.get("tid"),
|
|
602
|
+
"code": flat_code,
|
|
603
|
+
"msg": msg,
|
|
604
|
+
"maas_platform_url": MAAS_PLATFORM_URL if quota_exhausted else None,
|
|
605
|
+
"search_meta": search_meta
|
|
606
|
+
}
|
|
607
|
+
|
|
552
608
|
knowledge_base_url = extract_knowledge_base_url(result)
|
|
553
609
|
|
|
554
610
|
# 如果需要清洗数据
|
|
555
611
|
if clean:
|
|
556
612
|
cleaned_result = clean_dkag_response(result)
|
|
557
613
|
cleaned_result["search_meta"] = search_meta
|
|
614
|
+
cleaned_result["tid"] = search_meta.get("tid")
|
|
558
615
|
attach_knowledge_base_aliases(cleaned_result, knowledge_base_url or cleaned_result.get("knowledgeBase", ""))
|
|
559
616
|
return cleaned_result
|
|
560
617
|
result["search_meta"] = search_meta
|
|
@@ -604,7 +661,8 @@ def main():
|
|
|
604
661
|
parser.add_argument(
|
|
605
662
|
"--search-type",
|
|
606
663
|
action="append",
|
|
607
|
-
help="
|
|
664
|
+
help="指定单一搜索素材类型(每次调用只传一个):policy, affair, govSite, qa, private;"
|
|
665
|
+
"需要不同来源时请分路并行调用后合并"
|
|
608
666
|
)
|
|
609
667
|
parser.add_argument(
|
|
610
668
|
"--search-channel",
|
|
@@ -617,9 +675,26 @@ def main():
|
|
|
617
675
|
default=DEFAULT_MATERIAL_LENGTH,
|
|
618
676
|
help=f"控制返回素材总长度(默认: {DEFAULT_MATERIAL_LENGTH})"
|
|
619
677
|
)
|
|
678
|
+
parser.add_argument(
|
|
679
|
+
"--segment-count",
|
|
680
|
+
type=int,
|
|
681
|
+
default=DEFAULT_SEGMENT_COUNT,
|
|
682
|
+
help=f"每篇材料最多返回的相关段落数(默认: {DEFAULT_SEGMENT_COUNT};用于参数调优)"
|
|
683
|
+
)
|
|
684
|
+
parser.add_argument(
|
|
685
|
+
"--no-filter-para",
|
|
686
|
+
dest="filter_para",
|
|
687
|
+
action="store_false",
|
|
688
|
+
help="不过滤弱相关(R 级)段落;默认过滤"
|
|
689
|
+
)
|
|
690
|
+
parser.add_argument(
|
|
691
|
+
"--top-area",
|
|
692
|
+
action="store_true",
|
|
693
|
+
help="开启 queryTopArea(由接口带出上级地域材料);默认关闭,上级材料走单独构路"
|
|
694
|
+
)
|
|
620
695
|
parser.add_argument("--output", "-o", help="输出 JSON 文件路径(可选,默认输出到标准输出)")
|
|
621
696
|
|
|
622
|
-
parser.set_defaults(policy=True)
|
|
697
|
+
parser.set_defaults(policy=True, filter_para=True)
|
|
623
698
|
args = parser.parse_args()
|
|
624
699
|
|
|
625
700
|
# 调用搜索。配置缺失、API Key 缺失等启动阶段异常也输出为结构化 JSON,便于 Agent 稳定转述配置引导。
|
|
@@ -635,7 +710,10 @@ def main():
|
|
|
635
710
|
full=args.full,
|
|
636
711
|
search_types=args.search_type,
|
|
637
712
|
search_channels=args.search_channel,
|
|
638
|
-
material_length=args.material_length
|
|
713
|
+
material_length=args.material_length,
|
|
714
|
+
segment_count=args.segment_count,
|
|
715
|
+
filter_para=args.filter_para,
|
|
716
|
+
query_top_area=args.top_area,
|
|
639
717
|
)
|
|
640
718
|
except Exception as exc:
|
|
641
719
|
result = {
|
|
@@ -31,7 +31,7 @@ import sys
|
|
|
31
31
|
from pathlib import Path
|
|
32
32
|
|
|
33
33
|
SKILL_ROOT = Path(__file__).resolve().parent.parent
|
|
34
|
-
# 工作区根:dsh 场景通过环境变量 DKNWOC_WS_ROOT 指向会话工作区,未设置时回退到 cwd
|
|
34
|
+
# 工作区根:dsh 场景通过环境变量 DKNWOC_WS_ROOT 指向会话工作区,未设置时回退到 cwd
|
|
35
35
|
import os as _os
|
|
36
36
|
_ws = _os.environ.get("DKNWOC_WS_ROOT")
|
|
37
37
|
if not _ws:
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env python3
|
|
2
2
|
"""
|
|
3
3
|
公文排版脚本 v2.0.0
|
|
4
|
-
|
|
4
|
+
严格按照 config/format.json 与 reference/standards/ 的格式规范进行自动排版
|
|
5
5
|
|
|
6
6
|
【v2.0.0 更新说明】
|
|
7
7
|
- 删除所有红头文件相关代码(红头+尾表由 template_generator.py 处理)
|
|
@@ -17,7 +17,10 @@ import sys
|
|
|
17
17
|
from datetime import datetime
|
|
18
18
|
from pathlib import Path
|
|
19
19
|
|
|
20
|
-
|
|
20
|
+
try:
|
|
21
|
+
import docx
|
|
22
|
+
except ImportError: # 顶层导入失败时给出可执行的安装提示,而不是堆栈
|
|
23
|
+
raise SystemExit("缺少依赖 python-docx,请先执行:python3 -m pip install python-docx")
|
|
21
24
|
import docx.opc.constants
|
|
22
25
|
from docx.enum.section import WD_ORIENT, WD_SECTION
|
|
23
26
|
from docx.enum.table import WD_CELL_VERTICAL_ALIGNMENT, WD_TABLE_ALIGNMENT
|
|
@@ -103,8 +106,11 @@ def normalize_kb_label(label):
|
|
|
103
106
|
|
|
104
107
|
|
|
105
108
|
def is_internal_search_endpoint(url):
|
|
106
|
-
"""
|
|
107
|
-
return
|
|
109
|
+
"""识别深知搜索接口地址(V1 历史数据 / V2 生产入口),避免误当成知识专库链接输出。"""
|
|
110
|
+
return any(part in url for part in (
|
|
111
|
+
"open.dknowc.cn/dependable/search",
|
|
112
|
+
"open-api/maas/dependable/v2/search",
|
|
113
|
+
))
|
|
108
114
|
|
|
109
115
|
|
|
110
116
|
def is_generic_kb_label(text):
|
|
@@ -186,27 +192,43 @@ def get_configured_output_dir():
|
|
|
186
192
|
|
|
187
193
|
|
|
188
194
|
def is_path_within(path, parent):
|
|
189
|
-
"""判断 path 是否位于 parent
|
|
195
|
+
"""判断 path 是否位于 parent 目录内(按真实路径比较,解析符号链接)。"""
|
|
190
196
|
try:
|
|
191
|
-
return os.path.commonpath([os.path.
|
|
197
|
+
return os.path.commonpath([os.path.realpath(path), os.path.realpath(parent)]) == os.path.realpath(parent)
|
|
192
198
|
except ValueError:
|
|
193
199
|
return False
|
|
194
200
|
|
|
195
201
|
|
|
202
|
+
def read_text_auto(path):
|
|
203
|
+
"""按 utf-8-sig → utf-8 → gb18030 依次尝试读取正文,全部失败时给出明确提示。
|
|
204
|
+
|
|
205
|
+
中文材料常由 Word/WPS 另存为 GBK,硬用 utf-8 会直接抛 UnicodeDecodeError;
|
|
206
|
+
这里统一回退,并提示用户另存为 UTF-8 以便排查。
|
|
207
|
+
"""
|
|
208
|
+
raw = open(path, "rb").read()
|
|
209
|
+
for enc in ("utf-8-sig", "utf-8", "gb18030"):
|
|
210
|
+
try:
|
|
211
|
+
return raw.decode(enc)
|
|
212
|
+
except UnicodeDecodeError:
|
|
213
|
+
continue
|
|
214
|
+
raise SystemExit(
|
|
215
|
+
f"错误:无法识别正文文件编码({path})。请用文本编辑器另存为 UTF-8 后重试。")
|
|
216
|
+
|
|
217
|
+
|
|
196
218
|
def resolve_input_text_path(input_path):
|
|
197
|
-
"""只允许读取 skill
|
|
219
|
+
"""只允许读取 skill 工作目录内的正文文本文件(符号链接解析后校验)。"""
|
|
198
220
|
raw_path = os.path.expanduser(str(input_path).strip())
|
|
199
221
|
if os.path.isabs(raw_path):
|
|
200
|
-
resolved = os.path.
|
|
222
|
+
resolved = os.path.realpath(raw_path)
|
|
201
223
|
elif raw_path == os.path.basename(raw_path):
|
|
202
|
-
resolved = os.path.
|
|
224
|
+
resolved = os.path.realpath(os.path.join(INPUT_DIR, raw_path))
|
|
203
225
|
else:
|
|
204
|
-
resolved = os.path.
|
|
226
|
+
resolved = os.path.realpath(os.path.join(get_skill_root(), raw_path))
|
|
205
227
|
|
|
206
228
|
allowed_dirs = [
|
|
207
|
-
os.path.
|
|
208
|
-
os.path.
|
|
209
|
-
os.path.
|
|
229
|
+
os.path.realpath(INPUT_DIR),
|
|
230
|
+
os.path.realpath(get_configured_output_dir()),
|
|
231
|
+
os.path.realpath(SEARCH_RESULTS_DIR),
|
|
210
232
|
]
|
|
211
233
|
if not any(is_path_within(resolved, allowed_dir) for allowed_dir in allowed_dirs):
|
|
212
234
|
raise ValueError(f"输入文件必须位于 skill 工作目录内: {input_path}")
|
|
@@ -220,7 +242,7 @@ def _looks_like_path(text):
|
|
|
220
242
|
|
|
221
243
|
用于路径解析失败时的兜底判定:含路径分隔符,或以常见正文扩展名结尾时
|
|
222
244
|
视为路径——此时若文件读不到,宁可报错也不要把路径字符串当成正文写进 Word
|
|
223
|
-
|
|
245
|
+
(否则会静默生成一份正文只有一行路径的"正式公文")。
|
|
224
246
|
"""
|
|
225
247
|
value = (text or "").strip()
|
|
226
248
|
if not value or "\n" in value:
|
|
@@ -986,8 +1008,8 @@ def strip_citation_markers(content_text: str) -> str:
|
|
|
986
1008
|
|
|
987
1009
|
背景:素材清单先行要求写作时边写边标 [n] 角标——但角标只服务于
|
|
988
1010
|
build_trace_json 装配溯源 JSON、在溯源核验报告 HTML 中变成可点击跳转;
|
|
989
|
-
**正式 Word
|
|
990
|
-
|
|
1011
|
+
**正式 Word 交付的正文不应内嵌来源角标**(见 reference/output_guide.md 交付规则)。
|
|
1012
|
+
模型常把同一份带角标正文直接交给本脚本,导致 Word 交付物残留
|
|
991
1013
|
[1]…[23] 角标(带角标正文两用时,交付物曾残留 86~141 个角标)。
|
|
992
1014
|
本函数作为兜底,在排版前统一剥离半角 [n] 与全角 【n】 形式。
|
|
993
1015
|
"""
|
|
@@ -1718,7 +1740,7 @@ def create_document(content_text, output_path=None):
|
|
|
1718
1740
|
# 署名右空相应增加——两分支均满足"日期首字=署名首字右移2字"。
|
|
1719
1741
|
# 右缩进是"距右缘的字数",右移=更靠右=字数更小:设日期首字距右缘为 date_len+date_indent、
|
|
1720
1742
|
# 署名首字为 unit_len+unit_indent,右移二字即 date_len+date_indent = unit_len+unit_indent-2。
|
|
1721
|
-
#
|
|
1743
|
+
# 修正:两分支旧实现均少算 4 字(写成 unit_len+4-date_len 与 date_len-unit_len),
|
|
1722
1744
|
# 导致每份稿子的成文日期都比规则要求偏左。
|
|
1723
1745
|
if should_right_align_date(lines, i):
|
|
1724
1746
|
last_sign_date = stripped
|
|
@@ -1807,10 +1829,9 @@ def main():
|
|
|
1807
1829
|
text_path = None
|
|
1808
1830
|
if text_path and os.path.exists(text_path) and os.path.isfile(text_path):
|
|
1809
1831
|
print(f'⚠ 检测到 --text 参数是文件路径,自动读取文件内容: {text_path}')
|
|
1810
|
-
|
|
1811
|
-
content = f.read()
|
|
1832
|
+
content = read_text_auto(text_path)
|
|
1812
1833
|
elif _looks_like_path(args.text):
|
|
1813
|
-
#
|
|
1834
|
+
# 路径解析失败时不得把路径字符串当正文——旧实现会生成一份
|
|
1814
1835
|
# 正文只有一行路径的"正式公文",且打印成功、退出码 0,用户与模型都无从察觉
|
|
1815
1836
|
raise SystemExit(
|
|
1816
1837
|
f'错误:--text 收到的是文件路径而非正文({args.text}),且该文件无法读取。\n'
|
|
@@ -1826,8 +1847,7 @@ def main():
|
|
|
1826
1847
|
elif args.input:
|
|
1827
1848
|
input_path = resolve_input_text_path(args.input)
|
|
1828
1849
|
if os.path.exists(input_path):
|
|
1829
|
-
|
|
1830
|
-
content = f.read()
|
|
1850
|
+
content = read_text_auto(input_path)
|
|
1831
1851
|
else:
|
|
1832
1852
|
raise FileNotFoundError(f"输入文件不存在: {input_path}")
|
|
1833
1853
|
else:
|
|
@@ -1845,7 +1865,7 @@ def main():
|
|
|
1845
1865
|
print(f'✗ 生成失败: {e}')
|
|
1846
1866
|
import traceback
|
|
1847
1867
|
traceback.print_exc()
|
|
1848
|
-
#
|
|
1868
|
+
# 旧实现失败分支不设退出码,宿主按退出码判断成败时会把
|
|
1849
1869
|
# 失败当成功继续走交付话术,用户收到不存在的路径
|
|
1850
1870
|
sys.exit(1)
|
|
1851
1871
|
|
|
@@ -70,10 +70,9 @@ def check_environment():
|
|
|
70
70
|
"api_key_source": config_status["api_key_source"],
|
|
71
71
|
"api_key_hint": config_status["api_key_hint"],
|
|
72
72
|
"config_issue": None if config_status["api_key_configured"] else "api_key_missing",
|
|
73
|
-
# channel_note
|
|
73
|
+
# channel_note:检索通道提示(常驻,面向使用者,不含内部路线图)。
|
|
74
74
|
"channel_note": (
|
|
75
|
-
"检索与大纲统一走本 Skill 脚本通道(deep_query.py / dkag_search.py / outline_reference.py
|
|
76
|
-
"需要 API Key。MCP「深知可信工作台」通道于 3.7.5 停用,待其大结果落盘方案改造完成后另行加回。"
|
|
75
|
+
"检索与大纲统一走本 Skill 脚本通道(deep_query.py / dkag_search.py / outline_reference.py),需要 API Key。"
|
|
77
76
|
),
|
|
78
77
|
"search_ready": config_status["api_key_configured"] and requests_available,
|
|
79
78
|
"search_blocking_issues": search_blocking_issues,
|
|
@@ -91,7 +90,7 @@ def check_environment():
|
|
|
91
90
|
"font_note": "Word 文档会写入公文常用字体名称;打开端如缺少对应字体,Word/WPS 可能自动替换,需以本机打开后的显示为准。",
|
|
92
91
|
"blocking_issues": blocking_issues,
|
|
93
92
|
"ready": not blocking_issues,
|
|
94
|
-
"search_ready_note": None if config_status["api_key_configured"] else "仅需要搜索的任务需先完成 MaaS 注册获取 API Key
|
|
93
|
+
"search_ready_note": None if config_status["api_key_configured"] else "仅需要搜索的任务需先完成 MaaS 注册获取 API Key(写入本机 Key 专用配置文件或注入环境变量);无需搜索的任务可先直接写作。",
|
|
95
94
|
"local_memory": {
|
|
96
95
|
"knowledge_base_materials": kb_count,
|
|
97
96
|
"knowledge_base_dir": "knowledge-base/",
|
|
@@ -152,7 +151,7 @@ def _in_dsh() -> bool:
|
|
|
152
151
|
def check_api_key_config():
|
|
153
152
|
if _in_dsh():
|
|
154
153
|
# dsh:优先 DSH_DKNOWC_API_KEY(与 MCP Bearer 同源);缺失时 resolve_api_key 兜底
|
|
155
|
-
# (环境变量 →
|
|
154
|
+
# (环境变量 → 专用配置文件)。配置文件读取不受 dsh 环境清理影响,
|
|
156
155
|
# 注册后本会话脚本立即可用。无 Key 仅暂停搜索,不阻断纯写作。
|
|
157
156
|
api_key = os.environ.get("DSH_DKNOWC_API_KEY", "").strip()
|
|
158
157
|
source = "environment"
|
|
@@ -166,7 +165,7 @@ def check_api_key_config():
|
|
|
166
165
|
pass
|
|
167
166
|
if not _valid_api_key(api_key):
|
|
168
167
|
return {"api_key_configured": False, "api_key_source": None,
|
|
169
|
-
"api_key_hint": f"未检测到可用的 {API_KEY_ENV}
|
|
168
|
+
"api_key_hint": f"未检测到可用的 {API_KEY_ENV}(环境变量与专用配置文件均未找到)。运行注册脚本开通后 Key 自动写入 ~/.config/dknowc/api_key,本会话立即可用。仅搜索任务受影响,不涉及搜索的写作任务可继续。"}
|
|
170
169
|
return {"api_key_configured": True, "api_key_source": source, "api_key_hint": None}
|
|
171
170
|
|
|
172
171
|
|
|
@@ -191,7 +190,16 @@ def check_api_key_config():
|
|
|
191
190
|
|
|
192
191
|
|
|
193
192
|
def _valid_api_key(value):
|
|
194
|
-
|
|
193
|
+
"""判断 Key 是否像一份真实的检索密钥。
|
|
194
|
+
|
|
195
|
+
只做本地格式校验(不发网络请求):MaaS 密钥为 sk- 开头、长度不小于 20。
|
|
196
|
+
真实可用性(过期/无权限/额度用尽)由首次搜索调用的 401/403/429 分支处理,
|
|
197
|
+
避免每次初始化都多打一次接口。
|
|
198
|
+
"""
|
|
199
|
+
key = (value or "").strip()
|
|
200
|
+
if len(key) < 20 or not key.startswith("sk-"):
|
|
201
|
+
return False
|
|
202
|
+
return key not in {"your_api_key_here", "你的深知搜索 API Key"}
|
|
195
203
|
|
|
196
204
|
|
|
197
205
|
def main():
|
|
@@ -6,8 +6,7 @@
|
|
|
6
6
|
本地代理(127.0.0.1,路径带会话级 hash),内部持有真实凭据转发到云端 mcp.dknowc.cn。
|
|
7
7
|
环境变量 `CODEBUDDY_MCP_CONFIG` 内联 JSON 里含各 MCP server 的 url + headers
|
|
8
8
|
(Bearer 会话令牌)。脚本从该变量动态拿到 dknowc-mcp 的地址与头,直连代理发 JSON-RPC,
|
|
9
|
-
返回的完整 JSON 由脚本写入文件——模型不抄写大 JSON
|
|
10
|
-
(此前模型调 MCP 工具会把 60-170KB 返回抄进上下文再落盘,实测丢失 83%)。
|
|
9
|
+
返回的完整 JSON 由脚本写入文件——模型不抄写大 JSON,避免转写大返回时的内容丢失问题。
|
|
11
10
|
|
|
12
11
|
只负责"调用 + 落盘原始返回";转换仍走现有 deep_convert.py / mcp_convert.py。
|
|
13
12
|
|
|
@@ -31,7 +30,7 @@ import urllib.request
|
|
|
31
30
|
from pathlib import Path
|
|
32
31
|
|
|
33
32
|
SKILL_ROOT = Path(__file__).resolve().parent.parent
|
|
34
|
-
# 工作区根:dsh 场景通过环境变量 DKNWOC_WS_ROOT 指向会话工作区,未设置时回退到 skill
|
|
33
|
+
# 工作区根:dsh 场景通过环境变量 DKNWOC_WS_ROOT 指向会话工作区,未设置时回退到 skill 目录
|
|
35
34
|
import os as _os
|
|
36
35
|
_ws = _os.environ.get("DKNWOC_WS_ROOT")
|
|
37
36
|
if not _ws:
|