Skillpedia
PDF وWord والعروض التقديمية7.8k · #12862

document-gen-resilient-workflow

ما الذي تفعله

هذه المهارة طريقة خطوة بخطوة لإنشاء مستندات Word أو PDF أو HTML، مع بدائل احتياطية وتفاصيل واضحة عن الأخطاء. وهي مناسبة لمن تفشل مهام المستندات لديه مرارًا بأخطاء غير مفهومة.

متى تستخدمها

  • ✓عندما يُرجع أمر في الطرفية خطأ غير معروف دون تفاصيل مفيدة.
  • ✓عندما يفشل ملف PDF لأن محرك LaTeX غير مثبت أو لأن هناك مشكلة في الترميز.
  • ✓عندما تفشل عملية إنشاء مستند عدة مرات في أعمال متشابهة.

رابط المهارة

https://github.com/HKUDS/AgentPilot/blob/main/openspace/benchmarks/gdpval/skills/document-gen-fallback-enhanced-enhanced/SKILL.md

انسخه والصقه في الذكاء الاصطناعي الذي تستخدمه (Claude أو ChatGPT أو Cursor) واطلب منه اتباع التعليمات.

طريقة الاستخدام

أسهل طريقة: انسخ الرسالة والصقها في الذكاء الاصطناعي الذي تستخدمه. سيقرأ المهارة وينفّذ تعليماتها.

رسالة جاهزة للصق

استخدم هذه المهارة لمساعدتي: https://github.com/HKUDS/AgentPilot/blob/main/openspace/benchmarks/gdpval/skills/document-gen-fallback-enhanced-enhanced/SKILL.md اقرأ ملف SKILL.md في هذا الرابط ونفّذ تعليماته لمهمتي.
تريد أن يجد الذكاء الاصطناعي مهارات مثل هذه بنفسه؟ثبّت خادم Skillpedia MCP المجاني: سطر واحد، ويبحث في 15,000+ مهارة قبل كل مهمة.ثبّته في دقيقة واحدة →

مثال على ما تطلبه من الذكاء الاصطناعي

“ما زال إنشاء ملف PDF الخاص بي يفشل بخطأ غير معروف. من فضلك تحقق من الأدوات، وجرّب محركًا آخر، وأخبرني بما حدث بالضبط.”

5 مهارات جديدة كل أسبوع. قراءة في دقيقة واحدة.

كيف تعمل

يتحقق الذكاء الاصطناعي من مجلد العمل ومن الأدوات، ويكتب المحتوى، ويسجل رسائل الخطأ، ويجرّب محركات PDF بالترتيب حتى ينجح واحد منها، ثم يتأكد من أن ملف الناتج يمكن قراءته.

المحتوى التقني (ملف SKILL.md الأصلي)

النص الأصلي من المؤلف، مباشرة من GitHub.

Resilient Document Generation Workflow

When to Use

Use this skill when document generation tasks encounter tool errors or failures, especially:

  • run_shell commands return 'unknown error' without diagnostic details
  • PDF generation fails with LaTeX encoding or missing engine errors
  • You need fallback options when primary conversion methods fail
  • Workspace or path issues cause file access problems
  • Unicode/special characters cause rendering issues in PDF output
  • shell_agent has failed multiple times on similar tasks

Core Technique

Split document generation into observable, verifiable steps with explicit error capture and progressive fallback:

  1. Validate workspace → Confirm current directory and write permissions
  2. Pre-flight checks → Verify required tools (pandoc, LaTeX engines) are available
  3. Content creation → Use write_file for source Markdown with full visibility
  4. Unicode sanitization → Preprocess for PDF conversion when needed
  5. Progressive conversion → Try multiple engines/methods until one succeeds
  6. Explicit error capture → Redirect stderr to diagnose failures
  7. Verification → Confirm output files exist and are readable

⚠️ Critical: Tool Error Patterns

'unknown error' from run_shell: This typically indicates:

  • Sandbox execution context issues (not the command itself)
  • Missing stderr capture preventing diagnosis
  • Transient file access problems

Solution: Use explicit error capture with 2>&1 and verify tool availability first:

run_shell
command: pandoc --version 2>&1 || echo "PANDOC NOT AVAILABLE"

Pre-Flight Checklist

Before starting conversion, verify your environment:

## Pre-Flight Checks

### Check 1: Verify working directory
run_shell
command: pwd && ls -la

### Check 2: Verify pandoc availability
run_shell
command: pandoc --version 2>&1 | head -3 || echo "PANDOC MISSING"

### Check 3: Check LaTeX engines
run_shell
command: which pdflatex xelatex wkhtmltopdf 2>&1 || echo "Some engines missing"

### Check 4: Check Python libraries (fallback option)
run_shell
command: python3 -c "import fpdf; print('fpdf OK')" 2>&1 || echo "fpdf missing"
run_shell
command: python3 -c "import docx; print('python-docx OK')" 2>&1 || echo "python-docx missing"

Complete Step-by-Step Workflow

Step 1: Validate Workspace

Confirm you're in the correct directory and can write files:

run_shell
command: pwd && echo "Test write" > /tmp/workspace_test_$$.txt && ls -la /tmp/workspace_test_$$.txt && rm /tmp/workspace_test_$$.txt

If this fails, you may have directory permission issues. Use absolute paths for all files.

Step 2: Create Source Content with write_file

Write document content as Markdown to a source file:

write_file
path: /tmp/document_source.md
content: |
  # Document Title
  
  ## Section 1
  Content here...

Step 3: Unicode Sanitization (PDF Only)

Only needed for PDF conversion via LaTeX engines. DOCX and HTML handle Unicode natively.

Create a sanitized version replacing LaTeX-problematic characters:

write_file
path: /tmp/document_source_sanitized.md
content: |
  # Document Title
  
  [Same content with: em-dash → --, curly quotes → straight, → arrows → text, etc.]

Common replacements (see full table below):

Original Replace With
— (em dash) --
" " (curly quotes) " " (straight)
… (ellipsis) ...
→ ← (arrows) -> <-
✓ ✗ [x] [ ]
© ® ™ (c) (r) (tm)

Alternative: Use sanitization script (see Scripts section below).

Step 4: Progressive Format Conversion

Try multiple methods in order of preference. Capture stderr explicitly for diagnosis.

Method A: DOCX Conversion (Most Reliable)

run_shell
command: pandoc /tmp/document_source.md -o output.docx 2>&1 && echo "SUCCESS" || echo "FAILED: $?"

If this fails, try with explicit UTF-8 flag:

run_shell
command: pandoc /tmp/document_source.md -f markdown+utf8 -o output.docx 2>&1

Method B: PDF Conversion (Progressive Fallback)

Try engines in this order until one succeeds:

run_shell
command: pandoc /tmp/document_source_sanitized.md -o output.pdf 2>&1 | tee /tmp/pdf_error.log && echo "PDF SUCCESS"

If Method B fails, check error log and try next engine:

run_shell
command: pandoc /tmp/document_source_sanitized.md --pdf-engine=xelatex -o output.pdf 2>&1 | tee 
الأسئلة الشائعة

ما الأدوات التي يتحقق منها أولًا؟

يتحقق من وجود pandoc ومحركات LaTeX قبل التحويل.

لماذا يُسجَّل ناتج الخطأ؟

تُظهر تفاصيل الخطأ السبب الحقيقي، فلا يضطر الوكيل إلى التخمين.

ماذا لو كانت المشكلة في المجلد؟

يذكر الدليل أن على الذكاء الاصطناعي التحقق من مجلد العمل وصلاحيات الكتابة قبل التحويل.

التفاصيل

الوصف الأصلي من المؤلف

Robust document generation with engine fallback chain, error diagnostics, and Python alternatives

repo: HKUDS/AgentPilot

الشعبية

نجوم GitHub
7.8k
الترتيب
#12862
الترخيص
MIT
آخر تحديث
1‏/11‏/2026

هل هذه المهارة مفيدة؟

0

سجّل الدخول للتصويت.

التعليقات

  • …

المزيد من المهارات من هذا المستودع

مهارات مشابهة