204 lines
7.9 KiB
Python
204 lines
7.9 KiB
Python
"Acquire bounded exact text only, verifying Git objects; never import upstream."
|
|
|
|
import datetime
|
|
import hashlib
|
|
import importlib.util
|
|
import io
|
|
import json
|
|
import subprocess
|
|
import zipfile
|
|
from pathlib import Path
|
|
|
|
OUT = Path(__file__).resolve().parent
|
|
REF = OUT.parent / "ace-qwen-reference"
|
|
spec = importlib.util.spec_from_file_location(
|
|
"acquire", OUT.parent / "ace-document-evidence/fetch_sources.py"
|
|
)
|
|
m = importlib.util.module_from_spec(spec)
|
|
spec.loader.exec_module(m)
|
|
m.OUT = REF
|
|
|
|
|
|
def main():
|
|
REF.mkdir(exist_ok=True)
|
|
old = OUT.parent / "ace-reference"
|
|
rows = []
|
|
for e in json.loads((old / "sources.json").read_bytes())["sources"]:
|
|
if e["id"] == "core":
|
|
(REF / e["local_file"]).write_bytes((old / e["local_file"]).read_bytes())
|
|
rows.append(e)
|
|
for f in ["core-tag.json", "core-tree.json", "core-commit.json"]:
|
|
(REF / f).write_bytes((old / f).read_bytes())
|
|
(REF / "sources.json").write_text(
|
|
json.dumps({"sources": rows}, ensure_ascii=False, indent=2) + "\n"
|
|
)
|
|
rev = "0f1e54530cfc1bf6f5dc0c4b946bb626d327587f"
|
|
(REF / "frontend-tag.json").write_text(
|
|
json.dumps(
|
|
{
|
|
"ref": "refs/tags/v1.38.0",
|
|
"object": {"sha": rev, "type": "commit"},
|
|
"transport": "git ls-remote exact tag",
|
|
}
|
|
)
|
|
+ "\n"
|
|
)
|
|
specs = {
|
|
"frontend": (
|
|
"Comfy-Org/ComfyUI_frontend",
|
|
rev,
|
|
[
|
|
"package.json",
|
|
"pnpm-lock.yaml",
|
|
"src/scripts/widgets.ts",
|
|
"src/scripts/app.ts",
|
|
"src/extensions/core/widgetInputs.ts",
|
|
"src/lib/litegraph/src/LGraphNode.ts",
|
|
"LICENSE",
|
|
"src/lib/litegraph/LICENSE",
|
|
("src/renderer/extensions/vueNodes/widgets/composables/useIntWidget.ts"),
|
|
("src/renderer/extensions/vueNodes/widgets/composables/useFloatWidget.ts"),
|
|
"src/schemas/nodeDef/migration.ts",
|
|
"src/extensions/core/uploadAudio.ts",
|
|
],
|
|
),
|
|
"llama": (
|
|
"lihaoyun6/ComfyUI-llama-cpp_vlm",
|
|
"20571a3cf504b8308781d3cad2e432444ec3d75b",
|
|
["nodes.py", "__init__.py", "pyproject.toml", "support/gguf_layers.py"],
|
|
),
|
|
"various": (
|
|
"jamesWalker55/comfyui-various",
|
|
"5bd85aaf7616878471469c4ec7e11bbd0cef3bf2",
|
|
["comfyui_primitive_ops.py", "__init__.py", "LICENSE"],
|
|
),
|
|
"cr": (
|
|
"Suzie1/ComfyUI_Comfyroll_CustomNodes",
|
|
"d78b780ae43fcf8c6b7c6505e6ffb4584281ceca",
|
|
["nodes/nodes_core.py", "node_mappings.py", "LICENSE"],
|
|
),
|
|
}
|
|
for key, (repo, rev, files) in specs.items():
|
|
print("Fetching", key, flush=True)
|
|
cache = OUT.parents[2] / ".local-evidence" / ("ace-qwen-" + key + "-git")
|
|
if key == "llama":
|
|
(REF / "llama-unavailable.json").write_text(
|
|
json.dumps(
|
|
dict(
|
|
repo=repo,
|
|
requested_commit=rev,
|
|
registry_id="llama-cpp_vllm",
|
|
attempts=[
|
|
"git fetch exact commit: upload-pack not our ref",
|
|
"pinned raw nodes.py: HTTP 404",
|
|
],
|
|
conclusion="准确提交不可得;不套f2209ccc或其它版,三个节点schema/实现/恢复/许可绑定未知",
|
|
),
|
|
ensure_ascii=False,
|
|
indent=2,
|
|
)
|
|
+ "\n"
|
|
)
|
|
continue
|
|
if not cache.exists():
|
|
cache.mkdir(parents=True)
|
|
subprocess.run(
|
|
["git", "init", "--bare", str(cache)], check=True, stdout=subprocess.DEVNULL
|
|
)
|
|
subprocess.run(
|
|
[
|
|
"git",
|
|
"-C",
|
|
str(cache),
|
|
"fetch",
|
|
"--depth=1",
|
|
"https://github.com/" + repo + ".git",
|
|
rev,
|
|
],
|
|
check=True,
|
|
)
|
|
|
|
def git(*args):
|
|
return subprocess.check_output(["git", "-C", str(cache), *args])
|
|
|
|
commit = git("cat-file", "commit", rev)
|
|
tree = []
|
|
for line in git("ls-tree", "-r", rev).decode().splitlines():
|
|
head, path = line.split("\t", 1)
|
|
mode, kind, sha = head.split()
|
|
tree.append(dict(path=path, mode=mode, type=kind, sha=sha))
|
|
tree_sha = git("rev-parse", rev + "^{tree}").decode().strip()
|
|
(REF / (key + "-commit.txt")).write_bytes(commit)
|
|
(REF / (key + "-tree.json")).write_text(
|
|
json.dumps(dict(sha=tree_sha, truncated=False, tree=tree), indent=2) + "\n"
|
|
)
|
|
for file in files:
|
|
entry = next((e for e in tree if e["path"] == file), None)
|
|
if entry is None:
|
|
print("Absent at exact tree:", key, file, flush=True)
|
|
continue
|
|
raw = git("show", rev + ":" + file)
|
|
name = key + "__" + file.replace("/", "__")
|
|
(REF / name).write_bytes(raw)
|
|
rows.append(
|
|
dict(
|
|
id=key,
|
|
repo=repo,
|
|
file=file,
|
|
local_file=name,
|
|
commit=rev,
|
|
tree=tree_sha,
|
|
url=f"https://raw.githubusercontent.com/{repo}/{rev}/{file}",
|
|
sha256=hashlib.sha256(raw).hexdigest(),
|
|
git_blob_sha1=entry["sha"],
|
|
acquisition_time=datetime.datetime.now(datetime.timezone.utc).isoformat(),
|
|
license_file=key + "__LICENSE"
|
|
if any(e["path"] == "LICENSE" for e in tree)
|
|
else "unknown: exact tree lacks LICENSE",
|
|
applicability="准确声明提交/前端tag;registry拼写保留;目标及前端组合恢复未知",
|
|
transport="git exact commit text; no checkout/execution",
|
|
)
|
|
)
|
|
(REF / "sources.json").write_text(
|
|
json.dumps({"sources": rows}, ensure_ascii=False, indent=2) + "\n"
|
|
)
|
|
# Registry version package: preserve complete original ZIP and exact selected members.
|
|
meta = json.loads((REF / "show-registry.json").read_bytes())
|
|
p = REF / "showtext-1.2.5.zip"
|
|
if not p.exists():
|
|
p.write_bytes(m.get(meta["downloadUrl"]))
|
|
z = zipfile.ZipFile(io.BytesIO(p.read_bytes()))
|
|
(REF / "showtext-members.json").write_text(json.dumps(z.namelist(), indent=2) + "\n")
|
|
for f in ["py/show_text.py", "web/js/showText.js", "__init__.py", "LICENSE", "pyproject.toml"]:
|
|
raw = z.read(f)
|
|
name = "showtext__" + f.replace("/", "__")
|
|
(REF / name).write_bytes(raw)
|
|
rows.append(
|
|
dict(
|
|
id="showtext",
|
|
repo="pythongosssss/ComfyUI-Custom-Scripts",
|
|
file=f,
|
|
local_file=name,
|
|
commit=None,
|
|
tree=None,
|
|
git_blob_sha1=None,
|
|
version="1.2.5",
|
|
url=meta["downloadUrl"],
|
|
sha256=hashlib.sha256(raw).hexdigest(),
|
|
package_sha256=hashlib.sha256(p.read_bytes()).hexdigest(),
|
|
package_file="showtext-1.2.5.zip",
|
|
package_member=f,
|
|
acquisition_time=datetime.datetime.now(datetime.timezone.utc).isoformat(),
|
|
license_file="showtext__LICENSE",
|
|
applicability="准确registry1.2.5发布包成员;Git提交/目标安装绑定未知",
|
|
transport="registry package member bytes; no execution",
|
|
)
|
|
)
|
|
(REF / "sources.json").write_text(
|
|
json.dumps({"sources": rows}, ensure_ascii=False, indent=2) + "\n"
|
|
)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|