[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M6HXGSVTNY9JQZ02QV6DPGGW":3,"skill-same:01M6HXGSVTNY9JQZ02QV6DPGGW":74},{"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":26,"publishedAt":41,"linkOnly":42,"markdownContent":43,"markdownBody":44,"frontMatter":45,"refName":46,"commitSha":47,"skillDirectory":48,"forksCount":49,"repositoryHtmlUrl":50,"repositoryHomepageUrl":6,"ownerHtmlUrl":51,"ownerBlogUrl":52,"ownerDescription":6,"updatedAt":53,"install":54,"resources":67},"01M6HXGSVTNY9JQZ02QV6DPGGW","document-gen-unicode-safe",null,"Unicode-safe fallback workflow for multi-format document generation with character sanitization","HKUDS\u002FAgentPilot","HKUDS","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F118165258?v=4","01M6HW8VRNZP64G0P4MVJW2KKQ","✨Data Intelligence Lab@HKU✨","01M6HW8VWZVHBRHYH3T330PFWV",8029,"MIT","https:\u002F\u002Fgithub.com\u002FHKUDS\u002FAgentPilot\u002Fblob\u002Fmain\u002Fopenspace\u002Flegacy\u002Fv1\u002Fgdpval_bench\u002Fskills\u002Fdocument-gen-fallback-enhanced-enhanced-c5d426\u002FSKILL.md",[18,23],{"categoryNo":19,"categoryName":20,"taxonomyType":21,"taxonomyTypeDesc":22},"01JBSEEDCAT000000000000002","文档处理","SCENARIO","使用场景",{"categoryNo":24,"categoryName":25,"taxonomyType":21,"taxonomyTypeDesc":22},"01JBSEEDCAT000000000000023","Skill与智能体开发",[27,28,29,30,31,32,33,34,35,36,37,38,39,40],"safe","document","Unicode","document gen unicode safe","workflow","format","fallback","character","generation","multi","document generation","with","sanitization","for","2026-11-10 10:12:30",false,"---\nname: document-gen-unicode-safe\ndescription: Unicode-safe fallback workflow for multi-format document generation with character sanitization\n---\n\n# Document Generation Fallback Workflow (Unicode-Safe)\n\n## When to Use\n\n**First**, assess whether to delegate to `shell_agent` or use manual workflow:\n\n### ✅ Use shell_agent Directly When:\n- Document is straightforward (no special Unicode characters, symbols, or non-ASCII text)\n- Single format output needed (e.g., just `.docx`)\n- Content is primarily ASCII text with standard punctuation\n- No complex formatting requirements (tables, equations, custom templates)\n- You want quick iteration and `shell_agent` has succeeded on similar tasks before\n\n### ⚠️ Use Manual Workflow When:\n- `shell_agent` returns unknown or unclear errors\n- **Document contains special characters, symbols, or non-ASCII text** (see Unicode table below)\n- Generating multiple formats simultaneously (e.g., `.docx`, `.pdf`, `.html`)\n- PDF generation fails due to LaTeX encoding issues\n- You need fine-grained control over each conversion step\n- Previous `shell_agent` attempts failed on similar content\n\n### ? Decision Checklist\n\n```markdown\n1. Does the document contain: em-dashes (—), curly quotes (\" \"), arrows (→), \n   checkmarks (✓), or other special symbols? → Use Manual Workflow\n\n2. Is non-ASCII text present (é, ñ, ü, 中文，العربية)? → Use Manual Workflow with sanitization\n\n3. Did shell_agent already fail on this or similar content? → Use Manual Workflow\n\n4. Need multiple output formats with guaranteed success? → Use Manual Workflow\n\n5. Simple ASCII document, single format, first attempt? → Try shell_agent First\n```\n\n## Core Technique\n\n**Quick Path** (for straightforward documents): Delegate directly to `shell_agent` with clear instructions:\n\n```\nshell_agent\ntask: Create a Word document from markdown content. Write the markdown to \n      \u002Ftmp\u002Fdocument.md, then convert to .docx using pandoc, and verify the output exists.\n```\n\n**Manual Path** (for complex\u002FUnicode-heavy documents): Split the workflow into discrete, observable steps:\n1. **Content creation** → Use `write_file` to create source document (Markdown)\n2. **Unicode sanitization** → Preprocess markdown to replace problematic characters before PDF conversion\n3. **Format conversion** → Use `run_shell` with `pandoc` for each target format\n4. **Verification** → Check output files exist and are valid\n\n## Why This Adaptive Approach?\n\n| Scenario | Recommended Approach | Rationale |\n|----------|---------------------|-----------|\n| Simple ASCII doc, single format | shell_agent | Faster, less manual overhead |\n| Unicode symbols present | Manual workflow | Prevents LaTeX encoding failures |\n| Previous shell_agent failure | Manual workflow | Avoids repeat failures |\n| Multiple formats needed | Manual workflow | Granular control per format |\n| Time-sensitive, low-risk | shell_agent first | Try fast path, fallback if needed |\n1. **Content creation** → Use `write_file` to create source document (Markdown)\n2. **Unicode sanitization** → Preprocess markdown to replace problematic characters before PDF conversion\n3. **Format conversion** → Use `run_shell` with `pandoc` for each target format\n4. **Verification** → Check output files exist and are valid\n\n## ⚠️ Unicode & LaTeX Compatibility Warning\n\n**Critical**: 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## Step-by-Step Workflow\n\n### Step 1: Create Source Content with write_file\n\nWrite your document content as Markdown to a temporary source file. This gives you full visibility into the content being generated.\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 2: Sanitize Unicode Characters (Pre-PDF Conversion)\n\n**Before PDF conversion**, create a sanitized version of your markdown with LaTeX-safe characters:\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**Alternative**: Use a shell script to sanitize:\n\n```\nrun_shell\ncommand: sed -e 's\u002F—\u002F--\u002Fg' -e 's\u002F–\u002F-\u002Fg' -e 's\u002F\"([^\"]*)\"\u002F\"\\1\"\u002Fg' -e 's\u002F'([^']*)\u002F'\\1'\u002Fg' \u002Ftmp\u002Fdocument_source.md > \u002Ftmp\u002Fdocument_source_sanitized.md\n```\n\n**Note**: Keep the original unsanitized file for DOCX\u002FHTML conversion (these formats handle Unicode better).\n\n### Step 3: Convert to Target Formats with run_shell\n\nUse `run_shell` with explicit `pandoc` commands for each format. Use sanitized source for PDF, original for other formats.\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### Step 4: Verify Outputs\n\nCheck that files were created successfully:\n\n```\nrun_shell\ncommand: ls -lh output.docx output.pdf output.html\n```\n\n## Complete Example\n\n### Quick Path Example (Simple Document)\n\n```markdown\n# Generate Simple Meeting Notes\n\n## Delegate to shell_agent\nshell_agent\ntask: |\n  Create meeting notes document:\n  1. Write to \u002Ftmp\u002Fmeeting_notes.md with content:\n     \"# Team Meeting Notes\n     \n     ## Date: 2024-01-15\n     ## Attendees: Alice, Bob, Carol\n     \n     ## Action Items\n     - Alice: Complete report by Friday\n     - Bob: Schedule follow-up meeting\n     \n     ## Next Meeting: 2024-01-22\"\n  2. Convert to Word: pandoc \u002Ftmp\u002Fmeeting_notes.md -o meeting_notes.docx\n  3. Verify: ls -lh meeting_notes.docx\n```\n\n### Manual Path Example (Unicode-Heavy Document)\n\n```markdown\n# Generate Negotiation Strategy Document\n\n## Step 1: Write Markdown source\nwrite_file\npath: \u002Ftmp\u002Fnegotiation_strategy.md\ncontent: |\n  # Negotiation Strategy\n  \n  ## Executive Summary\n  [Content with original unicode...]\n  \n  ## Resolution Path\n  [Content...]\n  \n  ## BATNA Analysis\n  [Content...]\n\n## Step 2: Create sanitized version for PDF\nwrite_file\npath: \u002Ftmp\u002Fnegotiation_strategy_sanitized.md\ncontent: |\n  # Negotiation Strategy\n  \n  ## Executive Summary\n  [Content with unicode replaced: em-dash -> --, curly quotes -> straight, etc.]\n  \n  ## Resolution Path\n  [Content...]\n  \n  ## BATNA Analysis\n  [Content...]\n\n## Step 3: Convert to DOCX (from original)\nrun_shell\ncommand: pandoc \u002Ftmp\u002Fnegotiation_strategy.md -o negotiation_strategy.docx\n\n## Step 4: Convert to PDF (from sanitized)\nrun_shell\ncommand: pandoc \u002Ftmp\u002Fnegotiation_strategy_sanitized.md -o negotiation_strategy.pdf\n\n## Step 5: Convert to HTML (from original)\nrun_shell\ncommand: pandoc \u002Ftmp\u002Fnegotiation_strategy.md -o negotiation_strategy.html\n\n## Step 6: Verify\nrun_shell\ncommand: ls -lh negotiation_strategy.*\n```\n\n## Advantages Over shell_agent\n\n| Aspect | shell_agent | Manual Workflow |\n|--------|-------------|-----------------|\n| Error visibility | Opaque, may retry silently | Each step shows explicit output |\n| Recovery | Automatic but may loop | Manual intervention at specific step |\n| Debugging | Hard to isolate failure point | Clear which step failed |\n| Unicode control | Agent may not handle encoding | You control character sanitization |\n| Control | Agent decides approach | You control each conversion |\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 or wkhtmltopdf)\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 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## Troubleshooting\n\n- **PDF generation fails with encoding error**: \n  - Use the sanitized markdown file (Step 2)\n  - Or try `--pdf-engine=xelatex` for better Unicode support\n  - Or use `--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  - Or use `--pdf-engine=wkhtmltopdf` instead\n\n- **DOCX formatting issues**: Add `--reference-doc=template.docx` for custom styles\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  - Use the character replacement table above\n  - Create sanitized version before PDF conversion\n\n- **Missing pandoc**: Install via `apt-get install pandoc` or `brew install pandoc`\n\n## Unicode Sanitization Script (Optional)\n\nFor repeated use, 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## When to Return to shell_agent\n\n**After successful shell_agent completion**: Continue using shell_agent for similar straightforward documents.\n\n**After shell_agent failure on Unicode content**: Switch to manual workflow for that document and similar future documents. Document the failure pattern.\n\n**After successful manual workflow**: You now have a proven approach. For future similar documents:\n- If content is similar (same Unicode patterns): Use manual workflow directly\n- If content is simpler: Try shell_agent first, keep manual workflow as backup\n- Build a library of sanitized templates for repeated use\n\n## Related Skills\n\n- `document-gen-fallback`: Original fallback workflow without Unicode guidance\n- Use this skill as your **primary** document generation skill—it adapts to document complexity\n- Fall back to `document-gen-unicode-safe` (parent) if you need the original prescriptive manual-only approach\nname: document-gen-adaptive-workflow\ndescription: Adaptive document generation with smart fallback to manual Unicode-safe workflow\n### Quick Path: Delegate to shell_agent\n\nFor straightforward documents without Unicode concerns:\n\n```\nshell_agent\ntask: |\n  1. Write markdown content to \u002Ftmp\u002Freport.md using write_file\n  2. Convert to Word format: pandoc \u002Ftmp\u002Freport.md -o report.docx\n  3. Convert to PDF: pandoc \u002Ftmp\u002Freport.md -o report.pdf --pdf-engine=xelatex\n  4. Verify both files exist with: ls -lh report.docx report.pdf\n  5. Report the file sizes and confirm successful generation\n```\n\n**If shell_agent succeeds**: Task complete.\n\n**If shell_agent fails**: Switch to Manual Path below.\n\n### Manual Path: Step-by-Step Workflow\n","# Document Generation Fallback Workflow (Unicode-Safe)\n\n## When to Use\n\n**First**, assess whether to delegate to `shell_agent` or use manual workflow:\n\n### ✅ Use shell_agent Directly When:\n- Document is straightforward (no special Unicode characters, symbols, or non-ASCII text)\n- Single format output needed (e.g., just `.docx`)\n- Content is primarily ASCII text with standard punctuation\n- No complex formatting requirements (tables, equations, custom templates)\n- You want quick iteration and `shell_agent` has succeeded on similar tasks before\n\n### ⚠️ Use Manual Workflow When:\n- `shell_agent` returns unknown or unclear errors\n- **Document contains special characters, symbols, or non-ASCII text** (see Unicode table below)\n- Generating multiple formats simultaneously (e.g., `.docx`, `.pdf`, `.html`)\n- PDF generation fails due to LaTeX encoding issues\n- You need fine-grained control over each conversion step\n- Previous `shell_agent` attempts failed on similar content\n\n### ? Decision Checklist\n\n```markdown\n1. Does the document contain: em-dashes (—), curly quotes (\" \"), arrows (→), \n   checkmarks (✓), or other special symbols? → Use Manual Workflow\n\n2. Is non-ASCII text present (é, ñ, ü, 中文，العربية)? → Use Manual Workflow with sanitization\n\n3. Did shell_agent already fail on this or similar content? → Use Manual Workflow\n\n4. Need multiple output formats with guaranteed success? → Use Manual Workflow\n\n5. Simple ASCII document, single format, first attempt? → Try shell_agent First\n```\n\n## Core Technique\n\n**Quick Path** (for straightforward documents): Delegate directly to `shell_agent` with clear instructions:\n\n```\nshell_agent\ntask: Create a Word document from markdown content. Write the markdown to \n      \u002Ftmp\u002Fdocument.md, then convert to .docx using pandoc, and verify the output exists.\n```\n\n**Manual Path** (for complex\u002FUnicode-heavy documents): Split the workflow into discrete, observable steps:\n1. **Content creation** → Use `write_file` to create source document (Markdown)\n2. **Unicode sanitization** → Preprocess markdown to replace problematic characters before PDF conversion\n3. **Format conversion** → Use `run_shell` with `pandoc` for each target format\n4. **Verification** → Check output files exist and are valid\n\n## Why This Adaptive Approach?\n\n| Scenario | Recommended Approach | Rationale |\n|----------|---------------------|-----------|\n| Simple ASCII doc, single format | shell_agent | Faster, less manual overhead |\n| Unicode symbols present | Manual workflow | Prevents LaTeX encoding failures |\n| Previous shell_agent failure | Manual workflow | Avoids repeat failures |\n| Multiple formats needed | Manual workflow | Granular control per format |\n| Time-sensitive, low-risk | shell_agent first | Try fast path, fallback if needed |\n1. **Content creation** → Use `write_file` to create source document (Markdown)\n2. **Unicode sanitization** → Preprocess markdown to replace problematic characters before PDF conversion\n3. **Format conversion** → Use `run_shell` with `pandoc` for each target format\n4. **Verification** → Check output files exist and are valid\n\n## ⚠️ Unicode & LaTeX Compatibility Warning\n\n**Critical**: 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## Step-by-Step Workflow\n\n### Step 1: Create Source Content with write_file\n\nWrite your document content as Markdown to a temporary source file. This gives you full visibility into the content being generated.\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 2: Sanitize Unicode Characters (Pre-PDF Conversion)\n\n**Before PDF conversion**, create a sanitized version of your markdown with LaTeX-safe characters:\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**Alternative**: Use a shell script to sanitize:\n\n```\nrun_shell\ncommand: sed -e 's\u002F—\u002F--\u002Fg' -e 's\u002F–\u002F-\u002Fg' -e 's\u002F\"([^\"]*)\"\u002F\"\\1\"\u002Fg' -e 's\u002F'([^']*)\u002F'\\1'\u002Fg' \u002Ftmp\u002Fdocument_source.md > \u002Ftmp\u002Fdocument_source_sanitized.md\n```\n\n**Note**: Keep the original unsanitized file for DOCX\u002FHTML conversion (these formats handle Unicode better).\n\n### Step 3: Convert to Target Formats with run_shell\n\nUse `run_shell` with explicit `pandoc` commands for each format. Use sanitized source for PDF, original for other formats.\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### Step 4: Verify Outputs\n\nCheck that files were created successfully:\n\n```\nrun_shell\ncommand: ls -lh output.docx output.pdf output.html\n```\n\n## Complete Example\n\n### Quick Path Example (Simple Document)\n\n```markdown\n# Generate Simple Meeting Notes\n\n## Delegate to shell_agent\nshell_agent\ntask: |\n  Create meeting notes document:\n  1. Write to \u002Ftmp\u002Fmeeting_notes.md with content:\n     \"# Team Meeting Notes\n     \n     ## Date: 2024-01-15\n     ## Attendees: Alice, Bob, Carol\n     \n     ## Action Items\n     - Alice: Complete report by Friday\n     - Bob: Schedule follow-up meeting\n     \n     ## Next Meeting: 2024-01-22\"\n  2. Convert to Word: pandoc \u002Ftmp\u002Fmeeting_notes.md -o meeting_notes.docx\n  3. Verify: ls -lh meeting_notes.docx\n```\n\n### Manual Path Example (Unicode-Heavy Document)\n\n```markdown\n# Generate Negotiation Strategy Document\n\n## Step 1: Write Markdown source\nwrite_file\npath: \u002Ftmp\u002Fnegotiation_strategy.md\ncontent: |\n  # Negotiation Strategy\n  \n  ## Executive Summary\n  [Content with original unicode...]\n  \n  ## Resolution Path\n  [Content...]\n  \n  ## BATNA Analysis\n  [Content...]\n\n## Step 2: Create sanitized version for PDF\nwrite_file\npath: \u002Ftmp\u002Fnegotiation_strategy_sanitized.md\ncontent: |\n  # Negotiation Strategy\n  \n  ## Executive Summary\n  [Content with unicode replaced: em-dash -> --, curly quotes -> straight, etc.]\n  \n  ## Resolution Path\n  [Content...]\n  \n  ## BATNA Analysis\n  [Content...]\n\n## Step 3: Convert to DOCX (from original)\nrun_shell\ncommand: pandoc \u002Ftmp\u002Fnegotiation_strategy.md -o negotiation_strategy.docx\n\n## Step 4: Convert to PDF (from sanitized)\nrun_shell\ncommand: pandoc \u002Ftmp\u002Fnegotiation_strategy_sanitized.md -o negotiation_strategy.pdf\n\n## Step 5: Convert to HTML (from original)\nrun_shell\ncommand: pandoc \u002Ftmp\u002Fnegotiation_strategy.md -o negotiation_strategy.html\n\n## Step 6: Verify\nrun_shell\ncommand: ls -lh negotiation_strategy.*\n```\n\n## Advantages Over shell_agent\n\n| Aspect | shell_agent | Manual Workflow |\n|--------|-------------|-----------------|\n| Error visibility | Opaque, may retry silently | Each step shows explicit output |\n| Recovery | Automatic but may loop | Manual intervention at specific step |\n| Debugging | Hard to isolate failure point | Clear which step failed |\n| Unicode control | Agent may not handle encoding | You control character sanitization |\n| Control | Agent decides approach | You control each conversion |\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 or wkhtmltopdf)\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 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## Troubleshooting\n\n- **PDF generation fails with encoding error**: \n  - Use the sanitized markdown file (Step 2)\n  - Or try `--pdf-engine=xelatex` for better Unicode support\n  - Or use `--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  - Or use `--pdf-engine=wkhtmltopdf` instead\n\n- **DOCX formatting issues**: Add `--reference-doc=template.docx` for custom styles\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  - Use the character replacement table above\n  - Create sanitized version before PDF conversion\n\n- **Missing pandoc**: Install via `apt-get install pandoc` or `brew install pandoc`\n\n## Unicode Sanitization Script (Optional)\n\nFor repeated use, 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## When to Return to shell_agent\n\n**After successful shell_agent completion**: Continue using shell_agent for similar straightforward documents.\n\n**After shell_agent failure on Unicode content**: Switch to manual workflow for that document and similar future documents. Document the failure pattern.\n\n**After successful manual workflow**: You now have a proven approach. For future similar documents:\n- If content is similar (same Unicode patterns): Use manual workflow directly\n- If content is simpler: Try shell_agent first, keep manual workflow as backup\n- Build a library of sanitized templates for repeated use\n\n## Related Skills\n\n- `document-gen-fallback`: Original fallback workflow without Unicode guidance\n- Use this skill as your **primary** document generation skill—it adapts to document complexity\n- Fall back to `document-gen-unicode-safe` (parent) if you need the original prescriptive manual-only approach\nname: document-gen-adaptive-workflow\ndescription: Adaptive document generation with smart fallback to manual Unicode-safe workflow\n### Quick Path: Delegate to shell_agent\n\nFor straightforward documents without Unicode concerns:\n\n```\nshell_agent\ntask: |\n  1. Write markdown content to \u002Ftmp\u002Freport.md using write_file\n  2. Convert to Word format: pandoc \u002Ftmp\u002Freport.md -o report.docx\n  3. Convert to PDF: pandoc \u002Ftmp\u002Freport.md -o report.pdf --pdf-engine=xelatex\n  4. Verify both files exist with: ls -lh report.docx report.pdf\n  5. Report the file sizes and confirm successful generation\n```\n\n**If shell_agent succeeds**: Task complete.\n\n**If shell_agent fails**: Switch to Manual Path below.\n\n### Manual Path: Step-by-Step Workflow\n",{"name":5,"description":7},"main","6b84b0689ca0d9e7b1e4061188ff6b60758e0f8a","openspace\u002Flegacy\u002Fv1\u002Fgdpval_bench\u002Fskills\u002Fdocument-gen-fallback-enhanced-enhanced-c5d426",944,"https:\u002F\u002Fgithub.com\u002FHKUDS\u002FAgentPilot","https:\u002F\u002Fgithub.com\u002FHKUDS","https:\u002F\u002Fsites.google.com\u002Fview\u002Fchaoh","2026-11-12 22:26:39",{"source":8,"skillName":5,"commands":55,"prompt":65,"zipAvailable":66},[56,59,62],{"tool":57,"command":58},"npx","npx skills add HKUDS\u002FAgentPilot --skill document-gen-unicode-safe",{"tool":60,"command":61},"bunx","bunx skills add HKUDS\u002FAgentPilot --skill document-gen-unicode-safe",{"tool":63,"command":64},"pnpm","pnpm dlx skills add HKUDS\u002FAgentPilot --skill document-gen-unicode-safe","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002FHKUDS\u002FAgentPilot\u002Fblob\u002Fmain\u002Fopenspace\u002Flegacy\u002Fv1\u002Fgdpval_bench\u002Fskills\u002Fdocument-gen-fallback-enhanced-enhanced-c5d426\u002FSKILL.md",true,[68],{"path":69,"resourceType":70,"resourceTypeDesc":71,"sizeBytes":72,"sourceHtmlUrl":73},".skill_id","OTHER","其他",60,"https:\u002F\u002Fgithub.com\u002FHKUDS\u002FAgentPilot\u002Fblob\u002Fmain\u002Fopenspace\u002Flegacy\u002Fv1\u002Fgdpval_bench\u002Fskills\u002Fdocument-gen-fallback-enhanced-enhanced-c5d426\u002F.skill_id",[75,94,113,134,157,180],{"skillNo":76,"name":77,"nameZh":6,"description":78,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":79,"categories":80,"keywords":81,"publishedAt":41},"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",[],[77,82,83,38,84,85,86,87,88,89,90,91,92,93],"prepare","requests","missing","installation","rsi","up","use","user","work","SET","run","experiments",{"skillNo":95,"name":96,"nameZh":6,"description":97,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":98,"categories":99,"keywords":100,"publishedAt":41},"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",[],[96,101,102,103,104,105,106,107,108,109,110,111,112],"memory","review","auto","openspace","changes","facts","detect","entries","local","conflicts","stale","duplicates",{"skillNo":114,"name":115,"nameZh":6,"description":116,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":117,"categories":118,"keywords":120,"publishedAt":41},"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",[119],{"categoryNo":24,"categoryName":25,"taxonomyType":21,"taxonomyTypeDesc":22},[121,122,123,104,124,125,126,127,128,129,130,131,132,133],"skill discovery","discovery","reusable","step by step","tokens","packages","help","cloud","reliability","capabilities","browse","search","Tools",{"skillNo":135,"name":136,"nameZh":6,"description":137,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":138,"categories":139,"keywords":141,"publishedAt":41},"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",[140],{"categoryNo":24,"categoryName":25,"taxonomyType":21,"taxonomyTypeDesc":22},[142,143,144,104,145,146,147,148,149,123,103,88,150,151,152,40,153,154,155,156],"delegate","task","delegate task","time","improve","desktop automation","worker","community","autonomous","tool","stack","share","tasks","automation","MCP",{"skillNo":158,"name":159,"nameZh":6,"description":160,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":161,"categories":162,"keywords":163,"publishedAt":41},"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",[],[164,165,166,167,168,169,170,171,172,173,174,175,176,177,40,178,179],"write special chars ts check","write","check","type","files","filters","only","template","file","python","typescript","output","Existing","type-checking","errors","script",{"skillNo":181,"name":182,"nameZh":6,"description":183,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":184,"categories":185,"keywords":186,"publishedAt":41},"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",[],[187,188,165,38,40,179,189,190,191,192,193,171,172,194,195,173],"write special chars readback","readback","helper","post","via","scripts","read","verification","cleanup"]