[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M6HXGMS1VAFSY9VCD6PBHRMC":3,"skill-same:01M6HXGMS1VAFSY9VCD6PBHRMC":76},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":29,"publishedAt":43,"linkOnly":44,"markdownContent":45,"markdownBody":46,"frontMatter":47,"refName":48,"commitSha":49,"skillDirectory":50,"forksCount":51,"repositoryHtmlUrl":52,"repositoryHomepageUrl":6,"ownerHtmlUrl":53,"ownerBlogUrl":54,"ownerDescription":6,"updatedAt":55,"install":56,"resources":69},"01M6HXGMS1VAFSY9VCD6PBHRMC","document-gen-dual-backend",null,"Document generation with direct pandoc\u002FReportLab execution (lightweight default) and optional shell_agent fallback for complex scenarios","HKUDS\u002FAgentPilot","HKUDS","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F118165258?v=4","01M6HW8VRNZP64G0P4MVJW2KKQ","✨Data Intelligence Lab@HKU✨","01M6HW8VWZVHBRHYH3T330PFWV",7993,"MIT","https:\u002F\u002Fgithub.com\u002FHKUDS\u002FAgentPilot\u002Fblob\u002Fmain\u002Fopenspace\u002Flegacy\u002Fv1\u002Fgdpval_bench\u002Fskills\u002Fdocument-gen-fallback-enhanced-enhanced-9f3b1f\u002FSKILL.md",[18,23,26],{"categoryNo":19,"categoryName":20,"taxonomyType":21,"taxonomyTypeDesc":22},"01JBSEEDCAT000000000000002","文档处理","SCENARIO","使用场景",{"categoryNo":24,"categoryName":25,"taxonomyType":21,"taxonomyTypeDesc":22},"01JBSEEDCAT000000000000010","后端与接口",{"categoryNo":27,"categoryName":28,"taxonomyType":21,"taxonomyTypeDesc":22},"01JBSEEDCAT000000000000023","Skill与智能体开发",[30,31,32,33,34,35,36,37,38,39,40,41,42],"backend","document","document gen dual backend","execution","shell","direct","fallback","default","generation","pandoc","document generation","with","for","2026-11-10 10:12:30",false,"---\nname: document-gen-dual-backend\ndescription: Document generation with direct pandoc\u002FReportLab execution (lightweight default) and optional shell_agent fallback for complex scenarios\n---\n\n# Document Generation: Dual-Backend Workflow (Unicode-Safe)\n\n## When to Use\n\n**Default Approach: Lightweight Direct Execution (Recommended for 90% of tasks)**\n\nFor most document generation tasks, use direct `write_file` + `run_shell` **without** `shell_agent`:\n- Generating documents in standard formats (`.docx`, `.pdf`, `.html`) from Markdown\n- Content is straightforward with minimal special characters\n- You already know the pandoc\u002FReportLab commands needed\n- Quick single-format or multi-format output is needed\n\n**Fallback Approach: shell_agent Delegation (For Complex Scenarios Only)**\n\nUse `shell_agent` delegation only when:\n- Automated fallback handling between backends requires complex logic\n- Dynamic content generation needs programmatic decision-making\n- You need to capture and analyze error messages for intelligent retry logic\n\n### When shell_agent May Be Useful (Optional)\n\nOnly consider `shell_agent` delegation for:\n- Complex error recovery requiring automated backend switching\n- Dynamic workflows with conditional branching based on generation results\n\n## Core Technique\n\n**For simple tasks (default):** Use direct `write_file` + `run_shell` with pandoc or ReportLab (no shell_agent needed)\n\n**For complex tasks requiring fallback logic:** Split the workflow into discrete, observable steps with **two PDF generation paths**:\n\n**Path A (Pandoc)**: Best for Markdown-to-PDF conversion with rich text formatting\n**Path B (ReportLab)**: Best for programmatic PDF generation without LaTeX dependencies\n\nWorkflow steps:\n1. **Content creation** → Use `write_file` to create source document (Markdown)\n2. **Choose PDF backend** → Decide between pandoc (rich formatting) or ReportLab (programmatic control)\n3. **Unicode handling** → Apply sanitization for pandoc; ReportLab handles Unicode natively\n4. **Format conversion** → Use `run_shell` with appropriate commands for each format\n5. **Verification** → Check output files exist and are valid\n\n## ⚠️ Backend Selection Guide\n\n| Requirement | Recommended Backend | Rationale |\n|-------------|---------------------|-----------|\n| Markdown source with headers, lists, tables | **Pandoc** | Native Markdown parsing |\n| Heavy Unicode\u002Fspecial characters | **ReportLab** | Native UTF-8 support, no sanitization needed |\n| LaTeX not available | **ReportLab** | Pure Python, no external dependencies |\n| Precise layout control (positions, graphics) | **ReportLab** | Programmatic canvas control |\n| Quick DOCX + PDF + HTML batch | **Pandoc** | Single tool, multiple outputs |\n| Tables with complex formatting | **Pandoc** | Better table rendering |\n| Dynamic\u002Fcharts\u002Fgraphs in PDF | **ReportLab** | Drawing operations support |\n\n## Unicode & LaTeX Compatibility Warning\n\n**Critical for Pandoc Path**: PDF generation via pandoc typically uses LaTeX (`pdflatex` or `xelatex`), which has limited Unicode support. Common problematic characters include:\n\n| Character | Issue | Safe Replacement |\n|-----------|-------|------------------|\n| `—` (em dash) | May not render | `--` or `-` |\n| `–` (en dash) | May not render | `-` |\n| `\" \"` (curly quotes) | Encoding errors | `\" \"` (straight quotes) |\n| `' '` (curly apostrophe) | Encoding errors | `'` (straight apostrophe) |\n| `…` (ellipsis) | May not render | `...` |\n| `→` `←` `↑` `↓` (arrows) | LaTeX incompatibility | `->` `\u003C-` `^` `v` |\n| `✓` `✗` (checkmarks) | May not render | `[x]` `[ ]` |\n| `★` `●` (symbols) | May not render | `*` `-` |\n| `©` `®` `™` | May require packages | `(c)` `(r)` `(tm)` |\n| Non-ASCII letters (é, ñ, ü) | Font-dependent | Use xeLaTeX or replace |\n\n**ReportLab Path**: Handles Unicode natively. Pass content as UTF-8 strings; no character sanitization required.\n\n## Step-by-Step Workflow\n\n### Quick Start: Lightweight Direct Execution (Default for Most Tasks)\n\n**This is the recommended approach for most document generation tasks. No shell_agent delegation needed:**\n\n```\n# Step 1: Write Markdown content\nwrite_file\npath: \u002Ftmp\u002Fdoc.md\ncontent: |\n  # My Document\n  \n  Simple content here.\n\n# Step 2: Convert with pandoc (direct)\nrun_shell\ncommand: pandoc \u002Ftmp\u002Fdoc.md -o output.docx\n\n# Step 3: Verify\nrun_shell\ncommand: ls -lh output.docx\n```\n\n**For PDF with potential Unicode issues:**\n\n```\n# Create sanitized version if needed\nwrite_file\npath: \u002Ftmp\u002Fdoc_sanitized.md\ncontent: |\n  # My Document\n  Content with safe ASCII characters only.\n\nrun_shell\ncommand: pandoc \u002Ftmp\u002Fdoc_sanitized.md -o output.pdf\n```\n\n**For Unicode-heavy content (use ReportLab directly):**\n\n```\nwrite_file\npath: \u002Ftmp\u002Fgen.py\ncontent: |\n  from reportlab.platypus import SimpleDocTemplate, Paragraph\n  from reportlab.lib.styles import getSampleStyleSheet\n  doc = SimpleDocTemplate(\"output.pdf\")\n  styles = getSampleStyleSheet()\n  story = [Paragraph(\"Unicode: é ñ ü 日本語\", styles[\"Normal\"])]\n  doc.build(story)\n\nrun_shell\ncommand: python \u002Ftmp\u002Fgen.py\n```\n\n---\n\n### Full Workflow: Dual-Backend with Fallback (For Complex Cases)\n\n### Step 1: Create Source Content with write_file\n\nWrite your document content as Markdown to a temporary source file:\n\n```\nwrite_file\npath: \u002Ftmp\u002Fdocument_source.md\ncontent: |\n  # Document Title\n  \n  ## Section 1\n  Content here...\n  \n  ## Section 2\n  More content...\n```\n\n### Step 2A: Pandoc Path - Sanitize Unicode (Pre-PDF Conversion)\n\n**Before PDF conversion with pandoc**, create a sanitized version:\n\n```\nwrite_file\npath: \u002Ftmp\u002Fdocument_source_sanitized.md\ncontent: |\n  # Document Title\n  \n  ## Section 1\n  Content here... (with all special chars replaced per table above)\n```\n\n### Step 2B: ReportLab Path - Create Python Script\n\nFor ReportLab, create a Python script that generates PDF directly:\n\n```\nwrite_file\npath: \u002Ftmp\u002Fgenerate_pdf.py\ncontent: |\n  from reportlab.lib.pagesizes import letter\n  from reportlab.platypus import SimpleDocTemplate, Paragraph, Spacer, Table, TableStyle\n  from reportlab.lib.styles import getSampleStyleSheet, ParagraphStyle\n  from reportlab.lib import colors\n  from reportlab.pdfbase import pdfmetrics\n  from reportlab.pdfbase.ttfonts import TTFont\n  \n  # Create PDF\n  doc = SimpleDocTemplate(\"output.pdf\", pagesize=letter)\n  styles = getSampleStyleSheet()\n  story = []\n  \n  # Add content\n  story.append(Paragraph(\"Document Title\", styles[\"Heading1\"]))\n  story.append(Spacer(1, 12))\n  story.append(Paragraph(\"Section 1 content with Unicode: é ñ ü → ✓ …\", styles[\"Normal\"]))\n  \n  # Build PDF\n  doc.build(story)\n```\n\n### Step 3: Convert to Target Formats\n\n#### Option A: Pandoc Conversion (Use sanitized source for PDF)\n\n```\nrun_shell\ncommand: pandoc \u002Ftmp\u002Fdocument_source.md -o output.docx\n```\n\n```\nrun_shell\ncommand: pandoc \u002Ftmp\u002Fdocument_source_sanitized.md -o output.pdf\n```\n\n```\nrun_shell\ncommand: pandoc \u002Ftmp\u002Fdocument_source.md -o output.html\n```\n\n#### Option B: ReportLab Conversion (Direct PDF generation)\n\n```\nrun_shell\ncommand: python \u002Ftmp\u002Fgenerate_pdf.py\n```\n\nThen use pandoc for other formats from original source:\n\n```\nrun_shell\ncommand: pandoc \u002Ftmp\u002Fdocument_source.md -o output.docx\n```\n\n```\nrun_shell\ncommand: pandoc \u002Ftmp\u002Fdocument_source.md -o output.html\n```\n\n### Step 4: Verify Outputs\n\n```\nrun_shell\ncommand: ls -lh output.docx output.pdf output.html\n```\n\n## Complete Examples\n\n### Example 1: Pandoc-First Approach\n\n```markdown\n# Generate Report with Pandoc\n\n## Step 1: Write Markdown source\nwrite_file\npath: \u002Ftmp\u002Freport.md\ncontent: |\n  # Quarterly Report\n  \n  ## Executive Summary\n  Performance improved by 15% this quarter...\n  \n  ## Key Metrics\n  - Revenue: $1.2M\n  - Growth: +15%\n  - Customers: 500+\n\n## Step 2: Create sanitized version for PDF\nwrite_file\npath: \u002Ftmp\u002Freport_sanitized.md\ncontent: |\n  # Quarterly Report\n  \n  ## Executive Summary\n  Performance improved by 15% this quarter...\n  \n  ## Key Metrics\n  - Revenue: $1.2M\n  - Growth: +15%\n  - Customers: 500+\n\n## Step 3: Convert to DOCX (from original)\nrun_shell\ncommand: pandoc \u002Ftmp\u002Freport.md -o quarterly_report.docx\n\n## Step 4: Convert to PDF (from sanitized)\nrun_shell\ncommand: pandoc \u002Ftmp\u002Freport_sanitized.md -o quarterly_report.pdf\n\n## Step 5: Convert to HTML (from original)\nrun_shell\ncommand: pandoc \u002Ftmp\u002Freport.md -o quarterly_report.html\n\n## Step 6: Verify\nrun_shell\ncommand: ls -lh quarterly_report.*\n```\n\n### Example 2: ReportLab-First Approach (Heavy Unicode)\n\n```markdown\n# Generate Unicode-Heavy Document with ReportLab\n\n## Step 1: Write Markdown source (for DOCX\u002FHTML)\nwrite_file\npath: \u002Ftmp\u002Fintl_report.md\ncontent: |\n  # International Market Analysis\n  \n  ## Région EMEA\n  Performance in Europe: ↑ 12%\n  Markets: Deutschland, França, España\n  \n  ## Région APAC\n  Growth: ✓ Exceeded targets\n  Key: 日本，中国，한국\n\n## Step 2: Create ReportLab Python script for PDF\nwrite_file\npath: \u002Ftmp\u002Fgenerate_intl_pdf.py\ncontent: |\n  from reportlab.lib.pagesizes import letter\n  from reportlab.platypus import SimpleDocTemplate, Paragraph, Spacer, Table, TableStyle\n  from reportlab.lib.styles import getSampleStyleSheet\n  from reportlab.lib import colors\n  \n  doc = SimpleDocTemplate(\"intl_analysis.pdf\", pagesize=letter)\n  styles = getSampleStyleSheet()\n  story = []\n  \n  # Title - Unicode handled natively\n  story.append(Paragraph(\"International Market Analysis\", styles[\"Heading1\"]))\n  story.append(Spacer(1, 12))\n  \n  # EMEA Section\n  story.append(Paragraph(\"Région EMEA\", styles[\"Heading2\"]))\n  story.append(Paragraph(\"Performance in Europe: ↑ 12%\", styles[\"Normal\"]))\n  story.append(Paragraph(\"Markets: Deutschland, França, España\", styles[\"Normal\"]))\n  story.append(Spacer(1, 12))\n  \n  # APAC Section\n  story.append(Paragraph(\"Région APAC\", styles[\"Heading2\"]))\n  story.append(Paragraph(\"Growth: ✓ Exceeded targets\", styles[\"Normal\"]))\n  story.append(Paragraph(\"Key: 日本，中国，한국\", styles[\"Normal\"]))\n  \n  doc.build(story)\n\n## Step 3: Generate PDF with ReportLab\nrun_shell\ncommand: python \u002Ftmp\u002Fgenerate_intl_pdf.py\n\n## Step 4: Generate DOCX with pandoc\nrun_shell\ncommand: pandoc \u002Ftmp\u002Fintl_report.md -o intl_analysis.docx\n\n## Step 5: Generate HTML with pandoc\nrun_shell\ncommand: pandoc \u002Ftmp\u002Fintl_report.md -o intl_analysis.html\n\n## Step 6: Verify\nrun_shell\ncommand: ls -lh intl_analysis.*\n```\n\n### Example 3: Hybrid Approach with Fallback\n\n```markdown\n# Generate with Pandoc, Fallback to ReportLab\n\n## Step 1: Create source document\nwrite_file\npath: \u002Ftmp\u002Fanalysis.md\ncontent: |\n  # Analysis Document\n  [Content...]\n\n## Step 2: Try pandoc first\nrun_shell\ncommand: pandoc \u002Ftmp\u002Fanalysis.md -o analysis.pdf\n\n## Step 3: If pandoc fails, use ReportLab fallback\n[If Step 2 returns error...]\nwrite_file\npath: \u002Ftmp\u002Ffallback_pdf.py\ncontent: |\n  from reportlab.lib.pagesizes import letter\n  from reportlab.platypus import SimpleDocTemplate, Paragraph, Spacer\n  from reportlab.lib.styles import getSampleStyleSheet\n  from reportlab.pdfbase import pdfmetrics\n  from reportlab.pdfbase.ttfonts import TTFont\n  \n  # Register Unicode font if needed\n  # pdfmetrics.registerFont(TTFont('UnicodeFont', '\u002Fpath\u002Fto\u002Ffont.ttf'))\n  \n  doc = SimpleDocTemplate(\"analysis.pdf\", pagesize=letter)\n  styles = getSampleStyleSheet()\n  story = []\n  story.append(Paragraph(\"Analysis Document\", styles[\"Heading1\"]))\n  story.append(Spacer(1, 12))\n  story.append(Paragraph(\"[Content from analysis.md parsed here]\", styles[\"Normal\"]))\n  doc.build(story)\n\nrun_shell\ncommand: python \u002Ftmp\u002Ffallback_pdf.py\n```\n\n## Common pandoc Commands\n\n```bash\n# Markdown to Word\npandoc input.md -o output.docx\n\n# Markdown to PDF (requires LaTeX)\npandoc input.md -o output.pdf\n\n# Markdown to PDF with Unicode-safe engine (better Unicode support)\npandoc input.md -o output.pdf --pdf-engine=xelatex\n\n# Markdown to PDF with wkhtmltopdf (alternative, no LaTeX)\npandoc input.md -o output.pdf --pdf-engine=wkhtmltopdf\n\n# Markdown to HTML\npandoc input.md -o output.html\n\n# With custom template\npandoc input.md --template=template.html -o output.html\n\n# With metadata\npandoc input.md -o output.pdf --metadata title=\"Document Title\"\n```\n\n## Common ReportLab Patterns\n\n```python\n# Basic PDF creation\nfrom reportlab.lib.pagesizes import letter\nfrom reportlab.platypus import SimpleDocTemplate, Paragraph, Spacer\nfrom reportlab.lib.styles import getSampleStyleSheet\n\ndoc = SimpleDocTemplate(\"output.pdf\", pagesize=letter)\nstyles = getSampleStyleSheet()\nstory = []\nstory.append(Paragraph(\"Title\", styles[\"Heading1\"]))\nstory.append(Spacer(1, 12))\nstory.append(Paragraph(\"Content\", styles[\"Normal\"]))\ndoc.build(story)\n\n# With tables\nfrom reportlab.platypus import Table, TableStyle\nfrom reportlab.lib import colors\n\ndata = [['Header1', 'Header2'], ['Row1-Col1', 'Row1-Col2']]\ntable = Table(data)\ntable.setStyle(TableStyle([\n    ('BACKGROUND', (0, 0), (-1, 0), colors.grey),\n    ('TEXTCOLOR', (0, 0), (-1, 0), colors.whitesmoke),\n    ('GRID', (0, 0), (-1, -1), 0.5, colors.black),\n]))\nstory.append(table)\n\n# With custom fonts for Unicode\nfrom reportlab.pdfbase import pdfmetrics\nfrom reportlab.pdfbase.ttfonts import TTFont\n\npdfmetrics.registerFont(TTFont('NotoSans', 'NotoSans-Regular.ttf'))\ncustom_style = ParagraphStyle('Custom', fontName='NotoSans', fontSize=12)\nstory.append(Paragraph(\"Unicode: 日本語 العربية\", custom_style))\n```\n\n## Troubleshooting\n\n### Pandoc Issues\n\n- **PDF generation fails with encoding error**: \n  - Use the sanitized markdown file\n  - Try `--pdf-engine=xelatex` for better Unicode support\n  - Try `--pdf-engine=wkhtmltopdf` as alternative\n\n- **PDF generation fails: LaTeX not found**: \n  - Install LaTeX: `apt-get install texlive-latex-recommended texlive-fonts-recommended`\n  - **Switch to ReportLab backend** (no LaTeX needed)\n\n- **DOCX formatting issues**: Add `--reference-doc=template.docx` for custom styles\n\n- **Missing pandoc**: Install via `apt-get install pandoc` or `brew install pandoc`\n\n### ReportLab Issues\n\n- **Missing reportlab**: Install via `pip install reportlab`\n\n- **Unicode characters not rendering**: \n  - ReportLab handles UTF-8 natively - ensure Python script uses UTF-8\n  - For CJK\u002FArabic\u002Fetc., register a Unicode-capable font:\n    ```python\n    from reportlab.pdfbase import pdfmetrics\n    from reportlab.pdfbase.ttfonts import TTFont\n    pdfmetrics.registerFont(TTFont('NotoSans', 'NotoSans-Regular.ttf'))\n    ```\n\n- **Complex layouts needed**: Use `reportlab.lib.canvas` for direct drawing operations\n\n- **Tables breaking across pages**: Use `reportlab.platypus.LongTable` instead of `Table`\n\n### General Issues\n\n- **Unicode\u002Fencoding errors in any format**: \n  - Add `-f markdown+utf8` to pandoc command\n  - Ensure source file is UTF-8 encoded: `file -i source.md`\n\n- **Special characters not rendering in PDF**: \n  - For pandoc: Use character replacement table or ReportLab\n  - For ReportLab: Register appropriate Unicode fonts\n\n## Installation Commands\n\n```bash\n# Install pandoc\napt-get install pandoc  # Debian\u002FUbuntu\nbrew install pandoc     # macOS\n\n# Install LaTeX (for pdflatex)\napt-get install texlive-latex-recommended texlive-fonts-recommended\n\n# Install wkhtmltopdf (alternative PDF engine)\napt-get install wkhtmltopdf\n\n# Install ReportLab\npip install reportlab\n\n# Install fonts for Unicode support\napt-get install fonts-noto-core  # Comprehensive Unicode font\n```\n\n## Unicode Sanitization Script (For Pandoc Path)\n\nFor repeated use with pandoc, create a reusable sanitization script:\n\n```bash\n#!\u002Fbin\u002Fbash\n# sanitize_for_pdf.sh - Replace problematic unicode chars for LaTeX\u002FPDF\nif [ -z \"$1\" ]; then\n  echo \"Usage: $0 \u003Cinput.md> [output.md]\"\n  exit 1\nfi\nINPUT=\"$1\"\nOUTPUT=\"${2:-${1%.md}_sanitized.md}\"\n\nsed -e 's\u002F—\u002F--\u002Fg' \\\n    -e 's\u002F–\u002F-\u002Fg' \\\n    -e 's\u002F\"([^\"]*)\"\u002F\"\\1\"\u002Fg' \\\n    -e \"s\u002F'([^']*)'\u002F\\1'\u002Fg\" \\\n    -e 's\u002F…\u002F...\u002Fg' \\\n    -e 's\u002F→\u002F->\u002Fg' \\\n    -e 's\u002F←\u002F\u003C-\u002Fg' \\\n    -e 's\u002F✓\u002F[x]\u002Fg' \\\n    -e 's\u002F✗\u002F[ ]\u002Fg' \\\n    -e 's\u002F©\u002F(c)\u002Fg' \\\n    -e 's\u002F®\u002F(r)\u002Fg' \\\n    -e 's\u002F™\u002F(tm)\u002Fg' \\\n    \"$INPUT\" > \"$OUTPUT\"\n\necho \"Sanitized: $INPUT -> $OUTPUT\"\n```\n\nSave as `sanitize_for_pdf.sh`, make executable with `chmod +x sanitize_for_pdf.sh`, then use:\n\n```\nrun_shell\ncommand: .\u002Fsanitize_for_pdf.sh \u002Ftmp\u002Fdocument_source.md \u002Ftmp\u002Fdocument_source_sanitized.md\n```\n\n## Decision Flowchart\n\n```\nNeed PDF generation?\n    │\n    ├─ Heavy Unicode\u002Fsymbols? ──YES──> Use ReportLab\n    │         │\n    │         NO\n    │         │\n    ├─ LaTeX available? ──NO──> Use ReportLab\n    │         │\n    │         YES\n    │         │\n    ├─ Need Markdown formatting? ──YES──> Use Pandoc (with sanitization)\n    │         │\n    │         NO\n    │         │\n    └─ Need programmatic layout? ──YES──> Use ReportLab\n```\n\n## When to Return to shell_agent\n\nAfter successfully completing the manual workflow once, you can attempt `shell_agent` again for similar tasks, now with a known-working fallback if errors recur. For documents with heavy Unicode content or when LaTeX is unavailable, prefer the ReportLab path.\n\n## Related Skills\n\n- `document-gen-unicode-safe`: Parent skill with pandoc-only approach\n- `document-gen-fallback`: Original fallback workflow without Unicode guidance\n- Use this skill when you need flexible PDF generation with multiple backend options\n### Example 0: Lightweight Single-Format Generation\n\n```markdown\n# Quick DOCX Generation (No shell_agent needed)\n\n## Step 1: Write content\nwrite_file\npath: \u002Ftmp\u002Fbrief.md\ncontent: |\n  # Meeting Notes\n  \n  ## Attendees\n  - Alice\n  - Bob\n  \n  ## Decisions\n  Project approved.\n\n## Step 2: Convert directly\nrun_shell\ncommand: pandoc \u002Ftmp\u002Fbrief.md -o meeting_notes.docx\n\n## Step 3: Verify\nrun_shell\ncommand: ls -lh meeting_notes.docx\n```\n\n---\n\n### Example 1: Pandoc-First Approach (Multi-Format with Sanitization)\n\n### Example 2: ReportLab-First Approach (Heavy Unicode — Direct Execution)\n\n## Mode Selection Quick Reference\n\n| Scenario | Recommended Mode | Why |\n|----------|------------------|-----|\n| Simple Markdown → DOCX | **Lightweight** | Direct pandoc call is fastest |\n| Single PDF from ASCII content | **Lightweight** | No sanitization needed |\n| Multi-format batch (DOCX + PDF + HTML) | **Full Workflow** | Coordinated conversion with error handling |\n| Content with Unicode\u002Fsymbols | **Lightweight + ReportLab** | Direct Python script avoids LaTeX issues |\n| Uncertain about LaTeX availability | **Full Workflow** | Built-in fallback detection |\n| Need programmatic layout control | **Full Workflow** | ReportLab integration with fallback logic |\n| Production pipeline with error recovery | **Full Workflow** | Automated retry and backend switching |\n\n---\n\n## Troubleshooting\n\n- **Missing reportlab**: Install\n### ReportLab Issues\n\n- **Missing reportlab**: Install via `pip install reportlab`\n","# Document Generation: Dual-Backend Workflow (Unicode-Safe)\n\n## When to Use\n\n**Default Approach: Lightweight Direct Execution (Recommended for 90% of tasks)**\n\nFor most document generation tasks, use direct `write_file` + `run_shell` **without** `shell_agent`:\n- Generating documents in standard formats (`.docx`, `.pdf`, `.html`) from Markdown\n- Content is straightforward with minimal special characters\n- You already know the pandoc\u002FReportLab commands needed\n- Quick single-format or multi-format output is needed\n\n**Fallback Approach: shell_agent Delegation (For Complex Scenarios Only)**\n\nUse `shell_agent` delegation only when:\n- Automated fallback handling between backends requires complex logic\n- Dynamic content generation needs programmatic decision-making\n- You need to capture and analyze error messages for intelligent retry logic\n\n### When shell_agent May Be Useful (Optional)\n\nOnly consider `shell_agent` delegation for:\n- Complex error recovery requiring automated backend switching\n- Dynamic workflows with conditional branching based on generation results\n\n## Core Technique\n\n**For simple tasks (default):** Use direct `write_file` + `run_shell` with pandoc or ReportLab (no shell_agent needed)\n\n**For complex tasks requiring fallback logic:** Split the workflow into discrete, observable steps with **two PDF generation paths**:\n\n**Path A (Pandoc)**: Best for Markdown-to-PDF conversion with rich text formatting\n**Path B (ReportLab)**: Best for programmatic PDF generation without LaTeX dependencies\n\nWorkflow steps:\n1. **Content creation** → Use `write_file` to create source document (Markdown)\n2. **Choose PDF backend** → Decide between pandoc (rich formatting) or ReportLab (programmatic control)\n3. **Unicode handling** → Apply sanitization for pandoc; ReportLab handles Unicode natively\n4. **Format conversion** → Use `run_shell` with appropriate commands for each format\n5. **Verification** → Check output files exist and are valid\n\n## ⚠️ Backend Selection Guide\n\n| Requirement | Recommended Backend | Rationale |\n|-------------|---------------------|-----------|\n| Markdown source with headers, lists, tables | **Pandoc** | Native Markdown parsing |\n| Heavy Unicode\u002Fspecial characters | **ReportLab** | Native UTF-8 support, no sanitization needed |\n| LaTeX not available | **ReportLab** | Pure Python, no external dependencies |\n| Precise layout control (positions, graphics) | **ReportLab** | Programmatic canvas control |\n| Quick DOCX + PDF + HTML batch | **Pandoc** | Single tool, multiple outputs |\n| Tables with complex formatting | **Pandoc** | Better table rendering |\n| Dynamic\u002Fcharts\u002Fgraphs in PDF | **ReportLab** | Drawing operations support |\n\n## Unicode & LaTeX Compatibility Warning\n\n**Critical for Pandoc Path**: PDF generation via pandoc typically uses LaTeX (`pdflatex` or `xelatex`), which has limited Unicode support. Common problematic characters include:\n\n| Character | Issue | Safe Replacement |\n|-----------|-------|------------------|\n| `—` (em dash) | May not render | `--` or `-` |\n| `–` (en dash) | May not render | `-` |\n| `\" \"` (curly quotes) | Encoding errors | `\" \"` (straight quotes) |\n| `' '` (curly apostrophe) | Encoding errors | `'` (straight apostrophe) |\n| `…` (ellipsis) | May not render | `...` |\n| `→` `←` `↑` `↓` (arrows) | LaTeX incompatibility | `->` `\u003C-` `^` `v` |\n| `✓` `✗` (checkmarks) | May not render | `[x]` `[ ]` |\n| `★` `●` (symbols) | May not render | `*` `-` |\n| `©` `®` `™` | May require packages | `(c)` `(r)` `(tm)` |\n| Non-ASCII letters (é, ñ, ü) | Font-dependent | Use xeLaTeX or replace |\n\n**ReportLab Path**: Handles Unicode natively. Pass content as UTF-8 strings; no character sanitization required.\n\n## Step-by-Step Workflow\n\n### Quick Start: Lightweight Direct Execution (Default for Most Tasks)\n\n**This is the recommended approach for most document generation tasks. No shell_agent delegation needed:**\n\n```\n# Step 1: Write Markdown content\nwrite_file\npath: \u002Ftmp\u002Fdoc.md\ncontent: |\n  # My Document\n  \n  Simple content here.\n\n# Step 2: Convert with pandoc (direct)\nrun_shell\ncommand: pandoc \u002Ftmp\u002Fdoc.md -o output.docx\n\n# Step 3: Verify\nrun_shell\ncommand: ls -lh output.docx\n```\n\n**For PDF with potential Unicode issues:**\n\n```\n# Create sanitized version if needed\nwrite_file\npath: \u002Ftmp\u002Fdoc_sanitized.md\ncontent: |\n  # My Document\n  Content with safe ASCII characters only.\n\nrun_shell\ncommand: pandoc \u002Ftmp\u002Fdoc_sanitized.md -o output.pdf\n```\n\n**For Unicode-heavy content (use ReportLab directly):**\n\n```\nwrite_file\npath: \u002Ftmp\u002Fgen.py\ncontent: |\n  from reportlab.platypus import SimpleDocTemplate, Paragraph\n  from reportlab.lib.styles import getSampleStyleSheet\n  doc = SimpleDocTemplate(\"output.pdf\")\n  styles = getSampleStyleSheet()\n  story = [Paragraph(\"Unicode: é ñ ü 日本語\", styles[\"Normal\"])]\n  doc.build(story)\n\nrun_shell\ncommand: python \u002Ftmp\u002Fgen.py\n```\n\n---\n\n### Full Workflow: Dual-Backend with Fallback (For Complex Cases)\n\n### Step 1: Create Source Content with write_file\n\nWrite your document content as Markdown to a temporary source file:\n\n```\nwrite_file\npath: \u002Ftmp\u002Fdocument_source.md\ncontent: |\n  # Document Title\n  \n  ## Section 1\n  Content here...\n  \n  ## Section 2\n  More content...\n```\n\n### Step 2A: Pandoc Path - Sanitize Unicode (Pre-PDF Conversion)\n\n**Before PDF conversion with pandoc**, create a sanitized version:\n\n```\nwrite_file\npath: \u002Ftmp\u002Fdocument_source_sanitized.md\ncontent: |\n  # Document Title\n  \n  ## Section 1\n  Content here... (with all special chars replaced per table above)\n```\n\n### Step 2B: ReportLab Path - Create Python Script\n\nFor ReportLab, create a Python script that generates PDF directly:\n\n```\nwrite_file\npath: \u002Ftmp\u002Fgenerate_pdf.py\ncontent: |\n  from reportlab.lib.pagesizes import letter\n  from reportlab.platypus import SimpleDocTemplate, Paragraph, Spacer, Table, TableStyle\n  from reportlab.lib.styles import getSampleStyleSheet, ParagraphStyle\n  from reportlab.lib import colors\n  from reportlab.pdfbase import pdfmetrics\n  from reportlab.pdfbase.ttfonts import TTFont\n  \n  # Create PDF\n  doc = SimpleDocTemplate(\"output.pdf\", pagesize=letter)\n  styles = getSampleStyleSheet()\n  story = []\n  \n  # Add content\n  story.append(Paragraph(\"Document Title\", styles[\"Heading1\"]))\n  story.append(Spacer(1, 12))\n  story.append(Paragraph(\"Section 1 content with Unicode: é ñ ü → ✓ …\", styles[\"Normal\"]))\n  \n  # Build PDF\n  doc.build(story)\n```\n\n### Step 3: Convert to Target Formats\n\n#### Option A: Pandoc Conversion (Use sanitized source for PDF)\n\n```\nrun_shell\ncommand: pandoc \u002Ftmp\u002Fdocument_source.md -o output.docx\n```\n\n```\nrun_shell\ncommand: pandoc \u002Ftmp\u002Fdocument_source_sanitized.md -o output.pdf\n```\n\n```\nrun_shell\ncommand: pandoc \u002Ftmp\u002Fdocument_source.md -o output.html\n```\n\n#### Option B: ReportLab Conversion (Direct PDF generation)\n\n```\nrun_shell\ncommand: python \u002Ftmp\u002Fgenerate_pdf.py\n```\n\nThen use pandoc for other formats from original source:\n\n```\nrun_shell\ncommand: pandoc \u002Ftmp\u002Fdocument_source.md -o output.docx\n```\n\n```\nrun_shell\ncommand: pandoc \u002Ftmp\u002Fdocument_source.md -o output.html\n```\n\n### Step 4: Verify Outputs\n\n```\nrun_shell\ncommand: ls -lh output.docx output.pdf output.html\n```\n\n## Complete Examples\n\n### Example 1: Pandoc-First Approach\n\n```markdown\n# Generate Report with Pandoc\n\n## Step 1: Write Markdown source\nwrite_file\npath: \u002Ftmp\u002Freport.md\ncontent: |\n  # Quarterly Report\n  \n  ## Executive Summary\n  Performance improved by 15% this quarter...\n  \n  ## Key Metrics\n  - Revenue: $1.2M\n  - Growth: +15%\n  - Customers: 500+\n\n## Step 2: Create sanitized version for PDF\nwrite_file\npath: \u002Ftmp\u002Freport_sanitized.md\ncontent: |\n  # Quarterly Report\n  \n  ## Executive Summary\n  Performance improved by 15% this quarter...\n  \n  ## Key Metrics\n  - Revenue: $1.2M\n  - Growth: +15%\n  - Customers: 500+\n\n## Step 3: Convert to DOCX (from original)\nrun_shell\ncommand: pandoc \u002Ftmp\u002Freport.md -o quarterly_report.docx\n\n## Step 4: Convert to PDF (from sanitized)\nrun_shell\ncommand: pandoc \u002Ftmp\u002Freport_sanitized.md -o quarterly_report.pdf\n\n## Step 5: Convert to HTML (from original)\nrun_shell\ncommand: pandoc \u002Ftmp\u002Freport.md -o quarterly_report.html\n\n## Step 6: Verify\nrun_shell\ncommand: ls -lh quarterly_report.*\n```\n\n### Example 2: ReportLab-First Approach (Heavy Unicode)\n\n```markdown\n# Generate Unicode-Heavy Document with ReportLab\n\n## Step 1: Write Markdown source (for DOCX\u002FHTML)\nwrite_file\npath: \u002Ftmp\u002Fintl_report.md\ncontent: |\n  # International Market Analysis\n  \n  ## Région EMEA\n  Performance in Europe: ↑ 12%\n  Markets: Deutschland, França, España\n  \n  ## Région APAC\n  Growth: ✓ Exceeded targets\n  Key: 日本，中国，한국\n\n## Step 2: Create ReportLab Python script for PDF\nwrite_file\npath: \u002Ftmp\u002Fgenerate_intl_pdf.py\ncontent: |\n  from reportlab.lib.pagesizes import letter\n  from reportlab.platypus import SimpleDocTemplate, Paragraph, Spacer, Table, TableStyle\n  from reportlab.lib.styles import getSampleStyleSheet\n  from reportlab.lib import colors\n  \n  doc = SimpleDocTemplate(\"intl_analysis.pdf\", pagesize=letter)\n  styles = getSampleStyleSheet()\n  story = []\n  \n  # Title - Unicode handled natively\n  story.append(Paragraph(\"International Market Analysis\", styles[\"Heading1\"]))\n  story.append(Spacer(1, 12))\n  \n  # EMEA Section\n  story.append(Paragraph(\"Région EMEA\", styles[\"Heading2\"]))\n  story.append(Paragraph(\"Performance in Europe: ↑ 12%\", styles[\"Normal\"]))\n  story.append(Paragraph(\"Markets: Deutschland, França, España\", styles[\"Normal\"]))\n  story.append(Spacer(1, 12))\n  \n  # APAC Section\n  story.append(Paragraph(\"Région APAC\", styles[\"Heading2\"]))\n  story.append(Paragraph(\"Growth: ✓ Exceeded targets\", styles[\"Normal\"]))\n  story.append(Paragraph(\"Key: 日本，中国，한국\", styles[\"Normal\"]))\n  \n  doc.build(story)\n\n## Step 3: Generate PDF with ReportLab\nrun_shell\ncommand: python \u002Ftmp\u002Fgenerate_intl_pdf.py\n\n## Step 4: Generate DOCX with pandoc\nrun_shell\ncommand: pandoc \u002Ftmp\u002Fintl_report.md -o intl_analysis.docx\n\n## Step 5: Generate HTML with pandoc\nrun_shell\ncommand: pandoc \u002Ftmp\u002Fintl_report.md -o intl_analysis.html\n\n## Step 6: Verify\nrun_shell\ncommand: ls -lh intl_analysis.*\n```\n\n### Example 3: Hybrid Approach with Fallback\n\n```markdown\n# Generate with Pandoc, Fallback to ReportLab\n\n## Step 1: Create source document\nwrite_file\npath: \u002Ftmp\u002Fanalysis.md\ncontent: |\n  # Analysis Document\n  [Content...]\n\n## Step 2: Try pandoc first\nrun_shell\ncommand: pandoc \u002Ftmp\u002Fanalysis.md -o analysis.pdf\n\n## Step 3: If pandoc fails, use ReportLab fallback\n[If Step 2 returns error...]\nwrite_file\npath: \u002Ftmp\u002Ffallback_pdf.py\ncontent: |\n  from reportlab.lib.pagesizes import letter\n  from reportlab.platypus import SimpleDocTemplate, Paragraph, Spacer\n  from reportlab.lib.styles import getSampleStyleSheet\n  from reportlab.pdfbase import pdfmetrics\n  from reportlab.pdfbase.ttfonts import TTFont\n  \n  # Register Unicode font if needed\n  # pdfmetrics.registerFont(TTFont('UnicodeFont', '\u002Fpath\u002Fto\u002Ffont.ttf'))\n  \n  doc = SimpleDocTemplate(\"analysis.pdf\", pagesize=letter)\n  styles = getSampleStyleSheet()\n  story = []\n  story.append(Paragraph(\"Analysis Document\", styles[\"Heading1\"]))\n  story.append(Spacer(1, 12))\n  story.append(Paragraph(\"[Content from analysis.md parsed here]\", styles[\"Normal\"]))\n  doc.build(story)\n\nrun_shell\ncommand: python \u002Ftmp\u002Ffallback_pdf.py\n```\n\n## Common pandoc Commands\n\n```bash\n# Markdown to Word\npandoc input.md -o output.docx\n\n# Markdown to PDF (requires LaTeX)\npandoc input.md -o output.pdf\n\n# Markdown to PDF with Unicode-safe engine (better Unicode support)\npandoc input.md -o output.pdf --pdf-engine=xelatex\n\n# Markdown to PDF with wkhtmltopdf (alternative, no LaTeX)\npandoc input.md -o output.pdf --pdf-engine=wkhtmltopdf\n\n# Markdown to HTML\npandoc input.md -o output.html\n\n# With custom template\npandoc input.md --template=template.html -o output.html\n\n# With metadata\npandoc input.md -o output.pdf --metadata title=\"Document Title\"\n```\n\n## Common ReportLab Patterns\n\n```python\n# Basic PDF creation\nfrom reportlab.lib.pagesizes import letter\nfrom reportlab.platypus import SimpleDocTemplate, Paragraph, Spacer\nfrom reportlab.lib.styles import getSampleStyleSheet\n\ndoc = SimpleDocTemplate(\"output.pdf\", pagesize=letter)\nstyles = getSampleStyleSheet()\nstory = []\nstory.append(Paragraph(\"Title\", styles[\"Heading1\"]))\nstory.append(Spacer(1, 12))\nstory.append(Paragraph(\"Content\", styles[\"Normal\"]))\ndoc.build(story)\n\n# With tables\nfrom reportlab.platypus import Table, TableStyle\nfrom reportlab.lib import colors\n\ndata = [['Header1', 'Header2'], ['Row1-Col1', 'Row1-Col2']]\ntable = Table(data)\ntable.setStyle(TableStyle([\n    ('BACKGROUND', (0, 0), (-1, 0), colors.grey),\n    ('TEXTCOLOR', (0, 0), (-1, 0), colors.whitesmoke),\n    ('GRID', (0, 0), (-1, -1), 0.5, colors.black),\n]))\nstory.append(table)\n\n# With custom fonts for Unicode\nfrom reportlab.pdfbase import pdfmetrics\nfrom reportlab.pdfbase.ttfonts import TTFont\n\npdfmetrics.registerFont(TTFont('NotoSans', 'NotoSans-Regular.ttf'))\ncustom_style = ParagraphStyle('Custom', fontName='NotoSans', fontSize=12)\nstory.append(Paragraph(\"Unicode: 日本語 العربية\", custom_style))\n```\n\n## Troubleshooting\n\n### Pandoc Issues\n\n- **PDF generation fails with encoding error**: \n  - Use the sanitized markdown file\n  - Try `--pdf-engine=xelatex` for better Unicode support\n  - Try `--pdf-engine=wkhtmltopdf` as alternative\n\n- **PDF generation fails: LaTeX not found**: \n  - Install LaTeX: `apt-get install texlive-latex-recommended texlive-fonts-recommended`\n  - **Switch to ReportLab backend** (no LaTeX needed)\n\n- **DOCX formatting issues**: Add `--reference-doc=template.docx` for custom styles\n\n- **Missing pandoc**: Install via `apt-get install pandoc` or `brew install pandoc`\n\n### ReportLab Issues\n\n- **Missing reportlab**: Install via `pip install reportlab`\n\n- **Unicode characters not rendering**: \n  - ReportLab handles UTF-8 natively - ensure Python script uses UTF-8\n  - For CJK\u002FArabic\u002Fetc., register a Unicode-capable font:\n    ```python\n    from reportlab.pdfbase import pdfmetrics\n    from reportlab.pdfbase.ttfonts import TTFont\n    pdfmetrics.registerFont(TTFont('NotoSans', 'NotoSans-Regular.ttf'))\n    ```\n\n- **Complex layouts needed**: Use `reportlab.lib.canvas` for direct drawing operations\n\n- **Tables breaking across pages**: Use `reportlab.platypus.LongTable` instead of `Table`\n\n### General Issues\n\n- **Unicode\u002Fencoding errors in any format**: \n  - Add `-f markdown+utf8` to pandoc command\n  - Ensure source file is UTF-8 encoded: `file -i source.md`\n\n- **Special characters not rendering in PDF**: \n  - For pandoc: Use character replacement table or ReportLab\n  - For ReportLab: Register appropriate Unicode fonts\n\n## Installation Commands\n\n```bash\n# Install pandoc\napt-get install pandoc  # Debian\u002FUbuntu\nbrew install pandoc     # macOS\n\n# Install LaTeX (for pdflatex)\napt-get install texlive-latex-recommended texlive-fonts-recommended\n\n# Install wkhtmltopdf (alternative PDF engine)\napt-get install wkhtmltopdf\n\n# Install ReportLab\npip install reportlab\n\n# Install fonts for Unicode support\napt-get install fonts-noto-core  # Comprehensive Unicode font\n```\n\n## Unicode Sanitization Script (For Pandoc Path)\n\nFor repeated use with pandoc, create a reusable sanitization script:\n\n```bash\n#!\u002Fbin\u002Fbash\n# sanitize_for_pdf.sh - Replace problematic unicode chars for LaTeX\u002FPDF\nif [ -z \"$1\" ]; then\n  echo \"Usage: $0 \u003Cinput.md> [output.md]\"\n  exit 1\nfi\nINPUT=\"$1\"\nOUTPUT=\"${2:-${1%.md}_sanitized.md}\"\n\nsed -e 's\u002F—\u002F--\u002Fg' \\\n    -e 's\u002F–\u002F-\u002Fg' \\\n    -e 's\u002F\"([^\"]*)\"\u002F\"\\1\"\u002Fg' \\\n    -e \"s\u002F'([^']*)'\u002F\\1'\u002Fg\" \\\n    -e 's\u002F…\u002F...\u002Fg' \\\n    -e 's\u002F→\u002F->\u002Fg' \\\n    -e 's\u002F←\u002F\u003C-\u002Fg' \\\n    -e 's\u002F✓\u002F[x]\u002Fg' \\\n    -e 's\u002F✗\u002F[ ]\u002Fg' \\\n    -e 's\u002F©\u002F(c)\u002Fg' \\\n    -e 's\u002F®\u002F(r)\u002Fg' \\\n    -e 's\u002F™\u002F(tm)\u002Fg' \\\n    \"$INPUT\" > \"$OUTPUT\"\n\necho \"Sanitized: $INPUT -> $OUTPUT\"\n```\n\nSave as `sanitize_for_pdf.sh`, make executable with `chmod +x sanitize_for_pdf.sh`, then use:\n\n```\nrun_shell\ncommand: .\u002Fsanitize_for_pdf.sh \u002Ftmp\u002Fdocument_source.md \u002Ftmp\u002Fdocument_source_sanitized.md\n```\n\n## Decision Flowchart\n\n```\nNeed PDF generation?\n    │\n    ├─ Heavy Unicode\u002Fsymbols? ──YES──> Use ReportLab\n    │         │\n    │         NO\n    │         │\n    ├─ LaTeX available? ──NO──> Use ReportLab\n    │         │\n    │         YES\n    │         │\n    ├─ Need Markdown formatting? ──YES──> Use Pandoc (with sanitization)\n    │         │\n    │         NO\n    │         │\n    └─ Need programmatic layout? ──YES──> Use ReportLab\n```\n\n## When to Return to shell_agent\n\nAfter successfully completing the manual workflow once, you can attempt `shell_agent` again for similar tasks, now with a known-working fallback if errors recur. For documents with heavy Unicode content or when LaTeX is unavailable, prefer the ReportLab path.\n\n## Related Skills\n\n- `document-gen-unicode-safe`: Parent skill with pandoc-only approach\n- `document-gen-fallback`: Original fallback workflow without Unicode guidance\n- Use this skill when you need flexible PDF generation with multiple backend options\n### Example 0: Lightweight Single-Format Generation\n\n```markdown\n# Quick DOCX Generation (No shell_agent needed)\n\n## Step 1: Write content\nwrite_file\npath: \u002Ftmp\u002Fbrief.md\ncontent: |\n  # Meeting Notes\n  \n  ## Attendees\n  - Alice\n  - Bob\n  \n  ## Decisions\n  Project approved.\n\n## Step 2: Convert directly\nrun_shell\ncommand: pandoc \u002Ftmp\u002Fbrief.md -o meeting_notes.docx\n\n## Step 3: Verify\nrun_shell\ncommand: ls -lh meeting_notes.docx\n```\n\n---\n\n### Example 1: Pandoc-First Approach (Multi-Format with Sanitization)\n\n### Example 2: ReportLab-First Approach (Heavy Unicode — Direct Execution)\n\n## Mode Selection Quick Reference\n\n| Scenario | Recommended Mode | Why |\n|----------|------------------|-----|\n| Simple Markdown → DOCX | **Lightweight** | Direct pandoc call is fastest |\n| Single PDF from ASCII content | **Lightweight** | No sanitization needed |\n| Multi-format batch (DOCX + PDF + HTML) | **Full Workflow** | Coordinated conversion with error handling |\n| Content with Unicode\u002Fsymbols | **Lightweight + ReportLab** | Direct Python script avoids LaTeX issues |\n| Uncertain about LaTeX availability | **Full Workflow** | Built-in fallback detection |\n| Need programmatic layout control | **Full Workflow** | ReportLab integration with fallback logic |\n| Production pipeline with error recovery | **Full Workflow** | Automated retry and backend switching |\n\n---\n\n## Troubleshooting\n\n- **Missing reportlab**: Install\n### ReportLab Issues\n\n- **Missing reportlab**: Install via `pip install reportlab`\n",{"name":5,"description":7},"main","6b84b0689ca0d9e7b1e4061188ff6b60758e0f8a","openspace\u002Flegacy\u002Fv1\u002Fgdpval_bench\u002Fskills\u002Fdocument-gen-fallback-enhanced-enhanced-9f3b1f",940,"https:\u002F\u002Fgithub.com\u002FHKUDS\u002FAgentPilot","https:\u002F\u002Fgithub.com\u002FHKUDS","https:\u002F\u002Fsites.google.com\u002Fview\u002Fchaoh","2026-11-06 23:04:01",{"source":8,"skillName":5,"commands":57,"prompt":67,"zipAvailable":68},[58,61,64],{"tool":59,"command":60},"npx","npx skills add HKUDS\u002FAgentPilot --skill document-gen-dual-backend",{"tool":62,"command":63},"bunx","bunx skills add HKUDS\u002FAgentPilot --skill document-gen-dual-backend",{"tool":65,"command":66},"pnpm","pnpm dlx skills add HKUDS\u002FAgentPilot --skill document-gen-dual-backend","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002FHKUDS\u002FAgentPilot\u002Fblob\u002Fmain\u002Fopenspace\u002Flegacy\u002Fv1\u002Fgdpval_bench\u002Fskills\u002Fdocument-gen-fallback-enhanced-enhanced-9f3b1f\u002FSKILL.md",true,[70],{"path":71,"resourceType":72,"resourceTypeDesc":73,"sizeBytes":74,"sourceHtmlUrl":75},".skill_id","OTHER","其他",60,"https:\u002F\u002Fgithub.com\u002FHKUDS\u002FAgentPilot\u002Fblob\u002Fmain\u002Fopenspace\u002Flegacy\u002Fv1\u002Fgdpval_bench\u002Fskills\u002Fdocument-gen-fallback-enhanced-enhanced-9f3b1f\u002F.skill_id",[77,96,115,136,159,182],{"skillNo":78,"name":79,"nameZh":6,"description":80,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":81,"categories":82,"keywords":83,"publishedAt":43},"01M6HYB297NDABRERJRVG0K8R0","agentpilot","Set up AgentPilot and use its single entry to prepare missing inputs and run configured RSI experiments. Use when the user requests AgentPilot installation or work with AgentPilot.","https:\u002F\u002Fgithub.com\u002FHKUDS\u002FAgentPilot\u002Fblob\u002Fmain\u002Fplugins\u002Fagentpilot\u002Fskills\u002Fagentpilot\u002FSKILL.md",[],[79,84,85,41,86,87,88,89,90,91,92,93,94,95],"prepare","requests","missing","installation","rsi","up","use","user","work","SET","run","experiments",{"skillNo":97,"name":98,"nameZh":6,"description":99,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":100,"categories":101,"keywords":102,"publishedAt":43},"01M6HYAYWXTTE1J7DJM0MFNQ4H","remember","Review auto-memory entries and propose promotions to OPENSPACE.md, OPENSPACE.local.md, or retained auto-memory topics; detect duplicates, stale facts, conflicts, and ambiguous entries before making changes.","https:\u002F\u002Fgithub.com\u002FHKUDS\u002FAgentPilot\u002Fblob\u002Fmain\u002Fopenspace\u002Fopenspace\u002Fskills\u002Fremember\u002FSKILL.md",[],[98,103,104,105,106,107,108,109,110,111,112,113,114],"memory","review","auto","openspace","changes","facts","detect","entries","local","conflicts","stale","duplicates",{"skillNo":116,"name":117,"nameZh":6,"description":118,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":119,"categories":120,"keywords":122,"publishedAt":43},"01M6HYAVMPM4SBDV60R2B5HPV8","skill-discovery","Search reusable OpenSpace skills locally, and browse cloud packages step by step when a cloud skill may help. Reusing proven skills saves tokens, improves reliability, and extends your capabilities beyond built-in tools.","https:\u002F\u002Fgithub.com\u002FHKUDS\u002FAgentPilot\u002Fblob\u002Fmain\u002Fopenspace\u002Fopenspace\u002Fhost_skills\u002Fskill-discovery\u002FSKILL.md",[121],{"categoryNo":27,"categoryName":28,"taxonomyType":21,"taxonomyTypeDesc":22},[123,124,125,106,126,127,128,129,130,131,132,133,134,135],"skill discovery","discovery","reusable","step by step","tokens","packages","help","cloud","reliability","capabilities","browse","search","Tools",{"skillNo":137,"name":138,"nameZh":6,"description":139,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":140,"categories":141,"keywords":143,"publishedAt":43},"01M6HYAR811B3RB0M50RBEDGN6","delegate-task","Delegate tasks to OpenSpace — a full-stack autonomous worker for coding, DevOps, web research, and desktop automation, backed by an extensive MCP tool and skill library. Skills auto-improve through use, reducing token consumption over time. A cloud community lets agents share and collectively evolve reusable skills.","https:\u002F\u002Fgithub.com\u002FHKUDS\u002FAgentPilot\u002Fblob\u002Fmain\u002Fopenspace\u002Fopenspace\u002Fhost_skills\u002Fdelegate-task\u002FSKILL.md",[142],{"categoryNo":27,"categoryName":28,"taxonomyType":21,"taxonomyTypeDesc":22},[144,145,146,106,147,148,149,150,151,125,105,90,152,153,154,42,155,156,157,158],"delegate","task","delegate task","time","improve","desktop automation","worker","community","autonomous","tool","stack","share","tasks","automation","MCP",{"skillNo":160,"name":161,"nameZh":6,"description":162,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":163,"categories":164,"keywords":165,"publishedAt":43},"01M6HYAM9FSGV6E52AYENDQXYH","write-special-chars-ts-check","Workaround for write_file failures caused by special characters (apostrophes, backticks, template literals) using a Python heredoc script, plus a reliable TypeScript type-checking step that filters output to only the newly-written files to avoid being misled by pre-existing errors.","https:\u002F\u002Fgithub.com\u002FHKUDS\u002FAgentPilot\u002Fblob\u002Fmain\u002Fopenspace\u002Flegacy\u002Fv1\u002Fshowcase\u002Fskills\u002Fwrite-special-chars-ts-check\u002FSKILL.md",[],[166,167,168,169,170,171,172,173,174,175,176,177,178,179,42,180,181],"write special chars ts check","write","check","type","files","filters","only","template","file","python","typescript","output","Existing","type-checking","errors","script",{"skillNo":183,"name":184,"nameZh":6,"description":185,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":186,"categories":187,"keywords":188,"publishedAt":43},"01M6HYAH05HGV7SVWSVR8PJRQD","write-special-chars-readback","Workaround for write_file failures caused by special characters (apostrophes, backticks, template literals) using a Python heredoc script, with mandatory post-write verification via read_file and cleanup of \u002Ftmp helper scripts.","https:\u002F\u002Fgithub.com\u002FHKUDS\u002FAgentPilot\u002Fblob\u002Fmain\u002Fopenspace\u002Flegacy\u002Fv1\u002Fshowcase\u002Fskills\u002Fwrite-special-chars-readback\u002FSKILL.md",[],[189,190,167,41,42,181,191,192,193,194,195,173,174,196,197,175],"write special chars readback","readback","helper","post","via","scripts","read","verification","cleanup"]