跳到正文
cccskills
免费在 GitHub 公开

ppt-generation-resilient

Create PowerPoint presentations with specified slide content and structure. If generation through shell_agent fails, the workflow switches to Python, captures error details, locates the output, and checks the file format, size, and slide count.

中文简介正在准备中。当前显示英语简介。

原文查看原文说明

Robust PowerPoint generation with shell_agent primary approach and python-pptx fallback, including working directory verification and inline error debugging

集成工具PowerPoint
查看安装方法

适用场景

  • Create presentations with specified slide counts and topics
  • Retry failed PowerPoint generation using Python
  • Locate generated files and verify them before delivery

包含的文件(2)

  • SKILL.md8.6 KB
  • .skill_id51 B

SKILL.md(原文)

安装前可以查看交给 AI 代理的指令内容。

Resilient PowerPoint Generation Workflow

When to Use This Skill

Use this workflow when:

  • You need to create PowerPoint presentations with specific slide content and structure
  • Direct document generation tools fail or are unavailable
  • shell_agent encounters opaque errors during PowerPoint generation
  • Output files may be created in unexpected nested directories within the workspace

Overview

This workflow provides a resilient approach with two tiers:

  1. Primary: shell_agent delegation with clear specifications
  2. Fallback: Direct Python execution using python-pptx library with proper error capture

Step 0: Verify Working Directory

Before starting, establish your working directory context:

# Capture current working directory
pwd
# Store for later reference
WORK_DIR=$(pwd)
echo "Working directory: $WORK_DIR"

Step 1: Attempt PowerPoint Generation via shell_agent (Primary)

Delegate the PowerPoint creation task to shell_agent with explicit specifications:

Use shell_agent to create a PowerPoint presentation with:
- Specify the exact number of slides needed
- Define the content/topic for each slide
- Request the file be saved with a clear filename (e.g., presentation.pptx)
- Ask the agent to confirm the file path after creation using: echo "FILE_PATH: $(pwd)/presentation.pptx"
- Request that any errors be printed to stderr with full tracebacks

Example task description:

Create a PowerPoint presentation with 10 slides covering [topic]. Each slide should have a title and bullet points. Save it as presentation.pptx in the current working directory. After creation, run: echo "FILE_PATH: $(pwd)/presentation.pptx" and report any errors with full tracebacks.

Wait for shell_agent response. If successful with file path confirmed, proceed to Step 4. If shell_agent fails or returns opaque errors, proceed to Step 2.

Step 2: Fallback to Direct Python Execution with python-pptx

When shell_agent fails, create and execute a Python script directly:

2a: Create the Python Script

Write the PowerPoint generation script to a .py file first:

# save as generate_pptx.py
from pptx import Presentation
from pptx.util import Inches, Pt
import os

# Verify working directory
print(f"Working directory: {os.getcwd()}")

# Create presentation
prs = Presentation()

# Slide 1: Title slide
slide_layout = prs.slide_layouts[0]
slide = prs.slides.add_slide(slide_layout)
title = slide.shapes.title
subtitle = slide.placeholders[1]
title.text = "Your Title"
subtitle.text = "Your Subtitle"

# Additional slides (add as needed)
for i in range(2, 11):
    slide_layout = prs.slide_layouts[1]
    slide = prs.slides.add_slide(slide_layout)
    title = slide.shapes.title
    content = slide.placeholders[1]
    title.text = f"Slide {i} Title"
    content.text = f"• Bullet point 1\n• Bullet point 2\n• Bullet point 3"

# Save with full path verification
output_path = os.path.join(os.getcwd(), "presentation.pptx")
prs.save(output_path)
print(f"FILE_PATH: {output_path}")
print(f"File size: {os.path.getsize(output_path)} bytes")

2b: Execute with Full Error Capture

Run the script with stderr redirected to capture actual errors:

# Execute with full error output capture
python generate_pptx.py 2>&1 | tee execution_log.txt

# Or if using run_shell tool, ensure 2>&1 is included
python generate_pptx.py 2>&1

Critical: The 2>&1 redirect ensures Python exceptions are captured, not masked as "unknown error".

2c: Verify Script Execution Output

Check the execution log for:

  • FILE_PATH: confirmation line
  • File size confirmation
  • Any error tracebacks in execution_log.txt

Step 3: Locate the Output File

PowerPoint files may be in nested workspace directories. Use find to locate them:

# Find all .pptx files in the workspace
find . -name "*.pptx" -type f 2>&1

# Or search for a specific filename
find . -name "presentation.pptx" -type f 2>&1

# If not found, search broader (may require elevated permissions)
find /workspace -name "*.pptx" -type f 2>/dev/null

Expected output format:

./presentation.pptx
or
./workspace/task_123/output/presentation.pptx

Step 4: Copy to Working Directory

Once located, copy the file to your working directory:

# Copy the found file to current directory
cp /path/to/found/presentation.pptx .

# Or move it if you prefer
mv /path/to/found/presentation.pptx .

# Verify copy succeeded
ls -la presentation.pptx

Step 5: Verify the File

Confirm the file exists and is valid:

# List the file with details
ls -la presentation.pptx

# Check file size to ensure it's not empty (should be > 0 bytes)
FILE_SIZE=$(stat -f%z presentation.pptx 2>/dev/null || stat -c%s presentation.pptx 2>/dev/null)
echo "File size: $FILE_SIZE bytes"

# Verify it's a valid PowerPoint file
file presentation.pptx
# Expected: "Microsoft PowerPoint 2007+"

# If python-pptx was used, verify slide count
python -c "from pptx import Presentation; prs=Presentation('presentation.pptx'); print(f'Slide count: {len(prs.slides)}')" 2>&1

Common Pitfalls

  1. Don't assume the file is in the current directory - shell_agent may create files in subdirectories
  2. Don't skip the find step - always verify the file location before proceeding
  3. Check file size - ensure the PowerPoint file is not empty (0 bytes)
  4. Always use 2>&1 - redirect stderr to capture actual Python exceptions, not "unknown error"
  5. Write scripts to .py files first - don't rely on inline execution which may have path issues
  6. Verify working directory - capture and confirm pwd before and after script execution

Debugging Commands

When errors occur, use these commands to diagnose:

# Check if python-pptx is available
python -c "import pptx; print(pptx.__version__)" 2>&1

# Check current directory permissions
ls -la . 
ls -la ..

# Test write permissions
touch test_write.txt && rm test_write.txt && echo "Write permissions OK"

# Check Python path
which python
python --version

# Verify no stale files interfering
find . -name "*.pptx" -type f -mtime -1 2>&1

Example Workflow (Complete)

# Step 0: Verify working directory
pwd
# Output: /workspace/task_abc

# Step 1: shell_agent attempt (via task delegation)
# If shell_agent fails with opaque errors...

# Step 2: Fallback to direct Python
cat > generate_pptx.py << 'EOF'
from pptx import Presentation
import os
print(f"Working directory: {os.getcwd()}")
prs = Presentation()
slide_layout = prs.slide_layouts[0]
slide = prs.slides.add_slide(slide_layout)
slide.shapes.title.text = "Title Slide"
output_path = os.path.join(os.getcwd(), "presentation.pptx")
prs.save(output_path)
print(f"FILE_PATH: {output_path}")
EOF

python generate_pptx.py 2>&1 | tee execution_log.txt
# Output: Working directory: /workspace/task_abc
# Output: FILE_PATH: /workspace/task_abc/presentation.pptx

# Step 3: Locate (if needed)
find . -name "*.pptx" -type f
# Output: ./presentation.pptx

# Step 4: Copy (if in nested directory)
# (skip if already in working directory)

# Step 5: Verify
ls -la presentation.pptx
# Output: -rw-r--r-- 1 user user 45632 Jan 15 10:30 presentation.pptx

python -c "from pptx import Presentation; prs=Presentation('presentation.pptx'); print(f'Slide count: {len(prs.slides)}')" 2>&1
# Output: Slide count: 1

Troubleshooting

ProblemSolution
shell_agent returns "unknown error"Immediately fall back to Step 2; add 2>&1 to capture actual exceptions
File not found with findSearch broader: find /workspace -name "*.pptx" 2>/dev/null; check if script executed at all
File is 0 bytesRe-run Python script; check for exceptions in execution_log.txt
Permission deniedCheck directory permissions with ls -la; try creating in /tmp first
Multiple .pptx files foundUse more specific search: find . -name "*presentation*.pptx" -type f
python-pptx not installedTry pip install python-pptx or use alternative library
Script executes but no file createdCheck working directory mismatch; add explicit os.chdir() in script

Success Criteria

The workflow is complete when:

  • PowerPoint file exists in working directory
  • File size > 0 bytes (typically > 20KB for multi-slide presentations)
  • file command identifies it as Microsoft PowerPoint format
  • Slide count matches requirements (verify with python-pptx if needed)
  • File is readable and not corrupted

评价

还没有评价。欢迎分享你的使用感受。

评论

无需登录即可发表。欢迎分享使用感受、提问,或说明在哪些环境下无法运行。

还没有评论。来写第一条吧。

提交后会立即公开。请勿填写邮箱、电话等个人信息。URL 最多 2 个。

0 / 1000 字

此表单受 reCAPTCHA 保护,适用 Google 的隐私权政策和服务条款。

同一仓库的技能

Prepare audio stems, the separate parts of a track, for mixing by matching their durations with silence, loops, or crossfades. Verify each generated and processed file before moving to the next production step.

中文简介正在准备中。当前显示英语简介。

  • Match audio parts with different durations
  • Extend drums and melodic parts using suitable methods
  • Check audio specifications before mixing
HKUDS/OpenSpace77572026年8月13日 更新

Produce audio in separate stems, meaning individual instrument tracks, and verify each output as you go. Align track lengths with silence, loops, or crossfades, then apply effects, mix a master, and package the files.

中文简介正在准备中。当前显示英语简介。

  • Align instrument tracks to a reference audio file
  • Choose how to extend tracks that are too short
  • Verify audio properties after generation and effects
HKUDS/OpenSpace77572026年8月13日 更新

Build serverless endpoints that relay external API requests for a dashboard while keeping API keys on the server. Includes Vercel examples for input checks, caching, cross-origin access, and consistent JSON responses.

中文简介正在准备中。当前显示英语简介。

  • Connect a dashboard to external APIs without exposing API keys
  • Create endpoints for stock quotes and news
  • Standardize API responses and error handling
HKUDS/OpenSpace77572026年8月13日 更新

Produce a master track and separate audio parts through a structured Python workflow. Apply filters and reverb, export WAV files with consistent settings, package them in a ZIP archive, and check that the deliverables meet the requested specifications.

中文简介正在准备中。当前显示英语简介。

  • Export a master track with separate audio parts
  • Apply filters and reverb to audio
  • Check duration and format across deliverables
HKUDS/OpenSpace77572026年8月13日 更新

Keep document creation moving when web searches and page retrieval repeatedly fail. The skill preserves the original task, uses the model’s existing knowledge, and clearly identifies information that could not be checked against external sources.

中文简介正在准备中。当前显示英语简介。

  • Continue drafting after repeated web retrieval failures
  • Preserve task requirements during network errors
  • Mark information that could not be externally verified
HKUDS/OpenSpace77572026年8月13日 更新

When Python execution repeatedly fails in execute_code_sandbox, use a file-based alternative: save the script, run it through the shell, and capture results or errors. The guidance covers paths, imports, timeouts, structured output, and optional cleanup.

中文简介正在准备中。当前显示英语简介。

  • Retry Python work through the shell after repeated sandbox failures
  • Run longer tasks with an adjusted timeout
  • Execute Python work that needs multiple files or system utilities
HKUDS/OpenSpace77572026年8月13日 更新

查看 HKUDS 的全部技能

报告此技能的问题