@hfyjq/crannia 1.0.0 → 1.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (222) hide show
  1. package/LICENSE +201 -201
  2. package/NOTICE +45 -45
  3. package/THIRD-PARTY-FRONTEND.md +5266 -5266
  4. package/THIRD-PARTY-PYTHON.md +162 -153
  5. package/THIRD-PARTY.md +316 -316
  6. package/apps/desktop/quotes.txt +56 -56
  7. package/bus/core.py +671 -671
  8. package/bus/loaders/channel_loader.py +64 -64
  9. package/bus/loaders/skill_md.py +676 -676
  10. package/bus/skill_state.py +124 -124
  11. package/channels/cli_channel/manifest.yaml +5 -5
  12. package/channels/dingtalk_channel/manifest.yaml +12 -12
  13. package/channels/feishu_channel/manifest.yaml +12 -12
  14. package/channels/qq_bot_channel/__init__.py +1 -1
  15. package/channels/qq_bot_channel/handler.py +881 -881
  16. package/channels/qq_bot_channel/manifest.yaml +4 -4
  17. package/channels/telegram_channel/__init__.py +1 -1
  18. package/channels/telegram_channel/handler.py +813 -813
  19. package/channels/telegram_channel/manifest.yaml +4 -4
  20. package/channels/telegram_channel/media.py +231 -231
  21. package/channels/textfmt.py +58 -58
  22. package/channels/wechat_channel/__init__.py +1 -1
  23. package/channels/wechat_channel/auth.py +23 -5
  24. package/channels/wechat_channel/manifest.yaml +5 -5
  25. package/channels/wechat_channel/media.py +178 -178
  26. package/config.yaml +2 -2
  27. package/core/activity.py +3 -0
  28. package/core/agent_loop.py +390 -55
  29. package/core/approval.py +17 -6
  30. package/core/artifacts.py +7 -0
  31. package/core/auto_review.py +23 -5
  32. package/core/channel_configs.py +34 -2
  33. package/core/channel_turns.py +759 -759
  34. package/core/child_approval.py +150 -0
  35. package/core/config_requirements.py +205 -0
  36. package/core/cron/runner.py +118 -6
  37. package/core/cron/store.py +14 -5
  38. package/core/cron/tools.py +17 -5
  39. package/core/endpoint.py +141 -0
  40. package/core/events.py +23 -0
  41. package/core/i18n.py +329 -329
  42. package/core/ice/store.py +191 -191
  43. package/core/inbound.py +193 -193
  44. package/core/jobs.py +19 -3
  45. package/core/last_good.py +150 -150
  46. package/core/llm_errors.py +227 -227
  47. package/core/llm_retry.py +230 -230
  48. package/core/memory/compressor.py +1214 -1214
  49. package/core/memory/manager.py +14 -0
  50. package/core/model_configs.py +80 -0
  51. package/core/pipeline/scheduler.py +2 -2
  52. package/core/pipeline/stages/agent_loop.py +24 -4
  53. package/core/pipeline/stages/pre_process.py +58 -7
  54. package/core/prompt_assembler.py +680 -680
  55. package/core/rg.py +255 -255
  56. package/core/security.py +1544 -1544
  57. package/core/settings_baseline.py +70 -1
  58. package/core/shell.py +5 -17
  59. package/core/skill_settings.py +7 -2
  60. package/core/state_registry.py +19 -0
  61. package/core/subagent.py +64 -3
  62. package/core/task_tool.py +1 -1
  63. package/core/tasks_notify.py +69 -4
  64. package/core/tiers.py +9 -3
  65. package/core/tool_outcome.py +108 -0
  66. package/core/update_tui.py +158 -0
  67. package/core/updater.py +229 -40
  68. package/core/version.py +2 -2
  69. package/core/web_cache.py +152 -0
  70. package/crannia_tray.py +278 -278
  71. package/creators/models.json +4 -4
  72. package/data/settings.example.json +67 -0
  73. package/licenses/GPL-3.0.txt +619 -619
  74. package/licenses/LGPL-2.1.txt +502 -502
  75. package/licenses/LGPL-3.0.txt +165 -165
  76. package/licenses/MIT-chat-on-wechat.txt +18 -18
  77. package/licenses/MIT-deepseek-harness.txt +21 -21
  78. package/licenses/Molio-LICENSE.txt +44 -44
  79. package/locales/en.json +9 -4
  80. package/main.py +154 -154
  81. package/mcpx/manager.py +522 -522
  82. package/mcpx/servers/__init__.py +22 -22
  83. package/mcpx/servers/web_search.py +321 -33
  84. package/package.json +24 -10
  85. package/providers/anthropic/client.py +772 -772
  86. package/providers/cost_table.json +3779 -3779
  87. package/providers/deepseek/client.py +20 -20
  88. package/providers/deepseek/manifest.yaml +2 -2
  89. package/providers/factory.py +136 -136
  90. package/providers/lmstudio/client.py +2 -2
  91. package/providers/metadata.py +80 -80
  92. package/providers/model_capabilities.json +6665 -6665
  93. package/providers/moonshot/client.py +12 -12
  94. package/providers/ollama/client.py +2 -2
  95. package/providers/openai/client.py +13 -13
  96. package/providers/openrouter/client.py +2 -2
  97. package/providers/qwen/__init__.py +1 -1
  98. package/providers/qwen/client.py +2 -2
  99. package/providers/qwen/manifest.yaml +16 -16
  100. package/providers/rate_limiter.py +144 -144
  101. package/providers/siliconflow/client.py +2 -2
  102. package/providers/validation.py +171 -171
  103. package/providers/window_table.json +8909 -8909
  104. package/sbom.json +4413 -4296
  105. package/skills/entertainment/SKILL.md +35 -35
  106. package/skills/entertainment/__init__.py +1 -1
  107. package/skills/entertainment/handler.py +91 -91
  108. package/skills/entertainment/manifest.yaml +26 -26
  109. package/skills/file_parser/GUIDANCE.md +10 -10
  110. package/skills/file_parser/handler.py +177 -4
  111. package/skills/file_parser/manifest.yaml +22 -1
  112. package/skills/github/SKILL.md +32 -32
  113. package/skills/github/__init__.py +1 -1
  114. package/skills/github/manifest.yaml +5 -0
  115. package/skills/mail_parser/SKILL.md +68 -68
  116. package/skills/mail_parser/__init__.py +1 -1
  117. package/skills/mail_parser/handler.py +806 -806
  118. package/skills/mail_parser/manifest.yaml +5 -0
  119. package/skills/media_gen/GUIDANCE.md +19 -19
  120. package/skills/media_gen/SKILL.md +43 -43
  121. package/skills/media_gen/__init__.py +1 -1
  122. package/skills/media_gen/handler.py +430 -430
  123. package/skills/media_gen/manifest.yaml +93 -88
  124. package/skills/office_parser/cell_validation.py +127 -127
  125. package/skills/office_parser/excel_transform.py +936 -936
  126. package/skills/office_parser/layout_spec.py +243 -243
  127. package/skills/office_parser/pptx_export/console_encoding.py +27 -27
  128. package/skills/office_parser/pptx_export/resource_paths.py +88 -88
  129. package/skills/office_parser/pptx_export/svg_finalize/__init__.py +12 -12
  130. package/skills/office_parser/pptx_export/svg_finalize/align_embed_images.py +575 -575
  131. package/skills/office_parser/pptx_export/svg_finalize/crop_images.py +366 -366
  132. package/skills/office_parser/pptx_export/svg_finalize/embed_icons.py +498 -498
  133. package/skills/office_parser/pptx_export/svg_finalize/embed_images.py +288 -288
  134. package/skills/office_parser/pptx_export/svg_finalize/fix_image_aspect.py +388 -388
  135. package/skills/office_parser/pptx_export/svg_finalize/flatten_tspan.py +818 -818
  136. package/skills/office_parser/pptx_export/svg_finalize/svg_rect_to_path.py +345 -345
  137. package/skills/office_parser/pptx_export/svg_to_pptx/__init__.py +14 -14
  138. package/skills/office_parser/pptx_export/svg_to_pptx/drawingml/__init__.py +1 -1
  139. package/skills/office_parser/pptx_export/svg_to_pptx/drawingml/context.py +186 -186
  140. package/skills/office_parser/pptx_export/svg_to_pptx/drawingml/converter.py +781 -781
  141. package/skills/office_parser/pptx_export/svg_to_pptx/drawingml/elements.py +2490 -2490
  142. package/skills/office_parser/pptx_export/svg_to_pptx/drawingml/paths.py +429 -429
  143. package/skills/office_parser/pptx_export/svg_to_pptx/drawingml/styles.py +656 -656
  144. package/skills/office_parser/pptx_export/svg_to_pptx/pptx_package/__init__.py +1 -1
  145. package/skills/office_parser/pptx_export/svg_to_pptx/pptx_package/builder.py +1267 -1267
  146. package/skills/office_parser/pptx_export/svg_to_pptx/pptx_package/dimensions.py +155 -155
  147. package/skills/office_parser/pptx_export/svg_to_pptx/pptx_package/discovery.py +101 -101
  148. package/skills/office_parser/pptx_export/svg_to_pptx/pptx_package/media.py +141 -141
  149. package/skills/office_parser/pptx_export/svg_to_pptx/pptx_package/narration.py +236 -236
  150. package/skills/office_parser/pptx_export/svg_to_pptx/pptx_package/notes.py +257 -257
  151. package/skills/office_parser/pptx_export/svg_to_pptx/pptx_package/slide_xml.py +136 -136
  152. package/skills/office_parser/pptx_export/svg_to_pptx/tspan_flattener.py +44 -44
  153. package/skills/office_parser/pptx_export/svg_to_pptx/use_expander.py +129 -129
  154. package/skills/office_parser/references/LICENSE-Office-Word-MCP-Server.txt +20 -20
  155. package/skills/office_parser/references/LICENSE-excel-mcp-server.txt +21 -21
  156. package/skills/office_parser/references/layout_library.md +816 -816
  157. package/skills/office_parser/references/ppt-master/LICENSE +21 -21
  158. package/skills/office_parser/references/ppt-master/references/executor-base.md +474 -474
  159. package/skills/office_parser/references/ppt-master/references/shared-standards.md +1002 -1002
  160. package/skills/office_parser/references/ppt-master/references/strategist.md +880 -880
  161. package/skills/office_parser/references/ppt-master/references/template-designer.md +402 -402
  162. package/skills/office_parser/references/ppt-master/references/visual-review.md +240 -240
  163. package/skills/office_parser/references/ppt-master/references/visual-styles/_index.md +106 -106
  164. package/skills/office_parser/references/ppt-master/references/visual-styles/blueprint.md +37 -37
  165. package/skills/office_parser/references/ppt-master/references/visual-styles/brutalist.md +38 -38
  166. package/skills/office_parser/references/ppt-master/references/visual-styles/chalkboard.md +36 -36
  167. package/skills/office_parser/references/ppt-master/references/visual-styles/dark-tech.md +37 -37
  168. package/skills/office_parser/references/ppt-master/references/visual-styles/data-journalism.md +36 -36
  169. package/skills/office_parser/references/ppt-master/references/visual-styles/editorial.md +38 -38
  170. package/skills/office_parser/references/ppt-master/references/visual-styles/glassmorphism.md +36 -36
  171. package/skills/office_parser/references/ppt-master/references/visual-styles/ink-notes.md +37 -37
  172. package/skills/office_parser/references/ppt-master/references/visual-styles/ink-wash.md +36 -36
  173. package/skills/office_parser/references/ppt-master/references/visual-styles/memphis.md +37 -37
  174. package/skills/office_parser/references/ppt-master/references/visual-styles/paper-cut.md +36 -36
  175. package/skills/office_parser/references/ppt-master/references/visual-styles/photo-editorial.md +38 -38
  176. package/skills/office_parser/references/ppt-master/references/visual-styles/pixel-art.md +36 -36
  177. package/skills/office_parser/references/ppt-master/references/visual-styles/sketch-notes.md +36 -36
  178. package/skills/office_parser/references/ppt-master/references/visual-styles/soft-rounded.md +37 -37
  179. package/skills/office_parser/references/ppt-master/references/visual-styles/swiss-minimal.md +38 -38
  180. package/skills/office_parser/references/ppt-master/references/visual-styles/vintage-poster.md +36 -36
  181. package/skills/office_parser/references/ppt-master/references/visual-styles/zine.md +37 -37
  182. package/skills/office_parser/references/spec_lock.md +235 -235
  183. package/skills/office_parser/soffice.py +68 -68
  184. package/skills/office_parser/word_tools.py +2909 -2909
  185. package/tui/crannia.cmd +134 -0
  186. package/tui/crannia_tui/__init__.py +1 -0
  187. package/tui/crannia_tui/__main__.py +223 -0
  188. package/tui/crannia_tui/app.py +1318 -0
  189. package/tui/crannia_tui/app.tcss +153 -0
  190. package/tui/crannia_tui/approval.py +85 -0
  191. package/tui/crannia_tui/backend.py +279 -0
  192. package/tui/crannia_tui/channel.py +472 -0
  193. package/tui/crannia_tui/client.py +125 -0
  194. package/tui/crannia_tui/clipboard.py +62 -0
  195. package/tui/crannia_tui/commands.py +65 -0
  196. package/tui/crannia_tui/doctor.py +304 -0
  197. package/tui/crannia_tui/events.py +84 -0
  198. package/tui/crannia_tui/headless.py +152 -0
  199. package/tui/crannia_tui/i18n.py +164 -0
  200. package/tui/crannia_tui/locales/en.json +263 -0
  201. package/tui/crannia_tui/outcome.py +62 -0
  202. package/tui/crannia_tui/paths.py +181 -0
  203. package/tui/crannia_tui/probe.py +53 -0
  204. package/tui/crannia_tui/profile.py +169 -0
  205. package/tui/crannia_tui/render.py +209 -0
  206. package/tui/crannia_tui/settings.py +134 -0
  207. package/tui/crannia_tui/setup.py +380 -0
  208. package/tui/crannia_tui/term.py +116 -0
  209. package/tui/crannia_tui/ui.py +1236 -0
  210. package/tui/crannia_tui/update.py +389 -0
  211. package/vendor/ripgrep/COPYING.txt +3 -3
  212. package/vendor/ripgrep/LICENSE-MIT.txt +21 -21
  213. package/vendor/ripgrep/NOTICE-vscode-ripgrep.txt +13 -13
  214. package/vendor/ripgrep/README.md +51 -51
  215. package/vendor/ripgrep/UNLICENSE.txt +24 -24
  216. package/vendor/ripgrep/package-source.json +19 -19
  217. package/web/__main__.py +15 -0
  218. package/web/server.py +178 -20
  219. package/web/static/img/channel-telegram.svg +1 -1
  220. package/web/static/img/channel-wechat.svg +1 -1
  221. package/web/templates/logs.html +49 -49
  222. package/web/templates/models.html +46 -46
@@ -1,402 +1,402 @@
1
- > See shared-standards.md for common technical constraints.
2
-
3
- # Template Designer — Template Design Role
4
-
5
- ## Core Mission
6
-
7
- Generate reusable page templates for the **global template library** based on a finalized template brief, and write a concise `design_spec.md` that captures the source-derived basic norms that make the template reusable.
8
-
9
- > This is a standalone role: only triggered via the `/create-template` workflow. It is **not** the project-level template selection/customization step in the main PPT generation pipeline.
10
-
11
- ## Usage
12
-
13
- - **Trigger**: `/create-template` workflow
14
- - **Output location**: `templates/<kind_dir>/<template_name>/` where `<kind_dir>` is `decks` (default — full-PPT replica with identity) or `layouts` (structure-only, no identity segment)
15
- - **Input**: finalized template brief (template ID, display name, kind, applicable scenarios, tone, theme mode, canvas format, optional reference assets, accepted basic template norms)
16
-
17
- When the workflow provides a PPTX reference source, the effective input package comes from the unified `pptx_template_import.py` preparation workspace and becomes:
18
-
19
- - finalized template brief
20
- - `manifest.json` — single source of truth (slide size, theme, per-master themes, assets, asset map, placeholders, layouts, masters, slides, SVG file paths, page-type candidates)
21
- - `summary.md` — short orientation digest derived from manifest.json
22
- - exported `assets/`
23
- - `svg/master_*.svg` / `svg/layout_*.svg` — every master / layout in the deck rendered once as standalone SVG, including ones no sample slide references (template packages often ship more design surfaces than the embedded samples exercise)
24
- - `svg/slide_NN.svg` — each slide's own shapes and slide-local background only; master / layout decoration and backgrounds are **not** inlined here
25
- - `svg/inheritance.json` — which layout / master each slide consumes
26
- - `svg-flat/slide_NN.svg` — companion view; each slide is self-contained so you can preview or screenshot a single page without losing the surrounding chrome. Use it as a sanity check for "what would PowerPoint actually show", not as an authoring source — the master/layout chrome will be duplicated across every flat slide.
27
- - optional screenshots for visual cross-checking
28
-
29
- PPTX import interpretation:
30
-
31
- - Placeholder guides in master / layout SVGs are layout signals. Use `manifest.json` placeholder records for type / index / geometry / base style; do not copy dashed guide boxes into final templates unless the visual design truly uses dashed boxes.
32
- - Charts, SmartArt, diagrams, and OLE objects may appear as typed placeholders in layered SVGs. In flat SVGs they may show preview images. Treat them as source intent markers, not reusable decorative assets.
33
- - The asset filenames referenced by SVGs are governed by the manifest asset map. Prefer those references over inventing duplicate asset names.
34
-
35
- Input priority for PPTX-backed template creation:
36
-
37
- 1. `manifest.json` for all factual metadata (theme, assets, unique layout/master structure, slide reuse, page-type guidance)
38
- 2. `svg/master_*.svg` + `svg/layout_*.svg` — the **primary source for the deck's shared visual language**: backgrounds, page chrome, decorative bars, recurring brand motifs. These are what the new template's fixed structure should adopt or reinterpret. Read these before any slide SVG.
39
- 3. `svg/inheritance.json` for confirming which slide uses which layout / master
40
- 4. exported `assets/` for reusable visual resources
41
- 5. `svg/slide_NN.svg` — each slide's unique content, useful for judging composition rhythm and content density (not for fixed structure)
42
- 6. `summary.md` only as a fast scan; never as the canonical fact source
43
- 7. screenshots / original PPTX only for style verification
44
-
45
- ---
46
-
47
- ## Page Roster
48
-
49
- The output page set is determined by **replication mode**, declared in the finalized template brief:
50
-
51
- | Mode | When to use | Roster |
52
- |------|-------------|--------|
53
- | `standard` (default) | Most templates — clean, reusable, balanced coverage | `01_cover`, `02_chapter`, `03_content`, `04_ending`, optional `02_toc` |
54
- | `fidelity` | User explicitly wants strict replication of a source PPTX, but still wants the AI to clean / cluster / cap variants | Standard roster + one variant per distinct layout cluster found in `manifest.json` |
55
- | `mirror` | Creation-time harvesting mode: every source slide is preserved 1:1 as a reference page for the template package. Verbatim copy, no abstraction, no placeholders | One SVG per source slide, named `<NNN>_<page_type>.svg` by source order |
56
-
57
- ### Standard mode
58
-
59
- | # | Filename | Purpose | Description |
60
- |---|----------|---------|-------------|
61
- | 01 | `01_cover.svg` | Cover | Fixed structure: title, subtitle, date, organization |
62
- | 02 | `02_chapter.svg` | Chapter page | Fixed structure: chapter number, chapter title |
63
- | 03 | `03_content.svg` | Content page | Flexible structure: only defines header/footer; content area freely laid out by AI |
64
- | 04 | `04_ending.svg` | Ending page | Fixed structure: thank-you message, contact info |
65
- | -- | `02_toc.svg` | Table of contents | Optional: TOC title, chapter list (number + title) |
66
-
67
- **Design philosophy**: Templates define visual consistency and structural pages; content pages maintain maximum flexibility.
68
-
69
- **Naming note**: TOC page keeps `02_toc.svg` naming for template library compatibility and sort order.
70
-
71
- ### Fidelity mode
72
-
73
- When the brief sets `Replication mode: fidelity`, derive the page roster from `manifest.json` page-type clusters and emit one SVG per distinct visual cluster.
74
-
75
- **Variant naming**: append a lowercase letter suffix to the parent type's index, preserving sort order:
76
-
77
- | Parent type | Example variants |
78
- |-------------|------------------|
79
- | Chapter | `02a_chapter_full.svg`, `02b_chapter_minimal.svg` |
80
- | Content | `03a_content_two_col.svg`, `03b_content_data_card.svg`, `03c_content_quote.svg` |
81
- | Ending | `04a_ending_thanks.svg`, `04b_ending_contact.svg` |
82
-
83
- Extension page types beyond the canonical four (transition / appendix / disclaimer / divider) take the next free index: `05_section_break.svg`, `06_appendix.svg`, `07_disclaimer.svg`.
84
-
85
- **Roster decision**:
86
-
87
- - Cluster slides from `manifest.json` by `pageType` + visual structure (column count, hero-image vs. icon-grid vs. quote, etc.)
88
- - One SVG per cluster — do **not** emit a variant for a cluster represented by a single source slide unless that slide is structurally distinct from existing variants
89
- - One variant per visually distinct cluster — let the source's structural diversity drive the count. Collapse only **near-duplicates** (same column count, same hero element, same content density); do not collapse genuine structural differences just to keep the variant count down. If you find yourself wanting one variant per source slide, that is the signal the user should be in `mirror` mode, not `fidelity`
90
- - Record every emitted page in `design_spec.md §V Page Roster`; the corresponding index entry (`decks_index.json` or `layouts_index.json`) is generated automatically by `register_template.py` from the directory's actual SVG files
91
-
92
- > Variants reuse the parent type's placeholder set — see §4 (Placeholder Reference) below.
93
-
94
- ### Mirror mode
95
-
96
- When the brief sets `Replication mode: mirror`, the role does **not** abstract or reconstruct. Each source slide becomes one template page **byte-for-byte**:
97
-
98
- - Source: `<import_workspace>/svg-flat/slide_NN.svg` (the self-contained "what PowerPoint shows" view). Do **not** read or use `svg/master_*.svg`, `svg/layout_*.svg`, or `svg/inheritance.json` — chrome / content separation is irrelevant because mirror does not insert placeholders.
99
- - Output: `templates/<kind_dir>/<template_id>/<NNN>_<page_type>.svg`, where `<NNN>` is the zero-padded source slide index (3 digits) and `<page_type>` is derived from `manifest.json` `pageTypeCandidates` — `cover` / `toc` / `chapter` / `content` / `ending`. When the page-type heuristic is ambiguous, fall back to `content`. Preserve source slide order via the numeric prefix.
100
- - Modifications allowed: **only** rewriting `<image href="...">` paths to point at the local `assets/` copy, and renaming asset files to semantic names. Everything else — geometry, decoration, sprite-sheet wrappers, original example text, chart placeholders, embedded fonts — is copied as-is.
101
- - Modifications forbidden: inserting `{{TITLE}}` / `{{CONTENT_AREA}}` / any other placeholder; "cleaning up" decorative complexity; merging similar slides; dropping master/layout chrome (it's already baked into the flat SVG, leave it).
102
- - `design_spec.md` §V Page Roster lists every emitted file with **a one-line description** of what the page contains and what content slot it suits — Strategist selects pages from these descriptions, since the SVG itself carries no placeholder contract.
103
-
104
- **Mirror consumption boundary**: `mirror` applies only while creating the template package from the source deck. Once created, the package is consumed as an ordinary deck / layout template roster: downstream generation may select, repeat, skip, reorder, or adapt pages according to the new content. The `replication_mode: mirror` field must not force the generated deck to preserve the source page count, source order, or one-output-slide-per-template-slide mapping.
105
-
106
- **What mirror is not**: a pixel-perfect re-rendering pipeline test. Charts, SmartArt, OLE objects, and EMF / WMF media that fail to round-trip in `pptx_template_import.py` will fail the same way in mirror. If the import workspace has missing media or unsupported objects, mirror inherits those gaps — the user should be told before generation begins.
107
-
108
- ---
109
-
110
- ## Template Design Specifications
111
-
112
- ### 1. Must Generate design_spec.md
113
-
114
- **Scope rule — personality only.** A template `design_spec.md` describes **what makes this template recognizable**: brand colors, signature decorative motifs, page-by-page visual character, bundled assets. It does **not** restate generic constraints — those live in the canonical references and are already loaded by every downstream role:
115
-
116
- - SVG technical constraints, PPT compatibility rules → [`shared-standards.md`](shared-standards.md)
117
- - Generic layout pattern library, spacing bands, font-size ratio bands → [`templates/design_spec_reference.md`](../templates/design_spec_reference.md) (read by Strategist when authoring the **project** design_spec)
118
- - Canonical placeholder vocabulary → §4 below
119
- - Content methodology (pyramid / SCQA / MECE) → [`strategist.md`](strategist.md)
120
-
121
- Re-declaring any of these in a template `design_spec.md` is noise — Strategist already has them in context, and duplication forces every relaxation to sweep N templates instead of one source. **If a rule is generic, omit it. If this template breaks a generic rule, write only the deviation.**
122
-
123
- **Required skeleton:**
124
-
125
- ```markdown
126
- ---
127
- template_id: <id>
128
- category: brand | general | scenario | government | special
129
- summary: <one-line tone & use case>
130
- keywords: [tag1, tag2, tag3]
131
- primary_color: "#......"
132
- canvas_format: ppt169
133
- canvas_width: 1280
134
- canvas_height: 720
135
- canvas_viewbox: "0 0 1280 720"
136
- # Required when a PPTX/SVG source canvas is known; keep equal to canvas_* unless explicitly normalized.
137
- source_canvas_width: 1280
138
- source_canvas_height: 720
139
- source_viewbox: "0 0 1280 720"
140
- replication_mode: standard | fidelity | mirror
141
- # Optional — only when this template overrides canonical placeholder vocabulary.
142
- # Omit entirely for `mirror` mode (mirror has no placeholders).
143
- # placeholders:
144
- # 01_cover: ["{{TITLE}}", "{{SUBTITLE}}", "{{BRAND_LOGO}}"]
145
- # 03_content: ["{{KEY_MESSAGE}}", "{{CONTENT_AREA}}"]
146
- ---
147
-
148
- # [Template Name] — Design Specification
149
-
150
- ## I. Template Overview
151
- - Use cases, design tone, theme mode (light / dark / mixed)
152
- - One paragraph: what visually identifies this template at a glance
153
-
154
- ## II. Color Scheme
155
- - HEX values with role labels (primary / accent / background / text / etc.)
156
- - Brand-specific application rules when present (e.g. "KPI cards rotate blue→green→red→yellow")
157
-
158
- ## III. Typography (omit when using the default `Arial, "Microsoft YaHei", sans-serif` stack)
159
- - Per-role font stacks ONLY when the template intentionally diverges (display serif title, brand typeface, etc.)
160
- - Font-install or embedding requirement when a non-preinstalled font leads any stack
161
- - Body baseline px (informational; `spec_lock.md` owns the actual values per project)
162
-
163
- ## IV. Signature Design Elements
164
- - Decorative motifs that ARE this template — top bar, gradient underline, logo treatment, brand emblem placement
165
- - Source-derived layout grammar — grid / column rhythm, page chrome, image zones, mask / crop behavior, overlay treatment, and density rhythm that make the template recognizable
166
- - Optional XML snippet for any reusable component unique to this template
167
-
168
- ## V. Page Roster
169
- One row per emitted SVG describing what this template's version of cover / chapter / content / ending looks like (background treatment, decorative anchors, layout rhythm, image behavior, content density, intended content slot). For `fidelity` mode, also note the cluster source and visual differentiator. For `mirror` mode the roster is the **load-bearing artifact** — Strategist picks pages from these descriptions, so each row must include enough detail to distinguish it from siblings (column count, hero element, content density, what kind of content slot it fits — "three-column KPI grid with large numbers, suits quarterly summary"). Roster entries must match the actual SVG files on disk.
170
-
171
- ## VI. Assets (omit when none)
172
- Logos, cover backgrounds, brand textures bundled with the template package — file name, dimensions, intended usage.
173
-
174
- ## VII. Placeholder Overrides (omit when none)
175
- Reference the `placeholders:` frontmatter declaration and explain the rationale (e.g. "consulting decks lead with `{{KEY_MESSAGE}}` instead of `{{PAGE_TITLE}}`").
176
- ```
177
-
178
- Sections to **omit** from template `design_spec.md` (sourced elsewhere — listing them here is noise):
179
-
180
- | Don't write | Source |
181
- |---|---|
182
- | SVG technical constraints / Mandatory rules / Prohibited elements | `shared-standards.md` §1 |
183
- | PPT compatibility rules (`<g opacity>`, inline-styles-only, etc.) | `shared-standards.md` |
184
- | Generic layout pattern library (centered card / 三栏 / timeline / …) | `design_spec_reference.md` §V |
185
- | Generic spacing bands (margin 40-60px, card gap 20-32px, etc.) | `design_spec_reference.md` §V |
186
- | Generic font-size hierarchy (cover 2.5-5x body, page title 1.5-2x, …) | `design_spec_reference.md` §IV |
187
- | Canonical placeholder table (`{{TITLE}}`, `{{PAGE_NUM}}`, …) | §4 below |
188
- | Content methodology (pyramid / SCQA / MECE / 金字塔) | `strategist.md` |
189
- | "Usage Instructions" boilerplate (copy template / select page / …) | `create-template.md` |
190
- | Created Date / Page Count rows | not a library-level field |
191
-
192
- When rewriting an existing template that contains the omitted sections, delete them — do not leave a "see XXX" pointer behind. The pointer is what this scope rule replaces.
193
-
194
- ### 2. Inherit Design Specification
195
-
196
- Templates must strictly follow the finalized template brief and the generated `design_spec.md`:
197
- - **Canvas dimensions**: `canvas_format` is not enough; root SVG `viewBox` matches `canvas_viewbox` in the design spec. Root `width` / `height` are optional compatibility attributes and are not PPT Master canvas authority.
198
- - **Source canvas**: when a PPTX/SVG reference is used, record `source_canvas_width`, `source_canvas_height`, and `source_viewbox`. If the output canvas differs from the source, normalize all geometry, typography, line heights, strokes, and image crop coordinates explicitly instead of relying on the shared aspect ratio.
199
- - **Color scheme**: Uses primary, secondary, and accent colors from the spec
200
- - **Font plan**: Uses the per-role font families declared in the spec
201
- - **Layout principles**: Margins and spacing conform to the spec
202
- - **Image system**: Image placement, crop / mask behavior, full-bleed zones, and overlay rules follow the source-derived norms in the spec
203
-
204
- If PPTX import output exists:
205
- - Prefer imported theme colors and fonts over visually guessed values
206
- - Reuse exported `assets/` images directly — `<image>` references in `svg/` already point at canonical files
207
- - Treat page-type candidates from `manifest.pageTypeCandidates` as hints, not guarantees
208
-
209
- **Precondition**:
210
-
211
- - When PPTX import output is provided, do not generate any template SVG or `design_spec.md` until every file under `<import_workspace>/svg/` has been read — including `master_*.svg`, `layout_*.svg`, and every `slide_*.svg`
212
- - Before template generation begins, explicitly report the read slide indexes
213
-
214
- ### 2.1 PPTX Import Simplification Rule
215
-
216
- The imported PPTX is a **reference source**, not a direct conversion target.
217
-
218
- Do:
219
- - preserve brand assets, recurring backgrounds, and stable structural motifs
220
- - rebuild the layout into a clean SVG structure aligned with PPT Master constraints
221
- - simplify repeated decorative fragments into a smaller number of maintainable SVG elements
222
- - use a background image asset when the original decorative layer is too complex to recreate cleanly
223
- - use cleaned slide SVG references to inspect composition, spacing, text hierarchy, and fixed decorative structure only after factual metadata has been anchored
224
- - read every reference SVG under `svg/` — `master_*.svg`, `layout_*.svg`, and every `slide_*.svg` regardless of slide count. Master / layout files describe the deck's shared visual language (read first); slide files describe per-page content (read after). Partial coverage drops template fidelity.
225
- - rename adopted assets to semantic names (`cover_bg.png`, `brand_emblem.png`) rather than carrying raw `image3.png` into the final template
226
-
227
- Do not:
228
- - attempt 1:1 translation of every PowerPoint shape, group, shadow, or decorative fragment
229
- - mirror PPT-specific complexity when it makes the resulting SVG brittle or hard to edit
230
- - introduce dense low-value vector detail that does not materially improve template reuse
231
-
232
- ### 3. Placeholder Markers
233
-
234
- > **Mirror mode skips this section entirely.** Mirror SVGs are verbatim copies of the source flat slides — they carry no `{{}}` markers. Mirror is only a template-creation mode; downstream generation treats the finished files as normal template roster candidates. The rest of this section applies to `standard` and `fidelity` only.
235
-
236
- Use clear placeholder markers for replaceable content:
237
-
238
- ```xml
239
- <!-- Text placeholder -->
240
- <text x="80" y="320" fill="#FFFFFF" font-size="48" font-weight="bold">
241
- {{TITLE}}
242
- </text>
243
-
244
- <!-- Content area placeholder (content page only) -->
245
- <rect x="40" y="90" width="1200" height="550" fill="#FFFFFF" rx="8"/>
246
- <text x="640" y="365" text-anchor="middle" fill="#CBD5E1" font-size="16">
247
- {{CONTENT_AREA}}
248
- </text>
249
- ```
250
-
251
- ### 4. Placeholder Reference (canonical convention, overridable per template)
252
-
253
- This is the **default vocabulary** used across the library. Newly created templates SHOULD prefer these names so projects that consume the library find familiar slots; designers MAY substitute or extend them when a style genuinely needs different vocabulary (e.g. consulting decks lead with `{{KEY_MESSAGE}}` instead of `{{PAGE_TITLE}}`; a brand cover may need `{{BRAND_LOGO}}`).
254
-
255
- `svg_quality_checker.py --template-mode` emits **advisory warnings** when a page lacks the conventional placeholder for its type. To silence those warnings — and document the template's actual contract — declare a `placeholders:` map in `design_spec.md` frontmatter:
256
-
257
- ```yaml
258
- placeholders:
259
- 01_cover: ["{{TITLE}}", "{{SUBTITLE}}", "{{BRAND_LOGO}}"]
260
- 03_content: ["{{KEY_MESSAGE}}", "{{CONTENT_AREA}}"]
261
- 03a_content_dual_col: [] # explicitly assert "no required placeholders"
262
- ```
263
-
264
- | Placeholder | Purpose | Applicable page | Convention role |
265
- |------------|---------|-------------------|--------|
266
- | `{{TITLE}}` | Main title | Cover | Default |
267
- | `{{SUBTITLE}}` | Subtitle | Cover | Default |
268
- | `{{DATE}}` | Date | Cover | Default |
269
- | `{{AUTHOR}}` | Author / Organization | Cover | Default |
270
- | `{{CHAPTER_NUM}}` | Chapter number | Chapter page | Default |
271
- | `{{CHAPTER_TITLE}}` | Chapter title | Chapter page | Default |
272
- | `{{CHAPTER_DESC}}` | Chapter description | Chapter page | Optional |
273
- | `{{PAGE_TITLE}}` | Page title | Content page | Default |
274
- | `{{CONTENT_AREA}}` | Content area | Content page | Default |
275
- | `{{PAGE_NUM}}` | Page number | Content page, ending page | Default |
276
- | `{{KEY_MESSAGE}}` | Key takeaway | Content page (consulting style) | Style-specific |
277
- | `{{SECTION_NAME}}` | Section name | Content page footer | Optional |
278
- | `{{SOURCE}}` | Data source | Content page footer | Optional |
279
- | `{{THANK_YOU}}` | Thank-you message | Ending page | Default |
280
- | `{{CONTACT_INFO}}` | Contact info | Ending page | Default |
281
- | `{{ENDING_SUBTITLE}}` | Ending subtitle | Ending page | Optional |
282
- | `{{CLOSING_MESSAGE}}` | Closing message | Ending page | Style-specific |
283
- | `{{COPYRIGHT}}` | Copyright | Ending page | Optional |
284
-
285
- For TOC pages in **newly created library templates**, use indexed placeholders:
286
-
287
- - `{{TOC_ITEM_1_TITLE}}`, `{{TOC_ITEM_1_DESC}}`
288
- - `{{TOC_ITEM_2_TITLE}}`, `{{TOC_ITEM_2_DESC}}`
289
- - ...
290
-
291
- Do **not** create new TOC placeholder families such as `{{CHAPTER_01_TITLE}}` for new templates. Existing templates may contain legacy placeholder variants, but new library assets should converge on the indexed TOC contract.
292
-
293
- Variants reuse their parent type's placeholder set by default: every `03*_content*.svg` shares the content placeholder list above, unless the spec frontmatter declares an override for that specific stem.
294
-
295
- When rebuilding from imported PPTX references, placeholder insertion takes priority over visual mimicry. If the original layout leaves insufficient room for canonical placeholders, adjust the layout instead of inventing one-off placeholder families — or, if the deviation is intentional and meaningful, declare it in frontmatter.
296
-
297
- ---
298
-
299
- ## Output Requirements
300
-
301
- ### File Save Location
302
-
303
- Standard mode (default):
304
-
305
- ```
306
- templates/<kind_dir>/<template_name>/
307
- ├── design_spec.md # Design specification (required)
308
- ├── 01_cover.svg
309
- ├── 02_chapter.svg
310
- ├── 02_toc.svg # Optional
311
- ├── 03_content.svg
312
- ├── 04_ending.svg
313
- └── *.png / *.jpg # Image assets (if any)
314
- ```
315
-
316
- Fidelity mode adds variants and extension pages, e.g.:
317
-
318
- ```
319
- templates/<kind_dir>/<template_name>/
320
- ├── design_spec.md
321
- ├── 01_cover.svg
322
- ├── 02a_chapter_full.svg
323
- ├── 02b_chapter_minimal.svg
324
- ├── 02_toc.svg
325
- ├── 03a_content_two_col.svg
326
- ├── 03b_content_data_card.svg
327
- ├── 03c_content_quote.svg
328
- ├── 04_ending.svg
329
- ├── 05_section_break.svg
330
- └── *.png / *.jpg
331
- ```
332
-
333
- Mirror mode emits one SVG per source slide, named by source order:
334
-
335
- ```
336
- templates/<kind_dir>/<template_name>/
337
- ├── design_spec.md
338
- ├── 001_cover.svg
339
- ├── 002_toc.svg
340
- ├── 003_content.svg
341
- ├── 004_content.svg
342
- ├── 005_chapter.svg
343
- ├── 006_content.svg
344
- ├── ...
345
- ├── 049_content.svg
346
- ├── 050_ending.svg
347
- └── *.png / *.jpg
348
- ```
349
-
350
- Filenames preserve the source slide order via the 3-digit prefix; `<page_type>` is derived from `manifest.json` `pageTypeCandidates`. No `{{}}` placeholders appear in any mirror SVG.
351
-
352
- ### Template Preview
353
-
354
- After each template is generated, provide a brief summary table listing each template's status.
355
-
356
- If the template is based on PPTX import output, briefly note:
357
- - which extracted assets were reused directly
358
- - which complex original decorations were intentionally simplified
359
- - whether any page-type mapping required judgment beyond the import heuristic
360
-
361
- ---
362
-
363
- ## Using Pre-built Template Library (Optional)
364
-
365
- If suitable template resources already exist, use them directly instead of generating new ones:
366
-
367
- 1. **Copy template**: copy the spec + template SVGs into the project's `templates/`, and any bundled bitmaps into the project's `images/` (the runtime image pool, referenced as `../images/`)
368
- 2. **Adjust colors**: Modify colors per the project design spec
369
- 3. **Customize**: Make project-specific adjustments
370
-
371
- This section describes downstream reuse. The `Template_Designer` role itself is responsible for creating or normalizing the reusable library asset first.
372
-
373
- **Example library structure** (query the appropriate kind's index — `templates/layouts/layouts_index.json` for structure-only templates, `templates/decks/decks_index.json` for full-PPT replicas, `templates/brands/brands_index.json` for identity-only presets):
374
-
375
- ```
376
- templates/
377
- ├── brands/
378
- │ ├── anthropic/ # Anthropic brand identity (logo + colors + typography)
379
- │ └── google/ # Google brand identity
380
- ├── layouts/
381
- │ ├── academic_defense/ # Academic-defense structure (no identity)
382
- │ └── pixel_retro/ # Pixel retro / cyberpunk structure (no identity)
383
- └── decks/
384
- ├── 招商银行/ # China Merchants Bank full PPT replica
385
- └── 中国电建/ # PowerChina full PPT replica
386
- ```
387
-
388
- ---
389
-
390
- ## Phase Completion Checkpoint
391
-
392
- ```markdown
393
- ## Template_Designer Phase Complete
394
-
395
- - [x] Read `references/template-designer.md`
396
- - [x] Replication mode confirmed: `standard` | `fidelity` | `mirror`
397
- - [x] Every page listed in `design_spec.md §V Page Roster` saved to `templates/<layouts|decks>/<template_name>/` (decks for full-PPT replicas, layouts for structure-only)
398
- - [x] Naming convention applied (standard / fidelity: letter-suffix variants; mirror: `<NNN>_<page_type>.svg`)
399
- - [x] Templates follow design spec (colors, fonts, layout)
400
- - [x] Placeholder markers are clear and standardized (standard / fidelity); mirror SVGs contain **no** `{{}}` markers
401
- - [ ] **Next step**: Validate assets and register the template via `register_template.py <id> --kind <deck|layout>`
402
- ```
1
+ > See shared-standards.md for common technical constraints.
2
+
3
+ # Template Designer — Template Design Role
4
+
5
+ ## Core Mission
6
+
7
+ Generate reusable page templates for the **global template library** based on a finalized template brief, and write a concise `design_spec.md` that captures the source-derived basic norms that make the template reusable.
8
+
9
+ > This is a standalone role: only triggered via the `/create-template` workflow. It is **not** the project-level template selection/customization step in the main PPT generation pipeline.
10
+
11
+ ## Usage
12
+
13
+ - **Trigger**: `/create-template` workflow
14
+ - **Output location**: `templates/<kind_dir>/<template_name>/` where `<kind_dir>` is `decks` (default — full-PPT replica with identity) or `layouts` (structure-only, no identity segment)
15
+ - **Input**: finalized template brief (template ID, display name, kind, applicable scenarios, tone, theme mode, canvas format, optional reference assets, accepted basic template norms)
16
+
17
+ When the workflow provides a PPTX reference source, the effective input package comes from the unified `pptx_template_import.py` preparation workspace and becomes:
18
+
19
+ - finalized template brief
20
+ - `manifest.json` — single source of truth (slide size, theme, per-master themes, assets, asset map, placeholders, layouts, masters, slides, SVG file paths, page-type candidates)
21
+ - `summary.md` — short orientation digest derived from manifest.json
22
+ - exported `assets/`
23
+ - `svg/master_*.svg` / `svg/layout_*.svg` — every master / layout in the deck rendered once as standalone SVG, including ones no sample slide references (template packages often ship more design surfaces than the embedded samples exercise)
24
+ - `svg/slide_NN.svg` — each slide's own shapes and slide-local background only; master / layout decoration and backgrounds are **not** inlined here
25
+ - `svg/inheritance.json` — which layout / master each slide consumes
26
+ - `svg-flat/slide_NN.svg` — companion view; each slide is self-contained so you can preview or screenshot a single page without losing the surrounding chrome. Use it as a sanity check for "what would PowerPoint actually show", not as an authoring source — the master/layout chrome will be duplicated across every flat slide.
27
+ - optional screenshots for visual cross-checking
28
+
29
+ PPTX import interpretation:
30
+
31
+ - Placeholder guides in master / layout SVGs are layout signals. Use `manifest.json` placeholder records for type / index / geometry / base style; do not copy dashed guide boxes into final templates unless the visual design truly uses dashed boxes.
32
+ - Charts, SmartArt, diagrams, and OLE objects may appear as typed placeholders in layered SVGs. In flat SVGs they may show preview images. Treat them as source intent markers, not reusable decorative assets.
33
+ - The asset filenames referenced by SVGs are governed by the manifest asset map. Prefer those references over inventing duplicate asset names.
34
+
35
+ Input priority for PPTX-backed template creation:
36
+
37
+ 1. `manifest.json` for all factual metadata (theme, assets, unique layout/master structure, slide reuse, page-type guidance)
38
+ 2. `svg/master_*.svg` + `svg/layout_*.svg` — the **primary source for the deck's shared visual language**: backgrounds, page chrome, decorative bars, recurring brand motifs. These are what the new template's fixed structure should adopt or reinterpret. Read these before any slide SVG.
39
+ 3. `svg/inheritance.json` for confirming which slide uses which layout / master
40
+ 4. exported `assets/` for reusable visual resources
41
+ 5. `svg/slide_NN.svg` — each slide's unique content, useful for judging composition rhythm and content density (not for fixed structure)
42
+ 6. `summary.md` only as a fast scan; never as the canonical fact source
43
+ 7. screenshots / original PPTX only for style verification
44
+
45
+ ---
46
+
47
+ ## Page Roster
48
+
49
+ The output page set is determined by **replication mode**, declared in the finalized template brief:
50
+
51
+ | Mode | When to use | Roster |
52
+ |------|-------------|--------|
53
+ | `standard` (default) | Most templates — clean, reusable, balanced coverage | `01_cover`, `02_chapter`, `03_content`, `04_ending`, optional `02_toc` |
54
+ | `fidelity` | User explicitly wants strict replication of a source PPTX, but still wants the AI to clean / cluster / cap variants | Standard roster + one variant per distinct layout cluster found in `manifest.json` |
55
+ | `mirror` | Creation-time harvesting mode: every source slide is preserved 1:1 as a reference page for the template package. Verbatim copy, no abstraction, no placeholders | One SVG per source slide, named `<NNN>_<page_type>.svg` by source order |
56
+
57
+ ### Standard mode
58
+
59
+ | # | Filename | Purpose | Description |
60
+ |---|----------|---------|-------------|
61
+ | 01 | `01_cover.svg` | Cover | Fixed structure: title, subtitle, date, organization |
62
+ | 02 | `02_chapter.svg` | Chapter page | Fixed structure: chapter number, chapter title |
63
+ | 03 | `03_content.svg` | Content page | Flexible structure: only defines header/footer; content area freely laid out by AI |
64
+ | 04 | `04_ending.svg` | Ending page | Fixed structure: thank-you message, contact info |
65
+ | -- | `02_toc.svg` | Table of contents | Optional: TOC title, chapter list (number + title) |
66
+
67
+ **Design philosophy**: Templates define visual consistency and structural pages; content pages maintain maximum flexibility.
68
+
69
+ **Naming note**: TOC page keeps `02_toc.svg` naming for template library compatibility and sort order.
70
+
71
+ ### Fidelity mode
72
+
73
+ When the brief sets `Replication mode: fidelity`, derive the page roster from `manifest.json` page-type clusters and emit one SVG per distinct visual cluster.
74
+
75
+ **Variant naming**: append a lowercase letter suffix to the parent type's index, preserving sort order:
76
+
77
+ | Parent type | Example variants |
78
+ |-------------|------------------|
79
+ | Chapter | `02a_chapter_full.svg`, `02b_chapter_minimal.svg` |
80
+ | Content | `03a_content_two_col.svg`, `03b_content_data_card.svg`, `03c_content_quote.svg` |
81
+ | Ending | `04a_ending_thanks.svg`, `04b_ending_contact.svg` |
82
+
83
+ Extension page types beyond the canonical four (transition / appendix / disclaimer / divider) take the next free index: `05_section_break.svg`, `06_appendix.svg`, `07_disclaimer.svg`.
84
+
85
+ **Roster decision**:
86
+
87
+ - Cluster slides from `manifest.json` by `pageType` + visual structure (column count, hero-image vs. icon-grid vs. quote, etc.)
88
+ - One SVG per cluster — do **not** emit a variant for a cluster represented by a single source slide unless that slide is structurally distinct from existing variants
89
+ - One variant per visually distinct cluster — let the source's structural diversity drive the count. Collapse only **near-duplicates** (same column count, same hero element, same content density); do not collapse genuine structural differences just to keep the variant count down. If you find yourself wanting one variant per source slide, that is the signal the user should be in `mirror` mode, not `fidelity`
90
+ - Record every emitted page in `design_spec.md §V Page Roster`; the corresponding index entry (`decks_index.json` or `layouts_index.json`) is generated automatically by `register_template.py` from the directory's actual SVG files
91
+
92
+ > Variants reuse the parent type's placeholder set — see §4 (Placeholder Reference) below.
93
+
94
+ ### Mirror mode
95
+
96
+ When the brief sets `Replication mode: mirror`, the role does **not** abstract or reconstruct. Each source slide becomes one template page **byte-for-byte**:
97
+
98
+ - Source: `<import_workspace>/svg-flat/slide_NN.svg` (the self-contained "what PowerPoint shows" view). Do **not** read or use `svg/master_*.svg`, `svg/layout_*.svg`, or `svg/inheritance.json` — chrome / content separation is irrelevant because mirror does not insert placeholders.
99
+ - Output: `templates/<kind_dir>/<template_id>/<NNN>_<page_type>.svg`, where `<NNN>` is the zero-padded source slide index (3 digits) and `<page_type>` is derived from `manifest.json` `pageTypeCandidates` — `cover` / `toc` / `chapter` / `content` / `ending`. When the page-type heuristic is ambiguous, fall back to `content`. Preserve source slide order via the numeric prefix.
100
+ - Modifications allowed: **only** rewriting `<image href="...">` paths to point at the local `assets/` copy, and renaming asset files to semantic names. Everything else — geometry, decoration, sprite-sheet wrappers, original example text, chart placeholders, embedded fonts — is copied as-is.
101
+ - Modifications forbidden: inserting `{{TITLE}}` / `{{CONTENT_AREA}}` / any other placeholder; "cleaning up" decorative complexity; merging similar slides; dropping master/layout chrome (it's already baked into the flat SVG, leave it).
102
+ - `design_spec.md` §V Page Roster lists every emitted file with **a one-line description** of what the page contains and what content slot it suits — Strategist selects pages from these descriptions, since the SVG itself carries no placeholder contract.
103
+
104
+ **Mirror consumption boundary**: `mirror` applies only while creating the template package from the source deck. Once created, the package is consumed as an ordinary deck / layout template roster: downstream generation may select, repeat, skip, reorder, or adapt pages according to the new content. The `replication_mode: mirror` field must not force the generated deck to preserve the source page count, source order, or one-output-slide-per-template-slide mapping.
105
+
106
+ **What mirror is not**: a pixel-perfect re-rendering pipeline test. Charts, SmartArt, OLE objects, and EMF / WMF media that fail to round-trip in `pptx_template_import.py` will fail the same way in mirror. If the import workspace has missing media or unsupported objects, mirror inherits those gaps — the user should be told before generation begins.
107
+
108
+ ---
109
+
110
+ ## Template Design Specifications
111
+
112
+ ### 1. Must Generate design_spec.md
113
+
114
+ **Scope rule — personality only.** A template `design_spec.md` describes **what makes this template recognizable**: brand colors, signature decorative motifs, page-by-page visual character, bundled assets. It does **not** restate generic constraints — those live in the canonical references and are already loaded by every downstream role:
115
+
116
+ - SVG technical constraints, PPT compatibility rules → [`shared-standards.md`](shared-standards.md)
117
+ - Generic layout pattern library, spacing bands, font-size ratio bands → [`templates/design_spec_reference.md`](../templates/design_spec_reference.md) (read by Strategist when authoring the **project** design_spec)
118
+ - Canonical placeholder vocabulary → §4 below
119
+ - Content methodology (pyramid / SCQA / MECE) → [`strategist.md`](strategist.md)
120
+
121
+ Re-declaring any of these in a template `design_spec.md` is noise — Strategist already has them in context, and duplication forces every relaxation to sweep N templates instead of one source. **If a rule is generic, omit it. If this template breaks a generic rule, write only the deviation.**
122
+
123
+ **Required skeleton:**
124
+
125
+ ```markdown
126
+ ---
127
+ template_id: <id>
128
+ category: brand | general | scenario | government | special
129
+ summary: <one-line tone & use case>
130
+ keywords: [tag1, tag2, tag3]
131
+ primary_color: "#......"
132
+ canvas_format: ppt169
133
+ canvas_width: 1280
134
+ canvas_height: 720
135
+ canvas_viewbox: "0 0 1280 720"
136
+ # Required when a PPTX/SVG source canvas is known; keep equal to canvas_* unless explicitly normalized.
137
+ source_canvas_width: 1280
138
+ source_canvas_height: 720
139
+ source_viewbox: "0 0 1280 720"
140
+ replication_mode: standard | fidelity | mirror
141
+ # Optional — only when this template overrides canonical placeholder vocabulary.
142
+ # Omit entirely for `mirror` mode (mirror has no placeholders).
143
+ # placeholders:
144
+ # 01_cover: ["{{TITLE}}", "{{SUBTITLE}}", "{{BRAND_LOGO}}"]
145
+ # 03_content: ["{{KEY_MESSAGE}}", "{{CONTENT_AREA}}"]
146
+ ---
147
+
148
+ # [Template Name] — Design Specification
149
+
150
+ ## I. Template Overview
151
+ - Use cases, design tone, theme mode (light / dark / mixed)
152
+ - One paragraph: what visually identifies this template at a glance
153
+
154
+ ## II. Color Scheme
155
+ - HEX values with role labels (primary / accent / background / text / etc.)
156
+ - Brand-specific application rules when present (e.g. "KPI cards rotate blue→green→red→yellow")
157
+
158
+ ## III. Typography (omit when using the default `Arial, "Microsoft YaHei", sans-serif` stack)
159
+ - Per-role font stacks ONLY when the template intentionally diverges (display serif title, brand typeface, etc.)
160
+ - Font-install or embedding requirement when a non-preinstalled font leads any stack
161
+ - Body baseline px (informational; `spec_lock.md` owns the actual values per project)
162
+
163
+ ## IV. Signature Design Elements
164
+ - Decorative motifs that ARE this template — top bar, gradient underline, logo treatment, brand emblem placement
165
+ - Source-derived layout grammar — grid / column rhythm, page chrome, image zones, mask / crop behavior, overlay treatment, and density rhythm that make the template recognizable
166
+ - Optional XML snippet for any reusable component unique to this template
167
+
168
+ ## V. Page Roster
169
+ One row per emitted SVG describing what this template's version of cover / chapter / content / ending looks like (background treatment, decorative anchors, layout rhythm, image behavior, content density, intended content slot). For `fidelity` mode, also note the cluster source and visual differentiator. For `mirror` mode the roster is the **load-bearing artifact** — Strategist picks pages from these descriptions, so each row must include enough detail to distinguish it from siblings (column count, hero element, content density, what kind of content slot it fits — "three-column KPI grid with large numbers, suits quarterly summary"). Roster entries must match the actual SVG files on disk.
170
+
171
+ ## VI. Assets (omit when none)
172
+ Logos, cover backgrounds, brand textures bundled with the template package — file name, dimensions, intended usage.
173
+
174
+ ## VII. Placeholder Overrides (omit when none)
175
+ Reference the `placeholders:` frontmatter declaration and explain the rationale (e.g. "consulting decks lead with `{{KEY_MESSAGE}}` instead of `{{PAGE_TITLE}}`").
176
+ ```
177
+
178
+ Sections to **omit** from template `design_spec.md` (sourced elsewhere — listing them here is noise):
179
+
180
+ | Don't write | Source |
181
+ |---|---|
182
+ | SVG technical constraints / Mandatory rules / Prohibited elements | `shared-standards.md` §1 |
183
+ | PPT compatibility rules (`<g opacity>`, inline-styles-only, etc.) | `shared-standards.md` |
184
+ | Generic layout pattern library (centered card / 三栏 / timeline / …) | `design_spec_reference.md` §V |
185
+ | Generic spacing bands (margin 40-60px, card gap 20-32px, etc.) | `design_spec_reference.md` §V |
186
+ | Generic font-size hierarchy (cover 2.5-5x body, page title 1.5-2x, …) | `design_spec_reference.md` §IV |
187
+ | Canonical placeholder table (`{{TITLE}}`, `{{PAGE_NUM}}`, …) | §4 below |
188
+ | Content methodology (pyramid / SCQA / MECE / 金字塔) | `strategist.md` |
189
+ | "Usage Instructions" boilerplate (copy template / select page / …) | `create-template.md` |
190
+ | Created Date / Page Count rows | not a library-level field |
191
+
192
+ When rewriting an existing template that contains the omitted sections, delete them — do not leave a "see XXX" pointer behind. The pointer is what this scope rule replaces.
193
+
194
+ ### 2. Inherit Design Specification
195
+
196
+ Templates must strictly follow the finalized template brief and the generated `design_spec.md`:
197
+ - **Canvas dimensions**: `canvas_format` is not enough; root SVG `viewBox` matches `canvas_viewbox` in the design spec. Root `width` / `height` are optional compatibility attributes and are not PPT Master canvas authority.
198
+ - **Source canvas**: when a PPTX/SVG reference is used, record `source_canvas_width`, `source_canvas_height`, and `source_viewbox`. If the output canvas differs from the source, normalize all geometry, typography, line heights, strokes, and image crop coordinates explicitly instead of relying on the shared aspect ratio.
199
+ - **Color scheme**: Uses primary, secondary, and accent colors from the spec
200
+ - **Font plan**: Uses the per-role font families declared in the spec
201
+ - **Layout principles**: Margins and spacing conform to the spec
202
+ - **Image system**: Image placement, crop / mask behavior, full-bleed zones, and overlay rules follow the source-derived norms in the spec
203
+
204
+ If PPTX import output exists:
205
+ - Prefer imported theme colors and fonts over visually guessed values
206
+ - Reuse exported `assets/` images directly — `<image>` references in `svg/` already point at canonical files
207
+ - Treat page-type candidates from `manifest.pageTypeCandidates` as hints, not guarantees
208
+
209
+ **Precondition**:
210
+
211
+ - When PPTX import output is provided, do not generate any template SVG or `design_spec.md` until every file under `<import_workspace>/svg/` has been read — including `master_*.svg`, `layout_*.svg`, and every `slide_*.svg`
212
+ - Before template generation begins, explicitly report the read slide indexes
213
+
214
+ ### 2.1 PPTX Import Simplification Rule
215
+
216
+ The imported PPTX is a **reference source**, not a direct conversion target.
217
+
218
+ Do:
219
+ - preserve brand assets, recurring backgrounds, and stable structural motifs
220
+ - rebuild the layout into a clean SVG structure aligned with PPT Master constraints
221
+ - simplify repeated decorative fragments into a smaller number of maintainable SVG elements
222
+ - use a background image asset when the original decorative layer is too complex to recreate cleanly
223
+ - use cleaned slide SVG references to inspect composition, spacing, text hierarchy, and fixed decorative structure only after factual metadata has been anchored
224
+ - read every reference SVG under `svg/` — `master_*.svg`, `layout_*.svg`, and every `slide_*.svg` regardless of slide count. Master / layout files describe the deck's shared visual language (read first); slide files describe per-page content (read after). Partial coverage drops template fidelity.
225
+ - rename adopted assets to semantic names (`cover_bg.png`, `brand_emblem.png`) rather than carrying raw `image3.png` into the final template
226
+
227
+ Do not:
228
+ - attempt 1:1 translation of every PowerPoint shape, group, shadow, or decorative fragment
229
+ - mirror PPT-specific complexity when it makes the resulting SVG brittle or hard to edit
230
+ - introduce dense low-value vector detail that does not materially improve template reuse
231
+
232
+ ### 3. Placeholder Markers
233
+
234
+ > **Mirror mode skips this section entirely.** Mirror SVGs are verbatim copies of the source flat slides — they carry no `{{}}` markers. Mirror is only a template-creation mode; downstream generation treats the finished files as normal template roster candidates. The rest of this section applies to `standard` and `fidelity` only.
235
+
236
+ Use clear placeholder markers for replaceable content:
237
+
238
+ ```xml
239
+ <!-- Text placeholder -->
240
+ <text x="80" y="320" fill="#FFFFFF" font-size="48" font-weight="bold">
241
+ {{TITLE}}
242
+ </text>
243
+
244
+ <!-- Content area placeholder (content page only) -->
245
+ <rect x="40" y="90" width="1200" height="550" fill="#FFFFFF" rx="8"/>
246
+ <text x="640" y="365" text-anchor="middle" fill="#CBD5E1" font-size="16">
247
+ {{CONTENT_AREA}}
248
+ </text>
249
+ ```
250
+
251
+ ### 4. Placeholder Reference (canonical convention, overridable per template)
252
+
253
+ This is the **default vocabulary** used across the library. Newly created templates SHOULD prefer these names so projects that consume the library find familiar slots; designers MAY substitute or extend them when a style genuinely needs different vocabulary (e.g. consulting decks lead with `{{KEY_MESSAGE}}` instead of `{{PAGE_TITLE}}`; a brand cover may need `{{BRAND_LOGO}}`).
254
+
255
+ `svg_quality_checker.py --template-mode` emits **advisory warnings** when a page lacks the conventional placeholder for its type. To silence those warnings — and document the template's actual contract — declare a `placeholders:` map in `design_spec.md` frontmatter:
256
+
257
+ ```yaml
258
+ placeholders:
259
+ 01_cover: ["{{TITLE}}", "{{SUBTITLE}}", "{{BRAND_LOGO}}"]
260
+ 03_content: ["{{KEY_MESSAGE}}", "{{CONTENT_AREA}}"]
261
+ 03a_content_dual_col: [] # explicitly assert "no required placeholders"
262
+ ```
263
+
264
+ | Placeholder | Purpose | Applicable page | Convention role |
265
+ |------------|---------|-------------------|--------|
266
+ | `{{TITLE}}` | Main title | Cover | Default |
267
+ | `{{SUBTITLE}}` | Subtitle | Cover | Default |
268
+ | `{{DATE}}` | Date | Cover | Default |
269
+ | `{{AUTHOR}}` | Author / Organization | Cover | Default |
270
+ | `{{CHAPTER_NUM}}` | Chapter number | Chapter page | Default |
271
+ | `{{CHAPTER_TITLE}}` | Chapter title | Chapter page | Default |
272
+ | `{{CHAPTER_DESC}}` | Chapter description | Chapter page | Optional |
273
+ | `{{PAGE_TITLE}}` | Page title | Content page | Default |
274
+ | `{{CONTENT_AREA}}` | Content area | Content page | Default |
275
+ | `{{PAGE_NUM}}` | Page number | Content page, ending page | Default |
276
+ | `{{KEY_MESSAGE}}` | Key takeaway | Content page (consulting style) | Style-specific |
277
+ | `{{SECTION_NAME}}` | Section name | Content page footer | Optional |
278
+ | `{{SOURCE}}` | Data source | Content page footer | Optional |
279
+ | `{{THANK_YOU}}` | Thank-you message | Ending page | Default |
280
+ | `{{CONTACT_INFO}}` | Contact info | Ending page | Default |
281
+ | `{{ENDING_SUBTITLE}}` | Ending subtitle | Ending page | Optional |
282
+ | `{{CLOSING_MESSAGE}}` | Closing message | Ending page | Style-specific |
283
+ | `{{COPYRIGHT}}` | Copyright | Ending page | Optional |
284
+
285
+ For TOC pages in **newly created library templates**, use indexed placeholders:
286
+
287
+ - `{{TOC_ITEM_1_TITLE}}`, `{{TOC_ITEM_1_DESC}}`
288
+ - `{{TOC_ITEM_2_TITLE}}`, `{{TOC_ITEM_2_DESC}}`
289
+ - ...
290
+
291
+ Do **not** create new TOC placeholder families such as `{{CHAPTER_01_TITLE}}` for new templates. Existing templates may contain legacy placeholder variants, but new library assets should converge on the indexed TOC contract.
292
+
293
+ Variants reuse their parent type's placeholder set by default: every `03*_content*.svg` shares the content placeholder list above, unless the spec frontmatter declares an override for that specific stem.
294
+
295
+ When rebuilding from imported PPTX references, placeholder insertion takes priority over visual mimicry. If the original layout leaves insufficient room for canonical placeholders, adjust the layout instead of inventing one-off placeholder families — or, if the deviation is intentional and meaningful, declare it in frontmatter.
296
+
297
+ ---
298
+
299
+ ## Output Requirements
300
+
301
+ ### File Save Location
302
+
303
+ Standard mode (default):
304
+
305
+ ```
306
+ templates/<kind_dir>/<template_name>/
307
+ ├── design_spec.md # Design specification (required)
308
+ ├── 01_cover.svg
309
+ ├── 02_chapter.svg
310
+ ├── 02_toc.svg # Optional
311
+ ├── 03_content.svg
312
+ ├── 04_ending.svg
313
+ └── *.png / *.jpg # Image assets (if any)
314
+ ```
315
+
316
+ Fidelity mode adds variants and extension pages, e.g.:
317
+
318
+ ```
319
+ templates/<kind_dir>/<template_name>/
320
+ ├── design_spec.md
321
+ ├── 01_cover.svg
322
+ ├── 02a_chapter_full.svg
323
+ ├── 02b_chapter_minimal.svg
324
+ ├── 02_toc.svg
325
+ ├── 03a_content_two_col.svg
326
+ ├── 03b_content_data_card.svg
327
+ ├── 03c_content_quote.svg
328
+ ├── 04_ending.svg
329
+ ├── 05_section_break.svg
330
+ └── *.png / *.jpg
331
+ ```
332
+
333
+ Mirror mode emits one SVG per source slide, named by source order:
334
+
335
+ ```
336
+ templates/<kind_dir>/<template_name>/
337
+ ├── design_spec.md
338
+ ├── 001_cover.svg
339
+ ├── 002_toc.svg
340
+ ├── 003_content.svg
341
+ ├── 004_content.svg
342
+ ├── 005_chapter.svg
343
+ ├── 006_content.svg
344
+ ├── ...
345
+ ├── 049_content.svg
346
+ ├── 050_ending.svg
347
+ └── *.png / *.jpg
348
+ ```
349
+
350
+ Filenames preserve the source slide order via the 3-digit prefix; `<page_type>` is derived from `manifest.json` `pageTypeCandidates`. No `{{}}` placeholders appear in any mirror SVG.
351
+
352
+ ### Template Preview
353
+
354
+ After each template is generated, provide a brief summary table listing each template's status.
355
+
356
+ If the template is based on PPTX import output, briefly note:
357
+ - which extracted assets were reused directly
358
+ - which complex original decorations were intentionally simplified
359
+ - whether any page-type mapping required judgment beyond the import heuristic
360
+
361
+ ---
362
+
363
+ ## Using Pre-built Template Library (Optional)
364
+
365
+ If suitable template resources already exist, use them directly instead of generating new ones:
366
+
367
+ 1. **Copy template**: copy the spec + template SVGs into the project's `templates/`, and any bundled bitmaps into the project's `images/` (the runtime image pool, referenced as `../images/`)
368
+ 2. **Adjust colors**: Modify colors per the project design spec
369
+ 3. **Customize**: Make project-specific adjustments
370
+
371
+ This section describes downstream reuse. The `Template_Designer` role itself is responsible for creating or normalizing the reusable library asset first.
372
+
373
+ **Example library structure** (query the appropriate kind's index — `templates/layouts/layouts_index.json` for structure-only templates, `templates/decks/decks_index.json` for full-PPT replicas, `templates/brands/brands_index.json` for identity-only presets):
374
+
375
+ ```
376
+ templates/
377
+ ├── brands/
378
+ │ ├── anthropic/ # Anthropic brand identity (logo + colors + typography)
379
+ │ └── google/ # Google brand identity
380
+ ├── layouts/
381
+ │ ├── academic_defense/ # Academic-defense structure (no identity)
382
+ │ └── pixel_retro/ # Pixel retro / cyberpunk structure (no identity)
383
+ └── decks/
384
+ ├── 招商银行/ # China Merchants Bank full PPT replica
385
+ └── 中国电建/ # PowerChina full PPT replica
386
+ ```
387
+
388
+ ---
389
+
390
+ ## Phase Completion Checkpoint
391
+
392
+ ```markdown
393
+ ## Template_Designer Phase Complete
394
+
395
+ - [x] Read `references/template-designer.md`
396
+ - [x] Replication mode confirmed: `standard` | `fidelity` | `mirror`
397
+ - [x] Every page listed in `design_spec.md §V Page Roster` saved to `templates/<layouts|decks>/<template_name>/` (decks for full-PPT replicas, layouts for structure-only)
398
+ - [x] Naming convention applied (standard / fidelity: letter-suffix variants; mirror: `<NNN>_<page_type>.svg`)
399
+ - [x] Templates follow design spec (colors, fonts, layout)
400
+ - [x] Placeholder markers are clear and standardized (standard / fidelity); mirror SVGs contain **no** `{{}}` markers
401
+ - [ ] **Next step**: Validate assets and register the template via `register_template.py <id> --kind <deck|layout>`
402
+ ```