doc-gen-unicode-diagnostic
它能做什么
这项技能为 AI 提供一套分步方法,用于制作文档,并避免含糊的错误。它适合制作包含特殊字符的文档,或反复遇到导出失败的人。
适用场景
- ✓当 PDF 生成因编码或 LaTeX 错误而失败的时候。
- ✓当文档生成返回一个没有细节的、含糊不清的错误的时候。
- ✓当文档包含需要谨慎处理的特殊字符或符号的时候。
技能链接
https://github.com/HKUDS/AgentPilot/blob/main/openspace/benchmarks/gdpval/skills/document-gen-fallback-enhanced-enhanced-3d3a9a/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“我的 PDF 导出一直因 LaTeX 错误而失败,而且文本中有符号。请找出原因并生成 PDF。”
每周 5 个新技能,1 分钟读完。
工作原理
AI 会先检查哪些文档工具已安装,然后清理特殊字符,依次尝试一系列 PDF 引擎,并捕获错误信息,以便诊断任何失败。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
Document Generation with Diagnostic Workflow (Unicode-Safe)
When to Use
Use this skill when document generation tasks fail or return unclear errors, especially when:
- Generating documents in multiple formats (
.docx,.pdf,.html) - PDF generation fails with encoding/LaTeX errors
shell_agentreturns "unknown error" without diagnostics- Documents contain special characters, symbols, or non-ASCII text
- You need systematic error diagnosis rather than blind retries
⚠️ Critical: Why This Skill Exists
Recent executions show 43% effectiveness because agents:
- Skip unicode sanitization before PDF conversion
- Don't try
xelatexengine (better Unicode support) - Don't capture stderr for proper diagnosis
- Exhaust iterations on repeated failures without systematic troubleshooting
This skill fixes those gaps with mandatory steps.
Pre-Flight Validation (NEW - Required Step 0)
Before starting document generation, verify your toolchain:
run_shell
command: which pandoc && pandoc --version | head -3
run_shell
command: which pdflatex xelatex wkhtmltopdf 2>/dev/null || echo "Some engines missing"
run_shell
command: python3 -c "import sys; print(sys.version)"
If pandoc is missing, install it:
run_shell
command: apt-get update && apt-get install -y pandoc
For PDF support, install LaTeX engines:
run_shell
command: apt-get install -y texlive-latex-recommended texlive-fonts-recommended texlive-xetex
Core Technique
Manually split the workflow into observable, diagnostic steps:
- Pre-flight → Verify toolchain availability
- Content creation → Use
write_filefor markdown source (visible content) - Unicode sanitization → MANDATORY for PDF: Create sanitized version
- Format conversion with fallback → Try engines in order, capture stderr
- Verification → Check outputs exist and validate content
Unicode & LaTeX Compatibility (MANDATORY for PDF)
PDF generation via LaTeX has limited Unicode support. Before PDF conversion, you MUST sanitize:
| Character | Issue | Safe Replacement |
|---|---|---|
— (em dash) |
LaTeX incompatibility | -- |
– (en dash) |
LaTeX incompatibility | - |
" " (curly quotes) |
Encoding errors | " " (straight) |
' ' (curly apostrophe) |
Encoding errors | ' (straight) |
… (ellipsis) |
May not render | ... |
→ ← ↑ ↓ (arrows) |
LaTeX incompatibility | -> <- ^ v |
✓ ✗ (checkmarks) |
May not render | [x] [ ] |
★ ● (symbols) |
May not render | * - |
© ® ™ |
Require packages | (c) (r) (tm) |
| Non-ASCII (é, ñ, ü) | Font-dependent | Keep for xelatex, sanitize for pdflatex |
DOCX and HTML handle Unicode natively - use original markdown for these formats.
Step-by-Step Workflow
Step 0: Pre-Flight Validation
run_shell
command: which pandoc || (apt-get update && apt-get install -y pandoc)
run_shell
command: which xelatex || echo "xelatex not available - will use fallback"
Step 1: Create Source Content with write_file
write_file
path: /tmp/document_source.md
content: |
# Document Title
## Section 1
Your content here with full Unicode support...
## Section 2
Special chars: "quotes" — dashes … ellipsis ✓ checkmarks
Step 2: Create Sanitized Version for PDF (MANDATORY)
Option A: Manual sanitization with write_file
write_file
path: /tmp/document_source_sanitized.md
content: |
# Document Title
## Section 1
Your content here...
## Section 2
Special chars: "quotes" -- dashes ... ellipsis [x] checkmarks
Option B: Automated sanitization script
First create the script:
write_file
path: /tmp/sanitize_for_pdf.sh
content: |
#!/bin/bash
INPUT="$1"
OUTPUT="${2:-${1%.md}_sanitized.md}"
sed -e 's/—/--/g' -e 's/–/-/g' \
-e 's/"([^"]*)"/"\1"/g' -e "s/'([^']*)'/\`\1\`/g" \
-e 's/…/.../g' -e 's/→/->/g' -e 's/←/<-/g' \
-e 's/✓/[x]/g' -e 's/✗/[ ]/g' \
-e 's/©/(c)/g' -e 's/®/(r)/g' -e 's/™/(tm)/g' \
"$INPUT" > "$OUTPUT"
echo "Sanitized: $INPUT -> $OUTPUT"
run_shell
command: chmod +x /tmp/sanitize_for_pdf.sh && /tmp/sanitize_for_pdf.sh /tmp/document_source.md /tmp/document_source_sanitized.md
Step 3: Convert to DOCX (from original, supports Unicode)
run_shell
command: pandoc /tmp/document_source.md -o output.docx 2>&1
Capture stderr with 2>&1 t
常见问题
需要安装哪些工具?
指南提到了 pandoc,以及用于 PDF 输出的 LaTeX 引擎,例如 pdflatex 或 xelatex。
为什么要捕获错误信息?
阅读错误输出,AI 才能找出真正的原因,而不是盲目重试。
哪个引擎对 Unicode 支持最好?
指南说,xelatex 对非 ASCII 文本的支持优于 pdflatex。
详情
作者的原始描述
Systematic document generation with unicode sanitization, engine fallback chain, and explicit error diagnosis
repo: HKUDS/AgentPilot
热度
- GitHub 星标
- 7.8k
- 排名
- #12857
- 许可证
- MIT
- 更新时间
- 2026/11/1
评论
- …
同一仓库的更多技能
agentpilot
7.8k帮你的智能体准备任务并运行 AgentPilot 循环,逐步改进项目:循环会提出修改、测试修改并为其打分。
openspace
7.8k帮你的智能体设置 OpenSpace,这是一个用于存储和获取智能体技能的工具,并通过 MCP 将其连接到你的 AI 应用。
rsi-arena
7.8k帮你的智能体设置并运行标准 AI 基准测试,例如 AIME 和 Terminal-Bench,用来比较不同的改进方法。
experiment-guide
7.8k帮你的智能体规划小型实验、阅读实验结果并记录发现,同时研究如何改进一个程序。