Skip to content

AI turns documents or topics into real, native PowerPoint decks—with native shapes, transitions and animations, data-backed charts and tables on demand, audio narration from speaker notes, and support for your own .pptx templates. · by Hugo He

fix(shape-boolean): harden merge-shape materialization

hugohe39106414dd92d
diff --git a/requirements.txt b/requirements.txt
index 4346dde9..518a5aee 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -2,7 +2,9 @@
# =============================================
#
# Full list lives inside the skill so installing the skill alone gives full capability.
+# update_repo.py fingerprints this file and its recursive -r/--requirement include tree.
# 完整依赖列表已内置于 skill 内部,单独安装 skill 即可获得完整能力。
+# update_repo.py 会对本文件及递归 -r/--requirement 引用树计算指纹。
#
# Install / 安装方式:
# pip install -r requirements.txt # from repo root / 仓库根目录
diff --git a/skills/ppt-master/references/image-layout-patterns.md b/skills/ppt-master/references/image-layout-patterns.md
index 9ab59c1c..86f2cc92 100644
--- a/skills/ppt-master/references/image-layout-patterns.md
+++ b/skills/ppt-master/references/image-layout-patterns.md
@@ -154,7 +154,7 @@ This is the family that opens up the largest design space and the one AI is most
| Wave band + vertical bars | Rhythmic strip |
| Trapezoid + slanted bars | Perspective row |
- **Authoring**: compute each cell's contour and write it as its own `<path>` clip — the geometry is deterministic, so derive the cells rather than eyeballing them. `shape_boolean_svg.py fragment` returns exactly these interlocking regions as separately addressable paths. Give every cell the same stroke (2px, background color) so the cuts read as designed seams.
+ **Authoring**: compute each cell's contour and write it as its own `<path>` clip — the geometry is deterministic, so derive the cells rather than eyeballing them. `shape_boolean_svg.py render <svg-file> --operation fragment --source <id> --source <id> --id <result-id>` returns exactly these interlocking regions as separately addressable paths. Give every cell the same stroke (2px, background color) so the cuts read as designed seams.
**Choosing between #92 and #82**: same construction, opposite content rule. One image across all cells (#82) says "these fragments are one thing"; a different image per cell (#92) says "these are peers, cut from one frame". Mixing them destroys both readings. Distinct from #50 / #51, where cells are independent rectangles that never shared a parent.
@@ -212,17 +212,17 @@ Stack any of these freely on top of a Primary structure. Multiple Modifiers per
**The one thing that makes or breaks it — registration**: place the `<image>` over the *union bounding box* of every subpath (not one image per shape), sized with `preserveAspectRatio="xMidYMid slice"`. The photo then runs continuously *behind* the containers and the gaps read as cuts through one scene. Give each container a different image and it instantly collapses into an ordinary tile grid (#50 / #51) — the continuity is the entire design, not the shapes.
- Distinct from #24 (one connected contour) and #47–#56 (every cell its own image). For non-trivial contours take the `d` from `shape_boolean_svg.py union` / `combine` (see [`native-shape-authoring.md`](./native-shape-authoring.md)) instead of deriving it by hand. Clip-shape constraints — one direct shape child, no `fill-rule` / `clip-rule`, `<image>` targets only — are owned by [`shared-standards-core.md`](./shared-standards-core.md) §1.2.
+ Distinct from #24 (one connected contour) and #47–#56 (every cell its own image). For non-trivial contours take the `d` from the `union` or `combine` operation of `shape_boolean_svg.py render` (see [`native-shape-authoring.md`](./native-shape-authoring.md) §6) instead of deriving it by hand. Clip-shape constraints — one direct shape child, no `fill-rule` / `clip-rule`, `<image>` targets only — are owned by [`shared-standards-core.md`](./shared-standards-core.md) §1.2.
83. **Panel with a real hole punched through it (Subtract window)** — a solid or tinted panel with a shape-cut opening that reveals the image below, PowerPoint's Merge Shapes 剪除.
- **Geometry**: one `<path>` containing both contours, running in **opposite directions**. Outer clockwise, inner counter-clockwise — e.g. panel `M 80,80 H 1200 V 640 H 80 Z` followed by hole `M 420,220 V 500 H 760 V 220 H 420 Z` (note the second one descends first, reversing the winding). Under nonzero winding the reversed subpath subtracts, producing a true hole, so the effect never needs `fill-rule` and stays inside the [`shared-standards-core.md`](./shared-standards-core.md) §1.2 boundary. Verified end-to-end: both subpaths survive into a single `<a:path>` in the exported `custGeom`. `shape_boolean_svg.py subtract` emits this contour directly.
+ **Geometry**: one `<path>` containing both contours, running in **opposite directions**. Outer clockwise, inner counter-clockwise — e.g. panel `M 80,80 H 1200 V 640 H 80 Z` followed by hole `M 420,220 V 500 H 760 V 220 H 420 Z` (note the second one descends first, reversing the winding). Under nonzero winding the reversed subpath subtracts, producing a true hole, so the effect never needs `fill-rule` and stays inside the [`shared-standards-core.md`](./shared-standards-core.md) §1.2 boundary. Verified end-to-end: both subpaths survive into a single `<a:path>` in the exported `custGeom`. The `subtract` operation of `shape_boolean_svg.py render` emits this contour directly; follow [`native-shape-authoring.md`](./native-shape-authoring.md) §6.
**Why not #67**: that pattern fakes the opening by laying a background-colored shape on top. It works only over a flat background and silently breaks the moment the page gains a gradient, a texture, or a second image behind the panel. A real hole also lets the underlying image be moved or swapped without recutting the panel.
84. **Deliberately misregistered fragments (Fragment look)** — the inverse of #82. Cut one image into pieces using several `<image>` elements that share the same source, each with its own clip, then **break the alignment on purpose**: offset a few px, rotate 1–3°, or nudge one piece's scale. The eye still assembles one photo, but the seams now read as intentional — misprint, torn paper, glitch.
- Keep the displacement small and consistent in direction; large or random offsets stop reading as a decision and start reading as a rendering bug. `shape_boolean_svg.py fragment` returns each atomic region as a separately addressable path when the pieces must be individually positioned.
+ Keep the displacement small and consistent in direction; large or random offsets stop reading as a decision and start reading as a rendering bug. The `fragment` operation of `shape_boolean_svg.py render` returns each atomic region as a separately addressable path when the pieces must be individually positioned; follow [`native-shape-authoring.md`](./native-shape-authoring.md) §6.
85. **Subject breaking out of its container** — the subject sits half inside a card / grid cell / color panel and half outside its boundary. Two `<image>` elements from the same file: one clipped to the container (optionally tinted, #31), one clipped to only the escaping region, positioned so the two halves stay in perfect register. Produces depth with no shadow at all.
diff --git a/skills/ppt-master/references/native-shape-authoring.md b/skills/ppt-master/references/native-shape-authoring.md
index 082ef46a..10a7f706 100644
--- a/skills/ppt-master/references/native-shape-authoring.md
+++ b/skills/ppt-master/references/native-shape-authoring.md
@@ -201,9 +201,11 @@ freshness contract.
## 6. Shape Boolean Materialization
-**Trigger**: The authored design explicitly requires a PowerPoint-style Union,
-Combine, Fragment, Intersect, or Subtract operation over two or more closed
-vector shapes.
+**Trigger**: Current page construction has two or more closed vector operands
+whose faithful result calls for PowerPoint-style Union, Combine, Fragment,
+Intersect, or Subtract. A §IX `Native shape suggestion` is a semantic candidate,
+not a prerequisite or tool command; Executor may adopt, adapt, or decline it
+from the actual content and explicit user/template constraints.
```bash
python3 ${SKILL_DIR}/scripts/shape_boolean_svg.py render <svg-file> \
@@ -217,7 +219,9 @@ python3 ${SKILL_DIR}/scripts/shape_boolean_svg.py render <svg-file> \
|---|---|
| Sources | Closed `path`, `polygon`, `rect`, `circle`, `ellipse`, or one validated compact authored shape preset. Open ordinary geometry, connectors, ordinary groups, text, images, definitions, and nested SVG viewports fail closed. |
| Primary shape | The first `--source` supplies result paint. For `subtract`, all later operands are removed from that primary geometry. Explicit paint flags override only their named channels. |
-| Coordinates | Ancestor and local transforms are baked into SVG-root coordinates. Insert stdout at the root in the primary operand's z-order; never reinsert it under an original transformed ancestor. |
+| Coordinates | Ancestor and local transforms are baked into SVG-root coordinate space. Place stdout in the primary operand's z-order with no additional transform; never reinsert it under an original transformed ancestor. Root-coordinate space does not require each result path to be a direct `<svg>` child. |
+| Placement | Ordinary Slide-local results belong in the applicable untransformed direct-root semantic `<g>` with its normal `id` / `data-pptx-bounds`. Master/Layout results remain direct-root path atoms and redeclare `data-pptx-layer`. One non-fragment result may be the direct `data-pptx-carrier="true"` child of an `object` slot. |
+| Fragment roles | Fragment paths may share one ordinary Slide-local semantic group, but remain separate shapes and cannot collectively claim one carrier or one Master/Layout atom. Helper output inherits no structural role metadata from its operands; redeclare only the final layer/carrier/role contract. |
| Result | `union`, `combine`, `intersect`, and `subtract` emit one ordinary `<path>`. `fragment` emits stable sibling paths named `<id>-1`, `<id>-2`, ... in top/left/bottom/right/area order. |
| Winding | Results use explicit nonzero contour direction and never emit `fill-rule`, `clip-rule`, `clip-path`, `mask`, or Merge Shapes metadata. Operands that depend on even-odd fill, clipping, or masking fail closed. |
| Preservation | This helper authors new geometry only. Never use it to merge or split mirror/preserve source structure. |
@@ -230,8 +234,9 @@ stores the materialized freeform geometry, not replayable operation history.
**Hard rule — stdout-only replacement**: The helper never writes the source
page. In one normal `apply_patch` edit, remove every selected operand and insert
-every returned path at the SVG root in the primary operand's z-order. Fragment
-paths remain separate shapes; do not wrap them to claim one structural atom.
+every returned path in root coordinate space at the primary operand's z-order,
+using the placement contract above. Fragment paths remain separate shapes; an
+ordinary semantic group does not turn them into one structural atom.
---
diff --git a/skills/ppt-master/scripts/docs/svg-pipeline.md b/skills/ppt-master/scripts/docs/svg-pipeline.md
index b40e2805..79610938 100644
--- a/skills/ppt-master/scripts/docs/svg-pipeline.md
+++ b/skills/ppt-master/scripts/docs/svg-pipeline.md
@@ -67,6 +67,231 @@ is owned by [`shared-standards-core.md`](../../references/shared-standards-core.
authoring guidance in
[`native-shape-authoring.md`](../../references/native-shape-authoring.md).
+## Shape Boolean maintenance smoke
+
+Run this manual smoke from the repository root after changing
+`shape_boolean_svg.py`, preset geometry, path conversion, or custom-geometry
+import/export. It uses only a gitignored `projects/_smoke_*` workspace and the
+inline-smoke convention from [`code-style.md`](../../../../docs/rules/code-style.md)
+§11; do not turn it into a test file or example deck.
+
+```bash
+python3 - <<'PY'
+import re
+import subprocess
+import sys
+import tempfile
+import zipfile
+from pathlib import Path
+from xml.etree import ElementTree as ET
+
+import pathops
+
+project = Path(tempfile.mkdtemp(prefix="_smoke_shape_boolean_", dir="projects"))
+scripts = Path("skills/ppt-master/scripts")
+svg_output = project / "svg_output"
+svg_output.mkdir()
+(project / "spec_lock.md").write_text(
+ """<!-- ppt-master-schema: spec-lock/v1 -->
+# Execution Lock
+
+## canvas
+- viewBox: 0 0 1280 720
+- format: ppt169
+## communication
+- audience:
+- objective:
+- core_message:
+## mode
+- mode: briefing
+## visual_style
+- visual_style: Boolean maintenance smoke
+## colors
+- bg: #FFFFFF
+- primary: #2563EB
+- accent: #F97316
+- text: #0F172A
+## typography
+- font_family: Arial, sans-serif
+- title_family: Arial, sans-serif
+- body_family: Arial, sans-serif
+- title: 36
+- body: 20
+## icons
+- library: none
+- inventory: none
+## page_rhythm
+- P01: dense
+## pptx_structure
+- mode: flat
+## forbidden
+- Unsupported SVG constructs
+""",
+ encoding="utf-8",
+)
+
+
+def run_tool(script, *args):
+ result = subprocess.run(
+ [sys.executable, str(scripts / script), *map(str, args)],
+ capture_output=True, text=True,
+ )
+ assert result.returncode == 0, result.stderr or result.stdout
+ return result.stdout.strip()
+
+preset = run_tool(
+ "preset_shape_svg.py", "render", "rightArrow",
+ "--id", "preset-source", "--frame", "500", "120", "240", "120",
+ "--fill", "#2563EB", "--stroke", "none",
+)
+source = project / "operands.svg"
+source.write_text(
+ f"""<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1280 720">
+ <defs><clipPath id="clip"><rect width="80" height="80"/></clipPath></defs>
+ <g transform="translate(100 80) scale(1.2)">
+ <rect id="body" x="40" y="40" width="400" height="240" rx="20"
+ fill="#2563EB" stroke="#0F172A" stroke-width="5"
+ stroke-dasharray="10 4"/>
+ <circle id="cutout" cx="240" cy="160" r="70" fill="#F97316"/>
+ <path id="open" d="M 40 320 L 260 320 L 260 420" fill="#2563EB"/>
+ <rect id="clipped" x="40" y="320" width="160" height="100"
+ clip-path="url(#clip)" fill="#2563EB"/>
+ <path id="imported" d="M 240 320 H 400 V 420 H 240 Z"
+ data-pptx-geometry-kind="custom" fill="#2563EB"/>
+ <rect id="dashoffset" x="440" y="320" width="120" height="100"
+ fill="#2563EB" stroke="#0F172A" stroke-dashoffset="2"/>
+ <rect id="non-scaling" x="500" y="40" width="150" height="120"
+ fill="#2563EB" stroke="#0F172A" stroke-width="5"
+ stroke-dasharray="10 4" vector-effect="non-scaling-stroke"/>
+ <circle id="non-scaling-cut" cx="625" cy="100" r="45" fill="#F97316"/>
+ <rect id="far" x="800" y="320" width="100" height="80" fill="#2563EB"/>
+ </g>
+ {preset}
+ <circle id="preset-cut" cx="690" cy="180" r="52" fill="#F97316"/>
+</svg>
+""",
+ encoding="utf-8",
+)
+
+operations = [
+ ("union", "preset-source", "preset-cut"),
+ ("combine", "body", "cutout"),
+ ("fragment", "body", "cutout"),
+ ("intersect", "body", "cutout"),
+ ("subtract", "body", "cutout"),
+]
+expected_custom_shapes = 0
+for index, (operation, first, second) in enumerate(operations, start=1):
+ fragment = run_tool(
+ "shape_boolean_svg.py", "render", source, "--operation", operation,
+ "--source", first, "--source", second, "--id", f"result-{operation}",
+ )
+ paths = list(
+ ET.fromstring(
+ f'<svg xmlns="http://www.w3.org/2000/svg">{fragment}</svg>'
+ )
+ )
+ assert paths and all(path.tag.endswith("}path") for path in paths)
+ assert all(
+ token not in fragment
+ for token in ("clip-path=", "fill-rule=", "mask=", "transform=")
+ )
+ if operation == "fragment":
+ assert len(paths) > 1
+ assert [path.get("id") for path in paths] == [
+ f"result-fragment-{piece}"
+ for piece in range(1, len(paths) + 1)
+ ]
+ else:
+ assert len(paths) == 1
+ assert paths[0].get("id") == f"result-{operation}"
+ if operation == "combine":
+ assert all(path.get("stroke-width") == "6" for path in paths)
+ assert all(path.get("stroke-dasharray") == "12 4.8" for path in paths)
+ if operation == "subtract":
+ assert (paths[0].get("d") or "").count("M ") >= 2
+
+ expected_custom_shapes += len(paths)
+ (svg_output / f"{index:02d}_{operation}.svg").write_text(
+ '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1280 720" '
+ 'data-pptx-page-role="content">'
+ '<rect x="0" y="0" width="1280" height="720" fill="#FFFFFF"/>'
+ f"{fragment}</svg>\n",
+ encoding="utf-8",
+ )
+
+non_scaling = ET.fromstring(
+ run_tool(
+ "shape_boolean_svg.py", "render", source, "--operation", "union",
+ "--source", "non-scaling", "--source", "non-scaling-cut",
+ "--id", "result-non-scaling",
+ )
+)
+assert non_scaling.get("stroke-width") == "5"
+assert non_scaling.get("stroke-dasharray") == "10 4"
+assert non_scaling.get("vector-effect") == "non-scaling-stroke"
+
+rejections = [
+ ("union", "body", "open", "open subpath"),
+ ("union", "body", "clipped", "uses clip-path"),
+ ("union", "body", "imported", "PPTX import/round-trip metadata"),
+ ("union", "body", "dashoffset", "stroke-dashoffset"),
+ ("intersect", "body", "far", "produced no filled area"),
+]
+for operation, first, second, expected_error in rejections:
+ rejected = subprocess.run(
+ [
+ sys.executable,
+ str(scripts / "shape_boolean_svg.py"),
+ "render", str(source), "--operation", operation,
+ "--source", first, "--source", second,
+ "--id", f"reject-{second}",
+ ],
+ capture_output=True, text=True,
+ )
+ assert rejected.returncode != 0
+ assert expected_error in rejected.stderr, rejected.stderr
+
+run_tool("svg_quality_checker.py", svg_output, "--format", "ppt169")
+pptx = project / "boolean-smoke.pptx"
+run_tool("svg_to_pptx.py", project, "--quick-test", "-o", pptx)
+with zipfile.ZipFile(pptx) as archive:
+ slides = [
+ name
+ for name in archive.namelist()
+ if re.fullmatch(r"ppt/slides/slide\d+\.xml", name)
+ ]
+ custom_shapes = sum(
+ archive.read(name).count(b"<a:custGeom>")
+ for name in slides
+ )
+assert len(slides) == 5, slides
+assert custom_shapes == expected_custom_shapes
+
+readback = project / "readback"
+run_tool(
+ "pptx_to_svg.py", pptx, "-o", readback,
+ "--inheritance-mode", "flat", "--strict",
+)
+slides = sorted((readback / "svg").glob("slide_*.svg"))
+readback_custom_shapes = sum(
+ slide.read_text(encoding="utf-8").count('data-pptx-custgeom="')
+ for slide in slides
+)
+assert len(slides) == 5, slides
+assert readback_custom_shapes == expected_custom_shapes
+print(
+ f"Shape Boolean smoke: passed "
+ f"({expected_custom_shapes} custom shapes; {project})"
+)
+PY
+```
+
+The five inline negative cases must return nonzero and match their expected
+errors; every other command must pass. Open the printed
+`boolean-smoke.pptx` path in PowerPoint: the Subtract result must have a real
+hole, and every Fragment sibling must remain separately selectable.
+
## `compact_svg_coordinates.py`
Compact safe model-facing page-space coordinates without rewriting unrelated
diff --git a/skills/ppt-master/scripts/prompt_audit_manifest.json b/skills/ppt-master/scripts/prompt_audit_manifest.json
index 8159881a..45b9d868 100644
--- a/skills/ppt-master/scripts/prompt_audit_manifest.json
+++ b/skills/ppt-master/scripts/prompt_audit_manifest.json
@@ -675,7 +675,7 @@
"files": [
"skills/ppt-master/references/native-shape-authoring.md"
],
- "max_tokens": 3250
+ "max_tokens": 4500
},
"route.generate.planning-template": {
"description": "Generate-PPTX planning context after an explicit template workspace is installed.",
@@ -776,7 +776,7 @@
"files": [
"skills/ppt-master/references/native-shape-authoring.md"
],
- "max_tokens": 3250
+ "max_tokens": 4500
},
"stage.shared.svg-effects": {
"description": "Conditional advanced SVG paint, effects, transforms, and geometry for Generate Executor or Create Template.",
diff --git a/skills/ppt-master/scripts/shape_boolean_svg.py b/skills/ppt-master/scripts/shape_boolean_svg.py
index 94e43664..588d7bf1 100644
--- a/skills/ppt-master/scripts/shape_boolean_svg.py
+++ b/skills/ppt-master/scripts/shape_boolean_svg.py
@@ -3,10 +3,10 @@
PPT Master - Shape Boolean SVG Fragment Tool
Combine closed SVG shapes and print the resulting canonical SVG path fragment
-to stdout. Result geometry is baked into SVG root coordinates: replace the
-operands at the SVG root while preserving the primary operand's z-order, and
-never reinsert the result into an original transformed ancestor. The source
-SVG is read-only; this tool never rewrites the page.
+to stdout. Result geometry is in SVG-root coordinate space: replace the
+operands at their original z-order under the final semantic or structured
+parent, never under the old transformed ancestor. The source SVG is read-only;
+this tool never rewrites the page.
Usage:
python3 scripts/shape_boolean_svg.py render SVG_FILE \
@@ -41,9 +41,10 @@ def build_parser() -> argparse.ArgumentParser:
parser = argparse.ArgumentParser(
description=(
"Print the Boolean result of closed SVG shapes as canonical SVG "
- "path fragments in SVG root coordinates. Insert the result at the "
- "SVG root in the primary operand's z-order, not under an original "
- "transformed ancestor. The source file is never modified."
+ "path fragments in SVG-root coordinate space. Insert the result at "
+ "the original z-order under the final semantic or structured "
+ "parent, never under the old transformed ancestor. The source file "
+ "is never modified."
),
formatter_class=argparse.RawDescriptionHelpFormatter,
)
@@ -51,7 +52,7 @@ def build_parser() -> argparse.ArgumentParser:
render_parser = subparsers.add_parser(
"render",
- help="Print root-coordinate Boolean-result SVG paths to stdout.",
+ help="Print SVG-root-coordinate Boolean-result paths to stdout.",
)
render_parser.add_argument(
"svg_file",
diff --git a/skills/ppt-master/scripts/svg_to_pptx/shape_boolean.py b/skills/ppt-master/scripts/svg_to_pptx/shape_boolean.py
index 1b772070..d3e2cf90 100644
--- a/skills/ppt-master/scripts/svg_to_pptx/shape_boolean.py
+++ b/skills/ppt-master/scripts/svg_to_pptx/shape_boolean.py
@@ -2,10 +2,10 @@
"""
PPT Master - Shape Boolean Core
-Resolve closed SVG operands into root-coordinate paths and apply
+Resolve closed SVG operands into SVG-root-coordinate paths and apply
PowerPoint-compatible merge-shapes operations without mutating the source SVG.
-Callers insert returned paths at the SVG root in the primary operand's z-order;
-reinserting them below an original transformed ancestor would transform twice.
+Callers insert returned paths at the original z-order under the final semantic
+or structured parent, never under the old transformed ancestor.
Usage:
Import render_boolean_svg_fragments from svg_to_pptx.shape_boolean.
@@ -49,10 +49,13 @@ from .drawingml.paths import (
transform_path_commands,
)
from .drawingml.utils import (
+ format_project_geometry_length,
matrix_multiply,
parse_inline_style,
parse_opacity,
parse_project_geometry_length,
+ parse_project_stroke_dasharray,
+ parse_project_stroke_enum,
parse_transform_matrix,
)
@@ -75,7 +78,7 @@ _DEFINITION_TAGS = frozenset({
"symbol",
})
_ID_RE = re.compile(r"[A-Za-z_][A-Za-z0-9_.:-]*")
-_PRESENTATION_ATTRS = (
+_STYLE_OVERRIDE_ATTRS = (
"fill",
"fill-opacity",
"opacity",
@@ -86,6 +89,10 @@ _PRESENTATION_ATTRS = (
"stroke-linecap",
"stroke-linejoin",
)
+_PRESENTATION_ATTRS = (
+ *_STYLE_OVERRIDE_ATTRS,
+ "vector-effect",
+)
_ROUNDTRIP_TRANSPORT_ATTRS = frozenset({
"data-pptx-custgeom",
"data-pptx-custgeom-ref",
@@ -115,8 +122,9 @@ def render_boolean_svg_fragments(
The first source is the primary shape: subtract removes all later sources
from it, and every result inherits its effective presentation attributes.
- All transforms are baked into root SVG coordinates, so callers must insert
- the result at the root in the primary operand's z-order. Fragment returns
+ All transforms are baked into SVG-root coordinates, so callers insert the
+ result at the original z-order under the final semantic or structured
+ parent, never under the old transformed ancestor. Fragment returns
top-to-bottom, left-to-right sibling paths named ``<output_id>-1`` onward;
every other operation returns one path named exactly ``output_id``.
"""
@@ -167,7 +175,10 @@ def render_boolean_svg_fragments(
_element_to_pathops(element, parents, pathops)
for element in selected
]
- inherited_style = _effective_style(selected[0], parents)
+ inherited_style = _materialize_baked_stroke_style(
+ _effective_style(selected[0], parents),
+ _combined_transform(_element_chain(selected[0], parents)),
+ )
inherited_style.update(style_overrides)
if normalized_operation == "fragment":
@@ -227,14 +238,14 @@ def _validate_style_overrides(
) -> dict[str, str]:
if style is None:
return {}
- unknown = sorted(set(style) - set(_PRESENTATION_ATTRS))
+ unknown = sorted(set(style) - set(_STYLE_OVERRIDE_ATTRS))
if unknown:
raise ValueError(
"Unsupported shape Boolean style override(s): "
+ ", ".join(unknown)
)
normalized: dict[str, str] = {}
- for name in _PRESENTATION_ATTRS:
+ for name in _STYLE_OVERRIDE_ATTRS:
if name not in style:
continue
value = style[name]
@@ -443,6 +454,16 @@ def _validate_geometry_presentation(
f"Shape Boolean source {_element_label(element)} uses filter; "
"reapply the effect after materializing the result"
)
+ raw_dash_offset = inline.get(
+ "stroke-dashoffset",
+ current.get("stroke-dashoffset"),
+ )
+ if raw_dash_offset is not None:
+ raise ValueError(
+ f"Shape Boolean source {_element_label(element)} uses "
+ "stroke-dashoffset; dashed-arc phase cannot be materialized "
+ "as filled Boolean geometry"
+ )
raw_fill_rule = inline.get("fill-rule", current.get("fill-rule"))
if (
raw_fill_rule is not None
@@ -468,6 +489,74 @@ def _combined_transform(chain: Sequence[ET.Element]) -> AffineMatrix:
return matrix
+def _materialize_baked_stroke_style(
+ style: Mapping[str, str],
+ matrix: AffineMatrix,
+) -> dict[str, str]:
+ """Keep stroke metrics visually stable after baking a geometry transform."""
+ materialized = dict(style)
+ raw_vector_effect = materialized.get("vector-effect")
+ vector_effect = None
+ if raw_vector_effect is not None:
+ try:
+ vector_effect = parse_project_stroke_enum(
+ "vector-effect",
+ raw_vector_effect,
+ )
+ except ValueError as exc:
+ raise ValueError(
+ f"Shape Boolean primary vector-effect "
+ f"{raw_vector_effect!r} {exc}"
+ ) from exc
+ materialized["vector-effect"] = vector_effect
+
+ stroke = materialized.get("stroke")
+ if not stroke or stroke.strip().lower() in {"none", "transparent"}:
+ return materialized
+ if vector_effect == "non-scaling-stroke":
+ return materialized
+
+ a, b, c, d, _e, _f = matrix
+ scale = math.sqrt(abs(a * d - b * c))
+ if not math.isfinite(scale):
+ raise ValueError(
+ "Shape Boolean primary transform produces a non-finite stroke scale"
+ )
+ if scale == 1.0:
+ return materialized
+
+ raw_width = materialized.get("stroke-width", "1")
+ try:
+ source_width = parse_project_geometry_length(
+ raw_width,
+ "stroke-width",
+ )
+ except ValueError as exc:
+ raise ValueError(
+ f"Shape Boolean primary stroke-width {raw_width!r} {exc}"
+ ) from exc
+ materialized["stroke-width"] = format_project_geometry_length(
+ source_width * scale
+ )
+
+ raw_dasharray = materialized.get("stroke-dasharray")
+ if raw_dasharray is None or raw_dasharray.strip().lower() == "none":
+ return materialized
+ try:
+ parsed_dasharray = parse_project_stroke_dasharray(raw_dasharray)
+ except ValueError as exc:
+ raise ValueError(
+ f"Shape Boolean primary stroke-dasharray {raw_dasharray!r} {exc}"
+ ) from exc
+ if parsed_dasharray is not None:
+ _preset, values = parsed_dasharray
+ materialized["stroke-dasharray"] = " ".join(
+ format_project_geometry_length(value * scale)
+ for value in values
+ )
+ return materialized
+
+
def _shape_commands(element: ET.Element) -> list[PathCommand]:
tag = _local_name(element.tag)
if tag == "path":
diff --git a/skills/ppt-master/scripts/update_repo.py b/skills/ppt-master/scripts/update_repo.py
index 00e3d423..91280209 100644
--- a/skills/ppt-master/scripts/update_repo.py
+++ b/skills/ppt-master/scripts/update_repo.py
@@ -1,8 +1,8 @@
#!/usr/bin/env python3
"""PPT Master - Repository Updater
-Pull the latest Git checkout and sync Python dependencies when requirements
-change.
+Pull the latest Git checkout and sync Python dependencies when the effective
+requirements include tree changes.
Usage:
python3 skills/ppt-master/scripts/update_repo.py
@@ -20,6 +20,7 @@ from __future__ import annotations
import argparse
import hashlib
+import shlex
import shutil
import subprocess
import sys
@@ -59,14 +60,14 @@ def parse_args(argv: list[str] | None = None) -> argparse.Namespace:
parser = argparse.ArgumentParser(
description=(
"Pull the latest repository changes and sync Python dependencies "
- "only when requirements.txt changes."
+ "only when the requirements include tree changes."
),
formatter_class=argparse.RawDescriptionHelpFormatter,
)
parser.add_argument(
"--skip-pip",
action="store_true",
- help="Skip Python dependency sync even if requirements.txt changed.",
+ help="Skip Python dependency sync even if the requirements include tree changed.",
)
return parser.parse_args(argv)
@@ -88,14 +89,75 @@ def run_command(args: list[str], *, check: bool = True) -> subprocess.CompletedP
)
-def file_digest(path: Path) -> str | None:
+def _requirement_includes(path: Path, content: str) -> list[Path]:
+ """Resolve local -r/--requirement includes relative to their owning file."""
+ includes: list[Path] = []
+ for raw_line in content.splitlines():
+ try:
+ tokens = shlex.split(raw_line, comments=True, posix=True)
+ except ValueError:
+ continue
+ if not tokens:
+ continue
+
+ option = tokens[0]
+ include_value: str | None = None
+ if option in {"-r", "--requirement"}:
+ if len(tokens) >= 2:
+ include_value = tokens[1]
+ elif option.startswith("--requirement="):
+ include_value = option.partition("=")[2]
+ elif option.startswith("-r") and len(option) > 2:
+ include_value = option[2:].lstrip("=")
+
+ if not include_value:
+ continue
+ include_path = Path(include_value)
+ if not include_path.is_absolute():
+ include_path = path.parent / include_path
+ includes.append(include_path)
+ return includes
+
+
+def requirements_digest(path: Path) -> str | None:
+ """Hash one requirements file and its recursive local include closure."""
if not path.exists():
return None
digest = hashlib.sha256()
- with path.open("rb") as handle:
- for chunk in iter(lambda: handle.read(8192), b""):
- digest.update(chunk)
+ visited: set[Path] = set()
+
+ def visit(current: Path) -> None:
+ try:
+ resolved = current.resolve()
+ except OSError as exc:
+ raise RuntimeError(
+ f"Unable to resolve requirements file {current}: {exc}"
+ ) from exc
+ if resolved in visited:
+ digest.update(b"repeat\0")
+ return
+ visited.add(resolved)
+
+ if not resolved.is_file():
+ digest.update(b"missing\0")
+ return
+ try:
+ content = resolved.read_bytes()
+ except OSError as exc:
+ raise RuntimeError(
+ f"Unable to read requirements file {resolved}: {exc}"
+ ) from exc
+ digest.update(b"file\0")
+ digest.update(len(content).to_bytes(8, "big"))
+ digest.update(content)
+ for included in _requirement_includes(
+ resolved,
+ content.decode("utf-8", errors="replace"),
+ ):
+ visit(included)
+
+ visit(path)
return digest.hexdigest()
@@ -131,7 +193,7 @@ def sync_python_dependencies() -> None:
print_status("requirements.txt not found; skipping Python dependency sync.")
return
- print_status("requirements.txt changed. Syncing Python dependencies...")
+ print_status("Requirements include tree changed. Syncing Python dependencies...")
result = run_command([sys.executable, "-m", "pip", "install", "-r", str(REQUIREMENTS_FILE)])
if result.stdout.strip():
print_status(result.stdout.strip())
@@ -148,7 +210,7 @@ def main(argv: list[str] | None = None) -> int:
ensure_clean_tracked_worktree()
before_head = get_head_revision()
- before_requirements = file_digest(REQUIREMENTS_FILE)
+ before_requirements = requirements_digest(REQUIREMENTS_FILE)
print_status(f"Repository: {REPO_ROOT}")
pull_result = run_command(["git", "pull", "--ff-only"])
@@ -158,7 +220,7 @@ def main(argv: list[str] | None = None) -> int:
print_status(pull_result.stderr.strip())
after_head = get_head_revision()
- after_requirements = file_digest(REQUIREMENTS_FILE)
+ after_requirements = requirements_digest(REQUIREMENTS_FILE)
if before_head == after_head:
print_status("Repository is already up to date.")
@@ -170,7 +232,9 @@ def main(argv: list[str] | None = None) -> int:
elif before_requirements != after_requirements:
sync_python_dependencies()
else:
- print_status("requirements.txt unchanged. Skipping Python dependency sync.")
+ print_status(
+ "Requirements include tree unchanged. Skipping Python dependency sync."
+ )
print_status(
"Note: system dependencies such as Node.js and Pandoc still need "