"""Executable case prompts shared by synthesis, single reruns and batches.""" import re def case_prompt(case: dict) -> str: prefix = f"前置条件:\n{case['preconditions']}\n\n" if case.get("preconditions") else "" return prefix + case["goal"] def require_resolved_case(case: dict) -> str: """Drafts may contain parameters, but execution has no template substitution.""" prompt = case_prompt(case) variables = list(dict.fromkeys(re.findall(r"\$\{[^{}\r\n]+\}", prompt))) if variables: raise ValueError( "用例仍有未填写参数:" + "、".join(variables) + "。请在「查看 / 编辑」中填写实际值并保存新版本,或点击「重新提炼」;" "复跑和批次不会自动替换参数。未指定报告位置时可使用本次任务 trace。" ) return prompt