#!/usr/bin/env bash # create_wire_test_repo.sh [--large] # # Creates (or resets) ~/ecosystem/muse-wire-test with exactly N files. # Without --large: each file is ~1 KB of deterministic pseudorandom content. # With --large: each file is ~400 KB (forces OC-frame chunking via Phase 14B). # # After reset, configures staging + direct remotes and creates the repo on # MuseHub staging if it does not already exist. # # Usage: # bash create_wire_test_repo.sh 2000 # bash create_wire_test_repo.sh 10 --large set -euo pipefail N=${1:-10} LARGE=0 for arg in "${@:2}"; do [[ "$arg" == "--large" ]] && LARGE=1 done REPO_DIR="$HOME/ecosystem/muse-wire-test" STAGING_URL="https://staging.musehub.ai/gabriel/muse-wire-test" DIRECT_URL="http://23.22.27.39:1337/gabriel/muse-wire-test" echo "==> Resetting $REPO_DIR with N=$N files ($([ $LARGE -eq 1 ] && echo 'LARGE ~400KB' || echo 'small ~1KB') each)" # Remove and reinitialise rm -rf "$REPO_DIR" mkdir -p "$REPO_DIR" muse -C "$REPO_DIR" init --json > /dev/null # Generate N files with deterministic content — single Python invocation echo "==> Generating $N files..." python3 - "$REPO_DIR" "$N" "$LARGE" <<'PYEOF' import sys, hashlib, os repo_dir, n, large = sys.argv[1], int(sys.argv[2]), sys.argv[3] == "1" for i in range(n): fname = os.path.join(repo_dir, f"file_{i:06d}.txt") if large: lines = [] for line in range(400): seed = f"wire-test-large-{i}-{line}" h = hashlib.sha256(seed.encode()).hexdigest() lines.append((h * 32)[:1024]) content = "\n".join(lines) + "\n" else: h = hashlib.sha256(f"wire-test-{i}".encode()).hexdigest() content = (h * 32)[:1024] + "\n" with open(fname, "w") as f: f.write(content) PYEOF # Stage and commit echo "==> Staging and committing..." muse -C "$REPO_DIR" code add . --json > /dev/null muse -C "$REPO_DIR" commit \ -m "test: $N $([ $LARGE -eq 1 ] && echo 'large' || echo 'small') objects for wire protocol testing" \ --agent-id claude-code \ --model-id claude-sonnet-4-6 \ --sign \ --json > /dev/null # Configure remotes (add or update) echo "==> Configuring remotes..." muse -C "$REPO_DIR" remote add staging "$STAGING_URL" --json > /dev/null 2>&1 || \ muse -C "$REPO_DIR" remote set-url staging "$STAGING_URL" --json > /dev/null muse -C "$REPO_DIR" remote add direct "$DIRECT_URL" --json > /dev/null 2>&1 || \ muse -C "$REPO_DIR" remote set-url direct "$DIRECT_URL" --json > /dev/null # Create repo on MuseHub staging if missing echo "==> Ensuring gabriel/muse-wire-test exists on staging..." muse -C "$REPO_DIR" hub repo read \ --hub https://staging.musehub.ai --json > /dev/null 2>&1 || \ muse -C "$REPO_DIR" hub repo create \ --name muse-wire-test \ --visibility public \ --hub https://staging.musehub.ai \ --json > /dev/null echo "" echo "==> Done. $REPO_DIR ready with $N files." echo " Remotes:" muse -C "$REPO_DIR" remote --json | python3 -c " import sys, json for r in json.load(sys.stdin)['remotes']: print(f' {r[\"name\"]}: {r[\"url\"]}') "