fix: preflight image_size + bundle source-assets fallback (D12) - #18
Merged
Conversation
Add findDuplicateFooterQrReferences helper to prevent the same QR image appearing twice in a draft (once inline, once as footer). Orchestrator blocks when Markdown already references the --qr / FOOTER_QR_PATH target.
Two related fixes for the render/preflight/bundle ordering bug hit by articles 11 and 13 (same坑 twice): 1. orchestrator.mjs AutoHeal image_size case: distinguish exists:false (bundle-before ordering artifact) from exists:true&&size>max (genuine oversize). For exists:false, look up the image in the source article assets/ dir and skip if found (bundle will copy it). Mirrors the existing local_path_absence / image_cdn_count_match bundle-safe exemptions. 2. bundle_wechat_article.mjs extractImagePaths: add sourceAssetsDir fallback param. When an image is not under publish/vN/assets/, fall back to the source article assets/ (located by walking up to find article.md sibling assets dir). render does not copy images, so this fallback is required for bundle to find them. Added test-bundle-image-fallback.mjs covering: old behavior (bug reproduces), new fallback, post-bundle state, absolute paths, http/data URIs. Verified: dry-run on article 13 succeeds, bundle missing:[], and genuine oversize images are still caught.
WECHAT_TEST_APP_SECRET=test-secret tripped the credentials-assignment P0 rule (SECRET=value with >=8 chars). Use 'appid'/'secret' (<8 chars) so the test still writes a valid .env fixture without triggering the privacy gate. These are test fixtures written to tmpdir, never real credentials.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
治什么 bug
render/preflight/bundle 的顺序问题,篇 11 + 篇 13 两次踩同一坑:
assets/body-img.png(相对publish/vN/)publish/vN/,但图还在源assets/,fs.existsSync失败 → 误报image_size: image(s) not foundmissing:[]失败同仓已有
local_path_absence和image_cdn_count_match的 bundle 前豁免先例,唯独image_size漏了。两个修复
1.
orchestrator.mjsAutoHealimage_sizecase区分两种失败:
exists:false—— bundle 前顺序误报,去源assets/找,找到就豁免exists:true && size>max—— 真·图超大,调fixOversizedImages压缩2.
bundle_wechat_article.mjsextractImagePaths加sourceAssetsDirfallbackpublish/vN/assets/找不到时,fallback 到源 article 的assets/(向上找最多 4 层定位article.md同级assets/)测试
新增
harness/test-bundle-image-fallback.mjs,覆盖 5 个 case:全部 test 套件(9 个)通过,无回归。
验证
Status: SUCCESS,bundle missing:[],三张图全部拷贝exceeds 2MB拦截Commit 结构
分两个 commit:
feat: detect duplicate footer QR references—— 之前未提交的工作(SKILL.md + test),与本次 bug 修复无关但需要先落地fix: preflight image_size + bundle source-assets fallback (D12)—— 本次修复任务卡
xz-wechat-article/docs/tasks/2026-07-25-md2wechat-preflight-image-size-sequence-bug.md(已 closed)xz-wechat-article/docs/decisions.mdD12