Preface¶
In DeepSeek Harness (DSH), creating presentations often follows a common path: letting the model write an outline, which is then passed to a template or adapted by Office auto-sizing. Template engines typically estimate height based on character count and leave line breaking to the renderer. The result is either text squeezed out of the box or half a page left blank, making reproducible checks before rendering difficult.
Metre (格律) reverses this order: measure first, then layout. It serves as a DSH workflow plugin (the repository root acts as a skill loader) and can also be used as a portable Skill with a built-in layout engine in other agent environments. Maintained by Leica-Shen; community directory categorized as workflow. Default styles are written in style/me.json; changing this file changes the output.
What is it¶
Metre is positioned as a Measurement-driven slide layout engine: it uses real font metrics, line breaking, image placement, and layout auditing to render .pptx files from JSON descriptions. The Chinese name “Metre” (格律) refers to “grid” (格) and “rhythm” (律).
Compared to generators using “fixed coordinates + autofit”, the differences can be summarized as:
| Common Template Engines | Metre | |
|---|---|---|
| Text Height | Estimated by character count | Pillow reads real font metrics |
| Line Breaking | Left to renderer | DP finds optimal line breaks, writes to a:br |
| Layout | Hardcoded coordinates | Composition + vertical distribution laws |
| Whitespace | Remaining is whitespace | Auditable (e.g., maximum empty rectangle) |
| Quality | Visual inspection | 10 geometric checks before rendering |
The license is MIT (see LICENSE in the repo). Version is 5.1.0 in package.json, display name “Metre”, connected via cordis.patch.yml as a DSH bundle patch.
Core Features¶
Real Typography and Vertical Distribution¶
- Font metrics taken via Pillow; DP line breaking under CJK non-breaking rules; precise line spacing
spcPts; manual line breaks for consistency across PowerPoint / WPS / Keynote. - Remaining vertical space is handled in only three ways: increased spacing (with limits), optically centered, or handed to a filler device; elements are not scaled up.
Five Design Languages¶
Each language is a variation of paper, ink color, type scale, margins, media processing, etc., rather than a font directory. Optional language: sweet, iron, paper, grid (default), manifesto. Latin and Chinese family pairings (e.g., Lxgw WenKai, Droid Sans Fallback, Source Han Serif, Alibaba PuHuiTi), note that fonts are referenced by family name in the docs and not bundled with the repo; the default set includes macOS system fonts and Chinese font families; missing fonts will be listed by python3 -m studio.cli selftest.
Images and Color Palettes¶
python3 -m studio.cli fetchretrieves from Wikimedia Commons, filtered by CC0 / CC BY / CC BY-SA / PD licenses, and records sources.- Images can be used as full-bleed backgrounds, shape fills (
blipFillon autoshape), or text fills (blipFillina:rPr). - Cover image sets the color temperature;
color_modecan belanguageorimage(includingaccent_from_image), and a single page can still useaccent/panelto override.
Pre-rendering Audit and Self-test¶
studio/audit.py focuses on stacking, out-of-bounds, contrast (based on real background of text runs), type scale, alignment axes, spacing, whitespace registers, image coverage, rhythm, etc. python3 -m studio.cli selftest (and the metre selftest description in the docs) covers layout, determinism, information integrity, path leaks, volume, and SKILL.md prompt injection safety.
Machine-readable Contract¶
schema/deck.schema.json validates the deck before build; python3 -m studio.cli spec --json outputs language, page types, required keys, and style fields.
Installation and Dependencies¶
Environment requirements: Python 3.10+, dependencies include python-pptx, Pillow, lxml, numpy (see requirements.txt).
Given access to the plugin source code (e.g., from the SkillHub directory page or GitHub Release / source package), install Python dependencies in the repository root:
python3 -m pip install -r requirements.txt
DSH side: The plugin form is located in the repository root, loaded as a skill in DeepSeek Harness; package.json’s dsh.bundle.patch points to ./cordis.patch.yml. The portable form is in skill/metre/, includes the engine, and degrades gracefully when fonts are missing.
Note: DSH plugins run under the current DSH process permissions. Please read the source code and MIT license yourself before installing or enabling to ensure font and network image retrieval behaviors comply with your environment policies. The community directory is an independent site with no official affiliation with DeepSeek or BigModel.
Typical Usage¶
List Design Languages and Build Example¶
python3 -m studio.cli spec
python3 -m studio.cli build examples/coffee/deck.json out.pptx
python3 -m studio.cli build examples/coffee/deck.json out.pptx --png preview/
--png is documented as requiring Keynote on macOS; other pptx -> png export methods can be used.
Fetch Commons Images¶
python3 -m studio.cli fetch assets/coffee "coffee roasting|latte art" --n 6
Self-test¶
python3 -m studio.cli selftest
Learning and Building in the Portable Skill Directory¶
cd skill/metre
python3 tools/learn_style.py reference.pptx -o style.json
python3 tools/build.py examples/mini.json out.pptx --style style.json
Content Model (Excerpt)¶
deck.json specifies language, assets, and pages. Page types include cover, section, statement, points, metrics, band, cards, split, imagepanel, compare, table, chart, gallery, quote, closing, etc. Example in docs:
{
"language": "sweet",
"assets": "assets/",
"pages": [
{"kind": "cover", "kicker": "2026", "title": "第二家店,开在早晨最忙的那条街",
"sub": "单店模型与选址判断", "image": "assets/cover.jpg"},
{"kind": "points", "title": "为什么是现在",
"items": ["周边写字楼入住率回到 92%", "独立咖啡馆连锁化率不到 8%", "复购率 41%"]}
]
}
Four Optional Knobs¶
| Knob | Values | Default |
|---|---|---|
language |
sweet iron paper grid manifesto |
grid |
variation |
int / string / auto |
Determined by content seed, reproducible within same deck |
fonts |
auto or {ea_display, ea_body, ea_micro} |
Selected from palette matching |
color_mode |
language / image (and accent_from_image) |
Language sets paper color; page level can still be dyed by image |
Layouts rotate within a single deck (side-r, side-l, stack, full, inset, etc.), and the planner avoids consecutive pages with the same media position.
Use Cases and Considerations¶
Who is it for: Developers who need to stably generate .pptx files with structured JSON in agent workflows and want line breaking and whitespace to be auditable, with traceable image sources; scenarios where one writes “what each page says” first, then hands it to the engine to layout according to personal design rules (style/me.json).
Platform: The measurement layer relies on local real font files; the default language set leans towards macOS fonts and Chinese font families. It will still run without complete fonts, but self-test will prompt for missing items.
Ecosystem: The DSH philosophy is “Everything is a plugin”; Metre is categorized as workflow, complementing the “template-only” generation path. examples/coffee/ in the repo provides a complete deck, images, and previews; example photography is from Wikimedia Commons (CC BY / CC BY-SA), see examples/coffee/assets and the example deck footer for credits.
Conclusion¶
Metre changes slide generation from “estimate height + hard coordinates” to “measure text, line break, compose, audit, then render”, and can be embedded in your pipeline via DSH skill or skill/metre/. Further entry points:
- Community directory: skillhub.cn/plugins/Leica-Shen/deepseek-harness-metre
- Source code and documentation: github.com/Leica-Shen/deepseek-harness-metre