overleaf-sync
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseOverleaf Sync
Overleaf 同步
Bridge a local paper directory with an Overleaf project so that:
- You can keep editing in the Overleaf web UI (or share editing access with collaborators)
- ARIS can read your changes, run audits (,
/paper-claim-audit,/citation-audit), and push fixes back/auto-paper-improvement-loop
This uses the official Overleaf Git bridge (Premium feature). The agent never sees your authentication token — you do the one-time auth manually so the token lives in macOS Keychain, not in chat history or .
.git/config将本地论文目录与Overleaf项目桥接,实现:
- 你可以继续在Overleaf网页端编辑(或与协作者共享编辑权限)
- ARIS可以读取你的更改,运行审核(、
/paper-claim-audit、/citation-audit),并推送修复内容/auto-paper-improvement-loop
此功能使用官方Overleaf Git桥接(高级功能)。Agent绝不会接触你的身份验证令牌——你手动完成一次性身份验证,令牌将存储在macOS钥匙串中,不会出现在聊天记录或里。
.git/configWhen to Use This Skill
何时使用此技能
- You want to use Overleaf as the editing surface (better collaboration, shared with team) but still run ARIS pipelines locally
- You want to take an existing local ARIS paper and push it to Overleaf for a co-author to edit
- A collaborator made changes in Overleaf and you want to pull + diff them before continuing local work
- 你希望将Overleaf作为编辑界面(协作性更强,可与团队共享),但仍在本地运行ARIS流水线
- 你希望将现有的本地ARIS论文推送到Overleaf,供合著者编辑
- 协作者在Overleaf中进行了更改,你希望在继续本地工作前拉取并对比差异
Constants
常量
- CLONE_DIR_DEFAULT = (sibling of existing
paper-overleaf, NOT insidepaper/)paper/ - CREDENTIAL_HELPER = (macOS) /
osxkeychain(Windows) /manager(Linux fallback)cache - TOKEN_HANDLING = NEVER write token to disk, env var, or chat. User pastes it once into the terminal credential prompt; the OS keychain stores it from then on.
- CLONE_DIR_DEFAULT = (与现有
paper-overleaf同级,而非在paper/内部)paper/ - CREDENTIAL_HELPER = (macOS)/
osxkeychain(Windows)/manager(Linux备用)cache - TOKEN_HANDLING = 绝不将令牌写入磁盘、环境变量或聊天记录。用户在终端凭据提示中粘贴一次令牌;此后由操作系统钥匙串存储。
Architecture
架构
┌─────────────────┐ git pull/push ┌─────────────────┐
│ Local paper/ │ ◄─── rsync ──── ► │ paper-overleaf/ │ ◄──► Overleaf web
│ (ARIS audits) │ │ (git bridge) │ (collaborators)
└─────────────────┘ └─────────────────┘The directory is a git clone of the Overleaf project. The directory is the working copy where ARIS skills run. They are kept in sync via .
paper-overleaf/paper/rsyncSingle-source-of-truth rule: at any given time, treat one of them as authoritative for active editing. Switch directions explicitly with or , and run a check before either to surface unexpected divergence.
pullpushstatus┌─────────────────┐ git pull/push ┌─────────────────┐
│ Local paper/ │ ◄─── rsync ──── ► │ paper-overleaf/ │ ◄──► Overleaf web
│ (ARIS audits) │ │ (git bridge) │ (collaborators)
└─────────────────┘ └─────────────────┘paper-overleaf/paper/rsync单一数据源规则:在任何给定时间,将其中一个视为主动编辑的权威来源。通过或显式切换方向,并在执行任一操作前运行检查,以发现意外的分歧。
pullpushstatusSub-commands
子命令
setup <project-id>
— one-time
setup <project-id>setup <project-id>
— 一次性操作
setup <project-id>Sets up the bridge for a new Overleaf project. The user runs this in their own terminal, never through the agent. The skill ships with a hardened setup script that:
- Refuses to run unless stdin/stdout are a TTY (won't run inside an agent harness)
- Reads the token from a hidden prompt (no chat history, no shell history)
- Strips the token from the remote URL immediately after cloning
- Primes the OS keychain so subsequent agent operations are auth-free
- Auto-installs a hook in
pre-committhat refuses to commit any blob containing the token patternpaper-overleaf/.git/hooks/— a hard technical block, not a behavioral ruleolp_[A-Za-z0-9]{20,}
The agent's only role here is to print the user instruction:
Run this in your own terminal (NOT through me):
bash <ARIS_REPO>/tools/overleaf_setup.sh <project-id-or-url>
When it finishes, tell me "setup done" and I'll verify.After the user reports "setup done", the agent verifies (token-free):
bash
cd paper-overleaf
git remote -v # must show URL WITHOUT token
git config --get credential.helper
git fetch && git log --oneline -3 # must succeed without prompting
ls .git/hooks/pre-commit # must exist
bash <ARIS_REPO>/tools/overleaf_audit.sh . # must report "Audit clean"If exists but is empty (new Overleaf project), the agent then mirrors local into it (see workflow).
paper-overleaf/paper/push为新的Overleaf项目设置桥接。用户需在自己的终端中运行此命令,绝不能通过Agent执行。该技能附带一个加固的设置脚本,它会:
- 除非标准输入/输出为TTY,否则拒绝运行(不会在Agent环境中运行)
- 从隐藏提示中读取令牌(不会出现在聊天记录或Shell历史中)
- 克隆完成后立即从远程URL中移除令牌
- 初始化操作系统钥匙串,以便后续Agent操作无需身份验证
- 自动在中安装
paper-overleaf/.git/hooks/钩子,拒绝提交任何包含pre-commit令牌格式的Blob——这是一个硬性技术限制,而非行为规则olp_[A-Za-z0-9]{20,}
Agent的唯一作用是打印用户指令:
在你自己的终端中运行此命令(不要通过我):
bash <ARIS_REPO>/tools/overleaf_setup.sh <project-id-or-url>
完成后告诉我“setup done”,我会进行验证。用户报告“setup done”后,Agent将进行无令牌验证:
bash
cd paper-overleaf
git remote -v # 必须显示不含令牌的URL
git config --get credential.helper
git fetch && git log --oneline -3 # 必须无需提示即可成功运行
ls .git/hooks/pre-commit # 必须存在
bash <ARIS_REPO>/tools/overleaf_audit.sh . # 必须报告“Audit clean”如果已存在但为空(新Overleaf项目),Agent会将本地镜像到其中(见工作流)。
paper-overleaf/paper/pushpull
— before each editing session
pullpull
— 每次编辑会话前
pullbash
cd paper-overleaf && git pull --ff-onlybash
cd paper-overleaf && git pull --ff-onlyShow what changed since last pull
显示自上次拉取以来的更改
LAST=$(git rev-parse HEAD@{1})
git diff --stat $LAST..HEAD
git diff $LAST..HEAD -- 'sec/*.tex' # detailed view for prose changes
**Diff protocol — DO NOT blindly merge into local `paper/`.** Overleaf edits frequently include:
- **Half-finished sentences** (collaborator clicked save mid-thought)
- **Typos** that aren't in canonical references (`Lrage` for `Large`)
- **Commented-out blocks** that may be intentional or may be a stash
- **Number changes** that should re-trigger `/paper-claim-audit`
- **Cite key changes** that should re-trigger `/citation-audit`
For each diff hunk, decide one of:
| Hunk character | Action |
|----------------|--------|
| Clean editorial improvement | Sync into `paper/`, no audit needed |
| Numerical / claim change | Sync, then re-run `/paper-claim-audit` |
| New `\cite{...}` | Sync, then re-run `/citation-audit` |
| Half-sentence / obvious typo | Flag to user, do NOT auto-sync |
| New section / restructure | Stop, ask user before syncing |
After deciding per-hunk:
```bashLAST=$(git rev-parse HEAD@{1})
git diff --stat $LAST..HEAD
git diff $LAST..HEAD -- 'sec/*.tex' # 针对文本更改的详细视图
**差异协议——不要盲目合并到本地`paper/`中**。Overleaf编辑通常包含:
- **未完成的句子**(协作者在思考中途点击了保存)
- **拼写错误**(与标准引用不符,如`Lrage`应为`Large`)
- **被注释掉的代码块**可能是有意为之,也可能是暂存内容
- **数值更改**应重新触发`/paper-claim-audit`
- **引用键更改**应重新触发`/citation-audit`
对于每个差异块,需选择以下操作之一:
| 差异块特征 | 操作 |
|----------------|--------|
| 清晰的编辑改进 | 同步到`paper/`,无需审核 |
| 数值/声明更改 | 同步,然后重新运行`/paper-claim-audit` |
| 新增`\cite{...}` | 同步,然后重新运行`/citation-audit` |
| 未完成句子/明显拼写错误 | 标记给用户,不要自动同步 |
| 新增章节/结构调整 | 停止操作,询问用户后再同步 |
确定每个差异块的操作后:
```bashSync only the files the user approved into local paper/
仅将用户批准的文件同步到本地paper/
rsync -av paper-overleaf/sec/0.abstract.tex paper/sec/0.abstract.tex
rsync -av paper-overleaf/sec/0.abstract.tex paper/sec/0.abstract.tex
(or use Edit tool for surgical changes that skip half-sentences)
(或使用编辑工具进行精准更改,跳过未完成的句子)
undefinedundefinedpush
— after local editing
pushpush
— 本地编辑完成后
pushUse after ARIS skills have edited and you want collaborators on Overleaf to see the changes.
paper/bash
undefined在ARIS技能编辑完,且你希望Overleaf上的协作者看到更改时使用。
paper/bash
undefined1. Always pull first to surface remote drift
1. 始终先拉取以发现远程变更
cd paper-overleaf && git pull --ff-only
cd paper-overleaf && git pull --ff-only
2. If pull was a no-op, sync local paper → paper-overleaf
2. 如果拉取无变更,将本地paper同步到paper-overleaf
rsync -av --delete
--exclude='.git' --exclude='.DS_Store'
--exclude='.aux' --exclude='.log' --exclude='.bbl' --exclude='.blg'
--exclude='.fls' --exclude='.fdb_latexmk' --exclude='.out'
--exclude='.synctex.gz' --exclude='*.toc'
paper/ paper-overleaf/
--exclude='.git' --exclude='.DS_Store'
--exclude='.aux' --exclude='.log' --exclude='.bbl' --exclude='.blg'
--exclude='.fls' --exclude='.fdb_latexmk' --exclude='.out'
--exclude='.synctex.gz' --exclude='*.toc'
paper/ paper-overleaf/
rsync -av --delete
--exclude='.git' --exclude='.DS_Store'
--exclude='.aux' --exclude='.log' --exclude='.bbl' --exclude='.blg'
--exclude='.fls' --exclude='.fdb_latexmk' --exclude='.out'
--exclude='.synctex.gz' --exclude='*.toc'
paper/ paper-overleaf/
--exclude='.git' --exclude='.DS_Store'
--exclude='.aux' --exclude='.log' --exclude='.bbl' --exclude='.blg'
--exclude='.fls' --exclude='.fdb_latexmk' --exclude='.out'
--exclude='.synctex.gz' --exclude='*.toc'
paper/ paper-overleaf/
3. Show what would be pushed
3. 显示即将推送的内容
git status --short
git diff --stat
git status --short
git diff --stat
4. Commit + push
4. 提交并推送
git add -A
git commit -m "<descriptive message — what ARIS changed and why>"
git push
**Commit message protocol**: include the ARIS skill that produced the change so collaborators on Overleaf understand provenance. Examples:
- `paper-write: regenerated sec/3.assurance after audit cascade refactor`
- `citation-audit: fix 14 metadata entries (madaan2023, lee2024, ...)`
- `paper-claim-audit: correct sec/5 numbers vs results/run_2026_04_19.json`
**Confirmation gate**: `push` writes to a shared resource. ALWAYS show the user `git diff --stat` (and a representative hunk for prose changes) before running `git push`. Wait for explicit confirmation unless the user said `auto: true` upfront.git add -A
git commit -m "<描述性信息——ARIS更改了什么以及原因>"
git push
**提交信息协议**:需包含生成更改的ARIS技能,以便Overleaf上的协作者了解来源。示例:
- `paper-write: regenerated sec/3.assurance after audit cascade refactor`
- `citation-audit: fix 14 metadata entries (madaan2023, lee2024, ...)`
- `paper-claim-audit: correct sec/5 numbers vs results/run_2026_04_19.json`
**确认关卡**:`push`会写入共享资源。在运行`git push`前,始终向用户展示`git diff --stat`(以及文本更改的代表性差异块)。除非用户预先说明`auto: true`,否则需等待明确确认。status
— diagnostic
statusstatus
— 诊断
statusbash
cd paper-overleaf
git fetch
echo "=== Remote-vs-local divergence ==="
git log --oneline HEAD..origin/master # remote ahead
git log --oneline origin/master..HEAD # local ahead
echo "=== paper/ vs paper-overleaf/ divergence ==="
diff -rq --brief paper/ paper-overleaf/ 2>/dev/null \
| grep -v "Only in paper/.*\.\(aux\|log\|out\|fls\|fdb_latexmk\|bbl\|blg\|synctex\|toc\)" \
| grep -v "Only in paper-overleaf/.git" \
| grep -v "DS_Store"Three-way state assessment:
| Remote ahead? | paper/ vs paper-overleaf/ differ? | Meaning | Recommended action |
|---|---|---|---|
| No | No | Clean | Nothing to do |
| Yes | No | Overleaf has new edits | Run |
| No | Yes | Local ARIS edits unsynced | Run |
| Yes | Yes | Diverged — needs merge | Stop, surface to user, do NOT auto-resolve |
bash
cd paper-overleaf
git fetch
echo "=== 远程与本地差异 ==="
git log --oneline HEAD..origin/master # 远程领先
git log --oneline origin/master..HEAD # 本地领先
echo "=== paper/ 与 paper-overleaf/ 差异 ==="
diff -rq --brief paper/ paper-overleaf/ 2>/dev/null \
| grep -v "Only in paper/.*\.\(aux\|log\|out\|fls\|fdb_latexmk\|bbl\|blg\|synctex\|toc\)" \
| grep -v "Only in paper-overleaf/.git" \
| grep -v "DS_Store"三方状态评估:
| 远程领先? | paper/ 与 paper-overleaf/ 是否存在差异? | 含义 | 推荐操作 |
|---|---|---|---|
| 否 | 否 | 无差异 | 无需操作 |
| 是 | 否 | Overleaf有新编辑 | 运行 |
| 否 | 是 | 本地ARIS编辑未同步 | 运行 |
| 是 | 是 | 已分歧——需要合并 | 停止操作,告知用户,不要自动解决 |
Conflict Resolution
冲突解决
If fails because of true divergence:
git pull --ff-only- Do not run (which would auto-merge).
git pull - Do not run or
git reset --hard(destructive).git push --force - Show the user (their Overleaf commits) and
git log origin/master ^HEAD(local ARIS commits).git log HEAD ^origin/master - Ask the user which side to take per file, or to manually merge in Overleaf and then re-pull.
如果因真实分歧而失败:
git pull --ff-only- 不要运行(会自动合并)。
git pull - 不要运行或
git reset --hard(具有破坏性)。git push --force - 向用户展示(他们在Overleaf的提交)和
git log origin/master ^HEAD(本地ARIS的提交)。git log HEAD ^origin/master - 询问用户每个文件应保留哪一侧的内容,或让用户在Overleaf中手动合并后重新拉取。
Token Security — Defense in Depth
令牌安全——深度防御
Behavioral rules alone are not enough — the next agent reading this skill might forget them. The skill therefore relies on technical guards that hold even if the agent misbehaves:
| Layer | Guard | Where enforced |
|---|---|---|
| 1. Setup | | |
| 2. Input | Token is read by | |
| 3. Storage | Token goes straight into OS keychain via | |
| 4. Commits | | auto-installed by setup script |
| 5. Audit | | |
Behavioral rules (still apply, but secondary):
- Never ask the user to paste a token into chat. If they do anyway: (a) acknowledge it, (b) tell them to revoke it at https://www.overleaf.com/user/settings, (c) recover via keychain if already primed.
- Never write a token to a file (,
.env,.netrc, etc.) committed to any repo.tools/*.sh - Never include a token in a URL — strip it after clone.
git remote -v - On from push/pull, tell the user the keychain entry expired and to re-run
401 Unauthorized. Do not ask for a fresh token.overleaf_setup.sh
仅靠行为规则是不够的——后续读取此技能的Agent可能会忘记这些规则。因此,该技能依赖技术防护措施,即使Agent行为异常也能生效:
| 层级 | 防护措施 | 执行位置 |
|---|---|---|
| 1. 设置 | | |
| 2. 输入 | 通过 | |
| 3. 存储 | 令牌通过 | |
| 4. 提交 | | 由设置脚本自动安装 |
| 5. 审核 | | |
行为规则(仍适用,但为次要措施):
- 绝不要求用户将令牌粘贴到聊天中。如果用户仍这么做:(a) 确认收到,(b) 告知用户前往https://www.overleaf.com/user/settings撤销令牌,(c) 若已初始化钥匙串则通过钥匙串恢复。
- 绝不将令牌写入任何仓库中的文件(、
.env、.netrc等)。tools/*.sh - 绝不在URL中包含令牌——克隆后立即剥离。
git remote -v - 若推送/拉取时出现,告知用户钥匙串条目已过期,需重新运行
401 Unauthorized。不要请求新令牌。overleaf_setup.sh
Mutual-Exclusion Rule
互斥规则
The single biggest source of pain in two-way sync is simultaneous editing on both sides.
- If the user is in an active Overleaf editing session, ARIS skills should read-only access until the user runs
paper/./overleaf-sync pull - If ARIS is in the middle of or
/auto-paper-improvement-loop, the user should pause Overleaf editing until the loop finishes and/paper-writeis run./overleaf-sync push
When in doubt, run first.
status双向同步中最大的问题来源是双方同时编辑。
- 如果用户处于活跃的Overleaf编辑会话中,ARIS技能应对保持只读访问,直到用户运行
paper/。/overleaf-sync pull - 如果ARIS正在运行或
/auto-paper-improvement-loop,用户应暂停Overleaf编辑,直到循环完成并运行/paper-write。/overleaf-sync push
如有疑问,先运行。
statusOutput Contract
输出约定
- directory at repo root, git clone of Overleaf project (origin URL has NO token)
paper-overleaf/ - directory unchanged in role — still the ARIS working copy
paper/ - Each /
pulloperation: a one-line summary back to the user (commits pulled / pushed, file count, link to Overleaf project URL)push
- 仓库根目录下的目录,为Overleaf项目的Git克隆版本(远程URL不含令牌)
paper-overleaf/ - 目录的角色保持不变——仍是ARIS工作副本
paper/ - 每次/
pull操作:向用户返回一行摘要(拉取/推送的提交数、文件数、Overleaf项目URL链接)push
See Also
另请参阅
- — re-run after pulling Overleaf changes that touch numbers
/paper-claim-audit - — re-run after pulling Overleaf changes that add/edit
/citation-audit\cite{...} - — local LaTeX build; Overleaf compiles independently in the cloud
/paper-compile - Overleaf Git bridge docs: https://www.overleaf.com/learn/how-to/Using_Git_and_GitHub
- — 拉取涉及数值的Overleaf更改后重新运行
/paper-claim-audit - — 拉取新增/编辑
/citation-audit的Overleaf更改后重新运行\cite{...} - — 本地LaTeX构建;Overleaf在云端独立编译
/paper-compile - Overleaf Git桥接文档:https://www.overleaf.com/learn/how-to/Using_Git_and_GitHub