@lark-apaas/coding-steering 0.1.32-beta.0 → 0.1.32-dev.a87aa13
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.
- package/package.json +6 -6
- package/steering/design-html/skills/charts/SKILL.md +4 -0
- package/steering/design-html/skills/pptx-style-extract/SKILL.md +58 -22
- package/steering/design-html/skills/pptx-style-extract/font-fallback.yaml +3 -3
- package/steering/design-html/skills/pptx-style-extract/scripts/census.py +18 -12
- package/steering/design-html/skills/pptx-style-extract/scripts/check_v2.py +153 -8
- package/steering/design-html/skills/pptx-style-extract/scripts/draft.py +1768 -241
- package/steering/design-html/skills/pptx-style-extract/scripts/extract.py +325 -22
- package/steering/design-html/skills/pptx-style-extract/scripts/ooxml.py +1 -1
- package/steering/design-html/skills/pptx-style-extract/scripts/package.py +379 -156
- package/steering/design-html/skills/pptx-style-extract/scripts/parts.py +6 -3
- package/steering/design-html/skills/pptx-style-extract/scripts/query.py +4 -9
- package/steering/design-html/skills/pptx-style-extract/scripts/render_pages.py +16 -10
- package/steering/design-html/skills/pptx-style-extract/scripts/test_background_composite.py +57 -0
- package/steering/design-html/skills/pptx-style-extract/scripts/test_color_contract.py +60 -0
- package/steering/design-html/skills/pptx-style-extract/scripts/test_design_consumer_contract.py +62 -0
- package/steering/design-html/skills/pptx-style-extract/scripts/test_flow_layout_contract.py +378 -0
- package/steering/design-html/skills/pptx-style-extract/scripts/test_layout_css.py +98 -0
- package/steering/design-html/skills/pptx-style-extract/scripts/test_rounded_contract.py +112 -0
- package/steering/design-html/skills/pptx-style-extract/scripts/test_text_role_contract.py +168 -0
- package/steering/design-html/skills/pptx-style-extract/v2-format-spec.md +27 -15
- package/steering/design-html/skills/preflight/scripts/probe.sh +0 -0
- package/steering/nestjs-react-fullstack/skills/app-init-feasibility-guide/SKILL.md +1 -0
- package/steering/nestjs-react-fullstack/skills/authn-guide/SKILL.md +6 -0
- package/steering/nestjs-react-fullstack/skills/authz-guide/SKILL.md +5 -5
- package/steering/nestjs-react-fullstack/skills/authz-guide/references/dynamic-permission-guide.md +1 -1
- package/steering/nestjs-react-fullstack/skills/client-builtins-file-storage-service/SKILL.md +37 -113
- package/steering/nestjs-react-fullstack/skills/client-builtins-user-service/SKILL.md +13 -2
- package/steering/nestjs-react-fullstack/skills/code-fix/SKILL.md +7 -7
- package/steering/nestjs-react-fullstack/skills/coding-guide/SKILL.md +149 -24
- package/steering/nestjs-react-fullstack/skills/connections-sdk/SKILL.md +202 -0
- package/steering/nestjs-react-fullstack/skills/nestjs-cache/SKILL.md +255 -0
- package/steering/nestjs-react-fullstack/skills/plugin-guide/SKILL.md +158 -543
- package/steering/nestjs-react-fullstack/skills/plugin-guide/references/plugin-coding-guide.md +15 -1
- package/steering/nestjs-react-fullstack/skills/plugin-guide/references/table.md +30 -14
- package/steering/nestjs-react-fullstack/skills/raw-sql-boundary-audit/SKILL.md +63 -0
- package/steering/nestjs-react-fullstack/skills/server-builtins-file-storage-service/SKILL.md +1 -1
- package/steering/nestjs-react-fullstack/skills_common/trigger-guide/SKILL.md +284 -12
- package/steering/nestjs-react-fullstack/skills_local/plugin-guide/SKILL.md +4 -0
- package/steering/vite-react/skills/plugin-guide/SKILL.md +3 -1
- package/steering/vite-react/skills/react-three-fiber/SKILL.md +4 -0
- package/steering/nestjs-react-fullstack/skills/client-add-aily-web-chat/SKILL.md +0 -139
- package/steering/nestjs-react-fullstack/skills/feishu/SKILL.md +0 -269
- package/steering/nestjs-react-fullstack/skills/feishu/references/approval.md +0 -214
- package/steering/nestjs-react-fullstack/skills/feishu/references/attendance.md +0 -163
- package/steering/nestjs-react-fullstack/skills/feishu/references/bitable.md +0 -311
- package/steering/nestjs-react-fullstack/skills/feishu/references/calendar.md +0 -190
- package/steering/nestjs-react-fullstack/skills/feishu/references/contacts.md +0 -160
- package/steering/nestjs-react-fullstack/skills/feishu/references/doc.md +0 -257
- package/steering/nestjs-react-fullstack/skills/feishu/references/drive.md +0 -104
- package/steering/nestjs-react-fullstack/skills/feishu/references/events.md +0 -199
- package/steering/nestjs-react-fullstack/skills/feishu/references/id-convert.md +0 -128
- package/steering/nestjs-react-fullstack/skills/feishu/references/messaging.md +0 -207
- package/steering/nestjs-react-fullstack/skills/feishu/references/oauth.md +0 -165
- package/steering/nestjs-react-fullstack/skills/feishu/references/perm.md +0 -91
- package/steering/nestjs-react-fullstack/skills/feishu/references/wiki.md +0 -165
- package/steering/nestjs-react-fullstack/skills_common/trigger-guide/references/trigger-lifecycle.md +0 -301
|
@@ -38,7 +38,7 @@ L 层判断单 schema(<l-out-dir> 四个文件,这段就是填写说明书
|
|
|
38
38
|
assets: # 可选;无资产包可整段省略
|
|
39
39
|
- id: bg-cover # 必填。命名规则 <kind 前缀>-<语义名>,
|
|
40
40
|
# logo- / slogan- / bg- / texture- / icon-
|
|
41
|
-
source_media:
|
|
41
|
+
source_media: <原图文件名> # media-out/ 里的**原图**文件名(不是压缩版)
|
|
42
42
|
kind: background # logo|slogan|background|texture|icon
|
|
43
43
|
role: cover # background/icon 用;封闭枚举见规范 §2
|
|
44
44
|
theme: dark # 双主题包按需
|
|
@@ -80,9 +80,9 @@ L 层判断单 schema(<l-out-dir> 四个文件,这段就是填写说明书
|
|
|
80
80
|
|
|
81
81
|
colors:
|
|
82
82
|
surface: "#FFFFFF"
|
|
83
|
-
primary: "#
|
|
83
|
+
primary: "#RRGGBB"
|
|
84
84
|
safe-area:
|
|
85
|
-
content: {top:
|
|
85
|
+
content: {top: <px>, right: <px>, bottom: <px>, left: <px>, applies-to: [content]}
|
|
86
86
|
confidence: medium
|
|
87
87
|
|
|
88
88
|
--------------------------------------------------------------------------------
|
|
@@ -98,7 +98,8 @@ L 层判断单 schema(<l-out-dir> 四个文件,这段就是填写说明书
|
|
|
98
98
|
role: cover
|
|
99
99
|
background: bg-cover
|
|
100
100
|
slots:
|
|
101
|
-
- {role: title, box: [
|
|
101
|
+
- {role: title, box: [<x>, <y>, <w>, <h>], type: title,
|
|
102
|
+
css: "<由源模板转译出的 CSS 声明串>"}
|
|
102
103
|
confidence: high
|
|
103
104
|
|
|
104
105
|
可选 `body:` 块标量 —— 追加到 layouts.md frontmatter 之后作为说明正文。
|
|
@@ -139,9 +140,11 @@ ASSET_CONSUMER_FIELDS = ['path', 'url', 'color', 'full', 'kind', 'role',
|
|
|
139
140
|
ASSET_AUDIT_FIELDS = ['boxes', 'aspect', 'mark', 'confidence']
|
|
140
141
|
KIND_PREFIX = {'background': 'bg', 'logo': 'logo', 'slogan': 'slogan',
|
|
141
142
|
'texture': 'texture', 'icon': 'icon'}
|
|
142
|
-
#
|
|
143
|
-
|
|
144
|
-
|
|
143
|
+
# 交付包的 ref/ 只留 audit.yaml(人复核数值出处用,几 KB)。
|
|
144
|
+
# 频次原表、聚类原始数据、extract.json、重建图、logo 候选图全部留在 stage1 抽取目录,
|
|
145
|
+
# 不拷进包——规范原本指望「下发时链路剥离」,但链路上没有环节真的剥离,结果
|
|
146
|
+
# 审计材料带着「别读我」一起进消费上下文,还占掉包体的大头。
|
|
147
|
+
REF_CARRY = ()
|
|
145
148
|
|
|
146
149
|
|
|
147
150
|
class Fail(SystemExit):
|
|
@@ -272,6 +275,10 @@ def truthy(v):
|
|
|
272
275
|
return str(v).strip().lower() in ('1', 'true', 'yes', 'on')
|
|
273
276
|
|
|
274
277
|
|
|
278
|
+
# 浏览器能解码的图片格式。落进包的资产必须在此列,否则消费端引用到就是一张空白图。
|
|
279
|
+
WEB_SAFE_EXT = {'png', 'jpg', 'jpeg', 'webp', 'gif', 'svg', 'avif'}
|
|
280
|
+
|
|
281
|
+
|
|
275
282
|
def asset_ext(name):
|
|
276
283
|
return name.rsplit('.', 1)[-1].lower() if '.' in name else ''
|
|
277
284
|
|
|
@@ -351,12 +358,25 @@ def place_assets(manifest, extract, stage1, pack):
|
|
|
351
358
|
entry['path'] = 'assets/%ss/%s.%s' % (kind, base, cext)
|
|
352
359
|
if truthy(a.get('use_full')):
|
|
353
360
|
oext = asset_ext(row['out'])
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
361
|
+
if oext.lower() in WEB_SAFE_EXT:
|
|
362
|
+
fdst = os.path.join(sub, '%s@full.%s' % (base, oext))
|
|
363
|
+
shutil.copy2(orig_path, fdst)
|
|
364
|
+
copied.append(fdst)
|
|
365
|
+
entry['full'] = 'assets/%ss/%s@full.%s' % (kind, base, oext)
|
|
366
|
+
else:
|
|
367
|
+
# 原图是浏览器不解码的格式(tiff/bmp 之类)。落进包并在 design.md
|
|
368
|
+
# 里声明成可用资源,消费端引用它就是一张空白图——实测踩过一次,
|
|
369
|
+
# 封面与结束页因此空白。压缩版已经带着全部像素,full 不给。
|
|
370
|
+
print(' ⚠ %s 的原图是 .%s,浏览器不解码,只给压缩版' % (aid, oext))
|
|
358
371
|
else:
|
|
359
372
|
oext = asset_ext(row['out'])
|
|
373
|
+
if oext.lower() not in WEB_SAFE_EXT:
|
|
374
|
+
# 转码两条路(Pillow / sips)都没成,原图又是浏览器不解码的格式。
|
|
375
|
+
# 照落进去就是把一张永远显示不出来的图当资产下发——实测封面因此空白。
|
|
376
|
+
raise Fail('%s: 原图是 .%s,浏览器不解码,而转码没有产物'
|
|
377
|
+
'(extract.json 里看 transcode_blocked 的原因)。'
|
|
378
|
+
'装上 Pillow 重跑抽取,或把这条资产从 manifest 删掉'
|
|
379
|
+
'并在 gaps 写明。' % (aid, oext))
|
|
360
380
|
dst = os.path.join(sub, '%s.%s' % (base, oext))
|
|
361
381
|
shutil.copy2(orig_path, dst)
|
|
362
382
|
copied.append(dst)
|
|
@@ -382,7 +402,7 @@ def place_assets(manifest, extract, stage1, pack):
|
|
|
382
402
|
if boxes:
|
|
383
403
|
au['boxes'] = boxes
|
|
384
404
|
# aspect 取**未取整**的 box —— 从取整后的整数反算会明显偏
|
|
385
|
-
#
|
|
405
|
+
# 先取整再相除,误差会落到小数点后两位,logo 这种细长框尤其明显。
|
|
386
406
|
raw = clusters[0]['box']
|
|
387
407
|
if raw.get('h'):
|
|
388
408
|
au['aspect'] = round(raw['w'] / float(raw['h']), 3)
|
|
@@ -406,6 +426,27 @@ def _pages_of(extract, source_media):
|
|
|
406
426
|
return sorted(pages)
|
|
407
427
|
|
|
408
428
|
|
|
429
|
+
def _archetypes_using(layouts_text, aid, key='asset'):
|
|
430
|
+
"""layouts.yaml 里哪些 archetype 引用了这个资产。
|
|
431
|
+
|
|
432
|
+
key='asset' 查 slots 里的图片槽;key='background' 查页型底图。
|
|
433
|
+
"""
|
|
434
|
+
out, cur, sect = [], None, None
|
|
435
|
+
for line in (layouts_text or '').split('\n'):
|
|
436
|
+
if re.match(r'^\w[\w-]*:\s*$', line):
|
|
437
|
+
sect = line.split(':')[0]
|
|
438
|
+
continue
|
|
439
|
+
if sect != 'layouts':
|
|
440
|
+
continue
|
|
441
|
+
m = re.match(r'^ ([\w-]+):\s*$', line)
|
|
442
|
+
if m:
|
|
443
|
+
cur = m.group(1)
|
|
444
|
+
continue
|
|
445
|
+
if cur and re.search(r'%s:\s*%s\b' % (key, re.escape(aid)), line) and cur not in out:
|
|
446
|
+
out.append(cur)
|
|
447
|
+
return out
|
|
448
|
+
|
|
449
|
+
|
|
409
450
|
def expand_placeholders(body, manifest, consumer, audit, extract, layouts_text):
|
|
410
451
|
"""body.md 里的 `{{ASSET_TABLE}}` / `{{LAYOUT_LIST}}` 由本脚本按落盘真值渲染——
|
|
411
452
|
路径与页型清单是打包期才确定的事实,不该由 L 层手抄(抄错就是死链)。"""
|
|
@@ -415,18 +456,19 @@ def expand_placeholders(body, manifest, consumer, audit, extract, layouts_text):
|
|
|
415
456
|
for aid, e in consumer.items():
|
|
416
457
|
pages = _pages_of(extract, src_of.get(aid))
|
|
417
458
|
box = (audit.get(aid) or {}).get('boxes') or []
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
when = '固定位 (%d, %d),尺寸 %dx%d px' % tuple(b)
|
|
425
|
-
when += (',全 %d 页里只出现在第 %s 页' % (extract['counts']['slides'],
|
|
426
|
-
'、'.join(map(str, pages)))
|
|
427
|
-
if pages and len(pages) <= 4 else ',每页固定放一次')
|
|
459
|
+
# 单元格保持短句:哪个页型用哪张由 `background` 字段决定,
|
|
460
|
+
# 那句说明放在表格前一次即可,逐行重复只是把同一句抄 N 遍。
|
|
461
|
+
if e['kind'] == 'background':
|
|
462
|
+
users = _archetypes_using(layouts_text, aid, key='background')
|
|
463
|
+
when = ('%s 用它' % '/'.join('`%s`' % o for o in users[:6])
|
|
464
|
+
if users else '未被任何页型引用')
|
|
428
465
|
else:
|
|
429
|
-
|
|
466
|
+
# 位置逐页型不同(同一 logo 常在封面左上、内容页右上,尺寸也不同),
|
|
467
|
+
# 所以这里只给归属,坐标一律交给 layouts.md 的 slots。
|
|
468
|
+
owners = _archetypes_using(layouts_text, aid)
|
|
469
|
+
when = ('%s 这 %d 个页型带它' % ('/'.join('`%s`' % o for o in owners[:6]),
|
|
470
|
+
len(owners))
|
|
471
|
+
if owners else '⚠ 没有页型声明它的位置,本包不使用它')
|
|
430
472
|
f = '`%s`' % e['path'] if e.get('path') else (
|
|
431
473
|
'`%s`' % e['url'] if e.get('url') else '纯色 `%s`' % e.get('color'))
|
|
432
474
|
if e.get('full'):
|
|
@@ -466,7 +508,7 @@ def render_assets_block(consumer):
|
|
|
466
508
|
|
|
467
509
|
# ------------------------------------------------- 数值可追溯机检(抄错即 FAIL)
|
|
468
510
|
HEX_RE = re.compile(r'#([0-9A-Fa-f]{6})\b')
|
|
469
|
-
FONTSIZE_RE = re.compile(r'\
|
|
511
|
+
FONTSIZE_RE = re.compile(r'\b(?:fontSize|font-size):\s*([\d.]+)px')
|
|
470
512
|
BOX_RE = re.compile(r'\bbox:\s*\[\s*(-?[\d.]+)\s*,\s*(-?[\d.]+)\s*,'
|
|
471
513
|
r'\s*(-?[\d.]+)\s*,\s*(-?[\d.]+)\s*\]')
|
|
472
514
|
KEYLINE_RE = re.compile(r'^(\s*)-?\s*([A-Za-z_][\w-]*):\s*(.*)$')
|
|
@@ -604,6 +646,47 @@ def _box_hit(box, idx):
|
|
|
604
646
|
% (best[0], best[1], best[2], best[3], best[4], bestd))
|
|
605
647
|
|
|
606
648
|
|
|
649
|
+
# 判断产物:L 层看着背景图划出来的区域,本就不该命中普查值——整键豁免,
|
|
650
|
+
# 不要求写 derived。逼它们走 derived 只会把整段豁免掉,机检反而更弱。
|
|
651
|
+
JUDGEMENT_KEYS = frozenset(('avoid', 'text_safe', 'pairing_rule'))
|
|
652
|
+
|
|
653
|
+
|
|
654
|
+
def media_integrity(stage1, extract):
|
|
655
|
+
"""extract.json 记录的尺寸,必须和磁盘上那个文件真实的尺寸一致。
|
|
656
|
+
|
|
657
|
+
这条挡的是「记录全对、文件被顶替」——两个 media 的输出名撞车时,后写的覆盖先写的,
|
|
658
|
+
extract.json 里各自的记录都还是对的,任何只读记录的检查都发现不了;只有把记录和
|
|
659
|
+
文件本身对一遍才抓得到。实测某模板因此把一张 109x109 的图当成了整页背景。
|
|
660
|
+
"""
|
|
661
|
+
try:
|
|
662
|
+
from PIL import Image
|
|
663
|
+
except Exception:
|
|
664
|
+
return [] # 没有 Pillow 就量不了,跳过而不是假装通过
|
|
665
|
+
bad, seen = [], {}
|
|
666
|
+
for m in extract.get('media') or []:
|
|
667
|
+
for key, rel in (('source_px', m.get('out')),
|
|
668
|
+
('compressed_px', m.get('compressed_out'))):
|
|
669
|
+
rec = m.get(key)
|
|
670
|
+
if not rel or not rec:
|
|
671
|
+
continue
|
|
672
|
+
path = os.path.join(stage1, rel)
|
|
673
|
+
if not os.path.exists(path):
|
|
674
|
+
bad.append('%s 的 %s 指向 %s,文件不存在' % (m['media'], key, rel))
|
|
675
|
+
continue
|
|
676
|
+
try:
|
|
677
|
+
with Image.open(path) as im:
|
|
678
|
+
real = list(im.size)
|
|
679
|
+
except Exception:
|
|
680
|
+
continue
|
|
681
|
+
if real != list(rec):
|
|
682
|
+
bad.append('%s 的 %s 记录 %s,但 %s 实际是 %s'
|
|
683
|
+
% (m['media'], key, rec, rel, real))
|
|
684
|
+
if rel in seen and seen[rel] != m['media']:
|
|
685
|
+
bad.append('%s 与 %s 都写到 %s' % (seen[rel], m['media'], rel))
|
|
686
|
+
seen[rel] = m['media']
|
|
687
|
+
return bad
|
|
688
|
+
|
|
689
|
+
|
|
607
690
|
def trace_check(pack, extract, shapes, derived_values, derived_tokens, factor):
|
|
608
691
|
"""产物里每个 hex / 字号 / slot 坐标都必须可追溯到普查值或 derived 声明。"""
|
|
609
692
|
idx = build_trace_index(extract, shapes)
|
|
@@ -614,6 +697,9 @@ def trace_check(pack, extract, shapes, derived_values, derived_tokens, factor):
|
|
|
614
697
|
if not text:
|
|
615
698
|
continue
|
|
616
699
|
for lineno, path, raw in _scan_keyed(text):
|
|
700
|
+
if JUDGEMENT_KEYS & set(path):
|
|
701
|
+
checked['judgement'] += 1
|
|
702
|
+
continue
|
|
617
703
|
exempt_token = any(k in derived_tokens for k in path)
|
|
618
704
|
for m in HEX_RE.finditer(raw):
|
|
619
705
|
val = '#' + m.group(1).upper()
|
|
@@ -762,106 +848,6 @@ def build_package_manifest(manifest, consumer, audit, extract, pack):
|
|
|
762
848
|
return {k: v for k, v in pkg.items() if v is not None}
|
|
763
849
|
|
|
764
850
|
|
|
765
|
-
def layout_fast_index(layouts_blocks, max_slots=4):
|
|
766
|
-
if not layouts_blocks:
|
|
767
|
-
return []
|
|
768
|
-
blocks = {k: (inline, lines) for k, inline, lines in layouts_blocks}
|
|
769
|
-
if 'layouts' not in blocks:
|
|
770
|
-
return []
|
|
771
|
-
items = []
|
|
772
|
-
cur = None
|
|
773
|
-
for line in blocks['layouts'][1]:
|
|
774
|
-
m = re.match(r'^ ([\w-]+):\s*$', line)
|
|
775
|
-
if m:
|
|
776
|
-
cur = {'id': m.group(1), 'name': '', 'role': '', 'background': '', 'slots': []}
|
|
777
|
-
items.append(cur)
|
|
778
|
-
continue
|
|
779
|
-
if not cur:
|
|
780
|
-
continue
|
|
781
|
-
m = re.match(r'^ (name|role|background):\s*(.+?)\s*$', line)
|
|
782
|
-
if m:
|
|
783
|
-
cur[m.group(1)] = unquote(m.group(2))
|
|
784
|
-
continue
|
|
785
|
-
m = re.match(r'^\s{6}-\s*\{(.+)\}\s*$', line)
|
|
786
|
-
if m and len(cur['slots']) < max_slots:
|
|
787
|
-
raw = m.group(1)
|
|
788
|
-
role = re.search(r'role:\s*([^,}]+)', raw)
|
|
789
|
-
box = re.search(r'box:\s*\[([^\]]+)\]', raw)
|
|
790
|
-
typ = re.search(r'type:\s*([^,}]+)', raw)
|
|
791
|
-
if role and box:
|
|
792
|
-
label = unquote(role.group(1).strip())
|
|
793
|
-
if typ:
|
|
794
|
-
label += '/' + unquote(typ.group(1).strip())
|
|
795
|
-
cur['slots'].append('%s [%s]' % (label, box.group(1).strip()))
|
|
796
|
-
out = []
|
|
797
|
-
for item in items:
|
|
798
|
-
parts = ['`%s`' % item['id']]
|
|
799
|
-
if item.get('name'):
|
|
800
|
-
parts.append(item['name'])
|
|
801
|
-
if item.get('role'):
|
|
802
|
-
parts.append(item['role'])
|
|
803
|
-
if item.get('background'):
|
|
804
|
-
parts.append('背景 `%s`' % item['background'])
|
|
805
|
-
slots = ';'.join(item['slots'])
|
|
806
|
-
out.append('%s:%s' % (' / '.join(parts), slots or '按最接近用途套用'))
|
|
807
|
-
return out
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
def render_fast_path(manifest, consumer, has_sidecar, canvas, layouts_index=None):
|
|
811
|
-
"""Render the small consumer-first block that keeps runtime agents out of ref/."""
|
|
812
|
-
cover = next((aid for aid, a in consumer.items()
|
|
813
|
-
if a.get('kind') == 'background' and a.get('role') == 'cover'), None)
|
|
814
|
-
content_bgs = [aid for aid, a in consumer.items()
|
|
815
|
-
if a.get('kind') == 'background' and a.get('role') == 'content']
|
|
816
|
-
logos = [aid for aid, a in consumer.items() if a.get('kind') in ('logo', 'slogan')]
|
|
817
|
-
assets = []
|
|
818
|
-
for aid, a in consumer.items():
|
|
819
|
-
path = a.get('path') or a.get('color') or a.get('url')
|
|
820
|
-
role = a.get('role') or a.get('kind')
|
|
821
|
-
if path:
|
|
822
|
-
assets.append('`%s` -> `%s` (%s)' % (aid, path, role))
|
|
823
|
-
if len(assets) > 8:
|
|
824
|
-
assets = assets[:8] + ['其余资产见 frontmatter `assets`,不要去 `ref/` 里临时挑图。']
|
|
825
|
-
|
|
826
|
-
lines = [
|
|
827
|
-
'## Agent Fast Path',
|
|
828
|
-
'',
|
|
829
|
-
'消费本风格时先读这一节;它是给生成 Agent 的短路径,目标是把风格理解控制在 1 分钟内,避免把审计材料重新理解一遍。',
|
|
830
|
-
'',
|
|
831
|
-
'- **时间预算**:风格导入最多做 1 次 `read_file design.md`。本节已经内联常用坐标,读完后必须直接开始生成,不要再探索风格包。',
|
|
832
|
-
'- **只读入口**:常规生成只需要 `design.md`。只有本节的版式索引无法覆盖目标页时,才打开 %s。'
|
|
833
|
-
% ('`layouts.md`' if has_sidecar else '`design.md` 里的 `layouts`'),
|
|
834
|
-
'- **附件/zip 兜底**:如果当前内容来自 zip 附件的文本摘要,直接使用摘要中 `design.md` / `layouts.md` 的文本;不要尝试修复 zip、解析二进制、搜索附件目录或重建压缩包。',
|
|
835
|
-
'- **禁止动作**:不要读取 `ref/color-freq-raw.json`、`ref/font-clusters.json`、`ref/extract.json`、`ref/rebuild/`、`ref/rebuild/png/*`;不要 summarize / view 参考页;不要重新统计颜色、字体或版式。',
|
|
836
|
-
'- **信息来源优先级**:本节 > `## Usage` > frontmatter `assets` / `colors` / `typography` > `layouts.md`。除此之外的文件只用于人工审计,不用于生成。',
|
|
837
|
-
'- **缺信息时降级**:如果某个细节本节没有写,用 frontmatter token 和最接近的 `layouts.md` archetype 推断;不要打开审计文件补证。',
|
|
838
|
-
]
|
|
839
|
-
if canvas:
|
|
840
|
-
lines.append('- **画布**:所有坐标按 `%dx%d` 绝对像素理解。' % tuple(canvas))
|
|
841
|
-
if cover:
|
|
842
|
-
lines.append('- **封面背景**:优先使用 `%s`;整幅铺满画布,禁止自造渐变替代。' % cover)
|
|
843
|
-
if content_bgs:
|
|
844
|
-
lines.append('- **内容页背景**:按 `layouts.md` 中 archetype 的 `background` 字段取;常用内容背景为 %s。'
|
|
845
|
-
% '、'.join('`%s`' % x for x in content_bgs[:4]))
|
|
846
|
-
if cover or content_bgs:
|
|
847
|
-
lines.append('- **背景安全区**:背景图和版式必须配对。按 archetype 的 `background`、`text_safe`、`avoid` 一起放文字和卡片;标题、正文、关键数字、图表、卡片、时间线及其容器的外接矩形都不得压到背景视觉主体、强光斑、深色透明区上,透明容器也不能跨进禁放区。')
|
|
848
|
-
if logos:
|
|
849
|
-
lines.append('- **标识资产**:只使用 %s;不得重画、不得改比例。'
|
|
850
|
-
% '、'.join('`%s`' % x for x in logos))
|
|
851
|
-
lines += [
|
|
852
|
-
'- **配色与字体**:颜色只取 frontmatter `colors`;字体/字号只取 frontmatter `typography`;内容主题不得引入新色相。',
|
|
853
|
-
'- **版式**:优先使用下面内联版式索引;需要更多 slot 时才读 `layouts.md`;不要用 `ref/rebuild/png` 反推坐标。',
|
|
854
|
-
]
|
|
855
|
-
if layouts_index:
|
|
856
|
-
lines += ['', '内联版式索引(先用这里,不要为了选页型再读文件):']
|
|
857
|
-
lines += ['- ' + x for x in layouts_index]
|
|
858
|
-
if assets:
|
|
859
|
-
lines += ['', '关键资产:']
|
|
860
|
-
lines += ['- ' + a for a in assets]
|
|
861
|
-
lines.append('')
|
|
862
|
-
return '\n'.join(lines) + '\n'
|
|
863
|
-
|
|
864
|
-
|
|
865
851
|
def strip_agent_fast_path(body):
|
|
866
852
|
if '## Agent Fast Path' not in body:
|
|
867
853
|
return body
|
|
@@ -869,8 +855,7 @@ def strip_agent_fast_path(body):
|
|
|
869
855
|
count=1, flags=re.S).lstrip('\n')
|
|
870
856
|
|
|
871
857
|
|
|
872
|
-
def build_design(manifest, l_frontmatter, consumer, body, has_sidecar, canvas
|
|
873
|
-
layouts_index=None):
|
|
858
|
+
def build_design(manifest, l_frontmatter, consumer, body, has_sidecar, canvas):
|
|
874
859
|
blocks = {k: (inline, lines) for k, inline, lines in l_frontmatter}
|
|
875
860
|
bad = set(blocks) - L_FRONTMATTER_KEYS
|
|
876
861
|
if bad:
|
|
@@ -908,9 +893,9 @@ def build_design(manifest, l_frontmatter, consumer, body, has_sidecar, canvas,
|
|
|
908
893
|
out.append('canvas: %dx%d' % tuple(canvas))
|
|
909
894
|
out.append('---')
|
|
910
895
|
text = '\n'.join(out) + '\n'
|
|
896
|
+
# Fast Path 已废弃:它是 Usage / Hard Rules / 资产表 / 页型清单的第二份副本。
|
|
897
|
+
# 规则的唯一出处是正文各段,这里只负责把历史产物里的残留剥掉。
|
|
911
898
|
body = strip_agent_fast_path(body)
|
|
912
|
-
text += '\n' + render_fast_path(manifest, consumer, has_sidecar, canvas,
|
|
913
|
-
layouts_index=layouts_index)
|
|
914
899
|
if body:
|
|
915
900
|
text += body if body.startswith('\n') else '\n' + body
|
|
916
901
|
if not text.endswith('\n'):
|
|
@@ -918,26 +903,258 @@ def build_design(manifest, l_frontmatter, consumer, body, has_sidecar, canvas,
|
|
|
918
903
|
return text
|
|
919
904
|
|
|
920
905
|
|
|
906
|
+
def layout_forms(lines):
|
|
907
|
+
"""每个页型草案里实际给了哪几种形态(flow / slots)。"""
|
|
908
|
+
out, cur = {}, None
|
|
909
|
+
for line in lines:
|
|
910
|
+
m = re.match(r'^ ([\w-]+):\s*$', line)
|
|
911
|
+
if m:
|
|
912
|
+
cur = m.group(1)
|
|
913
|
+
out[cur] = set()
|
|
914
|
+
continue
|
|
915
|
+
m = re.match(r'^ (flow|slots):\s*$', line)
|
|
916
|
+
if m and cur:
|
|
917
|
+
out[cur].add(m.group(1))
|
|
918
|
+
return out
|
|
919
|
+
|
|
920
|
+
|
|
921
|
+
def layout_modes(lines):
|
|
922
|
+
"""读取扁平 `layout_modes:` 判断区。"""
|
|
923
|
+
out = {}
|
|
924
|
+
for line in lines:
|
|
925
|
+
m = re.match(r'^\s{2}([\w-]+):\s*([^\s#]+)', line)
|
|
926
|
+
if m:
|
|
927
|
+
out[m.group(1)] = m.group(2).strip()
|
|
928
|
+
return out
|
|
929
|
+
|
|
930
|
+
|
|
931
|
+
def text_role_boxes(lines):
|
|
932
|
+
"""从 slots 里的同名标记取回文本槽坐标,供 flow 固定锚点复用。"""
|
|
933
|
+
out, pending = {}, None
|
|
934
|
+
for line in lines:
|
|
935
|
+
marker = re.match(r'^\s*#\s*text-role:\s*([\w-]+)\s*$', line)
|
|
936
|
+
if marker:
|
|
937
|
+
pending = marker.group(1)
|
|
938
|
+
continue
|
|
939
|
+
if pending:
|
|
940
|
+
box = re.search(r'\bbox:\s*(\[[^\]]+\])', line)
|
|
941
|
+
if box:
|
|
942
|
+
out[pending] = box.group(1)
|
|
943
|
+
pending = None
|
|
944
|
+
return out
|
|
945
|
+
|
|
946
|
+
|
|
947
|
+
def select_layout_forms(lines, modes):
|
|
948
|
+
"""按 `layout_modes` 只保留每个页型选中的 flow 或 slots。"""
|
|
949
|
+
out, layout, drop = [], None, False
|
|
950
|
+
for line in lines:
|
|
951
|
+
layout_match = re.match(r'^ ([\w-]+):\s*$', line)
|
|
952
|
+
form_match = re.match(r'^ (flow|slots):\s*$', line)
|
|
953
|
+
if layout_match:
|
|
954
|
+
layout, drop = layout_match.group(1), False
|
|
955
|
+
elif form_match:
|
|
956
|
+
drop = modes.get(layout) not in (None, form_match.group(1))
|
|
957
|
+
elif drop and re.match(r'^ \S', line):
|
|
958
|
+
drop = False
|
|
959
|
+
if not drop:
|
|
960
|
+
out.append(line)
|
|
961
|
+
return out
|
|
962
|
+
|
|
963
|
+
|
|
964
|
+
def shrink_safe_area(lines):
|
|
965
|
+
"""text_safe 与 avoid 相交时把安全区收掉重叠的那部分。
|
|
966
|
+
|
|
967
|
+
text_safe 是脚本按「该背景各页型的槽位并集」算的,而模板里的槽位本身可能就压在
|
|
968
|
+
主视觉上;avoid 是看图的人填的。两者从不同来源来,会直接打架——实测一张背景的
|
|
969
|
+
text_safe 有 34% 落在 avoid 里,消费端按 text_safe 把标题放进了禁放区,正好压在
|
|
970
|
+
背景的山峰主体上。这里以 avoid 为准收缩:能不能放字是看图的人说了算。
|
|
971
|
+
"""
|
|
972
|
+
def parse_box(s):
|
|
973
|
+
m = re.findall(r'-?\d+', s)
|
|
974
|
+
return [int(x) for x in m[:4]] if len(m) >= 4 else None
|
|
975
|
+
|
|
976
|
+
ts_i = ts = None
|
|
977
|
+
avoids = []
|
|
978
|
+
for i, ln in enumerate(lines):
|
|
979
|
+
st = ln.strip()
|
|
980
|
+
if st.startswith('text_safe:'):
|
|
981
|
+
ts_i, ts = i, parse_box(st.split(':', 1)[1].split('#')[0])
|
|
982
|
+
elif st.startswith('avoid:'):
|
|
983
|
+
for chunk in re.findall(r'box:\s*\[[^\]]*\]', st):
|
|
984
|
+
b = parse_box(chunk)
|
|
985
|
+
if b:
|
|
986
|
+
avoids.append(b)
|
|
987
|
+
if ts is None or not avoids:
|
|
988
|
+
return lines, None
|
|
989
|
+
x0, y0, x1, y1 = ts[0], ts[1], ts[0] + ts[2], ts[1] + ts[3]
|
|
990
|
+
for a in avoids:
|
|
991
|
+
ax0, ay0, ax1, ay1 = a[0], a[1], a[0] + a[2], a[1] + a[3]
|
|
992
|
+
if ax1 <= x0 or ax0 >= x1 or ay1 <= y0 or ay0 >= y1:
|
|
993
|
+
continue # 不相交
|
|
994
|
+
# 从被侵占得最少的一边切:优先保留面积最大的剩余矩形
|
|
995
|
+
cands = []
|
|
996
|
+
if ax0 > x0:
|
|
997
|
+
cands.append((x0, y0, ax0, y1))
|
|
998
|
+
if ax1 < x1:
|
|
999
|
+
cands.append((ax1, y0, x1, y1))
|
|
1000
|
+
if ay0 > y0:
|
|
1001
|
+
cands.append((x0, y0, x1, ay0))
|
|
1002
|
+
if ay1 < y1:
|
|
1003
|
+
cands.append((x0, ay1, x1, y1))
|
|
1004
|
+
if not cands:
|
|
1005
|
+
return lines, 'text_safe 被 avoid 完全覆盖,这张背景没有可放文字的区域'
|
|
1006
|
+
x0, y0, x1, y1 = max(cands, key=lambda c: (c[2] - c[0]) * (c[3] - c[1]))
|
|
1007
|
+
new = [x0, y0, x1 - x0, y1 - y0]
|
|
1008
|
+
if new == ts:
|
|
1009
|
+
return lines, None
|
|
1010
|
+
lines = list(lines)
|
|
1011
|
+
lines[ts_i] = ' text_safe: [%d, %d, %d, %d] # 已按 avoid 收缩(原 %s)' % (
|
|
1012
|
+
new[0], new[1], new[2], new[3], ts)
|
|
1013
|
+
return lines, None
|
|
1014
|
+
|
|
1015
|
+
|
|
921
1016
|
def build_layouts_md(layouts_blocks, canvas):
|
|
922
1017
|
blocks = {k: (inline, lines) for k, inline, lines in layouts_blocks}
|
|
923
1018
|
if 'canvas' in blocks:
|
|
924
1019
|
raise Fail('layouts.yaml 不要写 canvas —— 脚本从 extract.json 取')
|
|
925
1020
|
if 'layouts' not in blocks:
|
|
926
1021
|
raise Fail('layouts.yaml 缺顶层键 `layouts:`')
|
|
927
|
-
# `names:` 是给 L
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
1022
|
+
# `names:` / `roles:` / `text_roles:` / `layout_modes:` / `bg_rules:` 是给 L 层集中填判断的
|
|
1023
|
+
# 扁平区——在这里并回各 archetype,本身不进产物。让 L 层只改扁平键值,别去动 layouts 里的
|
|
1024
|
+
# slots/confidence 结构(嵌套结构手改极易破坏缩进,进而静默改变语义)。
|
|
1025
|
+
names, roles = {}, {}
|
|
1026
|
+
for key, sink in (('names', names), ('roles', roles)):
|
|
1027
|
+
for line in blocks.get(key, ('', []))[1]:
|
|
1028
|
+
m = re.match(r'^\s{2}([\w-]+):\s*(.+?)\s*$', line)
|
|
1029
|
+
if m:
|
|
1030
|
+
sink[m.group(1)] = unquote(m.group(2))
|
|
1031
|
+
text_roles = {}
|
|
1032
|
+
allowed_text_roles = {'title', 'subtitle', 'header', 'footer', 'body'}
|
|
1033
|
+
for line in blocks.get('text_roles', ('', []))[1]:
|
|
1034
|
+
m = re.match(r'^\s{2}([\w-]+):\s*([A-Za-z-]+)(?:\s+#.*)?$', line)
|
|
1035
|
+
if not m:
|
|
1036
|
+
continue
|
|
1037
|
+
role_id, role = m.groups()
|
|
1038
|
+
if role not in allowed_text_roles:
|
|
1039
|
+
raise Fail('text_roles.%s 取值 %s 非法;应为 %s'
|
|
1040
|
+
% (role_id, role, '|'.join(sorted(allowed_text_roles))))
|
|
1041
|
+
text_roles[role_id] = role
|
|
1042
|
+
bg_rules, cur = {}, None
|
|
1043
|
+
for line in blocks.get('bg_rules', ('', []))[1]:
|
|
1044
|
+
# 键后面允许行内注释(草案会标「用它的页型:…」)
|
|
1045
|
+
m = re.match(r'^\s{2}([\w-]+):\s*(?:#.*)?$', line)
|
|
931
1046
|
if m:
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
1047
|
+
cur = m.group(1)
|
|
1048
|
+
bg_rules[cur] = []
|
|
1049
|
+
continue
|
|
1050
|
+
if cur and line.strip():
|
|
1051
|
+
bg_rules[cur].append(' ' + line.strip())
|
|
1052
|
+
out = ['---', 'canvas: %dx%d' % tuple(canvas)]
|
|
1053
|
+
# 禁放区是背景的属性,按背景写一次;页型只留 `background:` 指针。
|
|
1054
|
+
# 合并进每个页型会把同一句话按页型数复制 N 遍。
|
|
1055
|
+
if bg_rules:
|
|
1056
|
+
out.append('backgrounds:')
|
|
1057
|
+
for bg, lines in bg_rules.items():
|
|
1058
|
+
lines, err = shrink_safe_area(lines)
|
|
1059
|
+
if err:
|
|
1060
|
+
raise Fail('%s: %s' % (bg, err))
|
|
1061
|
+
out.append(' %s:' % bg)
|
|
1062
|
+
out += lines
|
|
1063
|
+
modes = layout_modes(blocks.get('layout_modes', ('', []))[1])
|
|
1064
|
+
out.append('layouts:')
|
|
1065
|
+
pending_text_role = None
|
|
1066
|
+
used_text_roles = set()
|
|
1067
|
+
source_layout_lines = blocks['layouts'][1]
|
|
1068
|
+
role_boxes = text_role_boxes(source_layout_lines)
|
|
1069
|
+
layout_lines = select_layout_forms(source_layout_lines, modes)
|
|
1070
|
+
cur, fixed_items = None, []
|
|
1071
|
+
|
|
1072
|
+
def flush_fixed_items():
|
|
1073
|
+
if not fixed_items:
|
|
1074
|
+
return
|
|
1075
|
+
out.append(' - kind: free')
|
|
1076
|
+
out.append(' items:')
|
|
1077
|
+
out.extend(fixed_items)
|
|
1078
|
+
fixed_items.clear()
|
|
1079
|
+
|
|
1080
|
+
for line in layout_lines:
|
|
936
1081
|
m = re.match(r'^ ([\w-]+):\s*$', line)
|
|
1082
|
+
if m:
|
|
1083
|
+
flush_fixed_items()
|
|
1084
|
+
cur = m.group(1)
|
|
1085
|
+
elif fixed_items and re.match(r'^ \S', line):
|
|
1086
|
+
flush_fixed_items()
|
|
1087
|
+
# 判断单里的结构事实(栅格、间距序列、样张字数、命中配方)是给 L 层判断用的,
|
|
1088
|
+
# 不进产物——消费端要的是结论,不是推导过程。layout_mode 同理,它是判断的载体。
|
|
1089
|
+
if line.lstrip().startswith('#'):
|
|
1090
|
+
marker = re.match(r'^\s*#\s*text-role:\s*([\w-]+)\s*$', line)
|
|
1091
|
+
if marker:
|
|
1092
|
+
pending_text_role = marker.group(1)
|
|
1093
|
+
continue
|
|
1094
|
+
if pending_text_role:
|
|
1095
|
+
if pending_text_role not in text_roles:
|
|
1096
|
+
raise Fail('text_roles 缺少 %s 的判断' % pending_text_role)
|
|
1097
|
+
role = text_roles[pending_text_role]
|
|
1098
|
+
slot_type = role if role in ('title', 'subtitle', 'header', 'footer') else 'body'
|
|
1099
|
+
line, role_n = re.subn(r'(\{\s*role:\s*)[\w-]+',
|
|
1100
|
+
r'\g<1>%s' % role, line, count=1)
|
|
1101
|
+
line, type_n = re.subn(r'(\btype:\s*)[\w-]+',
|
|
1102
|
+
r'\g<1>%s' % slot_type, line, count=1)
|
|
1103
|
+
if role_n != 1 or type_n != 1:
|
|
1104
|
+
raise Fail('text_roles.%s 没有命中一个文本槽' % pending_text_role)
|
|
1105
|
+
if (modes.get(cur) == 'flow' and role in ('header', 'footer')
|
|
1106
|
+
and re.match(r'^\s{12}-\s*\{', line) and 'box:' not in line):
|
|
1107
|
+
box = role_boxes.get(pending_text_role)
|
|
1108
|
+
if not box:
|
|
1109
|
+
raise Fail('text_roles.%s 识别为 %s,但 slots 中没有坐标'
|
|
1110
|
+
% (pending_text_role, role))
|
|
1111
|
+
line = re.sub(r',\s*type:', ', box: %s, type:' % box, line, count=1)
|
|
1112
|
+
fixed_items.append(line)
|
|
1113
|
+
used_text_roles.add(pending_text_role)
|
|
1114
|
+
pending_text_role = None
|
|
1115
|
+
continue
|
|
1116
|
+
used_text_roles.add(pending_text_role)
|
|
1117
|
+
pending_text_role = None
|
|
1118
|
+
out.append(line)
|
|
937
1119
|
if m and m.group(1) in names:
|
|
938
1120
|
out.append(' name: "%s"' % names.pop(m.group(1)))
|
|
1121
|
+
if m and m.group(1) in roles:
|
|
1122
|
+
out.append(' role: %s' % roles.pop(m.group(1)))
|
|
1123
|
+
flush_fixed_items()
|
|
939
1124
|
if names:
|
|
940
1125
|
raise Fail('names 里这些页型在 layouts 下找不到:%s' % ', '.join(sorted(names)))
|
|
1126
|
+
if roles:
|
|
1127
|
+
raise Fail('roles 里这些页型在 layouts 下找不到:%s' % ', '.join(sorted(roles)))
|
|
1128
|
+
unused_text_roles = set(text_roles) - used_text_roles
|
|
1129
|
+
if unused_text_roles:
|
|
1130
|
+
raise Fail('text_roles 里这些判断没有命中文本槽:%s'
|
|
1131
|
+
% ', '.join(sorted(unused_text_roles)))
|
|
1132
|
+
missing_role = [k for k in re.findall(r'^ ([\w-]+):\s*$', '\n'.join(blocks['layouts'][1]), re.M)
|
|
1133
|
+
if not re.search(r'^ %s:\s*$(?:\n(?! \S).*)*?\n role:' % re.escape(k),
|
|
1134
|
+
'\n'.join(out), re.M)]
|
|
1135
|
+
if missing_role:
|
|
1136
|
+
raise Fail('这些页型没有 role(在 layouts.yaml 的 roles 段填):%s' % ', '.join(missing_role))
|
|
1137
|
+
# `layout_modes.*: TODO` 由上面那道通用 TODO 扫描报(它连行内提示一起打出来),
|
|
1138
|
+
# 这里只管它管不到的两种:整行被删、以及填了 flow/slots 之外的值。
|
|
1139
|
+
forms = layout_forms(blocks['layouts'][1])
|
|
1140
|
+
bad = []
|
|
1141
|
+
for k, v in sorted(modes.items()):
|
|
1142
|
+
if len(forms.get(k) or ()) < 2:
|
|
1143
|
+
continue # 只有一份形态,无从选择
|
|
1144
|
+
if v not in ('flow', 'slots'):
|
|
1145
|
+
bad.append('%s 的 layout_modes 判断是 %r' % (k, v))
|
|
1146
|
+
elif v not in forms[k]:
|
|
1147
|
+
bad.append('%s 选了 %s 但该页型没有这一份' % (k, v))
|
|
1148
|
+
for k, forms_for_layout in sorted(forms.items()):
|
|
1149
|
+
if len(forms_for_layout) >= 2 and k not in modes:
|
|
1150
|
+
bad.append('%s 缺 layout_modes 判断' % k)
|
|
1151
|
+
if bad:
|
|
1152
|
+
raise Fail('layout_modes 只能填 flow 或 slots,一个页型一个词:%s' % ';'.join(bad))
|
|
1153
|
+
declared = set(re.findall(r'^ background:\s*(\S+)\s*$',
|
|
1154
|
+
'\n'.join(blocks['layouts'][1]), re.M))
|
|
1155
|
+
stray = set(bg_rules) - declared
|
|
1156
|
+
if stray:
|
|
1157
|
+
raise Fail('backgrounds 段里这些背景没有任何页型在用:%s' % ', '.join(sorted(stray)))
|
|
941
1158
|
out.append('---')
|
|
942
1159
|
text = '\n'.join(out) + '\n'
|
|
943
1160
|
if 'body' in blocks:
|
|
@@ -993,6 +1210,12 @@ def main(argv=None):
|
|
|
993
1210
|
if left:
|
|
994
1211
|
raise Fail('判断单还有 %d 处草案占位没改(TODO 是 draft.py 留给 L 层的判断点):\n %s'
|
|
995
1212
|
% (len(left), '\n '.join(left)))
|
|
1213
|
+
mdesc = re.search(r'^description:\s*[|>]?\s*\n((?:\s+\S.*\n?)+)',
|
|
1214
|
+
open(os.path.join(lout, 'manifest.yaml'), encoding='utf-8').read(), re.M)
|
|
1215
|
+
if mdesc and len(re.sub(r'\s+', '', mdesc.group(1))) < 20:
|
|
1216
|
+
raise Fail('manifest 的 description 只有 %d 个字符——它是消费模型定调的唯一入口,'
|
|
1217
|
+
'写清底色/主色/字形/版面骨架,不要留占位'
|
|
1218
|
+
% len(re.sub(r'\s+', '', mdesc.group(1))))
|
|
996
1219
|
|
|
997
1220
|
manifest = read_manifest(os.path.join(lout, 'manifest.yaml'))
|
|
998
1221
|
if args.style_name:
|
|
@@ -1016,34 +1239,23 @@ def main(argv=None):
|
|
|
1016
1239
|
|
|
1017
1240
|
lay_text = open(lay_path, encoding='utf-8').read() if os.path.exists(lay_path) else ''
|
|
1018
1241
|
body = expand_placeholders(body, manifest, consumer, audit, extract, lay_text)
|
|
1019
|
-
layouts_index = layout_fast_index(layouts_blocks)
|
|
1020
1242
|
design = build_design(manifest, l_fm, consumer, body,
|
|
1021
|
-
has_sidecar=layouts_blocks is not None, canvas=canvas
|
|
1022
|
-
layouts_index=layouts_index)
|
|
1243
|
+
has_sidecar=layouts_blocks is not None, canvas=canvas)
|
|
1023
1244
|
with open(os.path.join(pack, 'design.md'), 'w', encoding='utf-8') as f:
|
|
1024
1245
|
f.write(design)
|
|
1025
1246
|
if layouts_blocks is not None:
|
|
1026
1247
|
with open(os.path.join(pack, 'layouts.md'), 'w', encoding='utf-8') as f:
|
|
1027
1248
|
f.write(build_layouts_md(layouts_blocks, canvas))
|
|
1028
1249
|
|
|
1029
|
-
ref
|
|
1250
|
+
# 审计记录写回**抽取工作目录**,不进交付包:包是消费产物,`ref/` 里的东西
|
|
1251
|
+
# 没有任何门禁读、消费模型也用不上,放进去只会让「别读我」和「几 MB 材料」同时下发。
|
|
1252
|
+
ref = os.path.join(stage1, 'ref')
|
|
1030
1253
|
os.makedirs(ref, exist_ok=True)
|
|
1031
|
-
|
|
1254
|
+
audit_path = os.path.join(ref, 'audit.yaml')
|
|
1255
|
+
with open(audit_path, 'w', encoding='utf-8') as f:
|
|
1032
1256
|
f.write(render_audit(manifest, extract, audit))
|
|
1033
1257
|
carried = []
|
|
1034
|
-
|
|
1035
|
-
srcf = os.path.join(stage1, 'ref', name)
|
|
1036
|
-
if os.path.exists(srcf):
|
|
1037
|
-
shutil.copy2(srcf, os.path.join(ref, name))
|
|
1038
|
-
carried.append(name)
|
|
1039
|
-
shutil.copy2(ex_path, os.path.join(ref, 'extract.json'))
|
|
1040
|
-
carried.append('extract.json')
|
|
1041
|
-
for sub in ('rebuild', 'logo-candidates'):
|
|
1042
|
-
s = os.path.join(stage1, 'ref', sub)
|
|
1043
|
-
if os.path.isdir(s):
|
|
1044
|
-
shutil.copytree(s, os.path.join(ref, sub), dirs_exist_ok=True)
|
|
1045
|
-
carried.append(sub + '/')
|
|
1046
|
-
# L 层自备的 ref 补充件(判断理由、版式溯源等)原样带入
|
|
1258
|
+
# L 层自备的 ref 补充件(判断理由、版式溯源等)也归到抽取目录
|
|
1047
1259
|
l_ref = os.path.join(lout, 'ref')
|
|
1048
1260
|
if os.path.isdir(l_ref):
|
|
1049
1261
|
shutil.copytree(l_ref, ref, dirs_exist_ok=True)
|
|
@@ -1061,7 +1273,9 @@ def main(argv=None):
|
|
|
1061
1273
|
print(' assets %d 条目 / %d 文件落盘' % (len(consumer), len(copied)))
|
|
1062
1274
|
for d in copied:
|
|
1063
1275
|
print(' %-52s %8d B' % (os.path.relpath(d, pack), os.path.getsize(d)))
|
|
1064
|
-
print('
|
|
1276
|
+
print(' 审计记录 -> %s%s(不进交付包)'
|
|
1277
|
+
% (os.path.relpath(audit_path, os.path.dirname(stage1)),
|
|
1278
|
+
' ' + ', '.join(carried) if carried else ''))
|
|
1065
1279
|
|
|
1066
1280
|
# ---- 数值可追溯机检:产物里每个色值/字号/坐标都得能指回普查值
|
|
1067
1281
|
derived_values, derived_tokens = set(), set()
|
|
@@ -1079,9 +1293,17 @@ def main(argv=None):
|
|
|
1079
1293
|
shapes = json.load(open(sp, encoding='utf-8'))['shapes'] if os.path.exists(sp) else []
|
|
1080
1294
|
problems, checked = trace_check(pack, extract, shapes,
|
|
1081
1295
|
derived_values, derived_tokens, factor)
|
|
1296
|
+
integrity = media_integrity(stage1, extract)
|
|
1297
|
+
if integrity:
|
|
1298
|
+
print('\n--- 媒体产物完整性 ---')
|
|
1299
|
+
for b in integrity:
|
|
1300
|
+
print(' FAIL ' + b)
|
|
1301
|
+
raise Fail('media-out 里的文件和 extract.json 的记录对不上(%d 处)' % len(integrity))
|
|
1082
1302
|
print('\n--- 数值可追溯机检 ---')
|
|
1083
|
-
print(' 受检 hex %d / fontSize %d / slot box %d;derived 豁免 %d%s'
|
|
1303
|
+
print(' 受检 hex %d / fontSize %d / slot box %d;derived 豁免 %d%s%s'
|
|
1084
1304
|
% (checked['hex'], checked['size'], checked['box'], checked['exempt'],
|
|
1305
|
+
';判断键跳过 %d 行(avoid/text_safe/pairing_rule)' % checked['judgement']
|
|
1306
|
+
if checked['judgement'] else '',
|
|
1085
1307
|
';rebase_factor=%g' % factor if factor else ''))
|
|
1086
1308
|
if not shapes:
|
|
1087
1309
|
print(' ⚠ 未找到 %s,slot 坐标一项无法校验' % sp)
|
|
@@ -1108,6 +1330,7 @@ def main(argv=None):
|
|
|
1108
1330
|
print('check_v1: 未探测到($DSM_V1_DIR / 同级 skill / 开发机路径均无)—— v1 门禁未跑,交付前必须补跑')
|
|
1109
1331
|
if args.check_v1:
|
|
1110
1332
|
print('\n--- check_v1 ---')
|
|
1333
|
+
sys.stdout.flush()
|
|
1111
1334
|
r1 = subprocess.run([sys.executable, args.check_v1,
|
|
1112
1335
|
os.path.join(pack, 'design.md'), 'slide'])
|
|
1113
1336
|
rc = rc or r1.returncode
|