From 840fd500762714643d649bd034f86e7bb694a5ea Mon Sep 17 00:00:00 2001 From: Bob Lee Date: Thu, 6 Aug 2026 04:45:48 -0700 Subject: [PATCH] fix(skills): remove redistribution-restricted builtins Stop embedding the docx, pdf, pptx, and xlsx skill bundles, clean legacy loose installs, and keep the supported ppt-design workflow. Also restore the Superpowers MIT notice for the retained writing-skills content while dropping its vendored Anthropic documentation copy. --- README.md | 4 +- README.zh-CN.md | 4 +- .../core/builtin-skills-upstreams.json | 12 - .../core/builtin_skills/docx/LICENSE.txt | 30 - .../core/builtin_skills/docx/SKILL.md | 92 - .../builtin_skills/docx/scripts/__init__.py | 1 - .../docx/scripts/accept_changes.py | 135 - .../builtin_skills/docx/scripts/comment.py | 368 -- .../builtin_skills/docx/scripts/merge_runs.py | 310 -- .../docx/scripts/office/helpers/__init__.py | 150 - .../docx/scripts/office/helpers/pptx_chart.py | 170 - .../docx/scripts/office/helpers/pptx_slide.py | 60 - .../docx/scripts/office/helpers/pptx_theme.py | 114 - .../schemas/ISO-IEC29500-4_2016/dml-chart.xsd | 1499 ------ .../ISO-IEC29500-4_2016/dml-chartDrawing.xsd | 146 - .../ISO-IEC29500-4_2016/dml-diagram.xsd | 1085 ---- .../ISO-IEC29500-4_2016/dml-lockedCanvas.xsd | 11 - .../schemas/ISO-IEC29500-4_2016/dml-main.xsd | 3081 ------------ .../ISO-IEC29500-4_2016/dml-picture.xsd | 23 - .../dml-spreadsheetDrawing.xsd | 185 - .../dml-wordprocessingDrawing.xsd | 287 -- .../schemas/ISO-IEC29500-4_2016/pml.xsd | 1676 ------- .../shared-additionalCharacteristics.xsd | 28 - .../shared-bibliography.xsd | 144 - .../shared-commonSimpleTypes.xsd | 174 - .../shared-customXmlDataProperties.xsd | 25 - .../shared-customXmlSchemaProperties.xsd | 18 - .../shared-documentPropertiesCustom.xsd | 59 - .../shared-documentPropertiesExtended.xsd | 56 - .../shared-documentPropertiesVariantTypes.xsd | 195 - .../ISO-IEC29500-4_2016/shared-math.xsd | 582 --- .../shared-relationshipReference.xsd | 25 - .../schemas/ISO-IEC29500-4_2016/sml.xsd | 4439 ----------------- .../schemas/ISO-IEC29500-4_2016/vml-main.xsd | 570 --- .../ISO-IEC29500-4_2016/vml-officeDrawing.xsd | 509 -- .../vml-presentationDrawing.xsd | 12 - .../vml-spreadsheetDrawing.xsd | 108 - .../vml-wordprocessingDrawing.xsd | 96 - .../schemas/ISO-IEC29500-4_2016/wml.xsd | 3646 -------------- .../schemas/ISO-IEC29500-4_2016/xml.xsd | 116 - .../ecma/fouth-edition/opc-contentTypes.xsd | 42 - .../ecma/fouth-edition/opc-coreProperties.xsd | 50 - .../schemas/ecma/fouth-edition/opc-digSig.xsd | 49 - .../ecma/fouth-edition/opc-relationships.xsd | 33 - .../docx/scripts/office/schemas/mce/mc.xsd | 75 - .../office/schemas/microsoft/wml-2010.xsd | 560 --- .../office/schemas/microsoft/wml-2012.xsd | 67 - .../office/schemas/microsoft/wml-2018.xsd | 14 - .../office/schemas/microsoft/wml-cex-2018.xsd | 20 - .../office/schemas/microsoft/wml-cid-2016.xsd | 13 - .../microsoft/wml-sdtdatahash-2020.xsd | 4 - .../schemas/microsoft/wml-symex-2015.xsd | 8 - .../docx/scripts/office/soffice.py | 192 - .../docx/scripts/office/validate.py | 173 - .../scripts/office/validators/__init__.py | 15 - .../docx/scripts/office/validators/base.py | 875 ---- .../docx/scripts/office/validators/docx.py | 466 -- .../docx/scripts/office/validators/pptx.py | 441 -- .../scripts/office/validators/redlining.py | 299 -- .../docx/scripts/templates/comments.xml | 3 - .../scripts/templates/commentsExtended.xml | 3 - .../scripts/templates/commentsExtensible.xml | 3 - .../docx/scripts/templates/commentsIds.xml | 3 - .../docx/scripts/templates/people.xml | 3 - .../core/builtin_skills/pdf/LICENSE.txt | 30 - .../assembly/core/builtin_skills/pdf/SKILL.md | 314 -- .../assembly/core/builtin_skills/pdf/forms.md | 294 -- .../core/builtin_skills/pdf/reference.md | 612 --- .../pdf/scripts/check_bounding_boxes.py | 65 - .../pdf/scripts/check_fillable_fields.py | 11 - .../pdf/scripts/convert_pdf_to_images.py | 33 - .../pdf/scripts/create_validation_image.py | 37 - .../pdf/scripts/extract_form_field_info.py | 122 - .../pdf/scripts/extract_form_structure.py | 115 - .../pdf/scripts/fill_fillable_fields.py | 98 - .../scripts/fill_pdf_form_with_annotations.py | 107 - .../core/builtin_skills/pptx/LICENSE.txt | 30 - .../core/builtin_skills/pptx/SKILL.md | 238 - .../builtin_skills/pptx/scripts/__init__.py | 0 .../builtin_skills/pptx/scripts/add_slide.py | 367 -- .../core/builtin_skills/pptx/scripts/clean.py | 309 -- .../pptx/scripts/office/helpers/__init__.py | 150 - .../pptx/scripts/office/helpers/pptx_chart.py | 170 - .../pptx/scripts/office/helpers/pptx_slide.py | 60 - .../pptx/scripts/office/helpers/pptx_theme.py | 114 - .../schemas/ISO-IEC29500-4_2016/dml-chart.xsd | 1499 ------ .../ISO-IEC29500-4_2016/dml-chartDrawing.xsd | 146 - .../ISO-IEC29500-4_2016/dml-diagram.xsd | 1085 ---- .../ISO-IEC29500-4_2016/dml-lockedCanvas.xsd | 11 - .../schemas/ISO-IEC29500-4_2016/dml-main.xsd | 3081 ------------ .../ISO-IEC29500-4_2016/dml-picture.xsd | 23 - .../dml-spreadsheetDrawing.xsd | 185 - .../dml-wordprocessingDrawing.xsd | 287 -- .../schemas/ISO-IEC29500-4_2016/pml.xsd | 1676 ------- .../shared-additionalCharacteristics.xsd | 28 - .../shared-bibliography.xsd | 144 - .../shared-commonSimpleTypes.xsd | 174 - .../shared-customXmlDataProperties.xsd | 25 - .../shared-customXmlSchemaProperties.xsd | 18 - .../shared-documentPropertiesCustom.xsd | 59 - .../shared-documentPropertiesExtended.xsd | 56 - .../shared-documentPropertiesVariantTypes.xsd | 195 - .../ISO-IEC29500-4_2016/shared-math.xsd | 582 --- .../shared-relationshipReference.xsd | 25 - .../schemas/ISO-IEC29500-4_2016/sml.xsd | 4439 ----------------- .../schemas/ISO-IEC29500-4_2016/vml-main.xsd | 570 --- .../ISO-IEC29500-4_2016/vml-officeDrawing.xsd | 509 -- .../vml-presentationDrawing.xsd | 12 - .../vml-spreadsheetDrawing.xsd | 108 - .../vml-wordprocessingDrawing.xsd | 96 - .../schemas/ISO-IEC29500-4_2016/wml.xsd | 3646 -------------- .../schemas/ISO-IEC29500-4_2016/xml.xsd | 116 - .../ecma/fouth-edition/opc-contentTypes.xsd | 42 - .../ecma/fouth-edition/opc-coreProperties.xsd | 50 - .../schemas/ecma/fouth-edition/opc-digSig.xsd | 49 - .../ecma/fouth-edition/opc-relationships.xsd | 33 - .../pptx/scripts/office/schemas/mce/mc.xsd | 75 - .../office/schemas/microsoft/wml-2010.xsd | 560 --- .../office/schemas/microsoft/wml-2012.xsd | 67 - .../office/schemas/microsoft/wml-2018.xsd | 14 - .../office/schemas/microsoft/wml-cex-2018.xsd | 20 - .../office/schemas/microsoft/wml-cid-2016.xsd | 13 - .../microsoft/wml-sdtdatahash-2020.xsd | 4 - .../schemas/microsoft/wml-symex-2015.xsd | 8 - .../pptx/scripts/office/soffice.py | 192 - .../pptx/scripts/office/validate.py | 173 - .../scripts/office/validators/__init__.py | 15 - .../pptx/scripts/office/validators/base.py | 875 ---- .../pptx/scripts/office/validators/docx.py | 466 -- .../pptx/scripts/office/validators/pptx.py | 441 -- .../scripts/office/validators/redlining.py | 299 -- .../builtin_skills/pptx/scripts/thumbnail.py | 311 -- .../builtin_skills/writing-skills/LICENSE.txt | 21 + .../anthropic-best-practices.md | 1150 ----- .../core/builtin_skills/xlsx/LICENSE.txt | 30 - .../core/builtin_skills/xlsx/SKILL.md | 99 - .../xlsx/scripts/office/helpers/__init__.py | 150 - .../xlsx/scripts/office/helpers/pptx_chart.py | 170 - .../xlsx/scripts/office/helpers/pptx_slide.py | 60 - .../xlsx/scripts/office/helpers/pptx_theme.py | 114 - .../schemas/ISO-IEC29500-4_2016/dml-chart.xsd | 1499 ------ .../ISO-IEC29500-4_2016/dml-chartDrawing.xsd | 146 - .../ISO-IEC29500-4_2016/dml-diagram.xsd | 1085 ---- .../ISO-IEC29500-4_2016/dml-lockedCanvas.xsd | 11 - .../schemas/ISO-IEC29500-4_2016/dml-main.xsd | 3081 ------------ .../ISO-IEC29500-4_2016/dml-picture.xsd | 23 - .../dml-spreadsheetDrawing.xsd | 185 - .../dml-wordprocessingDrawing.xsd | 287 -- .../schemas/ISO-IEC29500-4_2016/pml.xsd | 1676 ------- .../shared-additionalCharacteristics.xsd | 28 - .../shared-bibliography.xsd | 144 - .../shared-commonSimpleTypes.xsd | 174 - .../shared-customXmlDataProperties.xsd | 25 - .../shared-customXmlSchemaProperties.xsd | 18 - .../shared-documentPropertiesCustom.xsd | 59 - .../shared-documentPropertiesExtended.xsd | 56 - .../shared-documentPropertiesVariantTypes.xsd | 195 - .../ISO-IEC29500-4_2016/shared-math.xsd | 582 --- .../shared-relationshipReference.xsd | 25 - .../schemas/ISO-IEC29500-4_2016/sml.xsd | 4439 ----------------- .../schemas/ISO-IEC29500-4_2016/vml-main.xsd | 570 --- .../ISO-IEC29500-4_2016/vml-officeDrawing.xsd | 509 -- .../vml-presentationDrawing.xsd | 12 - .../vml-spreadsheetDrawing.xsd | 108 - .../vml-wordprocessingDrawing.xsd | 96 - .../schemas/ISO-IEC29500-4_2016/wml.xsd | 3646 -------------- .../schemas/ISO-IEC29500-4_2016/xml.xsd | 116 - .../ecma/fouth-edition/opc-contentTypes.xsd | 42 - .../ecma/fouth-edition/opc-coreProperties.xsd | 50 - .../schemas/ecma/fouth-edition/opc-digSig.xsd | 49 - .../ecma/fouth-edition/opc-relationships.xsd | 33 - .../xlsx/scripts/office/schemas/mce/mc.xsd | 75 - .../office/schemas/microsoft/wml-2010.xsd | 560 --- .../office/schemas/microsoft/wml-2012.xsd | 67 - .../office/schemas/microsoft/wml-2018.xsd | 14 - .../office/schemas/microsoft/wml-cex-2018.xsd | 20 - .../office/schemas/microsoft/wml-cid-2016.xsd | 13 - .../microsoft/wml-sdtdatahash-2020.xsd | 4 - .../schemas/microsoft/wml-symex-2015.xsd | 8 - .../xlsx/scripts/office/soffice.py | 192 - .../xlsx/scripts/office/validate.py | 173 - .../scripts/office/validators/__init__.py | 15 - .../xlsx/scripts/office/validators/base.py | 875 ---- .../xlsx/scripts/office/validators/docx.py | 466 -- .../xlsx/scripts/office/validators/pptx.py | 441 -- .../scripts/office/validators/redlining.py | 299 -- .../builtin_skills/xlsx/scripts/recalc.py | 308 -- .../tools/implementations/skill_tool.rs | 5 +- .../tools/implementations/skills/builtin.rs | 83 +- .../tools/implementations/skills/catalog.rs | 7 +- .../tools/implementations/skills/policy.rs | 24 +- .../tools/implementations/skills/resolver.rs | 20 +- .../config/mode_config_canonicalizer.rs | 24 +- .../core/tests/office_archive_safety.py | 117 - .../agent-runtime/src/skills/catalog.rs | 16 - .../skill_contracts.rs | 51 +- src/web-ui/src/locales/en-US/flow-chat.json | 6 +- src/web-ui/src/locales/zh-CN/flow-chat.json | 6 +- src/web-ui/src/locales/zh-TW/flow-chat.json | 6 +- 199 files changed, 123 insertions(+), 73969 deletions(-) delete mode 100644 src/crates/assembly/core/builtin_skills/docx/LICENSE.txt delete mode 100644 src/crates/assembly/core/builtin_skills/docx/SKILL.md delete mode 100755 src/crates/assembly/core/builtin_skills/docx/scripts/__init__.py delete mode 100755 src/crates/assembly/core/builtin_skills/docx/scripts/accept_changes.py delete mode 100755 src/crates/assembly/core/builtin_skills/docx/scripts/comment.py delete mode 100755 src/crates/assembly/core/builtin_skills/docx/scripts/merge_runs.py delete mode 100644 src/crates/assembly/core/builtin_skills/docx/scripts/office/helpers/__init__.py delete mode 100644 src/crates/assembly/core/builtin_skills/docx/scripts/office/helpers/pptx_chart.py delete mode 100644 src/crates/assembly/core/builtin_skills/docx/scripts/office/helpers/pptx_slide.py delete mode 100644 src/crates/assembly/core/builtin_skills/docx/scripts/office/helpers/pptx_theme.py delete mode 100644 src/crates/assembly/core/builtin_skills/docx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-chart.xsd delete mode 100644 src/crates/assembly/core/builtin_skills/docx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-chartDrawing.xsd delete mode 100644 src/crates/assembly/core/builtin_skills/docx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-diagram.xsd delete mode 100644 src/crates/assembly/core/builtin_skills/docx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-lockedCanvas.xsd delete mode 100644 src/crates/assembly/core/builtin_skills/docx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-main.xsd delete mode 100644 src/crates/assembly/core/builtin_skills/docx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-picture.xsd delete mode 100644 src/crates/assembly/core/builtin_skills/docx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-spreadsheetDrawing.xsd delete mode 100644 src/crates/assembly/core/builtin_skills/docx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-wordprocessingDrawing.xsd delete mode 100644 src/crates/assembly/core/builtin_skills/docx/scripts/office/schemas/ISO-IEC29500-4_2016/pml.xsd delete mode 100644 src/crates/assembly/core/builtin_skills/docx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-additionalCharacteristics.xsd delete mode 100644 src/crates/assembly/core/builtin_skills/docx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-bibliography.xsd delete mode 100644 src/crates/assembly/core/builtin_skills/docx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-commonSimpleTypes.xsd delete mode 100644 src/crates/assembly/core/builtin_skills/docx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-customXmlDataProperties.xsd delete mode 100644 src/crates/assembly/core/builtin_skills/docx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-customXmlSchemaProperties.xsd delete mode 100644 src/crates/assembly/core/builtin_skills/docx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-documentPropertiesCustom.xsd delete mode 100644 src/crates/assembly/core/builtin_skills/docx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-documentPropertiesExtended.xsd delete mode 100644 src/crates/assembly/core/builtin_skills/docx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-documentPropertiesVariantTypes.xsd delete mode 100644 src/crates/assembly/core/builtin_skills/docx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-math.xsd delete mode 100644 src/crates/assembly/core/builtin_skills/docx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-relationshipReference.xsd delete mode 100644 src/crates/assembly/core/builtin_skills/docx/scripts/office/schemas/ISO-IEC29500-4_2016/sml.xsd delete mode 100644 src/crates/assembly/core/builtin_skills/docx/scripts/office/schemas/ISO-IEC29500-4_2016/vml-main.xsd delete mode 100644 src/crates/assembly/core/builtin_skills/docx/scripts/office/schemas/ISO-IEC29500-4_2016/vml-officeDrawing.xsd delete mode 100644 src/crates/assembly/core/builtin_skills/docx/scripts/office/schemas/ISO-IEC29500-4_2016/vml-presentationDrawing.xsd delete mode 100644 src/crates/assembly/core/builtin_skills/docx/scripts/office/schemas/ISO-IEC29500-4_2016/vml-spreadsheetDrawing.xsd delete mode 100644 src/crates/assembly/core/builtin_skills/docx/scripts/office/schemas/ISO-IEC29500-4_2016/vml-wordprocessingDrawing.xsd delete mode 100644 src/crates/assembly/core/builtin_skills/docx/scripts/office/schemas/ISO-IEC29500-4_2016/wml.xsd delete mode 100644 src/crates/assembly/core/builtin_skills/docx/scripts/office/schemas/ISO-IEC29500-4_2016/xml.xsd delete mode 100644 src/crates/assembly/core/builtin_skills/docx/scripts/office/schemas/ecma/fouth-edition/opc-contentTypes.xsd delete mode 100644 src/crates/assembly/core/builtin_skills/docx/scripts/office/schemas/ecma/fouth-edition/opc-coreProperties.xsd delete mode 100644 src/crates/assembly/core/builtin_skills/docx/scripts/office/schemas/ecma/fouth-edition/opc-digSig.xsd delete mode 100644 src/crates/assembly/core/builtin_skills/docx/scripts/office/schemas/ecma/fouth-edition/opc-relationships.xsd delete mode 100644 src/crates/assembly/core/builtin_skills/docx/scripts/office/schemas/mce/mc.xsd delete mode 100644 src/crates/assembly/core/builtin_skills/docx/scripts/office/schemas/microsoft/wml-2010.xsd delete mode 100644 src/crates/assembly/core/builtin_skills/docx/scripts/office/schemas/microsoft/wml-2012.xsd delete mode 100644 src/crates/assembly/core/builtin_skills/docx/scripts/office/schemas/microsoft/wml-2018.xsd delete mode 100644 src/crates/assembly/core/builtin_skills/docx/scripts/office/schemas/microsoft/wml-cex-2018.xsd delete mode 100644 src/crates/assembly/core/builtin_skills/docx/scripts/office/schemas/microsoft/wml-cid-2016.xsd delete mode 100644 src/crates/assembly/core/builtin_skills/docx/scripts/office/schemas/microsoft/wml-sdtdatahash-2020.xsd delete mode 100644 src/crates/assembly/core/builtin_skills/docx/scripts/office/schemas/microsoft/wml-symex-2015.xsd delete mode 100644 src/crates/assembly/core/builtin_skills/docx/scripts/office/soffice.py delete mode 100755 src/crates/assembly/core/builtin_skills/docx/scripts/office/validate.py delete mode 100644 src/crates/assembly/core/builtin_skills/docx/scripts/office/validators/__init__.py delete mode 100644 src/crates/assembly/core/builtin_skills/docx/scripts/office/validators/base.py delete mode 100644 src/crates/assembly/core/builtin_skills/docx/scripts/office/validators/docx.py delete mode 100644 src/crates/assembly/core/builtin_skills/docx/scripts/office/validators/pptx.py delete mode 100644 src/crates/assembly/core/builtin_skills/docx/scripts/office/validators/redlining.py delete mode 100644 src/crates/assembly/core/builtin_skills/docx/scripts/templates/comments.xml delete mode 100644 src/crates/assembly/core/builtin_skills/docx/scripts/templates/commentsExtended.xml delete mode 100644 src/crates/assembly/core/builtin_skills/docx/scripts/templates/commentsExtensible.xml delete mode 100644 src/crates/assembly/core/builtin_skills/docx/scripts/templates/commentsIds.xml delete mode 100644 src/crates/assembly/core/builtin_skills/docx/scripts/templates/people.xml delete mode 100644 src/crates/assembly/core/builtin_skills/pdf/LICENSE.txt delete mode 100644 src/crates/assembly/core/builtin_skills/pdf/SKILL.md delete mode 100644 src/crates/assembly/core/builtin_skills/pdf/forms.md delete mode 100644 src/crates/assembly/core/builtin_skills/pdf/reference.md delete mode 100644 src/crates/assembly/core/builtin_skills/pdf/scripts/check_bounding_boxes.py delete mode 100644 src/crates/assembly/core/builtin_skills/pdf/scripts/check_fillable_fields.py delete mode 100644 src/crates/assembly/core/builtin_skills/pdf/scripts/convert_pdf_to_images.py delete mode 100644 src/crates/assembly/core/builtin_skills/pdf/scripts/create_validation_image.py delete mode 100644 src/crates/assembly/core/builtin_skills/pdf/scripts/extract_form_field_info.py delete mode 100755 src/crates/assembly/core/builtin_skills/pdf/scripts/extract_form_structure.py delete mode 100644 src/crates/assembly/core/builtin_skills/pdf/scripts/fill_fillable_fields.py delete mode 100644 src/crates/assembly/core/builtin_skills/pdf/scripts/fill_pdf_form_with_annotations.py delete mode 100644 src/crates/assembly/core/builtin_skills/pptx/LICENSE.txt delete mode 100644 src/crates/assembly/core/builtin_skills/pptx/SKILL.md delete mode 100644 src/crates/assembly/core/builtin_skills/pptx/scripts/__init__.py delete mode 100755 src/crates/assembly/core/builtin_skills/pptx/scripts/add_slide.py delete mode 100755 src/crates/assembly/core/builtin_skills/pptx/scripts/clean.py delete mode 100644 src/crates/assembly/core/builtin_skills/pptx/scripts/office/helpers/__init__.py delete mode 100644 src/crates/assembly/core/builtin_skills/pptx/scripts/office/helpers/pptx_chart.py delete mode 100644 src/crates/assembly/core/builtin_skills/pptx/scripts/office/helpers/pptx_slide.py delete mode 100644 src/crates/assembly/core/builtin_skills/pptx/scripts/office/helpers/pptx_theme.py delete mode 100644 src/crates/assembly/core/builtin_skills/pptx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-chart.xsd delete mode 100644 src/crates/assembly/core/builtin_skills/pptx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-chartDrawing.xsd delete mode 100644 src/crates/assembly/core/builtin_skills/pptx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-diagram.xsd delete mode 100644 src/crates/assembly/core/builtin_skills/pptx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-lockedCanvas.xsd delete mode 100644 src/crates/assembly/core/builtin_skills/pptx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-main.xsd delete mode 100644 src/crates/assembly/core/builtin_skills/pptx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-picture.xsd delete mode 100644 src/crates/assembly/core/builtin_skills/pptx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-spreadsheetDrawing.xsd delete mode 100644 src/crates/assembly/core/builtin_skills/pptx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-wordprocessingDrawing.xsd delete mode 100644 src/crates/assembly/core/builtin_skills/pptx/scripts/office/schemas/ISO-IEC29500-4_2016/pml.xsd delete mode 100644 src/crates/assembly/core/builtin_skills/pptx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-additionalCharacteristics.xsd delete mode 100644 src/crates/assembly/core/builtin_skills/pptx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-bibliography.xsd delete mode 100644 src/crates/assembly/core/builtin_skills/pptx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-commonSimpleTypes.xsd delete mode 100644 src/crates/assembly/core/builtin_skills/pptx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-customXmlDataProperties.xsd delete mode 100644 src/crates/assembly/core/builtin_skills/pptx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-customXmlSchemaProperties.xsd delete mode 100644 src/crates/assembly/core/builtin_skills/pptx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-documentPropertiesCustom.xsd delete mode 100644 src/crates/assembly/core/builtin_skills/pptx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-documentPropertiesExtended.xsd delete mode 100644 src/crates/assembly/core/builtin_skills/pptx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-documentPropertiesVariantTypes.xsd delete mode 100644 src/crates/assembly/core/builtin_skills/pptx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-math.xsd delete mode 100644 src/crates/assembly/core/builtin_skills/pptx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-relationshipReference.xsd delete mode 100644 src/crates/assembly/core/builtin_skills/pptx/scripts/office/schemas/ISO-IEC29500-4_2016/sml.xsd delete mode 100644 src/crates/assembly/core/builtin_skills/pptx/scripts/office/schemas/ISO-IEC29500-4_2016/vml-main.xsd delete mode 100644 src/crates/assembly/core/builtin_skills/pptx/scripts/office/schemas/ISO-IEC29500-4_2016/vml-officeDrawing.xsd delete mode 100644 src/crates/assembly/core/builtin_skills/pptx/scripts/office/schemas/ISO-IEC29500-4_2016/vml-presentationDrawing.xsd delete mode 100644 src/crates/assembly/core/builtin_skills/pptx/scripts/office/schemas/ISO-IEC29500-4_2016/vml-spreadsheetDrawing.xsd delete mode 100644 src/crates/assembly/core/builtin_skills/pptx/scripts/office/schemas/ISO-IEC29500-4_2016/vml-wordprocessingDrawing.xsd delete mode 100644 src/crates/assembly/core/builtin_skills/pptx/scripts/office/schemas/ISO-IEC29500-4_2016/wml.xsd delete mode 100644 src/crates/assembly/core/builtin_skills/pptx/scripts/office/schemas/ISO-IEC29500-4_2016/xml.xsd delete mode 100644 src/crates/assembly/core/builtin_skills/pptx/scripts/office/schemas/ecma/fouth-edition/opc-contentTypes.xsd delete mode 100644 src/crates/assembly/core/builtin_skills/pptx/scripts/office/schemas/ecma/fouth-edition/opc-coreProperties.xsd delete mode 100644 src/crates/assembly/core/builtin_skills/pptx/scripts/office/schemas/ecma/fouth-edition/opc-digSig.xsd delete mode 100644 src/crates/assembly/core/builtin_skills/pptx/scripts/office/schemas/ecma/fouth-edition/opc-relationships.xsd delete mode 100644 src/crates/assembly/core/builtin_skills/pptx/scripts/office/schemas/mce/mc.xsd delete mode 100644 src/crates/assembly/core/builtin_skills/pptx/scripts/office/schemas/microsoft/wml-2010.xsd delete mode 100644 src/crates/assembly/core/builtin_skills/pptx/scripts/office/schemas/microsoft/wml-2012.xsd delete mode 100644 src/crates/assembly/core/builtin_skills/pptx/scripts/office/schemas/microsoft/wml-2018.xsd delete mode 100644 src/crates/assembly/core/builtin_skills/pptx/scripts/office/schemas/microsoft/wml-cex-2018.xsd delete mode 100644 src/crates/assembly/core/builtin_skills/pptx/scripts/office/schemas/microsoft/wml-cid-2016.xsd delete mode 100644 src/crates/assembly/core/builtin_skills/pptx/scripts/office/schemas/microsoft/wml-sdtdatahash-2020.xsd delete mode 100644 src/crates/assembly/core/builtin_skills/pptx/scripts/office/schemas/microsoft/wml-symex-2015.xsd delete mode 100644 src/crates/assembly/core/builtin_skills/pptx/scripts/office/soffice.py delete mode 100755 src/crates/assembly/core/builtin_skills/pptx/scripts/office/validate.py delete mode 100644 src/crates/assembly/core/builtin_skills/pptx/scripts/office/validators/__init__.py delete mode 100644 src/crates/assembly/core/builtin_skills/pptx/scripts/office/validators/base.py delete mode 100644 src/crates/assembly/core/builtin_skills/pptx/scripts/office/validators/docx.py delete mode 100644 src/crates/assembly/core/builtin_skills/pptx/scripts/office/validators/pptx.py delete mode 100644 src/crates/assembly/core/builtin_skills/pptx/scripts/office/validators/redlining.py delete mode 100755 src/crates/assembly/core/builtin_skills/pptx/scripts/thumbnail.py create mode 100644 src/crates/assembly/core/builtin_skills/writing-skills/LICENSE.txt delete mode 100644 src/crates/assembly/core/builtin_skills/writing-skills/anthropic-best-practices.md delete mode 100644 src/crates/assembly/core/builtin_skills/xlsx/LICENSE.txt delete mode 100644 src/crates/assembly/core/builtin_skills/xlsx/SKILL.md delete mode 100644 src/crates/assembly/core/builtin_skills/xlsx/scripts/office/helpers/__init__.py delete mode 100644 src/crates/assembly/core/builtin_skills/xlsx/scripts/office/helpers/pptx_chart.py delete mode 100644 src/crates/assembly/core/builtin_skills/xlsx/scripts/office/helpers/pptx_slide.py delete mode 100644 src/crates/assembly/core/builtin_skills/xlsx/scripts/office/helpers/pptx_theme.py delete mode 100644 src/crates/assembly/core/builtin_skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-chart.xsd delete mode 100644 src/crates/assembly/core/builtin_skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-chartDrawing.xsd delete mode 100644 src/crates/assembly/core/builtin_skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-diagram.xsd delete mode 100644 src/crates/assembly/core/builtin_skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-lockedCanvas.xsd delete mode 100644 src/crates/assembly/core/builtin_skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-main.xsd delete mode 100644 src/crates/assembly/core/builtin_skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-picture.xsd delete mode 100644 src/crates/assembly/core/builtin_skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-spreadsheetDrawing.xsd delete mode 100644 src/crates/assembly/core/builtin_skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-wordprocessingDrawing.xsd delete mode 100644 src/crates/assembly/core/builtin_skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/pml.xsd delete mode 100644 src/crates/assembly/core/builtin_skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-additionalCharacteristics.xsd delete mode 100644 src/crates/assembly/core/builtin_skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-bibliography.xsd delete mode 100644 src/crates/assembly/core/builtin_skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-commonSimpleTypes.xsd delete mode 100644 src/crates/assembly/core/builtin_skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-customXmlDataProperties.xsd delete mode 100644 src/crates/assembly/core/builtin_skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-customXmlSchemaProperties.xsd delete mode 100644 src/crates/assembly/core/builtin_skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-documentPropertiesCustom.xsd delete mode 100644 src/crates/assembly/core/builtin_skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-documentPropertiesExtended.xsd delete mode 100644 src/crates/assembly/core/builtin_skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-documentPropertiesVariantTypes.xsd delete mode 100644 src/crates/assembly/core/builtin_skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-math.xsd delete mode 100644 src/crates/assembly/core/builtin_skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-relationshipReference.xsd delete mode 100644 src/crates/assembly/core/builtin_skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/sml.xsd delete mode 100644 src/crates/assembly/core/builtin_skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/vml-main.xsd delete mode 100644 src/crates/assembly/core/builtin_skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/vml-officeDrawing.xsd delete mode 100644 src/crates/assembly/core/builtin_skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/vml-presentationDrawing.xsd delete mode 100644 src/crates/assembly/core/builtin_skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/vml-spreadsheetDrawing.xsd delete mode 100644 src/crates/assembly/core/builtin_skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/vml-wordprocessingDrawing.xsd delete mode 100644 src/crates/assembly/core/builtin_skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/wml.xsd delete mode 100644 src/crates/assembly/core/builtin_skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/xml.xsd delete mode 100644 src/crates/assembly/core/builtin_skills/xlsx/scripts/office/schemas/ecma/fouth-edition/opc-contentTypes.xsd delete mode 100644 src/crates/assembly/core/builtin_skills/xlsx/scripts/office/schemas/ecma/fouth-edition/opc-coreProperties.xsd delete mode 100644 src/crates/assembly/core/builtin_skills/xlsx/scripts/office/schemas/ecma/fouth-edition/opc-digSig.xsd delete mode 100644 src/crates/assembly/core/builtin_skills/xlsx/scripts/office/schemas/ecma/fouth-edition/opc-relationships.xsd delete mode 100644 src/crates/assembly/core/builtin_skills/xlsx/scripts/office/schemas/mce/mc.xsd delete mode 100644 src/crates/assembly/core/builtin_skills/xlsx/scripts/office/schemas/microsoft/wml-2010.xsd delete mode 100644 src/crates/assembly/core/builtin_skills/xlsx/scripts/office/schemas/microsoft/wml-2012.xsd delete mode 100644 src/crates/assembly/core/builtin_skills/xlsx/scripts/office/schemas/microsoft/wml-2018.xsd delete mode 100644 src/crates/assembly/core/builtin_skills/xlsx/scripts/office/schemas/microsoft/wml-cex-2018.xsd delete mode 100644 src/crates/assembly/core/builtin_skills/xlsx/scripts/office/schemas/microsoft/wml-cid-2016.xsd delete mode 100644 src/crates/assembly/core/builtin_skills/xlsx/scripts/office/schemas/microsoft/wml-sdtdatahash-2020.xsd delete mode 100644 src/crates/assembly/core/builtin_skills/xlsx/scripts/office/schemas/microsoft/wml-symex-2015.xsd delete mode 100644 src/crates/assembly/core/builtin_skills/xlsx/scripts/office/soffice.py delete mode 100755 src/crates/assembly/core/builtin_skills/xlsx/scripts/office/validate.py delete mode 100644 src/crates/assembly/core/builtin_skills/xlsx/scripts/office/validators/__init__.py delete mode 100644 src/crates/assembly/core/builtin_skills/xlsx/scripts/office/validators/base.py delete mode 100644 src/crates/assembly/core/builtin_skills/xlsx/scripts/office/validators/docx.py delete mode 100644 src/crates/assembly/core/builtin_skills/xlsx/scripts/office/validators/pptx.py delete mode 100644 src/crates/assembly/core/builtin_skills/xlsx/scripts/office/validators/redlining.py delete mode 100755 src/crates/assembly/core/builtin_skills/xlsx/scripts/recalc.py delete mode 100644 src/crates/assembly/core/tests/office_archive_safety.py diff --git a/README.md b/README.md index 16a98a313e..7d3564a344 100644 --- a/README.md +++ b/README.md @@ -36,7 +36,7 @@ Writes code, produces documents, and drives the desktop — with Mini Apps, a Ru | **Agentic Mini Apps** | A task gets its own interface — chart, board, form, panel — with a conversation bound to that interface's live state | | **Self-hosted multi-device control** | Login, cross-device session sync, and controlling one device from another run through a relay you deploy. Zero-knowledge; no vendor cloud in the path | | **Coding** | Plan, edit, test, and commit inside real Git repositories. Agentic, Plan, Debug, Deep Review, long-horizon tasks | -| **Office work** | Research, writing, PPT, DOCX, XLSX, PDF, meeting notes, reports | +| **Office work** | Research, writing, presentations, meeting notes, reports | | **Desktop execution** | Browser, terminal, desktop applications, the filesystem, and remote workspaces | | **Four tiers of customization** | Custom Agents → MCP / Skills / Hooks → Mini Apps → source-level changes | | **Performance** | 98.67% average KV cache hit rate; flashgrep searches Chromium-scale trees ~36x faster | @@ -91,7 +91,7 @@ Two kinds of complex work: shipping code in real repositories, and turning sourc | Scenario | Delivery goal | Typical capabilities | | --- | --- | --- | | **Coding** | Move from a real repository to a mergeable result. | Agentic, Plan, Debug, testing, Git, Deep Review, long-horizon tasks, and benchmarks. | -| **Office Work** | Move from source material to deliverable documents. | Research, PPT, DOCX, XLSX, PDF, summarization, writing, meeting notes, and reports. | +| **Office Work** | Move from source material to useful written and visual deliverables. | Research, presentations, summarization, writing, meeting notes, and reports. | **Shared capabilities** diff --git a/README.zh-CN.md b/README.zh-CN.md index 27386405f4..53a4cb7ec1 100644 --- a/README.zh-CN.md +++ b/README.zh-CN.md @@ -36,7 +36,7 @@ | **Agentic Mini App** | 为任务生成专属界面——图表、看板、表单、面板——对话绑定该界面的实时状态 | | **自部署多设备互联互控** | 账号登录、跨设备会话同步、设备间操控,全部走你自己部署的 relay。零知识加密,不经第三方云 | | **编码交付** | 在真实 Git 仓库里规划、改代码、跑测试、提交。Agentic、Plan、Debug、Deep Review、长程任务 | -| **办公交付** | 调研、写作、PPT、DOCX、XLSX、PDF、会议纪要、报告 | +| **办公交付** | 调研、写作、演示文稿、会议纪要、报告 | | **桌面执行层** | 浏览器、终端、桌面软件、文件系统、远程工作区 | | **四层可定制** | 自定义 Agent → MCP / Skills / Hooks → Mini App → 源码级改造 | | **性能** | KV Cache 平均命中率 98.67%;flashgrep 在千万行仓库上搜索平均快约 36 倍 | @@ -91,7 +91,7 @@ pnpm run desktop:dev | 场景 | 目标交付 | 典型能力 | | --- | --- | --- | | **编码** | 从真实仓库推进到可合并结果。 | Agentic、Plan、Debug、测试、Git、Deep Review、长程任务、Benchmark。 | -| **办公** | 从资料推进到可交付文档。 | Research、PPT、DOCX、XLSX、PDF、总结、写作、会议纪要、报告。 | +| **办公** | 从资料推进到实用的文字和视觉交付物。 | 调研、演示文稿、总结、写作、会议纪要、报告。 | **通用能力** diff --git a/src/crates/assembly/core/builtin-skills-upstreams.json b/src/crates/assembly/core/builtin-skills-upstreams.json index d15e4a66f6..631b961269 100644 --- a/src/crates/assembly/core/builtin-skills-upstreams.json +++ b/src/crates/assembly/core/builtin-skills-upstreams.json @@ -2,18 +2,6 @@ "schema_version": 1, "synced_on": "2026-07-22", "sources": [ - { - "skills": ["docx", "pptx", "xlsx"], - "repository": "https://github.com/anthropics/skills", - "revision": "fa0fa64bdc967915dc8399e803be67759e1e62b8", - "local_patches": [ - "normalize upstream trailing whitespace", - "route documented archive editing through safe_extract and rezip", - "bound archive extraction and reject normalized-path collisions", - "use BitFun as the default Word comment author", - "retain the BitFun 2026 year-format example" - ] - }, { "skills": ["agent-browser"], "repository": "https://github.com/vercel-labs/agent-browser", diff --git a/src/crates/assembly/core/builtin_skills/docx/LICENSE.txt b/src/crates/assembly/core/builtin_skills/docx/LICENSE.txt deleted file mode 100644 index c55ab42224..0000000000 --- a/src/crates/assembly/core/builtin_skills/docx/LICENSE.txt +++ /dev/null @@ -1,30 +0,0 @@ -© 2025 Anthropic, PBC. All rights reserved. - -LICENSE: Use of these materials (including all code, prompts, assets, files, -and other components of this Skill) is governed by your agreement with -Anthropic regarding use of Anthropic's services. If no separate agreement -exists, use is governed by Anthropic's Consumer Terms of Service or -Commercial Terms of Service, as applicable: -https://www.anthropic.com/legal/consumer-terms -https://www.anthropic.com/legal/commercial-terms -Your applicable agreement is referred to as the "Agreement." "Services" are -as defined in the Agreement. - -ADDITIONAL RESTRICTIONS: Notwithstanding anything in the Agreement to the -contrary, users may not: - -- Extract these materials from the Services or retain copies of these - materials outside the Services -- Reproduce or copy these materials, except for temporary copies created - automatically during authorized use of the Services -- Create derivative works based on these materials -- Distribute, sublicense, or transfer these materials to any third party -- Make, offer to sell, sell, or import any inventions embodied in these - materials -- Reverse engineer, decompile, or disassemble these materials - -The receipt, viewing, or possession of these materials does not convey or -imply any license or right beyond those expressly granted above. - -Anthropic retains all right, title, and interest in these materials, -including all copyrights, patents, and other intellectual property rights. diff --git a/src/crates/assembly/core/builtin_skills/docx/SKILL.md b/src/crates/assembly/core/builtin_skills/docx/SKILL.md deleted file mode 100644 index ab3cbd09a5..0000000000 --- a/src/crates/assembly/core/builtin_skills/docx/SKILL.md +++ /dev/null @@ -1,92 +0,0 @@ ---- -name: docx -description: "Use this skill whenever the user wants to create, read, edit, or manipulate Word documents (.docx files) or Word templates (.dotx files). Triggers include: any mention of 'Word doc', 'word document', '.docx', '.dotx', or requests to produce professional documents with formatting like tables of contents, headings, page numbers, or letterheads. Also use when extracting or reorganizing content from .docx or .dotx files, inserting or replacing images in documents, performing find-and-replace in Word files, working with tracked changes or comments, or converting content into a polished Word document. If the user asks for a 'report', 'memo', 'letter', 'template', or similar deliverable as a Word or .docx file, use this skill. Do NOT use for PDFs, spreadsheets, Google Docs, or general coding tasks unrelated to document generation." -license: Proprietary. LICENSE.txt has complete terms ---- - -# DOCX creation, editing, and analysis - -A `.docx` is a ZIP archive of XML files. Choose your approach by task: - -| Task | Approach | -|---|---| -| **Create** a new document | Write a `docx` (npm) script — see gotchas below | -| **Edit** an existing document | `safe_extract` → edit `word/document.xml` → `rezip` (docx-js cannot open existing files) | -| **Read** content | `pandoc -t markdown file.docx` | - -> Script paths below are relative to this skill's directory. - -## Creating with docx-js — gotchas - -`docx` is preinstalled — do not run `npm install` first; write the script and `require('docx')` directly. Only if that require fails: `npm install docx`. The model knows the API; these are the footguns: - -- **Page size defaults to A4.** For US Letter set `page: { size: { width: 12240, height: 15840 } }` (DXA; 1440 = 1″). -- **Landscape:** pass portrait dimensions and `orientation: PageOrientation.LANDSCAPE` — docx-js swaps width/height internally. -- **Tables need dual widths:** set `columnWidths` on the table AND `width` on every cell, both in `WidthType.DXA` (PERCENTAGE breaks in Google Docs). Column widths must sum to the table width. -- **Table shading:** use `ShadingType.CLEAR`, never `SOLID` (renders black). -- **Lists:** never insert `•` literally; use a `numbering` config with `LevelFormat.BULLET`. -- **`ImageRun` requires `type:`** (`"png"`, `"jpg"`, …). -- **`PageBreak` must be inside a `Paragraph`.** -- **Never use `\n`** — use separate `Paragraph` elements. -- **TOC:** headings must use built-in `HeadingLevel.*`; custom heading styles need `outlineLevel` set or they won't appear. -- **Don't use a table as a horizontal rule** — use a paragraph bottom border instead. -- **Dot-leader / right-aligned-on-same-line:** use `PositionalTab` (`alignment: PositionalTabAlignment.RIGHT`, `leader: PositionalTabLeader.DOT`) inside a `TextRun`, not literal `.` or space padding. - -## Verify the output - -After writing a `.docx`, render it and look at it: - -```bash -python scripts/office/soffice.py --headless --convert-to pdf output.docx -pdftoppm -jpeg -r 100 output.pdf page -ls page-*.jpg # then Read the images -``` - -`pdftoppm` zero-pads page numbers to the width of the page count (`page-01.jpg`…`page-12.jpg`). - -## Editing existing documents - -Legacy `.doc` files must be converted first: `python scripts/office/soffice.py --headless --convert-to docx file.doc`. - -```bash -python -c "import sys,zipfile; from pathlib import Path; from scripts.office.helpers import safe_extract; zf=zipfile.ZipFile(sys.argv[1]); safe_extract(zf, Path(sys.argv[2])); zf.close()" doc.docx unpacked -python scripts/merge_runs.py unpacked/ # coalesce fragmented runs so text is findable -# edit unpacked/word/document.xml in place — do NOT reformat or pretty-print -python -c "from pathlib import Path; from scripts.office.helpers import rezip; rezip(Path('unpacked'), Path('out.docx'))" -python scripts/office/validate.py out.docx --original doc.docx # XSD checks; --auto-repair fixes common issues -# redlining? add --author "" to check every edit is tracked -``` - -Word splits text across many `` runs (revision ids, spell-check markers), so a phrase you can see in the document often doesn't exist as a contiguous string in the XML. `merge_runs.py` merges adjacent identically-formatted runs in `word/document.xml` without changing content or rendering; it also accepts a `.docx` directly (`python scripts/merge_runs.py doc.docx -o merged.docx`). - -Use "BitFun" as the author for tracked changes and comments unless the user explicitly requests a different name. - -**Tracked changes:** when redlining, validate with `--author ""` (needs `--original`) — it reports any text you changed without a ``/`` around it, which is easy to do by accident and invisible in the accepted view. Wrap runs in ``/`` with `w:id`, `w:author`, `w:date` attributes. Inside ``, the text element is ``, not ``. A deleted paragraph mark (``) means "merge this paragraph into the next" — so deleting a paragraph outright is that plus a `` around every run. The `` must come before the rPr's other children; their order is schema-enforced. - -To produce a clean copy with all tracked changes accepted: `python scripts/accept_changes.py in.docx out.docx`. - -Accepting a deleted paragraph mark should join that paragraph to the one below it, so a paragraph whose runs are *all* deleted vanishes. Word does this; `accept_changes.py` and `pandoc --track-changes=accept` don't always. Both fail the same way — they strip the deleted text but leave the emptied paragraph behind, which reads as a stray empty bullet when it was auto-numbered: - -- `pandoc --track-changes=accept` never joins the paragraphs. -- `accept_changes.py` (LibreOffice) joins them correctly, except when the deleted paragraph is followed by an empty spacer paragraph. - -An empty bullet in either view is an artifact of that view, not a defect in the document. Check paragraph deletions in the XML. - -## Comments - -Comments require six cross-linked files. Use the helper — directory mode when you'll also be editing `document.xml` (saves an unzip/rezip cycle), `.docx`-direct mode otherwise: - -```bash -# Against an already-unpacked directory (preferred when also placing markers) -python scripts/comment.py unpacked/ "Fees & expenses cap is too low" -python scripts/comment.py unpacked/ "Agreed" --parent 0 - -# Against a .docx directly -python scripts/comment.py contract.docx "This cap is too low" -o annotated.docx -``` - -The script writes `comments.xml`, `commentsExtended.xml`, `commentsIds.xml`, `commentsExtensible.xml`, the relationships, and the content-type overrides. Comment IDs are auto-assigned. It then prints the ``/``/`` snippet to add to `word/document.xml` so the comment anchors to specific text — until you place those markers, the comment exists but is not visible. - -## Dependencies - -`docx` (npm, preinstalled — install only if `require('docx')` fails) · `pandoc` · LibreOffice (`soffice`) · `pdftoppm` (Poppler) diff --git a/src/crates/assembly/core/builtin_skills/docx/scripts/__init__.py b/src/crates/assembly/core/builtin_skills/docx/scripts/__init__.py deleted file mode 100755 index 8b13789179..0000000000 --- a/src/crates/assembly/core/builtin_skills/docx/scripts/__init__.py +++ /dev/null @@ -1 +0,0 @@ - diff --git a/src/crates/assembly/core/builtin_skills/docx/scripts/accept_changes.py b/src/crates/assembly/core/builtin_skills/docx/scripts/accept_changes.py deleted file mode 100755 index 8e36316191..0000000000 --- a/src/crates/assembly/core/builtin_skills/docx/scripts/accept_changes.py +++ /dev/null @@ -1,135 +0,0 @@ -"""Accept all tracked changes in a DOCX file using LibreOffice. - -Requires LibreOffice (soffice) to be installed. -""" - -import argparse -import logging -import shutil -import subprocess -from pathlib import Path - -from office.soffice import get_soffice_env - -logger = logging.getLogger(__name__) - -LIBREOFFICE_PROFILE = "/tmp/libreoffice_docx_profile" -MACRO_DIR = f"{LIBREOFFICE_PROFILE}/user/basic/Standard" - -ACCEPT_CHANGES_MACRO = """ - - - Sub AcceptAllTrackedChanges() - Dim document As Object - Dim dispatcher As Object - - document = ThisComponent.CurrentController.Frame - dispatcher = createUnoService("com.sun.star.frame.DispatchHelper") - - dispatcher.executeDispatch(document, ".uno:AcceptAllTrackedChanges", "", 0, Array()) - ThisComponent.store() - ThisComponent.close(True) - End Sub -""" - - -def accept_changes( - input_file: str, - output_file: str, -) -> tuple[None, str]: - input_path = Path(input_file) - output_path = Path(output_file) - - if not input_path.exists(): - return None, f"Error: Input file not found: {input_file}" - - if not input_path.suffix.lower() == ".docx": - return None, f"Error: Input file is not a DOCX file: {input_file}" - - try: - output_path.parent.mkdir(parents=True, exist_ok=True) - shutil.copy2(input_path, output_path) - except Exception as e: - return None, f"Error: Failed to copy input file to output location: {e}" - - if not _setup_libreoffice_macro(): - return None, "Error: Failed to setup LibreOffice macro" - - cmd = [ - "soffice", - "--headless", - f"-env:UserInstallation=file://{LIBREOFFICE_PROFILE}", - "--norestore", - "vnd.sun.star.script:Standard.Module1.AcceptAllTrackedChanges?language=Basic&location=application", - str(output_path.absolute()), - ] - - try: - result = subprocess.run( - cmd, - capture_output=True, - text=True, - timeout=30, - check=False, - env=get_soffice_env(), - ) - except subprocess.TimeoutExpired: - return ( - None, - f"Successfully accepted all tracked changes: {input_file} -> {output_file}", - ) - - if result.returncode != 0: - return None, f"Error: LibreOffice failed: {result.stderr}" - - return ( - None, - f"Successfully accepted all tracked changes: {input_file} -> {output_file}", - ) - - -def _setup_libreoffice_macro() -> bool: - macro_dir = Path(MACRO_DIR) - macro_file = macro_dir / "Module1.xba" - - if macro_file.exists() and "AcceptAllTrackedChanges" in macro_file.read_text(): - return True - - if not macro_dir.exists(): - subprocess.run( - [ - "soffice", - "--headless", - f"-env:UserInstallation=file://{LIBREOFFICE_PROFILE}", - "--terminate_after_init", - ], - capture_output=True, - timeout=10, - check=False, - env=get_soffice_env(), - ) - macro_dir.mkdir(parents=True, exist_ok=True) - - try: - macro_file.write_text(ACCEPT_CHANGES_MACRO) - return True - except Exception as e: - logger.warning(f"Failed to setup LibreOffice macro: {e}") - return False - - -if __name__ == "__main__": - parser = argparse.ArgumentParser( - description="Accept all tracked changes in a DOCX file" - ) - parser.add_argument("input_file", help="Input DOCX file with tracked changes") - parser.add_argument( - "output_file", help="Output DOCX file (clean, no tracked changes)" - ) - args = parser.parse_args() - - _, message = accept_changes(args.input_file, args.output_file) - print(message) - - if "Error" in message: - raise SystemExit(1) diff --git a/src/crates/assembly/core/builtin_skills/docx/scripts/comment.py b/src/crates/assembly/core/builtin_skills/docx/scripts/comment.py deleted file mode 100755 index 7e16100192..0000000000 --- a/src/crates/assembly/core/builtin_skills/docx/scripts/comment.py +++ /dev/null @@ -1,368 +0,0 @@ -"""Add comments to a DOCX document. - -Accepts either an unpacked directory OR a .docx/.dotx file directly. - -Usage: - # Against an unpacked directory (writes satellite files in place) - python comment.py unpacked/ "Comment text" - python comment.py unpacked/ "Reply text" --parent 0 - - # Against a .docx directly (extracts, writes satellite files, rezips) - python comment.py contract.docx "This cap is too low" -o annotated.docx - python comment.py contract.docx "Comment" --id 5 # explicit ID - -The comment ID is auto-assigned (max existing + 1) unless --id is given. -Plain text is XML-escaped automatically; if you pass already-escaped text -(e.g. &, ’) use --raw to skip escaping. - -After running, add markers to word/document.xml so the comment is visible: - - ... commented content ... - - -""" - -import argparse -import random -import shutil -import sys -import tempfile -import zipfile -from datetime import datetime, timezone -from pathlib import Path - -import defusedxml.minidom -from xml.parsers.expat import ExpatError -from xml.sax.saxutils import escape as xml_escape - -from office.helpers import opc_target, rezip as _rezip, safe_extract as _safe_extract - -TEMPLATE_DIR = Path(__file__).parent / "templates" -NS = { - "w": "http://schemas.openxmlformats.org/wordprocessingml/2006/main", - "w14": "http://schemas.microsoft.com/office/word/2010/wordml", - "w15": "http://schemas.microsoft.com/office/word/2012/wordml", - "w16cid": "http://schemas.microsoft.com/office/word/2016/wordml/cid", - "w16cex": "http://schemas.microsoft.com/office/word/2018/wordml/cex", -} - -COMMENT_XML = """\ - - - - - - - - - - - - - {text} - - -""" - -COMMENT_MARKER_TEMPLATE = """ -Add to word/document.xml (markers must be direct children of w:p, never inside w:r): - - ... - - """ - -REPLY_MARKER_TEMPLATE = """ -Nest markers inside parent {pid}'s markers (direct children of w:p, never inside w:r): - - ... - - - """ - -SMART_QUOTE_ENTITIES = { - "“": "“", - "”": "”", - "‘": "‘", - "’": "’", -} - - -def _generate_hex_id() -> str: - return f"{random.randint(0, 0x7FFFFFFE):08X}" - - -def _encode_smart_quotes(text: str) -> str: - for char, entity in SMART_QUOTE_ENTITIES.items(): - text = text.replace(char, entity) - return text - - -def _append_xml(xml_path: Path, root_tag: str, content: str) -> None: - dom = defusedxml.minidom.parseString(xml_path.read_text(encoding="utf-8")) - root = dom.getElementsByTagName(root_tag)[0] - ns_attrs = " ".join(f'xmlns:{k}="{v}"' for k, v in NS.items()) - wrapper_dom = defusedxml.minidom.parseString(f"{content}") - for child in wrapper_dom.documentElement.childNodes: - if child.nodeType == child.ELEMENT_NODE: - root.appendChild(dom.importNode(child, True)) - output = _encode_smart_quotes(dom.toxml(encoding="UTF-8").decode("utf-8")) - xml_path.write_text(output, encoding="utf-8") - - -def _find_para_id(comments_path: Path, comment_id: int) -> str | None: - dom = defusedxml.minidom.parseString(comments_path.read_text(encoding="utf-8")) - for c in dom.getElementsByTagName("w:comment"): - if c.getAttribute("w:id") == str(comment_id): - for p in c.getElementsByTagName("w:p"): - if pid := p.getAttribute("w14:paraId"): - return pid - return None - - -def _next_comment_id(comments_path: Path) -> int: - if not comments_path.exists(): - return 0 - dom = defusedxml.minidom.parseString(comments_path.read_text(encoding="utf-8")) - ids = [] - for c in dom.getElementsByTagName("w:comment"): - try: - ids.append(int(c.getAttribute("w:id"))) - except ValueError: - pass - return (max(ids) + 1) if ids else 0 - - -def _get_next_rid(rels_path: Path) -> int: - dom = defusedxml.minidom.parseString(rels_path.read_text(encoding="utf-8")) - max_rid = 0 - for rel in dom.getElementsByTagName("Relationship"): - rid = rel.getAttribute("Id") - if rid and rid.startswith("rId"): - try: - max_rid = max(max_rid, int(rid[3:])) - except ValueError: - pass - return max_rid + 1 - - -def _has_relationship(rels_path: Path, target: str) -> bool: - dom = defusedxml.minidom.parseString(rels_path.read_text(encoding="utf-8")) - return any( - rel.getAttribute("Target") == target - for rel in dom.getElementsByTagName("Relationship") - ) - - -def _has_content_type(ct_path: Path, part_name: str) -> bool: - dom = defusedxml.minidom.parseString(ct_path.read_text(encoding="utf-8")) - return any( - o.getAttribute("PartName") == part_name - for o in dom.getElementsByTagName("Override") - ) - - -_COMMENT_RELS = [ - ("http://schemas.openxmlformats.org/officeDocument/2006/relationships/comments", "comments.xml"), - ("http://schemas.microsoft.com/office/2011/relationships/commentsExtended", "commentsExtended.xml"), - ("http://schemas.microsoft.com/office/2016/09/relationships/commentsIds", "commentsIds.xml"), - ("http://schemas.microsoft.com/office/2018/08/relationships/commentsExtensible", "commentsExtensible.xml"), -] -_COMMENT_OVERRIDES = [ - ("/word/comments.xml", "application/vnd.openxmlformats-officedocument.wordprocessingml.comments+xml"), - ("/word/commentsExtended.xml", "application/vnd.openxmlformats-officedocument.wordprocessingml.commentsExtended+xml"), - ("/word/commentsIds.xml", "application/vnd.openxmlformats-officedocument.wordprocessingml.commentsIds+xml"), - ("/word/commentsExtensible.xml", "application/vnd.openxmlformats-officedocument.wordprocessingml.commentsExtensible+xml"), -] - - -def _ensure_comment_relationships(unpacked_dir: Path) -> None: - rels_path = unpacked_dir / "word" / "_rels" / "document.xml.rels" - if not rels_path.exists(): - return - dom = defusedxml.minidom.parseString(rels_path.read_text(encoding="utf-8")) - root = dom.documentElement - comment_types = {rel_type for rel_type, _ in _COMMENT_RELS} - existing = set() - for rel in dom.getElementsByTagName("Relationship"): - if rel.getAttribute("Type") not in comment_types: - continue - part = opc_target( - rel.getAttribute("Target"), - "word/document.xml", - rel.getAttribute("TargetMode"), - ) - if part is not None: - existing.add(part) - next_rid = _get_next_rid(rels_path) - changed = False - for rel_type, target in _COMMENT_RELS: - if opc_target(target, "word/document.xml") in existing: - continue - rel = dom.createElement("Relationship") - rel.setAttribute("Id", f"rId{next_rid}") - rel.setAttribute("Type", rel_type) - rel.setAttribute("Target", target) - root.appendChild(rel) - next_rid += 1 - changed = True - if changed: - rels_path.write_bytes(dom.toxml(encoding="UTF-8")) - - -def _ensure_comment_content_types(unpacked_dir: Path) -> None: - ct_path = unpacked_dir / "[Content_Types].xml" - if not ct_path.exists(): - return - dom = defusedxml.minidom.parseString(ct_path.read_text(encoding="utf-8")) - root = dom.documentElement - existing = { - o.getAttribute("PartName") - for o in dom.getElementsByTagName("Override") - } - changed = False - for part_name, content_type in _COMMENT_OVERRIDES: - if part_name in existing: - continue - override = dom.createElement("Override") - override.setAttribute("PartName", part_name) - override.setAttribute("ContentType", content_type) - root.appendChild(override) - changed = True - if changed: - ct_path.write_bytes(dom.toxml(encoding="UTF-8")) - - -def add_comment( - unpacked_dir: Path | str, - text: str, - comment_id: int | None = None, - author: str = "BitFun", - initials: str = "B", - parent_id: int | None = None, - raw: bool = False, -) -> tuple[int, str, str]: - unpacked_dir = Path(unpacked_dir) - if not raw: - text = xml_escape(text) - author = xml_escape(author, {'"': """}) - initials = xml_escape(initials, {'"': """}) - word = unpacked_dir / "word" - if not word.exists(): - raise FileNotFoundError(f"{word} not found (not an unpacked .docx?)") - - comments = word / "comments.xml" - if comment_id is None: - comment_id = _next_comment_id(comments) - - parent_para = None - if parent_id is not None: - parent_para = _find_para_id(comments, parent_id) if comments.exists() else None - if not parent_para: - raise ValueError(f"parent comment {parent_id} not found") - - para_id, durable_id = _generate_hex_id(), _generate_hex_id() - ts = datetime.now(timezone.utc).strftime("%Y-%m-%dT%H:%M:%SZ") - - if not comments.exists(): - shutil.copy(TEMPLATE_DIR / "comments.xml", comments) - _ensure_comment_relationships(unpacked_dir) - _ensure_comment_content_types(unpacked_dir) - _append_xml( - comments, - "w:comments", - COMMENT_XML.format( - id=comment_id, author=author, date=ts, initials=initials, - para_id=para_id, text=text, - ), - ) - - ext = word / "commentsExtended.xml" - if not ext.exists(): - shutil.copy(TEMPLATE_DIR / "commentsExtended.xml", ext) - if parent_para is not None: - _append_xml( - ext, "w15:commentsEx", - f'', - ) - else: - _append_xml( - ext, "w15:commentsEx", - f'', - ) - - ids = word / "commentsIds.xml" - if not ids.exists(): - shutil.copy(TEMPLATE_DIR / "commentsIds.xml", ids) - _append_xml( - ids, "w16cid:commentsIds", - f'', - ) - - extensible = word / "commentsExtensible.xml" - if not extensible.exists(): - shutil.copy(TEMPLATE_DIR / "commentsExtensible.xml", extensible) - _append_xml( - extensible, "w16cex:commentsExtensible", - f'', - ) - - action = "reply" if parent_id is not None else "comment" - return comment_id, para_id, f"Added {action} id={comment_id} (paraId={para_id})" - - -def main() -> None: - p = argparse.ArgumentParser(description="Add a comment to a DOCX (directory or .docx file).") - p.add_argument("input", help="Unpacked DOCX directory OR a .docx/.dotx file") - p.add_argument("text", help="Comment text (plain text; XML-escaped automatically)") - p.add_argument("--raw", action="store_true", - help="Treat text as pre-escaped XML (skip automatic escaping)") - p.add_argument("--id", type=int, dest="comment_id", - help="Comment ID (default: auto-assign as max existing + 1)") - p.add_argument("--author", default="BitFun", help="Author name") - p.add_argument("--initials", default="B", help="Author initials") - p.add_argument("--parent", type=int, help="Parent comment ID (makes this a reply)") - p.add_argument("-o", "--output", - help="Output .docx path (only used when input is a .docx; default: overwrite input)") - args = p.parse_args() - - src = Path(args.input) - - try: - if src.is_dir(): - if args.output: - print("Warning: --output ignored for directory input", file=sys.stderr) - cid, _, msg = add_comment( - src, args.text, comment_id=args.comment_id, - author=args.author, initials=args.initials, - parent_id=args.parent, raw=args.raw, - ) - print(msg) - elif src.is_file() and src.suffix.lower() in (".docx", ".dotx"): - out = Path(args.output) if args.output else src - with tempfile.TemporaryDirectory() as tmp: - tmp_path = Path(tmp) - with zipfile.ZipFile(src) as zf: - _safe_extract(zf, tmp_path) - cid, _, msg = add_comment( - tmp_path, args.text, comment_id=args.comment_id, - author=args.author, initials=args.initials, - parent_id=args.parent, raw=args.raw, - ) - _rezip(tmp_path, out) - print(msg) - print(f"Wrote {out} (comment defined; add markers to word/document.xml to make it visible)") - else: - print(f"Error: {src} is neither a directory nor a .docx/.dotx file", file=sys.stderr) - sys.exit(1) - except (FileNotFoundError, ValueError, zipfile.BadZipFile, ExpatError) as e: - print(f"Error: {e}", file=sys.stderr) - sys.exit(1) - - if args.parent is not None: - print(REPLY_MARKER_TEMPLATE.format(pid=args.parent, cid=cid)) - else: - print(COMMENT_MARKER_TEMPLATE.format(cid=cid)) - - -if __name__ == "__main__": - main() diff --git a/src/crates/assembly/core/builtin_skills/docx/scripts/merge_runs.py b/src/crates/assembly/core/builtin_skills/docx/scripts/merge_runs.py deleted file mode 100755 index 977822929c..0000000000 --- a/src/crates/assembly/core/builtin_skills/docx/scripts/merge_runs.py +++ /dev/null @@ -1,310 +0,0 @@ -"""Merge adjacent identically-formatted runs in a DOCX. - -Word fragments paragraph text across many elements (revision ids, -spell-check markers, editing history), which makes find-and-replace on -word/document.xml unreliable — the string you're looking for is split -across runs. This coalesces adjacent runs whose formatting () is -identical, strips rsid attributes and proofErr markers, and consolidates the -text elements — , and for text inside a tracked deletion. - -Rendering is unchanged. The text you search is what Word draws, which is not -always the bytes in the file: an element without xml:space="preserve" has its -edge whitespace trimmed before it reaches the page, so `Hello ` -followed by `world` reads "Helloworld" and merges to exactly that. - -Runs in two different / wrappers are never merged: that would -rewrite tracked-change structure, collapsing separate revisions into one. - -Only word/document.xml is processed (not headers, footers, or footnotes). - -Usage: - python merge_runs.py unpacked/ # after unzip, before editing - python merge_runs.py document.docx # rewrite in place - python merge_runs.py document.docx -o out.docx -""" - - -import argparse -import sys -import tempfile -import zipfile -from pathlib import Path - -import defusedxml.minidom - -from office.helpers import XML_SPACE, rendered_text, rezip, safe_extract - -WORDML_NS = "http://schemas.openxmlformats.org/wordprocessingml/2006/main" - - -def merge_runs(input_dir: str) -> tuple[int, str]: - doc_xml = Path(input_dir) / "word" / "document.xml" - - if not doc_xml.exists(): - return 0, f"Error: {doc_xml} not found" - - try: - dom = defusedxml.minidom.parseString(doc_xml.read_text(encoding="utf-8")) - root = dom.documentElement - run_names = _run_tag_names(root) - - _remove_elements(root, "proofErr") - - runs = _find_runs(root, run_names) - _strip_rsid_attrs(runs) - - merge_count = 0 - for container in {run.parentNode for run in runs}: - merge_count += _merge_runs_in(container, run_names) - - doc_xml.write_bytes(dom.toxml(encoding="UTF-8")) - return merge_count, f"Merged {merge_count} runs" - - except Exception as e: - return 0, f"Error: {e}" - - - - -def _is_element(node, tag: str) -> bool: - name = node.localName or node.tagName - return name == tag or name.endswith(f":{tag}") - - -def _run_tag_names(root) -> set[str]: - names = set() - for attr in root.attributes.values(): - if attr.value == WORDML_NS: - if attr.name == "xmlns": - names.add("r") - elif attr.name.startswith("xmlns:"): - names.add(attr.name.split(":", 1)[1] + ":r") - return names or {"w:r", "r"} - - -def _find_elements(root, tag: str) -> list: - results = [] - - def traverse(node): - if node.nodeType == node.ELEMENT_NODE: - if _is_element(node, tag): - results.append(node) - for child in node.childNodes: - traverse(child) - - traverse(root) - return results - - -def _find_runs(root, run_names: set[str]) -> list: - return [e for e in _find_elements(root, "r") if _is_run(e, run_names)] - - -def _get_child(parent, tag: str): - return next(iter(_get_children(parent, tag)), None) - - -def _get_children(parent, tag: str) -> list: - return [ - child - for child in parent.childNodes - if child.nodeType == child.ELEMENT_NODE and _is_element(child, tag) - ] - - -def _is_adjacent(elem1, elem2) -> bool: - node = elem1.nextSibling - while node: - if node == elem2: - return True - if node.nodeType == node.ELEMENT_NODE: - return False - if node.nodeType == node.TEXT_NODE and node.data.strip(XML_SPACE): - return False - node = node.nextSibling - return False - - - - -def _remove_elements(root, tag: str): - for elem in _find_elements(root, tag): - if elem.parentNode: - elem.parentNode.removeChild(elem) - - -def _strip_rsid_attrs(runs: list): - for run in runs: - for attr in list(run.attributes.values()): - if "rsid" in attr.name.lower(): - run.removeAttribute(attr.name) - - - - -def _merge_runs_in(container, run_names: set[str]) -> int: - merge_count = 0 - run = _first_child_run(container, run_names) - - while run: - while True: - next_elem = _next_element_sibling(run) - if next_elem and _is_run(next_elem, run_names) and _can_merge(run, next_elem): - _merge_run_content(run, next_elem) - container.removeChild(next_elem) - merge_count += 1 - else: - break - - _consolidate_text(run) - run = _next_sibling_run(run, run_names) - - return merge_count - - -def _first_child_run(container, run_names: set[str]): - for child in container.childNodes: - if child.nodeType == child.ELEMENT_NODE and _is_run(child, run_names): - return child - return None - - -def _next_element_sibling(node): - sibling = node.nextSibling - while sibling: - if sibling.nodeType == sibling.ELEMENT_NODE: - return sibling - sibling = sibling.nextSibling - return None - - -def _next_sibling_run(node, run_names: set[str]): - sibling = node.nextSibling - while sibling: - if sibling.nodeType == sibling.ELEMENT_NODE: - if _is_run(sibling, run_names): - return sibling - sibling = sibling.nextSibling - return None - - -def _is_run(node, run_names: set[str]) -> bool: - return node.tagName in run_names - - -def _can_merge(run1, run2) -> bool: - rpr1 = _get_child(run1, "rPr") - rpr2 = _get_child(run2, "rPr") - - if (rpr1 is None) != (rpr2 is None): - return False - if rpr1 is None: - return True - return rpr1.toxml() == rpr2.toxml() - - -def _merge_run_content(target, source): - for child in list(source.childNodes): - if child.nodeType == child.ELEMENT_NODE: - name = child.localName or child.tagName - if name != "rPr" and not name.endswith(":rPr"): - target.appendChild(child) - - -def _element_text(elem) -> str: - return "".join( - child.data - for child in elem.childNodes - if child.nodeType in (child.TEXT_NODE, child.CDATA_SECTION_NODE) - ) - - -def _has_preserve(elem) -> bool: - return elem.getAttribute("xml:space") == "preserve" - - -def _rendered_text(elem) -> str: - return rendered_text(_element_text(elem), _has_preserve(elem)) - - -def _consolidate_text(run): - for tag in ("t", "delText"): - _consolidate_text_elements(run, tag) - - -def _consolidate_text_elements(run, tag: str): - t_elements = _get_children(run, tag) - - for i in range(len(t_elements) - 1, 0, -1): - curr, prev = t_elements[i], t_elements[i - 1] - - if _is_adjacent(prev, curr): - merged = _rendered_text(prev) + _rendered_text(curr) - had_preserve = _has_preserve(prev) or _has_preserve(curr) - - new_text = run.ownerDocument.createTextNode(merged) - for node in list(prev.childNodes): - if node.nodeType in (node.TEXT_NODE, node.CDATA_SECTION_NODE): - prev.removeChild(node) - else: - run.insertBefore(node, curr) - prev.appendChild(new_text) - for node in list(curr.childNodes): - if node.nodeType not in (node.TEXT_NODE, node.CDATA_SECTION_NODE): - run.insertBefore(node, curr) - - if merged != merged.strip(XML_SPACE) or had_preserve: - prev.setAttribute("xml:space", "preserve") - elif prev.hasAttribute("xml:space"): - prev.removeAttribute("xml:space") - - run.removeChild(curr) - - - - -def _merge_or_die(path: Path) -> str: - _, msg = merge_runs(str(path)) - if msg.startswith("Error"): - print(msg, file=sys.stderr) - sys.exit(1) - return msg - - -def main() -> None: - p = argparse.ArgumentParser( - description="Merge adjacent identically-formatted runs in a DOCX (directory or .docx file)." - ) - p.add_argument("input", help="Unpacked DOCX directory OR a .docx/.dotx file") - p.add_argument( - "-o", "--output", - help="Output .docx path (only valid when input is a .docx; default: overwrite input)", - ) - args = p.parse_args() - - src = Path(args.input) - - try: - if src.is_dir(): - if args.output: - p.error("--output is only valid for .docx input; directory input is modified in place") - print(_merge_or_die(src)) - elif src.is_file() and src.suffix.lower() in (".docx", ".dotx"): - out = Path(args.output) if args.output else src - with tempfile.TemporaryDirectory() as tmp: - tmp_path = Path(tmp) - with zipfile.ZipFile(src) as zf: - safe_extract(zf, tmp_path) - msg = _merge_or_die(tmp_path) - rezip(tmp_path, out) - print(f"{msg}; wrote {out}") - else: - print(f"Error: {src} is neither a directory nor a .docx/.dotx file", file=sys.stderr) - sys.exit(1) - except (OSError, ValueError, zipfile.BadZipFile) as e: - print(f"Error: {e}", file=sys.stderr) - sys.exit(1) - - -if __name__ == "__main__": - main() diff --git a/src/crates/assembly/core/builtin_skills/docx/scripts/office/helpers/__init__.py b/src/crates/assembly/core/builtin_skills/docx/scripts/office/helpers/__init__.py deleted file mode 100644 index 188b00aff4..0000000000 --- a/src/crates/assembly/core/builtin_skills/docx/scripts/office/helpers/__init__.py +++ /dev/null @@ -1,150 +0,0 @@ -import os -import posixpath -import re -import stat -import tempfile -import urllib.parse -import zipfile -from pathlib import Path - -OOXML_FAMILY = { - ".docx": "docx", - ".dotx": "docx", - ".pptx": "pptx", - ".potx": "pptx", - ".xlsx": "xlsx", - ".xltx": "xlsx", -} - -_SCHEME_RE = re.compile(r"^[A-Za-z][A-Za-z0-9+.\-]*:") - -SLIDE_REL_TYPE = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/slide" - -MAX_ARCHIVE_MEMBERS = 10_000 -MAX_ARCHIVE_MEMBER_SIZE = 1 * 1024 * 1024 * 1024 -MAX_ARCHIVE_TOTAL_SIZE = 4 * 1024 * 1024 * 1024 -MAX_ARCHIVE_COMPRESSION_RATIO = 1_000 - - -def opc_target(target: str, source_part: str, target_mode: str = "") -> str | None: - if not target: - return None - if target_mode.lower() == "external": - return None - if _SCHEME_RE.match(target): - return None - - target = urllib.parse.unquote(target) - - if "\\" in target: - raise ValueError(f"relationship target is not a POSIX part name: {target!r}") - - if target.startswith("/"): - joined = target.lstrip("/") - else: - joined = posixpath.join(posixpath.dirname(source_part), target) - - parts: list[str] = [] - for segment in posixpath.normpath(joined).split("/"): - if segment in ("", "."): - continue - if segment == "..": - if not parts: - raise ValueError(f"relationship target escapes the package: {target!r}") - parts.pop() - else: - parts.append(segment) - - if not parts: - raise ValueError(f"relationship target resolves to nothing: {target!r}") - return "/".join(parts) - - -def rels_source_part(rels_file: Path, unpacked_dir: Path) -> str: - owner_dir = rels_file.parent.parent.relative_to(unpacked_dir) - return posixpath.join(owner_dir.as_posix(), rels_file.name[: -len(".rels")]).lstrip("./") - - -def part_text(data: bytes) -> str: - return data.decode("utf-8", "surrogateescape") - - -XML_SPACE = " \t\r\n" - - -def rendered_text(text: str, preserve: bool) -> str: - return text if preserve else text.strip(XML_SPACE) - - -def safe_extract(zf: zipfile.ZipFile, dest: Path) -> None: - dest = dest.resolve() - members = zf.infolist() - if len(members) > MAX_ARCHIVE_MEMBERS: - raise ValueError(f"archive has too many entries: {len(members)}") - - total_size = 0 - targets: set[str] = set() - file_targets: set[str] = set() - validated: list[tuple[zipfile.ZipInfo, Path]] = [] - for m in members: - if stat.S_ISLNK(m.external_attr >> 16): - raise ValueError(f"symlink archive entry not allowed: {m.filename!r}") - target = (dest / m.filename).resolve() - if target == dest or not target.is_relative_to(dest): - raise ValueError(f"unsafe archive entry: {m.filename!r}") - target_key = os.path.normcase(str(target)) - if target_key in targets: - raise ValueError(f"duplicate archive entry: {m.filename!r}") - targets.add(target_key) - if not m.is_dir(): - file_targets.add(target_key) - validated.append((m, target)) - if m.file_size > MAX_ARCHIVE_MEMBER_SIZE: - raise ValueError(f"archive entry is too large: {m.filename!r}") - total_size += m.file_size - if total_size > MAX_ARCHIVE_TOTAL_SIZE: - raise ValueError("archive expands beyond the allowed total size") - if m.file_size and ( - m.compress_size == 0 - or m.file_size > m.compress_size * MAX_ARCHIVE_COMPRESSION_RATIO - ): - raise ValueError(f"archive entry has an unsafe compression ratio: {m.filename!r}") - - for m, target in validated: - for parent in target.parents: - if parent == dest: - break - if os.path.normcase(str(parent)) in file_targets: - raise ValueError(f"archive file entry conflicts with child path: {m.filename!r}") - - for m, _ in validated: - zf.extract(m, dest) - - -def rezip(src_dir: Path, out_path: Path) -> None: - files = sorted(p for p in src_dir.rglob("*") if p.is_file()) - ct = src_dir / "[Content_Types].xml" - fd, tmp_name = tempfile.mkstemp( - prefix=out_path.name + ".", suffix=".tmp", dir=out_path.parent - ) - tmp_out = Path(tmp_name) - try: - with os.fdopen(fd, "wb") as fh: - with zipfile.ZipFile(fh, "w", zipfile.ZIP_DEFLATED) as zf: - if ct.exists(): - zf.write(ct, ct.relative_to(src_dir), compress_type=zipfile.ZIP_STORED) - for f in files: - if f == ct: - continue - zf.write(f, f.relative_to(src_dir)) - if out_path.exists(): - mode = out_path.stat().st_mode & 0o777 - else: - umask = os.umask(0) - os.umask(umask) - mode = 0o666 & ~umask - os.chmod(tmp_out, mode) - os.replace(tmp_out, out_path) - finally: - if tmp_out.exists(): - tmp_out.unlink() diff --git a/src/crates/assembly/core/builtin_skills/docx/scripts/office/helpers/pptx_chart.py b/src/crates/assembly/core/builtin_skills/docx/scripts/office/helpers/pptx_chart.py deleted file mode 100644 index 209cb7c58b..0000000000 --- a/src/crates/assembly/core/builtin_skills/docx/scripts/office/helpers/pptx_chart.py +++ /dev/null @@ -1,170 +0,0 @@ -"""Find chart XML that PowerPoint refuses but the schema accepts. - -Detection only: for either fault more than one repair is valid, and only the -author knows which was meant. -""" - - -from __future__ import annotations - -import re -from typing import Mapping - -from . import part_text - - -_CHART_PART_RE = re.compile(r"ppt/charts/chart\d+\.xml") - -_GROUPING_RE = re.compile(r"""]*?\bval=["'](\w+)["']""") -_DLBL_POS_RE = re.compile(r"""]*?\bval=["'](\w+)["']""") - -def _strip_ext_lst(text: str) -> str: - out, cursor = [], 0 - for lo, hi in _ext_lst_spans(text): - out.append(text[cursor:lo]) - cursor = hi - out.append(text[cursor:]) - return "".join(out) - -_BAR_GROUP_RE = re.compile(r"]*(?.*?", re.DOTALL) - -STACKED_GROUPINGS = frozenset({"stacked", "percentStacked"}) -ILLEGAL_ON_STACKED = frozenset({"outEnd"}) -LEGAL_ON_STACKED = ("ctr", "inEnd", "inBase") - - -def _check_stacked_label_positions(part: str, xml: str) -> list[str]: - problems: list[str] = [] - for match in _BAR_GROUP_RE.finditer(xml): - block = _strip_ext_lst(match.group(0)) - group = match.group(1) - - grouping = _GROUPING_RE.search(block) - if grouping is None or grouping.group(1) not in STACKED_GROUPINGS: - continue - - bad = [p for p in _DLBL_POS_RE.findall(block) if p in ILLEGAL_ON_STACKED] - for pos in sorted(set(bad)): - problems.append( - f'{part}: {bad.count(pos)} data label(s) use dLblPos="{pos}" on a ' - f"{grouping.group(1)} {group}; PowerPoint allows only " - f"{', '.join(LEGAL_ON_STACKED)} there" - ) - return problems - - - -_ANY_CHART_GROUP_RE = re.compile(r"]*(?.*?", re.DOTALL) - -_AXID_RE = re.compile( - r"""\s*]*?\bval=["'](-?\d+)["']\s*(?:/>|>\s*)""" -) - -_AXIS_DECL_RE = re.compile( - r"""]*(?\s*]*?\bval=["'](-?\d+)["']""" -) - -AXID_LIMIT = { - "barChart": 2, "lineChart": 2, "areaChart": 2, "scatterChart": 2, - "bubbleChart": 2, "radarChart": 2, "stockChart": 2, - "bar3DChart": 3, "line3DChart": 3, "area3DChart": 3, - "surfaceChart": 3, "surface3DChart": 3, -} - -AXID_MINIMUM = { - "barChart": 2, "lineChart": 2, "areaChart": 2, "scatterChart": 2, - "bubbleChart": 2, "radarChart": 2, "stockChart": 2, - "bar3DChart": 2, "area3DChart": 2, "surfaceChart": 2, - "line3DChart": 3, "surface3DChart": 3, -} - - -def _declared_axes(xml: str) -> dict[str, list[str]]: - axes: dict[str, list[str]] = {} - for kind, axid in _AXIS_DECL_RE.findall(xml): - axes.setdefault(kind, []).append(axid) - return axes - - -def _canonical_ids(axes: dict[str, list[str]], limit: int) -> list[str] | None: - category = axes.get("catAx", []) + axes.get("dateAx", []) - value = axes.get("valAx", []) - series = axes.get("serAx", []) - if len(category) != 1 or len(value) != 1 or len(series) > 1: - return None - ids = [category[0], value[0]] - if limit >= 3 and series: - ids.append(series[0]) - return ids - - -def _undeclared_axes(kind: str, block: str, axes: dict[str, list[str]]) -> list[str] | None: - if kind not in AXID_LIMIT: - return None - ids = _AXID_RE.findall(block) - declared = {i for group in axes.values() for i in group} - if len([i for i in ids if i in declared]) >= 2: - return None - return ids - - -def _check_chart_axis_references(part: str, xml: str) -> list[str]: - axes = _declared_axes(xml) - problems: list[str] = [] - declared = {i for group in axes.values() for i in group} - for match in _ANY_CHART_GROUP_RE.finditer(xml): - kind, block = match.group(1), match.group(0) - ids = _undeclared_axes(kind, block, axes) - if ids is None: - continue - if not ids: - problems.append( - f"{part}: declares no this part can resolve; a chart " - f"group needs {AXID_MINIMUM[kind]}, and PowerPoint discards one with fewer" - ) - continue - dead = [i for i in ids if i not in declared] - canonical = _canonical_ids(axes, AXID_LIMIT[kind]) - if canonical is not None and len(canonical) >= AXID_MINIMUM[kind]: - hint = f"Fix: point them at the axes this part declares ({', '.join(canonical)})" - else: - hint = ("Fix: the part declares several axes of a kind -- declare the " - "secondary axes the series expects, or drop them") - detail = (f"of which {', '.join(dead)} name no declared axis" - if dead else f"only {len(ids)} of which this part declares") - problems.append( - f"{part}: references axId {', '.join(ids)}, {detail}, " - f"leaving fewer than two live axes; PowerPoint discards the chart. {hint}" - ) - return problems - - -def _ext_lst_spans(text: str) -> list[tuple[int, int]]: - spans: list[tuple[int, int]] = [] - depth = 0 - start = 0 - for match in re.finditer(r"<(/?)c:extLst\b[^>]*?(/?)>", text): - closing, self_closing = match.group(1), match.group(2) - if self_closing: - continue - if closing: - depth -= 1 - if depth == 0: - spans.append((start, match.end())) - else: - if depth == 0: - start = match.start() - depth += 1 - return spans - - -CHART_CHECKS = (_check_stacked_label_positions, _check_chart_axis_references) - - -def find_chart_problems(files: Mapping[str, bytes]) -> list[str]: - problems: list[str] = [] - for part in sorted(n for n in files if _CHART_PART_RE.fullmatch(n)): - xml = part_text(files[part]) - for check in CHART_CHECKS: - problems.extend(check(part, xml)) - return problems diff --git a/src/crates/assembly/core/builtin_skills/docx/scripts/office/helpers/pptx_slide.py b/src/crates/assembly/core/builtin_skills/docx/scripts/office/helpers/pptx_slide.py deleted file mode 100644 index 22f9aee0ff..0000000000 --- a/src/crates/assembly/core/builtin_skills/docx/scripts/office/helpers/pptx_slide.py +++ /dev/null @@ -1,60 +0,0 @@ -"""Pick the slide-XML schema errors PowerPoint refuses the file over. - -A denylist over lxml's messages, so an unrecognised error class is a miss rather -than a false alarm. -""" - - -from __future__ import annotations - -import re - -SLIDE_PART_RE = re.compile( - r"ppt/(slides|slideLayouts|slideMasters|notesSlides|notesMasters|handoutMasters)" - r"/[^/]+\.xml" -) - -FATAL_SLIDE_ERRORS: tuple[tuple[re.Pattern[str], str], ...] = ( - ( - re.compile(r"\}tableStyleId': This element is not expected"), - "two in one (the schema allows one)", - ), - ( - re.compile(r"\}srgbClr', attribute 'val'"), - "a colour that is not six hex digits", - ), - ( - re.compile(r"\}txBody': Missing child element"), - "a with no children", - ), - ( - re.compile(r"\}miter', attribute 'lim'"), - 'a line join with lim="NaN"', - ), - ( - re.compile(r"\}uLnTx': This element is not expected"), - " in a position the schema forbids", - ), - ( - re.compile(r"\}overrideClrMapping': This element is not expected"), - " in a position the schema forbids", - ), - ( - re.compile(r"\}nvGrpSpPr': Missing child element"), - "a with no children", - ), -) - - -def is_schema_verdict(error: str) -> bool: - return error.startswith("Element ") - - -def fatal_slide_errors(errors: set[str]) -> list[str]: - out = [] - for error in sorted(errors): - for pattern, meaning in FATAL_SLIDE_ERRORS: - if pattern.search(error): - out.append(f"{meaning}: {error}") - break - return out diff --git a/src/crates/assembly/core/builtin_skills/docx/scripts/office/helpers/pptx_theme.py b/src/crates/assembly/core/builtin_skills/docx/scripts/office/helpers/pptx_theme.py deleted file mode 100644 index 5ef4c3e835..0000000000 --- a/src/crates/assembly/core/builtin_skills/docx/scripts/office/helpers/pptx_theme.py +++ /dev/null @@ -1,114 +0,0 @@ -"""Find masters sharing a theme part in the way PowerPoint refuses to open. - -Reports only; the fix is to move back to directly after - in ppt/presentation.xml. -""" - - -from __future__ import annotations - -import posixpath -import re -from typing import Mapping - -from . import part_text - -THEME_REL_TYPE = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme" - -_MASTER_RE = re.compile( - r"^ppt/(?PslideMasters|notesMasters|handoutMasters)/" - r"(?:slide|notes|handout)Master(?P\d+)\.xml$" -) -_GROUP_ORDER = {"slideMasters": 0, "notesMasters": 1, "handoutMasters": 2} - -_RELATIONSHIP_RE = re.compile( - r"]*?(?:/>|>.*?)", re.DOTALL -) - - -def _sort_key(name: str) -> tuple[int, int]: - m = _MASTER_RE.match(name) - assert m is not None - return (_GROUP_ORDER[m.group("group")], int(m.group("num"))) - - -def _rels_path(part: str) -> str: - directory, base = posixpath.split(part) - return f"{directory}/_rels/{base}.rels" - - -def _resolve(rels_path: str, target: str) -> str: - if target.startswith("/"): - return target.lstrip("/") - part_dir = posixpath.dirname(posixpath.dirname(rels_path)) - return posixpath.normpath(posixpath.join(part_dir, target)) - - -def _theme_rel(files: Mapping[str, bytes], master: str): - rels_path = _rels_path(master) - rels = files.get(rels_path) - if rels is None: - return None - for element in _RELATIONSHIP_RE.findall(part_text(rels)): - if f'Type="{THEME_REL_TYPE}"' not in element: - continue - target = re.search(r'\bTarget="([^"]+)"', element) - if target is None: - continue - return rels_path, element, _resolve(rels_path, target.group(1)) - return None - - -def _masters(files: Mapping[str, bytes]) -> list[str]: - return sorted((n for n in files if _MASTER_RE.match(n)), key=_sort_key) - - -_PRESENTATION = "ppt/presentation.xml" -_NOTES_MASTERS = "ppt/notesMasters/" -_IGNORABLE_RE = re.compile(r"|<\?.*?\?>", re.DOTALL) -_AFTER_SLDIDLST_RE = re.compile( - r"]*/>|[^>]*>.*?)\s*(<[^>\s/]+)", re.DOTALL -) - - -def _notes_master_share_is_inert(files: Mapping[str, bytes]) -> bool: - data = files.get(_PRESENTATION) - if data is None: - return False - match = _AFTER_SLDIDLST_RE.search(_IGNORABLE_RE.sub("", part_text(data))) - return match is not None and match.group(1) == " bool: - return inert_notes and master.startswith(_NOTES_MASTERS) - - -def find_shared_master_themes(files: Mapping[str, bytes]) -> list[str]: - return [ - f"{master} shares {theme} with {first}" - for master, _, _, theme, first in _shares(files) - ] - - -def live_shared_master_themes(files: Mapping[str, bytes]) -> list[str]: - inert_notes = _notes_master_share_is_inert(files) - return [ - f"{master} shares {theme} with {first}" - for master, _, _, theme, first in _shares(files) - if not _is_inert(master, inert_notes) - ] diff --git a/src/crates/assembly/core/builtin_skills/docx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-chart.xsd b/src/crates/assembly/core/builtin_skills/docx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-chart.xsd deleted file mode 100644 index 6454ef9a94..0000000000 --- a/src/crates/assembly/core/builtin_skills/docx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-chart.xsd +++ /dev/null @@ -1,1499 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/crates/assembly/core/builtin_skills/docx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-chartDrawing.xsd b/src/crates/assembly/core/builtin_skills/docx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-chartDrawing.xsd deleted file mode 100644 index afa4f463e3..0000000000 --- a/src/crates/assembly/core/builtin_skills/docx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-chartDrawing.xsd +++ /dev/null @@ -1,146 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/crates/assembly/core/builtin_skills/docx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-diagram.xsd b/src/crates/assembly/core/builtin_skills/docx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-diagram.xsd deleted file mode 100644 index 64e66b8abd..0000000000 --- a/src/crates/assembly/core/builtin_skills/docx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-diagram.xsd +++ /dev/null @@ -1,1085 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/crates/assembly/core/builtin_skills/docx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-lockedCanvas.xsd b/src/crates/assembly/core/builtin_skills/docx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-lockedCanvas.xsd deleted file mode 100644 index 687eea8297..0000000000 --- a/src/crates/assembly/core/builtin_skills/docx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-lockedCanvas.xsd +++ /dev/null @@ -1,11 +0,0 @@ - - - - - diff --git a/src/crates/assembly/core/builtin_skills/docx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-main.xsd b/src/crates/assembly/core/builtin_skills/docx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-main.xsd deleted file mode 100644 index 6ac81b06b7..0000000000 --- a/src/crates/assembly/core/builtin_skills/docx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-main.xsd +++ /dev/null @@ -1,3081 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/crates/assembly/core/builtin_skills/docx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-picture.xsd b/src/crates/assembly/core/builtin_skills/docx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-picture.xsd deleted file mode 100644 index 1dbf05140d..0000000000 --- a/src/crates/assembly/core/builtin_skills/docx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-picture.xsd +++ /dev/null @@ -1,23 +0,0 @@ - - - - - - - - - - - - - - - - - - diff --git a/src/crates/assembly/core/builtin_skills/docx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-spreadsheetDrawing.xsd b/src/crates/assembly/core/builtin_skills/docx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-spreadsheetDrawing.xsd deleted file mode 100644 index f1af17db4e..0000000000 --- a/src/crates/assembly/core/builtin_skills/docx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-spreadsheetDrawing.xsd +++ /dev/null @@ -1,185 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/crates/assembly/core/builtin_skills/docx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-wordprocessingDrawing.xsd b/src/crates/assembly/core/builtin_skills/docx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-wordprocessingDrawing.xsd deleted file mode 100644 index 0a185ab6ed..0000000000 --- a/src/crates/assembly/core/builtin_skills/docx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-wordprocessingDrawing.xsd +++ /dev/null @@ -1,287 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/crates/assembly/core/builtin_skills/docx/scripts/office/schemas/ISO-IEC29500-4_2016/pml.xsd b/src/crates/assembly/core/builtin_skills/docx/scripts/office/schemas/ISO-IEC29500-4_2016/pml.xsd deleted file mode 100644 index 14ef488865..0000000000 --- a/src/crates/assembly/core/builtin_skills/docx/scripts/office/schemas/ISO-IEC29500-4_2016/pml.xsd +++ /dev/null @@ -1,1676 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/crates/assembly/core/builtin_skills/docx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-additionalCharacteristics.xsd b/src/crates/assembly/core/builtin_skills/docx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-additionalCharacteristics.xsd deleted file mode 100644 index c20f3bf147..0000000000 --- a/src/crates/assembly/core/builtin_skills/docx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-additionalCharacteristics.xsd +++ /dev/null @@ -1,28 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/crates/assembly/core/builtin_skills/docx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-bibliography.xsd b/src/crates/assembly/core/builtin_skills/docx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-bibliography.xsd deleted file mode 100644 index ac60252262..0000000000 --- a/src/crates/assembly/core/builtin_skills/docx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-bibliography.xsd +++ /dev/null @@ -1,144 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/crates/assembly/core/builtin_skills/docx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-commonSimpleTypes.xsd b/src/crates/assembly/core/builtin_skills/docx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-commonSimpleTypes.xsd deleted file mode 100644 index 424b8ba8d1..0000000000 --- a/src/crates/assembly/core/builtin_skills/docx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-commonSimpleTypes.xsd +++ /dev/null @@ -1,174 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/crates/assembly/core/builtin_skills/docx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-customXmlDataProperties.xsd b/src/crates/assembly/core/builtin_skills/docx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-customXmlDataProperties.xsd deleted file mode 100644 index 2bddce2921..0000000000 --- a/src/crates/assembly/core/builtin_skills/docx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-customXmlDataProperties.xsd +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - - - - - - - - - - - - - - diff --git a/src/crates/assembly/core/builtin_skills/docx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-customXmlSchemaProperties.xsd b/src/crates/assembly/core/builtin_skills/docx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-customXmlSchemaProperties.xsd deleted file mode 100644 index 8a8c18ba2d..0000000000 --- a/src/crates/assembly/core/builtin_skills/docx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-customXmlSchemaProperties.xsd +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - - - - - - - - - - diff --git a/src/crates/assembly/core/builtin_skills/docx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-documentPropertiesCustom.xsd b/src/crates/assembly/core/builtin_skills/docx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-documentPropertiesCustom.xsd deleted file mode 100644 index 5c42706a0d..0000000000 --- a/src/crates/assembly/core/builtin_skills/docx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-documentPropertiesCustom.xsd +++ /dev/null @@ -1,59 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/crates/assembly/core/builtin_skills/docx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-documentPropertiesExtended.xsd b/src/crates/assembly/core/builtin_skills/docx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-documentPropertiesExtended.xsd deleted file mode 100644 index 853c341c87..0000000000 --- a/src/crates/assembly/core/builtin_skills/docx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-documentPropertiesExtended.xsd +++ /dev/null @@ -1,56 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/crates/assembly/core/builtin_skills/docx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-documentPropertiesVariantTypes.xsd b/src/crates/assembly/core/builtin_skills/docx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-documentPropertiesVariantTypes.xsd deleted file mode 100644 index da835ee82d..0000000000 --- a/src/crates/assembly/core/builtin_skills/docx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-documentPropertiesVariantTypes.xsd +++ /dev/null @@ -1,195 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/crates/assembly/core/builtin_skills/docx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-math.xsd b/src/crates/assembly/core/builtin_skills/docx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-math.xsd deleted file mode 100644 index 87ad2658fa..0000000000 --- a/src/crates/assembly/core/builtin_skills/docx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-math.xsd +++ /dev/null @@ -1,582 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/crates/assembly/core/builtin_skills/docx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-relationshipReference.xsd b/src/crates/assembly/core/builtin_skills/docx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-relationshipReference.xsd deleted file mode 100644 index 9e86f1b2be..0000000000 --- a/src/crates/assembly/core/builtin_skills/docx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-relationshipReference.xsd +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - - - - - - - - - - - - - - - diff --git a/src/crates/assembly/core/builtin_skills/docx/scripts/office/schemas/ISO-IEC29500-4_2016/sml.xsd b/src/crates/assembly/core/builtin_skills/docx/scripts/office/schemas/ISO-IEC29500-4_2016/sml.xsd deleted file mode 100644 index d0be42e757..0000000000 --- a/src/crates/assembly/core/builtin_skills/docx/scripts/office/schemas/ISO-IEC29500-4_2016/sml.xsd +++ /dev/null @@ -1,4439 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/crates/assembly/core/builtin_skills/docx/scripts/office/schemas/ISO-IEC29500-4_2016/vml-main.xsd b/src/crates/assembly/core/builtin_skills/docx/scripts/office/schemas/ISO-IEC29500-4_2016/vml-main.xsd deleted file mode 100644 index 8821dd183c..0000000000 --- a/src/crates/assembly/core/builtin_skills/docx/scripts/office/schemas/ISO-IEC29500-4_2016/vml-main.xsd +++ /dev/null @@ -1,570 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/crates/assembly/core/builtin_skills/docx/scripts/office/schemas/ISO-IEC29500-4_2016/vml-officeDrawing.xsd b/src/crates/assembly/core/builtin_skills/docx/scripts/office/schemas/ISO-IEC29500-4_2016/vml-officeDrawing.xsd deleted file mode 100644 index ca2575c753..0000000000 --- a/src/crates/assembly/core/builtin_skills/docx/scripts/office/schemas/ISO-IEC29500-4_2016/vml-officeDrawing.xsd +++ /dev/null @@ -1,509 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/crates/assembly/core/builtin_skills/docx/scripts/office/schemas/ISO-IEC29500-4_2016/vml-presentationDrawing.xsd b/src/crates/assembly/core/builtin_skills/docx/scripts/office/schemas/ISO-IEC29500-4_2016/vml-presentationDrawing.xsd deleted file mode 100644 index dd079e603f..0000000000 --- a/src/crates/assembly/core/builtin_skills/docx/scripts/office/schemas/ISO-IEC29500-4_2016/vml-presentationDrawing.xsd +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - - diff --git a/src/crates/assembly/core/builtin_skills/docx/scripts/office/schemas/ISO-IEC29500-4_2016/vml-spreadsheetDrawing.xsd b/src/crates/assembly/core/builtin_skills/docx/scripts/office/schemas/ISO-IEC29500-4_2016/vml-spreadsheetDrawing.xsd deleted file mode 100644 index 3dd6cf625a..0000000000 --- a/src/crates/assembly/core/builtin_skills/docx/scripts/office/schemas/ISO-IEC29500-4_2016/vml-spreadsheetDrawing.xsd +++ /dev/null @@ -1,108 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/crates/assembly/core/builtin_skills/docx/scripts/office/schemas/ISO-IEC29500-4_2016/vml-wordprocessingDrawing.xsd b/src/crates/assembly/core/builtin_skills/docx/scripts/office/schemas/ISO-IEC29500-4_2016/vml-wordprocessingDrawing.xsd deleted file mode 100644 index f1041e34ef..0000000000 --- a/src/crates/assembly/core/builtin_skills/docx/scripts/office/schemas/ISO-IEC29500-4_2016/vml-wordprocessingDrawing.xsd +++ /dev/null @@ -1,96 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/crates/assembly/core/builtin_skills/docx/scripts/office/schemas/ISO-IEC29500-4_2016/wml.xsd b/src/crates/assembly/core/builtin_skills/docx/scripts/office/schemas/ISO-IEC29500-4_2016/wml.xsd deleted file mode 100644 index 9c5b7a6334..0000000000 --- a/src/crates/assembly/core/builtin_skills/docx/scripts/office/schemas/ISO-IEC29500-4_2016/wml.xsd +++ /dev/null @@ -1,3646 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/crates/assembly/core/builtin_skills/docx/scripts/office/schemas/ISO-IEC29500-4_2016/xml.xsd b/src/crates/assembly/core/builtin_skills/docx/scripts/office/schemas/ISO-IEC29500-4_2016/xml.xsd deleted file mode 100644 index 0f13678d80..0000000000 --- a/src/crates/assembly/core/builtin_skills/docx/scripts/office/schemas/ISO-IEC29500-4_2016/xml.xsd +++ /dev/null @@ -1,116 +0,0 @@ - - - - - - See http://www.w3.org/XML/1998/namespace.html and - http://www.w3.org/TR/REC-xml for information about this namespace. - - This schema document describes the XML namespace, in a form - suitable for import by other schema documents. - - Note that local names in this namespace are intended to be defined - only by the World Wide Web Consortium or its subgroups. The - following names are currently defined in this namespace and should - not be used with conflicting semantics by any Working Group, - specification, or document instance: - - base (as an attribute name): denotes an attribute whose value - provides a URI to be used as the base for interpreting any - relative URIs in the scope of the element on which it - appears; its value is inherited. This name is reserved - by virtue of its definition in the XML Base specification. - - lang (as an attribute name): denotes an attribute whose value - is a language code for the natural language of the content of - any element; its value is inherited. This name is reserved - by virtue of its definition in the XML specification. - - space (as an attribute name): denotes an attribute whose - value is a keyword indicating what whitespace processing - discipline is intended for the content of the element; its - value is inherited. This name is reserved by virtue of its - definition in the XML specification. - - Father (in any context at all): denotes Jon Bosak, the chair of - the original XML Working Group. This name is reserved by - the following decision of the W3C XML Plenary and - XML Coordination groups: - - In appreciation for his vision, leadership and dedication - the W3C XML Plenary on this 10th day of February, 2000 - reserves for Jon Bosak in perpetuity the XML name - xml:Father - - - - - This schema defines attributes and an attribute group - suitable for use by - schemas wishing to allow xml:base, xml:lang or xml:space attributes - on elements they define. - - To enable this, such a schema must import this schema - for the XML namespace, e.g. as follows: - <schema . . .> - . . . - <import namespace="http://www.w3.org/XML/1998/namespace" - schemaLocation="http://www.w3.org/2001/03/xml.xsd"/> - - Subsequently, qualified reference to any of the attributes - or the group defined below will have the desired effect, e.g. - - <type . . .> - . . . - <attributeGroup ref="xml:specialAttrs"/> - - will define a type which will schema-validate an instance - element with any of those attributes - - - - In keeping with the XML Schema WG's standard versioning - policy, this schema document will persist at - http://www.w3.org/2001/03/xml.xsd. - At the date of issue it can also be found at - http://www.w3.org/2001/xml.xsd. - The schema document at that URI may however change in the future, - in order to remain compatible with the latest version of XML Schema - itself. In other words, if the XML Schema namespace changes, the version - of this document at - http://www.w3.org/2001/xml.xsd will change - accordingly; the version at - http://www.w3.org/2001/03/xml.xsd will not change. - - - - - - In due course, we should install the relevant ISO 2- and 3-letter - codes as the enumerated possible values . . . - - - - - - - - - - - - - - - See http://www.w3.org/TR/xmlbase/ for - information about this attribute. - - - - - - - - - - diff --git a/src/crates/assembly/core/builtin_skills/docx/scripts/office/schemas/ecma/fouth-edition/opc-contentTypes.xsd b/src/crates/assembly/core/builtin_skills/docx/scripts/office/schemas/ecma/fouth-edition/opc-contentTypes.xsd deleted file mode 100644 index a6de9d2733..0000000000 --- a/src/crates/assembly/core/builtin_skills/docx/scripts/office/schemas/ecma/fouth-edition/opc-contentTypes.xsd +++ /dev/null @@ -1,42 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/crates/assembly/core/builtin_skills/docx/scripts/office/schemas/ecma/fouth-edition/opc-coreProperties.xsd b/src/crates/assembly/core/builtin_skills/docx/scripts/office/schemas/ecma/fouth-edition/opc-coreProperties.xsd deleted file mode 100644 index 10e978b661..0000000000 --- a/src/crates/assembly/core/builtin_skills/docx/scripts/office/schemas/ecma/fouth-edition/opc-coreProperties.xsd +++ /dev/null @@ -1,50 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/crates/assembly/core/builtin_skills/docx/scripts/office/schemas/ecma/fouth-edition/opc-digSig.xsd b/src/crates/assembly/core/builtin_skills/docx/scripts/office/schemas/ecma/fouth-edition/opc-digSig.xsd deleted file mode 100644 index 4248bf7a39..0000000000 --- a/src/crates/assembly/core/builtin_skills/docx/scripts/office/schemas/ecma/fouth-edition/opc-digSig.xsd +++ /dev/null @@ -1,49 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/crates/assembly/core/builtin_skills/docx/scripts/office/schemas/ecma/fouth-edition/opc-relationships.xsd b/src/crates/assembly/core/builtin_skills/docx/scripts/office/schemas/ecma/fouth-edition/opc-relationships.xsd deleted file mode 100644 index 5649746712..0000000000 --- a/src/crates/assembly/core/builtin_skills/docx/scripts/office/schemas/ecma/fouth-edition/opc-relationships.xsd +++ /dev/null @@ -1,33 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/crates/assembly/core/builtin_skills/docx/scripts/office/schemas/mce/mc.xsd b/src/crates/assembly/core/builtin_skills/docx/scripts/office/schemas/mce/mc.xsd deleted file mode 100644 index ef725457cf..0000000000 --- a/src/crates/assembly/core/builtin_skills/docx/scripts/office/schemas/mce/mc.xsd +++ /dev/null @@ -1,75 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/crates/assembly/core/builtin_skills/docx/scripts/office/schemas/microsoft/wml-2010.xsd b/src/crates/assembly/core/builtin_skills/docx/scripts/office/schemas/microsoft/wml-2010.xsd deleted file mode 100644 index f65f777730..0000000000 --- a/src/crates/assembly/core/builtin_skills/docx/scripts/office/schemas/microsoft/wml-2010.xsd +++ /dev/null @@ -1,560 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/crates/assembly/core/builtin_skills/docx/scripts/office/schemas/microsoft/wml-2012.xsd b/src/crates/assembly/core/builtin_skills/docx/scripts/office/schemas/microsoft/wml-2012.xsd deleted file mode 100644 index 6b00755a9a..0000000000 --- a/src/crates/assembly/core/builtin_skills/docx/scripts/office/schemas/microsoft/wml-2012.xsd +++ /dev/null @@ -1,67 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/crates/assembly/core/builtin_skills/docx/scripts/office/schemas/microsoft/wml-2018.xsd b/src/crates/assembly/core/builtin_skills/docx/scripts/office/schemas/microsoft/wml-2018.xsd deleted file mode 100644 index f321d333a5..0000000000 --- a/src/crates/assembly/core/builtin_skills/docx/scripts/office/schemas/microsoft/wml-2018.xsd +++ /dev/null @@ -1,14 +0,0 @@ - - - - - - - - - - - - - - diff --git a/src/crates/assembly/core/builtin_skills/docx/scripts/office/schemas/microsoft/wml-cex-2018.xsd b/src/crates/assembly/core/builtin_skills/docx/scripts/office/schemas/microsoft/wml-cex-2018.xsd deleted file mode 100644 index 364c6a9b8d..0000000000 --- a/src/crates/assembly/core/builtin_skills/docx/scripts/office/schemas/microsoft/wml-cex-2018.xsd +++ /dev/null @@ -1,20 +0,0 @@ - - - - - - - - - - - - - - - - - - - - diff --git a/src/crates/assembly/core/builtin_skills/docx/scripts/office/schemas/microsoft/wml-cid-2016.xsd b/src/crates/assembly/core/builtin_skills/docx/scripts/office/schemas/microsoft/wml-cid-2016.xsd deleted file mode 100644 index fed9d15b7f..0000000000 --- a/src/crates/assembly/core/builtin_skills/docx/scripts/office/schemas/microsoft/wml-cid-2016.xsd +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - diff --git a/src/crates/assembly/core/builtin_skills/docx/scripts/office/schemas/microsoft/wml-sdtdatahash-2020.xsd b/src/crates/assembly/core/builtin_skills/docx/scripts/office/schemas/microsoft/wml-sdtdatahash-2020.xsd deleted file mode 100644 index 680cf15400..0000000000 --- a/src/crates/assembly/core/builtin_skills/docx/scripts/office/schemas/microsoft/wml-sdtdatahash-2020.xsd +++ /dev/null @@ -1,4 +0,0 @@ - - - - diff --git a/src/crates/assembly/core/builtin_skills/docx/scripts/office/schemas/microsoft/wml-symex-2015.xsd b/src/crates/assembly/core/builtin_skills/docx/scripts/office/schemas/microsoft/wml-symex-2015.xsd deleted file mode 100644 index 89ada90837..0000000000 --- a/src/crates/assembly/core/builtin_skills/docx/scripts/office/schemas/microsoft/wml-symex-2015.xsd +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - diff --git a/src/crates/assembly/core/builtin_skills/docx/scripts/office/soffice.py b/src/crates/assembly/core/builtin_skills/docx/scripts/office/soffice.py deleted file mode 100644 index 0b4c99deca..0000000000 --- a/src/crates/assembly/core/builtin_skills/docx/scripts/office/soffice.py +++ /dev/null @@ -1,192 +0,0 @@ -""" -Helper for running LibreOffice (soffice) in environments where AF_UNIX -sockets may be blocked (e.g., sandboxed VMs). Detects the restriction -at runtime and applies an LD_PRELOAD shim if needed. - -Usage: - from office.soffice import run_soffice - - result = run_soffice(["--headless", "--convert-to", "pdf", "input.docx"]) - -Call soffice through run_soffice, not through subprocess with get_soffice_env(): -the env dict carries the shim but names no user profile, and a non-root sandbox -cannot bootstrap the default one -- soffice aborts with "User installation could -not be completed" and converts nothing. get_soffice_env() stays public for the -callers that build their own argv (they must pass -env:UserInstallation too). -""" - -import contextlib -import os -import socket -import subprocess -import tempfile -from collections.abc import Iterable -from pathlib import Path - - -def get_soffice_env() -> dict: - env = os.environ.copy() - env["SAL_USE_VCLPLUGIN"] = "svp" - - if _needs_shim(): - shim = _ensure_shim() - env["LD_PRELOAD"] = str(shim) - - return env - - -def run_soffice(args: Iterable[str], **kwargs) -> subprocess.CompletedProcess: - args = list(args) - with contextlib.ExitStack() as stack: - if not any(str(a).startswith("-env:UserInstallation") for a in args): - profile = stack.enter_context( - tempfile.TemporaryDirectory(prefix="lo_profile_", ignore_cleanup_errors=True) - ) - args = [f"-env:UserInstallation={Path(profile).as_uri()}"] + args - return subprocess.run(["soffice"] + args, env=get_soffice_env(), **kwargs) - - - -_SHIM_SO = Path(tempfile.gettempdir()) / "lo_socket_shim.so" - - -def _needs_shim() -> bool: - try: - s = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) - s.close() - return False - except OSError: - return True - - -def _ensure_shim() -> Path: - if _SHIM_SO.exists(): - return _SHIM_SO - - src = Path(tempfile.gettempdir()) / "lo_socket_shim.c" - src.write_text(_SHIM_SOURCE) - subprocess.run( - ["gcc", "-shared", "-fPIC", "-o", str(_SHIM_SO), str(src), "-ldl"], - check=True, - capture_output=True, - ) - src.unlink() - return _SHIM_SO - - - -_SHIM_SOURCE = r""" -#define _GNU_SOURCE -#include -#include -#include -#include -#include -#include -#include - -static int (*real_socket)(int, int, int); -static int (*real_socketpair)(int, int, int, int[2]); -static int (*real_listen)(int, int); -static int (*real_accept)(int, struct sockaddr *, socklen_t *); -static int (*real_close)(int); -static int (*real_read)(int, void *, size_t); - -/* Per-FD bookkeeping (FDs >= 1024 are passed through unshimmed). */ -static int is_shimmed[1024]; -static int peer_of[1024]; -static int wake_r[1024]; /* accept() blocks reading this */ -static int wake_w[1024]; /* close() writes to this */ -static int listener_fd = -1; /* FD that received listen() */ - -__attribute__((constructor)) -static void init(void) { - real_socket = dlsym(RTLD_NEXT, "socket"); - real_socketpair = dlsym(RTLD_NEXT, "socketpair"); - real_listen = dlsym(RTLD_NEXT, "listen"); - real_accept = dlsym(RTLD_NEXT, "accept"); - real_close = dlsym(RTLD_NEXT, "close"); - real_read = dlsym(RTLD_NEXT, "read"); - for (int i = 0; i < 1024; i++) { - peer_of[i] = -1; - wake_r[i] = -1; - wake_w[i] = -1; - } -} - -/* ---- socket ---------------------------------------------------------- */ -int socket(int domain, int type, int protocol) { - if (domain == AF_UNIX) { - int fd = real_socket(domain, type, protocol); - if (fd >= 0) return fd; - /* socket(AF_UNIX) blocked – fall back to socketpair(). */ - int sv[2]; - if (real_socketpair(domain, type, protocol, sv) == 0) { - if (sv[0] >= 0 && sv[0] < 1024) { - is_shimmed[sv[0]] = 1; - peer_of[sv[0]] = sv[1]; - int wp[2]; - if (pipe(wp) == 0) { - wake_r[sv[0]] = wp[0]; - wake_w[sv[0]] = wp[1]; - } - } - return sv[0]; - } - errno = EPERM; - return -1; - } - return real_socket(domain, type, protocol); -} - -/* ---- listen ---------------------------------------------------------- */ -int listen(int sockfd, int backlog) { - if (sockfd >= 0 && sockfd < 1024 && is_shimmed[sockfd]) { - listener_fd = sockfd; - return 0; - } - return real_listen(sockfd, backlog); -} - -/* ---- accept ---------------------------------------------------------- */ -int accept(int sockfd, struct sockaddr *addr, socklen_t *addrlen) { - if (sockfd >= 0 && sockfd < 1024 && is_shimmed[sockfd]) { - /* Block until close() writes to the wake pipe. */ - if (wake_r[sockfd] >= 0) { - char buf; - real_read(wake_r[sockfd], &buf, 1); - } - errno = ECONNABORTED; - return -1; - } - return real_accept(sockfd, addr, addrlen); -} - -/* ---- close ----------------------------------------------------------- */ -int close(int fd) { - if (fd >= 0 && fd < 1024 && is_shimmed[fd]) { - int was_listener = (fd == listener_fd); - is_shimmed[fd] = 0; - - if (wake_w[fd] >= 0) { /* unblock accept() */ - char c = 0; - write(wake_w[fd], &c, 1); - real_close(wake_w[fd]); - wake_w[fd] = -1; - } - if (wake_r[fd] >= 0) { real_close(wake_r[fd]); wake_r[fd] = -1; } - if (peer_of[fd] >= 0) { real_close(peer_of[fd]); peer_of[fd] = -1; } - - if (was_listener) - _exit(0); /* conversion done – exit */ - } - return real_close(fd); -} -""" - - - -if __name__ == "__main__": - import sys - result = run_soffice(sys.argv[1:]) - sys.exit(result.returncode) diff --git a/src/crates/assembly/core/builtin_skills/docx/scripts/office/validate.py b/src/crates/assembly/core/builtin_skills/docx/scripts/office/validate.py deleted file mode 100755 index 8fbd2f71ca..0000000000 --- a/src/crates/assembly/core/builtin_skills/docx/scripts/office/validate.py +++ /dev/null @@ -1,173 +0,0 @@ -""" -Command line tool to validate Office document XML files against XSD schemas and tracked changes. - -Usage: - python validate.py [--original ] [--auto-repair] [--author NAME] - -The first argument can be either: -- An unpacked directory containing the Office document XML files -- A packed Office file (.docx/.pptx/.xlsx or .dotx/.potx/.xltx template) which will be unpacked to a temp directory - -Auto-repair fixes: -- paraId/durableId values that exceed OOXML limits -- Missing xml:space="preserve" on w:t elements with whitespace -""" - -import argparse -import sys -import tempfile -import zipfile -from pathlib import Path - -import defusedxml.ElementTree as ET -from defusedxml.common import DefusedXmlException - -from helpers import OOXML_FAMILY, rezip, safe_extract -from validators import DOCXSchemaValidator, PPTXSchemaValidator, RedliningValidator - -WORD_NS = "http://schemas.openxmlformats.org/wordprocessingml/2006/main" - - -def _fail(message: str): - print(f"Error: {message}", file=sys.stderr) - sys.exit(2) - - -def _has_tracked_changes(unpacked_dir: Path) -> bool: - document = unpacked_dir / "word" / "document.xml" - if not document.is_file(): - return False - try: - root = ET.parse(document).getroot() - except (ET.ParseError, DefusedXmlException): - return False - tracked = {f"{{{WORD_NS}}}ins", f"{{{WORD_NS}}}del"} - return any(elem.tag in tracked for elem in root.iter()) - - -def main(): - parser = argparse.ArgumentParser(description="Validate Office document XML files") - parser.add_argument( - "path", - help="Path to unpacked directory or packed Office file (.docx/.pptx/.xlsx or .dotx/.potx/.xltx)", - ) - parser.add_argument( - "--original", - required=False, - default=None, - help="Path to original file (.docx/.pptx/.xlsx or .dotx/.potx/.xltx). If omitted, all XSD errors are reported and redlining validation is skipped.", - ) - parser.add_argument( - "-v", - "--verbose", - action="store_true", - help="Enable verbose output", - ) - parser.add_argument( - "--auto-repair", - action="store_true", - help="Automatically repair common issues (hex IDs, whitespace preservation). " - "Modifies the input in place: repairs to a packed file are written back to it.", - ) - parser.add_argument( - "--author", - default=None, - help="The name you are redlining under. Passing it turns on the " - "tracked-change check: any text differing from --original without a " - "/ recording it is reported. Untracked edits carry no " - "author, so the check covers them whoever made them — the name marks " - "the run as redlining work and is not used to filter. Requires " - "--original; docx only.", - ) - args = parser.parse_args() - - if args.author is not None and not args.original: - _fail("--author requires --original") - - path = Path(args.path) - if not path.exists(): - _fail(f"{path} does not exist") - - original_file = None - if args.original: - original_file = Path(args.original) - if not original_file.is_file(): - _fail(f"{original_file} is not a file") - if original_file.suffix.lower() not in OOXML_FAMILY: - _fail(f"{original_file} must be one of: {', '.join(sorted(OOXML_FAMILY))}") - - family = OOXML_FAMILY.get((original_file or path).suffix.lower()) - if family is None: - _fail( - f"Cannot determine file type from {path}. Use --original or provide one of: {', '.join(sorted(OOXML_FAMILY))}." - ) - - if args.author is not None and family != "docx": - _fail(f"--author only applies to docx files, not {family}") - - packed_file = None - temp_dir_ctx = None - if path.is_file() and path.suffix.lower() in OOXML_FAMILY: - packed_file = path - temp_dir_ctx = tempfile.TemporaryDirectory() - unpacked_dir = Path(temp_dir_ctx.name) - try: - with zipfile.ZipFile(path, "r") as zf: - safe_extract(zf, unpacked_dir) - except (zipfile.BadZipFile, ValueError, OSError) as e: - _fail(f"cannot unpack {path}: {e}") - else: - if not path.is_dir(): - _fail(f"{path} is not a directory or Office file") - unpacked_dir = path - - match family: - case "docx": - validators = [ - DOCXSchemaValidator(unpacked_dir, original_file, verbose=args.verbose), - ] - if args.author is not None: - validators.append( - RedliningValidator(unpacked_dir, original_file, verbose=args.verbose) - ) - elif original_file and _has_tracked_changes(unpacked_dir): - print( - "Note: this document has tracked changes; they were not " - "checked against the original (pass --author to check)." - ) - case "pptx": - validators = [ - PPTXSchemaValidator(unpacked_dir, original_file, verbose=args.verbose), - ] - case "xlsx": - exts = ", ".join(k for k, v in sorted(OOXML_FAMILY.items()) if v == "xlsx") - print( - f"No XSD schema validation is performed for xlsx-family files ({exts}). " - "For formula-error checking, use scripts/recalc.py instead." - ) - sys.exit(0) - case _: - print(f"Error: Validation not supported for file type {family}") - sys.exit(1) - - if args.auto_repair: - total_repairs = sum(v.repair() for v in validators) - if total_repairs: - print(f"Auto-repaired {total_repairs} issue(s)") - if packed_file is not None: - rezip(unpacked_dir, packed_file) - print(f"Wrote repaired file to {packed_file}") - - success = all([v.validate() for v in validators]) - - if temp_dir_ctx is not None: - temp_dir_ctx.cleanup() - - if success: - print("All validations PASSED!") - - sys.exit(0 if success else 1) - - -if __name__ == "__main__": - main() diff --git a/src/crates/assembly/core/builtin_skills/docx/scripts/office/validators/__init__.py b/src/crates/assembly/core/builtin_skills/docx/scripts/office/validators/__init__.py deleted file mode 100644 index db092ece7e..0000000000 --- a/src/crates/assembly/core/builtin_skills/docx/scripts/office/validators/__init__.py +++ /dev/null @@ -1,15 +0,0 @@ -""" -Validation modules for Word document processing. -""" - -from .base import BaseSchemaValidator -from .docx import DOCXSchemaValidator -from .pptx import PPTXSchemaValidator -from .redlining import RedliningValidator - -__all__ = [ - "BaseSchemaValidator", - "DOCXSchemaValidator", - "PPTXSchemaValidator", - "RedliningValidator", -] diff --git a/src/crates/assembly/core/builtin_skills/docx/scripts/office/validators/base.py b/src/crates/assembly/core/builtin_skills/docx/scripts/office/validators/base.py deleted file mode 100644 index 19d52a7fe0..0000000000 --- a/src/crates/assembly/core/builtin_skills/docx/scripts/office/validators/base.py +++ /dev/null @@ -1,875 +0,0 @@ -""" -Base validator with common validation logic for document files. -""" - -import re -from pathlib import Path - -import defusedxml.minidom -from functools import lru_cache - -import lxml.etree - -from helpers import safe_extract - - -@lru_cache(maxsize=None) -def _load_schema(schema_path: str): - with open(schema_path, "rb") as xsd_file: - xsd_doc = lxml.etree.parse( - xsd_file, parser=lxml.etree.XMLParser(), base_url=schema_path - ) - return lxml.etree.XMLSchema(xsd_doc) - -class BaseSchemaValidator: - - IGNORED_VALIDATION_ERRORS = [ - "hyphenationZone", - "purl.org/dc/terms", - ] - - UNIQUE_ID_REQUIREMENTS = { - "comment": ("id", "file"), - "commentrangestart": ("id", "file"), - "commentrangeend": ("id", "file"), - "bookmarkstart": ("id", "file"), - "bookmarkend": ("id", "file"), - "sldid": ("id", "file"), - "sldmasterid": ("id", "global"), - "sldlayoutid": ("id", "global"), - "cm": ("authorid", "file"), - "sheet": ("sheetid", "file"), - "definedname": ("id", "file"), - "cxnsp": ("id", "file"), - "sp": ("id", "file"), - "pic": ("id", "file"), - "grpsp": ("id", "file"), - } - - EXCLUDED_ID_CONTAINERS = { - "sectionlst", - } - - ELEMENT_RELATIONSHIP_TYPES = {} - - SCHEMA_MAPPINGS = { - "word": "ISO-IEC29500-4_2016/wml.xsd", - "ppt": "ISO-IEC29500-4_2016/pml.xsd", - "xl": "ISO-IEC29500-4_2016/sml.xsd", - "[Content_Types].xml": "ecma/fouth-edition/opc-contentTypes.xsd", - "app.xml": "ISO-IEC29500-4_2016/shared-documentPropertiesExtended.xsd", - "core.xml": "ecma/fouth-edition/opc-coreProperties.xsd", - "custom.xml": "ISO-IEC29500-4_2016/shared-documentPropertiesCustom.xsd", - ".rels": "ecma/fouth-edition/opc-relationships.xsd", - "people.xml": "microsoft/wml-2012.xsd", - "commentsIds.xml": "microsoft/wml-cid-2016.xsd", - "commentsExtensible.xml": "microsoft/wml-cex-2018.xsd", - "commentsExtended.xml": "microsoft/wml-2012.xsd", - "chart": "ISO-IEC29500-4_2016/dml-chart.xsd", - "theme": "ISO-IEC29500-4_2016/dml-main.xsd", - "drawing": "ISO-IEC29500-4_2016/dml-main.xsd", - } - - MC_NAMESPACE = "http://schemas.openxmlformats.org/markup-compatibility/2006" - XML_NAMESPACE = "http://www.w3.org/XML/1998/namespace" - - PACKAGE_RELATIONSHIPS_NAMESPACE = ( - "http://schemas.openxmlformats.org/package/2006/relationships" - ) - OFFICE_RELATIONSHIPS_NAMESPACE = ( - "http://schemas.openxmlformats.org/officeDocument/2006/relationships" - ) - CONTENT_TYPES_NAMESPACE = ( - "http://schemas.openxmlformats.org/package/2006/content-types" - ) - - MAIN_CONTENT_FOLDERS = {"word", "ppt", "xl"} - - OOXML_NAMESPACES = { - "http://schemas.openxmlformats.org/officeDocument/2006/math", - "http://schemas.openxmlformats.org/officeDocument/2006/relationships", - "http://schemas.openxmlformats.org/schemaLibrary/2006/main", - "http://schemas.openxmlformats.org/drawingml/2006/main", - "http://schemas.openxmlformats.org/drawingml/2006/chart", - "http://schemas.openxmlformats.org/drawingml/2006/chartDrawing", - "http://schemas.openxmlformats.org/drawingml/2006/diagram", - "http://schemas.openxmlformats.org/drawingml/2006/picture", - "http://schemas.openxmlformats.org/drawingml/2006/spreadsheetDrawing", - "http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing", - "http://schemas.openxmlformats.org/wordprocessingml/2006/main", - "http://schemas.openxmlformats.org/presentationml/2006/main", - "http://schemas.openxmlformats.org/spreadsheetml/2006/main", - "http://schemas.openxmlformats.org/officeDocument/2006/sharedTypes", - "http://www.w3.org/XML/1998/namespace", - } - - def __init__(self, unpacked_dir, original_file=None, verbose=False): - self.unpacked_dir = Path(unpacked_dir).resolve() - self.original_file = Path(original_file) if original_file else None - self.verbose = verbose - - self.schemas_dir = Path(__file__).parent.parent / "schemas" - - patterns = ["*.xml", "*.rels"] - self.xml_files = [ - f for pattern in patterns for f in self.unpacked_dir.rglob(pattern) - ] - - if not self.xml_files: - print(f"Warning: No XML files found in {self.unpacked_dir}") - - def validate(self): - raise NotImplementedError("Subclasses must implement the validate method") - - def repair(self) -> int: - return self.repair_whitespace_preservation() - - def repair_whitespace_preservation(self) -> int: - repairs = 0 - - for xml_file in self.xml_files: - try: - content = xml_file.read_text(encoding="utf-8") - dom = defusedxml.minidom.parseString(content) - pending = [] - - for elem in dom.getElementsByTagName("*"): - local_name = elem.tagName.rsplit(":", 1)[-1] - if local_name in ("t", "delText", "instrText", "delInstrText"): - text = "".join( - child.data - for child in elem.childNodes - if child.nodeType in (child.TEXT_NODE, child.CDATA_SECTION_NODE) - ) - ws = (" ", "\t", "\n", "\r") - if text and (text.startswith(ws) or text.endswith(ws)): - if elem.getAttribute("xml:space") != "preserve": - elem.setAttribute("xml:space", "preserve") - text_preview = repr(text[:30]) + "..." if len(text) > 30 else repr(text) - pending.append(f" Repaired: {xml_file.name}: Added xml:space='preserve' to {elem.tagName}: {text_preview}") - - if pending: - xml_file.write_bytes(dom.toxml(encoding="UTF-8")) - for message in pending: - print(message) - repairs += len(pending) - - except Exception: - pass - - return repairs - - def validate_xml(self): - errors = [] - - for xml_file in self.xml_files: - try: - lxml.etree.parse(str(xml_file)) - except lxml.etree.XMLSyntaxError as e: - errors.append( - f" {xml_file.relative_to(self.unpacked_dir)}: " - f"Line {e.lineno}: {e.msg}" - ) - except Exception as e: - errors.append( - f" {xml_file.relative_to(self.unpacked_dir)}: " - f"Unexpected error: {str(e)}" - ) - - if errors: - print(f"FAILED - Found {len(errors)} XML violations:") - for error in errors: - print(error) - return False - else: - if self.verbose: - print("PASSED - All XML files are well-formed") - return True - - def validate_namespaces(self): - errors = [] - - for xml_file in self.xml_files: - try: - root = lxml.etree.parse(str(xml_file)).getroot() - declared = set(root.nsmap.keys()) - {None} - - for attr_val in [ - v for k, v in root.attrib.items() if k.endswith("Ignorable") - ]: - undeclared = set(attr_val.split()) - declared - errors.extend( - f" {xml_file.relative_to(self.unpacked_dir)}: " - f"Namespace '{ns}' in Ignorable but not declared" - for ns in undeclared - ) - except lxml.etree.XMLSyntaxError: - continue - - if errors: - print(f"FAILED - {len(errors)} namespace issues:") - for error in errors: - print(error) - return False - if self.verbose: - print("PASSED - All namespace prefixes properly declared") - return True - - def validate_unique_ids(self): - errors = [] - global_ids = {} - - for xml_file in self.xml_files: - try: - root = lxml.etree.parse(str(xml_file)).getroot() - file_ids = {} - - mc_elements = root.xpath( - ".//mc:AlternateContent", namespaces={"mc": self.MC_NAMESPACE} - ) - for elem in mc_elements: - elem.getparent().remove(elem) - - for elem in root.iter(): - if not hasattr(elem, "tag") or callable(elem.tag): - continue - tag = ( - elem.tag.split("}")[-1].lower() - if "}" in elem.tag - else elem.tag.lower() - ) - - if tag in self.UNIQUE_ID_REQUIREMENTS: - in_excluded_container = any( - ancestor.tag.split("}")[-1].lower() in self.EXCLUDED_ID_CONTAINERS - for ancestor in elem.iterancestors() - ) - if in_excluded_container: - continue - - attr_name, scope = self.UNIQUE_ID_REQUIREMENTS[tag] - - id_value = None - for attr, value in elem.attrib.items(): - attr_local = ( - attr.split("}")[-1].lower() - if "}" in attr - else attr.lower() - ) - if attr_local == attr_name: - id_value = value - break - - if id_value is not None: - if scope == "global": - if id_value in global_ids: - prev_file, prev_line, prev_tag = global_ids[ - id_value - ] - errors.append( - f" {xml_file.relative_to(self.unpacked_dir)}: " - f"Line {elem.sourceline}: Global ID '{id_value}' in <{tag}> " - f"already used in {prev_file} at line {prev_line} in <{prev_tag}>" - ) - else: - global_ids[id_value] = ( - xml_file.relative_to(self.unpacked_dir), - elem.sourceline, - tag, - ) - elif scope == "file": - key = (tag, attr_name) - if key not in file_ids: - file_ids[key] = {} - - if id_value in file_ids[key]: - prev_line = file_ids[key][id_value] - errors.append( - f" {xml_file.relative_to(self.unpacked_dir)}: " - f"Line {elem.sourceline}: Duplicate {attr_name}='{id_value}' in <{tag}> " - f"(first occurrence at line {prev_line})" - ) - else: - file_ids[key][id_value] = elem.sourceline - - except (lxml.etree.XMLSyntaxError, Exception) as e: - errors.append( - f" {xml_file.relative_to(self.unpacked_dir)}: Error: {e}" - ) - - if errors: - print(f"FAILED - Found {len(errors)} ID uniqueness violations:") - for error in errors: - print(error) - return False - else: - if self.verbose: - print("PASSED - All required IDs are unique") - return True - - def validate_file_references(self): - errors = [] - - rels_files = list(self.unpacked_dir.rglob("*.rels")) - - if not rels_files: - if self.verbose: - print("PASSED - No .rels files found") - return True - - all_files = [] - for file_path in self.unpacked_dir.rglob("*"): - if ( - file_path.is_file() - and file_path.name != "[Content_Types].xml" - and not file_path.name.endswith(".rels") - ): - all_files.append(file_path.resolve()) - - all_referenced_files = set() - - if self.verbose: - print( - f"Found {len(rels_files)} .rels files and {len(all_files)} target files" - ) - - for rels_file in rels_files: - try: - rels_root = lxml.etree.parse(str(rels_file)).getroot() - - rels_dir = rels_file.parent - - referenced_files = set() - broken_refs = [] - - for rel in rels_root.findall( - ".//ns:Relationship", - namespaces={"ns": self.PACKAGE_RELATIONSHIPS_NAMESPACE}, - ): - target = rel.get("Target") - if rel.get("TargetMode") == "External": - continue - if target and not target.startswith( - ("http", "mailto:") - ): - if target.startswith("/"): - target_path = self.unpacked_dir / target.lstrip("/") - elif rels_file.name == ".rels": - target_path = self.unpacked_dir / target - else: - base_dir = rels_dir.parent - target_path = base_dir / target - - try: - target_path = target_path.resolve() - if target_path.exists() and target_path.is_file(): - referenced_files.add(target_path) - all_referenced_files.add(target_path) - else: - broken_refs.append((target, rel.sourceline)) - except (OSError, ValueError): - broken_refs.append((target, rel.sourceline)) - - if broken_refs: - rel_path = rels_file.relative_to(self.unpacked_dir) - for broken_ref, line_num in broken_refs: - errors.append( - f" {rel_path}: Line {line_num}: Broken reference to {broken_ref}" - ) - - except Exception as e: - rel_path = rels_file.relative_to(self.unpacked_dir) - errors.append(f" Error parsing {rel_path}: {e}") - - unreferenced_files = set(all_files) - all_referenced_files - - if unreferenced_files: - for unref_file in sorted(unreferenced_files): - unref_rel_path = unref_file.relative_to(self.unpacked_dir) - errors.append(f" Unreferenced file: {unref_rel_path}") - - if errors: - print(f"FAILED - Found {len(errors)} relationship validation errors:") - for error in errors: - print(error) - print( - "CRITICAL: These errors will cause the document to appear corrupt. " - + "Broken references MUST be fixed, " - + "and unreferenced files MUST be referenced or removed." - ) - return False - else: - if self.verbose: - print( - "PASSED - All references are valid and all files are properly referenced" - ) - return True - - def validate_all_relationship_ids(self): - import lxml.etree - - errors = [] - - for xml_file in self.xml_files: - if xml_file.suffix == ".rels": - continue - - rels_dir = xml_file.parent / "_rels" - rels_file = rels_dir / f"{xml_file.name}.rels" - - if not rels_file.exists(): - continue - - try: - rels_root = lxml.etree.parse(str(rels_file)).getroot() - rid_to_type = {} - - for rel in rels_root.findall( - f".//{{{self.PACKAGE_RELATIONSHIPS_NAMESPACE}}}Relationship" - ): - rid = rel.get("Id") - rel_type = rel.get("Type", "") - if rid: - if rid in rid_to_type: - rels_rel_path = rels_file.relative_to(self.unpacked_dir) - errors.append( - f" {rels_rel_path}: Line {rel.sourceline}: " - f"Duplicate relationship ID '{rid}' (IDs must be unique)" - ) - type_name = ( - rel_type.split("/")[-1] if "/" in rel_type else rel_type - ) - rid_to_type[rid] = type_name - - xml_root = lxml.etree.parse(str(xml_file)).getroot() - - r_ns = self.OFFICE_RELATIONSHIPS_NAMESPACE - rid_attrs_to_check = ["id", "embed", "link"] - for elem in xml_root.iter(): - if not hasattr(elem, "tag") or callable(elem.tag): - continue - for attr_name in rid_attrs_to_check: - rid_attr = elem.get(f"{{{r_ns}}}{attr_name}") - if not rid_attr: - continue - xml_rel_path = xml_file.relative_to(self.unpacked_dir) - elem_name = ( - elem.tag.split("}")[-1] if "}" in elem.tag else elem.tag - ) - - if rid_attr not in rid_to_type: - errors.append( - f" {xml_rel_path}: Line {elem.sourceline}: " - f"<{elem_name}> r:{attr_name} references non-existent relationship '{rid_attr}' " - f"(valid IDs: {', '.join(sorted(rid_to_type.keys())[:5])}{'...' if len(rid_to_type) > 5 else ''})" - ) - elif attr_name == "id" and self.ELEMENT_RELATIONSHIP_TYPES: - expected_type = self._get_expected_relationship_type( - elem_name - ) - if expected_type: - actual_type = rid_to_type[rid_attr] - if expected_type not in actual_type.lower(): - errors.append( - f" {xml_rel_path}: Line {elem.sourceline}: " - f"<{elem_name}> references '{rid_attr}' which points to '{actual_type}' " - f"but should point to a '{expected_type}' relationship" - ) - - except Exception as e: - xml_rel_path = xml_file.relative_to(self.unpacked_dir) - errors.append(f" Error processing {xml_rel_path}: {e}") - - if errors: - print(f"FAILED - Found {len(errors)} relationship ID reference errors:") - for error in errors: - print(error) - print("\nThese ID mismatches will cause the document to appear corrupt!") - return False - else: - if self.verbose: - print("PASSED - All relationship ID references are valid") - return True - - def _get_expected_relationship_type(self, element_name): - elem_lower = element_name.lower() - - if elem_lower in self.ELEMENT_RELATIONSHIP_TYPES: - return self.ELEMENT_RELATIONSHIP_TYPES[elem_lower] - - if elem_lower.endswith("id") and len(elem_lower) > 2: - prefix = elem_lower[:-2] - if prefix.endswith("master"): - return prefix.lower() - elif prefix.endswith("layout"): - return prefix.lower() - else: - if prefix == "sld": - return "slide" - return prefix.lower() - - if elem_lower.endswith("reference") and len(elem_lower) > 9: - prefix = elem_lower[:-9] - return prefix.lower() - - return None - - def validate_content_types(self): - errors = [] - - content_types_file = self.unpacked_dir / "[Content_Types].xml" - if not content_types_file.exists(): - print("FAILED - [Content_Types].xml file not found") - return False - - try: - root = lxml.etree.parse(str(content_types_file)).getroot() - declared_parts = set() - declared_extensions = set() - - for override in root.findall( - f".//{{{self.CONTENT_TYPES_NAMESPACE}}}Override" - ): - part_name = override.get("PartName") - if part_name is not None: - declared_parts.add(part_name.lstrip("/")) - - for default in root.findall( - f".//{{{self.CONTENT_TYPES_NAMESPACE}}}Default" - ): - extension = default.get("Extension") - if extension is not None: - declared_extensions.add(extension.lower()) - - declarable_roots = { - "sld", - "sldLayout", - "sldMaster", - "presentation", - "document", - "workbook", - "worksheet", - "theme", - } - - media_extensions = { - "png": "image/png", - "jpg": "image/jpeg", - "jpeg": "image/jpeg", - "gif": "image/gif", - "bmp": "image/bmp", - "tiff": "image/tiff", - "wmf": "image/x-wmf", - "emf": "image/x-emf", - } - - all_files = list(self.unpacked_dir.rglob("*")) - all_files = [f for f in all_files if f.is_file()] - - for xml_file in self.xml_files: - path_str = str(xml_file.relative_to(self.unpacked_dir)).replace( - "\\", "/" - ) - - if any( - skip in path_str - for skip in [".rels", "[Content_Types]", "docProps/", "_rels/"] - ): - continue - - try: - root_tag = lxml.etree.parse(str(xml_file)).getroot().tag - root_name = root_tag.split("}")[-1] if "}" in root_tag else root_tag - - if root_name in declarable_roots and path_str not in declared_parts: - errors.append( - f" {path_str}: File with <{root_name}> root not declared in [Content_Types].xml" - ) - - except Exception: - continue - - for file_path in all_files: - if file_path.suffix.lower() in {".xml", ".rels"}: - continue - if file_path.name == "[Content_Types].xml": - continue - if "_rels" in file_path.parts or "docProps" in file_path.parts: - continue - - extension = file_path.suffix.lstrip(".").lower() - if extension and extension not in declared_extensions: - if extension in media_extensions: - relative_path = file_path.relative_to(self.unpacked_dir) - errors.append( - f' {relative_path}: File with extension \'{extension}\' not declared in [Content_Types].xml - should add: ' - ) - - except Exception as e: - errors.append(f" Error parsing [Content_Types].xml: {e}") - - if errors: - print(f"FAILED - Found {len(errors)} content type declaration errors:") - for error in errors: - print(error) - return False - else: - if self.verbose: - print( - "PASSED - All content files are properly declared in [Content_Types].xml" - ) - return True - - def validate_file_against_xsd(self, xml_file, verbose=False): - xml_file = Path(xml_file).resolve() - unpacked_dir = self.unpacked_dir.resolve() - - is_valid, current_errors = self._validate_single_file_xsd( - xml_file, unpacked_dir - ) - - if is_valid is None: - return None, set() - elif is_valid: - return True, set() - - original_errors = self._get_original_file_errors(xml_file) - - assert current_errors is not None - new_errors = current_errors - original_errors - - new_errors = { - e for e in new_errors - if not any(pattern in e for pattern in self.IGNORED_VALIDATION_ERRORS) - } - - if new_errors: - if verbose: - relative_path = xml_file.relative_to(unpacked_dir) - print(f"FAILED - {relative_path}: {len(new_errors)} new error(s)") - for error in list(new_errors)[:3]: - truncated = error[:250] + "..." if len(error) > 250 else error - print(f" - {truncated}") - return False, new_errors - else: - if verbose: - print( - f"PASSED - No new errors (original had {len(current_errors)} errors)" - ) - return True, set() - - def validate_against_xsd(self): - new_errors = [] - original_error_count = 0 - valid_count = 0 - skipped_count = 0 - - for xml_file in self.xml_files: - relative_path = str(xml_file.relative_to(self.unpacked_dir)) - is_valid, new_file_errors = self.validate_file_against_xsd( - xml_file, verbose=False - ) - - if is_valid is None: - skipped_count += 1 - continue - elif is_valid and not new_file_errors: - valid_count += 1 - continue - elif is_valid: - original_error_count += 1 - valid_count += 1 - continue - - new_errors.append(f" {relative_path}: {len(new_file_errors)} new error(s)") - for error in list(new_file_errors)[:3]: - new_errors.append( - f" - {error[:250]}..." if len(error) > 250 else f" - {error}" - ) - - if self.verbose: - print(f"Validated {len(self.xml_files)} files:") - print(f" - Valid: {valid_count}") - print(f" - Skipped (no schema): {skipped_count}") - if original_error_count: - print(f" - With original errors (ignored): {original_error_count}") - print( - f" - With NEW errors: {len(new_errors) > 0 and len([e for e in new_errors if not e.startswith(' ')]) or 0}" - ) - - if new_errors: - print("\nFAILED - Found NEW validation errors:") - for error in new_errors: - print(error) - return False - else: - if self.verbose: - print("\nPASSED - No new XSD validation errors introduced") - return True - - def _get_schema_path(self, xml_file): - if xml_file.name in self.SCHEMA_MAPPINGS: - return self.schemas_dir / self.SCHEMA_MAPPINGS[xml_file.name] - - if xml_file.suffix == ".rels": - return self.schemas_dir / self.SCHEMA_MAPPINGS[".rels"] - - if "charts/" in str(xml_file) and xml_file.name.startswith("chart"): - return self.schemas_dir / self.SCHEMA_MAPPINGS["chart"] - - if "theme/" in str(xml_file) and xml_file.name.startswith("theme"): - return self.schemas_dir / self.SCHEMA_MAPPINGS["theme"] - - if xml_file.parent.name in self.MAIN_CONTENT_FOLDERS: - return self.schemas_dir / self.SCHEMA_MAPPINGS[xml_file.parent.name] - - return None - - def _clean_ignorable_namespaces(self, xml_doc): - xml_string = lxml.etree.tostring(xml_doc, encoding="unicode") - xml_copy = lxml.etree.fromstring(xml_string) - - for elem in xml_copy.iter(): - attrs_to_remove = [] - - for attr in elem.attrib: - if "{" in attr: - ns = attr.split("}")[0][1:] - if ns not in self.OOXML_NAMESPACES: - attrs_to_remove.append(attr) - - for attr in attrs_to_remove: - del elem.attrib[attr] - - self._remove_ignorable_elements(xml_copy) - - return lxml.etree.ElementTree(xml_copy) - - def _remove_ignorable_elements(self, root): - elements_to_remove = [] - - for elem in list(root): - if not hasattr(elem, "tag") or callable(elem.tag): - continue - - tag_str = str(elem.tag) - if tag_str.startswith("{"): - ns = tag_str.split("}")[0][1:] - if ns not in self.OOXML_NAMESPACES: - elements_to_remove.append(elem) - continue - - self._remove_ignorable_elements(elem) - - for elem in elements_to_remove: - root.remove(elem) - - def _preprocess_for_mc_ignorable(self, xml_doc): - root = xml_doc.getroot() - - if f"{{{self.MC_NAMESPACE}}}Ignorable" in root.attrib: - del root.attrib[f"{{{self.MC_NAMESPACE}}}Ignorable"] - - return xml_doc - - def _preprocess_for_schema(self, xml_doc, relative_path): - return xml_doc - - def _validate_single_file_xsd(self, xml_file, base_path, schema_path=None): - schema_path = schema_path or self._get_schema_path(xml_file) - if not schema_path: - return None, None - - try: - schema = _load_schema(str(schema_path)) - - with open(xml_file, "r") as f: - xml_doc = lxml.etree.parse(f) - - xml_doc, _ = self._remove_template_tags_from_text_nodes(xml_doc) - xml_doc = self._preprocess_for_mc_ignorable(xml_doc) - - relative_path = xml_file.relative_to(base_path) - if ( - relative_path.parts - and relative_path.parts[0] in self.MAIN_CONTENT_FOLDERS - ): - xml_doc = self._clean_ignorable_namespaces(xml_doc) - - xml_doc = self._preprocess_for_schema(xml_doc, relative_path) - - if schema.validate(xml_doc): - return True, set() - else: - errors = set() - for error in schema.error_log: - errors.add(error.message) - return False, errors - - except Exception as e: - return False, {str(e)} - - def _get_original_file_errors(self, xml_file, schema_path=None): - if self.original_file is None: - return set() - - import tempfile - import zipfile - - xml_file = Path(xml_file).resolve() - unpacked_dir = self.unpacked_dir.resolve() - relative_path = xml_file.relative_to(unpacked_dir) - - with tempfile.TemporaryDirectory() as temp_dir: - temp_path = Path(temp_dir) - - try: - with zipfile.ZipFile(self.original_file, "r") as zip_ref: - safe_extract(zip_ref, temp_path) - except (zipfile.BadZipFile, ValueError, OSError): - return set() - - original_xml_file = temp_path / relative_path - - if not original_xml_file.exists(): - return set() - - is_valid, errors = self._validate_single_file_xsd( - original_xml_file, temp_path, schema_path=schema_path - ) - return errors if errors else set() - - def _remove_template_tags_from_text_nodes(self, xml_doc): - warnings = [] - template_pattern = re.compile(r"\{\{[^}]*\}\}") - - xml_string = lxml.etree.tostring(xml_doc, encoding="unicode") - xml_copy = lxml.etree.fromstring(xml_string) - - def process_text_content(text, content_type): - if not text: - return text - matches = list(template_pattern.finditer(text)) - if matches: - for match in matches: - warnings.append( - f"Found template tag in {content_type}: {match.group()}" - ) - return template_pattern.sub("", text) - return text - - for elem in xml_copy.iter(): - if not hasattr(elem, "tag") or callable(elem.tag): - continue - tag_str = str(elem.tag) - if tag_str.endswith("}t") or tag_str == "t": - continue - - elem.text = process_text_content(elem.text, "text content") - elem.tail = process_text_content(elem.tail, "tail content") - - return lxml.etree.ElementTree(xml_copy), warnings - - -if __name__ == "__main__": - raise RuntimeError("This module should not be run directly.") diff --git a/src/crates/assembly/core/builtin_skills/docx/scripts/office/validators/docx.py b/src/crates/assembly/core/builtin_skills/docx/scripts/office/validators/docx.py deleted file mode 100644 index 0d18b6979a..0000000000 --- a/src/crates/assembly/core/builtin_skills/docx/scripts/office/validators/docx.py +++ /dev/null @@ -1,466 +0,0 @@ -""" -Validator for Word document XML files against XSD schemas. -""" - -import random -import re -import tempfile -import zipfile -from pathlib import Path - -import defusedxml.minidom -import lxml.etree - -from helpers import safe_extract - -from .base import BaseSchemaValidator - - -class DOCXSchemaValidator(BaseSchemaValidator): - - WORD_2006_NAMESPACE = "http://schemas.openxmlformats.org/wordprocessingml/2006/main" - W14_NAMESPACE = "http://schemas.microsoft.com/office/word/2010/wordml" - W16CID_NAMESPACE = "http://schemas.microsoft.com/office/word/2016/wordml/cid" - - ELEMENT_RELATIONSHIP_TYPES = {} - - def validate(self): - if not self.validate_xml(): - return False - - all_valid = True - if not self.validate_namespaces(): - all_valid = False - - if not self.validate_unique_ids(): - all_valid = False - - if not self.validate_file_references(): - all_valid = False - - if not self.validate_content_types(): - all_valid = False - - if not self.validate_against_xsd(): - all_valid = False - - if not self.validate_whitespace_preservation(): - all_valid = False - - if not self.validate_deletions(): - all_valid = False - - if not self.validate_insertions(): - all_valid = False - - if not self.validate_all_relationship_ids(): - all_valid = False - - if not self.validate_id_constraints(): - all_valid = False - - if not self.validate_comment_markers(): - all_valid = False - - self.compare_paragraph_counts() - - return all_valid - - def validate_whitespace_preservation(self): - errors = [] - - for xml_file in self.xml_files: - if xml_file.name != "document.xml": - continue - - try: - root = lxml.etree.parse(str(xml_file)).getroot() - - for elem in root.iter(f"{{{self.WORD_2006_NAMESPACE}}}t"): - if elem.text: - text = elem.text - if re.search(r"^[ \t\n\r]", text) or re.search( - r"[ \t\n\r]$", text - ): - xml_space_attr = f"{{{self.XML_NAMESPACE}}}space" - if ( - xml_space_attr not in elem.attrib - or elem.attrib[xml_space_attr] != "preserve" - ): - text_preview = ( - repr(text)[:50] + "..." - if len(repr(text)) > 50 - else repr(text) - ) - errors.append( - f" {xml_file.relative_to(self.unpacked_dir)}: " - f"Line {elem.sourceline}: w:t element with whitespace missing xml:space='preserve': {text_preview}" - ) - - except (lxml.etree.XMLSyntaxError, Exception) as e: - errors.append( - f" {xml_file.relative_to(self.unpacked_dir)}: Error: {e}" - ) - - if errors: - print(f"FAILED - Found {len(errors)} whitespace preservation violations:") - for error in errors: - print(error) - return False - else: - if self.verbose: - print("PASSED - All whitespace is properly preserved") - return True - - def validate_deletions(self): - errors = [] - - for xml_file in self.xml_files: - if xml_file.name != "document.xml": - continue - - try: - root = lxml.etree.parse(str(xml_file)).getroot() - namespaces = {"w": self.WORD_2006_NAMESPACE} - - for t_elem in root.xpath(".//w:del//w:t", namespaces=namespaces): - if t_elem.text: - text_preview = ( - repr(t_elem.text)[:50] + "..." - if len(repr(t_elem.text)) > 50 - else repr(t_elem.text) - ) - errors.append( - f" {xml_file.relative_to(self.unpacked_dir)}: " - f"Line {t_elem.sourceline}: found within : {text_preview}" - ) - - for instr_elem in root.xpath( - ".//w:del//w:instrText", namespaces=namespaces - ): - text_preview = ( - repr(instr_elem.text or "")[:50] + "..." - if len(repr(instr_elem.text or "")) > 50 - else repr(instr_elem.text or "") - ) - errors.append( - f" {xml_file.relative_to(self.unpacked_dir)}: " - f"Line {instr_elem.sourceline}: found within (use ): {text_preview}" - ) - - except (lxml.etree.XMLSyntaxError, Exception) as e: - errors.append( - f" {xml_file.relative_to(self.unpacked_dir)}: Error: {e}" - ) - - if errors: - print(f"FAILED - Found {len(errors)} deletion validation violations:") - for error in errors: - print(error) - return False - else: - if self.verbose: - print("PASSED - No w:t elements found within w:del elements") - return True - - def count_paragraphs_in_unpacked(self): - count = 0 - - for xml_file in self.xml_files: - if xml_file.name != "document.xml": - continue - - try: - root = lxml.etree.parse(str(xml_file)).getroot() - paragraphs = root.findall(f".//{{{self.WORD_2006_NAMESPACE}}}p") - count = len(paragraphs) - except Exception as e: - print(f"Error counting paragraphs in unpacked document: {e}") - - return count - - def count_paragraphs_in_original(self): - original = self.original_file - if original is None: - return 0 - - count = 0 - - try: - with tempfile.TemporaryDirectory() as temp_dir: - with zipfile.ZipFile(original, "r") as zip_ref: - safe_extract(zip_ref, Path(temp_dir)) - - doc_xml_path = temp_dir + "/word/document.xml" - root = lxml.etree.parse(doc_xml_path).getroot() - - paragraphs = root.findall(f".//{{{self.WORD_2006_NAMESPACE}}}p") - count = len(paragraphs) - - except Exception as e: - print(f"Error counting paragraphs in original document: {e}") - - return count - - def validate_insertions(self): - errors = [] - - for xml_file in self.xml_files: - if xml_file.name != "document.xml": - continue - - try: - root = lxml.etree.parse(str(xml_file)).getroot() - namespaces = {"w": self.WORD_2006_NAMESPACE} - - invalid_elements = root.xpath( - ".//w:ins//w:delText[not(ancestor::w:del)]", namespaces=namespaces - ) - - for elem in invalid_elements: - text_preview = ( - repr(elem.text or "")[:50] + "..." - if len(repr(elem.text or "")) > 50 - else repr(elem.text or "") - ) - errors.append( - f" {xml_file.relative_to(self.unpacked_dir)}: " - f"Line {elem.sourceline}: within : {text_preview}" - ) - - except (lxml.etree.XMLSyntaxError, Exception) as e: - errors.append( - f" {xml_file.relative_to(self.unpacked_dir)}: Error: {e}" - ) - - if errors: - print(f"FAILED - Found {len(errors)} insertion validation violations:") - for error in errors: - print(error) - return False - else: - if self.verbose: - print("PASSED - No w:delText elements within w:ins elements") - return True - - def compare_paragraph_counts(self): - new_count = self.count_paragraphs_in_unpacked() - if self.original_file is None: - print(f"\nParagraphs: {new_count}") - return - - original_count = self.count_paragraphs_in_original() - diff = new_count - original_count - diff_str = f"+{diff}" if diff > 0 else str(diff) - print(f"\nParagraphs: {original_count} → {new_count} ({diff_str})") - - def _parse_id_value(self, val: str, base: int = 16) -> int: - return int(val, base) - - def validate_id_constraints(self): - errors = [] - para_id_attr = f"{{{self.W14_NAMESPACE}}}paraId" - durable_id_attr = f"{{{self.W16CID_NAMESPACE}}}durableId" - - for xml_file in self.xml_files: - try: - for elem in lxml.etree.parse(str(xml_file)).iter(): - if val := elem.get(para_id_attr): - try: - if self._parse_id_value(val, base=16) >= 0x80000000: - errors.append( - f" {xml_file.name}:{elem.sourceline}: paraId={val} >= 0x80000000" - ) - except ValueError: - errors.append( - f" {xml_file.name}:{elem.sourceline}: " - f"paraId={val} is not valid hex" - ) - - if val := elem.get(durable_id_attr): - if xml_file.name == "numbering.xml": - try: - if self._parse_id_value(val, base=10) >= 0x7FFFFFFF: - errors.append( - f" {xml_file.name}:{elem.sourceline}: " - f"durableId={val} >= 0x7FFFFFFF" - ) - except ValueError: - errors.append( - f" {xml_file.name}:{elem.sourceline}: " - f"durableId={val} must be decimal in numbering.xml" - ) - else: - try: - if self._parse_id_value(val, base=16) >= 0x7FFFFFFF: - errors.append( - f" {xml_file.name}:{elem.sourceline}: " - f"durableId={val} >= 0x7FFFFFFF" - ) - except ValueError: - errors.append( - f" {xml_file.name}:{elem.sourceline}: " - f"durableId={val} is not valid hex" - ) - except lxml.etree.XMLSyntaxError: - continue - - if errors: - print(f"FAILED - {len(errors)} ID constraint violations:") - for e in errors: - print(e) - elif self.verbose: - print("PASSED - All paraId/durableId values within constraints") - return not errors - - def validate_comment_markers(self): - errors = [] - - document_xml = None - comments_xml = None - for xml_file in self.xml_files: - if xml_file.name == "document.xml" and "word" in str(xml_file): - document_xml = xml_file - elif xml_file.name == "comments.xml": - comments_xml = xml_file - - if not document_xml: - if self.verbose: - print("PASSED - No document.xml found (skipping comment validation)") - return True - - try: - doc_root = lxml.etree.parse(str(document_xml)).getroot() - namespaces = {"w": self.WORD_2006_NAMESPACE} - - range_starts = { - elem.get(f"{{{self.WORD_2006_NAMESPACE}}}id") - for elem in doc_root.xpath( - ".//w:commentRangeStart", namespaces=namespaces - ) - } - range_ends = { - elem.get(f"{{{self.WORD_2006_NAMESPACE}}}id") - for elem in doc_root.xpath( - ".//w:commentRangeEnd", namespaces=namespaces - ) - } - references = { - elem.get(f"{{{self.WORD_2006_NAMESPACE}}}id") - for elem in doc_root.xpath( - ".//w:commentReference", namespaces=namespaces - ) - } - - orphaned_ends = range_ends - range_starts - for comment_id in sorted( - orphaned_ends, key=lambda x: int(x) if x and x.isdigit() else 0 - ): - errors.append( - f' document.xml: commentRangeEnd id="{comment_id}" has no matching commentRangeStart' - ) - - orphaned_starts = range_starts - range_ends - for comment_id in sorted( - orphaned_starts, key=lambda x: int(x) if x and x.isdigit() else 0 - ): - errors.append( - f' document.xml: commentRangeStart id="{comment_id}" has no matching commentRangeEnd' - ) - - comment_ids = set() - if comments_xml and comments_xml.exists(): - comments_root = lxml.etree.parse(str(comments_xml)).getroot() - comment_ids = { - elem.get(f"{{{self.WORD_2006_NAMESPACE}}}id") - for elem in comments_root.xpath( - ".//w:comment", namespaces=namespaces - ) - } - - marker_ids = range_starts | range_ends | references - invalid_refs = marker_ids - comment_ids - for comment_id in sorted( - invalid_refs, key=lambda x: int(x) if x and x.isdigit() else 0 - ): - if comment_id: - errors.append( - f' document.xml: marker id="{comment_id}" references non-existent comment' - ) - - except (lxml.etree.XMLSyntaxError, Exception) as e: - errors.append(f" Error parsing XML: {e}") - - if errors: - print(f"FAILED - {len(errors)} comment marker violations:") - for error in errors: - print(error) - return False - else: - if self.verbose: - print("PASSED - All comment markers properly paired") - return True - - def repair(self) -> int: - repairs = super().repair() - repairs += self.repair_durableId() - return repairs - - def repair_durableId(self) -> int: - DURABLE_ID_ATTRS = ("w16cid:durableId", "w16cex:durableId") - repairs = 0 - renames: dict = {} - - for xml_file in self.xml_files: - try: - content = xml_file.read_text(encoding="utf-8") - dom = defusedxml.minidom.parseString(content) - is_numbering = xml_file.name == "numbering.xml" - base = 10 if is_numbering else 16 - pending = [] - seen_in_file = set() - modified = False - - for elem in dom.getElementsByTagName("*"): - for attr_name in DURABLE_ID_ATTRS: - if not elem.hasAttribute(attr_name): - continue - - durable_id = elem.getAttribute(attr_name) - try: - key = self._parse_id_value(durable_id, base=base) - needs_repair = key >= 0x7FFFFFFF - except ValueError: - key = durable_id - needs_repair = True - - if needs_repair: - if key in seen_in_file: - value = random.randint(1, 0x7FFFFFFE) - else: - seen_in_file.add(key) - if key not in renames: - renames[key] = random.randint(1, 0x7FFFFFFE) - value = renames[key] - new_id = str(value) if is_numbering else f"{value:08X}" - - elem.setAttribute(attr_name, new_id) - pending.append( - f" Repaired: {xml_file.name}: durableId {durable_id} → {new_id}" - ) - modified = True - - if modified: - xml_file.write_bytes(dom.toxml(encoding="UTF-8")) - for message in pending: - print(message) - repairs += len(pending) - - except Exception: - pass - - return repairs - - -if __name__ == "__main__": - raise RuntimeError("This module should not be run directly.") diff --git a/src/crates/assembly/core/builtin_skills/docx/scripts/office/validators/pptx.py b/src/crates/assembly/core/builtin_skills/docx/scripts/office/validators/pptx.py deleted file mode 100644 index 7b53d0d3e4..0000000000 --- a/src/crates/assembly/core/builtin_skills/docx/scripts/office/validators/pptx.py +++ /dev/null @@ -1,441 +0,0 @@ -""" -Validator for PowerPoint presentation XML files against XSD schemas. -""" - -import re -from pathlib import Path - -from helpers import opc_target, rels_source_part, safe_extract - -from .base import BaseSchemaValidator - - -class PPTXSchemaValidator(BaseSchemaValidator): - - PRESENTATIONML_NAMESPACE = ( - "http://schemas.openxmlformats.org/presentationml/2006/main" - ) - - ELEMENT_RELATIONSHIP_TYPES = { - "sldid": "slide", - "sldmasterid": "slidemaster", - "notesmasterid": "notesmaster", - "sldlayoutid": "slidelayout", - "themeid": "theme", - "tablestyleid": "tablestyles", - } - - def validate(self): - if not self.validate_xml(): - return False - - all_valid = True - if not self.validate_namespaces(): - all_valid = False - - if not self.validate_unique_ids(): - all_valid = False - - if not self.validate_uuid_ids(): - all_valid = False - - if not self.validate_file_references(): - all_valid = False - - if not self.validate_slide_layout_ids(): - all_valid = False - - if not self.validate_content_types(): - all_valid = False - - if not self.validate_against_xsd(): - all_valid = False - - if not self.validate_notes_slide_references(): - all_valid = False - - if not self.validate_all_relationship_ids(): - all_valid = False - - if not self.validate_no_duplicate_slide_layouts(): - all_valid = False - - if not self.validate_master_theme_uniqueness(): - all_valid = False - - if not self.validate_charts(): - all_valid = False - - if not self.validate_slides(): - all_valid = False - - return all_valid - - def _package_map(self) -> dict: - wanted = [] - wanted += list(self.unpacked_dir.glob("[[]Content_Types[]].xml")) - wanted += list(self.unpacked_dir.glob("ppt/presentation.xml")) - wanted += list(self.unpacked_dir.glob("ppt/theme/*.xml")) - wanted += list(self.unpacked_dir.glob("ppt/theme/_rels/*.rels")) - wanted += list(self.unpacked_dir.glob("ppt/charts/chart*.xml")) - for group in ("slideMasters", "notesMasters", "handoutMasters"): - wanted += list(self.unpacked_dir.glob(f"ppt/{group}/*.xml")) - wanted += list(self.unpacked_dir.glob(f"ppt/{group}/_rels/*.rels")) - return { - p.relative_to(self.unpacked_dir).as_posix(): p.read_bytes() - for p in wanted - if p.is_file() - } - - def validate_master_theme_uniqueness(self): - from helpers.pptx_theme import _NOTES_MASTERS, live_shared_master_themes - - shared = live_shared_master_themes(self._package_map()) - if shared: - print(f"FAILED - Found {len(shared)} master(s) sharing a theme part:") - for message in shared: - print(f" {message}") - if any(m.startswith(_NOTES_MASTERS) for m in shared): - print(" Fix: in ppt/presentation.xml, move back to " - "directly after . PowerPoint reads that happily.") - else: - print(" Fix: give each master its own theme part.") - return False - - if self.verbose: - print("PASSED - No master shares a theme part in a way PowerPoint refuses") - return True - - def validate_charts(self): - from helpers.pptx_chart import find_chart_problems - - problems = find_chart_problems(self._package_map()) - if problems: - print(f"FAILED - Found {len(problems)} chart problem(s) PowerPoint rejects:") - for message in problems: - print(f" {message}") - return False - - if self.verbose: - print("PASSED - Charts satisfy the constraints PowerPoint enforces") - return True - - def _original_slide_defects(self, schema) -> set[str]: - import tempfile - import zipfile - - from helpers.pptx_slide import SLIDE_PART_RE, fatal_slide_errors - - if self.original_file is None: - return set() - - found: set[str] = set() - with tempfile.TemporaryDirectory() as temp_dir: - temp_path = Path(temp_dir) - try: - with zipfile.ZipFile(self.original_file, "r") as zf: - safe_extract(zf, temp_path) - except (zipfile.BadZipFile, ValueError, OSError): - return set() - - for part in sorted(temp_path.rglob("*.xml")): - relative = part.relative_to(temp_path).as_posix() - if not SLIDE_PART_RE.fullmatch(relative): - continue - ok, errors = self._validate_single_file_xsd( - part.resolve(), temp_path.resolve(), schema_path=schema - ) - if ok is None or ok or not errors: - continue - found |= set(fatal_slide_errors(set(errors))) - return found - - def validate_slides(self): - from helpers.pptx_slide import ( - SLIDE_PART_RE, - fatal_slide_errors, - is_schema_verdict, - ) - - schema = self.schemas_dir / self.SCHEMA_MAPPINGS["ppt"] - inherited = self._original_slide_defects(schema) - problems: list[str] = [] - broken: list[str] = [] - - for xml_file in self.xml_files: - relative = xml_file.relative_to(self.unpacked_dir).as_posix() - if not SLIDE_PART_RE.fullmatch(relative): - continue - ok, errors = self._validate_single_file_xsd( - xml_file.resolve(), self.unpacked_dir.resolve(), schema_path=schema - ) - if ok is None or not errors: - continue - - unreadable = [f"{relative}: {e}" for e in errors if not is_schema_verdict(e)] - if unreadable: - broken.extend(unreadable) - continue - if ok: - continue - - for message in fatal_slide_errors(set(errors)): - if message in inherited: - continue - problems.append(f"{relative}: {message}") - - if broken: - print(f"FAILED - Could not check {len(broken)} slide part(s):") - for message in sorted(broken): - print(f" {message[:240]}") - - if problems: - print(f"FAILED - Found {len(problems)} slide problem(s) PowerPoint rejects:") - for message in sorted(problems): - print(f" {message[:240]}") - - if broken or problems: - return False - - if self.verbose: - print("PASSED - Slide XML has none of the defects PowerPoint refuses") - return True - - def _get_schema_path(self, xml_file): - if xml_file.parent.name == "charts" and xml_file.name.startswith("chart"): - return None - return super()._get_schema_path(xml_file) - - def _preprocess_for_schema(self, xml_doc, relative_path): - if relative_path.as_posix() != "ppt/presentation.xml": - return xml_doc - - root = xml_doc.getroot() - ns = f"{{{self.PRESENTATIONML_NAMESPACE}}}" - notes = root.find(f"{ns}notesMasterIdLst") - slides = root.find(f"{ns}sldIdLst") - if notes is None or slides is None: - return xml_doc - - children = list(root) - if children.index(notes) < children.index(slides): - return xml_doc - - root.remove(notes) - root.insert(list(root).index(slides), notes) - return xml_doc - - def validate_uuid_ids(self): - import lxml.etree - - errors = [] - uuid_pattern = re.compile( - r"^[\{\(]?[0-9A-Fa-f]{8}-?[0-9A-Fa-f]{4}-?[0-9A-Fa-f]{4}-?[0-9A-Fa-f]{4}-?[0-9A-Fa-f]{12}[\}\)]?$" - ) - - for xml_file in self.xml_files: - try: - root = lxml.etree.parse(str(xml_file)).getroot() - - for elem in root.iter(): - for attr, value in elem.attrib.items(): - attr_name = attr.split("}")[-1].lower() - if attr_name == "id" or attr_name.endswith("id"): - if self._looks_like_uuid(value): - if not uuid_pattern.match(value): - errors.append( - f" {xml_file.relative_to(self.unpacked_dir)}: " - f"Line {elem.sourceline}: ID '{value}' appears to be a UUID but contains invalid hex characters" - ) - - except (lxml.etree.XMLSyntaxError, Exception) as e: - errors.append( - f" {xml_file.relative_to(self.unpacked_dir)}: Error: {e}" - ) - - if errors: - print(f"FAILED - Found {len(errors)} UUID ID validation errors:") - for error in errors: - print(error) - return False - else: - if self.verbose: - print("PASSED - All UUID-like IDs contain valid hex values") - return True - - def _looks_like_uuid(self, value): - clean_value = value.strip("{}()").replace("-", "") - return len(clean_value) == 32 and all(c.isalnum() for c in clean_value) - - def validate_slide_layout_ids(self): - import lxml.etree - - errors = [] - - slide_masters = list(self.unpacked_dir.glob("ppt/slideMasters/*.xml")) - - if not slide_masters: - if self.verbose: - print("PASSED - No slide masters found") - return True - - for slide_master in slide_masters: - try: - root = lxml.etree.parse(str(slide_master)).getroot() - - rels_file = slide_master.parent / "_rels" / f"{slide_master.name}.rels" - - if not rels_file.exists(): - errors.append( - f" {slide_master.relative_to(self.unpacked_dir)}: " - f"Missing relationships file: {rels_file.relative_to(self.unpacked_dir)}" - ) - continue - - rels_root = lxml.etree.parse(str(rels_file)).getroot() - - valid_layout_rids = set() - for rel in rels_root.findall( - f".//{{{self.PACKAGE_RELATIONSHIPS_NAMESPACE}}}Relationship" - ): - rel_type = rel.get("Type", "") - if "slideLayout" in rel_type: - valid_layout_rids.add(rel.get("Id")) - - for sld_layout_id in root.findall( - f".//{{{self.PRESENTATIONML_NAMESPACE}}}sldLayoutId" - ): - r_id = sld_layout_id.get( - f"{{{self.OFFICE_RELATIONSHIPS_NAMESPACE}}}id" - ) - layout_id = sld_layout_id.get("id") - - if r_id and r_id not in valid_layout_rids: - errors.append( - f" {slide_master.relative_to(self.unpacked_dir)}: " - f"Line {sld_layout_id.sourceline}: sldLayoutId with id='{layout_id}' " - f"references r:id='{r_id}' which is not found in slide layout relationships" - ) - - except (lxml.etree.XMLSyntaxError, Exception) as e: - errors.append( - f" {slide_master.relative_to(self.unpacked_dir)}: Error: {e}" - ) - - if errors: - print(f"FAILED - Found {len(errors)} slide layout ID validation errors:") - for error in errors: - print(error) - print( - "Remove invalid references or add missing slide layouts to the relationships file." - ) - return False - else: - if self.verbose: - print("PASSED - All slide layout IDs reference valid slide layouts") - return True - - def validate_no_duplicate_slide_layouts(self): - import lxml.etree - - errors = [] - slide_rels_files = list(self.unpacked_dir.glob("ppt/slides/_rels/*.xml.rels")) - - for rels_file in slide_rels_files: - try: - root = lxml.etree.parse(str(rels_file)).getroot() - - layout_rels = [ - rel - for rel in root.findall( - f".//{{{self.PACKAGE_RELATIONSHIPS_NAMESPACE}}}Relationship" - ) - if "slideLayout" in rel.get("Type", "") - ] - - if len(layout_rels) > 1: - errors.append( - f" {rels_file.relative_to(self.unpacked_dir)}: has {len(layout_rels)} slideLayout references" - ) - - except Exception as e: - errors.append( - f" {rels_file.relative_to(self.unpacked_dir)}: Error: {e}" - ) - - if errors: - print("FAILED - Found slides with duplicate slideLayout references:") - for error in errors: - print(error) - return False - else: - if self.verbose: - print("PASSED - All slides have exactly one slideLayout reference") - return True - - def validate_notes_slide_references(self): - import lxml.etree - - errors = [] - notes_slide_references = {} - - slide_rels_files = list(self.unpacked_dir.glob("ppt/slides/_rels/*.xml.rels")) - - if not slide_rels_files: - if self.verbose: - print("PASSED - No slide relationship files found") - return True - - for rels_file in slide_rels_files: - try: - root = lxml.etree.parse(str(rels_file)).getroot() - - for rel in root.findall( - f".//{{{self.PACKAGE_RELATIONSHIPS_NAMESPACE}}}Relationship" - ): - rel_type = rel.get("Type", "") - if "notesSlide" in rel_type: - part = opc_target( - rel.get("Target", ""), - rels_source_part(rels_file, self.unpacked_dir), - rel.get("TargetMode", ""), - ) - if part: - slide_name = rels_file.stem.replace( - ".xml", "" - ) - - notes_slide_references.setdefault(part, []).append( - (slide_name, rels_file) - ) - - except (lxml.etree.XMLSyntaxError, Exception) as e: - errors.append( - f" {rels_file.relative_to(self.unpacked_dir)}: Error: {e}" - ) - - for target, references in notes_slide_references.items(): - if len(references) > 1: - slide_names = [ref[0] for ref in references] - errors.append( - f" Notes slide '{target}' is referenced by multiple slides: {', '.join(slide_names)}" - ) - for slide_name, rels_file in references: - errors.append(f" - {rels_file.relative_to(self.unpacked_dir)}") - - if errors: - print( - f"FAILED - Found {len([e for e in errors if not e.startswith(' ')])} notes slide reference validation errors:" - ) - for error in errors: - print(error) - print("Each slide may optionally have its own slide file.") - return False - else: - if self.verbose: - print("PASSED - All notes slide references are unique") - return True - - -if __name__ == "__main__": - raise RuntimeError("This module should not be run directly.") diff --git a/src/crates/assembly/core/builtin_skills/docx/scripts/office/validators/redlining.py b/src/crates/assembly/core/builtin_skills/docx/scripts/office/validators/redlining.py deleted file mode 100644 index 18d0c68be9..0000000000 --- a/src/crates/assembly/core/builtin_skills/docx/scripts/office/validators/redlining.py +++ /dev/null @@ -1,299 +0,0 @@ -""" -Validator for tracked changes in Word documents. - -Detects untracked edits in word/document.xml: text that differs from the -original without a / wrapper recording it. The tracked changes -that are new relative to the original are undone, and the result is compared -against the original; whatever text still differs was edited without being -tracked. - -Only the document body is compared. Headers, footers, footnotes and endnotes -are separate parts and are not checked. -""" - -import subprocess -import tempfile -import zipfile -from pathlib import Path - -import defusedxml.ElementTree as ET -from defusedxml.common import DefusedXmlException - -from helpers import rendered_text, safe_extract - - -class RedliningValidator: - - def __init__(self, unpacked_dir, original_docx, verbose=False): - self.unpacked_dir = Path(unpacked_dir) - self.original_docx = Path(original_docx) - self.verbose = verbose - self.namespaces = { - "w": "http://schemas.openxmlformats.org/wordprocessingml/2006/main" - } - - def repair(self) -> int: - return 0 - - def validate(self): - modified_file = self.unpacked_dir / "word" / "document.xml" - if not modified_file.exists(): - print(f"FAILED - Modified document.xml not found at {modified_file}") - return False - - with tempfile.TemporaryDirectory() as temp_dir: - temp_path = Path(temp_dir) - - try: - with zipfile.ZipFile(self.original_docx, "r") as zip_ref: - safe_extract(zip_ref, temp_path) - except Exception as e: - print(f"FAILED - Error unpacking original docx: {e}") - return False - - original_file = temp_path / "word" / "document.xml" - if not original_file.exists(): - print( - f"FAILED - Original document.xml not found in {self.original_docx}" - ) - return False - - try: - modified_tree = ET.parse(modified_file) - modified_root = modified_tree.getroot() - original_tree = ET.parse(original_file) - original_root = original_tree.getroot() - except (ET.ParseError, DefusedXmlException) as e: - print(f"FAILED - Error parsing XML files: {e}") - return False - - new_changes = self._new_tracked_changes(original_root, modified_root) - self._remove_tracked_changes(modified_root, new_changes) - - modified_text = self._extract_text_content(modified_root) - original_text = self._extract_text_content(original_root) - - if modified_text != original_text: - error_message = self._generate_detailed_diff( - original_text, modified_text - ) - print(error_message) - return False - - if self.verbose: - print( - f"PASSED - All {len(new_changes)} change(s) against the original " - "are properly tracked" - ) - return True - - def _tracked_change_elements(self, root): - ins_tag = f"{{{self.namespaces['w']}}}ins" - del_tag = f"{{{self.namespaces['w']}}}del" - return [elem for elem in root.iter() if elem.tag in (ins_tag, del_tag)] - - def _rendered_text(self, elem): - preserve = elem.get("{http://www.w3.org/XML/1998/namespace}space") == "preserve" - return rendered_text(elem.text or "", preserve) - - def _text_elements(self, elem): - w = self.namespaces["w"] - return [ - node - for node in elem.iter() - if node.tag in (f"{{{w}}}t", f"{{{w}}}delText") - ] - - def _tracked_change_key(self, elem): - w = self.namespaces["w"] - text = "".join(self._rendered_text(node) for node in self._text_elements(elem)) - return (elem.tag, elem.get(f"{{{w}}}author"), elem.get(f"{{{w}}}date"), text) - - def _new_tracked_changes(self, original_root, modified_root): - original = self._tracked_change_elements(original_root) - modified = self._tracked_change_elements(modified_root) - - pool = {} - for elem in original: - pool.setdefault(self._tracked_change_key(elem), []).append(elem) - - matched, leftover = set(), [] - for elem in modified: - bucket = pool.get(self._tracked_change_key(elem)) - if bucket: - matched.add(bucket.pop()) - else: - leftover.append(elem) - - def group(elem): - return self._tracked_change_key(elem)[:3] - - def text_of(elems): - return "".join(self._tracked_change_key(e)[3] for e in elems) - - unmatched_original = {} - for elem in original: - if elem not in matched: - unmatched_original.setdefault(group(elem), []).append(elem) - - by_group = {} - for elem in leftover: - by_group.setdefault(group(elem), []).append(elem) - - new = set() - for key, elems in by_group.items(): - rebuilt = text_of(elems) - if rebuilt and rebuilt == text_of(unmatched_original.get(key, [])): - continue - new.update(elems) - return new - - def _generate_detailed_diff(self, original_text, modified_text): - error_parts = [ - "FAILED - Document text doesn't match after removing the tracked changes", - "", - "Likely causes:", - " 1. Modified text inside another author's or tags", - " 2. Made edits without proper tracked changes", - " 3. Didn't nest inside when deleting another's insertion", - " 4. Rewrote another author's / and changed its text on", - " the way. A tracked change from the original is recognised by its", - " author, date and text; anything that doesn't reproduce one exactly", - " reads as new, and the text it carried is reported missing.", - "", - "For pre-redlined documents, use correct patterns:", - " - To reject another's INSERTION: Nest inside their ", - " - To reject PART of one: nest around only the runs you reject.", - " Their may be split around it, so long as the pieces keep", - " their author and date and still spell out the same text.", - " - To restore another's DELETION: Add new AFTER their ", - "", - ] - - git_diff = self._get_git_word_diff(original_text, modified_text) - if git_diff: - error_parts.extend(["Differences:", "============", git_diff]) - else: - error_parts.append("Unable to generate word diff (git not available)") - - return "\n".join(error_parts) - - def _get_git_word_diff(self, original_text, modified_text): - try: - with tempfile.TemporaryDirectory() as temp_dir: - temp_path = Path(temp_dir) - - original_file = temp_path / "original.txt" - modified_file = temp_path / "modified.txt" - - original_file.write_text(original_text, encoding="utf-8") - modified_file.write_text(modified_text, encoding="utf-8") - - result = subprocess.run( - [ - "git", - "diff", - "--word-diff=plain", - "--word-diff-regex=.", - "-U0", - "--no-index", - str(original_file), - str(modified_file), - ], - capture_output=True, - text=True, - ) - - if result.stdout.strip(): - lines = result.stdout.split("\n") - content_lines = [] - in_content = False - for line in lines: - if line.startswith("@@"): - in_content = True - continue - if in_content and line.strip(): - content_lines.append(line) - - if content_lines: - return "\n".join(content_lines) - - result = subprocess.run( - [ - "git", - "diff", - "--word-diff=plain", - "-U0", - "--no-index", - str(original_file), - str(modified_file), - ], - capture_output=True, - text=True, - ) - - if result.stdout.strip(): - lines = result.stdout.split("\n") - content_lines = [] - in_content = False - for line in lines: - if line.startswith("@@"): - in_content = True - continue - if in_content and line.strip(): - content_lines.append(line) - return "\n".join(content_lines) - - except (subprocess.CalledProcessError, FileNotFoundError, Exception): - pass - - return None - - def _remove_tracked_changes(self, root, targets): - ins_tag = f"{{{self.namespaces['w']}}}ins" - del_tag = f"{{{self.namespaces['w']}}}del" - - for parent in root.iter(): - to_remove = [] - for child in parent: - if child.tag == ins_tag and child in targets: - to_remove.append(child) - for elem in to_remove: - parent.remove(elem) - - deltext_tag = f"{{{self.namespaces['w']}}}delText" - t_tag = f"{{{self.namespaces['w']}}}t" - - for parent in root.iter(): - to_process = [] - for child in parent: - if child.tag == del_tag and child in targets: - to_process.append((child, list(parent).index(child))) - - for del_elem, del_index in reversed(to_process): - for elem in del_elem.iter(): - if elem.tag == deltext_tag: - elem.tag = t_tag - - for child in reversed(list(del_elem)): - parent.insert(del_index, child) - parent.remove(del_elem) - - def _extract_text_content(self, root): - p_tag = f"{{{self.namespaces['w']}}}p" - t_tag = f"{{{self.namespaces['w']}}}t" - - paragraphs = [] - for p_elem in root.findall(f".//{p_tag}"): - text_parts = [] - for t_elem in p_elem.findall(f".//{t_tag}"): - text_parts.append(self._rendered_text(t_elem)) - paragraph_text = "".join(text_parts) - if paragraph_text: - paragraphs.append(paragraph_text) - - return "\n".join(paragraphs) - - -if __name__ == "__main__": - raise RuntimeError("This module should not be run directly.") diff --git a/src/crates/assembly/core/builtin_skills/docx/scripts/templates/comments.xml b/src/crates/assembly/core/builtin_skills/docx/scripts/templates/comments.xml deleted file mode 100644 index cd01a7d715..0000000000 --- a/src/crates/assembly/core/builtin_skills/docx/scripts/templates/comments.xml +++ /dev/null @@ -1,3 +0,0 @@ - - - diff --git a/src/crates/assembly/core/builtin_skills/docx/scripts/templates/commentsExtended.xml b/src/crates/assembly/core/builtin_skills/docx/scripts/templates/commentsExtended.xml deleted file mode 100644 index 411003cc48..0000000000 --- a/src/crates/assembly/core/builtin_skills/docx/scripts/templates/commentsExtended.xml +++ /dev/null @@ -1,3 +0,0 @@ - - - diff --git a/src/crates/assembly/core/builtin_skills/docx/scripts/templates/commentsExtensible.xml b/src/crates/assembly/core/builtin_skills/docx/scripts/templates/commentsExtensible.xml deleted file mode 100644 index f5572d7108..0000000000 --- a/src/crates/assembly/core/builtin_skills/docx/scripts/templates/commentsExtensible.xml +++ /dev/null @@ -1,3 +0,0 @@ - - - diff --git a/src/crates/assembly/core/builtin_skills/docx/scripts/templates/commentsIds.xml b/src/crates/assembly/core/builtin_skills/docx/scripts/templates/commentsIds.xml deleted file mode 100644 index 32f1629f2a..0000000000 --- a/src/crates/assembly/core/builtin_skills/docx/scripts/templates/commentsIds.xml +++ /dev/null @@ -1,3 +0,0 @@ - - - diff --git a/src/crates/assembly/core/builtin_skills/docx/scripts/templates/people.xml b/src/crates/assembly/core/builtin_skills/docx/scripts/templates/people.xml deleted file mode 100644 index 3803d2de0f..0000000000 --- a/src/crates/assembly/core/builtin_skills/docx/scripts/templates/people.xml +++ /dev/null @@ -1,3 +0,0 @@ - - - diff --git a/src/crates/assembly/core/builtin_skills/pdf/LICENSE.txt b/src/crates/assembly/core/builtin_skills/pdf/LICENSE.txt deleted file mode 100644 index c55ab42224..0000000000 --- a/src/crates/assembly/core/builtin_skills/pdf/LICENSE.txt +++ /dev/null @@ -1,30 +0,0 @@ -© 2025 Anthropic, PBC. All rights reserved. - -LICENSE: Use of these materials (including all code, prompts, assets, files, -and other components of this Skill) is governed by your agreement with -Anthropic regarding use of Anthropic's services. If no separate agreement -exists, use is governed by Anthropic's Consumer Terms of Service or -Commercial Terms of Service, as applicable: -https://www.anthropic.com/legal/consumer-terms -https://www.anthropic.com/legal/commercial-terms -Your applicable agreement is referred to as the "Agreement." "Services" are -as defined in the Agreement. - -ADDITIONAL RESTRICTIONS: Notwithstanding anything in the Agreement to the -contrary, users may not: - -- Extract these materials from the Services or retain copies of these - materials outside the Services -- Reproduce or copy these materials, except for temporary copies created - automatically during authorized use of the Services -- Create derivative works based on these materials -- Distribute, sublicense, or transfer these materials to any third party -- Make, offer to sell, sell, or import any inventions embodied in these - materials -- Reverse engineer, decompile, or disassemble these materials - -The receipt, viewing, or possession of these materials does not convey or -imply any license or right beyond those expressly granted above. - -Anthropic retains all right, title, and interest in these materials, -including all copyrights, patents, and other intellectual property rights. diff --git a/src/crates/assembly/core/builtin_skills/pdf/SKILL.md b/src/crates/assembly/core/builtin_skills/pdf/SKILL.md deleted file mode 100644 index d3e046a5ae..0000000000 --- a/src/crates/assembly/core/builtin_skills/pdf/SKILL.md +++ /dev/null @@ -1,314 +0,0 @@ ---- -name: pdf -description: Use this skill whenever the user wants to do anything with PDF files. This includes reading or extracting text/tables from PDFs, combining or merging multiple PDFs into one, splitting PDFs apart, rotating pages, adding watermarks, creating new PDFs, filling PDF forms, encrypting/decrypting PDFs, extracting images, and OCR on scanned PDFs to make them searchable. If the user mentions a .pdf file or asks to produce one, use this skill. -license: Proprietary. LICENSE.txt has complete terms ---- - -# PDF Processing Guide - -## Overview - -This guide covers essential PDF processing operations using Python libraries and command-line tools. For advanced features, JavaScript libraries, and detailed examples, see REFERENCE.md. If you need to fill out a PDF form, read FORMS.md and follow its instructions. - -## Quick Start - -```python -from pypdf import PdfReader, PdfWriter - -# Read a PDF -reader = PdfReader("document.pdf") -print(f"Pages: {len(reader.pages)}") - -# Extract text -text = "" -for page in reader.pages: - text += page.extract_text() -``` - -## Python Libraries - -### pypdf - Basic Operations - -#### Merge PDFs -```python -from pypdf import PdfWriter, PdfReader - -writer = PdfWriter() -for pdf_file in ["doc1.pdf", "doc2.pdf", "doc3.pdf"]: - reader = PdfReader(pdf_file) - for page in reader.pages: - writer.add_page(page) - -with open("merged.pdf", "wb") as output: - writer.write(output) -``` - -#### Split PDF -```python -reader = PdfReader("input.pdf") -for i, page in enumerate(reader.pages): - writer = PdfWriter() - writer.add_page(page) - with open(f"page_{i+1}.pdf", "wb") as output: - writer.write(output) -``` - -#### Extract Metadata -```python -reader = PdfReader("document.pdf") -meta = reader.metadata -print(f"Title: {meta.title}") -print(f"Author: {meta.author}") -print(f"Subject: {meta.subject}") -print(f"Creator: {meta.creator}") -``` - -#### Rotate Pages -```python -reader = PdfReader("input.pdf") -writer = PdfWriter() - -page = reader.pages[0] -page.rotate(90) # Rotate 90 degrees clockwise -writer.add_page(page) - -with open("rotated.pdf", "wb") as output: - writer.write(output) -``` - -### pdfplumber - Text and Table Extraction - -#### Extract Text with Layout -```python -import pdfplumber - -with pdfplumber.open("document.pdf") as pdf: - for page in pdf.pages: - text = page.extract_text() - print(text) -``` - -#### Extract Tables -```python -with pdfplumber.open("document.pdf") as pdf: - for i, page in enumerate(pdf.pages): - tables = page.extract_tables() - for j, table in enumerate(tables): - print(f"Table {j+1} on page {i+1}:") - for row in table: - print(row) -``` - -#### Advanced Table Extraction -```python -import pandas as pd - -with pdfplumber.open("document.pdf") as pdf: - all_tables = [] - for page in pdf.pages: - tables = page.extract_tables() - for table in tables: - if table: # Check if table is not empty - df = pd.DataFrame(table[1:], columns=table[0]) - all_tables.append(df) - -# Combine all tables -if all_tables: - combined_df = pd.concat(all_tables, ignore_index=True) - combined_df.to_excel("extracted_tables.xlsx", index=False) -``` - -### reportlab - Create PDFs - -#### Basic PDF Creation -```python -from reportlab.lib.pagesizes import letter -from reportlab.pdfgen import canvas - -c = canvas.Canvas("hello.pdf", pagesize=letter) -width, height = letter - -# Add text -c.drawString(100, height - 100, "Hello World!") -c.drawString(100, height - 120, "This is a PDF created with reportlab") - -# Add a line -c.line(100, height - 140, 400, height - 140) - -# Save -c.save() -``` - -#### Create PDF with Multiple Pages -```python -from reportlab.lib.pagesizes import letter -from reportlab.platypus import SimpleDocTemplate, Paragraph, Spacer, PageBreak -from reportlab.lib.styles import getSampleStyleSheet - -doc = SimpleDocTemplate("report.pdf", pagesize=letter) -styles = getSampleStyleSheet() -story = [] - -# Add content -title = Paragraph("Report Title", styles['Title']) -story.append(title) -story.append(Spacer(1, 12)) - -body = Paragraph("This is the body of the report. " * 20, styles['Normal']) -story.append(body) -story.append(PageBreak()) - -# Page 2 -story.append(Paragraph("Page 2", styles['Heading1'])) -story.append(Paragraph("Content for page 2", styles['Normal'])) - -# Build PDF -doc.build(story) -``` - -#### Subscripts and Superscripts - -**IMPORTANT**: Never use Unicode subscript/superscript characters (₀₁₂₃₄₅₆₇₈₉, ⁰¹²³⁴⁵⁶⁷⁸⁹) in ReportLab PDFs. The built-in fonts do not include these glyphs, causing them to render as solid black boxes. - -Instead, use ReportLab's XML markup tags in Paragraph objects: -```python -from reportlab.platypus import Paragraph -from reportlab.lib.styles import getSampleStyleSheet - -styles = getSampleStyleSheet() - -# Subscripts: use tag -chemical = Paragraph("H2O", styles['Normal']) - -# Superscripts: use tag -squared = Paragraph("x2 + y2", styles['Normal']) -``` - -For canvas-drawn text (not Paragraph objects), manually adjust font the size and position rather than using Unicode subscripts/superscripts. - -## Command-Line Tools - -### pdftotext (poppler-utils) -```bash -# Extract text -pdftotext input.pdf output.txt - -# Extract text preserving layout -pdftotext -layout input.pdf output.txt - -# Extract specific pages -pdftotext -f 1 -l 5 input.pdf output.txt # Pages 1-5 -``` - -### qpdf -```bash -# Merge PDFs -qpdf --empty --pages file1.pdf file2.pdf -- merged.pdf - -# Split pages -qpdf input.pdf --pages . 1-5 -- pages1-5.pdf -qpdf input.pdf --pages . 6-10 -- pages6-10.pdf - -# Rotate pages -qpdf input.pdf output.pdf --rotate=+90:1 # Rotate page 1 by 90 degrees - -# Remove password -qpdf --password=mypassword --decrypt encrypted.pdf decrypted.pdf -``` - -### pdftk (if available) -```bash -# Merge -pdftk file1.pdf file2.pdf cat output merged.pdf - -# Split -pdftk input.pdf burst - -# Rotate -pdftk input.pdf rotate 1east output rotated.pdf -``` - -## Common Tasks - -### Extract Text from Scanned PDFs -```python -# Requires: pip install pytesseract pdf2image -import pytesseract -from pdf2image import convert_from_path - -# Convert PDF to images -images = convert_from_path('scanned.pdf') - -# OCR each page -text = "" -for i, image in enumerate(images): - text += f"Page {i+1}:\n" - text += pytesseract.image_to_string(image) - text += "\n\n" - -print(text) -``` - -### Add Watermark -```python -from pypdf import PdfReader, PdfWriter - -# Create watermark (or load existing) -watermark = PdfReader("watermark.pdf").pages[0] - -# Apply to all pages -reader = PdfReader("document.pdf") -writer = PdfWriter() - -for page in reader.pages: - page.merge_page(watermark) - writer.add_page(page) - -with open("watermarked.pdf", "wb") as output: - writer.write(output) -``` - -### Extract Images -```bash -# Using pdfimages (poppler-utils) -pdfimages -j input.pdf output_prefix - -# This extracts all images as output_prefix-000.jpg, output_prefix-001.jpg, etc. -``` - -### Password Protection -```python -from pypdf import PdfReader, PdfWriter - -reader = PdfReader("input.pdf") -writer = PdfWriter() - -for page in reader.pages: - writer.add_page(page) - -# Add password -writer.encrypt("userpassword", "ownerpassword") - -with open("encrypted.pdf", "wb") as output: - writer.write(output) -``` - -## Quick Reference - -| Task | Best Tool | Command/Code | -|------|-----------|--------------| -| Merge PDFs | pypdf | `writer.add_page(page)` | -| Split PDFs | pypdf | One page per file | -| Extract text | pdfplumber | `page.extract_text()` | -| Extract tables | pdfplumber | `page.extract_tables()` | -| Create PDFs | reportlab | Canvas or Platypus | -| Command line merge | qpdf | `qpdf --empty --pages ...` | -| OCR scanned PDFs | pytesseract | Convert to image first | -| Fill PDF forms | pdf-lib or pypdf (see FORMS.md) | See FORMS.md | - -## Next Steps - -- For advanced pypdfium2 usage, see REFERENCE.md -- For JavaScript libraries (pdf-lib), see REFERENCE.md -- If you need to fill out a PDF form, follow the instructions in FORMS.md -- For troubleshooting guides, see REFERENCE.md diff --git a/src/crates/assembly/core/builtin_skills/pdf/forms.md b/src/crates/assembly/core/builtin_skills/pdf/forms.md deleted file mode 100644 index 6e7e1e0d9e..0000000000 --- a/src/crates/assembly/core/builtin_skills/pdf/forms.md +++ /dev/null @@ -1,294 +0,0 @@ -**CRITICAL: You MUST complete these steps in order. Do not skip ahead to writing code.** - -If you need to fill out a PDF form, first check to see if the PDF has fillable form fields. Run this script from this file's directory: - `python scripts/check_fillable_fields `, and depending on the result go to either the "Fillable fields" or "Non-fillable fields" and follow those instructions. - -# Fillable fields -If the PDF has fillable form fields: -- Run this script from this file's directory: `python scripts/extract_form_field_info.py `. It will create a JSON file with a list of fields in this format: -``` -[ - { - "field_id": (unique ID for the field), - "page": (page number, 1-based), - "rect": ([left, bottom, right, top] bounding box in PDF coordinates, y=0 is the bottom of the page), - "type": ("text", "checkbox", "radio_group", or "choice"), - }, - // Checkboxes have "checked_value" and "unchecked_value" properties: - { - "field_id": (unique ID for the field), - "page": (page number, 1-based), - "type": "checkbox", - "checked_value": (Set the field to this value to check the checkbox), - "unchecked_value": (Set the field to this value to uncheck the checkbox), - }, - // Radio groups have a "radio_options" list with the possible choices. - { - "field_id": (unique ID for the field), - "page": (page number, 1-based), - "type": "radio_group", - "radio_options": [ - { - "value": (set the field to this value to select this radio option), - "rect": (bounding box for the radio button for this option) - }, - // Other radio options - ] - }, - // Multiple choice fields have a "choice_options" list with the possible choices: - { - "field_id": (unique ID for the field), - "page": (page number, 1-based), - "type": "choice", - "choice_options": [ - { - "value": (set the field to this value to select this option), - "text": (display text of the option) - }, - // Other choice options - ], - } -] -``` -- Convert the PDF to PNGs (one image for each page) with this script (run from this file's directory): -`python scripts/convert_pdf_to_images.py ` -Then analyze the images to determine the purpose of each form field (make sure to convert the bounding box PDF coordinates to image coordinates). -- Create a `field_values.json` file in this format with the values to be entered for each field: -``` -[ - { - "field_id": "last_name", // Must match the field_id from `extract_form_field_info.py` - "description": "The user's last name", - "page": 1, // Must match the "page" value in field_info.json - "value": "Simpson" - }, - { - "field_id": "Checkbox12", - "description": "Checkbox to be checked if the user is 18 or over", - "page": 1, - "value": "/On" // If this is a checkbox, use its "checked_value" value to check it. If it's a radio button group, use one of the "value" values in "radio_options". - }, - // more fields -] -``` -- Run the `fill_fillable_fields.py` script from this file's directory to create a filled-in PDF: -`python scripts/fill_fillable_fields.py ` -This script will verify that the field IDs and values you provide are valid; if it prints error messages, correct the appropriate fields and try again. - -# Non-fillable fields -If the PDF doesn't have fillable form fields, you'll add text annotations. First try to extract coordinates from the PDF structure (more accurate), then fall back to visual estimation if needed. - -## Step 1: Try Structure Extraction First - -Run this script to extract text labels, lines, and checkboxes with their exact PDF coordinates: -`python scripts/extract_form_structure.py form_structure.json` - -This creates a JSON file containing: -- **labels**: Every text element with exact coordinates (x0, top, x1, bottom in PDF points) -- **lines**: Horizontal lines that define row boundaries -- **checkboxes**: Small square rectangles that are checkboxes (with center coordinates) -- **row_boundaries**: Row top/bottom positions calculated from horizontal lines - -**Check the results**: If `form_structure.json` has meaningful labels (text elements that correspond to form fields), use **Approach A: Structure-Based Coordinates**. If the PDF is scanned/image-based and has few or no labels, use **Approach B: Visual Estimation**. - ---- - -## Approach A: Structure-Based Coordinates (Preferred) - -Use this when `extract_form_structure.py` found text labels in the PDF. - -### A.1: Analyze the Structure - -Read form_structure.json and identify: - -1. **Label groups**: Adjacent text elements that form a single label (e.g., "Last" + "Name") -2. **Row structure**: Labels with similar `top` values are in the same row -3. **Field columns**: Entry areas start after label ends (x0 = label.x1 + gap) -4. **Checkboxes**: Use the checkbox coordinates directly from the structure - -**Coordinate system**: PDF coordinates where y=0 is at TOP of page, y increases downward. - -### A.2: Check for Missing Elements - -The structure extraction may not detect all form elements. Common cases: -- **Circular checkboxes**: Only square rectangles are detected as checkboxes -- **Complex graphics**: Decorative elements or non-standard form controls -- **Faded or light-colored elements**: May not be extracted - -If you see form fields in the PDF images that aren't in form_structure.json, you'll need to use **visual analysis** for those specific fields (see "Hybrid Approach" below). - -### A.3: Create fields.json with PDF Coordinates - -For each field, calculate entry coordinates from the extracted structure: - -**Text fields:** -- entry x0 = label x1 + 5 (small gap after label) -- entry x1 = next label's x0, or row boundary -- entry top = same as label top -- entry bottom = row boundary line below, or label bottom + row_height - -**Checkboxes:** -- Use the checkbox rectangle coordinates directly from form_structure.json -- entry_bounding_box = [checkbox.x0, checkbox.top, checkbox.x1, checkbox.bottom] - -Create fields.json using `pdf_width` and `pdf_height` (signals PDF coordinates): -```json -{ - "pages": [ - {"page_number": 1, "pdf_width": 612, "pdf_height": 792} - ], - "form_fields": [ - { - "page_number": 1, - "description": "Last name entry field", - "field_label": "Last Name", - "label_bounding_box": [43, 63, 87, 73], - "entry_bounding_box": [92, 63, 260, 79], - "entry_text": {"text": "Smith", "font_size": 10} - }, - { - "page_number": 1, - "description": "US Citizen Yes checkbox", - "field_label": "Yes", - "label_bounding_box": [260, 200, 280, 210], - "entry_bounding_box": [285, 197, 292, 205], - "entry_text": {"text": "X"} - } - ] -} -``` - -**Important**: Use `pdf_width`/`pdf_height` and coordinates directly from form_structure.json. - -### A.4: Validate Bounding Boxes - -Before filling, check your bounding boxes for errors: -`python scripts/check_bounding_boxes.py fields.json` - -This checks for intersecting bounding boxes and entry boxes that are too small for the font size. Fix any reported errors before filling. - ---- - -## Approach B: Visual Estimation (Fallback) - -Use this when the PDF is scanned/image-based and structure extraction found no usable text labels (e.g., all text shows as "(cid:X)" patterns). - -### B.1: Convert PDF to Images - -`python scripts/convert_pdf_to_images.py ` - -### B.2: Initial Field Identification - -Examine each page image to identify form sections and get **rough estimates** of field locations: -- Form field labels and their approximate positions -- Entry areas (lines, boxes, or blank spaces for text input) -- Checkboxes and their approximate locations - -For each field, note approximate pixel coordinates (they don't need to be precise yet). - -### B.3: Zoom Refinement (CRITICAL for accuracy) - -For each field, crop a region around the estimated position to refine coordinates precisely. - -**Create a zoomed crop using ImageMagick:** -```bash -magick -crop x++ +repage -``` - -Where: -- `, ` = top-left corner of crop region (use your rough estimate minus padding) -- `, ` = size of crop region (field area plus ~50px padding on each side) - -**Example:** To refine a "Name" field estimated around (100, 150): -```bash -magick images_dir/page_1.png -crop 300x80+50+120 +repage crops/name_field.png -``` - -(Note: if the `magick` command isn't available, try `convert` with the same arguments). - -**Examine the cropped image** to determine precise coordinates: -1. Identify the exact pixel where the entry area begins (after the label) -2. Identify where the entry area ends (before next field or edge) -3. Identify the top and bottom of the entry line/box - -**Convert crop coordinates back to full image coordinates:** -- full_x = crop_x + crop_offset_x -- full_y = crop_y + crop_offset_y - -Example: If the crop started at (50, 120) and the entry box starts at (52, 18) within the crop: -- entry_x0 = 52 + 50 = 102 -- entry_top = 18 + 120 = 138 - -**Repeat for each field**, grouping nearby fields into single crops when possible. - -### B.4: Create fields.json with Refined Coordinates - -Create fields.json using `image_width` and `image_height` (signals image coordinates): -```json -{ - "pages": [ - {"page_number": 1, "image_width": 1700, "image_height": 2200} - ], - "form_fields": [ - { - "page_number": 1, - "description": "Last name entry field", - "field_label": "Last Name", - "label_bounding_box": [120, 175, 242, 198], - "entry_bounding_box": [255, 175, 720, 218], - "entry_text": {"text": "Smith", "font_size": 10} - } - ] -} -``` - -**Important**: Use `image_width`/`image_height` and the refined pixel coordinates from the zoom analysis. - -### B.5: Validate Bounding Boxes - -Before filling, check your bounding boxes for errors: -`python scripts/check_bounding_boxes.py fields.json` - -This checks for intersecting bounding boxes and entry boxes that are too small for the font size. Fix any reported errors before filling. - ---- - -## Hybrid Approach: Structure + Visual - -Use this when structure extraction works for most fields but misses some elements (e.g., circular checkboxes, unusual form controls). - -1. **Use Approach A** for fields that were detected in form_structure.json -2. **Convert PDF to images** for visual analysis of missing fields -3. **Use zoom refinement** (from Approach B) for the missing fields -4. **Combine coordinates**: For fields from structure extraction, use `pdf_width`/`pdf_height`. For visually-estimated fields, you must convert image coordinates to PDF coordinates: - - pdf_x = image_x * (pdf_width / image_width) - - pdf_y = image_y * (pdf_height / image_height) -5. **Use a single coordinate system** in fields.json - convert all to PDF coordinates with `pdf_width`/`pdf_height` - ---- - -## Step 2: Validate Before Filling - -**Always validate bounding boxes before filling:** -`python scripts/check_bounding_boxes.py fields.json` - -This checks for: -- Intersecting bounding boxes (which would cause overlapping text) -- Entry boxes that are too small for the specified font size - -Fix any reported errors in fields.json before proceeding. - -## Step 3: Fill the Form - -The fill script auto-detects the coordinate system and handles conversion: -`python scripts/fill_pdf_form_with_annotations.py fields.json ` - -## Step 4: Verify Output - -Convert the filled PDF to images and verify text placement: -`python scripts/convert_pdf_to_images.py ` - -If text is mispositioned: -- **Approach A**: Check that you're using PDF coordinates from form_structure.json with `pdf_width`/`pdf_height` -- **Approach B**: Check that image dimensions match and coordinates are accurate pixels -- **Hybrid**: Ensure coordinate conversions are correct for visually-estimated fields diff --git a/src/crates/assembly/core/builtin_skills/pdf/reference.md b/src/crates/assembly/core/builtin_skills/pdf/reference.md deleted file mode 100644 index 41400bf4fc..0000000000 --- a/src/crates/assembly/core/builtin_skills/pdf/reference.md +++ /dev/null @@ -1,612 +0,0 @@ -# PDF Processing Advanced Reference - -This document contains advanced PDF processing features, detailed examples, and additional libraries not covered in the main skill instructions. - -## pypdfium2 Library (Apache/BSD License) - -### Overview -pypdfium2 is a Python binding for PDFium (Chromium's PDF library). It's excellent for fast PDF rendering, image generation, and serves as a PyMuPDF replacement. - -### Render PDF to Images -```python -import pypdfium2 as pdfium -from PIL import Image - -# Load PDF -pdf = pdfium.PdfDocument("document.pdf") - -# Render page to image -page = pdf[0] # First page -bitmap = page.render( - scale=2.0, # Higher resolution - rotation=0 # No rotation -) - -# Convert to PIL Image -img = bitmap.to_pil() -img.save("page_1.png", "PNG") - -# Process multiple pages -for i, page in enumerate(pdf): - bitmap = page.render(scale=1.5) - img = bitmap.to_pil() - img.save(f"page_{i+1}.jpg", "JPEG", quality=90) -``` - -### Extract Text with pypdfium2 -```python -import pypdfium2 as pdfium - -pdf = pdfium.PdfDocument("document.pdf") -for i, page in enumerate(pdf): - text = page.get_text() - print(f"Page {i+1} text length: {len(text)} chars") -``` - -## JavaScript Libraries - -### pdf-lib (MIT License) - -pdf-lib is a powerful JavaScript library for creating and modifying PDF documents in any JavaScript environment. - -#### Load and Manipulate Existing PDF -```javascript -import { PDFDocument } from 'pdf-lib'; -import fs from 'fs'; - -async function manipulatePDF() { - // Load existing PDF - const existingPdfBytes = fs.readFileSync('input.pdf'); - const pdfDoc = await PDFDocument.load(existingPdfBytes); - - // Get page count - const pageCount = pdfDoc.getPageCount(); - console.log(`Document has ${pageCount} pages`); - - // Add new page - const newPage = pdfDoc.addPage([600, 400]); - newPage.drawText('Added by pdf-lib', { - x: 100, - y: 300, - size: 16 - }); - - // Save modified PDF - const pdfBytes = await pdfDoc.save(); - fs.writeFileSync('modified.pdf', pdfBytes); -} -``` - -#### Create Complex PDFs from Scratch -```javascript -import { PDFDocument, rgb, StandardFonts } from 'pdf-lib'; -import fs from 'fs'; - -async function createPDF() { - const pdfDoc = await PDFDocument.create(); - - // Add fonts - const helveticaFont = await pdfDoc.embedFont(StandardFonts.Helvetica); - const helveticaBold = await pdfDoc.embedFont(StandardFonts.HelveticaBold); - - // Add page - const page = pdfDoc.addPage([595, 842]); // A4 size - const { width, height } = page.getSize(); - - // Add text with styling - page.drawText('Invoice #12345', { - x: 50, - y: height - 50, - size: 18, - font: helveticaBold, - color: rgb(0.2, 0.2, 0.8) - }); - - // Add rectangle (header background) - page.drawRectangle({ - x: 40, - y: height - 100, - width: width - 80, - height: 30, - color: rgb(0.9, 0.9, 0.9) - }); - - // Add table-like content - const items = [ - ['Item', 'Qty', 'Price', 'Total'], - ['Widget', '2', '$50', '$100'], - ['Gadget', '1', '$75', '$75'] - ]; - - let yPos = height - 150; - items.forEach(row => { - let xPos = 50; - row.forEach(cell => { - page.drawText(cell, { - x: xPos, - y: yPos, - size: 12, - font: helveticaFont - }); - xPos += 120; - }); - yPos -= 25; - }); - - const pdfBytes = await pdfDoc.save(); - fs.writeFileSync('created.pdf', pdfBytes); -} -``` - -#### Advanced Merge and Split Operations -```javascript -import { PDFDocument } from 'pdf-lib'; -import fs from 'fs'; - -async function mergePDFs() { - // Create new document - const mergedPdf = await PDFDocument.create(); - - // Load source PDFs - const pdf1Bytes = fs.readFileSync('doc1.pdf'); - const pdf2Bytes = fs.readFileSync('doc2.pdf'); - - const pdf1 = await PDFDocument.load(pdf1Bytes); - const pdf2 = await PDFDocument.load(pdf2Bytes); - - // Copy pages from first PDF - const pdf1Pages = await mergedPdf.copyPages(pdf1, pdf1.getPageIndices()); - pdf1Pages.forEach(page => mergedPdf.addPage(page)); - - // Copy specific pages from second PDF (pages 0, 2, 4) - const pdf2Pages = await mergedPdf.copyPages(pdf2, [0, 2, 4]); - pdf2Pages.forEach(page => mergedPdf.addPage(page)); - - const mergedPdfBytes = await mergedPdf.save(); - fs.writeFileSync('merged.pdf', mergedPdfBytes); -} -``` - -### pdfjs-dist (Apache License) - -PDF.js is Mozilla's JavaScript library for rendering PDFs in the browser. - -#### Basic PDF Loading and Rendering -```javascript -import * as pdfjsLib from 'pdfjs-dist'; - -// Configure worker (important for performance) -pdfjsLib.GlobalWorkerOptions.workerSrc = './pdf.worker.js'; - -async function renderPDF() { - // Load PDF - const loadingTask = pdfjsLib.getDocument('document.pdf'); - const pdf = await loadingTask.promise; - - console.log(`Loaded PDF with ${pdf.numPages} pages`); - - // Get first page - const page = await pdf.getPage(1); - const viewport = page.getViewport({ scale: 1.5 }); - - // Render to canvas - const canvas = document.createElement('canvas'); - const context = canvas.getContext('2d'); - canvas.height = viewport.height; - canvas.width = viewport.width; - - const renderContext = { - canvasContext: context, - viewport: viewport - }; - - await page.render(renderContext).promise; - document.body.appendChild(canvas); -} -``` - -#### Extract Text with Coordinates -```javascript -import * as pdfjsLib from 'pdfjs-dist'; - -async function extractText() { - const loadingTask = pdfjsLib.getDocument('document.pdf'); - const pdf = await loadingTask.promise; - - let fullText = ''; - - // Extract text from all pages - for (let i = 1; i <= pdf.numPages; i++) { - const page = await pdf.getPage(i); - const textContent = await page.getTextContent(); - - const pageText = textContent.items - .map(item => item.str) - .join(' '); - - fullText += `\n--- Page ${i} ---\n${pageText}`; - - // Get text with coordinates for advanced processing - const textWithCoords = textContent.items.map(item => ({ - text: item.str, - x: item.transform[4], - y: item.transform[5], - width: item.width, - height: item.height - })); - } - - console.log(fullText); - return fullText; -} -``` - -#### Extract Annotations and Forms -```javascript -import * as pdfjsLib from 'pdfjs-dist'; - -async function extractAnnotations() { - const loadingTask = pdfjsLib.getDocument('annotated.pdf'); - const pdf = await loadingTask.promise; - - for (let i = 1; i <= pdf.numPages; i++) { - const page = await pdf.getPage(i); - const annotations = await page.getAnnotations(); - - annotations.forEach(annotation => { - console.log(`Annotation type: ${annotation.subtype}`); - console.log(`Content: ${annotation.contents}`); - console.log(`Coordinates: ${JSON.stringify(annotation.rect)}`); - }); - } -} -``` - -## Advanced Command-Line Operations - -### poppler-utils Advanced Features - -#### Extract Text with Bounding Box Coordinates -```bash -# Extract text with bounding box coordinates (essential for structured data) -pdftotext -bbox-layout document.pdf output.xml - -# The XML output contains precise coordinates for each text element -``` - -#### Advanced Image Conversion -```bash -# Convert to PNG images with specific resolution -pdftoppm -png -r 300 document.pdf output_prefix - -# Convert specific page range with high resolution -pdftoppm -png -r 600 -f 1 -l 3 document.pdf high_res_pages - -# Convert to JPEG with quality setting -pdftoppm -jpeg -jpegopt quality=85 -r 200 document.pdf jpeg_output -``` - -#### Extract Embedded Images -```bash -# Extract all embedded images with metadata -pdfimages -j -p document.pdf page_images - -# List image info without extracting -pdfimages -list document.pdf - -# Extract images in their original format -pdfimages -all document.pdf images/img -``` - -### qpdf Advanced Features - -#### Complex Page Manipulation -```bash -# Split PDF into groups of pages -qpdf --split-pages=3 input.pdf output_group_%02d.pdf - -# Extract specific pages with complex ranges -qpdf input.pdf --pages input.pdf 1,3-5,8,10-end -- extracted.pdf - -# Merge specific pages from multiple PDFs -qpdf --empty --pages doc1.pdf 1-3 doc2.pdf 5-7 doc3.pdf 2,4 -- combined.pdf -``` - -#### PDF Optimization and Repair -```bash -# Optimize PDF for web (linearize for streaming) -qpdf --linearize input.pdf optimized.pdf - -# Remove unused objects and compress -qpdf --optimize-level=all input.pdf compressed.pdf - -# Attempt to repair corrupted PDF structure -qpdf --check input.pdf -qpdf --fix-qdf damaged.pdf repaired.pdf - -# Show detailed PDF structure for debugging -qpdf --show-all-pages input.pdf > structure.txt -``` - -#### Advanced Encryption -```bash -# Add password protection with specific permissions -qpdf --encrypt user_pass owner_pass 256 --print=none --modify=none -- input.pdf encrypted.pdf - -# Check encryption status -qpdf --show-encryption encrypted.pdf - -# Remove password protection (requires password) -qpdf --password=secret123 --decrypt encrypted.pdf decrypted.pdf -``` - -## Advanced Python Techniques - -### pdfplumber Advanced Features - -#### Extract Text with Precise Coordinates -```python -import pdfplumber - -with pdfplumber.open("document.pdf") as pdf: - page = pdf.pages[0] - - # Extract all text with coordinates - chars = page.chars - for char in chars[:10]: # First 10 characters - print(f"Char: '{char['text']}' at x:{char['x0']:.1f} y:{char['y0']:.1f}") - - # Extract text by bounding box (left, top, right, bottom) - bbox_text = page.within_bbox((100, 100, 400, 200)).extract_text() -``` - -#### Advanced Table Extraction with Custom Settings -```python -import pdfplumber -import pandas as pd - -with pdfplumber.open("complex_table.pdf") as pdf: - page = pdf.pages[0] - - # Extract tables with custom settings for complex layouts - table_settings = { - "vertical_strategy": "lines", - "horizontal_strategy": "lines", - "snap_tolerance": 3, - "intersection_tolerance": 15 - } - tables = page.extract_tables(table_settings) - - # Visual debugging for table extraction - img = page.to_image(resolution=150) - img.save("debug_layout.png") -``` - -### reportlab Advanced Features - -#### Create Professional Reports with Tables -```python -from reportlab.platypus import SimpleDocTemplate, Table, TableStyle, Paragraph -from reportlab.lib.styles import getSampleStyleSheet -from reportlab.lib import colors - -# Sample data -data = [ - ['Product', 'Q1', 'Q2', 'Q3', 'Q4'], - ['Widgets', '120', '135', '142', '158'], - ['Gadgets', '85', '92', '98', '105'] -] - -# Create PDF with table -doc = SimpleDocTemplate("report.pdf") -elements = [] - -# Add title -styles = getSampleStyleSheet() -title = Paragraph("Quarterly Sales Report", styles['Title']) -elements.append(title) - -# Add table with advanced styling -table = Table(data) -table.setStyle(TableStyle([ - ('BACKGROUND', (0, 0), (-1, 0), colors.grey), - ('TEXTCOLOR', (0, 0), (-1, 0), colors.whitesmoke), - ('ALIGN', (0, 0), (-1, -1), 'CENTER'), - ('FONTNAME', (0, 0), (-1, 0), 'Helvetica-Bold'), - ('FONTSIZE', (0, 0), (-1, 0), 14), - ('BOTTOMPADDING', (0, 0), (-1, 0), 12), - ('BACKGROUND', (0, 1), (-1, -1), colors.beige), - ('GRID', (0, 0), (-1, -1), 1, colors.black) -])) -elements.append(table) - -doc.build(elements) -``` - -## Complex Workflows - -### Extract Figures/Images from PDF - -#### Method 1: Using pdfimages (fastest) -```bash -# Extract all images with original quality -pdfimages -all document.pdf images/img -``` - -#### Method 2: Using pypdfium2 + Image Processing -```python -import pypdfium2 as pdfium -from PIL import Image -import numpy as np - -def extract_figures(pdf_path, output_dir): - pdf = pdfium.PdfDocument(pdf_path) - - for page_num, page in enumerate(pdf): - # Render high-resolution page - bitmap = page.render(scale=3.0) - img = bitmap.to_pil() - - # Convert to numpy for processing - img_array = np.array(img) - - # Simple figure detection (non-white regions) - mask = np.any(img_array != [255, 255, 255], axis=2) - - # Find contours and extract bounding boxes - # (This is simplified - real implementation would need more sophisticated detection) - - # Save detected figures - # ... implementation depends on specific needs -``` - -### Batch PDF Processing with Error Handling -```python -import os -import glob -from pypdf import PdfReader, PdfWriter -import logging - -logging.basicConfig(level=logging.INFO) -logger = logging.getLogger(__name__) - -def batch_process_pdfs(input_dir, operation='merge'): - pdf_files = glob.glob(os.path.join(input_dir, "*.pdf")) - - if operation == 'merge': - writer = PdfWriter() - for pdf_file in pdf_files: - try: - reader = PdfReader(pdf_file) - for page in reader.pages: - writer.add_page(page) - logger.info(f"Processed: {pdf_file}") - except Exception as e: - logger.error(f"Failed to process {pdf_file}: {e}") - continue - - with open("batch_merged.pdf", "wb") as output: - writer.write(output) - - elif operation == 'extract_text': - for pdf_file in pdf_files: - try: - reader = PdfReader(pdf_file) - text = "" - for page in reader.pages: - text += page.extract_text() - - output_file = pdf_file.replace('.pdf', '.txt') - with open(output_file, 'w', encoding='utf-8') as f: - f.write(text) - logger.info(f"Extracted text from: {pdf_file}") - - except Exception as e: - logger.error(f"Failed to extract text from {pdf_file}: {e}") - continue -``` - -### Advanced PDF Cropping -```python -from pypdf import PdfWriter, PdfReader - -reader = PdfReader("input.pdf") -writer = PdfWriter() - -# Crop page (left, bottom, right, top in points) -page = reader.pages[0] -page.mediabox.left = 50 -page.mediabox.bottom = 50 -page.mediabox.right = 550 -page.mediabox.top = 750 - -writer.add_page(page) -with open("cropped.pdf", "wb") as output: - writer.write(output) -``` - -## Performance Optimization Tips - -### 1. For Large PDFs -- Use streaming approaches instead of loading entire PDF in memory -- Use `qpdf --split-pages` for splitting large files -- Process pages individually with pypdfium2 - -### 2. For Text Extraction -- `pdftotext -bbox-layout` is fastest for plain text extraction -- Use pdfplumber for structured data and tables -- Avoid `pypdf.extract_text()` for very large documents - -### 3. For Image Extraction -- `pdfimages` is much faster than rendering pages -- Use low resolution for previews, high resolution for final output - -### 4. For Form Filling -- pdf-lib maintains form structure better than most alternatives -- Pre-validate form fields before processing - -### 5. Memory Management -```python -# Process PDFs in chunks -def process_large_pdf(pdf_path, chunk_size=10): - reader = PdfReader(pdf_path) - total_pages = len(reader.pages) - - for start_idx in range(0, total_pages, chunk_size): - end_idx = min(start_idx + chunk_size, total_pages) - writer = PdfWriter() - - for i in range(start_idx, end_idx): - writer.add_page(reader.pages[i]) - - # Process chunk - with open(f"chunk_{start_idx//chunk_size}.pdf", "wb") as output: - writer.write(output) -``` - -## Troubleshooting Common Issues - -### Encrypted PDFs -```python -# Handle password-protected PDFs -from pypdf import PdfReader - -try: - reader = PdfReader("encrypted.pdf") - if reader.is_encrypted: - reader.decrypt("password") -except Exception as e: - print(f"Failed to decrypt: {e}") -``` - -### Corrupted PDFs -```bash -# Use qpdf to repair -qpdf --check corrupted.pdf -qpdf --replace-input corrupted.pdf -``` - -### Text Extraction Issues -```python -# Fallback to OCR for scanned PDFs -import pytesseract -from pdf2image import convert_from_path - -def extract_text_with_ocr(pdf_path): - images = convert_from_path(pdf_path) - text = "" - for i, image in enumerate(images): - text += pytesseract.image_to_string(image) - return text -``` - -## License Information - -- **pypdf**: BSD License -- **pdfplumber**: MIT License -- **pypdfium2**: Apache/BSD License -- **reportlab**: BSD License -- **poppler-utils**: GPL-2 License -- **qpdf**: Apache License -- **pdf-lib**: MIT License -- **pdfjs-dist**: Apache License \ No newline at end of file diff --git a/src/crates/assembly/core/builtin_skills/pdf/scripts/check_bounding_boxes.py b/src/crates/assembly/core/builtin_skills/pdf/scripts/check_bounding_boxes.py deleted file mode 100644 index 2cc5e348f3..0000000000 --- a/src/crates/assembly/core/builtin_skills/pdf/scripts/check_bounding_boxes.py +++ /dev/null @@ -1,65 +0,0 @@ -from dataclasses import dataclass -import json -import sys - - - - -@dataclass -class RectAndField: - rect: list[float] - rect_type: str - field: dict - - -def get_bounding_box_messages(fields_json_stream) -> list[str]: - messages = [] - fields = json.load(fields_json_stream) - messages.append(f"Read {len(fields['form_fields'])} fields") - - def rects_intersect(r1, r2): - disjoint_horizontal = r1[0] >= r2[2] or r1[2] <= r2[0] - disjoint_vertical = r1[1] >= r2[3] or r1[3] <= r2[1] - return not (disjoint_horizontal or disjoint_vertical) - - rects_and_fields = [] - for f in fields["form_fields"]: - rects_and_fields.append(RectAndField(f["label_bounding_box"], "label", f)) - rects_and_fields.append(RectAndField(f["entry_bounding_box"], "entry", f)) - - has_error = False - for i, ri in enumerate(rects_and_fields): - for j in range(i + 1, len(rects_and_fields)): - rj = rects_and_fields[j] - if ri.field["page_number"] == rj.field["page_number"] and rects_intersect(ri.rect, rj.rect): - has_error = True - if ri.field is rj.field: - messages.append(f"FAILURE: intersection between label and entry bounding boxes for `{ri.field['description']}` ({ri.rect}, {rj.rect})") - else: - messages.append(f"FAILURE: intersection between {ri.rect_type} bounding box for `{ri.field['description']}` ({ri.rect}) and {rj.rect_type} bounding box for `{rj.field['description']}` ({rj.rect})") - if len(messages) >= 20: - messages.append("Aborting further checks; fix bounding boxes and try again") - return messages - if ri.rect_type == "entry": - if "entry_text" in ri.field: - font_size = ri.field["entry_text"].get("font_size", 14) - entry_height = ri.rect[3] - ri.rect[1] - if entry_height < font_size: - has_error = True - messages.append(f"FAILURE: entry bounding box height ({entry_height}) for `{ri.field['description']}` is too short for the text content (font size: {font_size}). Increase the box height or decrease the font size.") - if len(messages) >= 20: - messages.append("Aborting further checks; fix bounding boxes and try again") - return messages - - if not has_error: - messages.append("SUCCESS: All bounding boxes are valid") - return messages - -if __name__ == "__main__": - if len(sys.argv) != 2: - print("Usage: check_bounding_boxes.py [fields.json]") - sys.exit(1) - with open(sys.argv[1]) as f: - messages = get_bounding_box_messages(f) - for msg in messages: - print(msg) diff --git a/src/crates/assembly/core/builtin_skills/pdf/scripts/check_fillable_fields.py b/src/crates/assembly/core/builtin_skills/pdf/scripts/check_fillable_fields.py deleted file mode 100644 index 36dfb9513e..0000000000 --- a/src/crates/assembly/core/builtin_skills/pdf/scripts/check_fillable_fields.py +++ /dev/null @@ -1,11 +0,0 @@ -import sys -from pypdf import PdfReader - - - - -reader = PdfReader(sys.argv[1]) -if (reader.get_fields()): - print("This PDF has fillable form fields") -else: - print("This PDF does not have fillable form fields; you will need to visually determine where to enter data") diff --git a/src/crates/assembly/core/builtin_skills/pdf/scripts/convert_pdf_to_images.py b/src/crates/assembly/core/builtin_skills/pdf/scripts/convert_pdf_to_images.py deleted file mode 100644 index 7939cef56c..0000000000 --- a/src/crates/assembly/core/builtin_skills/pdf/scripts/convert_pdf_to_images.py +++ /dev/null @@ -1,33 +0,0 @@ -import os -import sys - -from pdf2image import convert_from_path - - - - -def convert(pdf_path, output_dir, max_dim=1000): - images = convert_from_path(pdf_path, dpi=200) - - for i, image in enumerate(images): - width, height = image.size - if width > max_dim or height > max_dim: - scale_factor = min(max_dim / width, max_dim / height) - new_width = int(width * scale_factor) - new_height = int(height * scale_factor) - image = image.resize((new_width, new_height)) - - image_path = os.path.join(output_dir, f"page_{i+1}.png") - image.save(image_path) - print(f"Saved page {i+1} as {image_path} (size: {image.size})") - - print(f"Converted {len(images)} pages to PNG images") - - -if __name__ == "__main__": - if len(sys.argv) != 3: - print("Usage: convert_pdf_to_images.py [input pdf] [output directory]") - sys.exit(1) - pdf_path = sys.argv[1] - output_directory = sys.argv[2] - convert(pdf_path, output_directory) diff --git a/src/crates/assembly/core/builtin_skills/pdf/scripts/create_validation_image.py b/src/crates/assembly/core/builtin_skills/pdf/scripts/create_validation_image.py deleted file mode 100644 index 10eadd8124..0000000000 --- a/src/crates/assembly/core/builtin_skills/pdf/scripts/create_validation_image.py +++ /dev/null @@ -1,37 +0,0 @@ -import json -import sys - -from PIL import Image, ImageDraw - - - - -def create_validation_image(page_number, fields_json_path, input_path, output_path): - with open(fields_json_path, 'r') as f: - data = json.load(f) - - img = Image.open(input_path) - draw = ImageDraw.Draw(img) - num_boxes = 0 - - for field in data["form_fields"]: - if field["page_number"] == page_number: - entry_box = field['entry_bounding_box'] - label_box = field['label_bounding_box'] - draw.rectangle(entry_box, outline='red', width=2) - draw.rectangle(label_box, outline='blue', width=2) - num_boxes += 2 - - img.save(output_path) - print(f"Created validation image at {output_path} with {num_boxes} bounding boxes") - - -if __name__ == "__main__": - if len(sys.argv) != 5: - print("Usage: create_validation_image.py [page number] [fields.json file] [input image path] [output image path]") - sys.exit(1) - page_number = int(sys.argv[1]) - fields_json_path = sys.argv[2] - input_image_path = sys.argv[3] - output_image_path = sys.argv[4] - create_validation_image(page_number, fields_json_path, input_image_path, output_image_path) diff --git a/src/crates/assembly/core/builtin_skills/pdf/scripts/extract_form_field_info.py b/src/crates/assembly/core/builtin_skills/pdf/scripts/extract_form_field_info.py deleted file mode 100644 index 64cd4703a4..0000000000 --- a/src/crates/assembly/core/builtin_skills/pdf/scripts/extract_form_field_info.py +++ /dev/null @@ -1,122 +0,0 @@ -import json -import sys - -from pypdf import PdfReader - - - - -def get_full_annotation_field_id(annotation): - components = [] - while annotation: - field_name = annotation.get('/T') - if field_name: - components.append(field_name) - annotation = annotation.get('/Parent') - return ".".join(reversed(components)) if components else None - - -def make_field_dict(field, field_id): - field_dict = {"field_id": field_id} - ft = field.get('/FT') - if ft == "/Tx": - field_dict["type"] = "text" - elif ft == "/Btn": - field_dict["type"] = "checkbox" - states = field.get("/_States_", []) - if len(states) == 2: - if "/Off" in states: - field_dict["checked_value"] = states[0] if states[0] != "/Off" else states[1] - field_dict["unchecked_value"] = "/Off" - else: - print(f"Unexpected state values for checkbox `${field_id}`. Its checked and unchecked values may not be correct; if you're trying to check it, visually verify the results.") - field_dict["checked_value"] = states[0] - field_dict["unchecked_value"] = states[1] - elif ft == "/Ch": - field_dict["type"] = "choice" - states = field.get("/_States_", []) - field_dict["choice_options"] = [{ - "value": state[0], - "text": state[1], - } for state in states] - else: - field_dict["type"] = f"unknown ({ft})" - return field_dict - - -def get_field_info(reader: PdfReader): - fields = reader.get_fields() - - field_info_by_id = {} - possible_radio_names = set() - - for field_id, field in fields.items(): - if field.get("/Kids"): - if field.get("/FT") == "/Btn": - possible_radio_names.add(field_id) - continue - field_info_by_id[field_id] = make_field_dict(field, field_id) - - - radio_fields_by_id = {} - - for page_index, page in enumerate(reader.pages): - annotations = page.get('/Annots', []) - for ann in annotations: - field_id = get_full_annotation_field_id(ann) - if field_id in field_info_by_id: - field_info_by_id[field_id]["page"] = page_index + 1 - field_info_by_id[field_id]["rect"] = ann.get('/Rect') - elif field_id in possible_radio_names: - try: - on_values = [v for v in ann["/AP"]["/N"] if v != "/Off"] - except KeyError: - continue - if len(on_values) == 1: - rect = ann.get("/Rect") - if field_id not in radio_fields_by_id: - radio_fields_by_id[field_id] = { - "field_id": field_id, - "type": "radio_group", - "page": page_index + 1, - "radio_options": [], - } - radio_fields_by_id[field_id]["radio_options"].append({ - "value": on_values[0], - "rect": rect, - }) - - fields_with_location = [] - for field_info in field_info_by_id.values(): - if "page" in field_info: - fields_with_location.append(field_info) - else: - print(f"Unable to determine location for field id: {field_info.get('field_id')}, ignoring") - - def sort_key(f): - if "radio_options" in f: - rect = f["radio_options"][0]["rect"] or [0, 0, 0, 0] - else: - rect = f.get("rect") or [0, 0, 0, 0] - adjusted_position = [-rect[1], rect[0]] - return [f.get("page"), adjusted_position] - - sorted_fields = fields_with_location + list(radio_fields_by_id.values()) - sorted_fields.sort(key=sort_key) - - return sorted_fields - - -def write_field_info(pdf_path: str, json_output_path: str): - reader = PdfReader(pdf_path) - field_info = get_field_info(reader) - with open(json_output_path, "w") as f: - json.dump(field_info, f, indent=2) - print(f"Wrote {len(field_info)} fields to {json_output_path}") - - -if __name__ == "__main__": - if len(sys.argv) != 3: - print("Usage: extract_form_field_info.py [input pdf] [output json]") - sys.exit(1) - write_field_info(sys.argv[1], sys.argv[2]) diff --git a/src/crates/assembly/core/builtin_skills/pdf/scripts/extract_form_structure.py b/src/crates/assembly/core/builtin_skills/pdf/scripts/extract_form_structure.py deleted file mode 100755 index f219e7d5b5..0000000000 --- a/src/crates/assembly/core/builtin_skills/pdf/scripts/extract_form_structure.py +++ /dev/null @@ -1,115 +0,0 @@ -""" -Extract form structure from a non-fillable PDF. - -This script analyzes the PDF to find: -- Text labels with their exact coordinates -- Horizontal lines (row boundaries) -- Checkboxes (small rectangles) - -Output: A JSON file with the form structure that can be used to generate -accurate field coordinates for filling. - -Usage: python extract_form_structure.py -""" - -import json -import sys -import pdfplumber - - -def extract_form_structure(pdf_path): - structure = { - "pages": [], - "labels": [], - "lines": [], - "checkboxes": [], - "row_boundaries": [] - } - - with pdfplumber.open(pdf_path) as pdf: - for page_num, page in enumerate(pdf.pages, 1): - structure["pages"].append({ - "page_number": page_num, - "width": float(page.width), - "height": float(page.height) - }) - - words = page.extract_words() - for word in words: - structure["labels"].append({ - "page": page_num, - "text": word["text"], - "x0": round(float(word["x0"]), 1), - "top": round(float(word["top"]), 1), - "x1": round(float(word["x1"]), 1), - "bottom": round(float(word["bottom"]), 1) - }) - - for line in page.lines: - if abs(float(line["x1"]) - float(line["x0"])) > page.width * 0.5: - structure["lines"].append({ - "page": page_num, - "y": round(float(line["top"]), 1), - "x0": round(float(line["x0"]), 1), - "x1": round(float(line["x1"]), 1) - }) - - for rect in page.rects: - width = float(rect["x1"]) - float(rect["x0"]) - height = float(rect["bottom"]) - float(rect["top"]) - if 5 <= width <= 15 and 5 <= height <= 15 and abs(width - height) < 2: - structure["checkboxes"].append({ - "page": page_num, - "x0": round(float(rect["x0"]), 1), - "top": round(float(rect["top"]), 1), - "x1": round(float(rect["x1"]), 1), - "bottom": round(float(rect["bottom"]), 1), - "center_x": round((float(rect["x0"]) + float(rect["x1"])) / 2, 1), - "center_y": round((float(rect["top"]) + float(rect["bottom"])) / 2, 1) - }) - - lines_by_page = {} - for line in structure["lines"]: - page = line["page"] - if page not in lines_by_page: - lines_by_page[page] = [] - lines_by_page[page].append(line["y"]) - - for page, y_coords in lines_by_page.items(): - y_coords = sorted(set(y_coords)) - for i in range(len(y_coords) - 1): - structure["row_boundaries"].append({ - "page": page, - "row_top": y_coords[i], - "row_bottom": y_coords[i + 1], - "row_height": round(y_coords[i + 1] - y_coords[i], 1) - }) - - return structure - - -def main(): - if len(sys.argv) != 3: - print("Usage: extract_form_structure.py ") - sys.exit(1) - - pdf_path = sys.argv[1] - output_path = sys.argv[2] - - print(f"Extracting structure from {pdf_path}...") - structure = extract_form_structure(pdf_path) - - with open(output_path, "w") as f: - json.dump(structure, f, indent=2) - - print(f"Found:") - print(f" - {len(structure['pages'])} pages") - print(f" - {len(structure['labels'])} text labels") - print(f" - {len(structure['lines'])} horizontal lines") - print(f" - {len(structure['checkboxes'])} checkboxes") - print(f" - {len(structure['row_boundaries'])} row boundaries") - print(f"Saved to {output_path}") - - -if __name__ == "__main__": - main() diff --git a/src/crates/assembly/core/builtin_skills/pdf/scripts/fill_fillable_fields.py b/src/crates/assembly/core/builtin_skills/pdf/scripts/fill_fillable_fields.py deleted file mode 100644 index 51c2600f38..0000000000 --- a/src/crates/assembly/core/builtin_skills/pdf/scripts/fill_fillable_fields.py +++ /dev/null @@ -1,98 +0,0 @@ -import json -import sys - -from pypdf import PdfReader, PdfWriter - -from extract_form_field_info import get_field_info - - - - -def fill_pdf_fields(input_pdf_path: str, fields_json_path: str, output_pdf_path: str): - with open(fields_json_path) as f: - fields = json.load(f) - fields_by_page = {} - for field in fields: - if "value" in field: - field_id = field["field_id"] - page = field["page"] - if page not in fields_by_page: - fields_by_page[page] = {} - fields_by_page[page][field_id] = field["value"] - - reader = PdfReader(input_pdf_path) - - has_error = False - field_info = get_field_info(reader) - fields_by_ids = {f["field_id"]: f for f in field_info} - for field in fields: - existing_field = fields_by_ids.get(field["field_id"]) - if not existing_field: - has_error = True - print(f"ERROR: `{field['field_id']}` is not a valid field ID") - elif field["page"] != existing_field["page"]: - has_error = True - print(f"ERROR: Incorrect page number for `{field['field_id']}` (got {field['page']}, expected {existing_field['page']})") - else: - if "value" in field: - err = validation_error_for_field_value(existing_field, field["value"]) - if err: - print(err) - has_error = True - if has_error: - sys.exit(1) - - writer = PdfWriter(clone_from=reader) - for page, field_values in fields_by_page.items(): - writer.update_page_form_field_values(writer.pages[page - 1], field_values, auto_regenerate=False) - - writer.set_need_appearances_writer(True) - - with open(output_pdf_path, "wb") as f: - writer.write(f) - - -def validation_error_for_field_value(field_info, field_value): - field_type = field_info["type"] - field_id = field_info["field_id"] - if field_type == "checkbox": - checked_val = field_info["checked_value"] - unchecked_val = field_info["unchecked_value"] - if field_value != checked_val and field_value != unchecked_val: - return f'ERROR: Invalid value "{field_value}" for checkbox field "{field_id}". The checked value is "{checked_val}" and the unchecked value is "{unchecked_val}"' - elif field_type == "radio_group": - option_values = [opt["value"] for opt in field_info["radio_options"]] - if field_value not in option_values: - return f'ERROR: Invalid value "{field_value}" for radio group field "{field_id}". Valid values are: {option_values}' - elif field_type == "choice": - choice_values = [opt["value"] for opt in field_info["choice_options"]] - if field_value not in choice_values: - return f'ERROR: Invalid value "{field_value}" for choice field "{field_id}". Valid values are: {choice_values}' - return None - - -def monkeypatch_pydpf_method(): - from pypdf.generic import DictionaryObject - from pypdf.constants import FieldDictionaryAttributes - - original_get_inherited = DictionaryObject.get_inherited - - def patched_get_inherited(self, key: str, default = None): - result = original_get_inherited(self, key, default) - if key == FieldDictionaryAttributes.Opt: - if isinstance(result, list) and all(isinstance(v, list) and len(v) == 2 for v in result): - result = [r[0] for r in result] - return result - - DictionaryObject.get_inherited = patched_get_inherited - - -if __name__ == "__main__": - if len(sys.argv) != 4: - print("Usage: fill_fillable_fields.py [input pdf] [field_values.json] [output pdf]") - sys.exit(1) - monkeypatch_pydpf_method() - input_pdf = sys.argv[1] - fields_json = sys.argv[2] - output_pdf = sys.argv[3] - fill_pdf_fields(input_pdf, fields_json, output_pdf) diff --git a/src/crates/assembly/core/builtin_skills/pdf/scripts/fill_pdf_form_with_annotations.py b/src/crates/assembly/core/builtin_skills/pdf/scripts/fill_pdf_form_with_annotations.py deleted file mode 100644 index b430069fd0..0000000000 --- a/src/crates/assembly/core/builtin_skills/pdf/scripts/fill_pdf_form_with_annotations.py +++ /dev/null @@ -1,107 +0,0 @@ -import json -import sys - -from pypdf import PdfReader, PdfWriter -from pypdf.annotations import FreeText - - - - -def transform_from_image_coords(bbox, image_width, image_height, pdf_width, pdf_height): - x_scale = pdf_width / image_width - y_scale = pdf_height / image_height - - left = bbox[0] * x_scale - right = bbox[2] * x_scale - - top = pdf_height - (bbox[1] * y_scale) - bottom = pdf_height - (bbox[3] * y_scale) - - return left, bottom, right, top - - -def transform_from_pdf_coords(bbox, pdf_height): - left = bbox[0] - right = bbox[2] - - pypdf_top = pdf_height - bbox[1] - pypdf_bottom = pdf_height - bbox[3] - - return left, pypdf_bottom, right, pypdf_top - - -def fill_pdf_form(input_pdf_path, fields_json_path, output_pdf_path): - - with open(fields_json_path, "r") as f: - fields_data = json.load(f) - - reader = PdfReader(input_pdf_path) - writer = PdfWriter() - - writer.append(reader) - - pdf_dimensions = {} - for i, page in enumerate(reader.pages): - mediabox = page.mediabox - pdf_dimensions[i + 1] = [mediabox.width, mediabox.height] - - annotations = [] - for field in fields_data["form_fields"]: - page_num = field["page_number"] - - page_info = next(p for p in fields_data["pages"] if p["page_number"] == page_num) - pdf_width, pdf_height = pdf_dimensions[page_num] - - if "pdf_width" in page_info: - transformed_entry_box = transform_from_pdf_coords( - field["entry_bounding_box"], - float(pdf_height) - ) - else: - image_width = page_info["image_width"] - image_height = page_info["image_height"] - transformed_entry_box = transform_from_image_coords( - field["entry_bounding_box"], - image_width, image_height, - float(pdf_width), float(pdf_height) - ) - - if "entry_text" not in field or "text" not in field["entry_text"]: - continue - entry_text = field["entry_text"] - text = entry_text["text"] - if not text: - continue - - font_name = entry_text.get("font", "Arial") - font_size = str(entry_text.get("font_size", 14)) + "pt" - font_color = entry_text.get("font_color", "000000") - - annotation = FreeText( - text=text, - rect=transformed_entry_box, - font=font_name, - font_size=font_size, - font_color=font_color, - border_color=None, - background_color=None, - ) - annotations.append(annotation) - writer.add_annotation(page_number=page_num - 1, annotation=annotation) - - with open(output_pdf_path, "wb") as output: - writer.write(output) - - print(f"Successfully filled PDF form and saved to {output_pdf_path}") - print(f"Added {len(annotations)} text annotations") - - -if __name__ == "__main__": - if len(sys.argv) != 4: - print("Usage: fill_pdf_form_with_annotations.py [input pdf] [fields.json] [output pdf]") - sys.exit(1) - input_pdf = sys.argv[1] - fields_json = sys.argv[2] - output_pdf = sys.argv[3] - - fill_pdf_form(input_pdf, fields_json, output_pdf) diff --git a/src/crates/assembly/core/builtin_skills/pptx/LICENSE.txt b/src/crates/assembly/core/builtin_skills/pptx/LICENSE.txt deleted file mode 100644 index c55ab42224..0000000000 --- a/src/crates/assembly/core/builtin_skills/pptx/LICENSE.txt +++ /dev/null @@ -1,30 +0,0 @@ -© 2025 Anthropic, PBC. All rights reserved. - -LICENSE: Use of these materials (including all code, prompts, assets, files, -and other components of this Skill) is governed by your agreement with -Anthropic regarding use of Anthropic's services. If no separate agreement -exists, use is governed by Anthropic's Consumer Terms of Service or -Commercial Terms of Service, as applicable: -https://www.anthropic.com/legal/consumer-terms -https://www.anthropic.com/legal/commercial-terms -Your applicable agreement is referred to as the "Agreement." "Services" are -as defined in the Agreement. - -ADDITIONAL RESTRICTIONS: Notwithstanding anything in the Agreement to the -contrary, users may not: - -- Extract these materials from the Services or retain copies of these - materials outside the Services -- Reproduce or copy these materials, except for temporary copies created - automatically during authorized use of the Services -- Create derivative works based on these materials -- Distribute, sublicense, or transfer these materials to any third party -- Make, offer to sell, sell, or import any inventions embodied in these - materials -- Reverse engineer, decompile, or disassemble these materials - -The receipt, viewing, or possession of these materials does not convey or -imply any license or right beyond those expressly granted above. - -Anthropic retains all right, title, and interest in these materials, -including all copyrights, patents, and other intellectual property rights. diff --git a/src/crates/assembly/core/builtin_skills/pptx/SKILL.md b/src/crates/assembly/core/builtin_skills/pptx/SKILL.md deleted file mode 100644 index 4a72b9bc18..0000000000 --- a/src/crates/assembly/core/builtin_skills/pptx/SKILL.md +++ /dev/null @@ -1,238 +0,0 @@ ---- -name: pptx -description: "Use this skill any time a .pptx or .potx file is involved in any way — as input, output, or both. This includes: creating slide decks, pitch decks, or presentations; reading, parsing, or extracting text from any .pptx or .potx file (even if the extracted content will be used elsewhere, like in an email or summary); editing, modifying, or updating existing presentations; combining or splitting slide files; working with templates (.potx), layouts, speaker notes, or comments. Trigger whenever the user mentions \"deck,\" \"slides,\" \"presentation,\" or references a .pptx or .potx filename, regardless of what they plan to do with the content afterward. If a .pptx or .potx file needs to be opened, created, or touched, use this skill." -license: Proprietary. LICENSE.txt has complete terms ---- - -# PPTX creation, editing, and analysis - -A `.pptx` is a ZIP archive of XML files. Choose your approach by task: - -| Task | Approach | -|---|---| -| **Create** a new deck | Write a `pptxgenjs` script — see gotchas below | -| **Edit** an existing deck, or build from a template | `safe_extract` → edit `ppt/slides/slideN.xml` → `rezip` | -| **Read** content | `markitdown deck.pptx` (one block per slide under `` markers); visual grid: `python scripts/thumbnail.py deck.pptx` | - -## Scripts - -Paths are relative to this skill's directory. Everything else is plain Python, `node`, or shell. - -| Script | What it does | -|---|---| -| `scripts/thumbnail.py deck.pptx [prefix]` | Labeled grid of every slide, for picking template layouts. `.pptx` only. Pass `prefix` — it defaults to `thumbnails`, which overwrites the grids of any other deck done in the same directory | -| `scripts/add_slide.py unpacked/ slide2.xml [--after slideN.xml]` | Duplicate a slide (or a `slideLayoutN.xml`) with all the package bookkeeping. Also takes a `.pptx` directly with `-o out.pptx` | -| `scripts/clean.py unpacked/` | Delete slides, media, and rels no longer referenced. Run **after** `` is final | -| `scripts/office/validate.py deck.pptx [--original src.pptx]` | Schema, relationship, content-type, chart and slide checks; each failure names its fix. Pass `--original` for any template-derived deck — it baselines the schema checks against the template, so the template's own XSD errors don't read as yours | -| `scripts/office/soffice.py --headless --convert-to pdf deck.pptx` | LibreOffice wrapper — bare `soffice` hangs in this sandbox | - -## Creating with pptxgenjs — gotchas - -`pptxgenjs` is preinstalled — do not run `npm install` first; write the script and `require('pptxgenjs')` directly. Only if that require fails: `npm install pptxgenjs`. The model knows the API; these are the footguns: - -- **Set `pres.layout` before adding slides.** The default canvas is `LAYOUT_16x9` = **10" × 5.625"**, not 13.3" wide. Coordinates past the edge are written, not clamped — the shape just isn't on the slide. (`LAYOUT_WIDE` is 13.3" × 7.5".) -- **Hex colors: never `#`, never 8 digits.** `color: "FF0000"`. Both `"#FF0000"` and alpha baked into the hex (`"00000020"`) **corrupt the file**. For translucency: `transparency: 0-100` on fills and images, `opacity: 0.0-1.0` on shadows — each is silently ignored on the other. -- **pptxgenjs mutates option objects in place** (converts values to EMU on first use). Never share one `shadow`/options object across two `add*` calls — build a fresh object each time. -- **Shadow `offset` must be ≥ 0** — a negative offset corrupts the file. To cast a shadow upward, use `angle: 270` with a positive offset. -- **`letterSpacing` is silently ignored** — the real option is `charSpacing`. -- **Lists:** `bullet: true` on each item, never a literal `•` (renders double bullets). Set `breakLine: true` on every array item except the last. Space bulleted paragraphs with `paraSpaceAfter`, not `lineSpacing` (huge gaps). -- **One `new pptxgen()` per output file** — never reuse an instance. -- **`rectRadius` only works on `ROUNDED_RECTANGLE`**, not `RECTANGLE`. -- **Gradient fills aren't supported** — use a gradient image as the background instead. -- **Text boxes have built-in internal padding** — set `margin: 0` whenever text must align with a shape, line, or icon at the same x. -- **Speaker notes go in `slide.addNotes("...")`** (plain text, once per slide), never in a text box on the slide. -- **Keep charts native.** Use `addChart()` for everything PowerPoint can chart (pass an array of `{type, data, options}` for combos). For PowerPoint-native features the library doesn't expose (trendlines, error bars), compute the extra series yourself or post-process the generated OOXML — do not fall back to a rendered image. Only chart types PowerPoint has no native form for (Sankey, network, chord) go in as images. -- **Default charts render bare** — no title, no data labels, dated palette. Set `showTitle` + `title`, `showValue: true` + `dataLabelPosition`, `chartColors: [...]` from your palette, and quiet the frame (`catAxisLabelColor`/`valAxisLabelColor`, `valGridLine: { color, size }`, `catGridLine: { style: "none" }`, `showLegend: false` for a single series). -- **On a stacked bar or column chart, `dataLabelPosition` must be `ctr`, `inEnd`, or `inBase`.** `outEnd` **corrupts the file**. -- **A combo series using `secondaryValAxis`/`secondaryCatAxis` needs both `valAxes` and `catAxes` on the chart options, two entries each.** Without them pptxgenjs writes axis *ids* it never declares, and PowerPoint **discards that chart** and reports the file as corrupt. Supplying only `valAxes` is not enough. -- **After `writeFile()`, run `python scripts/office/validate.py deck.pptx`.** It reports the two chart faults above and the slide-XML defects PowerPoint refuses, and names the fix for each. Fix them in your generator, not by hand-editing the packed XML. -- **Never reorder the children of ``.** pptxgenjs writes `` right after `` and points both masters at one theme part. PowerPoint reads that happily — move the element and the same deck becomes unopenable. -- **Icons:** render `react-icons` to SVG (`ReactDOMServer.renderToStaticMarkup`), rasterize with `sharp` at ≥256px, and insert via `addImage({ data: "image/png;base64," + buf.toString("base64") })` — the `image/png;base64,` prefix is required (`react-icons`, `react`, `react-dom`, and `sharp` are preinstalled — `npm install react-icons react react-dom sharp` only if a require fails). - -## Editing existing decks and templates - -Pick layouts first: `python scripts/thumbnail.py template.pptx template-thumbs` writes a labeled grid of every slide and prints the file(s) it created — `template-thumbs.jpg`, split into `template-thumbs-N.jpg` past 12 slides. **Always pass that second argument, named after the deck.** It defaults to `thumbnails`, so two decks thumbnailed in one directory silently overwrite each other's grids — the first deck's are simply gone (template analysis only — visual QA needs the full-resolution renders from [Converting to Images](#converting-to-images); it only accepts `.pptx`, so copy a `.potx` to a `.pptx` name first). Use it with `markitdown` to map each content section onto a template slide, and vary the layouts — don't put every section on the same title-and-bullets slide. - -```bash -python -c "import sys,zipfile; from pathlib import Path; from scripts.office.helpers import safe_extract; zf=zipfile.ZipFile(sys.argv[1]); safe_extract(zf, Path('unpacked')); zf.close()" deck.pptx -python scripts/add_slide.py unpacked/ slide2.xml --after slide2.xml # duplicate a slide (or slideLayoutN.xml); prints the new slide's path -# reorder / delete slides = edit in ppt/presentation.xml -python scripts/clean.py unpacked/ # after deletions: removes orphaned slides, media, rels -# edit slide content in ppt/slides/slideN.xml -python -c "from pathlib import Path; from scripts.office.helpers import rezip; rezip(Path('unpacked'), Path('out.pptx'))" -python scripts/office/validate.py out.pptx --original deck.pptx -``` - -- **Do all structural work — add, delete, reorder — before editing any slide's content.** `add_slide.py` copies a slide file verbatim, so duplicating after you edit clones the edited content; and `clean.py` deletes any slide missing from ``, including one you just wrote. -- **Never copy a slide file by hand** — `add_slide.py` does every registration a new slide needs and reports what it made (`Created ppt/slides/slide17.xml from slide2.xml`). It also works directly on a file: `add_slide.py deck.pptx slide2.xml -o out.pptx` — **pass `-o`, or it rewrites the input deck in place.** A duplicated slide still *references* its source's chart/SmartArt/embedded-object parts rather than cloning them, so editing one slide's chart changes the other's. -- **If you use `python-pptx`**, three things it won't do: duplicate a slide (its only entry point is `add_slide(layout)`), preserve formatting through `text_frame.text = "..."` (that collapses the paragraph to a single unstyled run — assign `run.text` instead), or read the SVG/EMF most template art uses (`add_picture` raises `UnidentifiedImageError`). -- Legacy `.ppt` must be converted first: `python scripts/office/soffice.py --headless --convert-to pptx file.ppt`. `.potx` templates unpack and pack identically — keep the `.potx` extension on the output. -- To reuse a template icon or image, duplicate a slide or layout that already contains it. - -When filling in a template: - -- If you script an XML transform, parse with `defusedxml.minidom` — round-tripping OOXML through `xml.etree.ElementTree` rewrites namespace prefixes and corrupts the deck. -- **Template slots ≠ source items.** If the template shows 4 team members and you have 3, delete the 4th member's entire group (image + text boxes), not just its text — then check for orphaned visuals in QA. -- One `` per list item — never concatenate items into a single paragraph. Copy the sibling `` to preserve spacing, and put `b="1"` on the `` of titles, section headers, and inline labels (`Status:`, `Owner:`). -- Let bullets inherit from the layout; only add ``, `` (numbered), or `` to override — never a literal `•` in the text. -- Text with leading or trailing spaces needs `xml:space="preserve"` on its ``. - -## Design Ideas - -**Don't create boring slides.** Plain bullets on a white background won't impress anyone. Consider ideas from this list for each slide. - -### Before Starting - -- **Pick a bold, content-informed color palette**: The palette should feel designed for THIS topic. If swapping your colors into a completely different presentation would still "work," you haven't made specific enough choices. -- **Dominance over equality**: One color should dominate (60-70% visual weight), with 1-2 supporting tones and one sharp accent. Never give all colors equal weight. -- **Dark/light contrast**: Dark backgrounds for title + conclusion slides, light for content ("sandwich" structure). Or commit to dark throughout for a premium feel. -- **Commit to a visual motif**: Pick ONE distinctive element and repeat it — rounded image frames, icons in colored circles. Carry it across every slide. **Do not use a color bar or accent stripe as your motif** (see Avoid list). - -### Color Palettes - -Choose colors that match your topic — don't default to generic blue. Use these palettes as inspiration: - -| Theme | Primary | Secondary | Accent | -|-------|---------|-----------|--------| -| **Midnight Executive** | `1E2761` (navy) | `CADCFC` (ice blue) | `FFFFFF` (white) | -| **Forest & Moss** | `2C5F2D` (forest) | `97BC62` (moss) | `F5F5F5` (cream) | -| **Coral Energy** | `F96167` (coral) | `F9E795` (gold) | `2F3C7E` (navy) | -| **Warm Terracotta** | `B85042` (terracotta) | `E7E8D1` (sand) | `A7BEAE` (sage) | -| **Ocean Gradient** | `065A82` (deep blue) | `1C7293` (teal) | `21295C` (midnight) | -| **Charcoal Minimal** | `36454F` (charcoal) | `F2F2F2` (off-white) | `212121` (black) | -| **Teal Trust** | `028090` (teal) | `00A896` (seafoam) | `02C39A` (mint) | -| **Berry & Cream** | `6D2E46` (berry) | `A26769` (dusty rose) | `ECE2D0` (cream) | -| **Sage Calm** | `84B59F` (sage) | `69A297` (eucalyptus) | `50808E` (slate) | -| **Cherry Bold** | `990011` (cherry) | `FCF6F5` (off-white) | `2F3C7E` (navy) | - -### For Each Slide - -**Every slide needs a visual element** — image, chart, icon, or shape. Text-only slides are forgettable. - -**Layout options:** -- Two-column (text left, illustration on right) -- Icon + text rows (icon in colored circle, bold header, description below) -- 2x2 or 2x3 grid (image on one side, grid of content blocks on other) -- Half-bleed image (full left or right side) with content overlay - -**Data display:** -- Large stat callouts (big numbers 60-72pt with small labels below) -- Comparison columns (before/after, pros/cons, side-by-side options) -- Timeline or process flow (numbered steps, arrows) - -**Visual polish:** -- Icons in small colored circles next to section headers -- Italic accent text for key stats or taglines - -### Typography - -**Font names you write into the .pptx are rendered by the user's PowerPoint, not by this environment.** Your visual QA renders via LibreOffice, which substitutes fonts it doesn't have — and for some fonts the substitute has different widths, so your QA preview can show text overflow (or fit) that the real deck won't have. To keep your QA trustworthy: - -- **Safe fonts** (render true-to-width in QA *and* ship with Office): **Arial, Calibri, Cambria, Times New Roman, Courier New, Bookman Old Style, Century Schoolbook**. Use these for body text and anything where fit matters. -- **Headers with personality at zero QA risk**: pair a safe-list serif header (Cambria, Bookman Old Style, Century Schoolbook) with a safe-list sans body (Calibri or Arial). You get visual contrast without giving up reliable overflow checks. -- **If the user asks for a font outside the safe list** (e.g. Georgia or Trebuchet MS): use it where the user asked, but size those containers with extra slack (~10%) and don't trust QA text-fit on those elements — the preview of that font is approximate. If the user hasn't specified, prefer safe-list fonts for body text. -- **QA-unreliable fonts** (substitute has different widths — overflow checks can be wrong): Georgia, Trebuchet MS, Impact, Arial Black, Garamond, Consolas, Palatino Linotype. Calibri Light substitution varies by environment; treat as QA-unreliable. Fine for titles/accents with slack; don't trust QA text-fit on these. -- **Never default to Aptos** — Office's post-2023 default has no metric-compatible substitute here *and* is missing from older Office installs, so it's unreliable on both ends. - -| Element | Size | -|---------|------| -| Slide title | 36-44pt bold | -| Section header | 20-24pt bold | -| Body text | 14-16pt | -| Captions | 10-12pt muted | - -### Spacing - -- 0.5" minimum margins -- 0.3-0.5" between content blocks -- Leave breathing room—don't fill every inch - -### Avoid (Common Mistakes) - -- **Don't repeat the same layout** — vary columns, cards, and callouts across slides -- **Don't center body text** — left-align paragraphs and lists; center only titles -- **Don't skimp on size contrast** — titles need 36pt+ to stand out from 14-16pt body -- **Don't default to blue** — pick colors that reflect the specific topic -- **Don't mix spacing randomly** — choose 0.3" or 0.5" gaps and use consistently -- **Don't style one slide and leave the rest plain** — commit fully or keep it simple throughout -- **Don't create text-only slides** — add images, icons, charts, or visual elements; avoid plain title + bullets -- **Don't forget text box padding** — when aligning lines or shapes with text edges, set `margin: 0` on the text box or offset the shape to account for padding -- **Don't use low-contrast elements** — icons AND text need strong contrast against the background; avoid light text on light backgrounds or dark text on dark backgrounds -- **NEVER use accent lines under titles** — these are a hallmark of AI-generated slides; use whitespace or background color instead -- **NEVER add decorative color bars or accent stripes** — this includes: header/footer bars spanning the slide width, vertical sidebar stripes down one edge of the slide, thin accent stripes along one edge of a card or content block, and "single-side borders" on rectangles. These read as AI-generated filler. If you want to set a card apart, use a subtle background tint, a drop shadow, or an icon — not an edge stripe. -- **Don't default to cream/beige backgrounds** — when no background is specified, use white (`FFFFFF`) or the user's brand palette; avoid warm-neutral defaults like `F5F5DC`, `FAF0E6`, `FAEBD7`, `FFF8E1` -- **Don't ship text that overflows its shape** — if text doesn't fit, reduce font size, split across slides, or enlarge the container; never leave content cut off or spilling past bounds - -## QA (Required) - -Your first render usually has a few real issues — overlaps, overflow, misalignment. Find and fix those, re-render only the slides you changed, and stop. - -### Content QA - -```bash -markitdown output.pptx -``` - -Check for missing content, typos, wrong order. - -**When using templates, check for leftover placeholder text:** - -```bash -markitdown output.pptx | grep -iE "\bx{3,}\b|lorem|ipsum|\bTODO|\[insert|this.*(page|slide).*layout" -``` - -If grep returns results, fix them before declaring success. - -### File QA (required) - -```bash -python scripts/office/validate.py output.pptx # built from scratch -python scripts/office/validate.py output.pptx --original src.pptx # built from a template -``` - -**If the deck came from a template, always pass `--original`.** A template may itself -contain parts the XSD rejects, so a bare run can report failures you never caused — and -a genuine regression can hide among them. `--original` baselines -the schema and slide checks against the template, suppressing errors it already had. -The structural checks — relationships, content types, charts — ignore `--original` and -report template-inherited problems either way, so read those on their own merits. - -pptxgenjs emits chart XML PowerPoint refuses to open, and every other tool -accepts: python-pptx opens those decks, LibreOffice renders them, the XSD -passes them. Every failure names its fix. Fix it in the generator and rebuild. - -### Visual QA - -Convert the slides to images (see [Converting to Images](#converting-to-images)) and inspect every one. After staring at the generating code you tend to see what you expect rather than what rendered, so look at the images fresh (a subagent works well for this if you have one). User-visible defects to look for: - -- **Text overflow or text cut off at a box or slide boundary — check this first.** It is the most common defect and always user-visible. (For a font the previewer renders unreliably per Typography, the preview is approximate: trust the ~10% slack you left, not its apparent fit.) -- Overlapping elements (text through shapes, lines through words, stacked elements) -- Source citations or footers colliding with content above -- Elements too close (< 0.3" gaps) or cards/sections nearly touching -- Uneven gaps (large empty area in one place, cramped in another) -- Insufficient margin from slide edges (< 0.5") -- Columns or similar elements not aligned consistently -- Low-contrast text (e.g., light gray text on cream-colored background) -- Template decoration mispositioned after text replacement — e.g., a title underline positioned for one line, but the replaced title wrapped to two -- Low-contrast icons (e.g., dark icons on dark backgrounds without a contrasting circle) -- Text boxes too narrow causing excessive wrapping -- Leftover placeholder content - -## Converting to Images - -Convert presentations to individual slide images for visual inspection: - -```bash -python scripts/office/soffice.py --headless --convert-to pdf output.pptx -rm -f slide-*.jpg -pdftoppm -jpeg -r 150 output.pdf slide -ls -1 "$PWD"/slide-*.jpg -``` - -**Pass the absolute paths printed above directly to the view tool.** The `rm` clears stale images from prior runs. `pdftoppm` zero-pads based on page count: `slide-1.jpg` for decks under 10 pages, `slide-01.jpg` for 10-99, `slide-001.jpg` for 100+. - -**After fixes, rerun all four commands above** — the PDF must be regenerated from the edited `.pptx` before `pdftoppm` can reflect your changes. - -## Dependencies - -`pptxgenjs` (npm, preinstalled — install only if `require('pptxgenjs')` fails) · `markitdown[pptx]`, `Pillow`, `defusedxml`, `lxml` (pip — text dump, thumbnail, clean, validate) · LibreOffice (`soffice`, auto-configured for sandboxed environments via `scripts/office/soffice.py`) · `pdftoppm` (Poppler) diff --git a/src/crates/assembly/core/builtin_skills/pptx/scripts/__init__.py b/src/crates/assembly/core/builtin_skills/pptx/scripts/__init__.py deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/src/crates/assembly/core/builtin_skills/pptx/scripts/add_slide.py b/src/crates/assembly/core/builtin_skills/pptx/scripts/add_slide.py deleted file mode 100755 index f013ea94d1..0000000000 --- a/src/crates/assembly/core/builtin_skills/pptx/scripts/add_slide.py +++ /dev/null @@ -1,367 +0,0 @@ -"""Add a slide to a PPTX: duplicate an existing slide or instantiate a layout. - -Does all of the package bookkeeping, so the deck stays valid: - - writes the new ppt/slides/slideN.xml (and its .rels, minus any - notesSlide reference, so the source's speaker notes aren't shared) - - registers it in [Content_Types].xml - - adds a slide relationship with a fresh rId to presentation.xml.rels - - inserts with a fresh id into - — at the end, or after --after SLIDE - -Works on an unpacked directory (during an editing session) or directly on a -.pptx/.potx file (extracted to a temp dir, then rezipped atomically; the -temp dir is discarded, so unpack the output if you still need to edit the -new slide's content). - -Usage: - python add_slide.py unpacked/ slide2.xml # duplicate slide2 - python add_slide.py unpacked/ slideLayout3.xml # new slide from a layout - python add_slide.py unpacked/ slide2.xml --after slide2.xml - python add_slide.py deck.pptx slide2.xml # rewrite deck.pptx in place - python add_slide.py deck.pptx slide2.xml -o out.pptx - -A duplicated slide still holds the source's content: edit ppt/slides/slideN.xml -(printed on success) to change it. To list layouts: ls /ppt/slideLayouts/ -""" - -import argparse -import re -import shutil -import sys -from typing import NoReturn -import tempfile -import zipfile -from pathlib import Path - -from office.helpers import rezip, safe_extract - -MINIMAL_SLIDE_XML = ''' - - - - - - - - - - - - - - - - - - - - - -''' - -SHARED_PART_TYPES = ("chart", "diagramData", "oleObject", "package") - -NOTES_SLIDE_TYPE_RE = re.compile(r"""Type=["'][^"']*/relationships/notesSlide["']""") -RELATIONSHIP_RE = re.compile(r"]*?(?:/>|>.*?)", re.DOTALL) - -SLIDE_ID_MIN = 256 -SLIDE_ID_MAX = 2147483647 - - -def _die(msg: str) -> NoReturn: - print(f"Error: {msg}", file=sys.stderr) - sys.exit(1) - - -def get_next_slide_number(slides_dir: Path) -> int: - existing = [int(m.group(1)) for f in slides_dir.glob("slide*.xml") - if (m := re.match(r"slide(\d+)\.xml", f.name))] - return max(existing) + 1 if existing else 1 - - -def parse_source(source: str) -> tuple[str, str | None]: - if source.startswith("slideLayout") and source.endswith(".xml"): - return ("layout", source) - - return ("slide", None) - - -def create_slide_from_layout(unpacked_dir: Path, layout_file: str, after: str | None = None) -> str: - slides_dir = unpacked_dir / "ppt" / "slides" - rels_dir = slides_dir / "_rels" - layout_path = unpacked_dir / "ppt" / "slideLayouts" / layout_file - - if not layout_path.exists(): - _die(f"{layout_path} not found") - - next_num = get_next_slide_number(slides_dir) - dest = f"slide{next_num}.xml" - after_rid = _precheck_registration(unpacked_dir, after, dest) - slides_dir.mkdir(parents=True, exist_ok=True) - - (slides_dir / dest).write_text(MINIMAL_SLIDE_XML, encoding="utf-8") - - rels_dir.mkdir(exist_ok=True) - rels_xml = f''' - - -''' - (rels_dir / f"{dest}.rels").write_text(rels_xml, encoding="utf-8") - - _register_slide(unpacked_dir, dest, layout_file, after_rid) - return dest - - -def duplicate_slide(unpacked_dir: Path, source: str, after: str | None = None) -> str: - slides_dir = unpacked_dir / "ppt" / "slides" - rels_dir = slides_dir / "_rels" - source_slide = slides_dir / source - - if not source_slide.exists(): - _die(f"{source_slide} not found") - - next_num = get_next_slide_number(slides_dir) - dest = f"slide{next_num}.xml" - after_rid = _precheck_registration(unpacked_dir, after, dest) - - shutil.copy2(source_slide, slides_dir / dest) - - source_rels = rels_dir / f"{source}.rels" - shared_parts: list[str] = [] - if source_rels.exists(): - dest_rels = rels_dir / f"{dest}.rels" - shutil.copy2(source_rels, dest_rels) - rels_content = dest_rels.read_text(encoding="utf-8") - rels_content = RELATIONSHIP_RE.sub( - lambda m: "" if NOTES_SLIDE_TYPE_RE.search(m.group(0)) else m.group(0), - rels_content, - ) - dest_rels.write_text(rels_content, encoding="utf-8") - shared_parts = sorted({ - t for t in re.findall(r'Type="[^"]*/relationships/(\w+)"', rels_content) - if t in SHARED_PART_TYPES - }) - - _register_slide(unpacked_dir, dest, source, after_rid) - if shared_parts: - print( - f"Note: {dest} shares its {', '.join(shared_parts)} part(s) with {source} " - f"(they are referenced, not copied) — editing those parts changes both slides" - ) - return dest - - -def _precheck_registration(unpacked_dir: Path, after: str | None, dest: str) -> str | None: - pres_path = unpacked_dir / "ppt" / "presentation.xml" - if not pres_path.exists(): - _die(f"{pres_path} not found — is this an unpacked PPTX?") - xml = pres_path.read_text(encoding="utf-8") - - has_slot = ( - "" in xml - or re.search(r"", xml) - or "" in xml - ) - if not has_slot: - _die("presentation.xml has no (or to anchor a new one)") - - stale = [] - content_types = unpacked_dir / "[Content_Types].xml" - if content_types.exists() and f'PartName="/ppt/slides/{dest}"' in content_types.read_text(encoding="utf-8"): - stale.append("[Content_Types].xml") - pres_rels = unpacked_dir / "ppt" / "_rels" / "presentation.xml.rels" - if pres_rels.exists() and _find_slide_relationship( - pres_rels.read_text(encoding="utf-8"), dest - ): - stale.append("presentation.xml.rels") - if stale: - _die( - f"{dest} is still registered in {' and '.join(stale)} but absent from ppt/slides/ — " - f"run clean.py first" - ) - - if not after: - return None - after_rid = _rid_for_slide(unpacked_dir, after) - if not re.search(rf']*r:id="{re.escape(after_rid)}"[^>]*>', xml): - _die(f"{after} ({after_rid}) is not listed in ") - return after_rid - - -def _register_slide(unpacked_dir: Path, dest: str, source_desc: str, after_rid: str | None) -> None: - _add_to_content_types(unpacked_dir, dest) - rid = _add_to_presentation_rels(unpacked_dir, dest) - slide_id = _get_next_slide_id(unpacked_dir) - pos, total = _insert_into_sld_id_lst(unpacked_dir, slide_id, rid, after_rid) - - print(f"Created ppt/slides/{dest} from {source_desc}") - print( - f'Inserted into ' - f"at position {pos} of {total}" - ) - - -def _add_to_content_types(unpacked_dir: Path, dest: str) -> None: - content_types_path = unpacked_dir / "[Content_Types].xml" - content_types = content_types_path.read_text(encoding="utf-8") - - new_override = f'' - - if f'PartName="/ppt/slides/{dest}"' not in content_types: - content_types = content_types.replace("", f" {new_override}\n") - content_types_path.write_text(content_types, encoding="utf-8") - - -def _add_to_presentation_rels(unpacked_dir: Path, dest: str) -> str: - pres_rels_path = unpacked_dir / "ppt" / "_rels" / "presentation.xml.rels" - pres_rels = pres_rels_path.read_text(encoding="utf-8") - - existing = _find_slide_relationship(pres_rels, dest) - if existing: - return existing - - pres_xml = (unpacked_dir / "ppt" / "presentation.xml").read_text(encoding="utf-8") - used = {int(n) for n in re.findall(r'\bId="rId(\d+)"', pres_rels)} - used |= {int(n) for n in re.findall(r'\br:id="rId(\d+)"', pres_xml)} - rid = f"rId{max(used) + 1 if used else 1}" - - new_rel = f'' - pres_rels = pres_rels.replace("", f" {new_rel}\n") - pres_rels_path.write_text(pres_rels, encoding="utf-8") - - return rid - - -def _find_slide_relationship(pres_rels: str, slide_name: str) -> str | None: - for m in re.finditer(r"]*>", pres_rels): - element = m.group(0) - if re.search(rf'Target="(?:/ppt/)?slides/{re.escape(slide_name)}"', element): - id_match = re.search(r'\bId="([^"]+)"', element) - if id_match: - return id_match.group(1) - return None - - -def _get_next_slide_id(unpacked_dir: Path) -> int: - pres_content = (unpacked_dir / "ppt" / "presentation.xml").read_text(encoding="utf-8") - used = {int(m) for m in re.findall(r']*\bid="(\d+)"', pres_content)} - - candidate = max((i for i in used if i >= SLIDE_ID_MIN), default=SLIDE_ID_MIN - 1) + 1 - if candidate <= SLIDE_ID_MAX and candidate not in used: - return candidate - for i in range(SLIDE_ID_MIN, SLIDE_ID_MAX + 1): - if i not in used: - return i - _die("no slide id available in [256, 2147483647] — the deck is full") - - -def _insert_into_sld_id_lst( - unpacked_dir: Path, slide_id: int, rid: str, after_rid: str | None = None -) -> tuple[int, int]: - pres_path = unpacked_dir / "ppt" / "presentation.xml" - xml = pres_path.read_text(encoding="utf-8") - entry = f'' - - if f'r:id="{rid}"' in xml: - _die(f"presentation.xml already references {rid}; refusing to add a duplicate") - - if after_rid: - open_tag = re.search(rf']*r:id="{re.escape(after_rid)}"[^>]*>', xml) - if not open_tag: - _die(f"{after_rid} is not listed in ") - end = open_tag.end() - if not open_tag.group(0).endswith("/>"): - close = xml.find("", end) - if close == -1: - _die(f"unclosed for {after_rid} in presentation.xml") - end = close + len("") - xml = xml[:end] + entry + xml[end:] - elif "" in xml: - xml = xml.replace("", f"{entry}", 1) - elif re.search(r"", xml): - xml = re.sub(r"", f"{entry}", xml, count=1) - elif "" in xml: - xml = xml.replace( - "", f"{entry}", 1 - ) - else: - _die("presentation.xml has no (or to anchor a new one)") - - pres_path.write_text(xml, encoding="utf-8") - - lst = re.search(r"(.*)", xml, re.DOTALL) - entries = re.findall(r"]*>", lst.group(1)) if lst else [] - position = next( - (i for i, e in enumerate(entries, 1) if f'r:id="{rid}"' in e), len(entries) - ) - return position, len(entries) - - -def _rid_for_slide(unpacked_dir: Path, slide_name: str) -> str: - pres_rels_path = unpacked_dir / "ppt" / "_rels" / "presentation.xml.rels" - rid = _find_slide_relationship(pres_rels_path.read_text(encoding="utf-8"), slide_name) - if not rid: - _die(f"{slide_name} has no relationship in presentation.xml.rels") - return rid - - -def add_slide(unpacked_dir: Path, source: str, after: str | None = None) -> str: - source_type, layout_file = parse_source(source) - if source_type == "layout" and layout_file is not None: - return create_slide_from_layout(unpacked_dir, layout_file, after) - return duplicate_slide(unpacked_dir, source, after) - - -def add_slide_to_package( - package: Path, source: str, after: str | None = None, output: Path | None = None -) -> str: - out = output or package - with tempfile.TemporaryDirectory() as tmp: - tmp_path = Path(tmp) - with zipfile.ZipFile(package) as zf: - safe_extract(zf, tmp_path) - dest = add_slide(tmp_path, source, after) - rezip(tmp_path, out) - print(f"Wrote {out} — the new slide is ppt/slides/{dest} inside it (unpack to edit its content)") - return dest - - -def main() -> None: - parser = argparse.ArgumentParser( - description="Add a slide to a PPTX: duplicate a slide or instantiate a layout. " - "Registers content types, relationships, and ." - ) - parser.add_argument("target", help="Unpacked PPTX directory OR a .pptx/.potx file") - parser.add_argument( - "source", - help="slideN.xml to duplicate, or slideLayoutN.xml to create from a layout " - "(list layouts with: ls /ppt/slideLayouts/)", - ) - parser.add_argument( - "--after", - metavar="SLIDE", - help="insert after this slide, e.g. slide2.xml (default: append at the end)", - ) - parser.add_argument( - "-o", - "--output", - help="output file (only with a .pptx/.potx target; default: rewrite the input in place)", - ) - args = parser.parse_args() - - target = Path(args.target) - if target.is_dir(): - if args.output: - parser.error("--output is only valid for .pptx/.potx input; a directory is modified in place") - add_slide(target, args.source, args.after) - elif target.is_file() and target.suffix.lower() in (".pptx", ".potx"): - try: - add_slide_to_package(target, args.source, args.after, Path(args.output) if args.output else None) - except (OSError, ValueError, zipfile.BadZipFile) as e: - _die(str(e)) - else: - _die(f"{target} is neither a directory nor a .pptx/.potx file") - - -if __name__ == "__main__": - main() diff --git a/src/crates/assembly/core/builtin_skills/pptx/scripts/clean.py b/src/crates/assembly/core/builtin_skills/pptx/scripts/clean.py deleted file mode 100755 index 551dd23192..0000000000 --- a/src/crates/assembly/core/builtin_skills/pptx/scripts/clean.py +++ /dev/null @@ -1,309 +0,0 @@ -"""Remove unreferenced files from an unpacked PPTX directory. - -Usage: python clean.py - -Example: - python clean.py unpacked/ - -This script removes: -- Orphaned slides (not in sldIdLst) and their relationships -- [trash] directory (unreferenced files) -- Orphaned .rels files for deleted resources -- Unreferenced media, embeddings, charts, diagrams, drawings, ink files -- Unreferenced theme files -- Unreferenced notes slides -- Content-Type overrides for deleted files -""" - -import posixpath -import re -import sys -from pathlib import Path - -import defusedxml.minidom - -from office.helpers import SLIDE_REL_TYPE, opc_target, rels_source_part - - -def _slide_rids(pres_rels_path: Path, unpacked_dir: Path) -> dict[str, str]: - source_part = rels_source_part(pres_rels_path, unpacked_dir) - rels_dom = defusedxml.minidom.parse(str(pres_rels_path)) - - rids: dict[str, str] = {} - for rel in rels_dom.getElementsByTagName("Relationship"): - if rel.getAttribute("Type") != SLIDE_REL_TYPE: - continue - part = opc_target( - rel.getAttribute("Target"), source_part, rel.getAttribute("TargetMode") - ) - if part is not None: - rids[rel.getAttribute("Id")] = part - return rids - - -def get_slides_in_sldidlst(unpacked_dir: Path) -> set[str]: - pres_path = unpacked_dir / "ppt" / "presentation.xml" - pres_rels_path = unpacked_dir / "ppt" / "_rels" / "presentation.xml.rels" - - if not pres_path.exists() or not pres_rels_path.exists(): - return set() - - rid_to_slide = _slide_rids(pres_rels_path, unpacked_dir) - - pres_content = pres_path.read_text(encoding="utf-8") - referenced_rids = set(re.findall(r']*r:id="([^"]+)"', pres_content)) - - return { - posixpath.basename(rid_to_slide[rid]) - for rid in referenced_rids - if rid in rid_to_slide - } - - -class RefusedToClean(Exception): - """The package does not look the way a readable package should.""" - - -def remove_orphaned_slides(unpacked_dir: Path) -> list[str]: - slides_dir = unpacked_dir / "ppt" / "slides" - slides_rels_dir = slides_dir / "_rels" - pres_rels_path = unpacked_dir / "ppt" / "_rels" / "presentation.xml.rels" - - if not slides_dir.exists(): - return [] - - referenced_slides = get_slides_in_sldidlst(unpacked_dir) - on_disk = sorted(slides_dir.glob("slide*.xml")) - - if on_disk and not any(s.name in referenced_slides for s in on_disk): - listed = re.findall( - r']*r:id="([^"]+)"', - (unpacked_dir / "ppt" / "presentation.xml").read_text(encoding="utf-8") - if (unpacked_dir / "ppt" / "presentation.xml").exists() - else "", - ) - if listed: - raise RefusedToClean( - f" lists {len(listed)} slide(s) and none of the " - f"{len(on_disk)} slide(s) on disk match any of them. Refusing to " - f"delete them all — this is a parse failure, not an empty deck." - ) - - removed = [] - - for slide_file in on_disk: - if slide_file.name not in referenced_slides: - rel_path = slide_file.relative_to(unpacked_dir) - slide_file.unlink() - removed.append(str(rel_path)) - - rels_file = slides_rels_dir / f"{slide_file.name}.rels" - if rels_file.exists(): - rels_file.unlink() - removed.append(str(rels_file.relative_to(unpacked_dir))) - - if removed and pres_rels_path.exists(): - rels_dom = defusedxml.minidom.parse(str(pres_rels_path)) - source_part = rels_source_part(pres_rels_path, unpacked_dir) - changed = False - - for rel in list(rels_dom.getElementsByTagName("Relationship")): - if rel.getAttribute("Type") != SLIDE_REL_TYPE: - continue - part = opc_target( - rel.getAttribute("Target"), source_part, rel.getAttribute("TargetMode") - ) - if part is None: - continue - if posixpath.basename(part) not in referenced_slides: - if rel.parentNode: - rel.parentNode.removeChild(rel) - changed = True - - if changed: - with open(pres_rels_path, "wb") as f: - f.write(rels_dom.toxml(encoding="utf-8")) - - return removed - - -def remove_trash_directory(unpacked_dir: Path) -> list[str]: - trash_dir = unpacked_dir / "[trash]" - removed = [] - - if trash_dir.exists() and trash_dir.is_dir(): - for file_path in trash_dir.iterdir(): - if file_path.is_file(): - rel_path = file_path.relative_to(unpacked_dir) - removed.append(str(rel_path)) - file_path.unlink() - trash_dir.rmdir() - - return removed - - -def _referenced_by(rels_files, unpacked_dir: Path) -> set: - referenced = set() - - for rels_file in rels_files: - source_part = rels_source_part(rels_file, unpacked_dir) - dom = defusedxml.minidom.parse(str(rels_file)) - for rel in dom.getElementsByTagName("Relationship"): - part = opc_target( - rel.getAttribute("Target"), source_part, rel.getAttribute("TargetMode") - ) - if part is not None: - referenced.add(Path(part)) - - return referenced - - -def remove_orphaned_rels_files(unpacked_dir: Path) -> list[str]: - resource_dirs = ["charts", "diagrams", "drawings"] - removed = [] - - for dir_name in resource_dirs: - rels_dir = unpacked_dir / "ppt" / dir_name / "_rels" - if not rels_dir.exists(): - continue - - for rels_file in rels_dir.glob("*.rels"): - resource_file = rels_dir.parent / rels_file.name.replace(".rels", "") - if not resource_file.exists(): - rels_file.unlink() - removed.append(str(rels_file.relative_to(unpacked_dir))) - - return removed - - -def get_referenced_files(unpacked_dir: Path) -> set: - return _referenced_by(sorted(unpacked_dir.rglob("*.rels")), unpacked_dir) - - -def remove_orphaned_files(unpacked_dir: Path, referenced: set) -> list[str]: - resource_dirs = ["media", "embeddings", "charts", "diagrams", "tags", "drawings", "ink"] - removed = [] - - for dir_name in resource_dirs: - dir_path = unpacked_dir / "ppt" / dir_name - if not dir_path.exists(): - continue - - for file_path in dir_path.glob("*"): - if not file_path.is_file(): - continue - rel_path = file_path.relative_to(unpacked_dir) - if rel_path not in referenced: - file_path.unlink() - removed.append(str(rel_path)) - - theme_dir = unpacked_dir / "ppt" / "theme" - if theme_dir.exists(): - for file_path in theme_dir.glob("theme*.xml"): - rel_path = file_path.relative_to(unpacked_dir) - if rel_path not in referenced: - file_path.unlink() - removed.append(str(rel_path)) - theme_rels = theme_dir / "_rels" / f"{file_path.name}.rels" - if theme_rels.exists(): - theme_rels.unlink() - removed.append(str(theme_rels.relative_to(unpacked_dir))) - - notes_dir = unpacked_dir / "ppt" / "notesSlides" - if notes_dir.exists(): - for file_path in notes_dir.glob("*.xml"): - if not file_path.is_file(): - continue - rel_path = file_path.relative_to(unpacked_dir) - if rel_path not in referenced: - file_path.unlink() - removed.append(str(rel_path)) - - notes_rels_dir = notes_dir / "_rels" - if notes_rels_dir.exists(): - for file_path in notes_rels_dir.glob("*.rels"): - notes_file = notes_dir / file_path.name.replace(".rels", "") - if not notes_file.exists(): - file_path.unlink() - removed.append(str(file_path.relative_to(unpacked_dir))) - - return removed - - -def update_content_types(unpacked_dir: Path, removed_files: list[str]) -> None: - ct_path = unpacked_dir / "[Content_Types].xml" - if not ct_path.exists(): - return - - dom = defusedxml.minidom.parse(str(ct_path)) - changed = False - - for override in list(dom.getElementsByTagName("Override")): - part_name = override.getAttribute("PartName").lstrip("/") - if part_name in removed_files: - if override.parentNode: - override.parentNode.removeChild(override) - changed = True - - if changed: - with open(ct_path, "wb") as f: - f.write(dom.toxml(encoding="utf-8")) - - -def clean_unused_files(unpacked_dir: Path) -> list[str]: - all_removed = [] - - if list(unpacked_dir.rglob("*.rels")) and not get_referenced_files(unpacked_dir): - raise RefusedToClean( - "no relationship in this package names a part we can resolve. " - "Refusing to treat every file as unreferenced." - ) - - slides_removed = remove_orphaned_slides(unpacked_dir) - all_removed.extend(slides_removed) - - trash_removed = remove_trash_directory(unpacked_dir) - all_removed.extend(trash_removed) - - while True: - removed_rels = remove_orphaned_rels_files(unpacked_dir) - referenced = get_referenced_files(unpacked_dir) - removed_files = remove_orphaned_files(unpacked_dir, referenced) - - total_removed = removed_rels + removed_files - if not total_removed: - break - - all_removed.extend(total_removed) - - if all_removed: - update_content_types(unpacked_dir, all_removed) - - return all_removed - - -if __name__ == "__main__": - if len(sys.argv) != 2: - print("Usage: python clean.py ", file=sys.stderr) - print("Example: python clean.py unpacked/", file=sys.stderr) - sys.exit(1) - - unpacked_dir = Path(sys.argv[1]) - - if not unpacked_dir.exists(): - print(f"Error: {unpacked_dir} not found", file=sys.stderr) - sys.exit(1) - - try: - removed = clean_unused_files(unpacked_dir) - except (RefusedToClean, ValueError) as e: - print(f"Error: {e}", file=sys.stderr) - print("Nothing was deleted.", file=sys.stderr) - sys.exit(1) - - if removed: - print(f"Removed {len(removed)} unreferenced files:") - for f in removed: - print(f" {f}") - else: - print("No unreferenced files found") diff --git a/src/crates/assembly/core/builtin_skills/pptx/scripts/office/helpers/__init__.py b/src/crates/assembly/core/builtin_skills/pptx/scripts/office/helpers/__init__.py deleted file mode 100644 index 188b00aff4..0000000000 --- a/src/crates/assembly/core/builtin_skills/pptx/scripts/office/helpers/__init__.py +++ /dev/null @@ -1,150 +0,0 @@ -import os -import posixpath -import re -import stat -import tempfile -import urllib.parse -import zipfile -from pathlib import Path - -OOXML_FAMILY = { - ".docx": "docx", - ".dotx": "docx", - ".pptx": "pptx", - ".potx": "pptx", - ".xlsx": "xlsx", - ".xltx": "xlsx", -} - -_SCHEME_RE = re.compile(r"^[A-Za-z][A-Za-z0-9+.\-]*:") - -SLIDE_REL_TYPE = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/slide" - -MAX_ARCHIVE_MEMBERS = 10_000 -MAX_ARCHIVE_MEMBER_SIZE = 1 * 1024 * 1024 * 1024 -MAX_ARCHIVE_TOTAL_SIZE = 4 * 1024 * 1024 * 1024 -MAX_ARCHIVE_COMPRESSION_RATIO = 1_000 - - -def opc_target(target: str, source_part: str, target_mode: str = "") -> str | None: - if not target: - return None - if target_mode.lower() == "external": - return None - if _SCHEME_RE.match(target): - return None - - target = urllib.parse.unquote(target) - - if "\\" in target: - raise ValueError(f"relationship target is not a POSIX part name: {target!r}") - - if target.startswith("/"): - joined = target.lstrip("/") - else: - joined = posixpath.join(posixpath.dirname(source_part), target) - - parts: list[str] = [] - for segment in posixpath.normpath(joined).split("/"): - if segment in ("", "."): - continue - if segment == "..": - if not parts: - raise ValueError(f"relationship target escapes the package: {target!r}") - parts.pop() - else: - parts.append(segment) - - if not parts: - raise ValueError(f"relationship target resolves to nothing: {target!r}") - return "/".join(parts) - - -def rels_source_part(rels_file: Path, unpacked_dir: Path) -> str: - owner_dir = rels_file.parent.parent.relative_to(unpacked_dir) - return posixpath.join(owner_dir.as_posix(), rels_file.name[: -len(".rels")]).lstrip("./") - - -def part_text(data: bytes) -> str: - return data.decode("utf-8", "surrogateescape") - - -XML_SPACE = " \t\r\n" - - -def rendered_text(text: str, preserve: bool) -> str: - return text if preserve else text.strip(XML_SPACE) - - -def safe_extract(zf: zipfile.ZipFile, dest: Path) -> None: - dest = dest.resolve() - members = zf.infolist() - if len(members) > MAX_ARCHIVE_MEMBERS: - raise ValueError(f"archive has too many entries: {len(members)}") - - total_size = 0 - targets: set[str] = set() - file_targets: set[str] = set() - validated: list[tuple[zipfile.ZipInfo, Path]] = [] - for m in members: - if stat.S_ISLNK(m.external_attr >> 16): - raise ValueError(f"symlink archive entry not allowed: {m.filename!r}") - target = (dest / m.filename).resolve() - if target == dest or not target.is_relative_to(dest): - raise ValueError(f"unsafe archive entry: {m.filename!r}") - target_key = os.path.normcase(str(target)) - if target_key in targets: - raise ValueError(f"duplicate archive entry: {m.filename!r}") - targets.add(target_key) - if not m.is_dir(): - file_targets.add(target_key) - validated.append((m, target)) - if m.file_size > MAX_ARCHIVE_MEMBER_SIZE: - raise ValueError(f"archive entry is too large: {m.filename!r}") - total_size += m.file_size - if total_size > MAX_ARCHIVE_TOTAL_SIZE: - raise ValueError("archive expands beyond the allowed total size") - if m.file_size and ( - m.compress_size == 0 - or m.file_size > m.compress_size * MAX_ARCHIVE_COMPRESSION_RATIO - ): - raise ValueError(f"archive entry has an unsafe compression ratio: {m.filename!r}") - - for m, target in validated: - for parent in target.parents: - if parent == dest: - break - if os.path.normcase(str(parent)) in file_targets: - raise ValueError(f"archive file entry conflicts with child path: {m.filename!r}") - - for m, _ in validated: - zf.extract(m, dest) - - -def rezip(src_dir: Path, out_path: Path) -> None: - files = sorted(p for p in src_dir.rglob("*") if p.is_file()) - ct = src_dir / "[Content_Types].xml" - fd, tmp_name = tempfile.mkstemp( - prefix=out_path.name + ".", suffix=".tmp", dir=out_path.parent - ) - tmp_out = Path(tmp_name) - try: - with os.fdopen(fd, "wb") as fh: - with zipfile.ZipFile(fh, "w", zipfile.ZIP_DEFLATED) as zf: - if ct.exists(): - zf.write(ct, ct.relative_to(src_dir), compress_type=zipfile.ZIP_STORED) - for f in files: - if f == ct: - continue - zf.write(f, f.relative_to(src_dir)) - if out_path.exists(): - mode = out_path.stat().st_mode & 0o777 - else: - umask = os.umask(0) - os.umask(umask) - mode = 0o666 & ~umask - os.chmod(tmp_out, mode) - os.replace(tmp_out, out_path) - finally: - if tmp_out.exists(): - tmp_out.unlink() diff --git a/src/crates/assembly/core/builtin_skills/pptx/scripts/office/helpers/pptx_chart.py b/src/crates/assembly/core/builtin_skills/pptx/scripts/office/helpers/pptx_chart.py deleted file mode 100644 index 209cb7c58b..0000000000 --- a/src/crates/assembly/core/builtin_skills/pptx/scripts/office/helpers/pptx_chart.py +++ /dev/null @@ -1,170 +0,0 @@ -"""Find chart XML that PowerPoint refuses but the schema accepts. - -Detection only: for either fault more than one repair is valid, and only the -author knows which was meant. -""" - - -from __future__ import annotations - -import re -from typing import Mapping - -from . import part_text - - -_CHART_PART_RE = re.compile(r"ppt/charts/chart\d+\.xml") - -_GROUPING_RE = re.compile(r"""]*?\bval=["'](\w+)["']""") -_DLBL_POS_RE = re.compile(r"""]*?\bval=["'](\w+)["']""") - -def _strip_ext_lst(text: str) -> str: - out, cursor = [], 0 - for lo, hi in _ext_lst_spans(text): - out.append(text[cursor:lo]) - cursor = hi - out.append(text[cursor:]) - return "".join(out) - -_BAR_GROUP_RE = re.compile(r"]*(?.*?", re.DOTALL) - -STACKED_GROUPINGS = frozenset({"stacked", "percentStacked"}) -ILLEGAL_ON_STACKED = frozenset({"outEnd"}) -LEGAL_ON_STACKED = ("ctr", "inEnd", "inBase") - - -def _check_stacked_label_positions(part: str, xml: str) -> list[str]: - problems: list[str] = [] - for match in _BAR_GROUP_RE.finditer(xml): - block = _strip_ext_lst(match.group(0)) - group = match.group(1) - - grouping = _GROUPING_RE.search(block) - if grouping is None or grouping.group(1) not in STACKED_GROUPINGS: - continue - - bad = [p for p in _DLBL_POS_RE.findall(block) if p in ILLEGAL_ON_STACKED] - for pos in sorted(set(bad)): - problems.append( - f'{part}: {bad.count(pos)} data label(s) use dLblPos="{pos}" on a ' - f"{grouping.group(1)} {group}; PowerPoint allows only " - f"{', '.join(LEGAL_ON_STACKED)} there" - ) - return problems - - - -_ANY_CHART_GROUP_RE = re.compile(r"]*(?.*?", re.DOTALL) - -_AXID_RE = re.compile( - r"""\s*]*?\bval=["'](-?\d+)["']\s*(?:/>|>\s*)""" -) - -_AXIS_DECL_RE = re.compile( - r"""]*(?\s*]*?\bval=["'](-?\d+)["']""" -) - -AXID_LIMIT = { - "barChart": 2, "lineChart": 2, "areaChart": 2, "scatterChart": 2, - "bubbleChart": 2, "radarChart": 2, "stockChart": 2, - "bar3DChart": 3, "line3DChart": 3, "area3DChart": 3, - "surfaceChart": 3, "surface3DChart": 3, -} - -AXID_MINIMUM = { - "barChart": 2, "lineChart": 2, "areaChart": 2, "scatterChart": 2, - "bubbleChart": 2, "radarChart": 2, "stockChart": 2, - "bar3DChart": 2, "area3DChart": 2, "surfaceChart": 2, - "line3DChart": 3, "surface3DChart": 3, -} - - -def _declared_axes(xml: str) -> dict[str, list[str]]: - axes: dict[str, list[str]] = {} - for kind, axid in _AXIS_DECL_RE.findall(xml): - axes.setdefault(kind, []).append(axid) - return axes - - -def _canonical_ids(axes: dict[str, list[str]], limit: int) -> list[str] | None: - category = axes.get("catAx", []) + axes.get("dateAx", []) - value = axes.get("valAx", []) - series = axes.get("serAx", []) - if len(category) != 1 or len(value) != 1 or len(series) > 1: - return None - ids = [category[0], value[0]] - if limit >= 3 and series: - ids.append(series[0]) - return ids - - -def _undeclared_axes(kind: str, block: str, axes: dict[str, list[str]]) -> list[str] | None: - if kind not in AXID_LIMIT: - return None - ids = _AXID_RE.findall(block) - declared = {i for group in axes.values() for i in group} - if len([i for i in ids if i in declared]) >= 2: - return None - return ids - - -def _check_chart_axis_references(part: str, xml: str) -> list[str]: - axes = _declared_axes(xml) - problems: list[str] = [] - declared = {i for group in axes.values() for i in group} - for match in _ANY_CHART_GROUP_RE.finditer(xml): - kind, block = match.group(1), match.group(0) - ids = _undeclared_axes(kind, block, axes) - if ids is None: - continue - if not ids: - problems.append( - f"{part}: declares no this part can resolve; a chart " - f"group needs {AXID_MINIMUM[kind]}, and PowerPoint discards one with fewer" - ) - continue - dead = [i for i in ids if i not in declared] - canonical = _canonical_ids(axes, AXID_LIMIT[kind]) - if canonical is not None and len(canonical) >= AXID_MINIMUM[kind]: - hint = f"Fix: point them at the axes this part declares ({', '.join(canonical)})" - else: - hint = ("Fix: the part declares several axes of a kind -- declare the " - "secondary axes the series expects, or drop them") - detail = (f"of which {', '.join(dead)} name no declared axis" - if dead else f"only {len(ids)} of which this part declares") - problems.append( - f"{part}: references axId {', '.join(ids)}, {detail}, " - f"leaving fewer than two live axes; PowerPoint discards the chart. {hint}" - ) - return problems - - -def _ext_lst_spans(text: str) -> list[tuple[int, int]]: - spans: list[tuple[int, int]] = [] - depth = 0 - start = 0 - for match in re.finditer(r"<(/?)c:extLst\b[^>]*?(/?)>", text): - closing, self_closing = match.group(1), match.group(2) - if self_closing: - continue - if closing: - depth -= 1 - if depth == 0: - spans.append((start, match.end())) - else: - if depth == 0: - start = match.start() - depth += 1 - return spans - - -CHART_CHECKS = (_check_stacked_label_positions, _check_chart_axis_references) - - -def find_chart_problems(files: Mapping[str, bytes]) -> list[str]: - problems: list[str] = [] - for part in sorted(n for n in files if _CHART_PART_RE.fullmatch(n)): - xml = part_text(files[part]) - for check in CHART_CHECKS: - problems.extend(check(part, xml)) - return problems diff --git a/src/crates/assembly/core/builtin_skills/pptx/scripts/office/helpers/pptx_slide.py b/src/crates/assembly/core/builtin_skills/pptx/scripts/office/helpers/pptx_slide.py deleted file mode 100644 index 22f9aee0ff..0000000000 --- a/src/crates/assembly/core/builtin_skills/pptx/scripts/office/helpers/pptx_slide.py +++ /dev/null @@ -1,60 +0,0 @@ -"""Pick the slide-XML schema errors PowerPoint refuses the file over. - -A denylist over lxml's messages, so an unrecognised error class is a miss rather -than a false alarm. -""" - - -from __future__ import annotations - -import re - -SLIDE_PART_RE = re.compile( - r"ppt/(slides|slideLayouts|slideMasters|notesSlides|notesMasters|handoutMasters)" - r"/[^/]+\.xml" -) - -FATAL_SLIDE_ERRORS: tuple[tuple[re.Pattern[str], str], ...] = ( - ( - re.compile(r"\}tableStyleId': This element is not expected"), - "two in one (the schema allows one)", - ), - ( - re.compile(r"\}srgbClr', attribute 'val'"), - "a colour that is not six hex digits", - ), - ( - re.compile(r"\}txBody': Missing child element"), - "a with no children", - ), - ( - re.compile(r"\}miter', attribute 'lim'"), - 'a line join with lim="NaN"', - ), - ( - re.compile(r"\}uLnTx': This element is not expected"), - " in a position the schema forbids", - ), - ( - re.compile(r"\}overrideClrMapping': This element is not expected"), - " in a position the schema forbids", - ), - ( - re.compile(r"\}nvGrpSpPr': Missing child element"), - "a with no children", - ), -) - - -def is_schema_verdict(error: str) -> bool: - return error.startswith("Element ") - - -def fatal_slide_errors(errors: set[str]) -> list[str]: - out = [] - for error in sorted(errors): - for pattern, meaning in FATAL_SLIDE_ERRORS: - if pattern.search(error): - out.append(f"{meaning}: {error}") - break - return out diff --git a/src/crates/assembly/core/builtin_skills/pptx/scripts/office/helpers/pptx_theme.py b/src/crates/assembly/core/builtin_skills/pptx/scripts/office/helpers/pptx_theme.py deleted file mode 100644 index 5ef4c3e835..0000000000 --- a/src/crates/assembly/core/builtin_skills/pptx/scripts/office/helpers/pptx_theme.py +++ /dev/null @@ -1,114 +0,0 @@ -"""Find masters sharing a theme part in the way PowerPoint refuses to open. - -Reports only; the fix is to move back to directly after - in ppt/presentation.xml. -""" - - -from __future__ import annotations - -import posixpath -import re -from typing import Mapping - -from . import part_text - -THEME_REL_TYPE = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme" - -_MASTER_RE = re.compile( - r"^ppt/(?PslideMasters|notesMasters|handoutMasters)/" - r"(?:slide|notes|handout)Master(?P\d+)\.xml$" -) -_GROUP_ORDER = {"slideMasters": 0, "notesMasters": 1, "handoutMasters": 2} - -_RELATIONSHIP_RE = re.compile( - r"]*?(?:/>|>.*?)", re.DOTALL -) - - -def _sort_key(name: str) -> tuple[int, int]: - m = _MASTER_RE.match(name) - assert m is not None - return (_GROUP_ORDER[m.group("group")], int(m.group("num"))) - - -def _rels_path(part: str) -> str: - directory, base = posixpath.split(part) - return f"{directory}/_rels/{base}.rels" - - -def _resolve(rels_path: str, target: str) -> str: - if target.startswith("/"): - return target.lstrip("/") - part_dir = posixpath.dirname(posixpath.dirname(rels_path)) - return posixpath.normpath(posixpath.join(part_dir, target)) - - -def _theme_rel(files: Mapping[str, bytes], master: str): - rels_path = _rels_path(master) - rels = files.get(rels_path) - if rels is None: - return None - for element in _RELATIONSHIP_RE.findall(part_text(rels)): - if f'Type="{THEME_REL_TYPE}"' not in element: - continue - target = re.search(r'\bTarget="([^"]+)"', element) - if target is None: - continue - return rels_path, element, _resolve(rels_path, target.group(1)) - return None - - -def _masters(files: Mapping[str, bytes]) -> list[str]: - return sorted((n for n in files if _MASTER_RE.match(n)), key=_sort_key) - - -_PRESENTATION = "ppt/presentation.xml" -_NOTES_MASTERS = "ppt/notesMasters/" -_IGNORABLE_RE = re.compile(r"|<\?.*?\?>", re.DOTALL) -_AFTER_SLDIDLST_RE = re.compile( - r"]*/>|[^>]*>.*?)\s*(<[^>\s/]+)", re.DOTALL -) - - -def _notes_master_share_is_inert(files: Mapping[str, bytes]) -> bool: - data = files.get(_PRESENTATION) - if data is None: - return False - match = _AFTER_SLDIDLST_RE.search(_IGNORABLE_RE.sub("", part_text(data))) - return match is not None and match.group(1) == " bool: - return inert_notes and master.startswith(_NOTES_MASTERS) - - -def find_shared_master_themes(files: Mapping[str, bytes]) -> list[str]: - return [ - f"{master} shares {theme} with {first}" - for master, _, _, theme, first in _shares(files) - ] - - -def live_shared_master_themes(files: Mapping[str, bytes]) -> list[str]: - inert_notes = _notes_master_share_is_inert(files) - return [ - f"{master} shares {theme} with {first}" - for master, _, _, theme, first in _shares(files) - if not _is_inert(master, inert_notes) - ] diff --git a/src/crates/assembly/core/builtin_skills/pptx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-chart.xsd b/src/crates/assembly/core/builtin_skills/pptx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-chart.xsd deleted file mode 100644 index 6454ef9a94..0000000000 --- a/src/crates/assembly/core/builtin_skills/pptx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-chart.xsd +++ /dev/null @@ -1,1499 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/crates/assembly/core/builtin_skills/pptx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-chartDrawing.xsd b/src/crates/assembly/core/builtin_skills/pptx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-chartDrawing.xsd deleted file mode 100644 index afa4f463e3..0000000000 --- a/src/crates/assembly/core/builtin_skills/pptx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-chartDrawing.xsd +++ /dev/null @@ -1,146 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/crates/assembly/core/builtin_skills/pptx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-diagram.xsd b/src/crates/assembly/core/builtin_skills/pptx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-diagram.xsd deleted file mode 100644 index 64e66b8abd..0000000000 --- a/src/crates/assembly/core/builtin_skills/pptx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-diagram.xsd +++ /dev/null @@ -1,1085 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/crates/assembly/core/builtin_skills/pptx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-lockedCanvas.xsd b/src/crates/assembly/core/builtin_skills/pptx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-lockedCanvas.xsd deleted file mode 100644 index 687eea8297..0000000000 --- a/src/crates/assembly/core/builtin_skills/pptx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-lockedCanvas.xsd +++ /dev/null @@ -1,11 +0,0 @@ - - - - - diff --git a/src/crates/assembly/core/builtin_skills/pptx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-main.xsd b/src/crates/assembly/core/builtin_skills/pptx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-main.xsd deleted file mode 100644 index 6ac81b06b7..0000000000 --- a/src/crates/assembly/core/builtin_skills/pptx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-main.xsd +++ /dev/null @@ -1,3081 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/crates/assembly/core/builtin_skills/pptx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-picture.xsd b/src/crates/assembly/core/builtin_skills/pptx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-picture.xsd deleted file mode 100644 index 1dbf05140d..0000000000 --- a/src/crates/assembly/core/builtin_skills/pptx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-picture.xsd +++ /dev/null @@ -1,23 +0,0 @@ - - - - - - - - - - - - - - - - - - diff --git a/src/crates/assembly/core/builtin_skills/pptx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-spreadsheetDrawing.xsd b/src/crates/assembly/core/builtin_skills/pptx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-spreadsheetDrawing.xsd deleted file mode 100644 index f1af17db4e..0000000000 --- a/src/crates/assembly/core/builtin_skills/pptx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-spreadsheetDrawing.xsd +++ /dev/null @@ -1,185 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/crates/assembly/core/builtin_skills/pptx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-wordprocessingDrawing.xsd b/src/crates/assembly/core/builtin_skills/pptx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-wordprocessingDrawing.xsd deleted file mode 100644 index 0a185ab6ed..0000000000 --- a/src/crates/assembly/core/builtin_skills/pptx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-wordprocessingDrawing.xsd +++ /dev/null @@ -1,287 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/crates/assembly/core/builtin_skills/pptx/scripts/office/schemas/ISO-IEC29500-4_2016/pml.xsd b/src/crates/assembly/core/builtin_skills/pptx/scripts/office/schemas/ISO-IEC29500-4_2016/pml.xsd deleted file mode 100644 index 14ef488865..0000000000 --- a/src/crates/assembly/core/builtin_skills/pptx/scripts/office/schemas/ISO-IEC29500-4_2016/pml.xsd +++ /dev/null @@ -1,1676 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/crates/assembly/core/builtin_skills/pptx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-additionalCharacteristics.xsd b/src/crates/assembly/core/builtin_skills/pptx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-additionalCharacteristics.xsd deleted file mode 100644 index c20f3bf147..0000000000 --- a/src/crates/assembly/core/builtin_skills/pptx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-additionalCharacteristics.xsd +++ /dev/null @@ -1,28 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/crates/assembly/core/builtin_skills/pptx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-bibliography.xsd b/src/crates/assembly/core/builtin_skills/pptx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-bibliography.xsd deleted file mode 100644 index ac60252262..0000000000 --- a/src/crates/assembly/core/builtin_skills/pptx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-bibliography.xsd +++ /dev/null @@ -1,144 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/crates/assembly/core/builtin_skills/pptx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-commonSimpleTypes.xsd b/src/crates/assembly/core/builtin_skills/pptx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-commonSimpleTypes.xsd deleted file mode 100644 index 424b8ba8d1..0000000000 --- a/src/crates/assembly/core/builtin_skills/pptx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-commonSimpleTypes.xsd +++ /dev/null @@ -1,174 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/crates/assembly/core/builtin_skills/pptx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-customXmlDataProperties.xsd b/src/crates/assembly/core/builtin_skills/pptx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-customXmlDataProperties.xsd deleted file mode 100644 index 2bddce2921..0000000000 --- a/src/crates/assembly/core/builtin_skills/pptx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-customXmlDataProperties.xsd +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - - - - - - - - - - - - - - diff --git a/src/crates/assembly/core/builtin_skills/pptx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-customXmlSchemaProperties.xsd b/src/crates/assembly/core/builtin_skills/pptx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-customXmlSchemaProperties.xsd deleted file mode 100644 index 8a8c18ba2d..0000000000 --- a/src/crates/assembly/core/builtin_skills/pptx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-customXmlSchemaProperties.xsd +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - - - - - - - - - - diff --git a/src/crates/assembly/core/builtin_skills/pptx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-documentPropertiesCustom.xsd b/src/crates/assembly/core/builtin_skills/pptx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-documentPropertiesCustom.xsd deleted file mode 100644 index 5c42706a0d..0000000000 --- a/src/crates/assembly/core/builtin_skills/pptx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-documentPropertiesCustom.xsd +++ /dev/null @@ -1,59 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/crates/assembly/core/builtin_skills/pptx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-documentPropertiesExtended.xsd b/src/crates/assembly/core/builtin_skills/pptx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-documentPropertiesExtended.xsd deleted file mode 100644 index 853c341c87..0000000000 --- a/src/crates/assembly/core/builtin_skills/pptx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-documentPropertiesExtended.xsd +++ /dev/null @@ -1,56 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/crates/assembly/core/builtin_skills/pptx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-documentPropertiesVariantTypes.xsd b/src/crates/assembly/core/builtin_skills/pptx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-documentPropertiesVariantTypes.xsd deleted file mode 100644 index da835ee82d..0000000000 --- a/src/crates/assembly/core/builtin_skills/pptx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-documentPropertiesVariantTypes.xsd +++ /dev/null @@ -1,195 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/crates/assembly/core/builtin_skills/pptx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-math.xsd b/src/crates/assembly/core/builtin_skills/pptx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-math.xsd deleted file mode 100644 index 87ad2658fa..0000000000 --- a/src/crates/assembly/core/builtin_skills/pptx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-math.xsd +++ /dev/null @@ -1,582 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/crates/assembly/core/builtin_skills/pptx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-relationshipReference.xsd b/src/crates/assembly/core/builtin_skills/pptx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-relationshipReference.xsd deleted file mode 100644 index 9e86f1b2be..0000000000 --- a/src/crates/assembly/core/builtin_skills/pptx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-relationshipReference.xsd +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - - - - - - - - - - - - - - - diff --git a/src/crates/assembly/core/builtin_skills/pptx/scripts/office/schemas/ISO-IEC29500-4_2016/sml.xsd b/src/crates/assembly/core/builtin_skills/pptx/scripts/office/schemas/ISO-IEC29500-4_2016/sml.xsd deleted file mode 100644 index d0be42e757..0000000000 --- a/src/crates/assembly/core/builtin_skills/pptx/scripts/office/schemas/ISO-IEC29500-4_2016/sml.xsd +++ /dev/null @@ -1,4439 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/crates/assembly/core/builtin_skills/pptx/scripts/office/schemas/ISO-IEC29500-4_2016/vml-main.xsd b/src/crates/assembly/core/builtin_skills/pptx/scripts/office/schemas/ISO-IEC29500-4_2016/vml-main.xsd deleted file mode 100644 index 8821dd183c..0000000000 --- a/src/crates/assembly/core/builtin_skills/pptx/scripts/office/schemas/ISO-IEC29500-4_2016/vml-main.xsd +++ /dev/null @@ -1,570 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/crates/assembly/core/builtin_skills/pptx/scripts/office/schemas/ISO-IEC29500-4_2016/vml-officeDrawing.xsd b/src/crates/assembly/core/builtin_skills/pptx/scripts/office/schemas/ISO-IEC29500-4_2016/vml-officeDrawing.xsd deleted file mode 100644 index ca2575c753..0000000000 --- a/src/crates/assembly/core/builtin_skills/pptx/scripts/office/schemas/ISO-IEC29500-4_2016/vml-officeDrawing.xsd +++ /dev/null @@ -1,509 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/crates/assembly/core/builtin_skills/pptx/scripts/office/schemas/ISO-IEC29500-4_2016/vml-presentationDrawing.xsd b/src/crates/assembly/core/builtin_skills/pptx/scripts/office/schemas/ISO-IEC29500-4_2016/vml-presentationDrawing.xsd deleted file mode 100644 index dd079e603f..0000000000 --- a/src/crates/assembly/core/builtin_skills/pptx/scripts/office/schemas/ISO-IEC29500-4_2016/vml-presentationDrawing.xsd +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - - diff --git a/src/crates/assembly/core/builtin_skills/pptx/scripts/office/schemas/ISO-IEC29500-4_2016/vml-spreadsheetDrawing.xsd b/src/crates/assembly/core/builtin_skills/pptx/scripts/office/schemas/ISO-IEC29500-4_2016/vml-spreadsheetDrawing.xsd deleted file mode 100644 index 3dd6cf625a..0000000000 --- a/src/crates/assembly/core/builtin_skills/pptx/scripts/office/schemas/ISO-IEC29500-4_2016/vml-spreadsheetDrawing.xsd +++ /dev/null @@ -1,108 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/crates/assembly/core/builtin_skills/pptx/scripts/office/schemas/ISO-IEC29500-4_2016/vml-wordprocessingDrawing.xsd b/src/crates/assembly/core/builtin_skills/pptx/scripts/office/schemas/ISO-IEC29500-4_2016/vml-wordprocessingDrawing.xsd deleted file mode 100644 index f1041e34ef..0000000000 --- a/src/crates/assembly/core/builtin_skills/pptx/scripts/office/schemas/ISO-IEC29500-4_2016/vml-wordprocessingDrawing.xsd +++ /dev/null @@ -1,96 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/crates/assembly/core/builtin_skills/pptx/scripts/office/schemas/ISO-IEC29500-4_2016/wml.xsd b/src/crates/assembly/core/builtin_skills/pptx/scripts/office/schemas/ISO-IEC29500-4_2016/wml.xsd deleted file mode 100644 index 9c5b7a6334..0000000000 --- a/src/crates/assembly/core/builtin_skills/pptx/scripts/office/schemas/ISO-IEC29500-4_2016/wml.xsd +++ /dev/null @@ -1,3646 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/crates/assembly/core/builtin_skills/pptx/scripts/office/schemas/ISO-IEC29500-4_2016/xml.xsd b/src/crates/assembly/core/builtin_skills/pptx/scripts/office/schemas/ISO-IEC29500-4_2016/xml.xsd deleted file mode 100644 index 0f13678d80..0000000000 --- a/src/crates/assembly/core/builtin_skills/pptx/scripts/office/schemas/ISO-IEC29500-4_2016/xml.xsd +++ /dev/null @@ -1,116 +0,0 @@ - - - - - - See http://www.w3.org/XML/1998/namespace.html and - http://www.w3.org/TR/REC-xml for information about this namespace. - - This schema document describes the XML namespace, in a form - suitable for import by other schema documents. - - Note that local names in this namespace are intended to be defined - only by the World Wide Web Consortium or its subgroups. The - following names are currently defined in this namespace and should - not be used with conflicting semantics by any Working Group, - specification, or document instance: - - base (as an attribute name): denotes an attribute whose value - provides a URI to be used as the base for interpreting any - relative URIs in the scope of the element on which it - appears; its value is inherited. This name is reserved - by virtue of its definition in the XML Base specification. - - lang (as an attribute name): denotes an attribute whose value - is a language code for the natural language of the content of - any element; its value is inherited. This name is reserved - by virtue of its definition in the XML specification. - - space (as an attribute name): denotes an attribute whose - value is a keyword indicating what whitespace processing - discipline is intended for the content of the element; its - value is inherited. This name is reserved by virtue of its - definition in the XML specification. - - Father (in any context at all): denotes Jon Bosak, the chair of - the original XML Working Group. This name is reserved by - the following decision of the W3C XML Plenary and - XML Coordination groups: - - In appreciation for his vision, leadership and dedication - the W3C XML Plenary on this 10th day of February, 2000 - reserves for Jon Bosak in perpetuity the XML name - xml:Father - - - - - This schema defines attributes and an attribute group - suitable for use by - schemas wishing to allow xml:base, xml:lang or xml:space attributes - on elements they define. - - To enable this, such a schema must import this schema - for the XML namespace, e.g. as follows: - <schema . . .> - . . . - <import namespace="http://www.w3.org/XML/1998/namespace" - schemaLocation="http://www.w3.org/2001/03/xml.xsd"/> - - Subsequently, qualified reference to any of the attributes - or the group defined below will have the desired effect, e.g. - - <type . . .> - . . . - <attributeGroup ref="xml:specialAttrs"/> - - will define a type which will schema-validate an instance - element with any of those attributes - - - - In keeping with the XML Schema WG's standard versioning - policy, this schema document will persist at - http://www.w3.org/2001/03/xml.xsd. - At the date of issue it can also be found at - http://www.w3.org/2001/xml.xsd. - The schema document at that URI may however change in the future, - in order to remain compatible with the latest version of XML Schema - itself. In other words, if the XML Schema namespace changes, the version - of this document at - http://www.w3.org/2001/xml.xsd will change - accordingly; the version at - http://www.w3.org/2001/03/xml.xsd will not change. - - - - - - In due course, we should install the relevant ISO 2- and 3-letter - codes as the enumerated possible values . . . - - - - - - - - - - - - - - - See http://www.w3.org/TR/xmlbase/ for - information about this attribute. - - - - - - - - - - diff --git a/src/crates/assembly/core/builtin_skills/pptx/scripts/office/schemas/ecma/fouth-edition/opc-contentTypes.xsd b/src/crates/assembly/core/builtin_skills/pptx/scripts/office/schemas/ecma/fouth-edition/opc-contentTypes.xsd deleted file mode 100644 index a6de9d2733..0000000000 --- a/src/crates/assembly/core/builtin_skills/pptx/scripts/office/schemas/ecma/fouth-edition/opc-contentTypes.xsd +++ /dev/null @@ -1,42 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/crates/assembly/core/builtin_skills/pptx/scripts/office/schemas/ecma/fouth-edition/opc-coreProperties.xsd b/src/crates/assembly/core/builtin_skills/pptx/scripts/office/schemas/ecma/fouth-edition/opc-coreProperties.xsd deleted file mode 100644 index 10e978b661..0000000000 --- a/src/crates/assembly/core/builtin_skills/pptx/scripts/office/schemas/ecma/fouth-edition/opc-coreProperties.xsd +++ /dev/null @@ -1,50 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/crates/assembly/core/builtin_skills/pptx/scripts/office/schemas/ecma/fouth-edition/opc-digSig.xsd b/src/crates/assembly/core/builtin_skills/pptx/scripts/office/schemas/ecma/fouth-edition/opc-digSig.xsd deleted file mode 100644 index 4248bf7a39..0000000000 --- a/src/crates/assembly/core/builtin_skills/pptx/scripts/office/schemas/ecma/fouth-edition/opc-digSig.xsd +++ /dev/null @@ -1,49 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/crates/assembly/core/builtin_skills/pptx/scripts/office/schemas/ecma/fouth-edition/opc-relationships.xsd b/src/crates/assembly/core/builtin_skills/pptx/scripts/office/schemas/ecma/fouth-edition/opc-relationships.xsd deleted file mode 100644 index 5649746712..0000000000 --- a/src/crates/assembly/core/builtin_skills/pptx/scripts/office/schemas/ecma/fouth-edition/opc-relationships.xsd +++ /dev/null @@ -1,33 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/crates/assembly/core/builtin_skills/pptx/scripts/office/schemas/mce/mc.xsd b/src/crates/assembly/core/builtin_skills/pptx/scripts/office/schemas/mce/mc.xsd deleted file mode 100644 index ef725457cf..0000000000 --- a/src/crates/assembly/core/builtin_skills/pptx/scripts/office/schemas/mce/mc.xsd +++ /dev/null @@ -1,75 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/crates/assembly/core/builtin_skills/pptx/scripts/office/schemas/microsoft/wml-2010.xsd b/src/crates/assembly/core/builtin_skills/pptx/scripts/office/schemas/microsoft/wml-2010.xsd deleted file mode 100644 index f65f777730..0000000000 --- a/src/crates/assembly/core/builtin_skills/pptx/scripts/office/schemas/microsoft/wml-2010.xsd +++ /dev/null @@ -1,560 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/crates/assembly/core/builtin_skills/pptx/scripts/office/schemas/microsoft/wml-2012.xsd b/src/crates/assembly/core/builtin_skills/pptx/scripts/office/schemas/microsoft/wml-2012.xsd deleted file mode 100644 index 6b00755a9a..0000000000 --- a/src/crates/assembly/core/builtin_skills/pptx/scripts/office/schemas/microsoft/wml-2012.xsd +++ /dev/null @@ -1,67 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/crates/assembly/core/builtin_skills/pptx/scripts/office/schemas/microsoft/wml-2018.xsd b/src/crates/assembly/core/builtin_skills/pptx/scripts/office/schemas/microsoft/wml-2018.xsd deleted file mode 100644 index f321d333a5..0000000000 --- a/src/crates/assembly/core/builtin_skills/pptx/scripts/office/schemas/microsoft/wml-2018.xsd +++ /dev/null @@ -1,14 +0,0 @@ - - - - - - - - - - - - - - diff --git a/src/crates/assembly/core/builtin_skills/pptx/scripts/office/schemas/microsoft/wml-cex-2018.xsd b/src/crates/assembly/core/builtin_skills/pptx/scripts/office/schemas/microsoft/wml-cex-2018.xsd deleted file mode 100644 index 364c6a9b8d..0000000000 --- a/src/crates/assembly/core/builtin_skills/pptx/scripts/office/schemas/microsoft/wml-cex-2018.xsd +++ /dev/null @@ -1,20 +0,0 @@ - - - - - - - - - - - - - - - - - - - - diff --git a/src/crates/assembly/core/builtin_skills/pptx/scripts/office/schemas/microsoft/wml-cid-2016.xsd b/src/crates/assembly/core/builtin_skills/pptx/scripts/office/schemas/microsoft/wml-cid-2016.xsd deleted file mode 100644 index fed9d15b7f..0000000000 --- a/src/crates/assembly/core/builtin_skills/pptx/scripts/office/schemas/microsoft/wml-cid-2016.xsd +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - diff --git a/src/crates/assembly/core/builtin_skills/pptx/scripts/office/schemas/microsoft/wml-sdtdatahash-2020.xsd b/src/crates/assembly/core/builtin_skills/pptx/scripts/office/schemas/microsoft/wml-sdtdatahash-2020.xsd deleted file mode 100644 index 680cf15400..0000000000 --- a/src/crates/assembly/core/builtin_skills/pptx/scripts/office/schemas/microsoft/wml-sdtdatahash-2020.xsd +++ /dev/null @@ -1,4 +0,0 @@ - - - - diff --git a/src/crates/assembly/core/builtin_skills/pptx/scripts/office/schemas/microsoft/wml-symex-2015.xsd b/src/crates/assembly/core/builtin_skills/pptx/scripts/office/schemas/microsoft/wml-symex-2015.xsd deleted file mode 100644 index 89ada90837..0000000000 --- a/src/crates/assembly/core/builtin_skills/pptx/scripts/office/schemas/microsoft/wml-symex-2015.xsd +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - diff --git a/src/crates/assembly/core/builtin_skills/pptx/scripts/office/soffice.py b/src/crates/assembly/core/builtin_skills/pptx/scripts/office/soffice.py deleted file mode 100644 index 0b4c99deca..0000000000 --- a/src/crates/assembly/core/builtin_skills/pptx/scripts/office/soffice.py +++ /dev/null @@ -1,192 +0,0 @@ -""" -Helper for running LibreOffice (soffice) in environments where AF_UNIX -sockets may be blocked (e.g., sandboxed VMs). Detects the restriction -at runtime and applies an LD_PRELOAD shim if needed. - -Usage: - from office.soffice import run_soffice - - result = run_soffice(["--headless", "--convert-to", "pdf", "input.docx"]) - -Call soffice through run_soffice, not through subprocess with get_soffice_env(): -the env dict carries the shim but names no user profile, and a non-root sandbox -cannot bootstrap the default one -- soffice aborts with "User installation could -not be completed" and converts nothing. get_soffice_env() stays public for the -callers that build their own argv (they must pass -env:UserInstallation too). -""" - -import contextlib -import os -import socket -import subprocess -import tempfile -from collections.abc import Iterable -from pathlib import Path - - -def get_soffice_env() -> dict: - env = os.environ.copy() - env["SAL_USE_VCLPLUGIN"] = "svp" - - if _needs_shim(): - shim = _ensure_shim() - env["LD_PRELOAD"] = str(shim) - - return env - - -def run_soffice(args: Iterable[str], **kwargs) -> subprocess.CompletedProcess: - args = list(args) - with contextlib.ExitStack() as stack: - if not any(str(a).startswith("-env:UserInstallation") for a in args): - profile = stack.enter_context( - tempfile.TemporaryDirectory(prefix="lo_profile_", ignore_cleanup_errors=True) - ) - args = [f"-env:UserInstallation={Path(profile).as_uri()}"] + args - return subprocess.run(["soffice"] + args, env=get_soffice_env(), **kwargs) - - - -_SHIM_SO = Path(tempfile.gettempdir()) / "lo_socket_shim.so" - - -def _needs_shim() -> bool: - try: - s = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) - s.close() - return False - except OSError: - return True - - -def _ensure_shim() -> Path: - if _SHIM_SO.exists(): - return _SHIM_SO - - src = Path(tempfile.gettempdir()) / "lo_socket_shim.c" - src.write_text(_SHIM_SOURCE) - subprocess.run( - ["gcc", "-shared", "-fPIC", "-o", str(_SHIM_SO), str(src), "-ldl"], - check=True, - capture_output=True, - ) - src.unlink() - return _SHIM_SO - - - -_SHIM_SOURCE = r""" -#define _GNU_SOURCE -#include -#include -#include -#include -#include -#include -#include - -static int (*real_socket)(int, int, int); -static int (*real_socketpair)(int, int, int, int[2]); -static int (*real_listen)(int, int); -static int (*real_accept)(int, struct sockaddr *, socklen_t *); -static int (*real_close)(int); -static int (*real_read)(int, void *, size_t); - -/* Per-FD bookkeeping (FDs >= 1024 are passed through unshimmed). */ -static int is_shimmed[1024]; -static int peer_of[1024]; -static int wake_r[1024]; /* accept() blocks reading this */ -static int wake_w[1024]; /* close() writes to this */ -static int listener_fd = -1; /* FD that received listen() */ - -__attribute__((constructor)) -static void init(void) { - real_socket = dlsym(RTLD_NEXT, "socket"); - real_socketpair = dlsym(RTLD_NEXT, "socketpair"); - real_listen = dlsym(RTLD_NEXT, "listen"); - real_accept = dlsym(RTLD_NEXT, "accept"); - real_close = dlsym(RTLD_NEXT, "close"); - real_read = dlsym(RTLD_NEXT, "read"); - for (int i = 0; i < 1024; i++) { - peer_of[i] = -1; - wake_r[i] = -1; - wake_w[i] = -1; - } -} - -/* ---- socket ---------------------------------------------------------- */ -int socket(int domain, int type, int protocol) { - if (domain == AF_UNIX) { - int fd = real_socket(domain, type, protocol); - if (fd >= 0) return fd; - /* socket(AF_UNIX) blocked – fall back to socketpair(). */ - int sv[2]; - if (real_socketpair(domain, type, protocol, sv) == 0) { - if (sv[0] >= 0 && sv[0] < 1024) { - is_shimmed[sv[0]] = 1; - peer_of[sv[0]] = sv[1]; - int wp[2]; - if (pipe(wp) == 0) { - wake_r[sv[0]] = wp[0]; - wake_w[sv[0]] = wp[1]; - } - } - return sv[0]; - } - errno = EPERM; - return -1; - } - return real_socket(domain, type, protocol); -} - -/* ---- listen ---------------------------------------------------------- */ -int listen(int sockfd, int backlog) { - if (sockfd >= 0 && sockfd < 1024 && is_shimmed[sockfd]) { - listener_fd = sockfd; - return 0; - } - return real_listen(sockfd, backlog); -} - -/* ---- accept ---------------------------------------------------------- */ -int accept(int sockfd, struct sockaddr *addr, socklen_t *addrlen) { - if (sockfd >= 0 && sockfd < 1024 && is_shimmed[sockfd]) { - /* Block until close() writes to the wake pipe. */ - if (wake_r[sockfd] >= 0) { - char buf; - real_read(wake_r[sockfd], &buf, 1); - } - errno = ECONNABORTED; - return -1; - } - return real_accept(sockfd, addr, addrlen); -} - -/* ---- close ----------------------------------------------------------- */ -int close(int fd) { - if (fd >= 0 && fd < 1024 && is_shimmed[fd]) { - int was_listener = (fd == listener_fd); - is_shimmed[fd] = 0; - - if (wake_w[fd] >= 0) { /* unblock accept() */ - char c = 0; - write(wake_w[fd], &c, 1); - real_close(wake_w[fd]); - wake_w[fd] = -1; - } - if (wake_r[fd] >= 0) { real_close(wake_r[fd]); wake_r[fd] = -1; } - if (peer_of[fd] >= 0) { real_close(peer_of[fd]); peer_of[fd] = -1; } - - if (was_listener) - _exit(0); /* conversion done – exit */ - } - return real_close(fd); -} -""" - - - -if __name__ == "__main__": - import sys - result = run_soffice(sys.argv[1:]) - sys.exit(result.returncode) diff --git a/src/crates/assembly/core/builtin_skills/pptx/scripts/office/validate.py b/src/crates/assembly/core/builtin_skills/pptx/scripts/office/validate.py deleted file mode 100755 index 8fbd2f71ca..0000000000 --- a/src/crates/assembly/core/builtin_skills/pptx/scripts/office/validate.py +++ /dev/null @@ -1,173 +0,0 @@ -""" -Command line tool to validate Office document XML files against XSD schemas and tracked changes. - -Usage: - python validate.py [--original ] [--auto-repair] [--author NAME] - -The first argument can be either: -- An unpacked directory containing the Office document XML files -- A packed Office file (.docx/.pptx/.xlsx or .dotx/.potx/.xltx template) which will be unpacked to a temp directory - -Auto-repair fixes: -- paraId/durableId values that exceed OOXML limits -- Missing xml:space="preserve" on w:t elements with whitespace -""" - -import argparse -import sys -import tempfile -import zipfile -from pathlib import Path - -import defusedxml.ElementTree as ET -from defusedxml.common import DefusedXmlException - -from helpers import OOXML_FAMILY, rezip, safe_extract -from validators import DOCXSchemaValidator, PPTXSchemaValidator, RedliningValidator - -WORD_NS = "http://schemas.openxmlformats.org/wordprocessingml/2006/main" - - -def _fail(message: str): - print(f"Error: {message}", file=sys.stderr) - sys.exit(2) - - -def _has_tracked_changes(unpacked_dir: Path) -> bool: - document = unpacked_dir / "word" / "document.xml" - if not document.is_file(): - return False - try: - root = ET.parse(document).getroot() - except (ET.ParseError, DefusedXmlException): - return False - tracked = {f"{{{WORD_NS}}}ins", f"{{{WORD_NS}}}del"} - return any(elem.tag in tracked for elem in root.iter()) - - -def main(): - parser = argparse.ArgumentParser(description="Validate Office document XML files") - parser.add_argument( - "path", - help="Path to unpacked directory or packed Office file (.docx/.pptx/.xlsx or .dotx/.potx/.xltx)", - ) - parser.add_argument( - "--original", - required=False, - default=None, - help="Path to original file (.docx/.pptx/.xlsx or .dotx/.potx/.xltx). If omitted, all XSD errors are reported and redlining validation is skipped.", - ) - parser.add_argument( - "-v", - "--verbose", - action="store_true", - help="Enable verbose output", - ) - parser.add_argument( - "--auto-repair", - action="store_true", - help="Automatically repair common issues (hex IDs, whitespace preservation). " - "Modifies the input in place: repairs to a packed file are written back to it.", - ) - parser.add_argument( - "--author", - default=None, - help="The name you are redlining under. Passing it turns on the " - "tracked-change check: any text differing from --original without a " - "/ recording it is reported. Untracked edits carry no " - "author, so the check covers them whoever made them — the name marks " - "the run as redlining work and is not used to filter. Requires " - "--original; docx only.", - ) - args = parser.parse_args() - - if args.author is not None and not args.original: - _fail("--author requires --original") - - path = Path(args.path) - if not path.exists(): - _fail(f"{path} does not exist") - - original_file = None - if args.original: - original_file = Path(args.original) - if not original_file.is_file(): - _fail(f"{original_file} is not a file") - if original_file.suffix.lower() not in OOXML_FAMILY: - _fail(f"{original_file} must be one of: {', '.join(sorted(OOXML_FAMILY))}") - - family = OOXML_FAMILY.get((original_file or path).suffix.lower()) - if family is None: - _fail( - f"Cannot determine file type from {path}. Use --original or provide one of: {', '.join(sorted(OOXML_FAMILY))}." - ) - - if args.author is not None and family != "docx": - _fail(f"--author only applies to docx files, not {family}") - - packed_file = None - temp_dir_ctx = None - if path.is_file() and path.suffix.lower() in OOXML_FAMILY: - packed_file = path - temp_dir_ctx = tempfile.TemporaryDirectory() - unpacked_dir = Path(temp_dir_ctx.name) - try: - with zipfile.ZipFile(path, "r") as zf: - safe_extract(zf, unpacked_dir) - except (zipfile.BadZipFile, ValueError, OSError) as e: - _fail(f"cannot unpack {path}: {e}") - else: - if not path.is_dir(): - _fail(f"{path} is not a directory or Office file") - unpacked_dir = path - - match family: - case "docx": - validators = [ - DOCXSchemaValidator(unpacked_dir, original_file, verbose=args.verbose), - ] - if args.author is not None: - validators.append( - RedliningValidator(unpacked_dir, original_file, verbose=args.verbose) - ) - elif original_file and _has_tracked_changes(unpacked_dir): - print( - "Note: this document has tracked changes; they were not " - "checked against the original (pass --author to check)." - ) - case "pptx": - validators = [ - PPTXSchemaValidator(unpacked_dir, original_file, verbose=args.verbose), - ] - case "xlsx": - exts = ", ".join(k for k, v in sorted(OOXML_FAMILY.items()) if v == "xlsx") - print( - f"No XSD schema validation is performed for xlsx-family files ({exts}). " - "For formula-error checking, use scripts/recalc.py instead." - ) - sys.exit(0) - case _: - print(f"Error: Validation not supported for file type {family}") - sys.exit(1) - - if args.auto_repair: - total_repairs = sum(v.repair() for v in validators) - if total_repairs: - print(f"Auto-repaired {total_repairs} issue(s)") - if packed_file is not None: - rezip(unpacked_dir, packed_file) - print(f"Wrote repaired file to {packed_file}") - - success = all([v.validate() for v in validators]) - - if temp_dir_ctx is not None: - temp_dir_ctx.cleanup() - - if success: - print("All validations PASSED!") - - sys.exit(0 if success else 1) - - -if __name__ == "__main__": - main() diff --git a/src/crates/assembly/core/builtin_skills/pptx/scripts/office/validators/__init__.py b/src/crates/assembly/core/builtin_skills/pptx/scripts/office/validators/__init__.py deleted file mode 100644 index db092ece7e..0000000000 --- a/src/crates/assembly/core/builtin_skills/pptx/scripts/office/validators/__init__.py +++ /dev/null @@ -1,15 +0,0 @@ -""" -Validation modules for Word document processing. -""" - -from .base import BaseSchemaValidator -from .docx import DOCXSchemaValidator -from .pptx import PPTXSchemaValidator -from .redlining import RedliningValidator - -__all__ = [ - "BaseSchemaValidator", - "DOCXSchemaValidator", - "PPTXSchemaValidator", - "RedliningValidator", -] diff --git a/src/crates/assembly/core/builtin_skills/pptx/scripts/office/validators/base.py b/src/crates/assembly/core/builtin_skills/pptx/scripts/office/validators/base.py deleted file mode 100644 index 19d52a7fe0..0000000000 --- a/src/crates/assembly/core/builtin_skills/pptx/scripts/office/validators/base.py +++ /dev/null @@ -1,875 +0,0 @@ -""" -Base validator with common validation logic for document files. -""" - -import re -from pathlib import Path - -import defusedxml.minidom -from functools import lru_cache - -import lxml.etree - -from helpers import safe_extract - - -@lru_cache(maxsize=None) -def _load_schema(schema_path: str): - with open(schema_path, "rb") as xsd_file: - xsd_doc = lxml.etree.parse( - xsd_file, parser=lxml.etree.XMLParser(), base_url=schema_path - ) - return lxml.etree.XMLSchema(xsd_doc) - -class BaseSchemaValidator: - - IGNORED_VALIDATION_ERRORS = [ - "hyphenationZone", - "purl.org/dc/terms", - ] - - UNIQUE_ID_REQUIREMENTS = { - "comment": ("id", "file"), - "commentrangestart": ("id", "file"), - "commentrangeend": ("id", "file"), - "bookmarkstart": ("id", "file"), - "bookmarkend": ("id", "file"), - "sldid": ("id", "file"), - "sldmasterid": ("id", "global"), - "sldlayoutid": ("id", "global"), - "cm": ("authorid", "file"), - "sheet": ("sheetid", "file"), - "definedname": ("id", "file"), - "cxnsp": ("id", "file"), - "sp": ("id", "file"), - "pic": ("id", "file"), - "grpsp": ("id", "file"), - } - - EXCLUDED_ID_CONTAINERS = { - "sectionlst", - } - - ELEMENT_RELATIONSHIP_TYPES = {} - - SCHEMA_MAPPINGS = { - "word": "ISO-IEC29500-4_2016/wml.xsd", - "ppt": "ISO-IEC29500-4_2016/pml.xsd", - "xl": "ISO-IEC29500-4_2016/sml.xsd", - "[Content_Types].xml": "ecma/fouth-edition/opc-contentTypes.xsd", - "app.xml": "ISO-IEC29500-4_2016/shared-documentPropertiesExtended.xsd", - "core.xml": "ecma/fouth-edition/opc-coreProperties.xsd", - "custom.xml": "ISO-IEC29500-4_2016/shared-documentPropertiesCustom.xsd", - ".rels": "ecma/fouth-edition/opc-relationships.xsd", - "people.xml": "microsoft/wml-2012.xsd", - "commentsIds.xml": "microsoft/wml-cid-2016.xsd", - "commentsExtensible.xml": "microsoft/wml-cex-2018.xsd", - "commentsExtended.xml": "microsoft/wml-2012.xsd", - "chart": "ISO-IEC29500-4_2016/dml-chart.xsd", - "theme": "ISO-IEC29500-4_2016/dml-main.xsd", - "drawing": "ISO-IEC29500-4_2016/dml-main.xsd", - } - - MC_NAMESPACE = "http://schemas.openxmlformats.org/markup-compatibility/2006" - XML_NAMESPACE = "http://www.w3.org/XML/1998/namespace" - - PACKAGE_RELATIONSHIPS_NAMESPACE = ( - "http://schemas.openxmlformats.org/package/2006/relationships" - ) - OFFICE_RELATIONSHIPS_NAMESPACE = ( - "http://schemas.openxmlformats.org/officeDocument/2006/relationships" - ) - CONTENT_TYPES_NAMESPACE = ( - "http://schemas.openxmlformats.org/package/2006/content-types" - ) - - MAIN_CONTENT_FOLDERS = {"word", "ppt", "xl"} - - OOXML_NAMESPACES = { - "http://schemas.openxmlformats.org/officeDocument/2006/math", - "http://schemas.openxmlformats.org/officeDocument/2006/relationships", - "http://schemas.openxmlformats.org/schemaLibrary/2006/main", - "http://schemas.openxmlformats.org/drawingml/2006/main", - "http://schemas.openxmlformats.org/drawingml/2006/chart", - "http://schemas.openxmlformats.org/drawingml/2006/chartDrawing", - "http://schemas.openxmlformats.org/drawingml/2006/diagram", - "http://schemas.openxmlformats.org/drawingml/2006/picture", - "http://schemas.openxmlformats.org/drawingml/2006/spreadsheetDrawing", - "http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing", - "http://schemas.openxmlformats.org/wordprocessingml/2006/main", - "http://schemas.openxmlformats.org/presentationml/2006/main", - "http://schemas.openxmlformats.org/spreadsheetml/2006/main", - "http://schemas.openxmlformats.org/officeDocument/2006/sharedTypes", - "http://www.w3.org/XML/1998/namespace", - } - - def __init__(self, unpacked_dir, original_file=None, verbose=False): - self.unpacked_dir = Path(unpacked_dir).resolve() - self.original_file = Path(original_file) if original_file else None - self.verbose = verbose - - self.schemas_dir = Path(__file__).parent.parent / "schemas" - - patterns = ["*.xml", "*.rels"] - self.xml_files = [ - f for pattern in patterns for f in self.unpacked_dir.rglob(pattern) - ] - - if not self.xml_files: - print(f"Warning: No XML files found in {self.unpacked_dir}") - - def validate(self): - raise NotImplementedError("Subclasses must implement the validate method") - - def repair(self) -> int: - return self.repair_whitespace_preservation() - - def repair_whitespace_preservation(self) -> int: - repairs = 0 - - for xml_file in self.xml_files: - try: - content = xml_file.read_text(encoding="utf-8") - dom = defusedxml.minidom.parseString(content) - pending = [] - - for elem in dom.getElementsByTagName("*"): - local_name = elem.tagName.rsplit(":", 1)[-1] - if local_name in ("t", "delText", "instrText", "delInstrText"): - text = "".join( - child.data - for child in elem.childNodes - if child.nodeType in (child.TEXT_NODE, child.CDATA_SECTION_NODE) - ) - ws = (" ", "\t", "\n", "\r") - if text and (text.startswith(ws) or text.endswith(ws)): - if elem.getAttribute("xml:space") != "preserve": - elem.setAttribute("xml:space", "preserve") - text_preview = repr(text[:30]) + "..." if len(text) > 30 else repr(text) - pending.append(f" Repaired: {xml_file.name}: Added xml:space='preserve' to {elem.tagName}: {text_preview}") - - if pending: - xml_file.write_bytes(dom.toxml(encoding="UTF-8")) - for message in pending: - print(message) - repairs += len(pending) - - except Exception: - pass - - return repairs - - def validate_xml(self): - errors = [] - - for xml_file in self.xml_files: - try: - lxml.etree.parse(str(xml_file)) - except lxml.etree.XMLSyntaxError as e: - errors.append( - f" {xml_file.relative_to(self.unpacked_dir)}: " - f"Line {e.lineno}: {e.msg}" - ) - except Exception as e: - errors.append( - f" {xml_file.relative_to(self.unpacked_dir)}: " - f"Unexpected error: {str(e)}" - ) - - if errors: - print(f"FAILED - Found {len(errors)} XML violations:") - for error in errors: - print(error) - return False - else: - if self.verbose: - print("PASSED - All XML files are well-formed") - return True - - def validate_namespaces(self): - errors = [] - - for xml_file in self.xml_files: - try: - root = lxml.etree.parse(str(xml_file)).getroot() - declared = set(root.nsmap.keys()) - {None} - - for attr_val in [ - v for k, v in root.attrib.items() if k.endswith("Ignorable") - ]: - undeclared = set(attr_val.split()) - declared - errors.extend( - f" {xml_file.relative_to(self.unpacked_dir)}: " - f"Namespace '{ns}' in Ignorable but not declared" - for ns in undeclared - ) - except lxml.etree.XMLSyntaxError: - continue - - if errors: - print(f"FAILED - {len(errors)} namespace issues:") - for error in errors: - print(error) - return False - if self.verbose: - print("PASSED - All namespace prefixes properly declared") - return True - - def validate_unique_ids(self): - errors = [] - global_ids = {} - - for xml_file in self.xml_files: - try: - root = lxml.etree.parse(str(xml_file)).getroot() - file_ids = {} - - mc_elements = root.xpath( - ".//mc:AlternateContent", namespaces={"mc": self.MC_NAMESPACE} - ) - for elem in mc_elements: - elem.getparent().remove(elem) - - for elem in root.iter(): - if not hasattr(elem, "tag") or callable(elem.tag): - continue - tag = ( - elem.tag.split("}")[-1].lower() - if "}" in elem.tag - else elem.tag.lower() - ) - - if tag in self.UNIQUE_ID_REQUIREMENTS: - in_excluded_container = any( - ancestor.tag.split("}")[-1].lower() in self.EXCLUDED_ID_CONTAINERS - for ancestor in elem.iterancestors() - ) - if in_excluded_container: - continue - - attr_name, scope = self.UNIQUE_ID_REQUIREMENTS[tag] - - id_value = None - for attr, value in elem.attrib.items(): - attr_local = ( - attr.split("}")[-1].lower() - if "}" in attr - else attr.lower() - ) - if attr_local == attr_name: - id_value = value - break - - if id_value is not None: - if scope == "global": - if id_value in global_ids: - prev_file, prev_line, prev_tag = global_ids[ - id_value - ] - errors.append( - f" {xml_file.relative_to(self.unpacked_dir)}: " - f"Line {elem.sourceline}: Global ID '{id_value}' in <{tag}> " - f"already used in {prev_file} at line {prev_line} in <{prev_tag}>" - ) - else: - global_ids[id_value] = ( - xml_file.relative_to(self.unpacked_dir), - elem.sourceline, - tag, - ) - elif scope == "file": - key = (tag, attr_name) - if key not in file_ids: - file_ids[key] = {} - - if id_value in file_ids[key]: - prev_line = file_ids[key][id_value] - errors.append( - f" {xml_file.relative_to(self.unpacked_dir)}: " - f"Line {elem.sourceline}: Duplicate {attr_name}='{id_value}' in <{tag}> " - f"(first occurrence at line {prev_line})" - ) - else: - file_ids[key][id_value] = elem.sourceline - - except (lxml.etree.XMLSyntaxError, Exception) as e: - errors.append( - f" {xml_file.relative_to(self.unpacked_dir)}: Error: {e}" - ) - - if errors: - print(f"FAILED - Found {len(errors)} ID uniqueness violations:") - for error in errors: - print(error) - return False - else: - if self.verbose: - print("PASSED - All required IDs are unique") - return True - - def validate_file_references(self): - errors = [] - - rels_files = list(self.unpacked_dir.rglob("*.rels")) - - if not rels_files: - if self.verbose: - print("PASSED - No .rels files found") - return True - - all_files = [] - for file_path in self.unpacked_dir.rglob("*"): - if ( - file_path.is_file() - and file_path.name != "[Content_Types].xml" - and not file_path.name.endswith(".rels") - ): - all_files.append(file_path.resolve()) - - all_referenced_files = set() - - if self.verbose: - print( - f"Found {len(rels_files)} .rels files and {len(all_files)} target files" - ) - - for rels_file in rels_files: - try: - rels_root = lxml.etree.parse(str(rels_file)).getroot() - - rels_dir = rels_file.parent - - referenced_files = set() - broken_refs = [] - - for rel in rels_root.findall( - ".//ns:Relationship", - namespaces={"ns": self.PACKAGE_RELATIONSHIPS_NAMESPACE}, - ): - target = rel.get("Target") - if rel.get("TargetMode") == "External": - continue - if target and not target.startswith( - ("http", "mailto:") - ): - if target.startswith("/"): - target_path = self.unpacked_dir / target.lstrip("/") - elif rels_file.name == ".rels": - target_path = self.unpacked_dir / target - else: - base_dir = rels_dir.parent - target_path = base_dir / target - - try: - target_path = target_path.resolve() - if target_path.exists() and target_path.is_file(): - referenced_files.add(target_path) - all_referenced_files.add(target_path) - else: - broken_refs.append((target, rel.sourceline)) - except (OSError, ValueError): - broken_refs.append((target, rel.sourceline)) - - if broken_refs: - rel_path = rels_file.relative_to(self.unpacked_dir) - for broken_ref, line_num in broken_refs: - errors.append( - f" {rel_path}: Line {line_num}: Broken reference to {broken_ref}" - ) - - except Exception as e: - rel_path = rels_file.relative_to(self.unpacked_dir) - errors.append(f" Error parsing {rel_path}: {e}") - - unreferenced_files = set(all_files) - all_referenced_files - - if unreferenced_files: - for unref_file in sorted(unreferenced_files): - unref_rel_path = unref_file.relative_to(self.unpacked_dir) - errors.append(f" Unreferenced file: {unref_rel_path}") - - if errors: - print(f"FAILED - Found {len(errors)} relationship validation errors:") - for error in errors: - print(error) - print( - "CRITICAL: These errors will cause the document to appear corrupt. " - + "Broken references MUST be fixed, " - + "and unreferenced files MUST be referenced or removed." - ) - return False - else: - if self.verbose: - print( - "PASSED - All references are valid and all files are properly referenced" - ) - return True - - def validate_all_relationship_ids(self): - import lxml.etree - - errors = [] - - for xml_file in self.xml_files: - if xml_file.suffix == ".rels": - continue - - rels_dir = xml_file.parent / "_rels" - rels_file = rels_dir / f"{xml_file.name}.rels" - - if not rels_file.exists(): - continue - - try: - rels_root = lxml.etree.parse(str(rels_file)).getroot() - rid_to_type = {} - - for rel in rels_root.findall( - f".//{{{self.PACKAGE_RELATIONSHIPS_NAMESPACE}}}Relationship" - ): - rid = rel.get("Id") - rel_type = rel.get("Type", "") - if rid: - if rid in rid_to_type: - rels_rel_path = rels_file.relative_to(self.unpacked_dir) - errors.append( - f" {rels_rel_path}: Line {rel.sourceline}: " - f"Duplicate relationship ID '{rid}' (IDs must be unique)" - ) - type_name = ( - rel_type.split("/")[-1] if "/" in rel_type else rel_type - ) - rid_to_type[rid] = type_name - - xml_root = lxml.etree.parse(str(xml_file)).getroot() - - r_ns = self.OFFICE_RELATIONSHIPS_NAMESPACE - rid_attrs_to_check = ["id", "embed", "link"] - for elem in xml_root.iter(): - if not hasattr(elem, "tag") or callable(elem.tag): - continue - for attr_name in rid_attrs_to_check: - rid_attr = elem.get(f"{{{r_ns}}}{attr_name}") - if not rid_attr: - continue - xml_rel_path = xml_file.relative_to(self.unpacked_dir) - elem_name = ( - elem.tag.split("}")[-1] if "}" in elem.tag else elem.tag - ) - - if rid_attr not in rid_to_type: - errors.append( - f" {xml_rel_path}: Line {elem.sourceline}: " - f"<{elem_name}> r:{attr_name} references non-existent relationship '{rid_attr}' " - f"(valid IDs: {', '.join(sorted(rid_to_type.keys())[:5])}{'...' if len(rid_to_type) > 5 else ''})" - ) - elif attr_name == "id" and self.ELEMENT_RELATIONSHIP_TYPES: - expected_type = self._get_expected_relationship_type( - elem_name - ) - if expected_type: - actual_type = rid_to_type[rid_attr] - if expected_type not in actual_type.lower(): - errors.append( - f" {xml_rel_path}: Line {elem.sourceline}: " - f"<{elem_name}> references '{rid_attr}' which points to '{actual_type}' " - f"but should point to a '{expected_type}' relationship" - ) - - except Exception as e: - xml_rel_path = xml_file.relative_to(self.unpacked_dir) - errors.append(f" Error processing {xml_rel_path}: {e}") - - if errors: - print(f"FAILED - Found {len(errors)} relationship ID reference errors:") - for error in errors: - print(error) - print("\nThese ID mismatches will cause the document to appear corrupt!") - return False - else: - if self.verbose: - print("PASSED - All relationship ID references are valid") - return True - - def _get_expected_relationship_type(self, element_name): - elem_lower = element_name.lower() - - if elem_lower in self.ELEMENT_RELATIONSHIP_TYPES: - return self.ELEMENT_RELATIONSHIP_TYPES[elem_lower] - - if elem_lower.endswith("id") and len(elem_lower) > 2: - prefix = elem_lower[:-2] - if prefix.endswith("master"): - return prefix.lower() - elif prefix.endswith("layout"): - return prefix.lower() - else: - if prefix == "sld": - return "slide" - return prefix.lower() - - if elem_lower.endswith("reference") and len(elem_lower) > 9: - prefix = elem_lower[:-9] - return prefix.lower() - - return None - - def validate_content_types(self): - errors = [] - - content_types_file = self.unpacked_dir / "[Content_Types].xml" - if not content_types_file.exists(): - print("FAILED - [Content_Types].xml file not found") - return False - - try: - root = lxml.etree.parse(str(content_types_file)).getroot() - declared_parts = set() - declared_extensions = set() - - for override in root.findall( - f".//{{{self.CONTENT_TYPES_NAMESPACE}}}Override" - ): - part_name = override.get("PartName") - if part_name is not None: - declared_parts.add(part_name.lstrip("/")) - - for default in root.findall( - f".//{{{self.CONTENT_TYPES_NAMESPACE}}}Default" - ): - extension = default.get("Extension") - if extension is not None: - declared_extensions.add(extension.lower()) - - declarable_roots = { - "sld", - "sldLayout", - "sldMaster", - "presentation", - "document", - "workbook", - "worksheet", - "theme", - } - - media_extensions = { - "png": "image/png", - "jpg": "image/jpeg", - "jpeg": "image/jpeg", - "gif": "image/gif", - "bmp": "image/bmp", - "tiff": "image/tiff", - "wmf": "image/x-wmf", - "emf": "image/x-emf", - } - - all_files = list(self.unpacked_dir.rglob("*")) - all_files = [f for f in all_files if f.is_file()] - - for xml_file in self.xml_files: - path_str = str(xml_file.relative_to(self.unpacked_dir)).replace( - "\\", "/" - ) - - if any( - skip in path_str - for skip in [".rels", "[Content_Types]", "docProps/", "_rels/"] - ): - continue - - try: - root_tag = lxml.etree.parse(str(xml_file)).getroot().tag - root_name = root_tag.split("}")[-1] if "}" in root_tag else root_tag - - if root_name in declarable_roots and path_str not in declared_parts: - errors.append( - f" {path_str}: File with <{root_name}> root not declared in [Content_Types].xml" - ) - - except Exception: - continue - - for file_path in all_files: - if file_path.suffix.lower() in {".xml", ".rels"}: - continue - if file_path.name == "[Content_Types].xml": - continue - if "_rels" in file_path.parts or "docProps" in file_path.parts: - continue - - extension = file_path.suffix.lstrip(".").lower() - if extension and extension not in declared_extensions: - if extension in media_extensions: - relative_path = file_path.relative_to(self.unpacked_dir) - errors.append( - f' {relative_path}: File with extension \'{extension}\' not declared in [Content_Types].xml - should add: ' - ) - - except Exception as e: - errors.append(f" Error parsing [Content_Types].xml: {e}") - - if errors: - print(f"FAILED - Found {len(errors)} content type declaration errors:") - for error in errors: - print(error) - return False - else: - if self.verbose: - print( - "PASSED - All content files are properly declared in [Content_Types].xml" - ) - return True - - def validate_file_against_xsd(self, xml_file, verbose=False): - xml_file = Path(xml_file).resolve() - unpacked_dir = self.unpacked_dir.resolve() - - is_valid, current_errors = self._validate_single_file_xsd( - xml_file, unpacked_dir - ) - - if is_valid is None: - return None, set() - elif is_valid: - return True, set() - - original_errors = self._get_original_file_errors(xml_file) - - assert current_errors is not None - new_errors = current_errors - original_errors - - new_errors = { - e for e in new_errors - if not any(pattern in e for pattern in self.IGNORED_VALIDATION_ERRORS) - } - - if new_errors: - if verbose: - relative_path = xml_file.relative_to(unpacked_dir) - print(f"FAILED - {relative_path}: {len(new_errors)} new error(s)") - for error in list(new_errors)[:3]: - truncated = error[:250] + "..." if len(error) > 250 else error - print(f" - {truncated}") - return False, new_errors - else: - if verbose: - print( - f"PASSED - No new errors (original had {len(current_errors)} errors)" - ) - return True, set() - - def validate_against_xsd(self): - new_errors = [] - original_error_count = 0 - valid_count = 0 - skipped_count = 0 - - for xml_file in self.xml_files: - relative_path = str(xml_file.relative_to(self.unpacked_dir)) - is_valid, new_file_errors = self.validate_file_against_xsd( - xml_file, verbose=False - ) - - if is_valid is None: - skipped_count += 1 - continue - elif is_valid and not new_file_errors: - valid_count += 1 - continue - elif is_valid: - original_error_count += 1 - valid_count += 1 - continue - - new_errors.append(f" {relative_path}: {len(new_file_errors)} new error(s)") - for error in list(new_file_errors)[:3]: - new_errors.append( - f" - {error[:250]}..." if len(error) > 250 else f" - {error}" - ) - - if self.verbose: - print(f"Validated {len(self.xml_files)} files:") - print(f" - Valid: {valid_count}") - print(f" - Skipped (no schema): {skipped_count}") - if original_error_count: - print(f" - With original errors (ignored): {original_error_count}") - print( - f" - With NEW errors: {len(new_errors) > 0 and len([e for e in new_errors if not e.startswith(' ')]) or 0}" - ) - - if new_errors: - print("\nFAILED - Found NEW validation errors:") - for error in new_errors: - print(error) - return False - else: - if self.verbose: - print("\nPASSED - No new XSD validation errors introduced") - return True - - def _get_schema_path(self, xml_file): - if xml_file.name in self.SCHEMA_MAPPINGS: - return self.schemas_dir / self.SCHEMA_MAPPINGS[xml_file.name] - - if xml_file.suffix == ".rels": - return self.schemas_dir / self.SCHEMA_MAPPINGS[".rels"] - - if "charts/" in str(xml_file) and xml_file.name.startswith("chart"): - return self.schemas_dir / self.SCHEMA_MAPPINGS["chart"] - - if "theme/" in str(xml_file) and xml_file.name.startswith("theme"): - return self.schemas_dir / self.SCHEMA_MAPPINGS["theme"] - - if xml_file.parent.name in self.MAIN_CONTENT_FOLDERS: - return self.schemas_dir / self.SCHEMA_MAPPINGS[xml_file.parent.name] - - return None - - def _clean_ignorable_namespaces(self, xml_doc): - xml_string = lxml.etree.tostring(xml_doc, encoding="unicode") - xml_copy = lxml.etree.fromstring(xml_string) - - for elem in xml_copy.iter(): - attrs_to_remove = [] - - for attr in elem.attrib: - if "{" in attr: - ns = attr.split("}")[0][1:] - if ns not in self.OOXML_NAMESPACES: - attrs_to_remove.append(attr) - - for attr in attrs_to_remove: - del elem.attrib[attr] - - self._remove_ignorable_elements(xml_copy) - - return lxml.etree.ElementTree(xml_copy) - - def _remove_ignorable_elements(self, root): - elements_to_remove = [] - - for elem in list(root): - if not hasattr(elem, "tag") or callable(elem.tag): - continue - - tag_str = str(elem.tag) - if tag_str.startswith("{"): - ns = tag_str.split("}")[0][1:] - if ns not in self.OOXML_NAMESPACES: - elements_to_remove.append(elem) - continue - - self._remove_ignorable_elements(elem) - - for elem in elements_to_remove: - root.remove(elem) - - def _preprocess_for_mc_ignorable(self, xml_doc): - root = xml_doc.getroot() - - if f"{{{self.MC_NAMESPACE}}}Ignorable" in root.attrib: - del root.attrib[f"{{{self.MC_NAMESPACE}}}Ignorable"] - - return xml_doc - - def _preprocess_for_schema(self, xml_doc, relative_path): - return xml_doc - - def _validate_single_file_xsd(self, xml_file, base_path, schema_path=None): - schema_path = schema_path or self._get_schema_path(xml_file) - if not schema_path: - return None, None - - try: - schema = _load_schema(str(schema_path)) - - with open(xml_file, "r") as f: - xml_doc = lxml.etree.parse(f) - - xml_doc, _ = self._remove_template_tags_from_text_nodes(xml_doc) - xml_doc = self._preprocess_for_mc_ignorable(xml_doc) - - relative_path = xml_file.relative_to(base_path) - if ( - relative_path.parts - and relative_path.parts[0] in self.MAIN_CONTENT_FOLDERS - ): - xml_doc = self._clean_ignorable_namespaces(xml_doc) - - xml_doc = self._preprocess_for_schema(xml_doc, relative_path) - - if schema.validate(xml_doc): - return True, set() - else: - errors = set() - for error in schema.error_log: - errors.add(error.message) - return False, errors - - except Exception as e: - return False, {str(e)} - - def _get_original_file_errors(self, xml_file, schema_path=None): - if self.original_file is None: - return set() - - import tempfile - import zipfile - - xml_file = Path(xml_file).resolve() - unpacked_dir = self.unpacked_dir.resolve() - relative_path = xml_file.relative_to(unpacked_dir) - - with tempfile.TemporaryDirectory() as temp_dir: - temp_path = Path(temp_dir) - - try: - with zipfile.ZipFile(self.original_file, "r") as zip_ref: - safe_extract(zip_ref, temp_path) - except (zipfile.BadZipFile, ValueError, OSError): - return set() - - original_xml_file = temp_path / relative_path - - if not original_xml_file.exists(): - return set() - - is_valid, errors = self._validate_single_file_xsd( - original_xml_file, temp_path, schema_path=schema_path - ) - return errors if errors else set() - - def _remove_template_tags_from_text_nodes(self, xml_doc): - warnings = [] - template_pattern = re.compile(r"\{\{[^}]*\}\}") - - xml_string = lxml.etree.tostring(xml_doc, encoding="unicode") - xml_copy = lxml.etree.fromstring(xml_string) - - def process_text_content(text, content_type): - if not text: - return text - matches = list(template_pattern.finditer(text)) - if matches: - for match in matches: - warnings.append( - f"Found template tag in {content_type}: {match.group()}" - ) - return template_pattern.sub("", text) - return text - - for elem in xml_copy.iter(): - if not hasattr(elem, "tag") or callable(elem.tag): - continue - tag_str = str(elem.tag) - if tag_str.endswith("}t") or tag_str == "t": - continue - - elem.text = process_text_content(elem.text, "text content") - elem.tail = process_text_content(elem.tail, "tail content") - - return lxml.etree.ElementTree(xml_copy), warnings - - -if __name__ == "__main__": - raise RuntimeError("This module should not be run directly.") diff --git a/src/crates/assembly/core/builtin_skills/pptx/scripts/office/validators/docx.py b/src/crates/assembly/core/builtin_skills/pptx/scripts/office/validators/docx.py deleted file mode 100644 index 0d18b6979a..0000000000 --- a/src/crates/assembly/core/builtin_skills/pptx/scripts/office/validators/docx.py +++ /dev/null @@ -1,466 +0,0 @@ -""" -Validator for Word document XML files against XSD schemas. -""" - -import random -import re -import tempfile -import zipfile -from pathlib import Path - -import defusedxml.minidom -import lxml.etree - -from helpers import safe_extract - -from .base import BaseSchemaValidator - - -class DOCXSchemaValidator(BaseSchemaValidator): - - WORD_2006_NAMESPACE = "http://schemas.openxmlformats.org/wordprocessingml/2006/main" - W14_NAMESPACE = "http://schemas.microsoft.com/office/word/2010/wordml" - W16CID_NAMESPACE = "http://schemas.microsoft.com/office/word/2016/wordml/cid" - - ELEMENT_RELATIONSHIP_TYPES = {} - - def validate(self): - if not self.validate_xml(): - return False - - all_valid = True - if not self.validate_namespaces(): - all_valid = False - - if not self.validate_unique_ids(): - all_valid = False - - if not self.validate_file_references(): - all_valid = False - - if not self.validate_content_types(): - all_valid = False - - if not self.validate_against_xsd(): - all_valid = False - - if not self.validate_whitespace_preservation(): - all_valid = False - - if not self.validate_deletions(): - all_valid = False - - if not self.validate_insertions(): - all_valid = False - - if not self.validate_all_relationship_ids(): - all_valid = False - - if not self.validate_id_constraints(): - all_valid = False - - if not self.validate_comment_markers(): - all_valid = False - - self.compare_paragraph_counts() - - return all_valid - - def validate_whitespace_preservation(self): - errors = [] - - for xml_file in self.xml_files: - if xml_file.name != "document.xml": - continue - - try: - root = lxml.etree.parse(str(xml_file)).getroot() - - for elem in root.iter(f"{{{self.WORD_2006_NAMESPACE}}}t"): - if elem.text: - text = elem.text - if re.search(r"^[ \t\n\r]", text) or re.search( - r"[ \t\n\r]$", text - ): - xml_space_attr = f"{{{self.XML_NAMESPACE}}}space" - if ( - xml_space_attr not in elem.attrib - or elem.attrib[xml_space_attr] != "preserve" - ): - text_preview = ( - repr(text)[:50] + "..." - if len(repr(text)) > 50 - else repr(text) - ) - errors.append( - f" {xml_file.relative_to(self.unpacked_dir)}: " - f"Line {elem.sourceline}: w:t element with whitespace missing xml:space='preserve': {text_preview}" - ) - - except (lxml.etree.XMLSyntaxError, Exception) as e: - errors.append( - f" {xml_file.relative_to(self.unpacked_dir)}: Error: {e}" - ) - - if errors: - print(f"FAILED - Found {len(errors)} whitespace preservation violations:") - for error in errors: - print(error) - return False - else: - if self.verbose: - print("PASSED - All whitespace is properly preserved") - return True - - def validate_deletions(self): - errors = [] - - for xml_file in self.xml_files: - if xml_file.name != "document.xml": - continue - - try: - root = lxml.etree.parse(str(xml_file)).getroot() - namespaces = {"w": self.WORD_2006_NAMESPACE} - - for t_elem in root.xpath(".//w:del//w:t", namespaces=namespaces): - if t_elem.text: - text_preview = ( - repr(t_elem.text)[:50] + "..." - if len(repr(t_elem.text)) > 50 - else repr(t_elem.text) - ) - errors.append( - f" {xml_file.relative_to(self.unpacked_dir)}: " - f"Line {t_elem.sourceline}: found within : {text_preview}" - ) - - for instr_elem in root.xpath( - ".//w:del//w:instrText", namespaces=namespaces - ): - text_preview = ( - repr(instr_elem.text or "")[:50] + "..." - if len(repr(instr_elem.text or "")) > 50 - else repr(instr_elem.text or "") - ) - errors.append( - f" {xml_file.relative_to(self.unpacked_dir)}: " - f"Line {instr_elem.sourceline}: found within (use ): {text_preview}" - ) - - except (lxml.etree.XMLSyntaxError, Exception) as e: - errors.append( - f" {xml_file.relative_to(self.unpacked_dir)}: Error: {e}" - ) - - if errors: - print(f"FAILED - Found {len(errors)} deletion validation violations:") - for error in errors: - print(error) - return False - else: - if self.verbose: - print("PASSED - No w:t elements found within w:del elements") - return True - - def count_paragraphs_in_unpacked(self): - count = 0 - - for xml_file in self.xml_files: - if xml_file.name != "document.xml": - continue - - try: - root = lxml.etree.parse(str(xml_file)).getroot() - paragraphs = root.findall(f".//{{{self.WORD_2006_NAMESPACE}}}p") - count = len(paragraphs) - except Exception as e: - print(f"Error counting paragraphs in unpacked document: {e}") - - return count - - def count_paragraphs_in_original(self): - original = self.original_file - if original is None: - return 0 - - count = 0 - - try: - with tempfile.TemporaryDirectory() as temp_dir: - with zipfile.ZipFile(original, "r") as zip_ref: - safe_extract(zip_ref, Path(temp_dir)) - - doc_xml_path = temp_dir + "/word/document.xml" - root = lxml.etree.parse(doc_xml_path).getroot() - - paragraphs = root.findall(f".//{{{self.WORD_2006_NAMESPACE}}}p") - count = len(paragraphs) - - except Exception as e: - print(f"Error counting paragraphs in original document: {e}") - - return count - - def validate_insertions(self): - errors = [] - - for xml_file in self.xml_files: - if xml_file.name != "document.xml": - continue - - try: - root = lxml.etree.parse(str(xml_file)).getroot() - namespaces = {"w": self.WORD_2006_NAMESPACE} - - invalid_elements = root.xpath( - ".//w:ins//w:delText[not(ancestor::w:del)]", namespaces=namespaces - ) - - for elem in invalid_elements: - text_preview = ( - repr(elem.text or "")[:50] + "..." - if len(repr(elem.text or "")) > 50 - else repr(elem.text or "") - ) - errors.append( - f" {xml_file.relative_to(self.unpacked_dir)}: " - f"Line {elem.sourceline}: within : {text_preview}" - ) - - except (lxml.etree.XMLSyntaxError, Exception) as e: - errors.append( - f" {xml_file.relative_to(self.unpacked_dir)}: Error: {e}" - ) - - if errors: - print(f"FAILED - Found {len(errors)} insertion validation violations:") - for error in errors: - print(error) - return False - else: - if self.verbose: - print("PASSED - No w:delText elements within w:ins elements") - return True - - def compare_paragraph_counts(self): - new_count = self.count_paragraphs_in_unpacked() - if self.original_file is None: - print(f"\nParagraphs: {new_count}") - return - - original_count = self.count_paragraphs_in_original() - diff = new_count - original_count - diff_str = f"+{diff}" if diff > 0 else str(diff) - print(f"\nParagraphs: {original_count} → {new_count} ({diff_str})") - - def _parse_id_value(self, val: str, base: int = 16) -> int: - return int(val, base) - - def validate_id_constraints(self): - errors = [] - para_id_attr = f"{{{self.W14_NAMESPACE}}}paraId" - durable_id_attr = f"{{{self.W16CID_NAMESPACE}}}durableId" - - for xml_file in self.xml_files: - try: - for elem in lxml.etree.parse(str(xml_file)).iter(): - if val := elem.get(para_id_attr): - try: - if self._parse_id_value(val, base=16) >= 0x80000000: - errors.append( - f" {xml_file.name}:{elem.sourceline}: paraId={val} >= 0x80000000" - ) - except ValueError: - errors.append( - f" {xml_file.name}:{elem.sourceline}: " - f"paraId={val} is not valid hex" - ) - - if val := elem.get(durable_id_attr): - if xml_file.name == "numbering.xml": - try: - if self._parse_id_value(val, base=10) >= 0x7FFFFFFF: - errors.append( - f" {xml_file.name}:{elem.sourceline}: " - f"durableId={val} >= 0x7FFFFFFF" - ) - except ValueError: - errors.append( - f" {xml_file.name}:{elem.sourceline}: " - f"durableId={val} must be decimal in numbering.xml" - ) - else: - try: - if self._parse_id_value(val, base=16) >= 0x7FFFFFFF: - errors.append( - f" {xml_file.name}:{elem.sourceline}: " - f"durableId={val} >= 0x7FFFFFFF" - ) - except ValueError: - errors.append( - f" {xml_file.name}:{elem.sourceline}: " - f"durableId={val} is not valid hex" - ) - except lxml.etree.XMLSyntaxError: - continue - - if errors: - print(f"FAILED - {len(errors)} ID constraint violations:") - for e in errors: - print(e) - elif self.verbose: - print("PASSED - All paraId/durableId values within constraints") - return not errors - - def validate_comment_markers(self): - errors = [] - - document_xml = None - comments_xml = None - for xml_file in self.xml_files: - if xml_file.name == "document.xml" and "word" in str(xml_file): - document_xml = xml_file - elif xml_file.name == "comments.xml": - comments_xml = xml_file - - if not document_xml: - if self.verbose: - print("PASSED - No document.xml found (skipping comment validation)") - return True - - try: - doc_root = lxml.etree.parse(str(document_xml)).getroot() - namespaces = {"w": self.WORD_2006_NAMESPACE} - - range_starts = { - elem.get(f"{{{self.WORD_2006_NAMESPACE}}}id") - for elem in doc_root.xpath( - ".//w:commentRangeStart", namespaces=namespaces - ) - } - range_ends = { - elem.get(f"{{{self.WORD_2006_NAMESPACE}}}id") - for elem in doc_root.xpath( - ".//w:commentRangeEnd", namespaces=namespaces - ) - } - references = { - elem.get(f"{{{self.WORD_2006_NAMESPACE}}}id") - for elem in doc_root.xpath( - ".//w:commentReference", namespaces=namespaces - ) - } - - orphaned_ends = range_ends - range_starts - for comment_id in sorted( - orphaned_ends, key=lambda x: int(x) if x and x.isdigit() else 0 - ): - errors.append( - f' document.xml: commentRangeEnd id="{comment_id}" has no matching commentRangeStart' - ) - - orphaned_starts = range_starts - range_ends - for comment_id in sorted( - orphaned_starts, key=lambda x: int(x) if x and x.isdigit() else 0 - ): - errors.append( - f' document.xml: commentRangeStart id="{comment_id}" has no matching commentRangeEnd' - ) - - comment_ids = set() - if comments_xml and comments_xml.exists(): - comments_root = lxml.etree.parse(str(comments_xml)).getroot() - comment_ids = { - elem.get(f"{{{self.WORD_2006_NAMESPACE}}}id") - for elem in comments_root.xpath( - ".//w:comment", namespaces=namespaces - ) - } - - marker_ids = range_starts | range_ends | references - invalid_refs = marker_ids - comment_ids - for comment_id in sorted( - invalid_refs, key=lambda x: int(x) if x and x.isdigit() else 0 - ): - if comment_id: - errors.append( - f' document.xml: marker id="{comment_id}" references non-existent comment' - ) - - except (lxml.etree.XMLSyntaxError, Exception) as e: - errors.append(f" Error parsing XML: {e}") - - if errors: - print(f"FAILED - {len(errors)} comment marker violations:") - for error in errors: - print(error) - return False - else: - if self.verbose: - print("PASSED - All comment markers properly paired") - return True - - def repair(self) -> int: - repairs = super().repair() - repairs += self.repair_durableId() - return repairs - - def repair_durableId(self) -> int: - DURABLE_ID_ATTRS = ("w16cid:durableId", "w16cex:durableId") - repairs = 0 - renames: dict = {} - - for xml_file in self.xml_files: - try: - content = xml_file.read_text(encoding="utf-8") - dom = defusedxml.minidom.parseString(content) - is_numbering = xml_file.name == "numbering.xml" - base = 10 if is_numbering else 16 - pending = [] - seen_in_file = set() - modified = False - - for elem in dom.getElementsByTagName("*"): - for attr_name in DURABLE_ID_ATTRS: - if not elem.hasAttribute(attr_name): - continue - - durable_id = elem.getAttribute(attr_name) - try: - key = self._parse_id_value(durable_id, base=base) - needs_repair = key >= 0x7FFFFFFF - except ValueError: - key = durable_id - needs_repair = True - - if needs_repair: - if key in seen_in_file: - value = random.randint(1, 0x7FFFFFFE) - else: - seen_in_file.add(key) - if key not in renames: - renames[key] = random.randint(1, 0x7FFFFFFE) - value = renames[key] - new_id = str(value) if is_numbering else f"{value:08X}" - - elem.setAttribute(attr_name, new_id) - pending.append( - f" Repaired: {xml_file.name}: durableId {durable_id} → {new_id}" - ) - modified = True - - if modified: - xml_file.write_bytes(dom.toxml(encoding="UTF-8")) - for message in pending: - print(message) - repairs += len(pending) - - except Exception: - pass - - return repairs - - -if __name__ == "__main__": - raise RuntimeError("This module should not be run directly.") diff --git a/src/crates/assembly/core/builtin_skills/pptx/scripts/office/validators/pptx.py b/src/crates/assembly/core/builtin_skills/pptx/scripts/office/validators/pptx.py deleted file mode 100644 index 7b53d0d3e4..0000000000 --- a/src/crates/assembly/core/builtin_skills/pptx/scripts/office/validators/pptx.py +++ /dev/null @@ -1,441 +0,0 @@ -""" -Validator for PowerPoint presentation XML files against XSD schemas. -""" - -import re -from pathlib import Path - -from helpers import opc_target, rels_source_part, safe_extract - -from .base import BaseSchemaValidator - - -class PPTXSchemaValidator(BaseSchemaValidator): - - PRESENTATIONML_NAMESPACE = ( - "http://schemas.openxmlformats.org/presentationml/2006/main" - ) - - ELEMENT_RELATIONSHIP_TYPES = { - "sldid": "slide", - "sldmasterid": "slidemaster", - "notesmasterid": "notesmaster", - "sldlayoutid": "slidelayout", - "themeid": "theme", - "tablestyleid": "tablestyles", - } - - def validate(self): - if not self.validate_xml(): - return False - - all_valid = True - if not self.validate_namespaces(): - all_valid = False - - if not self.validate_unique_ids(): - all_valid = False - - if not self.validate_uuid_ids(): - all_valid = False - - if not self.validate_file_references(): - all_valid = False - - if not self.validate_slide_layout_ids(): - all_valid = False - - if not self.validate_content_types(): - all_valid = False - - if not self.validate_against_xsd(): - all_valid = False - - if not self.validate_notes_slide_references(): - all_valid = False - - if not self.validate_all_relationship_ids(): - all_valid = False - - if not self.validate_no_duplicate_slide_layouts(): - all_valid = False - - if not self.validate_master_theme_uniqueness(): - all_valid = False - - if not self.validate_charts(): - all_valid = False - - if not self.validate_slides(): - all_valid = False - - return all_valid - - def _package_map(self) -> dict: - wanted = [] - wanted += list(self.unpacked_dir.glob("[[]Content_Types[]].xml")) - wanted += list(self.unpacked_dir.glob("ppt/presentation.xml")) - wanted += list(self.unpacked_dir.glob("ppt/theme/*.xml")) - wanted += list(self.unpacked_dir.glob("ppt/theme/_rels/*.rels")) - wanted += list(self.unpacked_dir.glob("ppt/charts/chart*.xml")) - for group in ("slideMasters", "notesMasters", "handoutMasters"): - wanted += list(self.unpacked_dir.glob(f"ppt/{group}/*.xml")) - wanted += list(self.unpacked_dir.glob(f"ppt/{group}/_rels/*.rels")) - return { - p.relative_to(self.unpacked_dir).as_posix(): p.read_bytes() - for p in wanted - if p.is_file() - } - - def validate_master_theme_uniqueness(self): - from helpers.pptx_theme import _NOTES_MASTERS, live_shared_master_themes - - shared = live_shared_master_themes(self._package_map()) - if shared: - print(f"FAILED - Found {len(shared)} master(s) sharing a theme part:") - for message in shared: - print(f" {message}") - if any(m.startswith(_NOTES_MASTERS) for m in shared): - print(" Fix: in ppt/presentation.xml, move back to " - "directly after . PowerPoint reads that happily.") - else: - print(" Fix: give each master its own theme part.") - return False - - if self.verbose: - print("PASSED - No master shares a theme part in a way PowerPoint refuses") - return True - - def validate_charts(self): - from helpers.pptx_chart import find_chart_problems - - problems = find_chart_problems(self._package_map()) - if problems: - print(f"FAILED - Found {len(problems)} chart problem(s) PowerPoint rejects:") - for message in problems: - print(f" {message}") - return False - - if self.verbose: - print("PASSED - Charts satisfy the constraints PowerPoint enforces") - return True - - def _original_slide_defects(self, schema) -> set[str]: - import tempfile - import zipfile - - from helpers.pptx_slide import SLIDE_PART_RE, fatal_slide_errors - - if self.original_file is None: - return set() - - found: set[str] = set() - with tempfile.TemporaryDirectory() as temp_dir: - temp_path = Path(temp_dir) - try: - with zipfile.ZipFile(self.original_file, "r") as zf: - safe_extract(zf, temp_path) - except (zipfile.BadZipFile, ValueError, OSError): - return set() - - for part in sorted(temp_path.rglob("*.xml")): - relative = part.relative_to(temp_path).as_posix() - if not SLIDE_PART_RE.fullmatch(relative): - continue - ok, errors = self._validate_single_file_xsd( - part.resolve(), temp_path.resolve(), schema_path=schema - ) - if ok is None or ok or not errors: - continue - found |= set(fatal_slide_errors(set(errors))) - return found - - def validate_slides(self): - from helpers.pptx_slide import ( - SLIDE_PART_RE, - fatal_slide_errors, - is_schema_verdict, - ) - - schema = self.schemas_dir / self.SCHEMA_MAPPINGS["ppt"] - inherited = self._original_slide_defects(schema) - problems: list[str] = [] - broken: list[str] = [] - - for xml_file in self.xml_files: - relative = xml_file.relative_to(self.unpacked_dir).as_posix() - if not SLIDE_PART_RE.fullmatch(relative): - continue - ok, errors = self._validate_single_file_xsd( - xml_file.resolve(), self.unpacked_dir.resolve(), schema_path=schema - ) - if ok is None or not errors: - continue - - unreadable = [f"{relative}: {e}" for e in errors if not is_schema_verdict(e)] - if unreadable: - broken.extend(unreadable) - continue - if ok: - continue - - for message in fatal_slide_errors(set(errors)): - if message in inherited: - continue - problems.append(f"{relative}: {message}") - - if broken: - print(f"FAILED - Could not check {len(broken)} slide part(s):") - for message in sorted(broken): - print(f" {message[:240]}") - - if problems: - print(f"FAILED - Found {len(problems)} slide problem(s) PowerPoint rejects:") - for message in sorted(problems): - print(f" {message[:240]}") - - if broken or problems: - return False - - if self.verbose: - print("PASSED - Slide XML has none of the defects PowerPoint refuses") - return True - - def _get_schema_path(self, xml_file): - if xml_file.parent.name == "charts" and xml_file.name.startswith("chart"): - return None - return super()._get_schema_path(xml_file) - - def _preprocess_for_schema(self, xml_doc, relative_path): - if relative_path.as_posix() != "ppt/presentation.xml": - return xml_doc - - root = xml_doc.getroot() - ns = f"{{{self.PRESENTATIONML_NAMESPACE}}}" - notes = root.find(f"{ns}notesMasterIdLst") - slides = root.find(f"{ns}sldIdLst") - if notes is None or slides is None: - return xml_doc - - children = list(root) - if children.index(notes) < children.index(slides): - return xml_doc - - root.remove(notes) - root.insert(list(root).index(slides), notes) - return xml_doc - - def validate_uuid_ids(self): - import lxml.etree - - errors = [] - uuid_pattern = re.compile( - r"^[\{\(]?[0-9A-Fa-f]{8}-?[0-9A-Fa-f]{4}-?[0-9A-Fa-f]{4}-?[0-9A-Fa-f]{4}-?[0-9A-Fa-f]{12}[\}\)]?$" - ) - - for xml_file in self.xml_files: - try: - root = lxml.etree.parse(str(xml_file)).getroot() - - for elem in root.iter(): - for attr, value in elem.attrib.items(): - attr_name = attr.split("}")[-1].lower() - if attr_name == "id" or attr_name.endswith("id"): - if self._looks_like_uuid(value): - if not uuid_pattern.match(value): - errors.append( - f" {xml_file.relative_to(self.unpacked_dir)}: " - f"Line {elem.sourceline}: ID '{value}' appears to be a UUID but contains invalid hex characters" - ) - - except (lxml.etree.XMLSyntaxError, Exception) as e: - errors.append( - f" {xml_file.relative_to(self.unpacked_dir)}: Error: {e}" - ) - - if errors: - print(f"FAILED - Found {len(errors)} UUID ID validation errors:") - for error in errors: - print(error) - return False - else: - if self.verbose: - print("PASSED - All UUID-like IDs contain valid hex values") - return True - - def _looks_like_uuid(self, value): - clean_value = value.strip("{}()").replace("-", "") - return len(clean_value) == 32 and all(c.isalnum() for c in clean_value) - - def validate_slide_layout_ids(self): - import lxml.etree - - errors = [] - - slide_masters = list(self.unpacked_dir.glob("ppt/slideMasters/*.xml")) - - if not slide_masters: - if self.verbose: - print("PASSED - No slide masters found") - return True - - for slide_master in slide_masters: - try: - root = lxml.etree.parse(str(slide_master)).getroot() - - rels_file = slide_master.parent / "_rels" / f"{slide_master.name}.rels" - - if not rels_file.exists(): - errors.append( - f" {slide_master.relative_to(self.unpacked_dir)}: " - f"Missing relationships file: {rels_file.relative_to(self.unpacked_dir)}" - ) - continue - - rels_root = lxml.etree.parse(str(rels_file)).getroot() - - valid_layout_rids = set() - for rel in rels_root.findall( - f".//{{{self.PACKAGE_RELATIONSHIPS_NAMESPACE}}}Relationship" - ): - rel_type = rel.get("Type", "") - if "slideLayout" in rel_type: - valid_layout_rids.add(rel.get("Id")) - - for sld_layout_id in root.findall( - f".//{{{self.PRESENTATIONML_NAMESPACE}}}sldLayoutId" - ): - r_id = sld_layout_id.get( - f"{{{self.OFFICE_RELATIONSHIPS_NAMESPACE}}}id" - ) - layout_id = sld_layout_id.get("id") - - if r_id and r_id not in valid_layout_rids: - errors.append( - f" {slide_master.relative_to(self.unpacked_dir)}: " - f"Line {sld_layout_id.sourceline}: sldLayoutId with id='{layout_id}' " - f"references r:id='{r_id}' which is not found in slide layout relationships" - ) - - except (lxml.etree.XMLSyntaxError, Exception) as e: - errors.append( - f" {slide_master.relative_to(self.unpacked_dir)}: Error: {e}" - ) - - if errors: - print(f"FAILED - Found {len(errors)} slide layout ID validation errors:") - for error in errors: - print(error) - print( - "Remove invalid references or add missing slide layouts to the relationships file." - ) - return False - else: - if self.verbose: - print("PASSED - All slide layout IDs reference valid slide layouts") - return True - - def validate_no_duplicate_slide_layouts(self): - import lxml.etree - - errors = [] - slide_rels_files = list(self.unpacked_dir.glob("ppt/slides/_rels/*.xml.rels")) - - for rels_file in slide_rels_files: - try: - root = lxml.etree.parse(str(rels_file)).getroot() - - layout_rels = [ - rel - for rel in root.findall( - f".//{{{self.PACKAGE_RELATIONSHIPS_NAMESPACE}}}Relationship" - ) - if "slideLayout" in rel.get("Type", "") - ] - - if len(layout_rels) > 1: - errors.append( - f" {rels_file.relative_to(self.unpacked_dir)}: has {len(layout_rels)} slideLayout references" - ) - - except Exception as e: - errors.append( - f" {rels_file.relative_to(self.unpacked_dir)}: Error: {e}" - ) - - if errors: - print("FAILED - Found slides with duplicate slideLayout references:") - for error in errors: - print(error) - return False - else: - if self.verbose: - print("PASSED - All slides have exactly one slideLayout reference") - return True - - def validate_notes_slide_references(self): - import lxml.etree - - errors = [] - notes_slide_references = {} - - slide_rels_files = list(self.unpacked_dir.glob("ppt/slides/_rels/*.xml.rels")) - - if not slide_rels_files: - if self.verbose: - print("PASSED - No slide relationship files found") - return True - - for rels_file in slide_rels_files: - try: - root = lxml.etree.parse(str(rels_file)).getroot() - - for rel in root.findall( - f".//{{{self.PACKAGE_RELATIONSHIPS_NAMESPACE}}}Relationship" - ): - rel_type = rel.get("Type", "") - if "notesSlide" in rel_type: - part = opc_target( - rel.get("Target", ""), - rels_source_part(rels_file, self.unpacked_dir), - rel.get("TargetMode", ""), - ) - if part: - slide_name = rels_file.stem.replace( - ".xml", "" - ) - - notes_slide_references.setdefault(part, []).append( - (slide_name, rels_file) - ) - - except (lxml.etree.XMLSyntaxError, Exception) as e: - errors.append( - f" {rels_file.relative_to(self.unpacked_dir)}: Error: {e}" - ) - - for target, references in notes_slide_references.items(): - if len(references) > 1: - slide_names = [ref[0] for ref in references] - errors.append( - f" Notes slide '{target}' is referenced by multiple slides: {', '.join(slide_names)}" - ) - for slide_name, rels_file in references: - errors.append(f" - {rels_file.relative_to(self.unpacked_dir)}") - - if errors: - print( - f"FAILED - Found {len([e for e in errors if not e.startswith(' ')])} notes slide reference validation errors:" - ) - for error in errors: - print(error) - print("Each slide may optionally have its own slide file.") - return False - else: - if self.verbose: - print("PASSED - All notes slide references are unique") - return True - - -if __name__ == "__main__": - raise RuntimeError("This module should not be run directly.") diff --git a/src/crates/assembly/core/builtin_skills/pptx/scripts/office/validators/redlining.py b/src/crates/assembly/core/builtin_skills/pptx/scripts/office/validators/redlining.py deleted file mode 100644 index 18d0c68be9..0000000000 --- a/src/crates/assembly/core/builtin_skills/pptx/scripts/office/validators/redlining.py +++ /dev/null @@ -1,299 +0,0 @@ -""" -Validator for tracked changes in Word documents. - -Detects untracked edits in word/document.xml: text that differs from the -original without a / wrapper recording it. The tracked changes -that are new relative to the original are undone, and the result is compared -against the original; whatever text still differs was edited without being -tracked. - -Only the document body is compared. Headers, footers, footnotes and endnotes -are separate parts and are not checked. -""" - -import subprocess -import tempfile -import zipfile -from pathlib import Path - -import defusedxml.ElementTree as ET -from defusedxml.common import DefusedXmlException - -from helpers import rendered_text, safe_extract - - -class RedliningValidator: - - def __init__(self, unpacked_dir, original_docx, verbose=False): - self.unpacked_dir = Path(unpacked_dir) - self.original_docx = Path(original_docx) - self.verbose = verbose - self.namespaces = { - "w": "http://schemas.openxmlformats.org/wordprocessingml/2006/main" - } - - def repair(self) -> int: - return 0 - - def validate(self): - modified_file = self.unpacked_dir / "word" / "document.xml" - if not modified_file.exists(): - print(f"FAILED - Modified document.xml not found at {modified_file}") - return False - - with tempfile.TemporaryDirectory() as temp_dir: - temp_path = Path(temp_dir) - - try: - with zipfile.ZipFile(self.original_docx, "r") as zip_ref: - safe_extract(zip_ref, temp_path) - except Exception as e: - print(f"FAILED - Error unpacking original docx: {e}") - return False - - original_file = temp_path / "word" / "document.xml" - if not original_file.exists(): - print( - f"FAILED - Original document.xml not found in {self.original_docx}" - ) - return False - - try: - modified_tree = ET.parse(modified_file) - modified_root = modified_tree.getroot() - original_tree = ET.parse(original_file) - original_root = original_tree.getroot() - except (ET.ParseError, DefusedXmlException) as e: - print(f"FAILED - Error parsing XML files: {e}") - return False - - new_changes = self._new_tracked_changes(original_root, modified_root) - self._remove_tracked_changes(modified_root, new_changes) - - modified_text = self._extract_text_content(modified_root) - original_text = self._extract_text_content(original_root) - - if modified_text != original_text: - error_message = self._generate_detailed_diff( - original_text, modified_text - ) - print(error_message) - return False - - if self.verbose: - print( - f"PASSED - All {len(new_changes)} change(s) against the original " - "are properly tracked" - ) - return True - - def _tracked_change_elements(self, root): - ins_tag = f"{{{self.namespaces['w']}}}ins" - del_tag = f"{{{self.namespaces['w']}}}del" - return [elem for elem in root.iter() if elem.tag in (ins_tag, del_tag)] - - def _rendered_text(self, elem): - preserve = elem.get("{http://www.w3.org/XML/1998/namespace}space") == "preserve" - return rendered_text(elem.text or "", preserve) - - def _text_elements(self, elem): - w = self.namespaces["w"] - return [ - node - for node in elem.iter() - if node.tag in (f"{{{w}}}t", f"{{{w}}}delText") - ] - - def _tracked_change_key(self, elem): - w = self.namespaces["w"] - text = "".join(self._rendered_text(node) for node in self._text_elements(elem)) - return (elem.tag, elem.get(f"{{{w}}}author"), elem.get(f"{{{w}}}date"), text) - - def _new_tracked_changes(self, original_root, modified_root): - original = self._tracked_change_elements(original_root) - modified = self._tracked_change_elements(modified_root) - - pool = {} - for elem in original: - pool.setdefault(self._tracked_change_key(elem), []).append(elem) - - matched, leftover = set(), [] - for elem in modified: - bucket = pool.get(self._tracked_change_key(elem)) - if bucket: - matched.add(bucket.pop()) - else: - leftover.append(elem) - - def group(elem): - return self._tracked_change_key(elem)[:3] - - def text_of(elems): - return "".join(self._tracked_change_key(e)[3] for e in elems) - - unmatched_original = {} - for elem in original: - if elem not in matched: - unmatched_original.setdefault(group(elem), []).append(elem) - - by_group = {} - for elem in leftover: - by_group.setdefault(group(elem), []).append(elem) - - new = set() - for key, elems in by_group.items(): - rebuilt = text_of(elems) - if rebuilt and rebuilt == text_of(unmatched_original.get(key, [])): - continue - new.update(elems) - return new - - def _generate_detailed_diff(self, original_text, modified_text): - error_parts = [ - "FAILED - Document text doesn't match after removing the tracked changes", - "", - "Likely causes:", - " 1. Modified text inside another author's or tags", - " 2. Made edits without proper tracked changes", - " 3. Didn't nest inside when deleting another's insertion", - " 4. Rewrote another author's / and changed its text on", - " the way. A tracked change from the original is recognised by its", - " author, date and text; anything that doesn't reproduce one exactly", - " reads as new, and the text it carried is reported missing.", - "", - "For pre-redlined documents, use correct patterns:", - " - To reject another's INSERTION: Nest inside their ", - " - To reject PART of one: nest around only the runs you reject.", - " Their may be split around it, so long as the pieces keep", - " their author and date and still spell out the same text.", - " - To restore another's DELETION: Add new AFTER their ", - "", - ] - - git_diff = self._get_git_word_diff(original_text, modified_text) - if git_diff: - error_parts.extend(["Differences:", "============", git_diff]) - else: - error_parts.append("Unable to generate word diff (git not available)") - - return "\n".join(error_parts) - - def _get_git_word_diff(self, original_text, modified_text): - try: - with tempfile.TemporaryDirectory() as temp_dir: - temp_path = Path(temp_dir) - - original_file = temp_path / "original.txt" - modified_file = temp_path / "modified.txt" - - original_file.write_text(original_text, encoding="utf-8") - modified_file.write_text(modified_text, encoding="utf-8") - - result = subprocess.run( - [ - "git", - "diff", - "--word-diff=plain", - "--word-diff-regex=.", - "-U0", - "--no-index", - str(original_file), - str(modified_file), - ], - capture_output=True, - text=True, - ) - - if result.stdout.strip(): - lines = result.stdout.split("\n") - content_lines = [] - in_content = False - for line in lines: - if line.startswith("@@"): - in_content = True - continue - if in_content and line.strip(): - content_lines.append(line) - - if content_lines: - return "\n".join(content_lines) - - result = subprocess.run( - [ - "git", - "diff", - "--word-diff=plain", - "-U0", - "--no-index", - str(original_file), - str(modified_file), - ], - capture_output=True, - text=True, - ) - - if result.stdout.strip(): - lines = result.stdout.split("\n") - content_lines = [] - in_content = False - for line in lines: - if line.startswith("@@"): - in_content = True - continue - if in_content and line.strip(): - content_lines.append(line) - return "\n".join(content_lines) - - except (subprocess.CalledProcessError, FileNotFoundError, Exception): - pass - - return None - - def _remove_tracked_changes(self, root, targets): - ins_tag = f"{{{self.namespaces['w']}}}ins" - del_tag = f"{{{self.namespaces['w']}}}del" - - for parent in root.iter(): - to_remove = [] - for child in parent: - if child.tag == ins_tag and child in targets: - to_remove.append(child) - for elem in to_remove: - parent.remove(elem) - - deltext_tag = f"{{{self.namespaces['w']}}}delText" - t_tag = f"{{{self.namespaces['w']}}}t" - - for parent in root.iter(): - to_process = [] - for child in parent: - if child.tag == del_tag and child in targets: - to_process.append((child, list(parent).index(child))) - - for del_elem, del_index in reversed(to_process): - for elem in del_elem.iter(): - if elem.tag == deltext_tag: - elem.tag = t_tag - - for child in reversed(list(del_elem)): - parent.insert(del_index, child) - parent.remove(del_elem) - - def _extract_text_content(self, root): - p_tag = f"{{{self.namespaces['w']}}}p" - t_tag = f"{{{self.namespaces['w']}}}t" - - paragraphs = [] - for p_elem in root.findall(f".//{p_tag}"): - text_parts = [] - for t_elem in p_elem.findall(f".//{t_tag}"): - text_parts.append(self._rendered_text(t_elem)) - paragraph_text = "".join(text_parts) - if paragraph_text: - paragraphs.append(paragraph_text) - - return "\n".join(paragraphs) - - -if __name__ == "__main__": - raise RuntimeError("This module should not be run directly.") diff --git a/src/crates/assembly/core/builtin_skills/pptx/scripts/thumbnail.py b/src/crates/assembly/core/builtin_skills/pptx/scripts/thumbnail.py deleted file mode 100755 index ae79b0e2fd..0000000000 --- a/src/crates/assembly/core/builtin_skills/pptx/scripts/thumbnail.py +++ /dev/null @@ -1,311 +0,0 @@ -"""Create thumbnail grids from PowerPoint presentation slides. - -Creates a grid layout of slide thumbnails for quick visual analysis. -Labels each thumbnail with its XML filename (e.g., slide1.xml). -Hidden slides are shown with a placeholder pattern. - -Usage: - python thumbnail.py input.pptx [output_prefix] [--cols N] - -Examples: - python thumbnail.py presentation.pptx - # Creates: thumbnails.jpg - - python thumbnail.py template.pptx grid --cols 4 - # Creates: grid.jpg (or grid-1.jpg, grid-2.jpg for large decks) -""" - -import argparse -import posixpath -import subprocess -import sys -import tempfile -import zipfile -from pathlib import Path - -import defusedxml.minidom -from defusedxml import ElementTree -from office.helpers import SLIDE_REL_TYPE, opc_target -from office.soffice import run_soffice -from PIL import Image, ImageDraw, ImageFont - - -THUMBNAIL_WIDTH = 300 -CONVERSION_DPI = 100 -MAX_COLS = 6 -DEFAULT_COLS = 3 -JPEG_QUALITY = 95 -GRID_PADDING = 20 -BORDER_WIDTH = 2 -FONT_SIZE_RATIO = 0.10 -LABEL_PADDING_RATIO = 0.4 - - -def main(): - parser = argparse.ArgumentParser( - description="Create thumbnail grids from PowerPoint slides." - ) - parser.add_argument("input", help="Input PowerPoint file (.pptx)") - parser.add_argument( - "output_prefix", - nargs="?", - default="thumbnails", - help="Output prefix for image files (default: thumbnails)", - ) - parser.add_argument( - "--cols", - type=int, - default=DEFAULT_COLS, - help=f"Number of columns (default: {DEFAULT_COLS}, max: {MAX_COLS})", - ) - - args = parser.parse_args() - - cols = min(args.cols, MAX_COLS) - if args.cols > MAX_COLS: - print(f"Warning: Columns limited to {MAX_COLS}") - - input_path = Path(args.input) - if not input_path.exists() or input_path.suffix.lower() != ".pptx": - print(f"Error: Invalid PowerPoint file: {args.input}", file=sys.stderr) - sys.exit(1) - - output_path = Path(f"{args.output_prefix}.jpg") - - try: - slide_info = get_slide_info(input_path) - - with tempfile.TemporaryDirectory() as temp_dir: - temp_path = Path(temp_dir) - visible_images = convert_to_images(input_path, temp_path) - - if not visible_images and not any(s["hidden"] for s in slide_info): - print("Error: No slides found", file=sys.stderr) - sys.exit(1) - - slides = build_slide_list(slide_info, visible_images, temp_path) - - grid_files = create_grids(slides, cols, THUMBNAIL_WIDTH, output_path) - - print(f"Created {len(grid_files)} grid(s):") - for grid_file in grid_files: - print(f" {grid_file}") - - except Exception as e: - print(f"Error: {e}", file=sys.stderr) - sys.exit(1) - - -def _is_hidden(zf: zipfile.ZipFile, part: str) -> bool: - try: - with zf.open(part) as f: - for _, root in ElementTree.iterparse(f, events=("start",)): - return root.get("show") in ("0", "false") - except (KeyError, ElementTree.ParseError): - return False - return False - - -def get_slide_info(pptx_path: Path) -> list[dict]: - with zipfile.ZipFile(pptx_path, "r") as zf: - rels_content = zf.read("ppt/_rels/presentation.xml.rels").decode("utf-8") - rels_dom = defusedxml.minidom.parseString(rels_content) - - rid_to_part = {} - for rel in rels_dom.getElementsByTagName("Relationship"): - if rel.getAttribute("Type") != SLIDE_REL_TYPE: - continue - part = opc_target( - rel.getAttribute("Target"), - "ppt/presentation.xml", - rel.getAttribute("TargetMode"), - ) - if part is not None: - rid_to_part[rel.getAttribute("Id")] = part - - pres_content = zf.read("ppt/presentation.xml").decode("utf-8") - pres_dom = defusedxml.minidom.parseString(pres_content) - - present = set(zf.namelist()) - - slides = [] - for sld_id in pres_dom.getElementsByTagName("p:sldId"): - part = rid_to_part.get(sld_id.getAttribute("r:id")) - if part is not None and part in present: - slides.append( - {"name": posixpath.basename(part), "hidden": _is_hidden(zf, part)} - ) - - return slides - - -def build_slide_list( - slide_info: list[dict], - visible_images: list[Path], - temp_dir: Path, -) -> list[tuple[Path, str]]: - visible_count = sum(1 for info in slide_info if not info["hidden"]) - rendered_hidden = len(visible_images) == len(slide_info) != visible_count - - if not rendered_hidden and visible_count != len(visible_images): - raise ValueError( - f"LibreOffice rendered {len(visible_images)} page(s) for {visible_count} " - f"visible slide(s) of {len(slide_info)}; thumbnails would be mislabeled" - ) - - if visible_images: - with Image.open(visible_images[0]) as img: - placeholder_size = img.size - else: - placeholder_size = (1920, 1080) - - slides = [] - visible_idx = 0 - - for info in slide_info: - if info["hidden"] and not rendered_hidden: - placeholder_path = temp_dir / f"hidden-{info['name']}.jpg" - placeholder_img = create_hidden_placeholder(placeholder_size) - placeholder_img.save(placeholder_path, "JPEG") - slides.append((placeholder_path, f"{info['name']} (hidden)")) - else: - label = f"{info['name']} (hidden)" if info["hidden"] else info["name"] - slides.append((visible_images[visible_idx], label)) - visible_idx += 1 - - return slides - - -def create_hidden_placeholder(size: tuple[int, int]) -> Image.Image: - img = Image.new("RGB", size, color="#F0F0F0") - draw = ImageDraw.Draw(img) - line_width = max(5, min(size) // 100) - draw.line([(0, 0), size], fill="#CCCCCC", width=line_width) - draw.line([(size[0], 0), (0, size[1])], fill="#CCCCCC", width=line_width) - return img - - -def convert_to_images(pptx_path: Path, temp_dir: Path) -> list[Path]: - pdf_path = temp_dir / f"{pptx_path.stem}.pdf" - - result = run_soffice( - ["--headless", "--convert-to", "pdf", "--outdir", str(temp_dir), str(pptx_path)], - capture_output=True, - text=True, - ) - if result.returncode != 0 or not pdf_path.exists(): - detail = (result.stderr or result.stdout or "").strip() - raise RuntimeError(f"PDF conversion failed: {detail}" if detail else "PDF conversion failed") - - result = subprocess.run( - [ - "pdftoppm", - "-jpeg", - "-r", - str(CONVERSION_DPI), - str(pdf_path), - str(temp_dir / "slide"), - ], - capture_output=True, - text=True, - ) - if result.returncode != 0: - raise RuntimeError("Image conversion failed") - - return sorted(temp_dir.glob("slide-*.jpg")) - - -def create_grids( - slides: list[tuple[Path, str]], - cols: int, - width: int, - output_path: Path, -) -> list[str]: - max_per_grid = cols * (cols + 1) - grid_files = [] - - for chunk_idx, start_idx in enumerate(range(0, len(slides), max_per_grid)): - end_idx = min(start_idx + max_per_grid, len(slides)) - chunk_slides = slides[start_idx:end_idx] - - grid = create_grid(chunk_slides, cols, width) - - if len(slides) <= max_per_grid: - grid_filename = output_path - else: - stem = output_path.stem - suffix = output_path.suffix - grid_filename = output_path.parent / f"{stem}-{chunk_idx + 1}{suffix}" - - grid_filename.parent.mkdir(parents=True, exist_ok=True) - grid.save(str(grid_filename), quality=JPEG_QUALITY) - grid_files.append(str(grid_filename)) - - return grid_files - - -def create_grid( - slides: list[tuple[Path, str]], - cols: int, - width: int, -) -> Image.Image: - font_size = int(width * FONT_SIZE_RATIO) - label_padding = int(font_size * LABEL_PADDING_RATIO) - - with Image.open(slides[0][0]) as img: - aspect = img.height / img.width - height = int(width * aspect) - - rows = (len(slides) + cols - 1) // cols - grid_w = cols * width + (cols + 1) * GRID_PADDING - grid_h = rows * (height + font_size + label_padding * 2) + (rows + 1) * GRID_PADDING - - grid = Image.new("RGB", (grid_w, grid_h), "white") - draw = ImageDraw.Draw(grid) - - try: - font = ImageFont.load_default(size=font_size) - except Exception: - font = ImageFont.load_default() - - for i, (img_path, slide_name) in enumerate(slides): - row, col = i // cols, i % cols - x = col * width + (col + 1) * GRID_PADDING - y_base = ( - row * (height + font_size + label_padding * 2) + (row + 1) * GRID_PADDING - ) - - label = slide_name - bbox = draw.textbbox((0, 0), label, font=font) - text_w = bbox[2] - bbox[0] - draw.text( - (x + (width - text_w) // 2, y_base + label_padding), - label, - fill="black", - font=font, - ) - - y_thumbnail = y_base + label_padding + font_size + label_padding - - with Image.open(img_path) as img: - img.thumbnail((width, height), Image.Resampling.LANCZOS) - w, h = img.size - tx = x + (width - w) // 2 - ty = y_thumbnail + (height - h) // 2 - grid.paste(img, (tx, ty)) - - if BORDER_WIDTH > 0: - draw.rectangle( - [ - (tx - BORDER_WIDTH, ty - BORDER_WIDTH), - (tx + w + BORDER_WIDTH - 1, ty + h + BORDER_WIDTH - 1), - ], - outline="gray", - width=BORDER_WIDTH, - ) - - return grid - - -if __name__ == "__main__": - main() diff --git a/src/crates/assembly/core/builtin_skills/writing-skills/LICENSE.txt b/src/crates/assembly/core/builtin_skills/writing-skills/LICENSE.txt new file mode 100644 index 0000000000..abf0390320 --- /dev/null +++ b/src/crates/assembly/core/builtin_skills/writing-skills/LICENSE.txt @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2025 Jesse Vincent + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/src/crates/assembly/core/builtin_skills/writing-skills/anthropic-best-practices.md b/src/crates/assembly/core/builtin_skills/writing-skills/anthropic-best-practices.md deleted file mode 100644 index 9f3f6ecfd9..0000000000 --- a/src/crates/assembly/core/builtin_skills/writing-skills/anthropic-best-practices.md +++ /dev/null @@ -1,1150 +0,0 @@ -# Skill authoring best practices - -> Learn how to write effective Skills that Claude can discover and use successfully. - -Good Skills are concise, well-structured, and tested with real usage. This guide provides practical authoring decisions to help you write Skills that Claude can discover and use effectively. - -For conceptual background on how Skills work, see the [Skills overview](/en/docs/agents-and-tools/agent-skills/overview). - -## Core principles - -### Concise is key - -The [context window](https://platform.claude.com/docs/en/build-with-claude/context-windows) is a public good. Your Skill shares the context window with everything else Claude needs to know, including: - -* The system prompt -* Conversation history -* Other Skills' metadata -* Your actual request - -Not every token in your Skill has an immediate cost. At startup, only the metadata (name and description) from all Skills is pre-loaded. Claude reads SKILL.md only when the Skill becomes relevant, and reads additional files only as needed. However, being concise in SKILL.md still matters: once Claude loads it, every token competes with conversation history and other context. - -**Default assumption**: Claude is already very smart - -Only add context Claude doesn't already have. Challenge each piece of information: - -* "Does Claude really need this explanation?" -* "Can I assume Claude knows this?" -* "Does this paragraph justify its token cost?" - -**Good example: Concise** (approximately 50 tokens): - -````markdown theme={null} -## Extract PDF text - -Use pdfplumber for text extraction: - -```python -import pdfplumber - -with pdfplumber.open("file.pdf") as pdf: - text = pdf.pages[0].extract_text() -``` -```` - -**Bad example: Too verbose** (approximately 150 tokens): - -```markdown theme={null} -## Extract PDF text - -PDF (Portable Document Format) files are a common file format that contains -text, images, and other content. To extract text from a PDF, you'll need to -use a library. There are many libraries available for PDF processing, but we -recommend pdfplumber because it's easy to use and handles most cases well. -First, you'll need to install it using pip. Then you can use the code below... -``` - -The concise version assumes Claude knows what PDFs are and how libraries work. - -### Set appropriate degrees of freedom - -Match the level of specificity to the task's fragility and variability. - -**High freedom** (text-based instructions): - -Use when: - -* Multiple approaches are valid -* Decisions depend on context -* Heuristics guide the approach - -Example: - -```markdown theme={null} -## Code review process - -1. Analyze the code structure and organization -2. Check for potential bugs or edge cases -3. Suggest improvements for readability and maintainability -4. Verify adherence to project conventions -``` - -**Medium freedom** (pseudocode or scripts with parameters): - -Use when: - -* A preferred pattern exists -* Some variation is acceptable -* Configuration affects behavior - -Example: - -````markdown theme={null} -## Generate report - -Use this template and customize as needed: - -```python -def generate_report(data, format="markdown", include_charts=True): - # Process data - # Generate output in specified format - # Optionally include visualizations -``` -```` - -**Low freedom** (specific scripts, few or no parameters): - -Use when: - -* Operations are fragile and error-prone -* Consistency is critical -* A specific sequence must be followed - -Example: - -````markdown theme={null} -## Database migration - -Run exactly this script: - -```bash -python scripts/migrate.py --verify --backup -``` - -Do not modify the command or add additional flags. -```` - -**Analogy**: Think of Claude as a robot exploring a path: - -* **Narrow bridge with cliffs on both sides**: There's only one safe way forward. Provide specific guardrails and exact instructions (low freedom). Example: database migrations that must run in exact sequence. -* **Open field with no hazards**: Many paths lead to success. Give general direction and trust Claude to find the best route (high freedom). Example: code reviews where context determines the best approach. - -### Test with all models you plan to use - -Skills act as additions to models, so effectiveness depends on the underlying model. Test your Skill with all the models you plan to use it with. - -**Testing considerations by model**: - -* **Claude Haiku** (fast, economical): Does the Skill provide enough guidance? -* **Claude Sonnet** (balanced): Is the Skill clear and efficient? -* **Claude Opus** (powerful reasoning): Does the Skill avoid over-explaining? - -What works perfectly for Opus might need more detail for Haiku. If you plan to use your Skill across multiple models, aim for instructions that work well with all of them. - -## Skill structure - - - **YAML Frontmatter**: The SKILL.md frontmatter requires two fields: - - * `name` - Human-readable name of the Skill (64 characters maximum) - * `description` - One-line description of what the Skill does and when to use it (1024 characters maximum) - - For complete Skill structure details, see the [Skills overview](/en/docs/agents-and-tools/agent-skills/overview#skill-structure). - - -### Naming conventions - -Use consistent naming patterns to make Skills easier to reference and discuss. We recommend using **gerund form** (verb + -ing) for Skill names, as this clearly describes the activity or capability the Skill provides. - -**Good naming examples (gerund form)**: - -* "Processing PDFs" -* "Analyzing spreadsheets" -* "Managing databases" -* "Testing code" -* "Writing documentation" - -**Acceptable alternatives**: - -* Noun phrases: "PDF Processing", "Spreadsheet Analysis" -* Action-oriented: "Process PDFs", "Analyze Spreadsheets" - -**Avoid**: - -* Vague names: "Helper", "Utils", "Tools" -* Overly generic: "Documents", "Data", "Files" -* Inconsistent patterns within your skill collection - -Consistent naming makes it easier to: - -* Reference Skills in documentation and conversations -* Understand what a Skill does at a glance -* Organize and search through multiple Skills -* Maintain a professional, cohesive skill library - -### Writing effective descriptions - -The `description` field enables Skill discovery and should include both what the Skill does and when to use it. - - - **Always write in third person**. The description is injected into the system prompt, and inconsistent point-of-view can cause discovery problems. - - * **Good:** "Processes Excel files and generates reports" - * **Avoid:** "I can help you process Excel files" - * **Avoid:** "You can use this to process Excel files" - - -**Be specific and include key terms**. Include both what the Skill does and specific triggers/contexts for when to use it. - -Each Skill has exactly one description field. The description is critical for skill selection: Claude uses it to choose the right Skill from potentially 100+ available Skills. Your description must provide enough detail for Claude to know when to select this Skill, while the rest of SKILL.md provides the implementation details. - -Effective examples: - -**PDF Processing skill:** - -```yaml theme={null} -description: Extract text and tables from PDF files, fill forms, merge documents. Use when working with PDF files or when the user mentions PDFs, forms, or document extraction. -``` - -**Excel Analysis skill:** - -```yaml theme={null} -description: Analyze Excel spreadsheets, create pivot tables, generate charts. Use when analyzing Excel files, spreadsheets, tabular data, or .xlsx files. -``` - -**Git Commit Helper skill:** - -```yaml theme={null} -description: Generate descriptive commit messages by analyzing git diffs. Use when the user asks for help writing commit messages or reviewing staged changes. -``` - -Avoid vague descriptions like these: - -```yaml theme={null} -description: Helps with documents -``` - -```yaml theme={null} -description: Processes data -``` - -```yaml theme={null} -description: Does stuff with files -``` - -### Progressive disclosure patterns - -SKILL.md serves as an overview that points Claude to detailed materials as needed, like a table of contents in an onboarding guide. For an explanation of how progressive disclosure works, see [How Skills work](/en/docs/agents-and-tools/agent-skills/overview#how-skills-work) in the overview. - -**Practical guidance:** - -* Keep SKILL.md body under 500 lines for optimal performance -* Split content into separate files when approaching this limit -* Use the patterns below to organize instructions, code, and resources effectively - -#### Visual overview: From simple to complex - -A basic Skill starts with just a SKILL.md file containing metadata and instructions: - -Simple SKILL.md file showing YAML frontmatter and markdown body - -As your Skill grows, you can bundle additional content that Claude loads only when needed: - -Bundling additional reference files like reference.md and forms.md. - -The complete Skill directory structure might look like this: - -``` -pdf/ -├── SKILL.md # Main instructions (loaded when triggered) -├── FORMS.md # Form-filling guide (loaded as needed) -├── reference.md # API reference (loaded as needed) -├── examples.md # Usage examples (loaded as needed) -└── scripts/ - ├── analyze_form.py # Utility script (executed, not loaded) - ├── fill_form.py # Form filling script - └── validate.py # Validation script -``` - -#### Pattern 1: High-level guide with references - -````markdown theme={null} ---- -name: PDF Processing -description: Extracts text and tables from PDF files, fills forms, and merges documents. Use when working with PDF files or when the user mentions PDFs, forms, or document extraction. ---- - -# PDF Processing - -## Quick start - -Extract text with pdfplumber: -```python -import pdfplumber -with pdfplumber.open("file.pdf") as pdf: - text = pdf.pages[0].extract_text() -``` - -## Advanced features - -**Form filling**: See [FORMS.md](FORMS.md) for complete guide -**API reference**: See [REFERENCE.md](REFERENCE.md) for all methods -**Examples**: See [EXAMPLES.md](EXAMPLES.md) for common patterns -```` - -Claude loads FORMS.md, REFERENCE.md, or EXAMPLES.md only when needed. - -#### Pattern 2: Domain-specific organization - -For Skills with multiple domains, organize content by domain to avoid loading irrelevant context. When a user asks about sales metrics, Claude only needs to read sales-related schemas, not finance or marketing data. This keeps token usage low and context focused. - -``` -bigquery-skill/ -├── SKILL.md (overview and navigation) -└── reference/ - ├── finance.md (revenue, billing metrics) - ├── sales.md (opportunities, pipeline) - ├── product.md (API usage, features) - └── marketing.md (campaigns, attribution) -``` - -````markdown SKILL.md theme={null} -# BigQuery Data Analysis - -## Available datasets - -**Finance**: Revenue, ARR, billing → See [reference/finance.md](reference/finance.md) -**Sales**: Opportunities, pipeline, accounts → See [reference/sales.md](reference/sales.md) -**Product**: API usage, features, adoption → See [reference/product.md](reference/product.md) -**Marketing**: Campaigns, attribution, email → See [reference/marketing.md](reference/marketing.md) - -## Quick search - -Find specific metrics using grep: - -```bash -grep -i "revenue" reference/finance.md -grep -i "pipeline" reference/sales.md -grep -i "api usage" reference/product.md -``` -```` - -#### Pattern 3: Conditional details - -Show basic content, link to advanced content: - -```markdown theme={null} -# DOCX Processing - -## Creating documents - -Use docx-js for new documents. See [DOCX-JS.md](DOCX-JS.md). - -## Editing documents - -For simple edits, modify the XML directly. - -**For tracked changes**: See [REDLINING.md](REDLINING.md) -**For OOXML details**: See [OOXML.md](OOXML.md) -``` - -Claude reads REDLINING.md or OOXML.md only when the user needs those features. - -### Avoid deeply nested references - -Claude may partially read files when they're referenced from other referenced files. When encountering nested references, Claude might use commands like `head -100` to preview content rather than reading entire files, resulting in incomplete information. - -**Keep references one level deep from SKILL.md**. All reference files should link directly from SKILL.md to ensure Claude reads complete files when needed. - -**Bad example: Too deep**: - -```markdown theme={null} -# SKILL.md -See [advanced.md](advanced.md)... - -# advanced.md -See [details.md](details.md)... - -# details.md -Here's the actual information... -``` - -**Good example: One level deep**: - -```markdown theme={null} -# SKILL.md - -**Basic usage**: [instructions in SKILL.md] -**Advanced features**: See [advanced.md](advanced.md) -**API reference**: See [reference.md](reference.md) -**Examples**: See [examples.md](examples.md) -``` - -### Structure longer reference files with table of contents - -For reference files longer than 100 lines, include a table of contents at the top. This ensures Claude can see the full scope of available information even when previewing with partial reads. - -**Example**: - -```markdown theme={null} -# API Reference - -## Contents -- Authentication and setup -- Core methods (create, read, update, delete) -- Advanced features (batch operations, webhooks) -- Error handling patterns -- Code examples - -## Authentication and setup -... - -## Core methods -... -``` - -Claude can then read the complete file or jump to specific sections as needed. - -For details on how this filesystem-based architecture enables progressive disclosure, see the [Runtime environment](#runtime-environment) section in the Advanced section below. - -## Workflows and feedback loops - -### Use workflows for complex tasks - -Break complex operations into clear, sequential steps. For particularly complex workflows, provide a checklist that Claude can copy into its response and check off as it progresses. - -**Example 1: Research synthesis workflow** (for Skills without code): - -````markdown theme={null} -## Research synthesis workflow - -Copy this checklist and track your progress: - -``` -Research Progress: -- [ ] Step 1: Read all source documents -- [ ] Step 2: Identify key themes -- [ ] Step 3: Cross-reference claims -- [ ] Step 4: Create structured summary -- [ ] Step 5: Verify citations -``` - -**Step 1: Read all source documents** - -Review each document in the `sources/` directory. Note the main arguments and supporting evidence. - -**Step 2: Identify key themes** - -Look for patterns across sources. What themes appear repeatedly? Where do sources agree or disagree? - -**Step 3: Cross-reference claims** - -For each major claim, verify it appears in the source material. Note which source supports each point. - -**Step 4: Create structured summary** - -Organize findings by theme. Include: -- Main claim -- Supporting evidence from sources -- Conflicting viewpoints (if any) - -**Step 5: Verify citations** - -Check that every claim references the correct source document. If citations are incomplete, return to Step 3. -```` - -This example shows how workflows apply to analysis tasks that don't require code. The checklist pattern works for any complex, multi-step process. - -**Example 2: PDF form filling workflow** (for Skills with code): - -````markdown theme={null} -## PDF form filling workflow - -Copy this checklist and check off items as you complete them: - -``` -Task Progress: -- [ ] Step 1: Analyze the form (run analyze_form.py) -- [ ] Step 2: Create field mapping (edit fields.json) -- [ ] Step 3: Validate mapping (run validate_fields.py) -- [ ] Step 4: Fill the form (run fill_form.py) -- [ ] Step 5: Verify output (run verify_output.py) -``` - -**Step 1: Analyze the form** - -Run: `python scripts/analyze_form.py input.pdf` - -This extracts form fields and their locations, saving to `fields.json`. - -**Step 2: Create field mapping** - -Edit `fields.json` to add values for each field. - -**Step 3: Validate mapping** - -Run: `python scripts/validate_fields.py fields.json` - -Fix any validation errors before continuing. - -**Step 4: Fill the form** - -Run: `python scripts/fill_form.py input.pdf fields.json output.pdf` - -**Step 5: Verify output** - -Run: `python scripts/verify_output.py output.pdf` - -If verification fails, return to Step 2. -```` - -Clear steps prevent Claude from skipping critical validation. The checklist helps both Claude and you track progress through multi-step workflows. - -### Implement feedback loops - -**Common pattern**: Run validator → fix errors → repeat - -This pattern greatly improves output quality. - -**Example 1: Style guide compliance** (for Skills without code): - -```markdown theme={null} -## Content review process - -1. Draft your content following the guidelines in STYLE_GUIDE.md -2. Review against the checklist: - - Check terminology consistency - - Verify examples follow the standard format - - Confirm all required sections are present -3. If issues found: - - Note each issue with specific section reference - - Revise the content - - Review the checklist again -4. Only proceed when all requirements are met -5. Finalize and save the document -``` - -This shows the validation loop pattern using reference documents instead of scripts. The "validator" is STYLE\_GUIDE.md, and Claude performs the check by reading and comparing. - -**Example 2: Document editing process** (for Skills with code): - -```markdown theme={null} -## Document editing process - -1. Make your edits to `word/document.xml` -2. **Validate immediately**: `python ooxml/scripts/validate.py unpacked_dir/` -3. If validation fails: - - Review the error message carefully - - Fix the issues in the XML - - Run validation again -4. **Only proceed when validation passes** -5. Rebuild: `python ooxml/scripts/pack.py unpacked_dir/ output.docx` -6. Test the output document -``` - -The validation loop catches errors early. - -## Content guidelines - -### Avoid time-sensitive information - -Don't include information that will become outdated: - -**Bad example: Time-sensitive** (will become wrong): - -```markdown theme={null} -If you're doing this before August 2025, use the old API. -After August 2025, use the new API. -``` - -**Good example** (use "old patterns" section): - -```markdown theme={null} -## Current method - -Use the v2 API endpoint: `api.example.com/v2/messages` - -## Old patterns - -
-Legacy v1 API (deprecated 2025-08) - -The v1 API used: `api.example.com/v1/messages` - -This endpoint is no longer supported. -
-``` - -The old patterns section provides historical context without cluttering the main content. - -### Use consistent terminology - -Choose one term and use it throughout the Skill: - -**Good - Consistent**: - -* Always "API endpoint" -* Always "field" -* Always "extract" - -**Bad - Inconsistent**: - -* Mix "API endpoint", "URL", "API route", "path" -* Mix "field", "box", "element", "control" -* Mix "extract", "pull", "get", "retrieve" - -Consistency helps Claude understand and follow instructions. - -## Common patterns - -### Template pattern - -Provide templates for output format. Match the level of strictness to your needs. - -**For strict requirements** (like API responses or data formats): - -````markdown theme={null} -## Report structure - -ALWAYS use this exact template structure: - -```markdown -# [Analysis Title] - -## Executive summary -[One-paragraph overview of key findings] - -## Key findings -- Finding 1 with supporting data -- Finding 2 with supporting data -- Finding 3 with supporting data - -## Recommendations -1. Specific actionable recommendation -2. Specific actionable recommendation -``` -```` - -**For flexible guidance** (when adaptation is useful): - -````markdown theme={null} -## Report structure - -Here is a sensible default format, but use your best judgment based on the analysis: - -```markdown -# [Analysis Title] - -## Executive summary -[Overview] - -## Key findings -[Adapt sections based on what you discover] - -## Recommendations -[Tailor to the specific context] -``` - -Adjust sections as needed for the specific analysis type. -```` - -### Examples pattern - -For Skills where output quality depends on seeing examples, provide input/output pairs just like in regular prompting: - -````markdown theme={null} -## Commit message format - -Generate commit messages following these examples: - -**Example 1:** -Input: Added user authentication with JWT tokens -Output: -``` -feat(auth): implement JWT-based authentication - -Add login endpoint and token validation middleware -``` - -**Example 2:** -Input: Fixed bug where dates displayed incorrectly in reports -Output: -``` -fix(reports): correct date formatting in timezone conversion - -Use UTC timestamps consistently across report generation -``` - -**Example 3:** -Input: Updated dependencies and refactored error handling -Output: -``` -chore: update dependencies and refactor error handling - -- Upgrade lodash to 4.17.21 -- Standardize error response format across endpoints -``` - -Follow this style: type(scope): brief description, then detailed explanation. -```` - -Examples help Claude understand the desired style and level of detail more clearly than descriptions alone. - -### Conditional workflow pattern - -Guide Claude through decision points: - -```markdown theme={null} -## Document modification workflow - -1. Determine the modification type: - - **Creating new content?** → Follow "Creation workflow" below - **Editing existing content?** → Follow "Editing workflow" below - -2. Creation workflow: - - Use docx-js library - - Build document from scratch - - Export to .docx format - -3. Editing workflow: - - Unpack existing document - - Modify XML directly - - Validate after each change - - Repack when complete -``` - - - If workflows become large or complicated with many steps, consider pushing them into separate files and tell Claude to read the appropriate file based on the task at hand. - - -## Evaluation and iteration - -### Build evaluations first - -**Create evaluations BEFORE writing extensive documentation.** This ensures your Skill solves real problems rather than documenting imagined ones. - -**Evaluation-driven development:** - -1. **Identify gaps**: Run Claude on representative tasks without a Skill. Document specific failures or missing context -2. **Create evaluations**: Build three scenarios that test these gaps -3. **Establish baseline**: Measure Claude's performance without the Skill -4. **Write minimal instructions**: Create just enough content to address the gaps and pass evaluations -5. **Iterate**: Execute evaluations, compare against baseline, and refine - -This approach ensures you're solving actual problems rather than anticipating requirements that may never materialize. - -**Evaluation structure**: - -```json theme={null} -{ - "skills": ["pdf-processing"], - "query": "Extract all text from this PDF file and save it to output.txt", - "files": ["test-files/document.pdf"], - "expected_behavior": [ - "Successfully reads the PDF file using an appropriate PDF processing library or command-line tool", - "Extracts text content from all pages in the document without missing any pages", - "Saves the extracted text to a file named output.txt in a clear, readable format" - ] -} -``` - - - This example demonstrates a data-driven evaluation with a simple testing rubric. We do not currently provide a built-in way to run these evaluations. Users can create their own evaluation system. Evaluations are your source of truth for measuring Skill effectiveness. - - -### Develop Skills iteratively with Claude - -The most effective Skill development process involves Claude itself. Work with one instance of Claude ("Claude A") to create a Skill that will be used by other instances ("Claude B"). Claude A helps you design and refine instructions, while Claude B tests them in real tasks. This works because Claude models understand both how to write effective agent instructions and what information agents need. - -**Creating a new Skill:** - -1. **Complete a task without a Skill**: Work through a problem with Claude A using normal prompting. As you work, you'll naturally provide context, explain preferences, and share procedural knowledge. Notice what information you repeatedly provide. - -2. **Identify the reusable pattern**: After completing the task, identify what context you provided that would be useful for similar future tasks. - - **Example**: If you worked through a BigQuery analysis, you might have provided table names, field definitions, filtering rules (like "always exclude test accounts"), and common query patterns. - -3. **Ask Claude A to create a Skill**: "Create a Skill that captures this BigQuery analysis pattern we just used. Include the table schemas, naming conventions, and the rule about filtering test accounts." - - - Claude models understand the Skill format and structure natively. You don't need special system prompts or a "writing skills" skill to get Claude to help create Skills. Simply ask Claude to create a Skill and it will generate properly structured SKILL.md content with appropriate frontmatter and body content. - - -4. **Review for conciseness**: Check that Claude A hasn't added unnecessary explanations. Ask: "Remove the explanation about what win rate means - Claude already knows that." - -5. **Improve information architecture**: Ask Claude A to organize the content more effectively. For example: "Organize this so the table schema is in a separate reference file. We might add more tables later." - -6. **Test on similar tasks**: Use the Skill with Claude B (a fresh instance with the Skill loaded) on related use cases. Observe whether Claude B finds the right information, applies rules correctly, and handles the task successfully. - -7. **Iterate based on observation**: If Claude B struggles or misses something, return to Claude A with specifics: "When Claude used this Skill, it forgot to filter by date for Q4. Should we add a section about date filtering patterns?" - -**Iterating on existing Skills:** - -The same hierarchical pattern continues when improving Skills. You alternate between: - -* **Working with Claude A** (the expert who helps refine the Skill) -* **Testing with Claude B** (the agent using the Skill to perform real work) -* **Observing Claude B's behavior** and bringing insights back to Claude A - -1. **Use the Skill in real workflows**: Give Claude B (with the Skill loaded) actual tasks, not test scenarios - -2. **Observe Claude B's behavior**: Note where it struggles, succeeds, or makes unexpected choices - - **Example observation**: "When I asked Claude B for a regional sales report, it wrote the query but forgot to filter out test accounts, even though the Skill mentions this rule." - -3. **Return to Claude A for improvements**: Share the current SKILL.md and describe what you observed. Ask: "I noticed Claude B forgot to filter test accounts when I asked for a regional report. The Skill mentions filtering, but maybe it's not prominent enough?" - -4. **Review Claude A's suggestions**: Claude A might suggest reorganizing to make rules more prominent, using stronger language like "MUST filter" instead of "always filter", or restructuring the workflow section. - -5. **Apply and test changes**: Update the Skill with Claude A's refinements, then test again with Claude B on similar requests - -6. **Repeat based on usage**: Continue this observe-refine-test cycle as you encounter new scenarios. Each iteration improves the Skill based on real agent behavior, not assumptions. - -**Gathering team feedback:** - -1. Share Skills with teammates and observe their usage -2. Ask: Does the Skill activate when expected? Are instructions clear? What's missing? -3. Incorporate feedback to address blind spots in your own usage patterns - -**Why this approach works**: Claude A understands agent needs, you provide domain expertise, Claude B reveals gaps through real usage, and iterative refinement improves Skills based on observed behavior rather than assumptions. - -### Observe how Claude navigates Skills - -As you iterate on Skills, pay attention to how Claude actually uses them in practice. Watch for: - -* **Unexpected exploration paths**: Does Claude read files in an order you didn't anticipate? This might indicate your structure isn't as intuitive as you thought -* **Missed connections**: Does Claude fail to follow references to important files? Your links might need to be more explicit or prominent -* **Overreliance on certain sections**: If Claude repeatedly reads the same file, consider whether that content should be in the main SKILL.md instead -* **Ignored content**: If Claude never accesses a bundled file, it might be unnecessary or poorly signaled in the main instructions - -Iterate based on these observations rather than assumptions. The 'name' and 'description' in your Skill's metadata are particularly critical. Claude uses these when deciding whether to trigger the Skill in response to the current task. Make sure they clearly describe what the Skill does and when it should be used. - -## Anti-patterns to avoid - -### Avoid Windows-style paths - -Always use forward slashes in file paths, even on Windows: - -* ✓ **Good**: `scripts/helper.py`, `reference/guide.md` -* ✗ **Avoid**: `scripts\helper.py`, `reference\guide.md` - -Unix-style paths work across all platforms, while Windows-style paths cause errors on Unix systems. - -### Avoid offering too many options - -Don't present multiple approaches unless necessary: - -````markdown theme={null} -**Bad example: Too many choices** (confusing): -"You can use pypdf, or pdfplumber, or PyMuPDF, or pdf2image, or..." - -**Good example: Provide a default** (with escape hatch): -"Use pdfplumber for text extraction: -```python -import pdfplumber -``` - -For scanned PDFs requiring OCR, use pdf2image with pytesseract instead." -```` - -## Advanced: Skills with executable code - -The sections below focus on Skills that include executable scripts. If your Skill uses only markdown instructions, skip to [Checklist for effective Skills](#checklist-for-effective-skills). - -### Solve, don't punt - -When writing scripts for Skills, handle error conditions rather than punting to Claude. - -**Good example: Handle errors explicitly**: - -```python theme={null} -def process_file(path): - """Process a file, creating it if it doesn't exist.""" - try: - with open(path) as f: - return f.read() - except FileNotFoundError: - # Create file with default content instead of failing - print(f"File {path} not found, creating default") - with open(path, 'w') as f: - f.write('') - return '' - except PermissionError: - # Provide alternative instead of failing - print(f"Cannot access {path}, using default") - return '' -``` - -**Bad example: Punt to Claude**: - -```python theme={null} -def process_file(path): - # Just fail and let Claude figure it out - return open(path).read() -``` - -Configuration parameters should also be justified and documented to avoid "voodoo constants" (Ousterhout's law). If you don't know the right value, how will Claude determine it? - -**Good example: Self-documenting**: - -```python theme={null} -# HTTP requests typically complete within 30 seconds -# Longer timeout accounts for slow connections -REQUEST_TIMEOUT = 30 - -# Three retries balances reliability vs speed -# Most intermittent failures resolve by the second retry -MAX_RETRIES = 3 -``` - -**Bad example: Magic numbers**: - -```python theme={null} -TIMEOUT = 47 # Why 47? -RETRIES = 5 # Why 5? -``` - -### Provide utility scripts - -Even if Claude could write a script, pre-made scripts offer advantages: - -**Benefits of utility scripts**: - -* More reliable than generated code -* Save tokens (no need to include code in context) -* Save time (no code generation required) -* Ensure consistency across uses - -Bundling executable scripts alongside instruction files - -The diagram above shows how executable scripts work alongside instruction files. The instruction file (forms.md) references the script, and Claude can execute it without loading its contents into context. - -**Important distinction**: Make clear in your instructions whether Claude should: - -* **Execute the script** (most common): "Run `analyze_form.py` to extract fields" -* **Read it as reference** (for complex logic): "See `analyze_form.py` for the field extraction algorithm" - -For most utility scripts, execution is preferred because it's more reliable and efficient. See the [Runtime environment](#runtime-environment) section below for details on how script execution works. - -**Example**: - -````markdown theme={null} -## Utility scripts - -**analyze_form.py**: Extract all form fields from PDF - -```bash -python scripts/analyze_form.py input.pdf > fields.json -``` - -Output format: -```json -{ - "field_name": {"type": "text", "x": 100, "y": 200}, - "signature": {"type": "sig", "x": 150, "y": 500} -} -``` - -**validate_boxes.py**: Check for overlapping bounding boxes - -```bash -python scripts/validate_boxes.py fields.json -# Returns: "OK" or lists conflicts -``` - -**fill_form.py**: Apply field values to PDF - -```bash -python scripts/fill_form.py input.pdf fields.json output.pdf -``` -```` - -### Use visual analysis - -When inputs can be rendered as images, have Claude analyze them: - -````markdown theme={null} -## Form layout analysis - -1. Convert PDF to images: - ```bash - python scripts/pdf_to_images.py form.pdf - ``` - -2. Analyze each page image to identify form fields -3. Claude can see field locations and types visually -```` - - - In this example, you'd need to write the `pdf_to_images.py` script. - - -Claude's vision capabilities help understand layouts and structures. - -### Create verifiable intermediate outputs - -When Claude performs complex, open-ended tasks, it can make mistakes. The "plan-validate-execute" pattern catches errors early by having Claude first create a plan in a structured format, then validate that plan with a script before executing it. - -**Example**: Imagine asking Claude to update 50 form fields in a PDF based on a spreadsheet. Without validation, Claude might reference non-existent fields, create conflicting values, miss required fields, or apply updates incorrectly. - -**Solution**: Use the workflow pattern shown above (PDF form filling), but add an intermediate `changes.json` file that gets validated before applying changes. The workflow becomes: analyze → **create plan file** → **validate plan** → execute → verify. - -**Why this pattern works:** - -* **Catches errors early**: Validation finds problems before changes are applied -* **Machine-verifiable**: Scripts provide objective verification -* **Reversible planning**: Claude can iterate on the plan without touching originals -* **Clear debugging**: Error messages point to specific problems - -**When to use**: Batch operations, destructive changes, complex validation rules, high-stakes operations. - -**Implementation tip**: Make validation scripts verbose with specific error messages like "Field 'signature\_date' not found. Available fields: customer\_name, order\_total, signature\_date\_signed" to help Claude fix issues. - -### Package dependencies - -Skills run in the code execution environment with platform-specific limitations: - -* **claude.ai**: Can install packages from npm and PyPI and pull from GitHub repositories -* **Anthropic API**: Has no network access and no runtime package installation - -List required packages in your SKILL.md and verify they're available in the [code execution tool documentation](/en/docs/agents-and-tools/tool-use/code-execution-tool). - -### Runtime environment - -Skills run in a code execution environment with filesystem access, bash commands, and code execution capabilities. For the conceptual explanation of this architecture, see [The Skills architecture](/en/docs/agents-and-tools/agent-skills/overview#the-skills-architecture) in the overview. - -**How this affects your authoring:** - -**How Claude accesses Skills:** - -1. **Metadata pre-loaded**: At startup, the name and description from all Skills' YAML frontmatter are loaded into the system prompt -2. **Files read on-demand**: Claude uses bash Read tools to access SKILL.md and other files from the filesystem when needed -3. **Scripts executed efficiently**: Utility scripts can be executed via bash without loading their full contents into context. Only the script's output consumes tokens -4. **No context penalty for large files**: Reference files, data, or documentation don't consume context tokens until actually read - -* **File paths matter**: Claude navigates your skill directory like a filesystem. Use forward slashes (`reference/guide.md`), not backslashes -* **Name files descriptively**: Use names that indicate content: `form_validation_rules.md`, not `doc2.md` -* **Organize for discovery**: Structure directories by domain or feature - * Good: `reference/finance.md`, `reference/sales.md` - * Bad: `docs/file1.md`, `docs/file2.md` -* **Bundle comprehensive resources**: Include complete API docs, extensive examples, large datasets; no context penalty until accessed -* **Prefer scripts for deterministic operations**: Write `validate_form.py` rather than asking Claude to generate validation code -* **Make execution intent clear**: - * "Run `analyze_form.py` to extract fields" (execute) - * "See `analyze_form.py` for the extraction algorithm" (read as reference) -* **Test file access patterns**: Verify Claude can navigate your directory structure by testing with real requests - -**Example:** - -``` -bigquery-skill/ -├── SKILL.md (overview, points to reference files) -└── reference/ - ├── finance.md (revenue metrics) - ├── sales.md (pipeline data) - └── product.md (usage analytics) -``` - -When the user asks about revenue, Claude reads SKILL.md, sees the reference to `reference/finance.md`, and invokes bash to read just that file. The sales.md and product.md files remain on the filesystem, consuming zero context tokens until needed. This filesystem-based model is what enables progressive disclosure. Claude can navigate and selectively load exactly what each task requires. - -For complete details on the technical architecture, see [How Skills work](/en/docs/agents-and-tools/agent-skills/overview#how-skills-work) in the Skills overview. - -### MCP tool references - -If your Skill uses MCP (Model Context Protocol) tools, always use fully qualified tool names to avoid "tool not found" errors. - -**Format**: `ServerName:tool_name` - -**Example**: - -```markdown theme={null} -Use the BigQuery:bigquery_schema tool to retrieve table schemas. -Use the GitHub:create_issue tool to create issues. -``` - -Where: - -* `BigQuery` and `GitHub` are MCP server names -* `bigquery_schema` and `create_issue` are the tool names within those servers - -Without the server prefix, Claude may fail to locate the tool, especially when multiple MCP servers are available. - -### Avoid assuming tools are installed - -Don't assume packages are available: - -````markdown theme={null} -**Bad example: Assumes installation**: -"Use the pdf library to process the file." - -**Good example: Explicit about dependencies**: -"Install required package: `pip install pypdf` - -Then use it: -```python -from pypdf import PdfReader -reader = PdfReader("file.pdf") -```" -```` - -## Technical notes - -### YAML frontmatter requirements - -The SKILL.md frontmatter requires `name` (64 characters max) and `description` (1024 characters max) fields. See the [Skills overview](/en/docs/agents-and-tools/agent-skills/overview#skill-structure) for complete structure details. - -### Token budgets - -Keep SKILL.md body under 500 lines for optimal performance. If your content exceeds this, split it into separate files using the progressive disclosure patterns described earlier. For architectural details, see the [Skills overview](/en/docs/agents-and-tools/agent-skills/overview#how-skills-work). - -## Checklist for effective Skills - -Before sharing a Skill, verify: - -### Core quality - -* [ ] Description is specific and includes key terms -* [ ] Description includes both what the Skill does and when to use it -* [ ] SKILL.md body is under 500 lines -* [ ] Additional details are in separate files (if needed) -* [ ] No time-sensitive information (or in "old patterns" section) -* [ ] Consistent terminology throughout -* [ ] Examples are concrete, not abstract -* [ ] File references are one level deep -* [ ] Progressive disclosure used appropriately -* [ ] Workflows have clear steps - -### Code and scripts - -* [ ] Scripts solve problems rather than punt to Claude -* [ ] Error handling is explicit and helpful -* [ ] No "voodoo constants" (all values justified) -* [ ] Required packages listed in instructions and verified as available -* [ ] Scripts have clear documentation -* [ ] No Windows-style paths (all forward slashes) -* [ ] Validation/verification steps for critical operations -* [ ] Feedback loops included for quality-critical tasks - -### Testing - -* [ ] At least three evaluations created -* [ ] Tested with Haiku, Sonnet, and Opus -* [ ] Tested with real usage scenarios -* [ ] Team feedback incorporated (if applicable) - -## Next steps - - - - Create your first Skill - - - - Create and manage Skills in Claude Code - - - - Upload and use Skills programmatically - - diff --git a/src/crates/assembly/core/builtin_skills/xlsx/LICENSE.txt b/src/crates/assembly/core/builtin_skills/xlsx/LICENSE.txt deleted file mode 100644 index c55ab42224..0000000000 --- a/src/crates/assembly/core/builtin_skills/xlsx/LICENSE.txt +++ /dev/null @@ -1,30 +0,0 @@ -© 2025 Anthropic, PBC. All rights reserved. - -LICENSE: Use of these materials (including all code, prompts, assets, files, -and other components of this Skill) is governed by your agreement with -Anthropic regarding use of Anthropic's services. If no separate agreement -exists, use is governed by Anthropic's Consumer Terms of Service or -Commercial Terms of Service, as applicable: -https://www.anthropic.com/legal/consumer-terms -https://www.anthropic.com/legal/commercial-terms -Your applicable agreement is referred to as the "Agreement." "Services" are -as defined in the Agreement. - -ADDITIONAL RESTRICTIONS: Notwithstanding anything in the Agreement to the -contrary, users may not: - -- Extract these materials from the Services or retain copies of these - materials outside the Services -- Reproduce or copy these materials, except for temporary copies created - automatically during authorized use of the Services -- Create derivative works based on these materials -- Distribute, sublicense, or transfer these materials to any third party -- Make, offer to sell, sell, or import any inventions embodied in these - materials -- Reverse engineer, decompile, or disassemble these materials - -The receipt, viewing, or possession of these materials does not convey or -imply any license or right beyond those expressly granted above. - -Anthropic retains all right, title, and interest in these materials, -including all copyrights, patents, and other intellectual property rights. diff --git a/src/crates/assembly/core/builtin_skills/xlsx/SKILL.md b/src/crates/assembly/core/builtin_skills/xlsx/SKILL.md deleted file mode 100644 index dab8cacf95..0000000000 --- a/src/crates/assembly/core/builtin_skills/xlsx/SKILL.md +++ /dev/null @@ -1,99 +0,0 @@ ---- -name: xlsx -description: "Use this skill any time a spreadsheet file is the primary input or output. This means any task where the user wants to: open, read, edit, or fix an existing .xlsx, .xlsm, .xltx, .csv, or .tsv file (e.g., adding columns, computing formulas, formatting, charting, cleaning messy data); create a new spreadsheet from scratch or from other data sources; or convert between tabular file formats. Trigger especially when the user references a spreadsheet file by name or path — even casually (like \"the xlsx in my downloads\") — and wants something done to it or produced from it. Also trigger for cleaning or restructuring messy tabular data files (malformed rows, misplaced headers, junk data) into proper spreadsheets. The deliverable must be a spreadsheet file. Do NOT trigger when the primary deliverable is a Word document, HTML report, standalone Python script, database pipeline, or Google Sheets API integration, even if tabular data is involved." -license: Proprietary. LICENSE.txt has complete terms ---- - -# XLSX creation, editing, and analysis - -| Task | Approach | -|---|---| -| **Create** or **edit** with formulas/formatting | `openpyxl` — see gotchas below | -| **Bulk data** in or out | `pandas` (`read_excel`, `to_excel`) | -| **Quick look** at a sheet | `markitdown file.xlsx` — `## SheetName` per sheet; reads `.xlsm` too. No cell coordinates, so don't plan edits from it | -| **Read** a model (formulas *and* values) | two `load_workbook` passes — see gotchas | - -> `openpyxl`, `pandas`, and `markitdown` are preinstalled — do not run `pip install` first; write the script and import directly. Only if an import fails (or the `markitdown` command is missing): `pip install` the missing package. - -> Script paths below are relative to this skill's directory. - -## Requirements for every output - -- **Professional font** (Arial, Times New Roman) throughout, unless the user says otherwise. -- **Zero formula errors.** Never ship while `recalc.py` reports `errors_found`. If you think an error predates you, prove it: load the *original* with `data_only=True` and look at that cell. An error you introduced looks exactly like one you inherited. -- **Use formulas, never hardcoded results.** Write `sheet['B10'] = '=SUM(B2:B9)'`, not the Python-computed total. The sheet must recalculate when its inputs change. -- **Follow the user's spec literally.** Exact tab names, exact column headers, and the formula they spelled out. A redesign that computes something else fails, however elegant. -- **Document every assumption and hardcoded number** where the reader will see it — a cell comment, or an adjacent cell at a table's end. Cite a real source when one exists (`Source: Company 10-K, FY2024, Page 45, Revenue Note, [SEC EDGAR URL]`); when the number came from the user, say so plainly. -- **A workbook *you create* for someone to fill in** needs a short legend naming which cells to edit, and one example row of realistic values showing the expected format. Never add such a row to a file you were asked to edit. -- **Editing an existing file: match its conventions exactly.** They override every guideline here. Find its designated input cells first — a distinct font color, fill, or shading marks them — write only there, and leave every existing formula untouched. - -## Recalculate (mandatory whenever the file contains formulas) - -openpyxl writes formulas as strings with **no cached values**. Until you recalculate, every -formula cell reads back as `None` to anything reading cached values — `pandas`, -`load_workbook(data_only=True)`, and most previewers. - -```bash -python scripts/recalc.py output.xlsx [timeout_seconds] # default 30 -``` - -LibreOffice computes every formula, the file is **rewritten in place**, and you get JSON: -`status` (`success` | `errors_found`), `total_formulas`, `total_errors`, and an -`error_summary` naming up to 100 cells per error type (`locations_truncated` says how many it -withheld — trust `total_errors`, not the length of the list). Fix what it names and run it -again. **JSON with an `error` key instead of a `status` means nothing was recalculated**, and -only that case exits non-zero — `errors_found` exits 0, so never treat a clean exit as a clean -workbook. - -**A green recalc proves your formulas *evaluate*, not that they are *right*.** An off-by-one -range or a reference to the wrong row yields a clean, error-free file with wrong numbers. -Write 2–3 formulas first and check they pull the values you expect, before building out a grid. - -**A workbook that links to another file loses those links** if you re-save it with openpyxl and -then recalculate. Such a formula reads `='[1]Returns Analysis'!$B$2` — the `[1]` is an index -into the workbook's external-reference list, naming a *separate file on disk*, not a sheet. -That file is rarely present here, so the cell's cached value is the only thing holding its -data. openpyxl strips that value on save; LibreOffice then has to resolve the reference for -real, fails, writes `#NAME?`, and deletes every link. `recalc.py` refuses to run in that state -— copy those cells' values out of the original before you save over them (`--force` overrides, -and accepts the loss). - -## Choosing formulas that survive verification - -LibreOffice implements fewer functions than Excel, and one it cannot evaluate becomes a -literal `#NAME?` baked into the file you deliver. - -- **Prefer Excel-2007-era functions** — `SUMIFS`, `INDEX`, `MATCH`, `IFERROR`, `SUMPRODUCT` — which need no prefix. -- **Six post-2007 functions work, but only with an `_xlfn.` prefix**, because openpyxl writes your formula into the XML verbatim and Excel stores post-2007 names prefixed (its UI hides the prefix): `_xlfn.TEXTJOIN`, `_xlfn.CONCAT`, `_xlfn.IFS`, `_xlfn.SWITCH`, `_xlfn.MAXIFS`, `_xlfn.MINIFS`. Written bare, each yields `#NAME?`. -- **Never use `XLOOKUP`, `XMATCH`, `SORT`, `FILTER`, `UNIQUE`, or `SEQUENCE`.** The runtime's LibreOffice cannot evaluate them under *any* prefix. Newer builds do evaluate them, but they are spilling array functions and an openpyxl-written file has no spill metadata, so only the top-left cell of the range gets a value — and `recalc.py` reports `total_errors: 0` on the truncated result. Use `INDEX`/`MATCH` for lookups, and sort, filter, and de-duplicate in Python before writing the cells. -- A formula LibreOffice could not parse is written back **lowercased** — a quick tell beside a `#NAME?`. - -## openpyxl gotchas - -- **Reading a model takes two loads.** `data_only=True` yields cached values with the formulas gone; the default yields formula strings with no values. One pass cannot give you both. -- **`data_only=True` is destructive if you save.** That workbook has no formulas left, so saving replaces every one with a literal — permanently. -- **`data_only=True` on a file openpyxl just wrote returns `None` everywhere** — run `recalc.py` first. (A formula whose result is `""` also reads back as `None`.) -- **Merged cells: write the top-left anchor only.** Every other cell in the range is a `MergedCell` whose `.value` is read-only. -- **`.xlsm` loses its macros unless you pass `keep_vba=True`** to `load_workbook`. -- **A sheet name containing a space must be quoted** in a cross-sheet reference: `='Assumptions Inputs'!$B$5`. Unquoted, it evaluates to `#VALUE!`. - -## Financial models - -Unless the user says otherwise, or the existing file already does something else. - -**Color:** blue text (`0,0,255`) for hardcoded inputs and scenario levers · black for formulas · -green (`0,128,0`) for links to another sheet · red (`255,0,0`) for links to another file · -yellow fill (`255,255,0`) for key assumptions and cells the user should fill in. - -**Numbers:** currency `$#,##0`, with the unit named in the header (`Revenue ($mm)`) · zeros -render as `-`, including in percentages (`$#,##0;($#,##0);-`) · negatives in parentheses · -percentages `0.0%`, **stored as fractions** (`0.15` renders `15.0%`; storing `15` renders -`1500.0%`) · valuation multiples `0.0x` · years as text (`"2026"`, never `2,026`). - -**Structure:** every assumption in its own labeled cell, referenced by the formulas that use it -(`=B5*(1+$B$6)`, never `=B5*1.05`) · formulas consistent across every projection period, since a -lone edited cell mid-row is the commonest silent error · guard denominators that can be zero. - -## Dependencies - -`openpyxl`, `pandas`, `markitdown` (pip, preinstalled — install only if an import fails or the command is missing) · LibreOffice (`soffice`, auto-configured for sandboxed environments via `scripts/office/soffice.py`) diff --git a/src/crates/assembly/core/builtin_skills/xlsx/scripts/office/helpers/__init__.py b/src/crates/assembly/core/builtin_skills/xlsx/scripts/office/helpers/__init__.py deleted file mode 100644 index 188b00aff4..0000000000 --- a/src/crates/assembly/core/builtin_skills/xlsx/scripts/office/helpers/__init__.py +++ /dev/null @@ -1,150 +0,0 @@ -import os -import posixpath -import re -import stat -import tempfile -import urllib.parse -import zipfile -from pathlib import Path - -OOXML_FAMILY = { - ".docx": "docx", - ".dotx": "docx", - ".pptx": "pptx", - ".potx": "pptx", - ".xlsx": "xlsx", - ".xltx": "xlsx", -} - -_SCHEME_RE = re.compile(r"^[A-Za-z][A-Za-z0-9+.\-]*:") - -SLIDE_REL_TYPE = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/slide" - -MAX_ARCHIVE_MEMBERS = 10_000 -MAX_ARCHIVE_MEMBER_SIZE = 1 * 1024 * 1024 * 1024 -MAX_ARCHIVE_TOTAL_SIZE = 4 * 1024 * 1024 * 1024 -MAX_ARCHIVE_COMPRESSION_RATIO = 1_000 - - -def opc_target(target: str, source_part: str, target_mode: str = "") -> str | None: - if not target: - return None - if target_mode.lower() == "external": - return None - if _SCHEME_RE.match(target): - return None - - target = urllib.parse.unquote(target) - - if "\\" in target: - raise ValueError(f"relationship target is not a POSIX part name: {target!r}") - - if target.startswith("/"): - joined = target.lstrip("/") - else: - joined = posixpath.join(posixpath.dirname(source_part), target) - - parts: list[str] = [] - for segment in posixpath.normpath(joined).split("/"): - if segment in ("", "."): - continue - if segment == "..": - if not parts: - raise ValueError(f"relationship target escapes the package: {target!r}") - parts.pop() - else: - parts.append(segment) - - if not parts: - raise ValueError(f"relationship target resolves to nothing: {target!r}") - return "/".join(parts) - - -def rels_source_part(rels_file: Path, unpacked_dir: Path) -> str: - owner_dir = rels_file.parent.parent.relative_to(unpacked_dir) - return posixpath.join(owner_dir.as_posix(), rels_file.name[: -len(".rels")]).lstrip("./") - - -def part_text(data: bytes) -> str: - return data.decode("utf-8", "surrogateescape") - - -XML_SPACE = " \t\r\n" - - -def rendered_text(text: str, preserve: bool) -> str: - return text if preserve else text.strip(XML_SPACE) - - -def safe_extract(zf: zipfile.ZipFile, dest: Path) -> None: - dest = dest.resolve() - members = zf.infolist() - if len(members) > MAX_ARCHIVE_MEMBERS: - raise ValueError(f"archive has too many entries: {len(members)}") - - total_size = 0 - targets: set[str] = set() - file_targets: set[str] = set() - validated: list[tuple[zipfile.ZipInfo, Path]] = [] - for m in members: - if stat.S_ISLNK(m.external_attr >> 16): - raise ValueError(f"symlink archive entry not allowed: {m.filename!r}") - target = (dest / m.filename).resolve() - if target == dest or not target.is_relative_to(dest): - raise ValueError(f"unsafe archive entry: {m.filename!r}") - target_key = os.path.normcase(str(target)) - if target_key in targets: - raise ValueError(f"duplicate archive entry: {m.filename!r}") - targets.add(target_key) - if not m.is_dir(): - file_targets.add(target_key) - validated.append((m, target)) - if m.file_size > MAX_ARCHIVE_MEMBER_SIZE: - raise ValueError(f"archive entry is too large: {m.filename!r}") - total_size += m.file_size - if total_size > MAX_ARCHIVE_TOTAL_SIZE: - raise ValueError("archive expands beyond the allowed total size") - if m.file_size and ( - m.compress_size == 0 - or m.file_size > m.compress_size * MAX_ARCHIVE_COMPRESSION_RATIO - ): - raise ValueError(f"archive entry has an unsafe compression ratio: {m.filename!r}") - - for m, target in validated: - for parent in target.parents: - if parent == dest: - break - if os.path.normcase(str(parent)) in file_targets: - raise ValueError(f"archive file entry conflicts with child path: {m.filename!r}") - - for m, _ in validated: - zf.extract(m, dest) - - -def rezip(src_dir: Path, out_path: Path) -> None: - files = sorted(p for p in src_dir.rglob("*") if p.is_file()) - ct = src_dir / "[Content_Types].xml" - fd, tmp_name = tempfile.mkstemp( - prefix=out_path.name + ".", suffix=".tmp", dir=out_path.parent - ) - tmp_out = Path(tmp_name) - try: - with os.fdopen(fd, "wb") as fh: - with zipfile.ZipFile(fh, "w", zipfile.ZIP_DEFLATED) as zf: - if ct.exists(): - zf.write(ct, ct.relative_to(src_dir), compress_type=zipfile.ZIP_STORED) - for f in files: - if f == ct: - continue - zf.write(f, f.relative_to(src_dir)) - if out_path.exists(): - mode = out_path.stat().st_mode & 0o777 - else: - umask = os.umask(0) - os.umask(umask) - mode = 0o666 & ~umask - os.chmod(tmp_out, mode) - os.replace(tmp_out, out_path) - finally: - if tmp_out.exists(): - tmp_out.unlink() diff --git a/src/crates/assembly/core/builtin_skills/xlsx/scripts/office/helpers/pptx_chart.py b/src/crates/assembly/core/builtin_skills/xlsx/scripts/office/helpers/pptx_chart.py deleted file mode 100644 index 209cb7c58b..0000000000 --- a/src/crates/assembly/core/builtin_skills/xlsx/scripts/office/helpers/pptx_chart.py +++ /dev/null @@ -1,170 +0,0 @@ -"""Find chart XML that PowerPoint refuses but the schema accepts. - -Detection only: for either fault more than one repair is valid, and only the -author knows which was meant. -""" - - -from __future__ import annotations - -import re -from typing import Mapping - -from . import part_text - - -_CHART_PART_RE = re.compile(r"ppt/charts/chart\d+\.xml") - -_GROUPING_RE = re.compile(r"""]*?\bval=["'](\w+)["']""") -_DLBL_POS_RE = re.compile(r"""]*?\bval=["'](\w+)["']""") - -def _strip_ext_lst(text: str) -> str: - out, cursor = [], 0 - for lo, hi in _ext_lst_spans(text): - out.append(text[cursor:lo]) - cursor = hi - out.append(text[cursor:]) - return "".join(out) - -_BAR_GROUP_RE = re.compile(r"]*(?.*?", re.DOTALL) - -STACKED_GROUPINGS = frozenset({"stacked", "percentStacked"}) -ILLEGAL_ON_STACKED = frozenset({"outEnd"}) -LEGAL_ON_STACKED = ("ctr", "inEnd", "inBase") - - -def _check_stacked_label_positions(part: str, xml: str) -> list[str]: - problems: list[str] = [] - for match in _BAR_GROUP_RE.finditer(xml): - block = _strip_ext_lst(match.group(0)) - group = match.group(1) - - grouping = _GROUPING_RE.search(block) - if grouping is None or grouping.group(1) not in STACKED_GROUPINGS: - continue - - bad = [p for p in _DLBL_POS_RE.findall(block) if p in ILLEGAL_ON_STACKED] - for pos in sorted(set(bad)): - problems.append( - f'{part}: {bad.count(pos)} data label(s) use dLblPos="{pos}" on a ' - f"{grouping.group(1)} {group}; PowerPoint allows only " - f"{', '.join(LEGAL_ON_STACKED)} there" - ) - return problems - - - -_ANY_CHART_GROUP_RE = re.compile(r"]*(?.*?", re.DOTALL) - -_AXID_RE = re.compile( - r"""\s*]*?\bval=["'](-?\d+)["']\s*(?:/>|>\s*)""" -) - -_AXIS_DECL_RE = re.compile( - r"""]*(?\s*]*?\bval=["'](-?\d+)["']""" -) - -AXID_LIMIT = { - "barChart": 2, "lineChart": 2, "areaChart": 2, "scatterChart": 2, - "bubbleChart": 2, "radarChart": 2, "stockChart": 2, - "bar3DChart": 3, "line3DChart": 3, "area3DChart": 3, - "surfaceChart": 3, "surface3DChart": 3, -} - -AXID_MINIMUM = { - "barChart": 2, "lineChart": 2, "areaChart": 2, "scatterChart": 2, - "bubbleChart": 2, "radarChart": 2, "stockChart": 2, - "bar3DChart": 2, "area3DChart": 2, "surfaceChart": 2, - "line3DChart": 3, "surface3DChart": 3, -} - - -def _declared_axes(xml: str) -> dict[str, list[str]]: - axes: dict[str, list[str]] = {} - for kind, axid in _AXIS_DECL_RE.findall(xml): - axes.setdefault(kind, []).append(axid) - return axes - - -def _canonical_ids(axes: dict[str, list[str]], limit: int) -> list[str] | None: - category = axes.get("catAx", []) + axes.get("dateAx", []) - value = axes.get("valAx", []) - series = axes.get("serAx", []) - if len(category) != 1 or len(value) != 1 or len(series) > 1: - return None - ids = [category[0], value[0]] - if limit >= 3 and series: - ids.append(series[0]) - return ids - - -def _undeclared_axes(kind: str, block: str, axes: dict[str, list[str]]) -> list[str] | None: - if kind not in AXID_LIMIT: - return None - ids = _AXID_RE.findall(block) - declared = {i for group in axes.values() for i in group} - if len([i for i in ids if i in declared]) >= 2: - return None - return ids - - -def _check_chart_axis_references(part: str, xml: str) -> list[str]: - axes = _declared_axes(xml) - problems: list[str] = [] - declared = {i for group in axes.values() for i in group} - for match in _ANY_CHART_GROUP_RE.finditer(xml): - kind, block = match.group(1), match.group(0) - ids = _undeclared_axes(kind, block, axes) - if ids is None: - continue - if not ids: - problems.append( - f"{part}: declares no this part can resolve; a chart " - f"group needs {AXID_MINIMUM[kind]}, and PowerPoint discards one with fewer" - ) - continue - dead = [i for i in ids if i not in declared] - canonical = _canonical_ids(axes, AXID_LIMIT[kind]) - if canonical is not None and len(canonical) >= AXID_MINIMUM[kind]: - hint = f"Fix: point them at the axes this part declares ({', '.join(canonical)})" - else: - hint = ("Fix: the part declares several axes of a kind -- declare the " - "secondary axes the series expects, or drop them") - detail = (f"of which {', '.join(dead)} name no declared axis" - if dead else f"only {len(ids)} of which this part declares") - problems.append( - f"{part}: references axId {', '.join(ids)}, {detail}, " - f"leaving fewer than two live axes; PowerPoint discards the chart. {hint}" - ) - return problems - - -def _ext_lst_spans(text: str) -> list[tuple[int, int]]: - spans: list[tuple[int, int]] = [] - depth = 0 - start = 0 - for match in re.finditer(r"<(/?)c:extLst\b[^>]*?(/?)>", text): - closing, self_closing = match.group(1), match.group(2) - if self_closing: - continue - if closing: - depth -= 1 - if depth == 0: - spans.append((start, match.end())) - else: - if depth == 0: - start = match.start() - depth += 1 - return spans - - -CHART_CHECKS = (_check_stacked_label_positions, _check_chart_axis_references) - - -def find_chart_problems(files: Mapping[str, bytes]) -> list[str]: - problems: list[str] = [] - for part in sorted(n for n in files if _CHART_PART_RE.fullmatch(n)): - xml = part_text(files[part]) - for check in CHART_CHECKS: - problems.extend(check(part, xml)) - return problems diff --git a/src/crates/assembly/core/builtin_skills/xlsx/scripts/office/helpers/pptx_slide.py b/src/crates/assembly/core/builtin_skills/xlsx/scripts/office/helpers/pptx_slide.py deleted file mode 100644 index 22f9aee0ff..0000000000 --- a/src/crates/assembly/core/builtin_skills/xlsx/scripts/office/helpers/pptx_slide.py +++ /dev/null @@ -1,60 +0,0 @@ -"""Pick the slide-XML schema errors PowerPoint refuses the file over. - -A denylist over lxml's messages, so an unrecognised error class is a miss rather -than a false alarm. -""" - - -from __future__ import annotations - -import re - -SLIDE_PART_RE = re.compile( - r"ppt/(slides|slideLayouts|slideMasters|notesSlides|notesMasters|handoutMasters)" - r"/[^/]+\.xml" -) - -FATAL_SLIDE_ERRORS: tuple[tuple[re.Pattern[str], str], ...] = ( - ( - re.compile(r"\}tableStyleId': This element is not expected"), - "two in one (the schema allows one)", - ), - ( - re.compile(r"\}srgbClr', attribute 'val'"), - "a colour that is not six hex digits", - ), - ( - re.compile(r"\}txBody': Missing child element"), - "a with no children", - ), - ( - re.compile(r"\}miter', attribute 'lim'"), - 'a line join with lim="NaN"', - ), - ( - re.compile(r"\}uLnTx': This element is not expected"), - " in a position the schema forbids", - ), - ( - re.compile(r"\}overrideClrMapping': This element is not expected"), - " in a position the schema forbids", - ), - ( - re.compile(r"\}nvGrpSpPr': Missing child element"), - "a with no children", - ), -) - - -def is_schema_verdict(error: str) -> bool: - return error.startswith("Element ") - - -def fatal_slide_errors(errors: set[str]) -> list[str]: - out = [] - for error in sorted(errors): - for pattern, meaning in FATAL_SLIDE_ERRORS: - if pattern.search(error): - out.append(f"{meaning}: {error}") - break - return out diff --git a/src/crates/assembly/core/builtin_skills/xlsx/scripts/office/helpers/pptx_theme.py b/src/crates/assembly/core/builtin_skills/xlsx/scripts/office/helpers/pptx_theme.py deleted file mode 100644 index 5ef4c3e835..0000000000 --- a/src/crates/assembly/core/builtin_skills/xlsx/scripts/office/helpers/pptx_theme.py +++ /dev/null @@ -1,114 +0,0 @@ -"""Find masters sharing a theme part in the way PowerPoint refuses to open. - -Reports only; the fix is to move back to directly after - in ppt/presentation.xml. -""" - - -from __future__ import annotations - -import posixpath -import re -from typing import Mapping - -from . import part_text - -THEME_REL_TYPE = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme" - -_MASTER_RE = re.compile( - r"^ppt/(?PslideMasters|notesMasters|handoutMasters)/" - r"(?:slide|notes|handout)Master(?P\d+)\.xml$" -) -_GROUP_ORDER = {"slideMasters": 0, "notesMasters": 1, "handoutMasters": 2} - -_RELATIONSHIP_RE = re.compile( - r"]*?(?:/>|>.*?)", re.DOTALL -) - - -def _sort_key(name: str) -> tuple[int, int]: - m = _MASTER_RE.match(name) - assert m is not None - return (_GROUP_ORDER[m.group("group")], int(m.group("num"))) - - -def _rels_path(part: str) -> str: - directory, base = posixpath.split(part) - return f"{directory}/_rels/{base}.rels" - - -def _resolve(rels_path: str, target: str) -> str: - if target.startswith("/"): - return target.lstrip("/") - part_dir = posixpath.dirname(posixpath.dirname(rels_path)) - return posixpath.normpath(posixpath.join(part_dir, target)) - - -def _theme_rel(files: Mapping[str, bytes], master: str): - rels_path = _rels_path(master) - rels = files.get(rels_path) - if rels is None: - return None - for element in _RELATIONSHIP_RE.findall(part_text(rels)): - if f'Type="{THEME_REL_TYPE}"' not in element: - continue - target = re.search(r'\bTarget="([^"]+)"', element) - if target is None: - continue - return rels_path, element, _resolve(rels_path, target.group(1)) - return None - - -def _masters(files: Mapping[str, bytes]) -> list[str]: - return sorted((n for n in files if _MASTER_RE.match(n)), key=_sort_key) - - -_PRESENTATION = "ppt/presentation.xml" -_NOTES_MASTERS = "ppt/notesMasters/" -_IGNORABLE_RE = re.compile(r"|<\?.*?\?>", re.DOTALL) -_AFTER_SLDIDLST_RE = re.compile( - r"]*/>|[^>]*>.*?)\s*(<[^>\s/]+)", re.DOTALL -) - - -def _notes_master_share_is_inert(files: Mapping[str, bytes]) -> bool: - data = files.get(_PRESENTATION) - if data is None: - return False - match = _AFTER_SLDIDLST_RE.search(_IGNORABLE_RE.sub("", part_text(data))) - return match is not None and match.group(1) == " bool: - return inert_notes and master.startswith(_NOTES_MASTERS) - - -def find_shared_master_themes(files: Mapping[str, bytes]) -> list[str]: - return [ - f"{master} shares {theme} with {first}" - for master, _, _, theme, first in _shares(files) - ] - - -def live_shared_master_themes(files: Mapping[str, bytes]) -> list[str]: - inert_notes = _notes_master_share_is_inert(files) - return [ - f"{master} shares {theme} with {first}" - for master, _, _, theme, first in _shares(files) - if not _is_inert(master, inert_notes) - ] diff --git a/src/crates/assembly/core/builtin_skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-chart.xsd b/src/crates/assembly/core/builtin_skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-chart.xsd deleted file mode 100644 index 6454ef9a94..0000000000 --- a/src/crates/assembly/core/builtin_skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-chart.xsd +++ /dev/null @@ -1,1499 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/crates/assembly/core/builtin_skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-chartDrawing.xsd b/src/crates/assembly/core/builtin_skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-chartDrawing.xsd deleted file mode 100644 index afa4f463e3..0000000000 --- a/src/crates/assembly/core/builtin_skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-chartDrawing.xsd +++ /dev/null @@ -1,146 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/crates/assembly/core/builtin_skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-diagram.xsd b/src/crates/assembly/core/builtin_skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-diagram.xsd deleted file mode 100644 index 64e66b8abd..0000000000 --- a/src/crates/assembly/core/builtin_skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-diagram.xsd +++ /dev/null @@ -1,1085 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/crates/assembly/core/builtin_skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-lockedCanvas.xsd b/src/crates/assembly/core/builtin_skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-lockedCanvas.xsd deleted file mode 100644 index 687eea8297..0000000000 --- a/src/crates/assembly/core/builtin_skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-lockedCanvas.xsd +++ /dev/null @@ -1,11 +0,0 @@ - - - - - diff --git a/src/crates/assembly/core/builtin_skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-main.xsd b/src/crates/assembly/core/builtin_skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-main.xsd deleted file mode 100644 index 6ac81b06b7..0000000000 --- a/src/crates/assembly/core/builtin_skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-main.xsd +++ /dev/null @@ -1,3081 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/crates/assembly/core/builtin_skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-picture.xsd b/src/crates/assembly/core/builtin_skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-picture.xsd deleted file mode 100644 index 1dbf05140d..0000000000 --- a/src/crates/assembly/core/builtin_skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-picture.xsd +++ /dev/null @@ -1,23 +0,0 @@ - - - - - - - - - - - - - - - - - - diff --git a/src/crates/assembly/core/builtin_skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-spreadsheetDrawing.xsd b/src/crates/assembly/core/builtin_skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-spreadsheetDrawing.xsd deleted file mode 100644 index f1af17db4e..0000000000 --- a/src/crates/assembly/core/builtin_skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-spreadsheetDrawing.xsd +++ /dev/null @@ -1,185 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/crates/assembly/core/builtin_skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-wordprocessingDrawing.xsd b/src/crates/assembly/core/builtin_skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-wordprocessingDrawing.xsd deleted file mode 100644 index 0a185ab6ed..0000000000 --- a/src/crates/assembly/core/builtin_skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-wordprocessingDrawing.xsd +++ /dev/null @@ -1,287 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/crates/assembly/core/builtin_skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/pml.xsd b/src/crates/assembly/core/builtin_skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/pml.xsd deleted file mode 100644 index 14ef488865..0000000000 --- a/src/crates/assembly/core/builtin_skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/pml.xsd +++ /dev/null @@ -1,1676 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/crates/assembly/core/builtin_skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-additionalCharacteristics.xsd b/src/crates/assembly/core/builtin_skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-additionalCharacteristics.xsd deleted file mode 100644 index c20f3bf147..0000000000 --- a/src/crates/assembly/core/builtin_skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-additionalCharacteristics.xsd +++ /dev/null @@ -1,28 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/crates/assembly/core/builtin_skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-bibliography.xsd b/src/crates/assembly/core/builtin_skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-bibliography.xsd deleted file mode 100644 index ac60252262..0000000000 --- a/src/crates/assembly/core/builtin_skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-bibliography.xsd +++ /dev/null @@ -1,144 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/crates/assembly/core/builtin_skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-commonSimpleTypes.xsd b/src/crates/assembly/core/builtin_skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-commonSimpleTypes.xsd deleted file mode 100644 index 424b8ba8d1..0000000000 --- a/src/crates/assembly/core/builtin_skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-commonSimpleTypes.xsd +++ /dev/null @@ -1,174 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/crates/assembly/core/builtin_skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-customXmlDataProperties.xsd b/src/crates/assembly/core/builtin_skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-customXmlDataProperties.xsd deleted file mode 100644 index 2bddce2921..0000000000 --- a/src/crates/assembly/core/builtin_skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-customXmlDataProperties.xsd +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - - - - - - - - - - - - - - diff --git a/src/crates/assembly/core/builtin_skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-customXmlSchemaProperties.xsd b/src/crates/assembly/core/builtin_skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-customXmlSchemaProperties.xsd deleted file mode 100644 index 8a8c18ba2d..0000000000 --- a/src/crates/assembly/core/builtin_skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-customXmlSchemaProperties.xsd +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - - - - - - - - - - diff --git a/src/crates/assembly/core/builtin_skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-documentPropertiesCustom.xsd b/src/crates/assembly/core/builtin_skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-documentPropertiesCustom.xsd deleted file mode 100644 index 5c42706a0d..0000000000 --- a/src/crates/assembly/core/builtin_skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-documentPropertiesCustom.xsd +++ /dev/null @@ -1,59 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/crates/assembly/core/builtin_skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-documentPropertiesExtended.xsd b/src/crates/assembly/core/builtin_skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-documentPropertiesExtended.xsd deleted file mode 100644 index 853c341c87..0000000000 --- a/src/crates/assembly/core/builtin_skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-documentPropertiesExtended.xsd +++ /dev/null @@ -1,56 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/crates/assembly/core/builtin_skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-documentPropertiesVariantTypes.xsd b/src/crates/assembly/core/builtin_skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-documentPropertiesVariantTypes.xsd deleted file mode 100644 index da835ee82d..0000000000 --- a/src/crates/assembly/core/builtin_skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-documentPropertiesVariantTypes.xsd +++ /dev/null @@ -1,195 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/crates/assembly/core/builtin_skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-math.xsd b/src/crates/assembly/core/builtin_skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-math.xsd deleted file mode 100644 index 87ad2658fa..0000000000 --- a/src/crates/assembly/core/builtin_skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-math.xsd +++ /dev/null @@ -1,582 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/crates/assembly/core/builtin_skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-relationshipReference.xsd b/src/crates/assembly/core/builtin_skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-relationshipReference.xsd deleted file mode 100644 index 9e86f1b2be..0000000000 --- a/src/crates/assembly/core/builtin_skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-relationshipReference.xsd +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - - - - - - - - - - - - - - - diff --git a/src/crates/assembly/core/builtin_skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/sml.xsd b/src/crates/assembly/core/builtin_skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/sml.xsd deleted file mode 100644 index d0be42e757..0000000000 --- a/src/crates/assembly/core/builtin_skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/sml.xsd +++ /dev/null @@ -1,4439 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/crates/assembly/core/builtin_skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/vml-main.xsd b/src/crates/assembly/core/builtin_skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/vml-main.xsd deleted file mode 100644 index 8821dd183c..0000000000 --- a/src/crates/assembly/core/builtin_skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/vml-main.xsd +++ /dev/null @@ -1,570 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/crates/assembly/core/builtin_skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/vml-officeDrawing.xsd b/src/crates/assembly/core/builtin_skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/vml-officeDrawing.xsd deleted file mode 100644 index ca2575c753..0000000000 --- a/src/crates/assembly/core/builtin_skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/vml-officeDrawing.xsd +++ /dev/null @@ -1,509 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/crates/assembly/core/builtin_skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/vml-presentationDrawing.xsd b/src/crates/assembly/core/builtin_skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/vml-presentationDrawing.xsd deleted file mode 100644 index dd079e603f..0000000000 --- a/src/crates/assembly/core/builtin_skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/vml-presentationDrawing.xsd +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - - diff --git a/src/crates/assembly/core/builtin_skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/vml-spreadsheetDrawing.xsd b/src/crates/assembly/core/builtin_skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/vml-spreadsheetDrawing.xsd deleted file mode 100644 index 3dd6cf625a..0000000000 --- a/src/crates/assembly/core/builtin_skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/vml-spreadsheetDrawing.xsd +++ /dev/null @@ -1,108 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/crates/assembly/core/builtin_skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/vml-wordprocessingDrawing.xsd b/src/crates/assembly/core/builtin_skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/vml-wordprocessingDrawing.xsd deleted file mode 100644 index f1041e34ef..0000000000 --- a/src/crates/assembly/core/builtin_skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/vml-wordprocessingDrawing.xsd +++ /dev/null @@ -1,96 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/crates/assembly/core/builtin_skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/wml.xsd b/src/crates/assembly/core/builtin_skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/wml.xsd deleted file mode 100644 index 9c5b7a6334..0000000000 --- a/src/crates/assembly/core/builtin_skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/wml.xsd +++ /dev/null @@ -1,3646 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/crates/assembly/core/builtin_skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/xml.xsd b/src/crates/assembly/core/builtin_skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/xml.xsd deleted file mode 100644 index 0f13678d80..0000000000 --- a/src/crates/assembly/core/builtin_skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/xml.xsd +++ /dev/null @@ -1,116 +0,0 @@ - - - - - - See http://www.w3.org/XML/1998/namespace.html and - http://www.w3.org/TR/REC-xml for information about this namespace. - - This schema document describes the XML namespace, in a form - suitable for import by other schema documents. - - Note that local names in this namespace are intended to be defined - only by the World Wide Web Consortium or its subgroups. The - following names are currently defined in this namespace and should - not be used with conflicting semantics by any Working Group, - specification, or document instance: - - base (as an attribute name): denotes an attribute whose value - provides a URI to be used as the base for interpreting any - relative URIs in the scope of the element on which it - appears; its value is inherited. This name is reserved - by virtue of its definition in the XML Base specification. - - lang (as an attribute name): denotes an attribute whose value - is a language code for the natural language of the content of - any element; its value is inherited. This name is reserved - by virtue of its definition in the XML specification. - - space (as an attribute name): denotes an attribute whose - value is a keyword indicating what whitespace processing - discipline is intended for the content of the element; its - value is inherited. This name is reserved by virtue of its - definition in the XML specification. - - Father (in any context at all): denotes Jon Bosak, the chair of - the original XML Working Group. This name is reserved by - the following decision of the W3C XML Plenary and - XML Coordination groups: - - In appreciation for his vision, leadership and dedication - the W3C XML Plenary on this 10th day of February, 2000 - reserves for Jon Bosak in perpetuity the XML name - xml:Father - - - - - This schema defines attributes and an attribute group - suitable for use by - schemas wishing to allow xml:base, xml:lang or xml:space attributes - on elements they define. - - To enable this, such a schema must import this schema - for the XML namespace, e.g. as follows: - <schema . . .> - . . . - <import namespace="http://www.w3.org/XML/1998/namespace" - schemaLocation="http://www.w3.org/2001/03/xml.xsd"/> - - Subsequently, qualified reference to any of the attributes - or the group defined below will have the desired effect, e.g. - - <type . . .> - . . . - <attributeGroup ref="xml:specialAttrs"/> - - will define a type which will schema-validate an instance - element with any of those attributes - - - - In keeping with the XML Schema WG's standard versioning - policy, this schema document will persist at - http://www.w3.org/2001/03/xml.xsd. - At the date of issue it can also be found at - http://www.w3.org/2001/xml.xsd. - The schema document at that URI may however change in the future, - in order to remain compatible with the latest version of XML Schema - itself. In other words, if the XML Schema namespace changes, the version - of this document at - http://www.w3.org/2001/xml.xsd will change - accordingly; the version at - http://www.w3.org/2001/03/xml.xsd will not change. - - - - - - In due course, we should install the relevant ISO 2- and 3-letter - codes as the enumerated possible values . . . - - - - - - - - - - - - - - - See http://www.w3.org/TR/xmlbase/ for - information about this attribute. - - - - - - - - - - diff --git a/src/crates/assembly/core/builtin_skills/xlsx/scripts/office/schemas/ecma/fouth-edition/opc-contentTypes.xsd b/src/crates/assembly/core/builtin_skills/xlsx/scripts/office/schemas/ecma/fouth-edition/opc-contentTypes.xsd deleted file mode 100644 index a6de9d2733..0000000000 --- a/src/crates/assembly/core/builtin_skills/xlsx/scripts/office/schemas/ecma/fouth-edition/opc-contentTypes.xsd +++ /dev/null @@ -1,42 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/crates/assembly/core/builtin_skills/xlsx/scripts/office/schemas/ecma/fouth-edition/opc-coreProperties.xsd b/src/crates/assembly/core/builtin_skills/xlsx/scripts/office/schemas/ecma/fouth-edition/opc-coreProperties.xsd deleted file mode 100644 index 10e978b661..0000000000 --- a/src/crates/assembly/core/builtin_skills/xlsx/scripts/office/schemas/ecma/fouth-edition/opc-coreProperties.xsd +++ /dev/null @@ -1,50 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/crates/assembly/core/builtin_skills/xlsx/scripts/office/schemas/ecma/fouth-edition/opc-digSig.xsd b/src/crates/assembly/core/builtin_skills/xlsx/scripts/office/schemas/ecma/fouth-edition/opc-digSig.xsd deleted file mode 100644 index 4248bf7a39..0000000000 --- a/src/crates/assembly/core/builtin_skills/xlsx/scripts/office/schemas/ecma/fouth-edition/opc-digSig.xsd +++ /dev/null @@ -1,49 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/crates/assembly/core/builtin_skills/xlsx/scripts/office/schemas/ecma/fouth-edition/opc-relationships.xsd b/src/crates/assembly/core/builtin_skills/xlsx/scripts/office/schemas/ecma/fouth-edition/opc-relationships.xsd deleted file mode 100644 index 5649746712..0000000000 --- a/src/crates/assembly/core/builtin_skills/xlsx/scripts/office/schemas/ecma/fouth-edition/opc-relationships.xsd +++ /dev/null @@ -1,33 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/crates/assembly/core/builtin_skills/xlsx/scripts/office/schemas/mce/mc.xsd b/src/crates/assembly/core/builtin_skills/xlsx/scripts/office/schemas/mce/mc.xsd deleted file mode 100644 index ef725457cf..0000000000 --- a/src/crates/assembly/core/builtin_skills/xlsx/scripts/office/schemas/mce/mc.xsd +++ /dev/null @@ -1,75 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/crates/assembly/core/builtin_skills/xlsx/scripts/office/schemas/microsoft/wml-2010.xsd b/src/crates/assembly/core/builtin_skills/xlsx/scripts/office/schemas/microsoft/wml-2010.xsd deleted file mode 100644 index f65f777730..0000000000 --- a/src/crates/assembly/core/builtin_skills/xlsx/scripts/office/schemas/microsoft/wml-2010.xsd +++ /dev/null @@ -1,560 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/crates/assembly/core/builtin_skills/xlsx/scripts/office/schemas/microsoft/wml-2012.xsd b/src/crates/assembly/core/builtin_skills/xlsx/scripts/office/schemas/microsoft/wml-2012.xsd deleted file mode 100644 index 6b00755a9a..0000000000 --- a/src/crates/assembly/core/builtin_skills/xlsx/scripts/office/schemas/microsoft/wml-2012.xsd +++ /dev/null @@ -1,67 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/crates/assembly/core/builtin_skills/xlsx/scripts/office/schemas/microsoft/wml-2018.xsd b/src/crates/assembly/core/builtin_skills/xlsx/scripts/office/schemas/microsoft/wml-2018.xsd deleted file mode 100644 index f321d333a5..0000000000 --- a/src/crates/assembly/core/builtin_skills/xlsx/scripts/office/schemas/microsoft/wml-2018.xsd +++ /dev/null @@ -1,14 +0,0 @@ - - - - - - - - - - - - - - diff --git a/src/crates/assembly/core/builtin_skills/xlsx/scripts/office/schemas/microsoft/wml-cex-2018.xsd b/src/crates/assembly/core/builtin_skills/xlsx/scripts/office/schemas/microsoft/wml-cex-2018.xsd deleted file mode 100644 index 364c6a9b8d..0000000000 --- a/src/crates/assembly/core/builtin_skills/xlsx/scripts/office/schemas/microsoft/wml-cex-2018.xsd +++ /dev/null @@ -1,20 +0,0 @@ - - - - - - - - - - - - - - - - - - - - diff --git a/src/crates/assembly/core/builtin_skills/xlsx/scripts/office/schemas/microsoft/wml-cid-2016.xsd b/src/crates/assembly/core/builtin_skills/xlsx/scripts/office/schemas/microsoft/wml-cid-2016.xsd deleted file mode 100644 index fed9d15b7f..0000000000 --- a/src/crates/assembly/core/builtin_skills/xlsx/scripts/office/schemas/microsoft/wml-cid-2016.xsd +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - diff --git a/src/crates/assembly/core/builtin_skills/xlsx/scripts/office/schemas/microsoft/wml-sdtdatahash-2020.xsd b/src/crates/assembly/core/builtin_skills/xlsx/scripts/office/schemas/microsoft/wml-sdtdatahash-2020.xsd deleted file mode 100644 index 680cf15400..0000000000 --- a/src/crates/assembly/core/builtin_skills/xlsx/scripts/office/schemas/microsoft/wml-sdtdatahash-2020.xsd +++ /dev/null @@ -1,4 +0,0 @@ - - - - diff --git a/src/crates/assembly/core/builtin_skills/xlsx/scripts/office/schemas/microsoft/wml-symex-2015.xsd b/src/crates/assembly/core/builtin_skills/xlsx/scripts/office/schemas/microsoft/wml-symex-2015.xsd deleted file mode 100644 index 89ada90837..0000000000 --- a/src/crates/assembly/core/builtin_skills/xlsx/scripts/office/schemas/microsoft/wml-symex-2015.xsd +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - diff --git a/src/crates/assembly/core/builtin_skills/xlsx/scripts/office/soffice.py b/src/crates/assembly/core/builtin_skills/xlsx/scripts/office/soffice.py deleted file mode 100644 index 0b4c99deca..0000000000 --- a/src/crates/assembly/core/builtin_skills/xlsx/scripts/office/soffice.py +++ /dev/null @@ -1,192 +0,0 @@ -""" -Helper for running LibreOffice (soffice) in environments where AF_UNIX -sockets may be blocked (e.g., sandboxed VMs). Detects the restriction -at runtime and applies an LD_PRELOAD shim if needed. - -Usage: - from office.soffice import run_soffice - - result = run_soffice(["--headless", "--convert-to", "pdf", "input.docx"]) - -Call soffice through run_soffice, not through subprocess with get_soffice_env(): -the env dict carries the shim but names no user profile, and a non-root sandbox -cannot bootstrap the default one -- soffice aborts with "User installation could -not be completed" and converts nothing. get_soffice_env() stays public for the -callers that build their own argv (they must pass -env:UserInstallation too). -""" - -import contextlib -import os -import socket -import subprocess -import tempfile -from collections.abc import Iterable -from pathlib import Path - - -def get_soffice_env() -> dict: - env = os.environ.copy() - env["SAL_USE_VCLPLUGIN"] = "svp" - - if _needs_shim(): - shim = _ensure_shim() - env["LD_PRELOAD"] = str(shim) - - return env - - -def run_soffice(args: Iterable[str], **kwargs) -> subprocess.CompletedProcess: - args = list(args) - with contextlib.ExitStack() as stack: - if not any(str(a).startswith("-env:UserInstallation") for a in args): - profile = stack.enter_context( - tempfile.TemporaryDirectory(prefix="lo_profile_", ignore_cleanup_errors=True) - ) - args = [f"-env:UserInstallation={Path(profile).as_uri()}"] + args - return subprocess.run(["soffice"] + args, env=get_soffice_env(), **kwargs) - - - -_SHIM_SO = Path(tempfile.gettempdir()) / "lo_socket_shim.so" - - -def _needs_shim() -> bool: - try: - s = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) - s.close() - return False - except OSError: - return True - - -def _ensure_shim() -> Path: - if _SHIM_SO.exists(): - return _SHIM_SO - - src = Path(tempfile.gettempdir()) / "lo_socket_shim.c" - src.write_text(_SHIM_SOURCE) - subprocess.run( - ["gcc", "-shared", "-fPIC", "-o", str(_SHIM_SO), str(src), "-ldl"], - check=True, - capture_output=True, - ) - src.unlink() - return _SHIM_SO - - - -_SHIM_SOURCE = r""" -#define _GNU_SOURCE -#include -#include -#include -#include -#include -#include -#include - -static int (*real_socket)(int, int, int); -static int (*real_socketpair)(int, int, int, int[2]); -static int (*real_listen)(int, int); -static int (*real_accept)(int, struct sockaddr *, socklen_t *); -static int (*real_close)(int); -static int (*real_read)(int, void *, size_t); - -/* Per-FD bookkeeping (FDs >= 1024 are passed through unshimmed). */ -static int is_shimmed[1024]; -static int peer_of[1024]; -static int wake_r[1024]; /* accept() blocks reading this */ -static int wake_w[1024]; /* close() writes to this */ -static int listener_fd = -1; /* FD that received listen() */ - -__attribute__((constructor)) -static void init(void) { - real_socket = dlsym(RTLD_NEXT, "socket"); - real_socketpair = dlsym(RTLD_NEXT, "socketpair"); - real_listen = dlsym(RTLD_NEXT, "listen"); - real_accept = dlsym(RTLD_NEXT, "accept"); - real_close = dlsym(RTLD_NEXT, "close"); - real_read = dlsym(RTLD_NEXT, "read"); - for (int i = 0; i < 1024; i++) { - peer_of[i] = -1; - wake_r[i] = -1; - wake_w[i] = -1; - } -} - -/* ---- socket ---------------------------------------------------------- */ -int socket(int domain, int type, int protocol) { - if (domain == AF_UNIX) { - int fd = real_socket(domain, type, protocol); - if (fd >= 0) return fd; - /* socket(AF_UNIX) blocked – fall back to socketpair(). */ - int sv[2]; - if (real_socketpair(domain, type, protocol, sv) == 0) { - if (sv[0] >= 0 && sv[0] < 1024) { - is_shimmed[sv[0]] = 1; - peer_of[sv[0]] = sv[1]; - int wp[2]; - if (pipe(wp) == 0) { - wake_r[sv[0]] = wp[0]; - wake_w[sv[0]] = wp[1]; - } - } - return sv[0]; - } - errno = EPERM; - return -1; - } - return real_socket(domain, type, protocol); -} - -/* ---- listen ---------------------------------------------------------- */ -int listen(int sockfd, int backlog) { - if (sockfd >= 0 && sockfd < 1024 && is_shimmed[sockfd]) { - listener_fd = sockfd; - return 0; - } - return real_listen(sockfd, backlog); -} - -/* ---- accept ---------------------------------------------------------- */ -int accept(int sockfd, struct sockaddr *addr, socklen_t *addrlen) { - if (sockfd >= 0 && sockfd < 1024 && is_shimmed[sockfd]) { - /* Block until close() writes to the wake pipe. */ - if (wake_r[sockfd] >= 0) { - char buf; - real_read(wake_r[sockfd], &buf, 1); - } - errno = ECONNABORTED; - return -1; - } - return real_accept(sockfd, addr, addrlen); -} - -/* ---- close ----------------------------------------------------------- */ -int close(int fd) { - if (fd >= 0 && fd < 1024 && is_shimmed[fd]) { - int was_listener = (fd == listener_fd); - is_shimmed[fd] = 0; - - if (wake_w[fd] >= 0) { /* unblock accept() */ - char c = 0; - write(wake_w[fd], &c, 1); - real_close(wake_w[fd]); - wake_w[fd] = -1; - } - if (wake_r[fd] >= 0) { real_close(wake_r[fd]); wake_r[fd] = -1; } - if (peer_of[fd] >= 0) { real_close(peer_of[fd]); peer_of[fd] = -1; } - - if (was_listener) - _exit(0); /* conversion done – exit */ - } - return real_close(fd); -} -""" - - - -if __name__ == "__main__": - import sys - result = run_soffice(sys.argv[1:]) - sys.exit(result.returncode) diff --git a/src/crates/assembly/core/builtin_skills/xlsx/scripts/office/validate.py b/src/crates/assembly/core/builtin_skills/xlsx/scripts/office/validate.py deleted file mode 100755 index 8fbd2f71ca..0000000000 --- a/src/crates/assembly/core/builtin_skills/xlsx/scripts/office/validate.py +++ /dev/null @@ -1,173 +0,0 @@ -""" -Command line tool to validate Office document XML files against XSD schemas and tracked changes. - -Usage: - python validate.py [--original ] [--auto-repair] [--author NAME] - -The first argument can be either: -- An unpacked directory containing the Office document XML files -- A packed Office file (.docx/.pptx/.xlsx or .dotx/.potx/.xltx template) which will be unpacked to a temp directory - -Auto-repair fixes: -- paraId/durableId values that exceed OOXML limits -- Missing xml:space="preserve" on w:t elements with whitespace -""" - -import argparse -import sys -import tempfile -import zipfile -from pathlib import Path - -import defusedxml.ElementTree as ET -from defusedxml.common import DefusedXmlException - -from helpers import OOXML_FAMILY, rezip, safe_extract -from validators import DOCXSchemaValidator, PPTXSchemaValidator, RedliningValidator - -WORD_NS = "http://schemas.openxmlformats.org/wordprocessingml/2006/main" - - -def _fail(message: str): - print(f"Error: {message}", file=sys.stderr) - sys.exit(2) - - -def _has_tracked_changes(unpacked_dir: Path) -> bool: - document = unpacked_dir / "word" / "document.xml" - if not document.is_file(): - return False - try: - root = ET.parse(document).getroot() - except (ET.ParseError, DefusedXmlException): - return False - tracked = {f"{{{WORD_NS}}}ins", f"{{{WORD_NS}}}del"} - return any(elem.tag in tracked for elem in root.iter()) - - -def main(): - parser = argparse.ArgumentParser(description="Validate Office document XML files") - parser.add_argument( - "path", - help="Path to unpacked directory or packed Office file (.docx/.pptx/.xlsx or .dotx/.potx/.xltx)", - ) - parser.add_argument( - "--original", - required=False, - default=None, - help="Path to original file (.docx/.pptx/.xlsx or .dotx/.potx/.xltx). If omitted, all XSD errors are reported and redlining validation is skipped.", - ) - parser.add_argument( - "-v", - "--verbose", - action="store_true", - help="Enable verbose output", - ) - parser.add_argument( - "--auto-repair", - action="store_true", - help="Automatically repair common issues (hex IDs, whitespace preservation). " - "Modifies the input in place: repairs to a packed file are written back to it.", - ) - parser.add_argument( - "--author", - default=None, - help="The name you are redlining under. Passing it turns on the " - "tracked-change check: any text differing from --original without a " - "/ recording it is reported. Untracked edits carry no " - "author, so the check covers them whoever made them — the name marks " - "the run as redlining work and is not used to filter. Requires " - "--original; docx only.", - ) - args = parser.parse_args() - - if args.author is not None and not args.original: - _fail("--author requires --original") - - path = Path(args.path) - if not path.exists(): - _fail(f"{path} does not exist") - - original_file = None - if args.original: - original_file = Path(args.original) - if not original_file.is_file(): - _fail(f"{original_file} is not a file") - if original_file.suffix.lower() not in OOXML_FAMILY: - _fail(f"{original_file} must be one of: {', '.join(sorted(OOXML_FAMILY))}") - - family = OOXML_FAMILY.get((original_file or path).suffix.lower()) - if family is None: - _fail( - f"Cannot determine file type from {path}. Use --original or provide one of: {', '.join(sorted(OOXML_FAMILY))}." - ) - - if args.author is not None and family != "docx": - _fail(f"--author only applies to docx files, not {family}") - - packed_file = None - temp_dir_ctx = None - if path.is_file() and path.suffix.lower() in OOXML_FAMILY: - packed_file = path - temp_dir_ctx = tempfile.TemporaryDirectory() - unpacked_dir = Path(temp_dir_ctx.name) - try: - with zipfile.ZipFile(path, "r") as zf: - safe_extract(zf, unpacked_dir) - except (zipfile.BadZipFile, ValueError, OSError) as e: - _fail(f"cannot unpack {path}: {e}") - else: - if not path.is_dir(): - _fail(f"{path} is not a directory or Office file") - unpacked_dir = path - - match family: - case "docx": - validators = [ - DOCXSchemaValidator(unpacked_dir, original_file, verbose=args.verbose), - ] - if args.author is not None: - validators.append( - RedliningValidator(unpacked_dir, original_file, verbose=args.verbose) - ) - elif original_file and _has_tracked_changes(unpacked_dir): - print( - "Note: this document has tracked changes; they were not " - "checked against the original (pass --author to check)." - ) - case "pptx": - validators = [ - PPTXSchemaValidator(unpacked_dir, original_file, verbose=args.verbose), - ] - case "xlsx": - exts = ", ".join(k for k, v in sorted(OOXML_FAMILY.items()) if v == "xlsx") - print( - f"No XSD schema validation is performed for xlsx-family files ({exts}). " - "For formula-error checking, use scripts/recalc.py instead." - ) - sys.exit(0) - case _: - print(f"Error: Validation not supported for file type {family}") - sys.exit(1) - - if args.auto_repair: - total_repairs = sum(v.repair() for v in validators) - if total_repairs: - print(f"Auto-repaired {total_repairs} issue(s)") - if packed_file is not None: - rezip(unpacked_dir, packed_file) - print(f"Wrote repaired file to {packed_file}") - - success = all([v.validate() for v in validators]) - - if temp_dir_ctx is not None: - temp_dir_ctx.cleanup() - - if success: - print("All validations PASSED!") - - sys.exit(0 if success else 1) - - -if __name__ == "__main__": - main() diff --git a/src/crates/assembly/core/builtin_skills/xlsx/scripts/office/validators/__init__.py b/src/crates/assembly/core/builtin_skills/xlsx/scripts/office/validators/__init__.py deleted file mode 100644 index db092ece7e..0000000000 --- a/src/crates/assembly/core/builtin_skills/xlsx/scripts/office/validators/__init__.py +++ /dev/null @@ -1,15 +0,0 @@ -""" -Validation modules for Word document processing. -""" - -from .base import BaseSchemaValidator -from .docx import DOCXSchemaValidator -from .pptx import PPTXSchemaValidator -from .redlining import RedliningValidator - -__all__ = [ - "BaseSchemaValidator", - "DOCXSchemaValidator", - "PPTXSchemaValidator", - "RedliningValidator", -] diff --git a/src/crates/assembly/core/builtin_skills/xlsx/scripts/office/validators/base.py b/src/crates/assembly/core/builtin_skills/xlsx/scripts/office/validators/base.py deleted file mode 100644 index 19d52a7fe0..0000000000 --- a/src/crates/assembly/core/builtin_skills/xlsx/scripts/office/validators/base.py +++ /dev/null @@ -1,875 +0,0 @@ -""" -Base validator with common validation logic for document files. -""" - -import re -from pathlib import Path - -import defusedxml.minidom -from functools import lru_cache - -import lxml.etree - -from helpers import safe_extract - - -@lru_cache(maxsize=None) -def _load_schema(schema_path: str): - with open(schema_path, "rb") as xsd_file: - xsd_doc = lxml.etree.parse( - xsd_file, parser=lxml.etree.XMLParser(), base_url=schema_path - ) - return lxml.etree.XMLSchema(xsd_doc) - -class BaseSchemaValidator: - - IGNORED_VALIDATION_ERRORS = [ - "hyphenationZone", - "purl.org/dc/terms", - ] - - UNIQUE_ID_REQUIREMENTS = { - "comment": ("id", "file"), - "commentrangestart": ("id", "file"), - "commentrangeend": ("id", "file"), - "bookmarkstart": ("id", "file"), - "bookmarkend": ("id", "file"), - "sldid": ("id", "file"), - "sldmasterid": ("id", "global"), - "sldlayoutid": ("id", "global"), - "cm": ("authorid", "file"), - "sheet": ("sheetid", "file"), - "definedname": ("id", "file"), - "cxnsp": ("id", "file"), - "sp": ("id", "file"), - "pic": ("id", "file"), - "grpsp": ("id", "file"), - } - - EXCLUDED_ID_CONTAINERS = { - "sectionlst", - } - - ELEMENT_RELATIONSHIP_TYPES = {} - - SCHEMA_MAPPINGS = { - "word": "ISO-IEC29500-4_2016/wml.xsd", - "ppt": "ISO-IEC29500-4_2016/pml.xsd", - "xl": "ISO-IEC29500-4_2016/sml.xsd", - "[Content_Types].xml": "ecma/fouth-edition/opc-contentTypes.xsd", - "app.xml": "ISO-IEC29500-4_2016/shared-documentPropertiesExtended.xsd", - "core.xml": "ecma/fouth-edition/opc-coreProperties.xsd", - "custom.xml": "ISO-IEC29500-4_2016/shared-documentPropertiesCustom.xsd", - ".rels": "ecma/fouth-edition/opc-relationships.xsd", - "people.xml": "microsoft/wml-2012.xsd", - "commentsIds.xml": "microsoft/wml-cid-2016.xsd", - "commentsExtensible.xml": "microsoft/wml-cex-2018.xsd", - "commentsExtended.xml": "microsoft/wml-2012.xsd", - "chart": "ISO-IEC29500-4_2016/dml-chart.xsd", - "theme": "ISO-IEC29500-4_2016/dml-main.xsd", - "drawing": "ISO-IEC29500-4_2016/dml-main.xsd", - } - - MC_NAMESPACE = "http://schemas.openxmlformats.org/markup-compatibility/2006" - XML_NAMESPACE = "http://www.w3.org/XML/1998/namespace" - - PACKAGE_RELATIONSHIPS_NAMESPACE = ( - "http://schemas.openxmlformats.org/package/2006/relationships" - ) - OFFICE_RELATIONSHIPS_NAMESPACE = ( - "http://schemas.openxmlformats.org/officeDocument/2006/relationships" - ) - CONTENT_TYPES_NAMESPACE = ( - "http://schemas.openxmlformats.org/package/2006/content-types" - ) - - MAIN_CONTENT_FOLDERS = {"word", "ppt", "xl"} - - OOXML_NAMESPACES = { - "http://schemas.openxmlformats.org/officeDocument/2006/math", - "http://schemas.openxmlformats.org/officeDocument/2006/relationships", - "http://schemas.openxmlformats.org/schemaLibrary/2006/main", - "http://schemas.openxmlformats.org/drawingml/2006/main", - "http://schemas.openxmlformats.org/drawingml/2006/chart", - "http://schemas.openxmlformats.org/drawingml/2006/chartDrawing", - "http://schemas.openxmlformats.org/drawingml/2006/diagram", - "http://schemas.openxmlformats.org/drawingml/2006/picture", - "http://schemas.openxmlformats.org/drawingml/2006/spreadsheetDrawing", - "http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing", - "http://schemas.openxmlformats.org/wordprocessingml/2006/main", - "http://schemas.openxmlformats.org/presentationml/2006/main", - "http://schemas.openxmlformats.org/spreadsheetml/2006/main", - "http://schemas.openxmlformats.org/officeDocument/2006/sharedTypes", - "http://www.w3.org/XML/1998/namespace", - } - - def __init__(self, unpacked_dir, original_file=None, verbose=False): - self.unpacked_dir = Path(unpacked_dir).resolve() - self.original_file = Path(original_file) if original_file else None - self.verbose = verbose - - self.schemas_dir = Path(__file__).parent.parent / "schemas" - - patterns = ["*.xml", "*.rels"] - self.xml_files = [ - f for pattern in patterns for f in self.unpacked_dir.rglob(pattern) - ] - - if not self.xml_files: - print(f"Warning: No XML files found in {self.unpacked_dir}") - - def validate(self): - raise NotImplementedError("Subclasses must implement the validate method") - - def repair(self) -> int: - return self.repair_whitespace_preservation() - - def repair_whitespace_preservation(self) -> int: - repairs = 0 - - for xml_file in self.xml_files: - try: - content = xml_file.read_text(encoding="utf-8") - dom = defusedxml.minidom.parseString(content) - pending = [] - - for elem in dom.getElementsByTagName("*"): - local_name = elem.tagName.rsplit(":", 1)[-1] - if local_name in ("t", "delText", "instrText", "delInstrText"): - text = "".join( - child.data - for child in elem.childNodes - if child.nodeType in (child.TEXT_NODE, child.CDATA_SECTION_NODE) - ) - ws = (" ", "\t", "\n", "\r") - if text and (text.startswith(ws) or text.endswith(ws)): - if elem.getAttribute("xml:space") != "preserve": - elem.setAttribute("xml:space", "preserve") - text_preview = repr(text[:30]) + "..." if len(text) > 30 else repr(text) - pending.append(f" Repaired: {xml_file.name}: Added xml:space='preserve' to {elem.tagName}: {text_preview}") - - if pending: - xml_file.write_bytes(dom.toxml(encoding="UTF-8")) - for message in pending: - print(message) - repairs += len(pending) - - except Exception: - pass - - return repairs - - def validate_xml(self): - errors = [] - - for xml_file in self.xml_files: - try: - lxml.etree.parse(str(xml_file)) - except lxml.etree.XMLSyntaxError as e: - errors.append( - f" {xml_file.relative_to(self.unpacked_dir)}: " - f"Line {e.lineno}: {e.msg}" - ) - except Exception as e: - errors.append( - f" {xml_file.relative_to(self.unpacked_dir)}: " - f"Unexpected error: {str(e)}" - ) - - if errors: - print(f"FAILED - Found {len(errors)} XML violations:") - for error in errors: - print(error) - return False - else: - if self.verbose: - print("PASSED - All XML files are well-formed") - return True - - def validate_namespaces(self): - errors = [] - - for xml_file in self.xml_files: - try: - root = lxml.etree.parse(str(xml_file)).getroot() - declared = set(root.nsmap.keys()) - {None} - - for attr_val in [ - v for k, v in root.attrib.items() if k.endswith("Ignorable") - ]: - undeclared = set(attr_val.split()) - declared - errors.extend( - f" {xml_file.relative_to(self.unpacked_dir)}: " - f"Namespace '{ns}' in Ignorable but not declared" - for ns in undeclared - ) - except lxml.etree.XMLSyntaxError: - continue - - if errors: - print(f"FAILED - {len(errors)} namespace issues:") - for error in errors: - print(error) - return False - if self.verbose: - print("PASSED - All namespace prefixes properly declared") - return True - - def validate_unique_ids(self): - errors = [] - global_ids = {} - - for xml_file in self.xml_files: - try: - root = lxml.etree.parse(str(xml_file)).getroot() - file_ids = {} - - mc_elements = root.xpath( - ".//mc:AlternateContent", namespaces={"mc": self.MC_NAMESPACE} - ) - for elem in mc_elements: - elem.getparent().remove(elem) - - for elem in root.iter(): - if not hasattr(elem, "tag") or callable(elem.tag): - continue - tag = ( - elem.tag.split("}")[-1].lower() - if "}" in elem.tag - else elem.tag.lower() - ) - - if tag in self.UNIQUE_ID_REQUIREMENTS: - in_excluded_container = any( - ancestor.tag.split("}")[-1].lower() in self.EXCLUDED_ID_CONTAINERS - for ancestor in elem.iterancestors() - ) - if in_excluded_container: - continue - - attr_name, scope = self.UNIQUE_ID_REQUIREMENTS[tag] - - id_value = None - for attr, value in elem.attrib.items(): - attr_local = ( - attr.split("}")[-1].lower() - if "}" in attr - else attr.lower() - ) - if attr_local == attr_name: - id_value = value - break - - if id_value is not None: - if scope == "global": - if id_value in global_ids: - prev_file, prev_line, prev_tag = global_ids[ - id_value - ] - errors.append( - f" {xml_file.relative_to(self.unpacked_dir)}: " - f"Line {elem.sourceline}: Global ID '{id_value}' in <{tag}> " - f"already used in {prev_file} at line {prev_line} in <{prev_tag}>" - ) - else: - global_ids[id_value] = ( - xml_file.relative_to(self.unpacked_dir), - elem.sourceline, - tag, - ) - elif scope == "file": - key = (tag, attr_name) - if key not in file_ids: - file_ids[key] = {} - - if id_value in file_ids[key]: - prev_line = file_ids[key][id_value] - errors.append( - f" {xml_file.relative_to(self.unpacked_dir)}: " - f"Line {elem.sourceline}: Duplicate {attr_name}='{id_value}' in <{tag}> " - f"(first occurrence at line {prev_line})" - ) - else: - file_ids[key][id_value] = elem.sourceline - - except (lxml.etree.XMLSyntaxError, Exception) as e: - errors.append( - f" {xml_file.relative_to(self.unpacked_dir)}: Error: {e}" - ) - - if errors: - print(f"FAILED - Found {len(errors)} ID uniqueness violations:") - for error in errors: - print(error) - return False - else: - if self.verbose: - print("PASSED - All required IDs are unique") - return True - - def validate_file_references(self): - errors = [] - - rels_files = list(self.unpacked_dir.rglob("*.rels")) - - if not rels_files: - if self.verbose: - print("PASSED - No .rels files found") - return True - - all_files = [] - for file_path in self.unpacked_dir.rglob("*"): - if ( - file_path.is_file() - and file_path.name != "[Content_Types].xml" - and not file_path.name.endswith(".rels") - ): - all_files.append(file_path.resolve()) - - all_referenced_files = set() - - if self.verbose: - print( - f"Found {len(rels_files)} .rels files and {len(all_files)} target files" - ) - - for rels_file in rels_files: - try: - rels_root = lxml.etree.parse(str(rels_file)).getroot() - - rels_dir = rels_file.parent - - referenced_files = set() - broken_refs = [] - - for rel in rels_root.findall( - ".//ns:Relationship", - namespaces={"ns": self.PACKAGE_RELATIONSHIPS_NAMESPACE}, - ): - target = rel.get("Target") - if rel.get("TargetMode") == "External": - continue - if target and not target.startswith( - ("http", "mailto:") - ): - if target.startswith("/"): - target_path = self.unpacked_dir / target.lstrip("/") - elif rels_file.name == ".rels": - target_path = self.unpacked_dir / target - else: - base_dir = rels_dir.parent - target_path = base_dir / target - - try: - target_path = target_path.resolve() - if target_path.exists() and target_path.is_file(): - referenced_files.add(target_path) - all_referenced_files.add(target_path) - else: - broken_refs.append((target, rel.sourceline)) - except (OSError, ValueError): - broken_refs.append((target, rel.sourceline)) - - if broken_refs: - rel_path = rels_file.relative_to(self.unpacked_dir) - for broken_ref, line_num in broken_refs: - errors.append( - f" {rel_path}: Line {line_num}: Broken reference to {broken_ref}" - ) - - except Exception as e: - rel_path = rels_file.relative_to(self.unpacked_dir) - errors.append(f" Error parsing {rel_path}: {e}") - - unreferenced_files = set(all_files) - all_referenced_files - - if unreferenced_files: - for unref_file in sorted(unreferenced_files): - unref_rel_path = unref_file.relative_to(self.unpacked_dir) - errors.append(f" Unreferenced file: {unref_rel_path}") - - if errors: - print(f"FAILED - Found {len(errors)} relationship validation errors:") - for error in errors: - print(error) - print( - "CRITICAL: These errors will cause the document to appear corrupt. " - + "Broken references MUST be fixed, " - + "and unreferenced files MUST be referenced or removed." - ) - return False - else: - if self.verbose: - print( - "PASSED - All references are valid and all files are properly referenced" - ) - return True - - def validate_all_relationship_ids(self): - import lxml.etree - - errors = [] - - for xml_file in self.xml_files: - if xml_file.suffix == ".rels": - continue - - rels_dir = xml_file.parent / "_rels" - rels_file = rels_dir / f"{xml_file.name}.rels" - - if not rels_file.exists(): - continue - - try: - rels_root = lxml.etree.parse(str(rels_file)).getroot() - rid_to_type = {} - - for rel in rels_root.findall( - f".//{{{self.PACKAGE_RELATIONSHIPS_NAMESPACE}}}Relationship" - ): - rid = rel.get("Id") - rel_type = rel.get("Type", "") - if rid: - if rid in rid_to_type: - rels_rel_path = rels_file.relative_to(self.unpacked_dir) - errors.append( - f" {rels_rel_path}: Line {rel.sourceline}: " - f"Duplicate relationship ID '{rid}' (IDs must be unique)" - ) - type_name = ( - rel_type.split("/")[-1] if "/" in rel_type else rel_type - ) - rid_to_type[rid] = type_name - - xml_root = lxml.etree.parse(str(xml_file)).getroot() - - r_ns = self.OFFICE_RELATIONSHIPS_NAMESPACE - rid_attrs_to_check = ["id", "embed", "link"] - for elem in xml_root.iter(): - if not hasattr(elem, "tag") or callable(elem.tag): - continue - for attr_name in rid_attrs_to_check: - rid_attr = elem.get(f"{{{r_ns}}}{attr_name}") - if not rid_attr: - continue - xml_rel_path = xml_file.relative_to(self.unpacked_dir) - elem_name = ( - elem.tag.split("}")[-1] if "}" in elem.tag else elem.tag - ) - - if rid_attr not in rid_to_type: - errors.append( - f" {xml_rel_path}: Line {elem.sourceline}: " - f"<{elem_name}> r:{attr_name} references non-existent relationship '{rid_attr}' " - f"(valid IDs: {', '.join(sorted(rid_to_type.keys())[:5])}{'...' if len(rid_to_type) > 5 else ''})" - ) - elif attr_name == "id" and self.ELEMENT_RELATIONSHIP_TYPES: - expected_type = self._get_expected_relationship_type( - elem_name - ) - if expected_type: - actual_type = rid_to_type[rid_attr] - if expected_type not in actual_type.lower(): - errors.append( - f" {xml_rel_path}: Line {elem.sourceline}: " - f"<{elem_name}> references '{rid_attr}' which points to '{actual_type}' " - f"but should point to a '{expected_type}' relationship" - ) - - except Exception as e: - xml_rel_path = xml_file.relative_to(self.unpacked_dir) - errors.append(f" Error processing {xml_rel_path}: {e}") - - if errors: - print(f"FAILED - Found {len(errors)} relationship ID reference errors:") - for error in errors: - print(error) - print("\nThese ID mismatches will cause the document to appear corrupt!") - return False - else: - if self.verbose: - print("PASSED - All relationship ID references are valid") - return True - - def _get_expected_relationship_type(self, element_name): - elem_lower = element_name.lower() - - if elem_lower in self.ELEMENT_RELATIONSHIP_TYPES: - return self.ELEMENT_RELATIONSHIP_TYPES[elem_lower] - - if elem_lower.endswith("id") and len(elem_lower) > 2: - prefix = elem_lower[:-2] - if prefix.endswith("master"): - return prefix.lower() - elif prefix.endswith("layout"): - return prefix.lower() - else: - if prefix == "sld": - return "slide" - return prefix.lower() - - if elem_lower.endswith("reference") and len(elem_lower) > 9: - prefix = elem_lower[:-9] - return prefix.lower() - - return None - - def validate_content_types(self): - errors = [] - - content_types_file = self.unpacked_dir / "[Content_Types].xml" - if not content_types_file.exists(): - print("FAILED - [Content_Types].xml file not found") - return False - - try: - root = lxml.etree.parse(str(content_types_file)).getroot() - declared_parts = set() - declared_extensions = set() - - for override in root.findall( - f".//{{{self.CONTENT_TYPES_NAMESPACE}}}Override" - ): - part_name = override.get("PartName") - if part_name is not None: - declared_parts.add(part_name.lstrip("/")) - - for default in root.findall( - f".//{{{self.CONTENT_TYPES_NAMESPACE}}}Default" - ): - extension = default.get("Extension") - if extension is not None: - declared_extensions.add(extension.lower()) - - declarable_roots = { - "sld", - "sldLayout", - "sldMaster", - "presentation", - "document", - "workbook", - "worksheet", - "theme", - } - - media_extensions = { - "png": "image/png", - "jpg": "image/jpeg", - "jpeg": "image/jpeg", - "gif": "image/gif", - "bmp": "image/bmp", - "tiff": "image/tiff", - "wmf": "image/x-wmf", - "emf": "image/x-emf", - } - - all_files = list(self.unpacked_dir.rglob("*")) - all_files = [f for f in all_files if f.is_file()] - - for xml_file in self.xml_files: - path_str = str(xml_file.relative_to(self.unpacked_dir)).replace( - "\\", "/" - ) - - if any( - skip in path_str - for skip in [".rels", "[Content_Types]", "docProps/", "_rels/"] - ): - continue - - try: - root_tag = lxml.etree.parse(str(xml_file)).getroot().tag - root_name = root_tag.split("}")[-1] if "}" in root_tag else root_tag - - if root_name in declarable_roots and path_str not in declared_parts: - errors.append( - f" {path_str}: File with <{root_name}> root not declared in [Content_Types].xml" - ) - - except Exception: - continue - - for file_path in all_files: - if file_path.suffix.lower() in {".xml", ".rels"}: - continue - if file_path.name == "[Content_Types].xml": - continue - if "_rels" in file_path.parts or "docProps" in file_path.parts: - continue - - extension = file_path.suffix.lstrip(".").lower() - if extension and extension not in declared_extensions: - if extension in media_extensions: - relative_path = file_path.relative_to(self.unpacked_dir) - errors.append( - f' {relative_path}: File with extension \'{extension}\' not declared in [Content_Types].xml - should add: ' - ) - - except Exception as e: - errors.append(f" Error parsing [Content_Types].xml: {e}") - - if errors: - print(f"FAILED - Found {len(errors)} content type declaration errors:") - for error in errors: - print(error) - return False - else: - if self.verbose: - print( - "PASSED - All content files are properly declared in [Content_Types].xml" - ) - return True - - def validate_file_against_xsd(self, xml_file, verbose=False): - xml_file = Path(xml_file).resolve() - unpacked_dir = self.unpacked_dir.resolve() - - is_valid, current_errors = self._validate_single_file_xsd( - xml_file, unpacked_dir - ) - - if is_valid is None: - return None, set() - elif is_valid: - return True, set() - - original_errors = self._get_original_file_errors(xml_file) - - assert current_errors is not None - new_errors = current_errors - original_errors - - new_errors = { - e for e in new_errors - if not any(pattern in e for pattern in self.IGNORED_VALIDATION_ERRORS) - } - - if new_errors: - if verbose: - relative_path = xml_file.relative_to(unpacked_dir) - print(f"FAILED - {relative_path}: {len(new_errors)} new error(s)") - for error in list(new_errors)[:3]: - truncated = error[:250] + "..." if len(error) > 250 else error - print(f" - {truncated}") - return False, new_errors - else: - if verbose: - print( - f"PASSED - No new errors (original had {len(current_errors)} errors)" - ) - return True, set() - - def validate_against_xsd(self): - new_errors = [] - original_error_count = 0 - valid_count = 0 - skipped_count = 0 - - for xml_file in self.xml_files: - relative_path = str(xml_file.relative_to(self.unpacked_dir)) - is_valid, new_file_errors = self.validate_file_against_xsd( - xml_file, verbose=False - ) - - if is_valid is None: - skipped_count += 1 - continue - elif is_valid and not new_file_errors: - valid_count += 1 - continue - elif is_valid: - original_error_count += 1 - valid_count += 1 - continue - - new_errors.append(f" {relative_path}: {len(new_file_errors)} new error(s)") - for error in list(new_file_errors)[:3]: - new_errors.append( - f" - {error[:250]}..." if len(error) > 250 else f" - {error}" - ) - - if self.verbose: - print(f"Validated {len(self.xml_files)} files:") - print(f" - Valid: {valid_count}") - print(f" - Skipped (no schema): {skipped_count}") - if original_error_count: - print(f" - With original errors (ignored): {original_error_count}") - print( - f" - With NEW errors: {len(new_errors) > 0 and len([e for e in new_errors if not e.startswith(' ')]) or 0}" - ) - - if new_errors: - print("\nFAILED - Found NEW validation errors:") - for error in new_errors: - print(error) - return False - else: - if self.verbose: - print("\nPASSED - No new XSD validation errors introduced") - return True - - def _get_schema_path(self, xml_file): - if xml_file.name in self.SCHEMA_MAPPINGS: - return self.schemas_dir / self.SCHEMA_MAPPINGS[xml_file.name] - - if xml_file.suffix == ".rels": - return self.schemas_dir / self.SCHEMA_MAPPINGS[".rels"] - - if "charts/" in str(xml_file) and xml_file.name.startswith("chart"): - return self.schemas_dir / self.SCHEMA_MAPPINGS["chart"] - - if "theme/" in str(xml_file) and xml_file.name.startswith("theme"): - return self.schemas_dir / self.SCHEMA_MAPPINGS["theme"] - - if xml_file.parent.name in self.MAIN_CONTENT_FOLDERS: - return self.schemas_dir / self.SCHEMA_MAPPINGS[xml_file.parent.name] - - return None - - def _clean_ignorable_namespaces(self, xml_doc): - xml_string = lxml.etree.tostring(xml_doc, encoding="unicode") - xml_copy = lxml.etree.fromstring(xml_string) - - for elem in xml_copy.iter(): - attrs_to_remove = [] - - for attr in elem.attrib: - if "{" in attr: - ns = attr.split("}")[0][1:] - if ns not in self.OOXML_NAMESPACES: - attrs_to_remove.append(attr) - - for attr in attrs_to_remove: - del elem.attrib[attr] - - self._remove_ignorable_elements(xml_copy) - - return lxml.etree.ElementTree(xml_copy) - - def _remove_ignorable_elements(self, root): - elements_to_remove = [] - - for elem in list(root): - if not hasattr(elem, "tag") or callable(elem.tag): - continue - - tag_str = str(elem.tag) - if tag_str.startswith("{"): - ns = tag_str.split("}")[0][1:] - if ns not in self.OOXML_NAMESPACES: - elements_to_remove.append(elem) - continue - - self._remove_ignorable_elements(elem) - - for elem in elements_to_remove: - root.remove(elem) - - def _preprocess_for_mc_ignorable(self, xml_doc): - root = xml_doc.getroot() - - if f"{{{self.MC_NAMESPACE}}}Ignorable" in root.attrib: - del root.attrib[f"{{{self.MC_NAMESPACE}}}Ignorable"] - - return xml_doc - - def _preprocess_for_schema(self, xml_doc, relative_path): - return xml_doc - - def _validate_single_file_xsd(self, xml_file, base_path, schema_path=None): - schema_path = schema_path or self._get_schema_path(xml_file) - if not schema_path: - return None, None - - try: - schema = _load_schema(str(schema_path)) - - with open(xml_file, "r") as f: - xml_doc = lxml.etree.parse(f) - - xml_doc, _ = self._remove_template_tags_from_text_nodes(xml_doc) - xml_doc = self._preprocess_for_mc_ignorable(xml_doc) - - relative_path = xml_file.relative_to(base_path) - if ( - relative_path.parts - and relative_path.parts[0] in self.MAIN_CONTENT_FOLDERS - ): - xml_doc = self._clean_ignorable_namespaces(xml_doc) - - xml_doc = self._preprocess_for_schema(xml_doc, relative_path) - - if schema.validate(xml_doc): - return True, set() - else: - errors = set() - for error in schema.error_log: - errors.add(error.message) - return False, errors - - except Exception as e: - return False, {str(e)} - - def _get_original_file_errors(self, xml_file, schema_path=None): - if self.original_file is None: - return set() - - import tempfile - import zipfile - - xml_file = Path(xml_file).resolve() - unpacked_dir = self.unpacked_dir.resolve() - relative_path = xml_file.relative_to(unpacked_dir) - - with tempfile.TemporaryDirectory() as temp_dir: - temp_path = Path(temp_dir) - - try: - with zipfile.ZipFile(self.original_file, "r") as zip_ref: - safe_extract(zip_ref, temp_path) - except (zipfile.BadZipFile, ValueError, OSError): - return set() - - original_xml_file = temp_path / relative_path - - if not original_xml_file.exists(): - return set() - - is_valid, errors = self._validate_single_file_xsd( - original_xml_file, temp_path, schema_path=schema_path - ) - return errors if errors else set() - - def _remove_template_tags_from_text_nodes(self, xml_doc): - warnings = [] - template_pattern = re.compile(r"\{\{[^}]*\}\}") - - xml_string = lxml.etree.tostring(xml_doc, encoding="unicode") - xml_copy = lxml.etree.fromstring(xml_string) - - def process_text_content(text, content_type): - if not text: - return text - matches = list(template_pattern.finditer(text)) - if matches: - for match in matches: - warnings.append( - f"Found template tag in {content_type}: {match.group()}" - ) - return template_pattern.sub("", text) - return text - - for elem in xml_copy.iter(): - if not hasattr(elem, "tag") or callable(elem.tag): - continue - tag_str = str(elem.tag) - if tag_str.endswith("}t") or tag_str == "t": - continue - - elem.text = process_text_content(elem.text, "text content") - elem.tail = process_text_content(elem.tail, "tail content") - - return lxml.etree.ElementTree(xml_copy), warnings - - -if __name__ == "__main__": - raise RuntimeError("This module should not be run directly.") diff --git a/src/crates/assembly/core/builtin_skills/xlsx/scripts/office/validators/docx.py b/src/crates/assembly/core/builtin_skills/xlsx/scripts/office/validators/docx.py deleted file mode 100644 index 0d18b6979a..0000000000 --- a/src/crates/assembly/core/builtin_skills/xlsx/scripts/office/validators/docx.py +++ /dev/null @@ -1,466 +0,0 @@ -""" -Validator for Word document XML files against XSD schemas. -""" - -import random -import re -import tempfile -import zipfile -from pathlib import Path - -import defusedxml.minidom -import lxml.etree - -from helpers import safe_extract - -from .base import BaseSchemaValidator - - -class DOCXSchemaValidator(BaseSchemaValidator): - - WORD_2006_NAMESPACE = "http://schemas.openxmlformats.org/wordprocessingml/2006/main" - W14_NAMESPACE = "http://schemas.microsoft.com/office/word/2010/wordml" - W16CID_NAMESPACE = "http://schemas.microsoft.com/office/word/2016/wordml/cid" - - ELEMENT_RELATIONSHIP_TYPES = {} - - def validate(self): - if not self.validate_xml(): - return False - - all_valid = True - if not self.validate_namespaces(): - all_valid = False - - if not self.validate_unique_ids(): - all_valid = False - - if not self.validate_file_references(): - all_valid = False - - if not self.validate_content_types(): - all_valid = False - - if not self.validate_against_xsd(): - all_valid = False - - if not self.validate_whitespace_preservation(): - all_valid = False - - if not self.validate_deletions(): - all_valid = False - - if not self.validate_insertions(): - all_valid = False - - if not self.validate_all_relationship_ids(): - all_valid = False - - if not self.validate_id_constraints(): - all_valid = False - - if not self.validate_comment_markers(): - all_valid = False - - self.compare_paragraph_counts() - - return all_valid - - def validate_whitespace_preservation(self): - errors = [] - - for xml_file in self.xml_files: - if xml_file.name != "document.xml": - continue - - try: - root = lxml.etree.parse(str(xml_file)).getroot() - - for elem in root.iter(f"{{{self.WORD_2006_NAMESPACE}}}t"): - if elem.text: - text = elem.text - if re.search(r"^[ \t\n\r]", text) or re.search( - r"[ \t\n\r]$", text - ): - xml_space_attr = f"{{{self.XML_NAMESPACE}}}space" - if ( - xml_space_attr not in elem.attrib - or elem.attrib[xml_space_attr] != "preserve" - ): - text_preview = ( - repr(text)[:50] + "..." - if len(repr(text)) > 50 - else repr(text) - ) - errors.append( - f" {xml_file.relative_to(self.unpacked_dir)}: " - f"Line {elem.sourceline}: w:t element with whitespace missing xml:space='preserve': {text_preview}" - ) - - except (lxml.etree.XMLSyntaxError, Exception) as e: - errors.append( - f" {xml_file.relative_to(self.unpacked_dir)}: Error: {e}" - ) - - if errors: - print(f"FAILED - Found {len(errors)} whitespace preservation violations:") - for error in errors: - print(error) - return False - else: - if self.verbose: - print("PASSED - All whitespace is properly preserved") - return True - - def validate_deletions(self): - errors = [] - - for xml_file in self.xml_files: - if xml_file.name != "document.xml": - continue - - try: - root = lxml.etree.parse(str(xml_file)).getroot() - namespaces = {"w": self.WORD_2006_NAMESPACE} - - for t_elem in root.xpath(".//w:del//w:t", namespaces=namespaces): - if t_elem.text: - text_preview = ( - repr(t_elem.text)[:50] + "..." - if len(repr(t_elem.text)) > 50 - else repr(t_elem.text) - ) - errors.append( - f" {xml_file.relative_to(self.unpacked_dir)}: " - f"Line {t_elem.sourceline}: found within : {text_preview}" - ) - - for instr_elem in root.xpath( - ".//w:del//w:instrText", namespaces=namespaces - ): - text_preview = ( - repr(instr_elem.text or "")[:50] + "..." - if len(repr(instr_elem.text or "")) > 50 - else repr(instr_elem.text or "") - ) - errors.append( - f" {xml_file.relative_to(self.unpacked_dir)}: " - f"Line {instr_elem.sourceline}: found within (use ): {text_preview}" - ) - - except (lxml.etree.XMLSyntaxError, Exception) as e: - errors.append( - f" {xml_file.relative_to(self.unpacked_dir)}: Error: {e}" - ) - - if errors: - print(f"FAILED - Found {len(errors)} deletion validation violations:") - for error in errors: - print(error) - return False - else: - if self.verbose: - print("PASSED - No w:t elements found within w:del elements") - return True - - def count_paragraphs_in_unpacked(self): - count = 0 - - for xml_file in self.xml_files: - if xml_file.name != "document.xml": - continue - - try: - root = lxml.etree.parse(str(xml_file)).getroot() - paragraphs = root.findall(f".//{{{self.WORD_2006_NAMESPACE}}}p") - count = len(paragraphs) - except Exception as e: - print(f"Error counting paragraphs in unpacked document: {e}") - - return count - - def count_paragraphs_in_original(self): - original = self.original_file - if original is None: - return 0 - - count = 0 - - try: - with tempfile.TemporaryDirectory() as temp_dir: - with zipfile.ZipFile(original, "r") as zip_ref: - safe_extract(zip_ref, Path(temp_dir)) - - doc_xml_path = temp_dir + "/word/document.xml" - root = lxml.etree.parse(doc_xml_path).getroot() - - paragraphs = root.findall(f".//{{{self.WORD_2006_NAMESPACE}}}p") - count = len(paragraphs) - - except Exception as e: - print(f"Error counting paragraphs in original document: {e}") - - return count - - def validate_insertions(self): - errors = [] - - for xml_file in self.xml_files: - if xml_file.name != "document.xml": - continue - - try: - root = lxml.etree.parse(str(xml_file)).getroot() - namespaces = {"w": self.WORD_2006_NAMESPACE} - - invalid_elements = root.xpath( - ".//w:ins//w:delText[not(ancestor::w:del)]", namespaces=namespaces - ) - - for elem in invalid_elements: - text_preview = ( - repr(elem.text or "")[:50] + "..." - if len(repr(elem.text or "")) > 50 - else repr(elem.text or "") - ) - errors.append( - f" {xml_file.relative_to(self.unpacked_dir)}: " - f"Line {elem.sourceline}: within : {text_preview}" - ) - - except (lxml.etree.XMLSyntaxError, Exception) as e: - errors.append( - f" {xml_file.relative_to(self.unpacked_dir)}: Error: {e}" - ) - - if errors: - print(f"FAILED - Found {len(errors)} insertion validation violations:") - for error in errors: - print(error) - return False - else: - if self.verbose: - print("PASSED - No w:delText elements within w:ins elements") - return True - - def compare_paragraph_counts(self): - new_count = self.count_paragraphs_in_unpacked() - if self.original_file is None: - print(f"\nParagraphs: {new_count}") - return - - original_count = self.count_paragraphs_in_original() - diff = new_count - original_count - diff_str = f"+{diff}" if diff > 0 else str(diff) - print(f"\nParagraphs: {original_count} → {new_count} ({diff_str})") - - def _parse_id_value(self, val: str, base: int = 16) -> int: - return int(val, base) - - def validate_id_constraints(self): - errors = [] - para_id_attr = f"{{{self.W14_NAMESPACE}}}paraId" - durable_id_attr = f"{{{self.W16CID_NAMESPACE}}}durableId" - - for xml_file in self.xml_files: - try: - for elem in lxml.etree.parse(str(xml_file)).iter(): - if val := elem.get(para_id_attr): - try: - if self._parse_id_value(val, base=16) >= 0x80000000: - errors.append( - f" {xml_file.name}:{elem.sourceline}: paraId={val} >= 0x80000000" - ) - except ValueError: - errors.append( - f" {xml_file.name}:{elem.sourceline}: " - f"paraId={val} is not valid hex" - ) - - if val := elem.get(durable_id_attr): - if xml_file.name == "numbering.xml": - try: - if self._parse_id_value(val, base=10) >= 0x7FFFFFFF: - errors.append( - f" {xml_file.name}:{elem.sourceline}: " - f"durableId={val} >= 0x7FFFFFFF" - ) - except ValueError: - errors.append( - f" {xml_file.name}:{elem.sourceline}: " - f"durableId={val} must be decimal in numbering.xml" - ) - else: - try: - if self._parse_id_value(val, base=16) >= 0x7FFFFFFF: - errors.append( - f" {xml_file.name}:{elem.sourceline}: " - f"durableId={val} >= 0x7FFFFFFF" - ) - except ValueError: - errors.append( - f" {xml_file.name}:{elem.sourceline}: " - f"durableId={val} is not valid hex" - ) - except lxml.etree.XMLSyntaxError: - continue - - if errors: - print(f"FAILED - {len(errors)} ID constraint violations:") - for e in errors: - print(e) - elif self.verbose: - print("PASSED - All paraId/durableId values within constraints") - return not errors - - def validate_comment_markers(self): - errors = [] - - document_xml = None - comments_xml = None - for xml_file in self.xml_files: - if xml_file.name == "document.xml" and "word" in str(xml_file): - document_xml = xml_file - elif xml_file.name == "comments.xml": - comments_xml = xml_file - - if not document_xml: - if self.verbose: - print("PASSED - No document.xml found (skipping comment validation)") - return True - - try: - doc_root = lxml.etree.parse(str(document_xml)).getroot() - namespaces = {"w": self.WORD_2006_NAMESPACE} - - range_starts = { - elem.get(f"{{{self.WORD_2006_NAMESPACE}}}id") - for elem in doc_root.xpath( - ".//w:commentRangeStart", namespaces=namespaces - ) - } - range_ends = { - elem.get(f"{{{self.WORD_2006_NAMESPACE}}}id") - for elem in doc_root.xpath( - ".//w:commentRangeEnd", namespaces=namespaces - ) - } - references = { - elem.get(f"{{{self.WORD_2006_NAMESPACE}}}id") - for elem in doc_root.xpath( - ".//w:commentReference", namespaces=namespaces - ) - } - - orphaned_ends = range_ends - range_starts - for comment_id in sorted( - orphaned_ends, key=lambda x: int(x) if x and x.isdigit() else 0 - ): - errors.append( - f' document.xml: commentRangeEnd id="{comment_id}" has no matching commentRangeStart' - ) - - orphaned_starts = range_starts - range_ends - for comment_id in sorted( - orphaned_starts, key=lambda x: int(x) if x and x.isdigit() else 0 - ): - errors.append( - f' document.xml: commentRangeStart id="{comment_id}" has no matching commentRangeEnd' - ) - - comment_ids = set() - if comments_xml and comments_xml.exists(): - comments_root = lxml.etree.parse(str(comments_xml)).getroot() - comment_ids = { - elem.get(f"{{{self.WORD_2006_NAMESPACE}}}id") - for elem in comments_root.xpath( - ".//w:comment", namespaces=namespaces - ) - } - - marker_ids = range_starts | range_ends | references - invalid_refs = marker_ids - comment_ids - for comment_id in sorted( - invalid_refs, key=lambda x: int(x) if x and x.isdigit() else 0 - ): - if comment_id: - errors.append( - f' document.xml: marker id="{comment_id}" references non-existent comment' - ) - - except (lxml.etree.XMLSyntaxError, Exception) as e: - errors.append(f" Error parsing XML: {e}") - - if errors: - print(f"FAILED - {len(errors)} comment marker violations:") - for error in errors: - print(error) - return False - else: - if self.verbose: - print("PASSED - All comment markers properly paired") - return True - - def repair(self) -> int: - repairs = super().repair() - repairs += self.repair_durableId() - return repairs - - def repair_durableId(self) -> int: - DURABLE_ID_ATTRS = ("w16cid:durableId", "w16cex:durableId") - repairs = 0 - renames: dict = {} - - for xml_file in self.xml_files: - try: - content = xml_file.read_text(encoding="utf-8") - dom = defusedxml.minidom.parseString(content) - is_numbering = xml_file.name == "numbering.xml" - base = 10 if is_numbering else 16 - pending = [] - seen_in_file = set() - modified = False - - for elem in dom.getElementsByTagName("*"): - for attr_name in DURABLE_ID_ATTRS: - if not elem.hasAttribute(attr_name): - continue - - durable_id = elem.getAttribute(attr_name) - try: - key = self._parse_id_value(durable_id, base=base) - needs_repair = key >= 0x7FFFFFFF - except ValueError: - key = durable_id - needs_repair = True - - if needs_repair: - if key in seen_in_file: - value = random.randint(1, 0x7FFFFFFE) - else: - seen_in_file.add(key) - if key not in renames: - renames[key] = random.randint(1, 0x7FFFFFFE) - value = renames[key] - new_id = str(value) if is_numbering else f"{value:08X}" - - elem.setAttribute(attr_name, new_id) - pending.append( - f" Repaired: {xml_file.name}: durableId {durable_id} → {new_id}" - ) - modified = True - - if modified: - xml_file.write_bytes(dom.toxml(encoding="UTF-8")) - for message in pending: - print(message) - repairs += len(pending) - - except Exception: - pass - - return repairs - - -if __name__ == "__main__": - raise RuntimeError("This module should not be run directly.") diff --git a/src/crates/assembly/core/builtin_skills/xlsx/scripts/office/validators/pptx.py b/src/crates/assembly/core/builtin_skills/xlsx/scripts/office/validators/pptx.py deleted file mode 100644 index 7b53d0d3e4..0000000000 --- a/src/crates/assembly/core/builtin_skills/xlsx/scripts/office/validators/pptx.py +++ /dev/null @@ -1,441 +0,0 @@ -""" -Validator for PowerPoint presentation XML files against XSD schemas. -""" - -import re -from pathlib import Path - -from helpers import opc_target, rels_source_part, safe_extract - -from .base import BaseSchemaValidator - - -class PPTXSchemaValidator(BaseSchemaValidator): - - PRESENTATIONML_NAMESPACE = ( - "http://schemas.openxmlformats.org/presentationml/2006/main" - ) - - ELEMENT_RELATIONSHIP_TYPES = { - "sldid": "slide", - "sldmasterid": "slidemaster", - "notesmasterid": "notesmaster", - "sldlayoutid": "slidelayout", - "themeid": "theme", - "tablestyleid": "tablestyles", - } - - def validate(self): - if not self.validate_xml(): - return False - - all_valid = True - if not self.validate_namespaces(): - all_valid = False - - if not self.validate_unique_ids(): - all_valid = False - - if not self.validate_uuid_ids(): - all_valid = False - - if not self.validate_file_references(): - all_valid = False - - if not self.validate_slide_layout_ids(): - all_valid = False - - if not self.validate_content_types(): - all_valid = False - - if not self.validate_against_xsd(): - all_valid = False - - if not self.validate_notes_slide_references(): - all_valid = False - - if not self.validate_all_relationship_ids(): - all_valid = False - - if not self.validate_no_duplicate_slide_layouts(): - all_valid = False - - if not self.validate_master_theme_uniqueness(): - all_valid = False - - if not self.validate_charts(): - all_valid = False - - if not self.validate_slides(): - all_valid = False - - return all_valid - - def _package_map(self) -> dict: - wanted = [] - wanted += list(self.unpacked_dir.glob("[[]Content_Types[]].xml")) - wanted += list(self.unpacked_dir.glob("ppt/presentation.xml")) - wanted += list(self.unpacked_dir.glob("ppt/theme/*.xml")) - wanted += list(self.unpacked_dir.glob("ppt/theme/_rels/*.rels")) - wanted += list(self.unpacked_dir.glob("ppt/charts/chart*.xml")) - for group in ("slideMasters", "notesMasters", "handoutMasters"): - wanted += list(self.unpacked_dir.glob(f"ppt/{group}/*.xml")) - wanted += list(self.unpacked_dir.glob(f"ppt/{group}/_rels/*.rels")) - return { - p.relative_to(self.unpacked_dir).as_posix(): p.read_bytes() - for p in wanted - if p.is_file() - } - - def validate_master_theme_uniqueness(self): - from helpers.pptx_theme import _NOTES_MASTERS, live_shared_master_themes - - shared = live_shared_master_themes(self._package_map()) - if shared: - print(f"FAILED - Found {len(shared)} master(s) sharing a theme part:") - for message in shared: - print(f" {message}") - if any(m.startswith(_NOTES_MASTERS) for m in shared): - print(" Fix: in ppt/presentation.xml, move back to " - "directly after . PowerPoint reads that happily.") - else: - print(" Fix: give each master its own theme part.") - return False - - if self.verbose: - print("PASSED - No master shares a theme part in a way PowerPoint refuses") - return True - - def validate_charts(self): - from helpers.pptx_chart import find_chart_problems - - problems = find_chart_problems(self._package_map()) - if problems: - print(f"FAILED - Found {len(problems)} chart problem(s) PowerPoint rejects:") - for message in problems: - print(f" {message}") - return False - - if self.verbose: - print("PASSED - Charts satisfy the constraints PowerPoint enforces") - return True - - def _original_slide_defects(self, schema) -> set[str]: - import tempfile - import zipfile - - from helpers.pptx_slide import SLIDE_PART_RE, fatal_slide_errors - - if self.original_file is None: - return set() - - found: set[str] = set() - with tempfile.TemporaryDirectory() as temp_dir: - temp_path = Path(temp_dir) - try: - with zipfile.ZipFile(self.original_file, "r") as zf: - safe_extract(zf, temp_path) - except (zipfile.BadZipFile, ValueError, OSError): - return set() - - for part in sorted(temp_path.rglob("*.xml")): - relative = part.relative_to(temp_path).as_posix() - if not SLIDE_PART_RE.fullmatch(relative): - continue - ok, errors = self._validate_single_file_xsd( - part.resolve(), temp_path.resolve(), schema_path=schema - ) - if ok is None or ok or not errors: - continue - found |= set(fatal_slide_errors(set(errors))) - return found - - def validate_slides(self): - from helpers.pptx_slide import ( - SLIDE_PART_RE, - fatal_slide_errors, - is_schema_verdict, - ) - - schema = self.schemas_dir / self.SCHEMA_MAPPINGS["ppt"] - inherited = self._original_slide_defects(schema) - problems: list[str] = [] - broken: list[str] = [] - - for xml_file in self.xml_files: - relative = xml_file.relative_to(self.unpacked_dir).as_posix() - if not SLIDE_PART_RE.fullmatch(relative): - continue - ok, errors = self._validate_single_file_xsd( - xml_file.resolve(), self.unpacked_dir.resolve(), schema_path=schema - ) - if ok is None or not errors: - continue - - unreadable = [f"{relative}: {e}" for e in errors if not is_schema_verdict(e)] - if unreadable: - broken.extend(unreadable) - continue - if ok: - continue - - for message in fatal_slide_errors(set(errors)): - if message in inherited: - continue - problems.append(f"{relative}: {message}") - - if broken: - print(f"FAILED - Could not check {len(broken)} slide part(s):") - for message in sorted(broken): - print(f" {message[:240]}") - - if problems: - print(f"FAILED - Found {len(problems)} slide problem(s) PowerPoint rejects:") - for message in sorted(problems): - print(f" {message[:240]}") - - if broken or problems: - return False - - if self.verbose: - print("PASSED - Slide XML has none of the defects PowerPoint refuses") - return True - - def _get_schema_path(self, xml_file): - if xml_file.parent.name == "charts" and xml_file.name.startswith("chart"): - return None - return super()._get_schema_path(xml_file) - - def _preprocess_for_schema(self, xml_doc, relative_path): - if relative_path.as_posix() != "ppt/presentation.xml": - return xml_doc - - root = xml_doc.getroot() - ns = f"{{{self.PRESENTATIONML_NAMESPACE}}}" - notes = root.find(f"{ns}notesMasterIdLst") - slides = root.find(f"{ns}sldIdLst") - if notes is None or slides is None: - return xml_doc - - children = list(root) - if children.index(notes) < children.index(slides): - return xml_doc - - root.remove(notes) - root.insert(list(root).index(slides), notes) - return xml_doc - - def validate_uuid_ids(self): - import lxml.etree - - errors = [] - uuid_pattern = re.compile( - r"^[\{\(]?[0-9A-Fa-f]{8}-?[0-9A-Fa-f]{4}-?[0-9A-Fa-f]{4}-?[0-9A-Fa-f]{4}-?[0-9A-Fa-f]{12}[\}\)]?$" - ) - - for xml_file in self.xml_files: - try: - root = lxml.etree.parse(str(xml_file)).getroot() - - for elem in root.iter(): - for attr, value in elem.attrib.items(): - attr_name = attr.split("}")[-1].lower() - if attr_name == "id" or attr_name.endswith("id"): - if self._looks_like_uuid(value): - if not uuid_pattern.match(value): - errors.append( - f" {xml_file.relative_to(self.unpacked_dir)}: " - f"Line {elem.sourceline}: ID '{value}' appears to be a UUID but contains invalid hex characters" - ) - - except (lxml.etree.XMLSyntaxError, Exception) as e: - errors.append( - f" {xml_file.relative_to(self.unpacked_dir)}: Error: {e}" - ) - - if errors: - print(f"FAILED - Found {len(errors)} UUID ID validation errors:") - for error in errors: - print(error) - return False - else: - if self.verbose: - print("PASSED - All UUID-like IDs contain valid hex values") - return True - - def _looks_like_uuid(self, value): - clean_value = value.strip("{}()").replace("-", "") - return len(clean_value) == 32 and all(c.isalnum() for c in clean_value) - - def validate_slide_layout_ids(self): - import lxml.etree - - errors = [] - - slide_masters = list(self.unpacked_dir.glob("ppt/slideMasters/*.xml")) - - if not slide_masters: - if self.verbose: - print("PASSED - No slide masters found") - return True - - for slide_master in slide_masters: - try: - root = lxml.etree.parse(str(slide_master)).getroot() - - rels_file = slide_master.parent / "_rels" / f"{slide_master.name}.rels" - - if not rels_file.exists(): - errors.append( - f" {slide_master.relative_to(self.unpacked_dir)}: " - f"Missing relationships file: {rels_file.relative_to(self.unpacked_dir)}" - ) - continue - - rels_root = lxml.etree.parse(str(rels_file)).getroot() - - valid_layout_rids = set() - for rel in rels_root.findall( - f".//{{{self.PACKAGE_RELATIONSHIPS_NAMESPACE}}}Relationship" - ): - rel_type = rel.get("Type", "") - if "slideLayout" in rel_type: - valid_layout_rids.add(rel.get("Id")) - - for sld_layout_id in root.findall( - f".//{{{self.PRESENTATIONML_NAMESPACE}}}sldLayoutId" - ): - r_id = sld_layout_id.get( - f"{{{self.OFFICE_RELATIONSHIPS_NAMESPACE}}}id" - ) - layout_id = sld_layout_id.get("id") - - if r_id and r_id not in valid_layout_rids: - errors.append( - f" {slide_master.relative_to(self.unpacked_dir)}: " - f"Line {sld_layout_id.sourceline}: sldLayoutId with id='{layout_id}' " - f"references r:id='{r_id}' which is not found in slide layout relationships" - ) - - except (lxml.etree.XMLSyntaxError, Exception) as e: - errors.append( - f" {slide_master.relative_to(self.unpacked_dir)}: Error: {e}" - ) - - if errors: - print(f"FAILED - Found {len(errors)} slide layout ID validation errors:") - for error in errors: - print(error) - print( - "Remove invalid references or add missing slide layouts to the relationships file." - ) - return False - else: - if self.verbose: - print("PASSED - All slide layout IDs reference valid slide layouts") - return True - - def validate_no_duplicate_slide_layouts(self): - import lxml.etree - - errors = [] - slide_rels_files = list(self.unpacked_dir.glob("ppt/slides/_rels/*.xml.rels")) - - for rels_file in slide_rels_files: - try: - root = lxml.etree.parse(str(rels_file)).getroot() - - layout_rels = [ - rel - for rel in root.findall( - f".//{{{self.PACKAGE_RELATIONSHIPS_NAMESPACE}}}Relationship" - ) - if "slideLayout" in rel.get("Type", "") - ] - - if len(layout_rels) > 1: - errors.append( - f" {rels_file.relative_to(self.unpacked_dir)}: has {len(layout_rels)} slideLayout references" - ) - - except Exception as e: - errors.append( - f" {rels_file.relative_to(self.unpacked_dir)}: Error: {e}" - ) - - if errors: - print("FAILED - Found slides with duplicate slideLayout references:") - for error in errors: - print(error) - return False - else: - if self.verbose: - print("PASSED - All slides have exactly one slideLayout reference") - return True - - def validate_notes_slide_references(self): - import lxml.etree - - errors = [] - notes_slide_references = {} - - slide_rels_files = list(self.unpacked_dir.glob("ppt/slides/_rels/*.xml.rels")) - - if not slide_rels_files: - if self.verbose: - print("PASSED - No slide relationship files found") - return True - - for rels_file in slide_rels_files: - try: - root = lxml.etree.parse(str(rels_file)).getroot() - - for rel in root.findall( - f".//{{{self.PACKAGE_RELATIONSHIPS_NAMESPACE}}}Relationship" - ): - rel_type = rel.get("Type", "") - if "notesSlide" in rel_type: - part = opc_target( - rel.get("Target", ""), - rels_source_part(rels_file, self.unpacked_dir), - rel.get("TargetMode", ""), - ) - if part: - slide_name = rels_file.stem.replace( - ".xml", "" - ) - - notes_slide_references.setdefault(part, []).append( - (slide_name, rels_file) - ) - - except (lxml.etree.XMLSyntaxError, Exception) as e: - errors.append( - f" {rels_file.relative_to(self.unpacked_dir)}: Error: {e}" - ) - - for target, references in notes_slide_references.items(): - if len(references) > 1: - slide_names = [ref[0] for ref in references] - errors.append( - f" Notes slide '{target}' is referenced by multiple slides: {', '.join(slide_names)}" - ) - for slide_name, rels_file in references: - errors.append(f" - {rels_file.relative_to(self.unpacked_dir)}") - - if errors: - print( - f"FAILED - Found {len([e for e in errors if not e.startswith(' ')])} notes slide reference validation errors:" - ) - for error in errors: - print(error) - print("Each slide may optionally have its own slide file.") - return False - else: - if self.verbose: - print("PASSED - All notes slide references are unique") - return True - - -if __name__ == "__main__": - raise RuntimeError("This module should not be run directly.") diff --git a/src/crates/assembly/core/builtin_skills/xlsx/scripts/office/validators/redlining.py b/src/crates/assembly/core/builtin_skills/xlsx/scripts/office/validators/redlining.py deleted file mode 100644 index 18d0c68be9..0000000000 --- a/src/crates/assembly/core/builtin_skills/xlsx/scripts/office/validators/redlining.py +++ /dev/null @@ -1,299 +0,0 @@ -""" -Validator for tracked changes in Word documents. - -Detects untracked edits in word/document.xml: text that differs from the -original without a / wrapper recording it. The tracked changes -that are new relative to the original are undone, and the result is compared -against the original; whatever text still differs was edited without being -tracked. - -Only the document body is compared. Headers, footers, footnotes and endnotes -are separate parts and are not checked. -""" - -import subprocess -import tempfile -import zipfile -from pathlib import Path - -import defusedxml.ElementTree as ET -from defusedxml.common import DefusedXmlException - -from helpers import rendered_text, safe_extract - - -class RedliningValidator: - - def __init__(self, unpacked_dir, original_docx, verbose=False): - self.unpacked_dir = Path(unpacked_dir) - self.original_docx = Path(original_docx) - self.verbose = verbose - self.namespaces = { - "w": "http://schemas.openxmlformats.org/wordprocessingml/2006/main" - } - - def repair(self) -> int: - return 0 - - def validate(self): - modified_file = self.unpacked_dir / "word" / "document.xml" - if not modified_file.exists(): - print(f"FAILED - Modified document.xml not found at {modified_file}") - return False - - with tempfile.TemporaryDirectory() as temp_dir: - temp_path = Path(temp_dir) - - try: - with zipfile.ZipFile(self.original_docx, "r") as zip_ref: - safe_extract(zip_ref, temp_path) - except Exception as e: - print(f"FAILED - Error unpacking original docx: {e}") - return False - - original_file = temp_path / "word" / "document.xml" - if not original_file.exists(): - print( - f"FAILED - Original document.xml not found in {self.original_docx}" - ) - return False - - try: - modified_tree = ET.parse(modified_file) - modified_root = modified_tree.getroot() - original_tree = ET.parse(original_file) - original_root = original_tree.getroot() - except (ET.ParseError, DefusedXmlException) as e: - print(f"FAILED - Error parsing XML files: {e}") - return False - - new_changes = self._new_tracked_changes(original_root, modified_root) - self._remove_tracked_changes(modified_root, new_changes) - - modified_text = self._extract_text_content(modified_root) - original_text = self._extract_text_content(original_root) - - if modified_text != original_text: - error_message = self._generate_detailed_diff( - original_text, modified_text - ) - print(error_message) - return False - - if self.verbose: - print( - f"PASSED - All {len(new_changes)} change(s) against the original " - "are properly tracked" - ) - return True - - def _tracked_change_elements(self, root): - ins_tag = f"{{{self.namespaces['w']}}}ins" - del_tag = f"{{{self.namespaces['w']}}}del" - return [elem for elem in root.iter() if elem.tag in (ins_tag, del_tag)] - - def _rendered_text(self, elem): - preserve = elem.get("{http://www.w3.org/XML/1998/namespace}space") == "preserve" - return rendered_text(elem.text or "", preserve) - - def _text_elements(self, elem): - w = self.namespaces["w"] - return [ - node - for node in elem.iter() - if node.tag in (f"{{{w}}}t", f"{{{w}}}delText") - ] - - def _tracked_change_key(self, elem): - w = self.namespaces["w"] - text = "".join(self._rendered_text(node) for node in self._text_elements(elem)) - return (elem.tag, elem.get(f"{{{w}}}author"), elem.get(f"{{{w}}}date"), text) - - def _new_tracked_changes(self, original_root, modified_root): - original = self._tracked_change_elements(original_root) - modified = self._tracked_change_elements(modified_root) - - pool = {} - for elem in original: - pool.setdefault(self._tracked_change_key(elem), []).append(elem) - - matched, leftover = set(), [] - for elem in modified: - bucket = pool.get(self._tracked_change_key(elem)) - if bucket: - matched.add(bucket.pop()) - else: - leftover.append(elem) - - def group(elem): - return self._tracked_change_key(elem)[:3] - - def text_of(elems): - return "".join(self._tracked_change_key(e)[3] for e in elems) - - unmatched_original = {} - for elem in original: - if elem not in matched: - unmatched_original.setdefault(group(elem), []).append(elem) - - by_group = {} - for elem in leftover: - by_group.setdefault(group(elem), []).append(elem) - - new = set() - for key, elems in by_group.items(): - rebuilt = text_of(elems) - if rebuilt and rebuilt == text_of(unmatched_original.get(key, [])): - continue - new.update(elems) - return new - - def _generate_detailed_diff(self, original_text, modified_text): - error_parts = [ - "FAILED - Document text doesn't match after removing the tracked changes", - "", - "Likely causes:", - " 1. Modified text inside another author's or tags", - " 2. Made edits without proper tracked changes", - " 3. Didn't nest inside when deleting another's insertion", - " 4. Rewrote another author's / and changed its text on", - " the way. A tracked change from the original is recognised by its", - " author, date and text; anything that doesn't reproduce one exactly", - " reads as new, and the text it carried is reported missing.", - "", - "For pre-redlined documents, use correct patterns:", - " - To reject another's INSERTION: Nest inside their ", - " - To reject PART of one: nest around only the runs you reject.", - " Their may be split around it, so long as the pieces keep", - " their author and date and still spell out the same text.", - " - To restore another's DELETION: Add new AFTER their ", - "", - ] - - git_diff = self._get_git_word_diff(original_text, modified_text) - if git_diff: - error_parts.extend(["Differences:", "============", git_diff]) - else: - error_parts.append("Unable to generate word diff (git not available)") - - return "\n".join(error_parts) - - def _get_git_word_diff(self, original_text, modified_text): - try: - with tempfile.TemporaryDirectory() as temp_dir: - temp_path = Path(temp_dir) - - original_file = temp_path / "original.txt" - modified_file = temp_path / "modified.txt" - - original_file.write_text(original_text, encoding="utf-8") - modified_file.write_text(modified_text, encoding="utf-8") - - result = subprocess.run( - [ - "git", - "diff", - "--word-diff=plain", - "--word-diff-regex=.", - "-U0", - "--no-index", - str(original_file), - str(modified_file), - ], - capture_output=True, - text=True, - ) - - if result.stdout.strip(): - lines = result.stdout.split("\n") - content_lines = [] - in_content = False - for line in lines: - if line.startswith("@@"): - in_content = True - continue - if in_content and line.strip(): - content_lines.append(line) - - if content_lines: - return "\n".join(content_lines) - - result = subprocess.run( - [ - "git", - "diff", - "--word-diff=plain", - "-U0", - "--no-index", - str(original_file), - str(modified_file), - ], - capture_output=True, - text=True, - ) - - if result.stdout.strip(): - lines = result.stdout.split("\n") - content_lines = [] - in_content = False - for line in lines: - if line.startswith("@@"): - in_content = True - continue - if in_content and line.strip(): - content_lines.append(line) - return "\n".join(content_lines) - - except (subprocess.CalledProcessError, FileNotFoundError, Exception): - pass - - return None - - def _remove_tracked_changes(self, root, targets): - ins_tag = f"{{{self.namespaces['w']}}}ins" - del_tag = f"{{{self.namespaces['w']}}}del" - - for parent in root.iter(): - to_remove = [] - for child in parent: - if child.tag == ins_tag and child in targets: - to_remove.append(child) - for elem in to_remove: - parent.remove(elem) - - deltext_tag = f"{{{self.namespaces['w']}}}delText" - t_tag = f"{{{self.namespaces['w']}}}t" - - for parent in root.iter(): - to_process = [] - for child in parent: - if child.tag == del_tag and child in targets: - to_process.append((child, list(parent).index(child))) - - for del_elem, del_index in reversed(to_process): - for elem in del_elem.iter(): - if elem.tag == deltext_tag: - elem.tag = t_tag - - for child in reversed(list(del_elem)): - parent.insert(del_index, child) - parent.remove(del_elem) - - def _extract_text_content(self, root): - p_tag = f"{{{self.namespaces['w']}}}p" - t_tag = f"{{{self.namespaces['w']}}}t" - - paragraphs = [] - for p_elem in root.findall(f".//{p_tag}"): - text_parts = [] - for t_elem in p_elem.findall(f".//{t_tag}"): - text_parts.append(self._rendered_text(t_elem)) - paragraph_text = "".join(text_parts) - if paragraph_text: - paragraphs.append(paragraph_text) - - return "\n".join(paragraphs) - - -if __name__ == "__main__": - raise RuntimeError("This module should not be run directly.") diff --git a/src/crates/assembly/core/builtin_skills/xlsx/scripts/recalc.py b/src/crates/assembly/core/builtin_skills/xlsx/scripts/recalc.py deleted file mode 100755 index ba6d0c3ad1..0000000000 --- a/src/crates/assembly/core/builtin_skills/xlsx/scripts/recalc.py +++ /dev/null @@ -1,308 +0,0 @@ -""" -Excel Formula Recalculation Script -Recalculates all formulas in an Excel file using LibreOffice -""" - -import contextlib -import json -import os -import platform -import re -import shutil -import subprocess -import sys -import tempfile -import time -import zipfile -from pathlib import Path - -from office.soffice import get_soffice_env, run_soffice - -from openpyxl import load_workbook - -MACRO_FILENAME = "Module1.xba" -SOFFICE_MISSING = "soffice not found on PATH; LibreOffice is required to recalculate" - -MAX_LOCATIONS = 100 - -EXTERNAL_REF_RE = re.compile(r"""(? - - - Sub RecalculateAndSave() - ThisComponent.calculateAll() - ThisComponent.store() - ThisComponent.close(True) - End Sub -""" - - -def has_gtimeout(): - try: - subprocess.run( - ["gtimeout", "--version"], capture_output=True, timeout=1, check=False - ) - return True - except (FileNotFoundError, subprocess.TimeoutExpired): - return False - - -def _stamp(path): - st = os.stat(path) - return st.st_mtime_ns, st.st_size - - -def setup_libreoffice_macro(profile_dir: Path, timeout=30): - url = profile_dir.as_uri() - try: - run_soffice( - ["--headless", "--terminate_after_init", f"-env:UserInstallation={url}"], - capture_output=True, - timeout=timeout, - ) - except FileNotFoundError: - return None, SOFFICE_MISSING - except subprocess.TimeoutExpired: - return None, "LibreOffice timed out creating its profile; formulas were NOT recalculated" - - macro_dir = profile_dir / "user" / "basic" / "Standard" - if not macro_dir.exists(): - return None, "LibreOffice did not create a usable profile; formulas were NOT recalculated" - - try: - (macro_dir / MACRO_FILENAME).write_text(RECALCULATE_MACRO) - except OSError as e: - return None, f"Could not install the recalculation macro: {e}" - - return url, None - - -def external_links_at_risk(filename): - try: - with zipfile.ZipFile(filename) as archive: - names = archive.namelist() - except (zipfile.BadZipFile, OSError): - return [] - if not any(n.startswith("xl/externalLinks/") for n in names): - return [] - - with contextlib.ExitStack() as stack: - formulas = load_workbook(filename, data_only=False) - stack.callback(formulas.close) - values = load_workbook(filename, data_only=True) - stack.callback(values.close) - - external_names = [ - name - for name, dn in formulas.defined_names.items() - if isinstance(getattr(dn, "value", None), str) and EXTERNAL_REF_RE.search(dn.value) - ] - name_re = ( - re.compile(r"\b(" + "|".join(re.escape(n) for n in external_names) + r")\b") - if external_names - else None - ) - - at_risk = [] - for sheet in formulas.sheetnames: - ws = formulas[sheet] - if not hasattr(ws, "iter_rows"): - continue - cached = values[sheet] - for row in ws.iter_rows(): - for cell in row: - v = cell.value - if not (isinstance(v, str) and v.startswith("=")): - continue - reaches_out = EXTERNAL_REF_RE.search(v) or (name_re and name_re.search(v)) - if reaches_out and cached[cell.coordinate].value is None: - at_risk.append(f"{sheet}!{cell.coordinate}") - return at_risk - - -def recalc(filename, timeout=30, force=False): - if not Path(filename).exists(): - return {"error": f"File {filename} does not exist"} - - abs_path = str(Path(filename).absolute()) - - if not os.access(abs_path, os.W_OK): - return {"error": f"{filename} is not writable; recalculation rewrites the file in place"} - - try: - get_soffice_env() - except Exception as e: - return {"error": f"Could not prepare the LibreOffice environment: {e}"} - - if not force: - try: - at_risk = external_links_at_risk(filename) - except Exception as e: - return {"error": f"Could not inspect {filename} for external links: {e}"} - if at_risk: - shown = at_risk[:MAX_LOCATIONS] - return { - "error": ( - "Refusing to recalculate: this workbook links to another workbook, and " - f"{len(at_risk)} linked cell(s) have lost their cached value (openpyxl strips " - "these on save). Recalculating would resolve them to #NAME? and delete the " - "external links for good. Copy those cells' values from the original file " - "before saving, or pass --force to accept the loss. Charts and conditional " - "formats can hold external references too, so this list may not be exhaustive." - ), - "external_link_cells": shown, - "external_link_cells_truncated": max(0, len(at_risk) - len(shown)), - } - - with tempfile.TemporaryDirectory( - prefix="recalc-lo-profile-", ignore_cleanup_errors=True - ) as profile_dir: - return _recalc_with_profile(filename, abs_path, timeout, Path(profile_dir)) - - -def _recalc_with_profile(filename, abs_path, timeout, profile_dir: Path): - started = time.monotonic() - profile_url, err = setup_libreoffice_macro(profile_dir, timeout=timeout) - if err: - return {"error": err} - - timeout = max(5, int(timeout - (time.monotonic() - started))) - - before = _stamp(abs_path) - - cmd = [ - "soffice", - "--headless", - "--norestore", - f"-env:UserInstallation={profile_url}", - "vnd.sun.star.script:Standard.Module1.RecalculateAndSave?language=Basic&location=application", - abs_path, - ] - - if platform.system() == "Linux" and shutil.which("timeout"): - cmd = ["timeout", str(timeout)] + cmd - elif platform.system() == "Darwin" and has_gtimeout(): - cmd = ["gtimeout", str(timeout)] + cmd - - timed_out = f"LibreOffice timed out after {timeout}s; formulas were NOT recalculated. Re-run with a longer timeout." - - try: - result = subprocess.run( - cmd, capture_output=True, text=True, env=get_soffice_env(), timeout=timeout + 15 - ) - except subprocess.TimeoutExpired: - return {"error": timed_out} - except FileNotFoundError: - return {"error": SOFFICE_MISSING} - - if result.returncode == 124: - return {"error": timed_out} - - if result.returncode != 0: - detail = (result.stderr or "").strip() or f"soffice exited {result.returncode}" - return {"error": f"LibreOffice failed to recalculate: {detail}"} - - if _stamp(abs_path) == before: - return { - "error": ( - "LibreOffice exited cleanly but never rewrote the file, so nothing was " - "recalculated. Check that no other LibreOffice instance is running, then retry." - ) - } - - try: - wb = load_workbook(filename, data_only=True) - - excel_errors = [ - "#VALUE!", - "#DIV/0!", - "#REF!", - "#NAME?", - "#NULL!", - "#NUM!", - "#N/A", - ] - error_details = {err: [] for err in excel_errors} - total_errors = 0 - - for sheet_name in wb.sheetnames: - ws = wb[sheet_name] - if not hasattr(ws, "iter_rows"): - continue - for row in ws.iter_rows(): - for cell in row: - if cell.value is not None and isinstance(cell.value, str): - for err in excel_errors: - if err in cell.value: - location = f"{sheet_name}!{cell.coordinate}" - error_details[err].append(location) - total_errors += 1 - break - - result = { - "status": "success" if total_errors == 0 else "errors_found", - "total_errors": total_errors, - "error_summary": {}, - } - - for err_type, locations in error_details.items(): - if locations: - entry = {"count": len(locations), "locations": locations[:MAX_LOCATIONS]} - if len(locations) > MAX_LOCATIONS: - entry["locations_truncated"] = len(locations) - MAX_LOCATIONS - result["error_summary"][err_type] = entry - - wb.close() - - wb_formulas = load_workbook(filename, data_only=False) - formula_count = 0 - for sheet_name in wb_formulas.sheetnames: - ws = wb_formulas[sheet_name] - if not hasattr(ws, "iter_rows"): - continue - for row in ws.iter_rows(): - for cell in row: - if ( - cell.value - and isinstance(cell.value, str) - and cell.value.startswith("=") - ): - formula_count += 1 - wb_formulas.close() - - result["total_formulas"] = formula_count - - return result - - except Exception as e: - return {"error": str(e)} - - -def main(): - args = [a for a in sys.argv[1:] if a != "--force"] - force = "--force" in sys.argv[1:] - - if not args: - print("Usage: python recalc.py [timeout_seconds] [--force]") - print("\nRecalculates all formulas in an Excel file using LibreOffice") - print("\nReturns JSON with error details:") - print(" - status: 'success' or 'errors_found'") - print(" - total_errors: Total number of Excel errors found") - print(" - total_formulas: Number of formulas in the file") - print(" - error_summary: Breakdown by error type with locations") - print(" - #VALUE!, #DIV/0!, #REF!, #NAME?, #NULL!, #NUM!, #N/A") - print("\nOn any failure the JSON has an 'error' key and no 'status'.") - print("--force recalculates even when it would destroy external links.") - sys.exit(1) - - filename = args[0] - timeout = int(args[1]) if len(args) > 1 else 30 - - result = recalc(filename, timeout, force=force) - print(json.dumps(result, indent=2)) - sys.exit(1 if "error" in result else 0) - - -if __name__ == "__main__": - main() diff --git a/src/crates/assembly/core/src/agentic/tools/implementations/skill_tool.rs b/src/crates/assembly/core/src/agentic/tools/implementations/skill_tool.rs index 05bc5acfec..71ee6c1bdc 100644 --- a/src/crates/assembly/core/src/agentic/tools/implementations/skill_tool.rs +++ b/src/crates/assembly/core/src/agentic/tools/implementations/skill_tool.rs @@ -34,9 +34,8 @@ How to use skills: - Pass user-provided invocation text relevant to the skill through `arguments`; never copy an `argument-hint` into arguments - The skill's prompt will expand and provide detailed instructions on how to complete the task - Examples: - - `command: "pdf"` - invoke the pdf skill + - `command: "writing-skills"` - invoke the writing-skills skill - `command: "review", arguments: "src/main.rs carefully"` - invoke a skill with arguments - - `command: "xlsx"` - invoke the xlsx skill - `command: "user::bitfun-system::ppt-design"` - invoke a specific built-in skill by stable key Important: @@ -137,7 +136,7 @@ impl Tool for SkillTool { "properties": { "command": { "type": "string", - "description": "The skill name or stable key. E.g., \"pdf\" or \"user::bitfun-system::ppt-design\"" + "description": "The skill name or stable key. E.g., \"writing-skills\" or \"user::bitfun-system::ppt-design\"" }, "arguments": { "type": "string", diff --git a/src/crates/assembly/core/src/agentic/tools/implementations/skills/builtin.rs b/src/crates/assembly/core/src/agentic/tools/implementations/skills/builtin.rs index dbc9759b85..6b5bf38af5 100644 --- a/src/crates/assembly/core/src/agentic/tools/implementations/skills/builtin.rs +++ b/src/crates/assembly/core/src/agentic/tools/implementations/skills/builtin.rs @@ -25,6 +25,11 @@ const BUILTIN_SKILLS_MANIFEST_FILE_NAME: &str = ".manifest.json"; const BUILTIN_SKILLS_INSTALL_LOCK_FILE_NAME: &str = ".system.install.lock"; const BUILTIN_SKILLS_STAGING_PREFIX: &str = ".system.tmp"; const LEGACY_BUILTIN_SKILL_DIR_NAMES: &[&str] = &[ + // Redistribution-restricted upstream skills removed in 2026-08. + "docx", + "pdf", + "pptx", + "xlsx", // Historical bundled "Superpowers" skills removed in 2026-04. "brainstorming", "dispatching-parallel-agents", @@ -367,7 +372,7 @@ async fn desired_file_content( #[cfg(test)] mod tests { - use super::{collect_files, BUILTIN_SKILLS_DIR}; + use super::{BUILTIN_SKILLS_DIR, LEGACY_BUILTIN_SKILL_DIR_NAMES}; fn embedded_skill_text(path: &str) -> &'static str { BUILTIN_SKILLS_DIR @@ -552,79 +557,15 @@ mod tests { } #[test] - fn office_helpers_use_validated_archive_extraction() { - for skill in ["docx", "pptx", "xlsx"] { - let helper_path = format!("{skill}/scripts/office/helpers/__init__.py"); - let helper = embedded_skill_text(&helper_path); + fn redistribution_restricted_skills_are_not_embedded() { + for skill in ["docx", "pdf", "pptx", "xlsx"] { assert!( - helper.contains("def safe_extract("), - "{helper_path} lacks safe_extract" + BUILTIN_SKILLS_DIR.get_dir(skill).is_none(), + "redistribution-restricted skill {skill} must not be embedded" ); assert!( - helper.contains("stat.S_ISLNK"), - "{helper_path} lacks symlink rejection" - ); - assert!( - helper.contains("MAX_ARCHIVE_TOTAL_SIZE") - && helper.contains("MAX_ARCHIVE_COMPRESSION_RATIO") - && helper.contains("duplicate archive entry"), - "{helper_path} lacks bounded, collision-safe extraction" - ); - - let dir = BUILTIN_SKILLS_DIR - .get_dir(skill) - .unwrap_or_else(|| panic!("Missing embedded Office skill {skill}")); - let mut files = Vec::new(); - collect_files(dir, &mut files); - for file in files { - let text = file.contents_utf8().unwrap_or(""); - assert!( - !text.contains(".extractall("), - "{} still uses unrestricted ZipFile.extractall", - file.path().display() - ); - } - - assert!(dir - .get_file(format!("{skill}/scripts/office/pack.py")) - .is_none()); - assert!(dir - .get_file(format!("{skill}/scripts/office/unpack.py")) - .is_none()); - - if matches!(skill, "docx" | "pptx") { - let skill_text = embedded_skill_text(&format!("{skill}/SKILL.md")); - assert!( - skill_text.contains("safe_extract") && skill_text.contains("rezip"), - "{skill}/SKILL.md must use the cross-platform safe archive helpers" - ); - assert!( - !skill_text.contains("unzip -q") && !skill_text.contains("zip -Xr"), - "{skill}/SKILL.md still recommends unsafe or non-portable archive commands" - ); - } - } - - let comment = embedded_skill_text("docx/scripts/comment.py"); - assert!(comment.contains("author: str = \"BitFun\"")); - assert!(comment.contains("initials: str = \"B\"")); - assert!(comment.contains("default=\"BitFun\"")); - assert!(comment.contains("default=\"B\"")); - - let docx_skill = embedded_skill_text("docx/SKILL.md"); - assert!(docx_skill.contains( - "Use \"BitFun\" as the author for tracked changes and comments unless the user explicitly requests a different name." - )); - - let xlsx_skill = embedded_skill_text("xlsx/SKILL.md"); - assert!(xlsx_skill.contains("years as text (`\"2026\"`, never `2,026`)")); - - let docx_helper = embedded_skill_text("docx/scripts/office/helpers/__init__.py"); - for skill in ["pptx", "xlsx"] { - assert_eq!( - docx_helper, - embedded_skill_text(&format!("{skill}/scripts/office/helpers/__init__.py")), - "Office safe extraction helpers drifted between bundled skills" + LEGACY_BUILTIN_SKILL_DIR_NAMES.contains(&skill), + "removed skill {skill} must be cleaned from legacy user skill roots" ); } } diff --git a/src/crates/assembly/core/src/agentic/tools/implementations/skills/catalog.rs b/src/crates/assembly/core/src/agentic/tools/implementations/skills/catalog.rs index 009c0a4263..ff43b4b58f 100644 --- a/src/crates/assembly/core/src/agentic/tools/implementations/skills/catalog.rs +++ b/src/crates/assembly/core/src/agentic/tools/implementations/skills/catalog.rs @@ -11,11 +11,10 @@ mod tests { #[test] fn builtin_skill_groups_match_expected_sets() { - assert_eq!(builtin_skill_group_key("docx"), Some("office")); - assert_eq!(builtin_skill_group_key("pdf"), Some("office")); assert_eq!(builtin_skill_group_key("ppt-design"), Some("office")); - assert_eq!(builtin_skill_group_key("pptx"), Some("office")); - assert_eq!(builtin_skill_group_key("xlsx"), Some("office")); + for removed in ["docx", "pdf", "pptx", "xlsx"] { + assert_eq!(builtin_skill_group_key(removed), None); + } assert_eq!(builtin_skill_group_key("create-bitfun-skin"), Some("meta")); assert_eq!(builtin_skill_group_key("find-skills"), Some("meta")); assert_eq!(builtin_skill_group_key("miniapp-dev"), Some("miniapp")); diff --git a/src/crates/assembly/core/src/agentic/tools/implementations/skills/policy.rs b/src/crates/assembly/core/src/agentic/tools/implementations/skills/policy.rs index 417fa32ff2..063ac0480f 100644 --- a/src/crates/assembly/core/src/agentic/tools/implementations/skills/policy.rs +++ b/src/crates/assembly/core/src/agentic/tools/implementations/skills/policy.rs @@ -10,10 +10,6 @@ mod tests { #[test] fn builtin_defaults_follow_mode_policies() { - assert_eq!( - resolve_builtin_default_enabled("pdf", "agentic"), - Some(false) - ); assert_eq!( resolve_builtin_default_enabled("ppt-design", "agentic"), Some(false) @@ -26,7 +22,6 @@ mod tests { resolve_builtin_default_enabled("agent-browser", "agentic"), Some(false) ); - assert_eq!(resolve_builtin_default_enabled("pdf", "Cowork"), Some(true)); assert_eq!( resolve_builtin_default_enabled("agent-browser", "Cowork"), Some(false) @@ -35,7 +30,10 @@ mod tests { resolve_builtin_default_enabled("gstack-review", "Team"), Some(true) ); - assert_eq!(resolve_builtin_default_enabled("pdf", "Team"), Some(false)); + assert_eq!( + resolve_builtin_default_enabled("ppt-design", "Team"), + Some(false) + ); assert_eq!( resolve_builtin_default_enabled("miniapp-dev", "Team"), Some(false) @@ -45,23 +43,29 @@ mod tests { Some(true) ); assert_eq!( - resolve_builtin_default_enabled("pdf", "DeepResearch"), + resolve_builtin_default_enabled("ppt-design", "DeepResearch"), Some(false) ); assert_eq!( resolve_builtin_default_enabled("agent-browser", "Claw"), Some(false) ); - assert_eq!(resolve_builtin_default_enabled("pdf", "Claw"), Some(false)); + assert_eq!( + resolve_builtin_default_enabled("ppt-design", "Claw"), + Some(false) + ); assert_eq!( resolve_builtin_default_enabled("agent-browser", "coding_shared"), Some(false) ); assert_eq!( - resolve_builtin_default_enabled("pdf", "coding_shared"), + resolve_builtin_default_enabled("ppt-design", "coding_shared"), + Some(false) + ); + assert_eq!( + resolve_builtin_default_enabled("ppt-design", "Other"), Some(false) ); - assert_eq!(resolve_builtin_default_enabled("pdf", "Other"), Some(false)); } #[test] diff --git a/src/crates/assembly/core/src/agentic/tools/implementations/skills/resolver.rs b/src/crates/assembly/core/src/agentic/tools/implementations/skills/resolver.rs index 8af83f3ef7..2fbe7b80c3 100644 --- a/src/crates/assembly/core/src/agentic/tools/implementations/skills/resolver.rs +++ b/src/crates/assembly/core/src/agentic/tools/implementations/skills/resolver.rs @@ -60,14 +60,20 @@ mod tests { #[test] fn builtin_default_state_follows_policy() { - let pdf = builtin_skill("pdf"); + let presentation = builtin_skill("ppt-design"); let browser = builtin_skill("agent-browser"); - assert!(!resolve_skill_default_enabled_for_mode(&pdf, "agentic")); + assert!(!resolve_skill_default_enabled_for_mode( + &presentation, + "agentic" + )); // agent-browser is opt-in everywhere: ControlHub's browser domain is // the default browser-automation path. assert!(!resolve_skill_default_enabled_for_mode(&browser, "agentic")); - assert!(resolve_skill_default_enabled_for_mode(&pdf, "Cowork")); + assert!(resolve_skill_default_enabled_for_mode( + &presentation, + "Cowork" + )); assert!(!resolve_skill_default_enabled_for_mode(&browser, "Cowork")); } @@ -88,21 +94,21 @@ mod tests { #[test] fn overrides_apply_on_top_of_defaults() { - let pdf = builtin_skill("pdf"); + let presentation = builtin_skill("ppt-design"); let mut overrides = UserModeSkillOverrides::default(); let disabled_project = HashSet::new(); let disabled_state = - resolve_skill_state_for_mode(&pdf, "agentic", &overrides, &disabled_project); + resolve_skill_state_for_mode(&presentation, "agentic", &overrides, &disabled_project); assert!(!disabled_state.effective_enabled); assert_eq!( disabled_state.reason, ModeSkillStateReason::BuiltinPolicyDisabled ); - overrides.enabled_skills.push(pdf.key.clone()); + overrides.enabled_skills.push(presentation.key.clone()); let enabled_state = - resolve_skill_state_for_mode(&pdf, "agentic", &overrides, &disabled_project); + resolve_skill_state_for_mode(&presentation, "agentic", &overrides, &disabled_project); assert!(enabled_state.effective_enabled); assert_eq!( enabled_state.reason, diff --git a/src/crates/assembly/core/src/service/config/mode_config_canonicalizer.rs b/src/crates/assembly/core/src/service/config/mode_config_canonicalizer.rs index b07f45bf90..0a85c55927 100644 --- a/src/crates/assembly/core/src/service/config/mode_config_canonicalizer.rs +++ b/src/crates/assembly/core/src/service/config/mode_config_canonicalizer.rs @@ -590,18 +590,24 @@ mod tests { fn normalize_skill_override_lists_removes_duplicates_and_conflicts() { let (disabled, enabled) = normalize_skill_override_lists( vec![ - "user::bitfun-system::pdf".to_string(), - "user::bitfun-system::pdf".to_string(), + "user::bitfun-system::ppt-design".to_string(), + "user::bitfun-system::ppt-design".to_string(), ], vec![ - "user::bitfun-system::pdf".to_string(), - "user::bitfun-system::docx".to_string(), - "user::bitfun-system::docx".to_string(), + "user::bitfun-system::ppt-design".to_string(), + "user::bitfun-system::agent-browser".to_string(), + "user::bitfun-system::agent-browser".to_string(), ], ); - assert_eq!(disabled, vec!["user::bitfun-system::pdf".to_string()]); - assert_eq!(enabled, vec!["user::bitfun-system::docx".to_string()]); + assert_eq!( + disabled, + vec!["user::bitfun-system::ppt-design".to_string()] + ); + assert_eq!( + enabled, + vec!["user::bitfun-system::agent-browser".to_string()] + ); } #[test] @@ -612,7 +618,7 @@ mod tests { added_tools: Vec::new(), removed_tools: Vec::new(), disabled_user_skills: Vec::new(), - enabled_user_skills: vec!["user::bitfun-system::pdf".to_string()], + enabled_user_skills: vec!["user::bitfun-system::ppt-design".to_string()], subagent_overrides: Default::default(), tool_permission_rules: Vec::new(), default_tools: &[], @@ -623,7 +629,7 @@ mod tests { assert_eq!(stored.profile_id, "coding_shared"); assert_eq!( stored.enabled_user_skills, - vec!["user::bitfun-system::pdf".to_string()] + vec!["user::bitfun-system::ppt-design".to_string()] ); assert!(stored.disabled_user_skills.is_empty()); } diff --git a/src/crates/assembly/core/tests/office_archive_safety.py b/src/crates/assembly/core/tests/office_archive_safety.py deleted file mode 100644 index e73ea02ee9..0000000000 --- a/src/crates/assembly/core/tests/office_archive_safety.py +++ /dev/null @@ -1,117 +0,0 @@ -import importlib.util -import io -import stat -import sys -import tempfile -import unittest -import warnings -import zipfile -from pathlib import Path - - -sys.dont_write_bytecode = True - - -CORE_ROOT = Path(__file__).resolve().parents[1] -SKILLS_ROOT = CORE_ROOT / "builtin_skills" - - -def load_helpers(skill: str): - path = SKILLS_ROOT / skill / "scripts" / "office" / "helpers" / "__init__.py" - spec = importlib.util.spec_from_file_location(f"{skill}_office_helpers", path) - if spec is None or spec.loader is None: - raise RuntimeError(f"cannot load Office helpers from {path}") - module = importlib.util.module_from_spec(spec) - spec.loader.exec_module(module) - return module - - -def archive_bytes(entries, compression=zipfile.ZIP_STORED): - data = io.BytesIO() - with warnings.catch_warnings(): - warnings.simplefilter("ignore", UserWarning) - with zipfile.ZipFile(data, "w", compression=compression) as archive: - for name, content in entries: - archive.writestr(name, content) - data.seek(0) - return data - - -class OfficeArchiveSafetyTests(unittest.TestCase): - def setUp(self): - self.helpers = {skill: load_helpers(skill) for skill in ("docx", "pptx", "xlsx")} - - def assert_rejected(self, data, message): - for skill, helpers in self.helpers.items(): - with self.subTest(skill=skill, message=message), tempfile.TemporaryDirectory() as temp: - data.seek(0) - with zipfile.ZipFile(data) as archive: - with self.assertRaisesRegex(ValueError, message): - helpers.safe_extract(archive, Path(temp)) - - def test_rejects_traversal_absolute_symlink_and_duplicate_targets(self): - self.assert_rejected(archive_bytes([("../escape.txt", b"x")]), "unsafe archive entry") - self.assert_rejected(archive_bytes([("/absolute.txt", b"x")]), "unsafe archive entry") - self.assert_rejected(archive_bytes([(".", b"x")]), "unsafe archive entry") - - symlink = zipfile.ZipInfo("link") - symlink.create_system = 3 - symlink.external_attr = (stat.S_IFLNK | 0o777) << 16 - data = io.BytesIO() - with zipfile.ZipFile(data, "w") as archive: - archive.writestr(symlink, "target") - data.seek(0) - self.assert_rejected(data, "symlink archive entry") - - self.assert_rejected( - archive_bytes([("duplicate.txt", b"a"), ("./duplicate.txt", b"b")]), - "duplicate archive entry", - ) - self.assert_rejected( - archive_bytes([("file", b"a"), ("file/child", b"b")]), - "file entry conflicts with child path", - ) - - def test_rejects_member_count_size_total_size_and_compression_ratio_limits(self): - cases = [ - ("MAX_ARCHIVE_MEMBERS", 1, [("a", b""), ("b", b"")], "too many entries"), - ("MAX_ARCHIVE_MEMBER_SIZE", 1, [("large", b"xx")], "entry is too large"), - ("MAX_ARCHIVE_TOTAL_SIZE", 1, [("total", b"xx")], "allowed total size"), - ] - for constant, limit, entries, message in cases: - for skill, helpers in self.helpers.items(): - with self.subTest(skill=skill, constant=constant), tempfile.TemporaryDirectory() as temp: - original = getattr(helpers, constant) - setattr(helpers, constant, limit) - try: - with zipfile.ZipFile(archive_bytes(entries)) as archive: - with self.assertRaisesRegex(ValueError, message): - helpers.safe_extract(archive, Path(temp)) - finally: - setattr(helpers, constant, original) - - for skill, helpers in self.helpers.items(): - with self.subTest(skill=skill, constant="compression_ratio"), tempfile.TemporaryDirectory() as temp: - original = helpers.MAX_ARCHIVE_COMPRESSION_RATIO - helpers.MAX_ARCHIVE_COMPRESSION_RATIO = 1 - try: - data = archive_bytes([("compressed", b"A" * 4096)], zipfile.ZIP_DEFLATED) - with zipfile.ZipFile(data) as archive: - with self.assertRaisesRegex(ValueError, "unsafe compression ratio"): - helpers.safe_extract(archive, Path(temp)) - finally: - helpers.MAX_ARCHIVE_COMPRESSION_RATIO = original - - def test_extracts_valid_archive(self): - for skill, helpers in self.helpers.items(): - with self.subTest(skill=skill), tempfile.TemporaryDirectory() as temp: - with zipfile.ZipFile(archive_bytes([("word/document.xml", b"")])) as archive: - helpers.safe_extract(archive, Path(temp)) - self.assertEqual( - (Path(temp) / "word" / "document.xml").read_bytes(), - b"", - ) - - -if __name__ == "__main__": - unittest.main() diff --git a/src/crates/execution/agent-runtime/src/skills/catalog.rs b/src/crates/execution/agent-runtime/src/skills/catalog.rs index 10cefe85e1..67eda816e8 100644 --- a/src/crates/execution/agent-runtime/src/skills/catalog.rs +++ b/src/crates/execution/agent-runtime/src/skills/catalog.rs @@ -48,10 +48,6 @@ pub(super) const BUILTIN_SKILL_SPECS: &[BuiltinSkillSpec] = &[ dir_name: "create-bitfun-skin", group: BuiltinSkillGroup::Meta, }, - BuiltinSkillSpec { - dir_name: "docx", - group: BuiltinSkillGroup::Office, - }, BuiltinSkillSpec { dir_name: "find-skills", group: BuiltinSkillGroup::Meta, @@ -120,18 +116,10 @@ pub(super) const BUILTIN_SKILL_SPECS: &[BuiltinSkillSpec] = &[ dir_name: "gstack-ship", group: BuiltinSkillGroup::Gstack, }, - BuiltinSkillSpec { - dir_name: "pdf", - group: BuiltinSkillGroup::Office, - }, BuiltinSkillSpec { dir_name: "ppt-design", group: BuiltinSkillGroup::Office, }, - BuiltinSkillSpec { - dir_name: "pptx", - group: BuiltinSkillGroup::Office, - }, BuiltinSkillSpec { dir_name: "pr-review-canvas", group: BuiltinSkillGroup::Canvas, @@ -140,10 +128,6 @@ pub(super) const BUILTIN_SKILL_SPECS: &[BuiltinSkillSpec] = &[ dir_name: "writing-skills", group: BuiltinSkillGroup::Meta, }, - BuiltinSkillSpec { - dir_name: "xlsx", - group: BuiltinSkillGroup::Office, - }, ]; pub(super) fn builtin_skill_spec(dir_name: &str) -> Option<&'static BuiltinSkillSpec> { diff --git a/src/crates/execution/agent-runtime/tests/agent_definition_contracts/skill_contracts.rs b/src/crates/execution/agent-runtime/tests/agent_definition_contracts/skill_contracts.rs index 3205b19a18..fb2d18db46 100644 --- a/src/crates/execution/agent-runtime/tests/agent_definition_contracts/skill_contracts.rs +++ b/src/crates/execution/agent-runtime/tests/agent_definition_contracts/skill_contracts.rs @@ -280,7 +280,10 @@ fn project_skill(dir_name: &str) -> SkillInfo { #[test] fn builtin_skill_catalog_and_mode_policy_are_runtime_owned() { - assert_eq!(builtin_skill_group_key("docx"), Some("office")); + assert_eq!(builtin_skill_group_key("ppt-design"), Some("office")); + for removed in ["docx", "pdf", "pptx", "xlsx"] { + assert_eq!(builtin_skill_group_key(removed), None); + } assert_eq!(builtin_skill_group_key("create-bitfun-skin"), Some("meta")); assert_eq!(builtin_skill_group_key("find-skills"), Some("meta")); assert_eq!(builtin_skill_group_key("miniapp-dev"), Some("miniapp")); @@ -435,15 +438,18 @@ fn user_config_skill_root_resolution_matches_platform_contract() { #[test] fn skill_resolution_applies_builtin_and_user_override_rules() { - let pdf = builtin_skill("pdf"); + let presentation = builtin_skill("ppt-design"); let custom = custom_user_skill("my-custom-skill"); let disabled_project = HashSet::new(); - assert!(!resolve_skill_default_enabled_for_mode(&pdf, "agentic")); + assert!(!resolve_skill_default_enabled_for_mode( + &presentation, + "agentic" + )); assert!(resolve_skill_default_enabled_for_mode(&custom, "agentic")); let default_state = resolve_skill_state_for_mode( - &pdf, + &presentation, "agentic", &UserModeSkillOverrides::default(), &disabled_project, @@ -455,9 +461,9 @@ fn skill_resolution_applies_builtin_and_user_override_rules() { ); let mut overrides = UserModeSkillOverrides::default(); - overrides.enabled_skills.push(pdf.key.clone()); + overrides.enabled_skills.push(presentation.key.clone()); let enabled_state = - resolve_skill_state_for_mode(&pdf, "agentic", &overrides, &disabled_project); + resolve_skill_state_for_mode(&presentation, "agentic", &overrides, &disabled_project); assert!(enabled_state.effective_enabled); assert_eq!( enabled_state.reason, @@ -687,14 +693,14 @@ fn implicit_skill_filter_keeps_explicit_only_skill_out_of_model_catalog() { #[test] fn skill_candidate_key_group_and_resolution_are_runtime_owned() { let markdown = r#"--- -name: pdf -description: Work with PDF files. +name: ppt-design +description: Design presentation slides. --- -Use the pdf workflow. +Use the presentation workflow. "#; let data = SkillData::from_markdown( - "/tmp/bitfun-system/pdf".to_string(), + "/tmp/bitfun-system/ppt-design".to_string(), markdown, SkillLocation::User, false, @@ -703,27 +709,30 @@ Use the pdf workflow. let candidate = SkillCandidate::from_data(data, "bitfun-system", "bitfun", "BitFun", "user", 10, true); - assert_eq!(candidate.info.key, "user::bitfun-system::pdf"); + assert_eq!(candidate.info.key, "user::bitfun-system::ppt-design"); assert_eq!(candidate.info.source_slot, "bitfun-system"); assert_eq!(candidate.info.group_key.as_deref(), Some("office")); - let project_pdf = SkillCandidate { - info: project_skill("pdf"), + let project_presentation = SkillCandidate { + info: project_skill("ppt-design"), priority: 0, }; - let visible = resolve_visible_skills(vec![candidate.clone(), project_pdf.clone()]); + let visible = resolve_visible_skills(vec![candidate.clone(), project_presentation.clone()]); assert_eq!(visible.len(), 1); - assert_eq!(visible[0].key, "project::bitfun::pdf"); + assert_eq!(visible[0].key, "project::bitfun::ppt-design"); - let annotated = sort_skills(annotate_shadowed_skills(vec![candidate, project_pdf])); - let user_pdf = annotated + let annotated = sort_skills(annotate_shadowed_skills(vec![ + candidate, + project_presentation, + ])); + let user_presentation = annotated .iter() - .find(|skill| skill.key == "user::bitfun-system::pdf") + .find(|skill| skill.key == "user::bitfun-system::ppt-design") .expect("user built-in skill should be present"); - assert!(user_pdf.is_shadowed); + assert!(user_presentation.is_shadowed); assert_eq!( - user_pdf.shadowed_by_key.as_deref(), - Some("project::bitfun::pdf") + user_presentation.shadowed_by_key.as_deref(), + Some("project::bitfun::ppt-design") ); } diff --git a/src/web-ui/src/locales/en-US/flow-chat.json b/src/web-ui/src/locales/en-US/flow-chat.json index c177403d62..27c7017b7d 100644 --- a/src/web-ui/src/locales/en-US/flow-chat.json +++ b/src/web-ui/src/locales/en-US/flow-chat.json @@ -2477,9 +2477,9 @@ "prompt": "Help me write an email reply.\n\nOriginal email (paste here):\nMy goal (confirm / decline / push forward / clarify):\nTone (formal / friendly / firm but polite):\nKey points to include:\n\nOutput:\n1) Subject line suggestions\n2) Body (2 versions: more formal / more concise)\n3) Questions for the recipient to confirm (if any)" }, "make_docx": { - "title": "Draft a DOCX", - "description": "Write a structured document and export as DOCX.", - "prompt": "Help me write a document and export it as a .docx file.\n\nDocument type (PRD / proposal / meeting summary / report / SOP):\nAudience:\nTone (formal / friendly / concise):\nMust-include points:\nLength target:\n\nDeliverable:\n1) Suggested outline\n2) Full content\n3) Export as a .docx file (save it under artifacts/)" + "title": "Draft a document", + "description": "Turn source material into a structured, reusable document.", + "prompt": "Help me write a structured document.\n\nDocument type (PRD / proposal / meeting summary / report / SOP):\nAudience:\nTone (formal / friendly / concise):\nMust-include points:\nLength target:\n\nDeliverable:\n1) Suggested outline\n2) Full content\n3) Save the Markdown document under artifacts/" }, "make_spreadsheet": { "title": "Design a spreadsheet", diff --git a/src/web-ui/src/locales/zh-CN/flow-chat.json b/src/web-ui/src/locales/zh-CN/flow-chat.json index 6b670de6cc..9317e0c39a 100644 --- a/src/web-ui/src/locales/zh-CN/flow-chat.json +++ b/src/web-ui/src/locales/zh-CN/flow-chat.json @@ -2477,9 +2477,9 @@ "prompt": "请帮我写一封邮件回复。\n\n对方邮件内容(可粘贴):\n我的目标(确认/拒绝/推进/澄清):\n语气(正式/友好/强硬但礼貌):\n需要包含的信息点:\n\n请输出:\n1) 主题(Subject)建议\n2) 邮件正文(2 个版本:更正式/更简洁)\n3) 需要对方确认的问题列表(如有)" }, "make_docx": { - "title": "写一份 Word 文档", - "description": "把内容结构化成文档,并导出为 DOCX。", - "prompt": "请帮我写一份文档,并导出为 .docx 文件。\n\n文档类型(PRD/方案/复盘/报告/SOP):\n受众:\n语气(正式/友好/简洁):\n必须包含的信息点:\n期望长度:\n\n最终交付:\n1) 建议目录结构\n2) 完整正文内容\n3) 导出为 DOCX 文件(保存到 artifacts/)" + "title": "写一份结构化文档", + "description": "把资料整理成清晰、可复用的文档。", + "prompt": "请帮我写一份结构化文档。\n\n文档类型(PRD/方案/复盘/报告/SOP):\n受众:\n语气(正式/友好/简洁):\n必须包含的信息点:\n期望长度:\n\n最终交付:\n1) 建议目录结构\n2) 完整正文内容\n3) 将 Markdown 文档保存到 artifacts/" }, "make_spreadsheet": { "title": "做一张表格", diff --git a/src/web-ui/src/locales/zh-TW/flow-chat.json b/src/web-ui/src/locales/zh-TW/flow-chat.json index cea321e2ec..d3b210c9e3 100644 --- a/src/web-ui/src/locales/zh-TW/flow-chat.json +++ b/src/web-ui/src/locales/zh-TW/flow-chat.json @@ -2477,9 +2477,9 @@ "prompt": "請幫我寫一封郵件回覆。\n\n對方郵件內容(可粘貼):\n我的目標(確認/拒絕/推進/澄清):\n語氣(正式/友好/強硬但禮貌):\n需要包含的資訊點:\n\n請輸出:\n1) 主題(Subject)建議\n2) 郵件正文(2 個版本:更正式/更簡潔)\n3) 需要對方確認的問題列表(如有)" }, "make_docx": { - "title": "寫一份 Word 文檔", - "description": "把內容結構化成文檔,並導出為 DOCX。", - "prompt": "請幫我寫一份文檔,並導出為 .docx 檔案。\n\n文檔類型(PRD/方案/覆盤/報告/SOP):\n受眾:\n語氣(正式/友好/簡潔):\n必須包含的資訊點:\n期望長度:\n\n最終交付:\n1) 建議目錄結構\n2) 完整正文內容\n3) 導出為 DOCX 檔案(儲存到 artifacts/)" + "title": "寫一份結構化文檔", + "description": "把資料整理成清晰、可複用的文檔。", + "prompt": "請幫我寫一份結構化文檔。\n\n文檔類型(PRD/方案/覆盤/報告/SOP):\n受眾:\n語氣(正式/友好/簡潔):\n必須包含的資訊點:\n期望長度:\n\n最終交付:\n1) 建議目錄結構\n2) 完整正文內容\n3) 將 Markdown 文檔儲存到 artifacts/" }, "make_spreadsheet": { "title": "做一張表格",