Skip to content

Add Overleaf project automation scripts#30

Merged
amcheste merged 2 commits into
mainfrom
feature/overleaf-automation
Apr 26, 2026
Merged

Add Overleaf project automation scripts#30
amcheste merged 2 commits into
mainfrom
feature/overleaf-automation

Conversation

@amcheste-ai-agent

Copy link
Copy Markdown
Contributor

Summary

Two professional bash scripts that automate the lifecycle of the EWRL 2026 paper's Overleaf mirror. Companion to amcheste/overleaf-mcp#13, which adds the non-interactive CLI flags these scripts depend on.

bin/setup-overleaf-project.sh — one-shot project provisioning

export OVERLEAF_TOKEN=olp_xxxxxx     # mint at Overleaf → Account → Git Integration
bin/setup-overleaf-project.sh \
    --alias pokemon-rl-ewrl-2026 \
    --project-id 6620abc123 \
    --display-name "Pokemon RL — EWRL 2026"

Wires the new alias into the MCP config + keychain + local clone in one command:

  1. overleaf-mcp init --alias ... --project-id ... (registers alias)
  2. printf '%s' "$OVERLEAF_TOKEN" | overleaf-mcp auth add --project ... --token-stdin (stores token)
  3. git clone https://x:${OVERLEAF_TOKEN}@git.overleaf.com/<id> ... (clones with token redacted from output)
  4. overleaf-mcp doctor (verifies green)

Token never appears on the command line (no leak via ps). Version preflight requires overleaf-mcp >= 0.1.2 and prints clear upgrade instructions otherwise. Idempotent: re-running with --force overwrites the alias, an existing clone is left alone.

scripts/mirror_paper_to_overleaf.sh — git → Overleaf sync

scripts/mirror_paper_to_overleaf.sh                          # default alias
scripts/mirror_paper_to_overleaf.sh --alias my-paper         # different alias
scripts/mirror_paper_to_overleaf.sh --dry-run                # preview

Treats git as canonical, Overleaf as the render/edit mirror:

  1. Pulls from Overleaf first (git pull --ff-only) so manual web-UI edits aren't silently clobbered. If Overleaf has diverged the script aborts with explicit resolution instructions.
  2. Rsync paper/ → clone with --delete so removed files are pruned on Overleaf.
  3. Excludes LaTeX build artefacts (*.aux, *.bbl, *.log, etc.) — only source goes to Overleaf.
  4. Skips commit if nothing changed — re-running on a clean state is a no-op.
  5. Auto-generated commit message includes the source git SHA + branch for traceability across the two histories.

How they fit together

You write the paper in git → mirror_paper_to_overleaf.sh → Overleaf web UI renders / co-authors edit
                                                              ↓ (their edits)
You pull back via overleaf-mcp sync, then mirror again

The setup script is run once per project. The mirror script is run after every paper edit, or wired into a git post-commit hook.

Test plan

  • --help renders cleanly on both scripts
  • Missing required args fail with clear error messages and exit 2
  • Mirror script aborts cleanly when source dir or clone is missing
  • Setup script's version preflight rejects older overleaf-mcp installs
  • End-to-end run blocked on (a) Alan creating the Overleaf project and (b) overleaf-mcp PR chore: auto-assign PR creator #13 landing in develop

🤖 Generated with Claude Code

Two professional bash scripts that automate the lifecycle of the EWRL
2026 paper's Overleaf mirror:

bin/setup-overleaf-project.sh — one-shot project provisioning that
wires a new alias into overleaf-mcp's config + keychain + local clone
in a single command.  Token is read from $OVERLEAF_TOKEN so it never
appears on the command line (no leak via ps).  Performs a version
preflight (requires overleaf-mcp >= 0.1.2 for non-interactive flags),
runs `overleaf-mcp doctor` at the end to verify, and is idempotent:
re-running with --force overwrites the alias, an existing clone is
left alone.

scripts/mirror_paper_to_overleaf.sh — keeps git canonical and
Overleaf as a render/edit mirror.  Pulls Overleaf first (so manual
web-UI edits aren't clobbered), rsyncs paper/ → clone with --delete,
commits, pushes.  Excludes LaTeX build artefacts (*.aux, *.bbl, etc.)
so only source goes to Overleaf.  Skips the commit step entirely if
nothing changed; supports --dry-run for previewing.

Both scripts validated manually against missing-arg, missing-env,
missing-clone, and missing-source-dir error paths.  Real end-to-end
runs are gated on the user creating an Overleaf project and the
upstream overleaf-mcp PR (amcheste/overleaf-mcp#13) merging.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Overleaf returns 403 for any clone URL whose user component isn't
literally "git" (matching their documented format
https://git:<TOKEN>@git.overleaf.com/<PROJECT_ID>).  My initial draft
used "x:<TOKEN>" by analogy with GitHub's pattern, which 403s.

Confirmed against the live API by setup of the EWRL paper project.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@amcheste amcheste merged commit ded1f1e into main Apr 26, 2026
@amcheste amcheste deleted the feature/overleaf-automation branch April 30, 2026 23:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants