| name | deliver-doc |
| description | Deliver a generated document (md/HTML) as PDF or Word and reveal it in Finder. Use when the user says "give me a PDF", "export to Word/docx", "in pdf", "open in finder", asks for a Korean version of a doc, or a session ends with a document deliverable. Encodes the one known-good md→PDF pipeline on this Mac (Chrome headless; pandoc/xelatex fallback with pinned CJK font) so each session stops reinventing a broken one. |
deliver-doc — md → PDF/DOCX → open in Finder
Session mining (2026-07-02) found 6+ sessions each improvising a different PDF pipeline
(xelatex fontspec failure, headless-Chrome hack killed by timeout, 2-min timeout on render)
and near-every doc session ending with a manual "open in finder". This is the one pipeline.
Tools verified on this Mac (2026-07-02): pandoc ✓, Google Chrome ✓, textutil ✓,
xelatex ✓ (/Library/TeX/texbin). NOT installed: wkhtmltopdf, weasyprint, LibreOffice — don't
reach for them.
DOCX
- Plain document:
pandoc in.md -o out.docx
- Korean government/proposal docs with styled tables → use the docx-table-styler skill
instead (it owns navy headers, HWP compatibility, etc.).
PDF (primary path — Chrome headless)
Exact commands (use the session scratchpad, never a fixed /tmp name — concurrent sessions collide):
T=$(mktemp -d "${SCRATCHPAD:-/tmp}/deliver-doc.XXXXXX")
cat > "$T/style.html" <<'EOF'
<style>
body{font-family:-apple-system,"Apple SD Gothic Neo",sans-serif;max-width:48em;margin:2em auto;line-height:1.55}
pre,code{font-family:Menlo,monospace}
</style>
EOF
pandoc in.md -s -H "$T/style.html" -o "$T/doc.html"
"/Applications/Google Chrome.app/Contents/MacOS/Google Chrome" --headless --disable-gpu \
--no-pdf-header-footer --print-to-pdf=<out.pdf> "file://$T/doc.html"
(-H injects the style block into <head> — pandoc's --css only LINKS a stylesheet, it does
not embed. The Apple SD Gothic Neo pin is what makes Korean render.)
- Give the Chrome call
timeout: 180000; do NOT let the 2-min default kill it.
- Verify before claiming done: the PDF exists and
file <out.pdf> says PDF; a 0-byte file
means Chrome died — re-run once, then fall back.
PDF (fallback — pandoc/xelatex, installed and working)
pandoc in.md -o out.pdf --pdf-engine=xelatex -V "CJKmainfont=Apple SD Gothic Neo" -V geometry:margin=2.5cm
(the historical fontspec failures were the missing CJKmainfont pin, not a broken TeX).
Always finish with
open -R <artifact> (reveals in Finder — the user asks for this almost every time; do it
unprompted).
- One line in the reply: the absolute path + size.
Korean version requests
"give it in Korean" = translate the source md first, then run the SAME pipeline on the
translated file; deliver both paths.