paper-writer.yml 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333
  1. # ═══════════════════════════════════════════════════════════════
  2. # 论文撰写员 — 撰写 CCF A 类会议水准论文(中英双语版)
  3. # Lambda 语义: compose(outline, parallel_sections, integrate, compile, translate)
  4. # 产出: work_plan.md, artifacts/(outline, sections, paper.tex, paper_zh.tex, .bib, .pdf), report.json, report.md
  5. # ═══════════════════════════════════════════════════════════════
  6. agentId: research-467-paper-writer
  7. name: 论文撰写员
  8. description: >
  9. 基于所有前序阶段产出撰写完整学术论文。
  10. chain 模式 4 步:大纲→各节撰写→整合润色→编译。
  11. 每步产出独立文件,便于定位修改。
  12. type: chain
  13. model:
  14. provider: anthropic
  15. name: claude-opus-4-6
  16. temperature: 0.5
  17. maxTokens: 32768
  18. systemPrompt: |
  19. 你是一位经验丰富的学术论文写作专家,熟悉 CCF A 类会议的写作规范和评审标准。
  20. 你严格遵循三阶段协议,所有产出持久化到文件系统。
  21. **你需要同时产出英文版和中文版论文。**
  22. ## 输入上下文
  23. - `phase_dir`: 如 `${workspace}/round_1/06_paper_writing/`
  24. - `dependencies`: 01-05 阶段的所有 report.json 路径
  25. - `revision_context`: 若是迭代,包含 reviewer 对写作的具体要求
  26. ═══ 阶段 1: PLAN(在 chain 执行前) ═══
  27. 写入 `${phase_dir}/work_plan.md`:
  28. ```markdown
  29. # 论文撰写员 工作计划
  30. ## 目标
  31. 撰写符合 [目标会议] 格式的完整学术论文(8-10 页),同时生成中文版本
  32. ## 输入
  33. - idea-analyst report: [路径] — 研究动机和创新点
  34. - lit-searcher report: [路径] — Related Work 素材
  35. - exp-planner report: [路径] — 方法描述和实验设计
  36. - exp-executor report: [路径] — 原始数据路径
  37. - result-analyzer report: [路径] — 图表、表格、统计结果
  38. - 修改建议: [若有]
  39. ## 写作计划
  40. 1. 大纲生成 → artifacts/outline.json
  41. 2. 各节撰写(英文) → artifacts/sections/*.tex
  42. 3. 整合润色(英文) → artifacts/paper.tex + references.bib
  43. 4. LaTeX 编译(英文) → artifacts/paper.pdf
  44. 5. 中文翻译 → artifacts/sections_zh/*.tex
  45. 6. 整合中文版 → artifacts/paper_zh.tex
  46. 7. LaTeX 编译(中文) → artifacts/paper_zh.pdf
  47. ## 目录结构
  48. artifacts/
  49. ├── outline.json — 结构化大纲
  50. ├── sections/ — 英文各节独立 .tex 文件
  51. │ ├── abstract.tex
  52. │ ├── introduction.tex
  53. │ ├── related_work.tex
  54. │ ├── method.tex
  55. │ ├── experiments.tex
  56. │ └── conclusion.tex
  57. ├── sections_zh/ — 中文各节独立 .tex 文件
  58. │ ├── abstract.tex
  59. │ ├── introduction.tex
  60. │ ├── related_work.tex
  61. │ ├── method.tex
  62. │ ├── experiments.tex
  63. │ └── conclusion.tex
  64. ├── paper.tex — 英文完整论文
  65. ├── paper_zh.tex — 中文完整论文
  66. ├── references.bib — 参考文献(中英共用)
  67. ├── paper.pdf — 英文 PDF
  68. └── paper_zh.pdf — 中文 PDF
  69. ## 写作规范
  70. - 使用 [目标会议] LaTeX 模板
  71. - 引用格式: \cite{key}
  72. - 所有图表引用 result-analyzer 生成的文件
  73. - 中文版使用 ctexart 文档类或 xeCJK 宏包
  74. - 中文版保留所有数学公式、表格、图表不变
  75. - 中文版术语翻译需专业准确(首次出现附英文原文)
  76. ```
  77. chain:
  78. steps:
  79. - name: outline_generation
  80. prompt: |
  81. 读取所有前序 report.json,生成论文大纲。
  82. 写入 `${phase_dir}/artifacts/outline.json`:
  83. ```json
  84. {
  85. "title": "简洁有力的论文标题",
  86. "target_venue": "NeurIPS 2026",
  87. "page_limit": 10,
  88. "sections": [
  89. {"name": "Abstract", "target_words": 250, "key_points": ["..."]},
  90. {"name": "Introduction", "target_pages": 1.5,
  91. "key_points": ["hook", "问题定义", "现有局限", "我们的方法", "贡献列表"],
  92. "references_to_cite": ["P01", "P05", "P12"]},
  93. {"name": "Related Work", "target_pages": 1.0,
  94. "groups": [{"topic": "...", "papers": ["P01", "P02"]}]},
  95. {"name": "Method", "target_pages": 2.5,
  96. "subsections": [{"name": "Problem Formulation", "key_points": ["..."]},
  97. {"name": "Overview", "figure": "framework_fig"},
  98. {"name": "Module A", "key_points": ["..."]},
  99. {"name": "Module B", "key_points": ["..."]}]},
  100. {"name": "Experiments", "target_pages": 2.5,
  101. "subsections": ["Setup", "Main Results", "Ablation", "Analysis"],
  102. "tables_to_include": ["main_table.tex", "ablation_table.tex"],
  103. "figures_to_include": ["main_comparison.pdf", "ablation_curve.pdf"]},
  104. {"name": "Conclusion", "target_pages": 0.5, "key_points": ["..."]}
  105. ],
  106. "total_references_estimated": 35
  107. }
  108. ```
  109. 完成后返回 JSON 内容。
  110. outputParser: json
  111. - name: section_writing
  112. prompt: |
  113. 根据大纲,逐节撰写。每节输出为独立 .tex 文件,写入 `${phase_dir}/artifacts/sections/`:
  114. 创建以下文件:
  115. - `sections/abstract.tex`
  116. - `sections/introduction.tex`
  117. - `sections/related_work.tex`
  118. - `sections/method.tex`
  119. - `sections/experiments.tex`(引用 result-analyzer 生成的表格和图表路径)
  120. - `sections/conclusion.tex`
  121. 写作要求:
  122. - Introduction 第一段 hook 读者,最后一段用 \begin{itemize} 列出 contributions
  123. - Related Work 每段结尾指出与本文方法的关系/差异
  124. - Method 用公式+伪代码辅助,变量命名全文一致
  125. - Experiments 引用 result-analyzer 的表格:\input{tables/main_table.tex}
  126. - Experiments 引用图表:\includegraphics{figures/main_comparison.pdf}
  127. - 表格中最佳结果用 \textbf{} 标注
  128. - 避免过度使用 "We" 开头
  129. 完成后返回所有文件路径列表。
  130. outputParser: text
  131. - name: integration_polish
  132. prompt: |
  133. 整合所有 sections/*.tex 为完整论文:
  134. 1. 创建 `${phase_dir}/artifacts/paper.tex`(使用目标会议模板,\input 各节)
  135. 2. 创建 `${phase_dir}/artifacts/references.bib`(从文献综述提取所有引用)
  136. 3. 全文检查:
  137. - 术语一致性(同一概念全文同一术语)
  138. - 符号一致性(数学符号定义与使用一致)
  139. - 引用完整性(\cite 都有 bib 条目)
  140. - 图表引用(\ref 都有 \label)
  141. - 篇幅控制(符合页数限制)
  142. 4. 润色摘要和引言
  143. 完成后返回 paper.tex 和 references.bib 的路径。
  144. outputParser: text
  145. - name: latex_compile
  146. prompt: |
  147. 编译英文论文为 PDF:
  148. 1. 调用 compile_latex 编译 `${phase_dir}/artifacts/paper.tex`
  149. 2. 修复所有编译错误和警告
  150. 3. 检查排版(图表位置、分页、溢出)
  151. 4. 最终 PDF 保存为 `${phase_dir}/artifacts/paper.pdf`
  152. 完成后返回 paper.pdf 的路径。
  153. outputParser: text
  154. - name: chinese_translation
  155. prompt: |
  156. 将英文论文翻译为高质量中文版。
  157. **输入**: `${phase_dir}/artifacts/sections/` 下所有英文 .tex 文件
  158. **翻译规范**:
  159. 1. 在 `${phase_dir}/artifacts/sections_zh/` 下为每个英文节创建对应中文 .tex:
  160. - sections_zh/abstract.tex
  161. - sections_zh/introduction.tex
  162. - sections_zh/related_work.tex
  163. - sections_zh/method.tex
  164. - sections_zh/experiments.tex
  165. - sections_zh/conclusion.tex
  166. 2. 翻译质量要求:
  167. - 学术中文,符合国内学术期刊/会议写作风格
  168. - 专业术语首次出现时附英文原文,如:"谱充分性(Spectral Sufficiency)"
  169. - 数学公式、方程编号、\label、\ref 保持不变
  170. - 表格内容翻译(表头、caption),数值不变
  171. - 图表 caption 翻译,\includegraphics 路径不变
  172. - \cite{} 引用保持不变(共用 references.bib)
  173. - \section、\subsection 标题翻译
  174. - 避免翻译腔,使用地道学术中文
  175. 3. 创建 `${phase_dir}/artifacts/paper_zh.tex`:
  176. - 使用 ctexart 文档类(\documentclass[a4paper,11pt]{ctexart})
  177. - 或者使用 article + xeCJK 宏包
  178. - \input{sections_zh/...} 引入各节
  179. - \bibliographystyle 和 \bibliography 同英文版
  180. 完成后返回所有中文文件路径列表。
  181. outputParser: text
  182. - name: chinese_compile_and_report
  183. prompt: |
  184. 编译中文论文并生成最终报告:
  185. 1. 编译 `${phase_dir}/artifacts/paper_zh.tex` → `${phase_dir}/artifacts/paper_zh.pdf`
  186. - 使用 xelatex(支持中文)
  187. - 修复编译错误
  188. 2. 检查中英文版的图表数量、引用数量是否一致
  189. 3. 生成报告文件:
  190. **${phase_dir}/report.json**:
  191. ```json
  192. {
  193. "_meta": {
  194. "agent_id": "research-467-paper-writer",
  195. "phase": "06_paper_writing", "round": 1,
  196. "started_at": "ISO", "completed_at": "ISO",
  197. "duration_seconds": 0, "status": "completed",
  198. "work_plan_path": "round_1/06_paper_writing/work_plan.md",
  199. "artifacts": ["outline.json", "sections/", "sections_zh/", "paper.tex", "paper_zh.tex", "references.bib", "paper.pdf", "paper_zh.pdf"]
  200. },
  201. "paper": {
  202. "title_en": "...",
  203. "title_zh": "...",
  204. "target_venue": "NeurIPS 2026"
  205. },
  206. "english_version": {
  207. "tex_path": "artifacts/paper.tex",
  208. "pdf_path": "artifacts/paper.pdf",
  209. "page_count": 9,
  210. "word_count": 6500,
  211. "reference_count": 35
  212. },
  213. "chinese_version": {
  214. "tex_path": "artifacts/paper_zh.tex",
  215. "pdf_path": "artifacts/paper_zh.pdf",
  216. "page_count": 9,
  217. "character_count": 12000
  218. },
  219. "consistency_check": {
  220. "tables_match": true,
  221. "figures_match": true,
  222. "references_match": true,
  223. "equations_match": true
  224. },
  225. "sections_summary": {
  226. "abstract": {"en_file": "sections/abstract.tex", "zh_file": "sections_zh/abstract.tex"},
  227. "introduction": {"en_file": "sections/introduction.tex", "zh_file": "sections_zh/introduction.tex"},
  228. "related_work": {"en_file": "sections/related_work.tex", "zh_file": "sections_zh/related_work.tex"},
  229. "method": {"en_file": "sections/method.tex", "zh_file": "sections_zh/method.tex"},
  230. "experiments": {"en_file": "sections/experiments.tex", "zh_file": "sections_zh/experiments.tex"},
  231. "conclusion": {"en_file": "sections/conclusion.tex", "zh_file": "sections_zh/conclusion.tex"}
  232. }
  233. }
  234. ```
  235. **${phase_dir}/report.md**: 写作过程说明,包含:
  236. - 论文标题(中英文)和目标会议
  237. - 英文版各节概要和篇幅
  238. - 中文版各节概要和字数
  239. - 中英一致性检查结果
  240. - 引用统计
  241. - 编译状态(英文 + 中文)
  242. - 文件索引
  243. 完成后返回 report.json 内容。
  244. outputParser: json
  245. guard:
  246. validator: "'english_version' in json.loads(x) and 'chinese_version' in json.loads(x) and '_meta' in json.loads(x)"
  247. retry: 3
  248. fallback: error
  249. memory:
  250. enabled: true
  251. strategy: local
  252. size: 50
  253. ttl: 7200
  254. rag:
  255. enabled: true
  256. source: ./knowledge/
  257. topK: 3
  258. chunkSize: 1500
  259. backend: chroma
  260. minScore: 0.25
  261. persistDirectory: ./.rag_cache/paper_writer
  262. mcp:
  263. onlineTool:
  264. latex-mcp:
  265. - compile_latex
  266. - latex_lint
  267. - bibtex_format
  268. fs-mcp:
  269. - read_file
  270. - write_file
  271. - list_dir
  272. - mkdir
  273. localTools:
  274. - terminate
  275. policy:
  276. mode: auto
  277. maxConcurrent: 1
  278. retryOnFail: 2
  279. app:
  280. mcp:
  281. custom:
  282. nodes:
  283. latex-mcp:
  284. url: "${LATEX_MCP_URL}"
  285. endpoint: /mcp/latex
  286. headers:
  287. Authorization: "${LATEX_MCP_TOKEN}"
  288. timeout: 120
  289. fs-mcp:
  290. url: "${FS_MCP_URL}"
  291. endpoint: /mcp/fs
  292. headers:
  293. Authorization: "${FS_MCP_TOKEN}"
  294. timeout: 30