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(scripts): import-sources copies another project's files, calibrate --role merges, preset describe prints the text rectangle

hugohe34456736dd2a9
diff --git a/skills/ppt-master/scripts/preset_shape_svg.py b/skills/ppt-master/scripts/preset_shape_svg.py
index faf8e097..c1410652 100644
--- a/skills/ppt-master/scripts/preset_shape_svg.py
+++ b/skills/ppt-master/scripts/preset_shape_svg.py
@@ -32,7 +32,7 @@ from pathlib import Path
from typing import Sequence
from console_encoding import configure_utf8_stdio
-from pptx_shapes import CONNECTOR_PRESET_TYPES, get_preset_registry
+from pptx_shapes import CONNECTOR_PRESET_TYPES, FormulaEvaluationError, get_preset_registry
from pptx_shapes.semantics import get_preset_shape_semantics
from pptx_to_svg.preset_authoring import render_preset_shape_fragment
@@ -101,6 +101,23 @@ def build_parser() -> argparse.ArgumentParser:
"Print one flat objective identity view with key geometry facts."
),
)
+ describe_parser.add_argument(
+ "--frame",
+ nargs=4,
+ type=float,
+ metavar=("X", "Y", "W", "H"),
+ help=(
+ "Also evaluate the text rectangle for this page frame and print it "
+ "as text_rectangle_px (page coordinates, same as render --frame)."
+ ),
+ )
+ describe_parser.add_argument(
+ "--adjust",
+ action="append",
+ default=[],
+ metavar="NAME=FORMULA",
+ help="Adjustment guide used when evaluating --frame (repeatable).",
+ )
render_parser = subparsers.add_parser(
"render",
@@ -237,6 +254,37 @@ def main(argv: Sequence[str] | None = None) -> int:
path_count = len(definition.paths)
connection_site_count = len(definition.connections)
has_text_rectangle = definition.text_rectangle is not None
+ text_rectangle = (
+ None
+ if definition.text_rectangle is None
+ else {
+ "left": definition.text_rectangle.left,
+ "top": definition.text_rectangle.top,
+ "right": definition.text_rectangle.right,
+ "bottom": definition.text_rectangle.bottom,
+ }
+ )
+ text_rectangle_px = None
+ if args.frame is not None and has_text_rectangle:
+ frame_x, frame_y, frame_w, frame_h = args.frame
+ try:
+ evaluated = registry.evaluate(
+ args.preset,
+ frame_w,
+ frame_h,
+ adjustments=_parse_adjustments(args.adjust),
+ )
+ except (ValueError, FormulaEvaluationError) as exc:
+ print(f"Error: {exc}", file=sys.stderr)
+ return 1
+ rect = evaluated.text_rectangle
+ if rect is not None:
+ text_rectangle_px = {
+ "x": round(frame_x + rect.left, 2),
+ "y": round(frame_y + rect.top, 2),
+ "width": round(rect.right - rect.left, 2),
+ "height": round(rect.bottom - rect.top, 2),
+ }
semantics = get_preset_shape_semantics().describe(args.preset)
full_payload = {
"preset": definition.name,
@@ -245,6 +293,8 @@ def main(argv: Sequence[str] | None = None) -> int:
"path_count": path_count,
"connection_site_count": connection_site_count,
"has_text_rectangle": has_text_rectangle,
+ "text_rectangle": text_rectangle,
+ "text_rectangle_px": text_rectangle_px,
"semantics": semantics,
}
payload = (
@@ -260,6 +310,8 @@ def main(argv: Sequence[str] | None = None) -> int:
"path_count": path_count,
"connection_site_count": connection_site_count,
"has_text_rectangle": has_text_rectangle,
+ "text_rectangle": text_rectangle,
+ "text_rectangle_px": text_rectangle_px,
}
if args.compact
else full_payload
diff --git a/skills/ppt-master/scripts/project_management/cli.py b/skills/ppt-master/scripts/project_management/cli.py
index d0089141..51e3225c 100644
--- a/skills/ppt-master/scripts/project_management/cli.py
+++ b/skills/ppt-master/scripts/project_management/cli.py
@@ -858,8 +858,23 @@ class ProjectManager:
continue
inside_projects = is_within_path(source_path, PROJECTS_ROOT)
+ # A file inside another project's tree (projects/<other>/...) is
+ # that project's material: taking it by default emptied a finished
+ # project's images/ once. Copy unless --move is explicit.
+ inside_other_project = (
+ inside_projects
+ and not is_within_path(source_path, project_dir.resolve())
+ and source_path.resolve().parent != PROJECTS_ROOT.resolve()
+ )
if copy:
effective_move = False
+ elif inside_other_project and not move:
+ effective_move = False
+ print(
+ f"note: {source_path} belongs to another project; copied "
+ f"(not moved). Pass --move to take it out of that project.",
+ file=sys.stderr,
+ )
elif inside_projects:
effective_move = True
else:
@@ -870,7 +885,7 @@ class ProjectManager:
f"(not moved). Only sources under projects/ may be moved.",
file=sys.stderr,
)
- elif inside_projects and not move and not copy:
+ elif inside_projects and not inside_other_project and not move and not copy:
print(
f"note: {source_path} is under projects/; moved into the target "
f"project. Pass --copy to preserve it.",
diff --git a/skills/ppt-master/scripts/text_measure.py b/skills/ppt-master/scripts/text_measure.py
index 247dd0aa..cdcb9c10 100644
--- a/skills/ppt-master/scripts/text_measure.py
+++ b/skills/ppt-master/scripts/text_measure.py
@@ -612,6 +612,19 @@ def _run_calibrate(args: argparse.Namespace) -> int:
payload['notes'] = _fallback_notes(roles, fallbacks)
output_path = project_path / 'validation' / 'text_calibration.json'
output_path.parent.mkdir(parents=True, exist_ok=True)
+ if args.role and output_path.is_file():
+ # A --role run recalibrates only the named roles; keep the roles
+ # an earlier run already wrote, so "calibrate again only for a
+ # role never calibrated" is incremental, not a table overwrite.
+ try:
+ previous = json.loads(output_path.read_text(encoding='utf-8'))
+ except (OSError, ValueError):
+ previous = {}
+ previous_roles = previous.get('roles') if isinstance(previous, dict) else None
+ if isinstance(previous_roles, dict):
+ merged = dict(previous_roles)
+ merged.update(payload['roles'])
+ payload['roles'] = merged
rendered_json = json.dumps(payload, ensure_ascii=False, indent=2)
output_path.write_text(rendered_json + '\n', encoding='utf-8')
except (OSError, ValueError) as exc: