diff --git a/.claude/bootstrap-version b/.claude/bootstrap-version new file mode 100644 index 0000000..0cfbf08 --- /dev/null +++ b/.claude/bootstrap-version @@ -0,0 +1 @@ +2 diff --git a/.claude/settings.json b/.claude/settings.json new file mode 100644 index 0000000..5812b6e --- /dev/null +++ b/.claude/settings.json @@ -0,0 +1,25 @@ +{ + "hooks": { + "PostToolUse": [ + { + "matcher": "Edit|Write", + "hooks": [ + { + "type": "command", + "command": "f=$(jq -r '.tool_input.file_path // empty'); case \"$f\" in *.py) python3 -m py_compile \"$f\" || exit 2;; esac" + } + ] + } + ], + "Stop": [ + { + "hooks": [ + { + "type": "command", + "command": "cd \"$CLAUDE_PROJECT_DIR\" && python3 -m py_compile adif_auth.py adif_client.py query_api.py 1>&2 || exit 2" + } + ] + } + ] + } +} diff --git a/.env.example b/.env.example new file mode 100644 index 0000000..300ebb4 --- /dev/null +++ b/.env.example @@ -0,0 +1,3 @@ +# The code takes no environment variables today. +# ADIF_ACCESS_KEY= +# ADIF_SECRET_KEY= diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..3c98178 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,18 @@ +name: CI +on: + pull_request: + branches: [development] + push: + branches: [development, main] +jobs: + check: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 + with: + python-version: "3.12" + - run: pip install requests + # No linter or automated tests exist yet: syntax check only. + - name: Lint (syntax check) + run: python3 -m py_compile adif_auth.py adif_client.py query_api.py diff --git a/.github/workflows/version.yml b/.github/workflows/version.yml new file mode 100644 index 0000000..90c3e04 --- /dev/null +++ b/.github/workflows/version.yml @@ -0,0 +1,45 @@ +name: Version +on: + push: + branches: [development, main] +permissions: + contents: write +jobs: + bump: + if: github.actor != 'github-actions[bot]' && !contains(github.event.head_commit.message, '[skip ci]') + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + - name: Bump version + run: | + set -e + git config user.name "github-actions[bot]" + git config user.email "github-actions[bot]@users.noreply.github.com" + [ -f VERSION ] || echo "0.1.0" > VERSION + IFS=. read -r MA MI PA < VERSION + BRANCH="${GITHUB_REF_NAME}" + BUMP=patch + if [ "$BRANCH" = "main" ]; then + # MINOR bump when every new commit already exists on development (PR from development) + git fetch origin development || true + RANGE="${{ github.event.before }}..${{ github.sha }}" + if git rev-parse -q --verify origin/development >/dev/null \ + && [ -n "$(git rev-list $RANGE 2>/dev/null)" ] \ + && [ -z "$(git rev-list $RANGE --not origin/development 2>/dev/null | grep -v "^$(git rev-parse HEAD)$" || true)" ]; then + BUMP=minor + fi + fi + if [ "$BUMP" = minor ]; then MI=$((MI+1)); PA=0; else PA=$((PA+1)); fi + NEW="$MA.$MI.$PA" + echo "$NEW" > VERSION + git add VERSION + git commit -m "chore(release): v$NEW [skip ci]" + git push origin "HEAD:$BRANCH" + if [ "$BRANCH" = "main" ]; then + git fetch origin development || exit 0 + git checkout -B development origin/development + git merge origin/main -m "chore(release): merge main v$NEW [skip ci]" + git push origin development + fi diff --git a/.gitignore b/.gitignore index 6dfec2e..c75fb10 100644 --- a/.gitignore +++ b/.gitignore @@ -21,5 +21,3 @@ ENV/ *.tmp .temp .cache/ -.claude/ -CLAUDE.md diff --git a/CLAUDE.md b/CLAUDE.md new file mode 100644 index 0000000..0a06c15 --- /dev/null +++ b/CLAUDE.md @@ -0,0 +1,31 @@ +# ADIF API reverse engineering + +## Overview +Python client for the ADIF "El Cano Móvil" API, reverse-engineered from the Android APK. Implements the HMAC-SHA256 request signing and 9 endpoints. Research project; keys come from the public APK. + +## Commands +- Dev/demo: `python3 adif_client.py`; `python3 query_api.py` +- Install: `pip install requests` +- Lint: `python3 -m py_compile adif_auth.py adif_client.py query_api.py` (no linter configured) +- Test: none automated. Files in `tests/` are live-API scripts (network, credentials); run manually, not in CI. +- Build: none + +## Architecture +- `adif_auth.py`: request signing (`AdifAuthenticator`) +- `adif_client.py`: high-level `AdifClient` +- `query_api.py`: CLI querying helper +- `docs/`: API, auth algorithm and endpoint analysis +- `apk_decompiled/`, `apk_extracted/`, `adif.apk`: reverse-engineering sources; do not edit + +## Conventions +Type-hinted Python 3 with `from __future__ import annotations`; `requests` for HTTP. + +## Workflow quirks +No `development` branch yet; branch from `main` until created. + +## Deployment +None (library/research scripts). + +## Gotchas +- `tests/` hit the real ADIF API; failures may be network or API changes, not code. +- Large binary/decompiled dirs: avoid broad greps; scope to the `.py` files and `docs/`. diff --git a/LESSONS.md b/LESSONS.md new file mode 100644 index 0000000..e914725 --- /dev/null +++ b/LESSONS.md @@ -0,0 +1,5 @@ +# Lessons + +Recurring mistakes and how to avoid them. Add an entry when a mistake repeats. + +- `.gitignore` used to exclude `.claude/` and `CLAUDE.md`; keep them tracked. diff --git a/VERSION b/VERSION new file mode 100644 index 0000000..6e8bf73 --- /dev/null +++ b/VERSION @@ -0,0 +1 @@ +0.1.0