AI-powered citation assistant for VS Code Copilot — Add academic citations to your LaTeX or Word documents through conversational interaction. All citations are sourced from real-time Semantic Scholar queries, eliminating AI hallucinations.
基于 VS Code Copilot 的学术引用助手 — 通过对话交互为你的 LaTeX 或 Word 文档自动添加学术引用,所有引用均来自 Semantic Scholar 实时查询,杜绝 AI 幻觉。
English | 中文
Based on KyuDan1/citeAgent. Credits to Kyudan Jung (정규단) for the original concept.
本项目改造自 KyuDan1/citeAgent,感谢原作者 Kyudan Jung (정규단) 的创意和工作。
| 原版 citeAgent | 本改造版 | |
|---|---|---|
| LLM | 需要 Gemini / Upstage API Key(付费) | VS Code Copilot 自身(无需额外 key) |
| 编辑方式 | Selenium 操控浏览器 ACE 编辑器 | VS Code 原生文件读写 |
| 同步 Overleaf | 必须在浏览器中打开 Overleaf | Overleaf Workshop 扩展自动同步 |
| 使用方式 | 命令行 python main.py |
Chat 对话式 @CiteAgent |
| 适用平台 | 主要支持 macOS (Safari AppleScript) | 全平台 (Windows / macOS / Linux) |
| 依赖 | openai, google-generativeai, selenium 等 |
零依赖 — 纯 Python stdlib |
| 使用范围 | 仅在项目目录内 | 任何 VS Code 工作区 |
| 交互方式 | 命令行单次处理 | 对话式,可指定段落/章节/全文 |
| 文件格式 | 仅 LaTeX (.tex) | LaTeX (.tex) + Word (.docx),支持 APA 7th、IEEE等格式输出 |
这是本工具最重要的设计原则。每一条引用都必须来自 Semantic Scholar API 的实时查询结果:
你的论文 (.tex)
↓
Copilot 分析 "哪里需要引用"(LLM 判断,无需真实数据)
↓
Copilot 生成搜索关键词(最多 3 个词)
↓
scholar.py 查询 Semantic Scholar API ← 唯一论文数据来源
↓
Copilot 从返回结果中选择最佳论文(仅能选,不能编造)
↓
使用 scholar.py 返回的 bibtex_key 和 bibtex_entry(原样使用)
↓
编辑 .tex 插入 \cite{},编辑 .bib 追加条目
5 条硬性约束:
- 每个
\cite{}的 key 必须来自scholar.py返回的 JSON - BibTeX 条目必须逐字复制
scholar.py返回的bibtex_entry - 必须先搜索、再引用,不能跳过搜索步骤
- 搜不到就跳过,不能用 LLM 自己"记忆"的论文凑数
- 搜到的论文标题必须与概念相关,不能张冠李戴
Semantic Scholar 索引论文的元数据(标题、作者、年份、引用数、DOI),涵盖几乎所有学术期刊和会议:
| 来源 | 覆盖 |
|---|---|
| Nature / Science / Cell | ✅ |
| IEEE / ACM / ACL / NeurIPS / ICML / CVPR | ✅ |
| Elsevier / Springer / Wiley | ✅ |
| arXiv 预印本 | ✅ |
无论论文是否开源,只要发表了就能搜到并生成正确的 BibTeX。
CiteAgent 不仅支持 LaTeX,还可以为 Word 文档生成 APA 7th 格式的引用:
- 分析文本内容,识别需要引用的概念
- 通过
scholar.py搜索真实论文 - 在文中插入
(Author, Year)格式的行内引用 - 使用
docx_helper.py生成带有可点击 DOI 超链接的 References 页 - 支持 APA 7th 格式:悬挂缩进、斜体期刊名、双倍行距
需额外安装
python-docx:pip install python-docx
- 零依赖安装:
scholar.py仅使用 Python 标准库(urllib+json),任何 Python 3.6+ 环境即可运行 - 全平台支持:Windows / macOS / Linux
- 对话式交互:可以处理整篇文档、指定章节、或粘贴的文本片段
- 智能引用放置:在概念首次出现处插入引用,而非仅在句末
- 自动匹配引用风格:检测文档已有的
\cite/\citep/\citet/\citeA风格并保持一致,支持 natbib、biblatex、apacite 和 IEEE - HTTP 200 来源核查:生成政策表、定义表、Excel/Word 报告或链接审计时,逐条验证来源链接可访问,并用关键词和证据片段确认来源支撑具体 claim
- 配合 Overleaf Workshop:编辑后文件自动同步到 Overleaf
- VS Code 已安装
- GitHub Copilot 扩展已安装并登录
- GitHub Copilot Chat 扩展已安装
- Python 3.6+(用于运行
scholar.py) - (可选)Overleaf Workshop 扩展 — 如需同步 Overleaf
git clone https://github.com/Di0105/CiteAgent-Copilot.git
cd CiteAgent-Copilot
.\install.ps1git clone https://github.com/Di0105/CiteAgent-Copilot.git
cd CiteAgent-Copilot
chmod +x install.sh
./install.sh-
将
scholar.py复制到你喜欢的位置(例如~/.agents/scripts/cite-agent/scholar.py) -
编辑
cite-agent.agent.md,找到 Step 3 中的scholar.py路径,替换为你的实际路径:python "/your/path/to/scholar.py" search "QUERY" --limit 5 --min-citations 10 -
将修改后的
cite-agent.agent.md复制到 VS Code 用户 prompts 目录:- Windows:
%APPDATA%\Code\User\prompts\ - macOS:
~/Library/Application Support/Code/User/prompts/ - Linux:
~/.config/Code/User/prompts/
- Windows:
-
重启 VS Code
python /path/to/scholar.py search "BERT" --limit 3如果输出 JSON 数组(包含论文信息),说明安装成功。
无 key 也能正常使用,但有速率限制(每分钟约 100 次请求)。如需提高限额:
- 在 Semantic Scholar API 免费申请 API Key
- 设置环境变量:
- Windows:
[System.Environment]::SetEnvironmentVariable("SEMANTIC_SCHOLAR_API_KEY", "your-key", "User") - macOS/Linux: 在
~/.bashrc或~/.zshrc中添加export SEMANTIC_SCHOLAR_API_KEY="your-key"
- Windows:
- 在 VS Code 中打开你的 LaTeX 项目
- 打开 Copilot Chat(
Ctrl+Shift+I或侧边栏) - 在 Agent 选择器中选择 CiteAgent
- 发送请求
@CiteAgent 帮我给 paper.tex 添加引用
@CiteAgent 只给 Introduction 部分添加引用
@CiteAgent 帮我给这段文字添加引用:
Self-supervised learning has revolutionized speech processing.
The Transformer architecture has become the backbone of modern speech models.
WavLM achieves state-of-the-art performance on the SUPERB benchmark.
@CiteAgent 帮我给这段文字添加 APA 7th 引用,输出为 Word 文档
CiteAgent 会:
- 分析文本,识别需要引用的概念
- 用
scholar.py搜索论文 - 生成带行内引用
(Author, Year)的文本 - 用
docx_helper.py创建 APA 7th 格式的 .docx,References 页的 DOI 均为可点击超链接
@CiteAgent 帮我给 methods.tex 添加引用,优先选择高引用论文(> 100 引用)
以下是 CiteAgent 处理一篇论文的完整流程:
输入 (paper.tex):
Self-supervised learning has revolutionized speech processing.
WavLM is a large-scale pre-training model designed for speech.
We use t-SNE for dimensionality reduction.CiteAgent 自动执行:
- 读取
paper.tex - 识别需要引用的概念:
WavLM、t-SNE、self-supervised learning - 运行搜索:
python scholar.py search "WavLM" python scholar.py search "t-SNE" python scholar.py search "self-supervised speech" - 从 Semantic Scholar 返回结果中选择最佳论文
- 编辑文件
输出 (paper.tex):
Self-supervised learning has revolutionized speech processing~\cite{baevski2020wav2vec}.
WavLM~\cite{chen2021wavlm} is a large-scale pre-training model designed for speech.
We use t-SNE~\cite{maaten2008visualizing} for dimensionality reduction.同时追加到 references.bib:
@article{chen2021wavlm,
title={WavLM: Large-Scale Self-Supervised Pre-Training for Full Stack Speech Processing},
author={Sanyuan Chen and Chengyi Wang and ...},
year={2021},
doi={10.1109/JSTSP.2022.3188113},
}
@article{maaten2008visualizing,
title={Visualizing Data using t-SNE},
author={Laurens van der Maaten and Geoffrey Hinton},
year={2008},
}- 安装 Overleaf Workshop 扩展
- 登录 Overleaf 并打开项目
- 正常使用
@CiteAgent— 编辑后的文件会自动同步到 Overleaf
CiteAgent-Copilot/
├── README.md # 本文档
├── LICENSE # MIT License
├── scholar.py # Semantic Scholar 搜索脚本(零依赖)
├── docx_helper.py # Word 文档辅助工具(需 python-docx)
├── cite-agent.agent.md # VS Code Copilot Agent 定义(模板)
├── install.ps1 # Windows 安装脚本
├── install.sh # macOS/Linux 安装脚本
└── examples/
├── paper.tex # 示例 LaTeX 文件(未引用)
└── references.bib # 空的 BibTeX 文件
- 原始项目: KyuDan1/citeAgent by Kyudan Jung (정규단) — CiteAgent 的核心理念(LLM + Semantic Scholar 防幻觉引用)源自此项目
- Semantic Scholar API: Semantic Scholar by Allen Institute for AI
- VS Code Copilot: GitHub Copilot
MIT License — 详见 LICENSE 文件
AI-powered citation assistant for VS Code Copilot — Add academic citations to your LaTeX or Word documents through conversational interaction. All citations are sourced from real-time Semantic Scholar queries, eliminating AI hallucinations.
Based on KyuDan1/citeAgent. Credits to Kyudan Jung for the original concept.
| Original citeAgent | This Version | |
|---|---|---|
| LLM | Requires Gemini / Upstage API Key | Uses VS Code Copilot (no extra key) |
| Editing | Selenium browser automation | Native VS Code file editing |
| Overleaf Sync | Must open Overleaf in browser | Overleaf Workshop extension auto-syncs |
| Usage | CLI python main.py |
Chat-based @CiteAgent |
| Platform | Primarily macOS (Safari AppleScript) | Cross-platform (Windows/macOS/Linux) |
| Dependencies | openai, selenium, etc. |
Zero dependencies (Python stdlib only) |
| Scope | Project-local only | Any VS Code workspace |
| File Formats | LaTeX (.tex) only | LaTeX (.tex) + Word (.docx) with APA 7th、IEEE output |
Every citation MUST come from Semantic Scholar API real-time query results. The agent is strictly forbidden from fabricating papers from its training data.
For structured outputs that depend on external links, such as policy tables, official-source summaries, definition tables, Excel workbooks, Word reports, or citation/link audits, CiteAgent verifies each source URL before relying on it. A source must return HTTP 200 and contain claim-specific evidence; otherwise the claim is revised, downgraded to a general clause, or omitted. Verification logs can include fetch status, matched keywords, missing patterns, and compact evidence snippets.
git clone https://github.com/Di0105/CiteAgent-Copilot.git
cd CiteAgent-Copilot
# Windows
.\install.ps1
# macOS / Linux
chmod +x install.sh && ./install.shOpen Copilot Chat in VS Code → select CiteAgent → send your request:
@CiteAgent Add citations to my paper.tex
@CiteAgent Only cite the Introduction section
@CiteAgent Add citations to this text: [paste LaTeX]
@CiteAgent Add APA 7th citations and generate a Word document
CiteAgent also supports Word documents with APA 7th formatting:
- In-text citations in
(Author, Year)format - References page with hanging indent, italicised journal names, and clickable DOI hyperlinks
- Requires
pip install python-docxfor thedocx_helper.pyutility
- VS Code with GitHub Copilot & Copilot Chat extensions
- Python 3.6+
- (Optional)
python-docxfor Word document generation - (Optional) Overleaf Workshop extension for Overleaf sync