#!/bin/sh t=$(mktemp -d); trap 'rm -rf "$t"' EXIT; cd "$t" || exit node -v fetch -q -o - https://registry.npmjs.org/stockfish/-/stockfish-15.0.0.tgz | tar -xzf - package/src/stockfish.js package/src/stockfish.wasm package/src/nn-6877cd24400e.nnue cd package/src || exit echo 'globalThis.fetch = undefined;' > compat.cjs python3 - <<'PY' import subprocess with open('err','w') as err: p=subprocess.Popen(['node','-r','./compat.cjs','stockfish.js'],stdin=subprocess.PIPE,stdout=subprocess.PIPE,stderr=err,text=True) p.stdin.write('uci\nsetoption name Threads value 2\nsetoption name Hash value 64\nisready\n');p.stdin.flush() for line in p.stdout: if line.startswith('id name'): print(line.strip(),flush=True) if line.startswith('readyok'): p.stdin.write('position fen rnbqkb1r/pp2pppp/3p1n2/2p5/2P1P3/2N2N2/PP1P1PPP/R1BQKB1R b KQkq - 2 4\ngo depth 25\n');p.stdin.flush() if line.startswith(('info string','info depth','bestmove')): print(line.strip(),flush=True) if line.startswith('bestmove'): p.stdin.write('quit\n');p.stdin.flush();break PY tail -c 1000 err