@lark-apaas/coding-steering 0.1.18-dev.6de99aa → 0.1.18-dev.7f786ca

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 (43) hide show
  1. package/README.md +19 -21
  2. package/package.json +1 -1
  3. package/steering/design-html/skills/animated-video/SKILL.md +2 -2
  4. package/steering/design-html/skills/charts/SKILL.md +52 -7
  5. package/steering/design-html/skills/{data-report → data-viz}/SKILL.md +65 -9
  6. package/steering/design-html/skills/frontend-design/SKILL.md +2 -2
  7. package/steering/design-html/skills/mini-game/SKILL.md +71 -0
  8. package/steering/design-html/skills/mini-game/references/three-js.md +54 -0
  9. package/steering/design-html/skills/pptx-style-extract/SKILL.md +148 -0
  10. package/steering/design-html/skills/pptx-style-extract/font-fallback.yaml +129 -0
  11. package/steering/design-html/skills/pptx-style-extract/scripts/census.py +961 -0
  12. package/steering/design-html/skills/pptx-style-extract/scripts/check_v2.py +1052 -0
  13. package/steering/design-html/skills/pptx-style-extract/scripts/draft.py +2804 -0
  14. package/steering/design-html/skills/pptx-style-extract/scripts/export_consumer_md.py +75 -0
  15. package/steering/design-html/skills/pptx-style-extract/scripts/export_consumer_zip.py +175 -0
  16. package/steering/design-html/skills/pptx-style-extract/scripts/extract.py +1068 -0
  17. package/steering/design-html/skills/pptx-style-extract/scripts/ooxml.py +716 -0
  18. package/steering/design-html/skills/pptx-style-extract/scripts/package.py +1464 -0
  19. package/steering/design-html/skills/pptx-style-extract/scripts/parts.py +464 -0
  20. package/steering/design-html/skills/pptx-style-extract/scripts/query.py +557 -0
  21. package/steering/design-html/skills/pptx-style-extract/scripts/render_pages.py +685 -0
  22. package/steering/design-html/skills/pptx-style-extract/scripts/test_asset_judgment_package.py +161 -0
  23. package/steering/design-html/skills/pptx-style-extract/scripts/test_background_composite.py +57 -0
  24. package/steering/design-html/skills/pptx-style-extract/scripts/test_color_contract.py +60 -0
  25. package/steering/design-html/skills/pptx-style-extract/scripts/test_design_consumer_contract.py +63 -0
  26. package/steering/design-html/skills/pptx-style-extract/scripts/test_flow_layout_contract.py +468 -0
  27. package/steering/design-html/skills/pptx-style-extract/scripts/test_layout_css.py +503 -0
  28. package/steering/design-html/skills/pptx-style-extract/scripts/test_rounded_contract.py +112 -0
  29. package/steering/design-html/skills/pptx-style-extract/scripts/test_text_role_contract.py +208 -0
  30. package/steering/design-html/skills/pptx-style-extract/scripts/verify_font.py +68 -0
  31. package/steering/design-html/skills/pptx-style-extract/v2-format-spec.md +205 -0
  32. package/steering/design-html/skills/preflight/SKILL.md +26 -131
  33. package/steering/design-html/skills/preflight/scripts/probe.sh +108 -0
  34. package/steering/design-html/skills/slide-deck/SKILL.md +160 -0
  35. package/steering/design-html/skills/slide-deck/scripts/check_local_references.py +179 -0
  36. package/steering/design-html/skills/{visual-exposure → visual-report}/SKILL.md +24 -2
  37. package/steering/nestjs-react-fullstack/skills/plugin-guide/SKILL.md +5 -3
  38. package/steering/nestjs-react-fullstack/skills_common/trigger-guide/SKILL.md +180 -0
  39. package/steering/nestjs-react-fullstack/{skills/trigger-guide/SKILL.md → skills_common/trigger-guide/references/trigger-lifecycle.md} +11 -162
  40. package/steering/nestjs-react-fullstack/skills_local/plugin-guide/SKILL.md +4 -0
  41. package/steering/vite-react/skills/plugin-guide/SKILL.md +3 -1
  42. package/steering/vite-react/skills/react-three-fiber/SKILL.md +4 -0
  43. package/steering/design-html/skills/make-a-deck/SKILL.md +0 -209
@@ -0,0 +1,161 @@
1
+ #!/usr/bin/env python3
2
+ """Integration regression tests for model-decided image 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 check_v2 import Pack, RULES # noqa: E402
12
+ from package import main as package_main # noqa: E402
13
+
14
+
15
+ class AssetJudgmentPackageTest(unittest.TestCase):
16
+ def test_package_strips_judgment_fields_and_preserves_content_slot(self):
17
+ try:
18
+ from PIL import Image
19
+ except ImportError:
20
+ self.skipTest('Pillow unavailable')
21
+
22
+ with tempfile.TemporaryDirectory() as root:
23
+ stage1 = os.path.join(root, 'stage1')
24
+ lout = os.path.join(stage1, 'l-out')
25
+ pack = os.path.join(root, 'pack')
26
+ media = os.path.join(stage1, 'media-out')
27
+ ref = os.path.join(stage1, 'ref')
28
+ os.makedirs(lout)
29
+ os.makedirs(media)
30
+ os.makedirs(ref)
31
+
32
+ Image.new('RGBA', (40, 20), (20, 40, 60, 255)).save(
33
+ os.path.join(media, 'partner-logo.png'))
34
+ Image.new('RGBA', (24, 24), (60, 40, 20, 255)).save(
35
+ os.path.join(media, 'ornament.png'))
36
+
37
+ box_rows = [
38
+ ('ppt/media/image1.png', 'partner-logo.png', [100, 200, 400, 200]),
39
+ ('ppt/media/image2.png', 'ornament.png', [40, 40, 120, 120]),
40
+ ]
41
+ extract = {
42
+ 'source': {'filename': 'fixture.pptx'},
43
+ 'canvas': {
44
+ 'px': [1920, 1080],
45
+ 'source': {'cx': 12192000, 'cy': 6858000, 'unit': 'EMU'},
46
+ },
47
+ 'media': [
48
+ {
49
+ 'media': source,
50
+ 'out': 'media-out/' + output,
51
+ 'source_px': [40, 20] if output == 'partner-logo.png' else [24, 24],
52
+ }
53
+ for source, output, _ in box_rows
54
+ ],
55
+ 'images': [
56
+ {
57
+ 'media': source,
58
+ 'boxes': [{
59
+ 'count': 1,
60
+ 'box': {'x': box[0], 'y': box[1], 'w': box[2], 'h': box[3]},
61
+ 'parts': ['ppt/slides/slide1.xml'],
62
+ }],
63
+ }
64
+ for source, _, box in box_rows
65
+ ],
66
+ 'color_freq': [],
67
+ 'text_scale': [],
68
+ }
69
+ with open(os.path.join(stage1, 'extract.json'), 'w', encoding='utf-8') as stream:
70
+ json.dump(extract, stream)
71
+ with open(os.path.join(ref, 'shapes.json'), 'w', encoding='utf-8') as stream:
72
+ json.dump({
73
+ 'shapes': [
74
+ {
75
+ 'part': 'ppt/slides/slide1.xml',
76
+ 'kind': 'pic',
77
+ 'name': output,
78
+ 'box': {'x': box[0], 'y': box[1], 'w': box[2], 'h': box[3]},
79
+ }
80
+ for _, output, box in box_rows
81
+ ],
82
+ }, stream)
83
+
84
+ with open(os.path.join(lout, 'manifest.yaml'), 'w', encoding='utf-8') as stream:
85
+ stream.write(
86
+ 'version: alpha\n'
87
+ 'name: asset-judgment-fixture\n'
88
+ 'description: >\n'
89
+ ' A restrained fixture with explicit image-role judgments and traced layout slots.\n'
90
+ 'assets:\n'
91
+ ' - id: logo-primary\n'
92
+ ' source_media: partner-logo.png\n'
93
+ ' kind: logo\n'
94
+ ' on-bg: light\n'
95
+ 'asset_decisions:\n'
96
+ ' - source_media: partner-logo.png\n'
97
+ ' decision: content\n'
98
+ ' - source_media: ornament.png\n'
99
+ ' decision: texture\n'
100
+ )
101
+ with open(os.path.join(lout, 'frontmatter.yaml'), 'w', encoding='utf-8') as stream:
102
+ stream.write('')
103
+ with open(os.path.join(lout, 'layouts.yaml'), 'w', encoding='utf-8') as stream:
104
+ stream.write(
105
+ 'layouts:\n'
106
+ ' content:\n'
107
+ ' name: "内容页"\n'
108
+ ' role: content\n'
109
+ ' slots:\n'
110
+ ' - {role: logo, box: [100, 200, 400, 200], type: pic, '
111
+ 'asset: logo-primary, source_media: partner-logo.png}\n'
112
+ ' - {role: asset-candidate, box: [40, 40, 120, 120], type: pic, '
113
+ 'source_media: ornament.png}\n'
114
+ ' confidence: high\n'
115
+ )
116
+ with open(os.path.join(lout, 'body.md'), 'w', encoding='utf-8') as stream:
117
+ stream.write(
118
+ '## Usage\n\n'
119
+ 'Read `layouts.md` before composing a slide.\n\n'
120
+ '## Assets\n\n'
121
+ '{{ASSET_TABLE}}\n\n'
122
+ '## Hard Rules\n\n'
123
+ '{{LOGO_RULES}}\n'
124
+ )
125
+ check_v1 = os.path.join(root, 'check_v1.py')
126
+ with open(check_v1, 'w', encoding='utf-8') as stream:
127
+ stream.write('raise SystemExit(0)\n')
128
+
129
+ rc = package_main([stage1, lout, pack, '--check-v1', check_v1])
130
+
131
+ self.assertEqual(rc, 0)
132
+ with open(os.path.join(pack, 'design.md'), encoding='utf-8') as stream:
133
+ design = stream.read()
134
+ with open(os.path.join(pack, 'layouts.md'), encoding='utf-8') as stream:
135
+ layouts = stream.read()
136
+ self.assertNotIn('asset_decisions', design)
137
+ self.assertNotIn('source_media', design)
138
+ self.assertNotIn('source_media', layouts)
139
+ self.assertNotIn('{{LOGO_RULES}}', design)
140
+ self.assertNotIn('logo-primary', design)
141
+ self.assertNotIn('logo-primary', layouts)
142
+ self.assertIn(
143
+ '- {role: pic, box: [100, 200, 400, 200], type: pic}',
144
+ layouts,
145
+ )
146
+ self.assertIn('texture-1:', design)
147
+ self.assertIn('kind: texture', design)
148
+ self.assertIn(
149
+ '- {role: texture, box: [40, 40, 120, 120], type: pic, asset: texture-1}',
150
+ layouts,
151
+ )
152
+ gate = Pack(pack)
153
+ self.assertFalse([
154
+ result
155
+ for result in (rule(gate) for rule in RULES)
156
+ if result.fails
157
+ ])
158
+
159
+
160
+ if __name__ == '__main__':
161
+ unittest.main()
@@ -0,0 +1,57 @@
1
+ #!/usr/bin/env python3
2
+ """Focused regression tests for deterministic picture compositing."""
3
+ import io
4
+ import os
5
+ import sys
6
+ import unittest
7
+
8
+ from PIL import Image
9
+
10
+ sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
11
+
12
+ from extract import _draw_picture # noqa: E402
13
+
14
+
15
+ class _Archive:
16
+ def __init__(self, media, raw):
17
+ self.names = {media}
18
+ self.zip = self
19
+ self.raw = raw
20
+
21
+ def read(self, media):
22
+ if media not in self.names:
23
+ raise KeyError(media)
24
+ return self.raw
25
+
26
+
27
+ def _png(pixels):
28
+ image = Image.new('RGBA', (len(pixels), 1))
29
+ image.putdata(pixels)
30
+ output = io.BytesIO()
31
+ image.save(output, 'PNG')
32
+ return output.getvalue()
33
+
34
+
35
+ class BackgroundCompositeTest(unittest.TestCase):
36
+ def test_applies_flip_and_opacity_once(self):
37
+ media = 'ppt/media/source.png'
38
+ package = _Archive(media, _png([(255, 0, 0, 255), (0, 0, 255, 255)]))
39
+ canvas = Image.new('RGBA', (2, 1), (255, 255, 255, 255))
40
+
41
+ drawn = _draw_picture(canvas, {
42
+ 'media': media,
43
+ 'box_unrotated': {'x': 0, 'y': 0, 'w': 2, 'h': 1},
44
+ 'flipH': True,
45
+ 'opacity': 0.5,
46
+ }, package)
47
+
48
+ self.assertTrue(drawn)
49
+ left, right = canvas.getpixel((0, 0)), canvas.getpixel((1, 0))
50
+ self.assertEqual(left[:3], (128, 128, 255))
51
+ self.assertEqual(right[:3], (255, 128, 128))
52
+ self.assertEqual(left[3], 255)
53
+ self.assertEqual(right[3], 255)
54
+
55
+
56
+ if __name__ == '__main__':
57
+ unittest.main()
@@ -0,0 +1,60 @@
1
+ #!/usr/bin/env python3
2
+ """Regression test for the generated consumer-facing color contract."""
3
+ import os
4
+ import tempfile
5
+ import unittest
6
+
7
+ from draft import emit_body
8
+
9
+
10
+ class ColorContractTest(unittest.TestCase):
11
+ def test_body_allows_supporting_colors_without_a_second_accent_system(self):
12
+ data = {
13
+ 'canvas': {'px': [1920, 1080]},
14
+ 'counts': {'slides': 1},
15
+ 'form_hint': {'form': 3},
16
+ }
17
+ tokens = [
18
+ ('primary', {'hex': '#123456'}),
19
+ ('surface', {'hex': '#FFFFFF'}),
20
+ ]
21
+ fonts = [
22
+ {
23
+ 'names': ['Example Sans'],
24
+ 'stack': ['Example Sans', 'Noto Sans SC'],
25
+ },
26
+ ]
27
+ roles = {'body': {'sz_px': 36}}
28
+ archetypes = [
29
+ {
30
+ 'name': 'content',
31
+ 'slots': [],
32
+ },
33
+ ]
34
+
35
+ with tempfile.TemporaryDirectory() as output_dir:
36
+ emit_body(
37
+ data,
38
+ tokens,
39
+ fonts,
40
+ roles,
41
+ [],
42
+ archetypes,
43
+ [],
44
+ {},
45
+ output_dir,
46
+ )
47
+ with open(os.path.join(output_dir, 'body.md'), encoding='utf-8') as stream:
48
+ body = stream.read()
49
+
50
+ self.assertIn('允许新增中性色、低彩度辅助色或局部语义色', body)
51
+ self.assertRegex(body, r'正负.*风险.*警告.*状态.*图表序列')
52
+ self.assertIn('必要时可以使用 Colors 之外的颜色', body)
53
+ self.assertIn('不能形成与模板主色竞争的第二强调色', body)
54
+ self.assertIn('色相、明度和饱和度关系', body)
55
+ self.assertIn('高饱和、高对比、大面积或跨页重复', body)
56
+ self.assertIn('标题、关键数字、图表主序列、卡片底色或渐变', body)
57
+
58
+
59
+ if __name__ == '__main__':
60
+ unittest.main()
@@ -0,0 +1,63 @@
1
+ #!/usr/bin/env python3
2
+ """Regression tests for consumer rules emitted into design.md."""
3
+ import os
4
+ import tempfile
5
+ import unittest
6
+
7
+ from draft import emit_body
8
+
9
+
10
+ class DesignConsumerContractTest(unittest.TestCase):
11
+ def test_generated_design_owns_template_consumption_rules(self):
12
+ data = {
13
+ 'canvas': {'px': [1920, 1080]},
14
+ 'counts': {'slides': 1},
15
+ 'form_hint': {'form': 3},
16
+ }
17
+ tokens = [('primary', {'hex': '#123456'})]
18
+ fonts = [
19
+ {
20
+ 'names': ['Example Sans'],
21
+ 'stack': ['Example Sans', 'Noto Sans SC'],
22
+ },
23
+ ]
24
+ roles = {'body': {'sz_px': 36}}
25
+ assets = [
26
+ {
27
+ 'id': 'bg-content',
28
+ 'kind': 'background',
29
+ 'role': 'content',
30
+ },
31
+ ]
32
+ archetypes = [{'name': 'content', 'slots': []}]
33
+
34
+ with tempfile.TemporaryDirectory() as output_dir:
35
+ emit_body(
36
+ data,
37
+ tokens,
38
+ fonts,
39
+ roles,
40
+ assets,
41
+ archetypes,
42
+ [],
43
+ {},
44
+ output_dir,
45
+ )
46
+ with open(os.path.join(output_dir, 'body.md'), encoding='utf-8') as stream:
47
+ body = stream.read()
48
+
49
+ self.assertIn('是全局 token', body)
50
+ self.assertIn('局部 slot / decor 的 `css` 优先', body)
51
+ self.assertIn('字体使用 Typography 的完整栈与降级', body)
52
+ self.assertIn('将包内 `assets/` 复制到项目内相对目录', body)
53
+ self.assertIn('本机绝对路径', body)
54
+ self.assertIn('背景、资产和本段规则均来自本风格包', body)
55
+ self.assertIn('页面无资源加载失败、内容溢出或画幅裁切', body)
56
+ self.assertIn('沿用该页型已有的标题层级与局部 `css`', body)
57
+ self.assertIn('背景中已经可见的固定标题不再创建文本', body)
58
+ self.assertIn('没有 `subtitle` 槽就不新增副标题', body)
59
+ self.assertIn('区带自带 `margin: [左, 右]` 时用它的', body)
60
+
61
+
62
+ if __name__ == '__main__':
63
+ unittest.main()