Skip to content

Shenrui-Ma/video-regen-recipes / templates/character-short/bit-by-bit-heartache

bit-by-bit-heartache

Verified

用角色参考图在本机制作 Heartache 连续动作配乐短片.

FileKindSize
.gitignoreother430 B
LICENSEother1.1 KB
LICENSES.mdmarkdown1.4 KB
README.mdmarkdown9.3 KB
SKILL.mdskill md7.3 KB
assets/README.mdmarkdown4.9 KB
assets/default/manifest.jsonconfig3.8 KB
assets/runtime-assets.jsonconfig5.5 KB
profile.jsonconfig3.8 KB
prompts/ref2va.template.txtmarkdown1.6 KB
prompts/yaoguang.historical.txtmarkdown5.0 KB
references/background-removal.mdmarkdown5.5 KB
references/changelog.mdmarkdown916 B
references/character-input.mdmarkdown4.7 KB
references/deployment.mdmarkdown4.9 KB
references/editing.mdmarkdown3.7 KB
references/environment.lock.jsonconfig1.5 KB
references/first-segment-validation.jsonconfig1.8 KB
references/generation.mdmarkdown3.8 KB
references/media-preflight.mdmarkdown4.2 KB
references/native-continuation.mdmarkdown17.8 KB
references/node-sources.jsonconfig6.7 KB
references/node-sources.mdmarkdown3.8 KB
references/package-verification.jsonconfig1.7 KB
references/reference-check.jsonconfig968 B
references/reproduction.mdmarkdown10.1 KB
references/validation.mdmarkdown2.6 KB
references/workflow-recovery.mdmarkdown2.2 KB
references/workflow.lock.jsonconfig1.2 KB
references/yaoguang-run.jsonconfig7.4 KB
scripts/character/prepare_character.pyscript6.5 KB
scripts/distribution/fetch_assets.pyscript5.8 KB
scripts/distribution/package_skill.pyscript5.6 KB
scripts/plan_segments.pyscript3.4 KB
scripts/prepare_driver.pyscript5.2 KB
scripts/render_default.pyscript5.5 KB
scripts/runtime/graphs.pyscript11.3 KB
scripts/runtime/heartache.pyscript14.6 KB
scripts/runtime/local_io.pyscript3.3 KB
scripts/runtime/media.pyscript13.2 KB
scripts/runtime/run_segment.pyscript13.3 KB
sources.mdmarkdown2.4 KB
tests/test_background_removal.pyscript2.6 KB
tests/test_character_input.pyscript12.2 KB
tests/test_default.pyscript879 B
tests/test_distribution.pyscript12.3 KB
tests/test_media_preflight.pyscript2.1 KB
tests/test_prepare_driver.pyscript1.9 KB
tests/test_release_review.pyscript1.7 KB
tests/test_reproduction.pyscript1.9 KB
tests/test_runtime_cli.pyscript11.3 KB
tests/test_runtime_graph.pyscript4.8 KB
tests/test_runtime_io.pyscript2.1 KB
tests/test_runtime_media.pyscript10.2 KB
tests/test_runtime_runner.pyscript1.6 KB
tests/test_segment_plan.pyscript3.4 KB
tests/test_skill_contract.pyscript1.6 KB
workflows/continue.editor.jsonconfig23.8 KB
workflows/first.editor.jsonconfig19.8 KB
workflows/node-schema.jsonconfig22.2 KB
workflows/provenance.jsonconfig911 B

scripts/distribution/fetch_assets.py

View on GitHub
#!/usr/bin/env python3
"""Acquire pinned runtime assets; no model installation or inference."""
import argparse
import hashlib
import json
import os
from pathlib import Path, PurePosixPath
import re
import shutil
import urllib.parse
import urllib.request

TEMPLATE=Path(__file__).resolve().parents[2]

def digest(path):
    h=hashlib.sha256()
    with Path(path).open('rb') as f:
        for chunk in iter(lambda:f.read(1024*1024),b''): h.update(chunk)
    return h.hexdigest()

def validate(root,row):
    name=PurePosixPath(row['path']); url=urllib.parse.urlsplit(row['url'])
    if name.is_absolute() or '..' in name.parts or '\\' in row['path'] or not name.parts:
        raise ValueError('Unsafe asset path')
    if url.scheme!='https' or not url.netloc or url.username or url.password:
        raise ValueError('Asset URL must be HTTPS without credentials')
    if not re.fullmatch(r'[0-9a-f]{64}',row['sha256']) or type(row['bytes']) is not int or row['bytes']<=0:
        raise ValueError('Invalid size or SHA256')
    root=Path(root).resolve(); target=root.joinpath(*name.parts)
    if target.is_symlink() or not target.resolve().is_relative_to(root):
        raise ValueError('Asset path escapes its root or is a symlink')
    return target

def check(root,row):
    target=validate(root,row)
    return target.is_file() and target.stat().st_size==row['bytes'] and digest(target)==row['sha256']

def acquire(root,row,cache=None):
    target=validate(root,row)
    if target.exists():
        if not check(root,row): raise ValueError('Existing asset differs; refusing overwrite: '+row['path'])
        return {'path':row['path'],'status':'already_verified','sha256':row['sha256']}
    source=Path(cache)/target.name if cache else None
    if source and source.exists():
        if source.stat().st_size!=row['bytes'] or digest(source)!=row['sha256']:
            raise ValueError('Cache asset hash mismatch')
    target.parent.mkdir(parents=True,exist_ok=True)
    part=target.with_name(target.name+'.part')
    if part.is_symlink(): raise ValueError('Refusing symlink partial')
    if not part.exists():
        with part.open('xb') as out:
            if source and source.is_file():
                with source.open('rb') as f: shutil.copyfileobj(f,out,1024*1024)
            else:
                with urllib.request.urlopen(row['url'],timeout=60) as f:
                    size=0
                    while chunk:=f.read(1024*1024):
                        size+=len(chunk)
                        if size>row['bytes']: raise ValueError('Asset exceeds manifest size')
                        out.write(chunk)
            out.flush(); os.fsync(out.fileno())
    if part.stat().st_size!=row['bytes'] or digest(part)!=row['sha256']:
        raise ValueError('Partial download is incomplete or changed; inspect/remove only the .part and retry')
    os.link(part,target); part.unlink()
    if not check(root,row): raise ValueError('Published asset readback failed')
    return {'path':row['path'],'status':'copied_verified_cache' if source and source.is_file() else 'downloaded_verified','sha256':row['sha256']}

def manual_instructions(root,row):
    """What the user needs to fetch by hand when the automatic path is unavailable."""
    target=validate(root,row)
    return {'path':row['path'],'url':row['url'],'target':str(target),'bytes':row['bytes'],'sha256':row['sha256'],
            'steps':['在浏览器打开 URL 并下载(需要登录或网盘时由用户手动完成,不要代登录或转存)',
                     '把文件放到 target 路径,文件名保持一致',
                     '重新运行本脚本并加 --check,核对字节数与 SHA-256 后再继续']}

def main():
    p=argparse.ArgumentParser(description=__doc__)
    p.add_argument('--asset-root',type=Path,default=TEMPLATE/'assets')
    p.add_argument('--manifest',type=Path,default=TEMPLATE/'assets/runtime-assets.json')
    p.add_argument('--cache-dir',type=Path)
    p.add_argument('--check',action='store_true',help='Read only; do not create files or use network')
    p.add_argument('--assets',nargs='+',metavar='PATH',help='Fetch/check only these manifest paths, including optional assets; paths are relative to assets/')
    p.add_argument('--without-default-character',action='store_true',help='Exclude the historical character image (already excluded by default)')
    p.add_argument('--manual',action='store_true',help='Read only; print the per-asset manual download instructions and exit')
    a=p.parse_args(); rows=json.loads(a.manifest.read_text(encoding='utf-8'))['assets']
    if a.assets:
        unknown=set(a.assets)-{r['path'] for r in rows}
        if unknown: p.error('Unknown asset path: '+', '.join(sorted(unknown)))
        rows=[r for r in rows if r['path'] in a.assets]
    else:
        rows=[r for r in rows if r.get('download_by_default',r['role']!='default_character')]
    if a.without_default_character: rows=[r for r in rows if r['role']!='default_character']
    if a.manual:
        print(json.dumps({'ok':True,'manual':[manual_instructions(a.asset_root,r) for r in rows]},ensure_ascii=False,indent=2)); return 0
    if a.check:
        statuses=[{'path':r['path'],'verified':check(a.asset_root,r)} for r in rows]
        ok=all(r['verified'] for r in statuses)
        print(json.dumps({'ok':ok,'read_only':True,'assets':statuses},ensure_ascii=False,indent=2)); return 0 if ok else 2
    statuses=[]; manual=[]
    for r in rows:
        try: statuses.append(acquire(a.asset_root,r,a.cache_dir))
        except Exception as error:
            manual.append({**manual_instructions(a.asset_root,r),'error':str(error)})
    if manual:
        print(json.dumps({'ok':False,'assets':statuses,'manual':manual},ensure_ascii=False,indent=2)); return 3
    print(json.dumps({'ok':True,'assets':statuses},ensure_ascii=False,indent=2)); return 0

if __name__=='__main__': raise SystemExit(main())
slack-gif-creatoranthropics/skillsKnowledge and utilities for creating animated GIFs optimized for Slack. Provides constraints, validation tools, and animation concepts. Use when users request animated GIFs for Slack like "make me a GIF of X doing Y for Slack."Stars: 198kUpdated Claude CodeCodexVerifiedInstall
ponytailDietrichGebert/ponytailLazy senior dev mode for any coding task: the smallest change that fully solves it, and a reply a busy human understands in one read.Stars: 194kUpdated Claude CodeCodexVerifiedInstall
ponytail-debtDietrichGebert/ponytailHarvest every shortcut: comment into one debt ledger, so deferrals get tracked instead of forgotten. One-shot report.Stars: 194kUpdated Claude CodeCodexVerifiedInstall
ponytail-debtDietrichGebert/ponytailList every `shortcut:` comment (and older `ponytail:` ones) as a debt ledger. One-shot report, changes nothing. Use for "ponytail debt", "what did ponytail defer", "list the shortcuts", /ponytail-debt.Stars: 194kUpdated Claude CodeCodexVerifiedInstall