Imported from hirokisakabe/pom (
packages/pom/AGENTS.md). Install upstream withnpx skills add hirokisakabe/pom --skill pom. Copyright stays with the author.
AGENTS.md — packages/pom
Core library of pom. PPTX generation pipeline: parseXml/ → calcYogaLayout/ → toPositioned/ → renderPptx/. リポジトリ共通ルールはルート AGENTS.md を参照。
Feature Addition Checklist
適用条件: src/** を変更して新しいプロパティや機能を追加する場合。
When adding new properties or features, update the following files:
- Type definitions:
packages/pom/src/types.ts- Add new types or properties - Coercion rules:
packages/pom/src/parseXml/coercionRules.ts- Add attribute coercion rules - XML parser:
packages/pom/src/parseXml/parseXml.ts- Add XML tag/attribute conversion logic - Node registry:
packages/pom/src/registry/definitions/- Add node definition to the registry - Rendering: Under
packages/pom/src/renderPptx/- Implement@pptx-glimpse/documentauthoring conversion - VRT test data:
packages/pom/vrt/lib/generatePptx.ts- Add test cases for the new feature - Update VRT baseline: Run
pnpm run vrt:docker:update(frompackages/pom/) - Documentation updates:
packages/pom/README.md- User-facing documentationpackages/pom/docs/nodes.md- Nodesapps/website/public/llm.txt- XML reference for LLMs (for prompts)- ルート
AGENTS.md- Add to Key Internal Types section
- Documentation image updates (when adding new node types):
- Add to
NODE_TYPESinpackages/pom/scripts/docs-images/config.ts - Define sample XML in
packages/pom/scripts/docs-images/sampleNodes.ts - Run
pnpm run docs:images:docker:update(frompackages/pom/)
- Add to
- Add changeset: Run
pnpm exec changeset addbefore creating a PR - pom-jsx updates (when adding new node types):
packages/pom-jsx/src/types.ts- Add{NodeName}Propsinterfacepackages/pom-jsx/src/components.ts- Add component functionpackages/pom-jsx/src/jsx-runtime.ts- Add toJSX.IntrinsicElementspackages/pom-jsx/src/index.ts- Export the new component and{NodeName}Propstypepackages/pom-jsx/src/integration.test.tsx- Add test casepackages/pom-jsx/README.md- Add to component table
- pom-editor updates (when adding new node types):
packages/pom-editor/src/ast.ts- Add new node type to AST mapping if neededpackages/pom-editor/src/AstTree.tsx- Add label toNODE_LABELSif needed
Preview Workflow
適用条件: main.ts を編集して PPTX 出力を検証する場合。
- Edit
packages/pom/main.ts(and modify logic underpackages/pom/src/as needed) - Run
pnpm run preview:dockerfrompackages/pom/ - Visually verify
packages/pom/preview/output/sample.png - If there are layout issues, fix and return to step 2
- If everything looks good, commit
Output Files
packages/pom/preview/output/sample.pptx- Generated PPTXpackages/pom/preview/output/sample.png- PNG image (for layout verification)
Text Measurement
適用条件: src/calcYogaLayout/** を変更する場合。
Text width measurement uses opentype.js. The Noto Sans JP font is bundled with the library and works in both Node.js and browser environments.
packages/pom/src/calcYogaLayout/measureText.ts- Text measurement logicpackages/pom/src/calcYogaLayout/fontLoader.ts- Font loading (opentype.js)packages/pom/src/calcYogaLayout/fonts/- Bundled fonts (Base64)- The
textMeasurementoption inbuildPptxallows explicit specification of the measurement method"opentype": Always measure with opentype.js; unregistered fonts use bundled Noto Sans JP metrics"fallback": Always use fallback calculation (CJK characters = 1em, alphanumeric = 0.5em)"auto": Measure bundled or registered fonts with opentype.js and use fallback for unregistered fonts (default)
Unit Conversion
- User input: pixels (px)
- Internal layout: pixels (yoga-layout)
- PPTX output: inches (converted via
pxToIn, 96 DPI basis)