Skip to content

Conversation

@spm1001
Copy link

@spm1001 spm1001 commented Dec 15, 2025

Problem

replace.py clears ALL text shapes in a presentation, then only restores those with "paragraphs" defined in the replacement JSON. This is a footgun for partial edits.

Example failure:

  • User wants to edit only slide 1 (2 shapes)
  • Creates JSON specifying only slide-1
  • Script clears all 67 shapes across 26 slides
  • Only restores 2 shapes
  • Result: 64 shapes wiped, presentation destroyed

While this behavior is documented, it's surprising and destructive for the common use case of making targeted edits to specific slides.

Solution

Add surgical mode (now the default) that only touches shapes explicitly listed in the replacement JSON. The old "clear everything" behavior remains available via --clear-all flag for template workflows where starting fresh is desired.

# Surgical mode (default) - safe for partial edits
python scripts/replace.py working.pptx replacement-text.json output.pptx

# Clear-all mode - for template workflows
python scripts/replace.py working.pptx replacement-text.json output.pptx --clear-all

Changes

replace.py:

  • Add --clear-all flag (surgical mode is default)
  • In surgical mode, skip shapes without "paragraphs" in replacement JSON
  • Add shapes_skipped counter to stats output
  • Use argparse for cleaner CLI handling
  • Update docstring to explain both modes

SKILL.md:

  • Document surgical mode as default behavior
  • Document --clear-all flag for template workflows
  • Update examples to show both modes

Backward Compatibility

This is a breaking change in default behavior:

  • Before: All shapes cleared by default
  • After: Only specified shapes modified by default

Users who rely on the old behavior for template workflows can add --clear-all to preserve it. This seems like the right trade-off since partial edits are likely more common than full template replacements, and the old default was destructive.

Problem:
replace.py clears ALL text shapes in a presentation, then only restores
those with "paragraphs" in the replacement JSON. This is destructive for
partial edits - editing just slide 1 would wipe all other slides.

Solution:
Add surgical mode (now default) that only touches shapes explicitly listed
in the replacement JSON. The old "clear everything" behavior is available
via --clear-all flag for template workflows.

Changes to replace.py:
- Add --clear-all flag (default: surgical mode)
- In surgical mode, skip shapes without "paragraphs" in replacement JSON
- Add shapes_skipped counter to stats output
- Use argparse for cleaner CLI handling
- Update docstring to explain both modes

Changes to SKILL.md:
- Document surgical mode as default behavior
- Document --clear-all flag for template workflows
- Update examples to show both modes
- Clarify that shapes are now left untouched by default
@spm1001 spm1001 closed this by deleting the head repository Dec 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant