# Paper Generator
> 一個人 + LLM = 一支完整的研究團隊。
[](https://python.org)
[](LICENSE)
你給它一個研究主題和實驗數據,它還你一篇符合期刊標準的 LaTeX 論文。13 個 Agent 協同工作——規劃、檢索文獻、撰寫、對抗性質疑、驗證引文、排版、模擬評審——全自動,端到端。
然後你不確定論文質量?23 個虛擬研究角色隨時待命:首席研究員幫你選方向,魔鬼辯護人攻擊你的弱點,倫理官確保合規,文獻管理員修好每一條 BibTeX。
**這不是 copilot。這是一支團隊。**
**誰適合用:**
- **獨立研究者** — 一個人做完探索、寫作、驗證、投稿全流程
- **研究生** — 結構化的論文生成 + 模擬同行評審,快速迭代
- **AI 助手用戶** — 31 個 MCP 工具,Claude Desktop / VS Code Copilot 直接調用
---
## 快速開始
```bash
# 安裝
git clone <repo-url> && cd new-laxtax
pip install -e .
# 探索方向
paper-generator explore "knowledge distillation for medical image segmentation" \
--provider qianwen --model qwen3.6-plus --api-key $LLM_API_KEY
# 生成論文
paper-generator generate "knowledge distillation for polyp segmentation" \
--provider qianwen --model qwen3.6-plus --api-key $LLM_API_KEY \
--data-dir data --venue springer --no-human \
--from-exploration output/exploration_report.json
# 一鍵全流程:探索 → 生成 → 潤色 → 驗證
paper-generator chain "polyp segmentation with knowledge distillation" \
--provider qianwen --model qwen3.6-plus --api-key $LLM_API_KEY \
--data-dir data --venue springer
```
三條命令。從零到一篇可投稿的論文。
---
## 看它工作
```
你: paper-generator explore "transformer pruning for edge deployment"
系統: [5 個 Agent 啟動]
DiscoveryAgent — 從 Semantic Scholar + OpenAlex + Crossref + ArXiv + Google Scholar + DBLP 六源並行抓取文獻
ParserAgent — LLM 批量提取特徵
DirectionAgent — 聚類出 4 個研究方向
FeasibilityAgent — 評估每個方向的可行性、數據可得性、GPU 預算
ReportAgent — 生成排名報告
→ output/exploration_report.json
你: paper-generator generate "structured pruning via knowledge distillation" \
--from-exploration output/exploration_report.json --venue neurips
系統: [13 個 Agent 流水線]
DataAgent → PlanningAgent → KnowledgeAgent → NarrativeDirector →
LiteratureSynthesis → VoiceAlignment → WritingAgent →
DevilsAdvocate → VerificationAgent → VisualVerify → TypesettingAgent → ReviewAgent
[自動 3 輪 writing ↔ verification 修訂]
→ output/paper.tex + references.bib + paper.pdf
你: paper-generator audit output/paper.tex --bib-file output/references.bib
系統: [三維審計]
引文完整性 — 2 條 DOI 無效,1 條元數據不匹配
深度驗證 — 第 3 節的第 2 個聲稱缺乏 PDF 證據支持
AI 味檢測 — Discussion 段對沖語言密度偏高
→ audit_report.json (CRITICAL: 0, HIGH: 2, MEDIUM: 3, LOW: 1)
```
你說「探索 transformer pruning」。系統從五個學術數據庫抓了 30+ 篇文獻,聚類出方向,評估可行性,生成論文,然後自己審計自己。全程不需要你動手。
---
## 生成流水線
**探索 → 規劃 → 撰寫 → 驗證 → 排版 → 審閱**
每個階段的 Agent 讀取上一階段的輸出,確保沒有遺漏。
### 13 個 Agent
| Agent | 做什麼 |
|-------|--------|
| **DataAgent** | 解析實驗 CSV,Data-View Decoupling 杜絕 LLM 臆造數據座標 |
| **PlanningAgent** | 生成 IMRaD 大綱,鎖定字數和期刊約束 |
| **KnowledgeAgent** | 檢索文獻,構建引用圖譜,每段綁定 DOI 錨點 |
| **NarrativeDirector** | 設計全局故事弧,按人類寫作順序(Method→Results→Intro→Discussion)編排 |
| **LiteratureSynthesis** | 將 Related Work 從「報菜名」升級為主題分組批判分析 |
| **VoiceAlignment** | 從範文 .tex 萃取風格 profile,Few-Shot Style Cloning |
| **WritingAgent** | 分節撰寫,引用密度控制,禁止套話和佔位符 |
| **DevilsAdvocate** | 生成 3-5 個對抗性問題,迫使 Discussion 深度反思 |
| **VerificationAgent** | 邏輯一致性 + 引文準確性 + 方法可復現性檢查 |
| **VisualVerify** | TCVR 循環:TikZ 編譯 → VLM 視覺評估 → LLM 修復 → 最多 3 輪 |
| **TypesettingAgent** | 套用期刊模板(IEEE / ACM / NeurIPS / Springer / Nature 等) |
| **ReviewAgent** | 四角色模擬同行評審(Critique / Support / Methodology / Editor) |
| **RebuttalAgent** | 逐條回覆審稿意見,生成修訂摘要 |
---
## Research Team — 23 個虛擬研究角色
在 AI 助手(Claude Desktop / VS Code Copilot)中使用 slash command 調用。每個角色封裝了特定的 MCP 工具組合。
### 核心角色
| 角色 | 技能 | 做什麼 |
|------|------|--------|
| 首席研究員 | `/research-direction` | 探索方向、選擇策略、規劃迭代、記錄反饋 |
| 文獻綜述專家 | `/lit-search` | 多源文獻檢索、歷史記憶搜索、競爭格局分析 |
| 方法論顧問 | `/methodology` | 研究設計、統計規劃、假設形式化 |
| 實驗設計師 | `/experiment-design` | 基線、消融因子、資源預算、時間線 |
| 數據分析師 | `/data-analysis` | 數據處理、表格/圖形生成、統計分析 |
| 敘事總監 | `/narrative` | 論文故事弧、節結構藍圖 |
| 論文撰寫人 | `/draft` | 調用 generate_paper 生成完整 LaTeX |
| 同儕評審小組 | `/peer-review` | 四審員對抗式評審 + 統一審計 |
| 引文驗證員 | `/verify` | DOI 驗證 + 聲稱-證據匹配 + PDF 下載 |
| 語言編輯 | `/polish` | 潤色、去 AI 味、風格校準 |
| 出版經理 | `/publish` | 版面格式、編譯、投稿包準備 |
| 實驗室主管 | `/research-pipeline` | 完整 A→F 管線編排 + 質量門禁 |
### 擴展角色
| 角色 | 技能 | 做什麼 |
|------|------|--------|
| 競爭格局分析師 | `/landscape` | 研究領域地圖、差異化機會、白色空間識別 |
| 盲點分析師 | `/gap-analysis` | 覆蓋缺口、跨學科機會、優先排序 |
| 假設放大器 | `/hypothesis` | 競爭假設生成、比較矩陣、人類選擇門 |
| 風格克隆專家 | `/style-align` | 參考文獻風格提取、語氣對齊、去 AI 味 |
| 可視化專家 | `/visualize` | TikZ/pgfplots 圖表生成 + TCVR 驗證循環 |
| 魔鬼辯護人 | `/challenge` | 五角度攻擊、聲稱-證據審計、討論強化 |
| 倫理官 | `/ethics-audit` | COPE 合規、AI 使用披露、數據倫理 |
| 文獻管理員 | `/bibliography` | BibTeX 修復、DOI 回填、PDF 下載 |
| 回覆撰稿人 | `/rebuttal` | 審稿意見逐條回覆、修訂摘要 |
| 進度管理員 | `/checkpoint` | 檢查點保存/恢復、管線狀態 |
| 回顧主持人 | `/retro` | 效率分析、質量演變、經驗教訓 |
### 研究管線六階段
| 階段 | 角色 | 質量門 |
|------|------|--------|
| **A. 探索** | `/research-direction` `/lit-search` | 至少 1 個方向分數 ≥ 75 |
| **B. 設計** | `/methodology` `/experiment-design` | 實驗計劃已批准 |
| **C. 分析** | `/data-analysis` | 至少 1 表格 + 1 圖形 |
| **D. 撰寫** | `/narrative` `/draft` | .tex 編譯成功 |
| **E. 品質** | `/peer-review` `/verify` `/polish` `/challenge` `/ethics-audit` | 評審均分 ≥ 6/10 |
| **F. 出版** | `/publish` `/bibliography` `/rebuttal` | 格式合規 + 投稿包就緒 |
關鍵決策使用 Voice A (LLM) + Voice B (DevilsAdvocateAgent) 雙模型對抗。分歧 > 3 分交由研究者決定。
---
## MCP Server — 31 個工具
AI 助手的原生接口。Claude Desktop、VS Code Copilot、ChatGPT 直接調用。
```bash
# stdio 模式(推薦)
paper-generator-mcp
# SSE 模式
paper-generator-mcp --transport sse
```
**Claude Desktop 配置:**
```json
{
"mcpServers": {
"paper-generator": {
"command": "paper-generator-mcp",
"args": []
}
}
}
```
### 原有工具(16 個)
| 工具 | 用途 |
|------|------|
| `explore_topic` | 六源文獻抓取 + LLM 方向挖掘 + 可行性評估 |
| `generate_paper` | 13 Agent 流水線生成完整 LaTeX 論文 |
| `polish_paper` | 7 Agent 潤色(語言 + AI 味 + 結構 + 審稿模擬) |
| `verify_citations` | DOI 驗證 + 元數據校驗 + 引文堆積檢測 |
| `deep_verify_citations` | PDF 提取 + LLM 聲稱-證據語義匹配 |
| `audit_paper` | 引文 + 深度驗證 + AI 味,三維統一審計 |
| `download_pdfs` | 從 Unpaywall / S2 / arXiv 自動獲取 PDF |
| `memory_search` | 語義搜索歷史探索結果 |
| `memory_feedback` | 標記方向為可行/不可行/需調整 |
| `list_checkpoints` | 查看管線緩存與探索進度 |
| `analyze_gaps` | 盲點識別 + 交叉方向機會 |
| `compare_landscape` | S2 + OpenAlex + ArXiv 三源競爭格局分析 |
| `plan_next_step` | 綜合探索/盲點/格局,決定下一步行動 |
| `execute_step` | 執行計劃步驟(白名單限制) |
| `design_experiment` | 結構化實驗計畫(假設、基線、數據集、度量) |
| `auto_research_loop` | 一鍵多輪迭代:explore → gaps → landscape → plan → execute |
### 新增工具(15 個)
#### Phase 1:暴露已有 Agent
| 工具 | 對應角色 | 用途 |
|------|----------|------|
| `analyze_data` | `/data-analysis` | CSV 數據 → LaTeX 表格 + pgfplots 圖表 |
| `design_narrative` | `/narrative` | 生成故事弧、節指令、寫作順序 |
| `compile_latex` | `/publish` | LaTeX 片段 → PNG 預覽 |
| `assemble_document` | `/publish` | 組裝最終 LaTeX 文檔(TypesettingAgent) |
| `generate_rebuttal` | `/rebuttal` | 逐條回覆審稿意見 |
| `extract_style_profile` | `/style-align` | 從參考論文提取寫作風格指紋 |
#### Phase 2:增強已有能力
| 工具 | 對應角色 | 用途 |
|------|----------|------|
| `simulate_review` | `/peer-review` | 多角色評審模擬 + 壓力測試 |
| `generate_figures` | `/visualize` | 數據圖表生成 + TCVR 視覺驗證循環 |
| `generate_adversarial_critique` | `/challenge` | 五角度對抗性質詢 |
| `synthesize_literature` | `/methodology` | 引用列表 → 主題分類綜述 |
| `plan_paper_outline` | `/hypothesis` | 假設生成 + 論文大綱規劃 |
#### Phase 3:全新能力
| 工具 | 對應角色 | 用途 |
|------|----------|------|
| `write_section` | `/draft` | 按節生成 LaTeX(Introduction、Method 等) |
| `fix_bibliography` | `/bibliography` | BibTeX 自動修復(DOI 回填、去重、規範化) |
| `check_ethics_compliance` | `/ethics-audit` | COPE 合規 + AI 披露 + 數據倫理檢查 |
| `save_research_checkpoint` | `/checkpoint` | 保存/恢復研究項目狀態 |
**自主探索循環:**
```
explore_topic → analyze_gaps → compare_landscape → plan_next_step → execute_step → ...
```
`auto_research_loop` 封裝了整個循環,收斂時自動停止(best_direction_score ≥ 75 且 coverage ≥ 60)。
---
## CLI 命令
8 個子命令,覆蓋完整研究工作流。
### 公共參數
| 參數 | 說明 | 默認值 |
|------|------|--------|
| `--provider` | `openai` / `anthropic` / `qianwen` / `local` | `openai` |
| `--model` | 模型名稱 | `gpt-4o` |
| `--api-key` | API 密鑰(或 `LLM_API_KEY` 環境變量) | — |
| `--config` | JSON 配置文件 | — |
### 各命令速查
```bash
# 探索(5 Agent 流水線)
paper-generator explore <query> [--seed-papers DOI1,DOI2] [-o OUTPUT_DIR]
# 生成(13 Agent 流水線)
paper-generator generate <topic> [-d DATA_DIR] [-v VENUE] [--from-exploration FILE]
[--no-review] [--no-human] [--style-reference paper1.tex] [--resume]
# 潤色(7 Agent 流水線)
paper-generator polish <tex_file> [--intensity conservative|balanced|aggressive]
[--num-reviewers N] [--target-journals J1,J2]
# 全流程串聯
paper-generator chain <topic> [-d DATA_DIR] [-v VENUE] [--skip-verify]
# 引文驗證(不需要 LLM)
paper-generator verify-citations <tex_file> [--bib-file FILE] [--check-doi] [--check-metadata]
# 深度引文驗證(需要 LLM)
paper-generator deep-verify <tex_file> [--pdf-dir DIR]
# 統一審計
paper-generator audit <tex_file> [--skip-deep-verify] [--skip-ai-flavor]
# PDF 下載
paper-generator download-pdfs <bib_file> [--pdf-dir DIR] [--email EMAIL]
```
**支持的期刊格式:** IEEE / ACM / NeurIPS / ACL / AAAI / ICLR / ICML / Springer / Nature
**支持的 LLM:** OpenAI / Anthropic / 通義千問 / 本地模型
---
## 安裝
```bash
pip install -e . # 基礎安裝
pip install -e ".[dev]" # 開發依賴(pytest, ruff)
pip install -e ".[mcp]" # MCP Server
pip install -e ".[vision]" # 視覺驗證(pdf2image)
pip install -e ".[deep-verify]" # 深度引文驗證(PyMuPDF)
pip install -e ".[langgraph]" # LangGraph 自主循環後端
pip install -e ".[exploration]" # 語義搜索(sentence-transformers)
```
**可選外部工具:**
- TeX Live / MiKTeX — PDF 編譯
- [LanguageTool](https://languagetool.org/) — 語法檢查
---
## Web UI
```bash
paper-generator-ui # 或 python -m paper_generator.web_ui
```
訪問 `http://localhost:7860`。6 個標籤頁:環境配置、論文生成、研究探索、論文潤色、結果查看、日誌監控。
---
## 架構
```
[研究主題 + 實驗數據 + 目標期刊]
│
▼
探索子系統(5 Agent + 自主循環)
DiscoveryAgent → ParserAgent → DirectionAgent → FeasibilityAgent → ReportAgent
│
▼
生成流水線(13 Agent)
Data → Planning → Knowledge → Narrative → Synthesis → Voice → Writing →
DevilsAdvocate → Verification → VisualVerify → Typesetting → Review
│ ↑_________|
│ (最多 3 輪修訂)
▼
潤色子系統(7 Agent)
LangPolish → AIFlavor → StructOpt → FormatCheck → JournalMatch → RevSimul → Report
│
▼
審計工具(引文 + 深度驗證 + AI 味)
│
▼
[期刊級稿件 + 審計報告 + COPE 聲明]
```
### 品質防護三層
| 層級 | 時機 | 防護 |
|------|------|------|
| **預防** | 生成時 | 引用密度控制、禁止佔位符、套話限一次、禁止章節預覽句 |
| **潤色** | polish 時 | 套話去重(11 種 hedging 模式)、內容縮水保護、段落分割 |
| **安全網** | 編譯前 | 引用合併、近重複段落去重、6 項 LaTeX 結構修復 |
### 視覺驗證
- **Data-View Decoupling**:CSV 數據通過 `\pgfplotstableread` 在編譯時讀取,杜絕 LLM 臆造座標
- **TCVR 循環**:TikZ 編譯 → PNG 渲染 → VLM 視覺評估 → LLM 修復 → 最多 3 輪
- **TikZ 模板庫**:8 種預驗證骨架(架構圖、流水線、柱狀圖、熱力圖等)
---
## 項目結構
```
new-laxtax/
├── paper_generator/
│ ├── main.py # CLI 入口(8 個子命令)
│ ├── pipeline.py # 生成主流水線
│ ├── llm_client.py # OpenAI 相容 API 客戶端
│ ├── mcp_server.py # MCP Server(16 個工具)
│ ├── web_ui.py # Gradio Web UI
│ ├── agents/ # 論文生成 Agent(13 個)
│ │ ├── data_agent.py # Data-View Decoupling
│ │ ├── planning.py # 大綱生成
│ │ ├── knowledge.py # 文獻檢索
│ │ ├── narrative.py # 敘事導演
│ │ ├── synthesis.py # 文獻綜合
│ │ ├── voice.py # 風格對齊
│ │ ├── writing.py # 分節撰寫
│ │ ├── devils_advocate.py # 對抗性質疑
│ │ ├── verification.py # 邏輯/引文驗證
│ │ ├── visual_verify.py # TCVR 視覺驗證
│ │ ├── typesetting.py # 期刊排版
│ │ ├── review.py # 模擬同行評審
│ │ └── rebuttal.py # 審稿意見回覆
│ ├── exploration/ # 探索子系統(5 Agent + 自主工具鏈)
│ │ ├── orchestrator.py # 流水線編排
│ │ ├── discovery.py # 六源文獻發現
│ │ ├── parser.py # 特徵解析
│ │ ├── direction.py # 方向挖掘
│ │ ├── feasibility.py # 可行性評估
│ │ ├── report.py # 報告生成
│ │ ├── gap_analyzer.py # 盲點分析
│ │ ├── landscape.py # 競爭格局
│ │ ├── planner.py # 下一步規劃
│ │ ├── auto_loop.py # 自主研究循環
│ │ ├── experiment_design.py # 實驗設計
│ │ ├── memory.py # 探索記憶庫
│ │ └── langgraph_loop.py # LangGraph 後端
│ ├── polishing/ # 潤色子系統(7 Agent)
│ │ ├── orchestrator.py # 潤色編排
│ │ ├── lang_polish.py # 語言潤色
│ │ ├── ai_flavor.py # AI 味檢測
│ │ ├── struct_opt.py # 結構優化
│ │ ├── format_check.py # 格式合規
│ │ ├── journal_match.py # 期刊匹配
│ │ ├── review_simul.py # 審稿模擬
│ │ └── cope_declaration.py # COPE 聲明
│ └── tools/ # 獨立工具
│ ├── verify_citations.py # 引文驗證
│ ├── deep_verify.py # 深度引文驗證
│ ├── audit.py # 統一審計
│ └── latex_compiler.py # LaTeX 編譯器
├── research-team/ # 虛擬研究團隊(23 個角色技能)
│ ├── SKILL.md # 路由器
│ ├── TEAM.md # 角色參考手冊
│ └── <23 skill dirs>/ # 各角色 SKILL.md
├── tests/ # 測試
├── data/ # 實驗數據(CSV / 圖表)
├── config.example.json # 配置範例
└── pyproject.toml # 項目元數據
```
---
## 配置
```json
{
"llm": {
"provider": "qianwen",
"model": "qwen3.6-plus",
"base_url": "https://dashscope.aliyuncs.com/compatible-mode/v1",
"temperature": 0.3,
"max_tokens": 4096,
"timeout": 300
},
"retrieval": {
"serpapi_key": "",
"openalex_api_key": "",
"crossref_email": "",
"semantic_scholar_api_key": "",
"max_papers": 30,
"recent_years": 3
},
"polishing": {
"reviewer_strictness": "moderate",
"citation_stacking_threshold": 3
},
"venue": "springer",
"human_in_the_loop": true
}
```
完整範例見 [config.example.json](config.example.json)。
**環境變量:**
| 變量 | 說明 |
|------|------|
| `LLM_API_KEY` | LLM API 密鑰 |
| `LLM_BASE_URL` | API 端點 |
| `GRADIO_SERVER_PORT` | Web UI 端口(默認 7860) |
---
## 更新日誌
### v0.9.0 — MCP 工具全覆蓋(31 個工具)
**新增 15 個 MCP 工具**,使所有 23 個虛擬研究角色都有至少 1 個專屬工具:
**Phase 1 — 暴露已有 Agent(6 個工具):**
- `analyze_data` — DataAgent 包裝:CSV → LaTeX 表格 + pgfplots 圖表
- `design_narrative` — NarrativeDirectorAgent 包裝:故事弧 + 節指令 + 寫作順序
- `compile_latex` — StandaloneCompiler 包裝:LaTeX 片段 → PNG 預覽
- `assemble_document` — TypesettingAgent 包裝:組裝最終 LaTeX 文檔
- `generate_rebuttal` — RebuttalAgent 包裝:逐條回覆審稿意見
- `extract_style_profile` — VoiceAlignmentAgent 包裝:風格指紋提取
**Phase 2 — 增強已有能力(5 個工具):**
- `simulate_review` — ReviewAgent 包裝:多角色評審模擬 + 壓力測試
- `generate_figures` — DataAgent + VisualVerifyAgent:圖表生成 + TCVR 循環
- `generate_adversarial_critique` — DevilsAdvocateAgent 包裝:五角度對抗質詢
- `synthesize_literature` — LiteratureSynthesisAgent 包裝:主題分類文獻綜述
- `plan_paper_outline` — PlanningAgent 包裝:假設生成 + 大綱規劃
**Phase 3 — 全新能力(4 個工具):**
- `write_section` — WritingAgent 包裝:按節生成 LaTeX
- `fix_bibliography` — BibTeX 自動修復(DOI 回填、去重、作者名規範化)
- `check_ethics_compliance` — COPE 合規 + AI 披露 + 數據倫理檢查
- `save_research_checkpoint` — 研究項目狀態保存/恢復
**其他改進:**
- `execute_step` 白名單擴展至 24 個工具
- 更新 TEAM.md 角色→工具映射
- 更新 copilot-instructions.md 工具文檔
### Research Team v1.1.0(2026-04-17)— 技能系統加固
- 24 個 SKILL.md 全部新增 Error Handling 表(按技能類型定制錯誤處理策略)
- 新增 `shared/dual-voice-protocol.md`(五角度攻擊、共識表模板、>3 分升級規則)
- 跨平台支持:`shared/preamble.md` 新增 bash↔PowerShell 等價命令表
- 修正工具列表:hypothesis(移除 generate_paper,加入 memory_search)、lit-search(加入 analyze_gaps)、methodology(加入 memory_search)、research-pipeline(加入 execute_step)
- 技能專屬增強:評審評分量表、6 源並行說明、截止日期感知、生成失敗恢復、API key 配置指引
### v0.8.0(2026-04-13)— 強大潤色 + MCP 一條龍
**Phase 1: 獨立引文驗證工具**
- 新增 `verify-citations` CLI 子命令
- DOI 驗證(Crossref API)、元數據交叉校驗(Semantic Scholar)
- 引文堆積檢測、SQLite 緩存、JSON 報告輸出
**Phase 2: AI 味檢測 Agent**
- 新增 `AIFlavorAgent`,插入潤色流水線 LangPolish→**AIFlavor**→StructOpt
- 6 維度檢測:句型重複、對沖語言密度、聲稱過度、列表/並列過密、被動語態密度、引文堆積
- 每段 AI-flavor 評分 0-1 + 具體問題標註
- AI-flavor 自動修正循環:高分段落自動向 LLM 請求改寫建議
**Phase 3: 視覺整合至潤色流程**
- 潤色開始前自動提取圖片並調用 VLM 生成描述
- StructOpt 新增 caption-figure 一致性檢查
- RevSimul 審稿模擬納入圖表評價
- FormatCheck 新增 caption 校驗
**Phase 4: MCP Server**
- 新增 `paper-generator-mcp` 入口點(FastMCP SDK)
- 16 個工具:基礎 6 + 探索記憶 3 + 自主探索 4 + 自主循環 + 實驗設計 + PDF 下載
- 支持 stdio / SSE 傳輸模式
- 路徑遍歷安全防護
**Phase 5: 深度引文驗證 v2**
- 新增 `deep-verify` CLI 子命令
- PyMuPDF 提取被引 PDF 文本
- LLM 聲稱-證據語義匹配,可信度評分 0-1
**Phase 6: CEO Review 全面加固**
- 新增 `audit` CLI 子命令——統一審計(引文 + 深度驗證 + AI 味)
- `chain` 命令新增自動驗證,`--skip-verify` 可跳過
- API 客戶端重構,審稿人性格系統,安全修復
**Phase 8-10: 自主探索 + PDF 下載**
- `auto_research_loop` 一鍵多輪迭代
- 多源文獻並行抓取(6 源)
- `design_experiment` 結構化實驗計畫
- `download-pdfs` 從 Unpaywall / S2 / arXiv 獲取 PDF
- LangGraph StateGraph 可選後端
**Research Team Phase 1-2: 虛擬研究團隊**
- 12 個核心角色 + 11 個擴展角色 = 23 個研究技能
- 雙聲道對抗協議(Voice A + Voice B)
- 六階段管線 + 質量門禁
**Phase 7: 自主探索工具鏈**
- 新增 4 個 MCP 工具:`analyze_gaps`、`compare_landscape`、`plan_next_step`、`execute_step`
- 新增探索記憶系統:`memory_search`、`memory_feedback`、`list_checkpoints`(3 個 MCP 工具)
- `GapAnalyzer` 盲點與交叉方向分析(LLM + 啟發式回退)
- `LandscapeAnalyzer` 競爭格局分析(Semantic Scholar 文獻抓取 + LLM 差異化評估)
- `Planner` 下一步規劃(deep_dive / pivot / broaden / need_data / converged)
- `execute_step` 白名單分發器,安全限制可調用工具範圍
- 探索記憶庫:TF-IDF 語義搜索、反饋權重調整、持久化存儲
- 32 個新測試
### v0.6.0(2026-04-10)— 流水線健壯性升級
**6 項關鍵 Bug 修復**,消除了 `chain` 命令 exit code 1 的級聯失敗鏈:
| # | 文件 | 問題 | 修復 |
|---|------|------|------|
| 1 | `exploration/discovery.py` | OpenAlex API 返回 `"source": null` 導致 `NoneType.get()` 崩潰 | 改用 `(or {})` 防禦鏈:`((item.get("primary_location") or {}).get("source") or {}).get("display_name", "")` |
| 2 | `agents/planning.py` | `chat_json()` 調用無 try/except,JSON 解析失敗直接崩潰 | 添加異常捕獲,拋出帶上下文的 `RuntimeError` |
| 3 | `agents/knowledge.py` | `chat_json()` 調用無 try/except,導致流水線中斷 | 添加異常捕獲 + 空結果回退(`{"references": [], "citation_plan": {}}`) |
| 4 | `agents/review.py` | `chat_json()` 調用無 try/except,審閱階段失敗即終止 | 添加異常捕獲 + 空字典回退,`_parse_review()` 返回默認 ReviewReport |
| 5 | `llm_client.py` | `_try_repair_json` 使用簡單計數修復截斷 JSON,無法處理字串內的括號 | 重寫為**棧式解析器**:追蹤 `in_string` 狀態、維護有序結構棧、正則清理尾部不完整的鍵值對 |
| 6 | `pipeline.py` | `_run_stage()` 對所有階段失敗一律 re-raise,非關鍵階段崩潰也會終止整個流水線 | 區分**關鍵階段**(`data`/`planning`/`writing`/`typesetting`)與非關鍵階段;非關鍵階段失敗僅記錄警告並繼續 |
**根因分析**:OpenAlex NoneType → JSON 截斷修復失敗 → 無保護的 `chat_json` 調用冒泡 → 流水線全階段 re-raise → exit code 1。六處修復形成縱深防禦。
### v0.5.x — 品質與排版改進
- **WritingAgent**:增強 `_SECTION_ROLES`(統計嚴謹度、可復現性、局限性),反誇大規則 #11
- **TypesettingAgent**:合規聲明節(Ethics、Data Availability、COPE AI 聲明),`_wrap_long_lines()` 修復 overfull boxes
- **LangPolishAgent**:balanced 模式段落密度指令
- **sanitize_latex**:浮動體邊界修復、寬表格 adjustbox 雙重包裝保護
- **converter.py**:Windows cp950 編碼修復(`encoding="utf-8"`),`-no-shell-escape` 安全加固
- **用戶自定義章節**:Pipeline + WritingAgent + WebUI + CLI `--user-sections`