zcode-app-cli 3.3.5-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 (169) hide show
  1. package/LICENSE +24 -0
  2. package/README.md +642 -0
  3. package/bin/zcode.js +848 -0
  4. package/config.example.json +110 -0
  5. package/package.json +81 -0
  6. package/vendor/.node-bundle-meta.json +6 -0
  7. package/vendor/extraction.json +11 -0
  8. package/vendor/node_modules/@zcode/tui/dist/index.js +161875 -0
  9. package/vendor/node_modules/@zcode/tui/package.json +14 -0
  10. package/vendor/packages/android-emulator-plugin/.mcp.json +19 -0
  11. package/vendor/packages/android-emulator-plugin/.zcode-plugin/plugin.json +63 -0
  12. package/vendor/packages/android-emulator-plugin/README.md +134 -0
  13. package/vendor/packages/android-emulator-plugin/commands/android-dev.md +11 -0
  14. package/vendor/packages/android-emulator-plugin/dist/lib/path.d.ts +4 -0
  15. package/vendor/packages/android-emulator-plugin/dist/lib/path.js +17 -0
  16. package/vendor/packages/android-emulator-plugin/dist/lib/result.d.ts +5 -0
  17. package/vendor/packages/android-emulator-plugin/dist/lib/result.js +22 -0
  18. package/vendor/packages/android-emulator-plugin/dist/lib/run.d.ts +18 -0
  19. package/vendor/packages/android-emulator-plugin/dist/lib/run.js +99 -0
  20. package/vendor/packages/android-emulator-plugin/dist/mcp/server.d.ts +3 -0
  21. package/vendor/packages/android-emulator-plugin/dist/mcp/server.js +47607 -0
  22. package/vendor/packages/android-emulator-plugin/dist/providers/app.d.ts +39 -0
  23. package/vendor/packages/android-emulator-plugin/dist/providers/app.js +50 -0
  24. package/vendor/packages/android-emulator-plugin/dist/providers/avd.d.ts +37 -0
  25. package/vendor/packages/android-emulator-plugin/dist/providers/avd.js +185 -0
  26. package/vendor/packages/android-emulator-plugin/dist/providers/build.d.ts +68 -0
  27. package/vendor/packages/android-emulator-plugin/dist/providers/build.js +131 -0
  28. package/vendor/packages/android-emulator-plugin/dist/providers/config.d.ts +7 -0
  29. package/vendor/packages/android-emulator-plugin/dist/providers/config.js +29 -0
  30. package/vendor/packages/android-emulator-plugin/dist/providers/device.d.ts +20 -0
  31. package/vendor/packages/android-emulator-plugin/dist/providers/device.js +91 -0
  32. package/vendor/packages/android-emulator-plugin/dist/providers/logs.d.ts +15 -0
  33. package/vendor/packages/android-emulator-plugin/dist/providers/logs.js +31 -0
  34. package/vendor/packages/android-emulator-plugin/dist/providers/preflight.d.ts +15 -0
  35. package/vendor/packages/android-emulator-plugin/dist/providers/preflight.js +123 -0
  36. package/vendor/packages/android-emulator-plugin/dist/providers/project-template.d.ts +13 -0
  37. package/vendor/packages/android-emulator-plugin/dist/providers/project-template.js +211 -0
  38. package/vendor/packages/android-emulator-plugin/dist/providers/project.d.ts +33 -0
  39. package/vendor/packages/android-emulator-plugin/dist/providers/project.js +195 -0
  40. package/vendor/packages/android-emulator-plugin/dist/providers/screenshot.d.ts +14 -0
  41. package/vendor/packages/android-emulator-plugin/dist/providers/screenshot.js +73 -0
  42. package/vendor/packages/android-emulator-plugin/dist/providers/sdk.d.ts +14 -0
  43. package/vendor/packages/android-emulator-plugin/dist/providers/sdk.js +185 -0
  44. package/vendor/packages/android-emulator-plugin/dist/providers/ui.d.ts +92 -0
  45. package/vendor/packages/android-emulator-plugin/dist/providers/ui.js +146 -0
  46. package/vendor/packages/android-emulator-plugin/hooks/hooks.json +3 -0
  47. package/vendor/packages/android-emulator-plugin/package.json +35 -0
  48. package/vendor/packages/android-emulator-plugin/skills/android-dev/INSTALL_ENVIRONMENT.md +357 -0
  49. package/vendor/packages/android-emulator-plugin/skills/android-dev/SKILL.md +73 -0
  50. package/vendor/packages/android-emulator-plugin/templates/compose-app/README.md +5 -0
  51. package/vendor/packages/document-skills-plugin/.zcode-plugin/plugin.json +8 -0
  52. package/vendor/packages/document-skills-plugin/package.json +8 -0
  53. package/vendor/packages/document-skills-plugin/skills/docx/LICENSE.txt +13 -0
  54. package/vendor/packages/document-skills-plugin/skills/docx/SKILL.md +201 -0
  55. package/vendor/packages/document-skills-plugin/skills/docx/references/chart-templates.md +386 -0
  56. package/vendor/packages/document-skills-plugin/skills/docx/references/common-rules.md +419 -0
  57. package/vendor/packages/document-skills-plugin/skills/docx/references/decorations.md +537 -0
  58. package/vendor/packages/document-skills-plugin/skills/docx/references/design-system.md +1797 -0
  59. package/vendor/packages/document-skills-plugin/skills/docx/references/docx-js-advanced.md +257 -0
  60. package/vendor/packages/document-skills-plugin/skills/docx/references/docx-js-core.md +332 -0
  61. package/vendor/packages/document-skills-plugin/skills/docx/references/faq.md +323 -0
  62. package/vendor/packages/document-skills-plugin/skills/docx/references/math-formulas.md +276 -0
  63. package/vendor/packages/document-skills-plugin/skills/docx/references/ooxml.md +222 -0
  64. package/vendor/packages/document-skills-plugin/skills/docx/references/toc.md +264 -0
  65. package/vendor/packages/document-skills-plugin/skills/docx/routes/comment.md +88 -0
  66. package/vendor/packages/document-skills-plugin/skills/docx/routes/create.md +207 -0
  67. package/vendor/packages/document-skills-plugin/skills/docx/routes/edit.md +115 -0
  68. package/vendor/packages/document-skills-plugin/skills/docx/routes/format.md +120 -0
  69. package/vendor/packages/document-skills-plugin/skills/docx/routes/read.md +114 -0
  70. package/vendor/packages/document-skills-plugin/skills/docx/scenes/academic.md +783 -0
  71. package/vendor/packages/document-skills-plugin/skills/docx/scenes/contract.md +463 -0
  72. package/vendor/packages/document-skills-plugin/skills/docx/scenes/copywriting.md +139 -0
  73. package/vendor/packages/document-skills-plugin/skills/docx/scenes/exam.md +698 -0
  74. package/vendor/packages/document-skills-plugin/skills/docx/scenes/official-doc.md +411 -0
  75. package/vendor/packages/document-skills-plugin/skills/docx/scenes/report.md +340 -0
  76. package/vendor/packages/document-skills-plugin/skills/docx/scenes/resume.md +534 -0
  77. package/vendor/packages/document-skills-plugin/skills/docx/scripts/__init__.py +1 -0
  78. package/vendor/packages/document-skills-plugin/skills/docx/scripts/add_toc_placeholders.py +749 -0
  79. package/vendor/packages/document-skills-plugin/skills/docx/scripts/document.py +1333 -0
  80. package/vendor/packages/document-skills-plugin/skills/docx/scripts/postcheck.py +807 -0
  81. package/vendor/packages/document-skills-plugin/skills/docx/scripts/templates/comments.xml +3 -0
  82. package/vendor/packages/document-skills-plugin/skills/docx/scripts/templates/commentsExtended.xml +3 -0
  83. package/vendor/packages/document-skills-plugin/skills/docx/scripts/templates/commentsExtensible.xml +3 -0
  84. package/vendor/packages/document-skills-plugin/skills/docx/scripts/templates/commentsIds.xml +3 -0
  85. package/vendor/packages/document-skills-plugin/skills/docx/scripts/templates/people.xml +3 -0
  86. package/vendor/packages/document-skills-plugin/skills/docx/scripts/utilities.py +374 -0
  87. package/vendor/packages/document-skills-plugin/skills/docx/setup.sh +177 -0
  88. package/vendor/packages/document-skills-plugin/skills/pdf/LICENSE.txt +13 -0
  89. package/vendor/packages/document-skills-plugin/skills/pdf/SKILL.md +919 -0
  90. package/vendor/packages/document-skills-plugin/skills/pdf/briefs/academic.md +1058 -0
  91. package/vendor/packages/document-skills-plugin/skills/pdf/briefs/creative.md +770 -0
  92. package/vendor/packages/document-skills-plugin/skills/pdf/briefs/poster.md +702 -0
  93. package/vendor/packages/document-skills-plugin/skills/pdf/briefs/process-advanced.md +284 -0
  94. package/vendor/packages/document-skills-plugin/skills/pdf/briefs/process.md +319 -0
  95. package/vendor/packages/document-skills-plugin/skills/pdf/briefs/report.md +1659 -0
  96. package/vendor/packages/document-skills-plugin/skills/pdf/configs/components.md +153 -0
  97. package/vendor/packages/document-skills-plugin/skills/pdf/configs/fonts.md +93 -0
  98. package/vendor/packages/document-skills-plugin/skills/pdf/configs/visual_framework.md +263 -0
  99. package/vendor/packages/document-skills-plugin/skills/pdf/references/resume-academic.tex +130 -0
  100. package/vendor/packages/document-skills-plugin/skills/pdf/references/resume-altacv.tex +190 -0
  101. package/vendor/packages/document-skills-plugin/skills/pdf/scripts/cover_validate.js +367 -0
  102. package/vendor/packages/document-skills-plugin/skills/pdf/scripts/design_engine.py +2816 -0
  103. package/vendor/packages/document-skills-plugin/skills/pdf/scripts/html2pdf-next.js +754 -0
  104. package/vendor/packages/document-skills-plugin/skills/pdf/scripts/html2poster.js +256 -0
  105. package/vendor/packages/document-skills-plugin/skills/pdf/scripts/pdf.py +2959 -0
  106. package/vendor/packages/document-skills-plugin/skills/pdf/scripts/pdf_qa.py +901 -0
  107. package/vendor/packages/document-skills-plugin/skills/pdf/scripts/poster_validate.py +1337 -0
  108. package/vendor/packages/document-skills-plugin/skills/pdf/scripts/setup.sh +269 -0
  109. package/vendor/packages/document-skills-plugin/skills/pdf/scripts/toc_validate.py +2075 -0
  110. package/vendor/packages/document-skills-plugin/skills/pdf/typesetting/charts.md +320 -0
  111. package/vendor/packages/document-skills-plugin/skills/pdf/typesetting/cover-backgrounds.md +384 -0
  112. package/vendor/packages/document-skills-plugin/skills/pdf/typesetting/cover.md +1442 -0
  113. package/vendor/packages/document-skills-plugin/skills/pdf/typesetting/fill-engine.md +527 -0
  114. package/vendor/packages/document-skills-plugin/skills/pdf/typesetting/geometry.md +142 -0
  115. package/vendor/packages/document-skills-plugin/skills/pdf/typesetting/overflow.md +630 -0
  116. package/vendor/packages/document-skills-plugin/skills/pdf/typesetting/pagination.md +367 -0
  117. package/vendor/packages/document-skills-plugin/skills/pdf/typesetting/palette.md +217 -0
  118. package/vendor/packages/document-skills-plugin/skills/pdf/typesetting/typography.md +20 -0
  119. package/vendor/packages/ios-simulator-plugin/.mcp.json +15 -0
  120. package/vendor/packages/ios-simulator-plugin/.zcode-plugin/plugin.json +34 -0
  121. package/vendor/packages/ios-simulator-plugin/README.md +111 -0
  122. package/vendor/packages/ios-simulator-plugin/commands/ios-dev.md +11 -0
  123. package/vendor/packages/ios-simulator-plugin/dist/lib/path.d.ts +4 -0
  124. package/vendor/packages/ios-simulator-plugin/dist/lib/path.js +18 -0
  125. package/vendor/packages/ios-simulator-plugin/dist/lib/result.d.ts +5 -0
  126. package/vendor/packages/ios-simulator-plugin/dist/lib/result.js +20 -0
  127. package/vendor/packages/ios-simulator-plugin/dist/lib/run.d.ts +17 -0
  128. package/vendor/packages/ios-simulator-plugin/dist/lib/run.js +83 -0
  129. package/vendor/packages/ios-simulator-plugin/dist/mcp/server.d.ts +3 -0
  130. package/vendor/packages/ios-simulator-plugin/dist/mcp/server.js +46833 -0
  131. package/vendor/packages/ios-simulator-plugin/dist/providers/build.d.ts +112 -0
  132. package/vendor/packages/ios-simulator-plugin/dist/providers/build.js +99 -0
  133. package/vendor/packages/ios-simulator-plugin/dist/providers/logs.d.ts +21 -0
  134. package/vendor/packages/ios-simulator-plugin/dist/providers/logs.js +26 -0
  135. package/vendor/packages/ios-simulator-plugin/dist/providers/preflight.d.ts +12 -0
  136. package/vendor/packages/ios-simulator-plugin/dist/providers/preflight.js +62 -0
  137. package/vendor/packages/ios-simulator-plugin/dist/providers/project.d.ts +35 -0
  138. package/vendor/packages/ios-simulator-plugin/dist/providers/project.js +288 -0
  139. package/vendor/packages/ios-simulator-plugin/dist/providers/screenshot.d.ts +22 -0
  140. package/vendor/packages/ios-simulator-plugin/dist/providers/screenshot.js +30 -0
  141. package/vendor/packages/ios-simulator-plugin/dist/providers/sim.d.ts +60 -0
  142. package/vendor/packages/ios-simulator-plugin/dist/providers/sim.js +116 -0
  143. package/vendor/packages/ios-simulator-plugin/dist/providers/ui.d.ts +57 -0
  144. package/vendor/packages/ios-simulator-plugin/dist/providers/ui.js +67 -0
  145. package/vendor/packages/ios-simulator-plugin/hooks/hooks.json +3 -0
  146. package/vendor/packages/ios-simulator-plugin/package.json +35 -0
  147. package/vendor/packages/ios-simulator-plugin/skills/ios-dev/SKILL.md +45 -0
  148. package/vendor/packages/ios-simulator-plugin/templates/swiftui-app/README.md +5 -0
  149. package/vendor/packages/restore-legacy-sessions-plugin/.zcode-plugin/plugin.json +9 -0
  150. package/vendor/packages/restore-legacy-sessions-plugin/README.md +35 -0
  151. package/vendor/packages/restore-legacy-sessions-plugin/commands/restore-legacy-sessions.md +11 -0
  152. package/vendor/packages/restore-legacy-sessions-plugin/package.json +8 -0
  153. package/vendor/packages/restore-legacy-sessions-plugin/skills/restore-legacy-sessions/SKILL.md +92 -0
  154. package/vendor/packages/restore-legacy-sessions-plugin/skills/restore-legacy-sessions/scripts/restore-conversation.mjs +648 -0
  155. package/vendor/packages/restore-legacy-sessions-plugin/skills/restore-legacy-sessions/scripts/scan-legacy-sessions.mjs +422 -0
  156. package/vendor/packages/skill-creator-plugin/.zcode-plugin/plugin.json +8 -0
  157. package/vendor/packages/skill-creator-plugin/package.json +8 -0
  158. package/vendor/packages/skill-creator-plugin/skills/skill-creator/SKILL.md +159 -0
  159. package/vendor/packages/zcode-guide-plugin/.zcode-plugin/plugin.json +8 -0
  160. package/vendor/packages/zcode-guide-plugin/README.md +22 -0
  161. package/vendor/packages/zcode-guide-plugin/package.json +8 -0
  162. package/vendor/packages/zcode-guide-plugin/skills/diagnosing-commands/SKILL.md +66 -0
  163. package/vendor/packages/zcode-guide-plugin/skills/diagnosing-hooks/SKILL.md +66 -0
  164. package/vendor/packages/zcode-guide-plugin/skills/diagnosing-mcp/SKILL.md +97 -0
  165. package/vendor/packages/zcode-guide-plugin/skills/diagnosing-plugins/SKILL.md +59 -0
  166. package/vendor/packages/zcode-guide-plugin/skills/diagnosing-skills/SKILL.md +61 -0
  167. package/vendor/packages/zcode-guide-plugin/skills/zcode-configuration-guide/SKILL.md +99 -0
  168. package/vendor/zcode.cjs +2926 -0
  169. package/zcode-runtime.lock.json +8 -0
@@ -0,0 +1,527 @@
1
+ # Fill Engine — Adaptive Anti-Void Layout Engine V2.0
2
+
3
+ > Solves the **"text too small to read"** and **"large page voids"** problems caused by varying input content length in automated PDF generation.
4
+ > Before rendering any page, it must pass through the following **four elastic filtering calculations**.
5
+ >
6
+ > **Positioning**: This is the mirror counterpart of `overflow.md` (anti-overflow) — overflow handles "too much content", fill-engine handles "too little content".
7
+ >
8
+ > Related:
9
+ > - `overflow.md` — Anti-overflow layout system (degradation strategy for excessive content)
10
+ > - `pagination.md` — Pagination & cross-page integrity control
11
+ > - `cover.md` — Cover layout engine (covers not affected by Fill Engine; they have their own layout system)
12
+
13
+ ---
14
+
15
+ ## ⚠️ Scope of Application
16
+
17
+ - ✅ **Body pages** (body pages of Report / Academic / Creative routes)
18
+ - ✅ **All three rendering routes** (ReportLab / LaTeX / Playwright-HTML)
19
+ - ❌ **Not applicable to covers** (covers are independently controlled by `cover.md`)
20
+ - ❌ **Not applicable to TOC pages** (TOC has a fixed format)
21
+
22
+ ---
23
+
24
+ ## Safety Net 1: Readability Red Line (Font Size Hard Floor)
25
+
26
+ **Principle: Never rely on shrinking font size to fit the layout. Font sizes have hard-coded minimums that cannot be breached.**
27
+
28
+ ### Absolute Font Size Floor
29
+
30
+ | Element | Single-column | Double-column | Notes |
31
+ |------|---------|---------|------|
32
+ | **Body Text** | **≥ 14pt** | **≥ 12pt** | Below this → considered unreadable, must trigger page break |
33
+ | **Default base size** | 15pt (CJK) / 14pt (Latin) | 13pt (CJK) / 12pt (Latin) | Starting value, not ceiling |
34
+
35
+ ### Heading Scale Hard Floor
36
+
37
+ | Level | Min Size | Recommended |
38
+ |------|---------|---------|
39
+ | **H1** (primary heading / page title) | **≥ 32pt** | 36–42pt |
40
+ | **H2** (secondary heading) | **≥ 24pt** | 26–30pt |
41
+ | **H3** (tertiary heading) | **≥ 18pt** | 20–22pt |
42
+
43
+ ### Coordination with overflow.md
44
+
45
+ `overflow.md` §5's font-size degradation staircase (`fit_text_with_degradation`) **must not breach the above floor**:
46
+
47
+ ```python
48
+ # overflow.md §5's min_size parameter must be >= Fill Engine red line
49
+ def fit_text_with_degradation(text, font_name, base_size, max_width,
50
+ min_size=14): # ← Single-column floor 14pt, not 7pt
51
+ """When overflow needs to shrink font size, it cannot go below the readability red line."""
52
+ for size in range(base_size, min_size - 1, -1):
53
+ if stringWidth(text, font_name, size) <= max_width:
54
+ return size
55
+ return min_size # Hit the floor → trigger page break, stop shrinking
56
+ ```
57
+
58
+ > **Core idea: If content doesn't fit → page break, not shrinking text to ant-size.**
59
+
60
+ ---
61
+
62
+ ## Safety Net 2: Page Fill Ratio & Paragraph Inflation (Fill Ratio Engine)
63
+
64
+ ### Virtual Rendering
65
+
66
+ Before actually rendering each page, the system **must first calculate** how much height the content would occupy under default font sizes and spacing.
67
+
68
+ ```python
69
+ def calculate_fill_ratio(content_blocks, available_height, default_styles):
70
+ """
71
+ Virtual rendering: calculate total height of current page content under default styles.
72
+ Returns fill ratio = total content height / available page height.
73
+ """
74
+ total_height = 0
75
+ for block in content_blocks:
76
+ block_height = measure_block_height(block, default_styles)
77
+ total_height += block_height
78
+
79
+ fill_ratio = total_height / available_height
80
+ return fill_ratio
81
+ ```
82
+
83
+ ### Elastic Inflation Trigger Conditions
84
+
85
+ | Fill Ratio | Status | Action |
86
+ |--------|------|------|
87
+ | **≥ 80%** | ✅ Full | No adjustment, render normally |
88
+ | **65%–80%** | ⚠️ Slightly empty | Light inflation (line-height + paragraph spacing only) |
89
+ | **40%–65%** | 🔶 Noticeably empty | Full inflation (line-height + spacing + slight font increase + component inflation) |
90
+ | **< 40%** | 🔴 Extremely empty | Full inflation + Y-axis golden ratio anchoring (Safety Net 4) |
91
+
92
+ ### Inflation Parameters (Triggered when fill ratio < 65%)
93
+
94
+ #### 2a. Line-Height Inflation
95
+
96
+ ```python
97
+ def inflate_line_height(base_line_height, fill_ratio):
98
+ """
99
+ Lower fill ratio means more line-height stretch.
100
+ base_line_height: default line-height (e.g. 1.4)
101
+ Returns inflated line-height, capped at 2.2.
102
+ """
103
+ if fill_ratio >= 0.65:
104
+ return base_line_height # No inflation
105
+
106
+ # Linear interpolation: as fill_ratio goes from 0.65→0.30, line-height goes from base→2.2
107
+ inflation = (0.65 - fill_ratio) / (0.65 - 0.30) # 0.0 ~ 1.0
108
+ inflation = min(inflation, 1.0)
109
+
110
+ target = base_line_height + (2.2 - base_line_height) * inflation
111
+ return round(target, 2)
112
+ ```
113
+
114
+ | Fill Ratio | Base line-height 1.4 → After inflation |
115
+ |--------|---------------------|
116
+ | 65% | 1.40 (unchanged) |
117
+ | 55% | 1.63 |
118
+ | 45% | 1.86 |
119
+ | 35% | 2.09 |
120
+ | ≤30% | 2.20 (cap) |
121
+
122
+ #### 2b. Paragraph Spacing Compensation (Margin-Bottom Injection)
123
+
124
+ ```python
125
+ def inject_paragraph_spacing(remaining_height, paragraph_count, heading_count):
126
+ """
127
+ Distribute 30%-50% of remaining whitespace evenly between paragraphs.
128
+ remaining_height: Available_H - content height after inflation
129
+ """
130
+ if remaining_height <= 0:
131
+ return 0
132
+
133
+ injection_pool = remaining_height * 0.4 # Take 40%
134
+ gap_count = paragraph_count + heading_count - 1 # Number of gaps
135
+
136
+ if gap_count <= 0:
137
+ return 0
138
+
139
+ per_gap = injection_pool / gap_count
140
+ return round(per_gap, 1)
141
+ ```
142
+
143
+ **Injection positions (by priority):**
144
+ 1. Between headings and body text (below H1/H2/H3)
145
+ 2. Between natural paragraphs
146
+ 3. Between body text and charts/tables
147
+
148
+ #### 2c. Font Scaling
149
+
150
+ ```python
151
+ def scale_font_size(base_size, fill_ratio):
152
+ """
153
+ When fill ratio < 65%, allow font size to float up by 1-2pt.
154
+ Never exceed +2pt, otherwise loses professional feel.
155
+ """
156
+ if fill_ratio >= 0.65:
157
+ return base_size
158
+ if fill_ratio >= 0.50:
159
+ return base_size + 1
160
+ return base_size + 2 # Max +2pt
161
+ ```
162
+
163
+ > **Constraint: Inflated font size ≤ base_size + 2pt. 15pt body can become at most 17pt, no larger.**
164
+
165
+ ---
166
+
167
+ ## Safety Net 3: Component-Level Elastic Fill (Component Inflation)
168
+
169
+ **Trigger: Same as Safety Net 2, active when fill ratio < 65%.**
170
+
171
+ ### 3a. Table Auto-Height Expansion (Table Padding Inflation)
172
+
173
+ ```python
174
+ def inflate_table_padding(base_padding, fill_ratio):
175
+ """
176
+ Lower fill ratio means larger table cell padding.
177
+ base_padding: default cell padding (e.g. 6pt)
178
+ """
179
+ if fill_ratio >= 0.65:
180
+ return base_padding
181
+
182
+ # Add 10-20pt
183
+ extra = int((0.65 - fill_ratio) / 0.25 * 20)
184
+ extra = max(10, min(extra, 20))
185
+ return base_padding + extra
186
+ ```
187
+
188
+ **Effect:** Originally flat compact data table → tall spacious data display board.
189
+
190
+ ### 3b. Blockquote Exaggeration (Blockquote Scaling)
191
+
192
+ When encountering a blockquote and the page has voids:
193
+
194
+ ```python
195
+ def scale_blockquote(base_font_size, fill_ratio):
196
+ """
197
+ Blockquote font enlarged, italicized, massive whitespace above and below.
198
+ """
199
+ if fill_ratio >= 0.65:
200
+ return {
201
+ "font_size": base_font_size,
202
+ "font_style": "normal",
203
+ "margin_top": 12,
204
+ "margin_bottom": 12,
205
+ "border_left_width": 3,
206
+ }
207
+ return {
208
+ "font_size": int(base_font_size * 1.5), # Scale up 1.5x
209
+ "font_style": "italic",
210
+ "margin_top": 40, # Large whitespace above
211
+ "margin_bottom": 40, # Large whitespace below
212
+ "border_left_width": 6, # Thicken blockquote left border
213
+ }
214
+ ```
215
+
216
+ ### 3c. List Item Spacing Expansion
217
+
218
+ ```python
219
+ def inflate_list_spacing(base_spacing, fill_ratio):
220
+ """
221
+ List item spacing expanded to 1.5x normal paragraph spacing.
222
+ """
223
+ if fill_ratio >= 0.65:
224
+ return base_spacing
225
+ return int(base_spacing * 1.5)
226
+ ```
227
+
228
+ ---
229
+
230
+ ## Safety Net 4: Y-Axis Golden Ratio Anchoring (Ultimate Measure for Extreme Voids)
231
+
232
+ **Trigger: After Safety Net 2 + 3 inflation, fill ratio still < 40%.**
233
+
234
+ **Core principle: Absolutely forbidden to pin content to the very top, leaving the bottom half as dead whitespace.**
235
+
236
+ ### Execution Logic
237
+
238
+ ```python
239
+ def anchor_content_vertically(content_bbox_height, available_height, fill_ratio):
240
+ """
241
+ Pack all current page content as a BBox, re-align vertically within available height.
242
+
243
+ Returns content_top_y: Y coordinate offset for content top.
244
+ """
245
+ if fill_ratio >= 0.40:
246
+ return 0 # No anchoring needed, normal flow from page top
247
+
248
+ remaining = available_height - content_bbox_height
249
+
250
+ # Option A: Golden ratio offset-up (recommended)
251
+ golden_offset = remaining * 0.382 # Top 38.2%, bottom 61.8%
252
+
253
+ # Option B: Absolute vertical center (alternative)
254
+ # center_offset = remaining / 2
255
+
256
+ return golden_offset
257
+ ```
258
+
259
+ ### Option Selection
260
+
261
+ | Option | Formula | Visual Effect | Applicable Scenario |
262
+ |------|------|---------|---------|
263
+ | **A. Golden ratio offset-up** (default) | `offset = remaining * 0.382` | Slightly less whitespace above, more below, visually stable | Most scenarios |
264
+ | **B. Absolute center** | `offset = remaining / 2` | Perfectly symmetrical | Minimal pages with single element |
265
+
266
+ ### Effect Illustration
267
+
268
+ ```
269
+ ┌─────────────────────────┐ ┌─────────────────────────┐
270
+ │ ← Content starts here │ │ │
271
+ │ Section Title │ │ ← 38.2% elegant space │
272
+ │ Body text... │ │ │
273
+ │ │ │ Section Title │
274
+ │ │ │ Body text... │
275
+ │ │ │ │
276
+ │ │ │ │
277
+ │ ← Huge dead whitespace! │ │ ← 61.8% bottom space │
278
+ │ │ │ │
279
+ │ │ │ │
280
+ └─────────────────────────┘ └─────────────────────────┘
281
+ ❌ No anchoring ✅ Golden ratio anchoring
282
+ ```
283
+
284
+ ---
285
+
286
+ ## Three-Route Implementation Guide
287
+
288
+ ### ReportLab Route (Report Pipeline)
289
+
290
+ ```python
291
+ from reportlab.platypus import SimpleDocTemplate, Spacer, Paragraph
292
+ from reportlab.lib.units import pt
293
+
294
+ def build_page_with_fill_engine(story_blocks, page_width, page_height, margins):
295
+ """
296
+ Fill Engine main entry — ReportLab route.
297
+ Call before doc.build().
298
+ """
299
+ available_h = page_height - margins['top'] - margins['bottom']
300
+ available_w = page_width - margins['left'] - margins['right']
301
+
302
+ # --- Safety Net 1: Check font size floor ---
303
+ enforce_font_floor(story_blocks, min_body=14, min_h1=32, min_h2=24, min_h3=18)
304
+
305
+ # --- Safety Net 2: Virtual render + inflation ---
306
+ fill_ratio = calculate_fill_ratio(story_blocks, available_h, default_styles)
307
+
308
+ if fill_ratio < 0.65:
309
+ # 2a. Line-height inflation
310
+ new_line_height = inflate_line_height(1.4, fill_ratio)
311
+ apply_line_height(story_blocks, new_line_height)
312
+
313
+ # 2b. Paragraph spacing injection
314
+ remaining = available_h - measure_total_height(story_blocks)
315
+ extra_gap = inject_paragraph_spacing(remaining, count_paragraphs(story_blocks),
316
+ count_headings(story_blocks))
317
+ inject_spacers(story_blocks, extra_gap)
318
+
319
+ # 2c. Font scaling
320
+ font_bump = scale_font_size(15, fill_ratio) - 15
321
+ if font_bump > 0:
322
+ bump_font_sizes(story_blocks, font_bump)
323
+
324
+ # --- Safety Net 3: Component inflation ---
325
+ if fill_ratio < 0.65:
326
+ inflate_tables(story_blocks, fill_ratio)
327
+ inflate_blockquotes(story_blocks, fill_ratio)
328
+ inflate_lists(story_blocks, fill_ratio)
329
+
330
+ # --- Safety Net 4: Y-axis anchoring ---
331
+ recalc_ratio = calculate_fill_ratio(story_blocks, available_h, inflated_styles)
332
+ if recalc_ratio < 0.40:
333
+ content_height = measure_total_height(story_blocks)
334
+ top_offset = anchor_content_vertically(content_height, available_h, recalc_ratio)
335
+ story_blocks.insert(0, Spacer(1, top_offset))
336
+
337
+ return story_blocks
338
+ ```
339
+
340
+ ### LaTeX Route (Academic Pipeline)
341
+
342
+ ```latex
343
+ % Safety Net 1: Font size floor — define in preamble
344
+ \newcommand{\bodysize}{\fontsize{14pt}{20pt}\selectfont} % 14pt floor
345
+ \renewcommand{\Large}{\fontsize{32pt}{38pt}\selectfont} % H1 ≥ 32pt
346
+ \renewcommand{\large}{\fontsize{24pt}{30pt}\selectfont} % H2 ≥ 24pt
347
+
348
+ % Safety Net 4: Vertical centering (for extreme voids)
349
+ \newcommand{\goldenpage}[1]{%
350
+ \null\vfill % Top elastic space (less)
351
+ #1 % Content
352
+ \vfill\vfill % Bottom elastic space (more, ~2:1 ratio)
353
+ }
354
+
355
+ % Usage (when content is minimal):
356
+ % \goldenpage{
357
+ % \section{Summary}
358
+ % Short content here...
359
+ % }
360
+ ```
361
+
362
+ ### Playwright/HTML Route (Creative Pipeline)
363
+
364
+ ```css
365
+ /* Safety Net 1: Font size red line */
366
+ :root {
367
+ --body-min-font: 14px;
368
+ --h1-min-font: 32px;
369
+ --h2-min-font: 24px;
370
+ --h3-min-font: 18px;
371
+ }
372
+
373
+ body {
374
+ font-size: max(var(--body-font, 15px), var(--body-min-font));
375
+ }
376
+
377
+ h1 { font-size: max(var(--h1-font, 36px), var(--h1-min-font)); }
378
+ h2 { font-size: max(var(--h2-font, 28px), var(--h2-min-font)); }
379
+ h3 { font-size: max(var(--h3-font, 22px), var(--h3-min-font)); }
380
+
381
+ /* Safety Net 2-3: Dynamically injected after JS virtual render */
382
+ /* Before Playwright screenshot, run Fill Engine JS via page.evaluate() */
383
+ ```
384
+
385
+ ```javascript
386
+ // Playwright page.evaluate() — Fill Engine
387
+ function runFillEngine(pageElement) {
388
+ const pageH = pageElement.clientHeight;
389
+ const contentH = pageElement.scrollHeight;
390
+ const fillRatio = contentH / pageH;
391
+
392
+ if (fillRatio >= 0.65) return; // No inflation needed
393
+
394
+ const root = pageElement.style;
395
+
396
+ // 2a. Line-height inflation
397
+ const inflation = Math.min((0.65 - fillRatio) / 0.35, 1.0);
398
+ const newLH = 1.4 + (2.2 - 1.4) * inflation;
399
+ root.setProperty('--body-line-height', newLH.toFixed(2));
400
+ pageElement.querySelectorAll('p, li').forEach(el => {
401
+ el.style.lineHeight = newLH.toFixed(2);
402
+ });
403
+
404
+ // 2c. Font scaling
405
+ if (fillRatio < 0.50) {
406
+ pageElement.querySelectorAll('p, li').forEach(el => {
407
+ const size = parseFloat(getComputedStyle(el).fontSize);
408
+ el.style.fontSize = Math.min(size + 2, size + 2) + 'px'; // +2pt max
409
+ });
410
+ } else if (fillRatio < 0.65) {
411
+ pageElement.querySelectorAll('p, li').forEach(el => {
412
+ const size = parseFloat(getComputedStyle(el).fontSize);
413
+ el.style.fontSize = (size + 1) + 'px'; // +1pt
414
+ });
415
+ }
416
+
417
+ // 3a. Table height expansion
418
+ pageElement.querySelectorAll('td, th').forEach(cell => {
419
+ const extra = Math.min(20, Math.round((0.65 - fillRatio) / 0.25 * 20));
420
+ cell.style.paddingTop = (6 + extra) + 'px';
421
+ cell.style.paddingBottom = (6 + extra) + 'px';
422
+ });
423
+
424
+ // 3b. Blockquote exaggeration
425
+ pageElement.querySelectorAll('blockquote').forEach(bq => {
426
+ const size = parseFloat(getComputedStyle(bq).fontSize);
427
+ bq.style.fontSize = (size * 1.5) + 'px';
428
+ bq.style.fontStyle = 'italic';
429
+ bq.style.marginTop = '40px';
430
+ bq.style.marginBottom = '40px';
431
+ });
432
+
433
+ // Safety Net 4: Y-axis anchoring
434
+ const newContentH = pageElement.scrollHeight;
435
+ const newRatio = newContentH / pageH;
436
+ if (newRatio < 0.40) {
437
+ const remaining = pageH - newContentH;
438
+ const offset = remaining * 0.382;
439
+ pageElement.style.paddingTop = offset + 'px';
440
+ }
441
+ }
442
+ ```
443
+
444
+ ---
445
+
446
+ ## Execution Order Summary
447
+
448
+ ```
449
+ Input content arrives
450
+ │
451
+ ▼
452
+ ┌─────────────────────────────────────────┐
453
+ │ Safety Net 1: Readability red line check │
454
+ │ → Font size ≥ floor? YES → Continue │
455
+ │ → Font size < floor? → Force raise to floor │
456
+ └──────────────────┬──────────────────────┘
457
+ │
458
+ ▼
459
+ ┌─────────────────────────────────────────┐
460
+ │ Virtual render: Calculate Fill Ratio │
461
+ │ → ≥ 80%? → Render normally, exit │
462
+ │ → 65%-80%? → Light inflation (2a+2b only) │
463
+ │ → < 65%? → Enter Safety Net 2+3 full inflation │
464
+ └──────────────────┬──────────────────────┘
465
+ │
466
+ ▼
467
+ ┌─────────────────────────────────────────┐
468
+ │ Safety Net 2: Paragraph inflation │
469
+ │ 2a. Line-height inflation (→ max 2.2) │
470
+ │ 2b. Paragraph spacing injection (30%-50% of remaining space) │
471
+ │ 2c. Font scaling (+1~2pt, max) │
472
+ └──────────────────┬──────────────────────┘
473
+ │
474
+ ▼
475
+ ┌─────────────────────────────────────────┐
476
+ │ Safety Net 3: Component inflation │
477
+ │ 3a. Table Padding increase (+10~20pt) │
478
+ │ 3b. Blockquote scale 1.5x + 40pt whitespace above/below │
479
+ │ 3c. List spacing × 1.5 │
480
+ └──────────────────┬──────────────────────┘
481
+ │
482
+ ▼
483
+ ┌─────────────────────────────────────────┐
484
+ │ Recalculate Fill Ratio │
485
+ │ → ≥ 40%? → Render normally, exit │
486
+ │ → < 40%? → Safety Net 4: Y-axis golden ratio anchoring │
487
+ └──────────────────┬──────────────────────┘
488
+ │
489
+ ▼
490
+ ┌─────────────────────────────────────────┐
491
+ │ Safety Net 4: Shift content down │
492
+ │ top_offset = remaining * 0.382 │
493
+ │ → Elegant space above, slightly more below │
494
+ │ → No longer "underfilled" but "intentional whitespace" │
495
+ └─────────────────────────────────────────┘
496
+ │
497
+ ▼
498
+ Actual render output
499
+ ```
500
+
501
+ ---
502
+
503
+ ## Coordination with Other Specifications
504
+
505
+ | Specification | Relationship | Coordination Rule |
506
+ |------|------|---------|
507
+ | `overflow.md` | Complementary (overflow vs void) | overflow's font degradation must not breach Fill Engine's red line |
508
+ | `pagination.md` | Complementary (pagination vs fill) | pagination's "last page ≥ 40%" aligns with Fill Engine's Fill Ratio concept |
509
+ | `cover.md` | Independent | Covers have their own layout system, not affected by Fill Engine |
510
+ | `typography.md` | Infrastructure | Fill Engine makes elastic adjustments on top of typography-defined fonts/line-heights |
511
+
512
+ ---
513
+
514
+ ## Checklist (Check Before Every Body Page Render)
515
+
516
+ ```
517
+ □ Body font size ≥ 14pt (single-column) / 12pt (double-column)?
518
+ □ H1 ≥ 32pt、H2 ≥ 24pt、H3 ≥ 18pt?
519
+ □ Virtual render calculated Fill Ratio?
520
+ □ Inflation triggered when Fill Ratio < 65%?
521
+ □ Line-height inflation not exceeding 2.2?
522
+ □ Font scaling not exceeding +2pt?
523
+ □ Table Padding increment within 10-20pt range?
524
+ □ Blockquote scale factor = 1.5x, top/bottom whitespace = 40pt?
525
+ □ Y-axis anchoring triggered when Fill Ratio < 40%?
526
+ □ Cover page not affected by Fill Engine?
527
+ ```
@@ -0,0 +1,142 @@
1
+ # Geometric Anchors
2
+
3
+ > Create sophisticated visual anchors from the simplest geometric shapes.
4
+
5
+ ---
6
+
7
+ ## What Are Visual Anchors
8
+
9
+ Visual anchors are **non-functional decorative elements** on a page, used to:
10
+ - Break the flatness of text-only / data-only layouts
11
+ - Establish a visual center of gravity on the page
12
+ - Convey abstract qualities and design intent
13
+ - Fill large whitespace areas without adding information noise
14
+
15
+ **Key principle: Anchors don't need to "look like" anything concrete. The more abstract, the more refined.**
16
+
17
+ ---
18
+
19
+ ## Basic Shape Vocabulary
20
+
21
+ | Shape | SVG | Mood / Character |
22
+ |-------|-----|-----------------|
23
+ | Circle | `<circle>` | Wholeness, inclusivity, softness |
24
+ | Semicircle | `<path d="M0,50 A50,50 0 0,1 100,50">` | Rising, gradual, metaphorical |
25
+ | Triangle | `<polygon>` | Direction, sharpness, modern |
26
+ | Rectangle | `<rect>` | Stability, order, architectural |
27
+ | Line | `<line>` | Connection, guidance, minimalism |
28
+ | Arc | `<path>` + Bézier | Flow, elegance, organic |
29
+
30
+ ---
31
+
32
+ ## Composition Patterns
33
+
34
+ ### Pattern 1: Offset Stacking
35
+
36
+ Multiple identical shapes, slightly offset, rotated, with decreasing opacity.
37
+
38
+ ```svg
39
+ <svg width="120" height="120" viewBox="0 0 120 120" fill="none">
40
+ <!-- Three offset circles -->
41
+ <circle cx="50" cy="50" r="35" stroke="currentColor" stroke-width="0.6" opacity="0.15"/>
42
+ <circle cx="60" cy="55" r="35" stroke="currentColor" stroke-width="0.6" opacity="0.25"/>
43
+ <circle cx="70" cy="60" r="35" stroke="currentColor" stroke-width="0.6" opacity="0.4"/>
44
+ </svg>
45
+ ```
46
+
47
+ **Key points**: Same shape, 3 layers, opacity 0.15 → 0.25 → 0.4, offset 10-15px
48
+
49
+ ### Pattern 2: Scale Contrast
50
+
51
+ One large shape + a few small shapes as accents.
52
+
53
+ ```svg
54
+ <svg width="150" height="150" viewBox="0 0 150 150" fill="none">
55
+ <circle cx="60" cy="60" r="50" stroke="currentColor" stroke-width="0.5" opacity="0.2"/>
56
+ <circle cx="115" cy="30" r="8" fill="currentColor" opacity="0.6"/>
57
+ <circle cx="105" cy="50" r="3" fill="currentColor" opacity="0.3"/>
58
+ <circle cx="125" cy="45" r="2" fill="currentColor" opacity="0.2"/>
59
+ </svg>
60
+ ```
61
+
62
+ **Key points**: Large circle stroke-only (hollow), small circles filled (solid), creating solid-void contrast
63
+
64
+ ### Pattern 3: Grid Intersection
65
+
66
+ Lines + dots forming nodes at intersections.
67
+
68
+ ```svg
69
+ <svg width="100" height="100" viewBox="0 0 100 100" fill="none">
70
+ <line x1="20" y1="0" x2="20" y2="100" stroke="currentColor" stroke-width="0.3" opacity="0.1"/>
71
+ <line x1="50" y1="0" x2="50" y2="100" stroke="currentColor" stroke-width="0.3" opacity="0.1"/>
72
+ <line x1="80" y1="0" x2="80" y2="100" stroke="currentColor" stroke-width="0.3" opacity="0.1"/>
73
+ <line x1="0" y1="30" x2="100" y2="30" stroke="currentColor" stroke-width="0.3" opacity="0.1"/>
74
+ <line x1="0" y1="70" x2="100" y2="70" stroke="currentColor" stroke-width="0.3" opacity="0.1"/>
75
+ <!-- Intersection points -->
76
+ <circle cx="50" cy="30" r="3" fill="currentColor" opacity="0.5"/>
77
+ <circle cx="20" cy="70" r="2" fill="currentColor" opacity="0.3"/>
78
+ <circle cx="80" cy="70" r="4" fill="currentColor" opacity="0.15"/>
79
+ </svg>
80
+ ```
81
+
82
+ ### Pattern 4: Arc Flow
83
+
84
+ Bézier curves + endpoint circles, expressing organic flow.
85
+
86
+ ```svg
87
+ <svg width="200" height="100" viewBox="0 0 200 100" fill="none">
88
+ <path d="M10,80 C50,10 150,10 190,80" stroke="currentColor" stroke-width="0.6" opacity="0.25"/>
89
+ <path d="M10,85 C60,20 140,20 190,85" stroke="currentColor" stroke-width="0.4" opacity="0.15"/>
90
+ <circle cx="10" cy="80" r="2.5" fill="currentColor" opacity="0.4"/>
91
+ <circle cx="190" cy="80" r="2.5" fill="currentColor" opacity="0.4"/>
92
+ </svg>
93
+ ```
94
+
95
+ ### Pattern 5: Geometric Collage
96
+
97
+ Intentional combination of different shapes, like an architectural plan.
98
+
99
+ ```svg
100
+ <svg width="120" height="120" viewBox="0 0 120 120" fill="none">
101
+ <!-- Rectangular frame -->
102
+ <rect x="10" y="10" width="60" height="60" stroke="currentColor" stroke-width="0.5" opacity="0.2"/>
103
+ <!-- Circle breaking the straight lines -->
104
+ <circle cx="70" cy="70" r="30" stroke="currentColor" stroke-width="0.5" opacity="0.2"/>
105
+ <!-- Diagonal line cutting through -->
106
+ <line x1="10" y1="10" x2="100" y2="100" stroke="currentColor" stroke-width="0.3" opacity="0.15"/>
107
+ <!-- Small solid triangle as focal point -->
108
+ <polygon points="85,20 95,40 75,40" fill="currentColor" opacity="0.4"/>
109
+ </svg>
110
+ ```
111
+
112
+ ---
113
+
114
+ ## Placement Guide
115
+
116
+ | Context | Recommended Position | Recommended Size | Pattern |
117
+ |---------|---------------------|-----------------|---------|
118
+ | Cover | Top-right / bottom-left offset | 120-200px | Offset Stacking, Geometric Collage |
119
+ | Chapter divider | Page center | 80-120px | Scale Contrast, Arc Flow |
120
+ | Header / footer decoration | Corners | 30-50px | Small offset, single circle + line |
121
+ | Whitespace fill | Alongside content | 60-100px | Grid Intersection |
122
+
123
+ ---
124
+
125
+ ## Color Rules
126
+
127
+ - Anchor color = document primary color from `palette.cascade` output (`--c-accent` or `--c-text`)
128
+ - **Use only one color**, layer via opacity (0.1 → 0.5)
129
+ - Strokes over fills (solid elements ≤ 30% of total shapes)
130
+ - stroke-width range: 0.3-0.8px (ultra-thin lines = refined look)
131
+ - **⚠️ All SVG examples below use `currentColor` as placeholder.** When generating actual SVG, replace with the document’s primary color from the palette system. NEVER copy `currentColor` literally into production SVG — substitute the actual hex value.
132
+
133
+ ---
134
+
135
+ ## Forbidden
136
+
137
+ - ❌ Figurative icons (flowers, stars, arrows, or other concrete shapes)
138
+ - ❌ Mixing multiple colors
139
+ - ❌ Over-complexity (more than 8 shape elements)
140
+ - ❌ Symmetric / centered placement (offset creates tension)
141
+ - ❌ Thick lines (> 1.5px looks heavy)
142
+ - ❌ Shadows / glow effects