feat(engine): 提示词调用 + 执行者/门禁两模型 + 三种执行方式 + 版本号
改了什么 - 调 agent 不再拼 --skill/--node/--task:skill 名与 SKILL.md 相对路径写进提示词, 子进程 cwd 改成目标项目根(原来在引擎目录,相对路径找不到) - 模型收到图级 models:executor / gate,按节点 kind 自动分配,环境变量可覆盖; 删掉 13 处节点级 model:,对抗验证检查简化为「两个模型是否相同」 - run 启动三选一:会话内开子 agent(默认)/ 只用主会话(--solo)/ 独立 agent(--agent); 三个入口互斥,选独立 agent 不给 --agent 直接报错 - 新增 --version 与 version.py(0.2.0)、CHANGELOG.md;decisions.jsonl 首行记引擎版本 - install.sh 读目标项目的 version.py 并与本预设对比,不一致直接提示(预设与引擎必须成对升级) 为什么 - 真实 CLI 没有认 --skill 的,改成提示词后不用再为每个 CLI 写包装脚本 - 执行者与门禁两个模型做对抗验证,图里一处配完,节点不再重复声明 - 当前会话能开子 agent 时不必拉进程,少一层进程边界 怎么验证的 - 单元测试 25 → 46,全绿(python3 agents-workflow-engine/tests/test_units.py) - ./.agents/verify.sh 全部通过(72 项),166 条相对链接有效 - 假 agent 真跑:argv 为 -q --model <模型> <提示词>、pwd 等于项目根、 执行者 10 次 / 门禁 2 次;--solo 真跑一遍核对 prompts.md 抬头与话术 文档同步检查 - 已更新:agents-workflow-engine/README.md、CHANGELOG.md、AGENTS.md(§8 §10 §12 §13)、 .agents/plan 三份记录(agent-protocol / default-session-subagent / version) - 不涉及:agile-team-sdd、catalog.json、placeholders.md;graph.html 与泳道标题不动
This commit is contained in:
68
agents-workflow-engine/agents_workflow_engine/prompts.py
Normal file
68
agents-workflow-engine/agents_workflow_engine/prompts.py
Normal file
@@ -0,0 +1,68 @@
|
||||
"""把节点渲染成给 agent 的提示词。skill 写在提示词里,不再拼 --skill 参数。"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Optional
|
||||
|
||||
from .models import role_of
|
||||
|
||||
ROLE_TITLES = {"executor": "执行者", "gate": "门禁"}
|
||||
|
||||
|
||||
def build_prompt(node: dict, model: str, task: Optional[str] = None, manual: bool = False,
|
||||
allow_subagent: bool = True) -> str:
|
||||
"""拼一段自解释的提示词:谁、做什么、用哪个 skill、算做完的判定标准。
|
||||
|
||||
manual 表示不拉进程、把提示词交回当前会话;allow_subagent=False 时要求
|
||||
主会话自己干,不开子 agent。
|
||||
"""
|
||||
kind = node.get("kind")
|
||||
role = role_of(node)
|
||||
lines = [
|
||||
"[graph-master] 节点 %s · %s · 模型 %s(%s)"
|
||||
% (node["id"], node.get("title") or node["id"], ROLE_TITLES[role], model or "未配置")
|
||||
]
|
||||
if manual:
|
||||
lines.append("")
|
||||
if allow_subagent:
|
||||
lines.append(
|
||||
"你(当前会话)现在扮演%s。能开子 agent 就开一个去做;开不了就自己按 skill 做完。"
|
||||
% ROLE_TITLES[role]
|
||||
)
|
||||
else:
|
||||
lines.append(
|
||||
"你(当前会话里的主会话)现在扮演%s,自己按 skill 做完本节点,不要开子 agent。"
|
||||
% ROLE_TITLES[role]
|
||||
)
|
||||
skill = node.get("skill") or ""
|
||||
lines.append("")
|
||||
if skill:
|
||||
lines.append("用 skill `%s` 完成本节点。" % skill)
|
||||
lines.append("skill 文件(相对项目根):.agents/skills/%s/SKILL.md" % skill)
|
||||
lines.append("(能直接加载 skill 就用 skill;加载不到就直接读这个文件)")
|
||||
else:
|
||||
lines.append("按节点说明完成本节点。")
|
||||
if task:
|
||||
lines.append("")
|
||||
lines.append("本批任务:%s" % task)
|
||||
notes = node.get("note") or []
|
||||
if notes:
|
||||
lines.append("")
|
||||
lines.append("节点说明:")
|
||||
for note in notes:
|
||||
lines.append("- %s" % note)
|
||||
lines.append("")
|
||||
lines.append("完成标准:")
|
||||
step = 1
|
||||
lines.append("%s. 只改当前项目内的文件" % step)
|
||||
step += 1
|
||||
lines.append("%s. 结论写在标准输出,引擎只读 stdout" % step)
|
||||
step += 1
|
||||
if kind == "gate":
|
||||
lines.append("%s. 最后单独一行输出「满意」或「不满意」" % step)
|
||||
step += 1
|
||||
if manual:
|
||||
lines.append("(本次引擎假定通过、继续往下走;实际判定不满意时请回到对应的打回节点)")
|
||||
if node.get("batch"):
|
||||
lines.append("%s. 每条任务单独一行输出 `TASK: <id>`" % step)
|
||||
return "\n".join(lines)
|
||||
Reference in New Issue
Block a user