[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M6KFD85VGCRE5GRV76RZT1M4":3,"skill-same:01M6KFD85VGCRE5GRV76RZT1M4":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":14,"repositoryHtmlUrl":49,"repositoryHomepageUrl":6,"ownerHtmlUrl":50,"ownerBlogUrl":51,"ownerDescription":52,"updatedAt":53,"install":54,"resources":67},"01M6KFD85VGCRE5GRV76RZT1M4","document-gen-unicode-safe",null,"Unicode-safe fallback workflow for multi-format document generation with character sanitization","xyliu-cs\u002FOpenSpace-GDPval","xyliu-cs","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F89236536?v=4","01M6KF8Z1V4TXS86CKSH48BY8T","xy","01M6KF8Z67443W0SHXM85JEF0B",0,"MIT","https:\u002F\u002Fgithub.com\u002Fxyliu-cs\u002FOpenSpace-GDPval\u002Fblob\u002Fmain\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","af1b40a42167d09c30b3a63000aa14ace4c1e229","gdpval_bench\u002Fskills\u002Fdocument-gen-fallback-enhanced-enhanced-c5d426","https:\u002F\u002Fgithub.com\u002Fxyliu-cs\u002FOpenSpace-GDPval","https:\u002F\u002Fgithub.com\u002Fxyliu-cs","https:\u002F\u002Fxyliu-cs.github.io","PhD Student in CS, CUHK-Shenzhen.","2026-04-06 20:32:15",{"source":8,"skillName":5,"commands":55,"prompt":65,"zipAvailable":66},[56,59,62],{"tool":57,"command":58},"npx","npx skills add xyliu-cs\u002FOpenSpace-GDPval --skill document-gen-unicode-safe",{"tool":60,"command":61},"bunx","bunx skills add xyliu-cs\u002FOpenSpace-GDPval --skill document-gen-unicode-safe",{"tool":63,"command":64},"pnpm","pnpm dlx skills add xyliu-cs\u002FOpenSpace-GDPval --skill document-gen-unicode-safe","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fxyliu-cs\u002FOpenSpace-GDPval\u002Fblob\u002Fmain\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\u002Fxyliu-cs\u002FOpenSpace-GDPval\u002Fblob\u002Fmain\u002Fgdpval_bench\u002Fskills\u002Fdocument-gen-fallback-enhanced-enhanced-c5d426\u002F.skill_id",[75,88,96,111,136,153],{"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},"01M6KG8MF1S664SWBDENYRSCK8","zip-export-deliverable","Ensures codebase deliverables are properly exported as ZIP archives through a dedicated finalization step","https:\u002F\u002Fgithub.com\u002Fxyliu-cs\u002FOpenSpace-GDPval\u002Fblob\u002Fmain\u002Fgdpval_bench\u002Fskills\u002Fzip-export-deliverable\u002FSKILL.md",[],[82,83,84,85,86,87],"zip export deliverable","zip","export","deliverables","codebase","as",{"skillNo":89,"name":90,"nameZh":6,"description":91,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":92,"categories":93,"keywords":94,"publishedAt":41},"01M6KG8GAZWHHEK7VNJDW0ME21","zip-deliverable-finalization","Ensure codebase deliverables are properly packaged as ZIP exports in a dedicated final step","https:\u002F\u002Fgithub.com\u002Fxyliu-cs\u002FOpenSpace-GDPval\u002Fblob\u002Fmain\u002Fgdpval_bench\u002Fskills\u002Fzip-deliverable-finalization\u002FSKILL.md",[],[95,83,85,86,87],"zip deliverable finalization",{"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":41},"01M6KG8CMQQ1PYMNTSRZ9VS1MD","zero-iteration-failure-analysis","Identify and handle agent failures with 0 iterations as pre-execution system issues","https:\u002F\u002Fgithub.com\u002Fxyliu-cs\u002FOpenSpace-GDPval\u002Fblob\u002Fmain\u002Fgdpval_bench\u002Fskills\u002Fzero-iteration-failure-analysis\u002FSKILL.md",[],[103,104,105,106,107,38,108,109,87,110],"failure analysis","ZeRO","analysis","iteration","zero iteration failure analysis","issues","execution","system",{"skillNo":112,"name":113,"nameZh":6,"description":114,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":115,"categories":116,"keywords":122,"publishedAt":41},"01M6KG86W3PA07FT9W58YHHERM","write-file-fallback-report","Generate professional documents using write_file when primary data sources fail, leveraging embedded domain knowledge instead of external retrieval","https:\u002F\u002Fgithub.com\u002Fxyliu-cs\u002FOpenSpace-GDPval\u002Fblob\u002Fmain\u002Fgdpval_bench\u002Fskills\u002Fwrite-file-fallback-report\u002FSKILL.md",[117],{"categoryNo":118,"categoryName":119,"taxonomyType":120,"taxonomyTypeDesc":121},"01JBSEEDCAT000000000000034","行政与办公人员","PROFESSION","适用职业",[33,123,124,125,126,127,128,129,130,131,132,133,134,135],"write","file","report","write file fallback report","domain","professional","sources","retrieval","generate","embedded","documents","data","knowledge",{"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":41},"01M6KG82GAEY3GG77CMGCK1C2T","fallback-doc-with-delegation","Generate professional documents after tool failures using shell_agent for complex formats or write_file for simple text\u002Fmarkdown","https:\u002F\u002Fgithub.com\u002Fxyliu-cs\u002FOpenSpace-GDPval\u002Fblob\u002Fmain\u002Fgdpval_bench\u002Fskills\u002Fwrite-file-fallback-report-enhanced\u002FSKILL.md",[142],{"categoryNo":24,"categoryName":25,"taxonomyType":21,"taxonomyTypeDesc":22},[144,38,33,145,146,147,133,131,124,148,149,150,123,151,128,152,40],"fallback doc with delegation","doc","delegation","shell","markdown","tool","text","simple","formats",{"skillNo":154,"name":155,"nameZh":6,"description":156,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":157,"categories":158,"keywords":160,"publishedAt":41},"01M6KG7WT7GX5NYCGEFHW22NV7","context-anchored-fallback-report","Generate documents with write_file when retrieval tools fail, with explicit guardrails against task context drift","https:\u002F\u002Fgithub.com\u002Fxyliu-cs\u002FOpenSpace-GDPval\u002Fblob\u002Fmain\u002Fgdpval_bench\u002Fskills\u002Fwrite-file-fallback-report-enhanced-4bc5c2\u002FSKILL.md",[159],{"categoryNo":118,"categoryName":119,"taxonomyType":120,"taxonomyTypeDesc":121},[33,125,161,162,131,124,163,164,123,165,166,130,38,167,133],"context","context anchored fallback report","Guardrails","Tools","task","drift","context drift"]