"""Authorized editorial revision: ten overviews plus one source-bound background document.""" from __future__ import annotations import hashlib import json import subprocess from pathlib import Path from build_definition import OUT, PATH, REPO, build, canonical BASE = "ec3388a06dafde3e37ac490311801721d160c287" RESOURCE = "calliope-backend/src/calliope/comfyui/source_reviews.json" # Reviewed concise summaries, derived only from existing flow/steps. No execution promises. OVERVIEWS = { "Minimax-H3提示词增强.json": ( "把原始视频描述交给文本模型整理成更详细的提示词,供后" "续视频生成核对使用。先核对原始描述、模型和文本生成设" "置;这张图本身不代表已生成视频,文本结果仍待核对。" ), "音频转MP3格式.json": ( "读取一段音频并另存为MP3。先核对输入文件、保存设置" "和文件名前缀;实际音质及文件能否读取仍待核对。" ), "音频人声分离.json": ( "读取并裁剪音频,分离为四条音轨,再试听人声。先核对音" "频、截取范围及分离模型;分离效果和真实文件仍待核对。" ), "视频-音频分离.json": ( "从视频文件读取音轨,一路保存原音轨为MP3,另一路分" "离为四轨供试听。先核对视频是否有可读音轨和分离模型;" "这张图不生成去掉声音的视频,实际音频效果仍待核对。" ), "图像嵌入文字描述.json": ( "把指定文字排到图片上并预览,适合核对文字、字号、颜色" "和位置。先确认输入图片和文字内容;最终排版效果仍待核" "对。" ), "Qwen3-ASR-语音转文字.json": ( "把输入语音交给语音识别模型转成文字。先核对音频、识别" "模型及语言设置;识别准确度和输出内容仍待核对。" ), "Qwen3-ASR-Subtitle语音转字幕.json": ( "把语音转为识别文字、分组字幕和检测语言的字符串。先核" "对音频、模型及对齐设置;识别内容和时间对齐仍待核对," "字符串不代表已保存字幕文件。" ), "ControlNet_aux_常用样例.json": ( "从参考图片提取线条、深度或姿态等控制信息,供后续生图" "参考。先核对图片和所需预处理分支;各分支的真实输出仍" "待核对。" ), "Qwen_image2.1_文生图_提示词增强.json": ( "先用文本模型整理生图描述,再交给图像模型生成图片。先" "核对原始描述、提示词优化开关和画面尺寸;当前只说明图" "中设置,生成效果仍待核对。" ), "Qwen_image2.1_图像编辑_提示词增强.json": ( "用两张参考图和编辑要求生成修改后的图片,并与第一张原" "图对比。先核对两张图片、编辑文字、提示词优化和尺寸开" "关;实际编辑效果仍待核对。" ), "Qwen_image2.1_图像编辑_背景移除.json": ( "尝试按编辑要求移除一张图片的背景,保存PNG并与原图" "对比。先核对输入图片;当前关闭自定义尺寸,按参考图尺" "寸对齐处理。PNG不保证背景透明,真实结果和透明通道仍待核对。" ), } def build_all(): previous = json.loads(subprocess.check_output(["git", "show", f"{BASE}:{RESOURCE}"], cwd=REPO)) reviews = json.loads(json.dumps(previous, ensure_ascii=False)) new = build() assert reviews[PATH]["source_sha"] == new["source_sha1"] reviews[PATH]["fixed_version_document"] = new entries = [] for p, r in reviews.items(): block = r.get("fixed_version_document") if not block: continue name = Path(p).name block["user_overview"] = OVERVIEWS[name] entries.append( dict( path=p, user_overview=block["user_overview"], basis=["flow", "steps"], previous_sha256=hashlib.sha256( canonical(previous[p]["fixed_version_document"]) ).hexdigest() if p != PATH else None, ) ) if p != PATH: without = {k: v for k, v in block.items() if k != "user_overview"} assert without == previous[p]["fixed_version_document"] assert len(entries) == 11 return reviews, entries def main(): current = json.loads((REPO / RESOURCE).read_bytes()) reviews, entries = build_all() (REPO / RESOURCE).write_text(json.dumps(reviews, ensure_ascii=False, indent=2) + "\n") (OUT / "definition.json").write_text( json.dumps(reviews[PATH]["fixed_version_document"], ensure_ascii=False, indent=2) + "\n" ) (OUT / "overview-evidence.json").write_text( json.dumps(entries, ensure_ascii=False, indent=2) + "\n" ) pins = { p: hashlib.sha256(canonical(r["fixed_version_document"])).hexdigest() for p, r in reviews.items() if "fixed_version_document" in r } # Only the explicit developer-maintained allowlist changes; runtime never trusts caller digests. module = REPO / "calliope-backend/src/calliope/comfyui/fixed_document.py" text = module.read_text() for p, r in current.items(): if "fixed_version_document" in r: digest = hashlib.sha256(canonical(r["fixed_version_document"])).hexdigest() # Initial run or a repeated deterministic build. text = text.replace(digest, pins[p]) if PATH not in text: text = text.replace( "DEFINITIONS = {", "DEFINITIONS = {\n (" + repr(PATH) + "): " + repr(pins[PATH]) + ",", ) module.write_text(text) print(json.dumps(pins, ensure_ascii=False, indent=2)) if __name__ == "__main__": main()