# Use a fixed GitHub release and inspect the source.
git clone --depth 1 --branch v0.4.3 https://github.com/Alien6-Studio/outerspace-apizr.git source
git -C source rev-parse --short HEAD
cat source/examples/repository-shop/pricing.py
apizr inspect source/examples/repository-shop/pricing.py

# Install and activate the OCI plugin explicitly.
plugin_sha=5b3f8905c1191f076379083a6c063cb2a9796eede40b277551a6e4acb478e27b
apizr plugins install plugin-wheels/outerspace_apizr_oci-0.4.3-py3-none-any.whl --sha256 "$plugin_sha" --requirements plugin.lock --wheelhouse plugin-wheels --plugins-dir "$PWD/plugins"
apizr plugins enable outerspace-apizr-oci --version 0.4.3 --plugins-dir "$PWD/plugins"

# Select the public function and direct execution.
apizr init source/examples/repository-shop
cat readiness.json
cat exposure.json

# Generate the repository MCP bundle.
apizr expose build mcp source/examples/repository-shop --operator-policy source/examples/repository-shop/.apizr/operator.json --readiness-policy readiness.json --policy exposure.json --output-dir mcp-bundle
ls mcp-bundle
cat mcp-bundle/requirements.txt

# Prepare the target runtime and build request.
docker image inspect python:3.14-slim --format '{{index .RepoDigests 0}}'
python prepare_build.py
python -c 'import json; d=json.load(open("build.json")); print({k:d[k] for k in ("interface","platform","tag")})'
python -c 'import json; g=json.load(open("build-operator.json"))["grants"][0]; print(g["operation"], g["permissions"]); print(g["plugin"]["name"], g["plugin"]["version"])'

# Apizr generates the OCI service image.
apizr plugins run outerspace-apizr-oci build --arguments build.json --operator-policy build-operator.json --plugins-dir "$PWD/plugins" --timeout-ms 360000 > build-result.json
python -c 'import json; r=json.load(open("build-result.json"))["result"]; print(json.dumps({k:r[k] for k in ("tag","platform","image_id","published")}, indent=2))'
docker image inspect apizr-academy:05-shop-mcp --format 'User={{.Config.User}}'

# Connect over container standard input and output.
uv venv --python python3.14 client
uv pip install --python client/bin/python 'mcp==2.3.0'
sed -n '25,35p' ollama_mcp.py
client/bin/python ollama_mcp.py list

# Watch Ollama request the actual container tool.
client/bin/python ollama_mcp.py

# Keep the machine-readable evidence.
python -c 'import json; t=json.load(open("ollama-trace.json")); print(json.dumps(t["results"], indent=2)); print(t["answer"])'
python verify_image.py
