#!/usr/bin/env bash # Builds wire-episode17/ and drives a real push/clone against the local # MuseHub hub for Episode 17 ("The Wire Protocol"). Requires the local # MuseHub dev stack running. Re-run to regenerate; never hand-edit the # repo directory directly. set -euo pipefail HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" REPO="$HERE/wire-episode17" CLONE_DIR="$HERE/wire-episode17-clone" rm -rf "$REPO" "$CLONE_DIR" mkdir -p "$REPO" cd "$REPO" muse init --json | python3 -m json.tool echo "hello wire protocol" > README.md muse code add . muse commit -m "Initial commit for wire protocol demo" \ --agent-id claude-code --model-id claude-sonnet-5 --sign echo echo "=== Part 1: build a real wire mpack, parse it by hand ===" COMMIT=$(muse rev-parse HEAD --json | python3 -c "import json,sys; print(json.load(sys.stdin)['commit_id'])") python3 - "$COMMIT" <<'PY' import sys, struct, hashlib, pathlib sys.path.insert(0, str(pathlib.Path.home() / "ecosystem" / "muse")) from muse.core.mpack import build_mpack, build_wire_mpack commit_id = sys.argv[1] root = pathlib.Path(".") mpack = build_mpack(root, [commit_id], have=set()) wire = build_wire_mpack(mpack, meta={"repo_id": "demo", "branch": "main", "head_commit_id": commit_id}) pathlib.Path("wire.mpack").write_bytes(wire) print("total wire size:", len(wire), "bytes") print("header (hex):", wire[:6].hex(' ')) version, section_count = struct.unpack_from(" /dev/null 2>&1 || true muse -C ~/ecosystem/musehub hub repo create --name wire-episode17 --visibility public --json | python3 -m json.tool | head -6 muse remote add local https://localhost:1337/gabriel/wire-episode17 --json > /dev/null 2>&1 || \ muse remote set-url local https://localhost:1337/gabriel/wire-episode17 --json > /dev/null muse push local main --force --json echo echo "=== Part 4: a second, incremental commit -- only new blobs travel ===" echo "second line" >> README.md muse code add README.md muse commit -m "Second commit, shares two objects with the first" \ --agent-id claude-code --model-id claude-sonnet-5 --sign muse push local main --json echo echo "=== Part 5: clone -- the asymmetric, simpler fetch path ===" mkdir -p "$CLONE_DIR" cd "$CLONE_DIR" muse clone https://localhost:1337/gabriel/wire-episode17 --json | tail -20 echo echo "Demo built at $REPO and $CLONE_DIR"