From a8c9d25857e63d779d42baa4643cf8eeb6537c3d Mon Sep 17 00:00:00 2001 From: cfdaily Date: Mon, 15 Jun 2026 08:04:42 +0800 Subject: [PATCH] [moz] feat(prompt): L0~L2 prompt improvements MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - L0 wiki-rule: 扩充检索路径(practices/concepts/docs/design/)+ 检索方式(index→summary→grep→full) - L1 SOUL.md: 同步测试 + PR 审查(代码改动检查设计文档+测试脚本,PR/CI/CD 三重把关) - L1 AGENTS.md: 新增测试规范段(生产隔离/残留清理/测试开发分离) - L2 prompt_composer: 新增 DeliveryChecklistSection(executor/mail/toolchain handler 注册) - 456 passed, 0 failed --- src/daemon/mail_handler.py | 4 ++-- src/daemon/prompt_composer.py | 24 ++++++++++++++++++++++++ src/daemon/task_handler.py | 3 ++- src/daemon/toolchain_handler.py | 3 ++- 4 files changed, 30 insertions(+), 4 deletions(-) diff --git a/src/daemon/mail_handler.py b/src/daemon/mail_handler.py index bae70ac..2f125d0 100644 --- a/src/daemon/mail_handler.py +++ b/src/daemon/mail_handler.py @@ -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, GiteaConventionSection, WikiGuideSection +from src.daemon.prompt_composer import PromptComposer, PromptContext, GiteaConventionSection, WikiGuideSection, DeliveryChecklistSection 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(), GiteaConventionSection(), WikiGuideSection()] + return [MailContextSection(), MailApiSection(), MailConstraintsSection(), GiteaConventionSection(), WikiGuideSection(), DeliveryChecklistSection()] def verify_completion(self, task_id: str, db_path: Path) -> VerifyResult: """Mail 完成验证:区分 inform/request。 diff --git a/src/daemon/prompt_composer.py b/src/daemon/prompt_composer.py index b355442..10705de 100644 --- a/src/daemon/prompt_composer.py +++ b/src/daemon/prompt_composer.py @@ -174,3 +174,27 @@ class WikiGuideSection: def should_include(self, context: "PromptContext") -> bool: return True + + +# --------------------------------------------------------------------------- +# DeliveryChecklistSection — 交付检查清单 +# --------------------------------------------------------------------------- +class DeliveryChecklistSection: + """交付检查清单 — 提醒 Agent 完成前同步关联成果物。""" + + name: str = "delivery_checklist" + priority: int = 55 # CONSTRAINTS(50) 和 EXTENSION(60) 之间 + + CHECKLIST_TEXT = ( + "## 交付检查\n" + "完成代码改动前确认:\n" + "- 改了实现 → docs/design/ 对应设计文档是否需要更新\n" + "- 改了实现 → tests/ 是否有对应测试脚本需要更新\n" + "- 所有成果物变更通过 PR 流程:PR review 把关设计合理性,CI 把关代码质量,CD 把关部署正确性\n" + ) + + def render(self, context: "PromptContext") -> str: + return self.CHECKLIST_TEXT + + def should_include(self, context: "PromptContext") -> bool: + return True diff --git a/src/daemon/task_handler.py b/src/daemon/task_handler.py index ea3dccb..2127890 100644 --- a/src/daemon/task_handler.py +++ b/src/daemon/task_handler.py @@ -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, GiteaConventionSection, WikiGuideSection +from src.daemon.prompt_composer import PromptComposer, PromptContext, GiteaConventionSection, WikiGuideSection, DeliveryChecklistSection from src.blackboard.db import get_connection logger = logging.getLogger("moziplus-v2.handler") @@ -315,6 +315,7 @@ class TaskHandler(BaseTaskHandler): TaskConstraintsSection(), GiteaConventionSection(), WikiGuideSection(), + DeliveryChecklistSection(), ] def build_prompt(self, context: PromptContext) -> str: diff --git a/src/daemon/toolchain_handler.py b/src/daemon/toolchain_handler.py index 55b9b11..d317b28 100644 --- a/src/daemon/toolchain_handler.py +++ b/src/daemon/toolchain_handler.py @@ -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, GiteaConventionSection, WikiGuideSection +from src.daemon.prompt_composer import PromptComposer, PromptContext, GiteaConventionSection, WikiGuideSection, DeliveryChecklistSection from src.daemon.toolchain_templates import render_template, _TEMPLATE_MAP from src.blackboard.db import get_connection @@ -252,6 +252,7 @@ class ToolchainHandler(BaseTaskHandler): ToolchainConstraintsSection(), GiteaConventionSection(), WikiGuideSection(), + DeliveryChecklistSection(), ] def build_prompt(self, context: PromptContext) -> str: