"""Check package files and local references; this does not assess visual quality.""" from pathlib import Path import hashlib,json,re,sys from urllib.parse import unquote ROOT=Path(__file__).resolve().parents[1] LINK=re.compile(r'\[([^\]\n]+)\]\(((?:[^()\n]|\([^()\n]*\))*)\)') def check(): failures=[] if sys.version_info<(3,10):failures.append('Python 3.10 or newer is required.') manifest=json.loads((ROOT/'package-manifest.json').read_text(encoding='utf-8')) for row in manifest['files']: p=ROOT/row['file'] if not p.is_file() or hashlib.sha256(p.read_bytes()).hexdigest()!=row['sha256']: failures.append('Missing or changed package file: '+row['file']) for p in ROOT.rglob('*'): if p.is_symlink():failures.append('Package contains a symbolic link: '+str(p.relative_to(ROOT))) if not p.is_file() or p.suffix not in ('.md','.txt','.py','.yaml','.json'):continue if any(part in ('input','output','__pycache__') for part in p.relative_to(ROOT).parts):continue text=p.read_text(encoding='utf-8-sig') if re.search(r'(?') if re.match(r'^(?:https?://|mailto:|#)',url):continue filename=url.split('#')[0] if filename and not (p.parent/unquote(filename)).resolve().exists(): failures.append('Missing local link in '+str(p.relative_to(ROOT))+': '+url) if failures: print(json.dumps({'ok':False,'failures':failures},ensure_ascii=False,indent=2));return 1 print(json.dumps({'ok':True,'files':len(manifest['files'])+1,'skills':4, 'python':'.'.join(map(str,sys.version_info[:3])), 'scope':'Files, hashes and local references only; image judgment is not validated.'},ensure_ascii=False)) return 0 if __name__=='__main__': sys.stdout.reconfigure(encoding='utf-8') raise SystemExit(check())