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

feat(spec-lock): validate custom catalog references

hugohe3346a6938b5ea
diff --git a/skills/ppt-master/scripts/project_specs.py b/skills/ppt-master/scripts/project_specs.py
index d287337c..4206c0af 100644
--- a/skills/ppt-master/scripts/project_specs.py
+++ b/skills/ppt-master/scripts/project_specs.py
@@ -47,6 +47,22 @@ SKILL_DIR = TOOLS_DIR.parent
SCHEMA_DIR = SKILL_DIR / "templates" / "schemas"
SCAFFOLD_DIR = SKILL_DIR / "templates" / "scaffolds"
+_CUSTOM_REFERENCE_CATALOGS = (
+ ("mode", "mode", "mode_references", SKILL_DIR / "references" / "modes"),
+ (
+ "visual_style",
+ "visual_style",
+ "visual_style_references",
+ SKILL_DIR / "references" / "visual-styles",
+ ),
+ (
+ "colors",
+ "image_rendering",
+ "image_rendering_references",
+ SKILL_DIR / "references" / "image-renderings",
+ ),
+)
+
_MARKDOWN_H2_RE = re.compile(r"^##[ \t]+(.+?)[ \t]*$", re.MULTILINE)
_MARKDOWN_SUBHEADING_RE = re.compile(r"^#{3,6}[ \t]+(.+?)[ \t]*$", re.MULTILINE)
_MARKDOWN_DATA_LINE_RE = re.compile(
@@ -697,6 +713,44 @@ def _validate_spec_lock_relations(
assert isinstance(raw_fields, dict)
return {str(key): str(value) for key, value in raw_fields.items()}
+ for section_id, selector_field, references_field, catalog_dir in (
+ _CUSTOM_REFERENCE_CATALOGS
+ ):
+ section_fields = fields(section_id)
+ is_custom = (
+ _normalize_schema_value(section_fields.get(selector_field, "")) == "custom"
+ )
+ raw_references = _normalize_schema_value(
+ section_fields.get(references_field, "")
+ )
+ if not is_custom:
+ if raw_references:
+ errors.append(
+ f"{markdown_name} schema: field '{references_field}' is valid "
+ f"only when '{selector_field}' is custom"
+ )
+ continue
+ if not raw_references:
+ continue
+ references = [item.strip() for item in raw_references.split(",")]
+ duplicates = sorted(
+ reference
+ for reference in set(references)
+ if references.count(reference) > 1
+ )
+ if duplicates:
+ errors.append(
+ f"{markdown_name} schema: field '{references_field}' repeats "
+ f"catalog id(s) {', '.join(duplicates)}"
+ )
+ for reference in references:
+ catalog_file = catalog_dir / f"{reference}.md"
+ if reference == "custom" or not catalog_file.is_file():
+ errors.append(
+ f"{markdown_name} schema: field '{references_field}' references "
+ f"unknown catalog id '{reference}'"
+ )
+
rhythm = fields("page_rhythm")
layouts = fields("pptx_layouts")
page_pptx_layouts = fields("page_pptx_layouts")
diff --git a/skills/ppt-master/templates/schemas/spec_lock.schema.json b/skills/ppt-master/templates/schemas/spec_lock.schema.json
index 1b90da7a..66723c2e 100644
--- a/skills/ppt-master/templates/schemas/spec_lock.schema.json
+++ b/skills/ppt-master/templates/schemas/spec_lock.schema.json
@@ -25,7 +25,8 @@
"type": "object",
"properties": {
"image_rendering": {"type": "string"},
- "image_rendering_behavior": {"type": "string"}
+ "image_rendering_behavior": {"type": "string"},
+ "image_rendering_references": {"type": "string"}
}
},
"typography": {
@@ -97,7 +98,10 @@
"pattern": "^mode$",
"required": true,
"required_fields": ["mode"],
- "allowed_fields": ["mode", "mode_behavior"],
+ "allowed_fields": ["mode", "mode_behavior", "mode_references"],
+ "field_patterns": {
+ "mode_references": "^[a-z0-9][a-z0-9-]*(?:\\s*,\\s*[a-z0-9][a-z0-9-]*)*$"
+ },
"field_enums": {
"mode": ["pyramid", "narrative", "instructional", "showcase", "briefing", "custom"]
}
@@ -107,9 +111,20 @@
"pattern": "^visual_style$",
"required": true,
"required_fields": ["visual_style"],
- "allowed_fields": ["visual_style", "visual_style_behavior"]
+ "allowed_fields": ["visual_style", "visual_style_behavior", "visual_style_references"],
+ "field_patterns": {
+ "visual_style_references": "^[a-z0-9][a-z0-9-]*(?:\\s*,\\s*[a-z0-9][a-z0-9-]*)*$"
+ }
+ },
+ {
+ "id": "colors",
+ "pattern": "^colors$",
+ "required": true,
+ "min_entries": 1,
+ "field_patterns": {
+ "image_rendering_references": "^[a-z0-9][a-z0-9-]*(?:\\s*,\\s*[a-z0-9][a-z0-9-]*)*$"
+ }
},
- {"id": "colors", "pattern": "^colors$", "required": true, "min_entries": 1},
{
"id": "typography",
"pattern": "^typography$",