# Show available recipes
[private]
help:
    @just --list -u

# uv sync + enable .githooks (guarded, never clobbers)
setup:
    uv sync
    @git config core.hooksPath >/dev/null 2>&1 || git config core.hooksPath .githooks

# Install CLI to $PATH, seed reference data (missing only)
install:
    uv tool install --force .
    uv run --no-sync python -m opencode_models.seed

# Run the console against ./data, e.g. just run next
run *args:
    uv run --no-sync opencode-models --data data {{args}}

# Refresh stale sources in your data dir (age-gated; warnings, never fails)
sync:
    uv run --no-sync opencode-models sync

# Refresh data/plans/*.json from the docs pages (gate fails shut on --check)
plans-sync:
    uv run --no-sync opencode-models --data data sync --force

# Validate the local snapshots offline (default: data/plans)
plans-check:
    uv run --no-sync opencode-models --data data sync --check

# Promote validated snapshots to the shipped fallback (curation: review, then PR)
plans-freeze: plans-check
    cp data/plans/go.json opencode_models/data/plans/go.json
    cp data/plans/zen.json opencode_models/data/plans/zen.json

# Unit tests
test:
    uv run --no-sync python -m unittest discover -s tests

# Lint: ruff check/format/complexity + 3.10 floor via vermin + offline zizmor
lint:
    uv run --no-sync ruff check opencode_models tests
    uv run --no-sync ruff format --check opencode_models tests
    uvx vermin@1.9.2 -t=3.10- --violations --quiet --no-tips opencode_models tests
    uvx zizmor --no-online-audits .github/workflows/

# Full check: everything a push needs (tests + lint + entry point + wheel)
check: test lint
    uv run --no-sync opencode-models --help >/dev/null
    uv build

# Sweep tracked files for secret patterns
audit:
    @grep -rniE 'BEGIN (RSA |OPENSSH |EC )?PRIVATE ''KEY|aws_secret_''access_key|ghp_''[A-Za-z0-9]{36}|github_pat_''[A-Za-z0-9]{22}' --exclude-dir=.venv --exclude-dir=.git --exclude-dir=__pycache__ . || echo "no tracked secret patterns"  # '' splits stop it matching its own pattern text
