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..8781644 --- /dev/null +++ b/.claude/settings.json @@ -0,0 +1,25 @@ +{ + "hooks": { + "PostToolUse": [ + { + "matcher": "Edit|Write", + "hooks": [ + { + "type": "command", + "command": "file=$(jq -r '.tool_input.file_path // empty'); if [ -n \"$file\" ] && [ \"${file##*.}\" = \"py\" ]; then python3 -m py_compile \"$file\"; fi" + } + ] + } + ], + "Stop": [ + { + "hooks": [ + { + "type": "command", + "command": "cd \"$CLAUDE_PROJECT_DIR\" && python3 -m py_compile run.py generator.py" + } + ] + } + ] + } +} diff --git a/.env.example b/.env.example new file mode 100644 index 0000000..3305d1e --- /dev/null +++ b/.env.example @@ -0,0 +1,5 @@ +# Copy to .env if you manage it yourself; run.py reads environment variables +# directly and does not load a .env file automatically. + +# Optional session cookie for vimm.net, needed if downloads return 403/redirect. +VIMM_COOKIE= diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..f5877a9 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,25 @@ +name: CI + +on: + pull_request: + branches: [development] + push: + branches: [development, main] + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - uses: actions/setup-python@v5 + with: + python-version: "3.x" + cache: "pip" + + - run: pip install -r requirements.txt + + # No linter or test suite exists in this repo yet; this is the only + # automated check currently available (catches syntax errors). + - name: Syntax check + run: python -m py_compile run.py generator.py diff --git a/.github/workflows/version.yml b/.github/workflows/version.yml new file mode 100644 index 0000000..ccc4d48 --- /dev/null +++ b/.github/workflows/version.yml @@ -0,0 +1,74 @@ +name: Version Bump + +on: + push: + branches: [development, main] + +permissions: + contents: write + +concurrency: + group: version-bump-${{ github.ref }} + cancel-in-progress: false + +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 + ref: ${{ github.ref_name }} + + - name: Configure git + run: | + git config user.name "github-actions[bot]" + git config user.email "github-actions[bot]@users.noreply.github.com" + + - name: Read current version + id: current + run: | + if [ -f VERSION ]; then + echo "version=$(cat VERSION)" >> "$GITHUB_OUTPUT" + else + echo "version=0.1.0" >> "$GITHUB_OUTPUT" + fi + + - name: Compute new version + id: bump + run: | + IFS='.' read -r MAJOR MINOR PATCH <<< "${{ steps.current.outputs.version }}" + if [ "${{ github.ref_name }}" = "development" ]; then + # Every push to development bumps PATCH. + PATCH=$((PATCH + 1)) + else + git fetch origin development + if git merge-base --is-ancestor origin/development HEAD; then + # main's new tip already contains development's tip: an + # approved development -> main PR. Bump MINOR, reset PATCH. + MINOR=$((MINOR + 1)) + PATCH=0 + else + # Direct hotfix push to main. + PATCH=$((PATCH + 1)) + fi + fi + echo "version=$MAJOR.$MINOR.$PATCH" >> "$GITHUB_OUTPUT" + + - name: Write VERSION and commit + run: | + echo "${{ steps.bump.outputs.version }}" > VERSION + git add VERSION + git commit -m "chore(release): v${{ steps.bump.outputs.version }} [skip ci]" + git push origin HEAD:${{ github.ref_name }} + + - name: Merge main back into development + if: github.ref_name == 'main' + run: | + git fetch origin development + git checkout development + git merge --no-edit origin/main + git push origin development diff --git a/CLAUDE.md b/CLAUDE.md new file mode 100644 index 0000000..9dec3ce --- /dev/null +++ b/CLAUDE.md @@ -0,0 +1,31 @@ +# VimmLoader + +## Overview +Command-line tool that batch-downloads archives from Vimm's Lair vault pages, extracts them, and tracks progress through `links.txt` as a resumable queue. + +## Commands +- Install deps: `pip install -r requirements.txt` +- Generate a range of vault URLs: `python3 generator.py` (edit `start`/`finish` in the file first) +- Run the downloader: `python3 run.py` +- Lint: none configured +- Tests: none configured — `python -m py_compile *.py` is the only automated check (syntax only) + +## Architecture +- `run.py`: scrapes each vault page for its download form, downloads the archive with a progress bar, extracts `.zip`/`.7z` into `finished/`, deletes the archive, and drops successfully processed lines from `links.txt`. +- `generator.py`: writes a sequential range of vault URLs to `links.txt`. +- `downloading/`, `finished/`: working directories; contents are gitignored, directories kept via `.gitkeep`. + +## Conventions +- Single-file scripts, no package structure; keep it that way unless the tool grows. +- Runtime config via environment variables (e.g. `VIMM_COOKIE`), never hardcoded. + +## Workflow quirks +- `links.txt` is the resumable work queue: failed/unresolved URLs stay in the file, successful ones are removed. +- TLS verification is disabled (`verify=False`) in requests to vimm.net; this is existing intentional behavior, not a bug to silently fix. + +## Deployment +- Not a deployed service; run locally/ad hoc as a CLI script. + +## Gotchas +- No linter or test suite exists yet; CI and the Stop hook only run a syntax check (`py_compile`). +- `VIMM_COOKIE` may be required for some downloads (403/redirect) — see README. diff --git a/LESSONS.md b/LESSONS.md new file mode 100644 index 0000000..52733ff --- /dev/null +++ b/LESSONS.md @@ -0,0 +1,3 @@ +# Lessons + +Recurring mistakes in this repo and how to avoid them. Read before starting a task; add an entry whenever a mistake repeats. diff --git a/VERSION b/VERSION new file mode 100644 index 0000000..6e8bf73 --- /dev/null +++ b/VERSION @@ -0,0 +1 @@ +0.1.0