#!/bin/sh
# Eight kinds of AI-code mistakes, one file each, so every verdict is attributable to one cause.
set -e
mkdir -p src/shop
: > src/shop/__init__.py
cat > src/shop/payments.py <<'PY'
def charge_card(amount, currency="usd"):
    return {"charged": amount, "currency": currency}
PY
cat > src/shop/h1_bare_name.py <<'PY'
def pay(amount):
    # undefined name, never imported (the challenge's case)
    return invented_payment_sdk.charge(amount)
PY
cat > src/shop/h2_fake_package.py <<'PY'
import invented_payment_sdk  # package that does not exist on PyPI

def pay(amount):
    return invented_payment_sdk.charge(amount)
PY
cat > src/shop/h3_undefined_function.py <<'PY'
def pay(user, amount):
    if verify_enterprise_auth(user):  # function never defined or imported
        return amount
    return None
PY
cat > src/shop/h3b_listed_name.py <<'PY'
def pay(user, amount):
    if validate_auth(user):  # same shape as h3, but a name on Skylos's built-in list
        return amount
    return None
PY
cat > src/shop/h4_local_missing_member.py <<'PY'
from shop.payments import charge_card_with_retry  # payments.py has charge_card only

def pay(amount):
    return charge_card_with_retry(amount)
PY
cat > src/shop/h5_local_bad_kwarg.py <<'PY'
from shop.payments import charge_card

def pay(amount):
    return charge_card(amount, idempotency_key="abc")  # no such parameter
PY
cat > src/shop/h6_real_pkg_fake_member.py <<'PY'
import requests

def fetch(url):
    return requests.get_json(url)  # requests has no get_json()
PY
cat > src/shop/h7_fake_guard.py <<'PY'
def is_admin(user):
    return True  # stub an agent left behind

def delete_account(user, target):
    if is_admin(user):
        return f"deleted {target}"
    return "denied"
PY
cat > src/shop/h8_logic_bug.py <<'PY'
def apply_discount(price, pct):
    # real names, real APIs, wrong math: 20 means 20%, so this should be price * (1 - pct / 100)
    return price * (1 - pct)
PY
printf 'requests==2.32.3
' > requirements.txt
git init -q && git add -A && git -c user.email=lab@example.com -c user.name=lab commit -qm init
