impl: #16 知识注入 L2 引擎层 — WikiGuideSection
- prompt_composer.py: 新增 WikiGuideSection 类(priority=60) - task_handler.py: get_sections() 注入 WikiGuideSection - mail_handler.py: get_sections() 注入 WikiGuideSection - toolchain_handler.py: get_sections() 注入 WikiGuideSection L0(gate-enforcer wiki-rule)和 L1(SOUL.md Red Flags)不在本仓库, 直接在对应文件修改。 设计文档:docs/design/16-knowledge-injection.md(v2 已合并)
This commit is contained in:
@@ -9,7 +9,7 @@ import logging
|
||||
from pathlib import Path
|
||||
|
||||
from src.daemon.base_task_handler import BaseTaskHandler, VerifyResult
|
||||
from src.daemon.prompt_composer import PromptComposer, PromptContext
|
||||
from src.daemon.prompt_composer import PromptComposer, PromptContext, WikiGuideSection
|
||||
from src.blackboard.db import get_connection
|
||||
|
||||
logger = logging.getLogger("moziplus-v2.handler.mail")
|
||||
@@ -36,7 +36,7 @@ class MailHandler(BaseTaskHandler):
|
||||
return composer.compose(context)
|
||||
|
||||
def get_sections(self) -> list:
|
||||
return [MailContextSection(), MailApiSection(), MailConstraintsSection()]
|
||||
return [MailContextSection(), MailApiSection(), MailConstraintsSection(), WikiGuideSection()]
|
||||
|
||||
def verify_completion(self, task_id: str, db_path: Path) -> VerifyResult:
|
||||
"""Mail 完成验证:区分 inform/request。
|
||||
|
||||
@@ -127,3 +127,27 @@ class PromptComposer:
|
||||
)
|
||||
|
||||
return result
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# WikiGuideSection — 知识查询引导段
|
||||
# ---------------------------------------------------------------------------
|
||||
class WikiGuideSection:
|
||||
"""知识查询引导段 — 引导 Agent 在关键决策点查 wiki-vault。"""
|
||||
|
||||
name: str = "wiki_guide"
|
||||
priority: int = 60 # PRIORITY_EXTENSION
|
||||
|
||||
WIKI_GUIDE = (
|
||||
"## 知识查询引导\n"
|
||||
"涉及方案设计、编码实现、故障排查时,先查 wiki-vault 相关实践:\n"
|
||||
"- 路径:/Volumes/KnowledgeBase/wiki-vault/\n"
|
||||
"- 速查:index.md → grep 关键词 → summary 字段 → 按需读全文\n"
|
||||
"- 查不到:在 _meta/knowledge-gaps.md 记录"
|
||||
)
|
||||
|
||||
def render(self, context: "PromptContext") -> str:
|
||||
return self.WIKI_GUIDE
|
||||
|
||||
def should_include(self, context: "PromptContext") -> bool:
|
||||
return True
|
||||
|
||||
@@ -10,7 +10,7 @@ from pathlib import Path
|
||||
from typing import Dict, Optional
|
||||
|
||||
from src.daemon.base_task_handler import BaseTaskHandler, VerifyResult
|
||||
from src.daemon.prompt_composer import PromptComposer, PromptContext
|
||||
from src.daemon.prompt_composer import PromptComposer, PromptContext, WikiGuideSection
|
||||
from src.blackboard.db import get_connection
|
||||
|
||||
logger = logging.getLogger("moziplus-v2.handler")
|
||||
@@ -313,6 +313,7 @@ class TaskHandler(BaseTaskHandler):
|
||||
RoleSkillSection(),
|
||||
TaskApiSection(),
|
||||
TaskConstraintsSection(),
|
||||
WikiGuideSection(),
|
||||
]
|
||||
|
||||
def build_prompt(self, context: PromptContext) -> str:
|
||||
|
||||
@@ -13,7 +13,7 @@ from pathlib import Path
|
||||
from typing import Dict, List
|
||||
|
||||
from src.daemon.base_task_handler import BaseTaskHandler, VerifyResult
|
||||
from src.daemon.prompt_composer import PromptComposer, PromptContext
|
||||
from src.daemon.prompt_composer import PromptComposer, PromptContext, WikiGuideSection
|
||||
from src.daemon.toolchain_templates import render_template, _TEMPLATE_MAP
|
||||
from src.blackboard.db import get_connection
|
||||
|
||||
@@ -226,6 +226,7 @@ class ToolchainHandler(BaseTaskHandler):
|
||||
ToolchainContextSection(),
|
||||
ToolchainApiSection(),
|
||||
ToolchainConstraintsSection(),
|
||||
WikiGuideSection(),
|
||||
]
|
||||
|
||||
def build_prompt(self, context: PromptContext) -> str:
|
||||
|
||||
Reference in New Issue
Block a user