$ show VILA-Lab/FigMirror
FigMirror is a reference-conditioned scientific figure style transfer system that iteratively generates matplotlib scripts matching the visual style of a reference figure. It operates as a multi-agent loop (Drawer/Reviewer) orchestrated by a runner backend (Codex, Claude, or Mock), with a local web UI for upload, iteration browsing, and refinement. The system is packaged as skills for both Claude Code and Codex, plus a standalone web server. While primarily an application, it has a strong research component: the prompts, aesthetic library, and evaluation benchmarks (PlotTwin-Bench) are the result of extensive empirical iteration. The codebase demonstrates high craftsmanship in its runner architecture, atomic file operations, SSE streaming, and deterministic review gates. However, it suffers from dual skill bundles (Claude/Codex) that must stay synchronized, retired artifacts, and some incomplete features (ClaudeRunner, SSE integration).
The LLM identified 6 files worth highlighting for reuse:
Thread-safe in-memory pub-sub event bus with per-session ring buffer (cap 1000). Used for SSE streaming to the web UI. Demonstrates clean separation of concerns and reconnect replay via Last-Event-ID. Reusable in any application requiring real-time event streaming with minimal dependencies.
Atomic append to chat.jsonl via read-all + rewrite with .tmp rename, including orphan recovery for crash resilience. Solves a common data integrity problem in file-backed logging. The pattern is directly reusable for any append-only log that must survive process crashes.
Deterministic system prompt builder for Step-2 refinement. Includes baseline code, accumulated rcParams, and output contract. Demonstrates a clean pattern for constructing LLM prompts from structured data, ensuring reproducibility and traceability. Reusable for any multi-turn refinement workflow.
Shared subprocess registry with SIGTERM → 3s → SIGKILL cancel logic, thread-safe. Manages subprocesses keyed by (workdir, slot). Demonstrates robust process lifecycle management with timeout escalation. Reusable in any application that spawns and manages multiple subprocesses.
Dep-free Python syntax highlighter (~80 lines) for the Export Code modal. Tokenizes Python source into HTML spans with CSS classes. Demonstrates a self-contained, zero-dependency utility that can be extracted and used in any web application needing client-side code highlighting.
Generic weighted image similarity scorer for 3D candidate PNGs against a reference. Computes pixel similarity, edge structure, silhouette IoU, primary geometry, etc., with proxy scorecard dimensions and strict floor validation. Reusable for any image comparison task requiring multi-metric scoring with configurable weights.