@lark-apaas/coding-steering 0.1.18-dev.4e64c13 → 0.1.18-dev.61b3ece

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 (24) hide show
  1. package/package.json +1 -1
  2. package/steering/design-html/skills/charts/SKILL.md +4 -0
  3. package/steering/design-html/skills/pptx-style-extract/SKILL.md +11 -8
  4. package/steering/design-html/skills/pptx-style-extract/scripts/check_v2.py +33 -3
  5. package/steering/design-html/skills/pptx-style-extract/scripts/draft.py +526 -110
  6. package/steering/design-html/skills/pptx-style-extract/scripts/extract.py +226 -6
  7. package/steering/design-html/skills/pptx-style-extract/scripts/ooxml.py +18 -1
  8. package/steering/design-html/skills/pptx-style-extract/scripts/package.py +167 -28
  9. package/steering/design-html/skills/pptx-style-extract/scripts/parts.py +3 -0
  10. package/steering/design-html/skills/pptx-style-extract/scripts/query.py +3 -8
  11. package/steering/design-html/skills/pptx-style-extract/scripts/test_background_composite.py +57 -0
  12. package/steering/design-html/skills/pptx-style-extract/scripts/test_color_contract.py +60 -0
  13. package/steering/design-html/skills/pptx-style-extract/scripts/test_design_consumer_contract.py +63 -0
  14. package/steering/design-html/skills/pptx-style-extract/scripts/test_flow_layout_contract.py +468 -0
  15. package/steering/design-html/skills/pptx-style-extract/scripts/test_layout_css.py +127 -0
  16. package/steering/design-html/skills/pptx-style-extract/scripts/test_rounded_contract.py +112 -0
  17. package/steering/design-html/skills/pptx-style-extract/scripts/test_text_role_contract.py +208 -0
  18. package/steering/design-html/skills/pptx-style-extract/v2-format-spec.md +14 -7
  19. package/steering/design-html/skills/slide-deck/SKILL.md +15 -20
  20. package/steering/design-html/skills/slide-deck/scripts/check_local_references.py +179 -0
  21. package/steering/nestjs-react-fullstack/skills/plugin-guide/SKILL.md +5 -3
  22. package/steering/nestjs-react-fullstack/skills_local/plugin-guide/SKILL.md +4 -0
  23. package/steering/vite-react/skills/plugin-guide/SKILL.md +3 -1
  24. package/steering/vite-react/skills/react-three-fiber/SKILL.md +4 -0
@@ -0,0 +1,127 @@
1
+ #!/usr/bin/env python3
2
+ """Regression tests for the consumer-facing layout slot CSS contract."""
3
+ import os
4
+ import sys
5
+ import tempfile
6
+ import unittest
7
+
8
+ sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
9
+
10
+ from check_v2 import Pack, rule_v2_16 # noqa: E402
11
+ from draft import emit_layouts, slot_style # noqa: E402
12
+ from package import FONTSIZE_RE, build_layouts_md, split_top_blocks # noqa: E402
13
+
14
+
15
+ class LayoutCssTest(unittest.TestCase):
16
+ def test_text_slot_emits_rendering_style_as_css_only(self):
17
+ shape = {
18
+ 'text': {
19
+ 'bodyPr': {
20
+ 'anchor': 'ctr',
21
+ 'insets_px': {'lIns': 12, 'tIns': 8, 'rIns': 10, 'bIns': 6},
22
+ 'rot': '900000',
23
+ },
24
+ 'lstStyle': {
25
+ 'lvl1pPr': {
26
+ 'sz_px': 48,
27
+ 'weight': 600,
28
+ 'italic': True,
29
+ 'underline': 'sng',
30
+ 'strike': 'sngStrike',
31
+ 'spc_px': 1.5,
32
+ 'color': {'resolved': '#123456'},
33
+ 'algn': 'ctr',
34
+ 'lnSpc': {'mult': 1.0},
35
+ },
36
+ },
37
+ 'paragraphs': [],
38
+ },
39
+ }
40
+ slot = {
41
+ 'role': 'title',
42
+ 'type': 'title',
43
+ 'box': [100, 80, 800, 160],
44
+ 'sz': 48,
45
+ 'txt': '标题',
46
+ }
47
+ slot.update(slot_style(shape))
48
+ archetype = {
49
+ 'name': 'layout-1',
50
+ 'zh': '标题页',
51
+ 'role': 'content',
52
+ 'bg': None,
53
+ 'slots': [slot],
54
+ 'decor': [],
55
+ 'pages': [1],
56
+ 'rep': 1,
57
+ 'pic_n': 0,
58
+ 'confidence': 'high',
59
+ }
60
+
61
+ with tempfile.TemporaryDirectory() as output_dir:
62
+ emit_layouts([archetype], output_dir)
63
+ with open(os.path.join(output_dir, 'layouts.yaml'), encoding='utf-8') as stream:
64
+ layouts_yaml = stream.read()
65
+ layouts_md = build_layouts_md(split_top_blocks(layouts_yaml), (1920, 1080))
66
+
67
+ self.assertIn(
68
+ 'css: "box-sizing: border-box; padding: 8px 10px 6px 12px; '
69
+ 'font-size: 48px; font-weight: 600; font-style: italic; '
70
+ 'text-decoration: underline line-through; letter-spacing: 1.5px; color: #123456; '
71
+ 'text-align: center; line-height: 1.2; display: flex; '
72
+ 'flex-direction: column; justify-content: center; rotate: 15deg"',
73
+ layouts_md,
74
+ )
75
+ for legacy_key in ('size', 'weight', 'color', 'align', 'valign', 'insets_px'):
76
+ self.assertNotRegex(layouts_md, rf'[,{{]\s*{legacy_key}:')
77
+ self.assertEqual(FONTSIZE_RE.findall(layouts_md), ['48'])
78
+
79
+ def test_layout_gate_rejects_legacy_slot_style_keys(self):
80
+ with tempfile.TemporaryDirectory() as pack_dir:
81
+ with open(os.path.join(pack_dir, 'design.md'), 'w', encoding='utf-8') as stream:
82
+ stream.write('---\nversion: alpha\nlayouts: layouts.md\n---\n\nRead layouts.md.\n')
83
+ with open(os.path.join(pack_dir, 'layouts.md'), 'w', encoding='utf-8') as stream:
84
+ stream.write(
85
+ '---\ncanvas: 1920x1080\nlayouts:\n cover:\n role: cover\n'
86
+ ' slots:\n - {role: title, type: title, box: [0, 0, 800, 100], '
87
+ 'size: 48, align: center}\n confidence: high\n---\n'
88
+ )
89
+
90
+ result = rule_v2_16(Pack(pack_dir))
91
+
92
+ self.assertEqual(result.level, 'FAIL')
93
+ self.assertEqual(len(result.fails), 1)
94
+ self.assertIn('旧样式键 align/size', result.fails[0])
95
+
96
+ def test_normautofit_fontscale_shrinks_emitted_font_size(self):
97
+ # 章节大号数字:160px 字号靠 normAutofit fontScale 0.9 装进 144px 的框。
98
+ # 不乘 fontScale,消费端拿到 160px,字比框高,渐变裁切把底部切成透明。
99
+ shape = {
100
+ 'text': {
101
+ 'bodyPr': {'anchor': 't', 'font_scale': 0.9, 'ln_spc_reduction': 0.1},
102
+ 'lstStyle': {'lvl1pPr': {'sz_px': 160, 'lnSpc': {'mult': 1.0}}},
103
+ 'paragraphs': [{'runs': [{'text': '01.'}]}],
104
+ },
105
+ }
106
+ style = slot_style(shape)
107
+ self.assertIn('font-size: 144px', style['css'])
108
+ self.assertNotIn('font-size: 160px', style['css'])
109
+ # lnSpcReduction 0.1 把 1.0*1.2 的行高压到 1.08
110
+ self.assertIn('line-height: 1.08', style['css'])
111
+
112
+ def test_missing_autofit_leaves_font_size_untouched(self):
113
+ # 无 normAutofit(或无 fontScale)时零影响:字号原样、行高不缩。
114
+ shape = {
115
+ 'text': {
116
+ 'bodyPr': {'anchor': 't'},
117
+ 'lstStyle': {'lvl1pPr': {'sz_px': 160, 'lnSpc': {'mult': 1.0}}},
118
+ 'paragraphs': [{'runs': [{'text': '01.'}]}],
119
+ },
120
+ }
121
+ style = slot_style(shape)
122
+ self.assertIn('font-size: 160px', style['css'])
123
+ self.assertIn('line-height: 1.2', style['css'])
124
+
125
+
126
+ if __name__ == '__main__':
127
+ unittest.main()
@@ -0,0 +1,112 @@
1
+ #!/usr/bin/env python3
2
+ """Regression tests for preserving per-container radii."""
3
+ import os
4
+ import tempfile
5
+ import unittest
6
+
7
+ from draft import emit_body, emit_frontmatter
8
+ from query import _recipe_css
9
+
10
+
11
+ def render_frontmatter(radii):
12
+ data = {
13
+ 'radii_census': radii,
14
+ 'spacing_candidates': {},
15
+ }
16
+ tokens = [('surface', {'hex': '#FFFFFF'})]
17
+
18
+ with tempfile.TemporaryDirectory() as output_dir:
19
+ emit_frontmatter(
20
+ data,
21
+ tokens,
22
+ [],
23
+ {},
24
+ [],
25
+ [],
26
+ output_dir,
27
+ )
28
+ with open(os.path.join(output_dir, 'frontmatter.yaml'), encoding='utf-8') as stream:
29
+ return stream.read()
30
+
31
+
32
+ def render_body():
33
+ data = {
34
+ 'canvas': {'px': [1920, 1080]},
35
+ 'form_hint': {'form': 2},
36
+ 'counts': {'slides': 1},
37
+ }
38
+
39
+ with tempfile.TemporaryDirectory() as output_dir:
40
+ emit_body(
41
+ data,
42
+ [],
43
+ [],
44
+ {},
45
+ [],
46
+ [],
47
+ [],
48
+ {},
49
+ output_dir,
50
+ )
51
+ with open(os.path.join(output_dir, 'body.md'), encoding='utf-8') as stream:
52
+ return stream.read()
53
+
54
+
55
+ class RoundedContractTest(unittest.TestCase):
56
+ def test_multiple_radius_tiers_are_not_collapsed_into_one_card_token(self):
57
+ frontmatter = render_frontmatter(
58
+ [
59
+ {'px': 6.9, 'n': 2},
60
+ {'px': 11.9, 'n': 2},
61
+ {'px': 14.4, 'n': 3},
62
+ ]
63
+ )
64
+
65
+ self.assertNotIn('rounded:', frontmatter)
66
+
67
+ def test_single_radius_tier_can_remain_a_global_token(self):
68
+ frontmatter = render_frontmatter([{'px': 12, 'n': 9}])
69
+
70
+ self.assertIn('rounded:\n card: 12px', frontmatter)
71
+
72
+ def test_rare_rounded_exceptions_do_not_override_a_zero_radius_majority(self):
73
+ frontmatter = render_frontmatter(
74
+ [
75
+ {'px': 0, 'n': 241},
76
+ {'px': 3.4, 'n': 4},
77
+ {'px': 6.9, 'n': 3},
78
+ {'px': 50.5, 'n': 1},
79
+ ]
80
+ )
81
+
82
+ self.assertNotIn('rounded:', frontmatter)
83
+
84
+ def test_generated_usage_defaults_unspecified_container_radius_to_zero(self):
85
+ body = render_body()
86
+
87
+ self.assertIn('没有 `border-radius` 就按 `0`', body)
88
+ self.assertIn('不得自行补圆角', body)
89
+
90
+ def test_recipe_does_not_promote_one_rounded_exception_to_the_whole_group(self):
91
+ css = _recipe_css(
92
+ {'type': 'solid', 'color': {'hex': '#FFFFFF'}},
93
+ None,
94
+ [0] * 70 + [50.5],
95
+ None,
96
+ )
97
+
98
+ self.assertFalse(any('border-radius' in declaration for declaration in css))
99
+
100
+ def test_recipe_keeps_a_radius_shared_by_the_whole_group(self):
101
+ css = _recipe_css(
102
+ {'type': 'solid', 'color': {'hex': '#FFFFFF'}},
103
+ None,
104
+ [6.9] * 17,
105
+ None,
106
+ )
107
+
108
+ self.assertIn('border-radius: 6.9px', css)
109
+
110
+
111
+ if __name__ == '__main__':
112
+ unittest.main()
@@ -0,0 +1,208 @@
1
+ #!/usr/bin/env python3
2
+ """Regression tests for inherited layout text and model-decided text roles."""
3
+ import json
4
+ import os
5
+ import sys
6
+ import tempfile
7
+ import unittest
8
+
9
+ sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
10
+
11
+ from draft import draft_layouts, emit_layouts, inherited_text_shapes
12
+ from package import build_layouts_md, split_top_blocks
13
+
14
+
15
+ def text_shape(part, layer, shape_id, box, text, placeholder):
16
+ return {
17
+ 'part': part,
18
+ 'layer': layer,
19
+ 'id': shape_id,
20
+ 'kind': 'sp',
21
+ 'name': 'Text Placeholder',
22
+ 'ph': placeholder,
23
+ 'box': box,
24
+ 'text': {
25
+ 'bodyPr': {},
26
+ 'lstStyle': {
27
+ 'lvl1pPr': {
28
+ 'sz_px': 48,
29
+ 'weight': 600,
30
+ 'color': {'resolved': '#C41230'},
31
+ },
32
+ },
33
+ 'paragraphs': [
34
+ {
35
+ 'runs': [{'text': text}],
36
+ },
37
+ ] if text else [],
38
+ },
39
+ }
40
+
41
+
42
+ class TextRoleContractTest(unittest.TestCase):
43
+ def test_empty_non_placeholder_layout_shape_is_not_a_text_slot(self):
44
+ layout_part = 'ppt/slideLayouts/slideLayout2.xml'
45
+ decorative_shape = text_shape(
46
+ layout_part,
47
+ 'layout',
48
+ '9',
49
+ {'x': 0, 'y': 0, 'w': 1920, 'h': 24},
50
+ '',
51
+ None,
52
+ )
53
+ decorative_shape['name'] = 'Decorative bar'
54
+
55
+ self.assertEqual(inherited_text_shapes([decorative_shape], []), [])
56
+
57
+ def test_empty_slide_inherits_text_slot_and_css_from_its_layout(self):
58
+ layout_part = 'ppt/slideLayouts/slideLayout2.xml'
59
+ slide_part = 'ppt/slides/slide1.xml'
60
+ shapes = [
61
+ text_shape(
62
+ layout_part,
63
+ 'layout',
64
+ '10',
65
+ {'x': 120, 'y': 80, 'w': 840, 'h': 120},
66
+ 'Example heading',
67
+ {'type': 'body', 'idx': '10'},
68
+ ),
69
+ text_shape(
70
+ slide_part,
71
+ 'slide',
72
+ '2',
73
+ None,
74
+ '',
75
+ {'type': 'body', 'idx': '10'},
76
+ ),
77
+ ]
78
+ data = {
79
+ 'canvas': {'px': [1920, 1080]},
80
+ 'form_hint': {'form': 0},
81
+ 'slides': [
82
+ {
83
+ 'part': slide_part,
84
+ 'layout': layout_part,
85
+ 'background': None,
86
+ },
87
+ ],
88
+ 'background_composites': {},
89
+ }
90
+
91
+ with tempfile.TemporaryDirectory() as output_dir:
92
+ os.makedirs(os.path.join(output_dir, 'ref'))
93
+ with open(
94
+ os.path.join(output_dir, 'ref', 'shapes.json'),
95
+ 'w',
96
+ encoding='utf-8',
97
+ ) as stream:
98
+ json.dump({'shapes': shapes}, stream)
99
+ archetypes, _, _ = draft_layouts(data, output_dir)
100
+
101
+ self.assertEqual(len(archetypes), 1)
102
+ self.assertEqual(len(archetypes[0]['slots']), 1)
103
+ slot = archetypes[0]['slots'][0]
104
+ self.assertEqual(slot['box'], [120, 80, 840, 120])
105
+ self.assertEqual(slot['txt'], 'Example heading')
106
+ self.assertEqual(slot['role'], 'body')
107
+ self.assertEqual(slot['type'], 'body')
108
+ self.assertTrue(slot['_needs_role'])
109
+ self.assertIn('font-size: 48px', slot['css'])
110
+ self.assertIn('font-weight: 600', slot['css'])
111
+ self.assertIn('color: #C41230', slot['css'])
112
+
113
+ def test_text_role_judgement_changes_semantics_without_dropping_slot(self):
114
+ archetype = {
115
+ 'name': 'layout-1',
116
+ 'zh': None,
117
+ 'role': 'content',
118
+ 'bg': None,
119
+ 'slots': [
120
+ {
121
+ 'role': 'body',
122
+ 'type': 'body',
123
+ 'box': [120, 80, 840, 120],
124
+ 'sz': 48,
125
+ 'txt': 'Example heading',
126
+ 'css': 'font-size: 48px; color: #C41230',
127
+ '_needs_role': True,
128
+ '_source_layer': 'layout',
129
+ '_placeholder': 'body/10',
130
+ },
131
+ ],
132
+ 'decor': [],
133
+ 'pages': [1],
134
+ 'rep': 1,
135
+ 'pic_n': 0,
136
+ 'confidence': 'low',
137
+ }
138
+
139
+ with tempfile.TemporaryDirectory() as output_dir:
140
+ emit_layouts([archetype], output_dir)
141
+ path = os.path.join(output_dir, 'layouts.yaml')
142
+ with open(path, encoding='utf-8') as stream:
143
+ draft = stream.read()
144
+
145
+ self.assertIn('text_roles:', draft)
146
+ self.assertIn(
147
+ 'layout-1-text-1: TODO文本角色',
148
+ draft,
149
+ )
150
+ self.assertEqual(draft.count('box: [120, 80, 840, 120]'), 1)
151
+
152
+ decided = draft.replace(
153
+ 'layout-1-text-1: TODO文本角色',
154
+ 'layout-1-text-1: title',
155
+ )
156
+ layouts_md = build_layouts_md(split_top_blocks(decided), (1920, 1080))
157
+
158
+ self.assertNotIn('text_roles:', layouts_md)
159
+ self.assertEqual(layouts_md.count('box: [120, 80, 840, 120]'), 1)
160
+ self.assertIn(
161
+ 'role: title, box: [120, 80, 840, 120], type: title',
162
+ layouts_md,
163
+ )
164
+ self.assertIn('css: "font-size: 48px; color: #C41230"', layouts_md)
165
+
166
+ def test_template_layout_shape_without_ph_key_does_not_crash(self):
167
+ # form=3 模板里,版式层可能有「带 box、带文字、但没有 ph 键」的普通形状
168
+ # (非占位符的文本/装饰)。layouts_from_template 的入口筛选是
169
+ # `s.get('ph') or shape_text(s)`——有文字就放进来,随后按 ph 判类型时若用
170
+ # s['ph'] 直接下标就会 KeyError: 'ph',整份抽取在草案阶段崩掉(EXTRACT_PARTIAL)。
171
+ layout_part = 'ppt/slideLayouts/slideLayout1.xml'
172
+ shape = {
173
+ 'part': layout_part,
174
+ 'layer': 'layout',
175
+ 'id': '7',
176
+ 'kind': 'sp',
177
+ 'name': '页脚文字',
178
+ # 关键:没有 'ph' 键
179
+ 'box': {'x': 100, 'y': 980, 'w': 800, 'h': 60},
180
+ 'text': {
181
+ 'bodyPr': {},
182
+ 'lstStyle': {'lvl1pPr': {'sz_px': 20}},
183
+ 'paragraphs': [{'runs': [{'text': '内部资料'}]}],
184
+ },
185
+ }
186
+ data = {
187
+ 'canvas': {'px': [1920, 1080]},
188
+ 'form_hint': {'form': 3},
189
+ 'layouts': [{'part': layout_part}],
190
+ 'slides': [{'part': 'ppt/slides/slide1.xml', 'layout': layout_part,
191
+ 'background': None}],
192
+ 'background_composites': {},
193
+ }
194
+
195
+ with tempfile.TemporaryDirectory() as output_dir:
196
+ os.makedirs(os.path.join(output_dir, 'ref'))
197
+ with open(os.path.join(output_dir, 'ref', 'shapes.json'), 'w',
198
+ encoding='utf-8') as stream:
199
+ json.dump({'shapes': [shape]}, stream)
200
+ # 修复前这里抛 KeyError: 'ph'(draft.py 用 s['ph'] 直接下标),
201
+ # 抽取在草案阶段崩掉、退成 EXTRACT_PARTIAL。修复后应正常返回。
202
+ archetypes, pages, leftover = draft_layouts(data, output_dir)
203
+
204
+ self.assertIsInstance(archetypes, list)
205
+
206
+
207
+ if __name__ == '__main__':
208
+ unittest.main()
@@ -99,17 +99,18 @@ assets:
99
99
  - 方案甲·包内(抽取产物默认形态):大图保留原图 + 压缩图(`<name>@full.<ext>` / `<name>.<ext>`,`path` 指压缩图、`full` 指原图),消费侧优先用压缩图;压缩图 >500KB WARN、包内总量 >20MB FAIL。
100
100
  - 方案乙·平台云盘(入库后目标形态):条目用 `url`,消费时按云盘图片处理参数取压缩版;包内不落二进制,体积约束不适用。入库时由后端把 `path`/`full` 重写为 `url`(重写版仍须过 V2-1/V2-12)。
101
101
  - `url` 必须 http(s) 持久地址,禁 24h TTL 签名 URL。
102
- - 被遮挡/无用资产、页面内容图不进包;抽不出不编造(记 `gaps`,logo 候选图存 `ref/logo-candidates/`)。**边界**:「内容图」指内容区里的图表/截图/配图;实例页整幅替换底图的满屏主视觉(含封面艺术图)属背景族,照收。
102
+ - 图片按用途三分:整幅替换底图的满屏主视觉(含封面艺术图)属**背景族**,照收;服务于具体内容的图表/截图/产品说明图是**内容图,不进包**;既非 logo、又不服务内容的纹理/装饰插画/色块/几何点缀是**装饰图,标 `texture`**。`logo` 特指这份 deck 自己的品牌标志——logo 墙里的第三方 logo 算内容图。被遮挡/无用资产不进包;抽不出不编造(记 `gaps`,logo 候选图存 `ref/logo-candidates/`)。
103
103
 
104
104
  ## 2.5 `## Usage` 章节(正文必产,紧随 Overview)
105
105
 
106
106
  design.md 是消费模型的操作文档,不是抽取记录。`## Usage` 承载三件事,全部**可执行**(具体文件、具体坐标、具体顺序):
107
107
 
108
- 1. **三步指引**:① 搭任何一页之前先读 `layouts.md`,从页型清单里选 archetypeslots 坐标照抄;② 按资产用法表给该页铺底图/放 logo;③ 双主题包写明默认主题与 token 前缀切换法。
108
+ 1. **消费步骤**:① 画布取 `layouts.md` 的 `canvas`;② 从页型清单选 archetype,按其 flow / slots / decor / background 原样落版;③ `design.md` frontmatter 的 colors / typography / spacing / rounded / components 作为全局 token,局部 CSS 优先;④ 包内资产复制到项目相对目录后引用,字体使用完整 fallback 栈且不在运行时安装;⑤ 双主题包写明默认主题与 token 前缀切换法。
109
109
  2. **资产用法表**:每个资产一行——id、文件路径、用在哪类页、怎么摆(logo 给坐标,背景给首选序——如「封面首选 cover-art,无主视觉需求用 cover-dark」)。
110
- 3. **色板纪律一句**:所有颜色取自 `colors` token,强调色只用 primary 家族——风格与内容解耦,内容主题不改变色板。
110
+ 3. **强调色族纪律**:强调色族以 `colors` 段和 layout slot CSS 为主。必要时可使用其他颜色,但新增颜色须与模板整体的色相、明度和饱和度关系协调,且不能形成与模板主色竞争的第二强调色。中性色、低彩度辅助色或局部语义色可表达正负、风险、警告、状态、图表序列,但须保持辅助层级;新色不得通过高饱和、高对比、大面积、跨页重复,或用于标题、关键数字、图表主序列、卡片底色、渐变来获得主视觉权重。
111
+ 4. **交付检查**:逐页确认色板、字体、版式、背景、资产和 Hard Rules 均来自本包,并检查资源加载、内容溢出与画幅裁切。
111
112
 
112
- **Hard Rules 必须包含对应的正向硬规则**(有资产的包):每页放 logo(位置+文件);封面底图必用 cover 资产;版式从 layouts.md 取;颜色只从 colors 取。禁止句只用于无法正向表达的红线,且同句给替代。
113
+ **Hard Rules 必须包含对应的正向硬规则**(有资产的包):每页放 logo(位置+文件);封面底图必用 cover 资产;版式从 layouts.md 取;以 colors / layout slot CSS 为强调色基准,新增颜色与整体色板协调并保持辅助层级。禁止句只用于无法正向表达的红线,且同句给替代。
113
114
 
114
115
  ## 3. `layouts` 段(默认 sidecar)
115
116
 
@@ -123,7 +124,7 @@ layouts:
123
124
  themes: [dark, light] # 深浅孪生合并
124
125
  background: {dark: bg-cover-dark, light: bg-cover-light}
125
126
  slots:
126
- - {role: title, box: [<x>, <y>, <w>, <h>], type: title}
127
+ - {role: title, box: [<x>, <y>, <w>, <h>], type: title, css: "<CSS 声明串>"}
127
128
  - {role: logo, box: [<x>, <y>, <w>, <h>], asset: {dark: logo-on-dark, light: logo-on-light}}
128
129
  decor:
129
130
  - {box: [<x>, <y>, <w>, <h>], geom: ellipse, css: "<CSS 声明串>"}
@@ -132,7 +133,12 @@ layouts:
132
133
 
133
134
  - **`background` 三形态**:`<asset-id>` / `{<theme>: <asset-id>}` / `{color: <colors-token>}`(`color` 是保留键,主题名禁止叫 color)。`asset` 两形态:`<asset-id>` / `{<theme>: <asset-id>}`。
134
135
  - **背景安全扩展**:有真实背景图的 archetype 建议写 `text_safe: [x,y,w,h]`、`avoid: [{box: [x,y,w,h], reason: "..."}]`、`pairing_rule: "..."`。这些是消费约束,不参与封闭枚举;用于避免标题、正文、图表、卡片、表格、时间线及其容器外接矩形覆盖背景视觉主体、强光斑或深色透明区;透明容器也不能跨进禁放区。
135
- - **`decor`(可选)**:这一页无文字的图形骨架——图标托底的圆、卡片、分隔线。每条 `{box, geom, css}`:`box` 定位,`css` 是可直接写进 style 的声明串,`geom` 取源形状的 prst(`ellipse` 另加 `border-radius: 50%`)。层级在背景之上、`slots` 之下;带 `asset` 的槽落在 decor 之上是版式本意,不算重叠。
136
+ - **流式页型**:内容长度会变化的内容页可用 `flow.regions` 表达纵向区带。`stack` 表达单列顺序,`grid` 表达并列列组,`free` 中的 item 必须带 `box`,用于 logo、页码、页眉和页脚等固定锚点。并列卡片可在 `grid.items` 中使用一层 `{role: group, css, gap, items}`:group 的 `css` 是卡片容器样式,内部 `items` 按顺序排布;不继续嵌套 group。区带可带自己的 `margin: [左, 右]`,覆盖 `flow` 整块的 `margin`(居中卡片组和贴左标题横向范围本就不同);不带则继承整块 `margin`。纵向位置与留白由消费模型结合实际内容决定,不把样张的 `y` 坐标当作流式硬约束。
137
+ - **`decor`(可选)**:这一页无文字的图形骨架——图标托底的圆、卡片、分隔线。每条 `{box, geom, css}`:`box` 定位,`css` 是可直接写进 style 的声明串,`geom` 取源形状的 prst(`ellipse` 另加 `border-radius: 50%`)。圆角以每条 `css` 为准,没有 `border-radius` 就按 `0`;不得因 `geom: roundRect` 自行补圆角,因为 OOXML 的 roundRect 可以有零圆角调节点。层级在背景之上、`slots` 之下;带 `asset` 的槽落在 decor 之上是版式本意,不算重叠。
138
+ - **slot 样式契约**:`box` 只承载 `[x,y,w,h]` 几何;可渲染属性统一放进 `css`,并可直接写入 HTML `style`。PPTX `bodyPr.insets_px` 转成 `box-sizing: border-box; padding: ...`,字号/字重/颜色/水平与垂直对齐/行高/字距/旋转分别转成标准 CSS。禁止在 slot 中输出 `size` / `weight` / `color` / `align` / `valign` / `insets_px` 等旧字段。
139
+ - **文本角色判断**:脚本把实例页及其引用版式中的现有文本槽、几何和 CSS 完整写入草案;`text_roles` 只供模型把这些槽判断为 `title | subtitle | header | footer | body`,不控制槽位去留。判断不清时用 `body`,不归纳模板中不存在的标题、页眉或页脚。
140
+ - **标题结构**:存在合适的模板页型时,沿用其标题层级和局部 CSS,只渲染该页型已有的文字槽;背景中已经可见的固定标题不重复创建文本,该页型没有副标题槽时不新增副标题。没有合适参考时由模型按模板整体视觉判断。
141
+ - **圆角作用域**:`rounded` 只允许表达全档共同的单一圆角档位;零圆角与非零圆角混用、或存在多个非零档位时不输出该全局 token。此时每个 `role: container` / `decor` 的 `css` 是唯一事实源,逐项原样消费,不得归并或推断。
136
142
  - **`type` 封闭枚举**:`title | subtitle | body | pic | table | chart | media | slide-number | footer`。大数字/序号走 `type: title`,语义由 `role`(如 `big-number`)承担。
137
143
  - **`slots.*.role` 开放不校验**(语义槽位):优先复用已知词表(OOXML ST_SlideLayoutType / Slidev 20 布局 / Google PredefinedLayout,如 big-number、caption、main-point),确无对应再自造。
138
144
  - archetype ≤15(内联降级形态 ≤11);深浅孪生合并为一条;版式溯源/母版取舍进 `ref/`。
@@ -149,7 +155,7 @@ safe-area: # 开放命名 map,可多套边距体系
149
155
 
150
156
  冲突裁决:`slots.box` 是实例真值,`safe-area` 是归纳框架,**以 slots.box 为准**。
151
157
 
152
- ## 5. check_v2 校验(18 行:V2-1..V2-15 + V2-R5/R6/R7)
158
+ ## 5. check_v2 校验(19 行:V2-1..V2-16 + V2-R5/R6/R7)
153
159
 
154
160
  check_v1 全部规则原样生效。扫描范围 = 包目录,V2-1/V2-2 跨 design.md + layouts.md 求并集。
155
161
 
@@ -170,6 +176,7 @@ check_v1 全部规则原样生效。扫描范围 = 包目录,V2-1/V2-2 跨 des
170
176
  | V2-13 | 多主题(`themes` 长度 >1)缺 `default-theme`(只看 design.md frontmatter——冲突以 design.md 为准) | WARN |
171
177
  | V2-14 | 版式的 `flow` 与 `slots` 互斥(同时出现 = FAIL);`flow.regions[].kind` 在 `grid`/`stack`/`free` 内,`grid` 必带 `cols` | FAIL |
172
178
  | V2-15 | 同段字段自洽:`backgrounds.*` 的 `text_safe` 不得与任一 `avoid` 相交;两者形态须为 `[x, y, w, h]` 四个数且 w/h 为正 | FAIL |
179
+ | V2-16 | slot/flow item 的渲染样式只通过 `css` 承载;出现 `size/weight/color/align/valign/insets_px` 旧键 | FAIL |
173
180
  | V2-R5 | sidecar frontmatter 重复 design.md 已有顶层键(`layouts` 载荷键与 `canvas` 除外——canvas 的家就在 sidecar) | WARN |
174
181
  | V2-R6 | assets 条目出现审计字段(boxes/aspect/mark/confidence)或 design.md 顶层出现 canvas/canvas-source/theme-mechanism/color-confidence——应移 `ref/audit.yaml` / layouts.md | WARN |
175
182
  | V2-R7 | 有 layouts sidecar 指针但正文未出现 `layouts.md` 字样(弱指针,消费者到不了版式数据) | WARN |
@@ -17,14 +17,6 @@ metadata:
17
17
 
18
18
  每张幻灯片既是版式设计的练习,也是文案写作的练习。动手前先写大纲;好的大纲本身就是一次讲故事和叙事结构的练习。
19
19
 
20
- ## PPTX/POTX 模板附件前置步骤
21
-
22
- 如果用户上传了 `.pptx` 或 `.potx`,并要求制作/生成/改做一个 PPT、演示文稿、slides、deck,先判断附件是否是模板或视觉参考。
23
-
24
- - 命中“按这个模板 / 照附件风格 / 参考这个 PPT / 保持同款视觉 / 基于这个模板”等意图时,先调用 `pptx-style-extract` skill,读取产出的 `design.md`、`layouts.md` 和 `assets/`,再开始写 deck。
25
- - 只总结、翻译、提取内容、审阅已有 PPTX 时,不需要抽取风格。
26
- - 不要用 `SummarizeAttachmentOrFile` 的 Markdown/文本摘要替代风格抽取;文本摘要不包含母版、色板、字体、版式坐标和素材角色。
27
-
28
20
  ## 动手前先问
29
21
 
30
22
  - 如果用户没有说明想要的视觉风格,也没有提供 design system,就用提问工具(ask_user_question)**主动询问**。绝不要直接给出一个通用设计!
@@ -45,18 +37,6 @@ metadata:
45
37
 
46
38
  deck-stage 组件会对每个 slotted 子元素做绝对定位——**绝不**在幻灯片 `<section>` 元素上自行设置 position/inset/width/height。
47
39
 
48
- ### 使用 PPTX 风格包
49
-
50
- 如果前一步产出了 `pptx-style-extract` 风格包,必须把它当作本 deck 的设计系统:
51
-
52
- - 先读 `design.md` 的 Usage / Hard Rules / colors / typography / components / assets / safe-area。
53
- - 再读 `layouts.md`,用其中的 layout archetype 和 slots 坐标生成页面;坐标单位已经是 px@1920,不需要 EMU 或 pt 换算。
54
- - 消费并落实 colors / typography / spacing / rounded / safe-area 等样式 token;可以用 CSS variables、类名或内联样式承载,但最终页面必须看得出这些 token 被系统性使用,而不是另起一套视觉系统。
55
- - 背景和版式必须成对消费:选择某个 layout archetype 时,同时采用它声明的 `background`、`text_safe`、`avoid` / `pairing_rule`。标题、正文、图表、表格、卡片、时间线及其容器外接矩形不得进入背景禁放区;如果内容与背景主体冲突,换页型、拆页或缩小内容区域,不要只换背景色或把容器铺到禁放区。
56
- - 把包内 `assets/` 复制到项目内相对目录并引用复制后的路径;最终 HTML 禁止引用 `/tmp` 或本机绝对路径。
57
- - 字体使用 design.md 的完整 font stack 和 fallback,不现场安装字体。
58
- - 自检时除了常规 deck preflight,还要确认色板、字体、版式坐标、资产和 Hard Rules 均来自该风格包。
59
-
60
40
  ### 把幻灯片内容写成静态 HTML,而不是 React
61
41
 
62
42
  幻灯片内容应写成静态 HTML,而非 React 或脚本生成的 DOM。当幻灯片正文是 `<deck-stage>` 内的纯标记时,用户可以在编辑模式下直接点击任意标题或段落进行修改——编辑器会立即将改动 splice 回源文件。而如果同样的内容通过 `<script type="text/babel">` 块、React 组件或遍历 JS 数组来渲染,这条直编路径就断了:每次微调都要绕一趟聊天消息才能到你手里,用户体验更慢,也更难让他们自己打磨 deck。因此,凡是静态页面能表达的——文本、布局、背景、图片——都直接在 HTML 里写字面元素并用 CSS 设置样式。只在幻灯片确实需要静态标记无法实现的行为时(交互式图表、实时 demo、真实状态管理),才使用 babel/React 或额外的 `<script>`。同样的渲染结果,静态 HTML 版本**始终优先于**动态版本,因为静态版本可被直接编辑。Tweaks 面板(`tweaks-panel.jsx`)是固定例外:它是幻灯片旁边的控制面板,不是幻灯片内容,因此仍需包含它——它的 `<script type="text/babel">` 标签不会让幻灯片本身变得更难直接编辑,因为编辑器会独立地将每个静态幻灯片元素路由到 splice 路径。
@@ -144,6 +124,21 @@ deck-stage 组件会对每个 slotted 子元素做绝对定位——**绝不**
144
124
  5. **把这套 token 当成每页的内容预算**:在上述数值下,一页正文区大约容纳 14 行正文、或 6 个两行 bullet——在 scratchpad 排内容时就按预算裁剪,而不是写完再看塞不塞得下。装不下的处置顺序是**拆页 > 删内容 > 换更省空间的版式**;缩小字号是最后手段,且绝不越过 24px 下限——靠缩字塞进去的页,只是把溢出换成了后排看不清。反过来,内容远少于预算的页按「视觉平衡」的出路增密或合并,而不是放大字号去撑面积。
145
125
  6. 构建幻灯片,牢记每张幻灯片既是设计练习也是文案练习。在版式、文字内容和语调方面给予每张幻灯片应有的关注。遵循上述原则,确保每张幻灯片能独立成立;一个只看这一页的人,应当无需其他上下文就能理解其高层含义。
146
126
 
127
+ ## 提交前资源完整性门禁
128
+
129
+ 最终一次写入 HTML/CSS 后、调用 `run_commit` 前,必须从项目根目录运行:
130
+
131
+ ```bash
132
+ python3 <本skill目录>/scripts/check_local_references.py index.html
133
+ ```
134
+
135
+ 把 `<本skill目录>` 换成本 skill 的实际所在目录。脚本从最终 `index.html` 出发,递归检查 HTML/CSS 引用的每个项目内脚本、样式、图片、字体等文件是否真实存在;外部 URL 不做离线探测。
136
+
137
+ - 只有输出 `RESOURCE_CHECK: PASS` 才能提交。
138
+ - 输出 `RESOURCE_CHECK: FAIL` 时,先重新复制或修正列出的项目内文件,再原样重跑;不得删除引用来掩盖仍在使用的资源。
139
+ - 该检查针对最终工作区状态。较早执行过复制命令或检查,不能证明最终提交完整。
140
+ - `run_commit` 的静态检查跳过参数不能替代本门禁,也不能用来绕过失败;提交时必须包含检查通过所依赖的全部项目内文件。
141
+
147
142
  ## 验证要点
148
143
 
149
144
  审阅时,用幻灯片构图规则——而非网页布局直觉——来检查版面。底部留白是不是缺陷,用「留白 ≠ 空洞」的归属判据:内容自身完整、下方是无边框的整块呼吸空间,这是正确的幻灯片构图——不要出于网页直觉把 `flex-start` 改成 `center`;空白被元素边界圈占的,是被动空洞,按「视觉平衡」的出路修。