#!/usr/bin/env bash # Drives real muse mist commands for Episode 20 ("Mist"). Requires the # local MuseHub dev stack running. Re-run to regenerate; each run creates # fresh Mists (content-addressed IDs derived from a timestamp-salted file). set -euo pipefail HUB="https://localhost:1337" DIR="$(mktemp -d)" cd "$DIR" echo "=== Part 1: create, sign, and push a real Mist (fast path) ===" cat > validate_assignee.py < bool: """Return True if handle is a valid assignee for this repo.""" return handle in collaborators # episode-20 salt: $(date +%s) EOF CREATE_JSON=$(muse mist create validate_assignee.py --title "Validate assignee helper" \ --description "A tiny reusable snippet, shared as a Mist." \ --sign --push --hub "$HUB" --json) echo "$CREATE_JSON" | python3 -m json.tool MIST_ID=$(echo "$CREATE_JSON" | python3 -c "import json,sys; print(json.load(sys.stdin)['mist_id'])") echo echo "=== Part 2: read it back -- real symbol anchoring, no VCS lineage ===" muse mist read "gabriel/$MIST_ID" --hub "$HUB" --json | python3 -m json.tool echo echo "=== Part 3: the honest part -- the documented manual push workflow crashes ===" mkdir -p vcs-repo && cd vcs-repo muse init --domain mist --json > /dev/null echo "A four-note motif, described in prose: C, E, G, C (up an octave)." > motif.txt muse commit -m "Add motif description" --agent-id claude-code --model-id claude-sonnet-5 --sign --json > /dev/null echo "--- muse mist push (exactly as --help documents) ---" muse mist push --remote local --branch main 2>&1 | tail -8 || true cd .. echo echo "=== Part 4: fork -- real, works correctly ===" FORK_JSON=$(muse mist fork "gabriel/$MIST_ID" --hub "$HUB" --json) echo "$FORK_JSON" | python3 -m json.tool echo "--- forkCount on the original, confirmed real ---" muse mist read "gabriel/$MIST_ID" --hub "$HUB" --json | python3 -c "import json,sys; print('forkCount:', json.load(sys.stdin)['forkCount'])" echo echo "=== Part 5: the second honest part -- muse mist forks silently returns {} ===" echo "--- via the CLI ---" muse mist forks "gabriel/$MIST_ID" --hub "$HUB" --json echo "--- the same query, raw curl + hand-signed header ---" HEADER=$(muse sign header --method GET --path "/api/mists/$MIST_ID/forks" --hub "$HUB" --json | python3 -c "import json,sys; print(json.load(sys.stdin)['header_value'])") curl -sk "$HUB/api/mists/$MIST_ID/forks" -H "Authorization: $HEADER" echo echo "=== Part 6: embed and raw -- both real, both work ===" muse mist embed "gabriel/$MIST_ID" --hub "$HUB" --json | python3 -m json.tool echo "--- raw bytes ---" muse mist raw "gabriel/$MIST_ID" --hub "$HUB" echo echo "Demo complete. (scratch dir: $DIR)"