"Fetch bounded exact source texts only; never import upstream code." import hashlib import json import urllib.request from pathlib import Path OUT = Path(__file__).resolve().parent REF = OUT.parent / "rtx-reference" PINS = { "core": ( "Comfy-Org/ComfyUI", "a7a6335be538f55faa2abf7404c9b8e970847d1f", ["nodes.py", "folder_paths.py", "comfy_api/latest/_io.py", "LICENSE"], ), "frontend": ( "Comfy-Org/ComfyUI_frontend", "d91c283b7b758787b4d29126c1a9ac39dc14d6a7", [ "src/core/graph/widgets/dynamicWidgets.ts", "src/scripts/widgets.ts", "src/extensions/core/uploadImage.ts", "LICENSE", ], ), } def main(): es = [] for key, (repo, commit, files) in PINS.items(): tree = json.loads((REF / (key + "-tree.json")).read_bytes()) assert tree["sha"] == commit and not tree["truncated"] blobs = {e["path"]: e["sha"] for e in tree["tree"] if e["type"] == "blob"} for file in files: url = f"https://raw.githubusercontent.com/{repo}/{commit}/{file}" raw = urllib.request.urlopen(url, timeout=30).read() blob = hashlib.sha1(b"blob " + str(len(raw)).encode() + b"\0" + raw).hexdigest() assert blob == blobs[file] name = key + "__" + file.replace("/", "__") (REF / name).write_bytes(raw) es.append( dict( id=key, file=file, local_file=name, url=url, commit=commit, sha256=hashlib.sha256(raw).hexdigest(), git_blob_sha1=blob, ) ) for e in json.loads((OUT.parent / "qwen-edit-reference/sources.json").read_bytes())["sources"]: if e["id"].startswith("rgthree/") and e["file"] in [ "py/image_comparer.py", "web/comfyui/image_comparer.js", "LICENSE", ]: es.append( { **e, "id": "rgthree", "local_file": "../qwen-edit-reference/" + e["local_file"], "identity_binding": ( "reference hypothesis only; source node has no provider/version" ), } ) package = json.loads((REF / "rtx-package.json").read_bytes()) for file in ["__init__.py", "pyproject.toml", "README.md", "LICENSE"]: name = "rtx__" + file raw = (REF / name).read_bytes() es.append( dict( id="rtx", file=file, local_file=name, url=package["url"], commit="发布包SHA256:" + package["sha256"], git_commit_binding="unknown", package_sha256=package["sha256"], sha256=hashlib.sha256(raw).hexdigest(), ) ) (REF / "sources.json").write_text( json.dumps({"sources": es}, ensure_ascii=False, indent=2) + "\n" ) print("PASS bounded exact texts", len(es)) if __name__ == "__main__": main()